|
@@ -332,20 +332,22 @@ common.getTime = function (second) {
|
|
|
var str = JSON.stringify(data)
|
|
|
return JSON.parse(str)
|
|
|
}),
|
|
|
- (common.CloneObject = function (copyObj, result, isSimpleCopy, simpleCopyList = []) {
|
|
|
+ (common.CloneObject = function (copyObj, isSimpleCopy, simpleCopyList = []) {
|
|
|
//isSimpleCopy 只复制最外层
|
|
|
//复制json result的可能:普通数字或字符串、普通数组、复杂对象
|
|
|
|
|
|
- simpleCopyList.push(THREE.Object3D) //遇到simpleCopyList中的类直接使用不拷贝
|
|
|
+ //isSimpleCopy 只复制最外层
|
|
|
+ //复制json result的可能:普通数字或字符串、普通数组、复杂对象
|
|
|
+
|
|
|
+ simpleCopyList.includes(THREE.Object3D) || simpleCopyList.push(THREE.Object3D) //遇到simpleCopyList中的类直接使用不拷贝
|
|
|
|
|
|
if (!copyObj || typeof copyObj == 'number' || typeof copyObj == 'string' || copyObj instanceof Function || simpleCopyList.some(className => copyObj instanceof className)) {
|
|
|
return copyObj
|
|
|
- }
|
|
|
-
|
|
|
- result = result || {}
|
|
|
+ }
|
|
|
+
|
|
|
if (copyObj instanceof Array) {
|
|
|
return copyObj.map(e => {
|
|
|
- return this.CloneObject(e)
|
|
|
+ return this.CloneObject(e, isSimpleCopy, simpleCopyList)
|
|
|
})
|
|
|
} else {
|
|
|
if (copyObj.clone instanceof Function) {
|
|
@@ -353,8 +355,10 @@ common.getTime = function (second) {
|
|
|
return copyObj.clone()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ let result = {}
|
|
|
for (var key in copyObj) {
|
|
|
- if (copyObj[key] instanceof Object && !isSimpleCopy) result[key] = this.CloneObject(copyObj[key])
|
|
|
+ if (copyObj[key] instanceof Object && !isSimpleCopy) result[key] = this.CloneObject(copyObj[key], isSimpleCopy, simpleCopyList )
|
|
|
else result[key] = copyObj[key]
|
|
|
//如果是函数类同基本数据,即复制引用
|
|
|
}
|
|
@@ -372,7 +376,7 @@ common.getTime = function (second) {
|
|
|
for (let i in copyObj) {
|
|
|
if (i in copyObj.__proto__) break //到函数了跳出
|
|
|
|
|
|
- targetObj[i] = this.CloneObject(copyObj[i], null)
|
|
|
+ targetObj[i] = this.CloneObject(copyObj[i])
|
|
|
}
|
|
|
}),
|
|
|
(common.ifSame = function (object1, object2) {
|