@babylonjs/core 7.3.1 → 7.3.3
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/condition.js.map +1 -1
- package/Actions/directActions.js.map +1 -1
- package/Actions/directAudioActions.js.map +1 -1
- package/Actions/interpolateValueAction.js.map +1 -1
- package/Animations/easing.js.map +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
- package/Bones/bone.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphArcRotateCamera.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphFreeCamera.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphGamepadCamera.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphUniversalCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicArcRotateCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicFreeCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicGamepadCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicUniversalCamera.js.map +1 -1
- package/Cameras/VR/vrDeviceOrientationArcRotateCamera.js.map +1 -1
- package/Cameras/VR/vrDeviceOrientationFreeCamera.js.map +1 -1
- package/Cameras/VR/vrDeviceOrientationGamepadCamera.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.js.map +1 -1
- package/Cameras/deviceOrientationCamera.js.map +1 -1
- package/Cameras/flyCamera.js.map +1 -1
- package/Cameras/followCamera.js.map +1 -1
- package/Cameras/freeCamera.js.map +1 -1
- package/Cameras/freeCameraInputsManager.js.map +1 -1
- package/Cameras/gamepadCamera.js.map +1 -1
- package/Cameras/targetCamera.js.map +1 -1
- package/Cameras/touchCamera.js.map +1 -1
- package/Cameras/universalCamera.js.map +1 -1
- package/Cameras/virtualJoysticksCamera.js.map +1 -1
- package/Compute/computeEffect.js +4 -4
- package/Compute/computeEffect.js.map +1 -1
- package/Debug/boneAxesViewer.js.map +1 -1
- package/Engines/IPipelineContext.d.ts +3 -0
- package/Engines/IPipelineContext.js.map +1 -1
- package/Engines/Native/nativePipelineContext.d.ts +2 -0
- package/Engines/Native/nativePipelineContext.js +3 -0
- package/Engines/Native/nativePipelineContext.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineAndOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineOrOperator.js.map +1 -1
- package/Engines/Processors/iShaderProcessor.d.ts +3 -2
- package/Engines/Processors/iShaderProcessor.js.map +1 -1
- package/Engines/Processors/shaderCodeConditionNode.js.map +1 -1
- package/Engines/Processors/shaderCodeTestNode.js.map +1 -1
- package/Engines/Processors/shaderProcessor.d.ts +15 -23
- package/Engines/Processors/shaderProcessor.js +332 -320
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGL/webGLPipelineContext.d.ts +2 -0
- package/Engines/WebGL/webGLPipelineContext.js +3 -0
- package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGL/webGLShaderProcessors.d.ts +3 -2
- package/Engines/WebGL/webGLShaderProcessors.js +2 -2
- package/Engines/WebGL/webGLShaderProcessors.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js +1 -1
- package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +10 -10
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js.map +1 -1
- package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +2 -0
- package/Engines/WebGPU/webgpuHardwareTexture.js +2 -0
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuPipelineContext.d.ts +2 -0
- package/Engines/WebGPU/webgpuPipelineContext.js +3 -0
- package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.d.ts +3 -2
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -4
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
- package/Engines/abstractEngine.d.ts +10 -5
- package/Engines/abstractEngine.functions.d.ts +38 -0
- package/Engines/abstractEngine.functions.js +75 -0
- package/Engines/abstractEngine.functions.js.map +1 -0
- package/Engines/abstractEngine.js +34 -14
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +2 -0
- package/Engines/constants.js +2 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +0 -8
- package/Engines/engine.js +0 -28
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +11 -6
- package/Engines/thinEngine.functions.d.ts +96 -0
- package/Engines/thinEngine.functions.js +249 -0
- package/Engines/thinEngine.functions.js.map +1 -0
- package/Engines/thinEngine.js +50 -129
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +5 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/keyboardEvents.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/Gamepads/dualShockGamepad.js.map +1 -1
- package/Gamepads/gamepad.js.map +1 -1
- package/Gamepads/xboxGamepad.js.map +1 -1
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Helpers/photoDome.js.map +1 -1
- package/Helpers/textureDome.js.map +1 -1
- package/Helpers/videoDome.js.map +1 -1
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/hemisphericLight.js.map +1 -1
- package/Lights/light.js.map +1 -1
- package/Lights/pointLight.js.map +1 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +3 -3
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/discardBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleRampGradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/arcTan2Block.js.map +1 -1
- package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/Blocks/crossBlock.js.map +1 -1
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/desaturateBlock.js.map +1 -1
- package/Materials/Node/Blocks/distanceBlock.js.map +1 -1
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/dotBlock.js.map +1 -1
- package/Materials/Node/Blocks/elbowBlock.js.map +1 -1
- package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/lengthBlock.js.map +1 -1
- package/Materials/Node/Blocks/lerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixDeterminantBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixTransposeBlock.js.map +1 -1
- package/Materials/Node/Blocks/maxBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/minBlock.js.map +1 -1
- package/Materials/Node/Blocks/modBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/nLerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/negateBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/oneMinusBlock.js.map +1 -1
- package/Materials/Node/Blocks/posterizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/powBlock.js.map +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js.map +1 -1
- package/Materials/Node/Blocks/reciprocalBlock.js.map +1 -1
- package/Materials/Node/Blocks/reflectBlock.js.map +1 -1
- package/Materials/Node/Blocks/refractBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/replaceColorBlock.js.map +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
- package/Materials/Node/Blocks/scaleBlock.js.map +1 -1
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
- package/Materials/Node/Blocks/smoothStepBlock.js.map +1 -1
- package/Materials/Node/Blocks/stepBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.js.map +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/MultiviewRenderTarget.js.map +1 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +9 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +16 -0
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/prePassRenderTarget.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/refractionTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/effect.d.ts +11 -6
- package/Materials/effect.functions.d.ts +86 -0
- package/Materials/effect.functions.js +185 -0
- package/Materials/effect.functions.js.map +1 -0
- package/Materials/effect.js +94 -153
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.d.ts +13 -0
- package/Materials/effect.webgl.functions.js +83 -0
- package/Materials/effect.webgl.functions.js.map +1 -0
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/materialPluginManager.js +2 -2
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/pushMaterial.js.map +1 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/Compression/dracoCompressionWorker.d.ts +1 -1
- package/Meshes/Compression/dracoCompressionWorker.js +21 -10
- package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateLinearBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateRadialBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/alignBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/nullBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/boundingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/computeNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryArcTan2Block.js.map +1 -1
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCrossBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDesaturateBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDistanceBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDotBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryElbowBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInfoBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryLengthBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryLerpBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryModBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryNLerpBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOutputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryPosterizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryPowBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryReplaceColorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryRotate2dBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryStepBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/normalizeVectorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/Node/Blocks/vectorConverterBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.js +1 -0
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/WebGL/webGLDataBuffer.js.map +1 -1
- package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/goldbergMesh.js.map +1 -1
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/trailMesh.js.map +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/depthReducer.js.map +1 -1
- package/Misc/fileTools.js +4 -3
- package/Misc/fileTools.js.map +1 -1
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/smartArray.js.map +1 -1
- package/Misc/workerPool.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/proximityCastResult.js.map +1 -1
- package/Physics/v1/physicsJoint.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
- package/PostProcesses/anaglyphPostProcess.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/displayPassPostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/highlightsPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/refractionPostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/stereoscopicInterlacePostProcess.js.map +1 -1
- package/PostProcesses/subSurfaceScatteringPostProcess.js.map +1 -1
- package/PostProcesses/tonemapPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/vrDistortionCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Sprites/sprite.js.map +1 -1
- package/Sprites/spritePackedManager.js.map +1 -1
- package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
- package/XR/features/Layers/WebXRProjectionLayer.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRBackgroundRemover.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDOMOverlay.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXREyeTracking.js.map +1 -1
- package/XR/features/WebXRFeaturePointSystem.js.map +1 -1
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRHitTestLegacy.js.map +1 -1
- package/XR/features/WebXRImageTracking.js.map +1 -1
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/features/WebXRWalkingLocomotion.js.map +1 -1
- package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
- package/XR/native/nativeXRRenderTarget.js.map +1 -1
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRWebGLLayer.js.map +1 -1
- package/assets/Draco/draco_wasm_wrapper.js +115 -115
- package/package.json +1 -1
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAoC,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAY7H,SAAS,kBAAkB,CAAC,UAAwB,EAAE,QAA6B;IAC/E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,CAAC,QAAQ,IAAI,kBAAkB,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AA6DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,gBAAgB;IAkBzB;;OAEG;IACI,MAAM,KAAK,gBAAgB;QAC9B,MAAM,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,OAAO,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slint-disable @typescript-eslint/naming-convention */\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { DecoderModule } from \"draco3dgltf\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { decodeMesh, type AttributeData, type Message, workerFunction, initializeWebWorker } from \"./dracoCompressionWorker\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\ninterface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\nfunction createDecoderAsync(wasmBinary?: ArrayBuffer, jsModule?: DracoDecoderModule): Promise<{ module: DecoderModule }> {\r\n return new Promise((resolve) => {\r\n (jsModule || DracoDecoderModule)({ wasmBinary }).then((module) => {\r\n resolve({ module });\r\n });\r\n });\r\n}\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: {\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 * Optional worker pool to use for async decoding instead of creating a new worker pool.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The decoder module if already available.\r\n */\r\n jsModule?: any /* DecoderModule */;\r\n };\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions {\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 * 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 * Optional worker pool to use for async decoding.\r\n * If provided, numWorkers will be ignored and the worker pool will be used instead.\r\n * If provided the draco script will not be loaded from the DracoConfiguration.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n}\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 implements IDisposable {\r\n private _workerPoolPromise?: Promise<AutoReleaseWorkerPool>;\r\n private _decoderModulePromise?: Promise<{ module: DecoderModule }>;\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 = {\r\n decoder: {\r\n wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,\r\n wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,\r\n fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,\r\n },\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 const decoder = DracoCompression.Configuration.decoder;\r\n return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\") || decoder.fallbackUrl);\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 = DracoCompression.GetDefaultNumWorkers();\r\n\r\n private static 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 private static _Default: Nullable<DracoCompression> = null;\r\n\r\n /**\r\n * Default instance for the draco compression object.\r\n */\r\n public static get Default(): DracoCompression {\r\n if (!DracoCompression._Default) {\r\n DracoCompression._Default = new DracoCompression();\r\n }\r\n\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n constructor(numWorkers: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n // check if the decoder 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 (decoder.workerPool || (typeof numWorkers === \"object\" && numWorkers.workerPool)) {\r\n // set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(decoder.workerPool || (numWorkers as IDracoCompressionOptions).workerPool!);\r\n } else {\r\n // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = decoder.wasmBinary || (typeof numWorkers === \"object\" && numWorkers.wasmBinary);\r\n const numberOfWorkers = typeof numWorkers === \"number\" ? numWorkers : numWorkers.numWorkers;\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || (!useWorkers && !decoder.jsModule);\r\n // code maintained here for back-compat with no changes\r\n\r\n const decoderInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n if (useWorkers) {\r\n this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {\r\n const workerContent = `${decodeMesh}(${workerFunction})()`;\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, decoderWasmBinary!, decoderInfo.url);\r\n });\r\n });\r\n } else {\r\n this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {\r\n if (typeof DracoDecoderModule === \"undefined\") {\r\n if (!decoder.jsModule) {\r\n if (!decoderInfo.url) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(decoderInfo.url);\r\n }\r\n }\r\n return await createDecoderAsync(decoderWasmBinary as ArrayBuffer, decoder.jsModule);\r\n });\r\n }\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._decoderModulePromise;\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 if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n await this._decoderModulePromise;\r\n return;\r\n }\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 const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const applyGltfNormalizedOverride = (kind: string, normalized: boolean): boolean => {\r\n if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {\r\n if (normalized !== gltfNormalizedOverride[kind]) {\r\n Logger.Warn(\r\n `Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`\r\n );\r\n }\r\n\r\n return gltfNormalizedOverride[kind];\r\n } else {\r\n return normalized;\r\n }\r\n };\r\n\r\n if (this._workerPoolPromise) {\r\n return this._workerPoolPromise.then((workerPool) => {\r\n return new Promise<MeshData>((resolve, reject) => {\r\n workerPool.push((worker, onComplete) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n onComplete();\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"decodeMeshDone\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve({ indices: resultIndices!, attributes: resultAttributes, totalVertices: message.totalVertices });\r\n onComplete();\r\n break;\r\n }\r\n case \"indices\": {\r\n resultIndices = message.data;\r\n break;\r\n }\r\n case \"attribute\": {\r\n resultAttributes.push({\r\n kind: message.kind,\r\n data: message.data,\r\n size: message.size,\r\n byteOffset: message.byteOffset,\r\n byteStride: message.byteStride,\r\n normalized: applyGltfNormalizedOverride(message.kind, message.normalized),\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n const dataViewCopy = dataView.slice();\r\n worker.postMessage({ id: \"decodeMesh\", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);\r\n });\r\n });\r\n });\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n return this._decoderModulePromise.then((decoder) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const numPoints = decodeMesh(\r\n decoder.module,\r\n dataView,\r\n attributes,\r\n (indices) => {\r\n resultIndices = indices;\r\n },\r\n (kind, data, size, byteOffset, byteStride, normalized) => {\r\n resultAttributes.push({\r\n kind,\r\n data,\r\n size,\r\n byteOffset,\r\n byteStride,\r\n normalized,\r\n });\r\n }\r\n );\r\n\r\n return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };\r\n });\r\n }\r\n\r\n throw new Error(\"Draco decoder module is not available\");\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 const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\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 ): Promise<Geometry> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\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.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,yDAAyD;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC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,OAAO,CAAC;SACzC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE;YACzC,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;SAC7C;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AAvVD;;;;;GAKG;AACW,8BAAa,GAAmC;IAC1D,OAAO,EAAE;QACL,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,6BAA6B;QAC7D,aAAa,EAAE,GAAG,KAAK,CAAC,cAAc,0BAA0B;QAChE,WAAW,EAAE,GAAG,KAAK,CAAC,cAAc,wBAAwB;KAC/D;CACJ,CAAC;AAUF;;GAEG;AACW,kCAAiB,GAAG,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AAW3D,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { DecoderModule } from \"draco3dgltf\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { decodeMesh, type AttributeData, type Message, workerFunction, initializeWebWorker } from \"./dracoCompressionWorker\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\ninterface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\nfunction createDecoderAsync(wasmBinary?: ArrayBuffer, jsModule?: DracoDecoderModule): Promise<{ module: DecoderModule }> {\r\n return new Promise((resolve) => {\r\n (jsModule || DracoDecoderModule)({ wasmBinary }).then((module) => {\r\n resolve({ module });\r\n });\r\n });\r\n}\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: {\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 * Optional worker pool to use for async decoding instead of creating a new worker pool.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The decoder module if already available.\r\n */\r\n jsModule?: any /* DecoderModule */;\r\n };\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions {\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 * 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 * Optional worker pool to use for async decoding.\r\n * If provided, numWorkers will be ignored and the worker pool will be used instead.\r\n * If provided the draco script will not be loaded from the DracoConfiguration.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n}\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 implements IDisposable {\r\n private _workerPoolPromise?: Promise<AutoReleaseWorkerPool>;\r\n private _decoderModulePromise?: Promise<{ module: DecoderModule }>;\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 = {\r\n decoder: {\r\n wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,\r\n wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,\r\n fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,\r\n },\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 const decoder = DracoCompression.Configuration.decoder;\r\n return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\") || decoder.fallbackUrl);\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 = DracoCompression.GetDefaultNumWorkers();\r\n\r\n private static 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 private static _Default: Nullable<DracoCompression> = null;\r\n\r\n /**\r\n * Default instance for the draco compression object.\r\n */\r\n public static get Default(): DracoCompression {\r\n if (!DracoCompression._Default) {\r\n DracoCompression._Default = new DracoCompression();\r\n }\r\n\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n constructor(numWorkers: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n // check if the decoder 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 (decoder.workerPool || (typeof numWorkers === \"object\" && numWorkers.workerPool)) {\r\n // set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(decoder.workerPool || (numWorkers as IDracoCompressionOptions).workerPool!);\r\n } else {\r\n // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = decoder.wasmBinary || (typeof numWorkers === \"object\" && numWorkers.wasmBinary);\r\n const numberOfWorkers = typeof numWorkers === \"number\" ? numWorkers : numWorkers.numWorkers;\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || (!useWorkers && !decoder.jsModule);\r\n // code maintained here for back-compat with no changes\r\n\r\n const decoderInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n if (useWorkers) {\r\n this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {\r\n const workerContent = `${decodeMesh}(${workerFunction})()`;\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, decoderWasmBinary, decoderInfo.url);\r\n });\r\n });\r\n } else {\r\n this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {\r\n if (typeof DracoDecoderModule === \"undefined\") {\r\n if (!decoder.jsModule) {\r\n if (!decoderInfo.url) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(decoderInfo.url);\r\n }\r\n }\r\n return await createDecoderAsync(decoderWasmBinary as ArrayBuffer, decoder.jsModule);\r\n });\r\n }\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._decoderModulePromise;\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 if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n await this._decoderModulePromise;\r\n return;\r\n }\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 const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const applyGltfNormalizedOverride = (kind: string, normalized: boolean): boolean => {\r\n if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {\r\n if (normalized !== gltfNormalizedOverride[kind]) {\r\n Logger.Warn(\r\n `Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`\r\n );\r\n }\r\n\r\n return gltfNormalizedOverride[kind];\r\n } else {\r\n return normalized;\r\n }\r\n };\r\n\r\n if (this._workerPoolPromise) {\r\n return this._workerPoolPromise.then((workerPool) => {\r\n return new Promise<MeshData>((resolve, reject) => {\r\n workerPool.push((worker, onComplete) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n onComplete();\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"decodeMeshDone\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve({ indices: resultIndices!, attributes: resultAttributes, totalVertices: message.totalVertices });\r\n onComplete();\r\n break;\r\n }\r\n case \"indices\": {\r\n resultIndices = message.data;\r\n break;\r\n }\r\n case \"attribute\": {\r\n resultAttributes.push({\r\n kind: message.kind,\r\n data: message.data,\r\n size: message.size,\r\n byteOffset: message.byteOffset,\r\n byteStride: message.byteStride,\r\n normalized: applyGltfNormalizedOverride(message.kind, message.normalized),\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n const dataViewCopy = dataView.slice();\r\n worker.postMessage({ id: \"decodeMesh\", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);\r\n });\r\n });\r\n });\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n return this._decoderModulePromise.then((decoder) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const numPoints = decodeMesh(\r\n decoder.module,\r\n dataView,\r\n attributes,\r\n (indices) => {\r\n resultIndices = indices;\r\n },\r\n (kind, data, size, byteOffset, byteStride, normalized) => {\r\n resultAttributes.push({\r\n kind,\r\n data,\r\n size,\r\n byteOffset,\r\n byteStride,\r\n normalized,\r\n });\r\n }\r\n );\r\n\r\n return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };\r\n });\r\n }\r\n\r\n throw new Error(\"Draco decoder module is not available\");\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 const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\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 ): Promise<Geometry> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\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.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"]}
|
|
@@ -39,5 +39,5 @@ export declare function workerFunction(): void;
|
|
|
39
39
|
* @param moduleUrl The url to the draco decoder module (optional)
|
|
40
40
|
* @returns A promise that resolves when the worker is initialized
|
|
41
41
|
*/
|
|
42
|
-
export declare function initializeWebWorker(worker: Worker, decoderWasmBinary
|
|
42
|
+
export declare function initializeWebWorker(worker: Worker, decoderWasmBinary?: ArrayBuffer, moduleUrl?: string): Promise<Worker>;
|
|
43
43
|
export {};
|
|
@@ -130,7 +130,8 @@ export function workerFunction() {
|
|
|
130
130
|
if (decoder.url) {
|
|
131
131
|
importScripts(decoder.url);
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
const initDecoderObject = decoder.wasmBinary ? { wasmBinary: decoder.wasmBinary } : {};
|
|
134
|
+
decoderPromise = DracoDecoderModule(initDecoderObject);
|
|
134
135
|
postMessage({ id: "initDone" });
|
|
135
136
|
break;
|
|
136
137
|
}
|
|
@@ -174,15 +175,25 @@ export function initializeWebWorker(worker, decoderWasmBinary, moduleUrl) {
|
|
|
174
175
|
};
|
|
175
176
|
worker.addEventListener("error", onError);
|
|
176
177
|
worker.addEventListener("message", onMessage);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
if (!decoderWasmBinary) {
|
|
179
|
+
worker.postMessage({
|
|
180
|
+
id: "init",
|
|
181
|
+
decoder: {
|
|
182
|
+
url: moduleUrl,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
// clone the array buffer to make it transferable
|
|
188
|
+
const clone = decoderWasmBinary.slice(0);
|
|
189
|
+
worker.postMessage({
|
|
190
|
+
id: "init",
|
|
191
|
+
decoder: {
|
|
192
|
+
url: moduleUrl,
|
|
193
|
+
wasmBinary: clone,
|
|
194
|
+
},
|
|
195
|
+
}, [clone]);
|
|
196
|
+
}
|
|
186
197
|
// note: no transfer list as the ArrayBuffer is shared across main thread and pool workers
|
|
187
198
|
});
|
|
188
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dracoCompressionWorker.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompressionWorker.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,aAAkB,CAAC,iBAAiB,EACpC,IAAe,EACf,UAAkD,EAClD,aAA2D,EAC3D,eAAiI;IAEjI,IAAI,OAAO,GAAsB,IAAI,CAAC;IACtC,IAAI,MAAM,GAA4B,IAAI,CAAC;IAC3C,IAAI,QAAQ,GAAgC,IAAI,CAAC;IAEjD,IAAI;QACA,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,EAAa,CAAC;QAEjD,MAAM,GAAG,IAAI,aAAa,CAAC,aAAa,EAAmB,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEnC,IAAI,MAAc,CAAC;QACnB,MAAM,I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ACL,CAAC,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,iBAA8B,EAAE,SAAkB;IAClG,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,CAAC,KAAiB,EAAE,EAAE;YAClC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACjD,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,KAA4B,EAAE,EAAE;YAC/C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,EAAE;gBAC9B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC7C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjD,OAAO,CAAC,MAAM,CAAC,CAAC;aACnB;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE9C,iDAAiD;QACjD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,WAAW,CACd;YACI,EAAE,EAAE,MAAM;YACV,OAAO,EAAE;gBACL,GAAG,EAAE,SAAS;gBACd,UAAU,EAAE,KAAK;aACpB;SACJ,EACD,CAAC,KAAK,CAAC,CACV,CAAC;QACF,0FAA0F;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DecoderBuffer, Decoder, Mesh, PointCloud, Status } from \"draco3dgltf\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\nexport interface AttributeData {\r\n kind: string;\r\n data: ArrayBufferView;\r\n size: number;\r\n byteOffset: number;\r\n byteStride: number;\r\n normalized: boolean;\r\n}\r\n\r\ninterface InitDoneMessage {\r\n id: \"initDone\";\r\n}\r\n\r\ninterface DecodeMeshDoneMessage {\r\n id: \"decodeMeshDone\";\r\n totalVertices: number;\r\n}\r\n\r\ninterface IndicesMessage {\r\n id: \"indices\";\r\n data: Uint16Array | Uint32Array;\r\n}\r\n\r\ninterface AttributeMessage extends AttributeData {\r\n id: \"attribute\";\r\n}\r\nexport type Message = InitDoneMessage | DecodeMeshDoneMessage | IndicesMessage | AttributeMessage;\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: Message, transfer?: any[]): void;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function decodeMesh(\r\n decoderModule: any /*DecoderModule*/,\r\n data: Int8Array,\r\n attributes: { [kind: string]: number } | undefined,\r\n onIndicesData: (indices: Uint16Array | Uint32Array) => void,\r\n onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void\r\n): number {\r\n let decoder: Nullable<Decoder> = null;\r\n let buffer: Nullable<DecoderBuffer> = null;\r\n let geometry: Nullable<Mesh | PointCloud> = null;\r\n\r\n try {\r\n decoder = new decoderModule.Decoder() as Decoder;\r\n\r\n buffer = new decoderModule.DecoderBuffer() as DecoderBuffer;\r\n buffer.Init(data, data.byteLength);\r\n\r\n let status: Status;\r\n const type = decoder.GetEncodedGeometryType(buffer);\r\n switch (type) {\r\n case decoderModule.TRIANGULAR_MESH: {\r\n const mesh = new decoderModule.Mesh();\r\n status = decoder.DecodeBufferToMesh(buffer, mesh);\r\n if (!status.ok() || mesh.ptr === 0) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n const numFaces = mesh.num_faces();\r\n const numIndices = numFaces * 3;\r\n const byteLength = numIndices * 4;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetTrianglesUInt32Array(mesh, byteLength, ptr);\r\n const indices = new Uint32Array(numIndices);\r\n indices.set(new Uint32Array(decoderModule.HEAPF32.buffer, ptr, numIndices));\r\n onIndicesData(indices);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n\r\n geometry = mesh as Mesh;\r\n break;\r\n }\r\n case decoderModule.POINT_CLOUD: {\r\n const pointCloud = new decoderModule.PointCloud();\r\n status = decoder.DecodeBufferToPointCloud(buffer, pointCloud);\r\n if (!status.ok() || !pointCloud.ptr) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n geometry = pointCloud as PointCloud;\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid geometry type ${type}`);\r\n }\r\n }\r\n\r\n const numPoints = geometry.num_points();\r\n\r\n const processAttribute = (decoder: Decoder, geometry: Mesh | PointCloud, kind: string, attribute: any) => {\r\n const dataType = attribute.data_type();\r\n const numComponents = attribute.num_components();\r\n const normalized = attribute.normalized();\r\n const byteStride = attribute.byte_stride();\r\n const byteOffset = attribute.byte_offset();\r\n\r\n const dataTypeInfo = {\r\n [decoderModule.DT_FLOAT32]: { typedArrayConstructor: Float32Array, heap: decoderModule.HEAPF32 },\r\n [decoderModule.DT_INT8]: { typedArrayConstructor: Int8Array, heap: decoderModule.HEAP8 },\r\n [decoderModule.DT_INT16]: { typedArrayConstructor: Int16Array, heap: decoderModule.HEAP16 },\r\n [decoderModule.DT_INT32]: { typedArrayConstructor: Int32Array, heap: decoderModule.HEAP32 },\r\n [decoderModule.DT_UINT8]: { typedArrayConstructor: Uint8Array, heap: decoderModule.HEAPU8 },\r\n [decoderModule.DT_UINT16]: { typedArrayConstructor: Uint16Array, heap: decoderModule.HEAPU16 },\r\n [decoderModule.DT_UINT32]: { typedArrayConstructor: Uint32Array, heap: decoderModule.HEAPU32 },\r\n };\r\n\r\n const info = dataTypeInfo[dataType];\r\n if (!info) {\r\n throw new Error(`Invalid data type ${dataType}`);\r\n }\r\n\r\n const numValues = numPoints * numComponents;\r\n const byteLength = numValues * info.typedArrayConstructor.BYTES_PER_ELEMENT;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);\r\n const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);\r\n onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n };\r\n\r\n if (attributes) {\r\n for (const kind in attributes) {\r\n const id = attributes[kind];\r\n const attribute = decoder.GetAttributeByUniqueId(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n } else {\r\n const dracoAttributeTypes: { [kind: string]: number } = {\r\n position: decoderModule.POSITION,\r\n normal: decoderModule.NORMAL,\r\n color: decoderModule.COLOR,\r\n uv: decoderModule.TEX_COORD,\r\n };\r\n\r\n for (const kind in dracoAttributeTypes) {\r\n const id = decoder.GetAttributeId(geometry, dracoAttributeTypes[kind]);\r\n if (id !== -1) {\r\n const attribute = decoder.GetAttribute(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n }\r\n }\r\n\r\n return numPoints;\r\n } finally {\r\n if (geometry) {\r\n decoderModule.destroy(geometry);\r\n }\r\n\r\n if (buffer) {\r\n decoderModule.destroy(buffer);\r\n }\r\n\r\n if (decoder) {\r\n decoderModule.destroy(decoder);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n * To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.\r\n */\r\nexport function workerFunction(): void {\r\n let decoderPromise: PromiseLike<any> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n const decoder = message.decoder;\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (decoder.url) {\r\n importScripts(decoder.url);\r\n }\r\n decoderPromise = DracoDecoderModule({ wasmBinary: decoder.wasmBinary });\r\n postMessage({ id: \"initDone\" });\r\n break;\r\n }\r\n case \"decodeMesh\": {\r\n if (!decoderPromise) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n decoderPromise.then((decoder) => {\r\n const numPoints = decodeMesh(\r\n decoder,\r\n message.dataView,\r\n message.attributes,\r\n (indices) => {\r\n postMessage({ id: \"indices\", data: indices }, [indices.buffer]);\r\n },\r\n (kind, data, size, offset, stride, normalized) => {\r\n postMessage({ id: \"attribute\", kind, data, size, byteOffset: offset, byteStride: stride, normalized }, [data.buffer]);\r\n }\r\n );\r\n postMessage({ id: \"decodeMeshDone\", totalVertices: numPoints });\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Initializes a worker that was created for the draco agent pool\r\n * @param worker The worker to initialize\r\n * @param decoderWasmBinary The wasm binary to load into the worker\r\n * @param moduleUrl The url to the draco decoder module (optional)\r\n * @returns A promise that resolves when the worker is initialized\r\n */\r\nexport function initializeWebWorker(worker: Worker, decoderWasmBinary: ArrayBuffer, moduleUrl?: string): Promise<Worker> {\r\n return new Promise<Worker>((resolve, reject) => {\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n if (event.data.id === \"initDone\") {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(worker);\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n // clone the array buffer to make it transferable\r\n const clone = decoderWasmBinary.slice(0);\r\n worker.postMessage(\r\n {\r\n id: \"init\",\r\n decoder: {\r\n url: moduleUrl,\r\n wasmBinary: clone,\r\n },\r\n },\r\n [clone]\r\n );\r\n // note: no transfer list as the ArrayBuffer is shared across main thread and pool workers\r\n });\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dracoCompressionWorker.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompressionWorker.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,aAAkB,CAAC,iBAAiB,EACpC,IAAe,EACf,UAAkD,EAClD,aAA2D,EAC3D,eAAiI;IAEjI,IAAI,OAAO,GAAsB,IAAI,CAAC;IACtC,IAAI,MAAM,GAA4B,IAAI,CAAC;IAC3C,IAAI,QAAQ,GAAgC,IAAI,CAAC;IAEjD,IAAI;QACA,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,EAAa,CAAC;QAEjD,MAAM,GAAG,IAAI,aAAa,CAAC,aAAa,EAAmB,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEnC,IAAI,MAAc,CAAC;QACnB,MAAM,IAAI,GAAG,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACpD,QAAQ,IAAI,EAAE;YACV,KAAK,aAAa,CAAC,eAAe,CAAC,CAAC;gBAChC,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,IAAI,EAAE,CAAC;gBACtC,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAClD,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,EAAE;oBAChC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;iBACvC;gBAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;gBAClC,MAAM,UAAU,GAAG,QAAQ,GAAG,CAAC,CAAC;gBAChC,MAAM,UAAU,GAAG,UAAU,GAAG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/C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,EAAE;gBAC9B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC7C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjD,OAAO,CAAC,MAAM,CAAC,CAAC;aACnB;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE9C,IAAI,CAAC,iBAAiB,EAAE;YACpB,MAAM,CAAC,WAAW,CAAC;gBACf,EAAE,EAAE,MAAM;gBACV,OAAO,EAAE;oBACL,GAAG,EAAE,SAAS;iBACjB;aACJ,CAAC,CAAC;SACN;aAAM;YACH,iDAAiD;YACjD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,WAAW,CACd;gBACI,EAAE,EAAE,MAAM;gBACV,OAAO,EAAE;oBACL,GAAG,EAAE,SAAS;oBACd,UAAU,EAAE,KAAK;iBACpB;aACJ,EACD,CAAC,KAAK,CAAC,CACV,CAAC;SACL;QACD,0FAA0F;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DecoderBuffer, Decoder, Mesh, PointCloud, Status } from \"draco3dgltf\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\nexport interface AttributeData {\r\n kind: string;\r\n data: ArrayBufferView;\r\n size: number;\r\n byteOffset: number;\r\n byteStride: number;\r\n normalized: boolean;\r\n}\r\n\r\ninterface InitDoneMessage {\r\n id: \"initDone\";\r\n}\r\n\r\ninterface DecodeMeshDoneMessage {\r\n id: \"decodeMeshDone\";\r\n totalVertices: number;\r\n}\r\n\r\ninterface IndicesMessage {\r\n id: \"indices\";\r\n data: Uint16Array | Uint32Array;\r\n}\r\n\r\ninterface AttributeMessage extends AttributeData {\r\n id: \"attribute\";\r\n}\r\nexport type Message = InitDoneMessage | DecodeMeshDoneMessage | IndicesMessage | AttributeMessage;\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: Message, transfer?: any[]): void;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function decodeMesh(\r\n decoderModule: any /*DecoderModule*/,\r\n data: Int8Array,\r\n attributes: { [kind: string]: number } | undefined,\r\n onIndicesData: (indices: Uint16Array | Uint32Array) => void,\r\n onAttributeData: (kind: string, data: ArrayBufferView, size: number, offset: number, stride: number, normalized: boolean) => void\r\n): number {\r\n let decoder: Nullable<Decoder> = null;\r\n let buffer: Nullable<DecoderBuffer> = null;\r\n let geometry: Nullable<Mesh | PointCloud> = null;\r\n\r\n try {\r\n decoder = new decoderModule.Decoder() as Decoder;\r\n\r\n buffer = new decoderModule.DecoderBuffer() as DecoderBuffer;\r\n buffer.Init(data, data.byteLength);\r\n\r\n let status: Status;\r\n const type = decoder.GetEncodedGeometryType(buffer);\r\n switch (type) {\r\n case decoderModule.TRIANGULAR_MESH: {\r\n const mesh = new decoderModule.Mesh();\r\n status = decoder.DecodeBufferToMesh(buffer, mesh);\r\n if (!status.ok() || mesh.ptr === 0) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n const numFaces = mesh.num_faces();\r\n const numIndices = numFaces * 3;\r\n const byteLength = numIndices * 4;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetTrianglesUInt32Array(mesh, byteLength, ptr);\r\n const indices = new Uint32Array(numIndices);\r\n indices.set(new Uint32Array(decoderModule.HEAPF32.buffer, ptr, numIndices));\r\n onIndicesData(indices);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n\r\n geometry = mesh as Mesh;\r\n break;\r\n }\r\n case decoderModule.POINT_CLOUD: {\r\n const pointCloud = new decoderModule.PointCloud();\r\n status = decoder.DecodeBufferToPointCloud(buffer, pointCloud);\r\n if (!status.ok() || !pointCloud.ptr) {\r\n throw new Error(status.error_msg());\r\n }\r\n\r\n geometry = pointCloud as PointCloud;\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Invalid geometry type ${type}`);\r\n }\r\n }\r\n\r\n const numPoints = geometry.num_points();\r\n\r\n const processAttribute = (decoder: Decoder, geometry: Mesh | PointCloud, kind: string, attribute: any) => {\r\n const dataType = attribute.data_type();\r\n const numComponents = attribute.num_components();\r\n const normalized = attribute.normalized();\r\n const byteStride = attribute.byte_stride();\r\n const byteOffset = attribute.byte_offset();\r\n\r\n const dataTypeInfo = {\r\n [decoderModule.DT_FLOAT32]: { typedArrayConstructor: Float32Array, heap: decoderModule.HEAPF32 },\r\n [decoderModule.DT_INT8]: { typedArrayConstructor: Int8Array, heap: decoderModule.HEAP8 },\r\n [decoderModule.DT_INT16]: { typedArrayConstructor: Int16Array, heap: decoderModule.HEAP16 },\r\n [decoderModule.DT_INT32]: { typedArrayConstructor: Int32Array, heap: decoderModule.HEAP32 },\r\n [decoderModule.DT_UINT8]: { typedArrayConstructor: Uint8Array, heap: decoderModule.HEAPU8 },\r\n [decoderModule.DT_UINT16]: { typedArrayConstructor: Uint16Array, heap: decoderModule.HEAPU16 },\r\n [decoderModule.DT_UINT32]: { typedArrayConstructor: Uint32Array, heap: decoderModule.HEAPU32 },\r\n };\r\n\r\n const info = dataTypeInfo[dataType];\r\n if (!info) {\r\n throw new Error(`Invalid data type ${dataType}`);\r\n }\r\n\r\n const numValues = numPoints * numComponents;\r\n const byteLength = numValues * info.typedArrayConstructor.BYTES_PER_ELEMENT;\r\n\r\n const ptr = decoderModule._malloc(byteLength);\r\n try {\r\n decoder.GetAttributeDataArrayForAllPoints(geometry, attribute, dataType, byteLength, ptr);\r\n const data = new info.typedArrayConstructor(info.heap.buffer, ptr, numValues);\r\n onAttributeData(kind, data.slice(), numComponents, byteOffset, byteStride, normalized);\r\n } finally {\r\n decoderModule._free(ptr);\r\n }\r\n };\r\n\r\n if (attributes) {\r\n for (const kind in attributes) {\r\n const id = attributes[kind];\r\n const attribute = decoder.GetAttributeByUniqueId(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n } else {\r\n const dracoAttributeTypes: { [kind: string]: number } = {\r\n position: decoderModule.POSITION,\r\n normal: decoderModule.NORMAL,\r\n color: decoderModule.COLOR,\r\n uv: decoderModule.TEX_COORD,\r\n };\r\n\r\n for (const kind in dracoAttributeTypes) {\r\n const id = decoder.GetAttributeId(geometry, dracoAttributeTypes[kind]);\r\n if (id !== -1) {\r\n const attribute = decoder.GetAttribute(geometry, id);\r\n processAttribute(decoder, geometry, kind, attribute);\r\n }\r\n }\r\n }\r\n\r\n return numPoints;\r\n } finally {\r\n if (geometry) {\r\n decoderModule.destroy(geometry);\r\n }\r\n\r\n if (buffer) {\r\n decoderModule.destroy(buffer);\r\n }\r\n\r\n if (decoder) {\r\n decoderModule.destroy(decoder);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n * To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.\r\n */\r\nexport function workerFunction(): void {\r\n let decoderPromise: PromiseLike<any> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n const decoder = message.decoder;\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (decoder.url) {\r\n importScripts(decoder.url);\r\n }\r\n const initDecoderObject = decoder.wasmBinary ? { wasmBinary: decoder.wasmBinary } : {};\r\n decoderPromise = DracoDecoderModule(initDecoderObject);\r\n postMessage({ id: \"initDone\" });\r\n break;\r\n }\r\n case \"decodeMesh\": {\r\n if (!decoderPromise) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n decoderPromise.then((decoder) => {\r\n const numPoints = decodeMesh(\r\n decoder,\r\n message.dataView,\r\n message.attributes,\r\n (indices) => {\r\n postMessage({ id: \"indices\", data: indices }, [indices.buffer]);\r\n },\r\n (kind, data, size, offset, stride, normalized) => {\r\n postMessage({ id: \"attribute\", kind, data, size, byteOffset: offset, byteStride: stride, normalized }, [data.buffer]);\r\n }\r\n );\r\n postMessage({ id: \"decodeMeshDone\", totalVertices: numPoints });\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Initializes a worker that was created for the draco agent pool\r\n * @param worker The worker to initialize\r\n * @param decoderWasmBinary The wasm binary to load into the worker\r\n * @param moduleUrl The url to the draco decoder module (optional)\r\n * @returns A promise that resolves when the worker is initialized\r\n */\r\nexport function initializeWebWorker(worker: Worker, decoderWasmBinary?: ArrayBuffer, moduleUrl?: string): Promise<Worker> {\r\n return new Promise<Worker>((resolve, reject) => {\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n if (event.data.id === \"initDone\") {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(worker);\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n if (!decoderWasmBinary) {\r\n worker.postMessage({\r\n id: \"init\",\r\n decoder: {\r\n url: moduleUrl,\r\n },\r\n });\r\n } else {\r\n // clone the array buffer to make it transferable\r\n const clone = decoderWasmBinary.slice(0);\r\n worker.postMessage(\r\n {\r\n id: \"init\",\r\n decoder: {\r\n url: moduleUrl,\r\n wasmBinary: clone,\r\n },\r\n },\r\n [clone]\r\n );\r\n }\r\n // note: no transfer list as the ArrayBuffer is shared across main thread and pool workers\r\n });\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"g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,CAAC,MAAM,CAAC,CAAC,CAAC;SACrD;IACL,CAAC,CAAC;AACN,CAAC,AAvC2B,CAuC1B","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { DeepImmutable, Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { SubMesh } from \"../subMesh\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Class used to render a gaussian splatting mesh\r\n */\r\nexport class GaussianSplattingMesh extends Mesh {\r\n private _vertexCount = 0;\r\n private _worker: Nullable<Worker> = null;\r\n private _frameIdLastUpdate = -1;\r\n private _modelViewMatrix = Matrix.Identity();\r\n private _material: Nullable<GaussianSplattingMaterial> = null;\r\n private _depthMix: BigInt64Array;\r\n private _canPostToWorker = true;\r\n private _lastProj: DeepImmutable<Float32Array | number[]>;\r\n private _covariancesATexture: Nullable<BaseTexture> = null;\r\n private _covariancesBTexture: Nullable<BaseTexture> = null;\r\n private _centersTexture: Nullable<BaseTexture> = null;\r\n private _colorsTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets the covariancesA texture\r\n */\r\n public get covariancesATexture() {\r\n return this._covariancesATexture;\r\n }\r\n\r\n /**\r\n * Gets the covariancesB texture\r\n */\r\n public get covariancesBTexture() {\r\n return this._covariancesBTexture;\r\n }\r\n\r\n /**\r\n * Gets the centers texture\r\n */\r\n public get centersTexture() {\r\n return this._centersTexture;\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n public get colorsTexture() {\r\n return this._colorsTexture;\r\n }\r\n\r\n /**\r\n * Creates a new gaussian splatting mesh\r\n * @param name defines the name of the mesh\r\n * @param url defines the url to load from (optional)\r\n * @param scene defines the hosting scene (optional)\r\n */\r\n constructor(name: string, url: Nullable<string> = null, scene: Nullable<Scene> = null) {\r\n super(name, scene);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];\r\n vertexData.indices = [0, 1, 2, 0, 2, 3];\r\n vertexData.applyToMesh(this);\r\n\r\n this.subMeshes = [];\r\n new SubMesh(0, 0, 4, 0, 6, this);\r\n\r\n this.doNotSyncBoundingInfo = true;\r\n this.setEnabled(false);\r\n\r\n this._lastProj = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\r\n\r\n if (url) {\r\n this.loadFileAsync(url);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the class name\r\n * @returns \"GaussianSplattingMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GaussianSplattingMesh\";\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (splats) within the mesh\r\n * @returns the total number of vertices\r\n */\r\n public getTotalVertices(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager\r\n * @param subMesh defines the subMesh to render\r\n * @param enableAlphaMode defines if alpha mode can be changed\r\n * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering\r\n * @returns the current mesh\r\n */\r\n public render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh {\r\n if (!this.material) {\r\n this._material = new GaussianSplattingMaterial(this.name + \"_material\", this._scene);\r\n this.material = this._material;\r\n }\r\n\r\n const frameId = this.getScene().getFrameId();\r\n if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {\r\n this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);\r\n\r\n const dot = this._lastProj[2] * this._modelViewMatrix.m[2] + this._lastProj[6] * this._modelViewMatrix.m[6] + this._lastProj[10] * this._modelViewMatrix.m[10];\r\n if (Math.abs(dot - 1) >= 0.01) {\r\n this._frameIdLastUpdate = frameId;\r\n this._canPostToWorker = false;\r\n this._lastProj = this._modelViewMatrix.m.slice(0);\r\n this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix }, [this._depthMix.buffer]);\r\n }\r\n }\r\n\r\n return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Converts a .ply data array buffer to splat\r\n * if data array buffer is not ply, returns the original buffer\r\n * @param data the .ply data to load\r\n * @returns the loaded splat buffer\r\n */\r\n public static ConvertPLYToSplat(data: ArrayBuffer): ArrayBuffer {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n\r\n let rowOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n const properties: PlyProperty[] = [];\r\n const filtered = header\r\n .slice(0, headerEndIndex)\r\n .split(\"\\n\")\r\n .filter((k) => k.startsWith(\"property \"));\r\n for (const prop of filtered) {\r\n const [, type, name] = prop.split(\" \");\r\n properties.push({ name, type, offset: rowOffset });\r\n if (offsets[type]) {\r\n rowOffset += offsets[type];\r\n } else {\r\n Logger.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);\r\n return new ArrayBuffer(0);\r\n }\r\n }\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const SH_C0 = 0.28209479177387814;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowLength * vertexCount);\r\n const q = new Quaternion();\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowLength, 3);\r\n const scale = new Float32Array(buffer, i * rowLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);\r\n\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(property.offset + i * rowOffset, true);\r\n break;\r\n default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\r\n }\r\n\r\n switch (property.name) {\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n }\r\n\r\n return buffer;\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian Splatting array buffer asynchronously\r\n * @param data arraybuffer containing splat file\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n\r\n public loadDataAsync(data: ArrayBuffer): Promise<void> {\r\n return Promise.resolve(this._loadData(data));\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian or .ply Splatting file asynchronously\r\n * @param url path to the splat file to load\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n public loadFileAsync(url: string): Promise<void> {\r\n return Tools.LoadFileAsync(url, true).then((data) => {\r\n this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));\r\n });\r\n }\r\n\r\n /**\r\n * Releases resources associated with this mesh.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n */\r\n public dispose(doNotRecurse?: boolean): void {\r\n this._covariancesATexture?.dispose();\r\n this._covariancesBTexture?.dispose();\r\n this._centersTexture?.dispose();\r\n this._colorsTexture?.dispose();\r\n\r\n this._covariancesATexture = null;\r\n this._covariancesBTexture = null;\r\n this._centersTexture = null;\r\n this._colorsTexture = null;\r\n\r\n this._material?.dispose(false, true);\r\n this._material = null;\r\n\r\n this._worker?.terminate();\r\n this._worker = null;\r\n\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n private static _CreateWorker = function (self: Worker) {\r\n let vertexCount = 0;\r\n let positions: Float32Array;\r\n let depthMix: BigInt64Array;\r\n let indices: Uint32Array;\r\n let floatMix: Float32Array;\r\n\r\n self.onmessage = (e: any) => {\r\n // updated on init\r\n if (e.data.positions) {\r\n positions = e.data.positions;\r\n vertexCount = e.data.vertexCount;\r\n }\r\n // udpate on view changed\r\n else {\r\n const viewProj = e.data.view;\r\n if (!positions || !viewProj) {\r\n // Sanity check, it shouldn't happen!\r\n throw new Error(\"positions or view is not defined!\");\r\n }\r\n\r\n depthMix = e.data.depthMix;\r\n indices = new Uint32Array(depthMix.buffer);\r\n floatMix = new Float32Array(depthMix.buffer);\r\n\r\n // Sort\r\n for (let j = 0; j < vertexCount; j++) {\r\n indices[2 * j] = j;\r\n }\r\n\r\n for (let j = 0; j < vertexCount; j++) {\r\n floatMix[2 * j + 1] = 10000 - (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]);\r\n }\r\n\r\n depthMix.sort();\r\n\r\n self.postMessage({ depthMix }, [depthMix.buffer]);\r\n }\r\n };\r\n };\r\n\r\n private _loadData(data: ArrayBuffer): void {\r\n if (!data.byteLength) {\r\n return;\r\n }\r\n // Parse the data\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(uBuffer.buffer);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n this._vertexCount = vertexCount;\r\n\r\n const textureSize = this._getTextureSize(vertexCount);\r\n const textureLength = textureSize.x * textureSize.y;\r\n\r\n const positions = new Float32Array(3 * textureLength);\r\n const covA = new Float32Array(3 * textureLength);\r\n const covB = new Float32Array(3 * textureLength);\r\n\r\n const matrixRotation = TmpVectors.Matrix[0];\r\n const matrixScale = TmpVectors.Matrix[1];\r\n const quaternion = TmpVectors.Quaternion[0];\r\n\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = -fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n\r\n positions[3 * i + 0] = x;\r\n positions[3 * i + 1] = y;\r\n positions[3 * i + 2] = z;\r\n\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n\r\n quaternion.set(\r\n (uBuffer[32 * i + 28 + 1] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 2] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 3] - 128) / 128,\r\n -(uBuffer[32 * i + 28 + 0] - 128) / 128\r\n );\r\n quaternion.toRotationMatrix(matrixRotation);\r\n\r\n Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);\r\n\r\n const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;\r\n\r\n covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];\r\n covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];\r\n covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];\r\n covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];\r\n covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];\r\n covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];\r\n }\r\n\r\n // Update the mesh\r\n const binfo = this.getBoundingInfo();\r\n binfo.reConstruct(minimum, maximum, this.getWorldMatrix());\r\n binfo.isLocked = true;\r\n\r\n this.forcedInstanceCount = this._vertexCount;\r\n this.setEnabled(true);\r\n\r\n const splatIndex = new Float32Array(this._vertexCount * 1);\r\n\r\n this.thinInstanceSetBuffer(\"splatIndex\", splatIndex, 1, false);\r\n\r\n // Update the material\r\n const createTextureFromData = (data: Float32Array, width: number, height: number, format: number) => {\r\n return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);\r\n };\r\n\r\n const convertRgbToRgba = (rgb: Float32Array) => {\r\n const count = rgb.length / 3;\r\n const rgba = new Float32Array(count * 4);\r\n for (let i = 0; i < count; ++i) {\r\n rgba[i * 4 + 0] = rgb[i * 3 + 0];\r\n rgba[i * 4 + 1] = rgb[i * 3 + 1];\r\n rgba[i * 4 + 2] = rgb[i * 3 + 2];\r\n rgba[i * 4 + 3] = 1.0;\r\n }\r\n return rgba;\r\n };\r\n\r\n const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);\r\n for (let i = 0; i < this._vertexCount; ++i) {\r\n colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;\r\n colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;\r\n colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;\r\n colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;\r\n }\r\n\r\n this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._centersTexture = createTextureFromData(convertRgbToRgba(positions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n\r\n // Start the worker thread\r\n this._worker?.terminate();\r\n this._worker = new Worker(\r\n URL.createObjectURL(\r\n new Blob([\"(\", GaussianSplattingMesh._CreateWorker.toString(), \")(self)\"], {\r\n type: \"application/javascript\",\r\n })\r\n )\r\n );\r\n\r\n this._depthMix = new BigInt64Array(vertexCount);\r\n\r\n this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);\r\n\r\n this._worker.onmessage = (e) => {\r\n this._depthMix = e.data.depthMix;\r\n const indexMix = new Uint32Array(e.data.depthMix.buffer);\r\n for (let j = 0; j < this._vertexCount; j++) {\r\n splatIndex[j] = indexMix[2 * j];\r\n }\r\n this.thinInstanceBufferUpdated(\"splatIndex\");\r\n this._canPostToWorker = true;\r\n };\r\n }\r\n\r\n private _getTextureSize(length: number): Vector2 {\r\n const engine = this._scene.getEngine();\r\n const width = engine.getCaps().maxTextureSize;\r\n\r\n let height = 1;\r\n\r\n if (engine.version === 1 && !engine.isWebGPU) {\r\n while (width * height < length) {\r\n height *= 2;\r\n }\r\n } else {\r\n height = Math.ceil(length / width);\r\n }\r\n\r\n if (height > width) {\r\n Logger.Error(\"GaussianSplatting texture size: (\" + width + \", \" + height + \"), maxTextureSize: \" + width);\r\n height = width;\r\n }\r\n\r\n return new Vector2(width, height);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"gaussianSplattingMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GaussianSplatting/gaussianSplattingMesh.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,4BAAwB;AACxC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAC1F,OAAO,EAAE,MAAM,EAAE,6BAAy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AO,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC3C,QAAQ,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAE7C,OAAO;YACP,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;gBAClC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;aACtB;YAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;gBAClC,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACjJ;YAED,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEhB,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;SACrD;IACL,CAAC,CAAC;AACN,CAAC,AAvC2B,CAuC1B","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { DeepImmutable, Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { SubMesh } from \"../subMesh\";\r\nimport type { AbstractMesh } from \"../abstractMesh\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Matrix, TmpVectors, Vector2, Vector3, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { GaussianSplattingMaterial } from \"core/Materials/GaussianSplatting/gaussianSplattingMaterial\";\r\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Class used to render a gaussian splatting mesh\r\n */\r\nexport class GaussianSplattingMesh extends Mesh {\r\n private _vertexCount = 0;\r\n private _worker: Nullable<Worker> = null;\r\n private _frameIdLastUpdate = -1;\r\n private _modelViewMatrix = Matrix.Identity();\r\n private _material: Nullable<GaussianSplattingMaterial> = null;\r\n private _depthMix: BigInt64Array;\r\n private _canPostToWorker = true;\r\n private _lastProj: DeepImmutable<Float32Array | number[]>;\r\n private _covariancesATexture: Nullable<BaseTexture> = null;\r\n private _covariancesBTexture: Nullable<BaseTexture> = null;\r\n private _centersTexture: Nullable<BaseTexture> = null;\r\n private _colorsTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets the covariancesA texture\r\n */\r\n public get covariancesATexture() {\r\n return this._covariancesATexture;\r\n }\r\n\r\n /**\r\n * Gets the covariancesB texture\r\n */\r\n public get covariancesBTexture() {\r\n return this._covariancesBTexture;\r\n }\r\n\r\n /**\r\n * Gets the centers texture\r\n */\r\n public get centersTexture() {\r\n return this._centersTexture;\r\n }\r\n\r\n /**\r\n * Gets the colors texture\r\n */\r\n public get colorsTexture() {\r\n return this._colorsTexture;\r\n }\r\n\r\n /**\r\n * Creates a new gaussian splatting mesh\r\n * @param name defines the name of the mesh\r\n * @param url defines the url to load from (optional)\r\n * @param scene defines the hosting scene (optional)\r\n */\r\n constructor(name: string, url: Nullable<string> = null, scene: Nullable<Scene> = null) {\r\n super(name, scene);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];\r\n vertexData.indices = [0, 1, 2, 0, 2, 3];\r\n vertexData.applyToMesh(this);\r\n\r\n this.subMeshes = [];\r\n new SubMesh(0, 0, 4, 0, 6, this);\r\n\r\n this.doNotSyncBoundingInfo = true;\r\n this.setEnabled(false);\r\n\r\n this._lastProj = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\r\n\r\n if (url) {\r\n this.loadFileAsync(url);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the class name\r\n * @returns \"GaussianSplattingMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GaussianSplattingMesh\";\r\n }\r\n\r\n /**\r\n * Returns the total number of vertices (splats) within the mesh\r\n * @returns the total number of vertices\r\n */\r\n public override getTotalVertices(): number {\r\n return this._vertexCount;\r\n }\r\n\r\n /**\r\n * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager\r\n * @param subMesh defines the subMesh to render\r\n * @param enableAlphaMode defines if alpha mode can be changed\r\n * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering\r\n * @returns the current mesh\r\n */\r\n public override render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh {\r\n if (!this.material) {\r\n this._material = new GaussianSplattingMaterial(this.name + \"_material\", this._scene);\r\n this.material = this._material;\r\n }\r\n\r\n const frameId = this.getScene().getFrameId();\r\n if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {\r\n this.getWorldMatrix().multiplyToRef(this._scene.activeCamera.getViewMatrix(), this._modelViewMatrix);\r\n\r\n const dot = this._lastProj[2] * this._modelViewMatrix.m[2] + this._lastProj[6] * this._modelViewMatrix.m[6] + this._lastProj[10] * this._modelViewMatrix.m[10];\r\n if (Math.abs(dot - 1) >= 0.01) {\r\n this._frameIdLastUpdate = frameId;\r\n this._canPostToWorker = false;\r\n this._lastProj = this._modelViewMatrix.m.slice(0);\r\n this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix }, [this._depthMix.buffer]);\r\n }\r\n }\r\n\r\n return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);\r\n }\r\n\r\n /**\r\n * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license\r\n * Converts a .ply data array buffer to splat\r\n * if data array buffer is not ply, returns the original buffer\r\n * @param data the .ply data to load\r\n * @returns the loaded splat buffer\r\n */\r\n public static ConvertPLYToSplat(data: ArrayBuffer): ArrayBuffer {\r\n const ubuf = new Uint8Array(data);\r\n const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));\r\n const headerEnd = \"end_header\\n\";\r\n const headerEndIndex = header.indexOf(headerEnd);\r\n if (headerEndIndex < 0 || !header) {\r\n return data;\r\n }\r\n const vertexCount = parseInt(/element vertex (\\d+)\\n/.exec(header)![1]);\r\n\r\n let rowOffset = 0;\r\n const offsets: Record<string, number> = {\r\n double: 8,\r\n int: 4,\r\n uint: 4,\r\n float: 4,\r\n short: 2,\r\n ushort: 2,\r\n uchar: 1,\r\n };\r\n\r\n type PlyProperty = {\r\n name: string;\r\n type: string;\r\n offset: number;\r\n };\r\n const properties: PlyProperty[] = [];\r\n const filtered = header\r\n .slice(0, headerEndIndex)\r\n .split(\"\\n\")\r\n .filter((k) => k.startsWith(\"property \"));\r\n for (const prop of filtered) {\r\n const [, type, name] = prop.split(\" \");\r\n properties.push({ name, type, offset: rowOffset });\r\n if (offsets[type]) {\r\n rowOffset += offsets[type];\r\n } else {\r\n Logger.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);\r\n return new ArrayBuffer(0);\r\n }\r\n }\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const SH_C0 = 0.28209479177387814;\r\n\r\n const dataView = new DataView(data, headerEndIndex + headerEnd.length);\r\n const buffer = new ArrayBuffer(rowLength * vertexCount);\r\n const q = new Quaternion();\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const position = new Float32Array(buffer, i * rowLength, 3);\r\n const scale = new Float32Array(buffer, i * rowLength + 12, 3);\r\n const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);\r\n const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);\r\n\r\n let r0: number = 255;\r\n let r1: number = 0;\r\n let r2: number = 0;\r\n let r3: number = 0;\r\n\r\n for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {\r\n const property = properties[propertyIndex];\r\n let value;\r\n switch (property.type) {\r\n case \"float\":\r\n value = dataView.getFloat32(property.offset + i * rowOffset, true);\r\n break;\r\n case \"int\":\r\n value = dataView.getInt32(property.offset + i * rowOffset, true);\r\n break;\r\n default:\r\n throw new Error(`Unsupported property type: ${property.type}`);\r\n }\r\n\r\n switch (property.name) {\r\n case \"x\":\r\n position[0] = value;\r\n break;\r\n case \"y\":\r\n position[1] = value;\r\n break;\r\n case \"z\":\r\n position[2] = value;\r\n break;\r\n case \"scale_0\":\r\n scale[0] = Math.exp(value);\r\n break;\r\n case \"scale_1\":\r\n scale[1] = Math.exp(value);\r\n break;\r\n case \"scale_2\":\r\n scale[2] = Math.exp(value);\r\n break;\r\n case \"red\":\r\n rgba[0] = value;\r\n break;\r\n case \"green\":\r\n rgba[1] = value;\r\n break;\r\n case \"blue\":\r\n rgba[2] = value;\r\n break;\r\n case \"f_dc_0\":\r\n rgba[0] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_1\":\r\n rgba[1] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_2\":\r\n rgba[2] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"f_dc_3\":\r\n rgba[3] = (0.5 + SH_C0 * value) * 255;\r\n break;\r\n case \"opacity\":\r\n rgba[3] = (1 / (1 + Math.exp(-value))) * 255;\r\n break;\r\n case \"rot_0\":\r\n r0 = value;\r\n break;\r\n case \"rot_1\":\r\n r1 = value;\r\n break;\r\n case \"rot_2\":\r\n r2 = value;\r\n break;\r\n case \"rot_3\":\r\n r3 = value;\r\n break;\r\n }\r\n }\r\n\r\n q.set(r1, r2, r3, r0);\r\n q.normalize();\r\n rot[0] = q.w * 128 + 128;\r\n rot[1] = q.x * 128 + 128;\r\n rot[2] = q.y * 128 + 128;\r\n rot[3] = q.z * 128 + 128;\r\n }\r\n\r\n return buffer;\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian Splatting array buffer asynchronously\r\n * @param data arraybuffer containing splat file\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n\r\n public loadDataAsync(data: ArrayBuffer): Promise<void> {\r\n return Promise.resolve(this._loadData(data));\r\n }\r\n\r\n /**\r\n * Loads a .splat Gaussian or .ply Splatting file asynchronously\r\n * @param url path to the splat file to load\r\n * @returns a promise that resolves when the operation is complete\r\n */\r\n public loadFileAsync(url: string): Promise<void> {\r\n return Tools.LoadFileAsync(url, true).then((data) => {\r\n this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));\r\n });\r\n }\r\n\r\n /**\r\n * Releases resources associated with this mesh.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean): void {\r\n this._covariancesATexture?.dispose();\r\n this._covariancesBTexture?.dispose();\r\n this._centersTexture?.dispose();\r\n this._colorsTexture?.dispose();\r\n\r\n this._covariancesATexture = null;\r\n this._covariancesBTexture = null;\r\n this._centersTexture = null;\r\n this._colorsTexture = null;\r\n\r\n this._material?.dispose(false, true);\r\n this._material = null;\r\n\r\n this._worker?.terminate();\r\n this._worker = null;\r\n\r\n super.dispose(doNotRecurse);\r\n }\r\n\r\n private static _CreateWorker = function (self: Worker) {\r\n let vertexCount = 0;\r\n let positions: Float32Array;\r\n let depthMix: BigInt64Array;\r\n let indices: Uint32Array;\r\n let floatMix: Float32Array;\r\n\r\n self.onmessage = (e: any) => {\r\n // updated on init\r\n if (e.data.positions) {\r\n positions = e.data.positions;\r\n vertexCount = e.data.vertexCount;\r\n }\r\n // udpate on view changed\r\n else {\r\n const viewProj = e.data.view;\r\n if (!positions || !viewProj) {\r\n // Sanity check, it shouldn't happen!\r\n throw new Error(\"positions or view is not defined!\");\r\n }\r\n\r\n depthMix = e.data.depthMix;\r\n indices = new Uint32Array(depthMix.buffer);\r\n floatMix = new Float32Array(depthMix.buffer);\r\n\r\n // Sort\r\n for (let j = 0; j < vertexCount; j++) {\r\n indices[2 * j] = j;\r\n }\r\n\r\n for (let j = 0; j < vertexCount; j++) {\r\n floatMix[2 * j + 1] = 10000 - (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]);\r\n }\r\n\r\n depthMix.sort();\r\n\r\n self.postMessage({ depthMix }, [depthMix.buffer]);\r\n }\r\n };\r\n };\r\n\r\n private _loadData(data: ArrayBuffer): void {\r\n if (!data.byteLength) {\r\n return;\r\n }\r\n // Parse the data\r\n const uBuffer = new Uint8Array(data);\r\n const fBuffer = new Float32Array(uBuffer.buffer);\r\n\r\n const rowLength = 3 * 4 + 3 * 4 + 4 + 4;\r\n const vertexCount = uBuffer.length / rowLength;\r\n\r\n this._vertexCount = vertexCount;\r\n\r\n const textureSize = this._getTextureSize(vertexCount);\r\n const textureLength = textureSize.x * textureSize.y;\r\n\r\n const positions = new Float32Array(3 * textureLength);\r\n const covA = new Float32Array(3 * textureLength);\r\n const covB = new Float32Array(3 * textureLength);\r\n\r\n const matrixRotation = TmpVectors.Matrix[0];\r\n const matrixScale = TmpVectors.Matrix[1];\r\n const quaternion = TmpVectors.Quaternion[0];\r\n\r\n const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);\r\n const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);\r\n\r\n for (let i = 0; i < vertexCount; i++) {\r\n const x = fBuffer[8 * i + 0];\r\n const y = -fBuffer[8 * i + 1];\r\n const z = fBuffer[8 * i + 2];\r\n\r\n positions[3 * i + 0] = x;\r\n positions[3 * i + 1] = y;\r\n positions[3 * i + 2] = z;\r\n\r\n minimum.minimizeInPlaceFromFloats(x, y, z);\r\n maximum.maximizeInPlaceFromFloats(x, y, z);\r\n\r\n quaternion.set(\r\n (uBuffer[32 * i + 28 + 1] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 2] - 128) / 128,\r\n (uBuffer[32 * i + 28 + 3] - 128) / 128,\r\n -(uBuffer[32 * i + 28 + 0] - 128) / 128\r\n );\r\n quaternion.toRotationMatrix(matrixRotation);\r\n\r\n Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);\r\n\r\n const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;\r\n\r\n covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];\r\n covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];\r\n covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];\r\n covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];\r\n covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];\r\n covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];\r\n }\r\n\r\n // Update the mesh\r\n const binfo = this.getBoundingInfo();\r\n binfo.reConstruct(minimum, maximum, this.getWorldMatrix());\r\n binfo.isLocked = true;\r\n\r\n this.forcedInstanceCount = this._vertexCount;\r\n this.setEnabled(true);\r\n\r\n const splatIndex = new Float32Array(this._vertexCount * 1);\r\n\r\n this.thinInstanceSetBuffer(\"splatIndex\", splatIndex, 1, false);\r\n\r\n // Update the material\r\n const createTextureFromData = (data: Float32Array, width: number, height: number, format: number) => {\r\n return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);\r\n };\r\n\r\n const convertRgbToRgba = (rgb: Float32Array) => {\r\n const count = rgb.length / 3;\r\n const rgba = new Float32Array(count * 4);\r\n for (let i = 0; i < count; ++i) {\r\n rgba[i * 4 + 0] = rgb[i * 3 + 0];\r\n rgba[i * 4 + 1] = rgb[i * 3 + 1];\r\n rgba[i * 4 + 2] = rgb[i * 3 + 2];\r\n rgba[i * 4 + 3] = 1.0;\r\n }\r\n return rgba;\r\n };\r\n\r\n const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);\r\n for (let i = 0; i < this._vertexCount; ++i) {\r\n colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;\r\n colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;\r\n colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;\r\n colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;\r\n }\r\n\r\n this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._centersTexture = createTextureFromData(convertRgbToRgba(positions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);\r\n\r\n // Start the worker thread\r\n this._worker?.terminate();\r\n this._worker = new Worker(\r\n URL.createObjectURL(\r\n new Blob([\"(\", GaussianSplattingMesh._CreateWorker.toString(), \")(self)\"], {\r\n type: \"application/javascript\",\r\n })\r\n )\r\n );\r\n\r\n this._depthMix = new BigInt64Array(vertexCount);\r\n\r\n this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);\r\n\r\n this._worker.onmessage = (e) => {\r\n this._depthMix = e.data.depthMix;\r\n const indexMix = new Uint32Array(e.data.depthMix.buffer);\r\n for (let j = 0; j < this._vertexCount; j++) {\r\n splatIndex[j] = indexMix[2 * j];\r\n }\r\n this.thinInstanceBufferUpdated(\"splatIndex\");\r\n this._canPostToWorker = true;\r\n };\r\n }\r\n\r\n private _getTextureSize(length: number): Vector2 {\r\n const engine = this._scene.getEngine();\r\n const width = engine.getCaps().maxTextureSize;\r\n\r\n let height = 1;\r\n\r\n if (engine.version === 1 && !engine.isWebGPU) {\r\n while (width * height < length) {\r\n height *= 2;\r\n }\r\n } else {\r\n height = Math.ceil(length / width);\r\n }\r\n\r\n if (height > width) {\r\n Logger.Error(\"GaussianSplatting texture size: (\" + width + \", \" + height + \"), maxTextureSize: \" + width);\r\n height = width;\r\n }\r\n\r\n return new Vector2(width, height);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greasedLineBaseMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineBaseMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAIlG;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACnC,yGAAsB,CAAA;IACtB,uGAAqB,CAAA;AACzB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IAClC,iHAA2B,CAAA;IAC3B,yJAA+C,CAAA;IAC/C,iHAA2B,CAAA;AAC/B,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kCAM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AAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { FloatArray, IndicesArray } from \"../../types\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_FACE_TO = 3,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: FloatArray;\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: FloatArray;\r\n protected _indices: IndicesArray;\r\n protected _uvs: FloatArray;\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: AbstractEngine;\r\n\r\n constructor(\r\n public readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public addPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n for (const p of points) {\r\n this._points.push(p);\r\n }\r\n\r\n if (!this._lazy) {\r\n this.setPoints(this._points, options);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the line and it's resources\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false) {\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Returns the UVs\r\n */\r\n get uvs() {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Sets the UVs\r\n * @param uvs the UVs\r\n */\r\n set uvs(uvs: FloatArray) {\r\n this._uvs = uvs instanceof Float32Array ? uvs : new Float32Array(uvs);\r\n this._createVertexBuffers();\r\n }\r\n\r\n /**\r\n * Returns the points offsets\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"greasedLineBaseMesh.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/GreasedLine/greasedLineBaseMesh.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAIlG;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACnC,yGAAsB,CAAA;IACtB,uGAAqB,CAAA;AACzB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BAIX;AAJD,WAAY,0BAA0B;IAClC,iHAA2B,CAAA;IAC3B,yJAA+C,CAAA;IAC/C,iHAA2B,CAAA;AAC/B,CAAC,EAJW,0BAA0B,KAA1B,0BAA0B,QAIrC;AAED;;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AAC,CAAC,CAAC;QAC7E,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;IACvC,CAAC;CACJ","sourcesContent":["import type { Scene } from \"../../scene\";\r\nimport type { IGreasedLineMaterial } from \"../../Materials/GreasedLine/greasedLineMaterialInterfaces\";\r\nimport { GreasedLinePluginMaterial } from \"../../Materials/GreasedLine/greasedLinePluginMaterial\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { Buffer } from \"../../Buffers/buffer\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport { GreasedLineSimpleMaterial } from \"../../Materials/GreasedLine/greasedLineSimpleMaterial\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { FloatArray, IndicesArray } from \"../../types\";\r\n\r\n/**\r\n * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.\r\n * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.\r\n */\r\nexport enum GreasedLineRibbonPointsMode {\r\n POINTS_MODE_POINTS = 0,\r\n POINTS_MODE_PATHS = 1,\r\n}\r\n\r\n/**\r\n * FACES_MODE_SINGLE_SIDED single sided with back face culling. Default value.\r\n * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.\r\n * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\nexport enum GreasedLineRibbonFacesMode {\r\n FACES_MODE_SINGLE_SIDED = 0,\r\n FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,\r\n FACES_MODE_DOUBLE_SIDED = 2,\r\n}\r\n\r\n/**\r\n * Only with POINTS_MODE_PATHS.\r\n * AUTO_DIRECTIONS_FROM_FIRST_SEGMENT sets the direction (slope) of the ribbon from the direction of the first line segment. Recommended.\r\n * AUTO_DIRECTIONS_FROM_ALL_SEGMENTS in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments. Slow method.\r\n * AUTO_DIRECTIONS_ENHANCED in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments using a more sophisitcaed algorithm. Slowest method.\r\n * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.\r\n * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.\r\n */\r\nexport enum GreasedLineRibbonAutoDirectionMode {\r\n AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,\r\n AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,\r\n AUTO_DIRECTIONS_ENHANCED = 2,\r\n AUTO_DIRECTIONS_FACE_TO = 3,\r\n AUTO_DIRECTIONS_NONE = 99,\r\n}\r\n\r\nexport type GreasedLineRibbonOptions = {\r\n /**\r\n * Defines how the points are processed.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_POINTS every array of points will become the center of the ribbon. The ribbon will be expanded by width/2 to +direction and -direction as well.\r\n * In GreasedLineRibbonPointsMode.POINTS_MODE_PATHS every array of points is one path. These will be used to buuid one ribbon.\r\n */\r\n pointsMode?: GreasedLineRibbonPointsMode;\r\n /**\r\n * Normalized directions of the slopes of the non camera facing lines.\r\n */\r\n directions?: Vector3[] | Vector3;\r\n /**\r\n * Defines the calculation mode of the directions which the line will be thickened to.\r\n */\r\n directionsAutoMode?: GreasedLineRibbonAutoDirectionMode;\r\n /**\r\n * Width of the ribbon.\r\n */\r\n width?: number;\r\n /**\r\n * Controls how the faces are created.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED = single sided with back face culling. Default value.\r\n * GreasedLineRibbonFacesMode.FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = single sided without back face culling\r\n * GreasedLineRibbonFacesMode.FACES_MODE_DOUBLE_SIDED = extra back faces are created. This doubles the amount of faces of the mesh.\r\n */\r\n facesMode?: GreasedLineRibbonFacesMode;\r\n /**\r\n * If true, the path will be closed.\r\n */\r\n closePath?: boolean;\r\n /**\r\n * If true, normals will be computed when creating the vertex buffers.\r\n * This results to smooth shading of the mesh.\r\n */\r\n smoothShading?: boolean;\r\n};\r\n\r\nexport type GreasedLinePoints = Vector3[] | Vector3[][] | Float32Array | Float32Array[] | number[][] | number[];\r\n\r\n/**\r\n * Options for creating a GreasedLineMesh\r\n */\r\nexport interface GreasedLineMeshOptions {\r\n /**\r\n * Points of the line.\r\n */\r\n points: GreasedLinePoints;\r\n /**\r\n * Each line segment (from point to point) can have it's width multiplier. Final width = widths[segmentIdx] * width.\r\n * Defaults to empty array.\r\n */\r\n widths?: number[];\r\n /**\r\n * If instance is specified, lines are added to the specified instance.\r\n * Defaults to undefined.\r\n */\r\n instance?: GreasedLineBaseMesh;\r\n /**\r\n * You can manually set the color pointers so you can control which segment/part\r\n * will use which color from the colors material option\r\n */\r\n colorPointers?: number[];\r\n /**\r\n * UVs for the mesh\r\n */\r\n uvs?: FloatArray;\r\n /**\r\n * If true, offsets and widths are updatable.\r\n * Defaults to false.\r\n */\r\n updatable?: boolean;\r\n /**\r\n * Use when @see instance is specified.\r\n * If true, the line will be rendered only after calling instance.updateLazy(). If false, line will be rerendered after every call to @see CreateGreasedLine\r\n * Defaults to false.\r\n */\r\n lazy?: boolean;\r\n /**\r\n * The options for the ribbon which will be used as a line.\r\n * If this option is set the line switches automatically to a non camera facing mode.\r\n */\r\n ribbonOptions?: GreasedLineRibbonOptions;\r\n}\r\n\r\n/**\r\n * GreasedLineBaseMesh\r\n */\r\nexport abstract class GreasedLineBaseMesh extends Mesh {\r\n protected _vertexPositions: FloatArray;\r\n protected _indices: IndicesArray;\r\n protected _uvs: FloatArray;\r\n protected _points: number[][];\r\n protected _offsets: number[];\r\n protected _colorPointers: number[];\r\n protected _widths: number[];\r\n\r\n protected _offsetsBuffer?: Buffer;\r\n protected _widthsBuffer?: Buffer;\r\n protected _colorPointersBuffer?: Buffer;\r\n\r\n protected _lazy = false;\r\n protected _updatable = false;\r\n\r\n protected _engine: AbstractEngine;\r\n\r\n constructor(\r\n public override readonly name: string,\r\n scene: Scene,\r\n protected _options: GreasedLineMeshOptions\r\n ) {\r\n super(name, scene, null, null, false, false);\r\n\r\n this._engine = scene.getEngine();\r\n\r\n this._lazy = _options.lazy ?? false;\r\n this._updatable = _options.updatable ?? false;\r\n\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n this._points = [];\r\n this._colorPointers = _options.colorPointers ?? [];\r\n this._widths = _options.widths ?? new Array(_options.points.length).fill(1);\r\n }\r\n\r\n /**\r\n * \"GreasedLineMesh\"\r\n * @returns \"GreasedLineMesh\"\r\n */\r\n public override getClassName(): string {\r\n return \"GreasedLineMesh\";\r\n }\r\n\r\n protected abstract _setPoints(points: number[][], options?: GreasedLineMeshOptions): void;\r\n protected abstract _updateColorPointers(): void;\r\n protected abstract _updateWidths(): void;\r\n\r\n protected _updateWidthsWithValue(defaulValue: number) {\r\n let pointCount = 0;\r\n for (const points of this._points) {\r\n pointCount += points.length;\r\n }\r\n const countDiff = (pointCount / 3) * 2 - this._widths.length;\r\n for (let i = 0; i < countDiff; i++) {\r\n this._widths.push(defaulValue);\r\n }\r\n }\r\n\r\n /**\r\n * Updated a lazy line. Rerenders the line and updates boundinfo as well.\r\n */\r\n public updateLazy() {\r\n this._setPoints(this._points);\r\n if (!this._options.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._createVertexBuffers(this._options.ribbonOptions?.smoothShading);\r\n this.refreshBoundingInfo();\r\n\r\n this.greasedLineMaterial?.updateLazy();\r\n }\r\n\r\n /**\r\n * Adds new points to the line. It doesn't rerenders the line if in lazy mode.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public addPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n for (const p of points) {\r\n this._points.push(p);\r\n }\r\n\r\n if (!this._lazy) {\r\n this.setPoints(this._points, options);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the line and it's resources\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false) {\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * @returns true if the mesh was created in lazy mode\r\n */\r\n public isLazy(): boolean {\r\n return this._lazy;\r\n }\r\n\r\n /**\r\n * Returns the UVs\r\n */\r\n get uvs() {\r\n return this._uvs;\r\n }\r\n\r\n /**\r\n * Sets the UVs\r\n * @param uvs the UVs\r\n */\r\n set uvs(uvs: FloatArray) {\r\n this._uvs = uvs instanceof Float32Array ? uvs : new Float32Array(uvs);\r\n this._createVertexBuffers();\r\n }\r\n\r\n /**\r\n * Returns the points offsets\r\n * Return the points offsets\r\n */\r\n get offsets() {\r\n return this._offsets;\r\n }\r\n\r\n /**\r\n * Sets point offests\r\n * @param offsets offset table [x,y,z, x,y,z, ....]\r\n */\r\n set offsets(offsets: number[]) {\r\n this._offsets = offsets;\r\n if (!this._offsetsBuffer) {\r\n this._createOffsetsBuffer(offsets);\r\n } else {\r\n this._offsetsBuffer.update(offsets);\r\n }\r\n }\r\n\r\n /**\r\n * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]\r\n */\r\n get widths() {\r\n return this._widths;\r\n }\r\n\r\n /**\r\n * Sets widths at each line point\r\n * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]\r\n */\r\n set widths(widths: number[]) {\r\n this._widths = widths;\r\n if (!this._lazy) {\r\n this._widthsBuffer && this._widthsBuffer.update(widths);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors\r\n */\r\n get colorPointers() {\r\n return this._colorPointers;\r\n }\r\n\r\n /**\r\n * Sets the color pointer\r\n * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.\r\n */\r\n set colorPointers(colorPointers: number[]) {\r\n this._colorPointers = colorPointers;\r\n if (!this._lazy) {\r\n this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the pluginMaterial associated with line\r\n */\r\n get greasedLineMaterial(): IGreasedLineMaterial | undefined {\r\n if (this.material && this.material instanceof GreasedLineSimpleMaterial) {\r\n return this.material;\r\n }\r\n const materialPlugin = this.material?.pluginManager?.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);\r\n if (materialPlugin) {\r\n return <GreasedLinePluginMaterial>materialPlugin;\r\n }\r\n return;\r\n }\r\n\r\n /**\r\n * Return copy the points.\r\n */\r\n get points() {\r\n const pointsCopy: number[][] = [];\r\n DeepCopier.DeepCopy(this._points, pointsCopy);\r\n return pointsCopy;\r\n }\r\n\r\n /**\r\n * Sets line points and rerenders the line.\r\n * @param points points table\r\n * @param options optional options\r\n */\r\n public setPoints(points: number[][], options?: GreasedLineMeshOptions) {\r\n this._points = points;\r\n this._updateWidths();\r\n if (!options?.colorPointers) {\r\n this._updateColorPointers();\r\n }\r\n this._setPoints(points, options);\r\n }\r\n\r\n protected _initGreasedLine() {\r\n this._vertexPositions = [];\r\n this._indices = [];\r\n this._uvs = [];\r\n }\r\n\r\n protected _createLineOptions() {\r\n const lineOptions: GreasedLineMeshOptions = {\r\n points: this._points,\r\n colorPointers: this._colorPointers,\r\n lazy: this._lazy,\r\n updatable: this._updatable,\r\n uvs: this._uvs,\r\n widths: this._widths,\r\n ribbonOptions: this._options.ribbonOptions,\r\n };\r\n return lineOptions;\r\n }\r\n\r\n /**\r\n * Serializes this GreasedLineMesh\r\n * @param serializationObject object to write serialization to\r\n */\r\n public override serialize(serializationObject: any): void {\r\n super.serialize(serializationObject);\r\n serializationObject.type = this.getClassName();\r\n\r\n serializationObject.lineOptions = this._createLineOptions();\r\n }\r\n\r\n protected _createVertexBuffers(computeNormals = false) {\r\n const vertexData = new VertexData();\r\n vertexData.positions = this._vertexPositions;\r\n vertexData.indices = this._indices;\r\n vertexData.uvs = this._uvs;\r\n if (computeNormals) {\r\n vertexData.normals = [];\r\n VertexData.ComputeNormals(this._vertexPositions, this._indices, vertexData.normals);\r\n }\r\n vertexData.applyToMesh(this, this._options.updatable);\r\n return vertexData;\r\n }\r\n\r\n protected _createOffsetsBuffer(offsets: number[]) {\r\n const engine = this._scene.getEngine();\r\n\r\n const offsetBuffer = new Buffer(engine, offsets, this._updatable, 3);\r\n this.setVerticesBuffer(offsetBuffer.createVertexBuffer(\"grl_offsets\", 0, 3));\r\n this._offsetsBuffer = offsetBuffer;\r\n }\r\n}\r\n"]}
|