@babylonjs/core 5.35.1 → 5.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/Audio/sound.d.ts +5 -0
  2. package/Audio/sound.js +7 -0
  3. package/Audio/sound.js.map +1 -1
  4. package/Cameras/arcRotateCamera.d.ts +2 -2
  5. package/Cameras/arcRotateCamera.js.map +1 -1
  6. package/Debug/physicsViewer.d.ts +4 -3
  7. package/Debug/physicsViewer.js +2 -2
  8. package/Debug/physicsViewer.js.map +1 -1
  9. package/Engines/Extensions/engine.views.d.ts +4 -0
  10. package/Engines/Extensions/engine.views.js +61 -42
  11. package/Engines/Extensions/engine.views.js.map +1 -1
  12. package/Engines/thinEngine.js +2 -2
  13. package/Engines/thinEngine.js.map +1 -1
  14. package/Gizmos/planeRotationGizmo.js +3 -1
  15. package/Gizmos/planeRotationGizmo.js.map +1 -1
  16. package/Inputs/scene.inputManager.js +4 -4
  17. package/Inputs/scene.inputManager.js.map +1 -1
  18. package/Loading/Plugins/babylonFileLoader.js +3 -3
  19. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  20. package/Materials/Node/Blocks/Dual/currentScreenBlock.js +2 -3
  21. package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
  22. package/Materials/Node/Blocks/Dual/fogBlock.js +4 -4
  23. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  24. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +2 -2
  25. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
  26. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +2 -3
  27. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  28. package/Materials/Node/Blocks/Dual/textureBlock.js +4 -5
  29. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  30. package/Materials/Node/Blocks/Fragment/TBNBlock.js +2 -2
  31. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  32. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -2
  33. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  34. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +2 -2
  35. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
  36. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +4 -0
  37. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +35 -19
  38. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  39. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +2 -2
  40. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
  41. package/Materials/Node/Blocks/Fragment/shadowMapBlock.js +2 -2
  42. package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
  43. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +2 -2
  44. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  45. package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -2
  46. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  47. package/Materials/Node/Blocks/Particle/particleTextureBlock.js +2 -3
  48. package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
  49. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +2 -2
  50. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  51. package/Materials/Node/Blocks/gradientBlock.js +7 -6
  52. package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
  53. package/Materials/Node/Blocks/normalBlendBlock.js +10 -8
  54. package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
  55. package/Materials/Node/Blocks/randomNumberBlock.js +6 -5
  56. package/Materials/Node/Blocks/randomNumberBlock.js.map +1 -1
  57. package/Materials/Node/Blocks/reflectBlock.js +10 -8
  58. package/Materials/Node/Blocks/reflectBlock.js.map +1 -1
  59. package/Materials/Node/Blocks/refractBlock.js +10 -8
  60. package/Materials/Node/Blocks/refractBlock.js.map +1 -1
  61. package/Materials/Node/Blocks/triPlanarBlock.js +4 -4
  62. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  63. package/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes.d.ts +3 -1
  64. package/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes.js +2 -0
  65. package/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes.js.map +1 -1
  66. package/Materials/Node/nodeMaterial.d.ts +19 -1
  67. package/Materials/Node/nodeMaterial.js +30 -0
  68. package/Materials/Node/nodeMaterial.js.map +1 -1
  69. package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +5 -0
  70. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +13 -0
  71. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  72. package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +2 -8
  73. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  74. package/Materials/Textures/baseTexture.d.ts +2 -1
  75. package/Materials/Textures/baseTexture.js +3 -2
  76. package/Materials/Textures/baseTexture.js.map +1 -1
  77. package/Materials/Textures/internalTexture.d.ts +2 -0
  78. package/Materials/Textures/internalTexture.js +4 -0
  79. package/Materials/Textures/internalTexture.js.map +1 -1
  80. package/Materials/Textures/mirrorTexture.js +0 -2
  81. package/Materials/Textures/mirrorTexture.js.map +1 -1
  82. package/Materials/Textures/texture.d.ts +2 -0
  83. package/Materials/Textures/texture.js +35 -7
  84. package/Materials/Textures/texture.js.map +1 -1
  85. package/Materials/Textures/videoTexture.d.ts +5 -0
  86. package/Materials/Textures/videoTexture.js +27 -23
  87. package/Materials/Textures/videoTexture.js.map +1 -1
  88. package/Materials/material.js +1 -1
  89. package/Materials/material.js.map +1 -1
  90. package/Materials/materialHelper.js +3 -0
  91. package/Materials/materialHelper.js.map +1 -1
  92. package/Meshes/abstractMesh.d.ts +4 -4
  93. package/Meshes/abstractMesh.js +4 -4
  94. package/Meshes/abstractMesh.js.map +1 -1
  95. package/Meshes/mesh.d.ts +2 -2
  96. package/Meshes/mesh.js +1 -1
  97. package/Meshes/mesh.js.map +1 -1
  98. package/Misc/copyTextureToTexture.d.ts +9 -2
  99. package/Misc/copyTextureToTexture.js +23 -1
  100. package/Misc/copyTextureToTexture.js.map +1 -1
  101. package/Misc/virtualJoystick.d.ts +1 -0
  102. package/Misc/virtualJoystick.js +6 -0
  103. package/Misc/virtualJoystick.js.map +1 -1
  104. package/Particles/IParticleSystem.d.ts +15 -1
  105. package/Particles/IParticleSystem.js.map +1 -1
  106. package/Particles/gpuParticleSystem.d.ts +24 -2
  107. package/Particles/gpuParticleSystem.js +98 -43
  108. package/Particles/gpuParticleSystem.js.map +1 -1
  109. package/Particles/particleSystem.d.ts +6 -1
  110. package/Particles/particleSystem.js +7 -2
  111. package/Particles/particleSystem.js.map +1 -1
  112. package/Physics/IPhysicsEngine.d.ts +8 -108
  113. package/Physics/IPhysicsEngine.js.map +1 -1
  114. package/Physics/Plugins/ammoJSPlugin.d.ts +1 -389
  115. package/Physics/Plugins/ammoJSPlugin.js +2 -1414
  116. package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
  117. package/Physics/Plugins/cannonJSPlugin.d.ts +1 -75
  118. package/Physics/Plugins/cannonJSPlugin.js +2 -664
  119. package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
  120. package/Physics/Plugins/oimoJSPlugin.d.ts +1 -59
  121. package/Physics/Plugins/oimoJSPlugin.js +2 -432
  122. package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
  123. package/Physics/index.d.ts +3 -6
  124. package/Physics/index.js +3 -6
  125. package/Physics/index.js.map +1 -1
  126. package/Physics/physicsEngine.d.ts +1 -135
  127. package/Physics/physicsEngine.js +2 -221
  128. package/Physics/physicsEngine.js.map +1 -1
  129. package/Physics/physicsEngineComponent.d.ts +7 -42
  130. package/Physics/physicsEngineComponent.js +11 -71
  131. package/Physics/physicsEngineComponent.js.map +1 -1
  132. package/Physics/physicsHelper.d.ts +1 -411
  133. package/Physics/physicsHelper.js +2 -708
  134. package/Physics/physicsHelper.js.map +1 -1
  135. package/Physics/physicsImpostor.d.ts +1 -640
  136. package/Physics/physicsImpostor.js +2 -1004
  137. package/Physics/physicsImpostor.js.map +1 -1
  138. package/Physics/physicsJoint.d.ts +1 -275
  139. package/Physics/physicsJoint.js +2 -222
  140. package/Physics/physicsJoint.js.map +1 -1
  141. package/Physics/v1/IPhysicsEnginePlugin.d.ts +73 -0
  142. package/Physics/v1/IPhysicsEnginePlugin.js +2 -0
  143. package/Physics/v1/IPhysicsEnginePlugin.js.map +1 -0
  144. package/Physics/v1/Plugins/ammoJSPlugin.d.ts +401 -0
  145. package/Physics/v1/Plugins/ammoJSPlugin.js +1431 -0
  146. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -0
  147. package/Physics/v1/Plugins/cannonJSPlugin.d.ts +87 -0
  148. package/Physics/v1/Plugins/cannonJSPlugin.js +683 -0
  149. package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -0
  150. package/Physics/{Plugins → v1/Plugins}/index.d.ts +0 -0
  151. package/Physics/{Plugins → v1/Plugins}/index.js +0 -0
  152. package/Physics/v1/Plugins/index.js.map +1 -0
  153. package/Physics/v1/Plugins/oimoJSPlugin.d.ts +71 -0
  154. package/Physics/v1/Plugins/oimoJSPlugin.js +450 -0
  155. package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -0
  156. package/Physics/v1/index.d.ts +7 -0
  157. package/Physics/v1/index.js +9 -0
  158. package/Physics/v1/index.js.map +1 -0
  159. package/Physics/v1/physicsEngine.d.ts +147 -0
  160. package/Physics/v1/physicsEngine.js +237 -0
  161. package/Physics/v1/physicsEngine.js.map +1 -0
  162. package/Physics/v1/physicsEngineComponent.d.ts +45 -0
  163. package/Physics/v1/physicsEngineComponent.js +70 -0
  164. package/Physics/v1/physicsEngineComponent.js.map +1 -0
  165. package/Physics/v1/physicsHelper.d.ts +411 -0
  166. package/Physics/v1/physicsHelper.js +709 -0
  167. package/Physics/v1/physicsHelper.js.map +1 -0
  168. package/Physics/v1/physicsImpostor.d.ts +636 -0
  169. package/Physics/v1/physicsImpostor.js +1001 -0
  170. package/Physics/v1/physicsImpostor.js.map +1 -0
  171. package/Physics/v1/physicsJoint.d.ts +275 -0
  172. package/Physics/v1/physicsJoint.js +223 -0
  173. package/Physics/v1/physicsJoint.js.map +1 -0
  174. package/Physics/v2/IPhysicsEnginePlugin.d.ts +170 -0
  175. package/Physics/v2/IPhysicsEnginePlugin.js +47 -0
  176. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -0
  177. package/Physics/v2/Plugins/index.d.ts +0 -0
  178. package/Physics/v2/Plugins/index.js +2 -0
  179. package/Physics/v2/Plugins/index.js.map +1 -0
  180. package/Physics/v2/index.d.ts +6 -0
  181. package/Physics/v2/index.js +8 -0
  182. package/Physics/v2/index.js.map +1 -0
  183. package/Physics/v2/physicsAggregate.d.ts +114 -0
  184. package/Physics/v2/physicsAggregate.js +46 -0
  185. package/Physics/v2/physicsAggregate.js.map +1 -0
  186. package/Physics/v2/physicsBody.d.ts +109 -0
  187. package/Physics/v2/physicsBody.js +158 -0
  188. package/Physics/v2/physicsBody.js.map +1 -0
  189. package/Physics/v2/physicsConstraint.d.ts +184 -0
  190. package/Physics/v2/physicsConstraint.js +257 -0
  191. package/Physics/v2/physicsConstraint.js.map +1 -0
  192. package/Physics/v2/physicsEngine.d.ts +103 -0
  193. package/Physics/v2/physicsEngine.js +146 -0
  194. package/Physics/v2/physicsEngine.js.map +1 -0
  195. package/Physics/v2/physicsEngineComponent.d.ts +31 -0
  196. package/Physics/v2/physicsEngineComponent.js +50 -0
  197. package/Physics/v2/physicsEngineComponent.js.map +1 -0
  198. package/Physics/v2/physicsMaterial.d.ts +45 -0
  199. package/Physics/v2/physicsMaterial.js +67 -0
  200. package/Physics/v2/physicsMaterial.js.map +1 -0
  201. package/Physics/v2/physicsShape.d.ts +182 -0
  202. package/Physics/v2/physicsShape.js +229 -0
  203. package/Physics/v2/physicsShape.js.map +1 -0
  204. package/PostProcesses/postProcess.d.ts +3 -1
  205. package/PostProcesses/postProcess.js +4 -1
  206. package/PostProcesses/postProcess.js.map +1 -1
  207. package/Rendering/fluidRenderer/fluidRenderer.d.ts +153 -0
  208. package/Rendering/fluidRenderer/fluidRenderer.js +410 -0
  209. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -0
  210. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.d.ts +13 -0
  211. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +31 -0
  212. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -0
  213. package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +81 -0
  214. package/Rendering/fluidRenderer/fluidRenderingObject.js +180 -0
  215. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -0
  216. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +63 -0
  217. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +130 -0
  218. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -0
  219. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +64 -0
  220. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +104 -0
  221. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -0
  222. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +234 -0
  223. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +690 -0
  224. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -0
  225. package/Rendering/fluidRenderer/fluidRenderingTextures.d.ts +56 -0
  226. package/Rendering/fluidRenderer/fluidRenderingTextures.js +261 -0
  227. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -0
  228. package/Rendering/fluidRenderer/index.d.ts +5 -0
  229. package/Rendering/fluidRenderer/index.js +6 -0
  230. package/Rendering/fluidRenderer/index.js.map +1 -0
  231. package/Rendering/index.d.ts +1 -0
  232. package/Rendering/index.js +2 -0
  233. package/Rendering/index.js.map +1 -1
  234. package/Shaders/copyTextureToTexture.fragment.js +4 -1
  235. package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
  236. package/Shaders/fluidRenderingBilateralBlur.fragment.d.ts +5 -0
  237. package/Shaders/fluidRenderingBilateralBlur.fragment.js +9 -0
  238. package/Shaders/fluidRenderingBilateralBlur.fragment.js.map +1 -0
  239. package/Shaders/fluidRenderingParticleDepth.fragment.d.ts +5 -0
  240. package/Shaders/fluidRenderingParticleDepth.fragment.js +17 -0
  241. package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -0
  242. package/Shaders/fluidRenderingParticleDepth.vertex.d.ts +5 -0
  243. package/Shaders/fluidRenderingParticleDepth.vertex.js +13 -0
  244. package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -0
  245. package/Shaders/fluidRenderingParticleDiffuse.fragment.d.ts +5 -0
  246. package/Shaders/fluidRenderingParticleDiffuse.fragment.js +9 -0
  247. package/Shaders/fluidRenderingParticleDiffuse.fragment.js.map +1 -0
  248. package/Shaders/fluidRenderingParticleDiffuse.vertex.d.ts +5 -0
  249. package/Shaders/fluidRenderingParticleDiffuse.vertex.js +4 -0
  250. package/Shaders/fluidRenderingParticleDiffuse.vertex.js.map +1 -0
  251. package/Shaders/fluidRenderingParticleThickness.fragment.d.ts +5 -0
  252. package/Shaders/fluidRenderingParticleThickness.fragment.js +9 -0
  253. package/Shaders/fluidRenderingParticleThickness.fragment.js.map +1 -0
  254. package/Shaders/fluidRenderingParticleThickness.vertex.d.ts +5 -0
  255. package/Shaders/fluidRenderingParticleThickness.vertex.js +9 -0
  256. package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -0
  257. package/Shaders/fluidRenderingRender.fragment.d.ts +5 -0
  258. package/Shaders/fluidRenderingRender.fragment.js +46 -0
  259. package/Shaders/fluidRenderingRender.fragment.js.map +1 -0
  260. package/Shaders/fluidRenderingStandardBlur.fragment.d.ts +5 -0
  261. package/Shaders/fluidRenderingStandardBlur.fragment.js +9 -0
  262. package/Shaders/fluidRenderingStandardBlur.fragment.js.map +1 -0
  263. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  264. package/XR/features/WebXRControllerPhysics.js +1 -1
  265. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  266. package/XR/features/WebXRHandTracking.js +1 -1
  267. package/XR/features/WebXRHandTracking.js.map +1 -1
  268. package/package.json +1 -1
  269. package/scene.js +6 -1
  270. package/scene.js.map +1 -1
  271. package/sceneComponent.d.ts +3 -0
  272. package/sceneComponent.js +3 -0
  273. package/sceneComponent.js.map +1 -1
  274. package/Physics/Plugins/index.js.map +0 -1
@@ -1,8 +1,9 @@
1
- import type { Nullable } from "../types";
1
+ import type { Immutable, Nullable } from "../types";
2
2
  import type { Color3Gradient, IValueGradient } from "../Misc/gradients";
3
3
  import { Observable } from "../Misc/observable";
4
4
  import { Matrix } from "../Maths/math.vector";
5
5
  import { Color4 } from "../Maths/math.color";
6
+ import { VertexBuffer } from "../Buffers/buffer";
6
7
  import type { IParticleSystem } from "./IParticleSystem";
7
8
  import { BaseParticleSystem } from "./baseParticleSystem";
8
9
  import type { IDisposable } from "../scene";
@@ -10,6 +11,7 @@ import type { Effect } from "../Materials/effect";
10
11
  import { RawTexture } from "../Materials/Textures/rawTexture";
11
12
  import type { IAnimatable } from "../Animations/animatable.interface";
12
13
  import { ThinEngine } from "../Engines/thinEngine";
14
+ import type { DataBuffer } from "../Buffers/dataBuffer";
13
15
  import { DrawWrapper } from "../Materials/drawWrapper";
14
16
  declare type Scene = import("../scene").Scene;
15
17
  import "../Shaders/gpuRenderParticles.fragment";
@@ -32,6 +34,7 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
32
34
  private _buffer0;
33
35
  private _buffer1;
34
36
  private _spriteBuffer;
37
+ private _renderVertexBuffers;
35
38
  private _targetIndex;
36
39
  private _sourceBuffer;
37
40
  private _targetBuffer;
@@ -44,6 +47,8 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
44
47
  _randomTexture: RawTexture;
45
48
  /** @internal */
46
49
  _randomTexture2: RawTexture;
50
+ /** Indicates that the update of particles is done in the animate function (and not in render). Default: false */
51
+ updateInAnimate: boolean;
47
52
  private _attributesStrideSize;
48
53
  private _cachedUpdateDefines;
49
54
  private _randomTextureSize;
@@ -84,6 +89,8 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
84
89
  * Specifies if the particles are updated in emitter local space or world space.
85
90
  */
86
91
  isLocal: boolean;
92
+ /** Indicates that the particle system is GPU based */
93
+ readonly isGPU = true;
87
94
  /** Gets or sets a matrix to use to compute projection */
88
95
  defaultProjectionMatrix: Matrix;
89
96
  /**
@@ -152,6 +159,18 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
152
159
  * Gets the name of the particle vertex shader
153
160
  */
154
161
  get vertexShaderName(): string;
162
+ /**
163
+ * Gets the vertex buffers used by the particle system
164
+ * Should be called after render() has been called for the current frame so that the buffers returned are the ones that have been updated
165
+ * in the current frame (there's a ping-pong between two sets of buffers - for a given frame, one set is used as the source and the other as the destination)
166
+ */
167
+ get vertexBuffers(): Immutable<{
168
+ [key: string]: VertexBuffer;
169
+ }>;
170
+ /**
171
+ * Gets the index buffer used by the particle system (null for GPU particle systems)
172
+ */
173
+ get indexBuffer(): Nullable<DataBuffer>;
155
174
  /** @internal */
156
175
  _colorGradientsTexture: RawTexture;
157
176
  protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
@@ -380,6 +399,8 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
380
399
  private _createDragGradientTexture;
381
400
  private _createColorGradientTexture;
382
401
  private _render;
402
+ /** @internal */
403
+ _update(emitterWM?: Matrix): void;
383
404
  /**
384
405
  * Renders the particle system in its current state
385
406
  * @param preWarm defines if the system should only update the particles but not render them
@@ -401,9 +422,10 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
401
422
  * Clones the particle system.
402
423
  * @param name The name of the cloned object
403
424
  * @param newEmitter The new emitter to use
425
+ * @param cloneTexture Also clone the textures if true
404
426
  * @returns the cloned particle system
405
427
  */
406
- clone(name: string, newEmitter: any): GPUParticleSystem;
428
+ clone(name: string, newEmitter: any, cloneTexture?: boolean): GPUParticleSystem;
407
429
  /**
408
430
  * Serializes the particle system to a JSON object
409
431
  * @param serializeTexture defines if the texture must be serialized as well
@@ -41,12 +41,15 @@ export class GPUParticleSystem extends BaseParticleSystem {
41
41
  */
42
42
  this.layerMask = 0x0fffffff;
43
43
  this._accumulatedCount = 0;
44
+ this._renderVertexBuffers = [];
44
45
  this._targetIndex = 0;
45
46
  this._currentRenderId = -1;
46
47
  this._currentRenderingCameraUniqueId = -1;
47
48
  this._started = false;
48
49
  this._stopped = false;
49
50
  this._timeDelta = 0;
51
+ /** Indicates that the update of particles is done in the animate function (and not in render). Default: false */
52
+ this.updateInAnimate = false;
50
53
  this._actualFrame = 0;
51
54
  this._rawTextureWidth = 256;
52
55
  /**
@@ -67,6 +70,8 @@ export class GPUParticleSystem extends BaseParticleSystem {
67
70
  * Specifies if the particles are updated in emitter local space or world space.
68
71
  */
69
72
  this.isLocal = false;
73
+ /** Indicates that the particle system is GPU based */
74
+ this.isGPU = true;
70
75
  /** @internal */
71
76
  this._onBeforeDrawParticlesObservable = null;
72
77
  if (!sceneOrEngine || sceneOrEngine.getClassName() === "Scene") {
@@ -308,6 +313,24 @@ export class GPUParticleSystem extends BaseParticleSystem {
308
313
  get vertexShaderName() {
309
314
  return "gpuRenderParticles";
310
315
  }
316
+ /**
317
+ * Gets the vertex buffers used by the particle system
318
+ * Should be called after render() has been called for the current frame so that the buffers returned are the ones that have been updated
319
+ * in the current frame (there's a ping-pong between two sets of buffers - for a given frame, one set is used as the source and the other as the destination)
320
+ */
321
+ get vertexBuffers() {
322
+ // We return the other buffers than those corresponding to this._targetIndex because it is assumed vertexBuffers will be called in the current frame
323
+ // after render() has been called, meaning that the buffers have already been swapped and this._targetIndex points to the buffers that will be updated
324
+ // in the next frame (and which are the sources in this frame) and (this._targetIndex ^ 1) points to the buffers that have been updated this frame
325
+ // (and that will be the source buffers in the next frame)
326
+ return this._renderVertexBuffers[this._targetIndex ^ 1];
327
+ }
328
+ /**
329
+ * Gets the index buffer used by the particle system (null for GPU particle systems)
330
+ */
331
+ get indexBuffer() {
332
+ return null;
333
+ }
311
334
  _removeGradientAndTexture(gradient, gradients, texture) {
312
335
  super._removeGradientAndTexture(gradient, gradients, texture);
313
336
  this._releaseBuffers();
@@ -711,6 +734,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
711
734
  }
712
735
  renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
713
736
  renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
737
+ this._renderVertexBuffers.push(renderVertexBuffers);
714
738
  this._platform.createVertexBuffers(updateBuffer, renderVertexBuffers);
715
739
  this.resetDrawCache();
716
740
  }
@@ -871,6 +895,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
871
895
  this._buffer1 = new Buffer(engine, bufferData2, false, this._attributesStrideSize);
872
896
  this._spriteBuffer = new Buffer(engine, spriteData, false, 4);
873
897
  // Update & Render vertex buffers
898
+ this._renderVertexBuffers = [];
874
899
  this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer);
875
900
  this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer);
876
901
  // Links
@@ -1055,6 +1080,9 @@ export class GPUParticleSystem extends BaseParticleSystem {
1055
1080
  this.stop();
1056
1081
  }
1057
1082
  }
1083
+ if (this.updateInAnimate) {
1084
+ this._update();
1085
+ }
1058
1086
  }
1059
1087
  _createFactorGradientTexture(factorGradients, textureName) {
1060
1088
  const texture = this[textureName];
@@ -1174,6 +1202,62 @@ export class GPUParticleSystem extends BaseParticleSystem {
1174
1202
  this._engine.setAlphaMode(0);
1175
1203
  return this._currentActiveCount;
1176
1204
  }
1205
+ /** @internal */
1206
+ _update(emitterWM) {
1207
+ if (!this.emitter) {
1208
+ return;
1209
+ }
1210
+ this._recreateUpdateEffect();
1211
+ if (this.emitter.position) {
1212
+ const emitterMesh = this.emitter;
1213
+ emitterWM = emitterMesh.getWorldMatrix();
1214
+ }
1215
+ else {
1216
+ const emitterPosition = this.emitter;
1217
+ emitterWM = TmpVectors.Matrix[0];
1218
+ Matrix.TranslationToRef(emitterPosition.x, emitterPosition.y, emitterPosition.z, emitterWM);
1219
+ }
1220
+ this._platform.preUpdateParticleBuffer();
1221
+ this._updateBuffer.setFloat("currentCount", this._currentActiveCount);
1222
+ this._updateBuffer.setFloat("timeDelta", this._timeDelta);
1223
+ this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1);
1224
+ this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize);
1225
+ this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
1226
+ this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
1227
+ if (!this._colorGradientsTexture) {
1228
+ this._updateBuffer.setDirectColor4("color1", this.color1);
1229
+ this._updateBuffer.setDirectColor4("color2", this.color2);
1230
+ }
1231
+ this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize);
1232
+ this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
1233
+ this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
1234
+ this._updateBuffer.setVector3("gravity", this.gravity);
1235
+ if (this._limitVelocityGradientsTexture) {
1236
+ this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping);
1237
+ }
1238
+ if (this.particleEmitterType) {
1239
+ this.particleEmitterType.applyToShader(this._updateBuffer);
1240
+ }
1241
+ if (this._isAnimationSheetEnabled) {
1242
+ this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0);
1243
+ }
1244
+ if (this.noiseTexture) {
1245
+ this._updateBuffer.setVector3("noiseStrength", this.noiseStrength);
1246
+ }
1247
+ if (!this.isLocal) {
1248
+ this._updateBuffer.setMatrix("emitterWM", emitterWM);
1249
+ }
1250
+ this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
1251
+ // Switch VAOs
1252
+ this._targetIndex++;
1253
+ if (this._targetIndex === 2) {
1254
+ this._targetIndex = 0;
1255
+ }
1256
+ // Switch buffers
1257
+ const tmpBuffer = this._sourceBuffer;
1258
+ this._sourceBuffer = this._targetBuffer;
1259
+ this._targetBuffer = tmpBuffer;
1260
+ }
1177
1261
  /**
1178
1262
  * Renders the particle system in its current state
1179
1263
  * @param preWarm defines if the system should only update the particles but not render them
@@ -1190,7 +1274,6 @@ export class GPUParticleSystem extends BaseParticleSystem {
1190
1274
  this._createVelocityGradientTexture();
1191
1275
  this._createLimitVelocityGradientTexture();
1192
1276
  this._createDragGradientTexture();
1193
- this._recreateUpdateEffect();
1194
1277
  if (!this.isReady()) {
1195
1278
  return 0;
1196
1279
  }
@@ -1230,40 +1313,13 @@ export class GPUParticleSystem extends BaseParticleSystem {
1230
1313
  }
1231
1314
  else {
1232
1315
  const emitterPosition = this.emitter;
1233
- emitterWM = Matrix.Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
1316
+ emitterWM = TmpVectors.Matrix[0];
1317
+ Matrix.TranslationToRef(emitterPosition.x, emitterPosition.y, emitterPosition.z, emitterWM);
1234
1318
  }
1235
1319
  const engine = this._engine;
1236
- this._platform.preUpdateParticleBuffer();
1237
- this._updateBuffer.setFloat("currentCount", this._currentActiveCount);
1238
- this._updateBuffer.setFloat("timeDelta", this._timeDelta);
1239
- this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1);
1240
- this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize);
1241
- this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
1242
- this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
1243
- if (!this._colorGradientsTexture) {
1244
- this._updateBuffer.setDirectColor4("color1", this.color1);
1245
- this._updateBuffer.setDirectColor4("color2", this.color2);
1320
+ if (!this.updateInAnimate) {
1321
+ this._update(emitterWM);
1246
1322
  }
1247
- this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize);
1248
- this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
1249
- this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
1250
- this._updateBuffer.setVector3("gravity", this.gravity);
1251
- if (this._limitVelocityGradientsTexture) {
1252
- this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping);
1253
- }
1254
- if (this.particleEmitterType) {
1255
- this.particleEmitterType.applyToShader(this._updateBuffer);
1256
- }
1257
- if (this._isAnimationSheetEnabled) {
1258
- this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0);
1259
- }
1260
- if (this.noiseTexture) {
1261
- this._updateBuffer.setVector3("noiseStrength", this.noiseStrength);
1262
- }
1263
- if (!this.isLocal) {
1264
- this._updateBuffer.setMatrix("emitterWM", emitterWM);
1265
- }
1266
- this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
1267
1323
  let outparticles = 0;
1268
1324
  if (!preWarm && !forceUpdateOnly) {
1269
1325
  engine.setState(false);
@@ -1278,15 +1334,6 @@ export class GPUParticleSystem extends BaseParticleSystem {
1278
1334
  }
1279
1335
  this._engine.setAlphaMode(0);
1280
1336
  }
1281
- // Switch VAOs
1282
- this._targetIndex++;
1283
- if (this._targetIndex === 2) {
1284
- this._targetIndex = 0;
1285
- }
1286
- // Switch buffers
1287
- const tmpBuffer = this._sourceBuffer;
1288
- this._sourceBuffer = this._targetBuffer;
1289
- this._targetBuffer = tmpBuffer;
1290
1337
  return outparticles;
1291
1338
  }
1292
1339
  /**
@@ -1328,6 +1375,13 @@ export class GPUParticleSystem extends BaseParticleSystem {
1328
1375
  }
1329
1376
  this._releaseBuffers();
1330
1377
  this._platform.releaseVertexBuffers();
1378
+ for (let i = 0; i < this._renderVertexBuffers.length; ++i) {
1379
+ const rvb = this._renderVertexBuffers[i];
1380
+ for (const key in rvb) {
1381
+ rvb[key].dispose();
1382
+ }
1383
+ }
1384
+ this._renderVertexBuffers = [];
1331
1385
  if (this._colorGradientsTexture) {
1332
1386
  this._colorGradientsTexture.dispose();
1333
1387
  this._colorGradientsTexture = null;
@@ -1377,9 +1431,10 @@ export class GPUParticleSystem extends BaseParticleSystem {
1377
1431
  * Clones the particle system.
1378
1432
  * @param name The name of the cloned object
1379
1433
  * @param newEmitter The new emitter to use
1434
+ * @param cloneTexture Also clone the textures if true
1380
1435
  * @returns the cloned particle system
1381
1436
  */
1382
- clone(name, newEmitter) {
1437
+ clone(name, newEmitter, cloneTexture = false) {
1383
1438
  const custom = { ...this._customWrappers };
1384
1439
  let program = null;
1385
1440
  const engine = this._engine;
@@ -1390,7 +1445,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
1390
1445
  custom[0] = engine.createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines, undefined, undefined, undefined, this);
1391
1446
  }
1392
1447
  }
1393
- const serialization = this.serialize();
1448
+ const serialization = this.serialize(cloneTexture);
1394
1449
  const result = GPUParticleSystem.Parse(serialization, this._scene || this._engine, this._rootUrl);
1395
1450
  result.name = name;
1396
1451
  result.customShader = program;