@babylonjs/core 7.40.2 → 7.40.4
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/Audio/sound.js +5 -10
- package/Audio/sound.js.map +1 -1
- package/Compute/computeEffect.js +6 -14
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.js +2 -9
- package/Compute/computeShader.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +5 -6
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Engines/abstractEngine.d.ts +7 -0
- package/Engines/abstractEngine.js +7 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.js +6 -8
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +6 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +6 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/frameGraph.js +4 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/Layers/effectLayer.js +2 -0
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.js +4 -0
- package/Layers/glowLayer.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +5 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +33 -0
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -4
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +10 -2
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +48 -2
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +3 -0
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +6 -0
- package/Materials/Node/nodeMaterial.js +17 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
- package/Materials/PBR/pbrBaseMaterial.js +3 -4
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +3 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.js +5 -2
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/effect.functions.d.ts +0 -1
- package/Materials/effect.functions.js +0 -19
- package/Materials/effect.functions.js.map +1 -1
- package/Materials/effect.js +3 -2
- package/Materials/effect.js.map +1 -1
- package/Materials/effect.webgl.functions.js +2 -1
- package/Materials/effect.webgl.functions.js.map +1 -1
- package/Materials/material.d.ts +4 -0
- package/Materials/material.js +8 -0
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.functions.js +2 -0
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.js +4 -0
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +1 -0
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Compression/dracoCodec.d.ts +83 -0
- package/Meshes/Compression/dracoCodec.js +107 -0
- package/Meshes/Compression/dracoCodec.js.map +1 -0
- package/Meshes/Compression/dracoCompression.d.ts +17 -63
- package/Meshes/Compression/dracoCompression.js +22 -200
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.d.ts +103 -0
- package/Meshes/Compression/dracoDecoder.js +216 -0
- package/Meshes/Compression/dracoDecoder.js.map +1 -0
- package/Meshes/Compression/index.d.ts +1 -0
- package/Meshes/Compression/index.js +1 -0
- package/Meshes/Compression/index.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +5 -0
- package/Meshes/abstractMesh.js +15 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.js +23 -0
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.functions.d.ts +6 -0
- package/Meshes/mesh.vertexData.functions.js +65 -0
- package/Meshes/mesh.vertexData.functions.js.map +1 -0
- package/Misc/bitArray.d.ts +26 -0
- package/Misc/bitArray.js +53 -0
- package/Misc/bitArray.js.map +1 -0
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/screenshotTools.d.ts +3 -3
- package/Misc/screenshotTools.js +10 -12
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/timingTools.d.ts +4 -0
- package/Misc/timingTools.js +38 -0
- package/Misc/timingTools.js.map +1 -1
- package/Misc/webRequest.d.ts +1 -1
- package/Misc/webRequest.js +1 -1
- package/Misc/webRequest.js.map +1 -1
- package/Morph/morphTarget.d.ts +15 -0
- package/Morph/morphTarget.js +35 -0
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +9 -0
- package/Morph/morphTargetManager.js +23 -0
- package/Morph/morphTargetManager.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +7 -5
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/iblCdfGenerator.d.ts +14 -19
- package/Rendering/iblCdfGenerator.js +64 -57
- package/Rendering/iblCdfGenerator.js.map +1 -1
- package/Rendering/index.d.ts +6 -6
- package/Rendering/index.js +6 -6
- package/Rendering/index.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +6 -6
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +1 -0
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js +7 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflection.js +2 -3
- package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js +2 -3
- package/Shaders/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/samplerVertexImplementation.js +1 -1
- package/Shaders/ShadersInclude/samplerVertexImplementation.js.map +1 -1
- package/Shaders/default.vertex.js +10 -1
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/depth.vertex.js +4 -1
- package/Shaders/depth.vertex.js.map +1 -1
- package/Shaders/geometry.vertex.js +9 -6
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/glowMapGeneration.vertex.js +6 -3
- package/Shaders/glowMapGeneration.vertex.js.map +1 -1
- package/Shaders/{iblIcdfx.fragment.d.ts → iblCdfDebug.fragment.d.ts} +1 -1
- package/Shaders/{importanceSamplingDebug.fragment.js → iblCdfDebug.fragment.js} +12 -11
- package/Shaders/iblCdfDebug.fragment.js.map +1 -0
- package/Shaders/iblCdfy.fragment.d.ts +1 -0
- package/Shaders/iblCdfy.fragment.js +4 -4
- package/Shaders/iblCdfy.fragment.js.map +1 -1
- package/Shaders/iblIcdf.fragment.d.ts +6 -0
- package/Shaders/iblIcdf.fragment.js +43 -0
- package/Shaders/iblIcdf.fragment.js.map +1 -0
- package/Shaders/iblScaledLuminance.fragment.d.ts +6 -0
- package/Shaders/iblScaledLuminance.fragment.js +25 -0
- package/Shaders/iblScaledLuminance.fragment.js.map +1 -0
- package/Shaders/iblShadowVoxelTracing.fragment.js +2 -2
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/outline.vertex.js +4 -1
- package/Shaders/outline.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +2 -4
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +10 -1
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/shadowMap.vertex.js +4 -1
- package/Shaders/shadowMap.vertex.js.map +1 -1
- package/Shaders/volumetricLightScatteringPass.vertex.js +4 -1
- package/Shaders/volumetricLightScatteringPass.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +8 -6
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +1 -0
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +7 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +4 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js +4 -8
- package/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/samplerVertexImplementation.js +1 -1
- package/ShadersWGSL/ShadersInclude/samplerVertexImplementation.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +10 -1
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/depth.vertex.js +4 -1
- package/ShadersWGSL/depth.vertex.js.map +1 -1
- package/ShadersWGSL/geometry.vertex.js +9 -6
- package/ShadersWGSL/geometry.vertex.js.map +1 -1
- package/ShadersWGSL/glowMapGeneration.vertex.js +6 -3
- package/ShadersWGSL/glowMapGeneration.vertex.js.map +1 -1
- package/ShadersWGSL/glowMapMerge.fragment.js +3 -2
- package/ShadersWGSL/glowMapMerge.fragment.js.map +1 -1
- package/ShadersWGSL/{iblIcdfy.fragment.d.ts → iblCdfDebug.fragment.d.ts} +1 -1
- package/ShadersWGSL/{importanceSamplingDebug.fragment.js → iblCdfDebug.fragment.js} +11 -10
- package/ShadersWGSL/iblCdfDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblCdfy.fragment.js +8 -7
- package/ShadersWGSL/iblCdfy.fragment.js.map +1 -1
- package/ShadersWGSL/iblIcdf.fragment.d.ts +6 -0
- package/ShadersWGSL/iblIcdf.fragment.js +43 -0
- package/ShadersWGSL/iblIcdf.fragment.js.map +1 -0
- package/ShadersWGSL/iblScaledLuminance.fragment.d.ts +6 -0
- package/ShadersWGSL/iblScaledLuminance.fragment.js +24 -0
- package/ShadersWGSL/iblScaledLuminance.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +3 -3
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/ShadersWGSL/outline.vertex.js +4 -1
- package/ShadersWGSL/outline.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +4 -8
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +10 -1
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/shadowMap.vertex.js +4 -1
- package/ShadersWGSL/shadowMap.vertex.js.map +1 -1
- package/assets/Draco/draco_encoder.js +38 -0
- package/assets/Draco/draco_encoder.wasm +0 -0
- package/assets/Draco/draco_encoder_wasm_wrapper.js +96 -0
- package/package.json +1 -1
- package/Shaders/iblIcdfx.fragment.js +0 -19
- package/Shaders/iblIcdfx.fragment.js.map +0 -1
- package/Shaders/iblIcdfy.fragment.d.ts +0 -5
- package/Shaders/iblIcdfy.fragment.js +0 -19
- package/Shaders/iblIcdfy.fragment.js.map +0 -1
- package/Shaders/importanceSamplingDebug.fragment.d.ts +0 -5
- package/Shaders/importanceSamplingDebug.fragment.js.map +0 -1
- package/ShadersWGSL/iblIcdfx.fragment.d.ts +0 -5
- package/ShadersWGSL/iblIcdfx.fragment.js +0 -18
- package/ShadersWGSL/iblIcdfx.fragment.js.map +0 -1
- package/ShadersWGSL/iblIcdfy.fragment.js +0 -17
- package/ShadersWGSL/iblIcdfy.fragment.js.map +0 -1
- package/ShadersWGSL/importanceSamplingDebug.fragment.d.ts +0 -5
- package/ShadersWGSL/importanceSamplingDebug.fragment.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAEA,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,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AAE,UAAU,CAAC,CAAC;QACxE,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC1C,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CACvC,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EACxC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,QAAQ,CAAC,aAAa,CACzB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AA3WD;;;;;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 type { BoundingInfo } from \"../../Culling/boundingInfo\";\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 * Reset the default draco compression object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static Configuration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoCompression._Default) {\r\n if (!skipDispose) {\r\n DracoCompression._Default.dispose();\r\n }\r\n DracoCompression._Default = null;\r\n }\r\n }\r\n\r\n /**\r\n * 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 boundingInfo: Nullable<BoundingInfo>\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 (boundingInfo) {\r\n geometry._boundingInfo = boundingInfo;\r\n geometry.useBoundingInfoFromGeometry = true;\r\n }\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/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AK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CACvC,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EACxC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,QAAQ,CAAC,aAAa,CACzB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AA3ID;;;;;GAKG;AACW,8BAAa,GAAmC,EAAE,OAAO,EAAE,EAAE,GAAG,YAAY,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,WAAW;AAShI;;GAEG;AACW,kCAAiB,GAAG,qBAAqB,EAAE,CAAC;AAEzC,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["import { _GetDefaultNumWorkers, _IsConfigurationAvailable } from \"./dracoCodec\";\r\nimport type { IDracoCodecConfiguration } from \"./dracoCodec\";\r\nimport { DracoDecoder } from \"./dracoDecoder\";\r\nimport type { MeshData } from \"./dracoDecoder\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Geometry } from \"../geometry\";\r\nimport type { BoundingInfo } from \"../../Culling/boundingInfo\";\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: IDracoCodecConfiguration;\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions extends Pick<IDracoCodecConfiguration, \"numWorkers\" | \"wasmBinary\" | \"workerPool\"> {}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression {\r\n private _decoder: DracoDecoder;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static Configuration: IDracoCompressionConfiguration = { decoder: { ...DracoDecoder.DefaultConfiguration } }; // Use copy\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n return _IsConfigurationAvailable(DracoCompression.Configuration.decoder);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = _GetDefaultNumWorkers();\r\n\r\n protected static _Default: Nullable<DracoCompression> = null;\r\n /**\r\n * Default instance for the DracoCompression.\r\n */\r\n public static get Default(): DracoCompression {\r\n DracoCompression._Default ??= new DracoCompression();\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Reset the default draco compression object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static Configuration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoCompression._Default) {\r\n if (!skipDispose) {\r\n DracoCompression._Default.dispose();\r\n }\r\n DracoCompression._Default = null;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new DracoCompression object.\r\n * @param numWorkersOrOptions Overrides for the Configuration. Either:\r\n * - The number of workers for async operations or a config object. Specify `0` to disable web workers and run synchronously in the current context.\r\n * - An options object\r\n */\r\n constructor(numWorkersOrOptions: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const configuration =\r\n typeof numWorkersOrOptions === \"number\"\r\n ? { ...DracoCompression.Configuration.decoder, numWorkers: numWorkersOrOptions }\r\n : { ...DracoCompression.Configuration.decoder, ...numWorkersOrOptions };\r\n this._decoder = new DracoDecoder(configuration);\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n this._decoder.dispose();\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n return this._decoder.whenReadyAsync();\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to mesh data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization\r\n * @returns A promise that resolves with the decoded mesh data\r\n */\r\n public decodeMeshToMeshDataAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n return this._decoder.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n return this._decoder.decodeMeshToGeometryAsync(name, scene, data, attributes);\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean },\r\n boundingInfo: Nullable<BoundingInfo>\r\n ): Promise<Geometry> {\r\n return this._decoder._decodeMeshToGeometryForGltfAsync(name, scene, data, attributes, gltfNormalizedOverride, boundingInfo);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this._decoder.decodeMeshToMeshDataAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { DracoCodec, type IDracoCodecConfiguration } from "./dracoCodec";
|
|
2
|
+
import { Geometry } from "../geometry";
|
|
3
|
+
import type { BoundingInfo } from "../../Culling/boundingInfo";
|
|
4
|
+
import type { Scene } from "../../scene";
|
|
5
|
+
import type { Nullable } from "../../types";
|
|
6
|
+
import type { AttributeData } from "./dracoCompressionWorker";
|
|
7
|
+
export interface MeshData {
|
|
8
|
+
indices?: Uint16Array | Uint32Array;
|
|
9
|
+
attributes: Array<AttributeData>;
|
|
10
|
+
totalVertices: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @experimental This class is an experimental version of `DracoCompression` and is subject to change.
|
|
14
|
+
*
|
|
15
|
+
* Draco Decoder (https://google.github.io/draco/)
|
|
16
|
+
*
|
|
17
|
+
* This class wraps the Draco decoder module.
|
|
18
|
+
*
|
|
19
|
+
* 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.
|
|
20
|
+
*
|
|
21
|
+
* To update the configuration, use the following code:
|
|
22
|
+
* ```javascript
|
|
23
|
+
* DracoDecoder.DefaultConfiguration = {
|
|
24
|
+
* wasmUrl: "<url to the WebAssembly library>",
|
|
25
|
+
* wasmBinaryUrl: "<url to the WebAssembly binary>",
|
|
26
|
+
* fallbackUrl: "<url to the fallback JavaScript library>",
|
|
27
|
+
* };
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* 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.
|
|
31
|
+
* Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
|
|
32
|
+
* Use `DracoDecoder.DefaultAvailable` to determine if the decoder configuration is available for the current context.
|
|
33
|
+
*
|
|
34
|
+
* To decode Draco compressed data, get the default DracoDecoder object and call decodeMeshToGeometryAsync:
|
|
35
|
+
* ```javascript
|
|
36
|
+
* var geometry = await DracoDecoder.Default.decodeMeshToGeometryAsync(data);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class DracoDecoder extends DracoCodec {
|
|
40
|
+
/**
|
|
41
|
+
* Default configuration for the DracoDecoder. Defaults to the following:
|
|
42
|
+
* - numWorkers: 50% of the available logical processors, capped to 4. If no logical processors are available, defaults to 1.
|
|
43
|
+
* - wasmUrl: `"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js"`
|
|
44
|
+
* - wasmBinaryUrl: `"https://cdn.babylonjs.com/draco_decoder_gltf.wasm"`
|
|
45
|
+
* - fallbackUrl: `"https://cdn.babylonjs.com/draco_decoder_gltf.js"`
|
|
46
|
+
*/
|
|
47
|
+
static DefaultConfiguration: IDracoCodecConfiguration;
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if the decoder's `DefaultConfiguration` is available.
|
|
50
|
+
*/
|
|
51
|
+
static get DefaultAvailable(): boolean;
|
|
52
|
+
protected static _Default: Nullable<DracoDecoder>;
|
|
53
|
+
/**
|
|
54
|
+
* Default instance for the DracoDecoder.
|
|
55
|
+
*/
|
|
56
|
+
static get Default(): DracoDecoder;
|
|
57
|
+
/**
|
|
58
|
+
* Reset the default DracoDecoder object to null and disposing the removed default instance.
|
|
59
|
+
* Note that if the workerPool is a member of the static DefaultConfiguration object it is recommended not to run dispose,
|
|
60
|
+
* unless the static worker pool is no longer needed.
|
|
61
|
+
* @param skipDispose set to true to not dispose the removed default instance
|
|
62
|
+
*/
|
|
63
|
+
static ResetDefault(skipDispose?: boolean): void;
|
|
64
|
+
protected _isModuleAvailable(): boolean;
|
|
65
|
+
protected _createModuleAsync(wasmBinary?: ArrayBuffer, jsModule?: any): Promise<{
|
|
66
|
+
module: any; /** DecoderModule */
|
|
67
|
+
}>;
|
|
68
|
+
protected _getWorkerContent(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new Draco decoder.
|
|
71
|
+
* @param configuration Optional override of the configuration for the DracoDecoder. If not provided, defaults to {@link DracoDecoder.DefaultConfiguration}.
|
|
72
|
+
*/
|
|
73
|
+
constructor(configuration?: IDracoCodecConfiguration);
|
|
74
|
+
/**
|
|
75
|
+
* Decode Draco compressed mesh data to mesh data.
|
|
76
|
+
* @param data The ArrayBuffer or ArrayBufferView of the compressed Draco data
|
|
77
|
+
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
|
|
78
|
+
* @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization
|
|
79
|
+
* @returns A promise that resolves with the decoded mesh data
|
|
80
|
+
*/
|
|
81
|
+
decodeMeshToMeshDataAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
|
|
82
|
+
[kind: string]: number;
|
|
83
|
+
}, gltfNormalizedOverride?: {
|
|
84
|
+
[kind: string]: boolean;
|
|
85
|
+
}): Promise<MeshData>;
|
|
86
|
+
/**
|
|
87
|
+
* Decode Draco compressed mesh data to Babylon geometry.
|
|
88
|
+
* @param name The name to use when creating the geometry
|
|
89
|
+
* @param scene The scene to use when creating the geometry
|
|
90
|
+
* @param data The ArrayBuffer or ArrayBufferView of the Draco compressed data
|
|
91
|
+
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
|
|
92
|
+
* @returns A promise that resolves with the decoded geometry
|
|
93
|
+
*/
|
|
94
|
+
decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: {
|
|
95
|
+
[kind: string]: number;
|
|
96
|
+
}): Promise<Geometry>;
|
|
97
|
+
/** @internal */
|
|
98
|
+
_decodeMeshToGeometryForGltfAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes: {
|
|
99
|
+
[kind: string]: number;
|
|
100
|
+
}, gltfNormalizedOverride: {
|
|
101
|
+
[kind: string]: boolean;
|
|
102
|
+
}, boundingInfo: Nullable<BoundingInfo>): Promise<Geometry>;
|
|
103
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { _IsConfigurationAvailable, DracoCodec } from "./dracoCodec.js";
|
|
2
|
+
import { Tools } from "../../Misc/tools.js";
|
|
3
|
+
import { Geometry } from "../geometry.js";
|
|
4
|
+
import { VertexBuffer } from "../buffer.js";
|
|
5
|
+
import { Logger } from "../../Misc/logger.js";
|
|
6
|
+
import { decodeMesh, workerFunction } from "./dracoCompressionWorker.js";
|
|
7
|
+
/**
|
|
8
|
+
* @experimental This class is an experimental version of `DracoCompression` and is subject to change.
|
|
9
|
+
*
|
|
10
|
+
* Draco Decoder (https://google.github.io/draco/)
|
|
11
|
+
*
|
|
12
|
+
* This class wraps the Draco decoder module.
|
|
13
|
+
*
|
|
14
|
+
* 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.
|
|
15
|
+
*
|
|
16
|
+
* To update the configuration, use the following code:
|
|
17
|
+
* ```javascript
|
|
18
|
+
* DracoDecoder.DefaultConfiguration = {
|
|
19
|
+
* wasmUrl: "<url to the WebAssembly library>",
|
|
20
|
+
* wasmBinaryUrl: "<url to the WebAssembly binary>",
|
|
21
|
+
* fallbackUrl: "<url to the fallback JavaScript library>",
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* 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.
|
|
26
|
+
* Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
|
|
27
|
+
* Use `DracoDecoder.DefaultAvailable` to determine if the decoder configuration is available for the current context.
|
|
28
|
+
*
|
|
29
|
+
* To decode Draco compressed data, get the default DracoDecoder object and call decodeMeshToGeometryAsync:
|
|
30
|
+
* ```javascript
|
|
31
|
+
* var geometry = await DracoDecoder.Default.decodeMeshToGeometryAsync(data);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export class DracoDecoder extends DracoCodec {
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if the decoder's `DefaultConfiguration` is available.
|
|
37
|
+
*/
|
|
38
|
+
static get DefaultAvailable() {
|
|
39
|
+
return _IsConfigurationAvailable(DracoDecoder.DefaultConfiguration);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Default instance for the DracoDecoder.
|
|
43
|
+
*/
|
|
44
|
+
static get Default() {
|
|
45
|
+
DracoDecoder._Default ?? (DracoDecoder._Default = new DracoDecoder());
|
|
46
|
+
return DracoDecoder._Default;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reset the default DracoDecoder object to null and disposing the removed default instance.
|
|
50
|
+
* Note that if the workerPool is a member of the static DefaultConfiguration object it is recommended not to run dispose,
|
|
51
|
+
* unless the static worker pool is no longer needed.
|
|
52
|
+
* @param skipDispose set to true to not dispose the removed default instance
|
|
53
|
+
*/
|
|
54
|
+
static ResetDefault(skipDispose) {
|
|
55
|
+
if (DracoDecoder._Default) {
|
|
56
|
+
if (!skipDispose) {
|
|
57
|
+
DracoDecoder._Default.dispose();
|
|
58
|
+
}
|
|
59
|
+
DracoDecoder._Default = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
_isModuleAvailable() {
|
|
63
|
+
return typeof DracoDecoderModule !== "undefined";
|
|
64
|
+
}
|
|
65
|
+
async _createModuleAsync(wasmBinary, jsModule) {
|
|
66
|
+
const module = await (jsModule || DracoDecoderModule)({ wasmBinary });
|
|
67
|
+
return { module };
|
|
68
|
+
}
|
|
69
|
+
_getWorkerContent() {
|
|
70
|
+
return `${decodeMesh}(${workerFunction})()`;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new Draco decoder.
|
|
74
|
+
* @param configuration Optional override of the configuration for the DracoDecoder. If not provided, defaults to {@link DracoDecoder.DefaultConfiguration}.
|
|
75
|
+
*/
|
|
76
|
+
constructor(configuration = DracoDecoder.DefaultConfiguration) {
|
|
77
|
+
super(configuration);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Decode Draco compressed mesh data to mesh data.
|
|
81
|
+
* @param data The ArrayBuffer or ArrayBufferView of the compressed Draco data
|
|
82
|
+
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
|
|
83
|
+
* @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization
|
|
84
|
+
* @returns A promise that resolves with the decoded mesh data
|
|
85
|
+
*/
|
|
86
|
+
decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride) {
|
|
87
|
+
const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
88
|
+
const applyGltfNormalizedOverride = (kind, normalized) => {
|
|
89
|
+
if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {
|
|
90
|
+
if (normalized !== gltfNormalizedOverride[kind]) {
|
|
91
|
+
Logger.Warn(`Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`);
|
|
92
|
+
}
|
|
93
|
+
return gltfNormalizedOverride[kind];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return normalized;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
if (this._workerPoolPromise) {
|
|
100
|
+
return this._workerPoolPromise.then((workerPool) => {
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
workerPool.push((worker, onComplete) => {
|
|
103
|
+
let resultIndices = null;
|
|
104
|
+
const resultAttributes = [];
|
|
105
|
+
const onError = (error) => {
|
|
106
|
+
worker.removeEventListener("error", onError);
|
|
107
|
+
worker.removeEventListener("message", onMessage);
|
|
108
|
+
reject(error);
|
|
109
|
+
onComplete();
|
|
110
|
+
};
|
|
111
|
+
const onMessage = (event) => {
|
|
112
|
+
const message = event.data;
|
|
113
|
+
switch (message.id) {
|
|
114
|
+
case "indices": {
|
|
115
|
+
resultIndices = message.data;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "attribute": {
|
|
119
|
+
resultAttributes.push({
|
|
120
|
+
kind: message.kind,
|
|
121
|
+
data: message.data,
|
|
122
|
+
size: message.size,
|
|
123
|
+
byteOffset: message.byteOffset,
|
|
124
|
+
byteStride: message.byteStride,
|
|
125
|
+
normalized: applyGltfNormalizedOverride(message.kind, message.normalized),
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
case "decodeMeshDone": {
|
|
130
|
+
worker.removeEventListener("error", onError);
|
|
131
|
+
worker.removeEventListener("message", onMessage);
|
|
132
|
+
resolve({ indices: resultIndices, attributes: resultAttributes, totalVertices: message.totalVertices });
|
|
133
|
+
onComplete();
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
worker.addEventListener("error", onError);
|
|
139
|
+
worker.addEventListener("message", onMessage);
|
|
140
|
+
const dataViewCopy = dataView.slice();
|
|
141
|
+
worker.postMessage({ id: "decodeMesh", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (this._modulePromise) {
|
|
147
|
+
return this._modulePromise.then((decoder) => {
|
|
148
|
+
let resultIndices = null;
|
|
149
|
+
const resultAttributes = [];
|
|
150
|
+
const numPoints = decodeMesh(decoder.module, dataView, attributes, (indices) => {
|
|
151
|
+
resultIndices = indices;
|
|
152
|
+
}, (kind, data, size, byteOffset, byteStride, normalized) => {
|
|
153
|
+
resultAttributes.push({
|
|
154
|
+
kind,
|
|
155
|
+
data,
|
|
156
|
+
size,
|
|
157
|
+
byteOffset,
|
|
158
|
+
byteStride,
|
|
159
|
+
normalized,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
return { indices: resultIndices, attributes: resultAttributes, totalVertices: numPoints };
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
throw new Error("Draco decoder module is not available");
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Decode Draco compressed mesh data to Babylon geometry.
|
|
169
|
+
* @param name The name to use when creating the geometry
|
|
170
|
+
* @param scene The scene to use when creating the geometry
|
|
171
|
+
* @param data The ArrayBuffer or ArrayBufferView of the Draco compressed data
|
|
172
|
+
* @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
|
|
173
|
+
* @returns A promise that resolves with the decoded geometry
|
|
174
|
+
*/
|
|
175
|
+
async decodeMeshToGeometryAsync(name, scene, data, attributes) {
|
|
176
|
+
const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);
|
|
177
|
+
const geometry = new Geometry(name, scene);
|
|
178
|
+
if (meshData.indices) {
|
|
179
|
+
geometry.setIndices(meshData.indices);
|
|
180
|
+
}
|
|
181
|
+
for (const attribute of meshData.attributes) {
|
|
182
|
+
geometry.setVerticesBuffer(new VertexBuffer(scene.getEngine(), attribute.data, attribute.kind, false, undefined, attribute.byteStride, undefined, attribute.byteOffset, attribute.size, undefined, attribute.normalized, true), meshData.totalVertices);
|
|
183
|
+
}
|
|
184
|
+
return geometry;
|
|
185
|
+
}
|
|
186
|
+
/** @internal */
|
|
187
|
+
async _decodeMeshToGeometryForGltfAsync(name, scene, data, attributes, gltfNormalizedOverride, boundingInfo) {
|
|
188
|
+
const meshData = await this.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);
|
|
189
|
+
const geometry = new Geometry(name, scene);
|
|
190
|
+
if (boundingInfo) {
|
|
191
|
+
geometry._boundingInfo = boundingInfo;
|
|
192
|
+
geometry.useBoundingInfoFromGeometry = true;
|
|
193
|
+
}
|
|
194
|
+
if (meshData.indices) {
|
|
195
|
+
geometry.setIndices(meshData.indices);
|
|
196
|
+
}
|
|
197
|
+
for (const attribute of meshData.attributes) {
|
|
198
|
+
geometry.setVerticesBuffer(new VertexBuffer(scene.getEngine(), attribute.data, attribute.kind, false, undefined, attribute.byteStride, undefined, attribute.byteOffset, attribute.size, undefined, attribute.normalized, true), meshData.totalVertices);
|
|
199
|
+
}
|
|
200
|
+
return geometry;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Default configuration for the DracoDecoder. Defaults to the following:
|
|
205
|
+
* - numWorkers: 50% of the available logical processors, capped to 4. If no logical processors are available, defaults to 1.
|
|
206
|
+
* - wasmUrl: `"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js"`
|
|
207
|
+
* - wasmBinaryUrl: `"https://cdn.babylonjs.com/draco_decoder_gltf.wasm"`
|
|
208
|
+
* - fallbackUrl: `"https://cdn.babylonjs.com/draco_decoder_gltf.js"`
|
|
209
|
+
*/
|
|
210
|
+
DracoDecoder.DefaultConfiguration = {
|
|
211
|
+
wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,
|
|
212
|
+
wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,
|
|
213
|
+
fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,
|
|
214
|
+
};
|
|
215
|
+
DracoDecoder._Default = null;
|
|
216
|
+
//# sourceMappingURL=dracoDecoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dracoDecoder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoDecoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,UAAU,EAAiC,MA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B,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1C,QAAQ,CAAC,iBAAiB,CACtB,IAAI,YAAY,CACZ,KAAK,CAAC,SAAS,EAAE,EACjB,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,KAAK,EACL,SAAS,EACT,SAAS,CAAC,UAAU,EACpB,SAAS,EACT,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,IAAI,EACd,SAAS,EACT,SAAS,CAAC,UAAU,EACpB,IAAI,CACP,EACD,QAAQ,CAAC,aAAa,CACzB,CAAC;QACN,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;;AA1PD;;;;;;GAMG;AACW,iCAAoB,GAA6B;IAC3D,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,6BAA6B;IAC7D,aAAa,EAAE,GAAG,KAAK,CAAC,cAAc,0BAA0B;IAChE,WAAW,EAAE,GAAG,KAAK,CAAC,cAAc,wBAAwB;CAC/D,CAAC;AASe,qBAAQ,GAA2B,IAAI,CAAC","sourcesContent":["import { DracoDecoderModule } from \"draco3dgltf\";\r\nimport { _IsConfigurationAvailable, DracoCodec, type IDracoCodecConfiguration } from \"./dracoCodec\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { BoundingInfo } from \"../../Culling/boundingInfo\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { decodeMesh, workerFunction } from \"./dracoCompressionWorker\";\r\nimport type { AttributeData, Message } from \"./dracoCompressionWorker\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\nexport interface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\n/**\r\n * @experimental This class is an experimental version of `DracoCompression` and is subject to change.\r\n *\r\n * Draco Decoder (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco decoder module.\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 * DracoDecoder.DefaultConfiguration = {\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 * 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 `DracoDecoder.DefaultAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoDecoder object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoDecoder.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n */\r\nexport class DracoDecoder extends DracoCodec {\r\n /**\r\n * Default configuration for the DracoDecoder. Defaults to the following:\r\n * - numWorkers: 50% of the available logical processors, capped to 4. If no logical processors are available, defaults to 1.\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 DefaultConfiguration: IDracoCodecConfiguration = {\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 * Returns true if the decoder's `DefaultConfiguration` is available.\r\n */\r\n public static get DefaultAvailable(): boolean {\r\n return _IsConfigurationAvailable(DracoDecoder.DefaultConfiguration);\r\n }\r\n\r\n protected static _Default: Nullable<DracoDecoder> = null;\r\n /**\r\n * Default instance for the DracoDecoder.\r\n */\r\n public static get Default(): DracoDecoder {\r\n DracoDecoder._Default ??= new DracoDecoder();\r\n return DracoDecoder._Default;\r\n }\r\n\r\n /**\r\n * Reset the default DracoDecoder object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static DefaultConfiguration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoDecoder._Default) {\r\n if (!skipDispose) {\r\n DracoDecoder._Default.dispose();\r\n }\r\n DracoDecoder._Default = null;\r\n }\r\n }\r\n\r\n protected override _isModuleAvailable(): boolean {\r\n return typeof DracoDecoderModule !== \"undefined\";\r\n }\r\n\r\n protected override async _createModuleAsync(wasmBinary?: ArrayBuffer, jsModule?: any): Promise<{ module: any /** DecoderModule */ }> {\r\n const module = await ((jsModule as DracoDecoderModule) || DracoDecoderModule)({ wasmBinary });\r\n return { module };\r\n }\r\n\r\n protected override _getWorkerContent(): string {\r\n return `${decodeMesh}(${workerFunction})()`;\r\n }\r\n\r\n /**\r\n * Creates a new Draco decoder.\r\n * @param configuration Optional override of the configuration for the DracoDecoder. If not provided, defaults to {@link DracoDecoder.DefaultConfiguration}.\r\n */\r\n constructor(configuration: IDracoCodecConfiguration = DracoDecoder.DefaultConfiguration) {\r\n super(configuration);\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to mesh data.\r\n * @param data The ArrayBuffer or ArrayBufferView of the compressed Draco 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 \"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 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 }\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._modulePromise) {\r\n return this._modulePromise.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 of the Draco compressed 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 boundingInfo: Nullable<BoundingInfo>\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 (boundingInfo) {\r\n geometry._boundingInfo = boundingInfo;\r\n geometry.useBoundingInfoFromGeometry = true;\r\n }\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./dracoCompression\";\r\nexport * from \"./meshoptCompression\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./dracoCompression\";\r\nexport * from \"./meshoptCompression\";\r\nexport * from \"./dracoDecoder\";\r\n"]}
|
package/Meshes/abstractMesh.d.ts
CHANGED
|
@@ -1099,6 +1099,11 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
|
|
|
1099
1099
|
* @returns the current mesh
|
|
1100
1100
|
*/
|
|
1101
1101
|
createNormals(updatable: boolean): AbstractMesh;
|
|
1102
|
+
/**
|
|
1103
|
+
* Optimize the indices order so that we keep the faces with similar indices together
|
|
1104
|
+
* @returns the current mesh
|
|
1105
|
+
*/
|
|
1106
|
+
optimizeIndicesAsync(): Promise<AbstractMesh>;
|
|
1102
1107
|
/**
|
|
1103
1108
|
* Align the mesh with a normal
|
|
1104
1109
|
* @param normal defines the normal to use
|
package/Meshes/abstractMesh.js
CHANGED
|
@@ -2218,6 +2218,21 @@ export class AbstractMesh extends TransformNode {
|
|
|
2218
2218
|
this.setVerticesData(VertexBuffer.NormalKind, normals, updatable);
|
|
2219
2219
|
return this;
|
|
2220
2220
|
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Optimize the indices order so that we keep the faces with similar indices together
|
|
2223
|
+
* @returns the current mesh
|
|
2224
|
+
*/
|
|
2225
|
+
async optimizeIndicesAsync() {
|
|
2226
|
+
const indices = this.getIndices();
|
|
2227
|
+
if (!indices) {
|
|
2228
|
+
return this;
|
|
2229
|
+
}
|
|
2230
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2231
|
+
const { OptimizeIndices } = await import("./mesh.vertexData.functions.js");
|
|
2232
|
+
OptimizeIndices(indices);
|
|
2233
|
+
this.setIndices(indices, this.getTotalVertices());
|
|
2234
|
+
return this;
|
|
2235
|
+
}
|
|
2221
2236
|
/**
|
|
2222
2237
|
* Align the mesh with a normal
|
|
2223
2238
|
* @param normal defines the normal to use
|