@onerjs/core 8.41.5 → 8.41.7
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/Animations/animation.d.ts +6 -2
- package/Animations/animation.js +28 -4
- package/Animations/animation.js.map +1 -1
- package/Animations/animationGroup.d.ts +2 -1
- package/Animations/animationGroup.js +3 -2
- package/Animations/animationGroup.js.map +1 -1
- package/Animations/animatorAvatar.d.ts +161 -0
- package/Animations/animatorAvatar.js +573 -0
- package/Animations/animatorAvatar.js.map +1 -0
- package/Animations/index.d.ts +1 -0
- package/Animations/index.js +1 -0
- package/Animations/index.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -2
- package/AudioV2/webAudio/webAudioSoundSource.js +12 -2
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/Bones/index.d.ts +1 -0
- package/Bones/index.js +1 -0
- package/Bones/index.js.map +1 -1
- package/Bones/skeleton.d.ts +13 -0
- package/Bones/skeleton.functions.d.ts +26 -0
- package/Bones/skeleton.functions.js +91 -0
- package/Bones/skeleton.functions.js.map +1 -0
- package/Bones/skeleton.js +26 -0
- package/Bones/skeleton.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +16 -0
- package/Cameras/Inputs/geospatialCameraPointersInput.js +19 -3
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Limits/geospatialLimits.d.ts +0 -6
- package/Cameras/Limits/geospatialLimits.js +0 -6
- package/Cameras/Limits/geospatialLimits.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +5 -0
- package/Cameras/geospatialCamera.js +54 -25
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +8 -1
- package/Cameras/geospatialCameraMovement.js +29 -8
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +11 -0
- package/Collisions/gpuPicker.js +148 -19
- package/Collisions/gpuPicker.js.map +1 -1
- package/Debug/skeletonViewer.d.ts +4 -8
- package/Debug/skeletonViewer.js +13 -22
- package/Debug/skeletonViewer.js.map +1 -1
- package/Engines/Extensions/engine.multiview.d.ts +2 -0
- package/Engines/Extensions/engine.multiview.js +7 -3
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -4
- package/Engines/webgpuEngine.js +8 -6
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/frameGraphContext.js +1 -1
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.js +2 -2
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/Instrumentation/engineInstrumentation.js +2 -1
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Layers/effectLayer.js +1 -3
- package/Layers/effectLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +2 -2
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +3 -4
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/lightingVolume.js +1 -1
- package/Lights/lightingVolume.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +37 -2
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +109 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +210 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +71 -15
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +86 -0
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +161 -0
- package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -0
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +0 -6
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +0 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +0 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +14 -0
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +14 -0
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +20 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +20 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/depthSourceBlock.d.ts +13 -0
- package/Materials/Node/Blocks/Dual/depthSourceBlock.js +13 -0
- package/Materials/Node/Blocks/Dual/depthSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.d.ts +21 -0
- package/Materials/Node/Blocks/Dual/fogBlock.js +21 -0
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.d.ts +21 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js +21 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.d.ts +38 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js +38 -0
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +29 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +29 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +5 -0
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +16 -0
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +16 -0
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +16 -0
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +16 -0
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +34 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js +34 -0
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +17 -0
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +17 -2
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.d.ts +7 -0
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js +7 -0
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +21 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +21 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +10 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +10 -0
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +28 -0
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +28 -0
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +30 -0
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +30 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.d.ts +4 -0
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +4 -0
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +5 -0
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.d.ts +3 -0
- package/Materials/Node/Blocks/Fragment/twirlBlock.js +3 -0
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.d.ts +6 -0
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -0
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.d.ts +16 -0
- package/Materials/Node/Blocks/Input/inputBlock.js +16 -1
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Input/prePassTextureBlock.js +5 -0
- package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +10 -0
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +10 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +23 -0
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +23 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.d.ts +17 -0
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +17 -0
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +41 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +41 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +21 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +21 -0
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +29 -0
- package/Materials/Node/Blocks/PBR/refractionBlock.js +29 -0
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.d.ts +14 -0
- package/Materials/Node/Blocks/PBR/sheenBlock.js +14 -0
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.d.ts +7 -0
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +7 -0
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.d.ts +23 -0
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +23 -0
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +6 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js +6 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.d.ts +17 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +17 -0
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.d.ts +22 -0
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +22 -0
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.d.ts +13 -0
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +13 -0
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +20 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +20 -0
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +27 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +27 -0
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.d.ts +10 -0
- package/Materials/Node/Blocks/clampBlock.js +10 -0
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.d.ts +10 -0
- package/Materials/Node/Blocks/cloudBlock.js +10 -0
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.d.ts +10 -0
- package/Materials/Node/Blocks/colorMergerBlock.js +10 -0
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.d.ts +14 -0
- package/Materials/Node/Blocks/conditionalBlock.js +14 -0
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/Blocks/curveBlock.d.ts +10 -0
- package/Materials/Node/Blocks/curveBlock.js +10 -0
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.d.ts +10 -0
- package/Materials/Node/Blocks/customBlock.js +10 -0
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/debugBlock.d.ts +10 -0
- package/Materials/Node/Blocks/debugBlock.js +10 -0
- package/Materials/Node/Blocks/debugBlock.js.map +1 -1
- package/Materials/Node/Blocks/fresnelBlock.d.ts +4 -0
- package/Materials/Node/Blocks/fresnelBlock.js +4 -0
- package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.d.ts +10 -0
- package/Materials/Node/Blocks/gradientBlock.js +10 -0
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/loopBlock.d.ts +10 -0
- package/Materials/Node/Blocks/loopBlock.js +10 -0
- package/Materials/Node/Blocks/loopBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.d.ts +1 -0
- package/Materials/Node/Blocks/matrixBuilderBlock.js +1 -0
- package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +10 -0
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +10 -0
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/pannerBlock.d.ts +5 -0
- package/Materials/Node/Blocks/pannerBlock.js +5 -0
- package/Materials/Node/Blocks/pannerBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.d.ts +10 -0
- package/Materials/Node/Blocks/remapBlock.js +10 -0
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.d.ts +1 -0
- package/Materials/Node/Blocks/rotate2dBlock.js +1 -0
- package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.d.ts +10 -0
- package/Materials/Node/Blocks/transformBlock.js +10 -0
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +22 -0
- package/Materials/Node/Blocks/triPlanarBlock.js +22 -0
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.d.ts +10 -0
- package/Materials/Node/Blocks/trigonometryBlock.js +10 -0
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.d.ts +10 -0
- package/Materials/Node/Blocks/vectorMergerBlock.js +10 -0
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.d.ts +5 -0
- package/Materials/Node/Blocks/viewDirectionBlock.js +5 -0
- package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.d.ts +10 -0
- package/Materials/Node/Blocks/waveBlock.js +10 -0
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.d.ts +1 -0
- package/Materials/Node/Blocks/worleyNoise3DBlock.js +1 -0
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +13 -0
- package/Materials/Node/nodeMaterial.js +14 -2
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +0 -3
- package/Materials/Node/nodeMaterialBlock.js +1 -6
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +1 -2
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +1 -1
- package/Materials/Textures/mirrorTexture.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/Maths/math.constants.d.ts +2 -1
- package/Maths/math.constants.js +3 -2
- package/Maths/math.constants.js.map +1 -1
- package/Meshes/Builders/capsuleBuilder.js +0 -3
- package/Meshes/Builders/capsuleBuilder.js.map +1 -1
- package/Meshes/Builders/cylinderBuilder.d.ts +1 -1
- package/Meshes/Builders/cylinderBuilder.js +1 -2
- package/Meshes/Builders/cylinderBuilder.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +2 -0
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/Builders/discBuilder.js +0 -1
- package/Meshes/Builders/discBuilder.js.map +1 -1
- package/Meshes/Builders/groundBuilder.d.ts +50 -54
- package/Meshes/Builders/groundBuilder.js +50 -54
- package/Meshes/Builders/groundBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.d.ts +0 -26
- package/Meshes/Builders/tiledBoxBuilder.js +0 -26
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.d.ts +0 -25
- package/Meshes/Builders/tiledPlaneBuilder.js +0 -25
- package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
- package/Meshes/Builders/torusBuilder.d.ts +0 -13
- package/Meshes/Builders/torusBuilder.js +0 -13
- package/Meshes/Builders/torusBuilder.js.map +1 -1
- package/Meshes/Builders/torusKnotBuilder.d.ts +0 -19
- package/Meshes/Builders/torusKnotBuilder.js +0 -19
- package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.types.d.ts +11 -0
- package/Meshes/Compression/dracoDecoder.types.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +0 -2
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +17 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +0 -8
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +1 -0
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/scalingBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js +1 -0
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/translationBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.js +1 -0
- package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/aggregatorBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -0
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/discBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js +1 -0
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/pointListBlock.d.ts +2 -1
- package/Meshes/Node/Blocks/Sources/pointListBlock.js +2 -1
- package/Meshes/Node/Blocks/Sources/pointListBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -0
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +1 -0
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.d.ts +3 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +3 -0
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +1 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/cleanGeometryBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/cleanGeometryBlock.js +1 -0
- package/Meshes/Node/Blocks/cleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/conditionBlock.js +2 -0
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryClampBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCollectionBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryCollectionBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/geometryCurveBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.d.ts +3 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js +3 -0
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.js +1 -0
- package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +2 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mappingBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/mappingBlock.js +1 -0
- package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/mathBlock.js +1 -0
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.js +1 -0
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/randomBlock.js +2 -0
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/Node/Blocks/subdivideBlock.d.ts +1 -0
- package/Meshes/Node/Blocks/subdivideBlock.js +1 -0
- package/Meshes/Node/Blocks/subdivideBlock.js.map +1 -1
- package/Meshes/Node/Interfaces/nodeGeometryTextureData.d.ts +3 -0
- package/Meshes/Node/Interfaces/nodeGeometryTextureData.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +0 -2
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +0 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/Node/nodeGeometryBuildState.js +0 -1
- package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
- package/Meshes/WebGL/webGLDataBuffer.d.ts +2 -0
- package/Meshes/WebGL/webGLDataBuffer.js +2 -0
- package/Meshes/WebGL/webGLDataBuffer.js.map +1 -1
- package/Meshes/WebGPU/webgpuDataBuffer.d.ts +4 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js +4 -0
- package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -0
- package/Meshes/abstractMesh.decalMap.d.ts +1 -0
- package/Meshes/abstractMesh.decalMap.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -6
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg.js +0 -6
- package/Meshes/csg.js.map +1 -1
- package/Meshes/csg2.js +1 -2
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geodesicMesh.d.ts +26 -0
- package/Meshes/geodesicMesh.js +18 -3
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/groundMesh.d.ts +1 -0
- package/Meshes/groundMesh.js +1 -0
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/index.js +0 -2
- package/Meshes/index.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +18 -3
- package/Meshes/instancedMesh.js +11 -3
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +291 -204
- package/Meshes/mesh.js +290 -213
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +15 -19
- package/Meshes/mesh.vertexData.js +15 -19
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/meshSimplification.d.ts +0 -1
- package/Meshes/meshSimplification.js +6 -1
- package/Meshes/meshSimplification.js.map +1 -1
- package/Meshes/meshSimplificationSceneComponent.d.ts +2 -0
- package/Meshes/meshSimplificationSceneComponent.js.map +1 -1
- package/Meshes/meshUVSpaceRenderer.d.ts +1 -0
- package/Meshes/meshUVSpaceRenderer.js.map +1 -1
- package/Meshes/polygonMesh.js +4 -0
- package/Meshes/polygonMesh.js.map +1 -1
- package/Meshes/subMesh.project.d.ts +1 -0
- package/Meshes/subMesh.project.js.map +1 -1
- package/Meshes/thinInstanceMesh.d.ts +5 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Meshes/transformNode.d.ts +1 -1
- package/Meshes/transformNode.js +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/dataStorage.d.ts +13 -0
- package/Misc/dataStorage.js +25 -0
- package/Misc/dataStorage.js.map +1 -1
- package/Morph/morphTarget.d.ts +9 -5
- package/Morph/morphTarget.js +15 -7
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +3 -1
- package/Morph/morphTargetManager.js +5 -2
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +3 -3
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js +7 -7
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +2 -2
- package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +7 -7
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +9 -4
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/particle.d.ts +73 -61
- package/Particles/particle.js +106 -91
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.js +5 -5
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.function.js +83 -83
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +8 -8
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +89 -3
- package/Physics/v2/Plugins/havokPlugin.js +388 -53
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Probes/reflectionProbe.js +10 -7
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +3 -1
- package/Rendering/objectRenderer.js +28 -8
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js +1 -1
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Rendering/thinDepthPeelingRenderer.js +8 -0
- package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +8 -2
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +8 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +7 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +8 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +22 -4
- package/scene.js +33 -20
- package/scene.js.map +1 -1
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { Vector3, Quaternion, TmpVectors, Matrix } from "../Maths/math.vector.js";
|
|
2
|
+
import { Logger } from "../Misc/logger.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents an animator avatar that manages skeletons and morph target managers for a hierarchical transform node and mesh structure.
|
|
5
|
+
* This class is used to group and manage animation-related resources (skeletons and morph targets) associated with a root transform node and its descendants.
|
|
6
|
+
*/
|
|
7
|
+
export class AnimatorAvatar {
|
|
8
|
+
/**
|
|
9
|
+
* Map of morph target names to their corresponding MorphTarget instances.
|
|
10
|
+
* The keys are constructed using the format "meshName_morphTargetName".
|
|
11
|
+
*/
|
|
12
|
+
get mapMorphTargetNameToMorphTarget() {
|
|
13
|
+
if (!this._mapMorphTargetNameToMorphTarget) {
|
|
14
|
+
this._buildMorphTargetMap();
|
|
15
|
+
}
|
|
16
|
+
return this._mapMorphTargetNameToMorphTarget;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates an instance of AnimatorAvatar.
|
|
20
|
+
* @param name - The name to assign to this avatar and its root node
|
|
21
|
+
* @param rootNode - The root node of the avatar hierarchy. This node and its descendants will be scanned for skeletons and morph target managers. If not provided, you are expected to manually manage skeletons and morph target managers.
|
|
22
|
+
* @param _disposeResources - Indicates whether to dispose of resources (skeletons, morph target managers, root node and descendants + materials and textures) when the avatar is disposed (true by default)
|
|
23
|
+
*/
|
|
24
|
+
constructor(name, rootNode, _disposeResources = true) {
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.rootNode = rootNode;
|
|
27
|
+
this._disposeResources = _disposeResources;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates whether to show warnings during retargeting operations.
|
|
30
|
+
*/
|
|
31
|
+
this.showWarnings = true;
|
|
32
|
+
this.skeletons = new Set();
|
|
33
|
+
this.morphTargetManagers = new Set();
|
|
34
|
+
if (!rootNode) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
rootNode.name = name;
|
|
38
|
+
if (!rootNode.rotationQuaternion) {
|
|
39
|
+
rootNode.rotationQuaternion = new Quaternion();
|
|
40
|
+
}
|
|
41
|
+
rootNode
|
|
42
|
+
.getChildMeshes(false, (node) => {
|
|
43
|
+
const mesh = node;
|
|
44
|
+
return mesh.getTotalVertices && mesh.getTotalVertices() > 0;
|
|
45
|
+
})
|
|
46
|
+
.forEach((mesh) => {
|
|
47
|
+
if (mesh.skeleton) {
|
|
48
|
+
this.skeletons.add(mesh.skeleton);
|
|
49
|
+
}
|
|
50
|
+
if (mesh.morphTargetManager) {
|
|
51
|
+
mesh.morphTargetManager.meshName = mesh.name;
|
|
52
|
+
mesh.morphTargetManager.numMaxInfluencers = mesh.morphTargetManager.numTargets;
|
|
53
|
+
this.morphTargetManagers.add(mesh.morphTargetManager);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
this._computeBoneWorldMatrices();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Finds a bone in the avatar's skeletons by its linked transform node or the name of the linked transform node.
|
|
60
|
+
* @param nameOrTransformNode The linked transform node or the name of the linked transform node
|
|
61
|
+
* @returns The found bone or null if not found
|
|
62
|
+
*/
|
|
63
|
+
findBone(nameOrTransformNode) {
|
|
64
|
+
const isName = !this._isTransformNode(nameOrTransformNode);
|
|
65
|
+
const iterator = this.skeletons.keys();
|
|
66
|
+
let bone = null;
|
|
67
|
+
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
68
|
+
const skeleton = key.value;
|
|
69
|
+
if (isName) {
|
|
70
|
+
bone = skeleton.findBoneFromLinkedTransformNodeName(nameOrTransformNode);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
bone = skeleton.findBoneFromLinkedTransformNode(nameOrTransformNode);
|
|
74
|
+
}
|
|
75
|
+
if (bone) {
|
|
76
|
+
return bone;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Make sures that the animation group passed as the first parameter will animate the bones in the skeleton(s) / the morphs in the morph target manager(s) of the avatar.
|
|
83
|
+
* Retargeting is based on the names of the targets (TransformNode or MorphTarget) in the animation and the names of the bones in the skeleton / morph targets in the morph target manager.
|
|
84
|
+
* Note that you can use the mapNodeNames option to specify a mapping between source transform node names and target bone names in case they are different.
|
|
85
|
+
* If no bones with the same name as a target (TransformNode) of a targeted animation are found, the targeted animation is removed from the animation group.
|
|
86
|
+
* Same for morph targets.
|
|
87
|
+
* Note that for the time being, we only support a source animation group which animates transform nodes, not bones!
|
|
88
|
+
* That's typically the case when the source animation group is created from a glTF file, as glTF animations always target transform nodes.
|
|
89
|
+
* @param sourceAnimationGroup The animation group to retarget
|
|
90
|
+
* @param options Options for retargeting the animation group (optional)
|
|
91
|
+
* @returns The retargeted (new) animation group
|
|
92
|
+
*/
|
|
93
|
+
retargetAnimationGroup(sourceAnimationGroup, options) {
|
|
94
|
+
const localOptions = {
|
|
95
|
+
animationGroupName: sourceAnimationGroup.name,
|
|
96
|
+
fixAnimations: true,
|
|
97
|
+
checkHierarchy: true,
|
|
98
|
+
retargetAnimationKeys: true,
|
|
99
|
+
fixGroundReference: true,
|
|
100
|
+
fixRootPosition: true,
|
|
101
|
+
...options,
|
|
102
|
+
};
|
|
103
|
+
// Make sure that all world matrices are up to date, both in the bone hierarchy and in the animation transform node hierarchy
|
|
104
|
+
this._computeBoneWorldMatrices();
|
|
105
|
+
const mapNodeNames = localOptions.mapNodeNames ?? new Map();
|
|
106
|
+
const lstTransformNodes = new Set();
|
|
107
|
+
const sourceTransformNodeNameToNode = new Map();
|
|
108
|
+
for (let i = 0; i < sourceAnimationGroup.targetedAnimations.length; ++i) {
|
|
109
|
+
const ta = sourceAnimationGroup.targetedAnimations[i];
|
|
110
|
+
if (ta.target.getClassName?.() === "TransformNode" && !lstTransformNodes.has(ta.target)) {
|
|
111
|
+
const tn = ta.target;
|
|
112
|
+
lstTransformNodes.add(tn);
|
|
113
|
+
if (!tn.rotationQuaternion) {
|
|
114
|
+
tn.rotationQuaternion = Quaternion.FromEulerAngles(tn.rotation.x, tn.rotation.y, tn.rotation.z);
|
|
115
|
+
tn.rotation.setAll(0);
|
|
116
|
+
}
|
|
117
|
+
sourceTransformNodeNameToNode.set(mapNodeNames.get(tn.name) ?? tn.name, {
|
|
118
|
+
node: tn,
|
|
119
|
+
initialTransformations: {
|
|
120
|
+
position: tn.position.clone(),
|
|
121
|
+
scaling: tn.scaling.clone(),
|
|
122
|
+
quaternion: tn.rotationQuaternion.clone(),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
lstTransformNodes.forEach((node) => {
|
|
128
|
+
node.computeWorldMatrix(true);
|
|
129
|
+
});
|
|
130
|
+
// Clone the source animation and retarget it
|
|
131
|
+
const animationGroup = sourceAnimationGroup.clone(localOptions.animationGroupName, undefined, true, true);
|
|
132
|
+
const mapTransformNodeToRootNode = new Map();
|
|
133
|
+
const lstAnims = new Set();
|
|
134
|
+
for (let i = 0; i < animationGroup.targetedAnimations.length; ++i) {
|
|
135
|
+
const ta = animationGroup.targetedAnimations[i];
|
|
136
|
+
const animation = ta.animation;
|
|
137
|
+
if (lstAnims.has(animation)) {
|
|
138
|
+
if (this.showWarnings) {
|
|
139
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': animation '${animation.name}' is used multiple times in the same animation group: duplicated animations are not supported, the retargeted animation may not work as expected.`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
lstAnims.add(animation);
|
|
143
|
+
switch (animation.targetProperty) {
|
|
144
|
+
case "influence": {
|
|
145
|
+
if (!this._retargetMorphTarget(ta, animationGroup.name)) {
|
|
146
|
+
animationGroup.targetedAnimations.splice(i, 1);
|
|
147
|
+
i--;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case "position":
|
|
152
|
+
case "rotationQuaternion":
|
|
153
|
+
case "scaling": {
|
|
154
|
+
if (ta.target.getClassName?.() !== "TransformNode") {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
const sourceTransformNode = ta.target;
|
|
158
|
+
const sourceTransformNodeName = mapNodeNames.get(sourceTransformNode.name) ?? sourceTransformNode.name;
|
|
159
|
+
const targetBone = this.findBone(sourceTransformNodeName);
|
|
160
|
+
if (!targetBone) {
|
|
161
|
+
if (this.showWarnings) {
|
|
162
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': "${sourceTransformNodeName}" bone not found in any skeleton of avatar: animation removed.`);
|
|
163
|
+
animationGroup.targetedAnimations.splice(i, 1);
|
|
164
|
+
i--;
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (!targetBone._linkedTransformNode) {
|
|
169
|
+
if (this.showWarnings) {
|
|
170
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': bone "${targetBone.name}" has no linked transform node: skipping retargeting.`);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (!this._retargetTransformNodeToBone(ta, sourceTransformNode, targetBone, animationGroup.name, mapTransformNodeToRootNode, mapNodeNames, !!localOptions.checkHierarchy)) {
|
|
175
|
+
animationGroup.targetedAnimations.splice(i, 1);
|
|
176
|
+
i--;
|
|
177
|
+
}
|
|
178
|
+
else if (localOptions.retargetAnimationKeys) {
|
|
179
|
+
this._retargetAnimationKeys(ta.animation, sourceTransformNode, targetBone);
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (localOptions.fixAnimations) {
|
|
186
|
+
this._fixAnimationGroup(animationGroup);
|
|
187
|
+
}
|
|
188
|
+
if (localOptions.fixGroundReference || localOptions.fixRootPosition) {
|
|
189
|
+
const msg = localOptions.fixGroundReference && localOptions.fixRootPosition
|
|
190
|
+
? "Ground reference and root position fixing processes skipped."
|
|
191
|
+
: localOptions.fixGroundReference
|
|
192
|
+
? "Ground reference fixing process skipped."
|
|
193
|
+
: "Root position fixing process skipped.";
|
|
194
|
+
const res = this._findVerticalAxis(msg, animationGroup, mapNodeNames.get(localOptions.rootNodeName) ?? localOptions.rootNodeName, sourceTransformNodeNameToNode, mapNodeNames.get(localOptions.groundReferenceNodeName) ?? localOptions.groundReferenceNodeName, localOptions.groundReferenceVerticalAxis);
|
|
195
|
+
if (res) {
|
|
196
|
+
const { verticalAxis, sourceRootTransformNode, targetRootTransformNode, targetRootPositionAnimation, sourceGroundReferenceTransformNode, targetGroundReferenceTransformNode, proportionRatio, } = res;
|
|
197
|
+
if (localOptions.fixRootPosition) {
|
|
198
|
+
this._fixRootPosition(sourceAnimationGroup, animationGroup, sourceRootTransformNode, targetRootTransformNode, targetRootPositionAnimation, proportionRatio);
|
|
199
|
+
this._resetStates(sourceTransformNodeNameToNode);
|
|
200
|
+
}
|
|
201
|
+
if (localOptions.fixGroundReference) {
|
|
202
|
+
this._fixGroundReference(sourceAnimationGroup, animationGroup, verticalAxis, targetRootTransformNode, targetRootPositionAnimation, sourceGroundReferenceTransformNode, targetGroundReferenceTransformNode);
|
|
203
|
+
this._resetStates(sourceTransformNodeNameToNode);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return animationGroup;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Disposes of the avatar and releases all associated resources.
|
|
211
|
+
* This will dispose all skeletons, morph target managers, and the root mesh with its descendants (including materials and textures).
|
|
212
|
+
* If disposeResources was set to false in the constructor, this method does nothing.
|
|
213
|
+
*/
|
|
214
|
+
dispose() {
|
|
215
|
+
if (!this._disposeResources) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const iterator = this.skeletons.keys();
|
|
219
|
+
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
220
|
+
key.value.dispose();
|
|
221
|
+
}
|
|
222
|
+
const iterator2 = this.morphTargetManagers.keys();
|
|
223
|
+
for (let key = iterator2.next(); key.done !== true; key = iterator2.next()) {
|
|
224
|
+
key.value.dispose();
|
|
225
|
+
}
|
|
226
|
+
this.rootNode?.dispose(false, true);
|
|
227
|
+
}
|
|
228
|
+
_computeBoneWorldMatrices() {
|
|
229
|
+
this.skeletons.forEach((skeleton) => {
|
|
230
|
+
skeleton.bones.forEach((bone) => {
|
|
231
|
+
bone._linkedTransformNode?.computeWorldMatrix(true);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
_isTransformNode(nameOrTransformNode) {
|
|
236
|
+
return typeof nameOrTransformNode !== "string";
|
|
237
|
+
}
|
|
238
|
+
_buildMorphTargetMap() {
|
|
239
|
+
this._mapMorphTargetNameToMorphTarget = new Map();
|
|
240
|
+
this.morphTargetManagers.forEach((manager) => {
|
|
241
|
+
const numTargets = manager.numTargets;
|
|
242
|
+
for (let t = 0; t < numTargets; ++t) {
|
|
243
|
+
const target = manager.getTarget(t);
|
|
244
|
+
const key = manager.meshName + "_" + target.name;
|
|
245
|
+
this._mapMorphTargetNameToMorphTarget.set(key, target);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
_retargetMorphTarget(ta, animationGroupName) {
|
|
250
|
+
const morphTarget = ta.target;
|
|
251
|
+
const key = morphTarget.morphTargetManager?.meshName + "_" + morphTarget.name;
|
|
252
|
+
if (!this.mapMorphTargetNameToMorphTarget.has(key)) {
|
|
253
|
+
if (this.showWarnings) {
|
|
254
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroupName}': "${morphTarget.name}" morph target not found in morph target manager of mesh "${morphTarget.morphTargetManager?.meshName}": animation removed`);
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
ta.target = this.mapMorphTargetNameToMorphTarget.get(key);
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
_retargetTransformNodeToBone(ta, sourceTransformNode, targetBone, animationGroupName, mapTransformNodeToRootNode, mapNodeNames, checkHierarchy) {
|
|
262
|
+
if (checkHierarchy) {
|
|
263
|
+
let rootNode = mapTransformNodeToRootNode.get(sourceTransformNode);
|
|
264
|
+
if (!rootNode) {
|
|
265
|
+
rootNode = this._getRootNode(sourceTransformNode);
|
|
266
|
+
mapTransformNodeToRootNode.set(sourceTransformNode, rootNode);
|
|
267
|
+
}
|
|
268
|
+
if (!this._checkParentHierarchy(targetBone, rootNode, mapNodeNames)) {
|
|
269
|
+
if (this.showWarnings) {
|
|
270
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroupName}': parent hierarchy mismatch between bone "${targetBone.name}" and transform node "${sourceTransformNode.name}": animation removed`);
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
ta.target = targetBone._linkedTransformNode;
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
_retargetAnimationKeys(animation, sourceTransformNode, targetBone) {
|
|
279
|
+
const keys = animation.getKeys();
|
|
280
|
+
const targetTransformNode = targetBone._linkedTransformNode;
|
|
281
|
+
const targetWorldMatrix = targetTransformNode.getWorldMatrix();
|
|
282
|
+
const targetParentWorldMatrix = targetTransformNode.parent ? targetTransformNode.parent.getWorldMatrix() : Matrix.IdentityReadOnly;
|
|
283
|
+
const targetParentInverseWorldMatrix = targetParentWorldMatrix.invertToRef(TmpVectors.Matrix[0]);
|
|
284
|
+
const sourceInverseWorld = sourceTransformNode.getWorldMatrix().invertToRef(TmpVectors.Matrix[1]);
|
|
285
|
+
const sourceParentWorld = sourceTransformNode.parent ? sourceTransformNode.parent.getWorldMatrix() : Matrix.IdentityReadOnly;
|
|
286
|
+
switch (animation.targetProperty) {
|
|
287
|
+
case "rotationQuaternion": {
|
|
288
|
+
for (const key of keys) {
|
|
289
|
+
const quaternion = key.value;
|
|
290
|
+
const localMat = Matrix.ComposeToRef(sourceTransformNode.scaling, quaternion, sourceTransformNode.position, TmpVectors.Matrix[2]);
|
|
291
|
+
sourceInverseWorld.multiplyToRef(localMat, localMat).multiplyToRef(sourceParentWorld, localMat);
|
|
292
|
+
targetWorldMatrix.multiplyToRef(localMat, localMat).multiplyToRef(targetParentInverseWorldMatrix, localMat).decompose(undefined, quaternion, undefined);
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case "position": {
|
|
297
|
+
for (const key of keys) {
|
|
298
|
+
const position = key.value;
|
|
299
|
+
const localMat = Matrix.ComposeToRef(sourceTransformNode.scaling, sourceTransformNode.rotationQuaternion, position, TmpVectors.Matrix[2]);
|
|
300
|
+
sourceInverseWorld.multiplyToRef(localMat, localMat).multiplyToRef(sourceParentWorld, localMat);
|
|
301
|
+
targetWorldMatrix.multiplyToRef(localMat, localMat).multiplyToRef(targetParentInverseWorldMatrix, localMat).decompose(undefined, undefined, position);
|
|
302
|
+
}
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
case "scaling": {
|
|
306
|
+
for (const key of keys) {
|
|
307
|
+
const scaling = key.value;
|
|
308
|
+
const localMat = Matrix.ComposeToRef(scaling, sourceTransformNode.rotationQuaternion, sourceTransformNode.position, TmpVectors.Matrix[2]);
|
|
309
|
+
sourceInverseWorld.multiplyToRef(localMat, localMat).multiplyToRef(sourceParentWorld, localMat);
|
|
310
|
+
targetWorldMatrix.multiplyToRef(localMat, localMat).multiplyToRef(targetParentInverseWorldMatrix, localMat).decompose(scaling, undefined, undefined);
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* This method does two things:
|
|
318
|
+
* - It deletes a targeted animation if a bone corresponding to the target cannot be found
|
|
319
|
+
* - It corrects quaternion animations when two consecutive quaternions are orthogonal to each other. When this happens, in 99.99% of cases it's an error
|
|
320
|
+
* in the animation data, as two consecutive rotations should normally be close to each other and not have a large gap.
|
|
321
|
+
* The fix is to copy the first quaternion into the second.
|
|
322
|
+
* @param animationGroup The animation group to fix
|
|
323
|
+
* @internal
|
|
324
|
+
*/
|
|
325
|
+
_fixAnimationGroup(animationGroup) {
|
|
326
|
+
for (let i = 0; i < animationGroup.targetedAnimations.length; ++i) {
|
|
327
|
+
const ta = animationGroup.targetedAnimations[i];
|
|
328
|
+
switch (ta.animation.targetProperty) {
|
|
329
|
+
case "position":
|
|
330
|
+
case "rotationQuaternion":
|
|
331
|
+
case "scaling": {
|
|
332
|
+
if (ta.target.getClassName() !== "TransformNode") {
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
const transformNode = ta.target;
|
|
336
|
+
const bone = this.findBone(transformNode);
|
|
337
|
+
if (!bone) {
|
|
338
|
+
if (this.showWarnings) {
|
|
339
|
+
Logger.Warn(`FixAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': no bone in any skeleton of the avatar ${this.name} animates the transform node ${transformNode.name}: animation removed`);
|
|
340
|
+
}
|
|
341
|
+
animationGroup.targetedAnimations.splice(i, 1);
|
|
342
|
+
i--;
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
ta.target = bone._linkedTransformNode;
|
|
346
|
+
if (ta.animation.targetProperty === "rotationQuaternion") {
|
|
347
|
+
this._fixAnimationQuaternion(ta.animation);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
_fixAnimationQuaternion(animation, epsilon = 0.001) {
|
|
354
|
+
const keys = animation.getKeys();
|
|
355
|
+
for (let i = 0; i < keys.length - 1; ++i) {
|
|
356
|
+
const curQuat = keys[i].value;
|
|
357
|
+
const nextQuat = keys[i + 1].value;
|
|
358
|
+
if (Math.abs(Quaternion.Dot(curQuat, nextQuat)) < epsilon) {
|
|
359
|
+
keys[i + 1].value = curQuat.clone();
|
|
360
|
+
i += 1;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
_getRootNode(node) {
|
|
365
|
+
let current = node;
|
|
366
|
+
while (current.parent) {
|
|
367
|
+
current = current.parent;
|
|
368
|
+
}
|
|
369
|
+
return current;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Checks whether the parent hierarchy of a bone matches that of a given transform node. Checks are performed by name.
|
|
373
|
+
* It works by first finding the transform node in the descendants of the root transform node that matches the bone's linked transform node.
|
|
374
|
+
* Then it traverses up the hierarchy of both the bone and the transform node, comparing their names at each level.
|
|
375
|
+
* @param bone The bone to check
|
|
376
|
+
* @param rootTransformNode The root transform node to check against
|
|
377
|
+
* @returns True if the hierarchies match, false otherwise
|
|
378
|
+
* @internal
|
|
379
|
+
*/
|
|
380
|
+
_checkParentHierarchy(bone, rootTransformNode, mapNodeNames) {
|
|
381
|
+
const children = rootTransformNode.getDescendants(false, (node) => (mapNodeNames.get(node.name) ?? node.name) === bone._linkedTransformNode.name);
|
|
382
|
+
if (!children || children.length !== 1) {
|
|
383
|
+
if (this.showWarnings) {
|
|
384
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', CheckParentHierarchy: unable to find a corresponding transform node to bone name ${bone._linkedTransformNode.name} in the source animation.`);
|
|
385
|
+
}
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
let transformNode = children[0];
|
|
389
|
+
while (bone) {
|
|
390
|
+
const name = mapNodeNames.get(transformNode?.name ?? "") ?? transformNode?.name;
|
|
391
|
+
if (bone._linkedTransformNode.name !== name) {
|
|
392
|
+
if (this.showWarnings) {
|
|
393
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', CheckParentHierarchy: bone name ${bone._linkedTransformNode.name} is different from transform node name ${name}.`);
|
|
394
|
+
}
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
bone = bone.parent;
|
|
398
|
+
transformNode = transformNode.parent;
|
|
399
|
+
}
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
_getRootNodeName(rootNodeName, transformNodeNameToNode) {
|
|
403
|
+
if (rootNodeName) {
|
|
404
|
+
return rootNodeName;
|
|
405
|
+
}
|
|
406
|
+
// Look for the first bone that doesn't have a parent
|
|
407
|
+
const iterator = this.skeletons.keys();
|
|
408
|
+
for (let key = iterator.next(); key.done !== true; key = iterator.next()) {
|
|
409
|
+
const skeleton = key.value;
|
|
410
|
+
for (const bone of skeleton.bones) {
|
|
411
|
+
if (!bone.parent) {
|
|
412
|
+
// Make sure there's a transform node with that name in the source animation
|
|
413
|
+
if (transformNodeNameToNode.get(bone.name)) {
|
|
414
|
+
return bone.name;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
_findVerticalAxis(msg, animationGroup, remappedRootNodeName, sourceTransformNodeNameToNode, remappedGroundReferenceNodeName, groundReferenceVerticalAxis) {
|
|
422
|
+
if (!remappedGroundReferenceNodeName) {
|
|
423
|
+
if (this.showWarnings) {
|
|
424
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': you must provide the name of the ground reference node (option parameter "groundReferenceNodeName"). ${msg}`);
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
remappedRootNodeName = this._getRootNodeName(remappedRootNodeName, sourceTransformNodeNameToNode);
|
|
429
|
+
if (!remappedRootNodeName) {
|
|
430
|
+
if (this.showWarnings) {
|
|
431
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': unable to find a suitable root node in the source animation. You should provide its name through the "rootNodeName" optional parameter. ${msg}`);
|
|
432
|
+
}
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
const sourceRootTransformNode = sourceTransformNodeNameToNode.get(remappedRootNodeName)?.node;
|
|
436
|
+
const sourceGroundReferenceTransformNode = sourceTransformNodeNameToNode.get(remappedGroundReferenceNodeName)?.node;
|
|
437
|
+
if (!sourceRootTransformNode) {
|
|
438
|
+
if (this.showWarnings) {
|
|
439
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': unable to find the transform node corresponding to "${remappedRootNodeName}" in the source animation. This transform node either doesn't exist or is not animated. ${msg}`);
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
if (!sourceGroundReferenceTransformNode) {
|
|
444
|
+
if (this.showWarnings) {
|
|
445
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': unable to find the transform node corresponding to "${remappedGroundReferenceNodeName}" in the source animation. This transform node either doesn't exist or is not animated. ${msg}`);
|
|
446
|
+
}
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
// Look for the position animation + target node of the root node name (generally the hips) in the retargeted animation
|
|
450
|
+
let targetRootPositionAnimation;
|
|
451
|
+
let targetRootTransformNode;
|
|
452
|
+
for (let i = 0; i < animationGroup.targetedAnimations.length; ++i) {
|
|
453
|
+
const ta = animationGroup.targetedAnimations[i];
|
|
454
|
+
const target = ta.target;
|
|
455
|
+
const animation = ta.animation;
|
|
456
|
+
if (target.name === remappedRootNodeName && animation.targetProperty === "position") {
|
|
457
|
+
targetRootPositionAnimation = animation;
|
|
458
|
+
targetRootTransformNode = ta.target;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (!targetRootPositionAnimation || !targetRootTransformNode) {
|
|
463
|
+
if (this.showWarnings) {
|
|
464
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': unable to find a "position" animation for the node "${remappedRootNodeName}". ${msg}`);
|
|
465
|
+
}
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
const targetGroundReferenceTransformNode = this.findBone(remappedGroundReferenceNodeName)?._linkedTransformNode;
|
|
469
|
+
if (!targetGroundReferenceTransformNode) {
|
|
470
|
+
if (this.showWarnings) {
|
|
471
|
+
Logger.Warn(`RetargetAnimationGroup - Avatar '${this.name}', AnimationGroup '${animationGroup.name}': unable to find the transform node corresponding to the bone "${remappedGroundReferenceNodeName}" in the avatar skeleton. Ensure that this bone exists and is linked to a transform node. ${msg}`);
|
|
472
|
+
}
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
sourceRootTransformNode.computeWorldMatrix(true);
|
|
476
|
+
sourceGroundReferenceTransformNode.computeWorldMatrix(true);
|
|
477
|
+
// Determine the vertical axis
|
|
478
|
+
const sourceRootGroundReferenceDiff = sourceRootTransformNode.getAbsolutePosition().subtract(sourceGroundReferenceTransformNode.getAbsolutePosition());
|
|
479
|
+
let verticalAxis = 0;
|
|
480
|
+
if (groundReferenceVerticalAxis) {
|
|
481
|
+
switch (groundReferenceVerticalAxis) {
|
|
482
|
+
case "Y":
|
|
483
|
+
verticalAxis = 1;
|
|
484
|
+
break;
|
|
485
|
+
case "Z":
|
|
486
|
+
verticalAxis = 2;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
// No axis provided: assume the vertical axis is the one with the larger difference between the reference and the ground reference transform nodes
|
|
492
|
+
if (Math.abs(sourceRootGroundReferenceDiff.y) > Math.abs(sourceRootGroundReferenceDiff.x)) {
|
|
493
|
+
verticalAxis = 1;
|
|
494
|
+
}
|
|
495
|
+
if (Math.abs(sourceRootGroundReferenceDiff.z) > Math.abs(sourceRootGroundReferenceDiff.y)) {
|
|
496
|
+
verticalAxis = 2;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const targetRootGroundReferenceDiff = targetRootTransformNode.getAbsolutePosition().subtract(targetGroundReferenceTransformNode.getAbsolutePosition());
|
|
500
|
+
return {
|
|
501
|
+
verticalAxis,
|
|
502
|
+
sourceRootTransformNode,
|
|
503
|
+
sourceGroundReferenceTransformNode,
|
|
504
|
+
targetRootTransformNode,
|
|
505
|
+
targetRootPositionAnimation,
|
|
506
|
+
targetGroundReferenceTransformNode,
|
|
507
|
+
proportionRatio: verticalAxis === 0
|
|
508
|
+
? targetRootGroundReferenceDiff.x / sourceRootGroundReferenceDiff.x
|
|
509
|
+
: verticalAxis === 1
|
|
510
|
+
? targetRootGroundReferenceDiff.y / sourceRootGroundReferenceDiff.y
|
|
511
|
+
: targetRootGroundReferenceDiff.z / sourceRootGroundReferenceDiff.z,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
_resetStates(sourceTransformNodeNameToNode) {
|
|
515
|
+
this.skeletons.forEach((skeleton) => skeleton.returnToRest());
|
|
516
|
+
sourceTransformNodeNameToNode.forEach((data) => {
|
|
517
|
+
const { node, initialTransformations } = data;
|
|
518
|
+
node.position = initialTransformations.position;
|
|
519
|
+
node.scaling = initialTransformations.scaling;
|
|
520
|
+
node.rotationQuaternion = initialTransformations.quaternion;
|
|
521
|
+
node.computeWorldMatrix(true);
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
_fixRootPosition(sourceAnimationGroup, animationGroup, sourceRootTransformNode, targetRootTransformNode, targetRootPositionAnimation, proportionRatio) {
|
|
525
|
+
const targetNodeInverseParentWorldMatrix = targetRootTransformNode.parent?.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]) ?? Matrix.IdentityReadOnly;
|
|
526
|
+
sourceRootTransformNode.computeWorldMatrix(true);
|
|
527
|
+
targetRootTransformNode.computeWorldMatrix(true);
|
|
528
|
+
const sourceWorldPosition = sourceRootTransformNode.absolutePosition.clone();
|
|
529
|
+
const targetWorldPosition = targetRootTransformNode.absolutePosition.clone();
|
|
530
|
+
sourceAnimationGroup.play(false);
|
|
531
|
+
animationGroup.play(false);
|
|
532
|
+
// Loop over the position animation of the root transform node
|
|
533
|
+
for (const key of targetRootPositionAnimation.getKeys()) {
|
|
534
|
+
const frame = key.frame;
|
|
535
|
+
// Advance the source and retargeted animations to this frame
|
|
536
|
+
sourceAnimationGroup.goToFrame(frame);
|
|
537
|
+
sourceAnimationGroup.pause();
|
|
538
|
+
animationGroup.goToFrame(frame);
|
|
539
|
+
animationGroup.pause();
|
|
540
|
+
sourceRootTransformNode.computeWorldMatrix(true);
|
|
541
|
+
const offset = sourceRootTransformNode.absolutePosition.subtractToRef(sourceWorldPosition, TmpVectors.Vector3[0]);
|
|
542
|
+
offset.scaleInPlace(proportionRatio);
|
|
543
|
+
offset.addInPlace(targetWorldPosition);
|
|
544
|
+
Vector3.TransformNormalToRef(offset, targetNodeInverseParentWorldMatrix, key.value);
|
|
545
|
+
}
|
|
546
|
+
sourceAnimationGroup.stop();
|
|
547
|
+
animationGroup.stop();
|
|
548
|
+
}
|
|
549
|
+
_fixGroundReference(sourceAnimationGroup, animationGroup, verticalAxis, targetRootTransformNode, targetRootPositionAnimation, sourceGroundReferenceTransformNode, targetGroundReferenceTransformNode) {
|
|
550
|
+
const targetNodeInverseParentWorldMatrix = targetRootTransformNode.parent?.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]) ?? Matrix.IdentityReadOnly;
|
|
551
|
+
sourceAnimationGroup.play(false);
|
|
552
|
+
animationGroup.play(false);
|
|
553
|
+
// Loop over the position animation of the root transform node
|
|
554
|
+
for (const key of targetRootPositionAnimation.getKeys()) {
|
|
555
|
+
const frame = key.frame;
|
|
556
|
+
// Advance the source and retargeted animations to this frame
|
|
557
|
+
sourceAnimationGroup.goToFrame(frame);
|
|
558
|
+
sourceAnimationGroup.pause();
|
|
559
|
+
animationGroup.goToFrame(frame);
|
|
560
|
+
animationGroup.pause();
|
|
561
|
+
sourceGroundReferenceTransformNode.computeWorldMatrix(true);
|
|
562
|
+
targetGroundReferenceTransformNode.computeWorldMatrix(true);
|
|
563
|
+
// Calculate the offset to apply to the root position in the target to have the ground reference at the same height in the source and target animations
|
|
564
|
+
const diffGroundReferences = targetGroundReferenceTransformNode.absolutePosition.subtractToRef(sourceGroundReferenceTransformNode.absolutePosition, TmpVectors.Vector3[0]);
|
|
565
|
+
const offset = verticalAxis === 0 ? diffGroundReferences.x : verticalAxis === 1 ? diffGroundReferences.y : diffGroundReferences.z;
|
|
566
|
+
const localOffset = Vector3.TransformNormalToRef(new Vector3(verticalAxis === 0 ? offset : 0, verticalAxis === 1 ? offset : 0, verticalAxis === 2 ? offset : 0), targetNodeInverseParentWorldMatrix, TmpVectors.Vector3[1]);
|
|
567
|
+
key.value.subtractInPlace(localOffset);
|
|
568
|
+
}
|
|
569
|
+
sourceAnimationGroup.stop();
|
|
570
|
+
animationGroup.stop();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
//# sourceMappingURL=animatorAvatar.js.map
|