@babylonjs/core 8.49.6 → 8.49.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/Animations/animationGroup.d.ts +2 -3
  2. package/Animations/animationGroup.js +10 -15
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Bones/bone.d.ts +2 -0
  5. package/Bones/bone.js +2 -0
  6. package/Bones/bone.js.map +1 -1
  7. package/Bones/skeleton.js +7 -0
  8. package/Bones/skeleton.js.map +1 -1
  9. package/Cameras/Limits/geospatialLimits.d.ts +1 -1
  10. package/Cameras/Limits/geospatialLimits.js +1 -1
  11. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  12. package/Culling/ray.core.js +2 -2
  13. package/Culling/ray.core.js.map +1 -1
  14. package/Engines/abstractEngine.js +2 -2
  15. package/Engines/abstractEngine.js.map +1 -1
  16. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.d.ts +76 -0
  17. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.js +209 -0
  18. package/FrameGraph/Node/Blocks/Layers/selectionOutlineLayerBlock.js.map +1 -0
  19. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +5 -0
  20. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +34 -0
  21. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  22. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
  23. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  24. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  25. package/FrameGraph/Node/Blocks/index.js +1 -0
  26. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  27. package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +20 -6
  28. package/FrameGraph/Tasks/Layers/baseLayerTask.js +108 -77
  29. package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
  30. package/FrameGraph/Tasks/Layers/glowLayerTask.js +1 -1
  31. package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -1
  32. package/FrameGraph/Tasks/Layers/highlightLayerTask.js +1 -1
  33. package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -1
  34. package/FrameGraph/Tasks/Layers/selectionOutlineTask.d.ts +28 -0
  35. package/FrameGraph/Tasks/Layers/selectionOutlineTask.js +36 -0
  36. package/FrameGraph/Tasks/Layers/selectionOutlineTask.js.map +1 -0
  37. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +5 -0
  38. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +12 -1
  39. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  40. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +5 -0
  41. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +12 -1
  42. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  43. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +5 -0
  44. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +10 -1
  45. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  46. package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.d.ts +5 -0
  47. package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js +12 -1
  48. package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js.map +1 -1
  49. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +5 -0
  50. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +12 -1
  51. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -1
  52. package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
  53. package/FrameGraph/frameGraphRenderContext.js +3 -1
  54. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  55. package/FrameGraph/index.d.ts +1 -0
  56. package/FrameGraph/index.js +1 -0
  57. package/FrameGraph/index.js.map +1 -1
  58. package/Layers/effectLayer.d.ts +4 -0
  59. package/Layers/effectLayer.js +2 -0
  60. package/Layers/effectLayer.js.map +1 -1
  61. package/Layers/highlightLayer.js +1 -0
  62. package/Layers/highlightLayer.js.map +1 -1
  63. package/Layers/index.d.ts +2 -0
  64. package/Layers/index.js +2 -0
  65. package/Layers/index.js.map +1 -1
  66. package/Layers/selectionOutlineLayer.d.ts +180 -0
  67. package/Layers/selectionOutlineLayer.js +319 -0
  68. package/Layers/selectionOutlineLayer.js.map +1 -0
  69. package/Layers/thinEffectLayer.d.ts +5 -1
  70. package/Layers/thinEffectLayer.js +21 -16
  71. package/Layers/thinEffectLayer.js.map +1 -1
  72. package/Layers/thinGlowLayer.js +1 -0
  73. package/Layers/thinGlowLayer.js.map +1 -1
  74. package/Layers/thinHighlightLayer.js +1 -0
  75. package/Layers/thinHighlightLayer.js.map +1 -1
  76. package/Layers/thinSelectionOutlineLayer.d.ts +148 -0
  77. package/Layers/thinSelectionOutlineLayer.js +579 -0
  78. package/Layers/thinSelectionOutlineLayer.js.map +1 -0
  79. package/Loading/Plugins/babylonFileLoader.js +136 -48
  80. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  81. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -0
  82. package/Materials/Node/Blocks/Dual/textureBlock.js +10 -0
  83. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  84. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -2
  85. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  86. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +9 -0
  87. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  88. package/Materials/Node/Blocks/index.d.ts +1 -0
  89. package/Materials/Node/Blocks/index.js +1 -0
  90. package/Materials/Node/Blocks/index.js.map +1 -1
  91. package/Materials/Node/Blocks/pannerBlock.d.ts +39 -0
  92. package/Materials/Node/Blocks/pannerBlock.js +88 -0
  93. package/Materials/Node/Blocks/pannerBlock.js.map +1 -0
  94. package/Materials/Node/nodeMaterialBuildStateSharedData.js +1 -1
  95. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  96. package/Maths/math.vector.functions.d.ts +11 -3
  97. package/Maths/math.vector.functions.js +10 -0
  98. package/Maths/math.vector.functions.js.map +1 -1
  99. package/Meshes/Compression/dracoCompressionWorker.d.ts +1 -1
  100. package/Meshes/Compression/dracoCompressionWorker.js +14 -9
  101. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  102. package/Meshes/Compression/dracoDecoder.js +1 -1
  103. package/Meshes/Compression/dracoDecoder.js.map +1 -1
  104. package/Meshes/Compression/dracoEncoder.d.ts +2 -2
  105. package/Meshes/Compression/dracoEncoder.js +11 -5
  106. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  107. package/Meshes/Compression/dracoEncoder.types.d.ts +8 -5
  108. package/Meshes/Compression/dracoEncoder.types.js.map +1 -1
  109. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +18 -0
  110. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +122 -28
  111. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  112. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.d.ts +74 -0
  113. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.js +107 -0
  114. package/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh.js.map +1 -0
  115. package/Meshes/abstractMesh.d.ts +4 -0
  116. package/Meshes/abstractMesh.js +4 -0
  117. package/Meshes/abstractMesh.js.map +1 -1
  118. package/Meshes/csg2.js +9 -1
  119. package/Meshes/csg2.js.map +1 -1
  120. package/Meshes/instancedMesh.js +2 -2
  121. package/Meshes/instancedMesh.js.map +1 -1
  122. package/Meshes/mesh.js +6 -1
  123. package/Meshes/mesh.js.map +1 -1
  124. package/Misc/environmentTextureTools.js +1 -1
  125. package/Misc/environmentTextureTools.js.map +1 -1
  126. package/Misc/fileTools.js +1 -1
  127. package/Misc/fileTools.js.map +1 -1
  128. package/Misc/textureTools.d.ts +2 -1
  129. package/Misc/textureTools.js +5 -3
  130. package/Misc/textureTools.js.map +1 -1
  131. package/Morph/morphTarget.js +2 -1
  132. package/Morph/morphTarget.js.map +1 -1
  133. package/Particles/Node/Blocks/systemBlock.d.ts +27 -4
  134. package/Particles/Node/Blocks/systemBlock.js +36 -8
  135. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  136. package/Particles/Node/nodeParticleSystemSet.helper.js +42 -6
  137. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  138. package/Shaders/selection.fragment.d.ts +7 -0
  139. package/Shaders/selection.fragment.js +47 -0
  140. package/Shaders/selection.fragment.js.map +1 -0
  141. package/Shaders/selection.vertex.d.ts +17 -0
  142. package/Shaders/selection.vertex.js +95 -0
  143. package/Shaders/selection.vertex.js.map +1 -0
  144. package/Shaders/selectionOutline.fragment.d.ts +5 -0
  145. package/Shaders/selectionOutline.fragment.js +23 -0
  146. package/Shaders/selectionOutline.fragment.js.map +1 -0
  147. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js +1 -1
  148. package/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.js.map +1 -1
  149. package/ShadersWGSL/selection.fragment.d.ts +7 -0
  150. package/ShadersWGSL/selection.fragment.js +47 -0
  151. package/ShadersWGSL/selection.fragment.js.map +1 -0
  152. package/ShadersWGSL/selection.vertex.d.ts +17 -0
  153. package/ShadersWGSL/selection.vertex.js +96 -0
  154. package/ShadersWGSL/selection.vertex.js.map +1 -0
  155. package/ShadersWGSL/selectionOutline.fragment.d.ts +5 -0
  156. package/ShadersWGSL/selectionOutline.fragment.js +24 -0
  157. package/ShadersWGSL/selectionOutline.fragment.js.map +1 -0
  158. package/package.json +1 -1
  159. package/scene.d.ts +2 -2
  160. package/scene.js +10 -2
  161. package/scene.js.map +1 -1
@@ -0,0 +1,88 @@
1
+ import { NodeMaterialBlock } from "../nodeMaterialBlock.js";
2
+ import { NodeMaterialBlockConnectionPointTypes } from "../Enums/nodeMaterialBlockConnectionPointTypes.js";
3
+ import { NodeMaterialBlockTargets } from "../Enums/nodeMaterialBlockTargets.js";
4
+ import { RegisterClass } from "../../../Misc/typeStore.js";
5
+ import { InputBlock } from "./Input/inputBlock.js";
6
+ import { AnimatedInputBlockTypes } from "./Input/animatedInputBlockTypes.js";
7
+ import { NodeMaterialModes } from "../Enums/nodeMaterialModes.js";
8
+ /**
9
+ * Block used to pan UV coordinates over time (similar to Unreal's Panner node).
10
+ * This block takes UV coordinates, speed values for X and Y axes, and a time input,
11
+ * then outputs animated UV coordinates that scroll based on the speed and time.
12
+ */
13
+ export class PannerBlock extends NodeMaterialBlock {
14
+ /**
15
+ * Creates a new PannerBlock
16
+ * @param name defines the block name
17
+ */
18
+ constructor(name) {
19
+ super(name, NodeMaterialBlockTargets.Neutral);
20
+ this.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2);
21
+ this.registerInput("speed", NodeMaterialBlockConnectionPointTypes.Vector2);
22
+ this.registerInput("time", NodeMaterialBlockConnectionPointTypes.Float);
23
+ this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2);
24
+ }
25
+ /**
26
+ * Gets the current class name
27
+ * @returns the class name
28
+ */
29
+ getClassName() {
30
+ return "PannerBlock";
31
+ }
32
+ /**
33
+ * Gets the uv input component
34
+ */
35
+ get uv() {
36
+ return this._inputs[0];
37
+ }
38
+ /**
39
+ * Gets the speed input component
40
+ */
41
+ get speed() {
42
+ return this._inputs[1];
43
+ }
44
+ /**
45
+ * Gets the time input component
46
+ */
47
+ get time() {
48
+ return this._inputs[2];
49
+ }
50
+ /**
51
+ * Gets the output component
52
+ */
53
+ get output() {
54
+ return this._outputs[0];
55
+ }
56
+ autoConfigure(material, additionalFilteringInfo = () => true) {
57
+ if (!this.uv.isConnected) {
58
+ if (material.mode !== NodeMaterialModes.PostProcess && material.mode !== NodeMaterialModes.ProceduralTexture) {
59
+ const attributeName = material.mode === NodeMaterialModes.Particle ? "particle_uv" : "uv";
60
+ let uvInput = material.getInputBlockByPredicate((b) => b.isAttribute && b.name === attributeName && additionalFilteringInfo(b));
61
+ if (!uvInput) {
62
+ uvInput = new InputBlock("uv");
63
+ uvInput.setAsAttribute(attributeName);
64
+ }
65
+ uvInput.output.connectTo(this.uv);
66
+ }
67
+ }
68
+ if (!this.time.isConnected) {
69
+ let timeInput = material.getInputBlockByPredicate((b) => b.animationType === AnimatedInputBlockTypes.Time && additionalFilteringInfo(b));
70
+ if (!timeInput) {
71
+ timeInput = new InputBlock("time");
72
+ timeInput.value = 0;
73
+ timeInput.animationType = AnimatedInputBlockTypes.Time;
74
+ }
75
+ timeInput.output.connectTo(this.time);
76
+ }
77
+ }
78
+ _buildBlock(state) {
79
+ super._buildBlock(state);
80
+ const output = this._outputs[0];
81
+ // Output = UV + speed * time
82
+ state.compilationString +=
83
+ state._declareOutput(output) + ` = ${this.uv.associatedVariableName} + ${this.speed.associatedVariableName} * ${this.time.associatedVariableName};\n`;
84
+ return this;
85
+ }
86
+ }
87
+ RegisterClass("BABYLON.PannerBlock", PannerBlock);
88
+ //# sourceMappingURL=pannerBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pannerBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Node/Blocks/pannerBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE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AAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEhC,6BAA6B;QAC7B,KAAK,CAAC,iBAAiB;YACnB,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,sBAAsB,MAAM,IAAI,CAAC,KAAK,CAAC,sBAAsB,MAAM,IAAI,CAAC,IAAI,CAAC,sBAAsB,KAAK,CAAC;QAE1J,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { InputBlock } from \"./Input/inputBlock\";\r\nimport type { NodeMaterial } from \"../nodeMaterial\";\r\nimport { AnimatedInputBlockTypes } from \"./Input/animatedInputBlockTypes\";\r\nimport { NodeMaterialModes } from \"../Enums/nodeMaterialModes\";\r\n\r\n/**\r\n * Block used to pan UV coordinates over time (similar to Unreal's Panner node).\r\n * This block takes UV coordinates, speed values for X and Y axes, and a time input,\r\n * then outputs animated UV coordinates that scroll based on the speed and time.\r\n */\r\nexport class PannerBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new PannerBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"uv\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n this.registerInput(\"speed\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n this.registerInput(\"time\", NodeMaterialBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.Vector2);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"PannerBlock\";\r\n }\r\n\r\n /**\r\n * Gets the uv input component\r\n */\r\n public get uv(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the speed input component\r\n */\r\n public get speed(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the time input component\r\n */\r\n public get time(): NodeMaterialConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure(material: NodeMaterial, additionalFilteringInfo: (node: NodeMaterialBlock) => boolean = () => true) {\r\n if (!this.uv.isConnected) {\r\n if (material.mode !== NodeMaterialModes.PostProcess && material.mode !== NodeMaterialModes.ProceduralTexture) {\r\n const attributeName = material.mode === NodeMaterialModes.Particle ? \"particle_uv\" : \"uv\";\r\n\r\n let uvInput = material.getInputBlockByPredicate((b) => b.isAttribute && b.name === attributeName && additionalFilteringInfo(b));\r\n\r\n if (!uvInput) {\r\n uvInput = new InputBlock(\"uv\");\r\n uvInput.setAsAttribute(attributeName);\r\n }\r\n\r\n uvInput.output.connectTo(this.uv);\r\n }\r\n }\r\n\r\n if (!this.time.isConnected) {\r\n let timeInput = material.getInputBlockByPredicate((b) => b.animationType === AnimatedInputBlockTypes.Time && additionalFilteringInfo(b));\r\n\r\n if (!timeInput) {\r\n timeInput = new InputBlock(\"time\");\r\n timeInput.value = 0;\r\n timeInput.animationType = AnimatedInputBlockTypes.Time;\r\n }\r\n\r\n timeInput.output.connectTo(this.time);\r\n }\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n const output = this._outputs[0];\r\n\r\n // Output = UV + speed * time\r\n state.compilationString +=\r\n state._declareOutput(output) + ` = ${this.uv.associatedVariableName} + ${this.speed.associatedVariableName} * ${this.time.associatedVariableName};\\n`;\r\n\r\n return this;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PannerBlock\", PannerBlock);\r\n"]}
@@ -141,7 +141,7 @@ export class NodeMaterialBuildStateSharedData {
141
141
  * @param message defines the error message to push
142
142
  */
143
143
  raiseBuildError(message) {
144
- if (this.checks.customErrors.indexOf(message) !== -1) {
144
+ if (this.checks.customErrors.indexOf(message) === -1) {
145
145
  this.checks.customErrors.push(message);
146
146
  }
147
147
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nodeMaterialBuildStateSharedData.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Node/nodeMaterialBuildStateSharedData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,gCAAgC;IAkJzC,gCAAgC;IAChC;QA7IA;;WAEG;QACI,UAAK,GAAa,EAAE,CAAC;QAE5B;;WAEG;QACI,aAAQ,GAAa,EAAE,CAAC;QAE/B;;WAEG;QACI,uBAAkB,GAAG,EAAE,CAAC;QAE/B;;;WAGG;QACI,+BAA0B,GAAG,EAAE,CAAC;QAEvC;;;WAGG;QACI,mCAA8B,GAAG,EAAE,CAAC;QAO3C;;WAEG;QACI,gBAAW,GAAiB,EAAE,CAAC;QAEtC;;WAEG;QACI,kBAAa,GAAgC,EAAE,CAAC;QAEvD;;WAEG;QACI,mBAAc,GAAwB,EAAE,CAAC;QAEhD;;WAEG;QACI,yBAAoB,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACI,wBAAmB,GAAwB,EAAE,CAAC;QAErD;;WAEG;QACI,sBAAiB,GAAwB,EAAE,CAAC;QAEnD;;WAEG;QACI,4BAAuB,GAAwB,EAAE,CAAC;QAEzD;;WAEG;QACI,yBAAoB,GAAwB,EAAE,CAAC;QAEtD;;WAEG;QACI,mBAAc,G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ionPoint } from \"./nodeMaterialBlockConnectionPoint\";\r\nimport type { NodeMaterialBlock } from \"./nodeMaterialBlock\";\r\nimport type { InputBlock } from \"./Blocks/Input/inputBlock\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Immutable, Nullable } from \"../../types\";\r\nimport type { NodeMaterial, NodeMaterialTextureBlocks } from \"./nodeMaterial\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to store shared data between 2 NodeMaterialBuildState\r\n */\r\nexport class NodeMaterialBuildStateSharedData {\r\n /**\r\n * The node material we are currently building\r\n */\r\n public nodeMaterial: NodeMaterial;\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public temps: string[] = [];\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public varyings: string[] = [];\r\n\r\n /**\r\n * Gets the varying declaration string (for vertex shader)\r\n */\r\n public varyingDeclaration = \"\";\r\n\r\n /**\r\n * Gets the varying declaration string (for fragment shader)\r\n * This is potentially different from varyingDeclaration only in WebGPU\r\n */\r\n public varyingDeclarationFragment = \"\";\r\n\r\n /**\r\n * Gets the varying initialization string (for fragment shader)\r\n * Only used in WebGPU, to reconstruct the varying values from the vertex shader if their types is mat4x4f\r\n */\r\n public varyingInitializationsFragment = \"\";\r\n\r\n /**\r\n * List of the fragment output nodes\r\n */\r\n public fragmentOutputNodes: Immutable<Array<NodeMaterialBlock>>;\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public inputBlocks: InputBlock[] = [];\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public textureBlocks: NodeMaterialTextureBlocks[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect)\r\n */\r\n public bindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect) that will always be called (by bindForSubMesh), contrary to bindableBlocks that won't be called if _mustRebind() returns false\r\n */\r\n public forcedBindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a compilation fallback\r\n */\r\n public blocksWithFallbacks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a define update\r\n */\r\n public blocksWithDefines: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a repeatable content\r\n */\r\n public repeatableContentBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a dynamic list of uniforms\r\n */\r\n public dynamicUniformBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can block the isReady function for the material\r\n */\r\n public blockingBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Gets the list of animated inputs\r\n */\r\n public animatedInputs: InputBlock[] = [];\r\n\r\n /**\r\n * Defines to inject in the vertex and fragment shaders\r\n */\r\n public defines: { [key: string]: string } = {};\r\n\r\n /**\r\n * Configurations used to format the generated code\r\n */\r\n public formatConfig = {\r\n getUniformAnnotation: null as Nullable<(name: string) => string>,\r\n formatVariablename: (name: string) => name.replace(/[^a-zA-Z_]+/g, \"\"),\r\n };\r\n\r\n /**\r\n * Build Id used to avoid multiple recompilations\r\n */\r\n public buildId: number;\r\n\r\n /** List of emitted variables */\r\n public variableNames: { [key: string]: number } = {};\r\n\r\n /** List of emitted defines */\r\n public defineNames: { [key: string]: number } = {};\r\n\r\n /** Should emit comments? */\r\n public emitComments: boolean;\r\n\r\n /** Emit build activity */\r\n public verbose: boolean;\r\n\r\n /** Gets or sets the hosting scene */\r\n public scene: Scene;\r\n\r\n /**\r\n * Gets the compilation hints emitted at compilation time\r\n */\r\n public hints = {\r\n needWorldViewMatrix: false,\r\n needWorldViewProjectionMatrix: false,\r\n needAlphaBlending: false,\r\n needAlphaTesting: false,\r\n };\r\n\r\n /**\r\n * List of compilation checks\r\n */\r\n public checks = {\r\n emitVertex: false,\r\n emitFragment: false,\r\n notConnectedNonOptionalInputs: new Array<NodeMaterialConnectionPoint>(),\r\n customErrors: new Array<string>(),\r\n };\r\n\r\n /**\r\n * Is vertex program allowed to be empty?\r\n */\r\n public allowEmptyVertexProgram: boolean = false;\r\n\r\n /** Creates a new shared data */\r\n public constructor() {\r\n // Exclude usual attributes from free variable names\r\n this.variableNames[\"position\"] = 0;\r\n this.variableNames[\"normal\"] = 0;\r\n this.variableNames[\"tangent\"] = 0;\r\n this.variableNames[\"uv\"] = 0;\r\n this.variableNames[\"uv2\"] = 0;\r\n this.variableNames[\"uv3\"] = 0;\r\n this.variableNames[\"uv4\"] = 0;\r\n this.variableNames[\"uv5\"] = 0;\r\n this.variableNames[\"uv6\"] = 0;\r\n this.variableNames[\"color\"] = 0;\r\n this.variableNames[\"matricesIndices\"] = 0;\r\n this.variableNames[\"matricesWeights\"] = 0;\r\n this.variableNames[\"matricesIndicesExtra\"] = 0;\r\n this.variableNames[\"matricesWeightsExtra\"] = 0;\r\n this.variableNames[\"diffuseBase\"] = 0;\r\n this.variableNames[\"specularBase\"] = 0;\r\n this.variableNames[\"worldPos\"] = 0;\r\n this.variableNames[\"shadow\"] = 0;\r\n this.variableNames[\"view\"] = 0;\r\n\r\n // Exclude known varyings\r\n this.variableNames[\"vTBN\"] = 0;\r\n\r\n // Exclude defines\r\n this.defineNames[\"MAINUV0\"] = 0;\r\n this.defineNames[\"MAINUV1\"] = 0;\r\n this.defineNames[\"MAINUV2\"] = 0;\r\n this.defineNames[\"MAINUV3\"] = 0;\r\n this.defineNames[\"MAINUV4\"] = 0;\r\n this.defineNames[\"MAINUV5\"] = 0;\r\n this.defineNames[\"MAINUV6\"] = 0;\r\n this.defineNames[\"MAINUV7\"] = 0;\r\n }\r\n\r\n /**\r\n * Push a new error to the build state, avoiding exceptions that can break the build process\r\n * @param message defines the error message to push\r\n */\r\n public raiseBuildError(message: string) {\r\n if (this.checks.customErrors.indexOf(message) !== -1) {\r\n this.checks.customErrors.push(message);\r\n }\r\n }\r\n\r\n /**\r\n * Emits console errors and exceptions if there is a failing check\r\n * @returns true if all checks pass\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n if (!this.checks.emitVertex && !this.allowEmptyVertexProgram) {\r\n errorMessage += \"NodeMaterial does not have a vertex output. You need to at least add a block that generates a position value.\\n\";\r\n }\r\n if (!this.checks.emitFragment) {\r\n errorMessage += \"NodeMaterial does not have a fragment output. You need to at least add a block that generates a color value.\\n\";\r\n }\r\n for (const notConnectedInput of this.checks.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n for (const customError of this.checks.customErrors) {\r\n errorMessage += customError + \"\\n\";\r\n }\r\n\r\n if (errorMessage) {\r\n errorMessage = \"Node material build failed: \\n\" + errorMessage;\r\n Logger.Error(errorMessage);\r\n this.nodeMaterial.onBuildErrorObservable.notifyObservers(errorMessage);\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"nodeMaterialBuildStateSharedData.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Node/nodeMaterialBuildStateSharedData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,6BAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,gCAAgC;IAkJzC,gCAAgC;IAChC;QA7IA;;WAEG;QACI,UAAK,GAAa,EAAE,CAAC;QAE5B;;WAEG;QACI,aAAQ,GAAa,EAAE,CAAC;QAE/B;;WAEG;QACI,uBAAkB,GAAG,EAAE,CAAC;QAE/B;;;WAGG;QACI,+BAA0B,GAAG,EAAE,CAAC;QAEvC;;;WAGG;QACI,mCAA8B,GAAG,EAAE,CAAC;QAO3C;;WAEG;QACI,gBAAW,GAAiB,EAAE,CAAC;QAEtC;;WAEG;QACI,kBAAa,GAAgC,EAAE,CAAC;QAEvD;;WAEG;QACI,mBAAc,GAAwB,EAAE,CAAC;QAEhD;;WAEG;QACI,yBAAoB,GAAwB,EAAE,CAAC;Q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AAC,KAAK,CAAC,YAAY,CAAC,CAAC;YAC3B,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { NodeMaterialConnectionPoint } from \"./nodeMaterialBlockConnectionPoint\";\r\nimport type { NodeMaterialBlock } from \"./nodeMaterialBlock\";\r\nimport type { InputBlock } from \"./Blocks/Input/inputBlock\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Immutable, Nullable } from \"../../types\";\r\nimport type { NodeMaterial, NodeMaterialTextureBlocks } from \"./nodeMaterial\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Class used to store shared data between 2 NodeMaterialBuildState\r\n */\r\nexport class NodeMaterialBuildStateSharedData {\r\n /**\r\n * The node material we are currently building\r\n */\r\n public nodeMaterial: NodeMaterial;\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public temps: string[] = [];\r\n\r\n /**\r\n * Gets the list of emitted varyings\r\n */\r\n public varyings: string[] = [];\r\n\r\n /**\r\n * Gets the varying declaration string (for vertex shader)\r\n */\r\n public varyingDeclaration = \"\";\r\n\r\n /**\r\n * Gets the varying declaration string (for fragment shader)\r\n * This is potentially different from varyingDeclaration only in WebGPU\r\n */\r\n public varyingDeclarationFragment = \"\";\r\n\r\n /**\r\n * Gets the varying initialization string (for fragment shader)\r\n * Only used in WebGPU, to reconstruct the varying values from the vertex shader if their types is mat4x4f\r\n */\r\n public varyingInitializationsFragment = \"\";\r\n\r\n /**\r\n * List of the fragment output nodes\r\n */\r\n public fragmentOutputNodes: Immutable<Array<NodeMaterialBlock>>;\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public inputBlocks: InputBlock[] = [];\r\n\r\n /**\r\n * Input blocks\r\n */\r\n public textureBlocks: NodeMaterialTextureBlocks[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect)\r\n */\r\n public bindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Bindable blocks (Blocks that need to set data to the effect) that will always be called (by bindForSubMesh), contrary to bindableBlocks that won't be called if _mustRebind() returns false\r\n */\r\n public forcedBindableBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a compilation fallback\r\n */\r\n public blocksWithFallbacks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a define update\r\n */\r\n public blocksWithDefines: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a repeatable content\r\n */\r\n public repeatableContentBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can provide a dynamic list of uniforms\r\n */\r\n public dynamicUniformBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * List of blocks that can block the isReady function for the material\r\n */\r\n public blockingBlocks: NodeMaterialBlock[] = [];\r\n\r\n /**\r\n * Gets the list of animated inputs\r\n */\r\n public animatedInputs: InputBlock[] = [];\r\n\r\n /**\r\n * Defines to inject in the vertex and fragment shaders\r\n */\r\n public defines: { [key: string]: string } = {};\r\n\r\n /**\r\n * Configurations used to format the generated code\r\n */\r\n public formatConfig = {\r\n getUniformAnnotation: null as Nullable<(name: string) => string>,\r\n formatVariablename: (name: string) => name.replace(/[^a-zA-Z_]+/g, \"\"),\r\n };\r\n\r\n /**\r\n * Build Id used to avoid multiple recompilations\r\n */\r\n public buildId: number;\r\n\r\n /** List of emitted variables */\r\n public variableNames: { [key: string]: number } = {};\r\n\r\n /** List of emitted defines */\r\n public defineNames: { [key: string]: number } = {};\r\n\r\n /** Should emit comments? */\r\n public emitComments: boolean;\r\n\r\n /** Emit build activity */\r\n public verbose: boolean;\r\n\r\n /** Gets or sets the hosting scene */\r\n public scene: Scene;\r\n\r\n /**\r\n * Gets the compilation hints emitted at compilation time\r\n */\r\n public hints = {\r\n needWorldViewMatrix: false,\r\n needWorldViewProjectionMatrix: false,\r\n needAlphaBlending: false,\r\n needAlphaTesting: false,\r\n };\r\n\r\n /**\r\n * List of compilation checks\r\n */\r\n public checks = {\r\n emitVertex: false,\r\n emitFragment: false,\r\n notConnectedNonOptionalInputs: new Array<NodeMaterialConnectionPoint>(),\r\n customErrors: new Array<string>(),\r\n };\r\n\r\n /**\r\n * Is vertex program allowed to be empty?\r\n */\r\n public allowEmptyVertexProgram: boolean = false;\r\n\r\n /** Creates a new shared data */\r\n public constructor() {\r\n // Exclude usual attributes from free variable names\r\n this.variableNames[\"position\"] = 0;\r\n this.variableNames[\"normal\"] = 0;\r\n this.variableNames[\"tangent\"] = 0;\r\n this.variableNames[\"uv\"] = 0;\r\n this.variableNames[\"uv2\"] = 0;\r\n this.variableNames[\"uv3\"] = 0;\r\n this.variableNames[\"uv4\"] = 0;\r\n this.variableNames[\"uv5\"] = 0;\r\n this.variableNames[\"uv6\"] = 0;\r\n this.variableNames[\"color\"] = 0;\r\n this.variableNames[\"matricesIndices\"] = 0;\r\n this.variableNames[\"matricesWeights\"] = 0;\r\n this.variableNames[\"matricesIndicesExtra\"] = 0;\r\n this.variableNames[\"matricesWeightsExtra\"] = 0;\r\n this.variableNames[\"diffuseBase\"] = 0;\r\n this.variableNames[\"specularBase\"] = 0;\r\n this.variableNames[\"worldPos\"] = 0;\r\n this.variableNames[\"shadow\"] = 0;\r\n this.variableNames[\"view\"] = 0;\r\n\r\n // Exclude known varyings\r\n this.variableNames[\"vTBN\"] = 0;\r\n\r\n // Exclude defines\r\n this.defineNames[\"MAINUV0\"] = 0;\r\n this.defineNames[\"MAINUV1\"] = 0;\r\n this.defineNames[\"MAINUV2\"] = 0;\r\n this.defineNames[\"MAINUV3\"] = 0;\r\n this.defineNames[\"MAINUV4\"] = 0;\r\n this.defineNames[\"MAINUV5\"] = 0;\r\n this.defineNames[\"MAINUV6\"] = 0;\r\n this.defineNames[\"MAINUV7\"] = 0;\r\n }\r\n\r\n /**\r\n * Push a new error to the build state, avoiding exceptions that can break the build process\r\n * @param message defines the error message to push\r\n */\r\n public raiseBuildError(message: string) {\r\n if (this.checks.customErrors.indexOf(message) === -1) {\r\n this.checks.customErrors.push(message);\r\n }\r\n }\r\n\r\n /**\r\n * Emits console errors and exceptions if there is a failing check\r\n * @returns true if all checks pass\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n if (!this.checks.emitVertex && !this.allowEmptyVertexProgram) {\r\n errorMessage += \"NodeMaterial does not have a vertex output. You need to at least add a block that generates a position value.\\n\";\r\n }\r\n if (!this.checks.emitFragment) {\r\n errorMessage += \"NodeMaterial does not have a fragment output. You need to at least add a block that generates a color value.\\n\";\r\n }\r\n for (const notConnectedInput of this.checks.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n for (const customError of this.checks.customErrors) {\r\n errorMessage += customError + \"\\n\";\r\n }\r\n\r\n if (errorMessage) {\r\n errorMessage = \"Node material build failed: \\n\" + errorMessage;\r\n Logger.Error(errorMessage);\r\n this.nodeMaterial.onBuildErrorObservable.notifyObservers(errorMessage);\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n"]}
@@ -65,9 +65,17 @@ export declare function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutab
65
65
  */
66
66
  export declare function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T;
67
67
  export declare function Vector3SubtractToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>, result: T): T;
68
- export declare function Vector3CopyToRef<T extends IVector3Like>(source: IVector3Like, result: T): T;
69
- export declare function Vector3LerpToRef<T extends IVector3Like>(start: T, end: T, amount: number, result: T): T;
70
- export declare function Vector3NormalizeToRef<T extends IVector3Like>(vector: DeepImmutable<T>, result: T): T;
68
+ export declare function Vector3CopyToRef<T extends IVector3Like>(source: DeepImmutable<IVector3Like>, result: T): T;
69
+ export declare function Vector3LerpToRef<T extends IVector3Like>(start: DeepImmutable<IVector3Like>, end: DeepImmutable<IVector3Like>, amount: number, result: T): T;
70
+ export declare function Vector3NormalizeToRef<T extends IVector3Like>(vector: DeepImmutable<IVector3Like>, result: T): T;
71
+ /**
72
+ * Computes the signed distance between the specified point and plane.
73
+ * @param origin defines a point on the plane
74
+ * @param normal defines the plane normal (assumes normalized)
75
+ * @param point defines the point to compute the signed distance to
76
+ * @returns the signed distance
77
+ */
78
+ export declare function Vector3SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<IVector3Like>, normal: DeepImmutable<IVector3Like>, point: DeepImmutable<IVector3Like>): number;
71
79
  /**
72
80
  * Creates a string representation of the IVector3Like
73
81
  * @param vector defines the IVector3Like to stringify
@@ -124,6 +124,16 @@ export function Vector3NormalizeToRef(vector, result) {
124
124
  }
125
125
  return result;
126
126
  }
127
+ /**
128
+ * Computes the signed distance between the specified point and plane.
129
+ * @param origin defines a point on the plane
130
+ * @param normal defines the plane normal (assumes normalized)
131
+ * @param point defines the point to compute the signed distance to
132
+ * @returns the signed distance
133
+ */
134
+ export function Vector3SignedDistanceToPlaneFromPositionAndNormal(origin, normal, point) {
135
+ return (point.x - origin.x) * normal.x + (point.y - origin.y) * normal.y + (point.z - origin.z) * normal.z;
136
+ }
127
137
  /**
128
138
  * Creates a string representation of the IVector3Like
129
139
  * @param vector defines the IVector3Like to stringify
@@ -1 +1 @@
1
- {"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACzF,CA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AAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AAC9H,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACnK,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport type { IVector2Like, IVector3Like, IVector4Like } from \"./math.like\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Computes the squared length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the squared length of the vector\r\n */\r\nexport function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number {\r\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\r\n}\r\n\r\n/**\r\n * Computes the length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the length of the vector\r\n */\r\nexport function Vector3Length(vector: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3LengthSquared(vector));\r\n}\r\n\r\n/**\r\n * Computes the squared distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the squared distance\r\n */\r\nexport function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n const x = b.x - a.x;\r\n const y = b.y - a.y;\r\n const z = b.z - a.z;\r\n return x * x + y * y + z * z;\r\n}\r\n\r\n/**\r\n * Computes the distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the distance\r\n */\r\nexport function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3DistanceSquared(a, b));\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the result vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the result vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Scales the current vector values in place by a factor.\r\n * @param vector defines the vector to scale\r\n * @param scale defines the scale factor\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T {\r\n vector.x *= scale;\r\n vector.y *= scale;\r\n vector.z *= scale;\r\n return vector;\r\n}\r\n\r\nexport function Vector3SubtractToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>, result: T): T {\r\n result.x = a.x - b.x;\r\n result.y = a.y - b.y;\r\n result.z = a.z - b.z;\r\n return result;\r\n}\r\n\r\nexport function Vector3CopyToRef<T extends IVector3Like>(source: IVector3Like, result: T): T {\r\n result.x = source.x;\r\n result.y = source.y;\r\n result.z = source.z;\r\n return result;\r\n}\r\n\r\nexport function Vector3LerpToRef<T extends IVector3Like>(start: T, end: T, amount: number, result: T): T {\r\n result.x = start.x + (end.x - start.x) * amount;\r\n result.y = start.y + (end.y - start.y) * amount;\r\n result.z = start.z + (end.z - start.z) * amount;\r\n return result;\r\n}\r\n\r\nexport function Vector3NormalizeToRef<T extends IVector3Like>(vector: DeepImmutable<T>, result: T): T {\r\n const len = Vector3Length(vector);\r\n if (len === 0) {\r\n result.x = 0;\r\n result.y = 0;\r\n result.z = 0;\r\n } else {\r\n result.x = vector.x / len;\r\n result.y = vector.y / len;\r\n result.z = vector.z / len;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector3Like\r\n * @param vector defines the IVector3Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector3Like coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector4Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector4Like\r\n * @param vector defines the IVector4Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector4Like coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n"]}
1
+ {"version":3,"file":"math.vector.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.vector.functions.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAmC;IACpE,OAAO,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CA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,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AAC9H,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,CAA8B,EAAE,CAA8B;IACrF,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmC,EAAE,YAAoB;IACpF,OAAO,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;AACnK,CAAC","sourcesContent":["import type { DeepImmutable } from \"../types\";\r\nimport type { IVector2Like, IVector3Like, IVector4Like } from \"./math.like\";\r\n\r\n/**\r\n * Creates a string representation of the IVector2Like\r\n * @param vector defines the IVector2Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector2Like coordinates.\r\n */\r\nexport function Vector2ToFixed(vector: DeepImmutable<IVector2Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector3Like objects.\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector3Dot(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z;\r\n}\r\n\r\n/**\r\n * Computes the squared length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the squared length of the vector\r\n */\r\nexport function Vector3LengthSquared(vector: DeepImmutable<IVector3Like>): number {\r\n return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;\r\n}\r\n\r\n/**\r\n * Computes the length of the IVector3Like\r\n * @param vector the vector to measure\r\n * @returns the length of the vector\r\n */\r\nexport function Vector3Length(vector: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3LengthSquared(vector));\r\n}\r\n\r\n/**\r\n * Computes the squared distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the squared distance\r\n */\r\nexport function Vector3DistanceSquared(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n const x = b.x - a.x;\r\n const y = b.y - a.y;\r\n const z = b.z - a.z;\r\n return x * x + y * y + z * z;\r\n}\r\n\r\n/**\r\n * Computes the distance between the IVector3Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the distance\r\n */\r\nexport function Vector3Distance(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>): number {\r\n return Math.sqrt(Vector3DistanceSquared(a, b));\r\n}\r\n\r\n/**\r\n * Sets the given floats into the result.\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n * @param z defines the z coordinate\r\n * @param result defines the result vector\r\n * @returns the result vector\r\n */\r\nexport function Vector3FromFloatsToRef<T extends IVector3Like>(x: number, y: number, z: number, result: T): T {\r\n result.x = x;\r\n result.y = y;\r\n result.z = z;\r\n return result;\r\n}\r\n\r\n/**\r\n * Stores the scaled values of a vector into the result.\r\n * @param a defines the source vector\r\n * @param scale defines the scale factor\r\n * @param result defines the result vector\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, scale: number, result: T): T {\r\n result.x = a.x * scale;\r\n result.y = a.y * scale;\r\n result.z = a.z * scale;\r\n return result;\r\n}\r\n\r\n/**\r\n * Scales the current vector values in place by a factor.\r\n * @param vector defines the vector to scale\r\n * @param scale defines the scale factor\r\n * @returns the scaled vector\r\n */\r\nexport function Vector3ScaleInPlace<T extends IVector3Like>(vector: T, scale: number): T {\r\n vector.x *= scale;\r\n vector.y *= scale;\r\n vector.z *= scale;\r\n return vector;\r\n}\r\n\r\nexport function Vector3SubtractToRef<T extends IVector3Like>(a: DeepImmutable<IVector3Like>, b: DeepImmutable<IVector3Like>, result: T): T {\r\n result.x = a.x - b.x;\r\n result.y = a.y - b.y;\r\n result.z = a.z - b.z;\r\n return result;\r\n}\r\n\r\nexport function Vector3CopyToRef<T extends IVector3Like>(source: DeepImmutable<IVector3Like>, result: T): T {\r\n result.x = source.x;\r\n result.y = source.y;\r\n result.z = source.z;\r\n return result;\r\n}\r\n\r\nexport function Vector3LerpToRef<T extends IVector3Like>(start: DeepImmutable<IVector3Like>, end: DeepImmutable<IVector3Like>, amount: number, result: T): T {\r\n result.x = start.x + (end.x - start.x) * amount;\r\n result.y = start.y + (end.y - start.y) * amount;\r\n result.z = start.z + (end.z - start.z) * amount;\r\n return result;\r\n}\r\n\r\nexport function Vector3NormalizeToRef<T extends IVector3Like>(vector: DeepImmutable<IVector3Like>, result: T): T {\r\n const len = Vector3Length(vector);\r\n if (len === 0) {\r\n result.x = 0;\r\n result.y = 0;\r\n result.z = 0;\r\n } else {\r\n result.x = vector.x / len;\r\n result.y = vector.y / len;\r\n result.z = vector.z / len;\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Computes the signed distance between the specified point and plane.\r\n * @param origin defines a point on the plane\r\n * @param normal defines the plane normal (assumes normalized)\r\n * @param point defines the point to compute the signed distance to\r\n * @returns the signed distance\r\n */\r\nexport function Vector3SignedDistanceToPlaneFromPositionAndNormal(\r\n origin: DeepImmutable<IVector3Like>,\r\n normal: DeepImmutable<IVector3Like>,\r\n point: DeepImmutable<IVector3Like>\r\n): number {\r\n return (point.x - origin.x) * normal.x + (point.y - origin.y) * normal.y + (point.z - origin.z) * normal.z;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector3Like\r\n * @param vector defines the IVector3Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector3Like coordinates.\r\n */\r\nexport function Vector3ToFixed(vector: DeepImmutable<IVector3Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)}}`;\r\n}\r\n\r\n/**\r\n * Computes the dot product of two IVector4Like objects\r\n * @param a defines the first vector\r\n * @param b defines the second vector\r\n * @returns the dot product\r\n */\r\nexport function Vector4Dot(a: DeepImmutable<IVector4Like>, b: DeepImmutable<IVector4Like>): number {\r\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\r\n}\r\n\r\n/**\r\n * Creates a string representation of the IVector4Like\r\n * @param vector defines the IVector4Like to stringify\r\n * @param decimalCount defines the number of decimals to use\r\n * @returns a string with the IVector4Like coordinates.\r\n */\r\nexport function Vector4ToFixed(vector: DeepImmutable<IVector4Like>, decimalCount: number): string {\r\n return `{X: ${vector.x.toFixed(decimalCount)} Y: ${vector.y.toFixed(decimalCount)} Z: ${vector.z.toFixed(decimalCount)} W: ${vector.w.toFixed(decimalCount)}}`;\r\n}\r\n"]}
@@ -3,7 +3,7 @@ import type { IDracoAttributeData, IDracoEncodedMeshData, IDracoEncoderOptions }
3
3
  /**
4
4
  * @internal
5
5
  */
6
- export declare function EncodeMesh(module: unknown /** EncoderModule */, attributes: Array<IDracoAttributeData>, indices: Nullable<Uint16Array | Uint32Array>, options: IDracoEncoderOptions): Nullable<IDracoEncodedMeshData>;
6
+ export declare function EncodeMesh(module: unknown /** EncoderModule */, attributes: Array<IDracoAttributeData>, indices: Nullable<Uint16Array | Uint32Array>, options: IDracoEncoderOptions): IDracoEncodedMeshData;
7
7
  /**
8
8
  * The worker function that gets converted to a blob url to pass into a worker.
9
9
  * To be used if a developer wants to create their own worker instance and inject it instead of using the default worker.
@@ -11,7 +11,7 @@ export function EncodeMesh(module /** EncoderModule */, attributes, indices, opt
11
11
  // Double-check that at least a position attribute is provided
12
12
  const positionAttribute = attributes.find((a) => a.dracoName === "POSITION");
13
13
  if (!positionAttribute) {
14
- throw new Error("Position attribute is required for Draco encoding");
14
+ throw new Error("Draco: Missing position attribute for encoding.");
15
15
  }
16
16
  // If no indices are provided, assume mesh is unindexed. Let's generate them, since Draco meshes require them.
17
17
  // TODO: This may be the POINT_CLOUD case, but need to investigate. Should work for now-- just less efficient.
@@ -61,7 +61,7 @@ export function EncodeMesh(module /** EncoderModule */, attributes, indices, opt
61
61
  encodedNativeBuffer = new encoderModule.DracoInt8Array();
62
62
  const encodedLength = encoder.EncodeMeshToDracoBuffer(mesh, encodedNativeBuffer);
63
63
  if (encodedLength <= 0) {
64
- throw new Error("Draco encoding failed.");
64
+ throw new Error("Draco: Failed to encode.");
65
65
  }
66
66
  // Copy the native buffer data to worker heap
67
67
  const encodedData = new Int8Array(encodedLength);
@@ -106,12 +106,17 @@ export function EncoderWorkerFunction() {
106
106
  }
107
107
  case "encodeMesh": {
108
108
  if (!encoderPromise) {
109
- throw new Error("Draco encoder module is not available");
109
+ throw new Error("Draco: Encoder module is not available.");
110
110
  }
111
- // eslint-disable-next-line github/no-then
112
- encoderPromise.then((encoder) => {
111
+ encoderPromise
112
+ // eslint-disable-next-line github/no-then
113
+ .then((encoder) => {
113
114
  const result = EncodeMesh(encoder, message.attributes, message.indices, message.options);
114
- postMessage({ id: "encodeMeshDone", encodedMeshData: result }, result ? [result.data.buffer] : undefined);
115
+ postMessage({ id: "encodeMeshSuccess", encodedMeshData: result }, result ? [result.data.buffer] : undefined);
116
+ })
117
+ // eslint-disable-next-line github/no-then
118
+ .catch((error) => {
119
+ postMessage({ id: "encodeMeshError", errorMessage: error.message });
115
120
  });
116
121
  break;
117
122
  }
@@ -165,7 +170,7 @@ export function DecodeMesh(module /** DecoderModule */, data, attributeIDs, onIn
165
170
  break;
166
171
  }
167
172
  default: {
168
- throw new Error(`Invalid geometry type ${type}`);
173
+ throw new Error(`Draco: Cannot decode invalid geometry type ${type}`);
169
174
  }
170
175
  }
171
176
  const numPoints = geometry.num_points();
@@ -186,7 +191,7 @@ export function DecodeMesh(module /** DecoderModule */, data, attributeIDs, onIn
186
191
  };
187
192
  const info = dataTypeInfo[dataType];
188
193
  if (!info) {
189
- throw new Error(`Invalid data type ${dataType}`);
194
+ throw new Error(`Draco: Cannot decode invalid data type ${dataType}`);
190
195
  }
191
196
  const numValues = numPoints * numComponents;
192
197
  const byteLength = numValues * info.typedArrayConstructor.BYTES_PER_ELEMENT;
@@ -257,7 +262,7 @@ export function DecoderWorkerFunction() {
257
262
  }
258
263
  case "decodeMesh": {
259
264
  if (!decoderPromise) {
260
- throw new Error("Draco decoder module is not available");
265
+ throw new Error("Draco: Decoder module is not available");
261
266
  }
262
267
  // eslint-disable-next-line github/no-then
263
268
  decoderPromise.then((decoder) => {
@@ -1 +1 @@
1
- {"version":3,"file":"dracoCompressionWorker.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompressionWorker.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,MAAe,CAAC,oBAAoB,EACpC,UAAsC,EACtC,OAA4C,EAC5C,OAA6B;IAE7B,MAAM,aAAa,GAAG,MAAuB,CAAC;IAC9C,IAAI,OAAO,GAAsB,IAAI,CAAC;IACtC,IAAI,WAAW,GAA0B,IAAI,CAAC;IAC9C,IAAI,IAAI,GAAmB,IAAI,CAAC;IAChC,IAAI,mBAAmB,GAA6B,IAAI,CAAC;IACzD,MAAM,YAAY,GAA2B,EAAE,CAAC,CAAC,kCAAkC;IAEnF,8DAA8D;IAC9D,MAAM,iBAAiB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC;IAC7E,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC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S,EAAE,SAAS,CAAC,CAAC;gBACjD,OAAO,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE9C,2CAA2C;QAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,CAAC,WAAW,CAAC;gBACf,EAAE,EAAE,MAAM;gBACV,GAAG,EAAE,SAAS;aACjB,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACJ,iDAAiD;YACjD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,WAAW,CACd;gBACI,EAAE,EAAE,MAAM;gBACV,GAAG,EAAE,SAAS;gBACd,UAAU,EAAE,KAAK;aACpB,EACD,CAAC,KAAK,CAAC,CACV,CAAC;QACN,CAAC;QACD,0FAA0F;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Nullable, TypedArray, TypedArrayConstructor } from \"core/types\";\r\nimport type { EncoderMessage, IDracoAttributeData, IDracoEncodedMeshData, IDracoEncoderOptions } from \"./dracoEncoder.types\";\r\nimport type { DecoderMessage } from \"./dracoDecoder.types\";\r\nimport type { DecoderBuffer, Decoder, Mesh, PointCloud, Status, DecoderModule, EncoderModule, MeshBuilder, Encoder, DracoInt8Array } from \"draco3dgltf\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\nimport type { VertexDataTypedArray } from \"core/Buffers/bufferUtils\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoEncoderModule: (props: { wasmBinary?: ArrayBuffer }) => Promise<EncoderModule>;\r\n\r\ninterface IInitDoneMessage {\r\n id: \"initDone\";\r\n}\r\n\r\n// WorkerGlobalScope\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare function importScripts(...urls: string[]): void;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare function postMessage(message: IInitDoneMessage | DecoderMessage | EncoderMessage, transfer?: ArrayBufferLike[]): void;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function EncodeMesh(\r\n module: unknown /** EncoderModule */,\r\n attributes: Array<IDracoAttributeData>,\r\n indices: Nullable<Uint16Array | Uint32Array>,\r\n options: IDracoEncoderOptions\r\n): Nullable<IDracoEncodedMeshData> {\r\n const encoderModule = module as EncoderModule;\r\n let encoder: Nullable<Encoder> = null;\r\n let meshBuilder: Nullable<MeshBuilder> = null;\r\n let mesh: Nullable<Mesh> = null;\r\n let encodedNativeBuffer: Nullable<DracoInt8Array> = null;\r\n const attributeIDs: Record<string, number> = {}; // Babylon kind -> Draco unique id\r\n\r\n // Double-check that at least a position attribute is provided\r\n const positionAttribute = attributes.find((a) => a.dracoName === \"POSITION\");\r\n if (!positionAttribute) {\r\n throw new Error(\"Position attribute is required for Draco encoding\");\r\n }\r\n\r\n // If no indices are provided, assume mesh is unindexed. Let's generate them, since Draco meshes require them.\r\n // TODO: This may be the POINT_CLOUD case, but need to investigate. Should work for now-- just less efficient.\r\n if (!indices) {\r\n // Assume position attribute is the largest attribute.\r\n const positionVerticesCount = positionAttribute.data.length / positionAttribute.size;\r\n indices = new (positionVerticesCount > 65535 ? Uint32Array : Uint16Array)(positionVerticesCount);\r\n for (let i = 0; i < positionVerticesCount; i++) {\r\n indices[i] = i;\r\n }\r\n }\r\n\r\n try {\r\n encoder = new encoderModule.Encoder();\r\n meshBuilder = new encoderModule.MeshBuilder();\r\n mesh = new encoderModule.Mesh();\r\n\r\n // Add the faces\r\n meshBuilder.AddFacesToMesh(mesh, indices.length / 3, indices);\r\n\r\n const addAttributeMap = new Map<\r\n Function,\r\n (builder: MeshBuilder, mesh: Mesh, attr: any, count: number, size: number, data: Exclude<VertexDataTypedArray, Uint8ClampedArray>) => number\r\n >([\r\n [Float32Array, (mb, m, a, c, s, d) => mb.AddFloatAttribute(m, a, c, s, d)],\r\n [Uint32Array, (mb, m, a, c, s, d) => mb.AddUInt32Attribute(m, a, c, s, d)],\r\n [Uint16Array, (mb, m, a, c, s, d) => mb.AddUInt16Attribute(m, a, c, s, d)],\r\n [Uint8Array, (mb, m, a, c, s, d) => mb.AddUInt8Attribute(m, a, c, s, d)],\r\n [Int32Array, (mb, m, a, c, s, d) => mb.AddInt32Attribute(m, a, c, s, d)],\r\n [Int16Array, (mb, m, a, c, s, d) => mb.AddInt16Attribute(m, a, c, s, d)],\r\n [Int8Array, (mb, m, a, c, s, d) => mb.AddInt8Attribute(m, a, c, s, d)],\r\n ]);\r\n\r\n // Add the attributes\r\n for (const attribute of attributes) {\r\n if (attribute.data instanceof Uint8ClampedArray) {\r\n attribute.data = new Uint8Array(attribute.data); // Draco does not support Uint8ClampedArray\r\n }\r\n const addAttribute = addAttributeMap.get(attribute.data.constructor)!;\r\n const verticesCount = attribute.data.length / attribute.size;\r\n attributeIDs[attribute.kind] = addAttribute(meshBuilder, mesh, encoderModule[attribute.dracoName], verticesCount, attribute.size, attribute.data);\r\n if (options.quantizationBits && options.quantizationBits[attribute.dracoName]) {\r\n encoder.SetAttributeQuantization(encoderModule[attribute.dracoName], options.quantizationBits[attribute.dracoName]);\r\n }\r\n }\r\n\r\n // Set the options\r\n if (options.method) {\r\n encoder.SetEncodingMethod(encoderModule[options.method]);\r\n }\r\n if (options.encodeSpeed !== undefined && options.decodeSpeed !== undefined) {\r\n encoder.SetSpeedOptions(options.encodeSpeed, options.decodeSpeed);\r\n }\r\n\r\n // Encode to native buffer\r\n encodedNativeBuffer = new encoderModule.DracoInt8Array();\r\n const encodedLength = encoder.EncodeMeshToDracoBuffer(mesh, encodedNativeBuffer);\r\n if (encodedLength <= 0) {\r\n throw new Error(\"Draco encoding failed.\");\r\n }\r\n\r\n // Copy the native buffer data to worker heap\r\n const encodedData = new Int8Array(encodedLength);\r\n for (let i = 0; i < encodedLength; i++) {\r\n encodedData[i] = encodedNativeBuffer.GetValue(i);\r\n }\r\n\r\n return { data: encodedData, attributeIds: attributeIDs };\r\n } finally {\r\n if (mesh) {\r\n encoderModule.destroy(mesh);\r\n }\r\n if (meshBuilder) {\r\n encoderModule.destroy(meshBuilder);\r\n }\r\n if (encoder) {\r\n encoderModule.destroy(encoder);\r\n }\r\n if (encodedNativeBuffer) {\r\n encoderModule.destroy(encodedNativeBuffer);\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 EncoderWorkerFunction(): void {\r\n let encoderPromise: PromiseLike<EncoderModule> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (message.url) {\r\n importScripts(message.url);\r\n }\r\n const initEncoderObject = message.wasmBinary ? { wasmBinary: message.wasmBinary } : {};\r\n encoderPromise = DracoEncoderModule(initEncoderObject);\r\n postMessage({ id: \"initDone\" });\r\n break;\r\n }\r\n case \"encodeMesh\": {\r\n if (!encoderPromise) {\r\n throw new Error(\"Draco encoder module is not available\");\r\n }\r\n // eslint-disable-next-line github/no-then\r\n encoderPromise.then((encoder) => {\r\n const result = EncodeMesh(encoder, message.attributes, message.indices, message.options);\r\n postMessage({ id: \"encodeMeshDone\", encodedMeshData: result }, result ? [result.data.buffer] : undefined);\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function DecodeMesh(\r\n module: unknown /** DecoderModule */,\r\n data: Int8Array,\r\n attributeIDs: Record<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 const decoderModule = module as DecoderModule;\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();\r\n\r\n buffer = new decoderModule.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;\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;\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 /** Attribute */) => {\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: Record<number, { typedArrayConstructor: TypedArrayConstructor; heap: TypedArray }> = {\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 (attributeIDs) {\r\n for (const kind in attributeIDs) {\r\n const id = attributeIDs[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: Record<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 DecoderWorkerFunction(): void {\r\n let decoderPromise: PromiseLike<DecoderModule> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (message.url) {\r\n importScripts(message.url);\r\n }\r\n const initDecoderObject = message.wasmBinary ? { wasmBinary: message.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 // eslint-disable-next-line github/no-then\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// For backwards compatibility\r\nexport { DecoderWorkerFunction as workerFunction };\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 wasmBinary 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\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport async function initializeWebWorker(worker: Worker, wasmBinary?: ArrayBuffer, moduleUrl?: string): Promise<Worker> {\r\n return await 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 // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(error);\r\n };\r\n\r\n const onMessage = (event: MessageEvent<IInitDoneMessage>) => {\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 // Load with either JS-only or WASM version\r\n if (!wasmBinary) {\r\n worker.postMessage({\r\n id: \"init\",\r\n url: moduleUrl,\r\n });\r\n } else {\r\n // clone the array buffer to make it transferable\r\n const clone = wasmBinary.slice(0);\r\n worker.postMessage(\r\n {\r\n id: \"init\",\r\n url: moduleUrl,\r\n wasmBinary: clone,\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
+ {"version":3,"file":"dracoCompressionWorker.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompressionWorker.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,MAAe,CAAC,oBAAoB,EACpC,UAAsC,EACtC,OAA4C,EAC5C,OAA6B;IAE7B,MAAM,aAAa,GAAG,MAAuB,CAAC;IAC9C,IAAI,OAAO,GAAsB,IAAI,CAAC;IACtC,IAAI,WAAW,GAA0B,IAAI,CAAC;IAC9C,IAAI,IAAI,GAAmB,IAAI,CAAC;IAChC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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,2EAA2E;YAC3E,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,CAAC,KAAqC,EAAE,EAAE;YACxD,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC/B,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;YACpB,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAE9C,2CAA2C;QAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,CAAC,WAAW,CAAC;gBACf,EAAE,EAAE,MAAM;gBACV,GAAG,EAAE,SAAS;aACjB,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACJ,iDAAiD;YACjD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,WAAW,CACd;gBACI,EAAE,EAAE,MAAM;gBACV,GAAG,EAAE,SAAS;gBACd,UAAU,EAAE,KAAK;aACpB,EACD,CAAC,KAAK,CAAC,CACV,CAAC;QACN,CAAC;QACD,0FAA0F;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Nullable, TypedArray, TypedArrayConstructor } from \"core/types\";\r\nimport type { EncoderMessage, IDracoAttributeData, IDracoEncodedMeshData, IDracoEncoderOptions } from \"./dracoEncoder.types\";\r\nimport type { DecoderMessage } from \"./dracoDecoder.types\";\r\nimport type { DecoderBuffer, Decoder, Mesh, PointCloud, Status, DecoderModule, EncoderModule, MeshBuilder, Encoder, DracoInt8Array } from \"draco3dgltf\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\nimport type { VertexDataTypedArray } from \"core/Buffers/bufferUtils\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoEncoderModule: (props: { wasmBinary?: ArrayBuffer }) => Promise<EncoderModule>;\r\n\r\ninterface IInitDoneMessage {\r\n id: \"initDone\";\r\n}\r\n\r\n// WorkerGlobalScope\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare function importScripts(...urls: string[]): void;\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare function postMessage(message: IInitDoneMessage | DecoderMessage | EncoderMessage, transfer?: ArrayBufferLike[]): void;\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function EncodeMesh(\r\n module: unknown /** EncoderModule */,\r\n attributes: Array<IDracoAttributeData>,\r\n indices: Nullable<Uint16Array | Uint32Array>,\r\n options: IDracoEncoderOptions\r\n): IDracoEncodedMeshData {\r\n const encoderModule = module as EncoderModule;\r\n let encoder: Nullable<Encoder> = null;\r\n let meshBuilder: Nullable<MeshBuilder> = null;\r\n let mesh: Nullable<Mesh> = null;\r\n let encodedNativeBuffer: Nullable<DracoInt8Array> = null;\r\n const attributeIDs: Record<string, number> = {}; // Babylon kind -> Draco unique id\r\n\r\n // Double-check that at least a position attribute is provided\r\n const positionAttribute = attributes.find((a) => a.dracoName === \"POSITION\");\r\n if (!positionAttribute) {\r\n throw new Error(\"Draco: Missing position attribute for encoding.\");\r\n }\r\n\r\n // If no indices are provided, assume mesh is unindexed. Let's generate them, since Draco meshes require them.\r\n // TODO: This may be the POINT_CLOUD case, but need to investigate. Should work for now-- just less efficient.\r\n if (!indices) {\r\n // Assume position attribute is the largest attribute.\r\n const positionVerticesCount = positionAttribute.data.length / positionAttribute.size;\r\n indices = new (positionVerticesCount > 65535 ? Uint32Array : Uint16Array)(positionVerticesCount);\r\n for (let i = 0; i < positionVerticesCount; i++) {\r\n indices[i] = i;\r\n }\r\n }\r\n\r\n try {\r\n encoder = new encoderModule.Encoder();\r\n meshBuilder = new encoderModule.MeshBuilder();\r\n mesh = new encoderModule.Mesh();\r\n\r\n // Add the faces\r\n meshBuilder.AddFacesToMesh(mesh, indices.length / 3, indices);\r\n\r\n const addAttributeMap = new Map<\r\n Function,\r\n (builder: MeshBuilder, mesh: Mesh, attr: any, count: number, size: number, data: Exclude<VertexDataTypedArray, Uint8ClampedArray>) => number\r\n >([\r\n [Float32Array, (mb, m, a, c, s, d) => mb.AddFloatAttribute(m, a, c, s, d)],\r\n [Uint32Array, (mb, m, a, c, s, d) => mb.AddUInt32Attribute(m, a, c, s, d)],\r\n [Uint16Array, (mb, m, a, c, s, d) => mb.AddUInt16Attribute(m, a, c, s, d)],\r\n [Uint8Array, (mb, m, a, c, s, d) => mb.AddUInt8Attribute(m, a, c, s, d)],\r\n [Int32Array, (mb, m, a, c, s, d) => mb.AddInt32Attribute(m, a, c, s, d)],\r\n [Int16Array, (mb, m, a, c, s, d) => mb.AddInt16Attribute(m, a, c, s, d)],\r\n [Int8Array, (mb, m, a, c, s, d) => mb.AddInt8Attribute(m, a, c, s, d)],\r\n ]);\r\n\r\n // Add the attributes\r\n for (const attribute of attributes) {\r\n if (attribute.data instanceof Uint8ClampedArray) {\r\n attribute.data = new Uint8Array(attribute.data); // Draco does not support Uint8ClampedArray\r\n }\r\n const addAttribute = addAttributeMap.get(attribute.data.constructor)!;\r\n const verticesCount = attribute.data.length / attribute.size;\r\n attributeIDs[attribute.kind] = addAttribute(meshBuilder, mesh, encoderModule[attribute.dracoName], verticesCount, attribute.size, attribute.data);\r\n if (options.quantizationBits && options.quantizationBits[attribute.dracoName]) {\r\n encoder.SetAttributeQuantization(encoderModule[attribute.dracoName], options.quantizationBits[attribute.dracoName]);\r\n }\r\n }\r\n\r\n // Set the options\r\n if (options.method) {\r\n encoder.SetEncodingMethod(encoderModule[options.method]);\r\n }\r\n if (options.encodeSpeed !== undefined && options.decodeSpeed !== undefined) {\r\n encoder.SetSpeedOptions(options.encodeSpeed, options.decodeSpeed);\r\n }\r\n\r\n // Encode to native buffer\r\n encodedNativeBuffer = new encoderModule.DracoInt8Array();\r\n const encodedLength = encoder.EncodeMeshToDracoBuffer(mesh, encodedNativeBuffer);\r\n if (encodedLength <= 0) {\r\n throw new Error(\"Draco: Failed to encode.\");\r\n }\r\n\r\n // Copy the native buffer data to worker heap\r\n const encodedData = new Int8Array(encodedLength);\r\n for (let i = 0; i < encodedLength; i++) {\r\n encodedData[i] = encodedNativeBuffer.GetValue(i);\r\n }\r\n\r\n return { data: encodedData, attributeIds: attributeIDs };\r\n } finally {\r\n if (mesh) {\r\n encoderModule.destroy(mesh);\r\n }\r\n if (meshBuilder) {\r\n encoderModule.destroy(meshBuilder);\r\n }\r\n if (encoder) {\r\n encoderModule.destroy(encoder);\r\n }\r\n if (encodedNativeBuffer) {\r\n encoderModule.destroy(encodedNativeBuffer);\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 EncoderWorkerFunction(): void {\r\n let encoderPromise: Promise<EncoderModule> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (message.url) {\r\n importScripts(message.url);\r\n }\r\n const initEncoderObject = message.wasmBinary ? { wasmBinary: message.wasmBinary } : {};\r\n encoderPromise = DracoEncoderModule(initEncoderObject);\r\n postMessage({ id: \"initDone\" });\r\n break;\r\n }\r\n case \"encodeMesh\": {\r\n if (!encoderPromise) {\r\n throw new Error(\"Draco: Encoder module is not available.\");\r\n }\r\n encoderPromise\r\n // eslint-disable-next-line github/no-then\r\n .then((encoder) => {\r\n const result = EncodeMesh(encoder, message.attributes, message.indices, message.options);\r\n postMessage({ id: \"encodeMeshSuccess\", encodedMeshData: result }, result ? [result.data.buffer] : undefined);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((error) => {\r\n postMessage({ id: \"encodeMeshError\", errorMessage: error.message });\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function DecodeMesh(\r\n module: unknown /** DecoderModule */,\r\n data: Int8Array,\r\n attributeIDs: Record<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 const decoderModule = module as DecoderModule;\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();\r\n\r\n buffer = new decoderModule.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;\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;\r\n break;\r\n }\r\n default: {\r\n throw new Error(`Draco: Cannot decode 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 /** Attribute */) => {\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: Record<number, { typedArrayConstructor: TypedArrayConstructor; heap: TypedArray }> = {\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(`Draco: Cannot decode 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 (attributeIDs) {\r\n for (const kind in attributeIDs) {\r\n const id = attributeIDs[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: Record<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 DecoderWorkerFunction(): void {\r\n let decoderPromise: PromiseLike<DecoderModule> | undefined;\r\n\r\n onmessage = (event) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"init\": {\r\n // if URL is provided then load the script. Otherwise expect the script to be loaded already\r\n if (message.url) {\r\n importScripts(message.url);\r\n }\r\n const initDecoderObject = message.wasmBinary ? { wasmBinary: message.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 // eslint-disable-next-line github/no-then\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// For backwards compatibility\r\nexport { DecoderWorkerFunction as workerFunction };\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 wasmBinary 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\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport async function initializeWebWorker(worker: Worker, wasmBinary?: ArrayBuffer, moduleUrl?: string): Promise<Worker> {\r\n return await 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 // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(error);\r\n };\r\n\r\n const onMessage = (event: MessageEvent<IInitDoneMessage>) => {\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 // Load with either JS-only or WASM version\r\n if (!wasmBinary) {\r\n worker.postMessage({\r\n id: \"init\",\r\n url: moduleUrl,\r\n });\r\n } else {\r\n // clone the array buffer to make it transferable\r\n const clone = wasmBinary.slice(0);\r\n worker.postMessage(\r\n {\r\n id: \"init\",\r\n url: moduleUrl,\r\n wasmBinary: clone,\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"]}
@@ -166,7 +166,7 @@ export class DracoDecoder extends DracoCodec {
166
166
  return { indices: resultIndices, attributes: resultAttributes, totalVertices: numPoints };
167
167
  });
168
168
  }
169
- throw new Error("Draco decoder module is not available");
169
+ throw new Error("Draco: Decoder module is not available");
170
170
  }
171
171
  /**
172
172
  * Decode Draco compressed mesh data to Babylon geometry.