diff --git a/ShadowEditor.Web/src/component/animation/BasicAnimationComponent.js b/ShadowEditor.Web/src/component/animation/BasicAnimationComponent.js index 1808c2d5..12b7060c 100644 --- a/ShadowEditor.Web/src/component/animation/BasicAnimationComponent.js +++ b/ShadowEditor.Web/src/component/animation/BasicAnimationComponent.js @@ -149,7 +149,7 @@ BasicAnimationComponent.prototype.updateUI = function (animation) { name.setValue(this.animation.name); - if (this.animation.target === null) { + if (this.animation.target === undefined || this.animation.target === null) { target.setValue('(无)'); } else { var obj = this.app.editor.objectByUuid(this.animation.target); diff --git a/ShadowEditor.Web/src/editor/bottom/ScenePanel.js b/ShadowEditor.Web/src/editor/bottom/ScenePanel.js index e6b2d5ec..1d23f566 100644 --- a/ShadowEditor.Web/src/editor/bottom/ScenePanel.js +++ b/ShadowEditor.Web/src/editor/bottom/ScenePanel.js @@ -280,6 +280,26 @@ ScenePanel.prototype.onLoadScene = function (obj) { if (obj.animations) { Object.assign(this.app.editor.animations, obj.animations); + } else { + this.app.editor.animations = [{ + id: null, + uuid: THREE.Math.generateUUID(), + layer: 0, + layerName: '动画层1', + animations: [] + }, { + id: null, + uuid: THREE.Math.generateUUID(), + layer: 1, + layerName: '动画层2', + animations: [] + }, { + id: null, + uuid: THREE.Math.generateUUID(), + layer: 2, + layerName: '动画层3', + animations: [] + }]; } if (obj.scene) { @@ -296,6 +316,7 @@ ScenePanel.prototype.onLoadScene = function (obj) { } this.app.call('sceneLoaded', this); + this.app.call('animationChanged', this, this.app.editor.animations); }; // ------------------------------- 编辑场景 --------------------------------------- diff --git a/ShadowEditor.Web/src/serialization/app/AnimationSerializer.js b/ShadowEditor.Web/src/serialization/app/AnimationSerializer.js index 19118022..c1c3d2a2 100644 --- a/ShadowEditor.Web/src/serialization/app/AnimationSerializer.js +++ b/ShadowEditor.Web/src/serialization/app/AnimationSerializer.js @@ -12,11 +12,27 @@ AnimationSerializer.prototype = Object.create(BaseSerializer.prototype); AnimationSerializer.prototype.constructor = AnimationSerializer; AnimationSerializer.prototype.toJSON = function (list) { - return list.slice(); + var jsons = []; + + list.forEach(n => { + var json = BaseSerializer.prototype.toJSON.call(this, n); + Object.assign(json, n); + jsons.push(json); + }); + + return jsons; }; AnimationSerializer.prototype.fromJSON = function (jsons) { - return jsons.slice(); + var list = []; + + jsons.forEach(n => { + var obj = Object.assign({}, n); + delete obj.metadata; + list.push(obj); + }); + + return list; }; export default AnimationSerializer; \ No newline at end of file