{"ast":null,"code":"import { Logger } from \"./logger.js\";\nconst CloneValue = (source, destinationObject, shallowCopyValues) => {\n if (!source) {\n return null;\n }\n if (source.getClassName && source.getClassName() === \"Mesh\") {\n return null;\n }\n if (source.getClassName && (source.getClassName() === \"SubMesh\" || source.getClassName() === \"PhysicsBody\")) {\n return source.clone(destinationObject);\n } else if (source.clone) {\n return source.clone();\n } else if (Array.isArray(source)) {\n return source.slice();\n } else if (shallowCopyValues && typeof source === \"object\") {\n return {\n ...source\n };\n }\n return null;\n};\nfunction GetAllPropertyNames(obj) {\n const props = [];\n do {\n Object.getOwnPropertyNames(obj).forEach(function (prop) {\n if (props.indexOf(prop) === -1) {\n props.push(prop);\n }\n });\n } while (obj = Object.getPrototypeOf(obj));\n return props;\n}\n/**\n * Class containing a set of static utilities functions for deep copy.\n */\nexport class DeepCopier {\n /**\n * Tries to copy an object by duplicating every property\n * @param source defines the source object\n * @param destination defines the target object\n * @param doNotCopyList defines a list of properties to avoid\n * @param mustCopyList defines a list of properties to copy (even if they start with _)\n * @param shallowCopyValues defines wether properties referencing objects (none cloneable) must be shallow copied (false by default)\n * @remarks shallowCopyValues will not instantite the copied values which makes it only usable for \"JSON objects\"\n */\n static DeepCopy(source, destination, doNotCopyList, mustCopyList, shallowCopyValues = false) {\n const properties = GetAllPropertyNames(source);\n for (const prop of properties) {\n if (prop[0] === \"_\" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {\n continue;\n }\n if (prop.endsWith(\"Observable\")) {\n continue;\n }\n if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {\n continue;\n }\n const sourceValue = source[prop];\n const typeOfSourceValue = typeof sourceValue;\n if (typeOfSourceValue === \"function\") {\n continue;\n }\n try {\n if (typeOfSourceValue === \"object\") {\n if (sourceValue instanceof Uint8Array) {\n destination[prop] = Uint8Array.from(sourceValue);\n } else if (sourceValue instanceof Array) {\n destination[prop] = [];\n if (sourceValue.length > 0) {\n if (typeof sourceValue[0] == \"object\") {\n for (let index = 0; index < sourceValue.length; index++) {\n const clonedValue = CloneValue(sourceValue[index], destination, shallowCopyValues);\n if (destination[prop].indexOf(clonedValue) === -1) {\n // Test if auto inject was not done\n destination[prop].push(clonedValue);\n }\n }\n } else {\n destination[prop] = sourceValue.slice(0);\n }\n }\n } else {\n destination[prop] = CloneValue(sourceValue, destination, shallowCopyValues);\n }\n } else {\n destination[prop] = sourceValue;\n }\n } catch (e) {\n // Log a warning (it could be because of a read-only property)\n Logger.Warn(e.message);\n }\n }\n }\n}","map":{"version":3,"names":["Logger","CloneValue","source","destinationObject","shallowCopyValues","getClassName","clone","Array","isArray","slice","GetAllPropertyNames","obj","props","Object","getOwnPropertyNames","forEach","prop","indexOf","push","getPrototypeOf","DeepCopier","DeepCopy","destination","doNotCopyList","mustCopyList","properties","endsWith","sourceValue","typeOfSourceValue","Uint8Array","from","length","index","clonedValue","e","Warn","message"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/deepCopier.js"],"sourcesContent":["import { Logger } from \"./logger.js\";\nconst CloneValue = (source, destinationObject, shallowCopyValues) => {\n if (!source) {\n return null;\n }\n if (source.getClassName && source.getClassName() === \"Mesh\") {\n return null;\n }\n if (source.getClassName && (source.getClassName() === \"SubMesh\" || source.getClassName() === \"PhysicsBody\")) {\n return source.clone(destinationObject);\n }\n else if (source.clone) {\n return source.clone();\n }\n else if (Array.isArray(source)) {\n return source.slice();\n }\n else if (shallowCopyValues && typeof source === \"object\") {\n return { ...source };\n }\n return null;\n};\nfunction GetAllPropertyNames(obj) {\n const props = [];\n do {\n Object.getOwnPropertyNames(obj).forEach(function (prop) {\n if (props.indexOf(prop) === -1) {\n props.push(prop);\n }\n });\n } while ((obj = Object.getPrototypeOf(obj)));\n return props;\n}\n/**\n * Class containing a set of static utilities functions for deep copy.\n */\nexport class DeepCopier {\n /**\n * Tries to copy an object by duplicating every property\n * @param source defines the source object\n * @param destination defines the target object\n * @param doNotCopyList defines a list of properties to avoid\n * @param mustCopyList defines a list of properties to copy (even if they start with _)\n * @param shallowCopyValues defines wether properties referencing objects (none cloneable) must be shallow copied (false by default)\n * @remarks shallowCopyValues will not instantite the copied values which makes it only usable for \"JSON objects\"\n */\n static DeepCopy(source, destination, doNotCopyList, mustCopyList, shallowCopyValues = false) {\n const properties = GetAllPropertyNames(source);\n for (const prop of properties) {\n if (prop[0] === \"_\" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {\n continue;\n }\n if (prop.endsWith(\"Observable\")) {\n continue;\n }\n if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {\n continue;\n }\n const sourceValue = source[prop];\n const typeOfSourceValue = typeof sourceValue;\n if (typeOfSourceValue === \"function\") {\n continue;\n }\n try {\n if (typeOfSourceValue === \"object\") {\n if (sourceValue instanceof Uint8Array) {\n destination[prop] = Uint8Array.from(sourceValue);\n }\n else if (sourceValue instanceof Array) {\n destination[prop] = [];\n if (sourceValue.length > 0) {\n if (typeof sourceValue[0] == \"object\") {\n for (let index = 0; index < sourceValue.length; index++) {\n const clonedValue = CloneValue(sourceValue[index], destination, shallowCopyValues);\n if (destination[prop].indexOf(clonedValue) === -1) {\n // Test if auto inject was not done\n destination[prop].push(clonedValue);\n }\n }\n }\n else {\n destination[prop] = sourceValue.slice(0);\n }\n }\n }\n else {\n destination[prop] = CloneValue(sourceValue, destination, shallowCopyValues);\n }\n }\n else {\n destination[prop] = sourceValue;\n }\n }\n catch (e) {\n // Log a warning (it could be because of a read-only property)\n Logger.Warn(e.message);\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,aAAa;AACpC,MAAMC,UAAU,GAAGA,CAACC,MAAM,EAAEC,iBAAiB,EAAEC,iBAAiB,KAAK;EACjE,IAAI,CAACF,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EACA,IAAIA,MAAM,CAACG,YAAY,IAAIH,MAAM,CAACG,YAAY,CAAC,CAAC,KAAK,MAAM,EAAE;IACzD,OAAO,IAAI;EACf;EACA,IAA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