@onerjs/core 8.31.8 → 8.32.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 (93) hide show
  1. package/Behaviors/Cameras/autoRotationBehavior.d.ts +4 -0
  2. package/Behaviors/Cameras/autoRotationBehavior.js +7 -0
  3. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  4. package/Behaviors/Cameras/bouncingBehavior.d.ts +5 -0
  5. package/Behaviors/Cameras/bouncingBehavior.js +8 -0
  6. package/Behaviors/Cameras/bouncingBehavior.js.map +1 -1
  7. package/Behaviors/Cameras/framingBehavior.d.ts +4 -0
  8. package/Behaviors/Cameras/framingBehavior.js +7 -0
  9. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  10. package/Behaviors/Cameras/interpolatingBehavior.d.ts +7 -2
  11. package/Behaviors/Cameras/interpolatingBehavior.js +12 -4
  12. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -1
  13. package/Behaviors/Meshes/attachToBoxBehavior.d.ts +5 -0
  14. package/Behaviors/Meshes/attachToBoxBehavior.js +8 -1
  15. package/Behaviors/Meshes/attachToBoxBehavior.js.map +1 -1
  16. package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +5 -2
  17. package/Behaviors/Meshes/baseSixDofDragBehavior.js +8 -0
  18. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  19. package/Behaviors/Meshes/fadeInOutBehavior.d.ts +5 -0
  20. package/Behaviors/Meshes/fadeInOutBehavior.js +6 -0
  21. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  22. package/Behaviors/Meshes/handConstraintBehavior.d.ts +5 -0
  23. package/Behaviors/Meshes/handConstraintBehavior.js +8 -0
  24. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  25. package/Behaviors/Meshes/multiPointerScaleBehavior.d.ts +5 -0
  26. package/Behaviors/Meshes/multiPointerScaleBehavior.js +8 -0
  27. package/Behaviors/Meshes/multiPointerScaleBehavior.js.map +1 -1
  28. package/Behaviors/Meshes/pointerDragBehavior.d.ts +1 -1
  29. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  30. package/Behaviors/Meshes/sixDofDragBehavior.js +1 -1
  31. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  32. package/Behaviors/Meshes/surfaceMagnetismBehavior.d.ts +5 -0
  33. package/Behaviors/Meshes/surfaceMagnetismBehavior.js +7 -0
  34. package/Behaviors/Meshes/surfaceMagnetismBehavior.js.map +1 -1
  35. package/Behaviors/behavior.d.ts +4 -0
  36. package/Behaviors/behavior.js.map +1 -1
  37. package/Cameras/geospatialCamera.d.ts +4 -5
  38. package/Cameras/geospatialCamera.js +42 -29
  39. package/Cameras/geospatialCamera.js.map +1 -1
  40. package/Cameras/geospatialCameraMovement.js +1 -1
  41. package/Cameras/geospatialCameraMovement.js.map +1 -1
  42. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
  43. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -2
  44. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  45. package/Engines/WebGPU/webgpuTextureHelper.d.ts +1 -0
  46. package/Engines/WebGPU/webgpuTextureHelper.js +11 -0
  47. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  48. package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -0
  49. package/Engines/WebGPU/webgpuTextureManager.js +100 -9
  50. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  51. package/Engines/abstractEngine.js +2 -2
  52. package/Engines/abstractEngine.js.map +1 -1
  53. package/Engines/renderTargetWrapper.js +6 -1
  54. package/Engines/renderTargetWrapper.js.map +1 -1
  55. package/Engines/webgpuEngine.d.ts +7 -4
  56. package/Engines/webgpuEngine.js +45 -16
  57. package/Engines/webgpuEngine.js.map +1 -1
  58. package/Helpers/sceneHelpers.js +1 -1
  59. package/Helpers/sceneHelpers.js.map +1 -1
  60. package/Lights/index.d.ts +1 -0
  61. package/Lights/index.js +1 -0
  62. package/Lights/index.js.map +1 -1
  63. package/Lights/lightingVolume.d.ts +89 -0
  64. package/Lights/lightingVolume.js +426 -0
  65. package/Lights/lightingVolume.js.map +1 -0
  66. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +7 -0
  67. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +19 -5
  68. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  69. package/Materials/Node/nodeMaterial.js +8 -5
  70. package/Materials/Node/nodeMaterial.js.map +1 -1
  71. package/Materials/floatingOriginMatrixOverrides.js +6 -5
  72. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  73. package/Materials/uniformBuffer.d.ts +1 -0
  74. package/Materials/uniformBuffer.js +8 -1
  75. package/Materials/uniformBuffer.js.map +1 -1
  76. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +5 -2
  77. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +138 -45
  78. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  79. package/Particles/solidParticle.d.ts +9 -0
  80. package/Particles/solidParticle.js +11 -0
  81. package/Particles/solidParticle.js.map +1 -1
  82. package/Particles/solidParticleSystem.d.ts +28 -0
  83. package/Particles/solidParticleSystem.js +75 -0
  84. package/Particles/solidParticleSystem.js.map +1 -1
  85. package/ShadersWGSL/gaussianSplattingDepth.fragment.d.ts +0 -1
  86. package/ShadersWGSL/gaussianSplattingDepth.fragment.js +0 -2
  87. package/ShadersWGSL/gaussianSplattingDepth.fragment.js.map +1 -1
  88. package/ShadersWGSL/lightingVolume.compute.d.ts +5 -0
  89. package/ShadersWGSL/lightingVolume.compute.js +27 -0
  90. package/ShadersWGSL/lightingVolume.compute.js.map +1 -0
  91. package/package.json +1 -1
  92. package/scene.js +6 -4
  93. package/scene.js.map +1 -1
@@ -65,6 +65,15 @@ export declare class SolidParticle {
65
65
  * Is the particle visible or not ?
66
66
  */
67
67
  isVisible: boolean;
68
+ /**
69
+ * Defines how long will the life of the particle be.
70
+ * Set to Infinity for particles that should never die (default behavior for SolidParticleSystem).
71
+ */
72
+ lifeTime: number;
73
+ /**
74
+ * The current age of the particle.
75
+ */
76
+ age: number;
68
77
  /**
69
78
  * Index of this particle in the global "positions" array (Internal use)
70
79
  * @internal
@@ -85,6 +85,15 @@ export class SolidParticle {
85
85
  * Is the particle visible or not ?
86
86
  */
87
87
  this.isVisible = true;
88
+ /**
89
+ * Defines how long will the life of the particle be.
90
+ * Set to Infinity for particles that should never die (default behavior for SolidParticleSystem).
91
+ */
92
+ this.lifeTime = Infinity;
93
+ /**
94
+ * The current age of the particle.
95
+ */
96
+ this.age = 0;
88
97
  /**
89
98
  * Index of this particle in the global "positions" array (Internal use)
90
99
  * @internal
@@ -187,6 +196,8 @@ export class SolidParticle {
187
196
  target.isVisible = this.isVisible;
188
197
  target.parentId = this.parentId;
189
198
  target.cullingStrategy = this.cullingStrategy;
199
+ target.lifeTime = this.lifeTime;
200
+ target.age = this.age;
190
201
  if (this.materialIndex !== null) {
191
202
  target.materialIndex = this.materialIndex;
192
203
  }
@@ -1 +1 @@
1
- {"version":3,"file":"solidParticle.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/solidParticle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,aAAa;IA2HtB;;;OAGG;IACI,eAAe;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OA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AC,CAAC,CAAC;IAC3B,CAAC;IACD,IAAW,CAAC,CAAC,GAAW;QACpB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3, TmpVectors, Quaternion, Vector4, Vector2 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport { BoundingSphere } from \"../Culling/boundingSphere\";\r\nimport type { SolidParticleSystem } from \"./solidParticleSystem\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport type { Material } from \"../Materials/material\";\r\n/**\r\n * Represents one particle of a solid particle system.\r\n */\r\nexport class SolidParticle {\r\n /**\r\n * particle global index\r\n */\r\n public idx: number = 0;\r\n /**\r\n * particle identifier\r\n */\r\n public id: number = 0;\r\n /**\r\n * The color of the particle\r\n */\r\n public color: Nullable<Color4> = new Color4(1.0, 1.0, 1.0, 1.0);\r\n /**\r\n * The world space position of the particle.\r\n */\r\n public position: Vector3 = Vector3.Zero();\r\n /**\r\n * The world space rotation of the particle. (Not use if rotationQuaternion is set)\r\n */\r\n public rotation: Vector3 = Vector3.Zero();\r\n /**\r\n * The world space rotation quaternion of the particle.\r\n */\r\n public rotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * The scaling of the particle.\r\n */\r\n public scaling: Vector3 = Vector3.One();\r\n /**\r\n * The uvs of the particle.\r\n */\r\n public uvs: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);\r\n /**\r\n * The current speed of the particle.\r\n */\r\n public velocity: Vector3 = Vector3.Zero();\r\n /**\r\n * The pivot point in the particle local space.\r\n */\r\n public pivot: Vector3 = Vector3.Zero();\r\n /**\r\n * Must the particle be translated from its pivot point in its local space ?\r\n * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.\r\n * Default : false\r\n */\r\n public translateFromPivot: boolean = false;\r\n /**\r\n * Is the particle active or not ?\r\n */\r\n public alive: boolean = true;\r\n /**\r\n * Is the particle visible or not ?\r\n */\r\n public isVisible: boolean = true;\r\n /**\r\n * Index of this particle in the global \"positions\" array (Internal use)\r\n * @internal\r\n */\r\n public _pos: number = 0;\r\n /**\r\n * @internal Index of this particle in the global \"indices\" array (Internal use)\r\n */\r\n public _ind: number = 0;\r\n /**\r\n * @internal ModelShape of this particle (Internal use)\r\n */\r\n public _model: ModelShape;\r\n /**\r\n * ModelShape id of this particle\r\n */\r\n public shapeId: number = 0;\r\n /**\r\n * Index of the particle in its shape id\r\n */\r\n public idxInShape: number = 0;\r\n /**\r\n * @internal Reference to the shape model BoundingInfo object (Internal use)\r\n */\r\n public _modelBoundingInfo: BoundingInfo;\r\n private _boundingInfo: BoundingInfo;\r\n /**\r\n * @internal Reference to the SPS what the particle belongs to (Internal use)\r\n */\r\n public _sps: SolidParticleSystem;\r\n /**\r\n * @internal Still set as invisible in order to skip useless computations (Internal use)\r\n */\r\n public _stillInvisible: boolean = false;\r\n /**\r\n * @internal Last computed particle rotation matrix\r\n */\r\n public _rotationMatrix: number[] = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];\r\n /**\r\n * Parent particle Id, if any.\r\n * Default null.\r\n */\r\n public parentId: Nullable<number> = null;\r\n /**\r\n * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.\r\n */\r\n public materialIndex: Nullable<number> = null;\r\n /**\r\n * Custom object or properties.\r\n */\r\n public props: Nullable<any> = null;\r\n /**\r\n * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().\r\n * The possible values are :\r\n * - AbstractMesh.CULLINGSTRATEGY_STANDARD\r\n * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION\r\n * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY\r\n * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.\r\n * */\r\n public cullingStrategy = AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;\r\n\r\n /**\r\n * @internal Internal global position in the SPS.\r\n */\r\n public _globalPosition: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * Particle BoundingInfo object\r\n * @returns a BoundingInfo\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Returns true if there is already a bounding info\r\n */\r\n public get hasBoundingInfo(): boolean {\r\n return this._boundingInfo !== null;\r\n }\r\n\r\n /**\r\n * Creates a Solid Particle object.\r\n * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()\r\n * @param particleIndex (integer) is the particle index in the Solid Particle System pool.\r\n * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.\r\n * @param positionIndex (integer) is the starting index of the particle vertices in the SPS \"positions\" array.\r\n * @param indiceIndex (integer) is the starting index of the particle indices in the SPS \"indices\" array.\r\n * @param model (ModelShape) is a reference to the model shape on what the particle is designed.\r\n * @param shapeId (integer) is the model shape identifier in the SPS.\r\n * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))\r\n * @param sps defines the sps it is associated to\r\n * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.\r\n * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.\r\n */\r\n constructor(\r\n particleIndex: number,\r\n particleId: number,\r\n positionIndex: number,\r\n indiceIndex: number,\r\n model: Nullable<ModelShape>,\r\n shapeId: number,\r\n idxInShape: number,\r\n sps: SolidParticleSystem,\r\n modelBoundingInfo: Nullable<BoundingInfo> = null,\r\n materialIndex: Nullable<number> = null\r\n ) {\r\n this.idx = particleIndex;\r\n this.id = particleId;\r\n this._pos = positionIndex;\r\n this._ind = indiceIndex;\r\n this._model = <ModelShape>model;\r\n this.shapeId = shapeId;\r\n this.idxInShape = idxInShape;\r\n this._sps = sps;\r\n if (modelBoundingInfo) {\r\n this._modelBoundingInfo = modelBoundingInfo;\r\n this._boundingInfo = new BoundingInfo(modelBoundingInfo.minimum, modelBoundingInfo.maximum);\r\n }\r\n if (materialIndex !== null) {\r\n this.materialIndex = materialIndex;\r\n }\r\n }\r\n /**\r\n * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive\r\n * @param target the particle target\r\n * @returns the current particle\r\n */\r\n public copyToRef(target: SolidParticle): SolidParticle {\r\n target.position.copyFrom(this.position);\r\n target.rotation.copyFrom(this.rotation);\r\n if (this.rotationQuaternion) {\r\n if (target.rotationQuaternion) {\r\n target.rotationQuaternion.copyFrom(this.rotationQuaternion);\r\n } else {\r\n target.rotationQuaternion = this.rotationQuaternion.clone();\r\n }\r\n }\r\n target.scaling.copyFrom(this.scaling);\r\n if (this.color) {\r\n if (target.color) {\r\n target.color.copyFrom(this.color);\r\n } else {\r\n target.color = this.color.clone();\r\n }\r\n }\r\n target.uvs.copyFrom(this.uvs);\r\n target.velocity.copyFrom(this.velocity);\r\n target.pivot.copyFrom(this.pivot);\r\n target.translateFromPivot = this.translateFromPivot;\r\n target.alive = this.alive;\r\n target.isVisible = this.isVisible;\r\n target.parentId = this.parentId;\r\n target.cullingStrategy = this.cullingStrategy;\r\n if (this.materialIndex !== null) {\r\n target.materialIndex = this.materialIndex;\r\n }\r\n return this;\r\n }\r\n /**\r\n * Legacy support, changed scale to scaling\r\n */\r\n public get scale(): Vector3 {\r\n return this.scaling;\r\n }\r\n\r\n /**\r\n * Legacy support, changed scale to scaling\r\n */\r\n public set scale(scale: Vector3) {\r\n this.scaling = scale;\r\n }\r\n\r\n /**\r\n * Legacy support, changed quaternion to rotationQuaternion\r\n */\r\n public get quaternion(): Nullable<Quaternion> {\r\n return this.rotationQuaternion;\r\n }\r\n\r\n /**\r\n * Legacy support, changed quaternion to rotationQuaternion\r\n */\r\n public set quaternion(q: Nullable<Quaternion>) {\r\n this.rotationQuaternion = q;\r\n }\r\n\r\n /**\r\n * Returns a boolean. True if the particle intersects another particle or another mesh, else false.\r\n * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)\r\n * @param target is the object (solid particle or mesh) what the intersection is computed against.\r\n * @returns true if it intersects\r\n */\r\n public intersectsMesh(target: Mesh | SolidParticle): boolean {\r\n if (!this._boundingInfo || !target.hasBoundingInfo) {\r\n return false;\r\n }\r\n if (this._sps._bSphereOnly) {\r\n return BoundingSphere.Intersects(this._boundingInfo.boundingSphere, target.getBoundingInfo().boundingSphere);\r\n }\r\n return this._boundingInfo.intersects(target.getBoundingInfo(), false);\r\n }\r\n\r\n /**\r\n * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.\r\n * A particle is in the frustum if its bounding box intersects the frustum\r\n * @param frustumPlanes defines the frustum to test\r\n * @returns true if the particle is in the frustum planes\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);\r\n }\r\n\r\n /**\r\n * get the rotation matrix of the particle\r\n * @internal\r\n */\r\n public getRotationMatrix(m: Matrix) {\r\n let quaternion: Quaternion;\r\n if (this.rotationQuaternion) {\r\n quaternion = this.rotationQuaternion;\r\n } else {\r\n quaternion = TmpVectors.Quaternion[0];\r\n const rotation = this.rotation;\r\n Quaternion.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);\r\n }\r\n\r\n quaternion.toRotationMatrix(m);\r\n }\r\n}\r\n\r\n/**\r\n * Represents the shape of the model used by one particle of a solid particle system.\r\n * SPS internal tool, don't use it manually.\r\n */\r\nexport class ModelShape {\r\n /**\r\n * Get or set the shapeId\r\n * @deprecated Please use shapeId instead\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get shapeID(): number {\r\n return this.shapeId;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public set shapeID(shapeID: number) {\r\n this.shapeId = shapeID;\r\n }\r\n /**\r\n * The shape id\r\n * @internal\r\n */\r\n public shapeId: number;\r\n /**\r\n * flat array of model positions (internal use)\r\n * @internal\r\n */\r\n public _shape: Vector3[];\r\n /**\r\n * flat array of model UVs (internal use)\r\n * @internal\r\n */\r\n public _shapeUV: number[];\r\n /**\r\n * color array of the model\r\n * @internal\r\n */\r\n public _shapeColors: number[];\r\n /**\r\n * indices array of the model\r\n * @internal\r\n */\r\n public _indices: number[];\r\n /**\r\n * normals array of the model\r\n * @internal\r\n */\r\n public _normals: number[];\r\n /**\r\n * length of the shape in the model indices array (internal use)\r\n * @internal\r\n */\r\n public _indicesLength: number = 0;\r\n /**\r\n * Custom position function (internal use)\r\n * @internal\r\n */\r\n public _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;\r\n /**\r\n * Custom vertex function (internal use)\r\n * @internal\r\n */\r\n public _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;\r\n /**\r\n * Model material (internal use)\r\n * @internal\r\n */\r\n public _material: Nullable<Material>;\r\n\r\n /**\r\n * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.\r\n * SPS internal tool, don't use it manually.\r\n * @internal\r\n */\r\n constructor(\r\n id: number,\r\n shape: Vector3[],\r\n indices: number[],\r\n normals: number[],\r\n colors: number[],\r\n shapeUV: number[],\r\n posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>,\r\n vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>,\r\n material: Nullable<Material>\r\n ) {\r\n this.shapeId = id;\r\n this._shape = shape;\r\n this._indices = indices;\r\n this._indicesLength = indices.length;\r\n this._shapeUV = shapeUV;\r\n this._shapeColors = colors;\r\n this._normals = normals;\r\n this._positionFunction = posFunction;\r\n this._vertexFunction = vtxFunction;\r\n this._material = material;\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Depth Sorted Particle in the solid particle system.\r\n * @internal\r\n */\r\nexport class DepthSortedParticle {\r\n /**\r\n * Particle index\r\n */\r\n public idx: number = 0;\r\n /**\r\n * Index of the particle in the \"indices\" array\r\n */\r\n public ind: number = 0;\r\n /**\r\n * Length of the particle shape in the \"indices\" array\r\n */\r\n public indicesLength: number = 0;\r\n /**\r\n * Squared distance from the particle to the camera\r\n */\r\n public sqDistance: number = 0.0;\r\n /**\r\n * Material index when used with MultiMaterials\r\n */\r\n public materialIndex: number = 0;\r\n\r\n /**\r\n * Creates a new sorted particle\r\n * @param idx\r\n * @param ind\r\n * @param indLength\r\n * @param materialIndex\r\n */\r\n constructor(idx: number, ind: number, indLength: number, materialIndex: number) {\r\n this.idx = idx;\r\n this.ind = ind;\r\n this.indicesLength = indLength;\r\n this.materialIndex = materialIndex;\r\n }\r\n}\r\n\r\n/**\r\n * Represents a solid particle vertex\r\n */\r\nexport class SolidParticleVertex {\r\n /**\r\n * Vertex position\r\n */\r\n public position: Vector3;\r\n /**\r\n * Vertex color\r\n */\r\n public color: Color4;\r\n /**\r\n * Vertex UV\r\n */\r\n public uv: Vector2;\r\n /**\r\n * Creates a new solid particle vertex\r\n */\r\n constructor() {\r\n this.position = Vector3.Zero();\r\n this.color = new Color4(1.0, 1.0, 1.0, 1.0);\r\n this.uv = Vector2.Zero();\r\n }\r\n // Getters and Setters for back-compatibility\r\n /** Vertex x coordinate */\r\n public get x(): number {\r\n return this.position.x;\r\n }\r\n public set x(val: number) {\r\n this.position.x = val;\r\n }\r\n /** Vertex y coordinate */\r\n public get y(): number {\r\n return this.position.y;\r\n }\r\n public set y(val: number) {\r\n this.position.y = val;\r\n }\r\n /** Vertex z coordinate */\r\n public get z(): number {\r\n return this.position.z;\r\n }\r\n public set z(val: number) {\r\n this.position.z = val;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"solidParticle.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/solidParticle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,aAAa;IAoItB;;;OAGG;IACI,eAAe;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,YACI,aAAqB,EACrB,UAAkB,EAClB,aAAqB,EACrB,WAAmB,EACnB,KAA2B,EAC3B,OAAe,EACf,UAAkB,EAClB,GAAwB,EACxB,oBAA4C,IAAI,EAChD,gBAAkC,IAAI;QA1K1C;;WAEG;QACI,QAAG,GAAW,CAAC,CAAC;QACvB;;WAEG;QACI,OAAE,GAAW,CAAC,CAAC;QACtB;;WAEG;QACI,UAAK,GAAqB,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAChE;;WAEG;QACI,aAAQ,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAC1C;;WAEG;QACI,aAAQ,GAAY,OAAO,CAAC,IAAI,EAAE,CAAC;QAK1C;;WAEG;QACI,YAAO,GAAY,OAAO,CAAC,GAAG,EAAE,CAAC;QACxC;;WAEG;QACI,QAAG,GAAY,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAA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mB;IAa5B;;OAEG;IACH;QACI,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IACD,6CAA6C;IAC7C,0BAA0B;IAC1B,IAAW,CAAC;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,IAAW,CAAC,CAAC,GAAW;QACpB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC;IAC1B,CAAC;IACD,0BAA0B;IAC1B,IAAW,CAAC;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,IAAW,CAAC,CAAC,GAAW;QACpB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC;IAC1B,CAAC;IACD,0BAA0B;IAC1B,IAAW,CAAC;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,IAAW,CAAC,CAAC,GAAW;QACpB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3, TmpVectors, Quaternion, Vector4, Vector2 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport { BoundingSphere } from \"../Culling/boundingSphere\";\r\nimport type { SolidParticleSystem } from \"./solidParticleSystem\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Plane } from \"../Maths/math.plane\";\r\nimport type { Material } from \"../Materials/material\";\r\n/**\r\n * Represents one particle of a solid particle system.\r\n */\r\nexport class SolidParticle {\r\n /**\r\n * particle global index\r\n */\r\n public idx: number = 0;\r\n /**\r\n * particle identifier\r\n */\r\n public id: number = 0;\r\n /**\r\n * The color of the particle\r\n */\r\n public color: Nullable<Color4> = new Color4(1.0, 1.0, 1.0, 1.0);\r\n /**\r\n * The world space position of the particle.\r\n */\r\n public position: Vector3 = Vector3.Zero();\r\n /**\r\n * The world space rotation of the particle. (Not use if rotationQuaternion is set)\r\n */\r\n public rotation: Vector3 = Vector3.Zero();\r\n /**\r\n * The world space rotation quaternion of the particle.\r\n */\r\n public rotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * The scaling of the particle.\r\n */\r\n public scaling: Vector3 = Vector3.One();\r\n /**\r\n * The uvs of the particle.\r\n */\r\n public uvs: Vector4 = new Vector4(0.0, 0.0, 1.0, 1.0);\r\n /**\r\n * The current speed of the particle.\r\n */\r\n public velocity: Vector3 = Vector3.Zero();\r\n /**\r\n * The pivot point in the particle local space.\r\n */\r\n public pivot: Vector3 = Vector3.Zero();\r\n /**\r\n * Must the particle be translated from its pivot point in its local space ?\r\n * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.\r\n * Default : false\r\n */\r\n public translateFromPivot: boolean = false;\r\n /**\r\n * Is the particle active or not ?\r\n */\r\n public alive: boolean = true;\r\n /**\r\n * Is the particle visible or not ?\r\n */\r\n public isVisible: boolean = true;\r\n /**\r\n * Defines how long will the life of the particle be.\r\n * Set to Infinity for particles that should never die (default behavior for SolidParticleSystem).\r\n */\r\n public lifeTime = Infinity;\r\n /**\r\n * The current age of the particle.\r\n */\r\n public age = 0;\r\n /**\r\n * Index of this particle in the global \"positions\" array (Internal use)\r\n * @internal\r\n */\r\n public _pos: number = 0;\r\n /**\r\n * @internal Index of this particle in the global \"indices\" array (Internal use)\r\n */\r\n public _ind: number = 0;\r\n /**\r\n * @internal ModelShape of this particle (Internal use)\r\n */\r\n public _model: ModelShape;\r\n /**\r\n * ModelShape id of this particle\r\n */\r\n public shapeId: number = 0;\r\n /**\r\n * Index of the particle in its shape id\r\n */\r\n public idxInShape: number = 0;\r\n /**\r\n * @internal Reference to the shape model BoundingInfo object (Internal use)\r\n */\r\n public _modelBoundingInfo: BoundingInfo;\r\n private _boundingInfo: BoundingInfo;\r\n /**\r\n * @internal Reference to the SPS what the particle belongs to (Internal use)\r\n */\r\n public _sps: SolidParticleSystem;\r\n /**\r\n * @internal Still set as invisible in order to skip useless computations (Internal use)\r\n */\r\n public _stillInvisible: boolean = false;\r\n /**\r\n * @internal Last computed particle rotation matrix\r\n */\r\n public _rotationMatrix: number[] = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];\r\n /**\r\n * Parent particle Id, if any.\r\n * Default null.\r\n */\r\n public parentId: Nullable<number> = null;\r\n /**\r\n * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.\r\n */\r\n public materialIndex: Nullable<number> = null;\r\n /**\r\n * Custom object or properties.\r\n */\r\n public props: Nullable<any> = null;\r\n /**\r\n * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().\r\n * The possible values are :\r\n * - AbstractMesh.CULLINGSTRATEGY_STANDARD\r\n * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION\r\n * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY\r\n * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY\r\n * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.\r\n * */\r\n public cullingStrategy = AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;\r\n\r\n /**\r\n * @internal Internal global position in the SPS.\r\n */\r\n public _globalPosition: Vector3 = Vector3.Zero();\r\n\r\n /**\r\n * Particle BoundingInfo object\r\n * @returns a BoundingInfo\r\n */\r\n public getBoundingInfo(): BoundingInfo {\r\n return this._boundingInfo;\r\n }\r\n\r\n /**\r\n * Returns true if there is already a bounding info\r\n */\r\n public get hasBoundingInfo(): boolean {\r\n return this._boundingInfo !== null;\r\n }\r\n\r\n /**\r\n * Creates a Solid Particle object.\r\n * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()\r\n * @param particleIndex (integer) is the particle index in the Solid Particle System pool.\r\n * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.\r\n * @param positionIndex (integer) is the starting index of the particle vertices in the SPS \"positions\" array.\r\n * @param indiceIndex (integer) is the starting index of the particle indices in the SPS \"indices\" array.\r\n * @param model (ModelShape) is a reference to the model shape on what the particle is designed.\r\n * @param shapeId (integer) is the model shape identifier in the SPS.\r\n * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))\r\n * @param sps defines the sps it is associated to\r\n * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.\r\n * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.\r\n */\r\n constructor(\r\n particleIndex: number,\r\n particleId: number,\r\n positionIndex: number,\r\n indiceIndex: number,\r\n model: Nullable<ModelShape>,\r\n shapeId: number,\r\n idxInShape: number,\r\n sps: SolidParticleSystem,\r\n modelBoundingInfo: Nullable<BoundingInfo> = null,\r\n materialIndex: Nullable<number> = null\r\n ) {\r\n this.idx = particleIndex;\r\n this.id = particleId;\r\n this._pos = positionIndex;\r\n this._ind = indiceIndex;\r\n this._model = <ModelShape>model;\r\n this.shapeId = shapeId;\r\n this.idxInShape = idxInShape;\r\n this._sps = sps;\r\n if (modelBoundingInfo) {\r\n this._modelBoundingInfo = modelBoundingInfo;\r\n this._boundingInfo = new BoundingInfo(modelBoundingInfo.minimum, modelBoundingInfo.maximum);\r\n }\r\n if (materialIndex !== null) {\r\n this.materialIndex = materialIndex;\r\n }\r\n }\r\n /**\r\n * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive\r\n * @param target the particle target\r\n * @returns the current particle\r\n */\r\n public copyToRef(target: SolidParticle): SolidParticle {\r\n target.position.copyFrom(this.position);\r\n target.rotation.copyFrom(this.rotation);\r\n if (this.rotationQuaternion) {\r\n if (target.rotationQuaternion) {\r\n target.rotationQuaternion.copyFrom(this.rotationQuaternion);\r\n } else {\r\n target.rotationQuaternion = this.rotationQuaternion.clone();\r\n }\r\n }\r\n target.scaling.copyFrom(this.scaling);\r\n if (this.color) {\r\n if (target.color) {\r\n target.color.copyFrom(this.color);\r\n } else {\r\n target.color = this.color.clone();\r\n }\r\n }\r\n target.uvs.copyFrom(this.uvs);\r\n target.velocity.copyFrom(this.velocity);\r\n target.pivot.copyFrom(this.pivot);\r\n target.translateFromPivot = this.translateFromPivot;\r\n target.alive = this.alive;\r\n target.isVisible = this.isVisible;\r\n target.parentId = this.parentId;\r\n target.cullingStrategy = this.cullingStrategy;\r\n target.lifeTime = this.lifeTime;\r\n target.age = this.age;\r\n if (this.materialIndex !== null) {\r\n target.materialIndex = this.materialIndex;\r\n }\r\n return this;\r\n }\r\n /**\r\n * Legacy support, changed scale to scaling\r\n */\r\n public get scale(): Vector3 {\r\n return this.scaling;\r\n }\r\n\r\n /**\r\n * Legacy support, changed scale to scaling\r\n */\r\n public set scale(scale: Vector3) {\r\n this.scaling = scale;\r\n }\r\n\r\n /**\r\n * Legacy support, changed quaternion to rotationQuaternion\r\n */\r\n public get quaternion(): Nullable<Quaternion> {\r\n return this.rotationQuaternion;\r\n }\r\n\r\n /**\r\n * Legacy support, changed quaternion to rotationQuaternion\r\n */\r\n public set quaternion(q: Nullable<Quaternion>) {\r\n this.rotationQuaternion = q;\r\n }\r\n\r\n /**\r\n * Returns a boolean. True if the particle intersects another particle or another mesh, else false.\r\n * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)\r\n * @param target is the object (solid particle or mesh) what the intersection is computed against.\r\n * @returns true if it intersects\r\n */\r\n public intersectsMesh(target: Mesh | SolidParticle): boolean {\r\n if (!this._boundingInfo || !target.hasBoundingInfo) {\r\n return false;\r\n }\r\n if (this._sps._bSphereOnly) {\r\n return BoundingSphere.Intersects(this._boundingInfo.boundingSphere, target.getBoundingInfo().boundingSphere);\r\n }\r\n return this._boundingInfo.intersects(target.getBoundingInfo(), false);\r\n }\r\n\r\n /**\r\n * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.\r\n * A particle is in the frustum if its bounding box intersects the frustum\r\n * @param frustumPlanes defines the frustum to test\r\n * @returns true if the particle is in the frustum planes\r\n */\r\n public isInFrustum(frustumPlanes: Plane[]): boolean {\r\n return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);\r\n }\r\n\r\n /**\r\n * get the rotation matrix of the particle\r\n * @internal\r\n */\r\n public getRotationMatrix(m: Matrix) {\r\n let quaternion: Quaternion;\r\n if (this.rotationQuaternion) {\r\n quaternion = this.rotationQuaternion;\r\n } else {\r\n quaternion = TmpVectors.Quaternion[0];\r\n const rotation = this.rotation;\r\n Quaternion.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);\r\n }\r\n\r\n quaternion.toRotationMatrix(m);\r\n }\r\n}\r\n\r\n/**\r\n * Represents the shape of the model used by one particle of a solid particle system.\r\n * SPS internal tool, don't use it manually.\r\n */\r\nexport class ModelShape {\r\n /**\r\n * Get or set the shapeId\r\n * @deprecated Please use shapeId instead\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get shapeID(): number {\r\n return this.shapeId;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public set shapeID(shapeID: number) {\r\n this.shapeId = shapeID;\r\n }\r\n /**\r\n * The shape id\r\n * @internal\r\n */\r\n public shapeId: number;\r\n /**\r\n * flat array of model positions (internal use)\r\n * @internal\r\n */\r\n public _shape: Vector3[];\r\n /**\r\n * flat array of model UVs (internal use)\r\n * @internal\r\n */\r\n public _shapeUV: number[];\r\n /**\r\n * color array of the model\r\n * @internal\r\n */\r\n public _shapeColors: number[];\r\n /**\r\n * indices array of the model\r\n * @internal\r\n */\r\n public _indices: number[];\r\n /**\r\n * normals array of the model\r\n * @internal\r\n */\r\n public _normals: number[];\r\n /**\r\n * length of the shape in the model indices array (internal use)\r\n * @internal\r\n */\r\n public _indicesLength: number = 0;\r\n /**\r\n * Custom position function (internal use)\r\n * @internal\r\n */\r\n public _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;\r\n /**\r\n * Custom vertex function (internal use)\r\n * @internal\r\n */\r\n public _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;\r\n /**\r\n * Model material (internal use)\r\n * @internal\r\n */\r\n public _material: Nullable<Material>;\r\n\r\n /**\r\n * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.\r\n * SPS internal tool, don't use it manually.\r\n * @internal\r\n */\r\n constructor(\r\n id: number,\r\n shape: Vector3[],\r\n indices: number[],\r\n normals: number[],\r\n colors: number[],\r\n shapeUV: number[],\r\n posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>,\r\n vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>,\r\n material: Nullable<Material>\r\n ) {\r\n this.shapeId = id;\r\n this._shape = shape;\r\n this._indices = indices;\r\n this._indicesLength = indices.length;\r\n this._shapeUV = shapeUV;\r\n this._shapeColors = colors;\r\n this._normals = normals;\r\n this._positionFunction = posFunction;\r\n this._vertexFunction = vtxFunction;\r\n this._material = material;\r\n }\r\n}\r\n\r\n/**\r\n * Represents a Depth Sorted Particle in the solid particle system.\r\n * @internal\r\n */\r\nexport class DepthSortedParticle {\r\n /**\r\n * Particle index\r\n */\r\n public idx: number = 0;\r\n /**\r\n * Index of the particle in the \"indices\" array\r\n */\r\n public ind: number = 0;\r\n /**\r\n * Length of the particle shape in the \"indices\" array\r\n */\r\n public indicesLength: number = 0;\r\n /**\r\n * Squared distance from the particle to the camera\r\n */\r\n public sqDistance: number = 0.0;\r\n /**\r\n * Material index when used with MultiMaterials\r\n */\r\n public materialIndex: number = 0;\r\n\r\n /**\r\n * Creates a new sorted particle\r\n * @param idx\r\n * @param ind\r\n * @param indLength\r\n * @param materialIndex\r\n */\r\n constructor(idx: number, ind: number, indLength: number, materialIndex: number) {\r\n this.idx = idx;\r\n this.ind = ind;\r\n this.indicesLength = indLength;\r\n this.materialIndex = materialIndex;\r\n }\r\n}\r\n\r\n/**\r\n * Represents a solid particle vertex\r\n */\r\nexport class SolidParticleVertex {\r\n /**\r\n * Vertex position\r\n */\r\n public position: Vector3;\r\n /**\r\n * Vertex color\r\n */\r\n public color: Color4;\r\n /**\r\n * Vertex UV\r\n */\r\n public uv: Vector2;\r\n /**\r\n * Creates a new solid particle vertex\r\n */\r\n constructor() {\r\n this.position = Vector3.Zero();\r\n this.color = new Color4(1.0, 1.0, 1.0, 1.0);\r\n this.uv = Vector2.Zero();\r\n }\r\n // Getters and Setters for back-compatibility\r\n /** Vertex x coordinate */\r\n public get x(): number {\r\n return this.position.x;\r\n }\r\n public set x(val: number) {\r\n this.position.x = val;\r\n }\r\n /** Vertex y coordinate */\r\n public get y(): number {\r\n return this.position.y;\r\n }\r\n public set y(val: number) {\r\n this.position.y = val;\r\n }\r\n /** Vertex z coordinate */\r\n public get z(): number {\r\n return this.position.z;\r\n }\r\n public set z(val: number) {\r\n this.position.z = val;\r\n }\r\n}\r\n"]}
@@ -3,6 +3,7 @@ import { Vector3 } from "../Maths/math.vector.js";
3
3
  import { Color4 } from "../Maths/math.color.js";
4
4
  import { Mesh } from "../Meshes/mesh.js";
5
5
  import type { Scene, IDisposable } from "../scene.js";
6
+ import type { Observer } from "../Misc/observable.js";
6
7
  import { DepthSortedParticle, SolidParticle, ModelShape, SolidParticleVertex } from "./solidParticle.js";
7
8
  import type { TargetCamera } from "../Cameras/targetCamera.js";
8
9
  import { BoundingInfo } from "../Culling/boundingInfo.js";
@@ -147,6 +148,15 @@ export declare class SolidParticleSystem implements IDisposable {
147
148
  protected _autoUpdateSubMeshes: boolean;
148
149
  protected _tmpVertex: SolidParticleVertex;
149
150
  protected _recomputeInvisibles: boolean;
151
+ protected _started: boolean;
152
+ protected _stopped: boolean;
153
+ protected _onBeforeRenderObserver: Nullable<Observer<Scene>>;
154
+ /**
155
+ * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
156
+ */
157
+ updateSpeed: number;
158
+ /** @internal */
159
+ protected _scaledUpdateSpeed: number;
150
160
  /**
151
161
  * Creates a SPS (Solid Particle System) object.
152
162
  * @param name (String) is the SPS name, this will be the underlying mesh name.
@@ -601,4 +611,22 @@ export declare class SolidParticleSystem implements IDisposable {
601
611
  * @param update the boolean update value actually passed to setParticles()
602
612
  */
603
613
  afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
614
+ /**
615
+ * Starts the particle system and begins to emit.
616
+ * This will call buildMesh(), initParticles(), setParticles() and register the update loop.
617
+ * @param delay defines the delay in milliseconds before starting the system (0 by default)
618
+ */
619
+ start(delay?: number): void;
620
+ /**
621
+ * Stops the particle system.
622
+ */
623
+ stop(): void;
624
+ /**
625
+ * Gets if the particle system is started
626
+ */
627
+ get started(): boolean;
628
+ /**
629
+ * Gets if the particle system is stopped
630
+ */
631
+ get stopped(): boolean;
604
632
  }
@@ -121,6 +121,13 @@ export class SolidParticleSystem {
121
121
  this._materialSortFunction = (p1, p2) => p1.materialIndex - p2.materialIndex;
122
122
  this._autoUpdateSubMeshes = false;
123
123
  this._recomputeInvisibles = false;
124
+ this._started = false;
125
+ this._stopped = false;
126
+ this._onBeforeRenderObserver = null;
127
+ /**
128
+ * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
129
+ */
130
+ this.updateSpeed = 0.01;
124
131
  this.name = name;
125
132
  this._scene = scene || EngineStore.LastCreatedScene;
126
133
  this._camera = scene.activeCamera;
@@ -942,8 +949,20 @@ export class SolidParticleSystem {
942
949
  const vpos = (index / 3) | 0;
943
950
  colorIndex = vpos * 4;
944
951
  uvIndex = vpos * 2;
952
+ // Calculate scaled update speed based on animation ratio (for FPS independence)
953
+ if (this._started && !this._stopped) {
954
+ this._scaledUpdateSpeed = this.updateSpeed * (this._scene?.getAnimationRatio() || 1);
955
+ }
945
956
  for (let p = start; p <= end; p++) {
946
957
  const particle = this.particles[p];
958
+ // Update particle age and check lifetime
959
+ if (this._started && !this._stopped) {
960
+ particle.age += this._scaledUpdateSpeed;
961
+ // Only check lifetime if it's finite (Infinity means particle never dies)
962
+ if (isFinite(particle.lifeTime) && particle.age >= particle.lifeTime) {
963
+ particle.alive = false;
964
+ }
965
+ }
947
966
  // call to custom user function to update the particle properties
948
967
  this.updateParticle(particle);
949
968
  const shape = particle._model._shape;
@@ -1279,6 +1298,7 @@ export class SolidParticleSystem {
1279
1298
  * Disposes the SPS.
1280
1299
  */
1281
1300
  dispose() {
1301
+ this.stop();
1282
1302
  this.mesh.dispose();
1283
1303
  this.vars = null;
1284
1304
  // drop references to internal big arrays for the GC
@@ -1770,5 +1790,60 @@ export class SolidParticleSystem {
1770
1790
  */
1771
1791
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1772
1792
  afterUpdateParticles(start, stop, update) { }
1793
+ /**
1794
+ * Starts the particle system and begins to emit.
1795
+ * This will call buildMesh(), initParticles(), setParticles() and register the update loop.
1796
+ * @param delay defines the delay in milliseconds before starting the system (0 by default)
1797
+ */
1798
+ start(delay = 0) {
1799
+ if (this._started) {
1800
+ return;
1801
+ }
1802
+ if (delay > 0) {
1803
+ setTimeout(() => {
1804
+ this.start(0);
1805
+ }, delay);
1806
+ return;
1807
+ }
1808
+ this.buildMesh();
1809
+ this.initParticles();
1810
+ this.setParticles();
1811
+ this._started = true;
1812
+ this._stopped = false;
1813
+ // Register update loop
1814
+ if (this._scene) {
1815
+ this._onBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {
1816
+ if (this._started && !this._stopped) {
1817
+ this.setParticles();
1818
+ }
1819
+ });
1820
+ }
1821
+ }
1822
+ /**
1823
+ * Stops the particle system.
1824
+ */
1825
+ stop() {
1826
+ if (this._stopped) {
1827
+ return;
1828
+ }
1829
+ this._stopped = true;
1830
+ // Unregister update loop
1831
+ if (this._onBeforeRenderObserver && this._scene) {
1832
+ this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
1833
+ this._onBeforeRenderObserver = null;
1834
+ }
1835
+ }
1836
+ /**
1837
+ * Gets if the particle system is started
1838
+ */
1839
+ get started() {
1840
+ return this._started;
1841
+ }
1842
+ /**
1843
+ * Gets if the particle system is stopped
1844
+ */
1845
+ get stopped() {
1846
+ return this._stopped;
1847
+ }
1773
1848
  }
1774
1849
  //# sourceMappingURL=solidParticleSystem.js.map