This commit is contained in:
董刚
2021-12-30 10:14:02 +08:00
parent fe71424379
commit b5f7e51ce3
10 changed files with 490 additions and 127 deletions

View File

@@ -0,0 +1,26 @@
/*
* @Author: dgflash
* @Date: 2021-12-28 16:16:15
* @LastEditors: dgflash
* @LastEditTime: 2021-12-28 17:54:51
*/
import { animation, Component, _decorator } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('AC')
export class AC extends Component {
@property({ type: animation.AnimationController })
private ac: animation.AnimationController = null!;
start() {
setInterval(() => {
if (this.ac.getValue("dir")) {
this.ac.setValue("dir", false);
}
else {
this.ac.setValue("dir", true);
}
}, 1000);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "fd3d4732-b828-4aed-8876-ce9cbf3d7dc4",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -11,7 +11,7 @@
],
"_variables": {
"dir": {
"__id__": 29
"__id__": 31
}
}
},
@@ -43,7 +43,7 @@
],
"_transitions": [
{
"__id__": 28
"__id__": 30
}
],
"_entryState": {
@@ -59,7 +59,7 @@
{
"__type__": "cc.animation.State",
"__editorExtras__": {
"centerX": -246,
"centerX": -245,
"centerY": -6
},
"name": "Entry"
@@ -119,10 +119,10 @@
"__id__": 18
},
{
"__id__": 22
"__id__": 21
},
{
"__id__": 26
"__id__": 24
},
{
"__id__": 27
@@ -148,13 +148,17 @@
},
{
"__type__": "cc.animation.State",
"__editorExtras__": {
"centerX": 201,
"centerY": 59
},
"name": "Exit"
},
{
"__type__": "cc.animation.State",
"__editorExtras__": {
"centerX": 196,
"centerY": -41
"centerX": 205,
"centerY": -106
},
"name": "Any"
},
@@ -187,7 +191,7 @@
"__type__": "cc.animation.Motion",
"__editorExtras__": {
"centerX": 68,
"centerY": 21
"centerY": 15
},
"name": "IdelRight",
"_components": [
@@ -223,24 +227,16 @@
]
},
{
"__type__": "cc.animation.BinaryCondition",
"__type__": "cc.animation.UnaryCondition",
"operator": 0,
"lhs": {
"operand": {
"__id__": 20
},
"rhs": {
"__id__": 21
}
},
{
"__type__": "cc.animation.BindableNumber",
"__type__": "cc.animation.BindableBoolean",
"variable": "dir",
"value": 0
},
{
"__type__": "cc.animation.BindableNumber",
"variable": "",
"value": 1
"value": false
},
{
"__type__": "cc.animation.Transition",
@@ -252,43 +248,21 @@
},
"conditions": [
{
"__id__": 23
"__id__": 22
}
]
},
{
"__type__": "cc.animation.BinaryCondition",
"operator": 0,
"lhs": {
"__id__": 24
},
"rhs": {
"__id__": 25
"__type__": "cc.animation.UnaryCondition",
"operator": 1,
"operand": {
"__id__": 23
}
},
{
"__type__": "cc.animation.BindableNumber",
"__type__": "cc.animation.BindableBoolean",
"variable": "dir",
"value": 0
},
{
"__type__": "cc.animation.BindableNumber",
"variable": "",
"value": 2
},
{
"__type__": "cc.animation.AnimationTransition",
"from": {
"__id__": 15
},
"to": {
"__id__": 12
},
"conditions": [],
"duration": 0.3,
"relativeDuration": false,
"exitConditionEnabled": true,
"_exitCondition": 1
"value": false
},
{
"__type__": "cc.animation.AnimationTransition",
@@ -298,12 +272,58 @@
"to": {
"__id__": 15
},
"conditions": [],
"conditions": [
{
"__id__": 25
}
],
"duration": 0.3,
"relativeDuration": false,
"exitConditionEnabled": true,
"_exitCondition": 1
},
{
"__type__": "cc.animation.UnaryCondition",
"operator": 1,
"operand": {
"__id__": 26
}
},
{
"__type__": "cc.animation.BindableBoolean",
"variable": "dir",
"value": false
},
{
"__type__": "cc.animation.AnimationTransition",
"from": {
"__id__": 15
},
"to": {
"__id__": 12
},
"conditions": [
{
"__id__": 28
}
],
"duration": 0.3,
"relativeDuration": false,
"exitConditionEnabled": true,
"_exitCondition": 1
},
{
"__type__": "cc.animation.UnaryCondition",
"operator": 0,
"operand": {
"__id__": 29
}
},
{
"__type__": "cc.animation.BindableBoolean",
"variable": "dir",
"value": false
},
{
"__type__": "cc.animation.Transition",
"from": {
@@ -316,7 +336,7 @@
},
{
"__type__": "cc.animation.Variable",
"_type": 3,
"_value": 0
"_type": 1,
"_value": false
}
]

View File

@@ -2,23 +2,11 @@
* @Author: dgflash
* @Date: 2021-11-16 14:30:24
* @LastEditors: dgflash
* @LastEditTime: 2021-11-18 10:32:14
* @LastEditTime: 2021-12-28 17:53:35
*/
import { _decorator, animation, sp } from "cc";
import { _decorator, animation, sp, v3 } from "cc";
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = AnimationGraphComponent
* DateTime = Tue Nov 16 2021 14:30:24 GMT+0800 (中国标准时间)
* Author = dgflash
* FileBasename = AnimationGraphComponent.ts
* FileBasenameNoExtension = AnimationGraphComponent
* URL = db://assets/resources/game/animator/AnimationGraphComponent.ts
* ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
*
*/
@ccclass("LeftComponent")
export class LeftComponent extends animation.StateMachineComponent {
/**
@@ -28,6 +16,11 @@ export class LeftComponent extends animation.StateMachineComponent {
*/
public onMotionStateEnter(controller: animation.AnimationController, stateStatus: Readonly<animation.StateStatus>): void {
// Can be overrode
console.log("LEFT", controller.getValue("dir"));
var spine: sp.Skeleton = controller.getComponent(sp.Skeleton)!;
spine.setAnimation(0, "huaxian/sideStand", true);
spine.node.setScale(v3(1, 1, 1))
}
/**
@@ -36,7 +29,7 @@ export class LeftComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onMotionStateExit(controller: animation.AnimationController, stateStatus: Readonly<animation.StateStatus>): void {
// Can be overrode
}
/**
@@ -45,7 +38,7 @@ export class LeftComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onMotionStateUpdate(controller: animation.AnimationController, stateStatus: Readonly<animation.StateStatus>): void {
// Can be overrode
}
/**
@@ -54,11 +47,7 @@ export class LeftComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onStateMachineEnter(controller: animation.AnimationController) {
// Can be overrode
console.log("LEFT");
var spine: sp.Skeleton = controller.getComponent(sp.Skeleton)!;
spine.setAnimation(0, "huaxian/sideStand", true);
}
/**
@@ -67,6 +56,6 @@ export class LeftComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onStateMachineExit(controller: animation.AnimationController) {
// Can be overrode
}
}

View File

@@ -2,23 +2,11 @@
* @Author: dgflash
* @Date: 2021-11-16 14:30:24
* @LastEditors: dgflash
* @LastEditTime: 2021-11-18 10:32:12
* @LastEditTime: 2021-12-28 17:53:51
*/
import { _decorator, animation, sp, v3 } from "cc";
import { animation, sp, v3, _decorator } from "cc";
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = AnimationGraphComponent
* DateTime = Tue Nov 16 2021 14:30:24 GMT+0800 (中国标准时间)
* Author = dgflash
* FileBasename = AnimationGraphComponent.ts
* FileBasenameNoExtension = AnimationGraphComponent
* URL = db://assets/resources/game/animator/AnimationGraphComponent.ts
* ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
*
*/
@ccclass("RightComponent")
export class RightComponent extends animation.StateMachineComponent {
/**
@@ -28,6 +16,12 @@ export class RightComponent extends animation.StateMachineComponent {
*/
public onMotionStateEnter(controller: animation.AnimationController, stateStatus: Readonly<animation.StateStatus>): void {
// Can be overrode
// console.log("onMotionStateEnter");
console.log("RIGHT", controller.getValue("dir"));
var spine: sp.Skeleton = controller.getComponent(sp.Skeleton)!;
spine.setAnimation(0, "huaxian/sideStand", true);
spine.node.setScale(v3(-1, 1, 1))
}
/**
@@ -36,7 +30,7 @@ export class RightComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onMotionStateExit(controller: animation.AnimationController, stateStatus: Readonly<animation.StateStatus>): void {
// Can be overrode
}
/**
@@ -45,7 +39,7 @@ export class RightComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onMotionStateUpdate(controller: animation.AnimationController, stateStatus: Readonly<animation.StateStatus>): void {
// Can be overrode
}
/**
@@ -54,12 +48,7 @@ export class RightComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onStateMachineEnter(controller: animation.AnimationController) {
// Can be overrode
console.log("RIGHT");
var spine: sp.Skeleton = controller.getComponent(sp.Skeleton)!;
spine.setAnimation(0, "huaxian/sideStand", true);
spine.node.setScale(v3(-1, 1, 1))
}
/**
@@ -68,6 +57,6 @@ export class RightComponent extends animation.StateMachineComponent {
* @param stateStatus The status of the motion.
*/
public onStateMachineExit(controller: animation.AnimationController) {
// Can be overrode
}
}

View File

@@ -21,11 +21,11 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 111
"__id__": 116
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 112
"__id__": 117
},
"_id": "ba0b085f-f8d5-40b0-9964-2fd25728d707"
},
@@ -47,7 +47,7 @@
"_active": true,
"_components": [
{
"__id__": 110
"__id__": 115
}
],
"_prefab": null,
@@ -3327,19 +3327,22 @@
"__id__": 95
},
{
"__id__": 97
"__id__": 100
},
{
"__id__": 102
}
],
"_active": true,
"_components": [
{
"__id__": 104
"__id__": 109
},
{
"__id__": 106
"__id__": 111
},
{
"__id__": 108
"__id__": 113
}
],
"_prefab": null,
@@ -3373,7 +3376,7 @@
},
{
"__type__": "cc.Node",
"_name": "UICamera",
"_name": "huaxian",
"_objFlags": 0,
"_parent": {
"__id__": 94
@@ -3383,6 +3386,147 @@
"_components": [
{
"__id__": 96
},
{
"__id__": 97
},
{
"__id__": 98
},
{
"__id__": 99
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -184.251,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "94c4UTwqJDEpnL+GVkGgf+"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 95
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 256,
"height": 256
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "b3txB6zNhOC7g4mX0LGbRd"
},
{
"__type__": "sp.Skeleton",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 95
},
"_enabled": true,
"__prefab": null,
"_visFlags": 0,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"loop": true,
"_premultipliedAlpha": true,
"_timeScale": 1,
"_useTint": false,
"_preCacheMode": 0,
"_cacheMode": 0,
"_defaultCacheMode": 0,
"_debugBones": false,
"_debugSlots": false,
"_skeletonData": {
"__uuid__": "bccbd7aa-4908-42ed-9518-45a5824e9362",
"__expectedType__": "sp.SkeletonData"
},
"defaultSkin": "default",
"defaultAnimation": "huaxian/positiveRun",
"_sockets": [],
"_debugMesh": false,
"_id": "e3Bb0l1vpPvaTB8oDCysJN"
},
{
"__type__": "cc.animation.AnimationController",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 95
},
"_enabled": true,
"__prefab": null,
"graph": {
"__uuid__": "986922ff-74f1-4ffe-9c70-ff65910341ae",
"__expectedType__": "cc.animation.AnimationGraph"
},
"_id": "cbrlfW0MpNsrf8F9qj4M+2"
},
{
"__type__": "fd3d4cyuChK7Yh2zpy/PX3E",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 95
},
"_enabled": true,
"__prefab": null,
"ac": {
"__id__": 98
},
"_id": "e9rO8YGvFNx5wmjRkGdF4r"
},
{
"__type__": "cc.Node",
"_name": "UICamera",
"_objFlags": 0,
"_parent": {
"__id__": 94
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 101
}
],
"_prefab": null,
@@ -3419,7 +3563,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 95
"__id__": 100
},
"_enabled": true,
"__prefab": null,
@@ -3427,7 +3571,7 @@
"_priority": 1073741824,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 401.67364016736406,
"_orthoHeight": 419.7772828507795,
"_near": 1,
"_far": 2000,
"_color": {
@@ -3466,13 +3610,13 @@
"_active": true,
"_components": [
{
"__id__": 98
"__id__": 103
},
{
"__id__": 100
"__id__": 105
},
{
"__id__": 102
"__id__": 107
}
],
"_prefab": null,
@@ -3509,11 +3653,11 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 97
"__id__": 102
},
"_enabled": true,
"__prefab": {
"__id__": 99
"__id__": 104
},
"_contentSize": {
"__type__": "cc.Size",
@@ -3536,11 +3680,11 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 97
"__id__": 102
},
"_enabled": true,
"__prefab": {
"__id__": 101
"__id__": 106
},
"_visFlags": 0,
"_customMaterial": null,
@@ -3580,12 +3724,12 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 97
"__id__": 102
},
"_enabled": true,
"__prefab": null,
"movement": {
"__id__": 103
"__id__": 108
},
"_id": "fakFE2p7BAeqFlPCvlFVr3"
},
@@ -3615,7 +3759,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 105
"__id__": 110
},
"_contentSize": {
"__type__": "cc.Size",
@@ -3642,10 +3786,10 @@
},
"_enabled": true,
"__prefab": {
"__id__": 107
"__id__": 112
},
"_cameraComponent": {
"__id__": 96
"__id__": 101
},
"_alignCanvasWithScreen": true,
"_id": "7acBC/yU9N05fc6HGd8fZS"
@@ -3663,7 +3807,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 109
"__id__": 114
},
"_alignFlags": 45,
"_target": null,
@@ -3713,19 +3857,19 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 113
"__id__": 118
},
"shadows": {
"__id__": 114
"__id__": 119
},
"_skybox": {
"__id__": 115
"__id__": 120
},
"fog": {
"__id__": 116
"__id__": 121
},
"octree": {
"__id__": 117
"__id__": 122
}
},
{

View File

@@ -42,10 +42,10 @@ export class Main extends Root {
}
protected run() {
engine.gui.init(UICF);
engine.gui.open(UIID.UILoading);
// engine.gui.init(UICF);
// engine.gui.open(UIID.UILoading);
this.ecs_demo();
// this.ecs_demo();
}
/** 通过ECS设计通用业务组件来复用 */

View File

@@ -1,2 +1,2 @@
/node_modules
/dist
# /dist

82
extensions/cinestation/dist/main.js vendored Normal file
View File

@@ -0,0 +1,82 @@
/*
* @Author: dgflash
* @Date: 2021-12-16 16:50:21
* @LastEditors: dgflash
* @LastEditTime: 2021-12-30 10:13:19
*/
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.unload = exports.load = exports.methods = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
/**
* @en Registration method for the main process of Extension
* @zh 为扩展的主进程的注册方法
*/
exports.methods = {
createVirtualCamera() {
Editor.Message.request("scene", "execute-scene-script", {
name: "cinestation",
method: "createVirtualCamera",
args: []
});
},
createTrackedCamera() {
Editor.Message.request("scene", "execute-scene-script", {
name: "cinestation",
method: "createTrackedCamera",
args: []
});
},
createFreeLookCamera() {
Editor.Message.request("scene", "execute-scene-script", {
name: "cinestation",
method: "createFreeLookCamera",
args: []
});
},
createFollowCamera() {
Editor.Message.request("scene", "execute-scene-script", {
name: "cinestation",
method: "createFollowCamera",
args: []
});
},
selectNode(type, uuid) {
if (type === "node") {
Editor.Message.request("scene", "execute-scene-script", {
name: "cinestation",
method: "selectNode",
args: [uuid]
});
}
},
async install() {
let installPath = path_1.default.resolve(__dirname, "../../../assets");
if (!fs_1.default.existsSync(installPath + "/cinestation")) {
console.log("[Package] cinestation start installing");
let resourcePath = path_1.default.resolve(__dirname, "../packages/cinestation.zip");
await Editor.Utils.File.unzip(resourcePath, installPath);
console.log("[Package] cinestation installed");
Editor.Message.request("asset-db", "refresh-asset", "db://assets");
}
}
};
/**
* @en Hooks triggered after extension loading is complete
* @zh 扩展加载完成后触发的钩子
*/
const load = function () {
exports.methods.install();
};
exports.load = load;
/**
* @en Hooks triggered after extension uninstallation is complete
* @zh 扩展卸载完成后触发的钩子
*/
const unload = function () {
};
exports.unload = unload;

104
extensions/cinestation/dist/scene.js vendored Normal file
View File

@@ -0,0 +1,104 @@
/*
* @Author: dgflash
* @Date: 2021-12-16 16:50:21
* @LastEditors: dgflash
* @LastEditTime: 2021-12-30 10:13:24
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unload = exports.load = exports.methods = void 0;
/**
* @en Registration method for the main process of Extension
* @zh 为扩展的主进程的注册方法
*/
exports.methods = {
createVirtualCamera() {
const js = cc.js;
const scene = cc.director.getScene();
let camera = scene.getComponentInChildren(cc.Camera);
if (camera == undefined) {
console.error("not find Camera");
return;
}
if (camera.node.getComponent(js.getClassByName("CinestationBrain")) == undefined) {
camera.node.addComponent(js.getClassByName("CinestationBrain"));
}
let editorCamera = cce.Camera.camera;
let vcams = scene.getComponentsInChildren(js.getClassByName("VirtualCamera"));
let cameraNode = new cc.Node("VCam" + vcams.length);
scene.addChild(cameraNode);
cameraNode.worldPosition = editorCamera.node.worldPosition;
cameraNode.worldRotation = editorCamera.node.worldRotation;
let vcam = cameraNode.addComponent(js.getClassByName("VirtualCamera"));
let lens = vcam.lens;
lens.fov = camera.fov;
lens.near = camera.near;
lens.far = camera.far;
return vcam;
},
createTrackedCamera() {
const js = cc.js;
const scene = cc.director.getScene();
let tracks = scene.getComponentsInChildren(js.getClassByName("CinestationSmoothPath"));
let editorCamera = cce.Camera.camera;
let trackNode = new cc.Node("DollyTrack" + tracks.length);
scene.addChild(trackNode);
let path = trackNode.addComponent(js.getClassByName("CinestationSmoothPath"));
trackNode.worldPosition = editorCamera.node.worldPosition;
trackNode.addChild(new cc.Node("Node0"));
trackNode.addChild(new cc.Node("Node1"));
let vcam = this.createVirtualCamera();
vcam.body.type = 2;
vcam.body.tracked.path = path;
vcam.aim.type = 1;
return vcam;
},
createFreeLookCamera() {
let vcam = this.createVirtualCamera();
vcam.body.type = 1;
vcam.aim.type = 2;
return vcam;
},
createFollowCamera() {
let vcam = this.createVirtualCamera();
vcam.body.type = 3;
vcam.aim.type = 1;
return vcam;
},
selectNode(uuid) {
const js = cc.js;
const scene = cc.director.getScene();
let vcams = scene.getComponentsInChildren(js.getClassByName("VirtualCamera"));
let selected = null;
for (let i = 0; i < vcams.length; i++) {
let vcam = vcams[i];
if (vcam.node.uuid === uuid) {
vcam.visible = true;
vcam._composerChanged = true;
vcam._editorChanged = true;
selected = vcam;
}
else {
vcam.visible = false;
}
}
let brain = scene.getComponentInChildren(js.getClassByName("CinestationBrain"));
if (brain) {
brain.__selectedCamera = selected;
}
},
};
/**
* @en Hooks triggered after extension loading is complete
* @zh 扩展加载完成后触发的钩子
*/
const load = function () {
};
exports.load = load;
/**
* @en Hooks triggered after extension uninstallation is complete
* @zh 扩展卸载完成后触发的钩子
*/
const unload = function () {
};
exports.unload = unload;