mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
不再依赖服务端模型userData.changed属性还原修改过的组件名称。
This commit is contained in:
parent
80eb76c2b8
commit
970b209486
@ -9,6 +9,7 @@ Supported Languages: 中文 / [繁體中文](README-tw.md) / [English](README-en
|
||||
## v0.3.3即将更新
|
||||
|
||||
1. 一键清理没用的场景和场景历史记录工具。
|
||||
2. 不再依赖服务端模型`userData.changed`属性还原修改过的组件名称。
|
||||
|
||||
## v0.3.2更新
|
||||
|
||||
|
||||
@ -125,8 +125,16 @@ Converter.prototype.toJSON = function (obj) {
|
||||
}
|
||||
|
||||
// 将场景转为json
|
||||
scene.userData.children = []; // 将层级结构保存在场景中,以供场景加载时还原。
|
||||
this.traverse(scene, scene.userData.children, list);
|
||||
let children = []; // 将层级结构保存在场景中,以供场景加载时还原。
|
||||
this.traverse(scene, children, list);
|
||||
|
||||
let sceneJson = list.filter(n => n.uuid === scene.uuid)[0];
|
||||
|
||||
if (sceneJson) {
|
||||
sceneJson.userData.children = children;
|
||||
} else {
|
||||
console.warn(`Converter: no scene json with id ${scene.uuid}`);
|
||||
}
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
@ -26,10 +26,6 @@ ServerObject.prototype.toJSON = function (obj) {
|
||||
json.userData.children = [];
|
||||
this.serializeChildren(obj.children, json.userData.children);
|
||||
|
||||
// 记录修改过的名称
|
||||
json.userData.changed = []; // 对应模型的children
|
||||
this.serializeChanged(obj, 0, json.userData.changed);
|
||||
|
||||
return json;
|
||||
};
|
||||
|
||||
@ -55,26 +51,6 @@ ServerObject.prototype.serializeChildren = function (children, list) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 序列化模型修改过的属性
|
||||
* @param {THREE.Object3D} obj 模型或部件
|
||||
* @param {Integer} index 索引
|
||||
* @param {Object} changed 修改过的属性
|
||||
*/
|
||||
ServerObject.prototype.serializeChanged = function (obj, index, changed) {
|
||||
changed[index] = {
|
||||
name: obj.name,
|
||||
};
|
||||
|
||||
if (obj.children) {
|
||||
changed[index].children = [];
|
||||
|
||||
obj.children.forEach((n, i) => {
|
||||
this.serializeChanged(n, i, changed[index].children);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
ServerObject.prototype.fromJSON = function (json, options, environment) {
|
||||
let url = json.userData.Url;
|
||||
|
||||
@ -102,11 +78,6 @@ ServerObject.prototype.fromJSON = function (json, options, environment) {
|
||||
// 还原原来修改过的模型
|
||||
this.revertObject(obj, environment.parts);
|
||||
|
||||
// 还原原来修改过的名称
|
||||
if (json.userData.changed) {
|
||||
this.parseChanged(obj, 0, json.userData.changed);
|
||||
}
|
||||
|
||||
resolve(obj);
|
||||
} else {
|
||||
resolve(null);
|
||||
@ -134,26 +105,6 @@ ServerObject.prototype.parseChildren = function (children, list) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 还原修改过的属性
|
||||
* @param {THREE.Object3D} obj 模型或部件
|
||||
* @param {Integer} index 索引
|
||||
* @param {Array} changed 修改过的属性
|
||||
*/
|
||||
ServerObject.prototype.parseChanged = function (obj, index, changed) {
|
||||
if (obj && changed[index]) {
|
||||
obj.name = changed[index].name;
|
||||
}
|
||||
|
||||
if (obj.children && changed[index]) {
|
||||
var changed1 = changed[index].children;
|
||||
|
||||
obj.children.forEach((n, i) => {
|
||||
this.parseChanged(n, i, changed1);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 还原调整过顺序的原始模型。
|
||||
* @param {THREE.Object3D} obj 服务端模型
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user