修复补间动画保存载入bug。

This commit is contained in:
liteng 2019-01-12 12:19:17 +08:00
parent 6098e2697a
commit 3ac603c0bd
3 changed files with 40 additions and 3 deletions

View File

@ -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);

View File

@ -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);
};
// ------------------------------- 编辑场景 ---------------------------------------

View File

@ -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;