@onerjs/core 8.30.4 → 8.30.6

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 (288) hide show
  1. package/Actions/action.d.ts +5 -0
  2. package/Actions/action.js.map +1 -1
  3. package/Actions/actionManager.js +6 -2
  4. package/Actions/actionManager.js.map +1 -1
  5. package/Animations/runtimeAnimation.d.ts +0 -2
  6. package/Animations/runtimeAnimation.js +3 -5
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.d.ts +9 -5
  9. package/Audio/audioSceneComponent.js +1 -0
  10. package/Audio/audioSceneComponent.js.map +1 -1
  11. package/AudioV2/abstractAudio/abstractSound.js +1 -0
  12. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  13. package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
  14. package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
  15. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  16. package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
  17. package/AudioV2/webAudio/webAudioEngine.js +8 -0
  18. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  19. package/AudioV2/webAudio/webAudioStaticSound.js +10 -5
  20. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  21. package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
  22. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  23. package/Cameras/camera.d.ts +4 -0
  24. package/Cameras/camera.js +18 -9
  25. package/Cameras/camera.js.map +1 -1
  26. package/Collisions/gpuPicker.js +0 -1
  27. package/Collisions/gpuPicker.js.map +1 -1
  28. package/Decorators/nodeDecorator.d.ts +3 -1
  29. package/Decorators/nodeDecorator.js +2 -0
  30. package/Decorators/nodeDecorator.js.map +1 -1
  31. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  32. package/Engines/Native/nativeInterfaces.js.map +1 -1
  33. package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
  34. package/Engines/WebGPU/webgpuDrawContext.js +8 -0
  35. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  36. package/Engines/abstractEngine.js +2 -2
  37. package/Engines/abstractEngine.js.map +1 -1
  38. package/Engines/nativeEngine.js +12 -13
  39. package/Engines/nativeEngine.js.map +1 -1
  40. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
  41. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
  42. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
  43. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
  44. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  45. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
  46. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
  47. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
  48. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
  49. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
  50. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
  51. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
  52. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  53. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
  54. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
  55. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
  56. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
  57. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +3 -3
  58. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
  59. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
  60. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
  61. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
  62. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
  63. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
  64. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
  65. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
  66. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
  67. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
  68. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
  69. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
  70. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
  71. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
  72. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
  73. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
  74. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
  75. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
  76. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
  77. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
  78. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
  79. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
  80. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
  81. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
  82. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
  83. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
  84. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
  85. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
  86. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
  87. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
  88. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
  89. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
  90. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
  91. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
  92. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
  93. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
  94. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
  95. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
  96. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
  97. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
  98. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
  99. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
  100. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
  101. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +17 -1
  102. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +70 -0
  103. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  104. package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
  105. package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
  106. package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
  107. package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
  108. package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
  109. package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -1
  110. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  111. package/FrameGraph/Node/Blocks/index.js +1 -0
  112. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  113. package/FrameGraph/Node/Blocks/inputBlock.js +2 -0
  114. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  115. package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
  116. package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
  117. package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
  118. package/FrameGraph/Node/nodeRenderGraph.js +7 -3
  119. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  120. package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
  121. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  122. package/FrameGraph/Passes/pass.d.ts +11 -1
  123. package/FrameGraph/Passes/pass.js +11 -1
  124. package/FrameGraph/Passes/pass.js.map +1 -1
  125. package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
  126. package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
  127. package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
  128. package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
  129. package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
  130. package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
  131. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
  132. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
  133. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  134. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
  135. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
  136. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  137. package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
  138. package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
  139. package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
  140. package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
  141. package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
  142. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
  143. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
  144. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  145. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +7 -1
  146. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +4 -1
  147. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  148. package/FrameGraph/frameGraph.d.ts +1 -1
  149. package/FrameGraph/frameGraph.js +3 -6
  150. package/FrameGraph/frameGraph.js.map +1 -1
  151. package/FrameGraph/frameGraphContext.d.ts +8 -1
  152. package/FrameGraph/frameGraphContext.js +9 -0
  153. package/FrameGraph/frameGraphContext.js.map +1 -1
  154. package/FrameGraph/frameGraphRenderContext.d.ts +4 -2
  155. package/FrameGraph/frameGraphRenderContext.js +11 -5
  156. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  157. package/FrameGraph/frameGraphTask.d.ts +11 -2
  158. package/FrameGraph/frameGraphTask.js +17 -2
  159. package/FrameGraph/frameGraphTask.js.map +1 -1
  160. package/FrameGraph/frameGraphTextureManager.js +2 -2
  161. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  162. package/FrameGraph/index.d.ts +1 -0
  163. package/FrameGraph/index.js +1 -0
  164. package/FrameGraph/index.js.map +1 -1
  165. package/Lights/directionalLight.js +1 -4
  166. package/Lights/directionalLight.js.map +1 -1
  167. package/Lights/pointLight.js +2 -5
  168. package/Lights/pointLight.js.map +1 -1
  169. package/Materials/Textures/mirrorTexture.js +4 -1
  170. package/Materials/Textures/mirrorTexture.js.map +1 -1
  171. package/Materials/clipPlaneMaterialHelper.js +11 -1
  172. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  173. package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
  174. package/Materials/floatingOriginMatrixOverrides.js +14 -2
  175. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  176. package/Materials/index.d.ts +1 -0
  177. package/Materials/index.js +1 -0
  178. package/Materials/index.js.map +1 -1
  179. package/Materials/materialHelper.functions.d.ts +8 -0
  180. package/Materials/materialHelper.functions.js +31 -0
  181. package/Materials/materialHelper.functions.js.map +1 -1
  182. package/Materials/shaderMaterial.js +21 -1
  183. package/Materials/shaderMaterial.js.map +1 -1
  184. package/Maths/math.vector.functions.d.ts +55 -16
  185. package/Maths/math.vector.functions.js +68 -10
  186. package/Maths/math.vector.functions.js.map +1 -1
  187. package/Misc/copyTextureToTexture.d.ts +10 -0
  188. package/Misc/copyTextureToTexture.js +15 -0
  189. package/Misc/copyTextureToTexture.js.map +1 -1
  190. package/Misc/decorators.d.ts +1 -1
  191. package/Misc/decorators.js.map +1 -1
  192. package/Misc/dumpTools.d.ts +20 -0
  193. package/Misc/dumpTools.js +60 -49
  194. package/Misc/dumpTools.js.map +1 -1
  195. package/Misc/index.d.ts +1 -2
  196. package/Misc/index.js +1 -2
  197. package/Misc/index.js.map +1 -1
  198. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
  199. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  200. package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
  201. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
  202. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
  203. package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
  204. package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
  205. package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
  206. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
  207. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  208. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
  209. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  210. package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
  211. package/Particles/Node/Blocks/Emitters/index.js +5 -4
  212. package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
  213. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
  214. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  215. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
  216. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  217. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
  218. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  219. package/Particles/Node/Blocks/particleInputBlock.js +2 -0
  220. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  221. package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
  222. package/Particles/Node/Blocks/systemBlock.js +82 -3
  223. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  224. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
  225. package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
  226. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  227. package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
  228. package/Particles/Node/nodeParticleBuildState.js +12 -22
  229. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  230. package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
  231. package/Particles/Node/nodeParticleSystemSet.helper.js +344 -112
  232. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  233. package/Particles/thinParticleSystem.js +1 -0
  234. package/Particles/thinParticleSystem.js.map +1 -1
  235. package/Physics/physicsRaycastResult.d.ts +3 -0
  236. package/Physics/physicsRaycastResult.js.map +1 -1
  237. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
  238. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  239. package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
  240. package/Physics/v2/Plugins/havokPlugin.js +73 -9
  241. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  242. package/Physics/v2/physicsEngine.d.ts +12 -2
  243. package/Physics/v2/physicsEngine.js +15 -1
  244. package/Physics/v2/physicsEngine.js.map +1 -1
  245. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
  246. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
  247. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  248. package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
  249. package/PostProcesses/thinSSAO2PostProcess.js +18 -6
  250. package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
  251. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
  252. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  253. package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
  254. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  255. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
  256. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  257. package/Shaders/particles.vertex.js +1 -1
  258. package/Shaders/particles.vertex.js.map +1 -1
  259. package/Shaders/picking.fragment.js +1 -1
  260. package/Shaders/picking.fragment.js.map +1 -1
  261. package/Shaders/picking.vertex.js +1 -1
  262. package/Shaders/picking.vertex.js.map +1 -1
  263. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
  264. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
  265. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
  266. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  267. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
  268. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  269. package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -4
  270. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  271. package/ShadersWGSL/particles.vertex.js +1 -1
  272. package/ShadersWGSL/particles.vertex.js.map +1 -1
  273. package/ShadersWGSL/picking.fragment.js +1 -1
  274. package/ShadersWGSL/picking.fragment.js.map +1 -1
  275. package/ShadersWGSL/picking.vertex.js +1 -1
  276. package/ShadersWGSL/picking.vertex.js.map +1 -1
  277. package/Sprites/spriteRenderer.js +10 -8
  278. package/Sprites/spriteRenderer.js.map +1 -1
  279. package/XR/features/WebXRLightEstimation.d.ts +8 -0
  280. package/XR/features/WebXRLightEstimation.js +6 -1
  281. package/XR/features/WebXRLightEstimation.js.map +1 -1
  282. package/assetContainer.d.ts +1 -1
  283. package/assetContainer.js +1 -1
  284. package/assetContainer.js.map +1 -1
  285. package/package.json +1 -1
  286. package/scene.d.ts +7 -2
  287. package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AC,eAAe,GAAG,eAAe,CAAC;AAC5C,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\n\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"./logger\";\r\n\r\ntype DumpResources = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n dumpEngine?: {\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n };\r\n};\r\n\r\nlet ResourcesPromise: Promise<DumpResources> | null = null;\r\n\r\nasync function _CreateDumpResourcesAsync(): Promise<DumpResources> {\r\n // Create a compatible canvas. Prefer an HTMLCanvasElement if possible to avoid alpha issues with OffscreenCanvas + WebGL in many browsers.\r\n const canvas = (EngineStore.LastCreatedEngine?.createCanvas(100, 100) ?? new OffscreenCanvas(100, 100)) as HTMLCanvasElement | OffscreenCanvas; // will be resized later\r\n if (canvas instanceof OffscreenCanvas) {\r\n Logger.Warn(\"DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.\");\r\n }\r\n\r\n // If WebGL via ThinEngine is not available (e.g. Native), use the BitmapRenderer.\r\n // If https://github.com/whatwg/html/issues/10142 is resolved, we can migrate to just BitmapRenderer and avoid an engine dependency altogether.\r\n const { ThinEngine: thinEngineClass } = await import(\"../Engines/thinEngine\");\r\n if (!thinEngineClass.IsSupported) {\r\n if (!canvas.getContext(\"bitmaprenderer\")) {\r\n throw new Error(\"DumpData: No WebGL or bitmap rendering context available. Cannot dump data.\");\r\n }\r\n return { canvas };\r\n }\r\n\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n const engine = new thinEngineClass(canvas, false, options);\r\n\r\n // remove this engine from the list of instances to avoid using it for other purposes\r\n EngineStore.Instances.pop();\r\n // However, make sure to dispose it when no other engines are left\r\n EngineStore.OnEnginesDisposedObservable.add((e) => {\r\n // guaranteed to run when no other instances are left\r\n // only dispose if it's not the current engine\r\n if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {\r\n // Dump the engine and the associated resources\r\n Dispose();\r\n }\r\n });\r\n\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n\r\n const renderer = new EffectRenderer(engine);\r\n const { passPixelShader } = await import(\"../Shaders/pass.fragment\");\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n\r\n return {\r\n canvas: canvas,\r\n dumpEngine: { engine, renderer, wrapper },\r\n };\r\n}\r\n\r\nasync function _GetDumpResourcesAsync() {\r\n if (!ResourcesPromise) {\r\n ResourcesPromise = _CreateDumpResourcesAsync();\r\n }\r\n return await ResourcesPromise;\r\n}\r\n\r\n/**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a void promise\r\n */\r\n// Should have \"Async\" in the name but this is a public API and we can't break it now\r\n// eslint-disable-next-line no-restricted-syntax\r\nexport async function DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: AbstractEngine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n}\r\n\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType: string | undefined,\r\n fileName: string | undefined,\r\n invertY: boolean | undefined,\r\n toArrayBuffer: true,\r\n quality?: number\r\n): Promise<ArrayBuffer>;\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n): Promise<string>;\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolve to the final data\r\n */\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): Promise<string | ArrayBuffer> {\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n const resources = await _GetDumpResourcesAsync();\r\n\r\n // Keep the async render + read from the shared canvas atomic\r\n // eslint-disable-next-line no-async-promise-executor\r\n return await new Promise<string | ArrayBuffer>(async (resolve) => {\r\n if (resources.dumpEngine) {\r\n const dumpEngine = resources.dumpEngine;\r\n dumpEngine.engine.setSize(width, height, true);\r\n\r\n // Create the image\r\n const texture = dumpEngine.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n dumpEngine.renderer.setViewport();\r\n dumpEngine.renderer.applyEffectWrapper(dumpEngine.wrapper);\r\n dumpEngine.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n dumpEngine.renderer.draw();\r\n\r\n texture.dispose();\r\n } else {\r\n const ctx = resources.canvas.getContext(\"bitmaprenderer\") as ImageBitmapRenderingContext;\r\n resources.canvas.width = width;\r\n resources.canvas.height = height;\r\n\r\n const imageData = new ImageData(width, height); // ImageData(data, sw, sh) ctor not yet widely implemented\r\n imageData.data.set(data as Uint8ClampedArray);\r\n const imageBitmap = await createImageBitmap(imageData, { premultiplyAlpha: \"none\", imageOrientation: invertY ? \"flipY\" : \"from-image\" });\r\n\r\n ctx.transferFromImageBitmap(imageBitmap);\r\n }\r\n\r\n Tools.ToBlob(\r\n resources.canvas,\r\n (blob) => {\r\n if (!blob) {\r\n throw new Error(\"DumpData: Failed to convert canvas to blob.\");\r\n }\r\n\r\n if (fileName !== undefined) {\r\n Tools.DownloadBlob(blob, fileName);\r\n }\r\n\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const result = event.target!.result as string | ArrayBuffer;\r\n resolve(result);\r\n };\r\n\r\n if (toArrayBuffer) {\r\n fileReader.readAsArrayBuffer(blob);\r\n } else {\r\n fileReader.readAsDataURL(blob);\r\n }\r\n },\r\n mimeType,\r\n quality\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName The name of the file to download. If present, the result will automatically be downloaded. If not defined, and `successCallback` is also not defined, the result will automatically be downloaded with an auto-generated file name.\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): void {\r\n // For back-compat: if no fileName and no callback, force download the result\r\n if (fileName === undefined && !successCallback) {\r\n fileName = \"\";\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n DumpDataAsync(width, height, data, mimeType, fileName, invertY, toArrayBuffer, quality)\r\n // eslint-disable-next-line github/no-then\r\n .then((result) => {\r\n if (successCallback) {\r\n successCallback(result);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Dispose the dump tools associated resources\r\n */\r\nexport function Dispose() {\r\n if (!ResourcesPromise) {\r\n return;\r\n }\r\n\r\n // in cases where the engine is not yet created, we need to wait for it to dispose it\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n ResourcesPromise?.then((resources) => {\r\n if (resources.canvas instanceof HTMLCanvasElement) {\r\n resources.canvas.remove();\r\n }\r\n if (resources.dumpEngine) {\r\n resources.dumpEngine.engine.dispose();\r\n resources.dumpEngine.renderer.dispose();\r\n resources.dumpEngine.wrapper.dispose();\r\n }\r\n });\r\n\r\n ResourcesPromise = null;\r\n}\r\n\r\n/**\r\n * Object containing a set of static utilities functions to dump data from a canvas\r\n * @deprecated use functions\r\n */\r\nexport const DumpTools = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpData,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpDataAsync,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpFramebuffer,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Dispose,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst InitSideEffects = () => {\r\n // References the dependencies.\r\n Tools.DumpData = DumpData;\r\n Tools.DumpDataAsync = DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpFramebuffer;\r\n};\r\n\r\nInitSideEffects();\r\n"]}
1
+ {"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAW9C,IAAI,gBAAgB,GAAkC,IAAI,CAAC;AAE3D,KAAK,UAAU,yBAAyB;IACpC,2IAA2I;IAC3I,MAAM,MAAM,GAAG,CAAC,WAAW,CAAC,iBAAiB,EAAE,YAAY,C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G;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,gEAAgE;IAChE,QAAQ;IACR,gEAAgE;IAChE,aAAa;IACb,gEAAgE;IAChE,eAAe;IACf,gEAAgE;IAChE,OAAO;CACV,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;IACpC,KAAK,CAAC,eAAe,GAAG,eAAe,CAAC;AAC5C,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\n\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"./logger\";\r\nimport { EncodeArrayBufferToBase64 } from \"./stringTools\";\r\nimport { nativeOverride } from \"./decorators\";\r\n\r\ntype DumpResources = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n dumpEngine: {\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n };\r\n};\r\n\r\nlet ResourcesPromise: Promise<DumpResources> | null = null;\r\n\r\nasync function _CreateDumpResourcesAsync(): Promise<DumpResources> {\r\n // Create a compatible canvas. Prefer an HTMLCanvasElement if possible to avoid alpha issues with OffscreenCanvas + WebGL in many browsers.\r\n const canvas = (EngineStore.LastCreatedEngine?.createCanvas(100, 100) ?? new OffscreenCanvas(100, 100)) as HTMLCanvasElement | OffscreenCanvas; // will be resized later\r\n if (canvas instanceof OffscreenCanvas) {\r\n Logger.Warn(\"DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.\");\r\n }\r\n\r\n // If WebGL via ThinEngine is not available, we cannot encode the data.\r\n // If https://github.com/whatwg/html/issues/10142 is resolved, we can migrate to just BitmapRenderer and avoid an engine dependency altogether.\r\n const { ThinEngine: thinEngineClass } = await import(\"../Engines/thinEngine\");\r\n if (!thinEngineClass.IsSupported) {\r\n throw new Error(\"DumpData: No WebGL context available. Cannot dump data.\");\r\n }\r\n\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n const engine = new thinEngineClass(canvas, false, options);\r\n\r\n // remove this engine from the list of instances to avoid using it for other purposes\r\n EngineStore.Instances.pop();\r\n // However, make sure to dispose it when no other engines are left\r\n EngineStore.OnEnginesDisposedObservable.add((e) => {\r\n // guaranteed to run when no other instances are left\r\n // only dispose if it's not the current engine\r\n if (engine && e !== engine && !engine.isDisposed && EngineStore.Instances.length === 0) {\r\n // Dump the engine and the associated resources\r\n Dispose();\r\n }\r\n });\r\n\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n\r\n const renderer = new EffectRenderer(engine);\r\n const { passPixelShader } = await import(\"../Shaders/pass.fragment\");\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n\r\n return {\r\n canvas: canvas,\r\n dumpEngine: { engine, renderer, wrapper },\r\n };\r\n}\r\n\r\nasync function _GetDumpResourcesAsync() {\r\n if (!ResourcesPromise) {\r\n ResourcesPromise = _CreateDumpResourcesAsync();\r\n }\r\n return await ResourcesPromise;\r\n}\r\n\r\nclass EncodingHelper {\r\n /**\r\n * Encodes image data to the given mime type.\r\n * This is put into a helper class so we can apply the nativeOverride decorator to it.\r\n * @internal\r\n */\r\n @nativeOverride\r\n public static async EncodeImageAsync(pixelData: ArrayBufferView, width: number, height: number, mimeType?: string, invertY?: boolean, quality?: number): Promise<Blob> {\r\n const resources = await _GetDumpResourcesAsync();\r\n\r\n const dumpEngine = resources.dumpEngine;\r\n dumpEngine.engine.setSize(width, height, true);\r\n\r\n // Create the image\r\n const texture = dumpEngine.engine.createRawTexture(pixelData, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n dumpEngine.renderer.setViewport();\r\n dumpEngine.renderer.applyEffectWrapper(dumpEngine.wrapper);\r\n dumpEngine.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n dumpEngine.renderer.draw();\r\n\r\n texture.dispose();\r\n\r\n return await new Promise<Blob>((resolve, reject) => {\r\n Tools.ToBlob(\r\n resources.canvas,\r\n (blob) => {\r\n if (!blob) {\r\n reject(new Error(\"EncodeImageAsync: Failed to convert canvas to blob.\"));\r\n } else {\r\n resolve(blob);\r\n }\r\n },\r\n mimeType,\r\n quality\r\n );\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Encodes pixel data to an image\r\n * @param pixelData 8-bit RGBA pixel data\r\n * @param width the width of the image\r\n * @param height the height of the image\r\n * @param mimeType the requested MIME type\r\n * @param invertY true to invert the image in the Y direction\r\n * @param quality the quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolves to the encoded image data. Note that the `blob.type` may differ from `mimeType` if it was not supported.\r\n */\r\nexport const EncodeImageAsync = EncodingHelper.EncodeImageAsync;\r\n\r\n/**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a void promise\r\n */\r\n// Should have \"Async\" in the name but this is a public API and we can't break it now\r\n// eslint-disable-next-line no-restricted-syntax\r\nexport async function DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: AbstractEngine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n}\r\n\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType: string | undefined,\r\n fileName: string | undefined,\r\n invertY: boolean | undefined,\r\n toArrayBuffer: true,\r\n quality?: number\r\n): Promise<ArrayBuffer>;\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType?: string,\r\n fileName?: string,\r\n invertY?: boolean,\r\n toArrayBuffer?: boolean,\r\n quality?: number\r\n): Promise<string>;\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolve to the final data\r\n */\r\nexport async function DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): Promise<string | ArrayBuffer> {\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n const blob = await EncodingHelper.EncodeImageAsync(data, width, height, mimeType, invertY, quality);\r\n\r\n if (fileName !== undefined) {\r\n Tools.DownloadBlob(blob, fileName);\r\n }\r\n\r\n if (blob.type !== mimeType) {\r\n Logger.Warn(`DumpData: The requested mimeType '${mimeType}' is not supported. The result has mimeType '${blob.type}' instead.`);\r\n }\r\n\r\n const buffer = await blob.arrayBuffer();\r\n\r\n if (toArrayBuffer) {\r\n return buffer;\r\n }\r\n\r\n return `data:${mimeType};base64,${EncodeArrayBufferToBase64(buffer)}`;\r\n}\r\n\r\n/**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName The name of the file to download. If present, the result will automatically be downloaded. If not defined, and `successCallback` is also not defined, the result will automatically be downloaded with an auto-generated file name.\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\nexport function DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n): void {\r\n // For back-compat: if no fileName and no callback, force download the result\r\n if (fileName === undefined && !successCallback) {\r\n fileName = \"\";\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n DumpDataAsync(width, height, data, mimeType, fileName, invertY, toArrayBuffer, quality)\r\n // eslint-disable-next-line github/no-then\r\n .then((result) => {\r\n if (successCallback) {\r\n successCallback(result);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Dispose the dump tools associated resources\r\n */\r\nexport function Dispose() {\r\n if (!ResourcesPromise) {\r\n return;\r\n }\r\n\r\n // in cases where the engine is not yet created, we need to wait for it to dispose it\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n ResourcesPromise?.then((resources) => {\r\n if (resources.canvas instanceof HTMLCanvasElement) {\r\n resources.canvas.remove();\r\n }\r\n if (resources.dumpEngine) {\r\n resources.dumpEngine.engine.dispose();\r\n resources.dumpEngine.renderer.dispose();\r\n resources.dumpEngine.wrapper.dispose();\r\n }\r\n });\r\n\r\n ResourcesPromise = null;\r\n}\r\n\r\n/**\r\n * Object containing a set of static utilities functions to dump data from a canvas\r\n * @deprecated use functions\r\n */\r\nexport const DumpTools = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpData,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpDataAsync,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n DumpFramebuffer,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Dispose,\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst InitSideEffects = () => {\r\n // References the dependencies.\r\n Tools.DumpData = DumpData;\r\n Tools.DumpDataAsync = DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpFramebuffer;\r\n};\r\n\r\nInitSideEffects();\r\n"]}
package/Misc/index.d.ts CHANGED
@@ -67,8 +67,7 @@ export * from "./error.js";
67
67
  export * from "./snapshotRenderingHelper.js";
68
68
  export * from "./observableCoroutine.js";
69
69
  export * from "./copyTextureToTexture.js";
70
- /** @deprecated Use individual exports */
71
- export { DumpTools } from "./dumpTools.js";
70
+ export { DumpTools, EncodeImageAsync } from "./dumpTools.js";
72
71
  export * from "./greasedLineTools.js";
73
72
  export * from "./equirectangularCapture.js";
74
73
  export * from "./decorators.serialization.js";
package/Misc/index.js CHANGED
@@ -70,8 +70,7 @@ export * from "./snapshotRenderingHelper.js";
70
70
  // eslint-disable-next-line import/export
71
71
  export * from "./observableCoroutine.js";
72
72
  export * from "./copyTextureToTexture.js";
73
- /** @deprecated Use individual exports */
74
- export { DumpTools } from "./dumpTools.js";
73
+ export { DumpTools, EncodeImageAsync } from "./dumpTools.js";
75
74
  export * from "./greasedLineTools.js";
76
75
  export * from "./equirectangularCapture.js";
77
76
  export * from "./decorators.serialization.js";
package/Misc/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,c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ACxB,cAAc,2BAA2B,CAAC;AAC1C,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AAEvB,mBAAmB;AACnB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AAEnD,uBAAuB;AACvB,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAE7D,cAAc,mBAAmB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\n// loaded from texture tools\r\nexport * from \"../Shaders/lodCube.fragment\";\r\nexport * from \"../Shaders/lod.fragment\";\r\nexport * from \"../ShadersWGSL/lodCube.fragment\";\r\nexport * from \"../ShadersWGSL/lod.fragment\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./deepMerger\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\nexport * from \"./snapshotRenderingHelper\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\n/** @deprecated Use individual exports */\r\nexport { DumpTools } from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\nexport * from \"./bitArray\";\r\nexport * from \"./urlTools\";\r\nexport * from \"./lazy\";\r\n\r\n// RGBDTextureTools\r\nexport * from \"../Shaders/rgbdDecode.fragment\";\r\nexport * from \"../Shaders/rgbdEncode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdDecode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdEncode.fragment\";\r\n\r\n// CopyTextureToTexture\r\nexport * from \"../Shaders/copyTextureToTexture.fragment\";\r\nexport * from \"../ShadersWGSL/copyTextureToTexture.fragment\";\r\n\r\nexport * from \"./tools.internals\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,4BAA4B;AAC5B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc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Ac,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,oCAAoC,CAAC;AAEnD,uBAAuB;AACvB,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAE7D,cAAc,mBAAmB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\n// loaded from texture tools\r\nexport * from \"../Shaders/lodCube.fragment\";\r\nexport * from \"../Shaders/lod.fragment\";\r\nexport * from \"../ShadersWGSL/lodCube.fragment\";\r\nexport * from \"../ShadersWGSL/lod.fragment\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./deepMerger\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\nexport * from \"./snapshotRenderingHelper\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport { DumpTools, EncodeImageAsync } from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\nexport * from \"./bitArray\";\r\nexport * from \"./urlTools\";\r\nexport * from \"./lazy\";\r\n\r\n// RGBDTextureTools\r\nexport * from \"../Shaders/rgbdDecode.fragment\";\r\nexport * from \"../Shaders/rgbdEncode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdDecode.fragment\";\r\nexport * from \"../ShadersWGSL/rgbdEncode.fragment\";\r\n\r\n// CopyTextureToTexture\r\nexport * from \"../Shaders/copyTextureToTexture.fragment\";\r\nexport * from \"../ShadersWGSL/copyTextureToTexture.fragment\";\r\n\r\nexport * from \"./tools.internals\";\r\n"]}
@@ -77,11 +77,11 @@ export class BoxShapeBlock extends NodeParticleBlock {
77
77
  const randX = RandomRange(direction1.x, direction2.x);
78
78
  const randY = RandomRange(direction1.y, direction2.y);
79
79
  const randZ = RandomRange(direction1.z, direction2.z);
80
- if (state.isEmitterTransformNode) {
81
- Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
80
+ if (system.isLocal) {
81
+ particle.direction.copyFromFloats(randX, randY, randZ);
82
82
  }
83
83
  else {
84
- particle.direction.copyFromFloats(randX, randY, randZ);
84
+ Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
85
85
  }
86
86
  particle._initialDirection = particle.direction.clone();
87
87
  };
@@ -93,13 +93,13 @@ export class BoxShapeBlock extends NodeParticleBlock {
93
93
  const randX = RandomRange(minEmitBox.x, maxEmitBox.x);
94
94
  const randY = RandomRange(minEmitBox.y, maxEmitBox.y);
95
95
  const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);
96
- if (state.isEmitterTransformNode) {
97
- Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
98
- }
99
- else {
96
+ if (system.isLocal) {
100
97
  particle.position.copyFromFloats(randX, randY, randZ);
101
98
  particle.position.addInPlace(state.emitterPosition);
102
99
  }
100
+ else {
101
+ Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
102
+ }
103
103
  };
104
104
  this.output._storedValue = system;
105
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAG/D;;GAEG;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AAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\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(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
1
+ {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAG/D;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CA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AC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\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(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
@@ -0,0 +1,57 @@
1
+ import type { IShapeBlock } from "./IShapeBlock.js";
2
+ import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
3
+ import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
4
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
+ /**
6
+ * Block used to provide a flow of particles emitted from a cone shape.
7
+ */
8
+ export declare class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {
9
+ /**
10
+ * Create a new ConeShapeBlock
11
+ * @param name defines the block name
12
+ */
13
+ constructor(name: string);
14
+ /**
15
+ * Gets the current class name
16
+ * @returns the class name
17
+ */
18
+ getClassName(): string;
19
+ /**
20
+ * Gets the particle input component
21
+ */
22
+ get particle(): NodeParticleConnectionPoint;
23
+ /**
24
+ * Gets the radius input component
25
+ */
26
+ get radius(): NodeParticleConnectionPoint;
27
+ /**
28
+ * Gets the angle input component
29
+ */
30
+ get angle(): NodeParticleConnectionPoint;
31
+ /**
32
+ * Gets the radiusRange input component
33
+ */
34
+ get radiusRange(): NodeParticleConnectionPoint;
35
+ /**
36
+ * Gets the heightRange input component
37
+ */
38
+ get heightRange(): NodeParticleConnectionPoint;
39
+ /**
40
+ * Gets the emitFromSpawnPointOnly input component
41
+ */
42
+ get emitFromSpawnPointOnly(): NodeParticleConnectionPoint;
43
+ /**
44
+ * Gets the directionRandomizer input component
45
+ */
46
+ get directionRandomizer(): NodeParticleConnectionPoint;
47
+ /**
48
+ * Gets the output component
49
+ */
50
+ get output(): NodeParticleConnectionPoint;
51
+ /**
52
+ * Builds the block
53
+ * @param state defines the build state
54
+ */
55
+ _build(state: NodeParticleBuildState): void;
56
+ private _calculateHeight;
57
+ }
@@ -0,0 +1,163 @@
1
+ import { RegisterClass } from "../../../../Misc/typeStore.js";
2
+ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
3
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
4
+ import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
5
+ import { TmpVectors, Vector3 } from "../../../../Maths/math.vector.js";
6
+ /**
7
+ * Block used to provide a flow of particles emitted from a cone shape.
8
+ */
9
+ export class ConeShapeBlock extends NodeParticleBlock {
10
+ /**
11
+ * Create a new ConeShapeBlock
12
+ * @param name defines the block name
13
+ */
14
+ constructor(name) {
15
+ super(name);
16
+ this.registerInput("particle", NodeParticleBlockConnectionPointTypes.Particle);
17
+ this.registerInput("radius", NodeParticleBlockConnectionPointTypes.Float, true, 1);
18
+ this.registerInput("angle", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);
19
+ this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1);
20
+ this.registerInput("heightRange", NodeParticleBlockConnectionPointTypes.Float, true, 1);
21
+ this.registerInput("emitFromSpawnPointOnly", NodeParticleBlockConnectionPointTypes.Int, true, 0);
22
+ this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0);
23
+ this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
24
+ }
25
+ /**
26
+ * Gets the current class name
27
+ * @returns the class name
28
+ */
29
+ getClassName() {
30
+ return "ConeShapeBlock";
31
+ }
32
+ /**
33
+ * Gets the particle input component
34
+ */
35
+ get particle() {
36
+ return this._inputs[0];
37
+ }
38
+ /**
39
+ * Gets the radius input component
40
+ */
41
+ get radius() {
42
+ return this._inputs[1];
43
+ }
44
+ /**
45
+ * Gets the angle input component
46
+ */
47
+ get angle() {
48
+ return this._inputs[2];
49
+ }
50
+ /**
51
+ * Gets the radiusRange input component
52
+ */
53
+ get radiusRange() {
54
+ return this._inputs[3];
55
+ }
56
+ /**
57
+ * Gets the heightRange input component
58
+ */
59
+ get heightRange() {
60
+ return this._inputs[4];
61
+ }
62
+ /**
63
+ * Gets the emitFromSpawnPointOnly input component
64
+ */
65
+ get emitFromSpawnPointOnly() {
66
+ return this._inputs[5];
67
+ }
68
+ /**
69
+ * Gets the directionRandomizer input component
70
+ */
71
+ get directionRandomizer() {
72
+ return this._inputs[6];
73
+ }
74
+ /**
75
+ * Gets the output component
76
+ */
77
+ get output() {
78
+ return this._outputs[0];
79
+ }
80
+ /**
81
+ * Builds the block
82
+ * @param state defines the build state
83
+ */
84
+ _build(state) {
85
+ const system = this.particle.getConnectedValue(state);
86
+ system._directionCreation.process = (particle) => {
87
+ state.particleContext = particle;
88
+ state.systemContext = system;
89
+ // Connected values
90
+ let directionRandomizer = this.directionRandomizer.getConnectedValue(state);
91
+ directionRandomizer = Math.max(0, Math.min(directionRandomizer, 1));
92
+ // Calculate create direction logic
93
+ if (system.isLocal) {
94
+ TmpVectors.Vector3[0].copyFrom(particle.position).normalize();
95
+ }
96
+ else {
97
+ particle.position.subtractToRef(state.emitterWorldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();
98
+ }
99
+ const randX = RandomRange(0, directionRandomizer);
100
+ const randY = RandomRange(0, directionRandomizer);
101
+ const randZ = RandomRange(0, directionRandomizer);
102
+ const directionToUpdate = new Vector3();
103
+ directionToUpdate.x = TmpVectors.Vector3[0].x + randX;
104
+ directionToUpdate.y = TmpVectors.Vector3[0].y + randY;
105
+ directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;
106
+ directionToUpdate.normalize();
107
+ if (system.isLocal) {
108
+ particle.direction.copyFromFloats(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z);
109
+ }
110
+ else {
111
+ Vector3.TransformNormalFromFloatsToRef(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z, state.emitterWorldMatrix, particle.direction);
112
+ }
113
+ particle._initialDirection = particle.direction.clone();
114
+ };
115
+ system._positionCreation.process = (particle) => {
116
+ state.particleContext = particle;
117
+ state.systemContext = system;
118
+ // Connected values
119
+ const radius = this.radius.getConnectedValue(state);
120
+ const angle = this.angle.getConnectedValue(state);
121
+ let radiusRange = this.radiusRange.getConnectedValue(state);
122
+ radiusRange = Math.max(0, Math.min(radiusRange, 1));
123
+ let heightRange = this.heightRange.getConnectedValue(state);
124
+ heightRange = Math.max(0, Math.min(heightRange, 1));
125
+ const emitFromSpawnPointOnly = this.emitFromSpawnPointOnly.getConnectedValue(state) !== 0;
126
+ // Calculate position creation logic
127
+ let h;
128
+ if (!emitFromSpawnPointOnly) {
129
+ h = RandomRange(0, heightRange);
130
+ // Better distribution in a cone at normal angles.
131
+ h = 1 - h * h;
132
+ }
133
+ else {
134
+ h = 0.0001;
135
+ }
136
+ let newRadius = radius - RandomRange(0, radius * radiusRange);
137
+ newRadius = newRadius * h;
138
+ const s = RandomRange(0, Math.PI * 2);
139
+ const height = this._calculateHeight(angle, radius);
140
+ const randX = newRadius * Math.sin(s);
141
+ const randZ = newRadius * Math.cos(s);
142
+ const randY = h * height;
143
+ if (system.isLocal) {
144
+ particle.position.copyFromFloats(randX, randY, randZ);
145
+ particle.position.addInPlace(state.emitterPosition);
146
+ }
147
+ else {
148
+ Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
149
+ }
150
+ };
151
+ this.output._storedValue = system;
152
+ }
153
+ _calculateHeight(angle, radius) {
154
+ if (angle !== 0) {
155
+ return radius / Math.tan(angle / 2);
156
+ }
157
+ else {
158
+ return 1;
159
+ }
160
+ }
161
+ }
162
+ RegisterClass("BABYLON.ConeShapeBlock", ConeShapeBlock);
163
+ //# sourceMappingURL=coneShapeBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coneShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/coneShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,yCAA+B;AAE7D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,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,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;IAEO,gBAAgB,CAAC,KAAa,EAAE,MAAc;QAClD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACd,OAAO,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { IShapeBlock } from \"./IShapeBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cone shape.\r\n */\r\nexport class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new ConeShapeBlock\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(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"heightRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"emitFromSpawnPointOnly\", NodeParticleBlockConnectionPointTypes.Int, true, 0);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\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 \"ConeShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the heightRange input component\r\n */\r\n public get heightRange(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the emitFromSpawnPointOnly input component\r\n */\r\n public get emitFromSpawnPointOnly(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // Connected values\r\n let directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n directionRandomizer = Math.max(0, Math.min(directionRandomizer, 1));\r\n\r\n // Calculate create direction logic\r\n if (system.isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle.position).normalize();\r\n } else {\r\n particle.position.subtractToRef(state.emitterWorldMatrix!.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n const directionToUpdate = new Vector3();\r\n directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // Connected values\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const angle = this.angle.getConnectedValue(state) as number;\r\n let radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n radiusRange = Math.max(0, Math.min(radiusRange, 1));\r\n let heightRange = this.heightRange.getConnectedValue(state) as number;\r\n heightRange = Math.max(0, Math.min(heightRange, 1));\r\n const emitFromSpawnPointOnly = (this.emitFromSpawnPointOnly.getConnectedValue(state) as number) !== 0;\r\n\r\n // Calculate position creation logic\r\n let h: number;\r\n if (!emitFromSpawnPointOnly) {\r\n h = RandomRange(0, heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n\r\n let newRadius = radius - RandomRange(0, radius * radiusRange);\r\n newRadius = newRadius * h;\r\n\r\n const s = RandomRange(0, Math.PI * 2);\r\n const height = this._calculateHeight(angle, radius);\r\n\r\n const randX = newRadius * Math.sin(s);\r\n const randZ = newRadius * Math.cos(s);\r\n const randY = h * height;\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n private _calculateHeight(angle: number, radius: number): number {\r\n if (angle !== 0) {\r\n return radius / Math.tan(angle / 2);\r\n } else {\r\n return 1;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConeShapeBlock\", ConeShapeBlock);\r\n"]}
@@ -39,6 +39,10 @@ export declare class CreateParticleBlock extends NodeParticleBlock {
39
39
  * Gets the angle input component
40
40
  */
41
41
  get angle(): NodeParticleConnectionPoint;
42
+ /**
43
+ * Gets the size component
44
+ */
45
+ get size(): NodeParticleConnectionPoint;
42
46
  /**
43
47
  * Gets the particle output component
44
48
  */
@@ -22,6 +22,7 @@ export class CreateParticleBlock extends NodeParticleBlock {
22
22
  this.registerInput("colorDead", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(0, 0, 0, 0));
23
23
  this.registerInput("scale", NodeParticleBlockConnectionPointTypes.Vector2, true, new Vector2(1, 1));
24
24
  this.registerInput("angle", NodeParticleBlockConnectionPointTypes.Float, true, 0);
25
+ this.registerInput("size", NodeParticleBlockConnectionPointTypes.Float, true, 1);
25
26
  this.registerOutput("particle", NodeParticleBlockConnectionPointTypes.Particle);
26
27
  this.scale.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);
27
28
  }
@@ -68,6 +69,12 @@ export class CreateParticleBlock extends NodeParticleBlock {
68
69
  get angle() {
69
70
  return this._inputs[5];
70
71
  }
72
+ /**
73
+ * Gets the size component
74
+ */
75
+ get size() {
76
+ return this._inputs[6];
77
+ }
71
78
  /**
72
79
  * Gets the particle output component
73
80
  */
@@ -88,7 +95,10 @@ export class CreateParticleBlock extends NodeParticleBlock {
88
95
  };
89
96
  system._colorCreation.process = (particle) => {
90
97
  state.particleContext = particle;
91
- particle.color.copyFrom(this.color.getConnectedValue(state));
98
+ const color = this.color.getConnectedValue(state);
99
+ if (color !== undefined) {
100
+ particle.color.copyFrom(color);
101
+ }
92
102
  };
93
103
  system._colorDeadCreation.process = (particle) => {
94
104
  state.particleContext = particle;
@@ -99,7 +109,13 @@ export class CreateParticleBlock extends NodeParticleBlock {
99
109
  };
100
110
  system._sizeCreation.process = (particle) => {
101
111
  state.particleContext = particle;
102
- particle.size = 1;
112
+ const size = this.size.getConnectedValue(state);
113
+ if (size !== undefined) {
114
+ particle.size = size;
115
+ }
116
+ else {
117
+ particle.size = 1.0;
118
+ }
103
119
  const scale = this.scale.getConnectedValue(state);
104
120
  if (scale.x !== undefined) {
105
121
  particle.scale.x = scale.x;
@@ -1 +1 @@
1
- {"version":3,"file":"createParticleBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/createParticleBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,mCAAsC;AAQ/D,OAAO,EAAE,MAAM,EA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C,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;gBACzB,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;YAC7B,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,QAAkB,EAAE,EAAE;YACnD,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YACjC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACzD,CAAC,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,MAAM,CAAC;IACxC,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { ParticleSystem } from \"core/Particles/particleSystem\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nimport type { _IExecutionQueueItem } from \"core/Particles/Queue/executionQueue\";\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nimport { _RemoveFromQueue } from \"core/Particles/Queue/executionQueue\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { PointParticleEmitter } from \"core/Particles/EmitterTypes/pointParticleEmitter\";\r\n\r\nconst ColorDiff = new Color4();\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class CreateParticleBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new CreateParticleBlock\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(\"emitPower\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"lifeTime\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"color\", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(1, 1, 1, 1));\r\n this.registerInput(\"colorDead\", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(0, 0, 0, 0));\r\n this.registerInput(\"scale\", NodeParticleBlockConnectionPointTypes.Vector2, true, new Vector2(1, 1));\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n\r\n this.scale.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);\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 \"CreateParticleBlock\";\r\n }\r\n\r\n /**\r\n * Gets the emitPower input component\r\n */\r\n public get emitPower(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the lifeTime input component\r\n */\r\n public get lifeTime(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the color input component\r\n */\r\n public get color(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the color dead input component\r\n */\r\n public get colorDead(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get scale(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the particle output component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = new ParticleSystem(this.name, state.capacity, state.scene, null, false, undefined, true);\r\n system.particleEmitterType = new PointParticleEmitter();\r\n\r\n // Creation\r\n system._lifeTimeCreation.process = (particle: Particle, system: ThinParticleSystem) => {\r\n state.particleContext = particle;\r\n particle.lifeTime = this.lifeTime.getConnectedValue(state);\r\n system._emitPower = this.emitPower.getConnectedValue(state);\r\n };\r\n\r\n system._colorCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.color.copyFrom(this.color.getConnectedValue(state));\r\n };\r\n\r\n system._colorDeadCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.colorDead.copyFrom(this.colorDead.getConnectedValue(state));\r\n particle.initialColor.copyFrom(particle.color);\r\n particle.colorDead.subtractToRef(particle.initialColor, ColorDiff);\r\n ColorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);\r\n };\r\n\r\n system._sizeCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.size = 1;\r\n\r\n const scale = this.scale.getConnectedValue(state);\r\n\r\n if (scale.x !== undefined) {\r\n particle.scale.x = scale.x;\r\n particle.scale.y = scale.y;\r\n } else {\r\n particle.scale.x = scale;\r\n particle.scale.y = scale;\r\n }\r\n };\r\n\r\n system._angleCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.angle = this.angle.getConnectedValue(state);\r\n };\r\n\r\n this.particle._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CreateParticleBlock\", CreateParticleBlock);\r\n"]}
1
+ {"version":3,"file":"createParticleBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/createParticleBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,m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BlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { ParticleSystem } from \"core/Particles/particleSystem\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nimport type { _IExecutionQueueItem } from \"core/Particles/Queue/executionQueue\";\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nimport { _RemoveFromQueue } from \"core/Particles/Queue/executionQueue\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { PointParticleEmitter } from \"core/Particles/EmitterTypes/pointParticleEmitter\";\r\n\r\nconst ColorDiff = new Color4();\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class CreateParticleBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new CreateParticleBlock\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(\"emitPower\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"lifeTime\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"color\", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(1, 1, 1, 1));\r\n this.registerInput(\"colorDead\", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(0, 0, 0, 0));\r\n this.registerInput(\"scale\", NodeParticleBlockConnectionPointTypes.Vector2, true, new Vector2(1, 1));\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerInput(\"size\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerOutput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n\r\n this.scale.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);\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 \"CreateParticleBlock\";\r\n }\r\n\r\n /**\r\n * Gets the emitPower input component\r\n */\r\n public get emitPower(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the lifeTime input component\r\n */\r\n public get lifeTime(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the color input component\r\n */\r\n public get color(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the color dead input component\r\n */\r\n public get colorDead(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get scale(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the size component\r\n */\r\n public get size(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\r\n }\r\n\r\n /**\r\n * Gets the particle output component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = new ParticleSystem(this.name, state.capacity, state.scene, null, false, undefined, true);\r\n system.particleEmitterType = new PointParticleEmitter();\r\n\r\n // Creation\r\n system._lifeTimeCreation.process = (particle: Particle, system: ThinParticleSystem) => {\r\n state.particleContext = particle;\r\n particle.lifeTime = this.lifeTime.getConnectedValue(state);\r\n system._emitPower = this.emitPower.getConnectedValue(state);\r\n };\r\n\r\n system._colorCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n\r\n const color = this.color.getConnectedValue(state);\r\n if (color !== undefined) {\r\n particle.color.copyFrom(color);\r\n }\r\n };\r\n\r\n system._colorDeadCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n\r\n particle.colorDead.copyFrom(this.colorDead.getConnectedValue(state));\r\n particle.initialColor.copyFrom(particle.color);\r\n particle.colorDead.subtractToRef(particle.initialColor, ColorDiff);\r\n ColorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);\r\n };\r\n\r\n system._sizeCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n\r\n const size = this.size.getConnectedValue(state);\r\n if (size !== undefined) {\r\n particle.size = size;\r\n } else {\r\n particle.size = 1.0;\r\n }\r\n\r\n const scale = this.scale.getConnectedValue(state);\r\n if (scale.x !== undefined) {\r\n particle.scale.x = scale.x;\r\n particle.scale.y = scale.y;\r\n } else {\r\n particle.scale.x = scale;\r\n particle.scale.y = scale;\r\n }\r\n };\r\n\r\n system._angleCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n\r\n particle.angle = this.angle.getConnectedValue(state);\r\n };\r\n\r\n this.particle._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CreateParticleBlock\", CreateParticleBlock);\r\n"]}