@babylonjs/core 6.45.0 → 6.46.0

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 (235) hide show
  1. package/Animations/animation.js +1 -1
  2. package/Animations/animation.js.map +1 -1
  3. package/BakedVertexAnimation/bakedVertexAnimationManager.js +2 -1
  4. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  5. package/Bones/skeleton.js +2 -2
  6. package/Bones/skeleton.js.map +1 -1
  7. package/Cameras/camera.d.ts +3 -3
  8. package/Cameras/camera.js +2 -1
  9. package/Cameras/camera.js.map +1 -1
  10. package/Cameras/cameraInputsManager.js +1 -1
  11. package/Cameras/cameraInputsManager.js.map +1 -1
  12. package/Cameras/targetCamera.js +4 -0
  13. package/Cameras/targetCamera.js.map +1 -1
  14. package/Compute/computeShader.d.ts +4 -2
  15. package/Compute/computeShader.js +7 -3
  16. package/Compute/computeShader.js.map +1 -1
  17. package/Debug/directionalLightFrustumViewer.js +6 -6
  18. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  19. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  20. package/Engines/Extensions/engine.computeShader.js +1 -0
  21. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  22. package/Engines/Extensions/engine.rawTexture.js +3 -3
  23. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  24. package/Engines/Native/nativePipelineContext.js +1 -1
  25. package/Engines/Native/nativePipelineContext.js.map +1 -1
  26. package/Engines/WebGL/webGLPipelineContext.js +1 -1
  27. package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
  28. package/Engines/WebGPU/webgpuComputeContext.js +7 -3
  29. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  30. package/Engines/engine.d.ts +1 -1
  31. package/Engines/thinEngine.js +2 -2
  32. package/Engines/thinEngine.js.map +1 -1
  33. package/Engines/webgpuEngine.js +2 -15
  34. package/Engines/webgpuEngine.js.map +1 -1
  35. package/Layers/glowLayer.js +2 -1
  36. package/Layers/glowLayer.js.map +1 -1
  37. package/Layers/highlightLayer.js +2 -1
  38. package/Layers/highlightLayer.js.map +1 -1
  39. package/Lights/light.js +2 -1
  40. package/Lights/light.js.map +1 -1
  41. package/Loading/Plugins/babylonFileLoader.js +9 -0
  42. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  43. package/Loading/sceneLoader.d.ts +6 -1
  44. package/Loading/sceneLoader.js +6 -5
  45. package/Loading/sceneLoader.js.map +1 -1
  46. package/Materials/Background/backgroundMaterial.js +2 -1
  47. package/Materials/Background/backgroundMaterial.js.map +1 -1
  48. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
  49. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  50. package/Materials/Node/nodeMaterial.d.ts +2 -1
  51. package/Materials/Node/nodeMaterial.js +5 -1
  52. package/Materials/Node/nodeMaterial.js.map +1 -1
  53. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -1
  54. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  55. package/Materials/PBR/pbrMaterial.js +2 -1
  56. package/Materials/PBR/pbrMaterial.js.map +1 -1
  57. package/Materials/PBR/pbrMetallicRoughnessMaterial.js +2 -1
  58. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  59. package/Materials/PBR/pbrSpecularGlossinessMaterial.js +2 -1
  60. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  61. package/Materials/Textures/baseTexture.js +2 -1
  62. package/Materials/Textures/baseTexture.js.map +1 -1
  63. package/Materials/Textures/cubeTexture.js +2 -1
  64. package/Materials/Textures/cubeTexture.js.map +1 -1
  65. package/Materials/Textures/rawCubeTexture.js +1 -1
  66. package/Materials/Textures/rawCubeTexture.js.map +1 -1
  67. package/Materials/Textures/texture.js +2 -1
  68. package/Materials/Textures/texture.js.map +1 -1
  69. package/Materials/colorCurves.d.ts +1 -1
  70. package/Materials/colorCurves.functions.d.ts +5 -0
  71. package/Materials/colorCurves.functions.js +8 -0
  72. package/Materials/colorCurves.functions.js.map +1 -0
  73. package/Materials/colorCurves.js +8 -8
  74. package/Materials/colorCurves.js.map +1 -1
  75. package/Materials/fresnelParameters.js +1 -1
  76. package/Materials/fresnelParameters.js.map +1 -1
  77. package/Materials/imageProcessingConfiguration.d.ts +3 -48
  78. package/Materials/imageProcessingConfiguration.defines.d.ts +46 -0
  79. package/Materials/imageProcessingConfiguration.defines.js +27 -0
  80. package/Materials/imageProcessingConfiguration.defines.js.map +1 -0
  81. package/Materials/imageProcessingConfiguration.functions.d.ts +13 -0
  82. package/Materials/imageProcessingConfiguration.functions.js +41 -0
  83. package/Materials/imageProcessingConfiguration.functions.js.map +1 -0
  84. package/Materials/imageProcessingConfiguration.js +18 -69
  85. package/Materials/imageProcessingConfiguration.js.map +1 -1
  86. package/Materials/material.js +2 -1
  87. package/Materials/material.js.map +1 -1
  88. package/Materials/materialHelper.d.ts +33 -33
  89. package/Materials/materialHelper.js +244 -286
  90. package/Materials/materialHelper.js.map +1 -1
  91. package/Materials/materialPluginBase.js +2 -1
  92. package/Materials/materialPluginBase.js.map +1 -1
  93. package/Materials/materialStencilState.js +2 -1
  94. package/Materials/materialStencilState.js.map +1 -1
  95. package/Materials/shaderMaterial.js +1 -1
  96. package/Materials/shaderMaterial.js.map +1 -1
  97. package/Materials/standardMaterial.d.ts +1 -1
  98. package/Materials/standardMaterial.js +2 -1
  99. package/Materials/standardMaterial.js.map +1 -1
  100. package/Materials/uniformBuffer.js +2 -2
  101. package/Materials/uniformBuffer.js.map +1 -1
  102. package/Maths/math.color.d.ts +392 -66
  103. package/Maths/math.color.js +541 -65
  104. package/Maths/math.color.js.map +1 -1
  105. package/Maths/math.like.d.ts +17 -28
  106. package/Maths/math.like.js.map +1 -1
  107. package/Maths/math.plane.d.ts +2 -1
  108. package/Maths/math.plane.js.map +1 -1
  109. package/Maths/math.polar.d.ts +1 -1
  110. package/Maths/math.polar.js.map +1 -1
  111. package/Maths/math.scalar.d.ts +6 -6
  112. package/Maths/math.scalar.functions.d.ts +51 -0
  113. package/Maths/math.scalar.functions.js +80 -0
  114. package/Maths/math.scalar.functions.js.map +1 -0
  115. package/Maths/math.scalar.js +48 -73
  116. package/Maths/math.scalar.js.map +1 -1
  117. package/Maths/math.vector.d.ts +571 -72
  118. package/Maths/math.vector.js +917 -119
  119. package/Maths/math.vector.js.map +1 -1
  120. package/Maths/math.viewport.d.ts +2 -1
  121. package/Maths/math.viewport.js.map +1 -1
  122. package/Maths/tensor.d.ts +411 -0
  123. package/Maths/tensor.js +3 -0
  124. package/Maths/tensor.js.map +1 -0
  125. package/Meshes/Node/Blocks/Set/setColorsBlock.js +20 -4
  126. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  127. package/Meshes/Node/nodeGeometry.js +2 -1
  128. package/Meshes/Node/nodeGeometry.js.map +1 -1
  129. package/Meshes/mesh.js +2 -2
  130. package/Meshes/mesh.js.map +1 -1
  131. package/Meshes/mesh.vertexData.d.ts +4 -0
  132. package/Meshes/mesh.vertexData.js +10 -0
  133. package/Meshes/mesh.vertexData.js.map +1 -1
  134. package/Meshes/transformNode.js +2 -1
  135. package/Meshes/transformNode.js.map +1 -1
  136. package/Misc/arrayTools.d.ts +2 -19
  137. package/Misc/arrayTools.js.map +1 -1
  138. package/Misc/decorators.d.ts +0 -80
  139. package/Misc/decorators.functions.d.ts +7 -0
  140. package/Misc/decorators.functions.js +52 -0
  141. package/Misc/decorators.functions.js.map +1 -0
  142. package/Misc/decorators.js +2 -318
  143. package/Misc/decorators.js.map +1 -1
  144. package/Misc/decorators.serialization.d.ts +81 -0
  145. package/Misc/decorators.serialization.js +269 -0
  146. package/Misc/decorators.serialization.js.map +1 -0
  147. package/Misc/index.d.ts +1 -0
  148. package/Misc/index.js +1 -0
  149. package/Misc/index.js.map +1 -1
  150. package/Misc/sceneRecorder.js +1 -1
  151. package/Misc/sceneRecorder.js.map +1 -1
  152. package/Misc/sceneSerializer.js +8 -1
  153. package/Misc/sceneSerializer.js.map +1 -1
  154. package/Misc/tools.functions.d.ts +14 -0
  155. package/Misc/tools.functions.js +23 -0
  156. package/Misc/tools.functions.js.map +1 -0
  157. package/Misc/tools.js +5 -6
  158. package/Misc/tools.js.map +1 -1
  159. package/Morph/morphTarget.js +2 -1
  160. package/Morph/morphTarget.js.map +1 -1
  161. package/Particles/EmitterTypes/boxParticleEmitter.js +8 -8
  162. package/Particles/EmitterTypes/boxParticleEmitter.js.map +1 -1
  163. package/Particles/baseParticleSystem.d.ts +8 -11
  164. package/Particles/baseParticleSystem.js +9 -40
  165. package/Particles/baseParticleSystem.js.map +1 -1
  166. package/Particles/gpuParticleSystem.d.ts +71 -1
  167. package/Particles/gpuParticleSystem.js +102 -1
  168. package/Particles/gpuParticleSystem.js.map +1 -1
  169. package/Particles/particle.d.ts +3 -3
  170. package/Particles/particle.js +3 -3
  171. package/Particles/particle.js.map +1 -1
  172. package/Particles/particleSystem.d.ts +81 -455
  173. package/Particles/particleSystem.functions.d.ts +61 -0
  174. package/Particles/particleSystem.functions.js +79 -0
  175. package/Particles/particleSystem.functions.js.map +1 -0
  176. package/Particles/particleSystem.js +390 -1984
  177. package/Particles/particleSystem.js.map +1 -1
  178. package/Particles/thinParticleSystem.d.ts +485 -0
  179. package/Particles/thinParticleSystem.js +1768 -0
  180. package/Particles/thinParticleSystem.js.map +1 -0
  181. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +2 -1
  182. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  183. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -1
  184. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  185. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +2 -1
  186. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  187. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +2 -1
  188. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  189. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +2 -1
  190. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
  191. package/PostProcesses/blackAndWhitePostProcess.js +2 -1
  192. package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
  193. package/PostProcesses/blurPostProcess.js +2 -1
  194. package/PostProcesses/blurPostProcess.js.map +1 -1
  195. package/PostProcesses/chromaticAberrationPostProcess.js +2 -1
  196. package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
  197. package/PostProcesses/colorCorrectionPostProcess.js +2 -1
  198. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  199. package/PostProcesses/convolutionPostProcess.js +2 -1
  200. package/PostProcesses/convolutionPostProcess.js.map +1 -1
  201. package/PostProcesses/displayPassPostProcess.js +1 -1
  202. package/PostProcesses/displayPassPostProcess.js.map +1 -1
  203. package/PostProcesses/filterPostProcess.js +2 -1
  204. package/PostProcesses/filterPostProcess.js.map +1 -1
  205. package/PostProcesses/fxaaPostProcess.js +1 -1
  206. package/PostProcesses/fxaaPostProcess.js.map +1 -1
  207. package/PostProcesses/grainPostProcess.js +2 -1
  208. package/PostProcesses/grainPostProcess.js.map +1 -1
  209. package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
  210. package/PostProcesses/motionBlurPostProcess.js +2 -1
  211. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  212. package/PostProcesses/passPostProcess.js +1 -1
  213. package/PostProcesses/passPostProcess.js.map +1 -1
  214. package/PostProcesses/postProcess.js +2 -1
  215. package/PostProcesses/postProcess.js.map +1 -1
  216. package/PostProcesses/refractionPostProcess.js +2 -1
  217. package/PostProcesses/refractionPostProcess.js.map +1 -1
  218. package/PostProcesses/screenSpaceCurvaturePostProcess.js +2 -1
  219. package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
  220. package/PostProcesses/screenSpaceReflectionPostProcess.js +2 -1
  221. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  222. package/PostProcesses/sharpenPostProcess.js +2 -1
  223. package/PostProcesses/sharpenPostProcess.js.map +1 -1
  224. package/Probes/reflectionProbe.js +2 -1
  225. package/Probes/reflectionProbe.js.map +1 -1
  226. package/Sprites/spriteManager.d.ts +4 -0
  227. package/Sprites/spriteManager.js.map +1 -1
  228. package/XR/features/WebXRControllerTeleportation.d.ts +9 -0
  229. package/XR/features/WebXRControllerTeleportation.js +75 -31
  230. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  231. package/node.js +2 -1
  232. package/node.js.map +1 -1
  233. package/package.json +1 -1
  234. package/types.d.ts +105 -0
  235. package/types.js.map +1 -1
@@ -1,7 +1,8 @@
1
+ import type { IViewportLike } from "./math.like";
1
2
  /**
2
3
  * Class used to represent a viewport on screen
3
4
  */
4
- export declare class Viewport {
5
+ export declare class Viewport implements IViewportLike {
5
6
  /** viewport left coordinate */
6
7
  x: number;
7
8
  /** viewport top coordinate */
@@ -1 +1 @@
1
- {"version":3,"file":"math.viewport.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.viewport.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACjB;;;;;;OAMG;IACH;IACI,+BAA+B;IACxB,CAAS;IAChB,8BAA8B;IACvB,CAAS;IAChB,oBAAoB;IACb,KAAa;IACpB,sBAAsB;IACf,MAAc;QANd,MAAC,GAAD,CAAC,CAAQ;QAET,MAAC,GAAD,CAAC,CAAQ;QAET,UAAK,GAAL,KAAK,CAAQ;QAEb,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;IAEJ;;;;;OAKG;IACI,QAAQ,CAAC,WAAmB,EAAE,YAAoB;QACrD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,GAAG,YAAY,EAAE,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;IAC3H,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAAC,WAAmB,EAAE,YAAoB,EAAE,GAAa;QACzE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,WAAW,CAAC;QAC7B,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC;QAC9B,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;QACrC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;QACxC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ","sourcesContent":["/**\r\n * Class used to represent a viewport on screen\r\n */\r\nexport class Viewport {\r\n /**\r\n * Creates a Viewport object located at (x, y) and sized (width, height)\r\n * @param x defines viewport left coordinate\r\n * @param y defines viewport top coordinate\r\n * @param width defines the viewport width\r\n * @param height defines the viewport height\r\n */\r\n constructor(\r\n /** viewport left coordinate */\r\n public x: number,\r\n /** viewport top coordinate */\r\n public y: number,\r\n /**viewport width */\r\n public width: number,\r\n /** viewport height */\r\n public height: number\r\n ) {}\r\n\r\n /**\r\n * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)\r\n * @param renderWidth defines the rendering width\r\n * @param renderHeight defines the rendering height\r\n * @returns a new Viewport\r\n */\r\n public toGlobal(renderWidth: number, renderHeight: number): Viewport {\r\n return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);\r\n }\r\n\r\n /**\r\n * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)\r\n * @param renderWidth defines the rendering width\r\n * @param renderHeight defines the rendering height\r\n * @param ref defines the target viewport\r\n * @returns the current viewport\r\n */\r\n public toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport {\r\n ref.x = this.x * renderWidth;\r\n ref.y = this.y * renderHeight;\r\n ref.width = this.width * renderWidth;\r\n ref.height = this.height * renderHeight;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns a new Viewport copied from the current one\r\n * @returns a new Viewport\r\n */\r\n public clone(): Viewport {\r\n return new Viewport(this.x, this.y, this.width, this.height);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"math.viewport.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/math.viewport.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,QAAQ;IACjB;;;;;;OAMG;IACH;IACI,+BAA+B;IACxB,CAAS;IAChB,8BAA8B;IACvB,CAAS;IAChB,oBAAoB;IACb,KAAa;IACpB,sBAAsB;IACf,MAAc;QANd,MAAC,GAAD,CAAC,CAAQ;QAET,MAAC,GAAD,CAAC,CAAQ;QAET,UAAK,GAAL,KAAK,CAAQ;QAEb,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;IAEJ;;;;;OAKG;IACI,QAAQ,CAAC,WAAmB,EAAE,YAAoB;QACrD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,GAAG,YAAY,EAAE,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;IAC3H,CAAC;IAED;;;;;;OAMG;IACI,aAAa,CAAC,WAAmB,EAAE,YAAoB,EAAE,GAAa;QACzE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,WAAW,CAAC;QAC7B,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC;QAC9B,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;QACrC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;QACxC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACJ","sourcesContent":["import type { IViewportLike } from \"./math.like\";\r\n\r\n/**\r\n * Class used to represent a viewport on screen\r\n */\r\nexport class Viewport implements IViewportLike {\r\n /**\r\n * Creates a Viewport object located at (x, y) and sized (width, height)\r\n * @param x defines viewport left coordinate\r\n * @param y defines viewport top coordinate\r\n * @param width defines the viewport width\r\n * @param height defines the viewport height\r\n */\r\n constructor(\r\n /** viewport left coordinate */\r\n public x: number,\r\n /** viewport top coordinate */\r\n public y: number,\r\n /**viewport width */\r\n public width: number,\r\n /** viewport height */\r\n public height: number\r\n ) {}\r\n\r\n /**\r\n * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)\r\n * @param renderWidth defines the rendering width\r\n * @param renderHeight defines the rendering height\r\n * @returns a new Viewport\r\n */\r\n public toGlobal(renderWidth: number, renderHeight: number): Viewport {\r\n return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);\r\n }\r\n\r\n /**\r\n * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)\r\n * @param renderWidth defines the rendering width\r\n * @param renderHeight defines the rendering height\r\n * @param ref defines the target viewport\r\n * @returns the current viewport\r\n */\r\n public toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport {\r\n ref.x = this.x * renderWidth;\r\n ref.y = this.y * renderHeight;\r\n ref.width = this.width * renderWidth;\r\n ref.height = this.height * renderHeight;\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns a new Viewport copied from the current one\r\n * @returns a new Viewport\r\n */\r\n public clone(): Viewport {\r\n return new Viewport(this.x, this.y, this.width, this.height);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,411 @@
1
+ import type { DeepImmutable, Flatten, FloatArray, Length } from "../types";
2
+ /**
3
+ * Computes the tensor dimension of a multi-dimensional array
4
+ */
5
+ export type Dimension<T> = T extends Array<infer U> ? [Length<T>, ...Dimension<U>] : T extends readonly [infer U, ...infer R] ? [Length<T>, ...Dimension<U>] : [];
6
+ /**
7
+ * Extracts the value type of a Tensor
8
+ */
9
+ export type TensorValue<T> = T extends Tensor<infer V> ? V : never;
10
+ /**
11
+ * Describes a mathematical tensor.
12
+ * @see https://wikipedia.org/wiki/Tensor
13
+ */
14
+ export interface Tensor<V extends unknown[] = unknown[]> {
15
+ /**
16
+ * An array of the size of each dimension.
17
+ * For example, [3] for a Vector3 and [4,4] for a Matrix
18
+ * @remarks
19
+ * This is to allow implementations with using a getter
20
+ */
21
+ readonly dimension: Readonly<Dimension<V>>;
22
+ /**
23
+ * The rank of the tensor. This is the same as the length of the tensor's dimension array.
24
+ * @remarks
25
+ * This is to allow implementations with using a getter
26
+ */
27
+ readonly rank: number;
28
+ /**
29
+ * Gets class name
30
+ * @returns the class name
31
+ */
32
+ getClassName(): string;
33
+ /**
34
+ * Gets current instance hash code
35
+ * @returns the instance hash code as a number
36
+ */
37
+ getHashCode(): number;
38
+ /**
39
+ * Sets the instance coordinates in the given array from the given index.
40
+ * @param array defines the source array
41
+ * @param index defines the offset in source array
42
+ * @returns the current instance
43
+ */
44
+ toArray(array: FloatArray, index?: number): this;
45
+ /**
46
+ * Update the current instance from an array
47
+ * @param array defines the destination array
48
+ * @param index defines the offset in the destination array
49
+ * @returns the current instance
50
+ */
51
+ fromArray(array: FloatArray, index?: number): this;
52
+ /**
53
+ * Copy the current instance to an array
54
+ * @returns a new array with the instance coordinates.
55
+ */
56
+ asArray(): Flatten<V>;
57
+ /**
58
+ * Sets the current instance coordinates with the given source coordinates
59
+ * @param source defines the source instance
60
+ * @returns the current updated instance
61
+ */
62
+ copyFrom(source: DeepImmutable<this>): this;
63
+ /**
64
+ * Sets the instance coordinates with the given floats
65
+ * @returns the current updated instance
66
+ */
67
+ copyFromFloats(...floats: Flatten<V>): this;
68
+ /**
69
+ * Sets the instance coordinates with the given floats
70
+ * @returns the current updated instance
71
+ */
72
+ set(...values: Flatten<V>): this;
73
+ /**
74
+ * Sets the instance coordinates to the given value
75
+ * @returns the current updated instance
76
+ */
77
+ setAll(value: number): this;
78
+ /**
79
+ * Add another instance with the current one
80
+ * @param other defines the other instance
81
+ * @returns a new instance set with the addition of the current instance and the given one coordinates
82
+ */
83
+ add(other: DeepImmutable<this>): this;
84
+ /**
85
+ * Sets the "result" coordinates with the addition of the current instance and the given one coordinates
86
+ * @param other defines the other instance
87
+ * @param result defines the target instance
88
+ * @returns result input
89
+ */
90
+ addToRef(other: DeepImmutable<this>, result: this): this;
91
+ /**
92
+ * Set the instance coordinates by adding the given instance coordinates
93
+ * @param other defines the other instance
94
+ * @returns the current updated instance
95
+ */
96
+ addInPlace(other: DeepImmutable<this>): this;
97
+ /**
98
+ * Adds the given coordinates to the current instance
99
+ * @param floats the floats to add
100
+ * @returns the current updated instance
101
+ */
102
+ addInPlaceFromFloats(...floats: Flatten<V>): this;
103
+ /**
104
+ * Returns a new instance set with the subtracted coordinates of other's coordinates from the current coordinates.
105
+ * @param other defines the other instance
106
+ * @returns a new instance
107
+ */
108
+ subtract(other: DeepImmutable<this>): this;
109
+ /**
110
+ * Sets the "result" coordinates with the subtraction of the other's coordinates from the current coordinates.
111
+ * @param other defines the other instance
112
+ * @param result defines the target instance
113
+ * @returns result input
114
+ */
115
+ subtractToRef(other: DeepImmutable<this>, result: this): this;
116
+ /**
117
+ * Sets the current instance coordinates by subtracting from it the given one coordinates
118
+ * @param other defines the other instance
119
+ * @returns the current updated instance
120
+ */
121
+ subtractInPlace(other: DeepImmutable<this>): this;
122
+ /**
123
+ * Returns a new instance set with the subtraction of the given floats from the current instance coordinates
124
+ * @param floats the coordinates to subtract
125
+ * @returns the resulting instance
126
+ */
127
+ subtractFromFloats(...floats: Flatten<V>): this;
128
+ /**
129
+ * Subtracts the given floats from the current instance coordinates and set the given instance "result" with this result
130
+ * Note: Implementation uses array magic so types may be confusing.
131
+ * @param args the coordinates to subtract with the last element as the result
132
+ * @returns the result
133
+ */
134
+ subtractFromFloatsToRef(...args: [...Flatten<V>, this]): this;
135
+ /**
136
+ * Returns a new instance set with the multiplication of the current instance and the given one coordinates
137
+ * @param other defines the other instance
138
+ * @returns a new instance
139
+ */
140
+ multiply(other: DeepImmutable<this>): this;
141
+ /**
142
+ * Sets "result" coordinates with the multiplication of the current instance and the given one coordinates
143
+ * @param other defines the other instance
144
+ * @param result defines the target instance
145
+ * @returns result input
146
+ */
147
+ multiplyToRef(other: DeepImmutable<this>, result: this): this;
148
+ /**
149
+ * Multiplies in place the current instance coordinates by the given ones
150
+ * @param other defines the other instance
151
+ * @returns the current updated instance
152
+ */
153
+ multiplyInPlace(other: DeepImmutable<this>): this;
154
+ /**
155
+ * Gets a new instance set with the instance coordinates multiplied by the given floats
156
+ * @returns a new instance
157
+ */
158
+ multiplyByFloats(...floats: Flatten<V>): this;
159
+ /**
160
+ * Returns a new instance set with the instance coordinates divided by the given one coordinates
161
+ * @param other defines the other instance
162
+ * @returns a new instance
163
+ */
164
+ divide(other: DeepImmutable<this>): this;
165
+ /**
166
+ * Sets the "result" coordinates with the instance coordinates divided by the given one coordinates
167
+ * @param other defines the other instance
168
+ * @param result defines the target instance
169
+ * @returns result input
170
+ */
171
+ divideToRef(other: DeepImmutable<this>, result: this): this;
172
+ /**
173
+ * Divides the current instance coordinates by the given ones
174
+ * @param other defines the other instance
175
+ * @returns the current updated instance
176
+ */
177
+ divideInPlace(other: DeepImmutable<this>): this;
178
+ /**
179
+ * Updates the current instance with the minmal coordinate values between its and the given instance ones.
180
+ * @param other defines the other instance
181
+ * @returns this current updated instance
182
+ */
183
+ minimizeInPlace(other: DeepImmutable<this>): this;
184
+ /**
185
+ * Updates the current instance with the minmal coordinate values between its and the given floats.
186
+ * @param floats defines the floats to compare against
187
+ * @returns this current updated instance
188
+ */
189
+ minimizeInPlaceFromFloats(...floats: Flatten<V>): this;
190
+ /**
191
+ * Updates the current instance with the maximal coordinate values between its and the given instance ones.
192
+ * @param other defines the other instance
193
+ * @returns this current updated instance
194
+ */
195
+ maximizeInPlace(other: DeepImmutable<this>): this;
196
+ /**
197
+ * Updates the current instance with the maximal coordinate values between its and the given floats.
198
+ * @param floats defines the floats to compare against
199
+ * @returns this current updated instance
200
+ */
201
+ maximizeInPlaceFromFloats(...floats: Flatten<V>): this;
202
+ /**
203
+ * Gets a new instance with current instance negated coordinates
204
+ * @returns a new instance
205
+ */
206
+ negate(): this;
207
+ /**
208
+ * Negate this instance in place
209
+ * @returns this
210
+ */
211
+ negateInPlace(): this;
212
+ /**
213
+ * Negate the current instance and stores the result in the given instance "result" coordinates
214
+ * @param result defines the instance object where to store the result
215
+ * @returns the result
216
+ */
217
+ negateToRef(result: this): this;
218
+ /**
219
+ * Multiply the instance coordinates by
220
+ * @param scale defines the scaling factor
221
+ * @returns the current updated instance
222
+ */
223
+ scaleInPlace(scale: number): this;
224
+ /**
225
+ * Returns a new instance scaled by "scale" from the current instance
226
+ * @param scale defines the scaling factor
227
+ * @returns a new instance
228
+ */
229
+ scale(scale: number): this;
230
+ /**
231
+ * Scale the current instance values by a factor to a given instance
232
+ * @param scale defines the scale factor
233
+ * @param result defines the instance object where to store the result
234
+ * @returns result input
235
+ */
236
+ scaleToRef(scale: number, result: this): this;
237
+ /**
238
+ * Scale the current instance values by a factor and add the result to a given instance
239
+ * @param scale defines the scale factor
240
+ * @param result defines the instance object where to store the result
241
+ * @returns result input
242
+ */
243
+ scaleAndAddToRef(scale: number, result: this): this;
244
+ /**
245
+ * Gets a boolean if two instances are equals
246
+ * @param other defines the other instance
247
+ * @returns true if the given instance coordinates strictly equal the current instance ones
248
+ */
249
+ equals(other: DeepImmutable<this>): boolean;
250
+ /**
251
+ * Gets a boolean if two instances are equals (using an epsilon value)
252
+ * @param other defines the other instance
253
+ * @param epsilon defines the minimal distance to consider equality
254
+ * @returns true if the given instance coordinates are close to the current ones by a distance of epsilon.
255
+ */
256
+ equalsWithEpsilon(other: DeepImmutable<this>, epsilon?: number): boolean;
257
+ /**
258
+ * Returns true if the current Vectoe coordinates equals the given floats
259
+ * @param floats defines the coordinates to compare against
260
+ * @returns true if both instances are equal
261
+ */
262
+ equalsToFloats(...floats: Flatten<V>): boolean;
263
+ /**
264
+ * Gets a new instance from current instance floored values
265
+ * eg (1.2, 2.31) returns (1, 2)
266
+ * @returns a new instance
267
+ */
268
+ floor(): this;
269
+ /**
270
+ * Gets the current instance's floored values and stores them in result
271
+ * @param result the instance to store the result in
272
+ * @returns the result instance
273
+ */
274
+ floorToRef(result: this): this;
275
+ /**
276
+ * Gets a new instance from current instance fractional values
277
+ * eg (1.2, 2.31) returns (0.2, 0.31)
278
+ * @returns a new instance
279
+ */
280
+ fract(): this;
281
+ /**
282
+ * Gets the current instance's fractional values and stores them in result
283
+ * @param result the instance to store the result in
284
+ * @returns the result instance
285
+ */
286
+ fractToRef(result: this): this;
287
+ /**
288
+ * Gets a new instance copied from the instance
289
+ * @returns a new instance
290
+ */
291
+ clone(): this;
292
+ }
293
+ /**
294
+ * Static side of Tensor
295
+ */
296
+ export interface TensorStatic<T extends Tensor> {
297
+ /**
298
+ * Creates a new instance from the given coordinates
299
+ */
300
+ new (...coords: Flatten<TensorValue<T>>): T;
301
+ /**
302
+ * So [[static]].prototype has typings, instead of just any
303
+ */
304
+ prototype: T;
305
+ /**
306
+ * Returns a new instance with random values between min and max
307
+ * @param min the minimum random value
308
+ * @param max the maximum random value
309
+ * @returns a instance with random values between min and max
310
+ */
311
+ Random(min?: number, max?: number): T;
312
+ /**
313
+ * Returns a new instance with random values between min and max
314
+ * @param min the minimum random value
315
+ * @param max the maximum random value
316
+ * @param result the result to store the random values in
317
+ * @returns the updated result instance
318
+ */
319
+ RandomToRef(min: number | undefined, max: number | undefined, result: T): T;
320
+ /**
321
+ * Gets a new instance from the given index element of the given array
322
+ * @param array defines the data source
323
+ * @param offset defines the offset in the data source
324
+ * @returns a new instance
325
+ */
326
+ FromArray(array: ArrayLike<number>, offset?: number): T;
327
+ /**
328
+ * Sets "result" from the given index element of the given array
329
+ * @param array defines the data source
330
+ * @param offset defines the offset in the data source
331
+ * @param result defines the target instance
332
+ * @returns result input
333
+ */
334
+ FromArrayToRef(array: ArrayLike<number>, offset: number, result: T): T;
335
+ /**
336
+ * Sets the given instance "result" with the given floats.
337
+ * @param args defines the coordinates of the source with the last paramater being the result
338
+ */
339
+ FromFloatsToRef(...args: [...Flatten<TensorValue<T>>, T]): T;
340
+ /**
341
+ * Gets the dot product of the instance "left" and the instance "right"
342
+ * @param left defines first instance
343
+ * @param right defines second instance
344
+ * @returns the dot product (float)
345
+ */
346
+ Dot(left: DeepImmutable<T>, right: DeepImmutable<T>): number;
347
+ /**
348
+ * Gets a new instance set with the minimal coordinate values from the "left" and "right" instances
349
+ * @param left defines 1st instance
350
+ * @param right defines 2nd instance
351
+ * @returns a new instance
352
+ */
353
+ Minimize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;
354
+ /**
355
+ * Gets a new instance set with the maximal coordinate values from the "left" and "right" instances
356
+ * @param left defines 1st instance
357
+ * @param right defines 2nd instance
358
+ * @returns a new instance
359
+ */
360
+ Maximize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;
361
+ /**
362
+ * Gets the distance between the instances "value1" and "value2"
363
+ * @param value1 defines first instance
364
+ * @param value2 defines second instance
365
+ * @returns the distance between instances
366
+ */
367
+ Distance(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;
368
+ /**
369
+ * Returns the squared distance between the instances "value1" and "value2"
370
+ * @param value1 defines first instance
371
+ * @param value2 defines second instance
372
+ * @returns the squared distance between instances
373
+ */
374
+ DistanceSquared(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;
375
+ /**
376
+ * Gets a new instance located at the center of the instances "value1" and "value2"
377
+ * @param value1 defines first instance
378
+ * @param value2 defines second instance
379
+ * @returns a new instance
380
+ */
381
+ Center(value1: DeepImmutable<T>, value2: DeepImmutable<T>): T;
382
+ /**
383
+ * Gets the center of the instances "value1" and "value2" and stores the result in the instance "ref"
384
+ * @param value1 defines first instance
385
+ * @param value2 defines second instance
386
+ * @param ref defines third instance
387
+ * @returns ref
388
+ */
389
+ CenterToRef(value1: DeepImmutable<T>, value2: DeepImmutable<T>, ref: T): T;
390
+ /**
391
+ * Returns a new instance set with same the coordinates than "value" ones if the instance "value" is in the square defined by "min" and "max".
392
+ * If a coordinate of "value" is lower than "min" coordinates, the returned instance is given this "min" coordinate.
393
+ * If a coordinate of "value" is greater than "max" coordinates, the returned instance is given this "max" coordinate
394
+ * @param value defines the value to clamp
395
+ * @param min defines the lower limit
396
+ * @param max defines the upper limit
397
+ * @returns a new instance
398
+ */
399
+ Clamp(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>): T;
400
+ /**
401
+ * Returns a new instance set with same the coordinates than "value" ones if the instance "value" is in the square defined by "min" and "max".
402
+ * If a coordinate of "value" is lower than "min" coordinates, the returned instance is given this "min" coordinate.
403
+ * If a coordinate of "value" is greater than "max" coordinates, the returned instance is given this "max" coordinate
404
+ * @param value defines the value to clamp
405
+ * @param min defines the lower limit
406
+ * @param max defines the upper limit
407
+ * @param result defines the instance where to store the result
408
+ * @returns the updated result instance
409
+ */
410
+ ClampToRef(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>, result: T): T;
411
+ }
@@ -0,0 +1,3 @@
1
+ export {};
2
+ /* eslint-enable @typescript-eslint/naming-convention */
3
+ //# sourceMappingURL=tensor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tensor.js","sourceRoot":"","sources":["../../../../dev/core/src/Maths/tensor.ts"],"names":[],"mappings":";AA8dA,wDAAwD","sourcesContent":["import type { DeepImmutable, Flatten, FloatArray, Length } from \"../types\";\r\n\r\n/**\r\n * Computes the tensor dimension of a multi-dimensional array\r\n */\r\nexport type Dimension<T> = T extends Array<infer U> ? [Length<T>, ...Dimension<U>] : T extends readonly [infer U, ...infer R] ? [Length<T>, ...Dimension<U>] : [];\r\n\r\n/**\r\n * Extracts the value type of a Tensor\r\n */\r\nexport type TensorValue<T> = T extends Tensor<infer V> ? V : never;\r\n\r\n/**\r\n * Describes a mathematical tensor.\r\n * @see https://wikipedia.org/wiki/Tensor\r\n */\r\nexport interface Tensor<V extends unknown[] = unknown[]> {\r\n /**\r\n * An array of the size of each dimension.\r\n * For example, [3] for a Vector3 and [4,4] for a Matrix\r\n * @remarks\r\n * This is to allow implementations with using a getter\r\n */\r\n readonly dimension: Readonly<Dimension<V>>;\r\n\r\n /**\r\n * The rank of the tensor. This is the same as the length of the tensor's dimension array.\r\n * @remarks\r\n * This is to allow implementations with using a getter\r\n */\r\n readonly rank: number;\r\n\r\n /**\r\n * Gets class name\r\n * @returns the class name\r\n */\r\n\r\n getClassName(): string;\r\n\r\n /**\r\n * Gets current instance hash code\r\n * @returns the instance hash code as a number\r\n */\r\n getHashCode(): number;\r\n\r\n /**\r\n * Sets the instance coordinates in the given array from the given index.\r\n * @param array defines the source array\r\n * @param index defines the offset in source array\r\n * @returns the current instance\r\n */\r\n toArray(array: FloatArray, index?: number): this;\r\n\r\n /**\r\n * Update the current instance from an array\r\n * @param array defines the destination array\r\n * @param index defines the offset in the destination array\r\n * @returns the current instance\r\n */\r\n fromArray(array: FloatArray, index?: number): this;\r\n\r\n /**\r\n * Copy the current instance to an array\r\n * @returns a new array with the instance coordinates.\r\n */\r\n asArray(): Flatten<V>;\r\n\r\n /**\r\n * Sets the current instance coordinates with the given source coordinates\r\n * @param source defines the source instance\r\n * @returns the current updated instance\r\n */\r\n copyFrom(source: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the instance coordinates with the given floats\r\n * @returns the current updated instance\r\n */\r\n\r\n copyFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Sets the instance coordinates with the given floats\r\n * @returns the current updated instance\r\n */\r\n set(...values: Flatten<V>): this;\r\n\r\n /**\r\n * Sets the instance coordinates to the given value\r\n * @returns the current updated instance\r\n */\r\n setAll(value: number): this;\r\n\r\n /**\r\n * Add another instance with the current one\r\n * @param other defines the other instance\r\n * @returns a new instance set with the addition of the current instance and the given one coordinates\r\n */\r\n add(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the addition of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n addToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Set the instance coordinates by adding the given instance coordinates\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n addInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Adds the given coordinates to the current instance\r\n * @param floats the floats to add\r\n * @returns the current updated instance\r\n */\r\n addInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Returns a new instance set with the subtracted coordinates of other's coordinates from the current coordinates.\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n subtract(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the subtraction of the other's coordinates from the current coordinates.\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n subtractToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Sets the current instance coordinates by subtracting from it the given one coordinates\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n subtractInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Returns a new instance set with the subtraction of the given floats from the current instance coordinates\r\n * @param floats the coordinates to subtract\r\n * @returns the resulting instance\r\n */\r\n subtractFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Subtracts the given floats from the current instance coordinates and set the given instance \"result\" with this result\r\n * Note: Implementation uses array magic so types may be confusing.\r\n * @param args the coordinates to subtract with the last element as the result\r\n * @returns the result\r\n */\r\n subtractFromFloatsToRef(...args: [...Flatten<V>, this]): this;\r\n\r\n /**\r\n * Returns a new instance set with the multiplication of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n multiply(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets \"result\" coordinates with the multiplication of the current instance and the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n multiplyToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Multiplies in place the current instance coordinates by the given ones\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n multiplyInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Gets a new instance set with the instance coordinates multiplied by the given floats\r\n * @returns a new instance\r\n */\r\n multiplyByFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Returns a new instance set with the instance coordinates divided by the given one coordinates\r\n * @param other defines the other instance\r\n * @returns a new instance\r\n */\r\n divide(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Sets the \"result\" coordinates with the instance coordinates divided by the given one coordinates\r\n * @param other defines the other instance\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n divideToRef(other: DeepImmutable<this>, result: this): this;\r\n\r\n /**\r\n * Divides the current instance coordinates by the given ones\r\n * @param other defines the other instance\r\n * @returns the current updated instance\r\n */\r\n divideInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the minmal coordinate values between its and the given instance ones.\r\n * @param other defines the other instance\r\n * @returns this current updated instance\r\n */\r\n minimizeInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the minmal coordinate values between its and the given floats.\r\n * @param floats defines the floats to compare against\r\n * @returns this current updated instance\r\n */\r\n minimizeInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Updates the current instance with the maximal coordinate values between its and the given instance ones.\r\n * @param other defines the other instance\r\n * @returns this current updated instance\r\n */\r\n maximizeInPlace(other: DeepImmutable<this>): this;\r\n\r\n /**\r\n * Updates the current instance with the maximal coordinate values between its and the given floats.\r\n * @param floats defines the floats to compare against\r\n * @returns this current updated instance\r\n */\r\n maximizeInPlaceFromFloats(...floats: Flatten<V>): this;\r\n\r\n /**\r\n * Gets a new instance with current instance negated coordinates\r\n * @returns a new instance\r\n */\r\n negate(): this;\r\n\r\n /**\r\n * Negate this instance in place\r\n * @returns this\r\n */\r\n negateInPlace(): this;\r\n\r\n /**\r\n * Negate the current instance and stores the result in the given instance \"result\" coordinates\r\n * @param result defines the instance object where to store the result\r\n * @returns the result\r\n */\r\n negateToRef(result: this): this;\r\n\r\n /**\r\n * Multiply the instance coordinates by\r\n * @param scale defines the scaling factor\r\n * @returns the current updated instance\r\n */\r\n scaleInPlace(scale: number): this;\r\n\r\n /**\r\n * Returns a new instance scaled by \"scale\" from the current instance\r\n * @param scale defines the scaling factor\r\n * @returns a new instance\r\n */\r\n scale(scale: number): this;\r\n\r\n /**\r\n * Scale the current instance values by a factor to a given instance\r\n * @param scale defines the scale factor\r\n * @param result defines the instance object where to store the result\r\n * @returns result input\r\n */\r\n scaleToRef(scale: number, result: this): this;\r\n\r\n /**\r\n * Scale the current instance values by a factor and add the result to a given instance\r\n * @param scale defines the scale factor\r\n * @param result defines the instance object where to store the result\r\n * @returns result input\r\n */\r\n scaleAndAddToRef(scale: number, result: this): this;\r\n\r\n /**\r\n * Gets a boolean if two instances are equals\r\n * @param other defines the other instance\r\n * @returns true if the given instance coordinates strictly equal the current instance ones\r\n */\r\n equals(other: DeepImmutable<this>): boolean;\r\n\r\n /**\r\n * Gets a boolean if two instances are equals (using an epsilon value)\r\n * @param other defines the other instance\r\n * @param epsilon defines the minimal distance to consider equality\r\n * @returns true if the given instance coordinates are close to the current ones by a distance of epsilon.\r\n */\r\n equalsWithEpsilon(other: DeepImmutable<this>, epsilon?: number): boolean;\r\n\r\n /**\r\n * Returns true if the current Vectoe coordinates equals the given floats\r\n * @param floats defines the coordinates to compare against\r\n * @returns true if both instances are equal\r\n */\r\n equalsToFloats(...floats: Flatten<V>): boolean;\r\n\r\n /**\r\n * Gets a new instance from current instance floored values\r\n * eg (1.2, 2.31) returns (1, 2)\r\n * @returns a new instance\r\n */\r\n floor(): this;\r\n\r\n /**\r\n * Gets the current instance's floored values and stores them in result\r\n * @param result the instance to store the result in\r\n * @returns the result instance\r\n */\r\n floorToRef(result: this): this;\r\n\r\n /**\r\n * Gets a new instance from current instance fractional values\r\n * eg (1.2, 2.31) returns (0.2, 0.31)\r\n * @returns a new instance\r\n */\r\n fract(): this;\r\n\r\n /**\r\n * Gets the current instance's fractional values and stores them in result\r\n * @param result the instance to store the result in\r\n * @returns the result instance\r\n */\r\n fractToRef(result: this): this;\r\n\r\n /**\r\n * Gets a new instance copied from the instance\r\n * @returns a new instance\r\n */\r\n clone(): this;\r\n}\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n/**\r\n * Static side of Tensor\r\n */\r\nexport interface TensorStatic<T extends Tensor> {\r\n /**\r\n * Creates a new instance from the given coordinates\r\n */\r\n new (...coords: Flatten<TensorValue<T>>): T;\r\n\r\n /**\r\n * So [[static]].prototype has typings, instead of just any\r\n */\r\n prototype: T;\r\n\r\n /**\r\n * Returns a new instance with random values between min and max\r\n * @param min the minimum random value\r\n * @param max the maximum random value\r\n * @returns a instance with random values between min and max\r\n */\r\n Random(min?: number, max?: number): T;\r\n\r\n /**\r\n * Returns a new instance with random values between min and max\r\n * @param min the minimum random value\r\n * @param max the maximum random value\r\n * @param result the result to store the random values in\r\n * @returns the updated result instance\r\n */\r\n RandomToRef(min: number | undefined, max: number | undefined, result: T): T;\r\n\r\n /**\r\n * Gets a new instance from the given index element of the given array\r\n * @param array defines the data source\r\n * @param offset defines the offset in the data source\r\n * @returns a new instance\r\n */\r\n FromArray(array: ArrayLike<number>, offset?: number): T;\r\n\r\n /**\r\n * Sets \"result\" from the given index element of the given array\r\n * @param array defines the data source\r\n * @param offset defines the offset in the data source\r\n * @param result defines the target instance\r\n * @returns result input\r\n */\r\n FromArrayToRef(array: ArrayLike<number>, offset: number, result: T): T;\r\n\r\n /**\r\n * Sets the given instance \"result\" with the given floats.\r\n * @param args defines the coordinates of the source with the last paramater being the result\r\n */\r\n FromFloatsToRef(...args: [...Flatten<TensorValue<T>>, T]): T;\r\n\r\n /**\r\n * Gets the dot product of the instance \"left\" and the instance \"right\"\r\n * @param left defines first instance\r\n * @param right defines second instance\r\n * @returns the dot product (float)\r\n */\r\n Dot(left: DeepImmutable<T>, right: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Gets a new instance set with the minimal coordinate values from the \"left\" and \"right\" instances\r\n * @param left defines 1st instance\r\n * @param right defines 2nd instance\r\n * @returns a new instance\r\n */\r\n Minimize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets a new instance set with the maximal coordinate values from the \"left\" and \"right\" instances\r\n * @param left defines 1st instance\r\n * @param right defines 2nd instance\r\n * @returns a new instance\r\n */\r\n Maximize(left: DeepImmutable<T>, right: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets the distance between the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns the distance between instances\r\n */\r\n Distance(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Returns the squared distance between the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns the squared distance between instances\r\n */\r\n DistanceSquared(value1: DeepImmutable<T>, value2: DeepImmutable<T>): number;\r\n\r\n /**\r\n * Gets a new instance located at the center of the instances \"value1\" and \"value2\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @returns a new instance\r\n */\r\n Center(value1: DeepImmutable<T>, value2: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Gets the center of the instances \"value1\" and \"value2\" and stores the result in the instance \"ref\"\r\n * @param value1 defines first instance\r\n * @param value2 defines second instance\r\n * @param ref defines third instance\r\n * @returns ref\r\n */\r\n CenterToRef(value1: DeepImmutable<T>, value2: DeepImmutable<T>, ref: T): T;\r\n\r\n /**\r\n * Returns a new instance set with same the coordinates than \"value\" ones if the instance \"value\" is in the square defined by \"min\" and \"max\".\r\n * If a coordinate of \"value\" is lower than \"min\" coordinates, the returned instance is given this \"min\" coordinate.\r\n * If a coordinate of \"value\" is greater than \"max\" coordinates, the returned instance is given this \"max\" coordinate\r\n * @param value defines the value to clamp\r\n * @param min defines the lower limit\r\n * @param max defines the upper limit\r\n * @returns a new instance\r\n */\r\n Clamp(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>): T;\r\n\r\n /**\r\n * Returns a new instance set with same the coordinates than \"value\" ones if the instance \"value\" is in the square defined by \"min\" and \"max\".\r\n * If a coordinate of \"value\" is lower than \"min\" coordinates, the returned instance is given this \"min\" coordinate.\r\n * If a coordinate of \"value\" is greater than \"max\" coordinates, the returned instance is given this \"max\" coordinate\r\n * @param value defines the value to clamp\r\n * @param min defines the lower limit\r\n * @param max defines the upper limit\r\n * @param result defines the instance where to store the result\r\n * @returns the updated result instance\r\n */\r\n ClampToRef(value: DeepImmutable<T>, min: DeepImmutable<T>, max: DeepImmutable<T>, result: T): T;\r\n}\r\n/* eslint-enable @typescript-eslint/naming-convention */\r\n"]}
@@ -19,8 +19,13 @@ export class SetColorsBlock extends NodeGeometryBlock {
19
19
  */
20
20
  this.evaluateContext = true;
21
21
  this.registerInput("geometry", NodeGeometryBlockConnectionPointTypes.Geometry);
22
- this.registerInput("colors", NodeGeometryBlockConnectionPointTypes.Vector4);
22
+ this.registerInput("colors", NodeGeometryBlockConnectionPointTypes.AutoDetect);
23
23
  this.registerOutput("output", NodeGeometryBlockConnectionPointTypes.Geometry);
24
+ this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);
25
+ this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);
26
+ this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Vector2);
27
+ this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);
28
+ this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);
24
29
  }
25
30
  /**
26
31
  * Gets the current index in the current flow
@@ -94,9 +99,20 @@ export class SetColorsBlock extends NodeGeometryBlock {
94
99
  // Processing
95
100
  const vertexCount = this._vertexData.positions.length / 3;
96
101
  for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {
97
- const tempVector4 = this.colors.getConnectedValue(state);
98
- if (tempVector4) {
99
- tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);
102
+ if (this.colors.connectedPoint?.type === NodeGeometryBlockConnectionPointTypes.Vector3) {
103
+ const tempVector3 = this.colors.getConnectedValue(state);
104
+ if (tempVector3) {
105
+ tempVector3.toArray(this._vertexData.colors, this._currentIndex * 4);
106
+ this._vertexData.colors[this._currentIndex * 4 + 3] = 1; // Alpha
107
+ this._vertexData.hasVertexAlpha = false;
108
+ }
109
+ }
110
+ else {
111
+ const tempVector4 = this.colors.getConnectedValue(state);
112
+ if (tempVector4) {
113
+ tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);
114
+ this._vertexData.hasVertexAlpha = true;
115
+ }
100
116
  }
101
117
  }
102
118
  // Storage
@@ -1 +1 @@
1
- {"version":3,"file":"setColorsBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setColorsBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D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CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport type { Vector4 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to set colors for a geometry\r\n */\r\nexport class SetColorsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetColorsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"colors\", NodeGeometryBlockConnectionPointTypes.Vector4);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"SetColorsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the colors input component\r\n */\r\n public get colors(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n state.pushGeometryContext(this._vertexData);\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n if (!this.colors.isConnected) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = this._vertexData;\r\n return;\r\n }\r\n\r\n if (!this._vertexData.colors) {\r\n this._vertexData.colors = [];\r\n }\r\n\r\n // Processing\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n const tempVector4 = this.colors.getConnectedValue(state) as Vector4;\r\n if (tempVector4) {\r\n tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);\r\n }\r\n }\r\n\r\n // Storage\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetColorsBlock\", SetColorsBlock);\r\n"]}
1
+ {"version":3,"file":"setColorsBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/setColorsBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAKrG,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEtG;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IAWjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAZhB;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAS1B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CA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;QAC7I,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,YAAY,CAAC,mBAAwB;QACxC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,eAAe,KAAK,SAAS,EAAE;YACnD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;SAC9D;IACL,CAAC;CACJ;AAjKU;IADN,sBAAsB,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;uDAC3F;AAmKlC,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport type { Vector3, Vector4 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to set colors for a geometry\r\n */\r\nexport class SetColorsBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndex: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Create a new SetColorsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"colors\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Float);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Vector2);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"SetColorsBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the colors input component\r\n */\r\n public get colors(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n state.pushGeometryContext(this._vertexData);\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n if (!this.colors.isConnected) {\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n this.output._storedValue = this._vertexData;\r\n return;\r\n }\r\n\r\n if (!this._vertexData.colors) {\r\n this._vertexData.colors = [];\r\n }\r\n\r\n // Processing\r\n const vertexCount = this._vertexData.positions.length / 3;\r\n for (this._currentIndex = 0; this._currentIndex < vertexCount; this._currentIndex++) {\r\n if (this.colors.connectedPoint?.type === NodeGeometryBlockConnectionPointTypes.Vector3) {\r\n const tempVector3 = this.colors.getConnectedValue(state) as Vector3;\r\n if (tempVector3) {\r\n tempVector3.toArray(this._vertexData.colors, this._currentIndex * 4);\r\n this._vertexData.colors[this._currentIndex * 4 + 3] = 1; // Alpha\r\n this._vertexData.hasVertexAlpha = false;\r\n }\r\n } else {\r\n const tempVector4 = this.colors.getConnectedValue(state) as Vector4;\r\n if (tempVector4) {\r\n tempVector4.toArray(this._vertexData.colors, this._currentIndex * 4);\r\n this._vertexData.hasVertexAlpha = true;\r\n }\r\n }\r\n }\r\n\r\n // Storage\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetColorsBlock\", SetColorsBlock);\r\n"]}
@@ -4,7 +4,8 @@ import { Mesh } from "../mesh.js";
4
4
  import { GeometryOutputBlock } from "./Blocks/geometryOutputBlock.js";
5
5
  import { NodeGeometryBuildState } from "./nodeGeometryBuildState.js";
6
6
  import { GetClass } from "../../Misc/typeStore.js";
7
- import { SerializationHelper, serialize } from "../../Misc/decorators.js";
7
+ import { serialize } from "../../Misc/decorators.js";
8
+ import { SerializationHelper } from "../../Misc/decorators.serialization.js";
8
9
 
9
10
  import { WebRequest } from "../../Misc/webRequest.js";
10
11
  import { BoxBlock } from "./Blocks/Sources/boxBlock.js";