@babylonjs/core 5.49.0 → 5.49.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engines/Native/nativeInterfaces.d.ts +1 -0
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativePipelineContext.d.ts +6 -2
- package/Engines/Native/nativePipelineContext.js +12 -3
- package/Engines/Native/nativePipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +2 -2
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js +1 -1
- package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
- package/Engines/engine.d.ts +53 -0
- package/Engines/nativeEngine.d.ts +2 -5
- package/Engines/nativeEngine.js +44 -12
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.decalMap.d.ts +12 -0
- package/Materials/PBR/pbrMaterial.decalMap.js +18 -0
- package/Materials/PBR/pbrMaterial.decalMap.js.map +1 -0
- package/Materials/Textures/renderTargetTexture.js +2 -4
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/index.d.ts +2 -0
- package/Materials/index.js +2 -0
- package/Materials/index.js.map +1 -1
- package/Materials/material.decalMap.d.ts +3 -0
- package/Materials/material.decalMap.js +4 -0
- package/Materials/material.decalMap.js.map +1 -0
- package/Materials/material.decalMapConfiguration.d.ts +63 -0
- package/Materials/material.decalMapConfiguration.js +119 -0
- package/Materials/material.decalMapConfiguration.js.map +1 -0
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/standardMaterial.decalMap.d.ts +12 -0
- package/Materials/standardMaterial.decalMap.js +18 -0
- package/Materials/standardMaterial.decalMap.js.map +1 -0
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +10 -0
- package/Maths/math.vector.js +14 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.decalMap.d.ts +12 -0
- package/Meshes/abstractMesh.decalMap.js +12 -0
- package/Meshes/abstractMesh.decalMap.js.map +1 -0
- package/Meshes/index.d.ts +2 -0
- package/Meshes/index.js +2 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.d.ts +94 -0
- package/Meshes/meshUVSpaceRenderer.js +141 -0
- package/Meshes/meshUVSpaceRenderer.js.map +1 -0
- package/Particles/gpuParticleSystem.js +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Physics/v2/physicsAggregate.d.ts +4 -0
- package/Physics/v2/physicsAggregate.js +4 -4
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +18 -2
- package/Physics/v2/physicsBody.js +66 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.js +2 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/renderingManager.js +4 -2
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/decalFragment.d.ts +5 -0
- package/Shaders/ShadersInclude/decalFragment.js +15 -0
- package/Shaders/ShadersInclude/decalFragment.js.map +1 -0
- package/Shaders/ShadersInclude/decalFragmentDeclaration.d.ts +5 -0
- package/Shaders/ShadersInclude/decalFragmentDeclaration.js +11 -0
- package/Shaders/ShadersInclude/decalFragmentDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/decalVertexDeclaration.d.ts +5 -0
- package/Shaders/ShadersInclude/decalVertexDeclaration.js +11 -0
- package/Shaders/ShadersInclude/decalVertexDeclaration.js.map +1 -0
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.d.ts +1 -0
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +2 -0
- package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/defaultVertexDeclaration.d.ts +1 -0
- package/Shaders/ShadersInclude/defaultVertexDeclaration.js +2 -0
- package/Shaders/ShadersInclude/defaultVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.d.ts +1 -0
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +4 -0
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.d.ts +1 -0
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +2 -0
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.d.ts +1 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +2 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/default.fragment.d.ts +1 -0
- package/Shaders/default.fragment.js +5 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +2 -0
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/geometry.fragment.js +1 -1
- package/Shaders/geometry.fragment.js.map +1 -1
- package/Shaders/meshUVSpaceRenderer.fragment.d.ts +5 -0
- package/Shaders/meshUVSpaceRenderer.fragment.js +9 -0
- package/Shaders/meshUVSpaceRenderer.fragment.js.map +1 -0
- package/Shaders/meshUVSpaceRenderer.vertex.d.ts +15 -0
- package/Shaders/meshUVSpaceRenderer.vertex.js +34 -0
- package/Shaders/meshUVSpaceRenderer.vertex.js.map +1 -0
- package/Shaders/pbr.fragment.js +4 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js +1 -1
- package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/Sprites/spriteManager.js +5 -3
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteSceneComponent.d.ts +1 -1
- package/Sprites/spriteSceneComponent.js +7 -4
- package/Sprites/spriteSceneComponent.js.map +1 -1
- package/XR/features/WebXRDepthSensing.d.ts +118 -0
- package/XR/features/WebXRDepthSensing.js +268 -0
- package/XR/features/WebXRDepthSensing.js.map +1 -0
- package/XR/features/index.d.ts +1 -0
- package/XR/features/index.js +1 -0
- package/XR/features/index.js.map +1 -1
- package/XR/native/nativeXRFrame.d.ts +1 -0
- package/XR/native/nativeXRFrame.js +4 -0
- package/XR/native/nativeXRFrame.js.map +1 -1
- package/XR/webXRCamera.d.ts +1 -0
- package/XR/webXRCamera.js +4 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRFeaturesManager.d.ts +4 -0
- package/XR/webXRFeaturesManager.js +4 -0
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/assetContainer.js +13 -5
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../lts/core/generated/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA4DtC;;GAEG;AACH,MAAM,OAAO,gBAAgB;;AACzB;;GAEG;AACoB,8BAAa,GAAG,kBAAkB,CAAC;AAC1D;;GAEG;AACoB,mCAAkB,GAAG,uBAAuB,CAAC;AACpE;;GAEG;AACoB,yBAAQ,GAAG,aAAa,CAAC;AAChD;;GAEG;AACoB,+BAAc,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AAC,qBAAqB,CAAC,yBAAyB,EAAE;gBACzD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;gBACjF,aAAa,GAAG;oBACZ,GAAG,aAAa;oBAChB,GAAG,QAAQ;iBACd,CAAC;aACL;SACJ;QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAxUuB,uCAAkB,GAMtC,EAAE,CAAC;AAWP;;GAEG;AACqB,yCAAoB,GAA8B;IACtE,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ;IAC3D,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,aAAa;CAC9D,CAAC","sourcesContent":["import type { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport type { IDisposable } from \"../scene\";\r\nimport { Tools } from \"../Misc/tools\";\r\n\r\n/**\r\n * Defining the interface required for a (webxr) feature\r\n */\r\nexport interface IWebXRFeature extends IDisposable {\r\n /**\r\n * Is this feature attached\r\n */\r\n attached: boolean;\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n disableAutoAttach: boolean;\r\n\r\n /**\r\n * Attach the feature to the session\r\n * Will usually be called by the features manager\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful.\r\n */\r\n attach(force?: boolean): boolean;\r\n /**\r\n * Detach the feature from the session\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n detach(): boolean;\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n isCompatible(): boolean;\r\n\r\n /**\r\n * Was this feature disposed;\r\n */\r\n isDisposed: boolean;\r\n\r\n /**\r\n * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)\r\n */\r\n xrNativeFeatureName?: string;\r\n\r\n /**\r\n * A list of (Babylon WebXR) features this feature depends on\r\n */\r\n dependsOn?: string[];\r\n\r\n /**\r\n * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object\r\n */\r\n getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;\r\n}\r\n\r\n/**\r\n * A list of the currently available features without referencing them\r\n */\r\nexport class WebXRFeatureName {\r\n /**\r\n * The name of the anchor system feature\r\n */\r\n public static readonly ANCHOR_SYSTEM = \"xr-anchor-system\";\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\";\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\";\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\";\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\";\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\";\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\";\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\";\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\";\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\";\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\";\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\";\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\";\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\";\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\";\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\";\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\";\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\";\r\n}\r\n\r\n/**\r\n * Defining the constructor of a feature. Used to register the modules.\r\n */\r\nexport type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;\r\n\r\n/**\r\n * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.\r\n * It is mainly used in AR sessions.\r\n *\r\n * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).\r\n */\r\nexport class WebXRFeaturesManager implements IDisposable {\r\n private static readonly _AvailableFeatures: {\r\n [name: string]: {\r\n stable: number;\r\n latest: number;\r\n [version: number]: WebXRFeatureConstructor;\r\n };\r\n } = {};\r\n\r\n private _features: {\r\n [name: string]: {\r\n featureImplementation: IWebXRFeature;\r\n version: number;\r\n enabled: boolean;\r\n required: boolean;\r\n };\r\n } = {};\r\n\r\n /**\r\n * The key is the feature to check and the value is the feature that conflicts.\r\n */\r\n private static readonly _ConflictingFeatures: { [key: string]: string } = {\r\n [WebXRFeatureName.TELEPORTATION]: WebXRFeatureName.MOVEMENT,\r\n [WebXRFeatureName.MOVEMENT]: WebXRFeatureName.TELEPORTATION,\r\n };\r\n\r\n /**\r\n * constructs a new features manages.\r\n *\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n */\r\n constructor(private _xrSessionManager: WebXRSessionManager) {\r\n // when session starts / initialized - attach\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n this.getEnabledFeatures().forEach((featureName) => {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {\r\n this.attachFeature(featureName);\r\n }\r\n });\r\n });\r\n\r\n // when session ends - detach\r\n this._xrSessionManager.onXRSessionEnded.add(() => {\r\n this.getEnabledFeatures().forEach((featureName) => {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && feature.featureImplementation.attached) {\r\n // detach, but don't disable!\r\n this.detachFeature(featureName);\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Used to register a module. After calling this function a developer can use this feature in the scene.\r\n * Mainly used internally.\r\n *\r\n * @param featureName the name of the feature to register\r\n * @param constructorFunction the function used to construct the module\r\n * @param version the (babylon) version of the module\r\n * @param stable is that a stable version of this module\r\n */\r\n public static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version: number = 1, stable: boolean = false) {\r\n this._AvailableFeatures[featureName] = this._AvailableFeatures[featureName] || { latest: version };\r\n if (version > this._AvailableFeatures[featureName].latest) {\r\n this._AvailableFeatures[featureName].latest = version;\r\n }\r\n if (stable) {\r\n this._AvailableFeatures[featureName].stable = version;\r\n }\r\n this._AvailableFeatures[featureName][version] = constructorFunction;\r\n }\r\n\r\n /**\r\n * Returns a constructor of a specific feature.\r\n *\r\n * @param featureName the name of the feature to construct\r\n * @param version the version of the feature to load\r\n * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n * @param options optional options provided to the module.\r\n * @returns a function that, when called, will return a new instance of this feature\r\n */\r\n public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n const constructorFunction = this._AvailableFeatures[featureName][version];\r\n if (!constructorFunction) {\r\n // throw an error? return nothing?\r\n throw new Error(\"feature not found\");\r\n }\r\n\r\n return constructorFunction(xrSessionManager, options);\r\n }\r\n\r\n /**\r\n * Can be used to return the list of features currently registered\r\n *\r\n * @returns an Array of available features\r\n */\r\n public static GetAvailableFeatures() {\r\n return Object.keys(this._AvailableFeatures);\r\n }\r\n\r\n /**\r\n * Gets the versions available for a specific feature\r\n * @param featureName the name of the feature\r\n * @returns an array with the available versions\r\n */\r\n public static GetAvailableVersions(featureName: string) {\r\n return Object.keys(this._AvailableFeatures[featureName]);\r\n }\r\n\r\n /**\r\n * Return the latest unstable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetLatestVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;\r\n }\r\n\r\n /**\r\n * Return the latest stable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetStableVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;\r\n }\r\n\r\n /**\r\n * Attach a feature to the current session. Mainly used when session started to start the feature effect.\r\n * Can be used during a session to start a feature\r\n * @param featureName the name of feature to attach\r\n */\r\n public attachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.enabled && !feature.featureImplementation.attached) {\r\n feature.featureImplementation.attach();\r\n }\r\n }\r\n\r\n /**\r\n * Can be used inside a session or when the session ends to detach a specific feature\r\n * @param featureName the name of the feature to detach\r\n */\r\n public detachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.featureImplementation.attached) {\r\n feature.featureImplementation.detach();\r\n }\r\n }\r\n\r\n /**\r\n * Used to disable an already-enabled feature\r\n * The feature will be disposed and will be recreated once enabled.\r\n * @param featureName the feature to disable\r\n * @returns true if disable was successful\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public disableFeature(featureName: string | { Name: string }): boolean {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n const feature = this._features[name];\r\n if (feature && feature.enabled) {\r\n feature.enabled = false;\r\n this.detachFeature(name);\r\n feature.featureImplementation.dispose();\r\n delete this._features[name];\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * dispose this features manager\r\n */\r\n public dispose(): void {\r\n this.getEnabledFeatures().forEach((feature) => {\r\n this.disableFeature(feature);\r\n });\r\n }\r\n\r\n /**\r\n * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.\r\n * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.\r\n *\r\n * @param featureName the name of the feature to load or the class of the feature\r\n * @param version optional version to load. if not provided the latest version will be enabled\r\n * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n */\r\n public enableFeature(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: string | { Name: string },\r\n version: number | string = \"latest\",\r\n moduleOptions: any = {},\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): IWebXRFeature {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad = 0;\r\n if (typeof version === \"string\") {\r\n if (!version) {\r\n throw new Error(`Error in provided version - ${name} (${version})`);\r\n }\r\n if (version === \"stable\") {\r\n versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n } else if (version === \"latest\") {\r\n versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n } else {\r\n // try loading the number the string represents\r\n versionToLoad = +version;\r\n }\r\n if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n throw new Error(`feature not found - ${name} (${version})`);\r\n }\r\n } else {\r\n versionToLoad = version;\r\n }\r\n\r\n // check if there is a feature conflict\r\n const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r\n if (conflictingFeature !== undefined && this.getEnabledFeatures().indexOf(conflictingFeature) !== -1) {\r\n throw new Error(`Feature ${name} cannot be enabled while ${conflictingFeature} is enabled.`);\r\n }\r\n\r\n // check if already initialized\r\n const feature = this._features[name];\r\n const constructFunction = WebXRFeaturesManager.ConstructFeature(name, versionToLoad, this._xrSessionManager, moduleOptions);\r\n if (!constructFunction) {\r\n // report error?\r\n throw new Error(`feature not found - ${name}`);\r\n }\r\n\r\n /* If the feature is already enabled, detach and dispose it, and create a new one */\r\n if (feature) {\r\n this.disableFeature(name);\r\n }\r\n\r\n const constructed = constructFunction();\r\n if (constructed.dependsOn) {\r\n const dependentsFound = constructed.dependsOn.every((featureName) => !!this._features[featureName]);\r\n if (!dependentsFound) {\r\n throw new Error(`Dependant features missing. Make sure the following features are enabled - ${constructed.dependsOn.join(\", \")}`);\r\n }\r\n }\r\n if (constructed.isCompatible()) {\r\n this._features[name] = {\r\n featureImplementation: constructed,\r\n enabled: true,\r\n version: versionToLoad,\r\n required,\r\n };\r\n\r\n if (attachIfPossible) {\r\n // if session started already, request and enable\r\n if (this._xrSessionManager.session && !this._features[name].featureImplementation.attached) {\r\n // enable feature\r\n this.attachFeature(name);\r\n }\r\n } else {\r\n // disable auto-attach when session starts\r\n this._features[name].featureImplementation.disableAutoAttach = true;\r\n }\r\n\r\n return this._features[name].featureImplementation;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n return constructed;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * get the implementation of an enabled feature.\r\n * @param featureName the name of the feature to load\r\n * @returns the feature class, if found\r\n */\r\n public getEnabledFeature(featureName: string): IWebXRFeature {\r\n return this._features[featureName] && this._features[featureName].featureImplementation;\r\n }\r\n\r\n /**\r\n * Get the list of enabled features\r\n * @returns an array of enabled features\r\n */\r\n public getEnabledFeatures() {\r\n return Object.keys(this._features);\r\n }\r\n\r\n /**\r\n * This function will extend the session creation configuration object with enabled features.\r\n * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,\r\n * according to the defined \"required\" variable, provided during enableFeature call\r\n * @param xrSessionInit the xr Session init object to extend\r\n *\r\n * @returns an extended XRSessionInit object\r\n */\r\n public async _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit> {\r\n const enabledFeatures = this.getEnabledFeatures();\r\n for (const featureName of enabledFeatures) {\r\n const feature = this._features[featureName];\r\n const nativeName = feature.featureImplementation.xrNativeFeatureName;\r\n if (nativeName) {\r\n if (feature.required) {\r\n xrSessionInit.requiredFeatures = xrSessionInit.requiredFeatures || [];\r\n if (xrSessionInit.requiredFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.requiredFeatures.push(nativeName);\r\n }\r\n } else {\r\n xrSessionInit.optionalFeatures = xrSessionInit.optionalFeatures || [];\r\n if (xrSessionInit.optionalFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.optionalFeatures.push(nativeName);\r\n }\r\n }\r\n }\r\n if (feature.featureImplementation.getXRSessionInitExtension) {\r\n const extended = await feature.featureImplementation.getXRSessionInitExtension();\r\n xrSessionInit = {\r\n ...xrSessionInit,\r\n ...extended,\r\n };\r\n }\r\n }\r\n return xrSessionInit;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"webXRFeaturesManager.js","sourceRoot":"","sources":["../../../../lts/core/generated/XR/webXRFeaturesManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA4DtC;;GAEG;AACH,MAAM,OAAO,gBAAgB;;AACzB;;GAEG;AACoB,8BAAa,GAAG,kBAAkB,CAAC;AAC1D;;GAEG;AACoB,mCAAkB,GAAG,uBAAuB,CAAC;AACpE;;GAEG;AACoB,yBAAQ,GAAG,aAAa,CAAC;AAChD;;GAEG;AACoB,+BAAc,GAAG,mBAAmB,CAAC;AAC5D;;GAEG;AACoB,oCAAmB,GAAG,uBAAuB,CAAC;AACrE;;GAEG;AACoB,gCAAe,GAAG,oBAAoB,CAAC;AAC9D;;GAEG;AACoB,kCAAiB,GAAG,iCAAiC,CAAC;AAC7E;;GAEG;AACoB,8BAAa,GAAG,6BAA6B,CAAC;AACrE;;GAEG;AACoB,+BAAc,GAA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QACD,OAAO,aAAa,CAAC;IACzB,CAAC;;AAxUuB,uCAAkB,GAMtC,EAAE,CAAC;AAWP;;GAEG;AACqB,yCAAoB,GAA8B;IACtE,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAC,QAAQ;IAC3D,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,aAAa;CAC9D,CAAC","sourcesContent":["import type { WebXRSessionManager } from \"./webXRSessionManager\";\r\nimport type { IDisposable } from \"../scene\";\r\nimport { Tools } from \"../Misc/tools\";\r\n\r\n/**\r\n * Defining the interface required for a (webxr) feature\r\n */\r\nexport interface IWebXRFeature extends IDisposable {\r\n /**\r\n * Is this feature attached\r\n */\r\n attached: boolean;\r\n /**\r\n * Should auto-attach be disabled?\r\n */\r\n disableAutoAttach: boolean;\r\n\r\n /**\r\n * Attach the feature to the session\r\n * Will usually be called by the features manager\r\n *\r\n * @param force should attachment be forced (even when already attached)\r\n * @returns true if successful.\r\n */\r\n attach(force?: boolean): boolean;\r\n /**\r\n * Detach the feature from the session\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n detach(): boolean;\r\n\r\n /**\r\n * This function will be executed during before enabling the feature and can be used to not-allow enabling it.\r\n * Note that at this point the session has NOT started, so this is purely checking if the browser supports it\r\n *\r\n * @returns whether or not the feature is compatible in this environment\r\n */\r\n isCompatible(): boolean;\r\n\r\n /**\r\n * Was this feature disposed;\r\n */\r\n isDisposed: boolean;\r\n\r\n /**\r\n * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)\r\n */\r\n xrNativeFeatureName?: string;\r\n\r\n /**\r\n * A list of (Babylon WebXR) features this feature depends on\r\n */\r\n dependsOn?: string[];\r\n\r\n /**\r\n * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object\r\n */\r\n getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;\r\n}\r\n\r\n/**\r\n * A list of the currently available features without referencing them\r\n */\r\nexport class WebXRFeatureName {\r\n /**\r\n * The name of the anchor system feature\r\n */\r\n public static readonly ANCHOR_SYSTEM = \"xr-anchor-system\";\r\n /**\r\n * The name of the background remover feature\r\n */\r\n public static readonly BACKGROUND_REMOVER = \"xr-background-remover\";\r\n /**\r\n * The name of the hit test feature\r\n */\r\n public static readonly HIT_TEST = \"xr-hit-test\";\r\n /**\r\n * The name of the mesh detection feature\r\n */\r\n public static readonly MESH_DETECTION = \"xr-mesh-detection\";\r\n /**\r\n * physics impostors for xr controllers feature\r\n */\r\n public static readonly PHYSICS_CONTROLLERS = \"xr-physics-controller\";\r\n /**\r\n * The name of the plane detection feature\r\n */\r\n public static readonly PLANE_DETECTION = \"xr-plane-detection\";\r\n /**\r\n * The name of the pointer selection feature\r\n */\r\n public static readonly POINTER_SELECTION = \"xr-controller-pointer-selection\";\r\n /**\r\n * The name of the teleportation feature\r\n */\r\n public static readonly TELEPORTATION = \"xr-controller-teleportation\";\r\n /**\r\n * The name of the feature points feature.\r\n */\r\n public static readonly FEATURE_POINTS = \"xr-feature-points\";\r\n /**\r\n * The name of the hand tracking feature.\r\n */\r\n public static readonly HAND_TRACKING = \"xr-hand-tracking\";\r\n /**\r\n * The name of the image tracking feature\r\n */\r\n public static readonly IMAGE_TRACKING = \"xr-image-tracking\";\r\n /**\r\n * The name of the near interaction feature\r\n */\r\n public static readonly NEAR_INTERACTION = \"xr-near-interaction\";\r\n /**\r\n * The name of the DOM overlay feature\r\n */\r\n public static readonly DOM_OVERLAY = \"xr-dom-overlay\";\r\n /**\r\n * The name of the movement feature\r\n */\r\n public static readonly MOVEMENT = \"xr-controller-movement\";\r\n /**\r\n * The name of the light estimation feature\r\n */\r\n public static readonly LIGHT_ESTIMATION = \"xr-light-estimation\";\r\n /**\r\n * The name of the eye tracking feature\r\n */\r\n public static readonly EYE_TRACKING = \"xr-eye-tracking\";\r\n /**\r\n * The name of the walking locomotion feature\r\n */\r\n public static readonly WALKING_LOCOMOTION = \"xr-walking-locomotion\";\r\n /**\r\n * The name of the composition layers feature\r\n */\r\n public static readonly LAYERS = \"xr-layers\";\r\n /**\r\n * The name of the depth sensing feature\r\n */\r\n public static readonly DEPTH_SENSING = \"xr-depth-sensing\";\r\n}\r\n\r\n/**\r\n * Defining the constructor of a feature. Used to register the modules.\r\n */\r\nexport type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;\r\n\r\n/**\r\n * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.\r\n * It is mainly used in AR sessions.\r\n *\r\n * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).\r\n */\r\nexport class WebXRFeaturesManager implements IDisposable {\r\n private static readonly _AvailableFeatures: {\r\n [name: string]: {\r\n stable: number;\r\n latest: number;\r\n [version: number]: WebXRFeatureConstructor;\r\n };\r\n } = {};\r\n\r\n private _features: {\r\n [name: string]: {\r\n featureImplementation: IWebXRFeature;\r\n version: number;\r\n enabled: boolean;\r\n required: boolean;\r\n };\r\n } = {};\r\n\r\n /**\r\n * The key is the feature to check and the value is the feature that conflicts.\r\n */\r\n private static readonly _ConflictingFeatures: { [key: string]: string } = {\r\n [WebXRFeatureName.TELEPORTATION]: WebXRFeatureName.MOVEMENT,\r\n [WebXRFeatureName.MOVEMENT]: WebXRFeatureName.TELEPORTATION,\r\n };\r\n\r\n /**\r\n * constructs a new features manages.\r\n *\r\n * @param _xrSessionManager an instance of WebXRSessionManager\r\n */\r\n constructor(private _xrSessionManager: WebXRSessionManager) {\r\n // when session starts / initialized - attach\r\n this._xrSessionManager.onXRSessionInit.add(() => {\r\n this.getEnabledFeatures().forEach((featureName) => {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {\r\n this.attachFeature(featureName);\r\n }\r\n });\r\n });\r\n\r\n // when session ends - detach\r\n this._xrSessionManager.onXRSessionEnded.add(() => {\r\n this.getEnabledFeatures().forEach((featureName) => {\r\n const feature = this._features[featureName];\r\n if (feature.enabled && feature.featureImplementation.attached) {\r\n // detach, but don't disable!\r\n this.detachFeature(featureName);\r\n }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Used to register a module. After calling this function a developer can use this feature in the scene.\r\n * Mainly used internally.\r\n *\r\n * @param featureName the name of the feature to register\r\n * @param constructorFunction the function used to construct the module\r\n * @param version the (babylon) version of the module\r\n * @param stable is that a stable version of this module\r\n */\r\n public static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version: number = 1, stable: boolean = false) {\r\n this._AvailableFeatures[featureName] = this._AvailableFeatures[featureName] || { latest: version };\r\n if (version > this._AvailableFeatures[featureName].latest) {\r\n this._AvailableFeatures[featureName].latest = version;\r\n }\r\n if (stable) {\r\n this._AvailableFeatures[featureName].stable = version;\r\n }\r\n this._AvailableFeatures[featureName][version] = constructorFunction;\r\n }\r\n\r\n /**\r\n * Returns a constructor of a specific feature.\r\n *\r\n * @param featureName the name of the feature to construct\r\n * @param version the version of the feature to load\r\n * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n * @param options optional options provided to the module.\r\n * @returns a function that, when called, will return a new instance of this feature\r\n */\r\n public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n const constructorFunction = this._AvailableFeatures[featureName][version];\r\n if (!constructorFunction) {\r\n // throw an error? return nothing?\r\n throw new Error(\"feature not found\");\r\n }\r\n\r\n return constructorFunction(xrSessionManager, options);\r\n }\r\n\r\n /**\r\n * Can be used to return the list of features currently registered\r\n *\r\n * @returns an Array of available features\r\n */\r\n public static GetAvailableFeatures() {\r\n return Object.keys(this._AvailableFeatures);\r\n }\r\n\r\n /**\r\n * Gets the versions available for a specific feature\r\n * @param featureName the name of the feature\r\n * @returns an array with the available versions\r\n */\r\n public static GetAvailableVersions(featureName: string) {\r\n return Object.keys(this._AvailableFeatures[featureName]);\r\n }\r\n\r\n /**\r\n * Return the latest unstable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetLatestVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].latest) || -1;\r\n }\r\n\r\n /**\r\n * Return the latest stable version of this feature\r\n * @param featureName the name of the feature to search\r\n * @returns the version number. if not found will return -1\r\n */\r\n public static GetStableVersionOfFeature(featureName: string): number {\r\n return (this._AvailableFeatures[featureName] && this._AvailableFeatures[featureName].stable) || -1;\r\n }\r\n\r\n /**\r\n * Attach a feature to the current session. Mainly used when session started to start the feature effect.\r\n * Can be used during a session to start a feature\r\n * @param featureName the name of feature to attach\r\n */\r\n public attachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.enabled && !feature.featureImplementation.attached) {\r\n feature.featureImplementation.attach();\r\n }\r\n }\r\n\r\n /**\r\n * Can be used inside a session or when the session ends to detach a specific feature\r\n * @param featureName the name of the feature to detach\r\n */\r\n public detachFeature(featureName: string) {\r\n const feature = this._features[featureName];\r\n if (feature && feature.featureImplementation.attached) {\r\n feature.featureImplementation.detach();\r\n }\r\n }\r\n\r\n /**\r\n * Used to disable an already-enabled feature\r\n * The feature will be disposed and will be recreated once enabled.\r\n * @param featureName the feature to disable\r\n * @returns true if disable was successful\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public disableFeature(featureName: string | { Name: string }): boolean {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n const feature = this._features[name];\r\n if (feature && feature.enabled) {\r\n feature.enabled = false;\r\n this.detachFeature(name);\r\n feature.featureImplementation.dispose();\r\n delete this._features[name];\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * dispose this features manager\r\n */\r\n public dispose(): void {\r\n this.getEnabledFeatures().forEach((feature) => {\r\n this.disableFeature(feature);\r\n });\r\n }\r\n\r\n /**\r\n * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.\r\n * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.\r\n *\r\n * @param featureName the name of the feature to load or the class of the feature\r\n * @param version optional version to load. if not provided the latest version will be enabled\r\n * @param moduleOptions options provided to the module. Ses the module documentation / constructor\r\n * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible\r\n * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.\r\n * @returns a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.\r\n */\r\n public enableFeature(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n featureName: string | { Name: string },\r\n version: number | string = \"latest\",\r\n moduleOptions: any = {},\r\n attachIfPossible: boolean = true,\r\n required: boolean = true\r\n ): IWebXRFeature {\r\n const name = typeof featureName === \"string\" ? featureName : featureName.Name;\r\n let versionToLoad = 0;\r\n if (typeof version === \"string\") {\r\n if (!version) {\r\n throw new Error(`Error in provided version - ${name} (${version})`);\r\n }\r\n if (version === \"stable\") {\r\n versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);\r\n } else if (version === \"latest\") {\r\n versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);\r\n } else {\r\n // try loading the number the string represents\r\n versionToLoad = +version;\r\n }\r\n if (versionToLoad === -1 || isNaN(versionToLoad)) {\r\n throw new Error(`feature not found - ${name} (${version})`);\r\n }\r\n } else {\r\n versionToLoad = version;\r\n }\r\n\r\n // check if there is a feature conflict\r\n const conflictingFeature = WebXRFeaturesManager._ConflictingFeatures[name];\r\n if (conflictingFeature !== undefined && this.getEnabledFeatures().indexOf(conflictingFeature) !== -1) {\r\n throw new Error(`Feature ${name} cannot be enabled while ${conflictingFeature} is enabled.`);\r\n }\r\n\r\n // check if already initialized\r\n const feature = this._features[name];\r\n const constructFunction = WebXRFeaturesManager.ConstructFeature(name, versionToLoad, this._xrSessionManager, moduleOptions);\r\n if (!constructFunction) {\r\n // report error?\r\n throw new Error(`feature not found - ${name}`);\r\n }\r\n\r\n /* If the feature is already enabled, detach and dispose it, and create a new one */\r\n if (feature) {\r\n this.disableFeature(name);\r\n }\r\n\r\n const constructed = constructFunction();\r\n if (constructed.dependsOn) {\r\n const dependentsFound = constructed.dependsOn.every((featureName) => !!this._features[featureName]);\r\n if (!dependentsFound) {\r\n throw new Error(`Dependant features missing. Make sure the following features are enabled - ${constructed.dependsOn.join(\", \")}`);\r\n }\r\n }\r\n if (constructed.isCompatible()) {\r\n this._features[name] = {\r\n featureImplementation: constructed,\r\n enabled: true,\r\n version: versionToLoad,\r\n required,\r\n };\r\n\r\n if (attachIfPossible) {\r\n // if session started already, request and enable\r\n if (this._xrSessionManager.session && !this._features[name].featureImplementation.attached) {\r\n // enable feature\r\n this.attachFeature(name);\r\n }\r\n } else {\r\n // disable auto-attach when session starts\r\n this._features[name].featureImplementation.disableAutoAttach = true;\r\n }\r\n\r\n return this._features[name].featureImplementation;\r\n } else {\r\n if (required) {\r\n throw new Error(\"required feature not compatible\");\r\n } else {\r\n Tools.Warn(`Feature ${name} not compatible with the current environment/browser and was not enabled.`);\r\n return constructed;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * get the implementation of an enabled feature.\r\n * @param featureName the name of the feature to load\r\n * @returns the feature class, if found\r\n */\r\n public getEnabledFeature(featureName: string): IWebXRFeature {\r\n return this._features[featureName] && this._features[featureName].featureImplementation;\r\n }\r\n\r\n /**\r\n * Get the list of enabled features\r\n * @returns an array of enabled features\r\n */\r\n public getEnabledFeatures() {\r\n return Object.keys(this._features);\r\n }\r\n\r\n /**\r\n * This function will extend the session creation configuration object with enabled features.\r\n * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,\r\n * according to the defined \"required\" variable, provided during enableFeature call\r\n * @param xrSessionInit the xr Session init object to extend\r\n *\r\n * @returns an extended XRSessionInit object\r\n */\r\n public async _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit> {\r\n const enabledFeatures = this.getEnabledFeatures();\r\n for (const featureName of enabledFeatures) {\r\n const feature = this._features[featureName];\r\n const nativeName = feature.featureImplementation.xrNativeFeatureName;\r\n if (nativeName) {\r\n if (feature.required) {\r\n xrSessionInit.requiredFeatures = xrSessionInit.requiredFeatures || [];\r\n if (xrSessionInit.requiredFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.requiredFeatures.push(nativeName);\r\n }\r\n } else {\r\n xrSessionInit.optionalFeatures = xrSessionInit.optionalFeatures || [];\r\n if (xrSessionInit.optionalFeatures.indexOf(nativeName) === -1) {\r\n xrSessionInit.optionalFeatures.push(nativeName);\r\n }\r\n }\r\n }\r\n if (feature.featureImplementation.getXRSessionInitExtension) {\r\n const extended = await feature.featureImplementation.getXRSessionInitExtension();\r\n xrSessionInit = {\r\n ...xrSessionInit,\r\n ...extended,\r\n };\r\n }\r\n }\r\n return xrSessionInit;\r\n }\r\n}\r\n"]}
|
package/assetContainer.js
CHANGED
|
@@ -252,10 +252,6 @@ export class AssetContainer extends AbstractScene {
|
|
|
252
252
|
doNotInstantiate: true,
|
|
253
253
|
...options,
|
|
254
254
|
};
|
|
255
|
-
if (!localOptions.doNotInstantiate) {
|
|
256
|
-
// Always clone skinned meshes.
|
|
257
|
-
localOptions.doNotInstantiate = (node) => !!node.skeleton;
|
|
258
|
-
}
|
|
259
255
|
const onClone = (source, clone) => {
|
|
260
256
|
conversionMap[source.uniqueId] = clone.uniqueId;
|
|
261
257
|
storeMap[clone.uniqueId] = clone;
|
|
@@ -363,7 +359,19 @@ export class AssetContainer extends AbstractScene {
|
|
|
363
359
|
}
|
|
364
360
|
else {
|
|
365
361
|
// Mesh or TransformNode
|
|
366
|
-
|
|
362
|
+
let canInstance = true;
|
|
363
|
+
if (node.getClassName() === "TransformNode" || node.skeleton || node.getTotalVertices() === 0) {
|
|
364
|
+
// Transform nodes, skinned meshes, and meshes with no vertices can never be instanced!
|
|
365
|
+
canInstance = false;
|
|
366
|
+
}
|
|
367
|
+
else if (localOptions.doNotInstantiate) {
|
|
368
|
+
if (typeof localOptions.doNotInstantiate === "function") {
|
|
369
|
+
canInstance = !localOptions.doNotInstantiate(node);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
canInstance = !localOptions.doNotInstantiate;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
367
375
|
const replicatedNode = canInstance ? node.createInstance(`instance of ${node.name}`) : node.clone(`Clone of ${node.name}`, null, true);
|
|
368
376
|
if (!replicatedNode) {
|
|
369
377
|
throw new Error(`Could not clone or instantiate node on Asset Container ${node.name}`);
|
package/assetContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetContainer.js","sourceRoot":"","sources":["../../../lts/core/generated/assetContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAOvD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAa;CAAG;AAEhD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACI;;WAEG;QACI,cAAS,GAAoB,EAAE,CAAC;QAEvC;;WAEG;QACI,cAAS,GAAe,EAAE,CAAC;QAElC;;WAEG;QACI,oBAAe,GAAqB,EAAE,CAAC;IAqBlD,CAAC;IAnBG;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;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a,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ","sourcesContent":["import { AbstractScene } from \"./abstractScene\";\r\nimport type { Scene } from \"./scene\";\r\nimport { Mesh } from \"./Meshes/mesh\";\r\nimport { TransformNode } from \"./Meshes/transformNode\";\r\nimport type { Skeleton } from \"./Bones/skeleton\";\r\nimport type { AnimationGroup } from \"./Animations/animationGroup\";\r\nimport type { Animatable } from \"./Animations/animatable\";\r\nimport type { AbstractMesh } from \"./Meshes/abstractMesh\";\r\nimport type { MultiMaterial } from \"./Materials/multiMaterial\";\r\nimport type { Material } from \"./Materials/material\";\r\nimport { Logger } from \"./Misc/logger\";\r\nimport { EngineStore } from \"./Engines/engineStore\";\r\nimport type { Nullable } from \"./types\";\r\nimport type { Node } from \"./node\";\r\nimport type { Observer } from \"./Misc/observable\";\r\nimport type { ThinEngine } from \"./Engines/thinEngine\";\r\nimport { InstancedMesh } from \"./Meshes/instancedMesh\";\r\nimport { Light } from \"./Lights/light\";\r\nimport { Camera } from \"./Cameras/camera\";\r\nimport { Tools } from \"./Misc/tools\";\r\n\r\n/**\r\n * Set of assets to keep when moving a scene into an asset container.\r\n */\r\nexport class KeepAssets extends AbstractScene {}\r\n\r\n/**\r\n * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function\r\n */\r\nexport class InstantiatedEntries {\r\n /**\r\n * List of new root nodes (eg. nodes with no parent)\r\n */\r\n public rootNodes: TransformNode[] = [];\r\n\r\n /**\r\n * List of new skeletons\r\n */\r\n public skeletons: Skeleton[] = [];\r\n\r\n /**\r\n * List of new animation groups\r\n */\r\n public animationGroups: AnimationGroup[] = [];\r\n\r\n /**\r\n * Disposes the instantiated entries from the scene\r\n */\r\n public dispose() {\r\n this.rootNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.rootNodes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n }\r\n}\r\n\r\n/**\r\n * Container with a set of assets that can be added or removed from a scene.\r\n */\r\nexport class AssetContainer extends AbstractScene {\r\n private _wasAddedToScene = false;\r\n private _onContextRestoredObserver: Nullable<Observer<ThinEngine>>;\r\n\r\n /**\r\n * The scene the AssetContainer belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Instantiates an AssetContainer.\r\n * @param scene The scene the AssetContainer belongs to.\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n super();\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this.scene = scene;\r\n this[\"sounds\"] = [];\r\n this[\"effectLayers\"] = [];\r\n this[\"layers\"] = [];\r\n this[\"lensFlareSystems\"] = [];\r\n this[\"proceduralTextures\"] = [];\r\n this[\"reflectionProbes\"] = [];\r\n\r\n scene.onDisposeObservable.add(() => {\r\n if (!this._wasAddedToScene) {\r\n this.dispose();\r\n }\r\n });\r\n\r\n this._onContextRestoredObserver = scene.getEngine().onContextRestoredObservable.add(() => {\r\n for (const geometry of this.geometries) {\r\n geometry._rebuild();\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n mesh._rebuild();\r\n }\r\n\r\n for (const system of this.particleSystems) {\r\n system.rebuild();\r\n }\r\n\r\n for (const texture of this.textures) {\r\n texture._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Given a list of nodes, return a topological sorting of them.\r\n * @param nodes\r\n */\r\n private _topologicalSort(nodes: TransformNode[]): TransformNode[] {\r\n const nodesUidMap = new Map<number, TransformNode>();\r\n\r\n for (const node of nodes) {\r\n nodesUidMap.set(node.uniqueId, node);\r\n }\r\n\r\n const dependencyGraph = {\r\n dependsOn: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes it depends on\r\n dependedBy: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes that depend on it\r\n };\r\n\r\n // Build the dependency graph given the list of nodes\r\n\r\n // First pass: Initialize the empty dependency graph\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n dependencyGraph.dependsOn.set(nodeId, new Set<number>());\r\n dependencyGraph.dependedBy.set(nodeId, new Set<number>());\r\n }\r\n\r\n // Second pass: Populate the dependency graph. We assume that we\r\n // don't need to check for cycles here, as the scene graph cannot\r\n // contain cycles. Our graph also already contains all transitive\r\n // dependencies because getDescendants returns the transitive\r\n // dependencies by default.\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n const dependsOn = dependencyGraph.dependsOn.get(nodeId)!;\r\n if (node instanceof InstancedMesh) {\r\n const masterMesh = node.sourceMesh;\r\n if (nodesUidMap.has(masterMesh.uniqueId)) {\r\n dependsOn.add(masterMesh.uniqueId);\r\n dependencyGraph.dependedBy.get(masterMesh.uniqueId)!.add(nodeId);\r\n }\r\n }\r\n const dependedBy = dependencyGraph.dependedBy.get(nodeId)!;\r\n\r\n for (const child of node.getDescendants()) {\r\n const childId = child.uniqueId;\r\n if (nodesUidMap.has(childId)) {\r\n dependedBy.add(childId);\r\n\r\n const childDependsOn = dependencyGraph.dependsOn.get(childId)!;\r\n childDependsOn.add(nodeId);\r\n }\r\n }\r\n }\r\n\r\n // Third pass: Topological sort\r\n const sortedNodes: TransformNode[] = [];\r\n\r\n // First: Find all nodes that have no dependencies\r\n const leaves: TransformNode[] = [];\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n if (dependencyGraph.dependsOn.get(nodeId)!.size === 0) {\r\n leaves.push(node);\r\n nodesUidMap.delete(nodeId);\r\n }\r\n }\r\n\r\n const visitList = leaves;\r\n while (visitList.length > 0) {\r\n const nodeToVisit = visitList.shift()!;\r\n\r\n sortedNodes.push(nodeToVisit);\r\n\r\n // Remove the node from the dependency graph\r\n // When a node is visited, we know that dependsOn is empty.\r\n // So we only need to remove the node from dependedBy.\r\n const dependedByVisitedNode = dependencyGraph.dependedBy.get(nodeToVisit.uniqueId)!;\r\n // Array.from(x.values()) is to make the TS compiler happy\r\n for (const dependedByVisitedNodeId of Array.from(dependedByVisitedNode.values())) {\r\n const dependsOnDependedByVisitedNode = dependencyGraph.dependsOn.get(dependedByVisitedNodeId)!;\r\n dependsOnDependedByVisitedNode.delete(nodeToVisit.uniqueId);\r\n\r\n if (dependsOnDependedByVisitedNode.size === 0 && nodesUidMap.get(dependedByVisitedNodeId)) {\r\n visitList.push(nodesUidMap.get(dependedByVisitedNodeId)!);\r\n nodesUidMap.delete(dependedByVisitedNodeId);\r\n }\r\n }\r\n }\r\n\r\n if (nodesUidMap.size > 0) {\r\n console.error(\"SceneSerializer._topologicalSort: There were unvisited nodes:\");\r\n nodesUidMap.forEach((node) => console.error(node.name));\r\n }\r\n\r\n return sortedNodes;\r\n }\r\n\r\n private _addNodeAndDescendantsToList(list: Node[], addedIds: Set<number>, rootNode: Node, predicate?: (entity: any) => boolean) {\r\n if ((predicate && !predicate(rootNode)) || addedIds.has(rootNode.uniqueId)) {\r\n return;\r\n }\r\n\r\n list.push(rootNode);\r\n addedIds.add(rootNode.uniqueId);\r\n\r\n for (const child of rootNode.getDescendants(true)) {\r\n this._addNodeAndDescendantsToList(list, addedIds, child, predicate);\r\n }\r\n }\r\n\r\n /**\r\n * Check if a specific node is contained in this asset container.\r\n * @param node\r\n */\r\n private _isNodeInContainer(node: Node) {\r\n if (node instanceof Mesh && this.meshes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof TransformNode && this.transformNodes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Light && this.lights.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Camera && this.cameras.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * For every node in the scene, check if its parent node is also in the scene.\r\n */\r\n private _isValidHierarchy() {\r\n for (const node of this.meshes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.transformNodes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.lights) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.cameras) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Instantiate or clone all meshes and add the new ones to the scene.\r\n * Skeletons and animation groups will all be cloned\r\n * @param nameFunction defines an optional function used to get new names for clones\r\n * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)\r\n * @param options defines an optional list of options to control how to instantiate / clone models\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.predicate defines a predicate used to filter whih mesh to instantiate/clone\r\n * @returns a list of rootNodes, skeletons and animation groups that were duplicated\r\n */\r\n public instantiateModelsToScene(\r\n nameFunction?: (sourceName: string) => string,\r\n cloneMaterials = false,\r\n options?: { doNotInstantiate?: boolean | ((node: TransformNode) => boolean); predicate?: (entity: any) => boolean }\r\n ): InstantiatedEntries {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n const conversionMap: { [key: number]: number } = {};\r\n const storeMap: { [key: number]: any } = {};\r\n const result = new InstantiatedEntries();\r\n const alreadySwappedSkeletons: Skeleton[] = [];\r\n const alreadySwappedMaterials: Material[] = [];\r\n\r\n const localOptions = {\r\n doNotInstantiate: true,\r\n ...options,\r\n };\r\n\r\n if (!localOptions.doNotInstantiate) {\r\n // Always clone skinned meshes.\r\n localOptions.doNotInstantiate = (node) => !!(node as AbstractMesh).skeleton;\r\n }\r\n\r\n const onClone = (source: TransformNode, clone: TransformNode) => {\r\n conversionMap[source.uniqueId] = clone.uniqueId;\r\n storeMap[clone.uniqueId] = clone;\r\n\r\n if (nameFunction) {\r\n clone.name = nameFunction(source.name);\r\n }\r\n\r\n if (clone instanceof Mesh) {\r\n const clonedMesh = clone as Mesh;\r\n\r\n if (clonedMesh.morphTargetManager) {\r\n const oldMorphTargetManager = (source as Mesh).morphTargetManager!;\r\n clonedMesh.morphTargetManager = oldMorphTargetManager.clone();\r\n\r\n for (let index = 0; index < oldMorphTargetManager.numTargets; index++) {\r\n const oldTarget = oldMorphTargetManager.getTarget(index);\r\n const newTarget = clonedMesh.morphTargetManager.getTarget(index);\r\n\r\n conversionMap[oldTarget.uniqueId] = newTarget.uniqueId;\r\n storeMap[newTarget.uniqueId] = newTarget;\r\n }\r\n }\r\n }\r\n };\r\n\r\n const nodesToSort: TransformNode[] = [];\r\n const idsOnSortList = new Set<number>();\r\n\r\n for (const transformNode of this.transformNodes) {\r\n if (transformNode.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, transformNode, localOptions.predicate);\r\n }\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n if (mesh.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, mesh, localOptions.predicate);\r\n }\r\n }\r\n\r\n // Topologically sort nodes by parenting/instancing relationships so that all resources are in place\r\n // when a given node is instantiated.\r\n const sortedNodes = this._topologicalSort(nodesToSort);\r\n\r\n const onNewCreated = (source: TransformNode, clone: TransformNode) => {\r\n onClone(source, clone);\r\n\r\n if (source.parent) {\r\n const replicatedParentId = conversionMap[source.parent.uniqueId];\r\n const replicatedParent = storeMap[replicatedParentId];\r\n\r\n if (replicatedParent) {\r\n clone.parent = replicatedParent;\r\n } else {\r\n clone.parent = source.parent;\r\n }\r\n }\r\n\r\n clone.position.copyFrom(source.position);\r\n clone.rotation.copyFrom(source.rotation);\r\n clone.scaling.copyFrom(source.scaling);\r\n\r\n if ((clone as any).material) {\r\n const mesh = clone as AbstractMesh;\r\n\r\n if (mesh.material) {\r\n if (cloneMaterials) {\r\n const sourceMaterial = (source as AbstractMesh).material!;\r\n\r\n if (alreadySwappedMaterials.indexOf(sourceMaterial) === -1) {\r\n let swap = sourceMaterial.clone(nameFunction ? nameFunction(sourceMaterial.name) : \"Clone of \" + sourceMaterial.name)!;\r\n alreadySwappedMaterials.push(sourceMaterial);\r\n conversionMap[sourceMaterial.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n\r\n if (sourceMaterial.getClassName() === \"MultiMaterial\") {\r\n const multi = sourceMaterial as MultiMaterial;\r\n\r\n for (const material of multi.subMaterials) {\r\n if (!material) {\r\n continue;\r\n }\r\n swap = material.clone(nameFunction ? nameFunction(material.name) : \"Clone of \" + material.name)!;\r\n alreadySwappedMaterials.push(material);\r\n conversionMap[material.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n }\r\n\r\n multi.subMaterials = multi.subMaterials.map((m) => m && storeMap[conversionMap[m.uniqueId]]);\r\n }\r\n }\r\n\r\n if (mesh.getClassName() !== \"InstancedMesh\") {\r\n mesh.material = storeMap[conversionMap[sourceMaterial.uniqueId]];\r\n }\r\n } else {\r\n if (mesh.material.getClassName() === \"MultiMaterial\") {\r\n if (this.scene.multiMaterials.indexOf(mesh.material as MultiMaterial) === -1) {\r\n this.scene.addMultiMaterial(mesh.material as MultiMaterial);\r\n }\r\n } else {\r\n if (this.scene.materials.indexOf(mesh.material) === -1) {\r\n this.scene.addMaterial(mesh.material);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (clone.parent === null) {\r\n result.rootNodes.push(clone);\r\n }\r\n };\r\n\r\n sortedNodes.forEach((node) => {\r\n if (node.getClassName() === \"InstancedMesh\") {\r\n const instancedNode = node as InstancedMesh;\r\n const sourceMesh = instancedNode.sourceMesh;\r\n const replicatedSourceId = conversionMap[sourceMesh.uniqueId];\r\n const replicatedSource = typeof replicatedSourceId === \"number\" ? storeMap[replicatedSourceId] : sourceMesh;\r\n const replicatedInstancedNode = replicatedSource.createInstance(instancedNode.name);\r\n onNewCreated(instancedNode, replicatedInstancedNode);\r\n } else {\r\n // Mesh or TransformNode\r\n const canInstance = !localOptions?.doNotInstantiate && (node as Mesh).getTotalVertices() > 0;\r\n const replicatedNode = canInstance ? (node as Mesh).createInstance(`instance of ${node.name}`) : node.clone(`Clone of ${node.name}`, null, true);\r\n if (!replicatedNode) {\r\n throw new Error(`Could not clone or instantiate node on Asset Container ${node.name}`);\r\n }\r\n onNewCreated(node, replicatedNode);\r\n }\r\n });\r\n\r\n this.skeletons.forEach((s) => {\r\n if (localOptions.predicate && !localOptions.predicate(s)) {\r\n return;\r\n }\r\n\r\n const clone = s.clone(nameFunction ? nameFunction(s.name) : \"Clone of \" + s.name);\r\n\r\n for (const m of this.meshes) {\r\n if (m.skeleton === s && !m.isAnInstance) {\r\n const copy = storeMap[conversionMap[m.uniqueId]] as Mesh;\r\n if (copy.isAnInstance) {\r\n continue;\r\n }\r\n copy.skeleton = clone;\r\n\r\n if (alreadySwappedSkeletons.indexOf(clone) !== -1) {\r\n continue;\r\n }\r\n\r\n alreadySwappedSkeletons.push(clone);\r\n\r\n // Check if bones are mesh linked\r\n for (const bone of clone.bones) {\r\n if (bone._linkedTransformNode) {\r\n bone._linkedTransformNode = storeMap[conversionMap[bone._linkedTransformNode.uniqueId]];\r\n }\r\n }\r\n }\r\n }\r\n\r\n result.skeletons.push(clone);\r\n });\r\n\r\n this.animationGroups.forEach((o) => {\r\n if (localOptions.predicate && !localOptions.predicate(o)) {\r\n return;\r\n }\r\n\r\n const clone = o.clone(nameFunction ? nameFunction(o.name) : \"Clone of \" + o.name, (oldTarget) => {\r\n const newTarget = storeMap[conversionMap[oldTarget.uniqueId]];\r\n\r\n return newTarget || oldTarget;\r\n });\r\n\r\n result.animationGroups.push(clone);\r\n });\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Adds all the assets from the container to the scene.\r\n */\r\n public addAllToScene() {\r\n if (this._wasAddedToScene) {\r\n return;\r\n }\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = true;\r\n\r\n this.addToScene(null);\r\n\r\n if (this.environmentTexture) {\r\n this.scene.environmentTexture = this.environmentTexture;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.addFromContainer(this);\r\n }\r\n\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n\r\n /**\r\n * Adds assets from the container to the scene.\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public addToScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Removes all the assets in the container from the scene\r\n */\r\n public removeAllFromScene() {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = false;\r\n\r\n this.removeFromScene(null);\r\n\r\n if (this.environmentTexture === this.scene.environmentTexture) {\r\n this.scene.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Removes assets in the container from the scene\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public removeFromScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Disposes all the assets in the container\r\n */\r\n public dispose() {\r\n this.cameras.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.cameras.length = 0;\r\n\r\n this.lights.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.lights.length = 0;\r\n\r\n this.meshes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.meshes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n\r\n this.multiMaterials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.multiMaterials.length = 0;\r\n\r\n this.materials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.materials.length = 0;\r\n\r\n this.geometries.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.geometries.length = 0;\r\n\r\n this.transformNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.transformNodes.length = 0;\r\n\r\n this.actionManagers.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.actionManagers.length = 0;\r\n\r\n this.textures.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.textures.length = 0;\r\n\r\n this.reflectionProbes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.reflectionProbes.length = 0;\r\n\r\n if (this.environmentTexture) {\r\n this.environmentTexture.dispose();\r\n this.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this, true);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n\r\n private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {\r\n if (!sourceAssets || !targetAssets) {\r\n return;\r\n }\r\n\r\n for (const asset of sourceAssets) {\r\n let move = true;\r\n if (keepAssets) {\r\n for (const keepAsset of keepAssets) {\r\n if (asset === keepAsset) {\r\n move = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (move) {\r\n targetAssets.push(asset);\r\n (asset as any)._parentContainer = this;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes all the assets contained in the scene and adds them to the container.\r\n * @param keepAssets Set of assets to keep in the scene. (default: empty)\r\n */\r\n public moveAllFromScene(keepAssets?: KeepAssets): void {\r\n this._wasAddedToScene = false;\r\n\r\n if (keepAssets === undefined) {\r\n keepAssets = new KeepAssets();\r\n }\r\n\r\n for (const key in this) {\r\n if (Object.prototype.hasOwnProperty.call(this, key)) {\r\n (<any>this)[key] = (<any>this)[key] || (key === \"_environmentTexture\" ? null : []);\r\n this._moveAssets((<any>this.scene)[key], (<any>this)[key], (<any>keepAssets)[key]);\r\n }\r\n }\r\n\r\n this.environmentTexture = this.scene.environmentTexture;\r\n\r\n this.removeAllFromScene();\r\n }\r\n\r\n /**\r\n * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.\r\n * @returns the root mesh\r\n */\r\n public createRootMesh() {\r\n const rootMesh = new Mesh(\"assetContainerRootMesh\", this.scene);\r\n this.meshes.forEach((m) => {\r\n if (!m.parent) {\r\n rootMesh.addChild(m);\r\n }\r\n });\r\n this.meshes.unshift(rootMesh);\r\n return rootMesh;\r\n }\r\n\r\n /**\r\n * Merge animations (direct and animation groups) from this asset container into a scene\r\n * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)\r\n * @param animatables set of animatables to retarget to a node from the scene\r\n * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)\r\n * @returns an array of the new AnimationGroup added to the scene (empty array if none)\r\n */\r\n public mergeAnimationsTo(\r\n scene: Nullable<Scene> = EngineStore.LastCreatedScene,\r\n animatables: Animatable[],\r\n targetConverter: Nullable<(target: any) => Nullable<Node>> = null\r\n ): AnimationGroup[] {\r\n if (!scene) {\r\n Logger.Error(\"No scene available to merge animations to\");\r\n return [];\r\n }\r\n\r\n const _targetConverter = targetConverter\r\n ? targetConverter\r\n : (target: any) => {\r\n let node = null;\r\n\r\n const targetProperty = target.animations.length ? target.animations[0].targetProperty : \"\";\r\n /*\r\n BabylonJS adds special naming to targets that are children of nodes.\r\n This name attempts to remove that special naming to get the parent nodes name in case the target\r\n can't be found in the node tree\r\n\r\n Ex: Torso_primitive0 likely points to a Mesh primitive. We take away primitive0 and are left with \"Torso\" which is the name\r\n of the primitive's parent.\r\n */\r\n const name = target.name.split(\".\").join(\"\").split(\"_primitive\")[0];\r\n\r\n switch (targetProperty) {\r\n case \"position\":\r\n case \"rotationQuaternion\":\r\n node = scene.getTransformNodeByName(target.name) || scene.getTransformNodeByName(name);\r\n break;\r\n case \"influence\":\r\n node = scene.getMorphTargetByName(target.name) || scene.getMorphTargetByName(name);\r\n break;\r\n default:\r\n node = scene.getNodeByName(target.name) || scene.getNodeByName(name);\r\n }\r\n\r\n return node;\r\n };\r\n\r\n // Copy new node animations\r\n const nodesInAC = this.getNodes();\r\n nodesInAC.forEach((nodeInAC) => {\r\n const nodeInScene = _targetConverter(nodeInAC);\r\n if (nodeInScene !== null) {\r\n // Remove old animations with same target property as a new one\r\n for (const animationInAC of nodeInAC.animations) {\r\n // Doing treatment on an array for safety measure\r\n const animationsWithSameProperty = nodeInScene.animations.filter((animationInScene) => {\r\n return animationInScene.targetProperty === animationInAC.targetProperty;\r\n });\r\n for (const animationWithSameProperty of animationsWithSameProperty) {\r\n const index = nodeInScene.animations.indexOf(animationWithSameProperty, 0);\r\n if (index > -1) {\r\n nodeInScene.animations.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n // Append new animations\r\n nodeInScene.animations = nodeInScene.animations.concat(nodeInAC.animations);\r\n }\r\n });\r\n\r\n const newAnimationGroups = new Array<AnimationGroup>();\r\n\r\n // Copy new animation groups\r\n this.animationGroups.slice().forEach((animationGroupInAC) => {\r\n // Clone the animation group and all its animatables\r\n newAnimationGroups.push(animationGroupInAC.clone(animationGroupInAC.name, _targetConverter));\r\n\r\n // Remove animatables related to the asset container\r\n animationGroupInAC.animatables.forEach((animatable) => {\r\n animatable.stop();\r\n });\r\n });\r\n\r\n // Retarget animatables\r\n animatables.forEach((animatable) => {\r\n const target = _targetConverter(animatable.target);\r\n\r\n if (target) {\r\n // Clone the animatable and retarget it\r\n scene.beginAnimation(\r\n target,\r\n animatable.fromFrame,\r\n animatable.toFrame,\r\n animatable.loopAnimation,\r\n animatable.speedRatio,\r\n animatable.onAnimationEnd ? animatable.onAnimationEnd : undefined,\r\n undefined,\r\n true,\r\n undefined,\r\n animatable.onAnimationLoop ? animatable.onAnimationLoop : undefined\r\n );\r\n\r\n // Stop animation for the target in the asset container\r\n scene.stopAnimation(animatable.target);\r\n }\r\n });\r\n\r\n return newAnimationGroups;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"assetContainer.js","sourceRoot":"","sources":["../../../lts/core/generated/assetContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAOvD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAa;CAAG;AAEhD;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACI;;WAEG;QACI,cAAS,GAAoB,EAAE,CAAC;QAEvC;;WAEG;QACI,cAAS,GAAe,EAAE,CAAC;QAElC;;WAEG;QACI,oBAAe,GAAqB,EAAE,CAAC;IAqBlD,CAAC;IAnBG;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,KAAK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AC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EACjE,SAAS,EACT,IAAI,EACJ,SAAS,EACT,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CACtE,CAAC;gBAEF,uDAAuD;gBACvD,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ","sourcesContent":["import { AbstractScene } from \"./abstractScene\";\r\nimport type { Scene } from \"./scene\";\r\nimport { Mesh } from \"./Meshes/mesh\";\r\nimport { TransformNode } from \"./Meshes/transformNode\";\r\nimport type { Skeleton } from \"./Bones/skeleton\";\r\nimport type { AnimationGroup } from \"./Animations/animationGroup\";\r\nimport type { Animatable } from \"./Animations/animatable\";\r\nimport type { AbstractMesh } from \"./Meshes/abstractMesh\";\r\nimport type { MultiMaterial } from \"./Materials/multiMaterial\";\r\nimport type { Material } from \"./Materials/material\";\r\nimport { Logger } from \"./Misc/logger\";\r\nimport { EngineStore } from \"./Engines/engineStore\";\r\nimport type { Nullable } from \"./types\";\r\nimport type { Node } from \"./node\";\r\nimport type { Observer } from \"./Misc/observable\";\r\nimport type { ThinEngine } from \"./Engines/thinEngine\";\r\nimport { InstancedMesh } from \"./Meshes/instancedMesh\";\r\nimport { Light } from \"./Lights/light\";\r\nimport { Camera } from \"./Cameras/camera\";\r\nimport { Tools } from \"./Misc/tools\";\r\n\r\n/**\r\n * Set of assets to keep when moving a scene into an asset container.\r\n */\r\nexport class KeepAssets extends AbstractScene {}\r\n\r\n/**\r\n * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function\r\n */\r\nexport class InstantiatedEntries {\r\n /**\r\n * List of new root nodes (eg. nodes with no parent)\r\n */\r\n public rootNodes: TransformNode[] = [];\r\n\r\n /**\r\n * List of new skeletons\r\n */\r\n public skeletons: Skeleton[] = [];\r\n\r\n /**\r\n * List of new animation groups\r\n */\r\n public animationGroups: AnimationGroup[] = [];\r\n\r\n /**\r\n * Disposes the instantiated entries from the scene\r\n */\r\n public dispose() {\r\n this.rootNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.rootNodes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n }\r\n}\r\n\r\n/**\r\n * Container with a set of assets that can be added or removed from a scene.\r\n */\r\nexport class AssetContainer extends AbstractScene {\r\n private _wasAddedToScene = false;\r\n private _onContextRestoredObserver: Nullable<Observer<ThinEngine>>;\r\n\r\n /**\r\n * The scene the AssetContainer belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Instantiates an AssetContainer.\r\n * @param scene The scene the AssetContainer belongs to.\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n super();\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this.scene = scene;\r\n this[\"sounds\"] = [];\r\n this[\"effectLayers\"] = [];\r\n this[\"layers\"] = [];\r\n this[\"lensFlareSystems\"] = [];\r\n this[\"proceduralTextures\"] = [];\r\n this[\"reflectionProbes\"] = [];\r\n\r\n scene.onDisposeObservable.add(() => {\r\n if (!this._wasAddedToScene) {\r\n this.dispose();\r\n }\r\n });\r\n\r\n this._onContextRestoredObserver = scene.getEngine().onContextRestoredObservable.add(() => {\r\n for (const geometry of this.geometries) {\r\n geometry._rebuild();\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n mesh._rebuild();\r\n }\r\n\r\n for (const system of this.particleSystems) {\r\n system.rebuild();\r\n }\r\n\r\n for (const texture of this.textures) {\r\n texture._rebuild();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Given a list of nodes, return a topological sorting of them.\r\n * @param nodes\r\n */\r\n private _topologicalSort(nodes: TransformNode[]): TransformNode[] {\r\n const nodesUidMap = new Map<number, TransformNode>();\r\n\r\n for (const node of nodes) {\r\n nodesUidMap.set(node.uniqueId, node);\r\n }\r\n\r\n const dependencyGraph = {\r\n dependsOn: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes it depends on\r\n dependedBy: new Map<number, Set<number>>(), // given a node id, what are the ids of the nodes that depend on it\r\n };\r\n\r\n // Build the dependency graph given the list of nodes\r\n\r\n // First pass: Initialize the empty dependency graph\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n dependencyGraph.dependsOn.set(nodeId, new Set<number>());\r\n dependencyGraph.dependedBy.set(nodeId, new Set<number>());\r\n }\r\n\r\n // Second pass: Populate the dependency graph. We assume that we\r\n // don't need to check for cycles here, as the scene graph cannot\r\n // contain cycles. Our graph also already contains all transitive\r\n // dependencies because getDescendants returns the transitive\r\n // dependencies by default.\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n const dependsOn = dependencyGraph.dependsOn.get(nodeId)!;\r\n if (node instanceof InstancedMesh) {\r\n const masterMesh = node.sourceMesh;\r\n if (nodesUidMap.has(masterMesh.uniqueId)) {\r\n dependsOn.add(masterMesh.uniqueId);\r\n dependencyGraph.dependedBy.get(masterMesh.uniqueId)!.add(nodeId);\r\n }\r\n }\r\n const dependedBy = dependencyGraph.dependedBy.get(nodeId)!;\r\n\r\n for (const child of node.getDescendants()) {\r\n const childId = child.uniqueId;\r\n if (nodesUidMap.has(childId)) {\r\n dependedBy.add(childId);\r\n\r\n const childDependsOn = dependencyGraph.dependsOn.get(childId)!;\r\n childDependsOn.add(nodeId);\r\n }\r\n }\r\n }\r\n\r\n // Third pass: Topological sort\r\n const sortedNodes: TransformNode[] = [];\r\n\r\n // First: Find all nodes that have no dependencies\r\n const leaves: TransformNode[] = [];\r\n for (const node of nodes) {\r\n const nodeId = node.uniqueId;\r\n if (dependencyGraph.dependsOn.get(nodeId)!.size === 0) {\r\n leaves.push(node);\r\n nodesUidMap.delete(nodeId);\r\n }\r\n }\r\n\r\n const visitList = leaves;\r\n while (visitList.length > 0) {\r\n const nodeToVisit = visitList.shift()!;\r\n\r\n sortedNodes.push(nodeToVisit);\r\n\r\n // Remove the node from the dependency graph\r\n // When a node is visited, we know that dependsOn is empty.\r\n // So we only need to remove the node from dependedBy.\r\n const dependedByVisitedNode = dependencyGraph.dependedBy.get(nodeToVisit.uniqueId)!;\r\n // Array.from(x.values()) is to make the TS compiler happy\r\n for (const dependedByVisitedNodeId of Array.from(dependedByVisitedNode.values())) {\r\n const dependsOnDependedByVisitedNode = dependencyGraph.dependsOn.get(dependedByVisitedNodeId)!;\r\n dependsOnDependedByVisitedNode.delete(nodeToVisit.uniqueId);\r\n\r\n if (dependsOnDependedByVisitedNode.size === 0 && nodesUidMap.get(dependedByVisitedNodeId)) {\r\n visitList.push(nodesUidMap.get(dependedByVisitedNodeId)!);\r\n nodesUidMap.delete(dependedByVisitedNodeId);\r\n }\r\n }\r\n }\r\n\r\n if (nodesUidMap.size > 0) {\r\n console.error(\"SceneSerializer._topologicalSort: There were unvisited nodes:\");\r\n nodesUidMap.forEach((node) => console.error(node.name));\r\n }\r\n\r\n return sortedNodes;\r\n }\r\n\r\n private _addNodeAndDescendantsToList(list: Node[], addedIds: Set<number>, rootNode: Node, predicate?: (entity: any) => boolean) {\r\n if ((predicate && !predicate(rootNode)) || addedIds.has(rootNode.uniqueId)) {\r\n return;\r\n }\r\n\r\n list.push(rootNode);\r\n addedIds.add(rootNode.uniqueId);\r\n\r\n for (const child of rootNode.getDescendants(true)) {\r\n this._addNodeAndDescendantsToList(list, addedIds, child, predicate);\r\n }\r\n }\r\n\r\n /**\r\n * Check if a specific node is contained in this asset container.\r\n * @param node\r\n */\r\n private _isNodeInContainer(node: Node) {\r\n if (node instanceof Mesh && this.meshes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof TransformNode && this.transformNodes.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Light && this.lights.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n if (node instanceof Camera && this.cameras.indexOf(node) !== -1) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * For every node in the scene, check if its parent node is also in the scene.\r\n */\r\n private _isValidHierarchy() {\r\n for (const node of this.meshes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.transformNodes) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.lights) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n for (const node of this.cameras) {\r\n if (node.parent && !this._isNodeInContainer(node.parent)) {\r\n Logger.Warn(`Node ${node.name} has a parent that is not in the container.`);\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Instantiate or clone all meshes and add the new ones to the scene.\r\n * Skeletons and animation groups will all be cloned\r\n * @param nameFunction defines an optional function used to get new names for clones\r\n * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)\r\n * @param options defines an optional list of options to control how to instantiate / clone models\r\n * @param options.doNotInstantiate defines if the model must be instantiated or just cloned\r\n * @param options.predicate defines a predicate used to filter whih mesh to instantiate/clone\r\n * @returns a list of rootNodes, skeletons and animation groups that were duplicated\r\n */\r\n public instantiateModelsToScene(\r\n nameFunction?: (sourceName: string) => string,\r\n cloneMaterials = false,\r\n options?: { doNotInstantiate?: boolean | ((node: TransformNode) => boolean); predicate?: (entity: any) => boolean }\r\n ): InstantiatedEntries {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n const conversionMap: { [key: number]: number } = {};\r\n const storeMap: { [key: number]: any } = {};\r\n const result = new InstantiatedEntries();\r\n const alreadySwappedSkeletons: Skeleton[] = [];\r\n const alreadySwappedMaterials: Material[] = [];\r\n\r\n const localOptions = {\r\n doNotInstantiate: true,\r\n ...options,\r\n };\r\n\r\n const onClone = (source: TransformNode, clone: TransformNode) => {\r\n conversionMap[source.uniqueId] = clone.uniqueId;\r\n storeMap[clone.uniqueId] = clone;\r\n\r\n if (nameFunction) {\r\n clone.name = nameFunction(source.name);\r\n }\r\n\r\n if (clone instanceof Mesh) {\r\n const clonedMesh = clone as Mesh;\r\n\r\n if (clonedMesh.morphTargetManager) {\r\n const oldMorphTargetManager = (source as Mesh).morphTargetManager!;\r\n clonedMesh.morphTargetManager = oldMorphTargetManager.clone();\r\n\r\n for (let index = 0; index < oldMorphTargetManager.numTargets; index++) {\r\n const oldTarget = oldMorphTargetManager.getTarget(index);\r\n const newTarget = clonedMesh.morphTargetManager.getTarget(index);\r\n\r\n conversionMap[oldTarget.uniqueId] = newTarget.uniqueId;\r\n storeMap[newTarget.uniqueId] = newTarget;\r\n }\r\n }\r\n }\r\n };\r\n\r\n const nodesToSort: TransformNode[] = [];\r\n const idsOnSortList = new Set<number>();\r\n\r\n for (const transformNode of this.transformNodes) {\r\n if (transformNode.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, transformNode, localOptions.predicate);\r\n }\r\n }\r\n\r\n for (const mesh of this.meshes) {\r\n if (mesh.parent === null) {\r\n this._addNodeAndDescendantsToList(nodesToSort, idsOnSortList, mesh, localOptions.predicate);\r\n }\r\n }\r\n\r\n // Topologically sort nodes by parenting/instancing relationships so that all resources are in place\r\n // when a given node is instantiated.\r\n const sortedNodes = this._topologicalSort(nodesToSort);\r\n\r\n const onNewCreated = (source: TransformNode, clone: TransformNode) => {\r\n onClone(source, clone);\r\n\r\n if (source.parent) {\r\n const replicatedParentId = conversionMap[source.parent.uniqueId];\r\n const replicatedParent = storeMap[replicatedParentId];\r\n\r\n if (replicatedParent) {\r\n clone.parent = replicatedParent;\r\n } else {\r\n clone.parent = source.parent;\r\n }\r\n }\r\n\r\n clone.position.copyFrom(source.position);\r\n clone.rotation.copyFrom(source.rotation);\r\n clone.scaling.copyFrom(source.scaling);\r\n\r\n if ((clone as any).material) {\r\n const mesh = clone as AbstractMesh;\r\n\r\n if (mesh.material) {\r\n if (cloneMaterials) {\r\n const sourceMaterial = (source as AbstractMesh).material!;\r\n\r\n if (alreadySwappedMaterials.indexOf(sourceMaterial) === -1) {\r\n let swap = sourceMaterial.clone(nameFunction ? nameFunction(sourceMaterial.name) : \"Clone of \" + sourceMaterial.name)!;\r\n alreadySwappedMaterials.push(sourceMaterial);\r\n conversionMap[sourceMaterial.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n\r\n if (sourceMaterial.getClassName() === \"MultiMaterial\") {\r\n const multi = sourceMaterial as MultiMaterial;\r\n\r\n for (const material of multi.subMaterials) {\r\n if (!material) {\r\n continue;\r\n }\r\n swap = material.clone(nameFunction ? nameFunction(material.name) : \"Clone of \" + material.name)!;\r\n alreadySwappedMaterials.push(material);\r\n conversionMap[material.uniqueId] = swap.uniqueId;\r\n storeMap[swap.uniqueId] = swap;\r\n }\r\n\r\n multi.subMaterials = multi.subMaterials.map((m) => m && storeMap[conversionMap[m.uniqueId]]);\r\n }\r\n }\r\n\r\n if (mesh.getClassName() !== \"InstancedMesh\") {\r\n mesh.material = storeMap[conversionMap[sourceMaterial.uniqueId]];\r\n }\r\n } else {\r\n if (mesh.material.getClassName() === \"MultiMaterial\") {\r\n if (this.scene.multiMaterials.indexOf(mesh.material as MultiMaterial) === -1) {\r\n this.scene.addMultiMaterial(mesh.material as MultiMaterial);\r\n }\r\n } else {\r\n if (this.scene.materials.indexOf(mesh.material) === -1) {\r\n this.scene.addMaterial(mesh.material);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (clone.parent === null) {\r\n result.rootNodes.push(clone);\r\n }\r\n };\r\n\r\n sortedNodes.forEach((node) => {\r\n if (node.getClassName() === \"InstancedMesh\") {\r\n const instancedNode = node as InstancedMesh;\r\n const sourceMesh = instancedNode.sourceMesh;\r\n const replicatedSourceId = conversionMap[sourceMesh.uniqueId];\r\n const replicatedSource = typeof replicatedSourceId === \"number\" ? storeMap[replicatedSourceId] : sourceMesh;\r\n const replicatedInstancedNode = replicatedSource.createInstance(instancedNode.name);\r\n onNewCreated(instancedNode, replicatedInstancedNode);\r\n } else {\r\n // Mesh or TransformNode\r\n let canInstance = true;\r\n if (node.getClassName() === \"TransformNode\" || (node as Mesh).skeleton || (node as Mesh).getTotalVertices() === 0) {\r\n // Transform nodes, skinned meshes, and meshes with no vertices can never be instanced!\r\n canInstance = false;\r\n } else if (localOptions.doNotInstantiate) {\r\n if (typeof localOptions.doNotInstantiate === \"function\") {\r\n canInstance = !localOptions.doNotInstantiate(node);\r\n } else {\r\n canInstance = !localOptions.doNotInstantiate;\r\n }\r\n }\r\n const replicatedNode = canInstance ? (node as Mesh).createInstance(`instance of ${node.name}`) : node.clone(`Clone of ${node.name}`, null, true);\r\n if (!replicatedNode) {\r\n throw new Error(`Could not clone or instantiate node on Asset Container ${node.name}`);\r\n }\r\n onNewCreated(node, replicatedNode);\r\n }\r\n });\r\n\r\n this.skeletons.forEach((s) => {\r\n if (localOptions.predicate && !localOptions.predicate(s)) {\r\n return;\r\n }\r\n\r\n const clone = s.clone(nameFunction ? nameFunction(s.name) : \"Clone of \" + s.name);\r\n\r\n for (const m of this.meshes) {\r\n if (m.skeleton === s && !m.isAnInstance) {\r\n const copy = storeMap[conversionMap[m.uniqueId]] as Mesh;\r\n if (copy.isAnInstance) {\r\n continue;\r\n }\r\n copy.skeleton = clone;\r\n\r\n if (alreadySwappedSkeletons.indexOf(clone) !== -1) {\r\n continue;\r\n }\r\n\r\n alreadySwappedSkeletons.push(clone);\r\n\r\n // Check if bones are mesh linked\r\n for (const bone of clone.bones) {\r\n if (bone._linkedTransformNode) {\r\n bone._linkedTransformNode = storeMap[conversionMap[bone._linkedTransformNode.uniqueId]];\r\n }\r\n }\r\n }\r\n }\r\n\r\n result.skeletons.push(clone);\r\n });\r\n\r\n this.animationGroups.forEach((o) => {\r\n if (localOptions.predicate && !localOptions.predicate(o)) {\r\n return;\r\n }\r\n\r\n const clone = o.clone(nameFunction ? nameFunction(o.name) : \"Clone of \" + o.name, (oldTarget) => {\r\n const newTarget = storeMap[conversionMap[oldTarget.uniqueId]];\r\n\r\n return newTarget || oldTarget;\r\n });\r\n\r\n result.animationGroups.push(clone);\r\n });\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Adds all the assets from the container to the scene.\r\n */\r\n public addAllToScene() {\r\n if (this._wasAddedToScene) {\r\n return;\r\n }\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = true;\r\n\r\n this.addToScene(null);\r\n\r\n if (this.environmentTexture) {\r\n this.scene.environmentTexture = this.environmentTexture;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.addFromContainer(this);\r\n }\r\n\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n\r\n /**\r\n * Adds assets from the container to the scene.\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public addToScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.addReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Removes all the assets in the container from the scene\r\n */\r\n public removeAllFromScene() {\r\n if (!this._isValidHierarchy()) {\r\n Tools.Warn(\"SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid.\");\r\n }\r\n\r\n this._wasAddedToScene = false;\r\n\r\n this.removeFromScene(null);\r\n\r\n if (this.environmentTexture === this.scene.environmentTexture) {\r\n this.scene.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Removes assets in the container from the scene\r\n * @param predicate defines a predicate used to select which entity will be added (can be null)\r\n */\r\n public removeFromScene(predicate: Nullable<(entity: any) => boolean> = null) {\r\n this.cameras.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeCamera(o);\r\n });\r\n this.lights.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeLight(o);\r\n });\r\n this.meshes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMesh(o);\r\n });\r\n this.skeletons.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeSkeleton(o);\r\n });\r\n this.animations.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimation(o);\r\n });\r\n this.animationGroups.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeAnimationGroup(o);\r\n });\r\n this.multiMaterials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMultiMaterial(o);\r\n });\r\n this.materials.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMaterial(o);\r\n });\r\n this.morphTargetManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeMorphTargetManager(o);\r\n });\r\n this.geometries.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeGeometry(o);\r\n });\r\n this.transformNodes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTransformNode(o);\r\n });\r\n this.actionManagers.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeActionManager(o);\r\n });\r\n this.textures.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeTexture(o);\r\n });\r\n this.reflectionProbes.forEach((o) => {\r\n if (predicate && !predicate(o)) {\r\n return;\r\n }\r\n this.scene.removeReflectionProbe(o);\r\n });\r\n }\r\n\r\n /**\r\n * Disposes all the assets in the container\r\n */\r\n public dispose() {\r\n this.cameras.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.cameras.length = 0;\r\n\r\n this.lights.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.lights.length = 0;\r\n\r\n this.meshes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.meshes.length = 0;\r\n\r\n this.skeletons.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.skeletons.length = 0;\r\n\r\n this.animationGroups.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.animationGroups.length = 0;\r\n\r\n this.multiMaterials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.multiMaterials.length = 0;\r\n\r\n this.materials.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.materials.length = 0;\r\n\r\n this.geometries.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.geometries.length = 0;\r\n\r\n this.transformNodes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.transformNodes.length = 0;\r\n\r\n this.actionManagers.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.actionManagers.length = 0;\r\n\r\n this.textures.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.textures.length = 0;\r\n\r\n this.reflectionProbes.slice(0).forEach((o) => {\r\n o.dispose();\r\n });\r\n this.reflectionProbes.length = 0;\r\n\r\n if (this.environmentTexture) {\r\n this.environmentTexture.dispose();\r\n this.environmentTexture = null;\r\n }\r\n\r\n for (const component of this.scene._serializableComponents) {\r\n component.removeFromContainer(this, true);\r\n }\r\n\r\n if (this._onContextRestoredObserver) {\r\n this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n this._onContextRestoredObserver = null;\r\n }\r\n }\r\n\r\n private _moveAssets<T>(sourceAssets: T[], targetAssets: T[], keepAssets: T[]): void {\r\n if (!sourceAssets || !targetAssets) {\r\n return;\r\n }\r\n\r\n for (const asset of sourceAssets) {\r\n let move = true;\r\n if (keepAssets) {\r\n for (const keepAsset of keepAssets) {\r\n if (asset === keepAsset) {\r\n move = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (move) {\r\n targetAssets.push(asset);\r\n (asset as any)._parentContainer = this;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes all the assets contained in the scene and adds them to the container.\r\n * @param keepAssets Set of assets to keep in the scene. (default: empty)\r\n */\r\n public moveAllFromScene(keepAssets?: KeepAssets): void {\r\n this._wasAddedToScene = false;\r\n\r\n if (keepAssets === undefined) {\r\n keepAssets = new KeepAssets();\r\n }\r\n\r\n for (const key in this) {\r\n if (Object.prototype.hasOwnProperty.call(this, key)) {\r\n (<any>this)[key] = (<any>this)[key] || (key === \"_environmentTexture\" ? null : []);\r\n this._moveAssets((<any>this.scene)[key], (<any>this)[key], (<any>keepAssets)[key]);\r\n }\r\n }\r\n\r\n this.environmentTexture = this.scene.environmentTexture;\r\n\r\n this.removeAllFromScene();\r\n }\r\n\r\n /**\r\n * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.\r\n * @returns the root mesh\r\n */\r\n public createRootMesh() {\r\n const rootMesh = new Mesh(\"assetContainerRootMesh\", this.scene);\r\n this.meshes.forEach((m) => {\r\n if (!m.parent) {\r\n rootMesh.addChild(m);\r\n }\r\n });\r\n this.meshes.unshift(rootMesh);\r\n return rootMesh;\r\n }\r\n\r\n /**\r\n * Merge animations (direct and animation groups) from this asset container into a scene\r\n * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)\r\n * @param animatables set of animatables to retarget to a node from the scene\r\n * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)\r\n * @returns an array of the new AnimationGroup added to the scene (empty array if none)\r\n */\r\n public mergeAnimationsTo(\r\n scene: Nullable<Scene> = EngineStore.LastCreatedScene,\r\n animatables: Animatable[],\r\n targetConverter: Nullable<(target: any) => Nullable<Node>> = null\r\n ): AnimationGroup[] {\r\n if (!scene) {\r\n Logger.Error(\"No scene available to merge animations to\");\r\n return [];\r\n }\r\n\r\n const _targetConverter = targetConverter\r\n ? targetConverter\r\n : (target: any) => {\r\n let node = null;\r\n\r\n const targetProperty = target.animations.length ? target.animations[0].targetProperty : \"\";\r\n /*\r\n BabylonJS adds special naming to targets that are children of nodes.\r\n This name attempts to remove that special naming to get the parent nodes name in case the target\r\n can't be found in the node tree\r\n\r\n Ex: Torso_primitive0 likely points to a Mesh primitive. We take away primitive0 and are left with \"Torso\" which is the name\r\n of the primitive's parent.\r\n */\r\n const name = target.name.split(\".\").join(\"\").split(\"_primitive\")[0];\r\n\r\n switch (targetProperty) {\r\n case \"position\":\r\n case \"rotationQuaternion\":\r\n node = scene.getTransformNodeByName(target.name) || scene.getTransformNodeByName(name);\r\n break;\r\n case \"influence\":\r\n node = scene.getMorphTargetByName(target.name) || scene.getMorphTargetByName(name);\r\n break;\r\n default:\r\n node = scene.getNodeByName(target.name) || scene.getNodeByName(name);\r\n }\r\n\r\n return node;\r\n };\r\n\r\n // Copy new node animations\r\n const nodesInAC = this.getNodes();\r\n nodesInAC.forEach((nodeInAC) => {\r\n const nodeInScene = _targetConverter(nodeInAC);\r\n if (nodeInScene !== null) {\r\n // Remove old animations with same target property as a new one\r\n for (const animationInAC of nodeInAC.animations) {\r\n // Doing treatment on an array for safety measure\r\n const animationsWithSameProperty = nodeInScene.animations.filter((animationInScene) => {\r\n return animationInScene.targetProperty === animationInAC.targetProperty;\r\n });\r\n for (const animationWithSameProperty of animationsWithSameProperty) {\r\n const index = nodeInScene.animations.indexOf(animationWithSameProperty, 0);\r\n if (index > -1) {\r\n nodeInScene.animations.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n // Append new animations\r\n nodeInScene.animations = nodeInScene.animations.concat(nodeInAC.animations);\r\n }\r\n });\r\n\r\n const newAnimationGroups = new Array<AnimationGroup>();\r\n\r\n // Copy new animation groups\r\n this.animationGroups.slice().forEach((animationGroupInAC) => {\r\n // Clone the animation group and all its animatables\r\n newAnimationGroups.push(animationGroupInAC.clone(animationGroupInAC.name, _targetConverter));\r\n\r\n // Remove animatables related to the asset container\r\n animationGroupInAC.animatables.forEach((animatable) => {\r\n animatable.stop();\r\n });\r\n });\r\n\r\n // Retarget animatables\r\n animatables.forEach((animatable) => {\r\n const target = _targetConverter(animatable.target);\r\n\r\n if (target) {\r\n // Clone the animatable and retarget it\r\n scene.beginAnimation(\r\n target,\r\n animatable.fromFrame,\r\n animatable.toFrame,\r\n animatable.loopAnimation,\r\n animatable.speedRatio,\r\n animatable.onAnimationEnd ? animatable.onAnimationEnd : undefined,\r\n undefined,\r\n true,\r\n undefined,\r\n animatable.onAnimationLoop ? animatable.onAnimationLoop : undefined\r\n );\r\n\r\n // Stop animation for the target in the asset container\r\n scene.stopAnimation(animatable.target);\r\n }\r\n });\r\n\r\n return newAnimationGroups;\r\n }\r\n}\r\n"]}
|