@babylonjs/core 7.43.0 → 7.44.1
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/Actions/actionEvent.d.ts +4 -4
- package/Buffers/bufferUtils.d.ts +8 -1
- package/Buffers/bufferUtils.js +15 -0
- package/Buffers/bufferUtils.js.map +1 -1
- package/Culling/Helper/boundingInfoHelper.d.ts +2 -9
- package/Culling/Helper/boundingInfoHelper.js +2 -9
- package/Culling/Helper/boundingInfoHelper.js.map +1 -1
- package/Debug/debugLayer.d.ts +4 -0
- package/Debug/debugLayer.js +9 -0
- package/Debug/debugLayer.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +2 -4
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -4
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/abstractEngine.d.ts +19 -1
- package/Engines/abstractEngine.js +48 -9
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +6 -3
- package/Engines/engine.js +2 -20
- package/Engines/engine.js.map +1 -1
- package/Engines/renderTargetWrapper.js +2 -2
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.js +1 -5
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/flowGraphConnection.d.ts +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +16 -12
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +63 -27
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.d.ts +72 -0
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +197 -0
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +42 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +78 -0
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +3 -19
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +3 -49
- package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.d.ts +3 -19
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +3 -49
- package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +3 -19
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +3 -49
- package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -17
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +3 -45
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.d.ts +2 -17
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +3 -44
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +3 -19
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +3 -49
- package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +47 -0
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +65 -0
- package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +4 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +9 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +2 -0
- package/FrameGraph/Node/Blocks/index.js +2 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +4 -2
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +2 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +3 -2
- package/FrameGraph/Node/nodeRenderGraph.js +4 -3
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +4 -4
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +8 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +10 -0
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.d.ts +21 -0
- package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.js +31 -0
- package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.js.map +1 -0
- package/FrameGraph/Passes/pass.d.ts +1 -0
- package/FrameGraph/Passes/pass.js +4 -1
- package/FrameGraph/Passes/pass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +81 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +304 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +3 -40
- package/FrameGraph/Tasks/Layers/glowLayerTask.js +4 -158
- package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Layers/highlightLayerTask.d.ts +21 -0
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js +32 -0
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +2 -2
- package/FrameGraph/Tasks/Misc/executeTask.js +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +5 -4
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +5 -4
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +2 -4
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/passTask.d.ts +29 -0
- package/FrameGraph/Tasks/PostProcesses/passTask.js +31 -0
- package/FrameGraph/Tasks/PostProcesses/passTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +4 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -2
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +1 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +2 -2
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +1 -0
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +8 -2
- package/FrameGraph/frameGraph.js +31 -5
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +10 -0
- package/FrameGraph/frameGraphRenderContext.js +14 -0
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +3 -2
- package/FrameGraph/frameGraphTask.js +12 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +4 -0
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/FrameGraph/index.d.ts +2 -0
- package/FrameGraph/index.js +2 -0
- package/FrameGraph/index.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +10 -0
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Helpers/environmentHelper.js +7 -6
- package/Helpers/environmentHelper.js.map +1 -1
- package/Inputs/scene.inputManager.js +2 -2
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -1
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +2 -14
- package/Layers/glowLayer.js +34 -36
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +13 -74
- package/Layers/highlightLayer.js +123 -309
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/index.d.ts +1 -0
- package/Layers/index.js +1 -0
- package/Layers/index.js.map +1 -1
- package/Layers/thinEffectLayer.d.ts +55 -2
- package/Layers/thinEffectLayer.js +66 -0
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Layers/thinGlowLayer.d.ts +3 -6
- package/Layers/thinGlowLayer.js +4 -1
- package/Layers/thinGlowLayer.js.map +1 -1
- package/Layers/thinHighlightLayer.d.ts +197 -0
- package/Layers/thinHighlightLayer.js +417 -0
- package/Layers/thinHighlightLayer.js.map +1 -0
- package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +6 -2
- package/Materials/GreasedLine/greasedLinePluginMaterial.js +8 -2
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +11 -3
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.d.ts +1 -0
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js +1 -0
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -3
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +3 -3
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +4 -2
- package/Materials/Node/nodeMaterial.js +9 -6
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +1 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +69 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +187 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -0
- package/Materials/Textures/hdrCubeTexture.d.ts +5 -1
- package/Materials/Textures/hdrCubeTexture.js +29 -3
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/index.d.ts +4 -0
- package/Materials/Textures/index.js +4 -0
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/effect.d.ts +5 -0
- package/Materials/effect.js +15 -0
- package/Materials/effect.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -2
- package/Materials/standardMaterial.js +0 -2
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Builders/planeBuilder.js +2 -2
- package/Meshes/Builders/planeBuilder.js.map +1 -1
- package/Meshes/Compression/dracoCodec.d.ts +4 -4
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoCompression.d.ts +5 -3
- package/Meshes/Compression/dracoCompression.js +24 -11
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.d.ts +16 -30
- package/Meshes/Compression/dracoCompressionWorker.js +128 -22
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.d.ts +4 -9
- package/Meshes/Compression/dracoDecoder.js +5 -5
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.types.d.ts +52 -0
- package/Meshes/Compression/dracoDecoder.types.js +2 -0
- package/Meshes/Compression/dracoDecoder.types.js.map +1 -0
- package/Meshes/Compression/dracoEncoder.d.ts +95 -0
- package/Meshes/Compression/dracoEncoder.js +245 -0
- package/Meshes/Compression/dracoEncoder.js.map +1 -0
- package/Meshes/Compression/dracoEncoder.types.d.ts +82 -0
- package/Meshes/Compression/dracoEncoder.types.js +2 -0
- package/Meshes/Compression/dracoEncoder.types.js.map +1 -0
- package/Meshes/Compression/index.d.ts +1 -0
- package/Meshes/Compression/index.js +1 -0
- package/Meshes/Compression/index.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.js +17 -2
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/Compression/test/integration/draco.test.d.ts +1 -0
- package/Meshes/Compression/test/integration/draco.test.js +30 -0
- package/Meshes/Compression/test/integration/draco.test.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +92 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +286 -10
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +4 -2
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -1
- package/Meshes/csg.js +4 -0
- package/Meshes/csg.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -2
- package/Meshes/transformNode.d.ts +4 -1
- package/Meshes/transformNode.js +6 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/copyTextureToTexture.js +1 -1
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/decorators.serialization.js +2 -0
- package/Misc/decorators.serialization.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +1 -1
- package/Misc/logger.d.ts +2 -1
- package/Misc/logger.js +2 -1
- package/Misc/logger.js.map +1 -1
- package/Misc/screenshotTools.js +58 -5
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/tools.d.ts +21 -1
- package/Misc/tools.js +33 -0
- package/Misc/tools.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +1 -0
- package/Morph/morphTargetManager.js +6 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/particleHelper.js +2 -1
- package/Particles/particleHelper.js.map +1 -1
- package/Particles/particleSystemSet.d.ts +1 -0
- package/Particles/particleSystemSet.js +1 -0
- package/Particles/particleSystemSet.js.map +1 -1
- package/Particles/pointsCloudSystem.d.ts +3 -3
- package/Particles/webgl2ParticleSystem.d.ts +1 -1
- package/Particles/webgl2ParticleSystem.js +1 -2
- package/Particles/webgl2ParticleSystem.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/index.d.ts +1 -0
- package/PostProcesses/index.js +1 -0
- package/PostProcesses/index.js.map +1 -1
- package/PostProcesses/passPostProcess.d.ts +2 -3
- package/PostProcesses/passPostProcess.js +36 -48
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/thinPassPostProcess.d.ts +48 -0
- package/PostProcesses/thinPassPostProcess.js +113 -0
- package/PostProcesses/thinPassPostProcess.js.map +1 -0
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/iblCdfGenerator.d.ts +13 -5
- package/Rendering/iblCdfGenerator.js +67 -10
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +5 -3
- package/Rendering/objectRenderer.js +5 -3
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/renderingManager.d.ts +4 -0
- package/Rendering/renderingManager.js +1 -0
- package/Rendering/renderingManager.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +6 -6
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/intersectionFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/intersectionFunctions.js +14 -0
- package/Shaders/ShadersInclude/intersectionFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrBlockReflection.js +13 -8
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/background.fragment.d.ts +1 -0
- package/Shaders/background.fragment.js +3 -5
- package/Shaders/background.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +2 -1
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/hdrIrradianceFiltering.fragment.d.ts +9 -0
- package/Shaders/hdrIrradianceFiltering.fragment.js +25 -0
- package/Shaders/hdrIrradianceFiltering.fragment.js.map +1 -0
- package/Shaders/hdrIrradianceFiltering.vertex.d.ts +5 -0
- package/Shaders/hdrIrradianceFiltering.vertex.js +15 -0
- package/Shaders/hdrIrradianceFiltering.vertex.js.map +1 -0
- package/Shaders/pbr.fragment.js +1 -3
- package/Shaders/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/intersectionFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/intersectionFunctions.js +14 -0
- package/ShadersWGSL/ShadersInclude/intersectionFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +13 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/background.fragment.d.ts +1 -0
- package/ShadersWGSL/background.fragment.js +3 -5
- package/ShadersWGSL/background.fragment.js.map +1 -1
- package/ShadersWGSL/greasedLine.fragment.js +9 -3
- package/ShadersWGSL/greasedLine.fragment.js.map +1 -1
- package/ShadersWGSL/greasedLine.vertex.js +12 -2
- package/ShadersWGSL/greasedLine.vertex.js.map +1 -1
- package/ShadersWGSL/hdrIrradianceFiltering.fragment.d.ts +9 -0
- package/ShadersWGSL/hdrIrradianceFiltering.fragment.js +26 -0
- package/ShadersWGSL/hdrIrradianceFiltering.fragment.js.map +1 -0
- package/ShadersWGSL/hdrIrradianceFiltering.vertex.d.ts +5 -0
- package/ShadersWGSL/hdrIrradianceFiltering.vertex.js +16 -0
- package/ShadersWGSL/hdrIrradianceFiltering.vertex.js.map +1 -0
- package/ShadersWGSL/outline.fragment.js +1 -1
- package/ShadersWGSL/outline.fragment.js.map +1 -1
- package/ShadersWGSL/passCube.fragment.js +1 -1
- package/ShadersWGSL/passCube.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +1 -3
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/XR/features/WebXRDepthSensing.d.ts +24 -2
- package/XR/features/WebXRDepthSensing.js +320 -26
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +8 -7
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +9 -5
- package/scene.js.map +1 -1
- package/types.d.ts +4 -0
- package/types.js.map +1 -1
|
@@ -17,8 +17,8 @@ export function CreatePlaneVertexData(options) {
|
|
|
17
17
|
const positions = [];
|
|
18
18
|
const normals = [];
|
|
19
19
|
const uvs = [];
|
|
20
|
-
const width = options.width
|
|
21
|
-
const height = options.height
|
|
20
|
+
const width = options.width !== undefined ? options.width : options.size !== undefined ? options.size : 1;
|
|
21
|
+
const height = options.height !== undefined ? options.height : options.size !== undefined ? options.size : 1;
|
|
22
22
|
const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
|
|
23
23
|
// Vertices
|
|
24
24
|
const halfWidth = width / 2.0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planeBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/planeBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA4H;IAC9J,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,GAAG,GAAG,EAAE,CAAC;I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;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,gEAAgE;IAChE,WAAW;CACd,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,qBAAqB,CAAC;AAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,KAAY,EAAE,SAAmB,EAAE,eAAwB,EAAQ,EAAE;IACjH,MAAM,OAAO,GAAG;QACZ,IAAI;QACJ,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,eAAe;QACf,SAAS;KACZ,CAAC;IAEF,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { Vector4 } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Plane } from \"../../Maths/math.plane\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n\r\n/**\r\n * Creates the VertexData for a Plane\r\n * @param options an object used to set the following optional parameters for the plane, required but can be empty\r\n * * size sets the width and height of the plane to the value of size, optional default 1\r\n * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size\r\n * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @returns the VertexData of the box\r\n */\r\nexport function CreatePlaneVertexData(options: { size?: number; width?: number; height?: number; sideOrientation?: number; frontUVs?: Vector4; backUVs?: Vector4 }): VertexData {\r\n const indices = [];\r\n const positions = [];\r\n const normals = [];\r\n const uvs = [];\r\n\r\n const width: number = options.width !== undefined ? options.width : options.size !== undefined ? options.size : 1;\r\n const height: number = options.height !== undefined ? options.height : options.size !== undefined ? options.size : 1;\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n // Vertices\r\n const halfWidth = width / 2.0;\r\n const halfHeight = height / 2.0;\r\n\r\n positions.push(-halfWidth, -halfHeight, 0);\r\n normals.push(0, 0, -1.0);\r\n uvs.push(0.0, useOpenGLOrientationForUV ? 1.0 : 0.0);\r\n\r\n positions.push(halfWidth, -halfHeight, 0);\r\n normals.push(0, 0, -1.0);\r\n uvs.push(1.0, useOpenGLOrientationForUV ? 1.0 : 0.0);\r\n\r\n positions.push(halfWidth, halfHeight, 0);\r\n normals.push(0, 0, -1.0);\r\n uvs.push(1.0, useOpenGLOrientationForUV ? 0.0 : 1.0);\r\n\r\n positions.push(-halfWidth, halfHeight, 0);\r\n normals.push(0, 0, -1.0);\r\n uvs.push(0.0, useOpenGLOrientationForUV ? 0.0 : 1.0);\r\n\r\n // Indices\r\n indices.push(0);\r\n indices.push(1);\r\n indices.push(2);\r\n\r\n indices.push(0);\r\n indices.push(2);\r\n indices.push(3);\r\n\r\n // Sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a plane mesh\r\n * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)\r\n * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)\r\n * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the plane mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#plane\r\n */\r\nexport function CreatePlane(\r\n name: string,\r\n options: { size?: number; width?: number; height?: number; sideOrientation?: number; frontUVs?: Vector4; backUVs?: Vector4; updatable?: boolean; sourcePlane?: Plane } = {},\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const plane = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n plane._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreatePlaneVertexData(options);\r\n\r\n vertexData.applyToMesh(plane, options.updatable);\r\n\r\n if (options.sourcePlane) {\r\n plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);\r\n plane.setDirection(options.sourcePlane.normal.scale(-1));\r\n }\r\n\r\n return plane;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the function directly from the module\r\n */\r\nexport const PlaneBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreatePlane,\r\n};\r\n\r\nVertexData.CreatePlane = CreatePlaneVertexData;\r\nMesh.CreatePlane = (name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh => {\r\n const options = {\r\n size,\r\n width: size,\r\n height: size,\r\n sideOrientation,\r\n updatable,\r\n };\r\n\r\n return CreatePlane(name, options, scene);\r\n};\r\n"]}
|
|
@@ -33,7 +33,7 @@ export interface IDracoCodecConfiguration {
|
|
|
33
33
|
/**
|
|
34
34
|
* The codec module if already available.
|
|
35
35
|
*/
|
|
36
|
-
jsModule?:
|
|
36
|
+
jsModule?: unknown;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
@@ -50,7 +50,7 @@ export declare function _IsConfigurationAvailable(config: IDracoCodecConfigurati
|
|
|
50
50
|
export declare abstract class DracoCodec implements IDisposable {
|
|
51
51
|
protected _workerPoolPromise?: Promise<WorkerPool>;
|
|
52
52
|
protected _modulePromise?: Promise<{
|
|
53
|
-
module:
|
|
53
|
+
module: unknown; /** DecoderModule | EncoderModule */
|
|
54
54
|
}>;
|
|
55
55
|
/**
|
|
56
56
|
* Checks if the default codec JS module is in scope.
|
|
@@ -59,8 +59,8 @@ export declare abstract class DracoCodec implements IDisposable {
|
|
|
59
59
|
/**
|
|
60
60
|
* Creates the JS Module for the corresponding wasm.
|
|
61
61
|
*/
|
|
62
|
-
protected abstract _createModuleAsync(wasmBinary?: ArrayBuffer, jsModule?:
|
|
63
|
-
module:
|
|
62
|
+
protected abstract _createModuleAsync(wasmBinary?: ArrayBuffer, jsModule?: unknown /** DracoDecoderModule | DracoEncoderModule */): Promise<{
|
|
63
|
+
module: unknown; /** DecoderModule | EncoderModule */
|
|
64
64
|
}>;
|
|
65
65
|
/**
|
|
66
66
|
* Returns the worker content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dracoCodec.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AA4C/D;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACjC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAA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,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;oBAC7B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;wBAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;4BACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;wBAC3D,CAAC;wBACD,MAAM,KAAK,CAAC,sBAAsB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;oBACtD,CAAC;gBACL,CAAC;gBACD,OAAO,IAAI,CAAC,kBAAkB,CAAC,UAAyB,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;YACtF,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,cAAc;QACvB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,kBAAkB,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,cAAc,CAAC;YAC1B,OAAO;QACX,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;gBACxC,UAAU,CAAC,OAAO,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC,kBAAkB,CAAC;QAC/B,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { WorkerPool } from \"../../Misc/workerPool\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport { initializeWebWorker } from \"./dracoCompressionWorker\";\r\n\r\n/**\r\n * Configuration for using a Draco codec.\r\n */\r\nexport interface IDracoCodecConfiguration {\r\n /**\r\n * The url to the WebAssembly module.\r\n */\r\n wasmUrl?: string;\r\n\r\n /**\r\n * The url to the WebAssembly binary.\r\n */\r\n wasmBinaryUrl?: string;\r\n\r\n /**\r\n * The url to the fallback JavaScript module.\r\n */\r\n fallbackUrl?: string;\r\n\r\n /**\r\n * The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n numWorkers?: number;\r\n\r\n /**\r\n * Optional worker pool to use for async encoding/decoding.\r\n * If provided, the worker pool will be used as is: no Draco scripts will be loaded, and numWorkers will be ignored.\r\n */\r\n workerPool?: WorkerPool;\r\n\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary.\r\n * If provided it will be used instead of loading the binary from wasmBinaryUrl.\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The codec module if already available.\r\n */\r\n jsModule?: any /* DracoDecoderModule | DracoEncoderModule */;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _GetDefaultNumWorkers(): number {\r\n if (typeof navigator !== \"object\" || !navigator.hardwareConcurrency) {\r\n return 1;\r\n }\r\n\r\n // Use 50% of the available logical processors but capped at 4.\r\n return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _IsConfigurationAvailable(config: IDracoCodecConfiguration): boolean {\r\n return !!((config.wasmUrl && (config.wasmBinary || config.wasmBinaryUrl) && typeof WebAssembly === \"object\") || config.fallbackUrl);\r\n // TODO: Account for jsModule\r\n}\r\n\r\n/**\r\n * Base class for a Draco codec.\r\n * @internal\r\n */\r\nexport abstract class DracoCodec implements IDisposable {\r\n protected _workerPoolPromise?: Promise<WorkerPool>;\r\n protected _modulePromise?: Promise<{ module: any /** DecoderModule | EncoderModule */ }>;\r\n\r\n /**\r\n * Checks if the default codec JS module is in scope.\r\n */\r\n protected abstract _isModuleAvailable(): boolean;\r\n\r\n /**\r\n * Creates the JS Module for the corresponding wasm.\r\n */\r\n protected abstract _createModuleAsync(wasmBinary?: ArrayBuffer, jsModule?: any): Promise<{ module: any /** DecoderModule | EncoderModule */ }>;\r\n\r\n /**\r\n * Returns the worker content.\r\n */\r\n protected abstract _getWorkerContent(): string;\r\n\r\n /**\r\n * Constructor\r\n * @param configuration The configuration for the DracoCodec instance.\r\n */\r\n constructor(configuration: IDracoCodecConfiguration) {\r\n // check if the codec binary and worker pool was injected\r\n // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available\r\n if (configuration.workerPool) {\r\n // Set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(configuration.workerPool);\r\n return;\r\n }\r\n\r\n // to avoid making big changes to the code here, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = configuration.wasmBinary;\r\n const numberOfWorkers = configuration.numWorkers ?? _GetDefaultNumWorkers();\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || !configuration.jsModule;\r\n // code maintained here for back-compat with no changes\r\n\r\n const codecInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n configuration.wasmUrl && configuration.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(configuration.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided\r\n ? Promise.resolve(wasmBinaryProvided)\r\n : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(configuration.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(configuration.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n // If using workers, initialize a worker pool with either the wasm or url?\r\n if (useWorkers) {\r\n this._workerPoolPromise = codecInfo.wasmBinaryPromise.then((wasmBinary) => {\r\n const workerContent = this._getWorkerContent();\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n\r\n return new AutoReleaseWorkerPool(numberOfWorkers as number, () => {\r\n const worker = new Worker(workerBlobUrl);\r\n return initializeWebWorker(worker, wasmBinary, codecInfo.url);\r\n });\r\n });\r\n } else {\r\n this._modulePromise = codecInfo.wasmBinaryPromise.then(async (wasmBinary) => {\r\n if (!this._isModuleAvailable()) {\r\n if (!configuration.jsModule) {\r\n if (!codecInfo.url) {\r\n throw new Error(\"Draco codec module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(codecInfo.url);\r\n }\r\n }\r\n return this._createModuleAsync(wasmBinary as ArrayBuffer, configuration.jsModule);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure the draco codec is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._modulePromise) {\r\n await this._modulePromise;\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n if (this._workerPoolPromise) {\r\n this._workerPoolPromise.then((workerPool) => {\r\n workerPool.dispose();\r\n });\r\n }\r\n\r\n delete this._workerPoolPromise;\r\n delete this._modulePromise;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dracoCodec.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AA4C/D;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACjC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC;QAClE,OAAO,CAAC,CAAC;IACb,CA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QAAQ,EAAE,CAAC;wBAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;4BACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;wBAC3D,CAAC;wBACD,MAAM,KAAK,CAAC,sBAAsB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;oBACtD,CAAC;gBACL,CAAC;gBACD,OAAO,IAAI,CAAC,kBAAkB,CAAC,UAAyB,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;YACtF,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,cAAc;QACvB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,kBAAkB,CAAC;YAC9B,OAAO;QACX,CAAC;QAED,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,cAAc,CAAC;YAC1B,OAAO;QACX,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;gBACxC,UAAU,CAAC,OAAO,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC,kBAAkB,CAAC;QAC/B,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { WorkerPool } from \"../../Misc/workerPool\";\r\nimport type { IDisposable } from \"../../scene\";\r\nimport { initializeWebWorker } from \"./dracoCompressionWorker\";\r\n\r\n/**\r\n * Configuration for using a Draco codec.\r\n */\r\nexport interface IDracoCodecConfiguration {\r\n /**\r\n * The url to the WebAssembly module.\r\n */\r\n wasmUrl?: string;\r\n\r\n /**\r\n * The url to the WebAssembly binary.\r\n */\r\n wasmBinaryUrl?: string;\r\n\r\n /**\r\n * The url to the fallback JavaScript module.\r\n */\r\n fallbackUrl?: string;\r\n\r\n /**\r\n * The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n numWorkers?: number;\r\n\r\n /**\r\n * Optional worker pool to use for async encoding/decoding.\r\n * If provided, the worker pool will be used as is: no Draco scripts will be loaded, and numWorkers will be ignored.\r\n */\r\n workerPool?: WorkerPool;\r\n\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary.\r\n * If provided it will be used instead of loading the binary from wasmBinaryUrl.\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The codec module if already available.\r\n */\r\n jsModule?: unknown /* DracoDecoderModule | DracoEncoderModule */;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _GetDefaultNumWorkers(): number {\r\n if (typeof navigator !== \"object\" || !navigator.hardwareConcurrency) {\r\n return 1;\r\n }\r\n\r\n // Use 50% of the available logical processors but capped at 4.\r\n return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function _IsConfigurationAvailable(config: IDracoCodecConfiguration): boolean {\r\n return !!((config.wasmUrl && (config.wasmBinary || config.wasmBinaryUrl) && typeof WebAssembly === \"object\") || config.fallbackUrl);\r\n // TODO: Account for jsModule\r\n}\r\n\r\n/**\r\n * Base class for a Draco codec.\r\n * @internal\r\n */\r\nexport abstract class DracoCodec implements IDisposable {\r\n protected _workerPoolPromise?: Promise<WorkerPool>;\r\n protected _modulePromise?: Promise<{ module: unknown /** DecoderModule | EncoderModule */ }>;\r\n\r\n /**\r\n * Checks if the default codec JS module is in scope.\r\n */\r\n protected abstract _isModuleAvailable(): boolean;\r\n\r\n /**\r\n * Creates the JS Module for the corresponding wasm.\r\n */\r\n protected abstract _createModuleAsync(\r\n wasmBinary?: ArrayBuffer,\r\n jsModule?: unknown /** DracoDecoderModule | DracoEncoderModule */\r\n ): Promise<{ module: unknown /** DecoderModule | EncoderModule */ }>;\r\n\r\n /**\r\n * Returns the worker content.\r\n */\r\n protected abstract _getWorkerContent(): string;\r\n\r\n /**\r\n * Constructor\r\n * @param configuration The configuration for the DracoCodec instance.\r\n */\r\n constructor(configuration: IDracoCodecConfiguration) {\r\n // check if the codec binary and worker pool was injected\r\n // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available\r\n if (configuration.workerPool) {\r\n // Set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(configuration.workerPool);\r\n return;\r\n }\r\n\r\n // to avoid making big changes to the code here, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = configuration.wasmBinary;\r\n const numberOfWorkers = configuration.numWorkers ?? _GetDefaultNumWorkers();\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || !configuration.jsModule;\r\n // code maintained here for back-compat with no changes\r\n\r\n const codecInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n configuration.wasmUrl && configuration.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(configuration.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided\r\n ? Promise.resolve(wasmBinaryProvided)\r\n : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(configuration.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(configuration.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n // If using workers, initialize a worker pool with either the wasm or url?\r\n if (useWorkers) {\r\n this._workerPoolPromise = codecInfo.wasmBinaryPromise.then((wasmBinary) => {\r\n const workerContent = this._getWorkerContent();\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n\r\n return new AutoReleaseWorkerPool(numberOfWorkers as number, () => {\r\n const worker = new Worker(workerBlobUrl);\r\n return initializeWebWorker(worker, wasmBinary, codecInfo.url);\r\n });\r\n });\r\n } else {\r\n this._modulePromise = codecInfo.wasmBinaryPromise.then(async (wasmBinary) => {\r\n if (!this._isModuleAvailable()) {\r\n if (!configuration.jsModule) {\r\n if (!codecInfo.url) {\r\n throw new Error(\"Draco codec module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(codecInfo.url);\r\n }\r\n }\r\n return this._createModuleAsync(wasmBinary as ArrayBuffer, configuration.jsModule);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure the draco codec is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._modulePromise) {\r\n await this._modulePromise;\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n if (this._workerPoolPromise) {\r\n this._workerPoolPromise.then((workerPool) => {\r\n workerPool.dispose();\r\n });\r\n }\r\n\r\n delete this._workerPoolPromise;\r\n delete this._modulePromise;\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IDracoCodecConfiguration } from "./dracoCodec";
|
|
2
|
-
import type { MeshData } from "./dracoDecoder";
|
|
2
|
+
import type { MeshData } from "./dracoDecoder.types";
|
|
3
3
|
import { VertexData } from "../mesh.vertexData";
|
|
4
4
|
import type { Nullable } from "../../types.js";
|
|
5
5
|
import type { Geometry } from "../geometry";
|
|
@@ -30,7 +30,8 @@ export interface IDracoCompressionOptions extends Pick<IDracoCodecConfiguration,
|
|
|
30
30
|
*
|
|
31
31
|
* **Decoder**
|
|
32
32
|
*
|
|
33
|
-
* By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js
|
|
33
|
+
* By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js cdn https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js.
|
|
34
|
+
* The configuration is shared with the DracoDecoder class.
|
|
34
35
|
*
|
|
35
36
|
* To update the configuration, use the following code:
|
|
36
37
|
* ```javascript
|
|
@@ -62,7 +63,8 @@ export declare class DracoCompression {
|
|
|
62
63
|
* - wasmBinaryUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.wasm"
|
|
63
64
|
* - fallbackUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.js"
|
|
64
65
|
*/
|
|
65
|
-
static Configuration: IDracoCompressionConfiguration;
|
|
66
|
+
static get Configuration(): IDracoCompressionConfiguration;
|
|
67
|
+
static set Configuration(value: IDracoCompressionConfiguration);
|
|
66
68
|
/**
|
|
67
69
|
* Returns true if the decoder configuration is available.
|
|
68
70
|
*/
|
|
@@ -13,7 +13,8 @@ import { VertexData } from "../mesh.vertexData.js";
|
|
|
13
13
|
*
|
|
14
14
|
* **Decoder**
|
|
15
15
|
*
|
|
16
|
-
* By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js
|
|
16
|
+
* By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js cdn https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js.
|
|
17
|
+
* The configuration is shared with the DracoDecoder class.
|
|
17
18
|
*
|
|
18
19
|
* To update the configuration, use the following code:
|
|
19
20
|
* ```javascript
|
|
@@ -38,11 +39,30 @@ import { VertexData } from "../mesh.vertexData.js";
|
|
|
38
39
|
* @see https://playground.babylonjs.com/#DMZIBD#0
|
|
39
40
|
*/
|
|
40
41
|
export class DracoCompression {
|
|
42
|
+
/**
|
|
43
|
+
* The configuration. Defaults to the following urls:
|
|
44
|
+
* - wasmUrl: "https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js"
|
|
45
|
+
* - wasmBinaryUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.wasm"
|
|
46
|
+
* - fallbackUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.js"
|
|
47
|
+
*/
|
|
48
|
+
static get Configuration() {
|
|
49
|
+
return {
|
|
50
|
+
get decoder() {
|
|
51
|
+
return DracoDecoder.DefaultConfiguration;
|
|
52
|
+
},
|
|
53
|
+
set decoder(value) {
|
|
54
|
+
DracoDecoder.DefaultConfiguration = value;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
static set Configuration(value) {
|
|
59
|
+
DracoDecoder.DefaultConfiguration = value.decoder;
|
|
60
|
+
}
|
|
41
61
|
/**
|
|
42
62
|
* Returns true if the decoder configuration is available.
|
|
43
63
|
*/
|
|
44
64
|
static get DecoderAvailable() {
|
|
45
|
-
return _IsConfigurationAvailable(
|
|
65
|
+
return _IsConfigurationAvailable(DracoDecoder.DefaultConfiguration);
|
|
46
66
|
}
|
|
47
67
|
/**
|
|
48
68
|
* Default instance for the DracoCompression.
|
|
@@ -73,8 +93,8 @@ export class DracoCompression {
|
|
|
73
93
|
*/
|
|
74
94
|
constructor(numWorkersOrOptions = DracoCompression.DefaultNumWorkers) {
|
|
75
95
|
const configuration = typeof numWorkersOrOptions === "number"
|
|
76
|
-
? { ...
|
|
77
|
-
: { ...
|
|
96
|
+
? { ...DracoDecoder.DefaultConfiguration, numWorkers: numWorkersOrOptions }
|
|
97
|
+
: { ...DracoDecoder.DefaultConfiguration, ...numWorkersOrOptions };
|
|
78
98
|
this._decoder = new DracoDecoder(configuration);
|
|
79
99
|
}
|
|
80
100
|
/**
|
|
@@ -135,13 +155,6 @@ export class DracoCompression {
|
|
|
135
155
|
return vertexData;
|
|
136
156
|
}
|
|
137
157
|
}
|
|
138
|
-
/**
|
|
139
|
-
* The configuration. Defaults to the following urls:
|
|
140
|
-
* - wasmUrl: "https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js"
|
|
141
|
-
* - wasmBinaryUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.wasm"
|
|
142
|
-
* - fallbackUrl: "https://cdn.babylonjs.com/draco_decoder_gltf.js"
|
|
143
|
-
*/
|
|
144
|
-
DracoCompression.Configuration = { decoder: { ...DracoDecoder.DefaultConfiguration } }; // Use copy
|
|
145
158
|
/**
|
|
146
159
|
* Default number of workers to create when creating the draco compression object.
|
|
147
160
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAqBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,gBAAgB;IAWzB;;OAEG;IACI,MAAM,KAAK,gBAAgB;QAC9B,OAAO,yBAAyB,CAAC,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC7E,CAAC;IAQD;;OAEG;IACI,MAAM,KAAK,OAAO;QACrB,gBAAgB,CAAC,QAAQ,KAAzB,gBAAgB,CAAC,QAAQ,GAAK,IAAI,gBAAgB,EAAE,EAAC;QACrD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,YAAY,CAAC,WAAqB;QAC5C,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,WAAW,EAAE,CAAC;gBACf,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxC,CAAC;YACD,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,YAAY,sBAAyD,gBAAgB,CAAC,iBAAiB;QAC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QACrG,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACjF,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC1C,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CACvC,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EACxC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,QAAQ,CAAC,aAAa,CACzB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AA3ID;;;;;GAKG;AACW,8BAAa,GAAmC,EAAE,OAAO,EAAE,EAAE,GAAG,YAAY,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,WAAW;AAShI;;GAEG;AACW,kCAAiB,GAAG,qBAAqB,EAAE,CAAC;AAEzC,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["import { _GetDefaultNumWorkers, _IsConfigurationAvailable } from \"./dracoCodec\";\r\nimport type { IDracoCodecConfiguration } from \"./dracoCodec\";\r\nimport { DracoDecoder } from \"./dracoDecoder\";\r\nimport type { MeshData } from \"./dracoDecoder\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Geometry } from \"../geometry\";\r\nimport type { BoundingInfo } from \"../../Culling/boundingInfo\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: IDracoCodecConfiguration;\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions extends Pick<IDracoCodecConfiguration, \"numWorkers\" | \"wasmBinary\" | \"workerPool\"> {}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression {\r\n private _decoder: DracoDecoder;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static Configuration: IDracoCompressionConfiguration = { decoder: { ...DracoDecoder.DefaultConfiguration } }; // Use copy\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n return _IsConfigurationAvailable(DracoCompression.Configuration.decoder);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = _GetDefaultNumWorkers();\r\n\r\n protected static _Default: Nullable<DracoCompression> = null;\r\n /**\r\n * Default instance for the DracoCompression.\r\n */\r\n public static get Default(): DracoCompression {\r\n DracoCompression._Default ??= new DracoCompression();\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Reset the default draco compression object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static Configuration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoCompression._Default) {\r\n if (!skipDispose) {\r\n DracoCompression._Default.dispose();\r\n }\r\n DracoCompression._Default = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new DracoCompression object.\r\n * @param numWorkersOrOptions Overrides for the Configuration. Either:\r\n * - The number of workers for async operations or a config object. Specify `0` to disable web workers and run synchronously in the current context.\r\n * - An options object\r\n */\r\n constructor(numWorkersOrOptions: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const configuration =\r\n typeof numWorkersOrOptions === \"number\"\r\n ? { ...DracoCompression.Configuration.decoder, numWorkers: numWorkersOrOptions }\r\n : { ...DracoCompression.Configuration.decoder, ...numWorkersOrOptions };\r\n this._decoder = new DracoDecoder(configuration);\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n this._decoder.dispose();\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n return this._decoder.whenReadyAsync();\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to mesh data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization\r\n * @returns A promise that resolves with the decoded mesh data\r\n */\r\n public decodeMeshToMeshDataAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n return this._decoder.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n return this._decoder.decodeMeshToGeometryAsync(name, scene, data, attributes);\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean },\r\n boundingInfo: Nullable<BoundingInfo>\r\n ): Promise<Geometry> {\r\n return this._decoder._decodeMeshToGeometryForGltfAsync(name, scene, data, attributes, gltfNormalizedOverride, boundingInfo);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this._decoder.decodeMeshToMeshDataAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAqBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,OAAO,gBAAgB;IAGzB;;;;;OAKG;IACI,MAAM,KAAK,aAAa;QAC3B,OAAO;YACH,IAAI,OAAO;gBACP,OAAO,YAAY,CAAC,oBAAoB,CAAC;YAC7C,CAAC;YACD,IAAI,OAAO,CAAC,KAA+B;gBACvC,YAAY,CAAC,oBAAoB,GAAG,KAAK,CAAC;YAC9C,CAAC;SACJ,CAAC;IACN,CAAC;IACM,MAAM,KAAK,aAAa,CAAC,KAAqC;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C;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AA5HD;;GAEG;AACW,kCAAiB,GAAG,qBAAqB,EAAE,CAAC;AAEzC,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["import { _GetDefaultNumWorkers, _IsConfigurationAvailable } from \"./dracoCodec\";\r\nimport type { IDracoCodecConfiguration } from \"./dracoCodec\";\r\nimport { DracoDecoder } from \"./dracoDecoder\";\r\nimport type { MeshData } from \"./dracoDecoder.types\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Geometry } from \"../geometry\";\r\nimport type { BoundingInfo } from \"../../Culling/boundingInfo\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: IDracoCodecConfiguration;\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions extends Pick<IDracoCodecConfiguration, \"numWorkers\" | \"wasmBinary\" | \"workerPool\"> {}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js cdn https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n * The configuration is shared with the DracoDecoder class.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression {\r\n private _decoder: DracoDecoder;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static get Configuration(): IDracoCompressionConfiguration {\r\n return {\r\n get decoder() {\r\n return DracoDecoder.DefaultConfiguration;\r\n },\r\n set decoder(value: IDracoCodecConfiguration) {\r\n DracoDecoder.DefaultConfiguration = value;\r\n },\r\n };\r\n }\r\n public static set Configuration(value: IDracoCompressionConfiguration) {\r\n DracoDecoder.DefaultConfiguration = value.decoder;\r\n }\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n return _IsConfigurationAvailable(DracoDecoder.DefaultConfiguration);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = _GetDefaultNumWorkers();\r\n\r\n protected static _Default: Nullable<DracoCompression> = null;\r\n /**\r\n * Default instance for the DracoCompression.\r\n */\r\n public static get Default(): DracoCompression {\r\n DracoCompression._Default ??= new DracoCompression();\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Reset the default draco compression object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static Configuration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoCompression._Default) {\r\n if (!skipDispose) {\r\n DracoCompression._Default.dispose();\r\n }\r\n DracoCompression._Default = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new DracoCompression object.\r\n * @param numWorkersOrOptions Overrides for the Configuration. Either:\r\n * - The number of workers for async operations or a config object. Specify `0` to disable web workers and run synchronously in the current context.\r\n * - An options object\r\n */\r\n constructor(numWorkersOrOptions: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const configuration =\r\n typeof numWorkersOrOptions === \"number\"\r\n ? { ...DracoDecoder.DefaultConfiguration, numWorkers: numWorkersOrOptions }\r\n : { ...DracoDecoder.DefaultConfiguration, ...numWorkersOrOptions };\r\n this._decoder = new DracoDecoder(configuration);\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n this._decoder.dispose();\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n return this._decoder.whenReadyAsync();\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to mesh data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization\r\n * @returns A promise that resolves with the decoded mesh data\r\n */\r\n public decodeMeshToMeshDataAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n return this._decoder.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n return this._decoder.decodeMeshToGeometryAsync(name, scene, data, attributes);\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean },\r\n boundingInfo: Nullable<BoundingInfo>\r\n ): Promise<Geometry> {\r\n return this._decoder._decodeMeshToGeometryForGltfAsync(name, scene, data, attributes, gltfNormalizedOverride, boundingInfo);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this._decoder.decodeMeshToMeshDataAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
|
@@ -1,43 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
data: ArrayBufferView;
|
|
4
|
-
size: number;
|
|
5
|
-
byteOffset: number;
|
|
6
|
-
byteStride: number;
|
|
7
|
-
normalized: boolean;
|
|
8
|
-
}
|
|
9
|
-
interface InitDoneMessage {
|
|
10
|
-
id: "initDone";
|
|
11
|
-
}
|
|
12
|
-
interface DecodeMeshDoneMessage {
|
|
13
|
-
id: "decodeMeshDone";
|
|
14
|
-
totalVertices: number;
|
|
15
|
-
}
|
|
16
|
-
interface IndicesMessage {
|
|
17
|
-
id: "indices";
|
|
18
|
-
data: Uint16Array | Uint32Array;
|
|
19
|
-
}
|
|
20
|
-
interface AttributeMessage extends AttributeData {
|
|
21
|
-
id: "attribute";
|
|
22
|
-
}
|
|
23
|
-
export type Message = InitDoneMessage | DecodeMeshDoneMessage | IndicesMessage | AttributeMessage;
|
|
1
|
+
import type { Nullable } from "../../types.js";
|
|
2
|
+
import type { IDracoAttributeData, IDracoEncodedMeshData, IDracoEncoderOptions } from "./dracoEncoder.types";
|
|
24
3
|
/**
|
|
25
4
|
* @internal
|
|
26
5
|
*/
|
|
27
|
-
export declare function
|
|
28
|
-
[kind: string]: number;
|
|
29
|
-
} | undefined, onIndicesData: (indices: Uint16Array | Uint32Array) => void, onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void): number;
|
|
6
|
+
export declare function EncodeMesh(module: unknown /** EncoderModule */, attributes: Array<IDracoAttributeData>, indices: Nullable<Uint16Array | Uint32Array>, options: IDracoEncoderOptions): Nullable<IDracoEncodedMeshData>;
|
|
30
7
|
/**
|
|
31
8
|
* The worker function that gets converted to a blob url to pass into a worker.
|
|
32
9
|
* To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.
|
|
33
10
|
*/
|
|
34
|
-
export declare function
|
|
11
|
+
export declare function EncoderWorkerFunction(): void;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function DecodeMesh(module: unknown /** DecoderModule */, data: Int8Array, attributeIDs: Record<string, number> | undefined, onIndicesData: (indices: Uint16Array | Uint32Array) => void, onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void): number;
|
|
16
|
+
/**
|
|
17
|
+
* The worker function that gets converted to a blob url to pass into a worker.
|
|
18
|
+
* To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.
|
|
19
|
+
*/
|
|
20
|
+
export declare function DecoderWorkerFunction(): void;
|
|
21
|
+
export { DecoderWorkerFunction as workerFunction };
|
|
35
22
|
/**
|
|
36
23
|
* Initializes a worker that was created for the draco agent pool
|
|
37
24
|
* @param worker The worker to initialize
|
|
38
|
-
* @param
|
|
25
|
+
* @param wasmBinary The wasm binary to load into the worker
|
|
39
26
|
* @param moduleUrl The url to the draco decoder module (optional)
|
|
40
27
|
* @returns A promise that resolves when the worker is initialized
|
|
41
28
|
*/
|
|
42
|
-
export declare function initializeWebWorker(worker: Worker,
|
|
43
|
-
export {};
|
|
29
|
+
export declare function initializeWebWorker(worker: Worker, wasmBinary?: ArrayBuffer, moduleUrl?: string): Promise<Worker>;
|
|
@@ -1,7 +1,114 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal
|
|
3
3
|
*/
|
|
4
|
-
export function
|
|
4
|
+
export function EncodeMesh(module /** EncoderModule */, attributes, indices, options) {
|
|
5
|
+
const encoderModule = module;
|
|
6
|
+
let encoder = null;
|
|
7
|
+
let meshBuilder = null;
|
|
8
|
+
let mesh = null;
|
|
9
|
+
let encodedNativeBuffer = null;
|
|
10
|
+
const attributeIDs = {}; // Babylon kind -> Draco unique id
|
|
11
|
+
// Double-check that at least a position attribute is provided
|
|
12
|
+
const positionAttribute = attributes.find((a) => a.dracoName === "POSITION");
|
|
13
|
+
if (!positionAttribute) {
|
|
14
|
+
throw new Error("Position attribute is required for Draco encoding");
|
|
15
|
+
}
|
|
16
|
+
// If no indices are provided, assume mesh is unindexed. Let's generate them, since Draco meshes require them.
|
|
17
|
+
// TODO: This may be the POINT_CLOUD case, but need to investigate. Should work for now-- just less efficient.
|
|
18
|
+
if (!indices) {
|
|
19
|
+
// Assume position attribute is the largest attribute.
|
|
20
|
+
const positionVerticesCount = positionAttribute.data.length / positionAttribute.size;
|
|
21
|
+
indices = new (positionVerticesCount > 65535 ? Uint32Array : Uint16Array)(positionVerticesCount);
|
|
22
|
+
for (let i = 0; i < positionVerticesCount; i++) {
|
|
23
|
+
indices[i] = i;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
encoder = new encoderModule.Encoder();
|
|
28
|
+
meshBuilder = new encoderModule.MeshBuilder();
|
|
29
|
+
mesh = new encoderModule.Mesh();
|
|
30
|
+
// Add the faces
|
|
31
|
+
meshBuilder.AddFacesToMesh(mesh, indices.length / 3, indices);
|
|
32
|
+
// Add the attributes
|
|
33
|
+
for (const attribute of attributes) {
|
|
34
|
+
const verticesCount = attribute.data.length / attribute.size;
|
|
35
|
+
attributeIDs[attribute.kind] = meshBuilder.AddFloatAttribute(mesh, encoderModule[attribute.dracoName], verticesCount, attribute.size, attribute.data);
|
|
36
|
+
if (options.quantizationBits && options.quantizationBits[attribute.dracoName]) {
|
|
37
|
+
encoder.SetAttributeQuantization(encoderModule[attribute.dracoName], options.quantizationBits[attribute.dracoName]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Set the options
|
|
41
|
+
if (options.method) {
|
|
42
|
+
encoder.SetEncodingMethod(encoderModule[options.method]);
|
|
43
|
+
}
|
|
44
|
+
if (options.encodeSpeed !== undefined && options.decodeSpeed !== undefined) {
|
|
45
|
+
encoder.SetSpeedOptions(options.encodeSpeed, options.decodeSpeed);
|
|
46
|
+
}
|
|
47
|
+
// Encode to native buffer
|
|
48
|
+
encodedNativeBuffer = new encoderModule.DracoInt8Array();
|
|
49
|
+
const encodedLength = encoder.EncodeMeshToDracoBuffer(mesh, encodedNativeBuffer);
|
|
50
|
+
if (encodedLength <= 0) {
|
|
51
|
+
throw new Error("Draco encoding failed.");
|
|
52
|
+
}
|
|
53
|
+
// Copy the native buffer data to worker heap
|
|
54
|
+
const encodedData = new Int8Array(encodedLength);
|
|
55
|
+
for (let i = 0; i < encodedLength; i++) {
|
|
56
|
+
encodedData[i] = encodedNativeBuffer.GetValue(i);
|
|
57
|
+
}
|
|
58
|
+
return { data: encodedData, attributeIDs: attributeIDs };
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
if (mesh) {
|
|
62
|
+
encoderModule.destroy(mesh);
|
|
63
|
+
}
|
|
64
|
+
if (meshBuilder) {
|
|
65
|
+
encoderModule.destroy(meshBuilder);
|
|
66
|
+
}
|
|
67
|
+
if (encoder) {
|
|
68
|
+
encoderModule.destroy(encoder);
|
|
69
|
+
}
|
|
70
|
+
if (encodedNativeBuffer) {
|
|
71
|
+
encoderModule.destroy(encodedNativeBuffer);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The worker function that gets converted to a blob url to pass into a worker.
|
|
77
|
+
* To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.
|
|
78
|
+
*/
|
|
79
|
+
export function EncoderWorkerFunction() {
|
|
80
|
+
let encoderPromise;
|
|
81
|
+
onmessage = (event) => {
|
|
82
|
+
const message = event.data;
|
|
83
|
+
switch (message.id) {
|
|
84
|
+
case "init": {
|
|
85
|
+
// if URL is provided then load the script. Otherwise expect the script to be loaded already
|
|
86
|
+
if (message.url) {
|
|
87
|
+
importScripts(message.url);
|
|
88
|
+
}
|
|
89
|
+
const initEncoderObject = message.wasmBinary ? { wasmBinary: message.wasmBinary } : {};
|
|
90
|
+
encoderPromise = DracoEncoderModule(initEncoderObject);
|
|
91
|
+
postMessage({ id: "initDone" });
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case "encodeMesh": {
|
|
95
|
+
if (!encoderPromise) {
|
|
96
|
+
throw new Error("Draco encoder module is not available");
|
|
97
|
+
}
|
|
98
|
+
encoderPromise.then((encoder) => {
|
|
99
|
+
const result = EncodeMesh(encoder, message.attributes, message.indices, message.options);
|
|
100
|
+
postMessage({ id: "encodeMeshDone", encodedMeshData: result }, result ? [result.data.buffer] : undefined);
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @internal
|
|
109
|
+
*/
|
|
110
|
+
export function DecodeMesh(module /** DecoderModule */, data, attributeIDs, onIndicesData, onAttributeData) {
|
|
111
|
+
const decoderModule = module;
|
|
5
112
|
let decoder = null;
|
|
6
113
|
let buffer = null;
|
|
7
114
|
let geometry = null;
|
|
@@ -48,7 +155,7 @@ export function decodeMesh(decoderModule /*DecoderModule*/, data, attributes, on
|
|
|
48
155
|
}
|
|
49
156
|
}
|
|
50
157
|
const numPoints = geometry.num_points();
|
|
51
|
-
const processAttribute = (decoder, geometry, kind, attribute) => {
|
|
158
|
+
const processAttribute = (decoder, geometry, kind, attribute /** Attribute */) => {
|
|
52
159
|
const dataType = attribute.data_type();
|
|
53
160
|
const numComponents = attribute.num_components();
|
|
54
161
|
const normalized = attribute.normalized();
|
|
@@ -72,6 +179,7 @@ export function decodeMesh(decoderModule /*DecoderModule*/, data, attributes, on
|
|
|
72
179
|
const ptr = decoderModule._malloc(byteLength);
|
|
73
180
|
try {
|
|
74
181
|
decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);
|
|
182
|
+
// this cast seems to be needed because of an issue with typescript, as all constructors do have the ptr and numValues arguments.
|
|
75
183
|
const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);
|
|
76
184
|
onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);
|
|
77
185
|
}
|
|
@@ -79,9 +187,9 @@ export function decodeMesh(decoderModule /*DecoderModule*/, data, attributes, on
|
|
|
79
187
|
decoderModule._free(ptr);
|
|
80
188
|
}
|
|
81
189
|
};
|
|
82
|
-
if (
|
|
83
|
-
for (const kind in
|
|
84
|
-
const id =
|
|
190
|
+
if (attributeIDs) {
|
|
191
|
+
for (const kind in attributeIDs) {
|
|
192
|
+
const id = attributeIDs[kind];
|
|
85
193
|
const attribute = decoder.GetAttributeByUniqueId(geometry, id);
|
|
86
194
|
processAttribute(decoder, geometry, kind, attribute);
|
|
87
195
|
}
|
|
@@ -119,18 +227,17 @@ export function decodeMesh(decoderModule /*DecoderModule*/, data, attributes, on
|
|
|
119
227
|
* The worker function that gets converted to a blob url to pass into a worker.
|
|
120
228
|
* To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.
|
|
121
229
|
*/
|
|
122
|
-
export function
|
|
230
|
+
export function DecoderWorkerFunction() {
|
|
123
231
|
let decoderPromise;
|
|
124
232
|
onmessage = (event) => {
|
|
125
233
|
const message = event.data;
|
|
126
234
|
switch (message.id) {
|
|
127
235
|
case "init": {
|
|
128
|
-
const decoder = message.decoder;
|
|
129
236
|
// if URL is provided then load the script. Otherwise expect the script to be loaded already
|
|
130
|
-
if (
|
|
131
|
-
importScripts(
|
|
237
|
+
if (message.url) {
|
|
238
|
+
importScripts(message.url);
|
|
132
239
|
}
|
|
133
|
-
const initDecoderObject =
|
|
240
|
+
const initDecoderObject = message.wasmBinary ? { wasmBinary: message.wasmBinary } : {};
|
|
134
241
|
decoderPromise = DracoDecoderModule(initDecoderObject);
|
|
135
242
|
postMessage({ id: "initDone" });
|
|
136
243
|
break;
|
|
@@ -140,7 +247,7 @@ export function workerFunction() {
|
|
|
140
247
|
throw new Error("Draco decoder module is not available");
|
|
141
248
|
}
|
|
142
249
|
decoderPromise.then((decoder) => {
|
|
143
|
-
const numPoints =
|
|
250
|
+
const numPoints = DecodeMesh(decoder, message.dataView, message.attributes, (indices) => {
|
|
144
251
|
postMessage({ id: "indices", data: indices }, [indices.buffer]);
|
|
145
252
|
}, (kind, data, size, offset, stride, normalized) => {
|
|
146
253
|
postMessage({ id: "attribute", kind, data, size, byteOffset: offset, byteStride: stride, normalized }, [data.buffer]);
|
|
@@ -152,14 +259,16 @@ export function workerFunction() {
|
|
|
152
259
|
}
|
|
153
260
|
};
|
|
154
261
|
}
|
|
262
|
+
// For backwards compatibility
|
|
263
|
+
export { DecoderWorkerFunction as workerFunction };
|
|
155
264
|
/**
|
|
156
265
|
* Initializes a worker that was created for the draco agent pool
|
|
157
266
|
* @param worker The worker to initialize
|
|
158
|
-
* @param
|
|
267
|
+
* @param wasmBinary The wasm binary to load into the worker
|
|
159
268
|
* @param moduleUrl The url to the draco decoder module (optional)
|
|
160
269
|
* @returns A promise that resolves when the worker is initialized
|
|
161
270
|
*/
|
|
162
|
-
export function initializeWebWorker(worker,
|
|
271
|
+
export function initializeWebWorker(worker, wasmBinary, moduleUrl) {
|
|
163
272
|
return new Promise((resolve, reject) => {
|
|
164
273
|
const onError = (error) => {
|
|
165
274
|
worker.removeEventListener("error", onError);
|
|
@@ -175,23 +284,20 @@ export function initializeWebWorker(worker, decoderWasmBinary, moduleUrl) {
|
|
|
175
284
|
};
|
|
176
285
|
worker.addEventListener("error", onError);
|
|
177
286
|
worker.addEventListener("message", onMessage);
|
|
178
|
-
|
|
287
|
+
// Load with either JS-only or WASM version
|
|
288
|
+
if (!wasmBinary) {
|
|
179
289
|
worker.postMessage({
|
|
180
290
|
id: "init",
|
|
181
|
-
|
|
182
|
-
url: moduleUrl,
|
|
183
|
-
},
|
|
291
|
+
url: moduleUrl,
|
|
184
292
|
});
|
|
185
293
|
}
|
|
186
294
|
else {
|
|
187
295
|
// clone the array buffer to make it transferable
|
|
188
|
-
const clone =
|
|
296
|
+
const clone = wasmBinary.slice(0);
|
|
189
297
|
worker.postMessage({
|
|
190
298
|
id: "init",
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
wasmBinary: clone,
|
|
194
|
-
},
|
|
299
|
+
url: moduleUrl,
|
|
300
|
+
wasmBinary: clone,
|
|
195
301
|
}, [clone]);
|
|
196
302
|
}
|
|
197
303
|
// note: no transfer list as the ArrayBuffer is shared across main thread and pool workers
|