|
@@ -332,38 +332,36 @@ common.getTime = function (second) {
|
|
|
var str = JSON.stringify(data)
|
|
|
return JSON.parse(str)
|
|
|
}),
|
|
|
- (common.CloneObject = function (copyObj, isSimpleCopy, simpleCopyList = []) {
|
|
|
- //isSimpleCopy 只复制最外层
|
|
|
- //复制json result的可能:普通数字或字符串、普通数组、复杂对象
|
|
|
-
|
|
|
- //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
|
|
|
- }
|
|
|
-
|
|
|
- if (copyObj instanceof Array) {
|
|
|
- return copyObj.map(e => {
|
|
|
- return this.CloneObject(e, isSimpleCopy, simpleCopyList)
|
|
|
- })
|
|
|
- } else {
|
|
|
- if (copyObj.clone instanceof Function) {
|
|
|
- //解决一部分
|
|
|
- return copyObj.clone()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- let result = {}
|
|
|
- for (var key in copyObj) {
|
|
|
- if (copyObj[key] instanceof Object && !isSimpleCopy) result[key] = this.CloneObject(copyObj[key], isSimpleCopy, simpleCopyList )
|
|
|
- else result[key] = copyObj[key]
|
|
|
- //如果是函数类同基本数据,即复制引用
|
|
|
+(common.CloneObject = function (copyObj, isSimpleCopy, simpleCopyList = [], judgeSimpleCopyFun) {
|
|
|
+ //isSimpleCopy 只复制最外层
|
|
|
+ //复制json result的可能:普通数字或字符串、普通数组、复杂对象
|
|
|
+
|
|
|
+ simpleCopyList.includes(THREE.Object3D) || simpleCopyList.push(THREE.Object3D) //遇到simpleCopyList中的类直接使用不拷贝
|
|
|
+ judgeSimpleCopyFun || (judgeSimpleCopyFun=()=>{})
|
|
|
+
|
|
|
+ if (!copyObj || typeof copyObj == 'number' || typeof copyObj == 'string' || copyObj instanceof Function || simpleCopyList.some(className => copyObj instanceof className) || judgeSimpleCopyFun(copyObj)) {
|
|
|
+ return copyObj
|
|
|
+ }
|
|
|
+
|
|
|
+ if (copyObj instanceof Array) {
|
|
|
+ return copyObj.map(e => {
|
|
|
+ return this.CloneObject(e, isSimpleCopy, simpleCopyList, judgeSimpleCopyFun)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (copyObj.clone instanceof Function) {
|
|
|
+ //解决一部分
|
|
|
+ return copyObj.clone()
|
|
|
}
|
|
|
- return result
|
|
|
- }),
|
|
|
+ }
|
|
|
+
|
|
|
+ let result = {}
|
|
|
+ for (var key in copyObj) {
|
|
|
+ if (copyObj[key] instanceof Object && !isSimpleCopy ) result[key] = this.CloneObject(copyObj[key], isSimpleCopy, simpleCopyList, judgeSimpleCopyFun)
|
|
|
+ else result[key] = copyObj[key]
|
|
|
+ //如果是函数类同基本数据,即复制引用
|
|
|
+ }
|
|
|
+ return result
|
|
|
+}),
|
|
|
(common.CloneClassObject = function (copyObj) {
|
|
|
//复杂类对象
|
|
|
var newobj = new copyObj.constructor()
|