solidParticle.d.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. import type { Nullable } from "../types";
  2. import type { Matrix } from "../Maths/math.vector";
  3. import { Vector3, Quaternion, Vector4, Vector2 } from "../Maths/math.vector";
  4. import { Color4 } from "../Maths/math.color";
  5. import type { Mesh } from "../Meshes/mesh";
  6. import { BoundingInfo } from "../Culling/boundingInfo";
  7. import type { SolidParticleSystem } from "./solidParticleSystem";
  8. import type { Plane } from "../Maths/math.plane";
  9. import type { Material } from "../Materials/material";
  10. /**
  11. * Represents one particle of a solid particle system.
  12. */
  13. export declare class SolidParticle {
  14. /**
  15. * particle global index
  16. */
  17. idx: number;
  18. /**
  19. * particle identifier
  20. */
  21. id: number;
  22. /**
  23. * The color of the particle
  24. */
  25. color: Nullable<Color4>;
  26. /**
  27. * The world space position of the particle.
  28. */
  29. position: Vector3;
  30. /**
  31. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32. */
  33. rotation: Vector3;
  34. /**
  35. * The world space rotation quaternion of the particle.
  36. */
  37. rotationQuaternion: Nullable<Quaternion>;
  38. /**
  39. * The scaling of the particle.
  40. */
  41. scaling: Vector3;
  42. /**
  43. * The uvs of the particle.
  44. */
  45. uvs: Vector4;
  46. /**
  47. * The current speed of the particle.
  48. */
  49. velocity: Vector3;
  50. /**
  51. * The pivot point in the particle local space.
  52. */
  53. pivot: Vector3;
  54. /**
  55. * Must the particle be translated from its pivot point in its local space ?
  56. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  57. * Default : false
  58. */
  59. translateFromPivot: boolean;
  60. /**
  61. * Is the particle active or not ?
  62. */
  63. alive: boolean;
  64. /**
  65. * Is the particle visible or not ?
  66. */
  67. isVisible: boolean;
  68. /**
  69. * Index of this particle in the global "positions" array (Internal use)
  70. * @internal
  71. */
  72. _pos: number;
  73. /**
  74. * @internal Index of this particle in the global "indices" array (Internal use)
  75. */
  76. _ind: number;
  77. /**
  78. * @internal ModelShape of this particle (Internal use)
  79. */
  80. _model: ModelShape;
  81. /**
  82. * ModelShape id of this particle
  83. */
  84. shapeId: number;
  85. /**
  86. * Index of the particle in its shape id
  87. */
  88. idxInShape: number;
  89. /**
  90. * @internal Reference to the shape model BoundingInfo object (Internal use)
  91. */
  92. _modelBoundingInfo: BoundingInfo;
  93. private _boundingInfo;
  94. /**
  95. * @internal Reference to the SPS what the particle belongs to (Internal use)
  96. */
  97. _sps: SolidParticleSystem;
  98. /**
  99. * @internal Still set as invisible in order to skip useless computations (Internal use)
  100. */
  101. _stillInvisible: boolean;
  102. /**
  103. * @internal Last computed particle rotation matrix
  104. */
  105. _rotationMatrix: number[];
  106. /**
  107. * Parent particle Id, if any.
  108. * Default null.
  109. */
  110. parentId: Nullable<number>;
  111. /**
  112. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  113. */
  114. materialIndex: Nullable<number>;
  115. /**
  116. * Custom object or properties.
  117. */
  118. props: Nullable<any>;
  119. /**
  120. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  121. * The possible values are :
  122. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  123. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  124. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  125. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  126. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  127. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  128. * */
  129. cullingStrategy: number;
  130. /**
  131. * @internal Internal global position in the SPS.
  132. */
  133. _globalPosition: Vector3;
  134. /**
  135. * Particle BoundingInfo object
  136. * @returns a BoundingInfo
  137. */
  138. getBoundingInfo(): BoundingInfo;
  139. /**
  140. * Returns true if there is already a bounding info
  141. */
  142. get hasBoundingInfo(): boolean;
  143. /**
  144. * Creates a Solid Particle object.
  145. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  146. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  147. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  148. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  149. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  150. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  151. * @param shapeId (integer) is the model shape identifier in the SPS.
  152. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  153. * @param sps defines the sps it is associated to
  154. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  155. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  156. */
  157. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  158. /**
  159. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  160. * @param target the particle target
  161. * @returns the current particle
  162. */
  163. copyToRef(target: SolidParticle): SolidParticle;
  164. /**
  165. * Legacy support, changed scale to scaling
  166. */
  167. get scale(): Vector3;
  168. /**
  169. * Legacy support, changed scale to scaling
  170. */
  171. set scale(scale: Vector3);
  172. /**
  173. * Legacy support, changed quaternion to rotationQuaternion
  174. */
  175. get quaternion(): Nullable<Quaternion>;
  176. /**
  177. * Legacy support, changed quaternion to rotationQuaternion
  178. */
  179. set quaternion(q: Nullable<Quaternion>);
  180. /**
  181. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  182. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  183. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  184. * @returns true if it intersects
  185. */
  186. intersectsMesh(target: Mesh | SolidParticle): boolean;
  187. /**
  188. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  189. * A particle is in the frustum if its bounding box intersects the frustum
  190. * @param frustumPlanes defines the frustum to test
  191. * @returns true if the particle is in the frustum planes
  192. */
  193. isInFrustum(frustumPlanes: Plane[]): boolean;
  194. /**
  195. * get the rotation matrix of the particle
  196. * @internal
  197. */
  198. getRotationMatrix(m: Matrix): void;
  199. }
  200. /**
  201. * Represents the shape of the model used by one particle of a solid particle system.
  202. * SPS internal tool, don't use it manually.
  203. */
  204. export declare class ModelShape {
  205. /**
  206. * Get or set the shapeId
  207. * @deprecated Please use shapeId instead
  208. */
  209. get shapeID(): number;
  210. set shapeID(shapeID: number);
  211. /**
  212. * The shape id
  213. * @internal
  214. */
  215. shapeId: number;
  216. /**
  217. * flat array of model positions (internal use)
  218. * @internal
  219. */
  220. _shape: Vector3[];
  221. /**
  222. * flat array of model UVs (internal use)
  223. * @internal
  224. */
  225. _shapeUV: number[];
  226. /**
  227. * color array of the model
  228. * @internal
  229. */
  230. _shapeColors: number[];
  231. /**
  232. * indices array of the model
  233. * @internal
  234. */
  235. _indices: number[];
  236. /**
  237. * normals array of the model
  238. * @internal
  239. */
  240. _normals: number[];
  241. /**
  242. * length of the shape in the model indices array (internal use)
  243. * @internal
  244. */
  245. _indicesLength: number;
  246. /**
  247. * Custom position function (internal use)
  248. * @internal
  249. */
  250. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  251. /**
  252. * Custom vertex function (internal use)
  253. * @internal
  254. */
  255. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  256. /**
  257. * Model material (internal use)
  258. * @internal
  259. */
  260. _material: Nullable<Material>;
  261. /**
  262. * 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.
  263. * SPS internal tool, don't use it manually.
  264. * @internal
  265. */
  266. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  267. }
  268. /**
  269. * Represents a Depth Sorted Particle in the solid particle system.
  270. * @internal
  271. */
  272. export declare class DepthSortedParticle {
  273. /**
  274. * Particle index
  275. */
  276. idx: number;
  277. /**
  278. * Index of the particle in the "indices" array
  279. */
  280. ind: number;
  281. /**
  282. * Length of the particle shape in the "indices" array
  283. */
  284. indicesLength: number;
  285. /**
  286. * Squared distance from the particle to the camera
  287. */
  288. sqDistance: number;
  289. /**
  290. * Material index when used with MultiMaterials
  291. */
  292. materialIndex: number;
  293. /**
  294. * Creates a new sorted particle
  295. * @param idx
  296. * @param ind
  297. * @param indLength
  298. * @param materialIndex
  299. */
  300. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  301. }
  302. /**
  303. * Represents a solid particle vertex
  304. */
  305. export declare class SolidParticleVertex {
  306. /**
  307. * Vertex position
  308. */
  309. position: Vector3;
  310. /**
  311. * Vertex color
  312. */
  313. color: Color4;
  314. /**
  315. * Vertex UV
  316. */
  317. uv: Vector2;
  318. /**
  319. * Creates a new solid particle vertex
  320. */
  321. constructor();
  322. /** Vertex x coordinate */
  323. get x(): number;
  324. set x(val: number);
  325. /** Vertex y coordinate */
  326. get y(): number;
  327. set y(val: number);
  328. /** Vertex z coordinate */
  329. get z(): number;
  330. set z(val: number);
  331. }