@babylonjs/core 8.51.2 → 8.52.1

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 (70) hide show
  1. package/Animations/animatorAvatar.d.ts +31 -16
  2. package/Animations/animatorAvatar.js +138 -86
  3. package/Animations/animatorAvatar.js.map +1 -1
  4. package/Behaviors/Meshes/pointerDragBehavior.d.ts +6 -0
  5. package/Behaviors/Meshes/pointerDragBehavior.js +4 -0
  6. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  7. package/Engines/Extensions/engine.multiview.d.ts +2 -0
  8. package/Engines/Extensions/engine.multiview.js +7 -3
  9. package/Engines/Extensions/engine.multiview.js.map +1 -1
  10. package/Engines/abstractEngine.js +2 -2
  11. package/Engines/abstractEngine.js.map +1 -1
  12. package/Gizmos/axisDragGizmo.d.ts +1 -1
  13. package/Gizmos/axisDragGizmo.js +13 -5
  14. package/Gizmos/axisDragGizmo.js.map +1 -1
  15. package/Gizmos/gizmo.js +8 -2
  16. package/Gizmos/gizmo.js.map +1 -1
  17. package/Gizmos/planeDragGizmo.js +10 -3
  18. package/Gizmos/planeDragGizmo.js.map +1 -1
  19. package/Gizmos/planeRotationGizmo.js +10 -0
  20. package/Gizmos/planeRotationGizmo.js.map +1 -1
  21. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  22. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  23. package/Lights/Shadows/shadowGenerator.js +2 -3
  24. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  25. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +1 -1
  26. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +3 -1
  27. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  28. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +10 -4
  29. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  30. package/Materials/Textures/mirrorTexture.js +1 -1
  31. package/Materials/Textures/mirrorTexture.js.map +1 -1
  32. package/Materials/Textures/texture.js +15 -4
  33. package/Materials/Textures/texture.js.map +1 -1
  34. package/Materials/effect.functions.js +29 -21
  35. package/Materials/effect.functions.js.map +1 -1
  36. package/Meshes/instancedMesh.js +1 -0
  37. package/Meshes/instancedMesh.js.map +1 -1
  38. package/Meshes/mesh.d.ts +5 -0
  39. package/Meshes/mesh.js +39 -16
  40. package/Meshes/mesh.js.map +1 -1
  41. package/Meshes/thinInstanceMesh.d.ts +7 -3
  42. package/Meshes/thinInstanceMesh.js +15 -3
  43. package/Meshes/thinInstanceMesh.js.map +1 -1
  44. package/Particles/EmitterTypes/coneParticleEmitter.js +3 -3
  45. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  46. package/Particles/EmitterTypes/sphereParticleEmitter.js +2 -2
  47. package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
  48. package/Particles/Node/nodeParticleSystemSet.helper.js +9 -4
  49. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  50. package/Probes/reflectionProbe.js +9 -6
  51. package/Probes/reflectionProbe.js.map +1 -1
  52. package/Rendering/objectRenderer.d.ts +3 -1
  53. package/Rendering/objectRenderer.js +28 -8
  54. package/Rendering/objectRenderer.js.map +1 -1
  55. package/Rendering/reflectiveShadowMap.js +1 -1
  56. package/Rendering/reflectiveShadowMap.js.map +1 -1
  57. package/Rendering/thinDepthPeelingRenderer.js +8 -0
  58. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  59. package/Shaders/gpuUpdateParticles.vertex.js +1 -1
  60. package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
  61. package/ShadersWGSL/ShadersInclude/depthPrePass.js +4 -1
  62. package/ShadersWGSL/ShadersInclude/depthPrePass.js.map +1 -1
  63. package/ShadersWGSL/default.fragment.js +1 -1
  64. package/ShadersWGSL/default.fragment.js.map +1 -1
  65. package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
  66. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  67. package/package.json +1 -1
  68. package/scene.d.ts +16 -0
  69. package/scene.js +7 -14
  70. package/scene.js.map +1 -1
@@ -75,10 +75,14 @@ declare module "./mesh.js" {
75
75
  * Applies a partial update to a buffer directly on the GPU
76
76
  * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
77
77
  * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
78
- * @param data the data to set in the GPU buffer
79
- * @param offset the offset in the GPU buffer where to update the data
78
+ * @param dataOrLength the data to set in the GPU buffer, or the length (in elements) of data to update starting from the offset.
79
+ * If you pass a length (number), it is the number of elements to update. For example, if kind is "matrix" and you pass 2 as length, it will update 2 matrices (2*16 floats) in the GPU buffer starting from the offset; in this case {@link offset} should also be expressed as a number of elements.
80
+ * If you pass a Float32Array, {@link offset} is interpreted in floats in the underlying GPU buffer, consistent with low-level buffer update methods such as updateDirectly.
81
+ * @param offset the offset in the GPU buffer where to update the data:
82
+ * - when {@link dataOrLength} is a number, this is an element offset (for example, a matrix index);
83
+ * - when {@link dataOrLength} is a Float32Array, this is a float offset in the underlying buffer.
80
84
  */
81
- thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
85
+ thinInstancePartialBufferUpdate(kind: string, dataOrLength: Float32Array | number, offset: number): void;
82
86
  /**
83
87
  * Refreshes the bounding info, taking into account all the thin instances defined
84
88
  * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
@@ -188,10 +188,15 @@ Mesh.prototype.thinInstanceBufferUpdated = function (kind) {
188
188
  }
189
189
  }
190
190
  };
191
- Mesh.prototype.thinInstancePartialBufferUpdate = function (kind, data, offset) {
191
+ Mesh.prototype.thinInstancePartialBufferUpdate = function (kind, dataOrLength, offset) {
192
192
  if (kind === "matrix") {
193
193
  if (this._thinInstanceDataStorage.matrixBuffer) {
194
- this._thinInstanceDataStorage.matrixBuffer.updateDirectly(data, offset);
194
+ if (typeof dataOrLength === "number") {
195
+ this._thinInstanceDataStorage.matrixBuffer.updateDirectly(new Float32Array(this._thinInstanceDataStorage.matrixData.buffer, this._thinInstanceDataStorage.matrixData.byteOffset + offset * 16 * Float32Array.BYTES_PER_ELEMENT, dataOrLength * 16), offset * 16);
196
+ }
197
+ else {
198
+ this._thinInstanceDataStorage.matrixBuffer.updateDirectly(dataOrLength, offset);
199
+ }
195
200
  }
196
201
  }
197
202
  else {
@@ -200,7 +205,14 @@ Mesh.prototype.thinInstancePartialBufferUpdate = function (kind, data, offset) {
200
205
  kind = VertexBuffer.ColorInstanceKind;
201
206
  }
202
207
  if (this._userThinInstanceBuffersStorage?.vertexBuffers[kind]) {
203
- this._userThinInstanceBuffersStorage.vertexBuffers[kind].updateDirectly(data, offset);
208
+ const buffer = this._userThinInstanceBuffersStorage.vertexBuffers[kind];
209
+ if (typeof dataOrLength === "number") {
210
+ const data = new Float32Array(this._userThinInstanceBuffersStorage.data[kind].buffer, this._userThinInstanceBuffersStorage.data[kind].byteOffset + offset * this._userThinInstanceBuffersStorage.strides[kind] * Float32Array.BYTES_PER_ELEMENT, dataOrLength * this._userThinInstanceBuffersStorage.strides[kind]);
211
+ this._userThinInstanceBuffersStorage.vertexBuffers[kind].updateDirectly(data, offset * this._userThinInstanceBuffersStorage.strides[kind]);
212
+ }
213
+ else {
214
+ buffer.updateDirectly(dataOrLength, offset);
215
+ }
204
216
  }
205
217
  }
206
218
  };
@@ -1 +1 @@
1
- {"version":3,"file":"thinInstanceMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/thinInstanceMesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,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import type { Nullable, DeepImmutableObject } from \"../types\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { VertexBuffer, Buffer } from \"../Buffers/buffer\";\r\nimport { Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { BoundingInfo } from \"core/Culling/boundingInfo\";\r\n\r\ndeclare module \"./mesh\" {\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Mesh {\r\n /**\r\n * Gets or sets a boolean defining if we want picking to pick thin instances as well\r\n */\r\n thinInstanceEnablePicking: boolean;\r\n\r\n /**\r\n * Indicates that a buffer created as static should be recreated if the buffer is updated (by calling thinInstanceSetMatrixAt or thinInstanceSetAttributeAt, for eg.)\r\n * If this flag is false (the default behavior), a buffer created as \"static\" won't show any update done to it, and will stay the same as it was created.\r\n * Note however that recreating a buffer each time there's a change will have some performance cost, that's why it is set to false by default.\r\n * You should set this flag to true only if your static buffers should change infrequently. If they change frequently, you should create your buffers as \"dynamic\" instead.\r\n */\r\n thinInstanceAllowAutomaticStaticBufferRecreation: boolean;\r\n\r\n /**\r\n * Creates a new thin instance\r\n * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc\r\n */\r\n thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh?: boolean): number;\r\n\r\n /**\r\n * Adds the transformation (matrix) of the current mesh as a thin instance\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n * @returns the thin instance index number\r\n */\r\n thinInstanceAddSelf(refresh?: boolean): number;\r\n\r\n /**\r\n * Registers a custom attribute to be used with thin instances\r\n * @param kind name of the attribute\r\n * @param stride size in floats of the attribute\r\n */\r\n thinInstanceRegisterAttribute(kind: string, stride: number): void;\r\n\r\n /**\r\n * Sets the matrix of a thin instance\r\n * @param index index of the thin instance\r\n * @param matrix matrix to set\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n */\r\n thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh?: boolean): void;\r\n\r\n /**\r\n * Sets the value of a custom attribute for a thin instance\r\n * @param kind name of the attribute\r\n * @param index index of the thin instance\r\n * @param value value to set\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n */\r\n thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh?: boolean): void;\r\n\r\n /**\r\n * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.\r\n */\r\n thinInstanceCount: number;\r\n\r\n /**\r\n * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly\r\n * @param kind name of the attribute. Use \"matrix\" to setup the buffer of matrices\r\n * @param buffer buffer to set\r\n * @param stride size in floats of each value of the buffer\r\n * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - true by default)\r\n */\r\n thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride?: number, staticBuffer?: boolean): void;\r\n\r\n /**\r\n * Gets the list of world matrices\r\n * @returns an array containing all the world matrices from the thin instances\r\n */\r\n thinInstanceGetWorldMatrices(): Matrix[];\r\n\r\n /**\r\n * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer\r\n * @param kind name of the attribute to update. Use \"matrix\" to update the buffer of matrices\r\n */\r\n thinInstanceBufferUpdated(kind: string): void;\r\n\r\n /**\r\n * Applies a partial update to a buffer directly on the GPU\r\n * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method\r\n * @param kind name of the attribute to update. Use \"matrix\" to update the buffer of matrices\r\n * @param data the data to set in the GPU buffer\r\n * @param offset the offset in the GPU buffer where to update the data\r\n */\r\n thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;\r\n\r\n /**\r\n * Refreshes the bounding info, taking into account all the thin instances defined\r\n * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info\r\n * @param applySkeleton defines whether to apply the skeleton before computing the bounding info\r\n * @param applyMorph defines whether to apply the morph target before computing the bounding info\r\n */\r\n thinInstanceRefreshBoundingInfo(forceRefreshParentInfo?: boolean, applySkeleton?: boolean, applyMorph?: boolean): void;\r\n\r\n /** @internal */\r\n _thinInstanceInitializeUserStorage(): void;\r\n\r\n /** @internal */\r\n _thinInstanceUpdateBufferSize(kind: string, numInstances?: number): void;\r\n\r\n /** @internal */\r\n _thinInstanceCreateMatrixBuffer(kind: string, buffer: Nullable<Float32Array>, staticBuffer: boolean): Buffer;\r\n\r\n /** @internal */\r\n _thinInstanceRecreateBuffer(kind: string, staticBuffer?: boolean): void;\r\n\r\n /** @internal */\r\n _userThinInstanceBuffersStorage: {\r\n /** @internal */\r\n data: { [key: string]: Float32Array };\r\n /** @internal */\r\n sizes: { [key: string]: number };\r\n /** @internal */\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n /** @internal */\r\n strides: { [key: string]: number };\r\n };\r\n }\r\n}\r\n\r\nMesh.prototype.thinInstanceAdd = function (matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean = true): number {\r\n if (!this.getScene().getEngine().getCaps().instancedArrays) {\r\n Logger.Error(\"Thin Instances are not supported on this device as Instanced Array extension not supported\");\r\n return -1;\r\n }\r\n\r\n this._thinInstanceUpdateBufferSize(\"matrix\", Array.isArray(matrix) ? matrix.length : 1);\r\n\r\n const index = this._thinInstanceDataStorage.instancesCount;\r\n\r\n if (Array.isArray(matrix)) {\r\n for (let i = 0; i < matrix.length; ++i) {\r\n this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, matrix[i], i === matrix.length - 1 && refresh);\r\n }\r\n } else {\r\n this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, matrix, refresh);\r\n }\r\n\r\n return index;\r\n};\r\n\r\nMesh.prototype.thinInstanceAddSelf = function (refresh: boolean = true): number {\r\n return this.thinInstanceAdd(Matrix.IdentityReadOnly, refresh);\r\n};\r\n\r\nMesh.prototype.thinInstanceRegisterAttribute = function (kind: string, stride: number): void {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n this.removeVerticesData(kind);\r\n\r\n this._thinInstanceInitializeUserStorage();\r\n\r\n this._userThinInstanceBuffersStorage.strides[kind] = stride;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = stride * Math.max(32, this._thinInstanceDataStorage.instancesCount); // Initial size\r\n this._userThinInstanceBuffersStorage.data[kind] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[kind]);\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userThinInstanceBuffersStorage.data[kind], kind, true, false, stride, true);\r\n\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n};\r\n\r\nMesh.prototype.thinInstanceSetMatrixAt = function (index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean = true): boolean {\r\n if (!this._thinInstanceDataStorage.matrixData || index >= this._thinInstanceDataStorage.instancesCount) {\r\n return false;\r\n }\r\n\r\n const matrixData = this._thinInstanceDataStorage.matrixData;\r\n\r\n matrix.copyToArray(matrixData, index * 16);\r\n\r\n if (this._thinInstanceDataStorage.worldMatrices) {\r\n this._thinInstanceDataStorage.worldMatrices[index] = matrix as Matrix;\r\n }\r\n\r\n if (refresh) {\r\n this.thinInstanceBufferUpdated(\"matrix\");\r\n\r\n if (!this.doNotSyncBoundingInfo) {\r\n this.thinInstanceRefreshBoundingInfo(false);\r\n }\r\n }\r\n\r\n return true;\r\n};\r\n\r\nMesh.prototype.thinInstanceSetAttributeAt = function (kind: string, index: number, value: Array<number>, refresh: boolean = true): boolean {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.data[kind] || index >= this._thinInstanceDataStorage.instancesCount) {\r\n return false;\r\n }\r\n\r\n this._thinInstanceUpdateBufferSize(kind, 0); // make sur the buffer for the kind attribute is big enough\r\n\r\n this._userThinInstanceBuffersStorage.data[kind].set(value, index * this._userThinInstanceBuffersStorage.strides[kind]);\r\n\r\n if (refresh) {\r\n this.thinInstanceBufferUpdated(kind);\r\n }\r\n\r\n return true;\r\n};\r\n\r\nObject.defineProperty(Mesh.prototype, \"thinInstanceCount\", {\r\n get: function (this: Mesh) {\r\n return this._thinInstanceDataStorage.instancesCount;\r\n },\r\n set: function (this: Mesh, value: number) {\r\n const matrixData = this._thinInstanceDataStorage.matrixData ?? this.source?._thinInstanceDataStorage.matrixData;\r\n const numMaxInstances = matrixData ? matrixData.length / 16 : 0;\r\n\r\n if (value <= numMaxInstances) {\r\n this._thinInstanceDataStorage.instancesCount = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nMesh.prototype._thinInstanceCreateMatrixBuffer = function (kind: string, buffer: Float32Array, staticBuffer: boolean = true): Buffer {\r\n const matrixBuffer = new Buffer(this.getEngine(), buffer, !staticBuffer, 16, false, true);\r\n\r\n for (let i = 0; i < 4; i++) {\r\n this.setVerticesBuffer(matrixBuffer.createVertexBuffer(kind + i, i * 4, 4));\r\n }\r\n\r\n return matrixBuffer;\r\n};\r\n\r\nMesh.prototype.thinInstanceSetBuffer = function (kind: string, buffer: Nullable<Float32Array>, stride: number = 0, staticBuffer: boolean = true): void {\r\n stride = stride || 16;\r\n\r\n if (kind === \"matrix\") {\r\n this._thinInstanceDataStorage.matrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = null;\r\n this._thinInstanceDataStorage.matrixBufferSize = buffer ? buffer.length : 32 * stride;\r\n this._thinInstanceDataStorage.matrixData = buffer;\r\n this._thinInstanceDataStorage.worldMatrices = null;\r\n\r\n if (buffer !== null) {\r\n this._thinInstanceDataStorage.instancesCount = buffer.length / stride;\r\n this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer(\"world\", buffer, staticBuffer);\r\n\r\n if (!this.doNotSyncBoundingInfo) {\r\n this.thinInstanceRefreshBoundingInfo(false);\r\n }\r\n } else {\r\n this._thinInstanceDataStorage.instancesCount = 0;\r\n if (!this.doNotSyncBoundingInfo) {\r\n // mesh has no more thin instances, so need to recompute the bounding box because it's the regular mesh that will now be displayed\r\n this.refreshBoundingInfo();\r\n }\r\n }\r\n } else if (kind === \"previousMatrix\") {\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = null;\r\n this._thinInstanceDataStorage.previousMatrixData = buffer;\r\n if (buffer !== null) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer(\"previousWorld\", buffer, staticBuffer);\r\n }\r\n } else if (kind === \"splatIndex\" && buffer) {\r\n this._thinInstanceInitializeUserStorage();\r\n this._thinInstanceDataStorage.instancesCount = buffer.length / stride;\r\n this._userThinInstanceBuffersStorage.data[kind] = buffer;\r\n this._userThinInstanceBuffersStorage.strides[kind] = stride;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = buffer.length;\r\n const splatInstancesBuffer = new Buffer(this.getEngine(), buffer, true, 16, false, true);\r\n this._thinInstanceDataStorage.matrixBuffer = splatInstancesBuffer;\r\n for (let i = 0; i < 4; i++) {\r\n this.setVerticesBuffer(splatInstancesBuffer.createVertexBuffer(kind + i, i * 4, 4));\r\n }\r\n } else {\r\n // color for instanced mesh is ColorInstanceKind and not ColorKind because of native that needs to do the differenciation\r\n // hot switching kind here to preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (buffer === null) {\r\n if (this._userThinInstanceBuffersStorage?.data[kind]) {\r\n this.removeVerticesData(kind);\r\n delete this._userThinInstanceBuffersStorage.data[kind];\r\n delete this._userThinInstanceBuffersStorage.strides[kind];\r\n delete this._userThinInstanceBuffersStorage.sizes[kind];\r\n delete this._userThinInstanceBuffersStorage.vertexBuffers[kind];\r\n }\r\n } else {\r\n this._thinInstanceInitializeUserStorage();\r\n\r\n this._userThinInstanceBuffersStorage.data[kind] = buffer;\r\n this._userThinInstanceBuffersStorage.strides[kind] = stride;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = buffer.length;\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), buffer, kind, !staticBuffer, false, stride, true);\r\n\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype.thinInstanceBufferUpdated = function (kind: string): void {\r\n if (kind === \"matrix\") {\r\n if (this.thinInstanceAllowAutomaticStaticBufferRecreation && this._thinInstanceDataStorage.matrixBuffer && !this._thinInstanceDataStorage.matrixBuffer.isUpdatable()) {\r\n this._thinInstanceRecreateBuffer(kind);\r\n }\r\n this._thinInstanceDataStorage.matrixBuffer?.updateDirectly(this._thinInstanceDataStorage.matrixData!, 0, this._thinInstanceDataStorage.instancesCount);\r\n } else if (kind === \"previousMatrix\") {\r\n if (\r\n this.thinInstanceAllowAutomaticStaticBufferRecreation &&\r\n this._thinInstanceDataStorage.previousMatrixBuffer &&\r\n !this._thinInstanceDataStorage.previousMatrixBuffer.isUpdatable()\r\n ) {\r\n this._thinInstanceRecreateBuffer(kind);\r\n }\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.updateDirectly(this._thinInstanceDataStorage.previousMatrixData!, 0, this._thinInstanceDataStorage.instancesCount);\r\n } else if (kind === \"splatIndex\") {\r\n this._thinInstanceDataStorage.matrixBuffer?.updateDirectly(this._userThinInstanceBuffersStorage.data[kind], 0, this._thinInstanceDataStorage.instancesCount);\r\n } else {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (this._userThinInstanceBuffersStorage?.vertexBuffers[kind]) {\r\n if (this.thinInstanceAllowAutomaticStaticBufferRecreation && !this._userThinInstanceBuffersStorage.vertexBuffers[kind]!.isUpdatable()) {\r\n this._thinInstanceRecreateBuffer(kind);\r\n }\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]!.updateDirectly(this._userThinInstanceBuffersStorage.data[kind], 0);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype.thinInstancePartialBufferUpdate = function (kind: string, data: Float32Array, offset: number): void {\r\n if (kind === \"matrix\") {\r\n if (this._thinInstanceDataStorage.matrixBuffer) {\r\n this._thinInstanceDataStorage.matrixBuffer.updateDirectly(data, offset);\r\n }\r\n } else {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (this._userThinInstanceBuffersStorage?.vertexBuffers[kind]) {\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, offset);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype.thinInstanceGetWorldMatrices = function (): Matrix[] {\r\n if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {\r\n return [];\r\n }\r\n const matrixData = this._thinInstanceDataStorage.matrixData;\r\n\r\n if (!this._thinInstanceDataStorage.worldMatrices) {\r\n this._thinInstanceDataStorage.worldMatrices = [] as Matrix[];\r\n\r\n for (let i = 0; i < this._thinInstanceDataStorage.instancesCount; ++i) {\r\n this._thinInstanceDataStorage.worldMatrices[i] = Matrix.FromArray(matrixData, i * 16);\r\n }\r\n }\r\n\r\n return this._thinInstanceDataStorage.worldMatrices;\r\n};\r\n\r\nMesh.prototype.thinInstanceRefreshBoundingInfo = function (forceRefreshParentInfo: boolean = false, applySkeleton: boolean = false, applyMorph: boolean = false) {\r\n if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {\r\n return;\r\n }\r\n\r\n const vectors = this._thinInstanceDataStorage.boundingVectors;\r\n\r\n if (forceRefreshParentInfo || !this.rawBoundingInfo) {\r\n vectors.length = 0;\r\n this.refreshBoundingInfo(applySkeleton, applyMorph);\r\n const boundingInfo = this.getBoundingInfo();\r\n this.rawBoundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n const boundingInfo = this.getBoundingInfo();\r\n const matrixData = this._thinInstanceDataStorage.matrixData;\r\n\r\n if (vectors.length === 0) {\r\n for (let v = 0; v < boundingInfo.boundingBox.vectors.length; ++v) {\r\n vectors.push(boundingInfo.boundingBox.vectors[v].clone());\r\n }\r\n }\r\n\r\n TmpVectors.Vector3[0].setAll(Number.POSITIVE_INFINITY); // min\r\n TmpVectors.Vector3[1].setAll(Number.NEGATIVE_INFINITY); // max\r\n\r\n for (let i = 0; i < this._thinInstanceDataStorage.instancesCount; ++i) {\r\n Matrix.FromArrayToRef(matrixData, i * 16, TmpVectors.Matrix[0]);\r\n\r\n for (let v = 0; v < vectors.length; ++v) {\r\n Vector3.TransformCoordinatesToRef(vectors[v], TmpVectors.Matrix[0], TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[0].minimizeInPlace(TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[1].maximizeInPlace(TmpVectors.Vector3[2]);\r\n }\r\n }\r\n\r\n boundingInfo.reConstruct(TmpVectors.Vector3[0], TmpVectors.Vector3[1]);\r\n\r\n this._updateBoundingInfo();\r\n};\r\n\r\nMesh.prototype._thinInstanceRecreateBuffer = function (kind: string, staticBuffer: boolean = true) {\r\n if (kind === \"matrix\") {\r\n this._thinInstanceDataStorage.matrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer(\"world\", this._thinInstanceDataStorage.matrixData, staticBuffer);\r\n } else if (kind === \"previousMatrix\") {\r\n if (this._scene.needsPreviousWorldMatrices) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer(\r\n \"previousWorld\",\r\n this._thinInstanceDataStorage.previousMatrixData ?? this._thinInstanceDataStorage.matrixData,\r\n staticBuffer\r\n );\r\n }\r\n } else {\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]?.dispose();\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(\r\n this.getEngine(),\r\n this._userThinInstanceBuffersStorage.data[kind],\r\n kind,\r\n !staticBuffer,\r\n false,\r\n this._userThinInstanceBuffersStorage.strides[kind],\r\n true\r\n );\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n }\r\n};\r\n\r\nMesh.prototype._thinInstanceUpdateBufferSize = function (kind: string, numInstances: number = 1) {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n const kindIsMatrix = kind === \"matrix\";\r\n\r\n if (!kindIsMatrix && (!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.strides[kind])) {\r\n return;\r\n }\r\n\r\n const stride = kindIsMatrix ? 16 : this._userThinInstanceBuffersStorage.strides[kind];\r\n const currentSize = kindIsMatrix ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[kind];\r\n let data = kindIsMatrix ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[kind];\r\n\r\n const bufferSize = (this._thinInstanceDataStorage.instancesCount + numInstances) * stride;\r\n\r\n let newSize = currentSize;\r\n\r\n while (newSize < bufferSize) {\r\n newSize *= 2;\r\n }\r\n\r\n if (!data || currentSize != newSize) {\r\n if (!data) {\r\n data = new Float32Array(newSize);\r\n } else {\r\n const newData = new Float32Array(newSize);\r\n newData.set(data, 0);\r\n data = newData;\r\n }\r\n\r\n if (kindIsMatrix) {\r\n this._thinInstanceDataStorage.matrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer(\"world\", data, false);\r\n this._thinInstanceDataStorage.matrixData = data;\r\n this._thinInstanceDataStorage.matrixBufferSize = newSize;\r\n if (this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer(\"previousWorld\", data, false);\r\n }\r\n } else {\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]?.dispose();\r\n\r\n this._userThinInstanceBuffersStorage.data[kind] = data;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = newSize;\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), data, kind, true, false, stride, true);\r\n\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype._thinInstanceInitializeUserStorage = function () {\r\n if (!this._userThinInstanceBuffersStorage) {\r\n this._userThinInstanceBuffersStorage = {\r\n data: {},\r\n sizes: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n };\r\n }\r\n};\r\n\r\nMesh.prototype._disposeThinInstanceSpecificData = function () {\r\n if (this._thinInstanceDataStorage?.matrixBuffer) {\r\n this._thinInstanceDataStorage.matrixBuffer.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = null;\r\n }\r\n if (this._thinInstanceDataStorage?.previousMatrixBuffer) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = null;\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"thinInstanceMesh.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/thinInstanceMesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,mCAAkC;AAmIzD,IAAI,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,MAAwE,EAAE,UAAmB,IAAI;IACxI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,eAAe,EAAE,CAAC;QACzD,MAAM,CAAC,KAAK,CAAC,4FAA4F,CAAC,CAAC;QAC3G,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;IAED,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAExF,MAAM,KAAK,GAAG,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC;IAE3D,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,wBAAw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G,IAAI,CAAC;IACtD,CAAC;IACD,IAAI,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,EAAE,CAAC;QACtD,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QAC7D,IAAI,CAAC,wBAAwB,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAC9D,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Nullable, DeepImmutableObject } from \"../types\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { VertexBuffer, Buffer } from \"../Buffers/buffer\";\r\nimport { Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { BoundingInfo } from \"core/Culling/boundingInfo\";\r\n\r\ndeclare module \"./mesh\" {\r\n /** @internal */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface Mesh {\r\n /**\r\n * Gets or sets a boolean defining if we want picking to pick thin instances as well\r\n */\r\n thinInstanceEnablePicking: boolean;\r\n\r\n /**\r\n * Indicates that a buffer created as static should be recreated if the buffer is updated (by calling thinInstanceSetMatrixAt or thinInstanceSetAttributeAt, for eg.)\r\n * If this flag is false (the default behavior), a buffer created as \"static\" won't show any update done to it, and will stay the same as it was created.\r\n * Note however that recreating a buffer each time there's a change will have some performance cost, that's why it is set to false by default.\r\n * You should set this flag to true only if your static buffers should change infrequently. If they change frequently, you should create your buffers as \"dynamic\" instead.\r\n */\r\n thinInstanceAllowAutomaticStaticBufferRecreation: boolean;\r\n\r\n /**\r\n * Creates a new thin instance\r\n * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc\r\n */\r\n thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh?: boolean): number;\r\n\r\n /**\r\n * Adds the transformation (matrix) of the current mesh as a thin instance\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n * @returns the thin instance index number\r\n */\r\n thinInstanceAddSelf(refresh?: boolean): number;\r\n\r\n /**\r\n * Registers a custom attribute to be used with thin instances\r\n * @param kind name of the attribute\r\n * @param stride size in floats of the attribute\r\n */\r\n thinInstanceRegisterAttribute(kind: string, stride: number): void;\r\n\r\n /**\r\n * Sets the matrix of a thin instance\r\n * @param index index of the thin instance\r\n * @param matrix matrix to set\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n */\r\n thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh?: boolean): void;\r\n\r\n /**\r\n * Sets the value of a custom attribute for a thin instance\r\n * @param kind name of the attribute\r\n * @param index index of the thin instance\r\n * @param value value to set\r\n * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance\r\n */\r\n thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh?: boolean): void;\r\n\r\n /**\r\n * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.\r\n */\r\n thinInstanceCount: number;\r\n\r\n /**\r\n * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly\r\n * @param kind name of the attribute. Use \"matrix\" to setup the buffer of matrices\r\n * @param buffer buffer to set\r\n * @param stride size in floats of each value of the buffer\r\n * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - true by default)\r\n */\r\n thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride?: number, staticBuffer?: boolean): void;\r\n\r\n /**\r\n * Gets the list of world matrices\r\n * @returns an array containing all the world matrices from the thin instances\r\n */\r\n thinInstanceGetWorldMatrices(): Matrix[];\r\n\r\n /**\r\n * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer\r\n * @param kind name of the attribute to update. Use \"matrix\" to update the buffer of matrices\r\n */\r\n thinInstanceBufferUpdated(kind: string): void;\r\n\r\n /**\r\n * Applies a partial update to a buffer directly on the GPU\r\n * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method\r\n * @param kind name of the attribute to update. Use \"matrix\" to update the buffer of matrices\r\n * @param dataOrLength the data to set in the GPU buffer, or the length (in elements) of data to update starting from the offset.\r\n * If you pass a length (number), it is the number of elements to update. For example, if kind is \"matrix\" and you pass 2 as length, it will update 2 matrices (2*16 floats) in the GPU buffer starting from the offset; in this case {@link offset} should also be expressed as a number of elements.\r\n * If you pass a Float32Array, {@link offset} is interpreted in floats in the underlying GPU buffer, consistent with low-level buffer update methods such as updateDirectly.\r\n * @param offset the offset in the GPU buffer where to update the data:\r\n * - when {@link dataOrLength} is a number, this is an element offset (for example, a matrix index);\r\n * - when {@link dataOrLength} is a Float32Array, this is a float offset in the underlying buffer.\r\n */\r\n thinInstancePartialBufferUpdate(kind: string, dataOrLength: Float32Array | number, offset: number): void;\r\n\r\n /**\r\n * Refreshes the bounding info, taking into account all the thin instances defined\r\n * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info\r\n * @param applySkeleton defines whether to apply the skeleton before computing the bounding info\r\n * @param applyMorph defines whether to apply the morph target before computing the bounding info\r\n */\r\n thinInstanceRefreshBoundingInfo(forceRefreshParentInfo?: boolean, applySkeleton?: boolean, applyMorph?: boolean): void;\r\n\r\n /** @internal */\r\n _thinInstanceInitializeUserStorage(): void;\r\n\r\n /** @internal */\r\n _thinInstanceUpdateBufferSize(kind: string, numInstances?: number): void;\r\n\r\n /** @internal */\r\n _thinInstanceCreateMatrixBuffer(kind: string, buffer: Nullable<Float32Array>, staticBuffer: boolean): Buffer;\r\n\r\n /** @internal */\r\n _thinInstanceRecreateBuffer(kind: string, staticBuffer?: boolean): void;\r\n\r\n /** @internal */\r\n _userThinInstanceBuffersStorage: {\r\n /** @internal */\r\n data: { [key: string]: Float32Array };\r\n /** @internal */\r\n sizes: { [key: string]: number };\r\n /** @internal */\r\n vertexBuffers: { [key: string]: Nullable<VertexBuffer> };\r\n /** @internal */\r\n strides: { [key: string]: number };\r\n };\r\n }\r\n}\r\n\r\nMesh.prototype.thinInstanceAdd = function (matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean = true): number {\r\n if (!this.getScene().getEngine().getCaps().instancedArrays) {\r\n Logger.Error(\"Thin Instances are not supported on this device as Instanced Array extension not supported\");\r\n return -1;\r\n }\r\n\r\n this._thinInstanceUpdateBufferSize(\"matrix\", Array.isArray(matrix) ? matrix.length : 1);\r\n\r\n const index = this._thinInstanceDataStorage.instancesCount;\r\n\r\n if (Array.isArray(matrix)) {\r\n for (let i = 0; i < matrix.length; ++i) {\r\n this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, matrix[i], i === matrix.length - 1 && refresh);\r\n }\r\n } else {\r\n this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++, matrix, refresh);\r\n }\r\n\r\n return index;\r\n};\r\n\r\nMesh.prototype.thinInstanceAddSelf = function (refresh: boolean = true): number {\r\n return this.thinInstanceAdd(Matrix.IdentityReadOnly, refresh);\r\n};\r\n\r\nMesh.prototype.thinInstanceRegisterAttribute = function (kind: string, stride: number): void {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n this.removeVerticesData(kind);\r\n\r\n this._thinInstanceInitializeUserStorage();\r\n\r\n this._userThinInstanceBuffersStorage.strides[kind] = stride;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = stride * Math.max(32, this._thinInstanceDataStorage.instancesCount); // Initial size\r\n this._userThinInstanceBuffersStorage.data[kind] = new Float32Array(this._userThinInstanceBuffersStorage.sizes[kind]);\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userThinInstanceBuffersStorage.data[kind], kind, true, false, stride, true);\r\n\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n};\r\n\r\nMesh.prototype.thinInstanceSetMatrixAt = function (index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean = true): boolean {\r\n if (!this._thinInstanceDataStorage.matrixData || index >= this._thinInstanceDataStorage.instancesCount) {\r\n return false;\r\n }\r\n\r\n const matrixData = this._thinInstanceDataStorage.matrixData;\r\n\r\n matrix.copyToArray(matrixData, index * 16);\r\n\r\n if (this._thinInstanceDataStorage.worldMatrices) {\r\n this._thinInstanceDataStorage.worldMatrices[index] = matrix as Matrix;\r\n }\r\n\r\n if (refresh) {\r\n this.thinInstanceBufferUpdated(\"matrix\");\r\n\r\n if (!this.doNotSyncBoundingInfo) {\r\n this.thinInstanceRefreshBoundingInfo(false);\r\n }\r\n }\r\n\r\n return true;\r\n};\r\n\r\nMesh.prototype.thinInstanceSetAttributeAt = function (kind: string, index: number, value: Array<number>, refresh: boolean = true): boolean {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.data[kind] || index >= this._thinInstanceDataStorage.instancesCount) {\r\n return false;\r\n }\r\n\r\n this._thinInstanceUpdateBufferSize(kind, 0); // make sur the buffer for the kind attribute is big enough\r\n\r\n this._userThinInstanceBuffersStorage.data[kind].set(value, index * this._userThinInstanceBuffersStorage.strides[kind]);\r\n\r\n if (refresh) {\r\n this.thinInstanceBufferUpdated(kind);\r\n }\r\n\r\n return true;\r\n};\r\n\r\nObject.defineProperty(Mesh.prototype, \"thinInstanceCount\", {\r\n get: function (this: Mesh) {\r\n return this._thinInstanceDataStorage.instancesCount;\r\n },\r\n set: function (this: Mesh, value: number) {\r\n const matrixData = this._thinInstanceDataStorage.matrixData ?? this.source?._thinInstanceDataStorage.matrixData;\r\n const numMaxInstances = matrixData ? matrixData.length / 16 : 0;\r\n\r\n if (value <= numMaxInstances) {\r\n this._thinInstanceDataStorage.instancesCount = value;\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nMesh.prototype._thinInstanceCreateMatrixBuffer = function (kind: string, buffer: Float32Array, staticBuffer: boolean = true): Buffer {\r\n const matrixBuffer = new Buffer(this.getEngine(), buffer, !staticBuffer, 16, false, true);\r\n\r\n for (let i = 0; i < 4; i++) {\r\n this.setVerticesBuffer(matrixBuffer.createVertexBuffer(kind + i, i * 4, 4));\r\n }\r\n\r\n return matrixBuffer;\r\n};\r\n\r\nMesh.prototype.thinInstanceSetBuffer = function (kind: string, buffer: Nullable<Float32Array>, stride: number = 0, staticBuffer: boolean = true): void {\r\n stride = stride || 16;\r\n\r\n if (kind === \"matrix\") {\r\n this._thinInstanceDataStorage.matrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = null;\r\n this._thinInstanceDataStorage.matrixBufferSize = buffer ? buffer.length : 32 * stride;\r\n this._thinInstanceDataStorage.matrixData = buffer;\r\n this._thinInstanceDataStorage.worldMatrices = null;\r\n\r\n if (buffer !== null) {\r\n this._thinInstanceDataStorage.instancesCount = buffer.length / stride;\r\n this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer(\"world\", buffer, staticBuffer);\r\n\r\n if (!this.doNotSyncBoundingInfo) {\r\n this.thinInstanceRefreshBoundingInfo(false);\r\n }\r\n } else {\r\n this._thinInstanceDataStorage.instancesCount = 0;\r\n if (!this.doNotSyncBoundingInfo) {\r\n // mesh has no more thin instances, so need to recompute the bounding box because it's the regular mesh that will now be displayed\r\n this.refreshBoundingInfo();\r\n }\r\n }\r\n } else if (kind === \"previousMatrix\") {\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = null;\r\n this._thinInstanceDataStorage.previousMatrixData = buffer;\r\n if (buffer !== null) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer(\"previousWorld\", buffer, staticBuffer);\r\n }\r\n } else if (kind === \"splatIndex\" && buffer) {\r\n this._thinInstanceInitializeUserStorage();\r\n this._thinInstanceDataStorage.instancesCount = buffer.length / stride;\r\n this._userThinInstanceBuffersStorage.data[kind] = buffer;\r\n this._userThinInstanceBuffersStorage.strides[kind] = stride;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = buffer.length;\r\n const splatInstancesBuffer = new Buffer(this.getEngine(), buffer, true, 16, false, true);\r\n this._thinInstanceDataStorage.matrixBuffer = splatInstancesBuffer;\r\n for (let i = 0; i < 4; i++) {\r\n this.setVerticesBuffer(splatInstancesBuffer.createVertexBuffer(kind + i, i * 4, 4));\r\n }\r\n } else {\r\n // color for instanced mesh is ColorInstanceKind and not ColorKind because of native that needs to do the differenciation\r\n // hot switching kind here to preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (buffer === null) {\r\n if (this._userThinInstanceBuffersStorage?.data[kind]) {\r\n this.removeVerticesData(kind);\r\n delete this._userThinInstanceBuffersStorage.data[kind];\r\n delete this._userThinInstanceBuffersStorage.strides[kind];\r\n delete this._userThinInstanceBuffersStorage.sizes[kind];\r\n delete this._userThinInstanceBuffersStorage.vertexBuffers[kind];\r\n }\r\n } else {\r\n this._thinInstanceInitializeUserStorage();\r\n\r\n this._userThinInstanceBuffersStorage.data[kind] = buffer;\r\n this._userThinInstanceBuffersStorage.strides[kind] = stride;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = buffer.length;\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), buffer, kind, !staticBuffer, false, stride, true);\r\n\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype.thinInstanceBufferUpdated = function (kind: string): void {\r\n if (kind === \"matrix\") {\r\n if (this.thinInstanceAllowAutomaticStaticBufferRecreation && this._thinInstanceDataStorage.matrixBuffer && !this._thinInstanceDataStorage.matrixBuffer.isUpdatable()) {\r\n this._thinInstanceRecreateBuffer(kind);\r\n }\r\n this._thinInstanceDataStorage.matrixBuffer?.updateDirectly(this._thinInstanceDataStorage.matrixData!, 0, this._thinInstanceDataStorage.instancesCount);\r\n } else if (kind === \"previousMatrix\") {\r\n if (\r\n this.thinInstanceAllowAutomaticStaticBufferRecreation &&\r\n this._thinInstanceDataStorage.previousMatrixBuffer &&\r\n !this._thinInstanceDataStorage.previousMatrixBuffer.isUpdatable()\r\n ) {\r\n this._thinInstanceRecreateBuffer(kind);\r\n }\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.updateDirectly(this._thinInstanceDataStorage.previousMatrixData!, 0, this._thinInstanceDataStorage.instancesCount);\r\n } else if (kind === \"splatIndex\") {\r\n this._thinInstanceDataStorage.matrixBuffer?.updateDirectly(this._userThinInstanceBuffersStorage.data[kind], 0, this._thinInstanceDataStorage.instancesCount);\r\n } else {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (this._userThinInstanceBuffersStorage?.vertexBuffers[kind]) {\r\n if (this.thinInstanceAllowAutomaticStaticBufferRecreation && !this._userThinInstanceBuffersStorage.vertexBuffers[kind]!.isUpdatable()) {\r\n this._thinInstanceRecreateBuffer(kind);\r\n }\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]!.updateDirectly(this._userThinInstanceBuffersStorage.data[kind], 0);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype.thinInstancePartialBufferUpdate = function (kind: string, dataOrLength: Float32Array | number, offset: number): void {\r\n if (kind === \"matrix\") {\r\n if (this._thinInstanceDataStorage.matrixBuffer) {\r\n if (typeof dataOrLength === \"number\") {\r\n this._thinInstanceDataStorage.matrixBuffer.updateDirectly(\r\n new Float32Array(\r\n this._thinInstanceDataStorage.matrixData!.buffer,\r\n this._thinInstanceDataStorage.matrixData!.byteOffset + offset * 16 * Float32Array.BYTES_PER_ELEMENT,\r\n dataOrLength * 16\r\n ),\r\n offset * 16\r\n );\r\n } else {\r\n this._thinInstanceDataStorage.matrixBuffer.updateDirectly(dataOrLength, offset);\r\n }\r\n }\r\n } else {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n if (this._userThinInstanceBuffersStorage?.vertexBuffers[kind]) {\r\n const buffer = this._userThinInstanceBuffersStorage.vertexBuffers[kind]!;\r\n if (typeof dataOrLength === \"number\") {\r\n const data = new Float32Array(\r\n this._userThinInstanceBuffersStorage.data[kind].buffer,\r\n this._userThinInstanceBuffersStorage.data[kind].byteOffset + offset * this._userThinInstanceBuffersStorage.strides[kind] * Float32Array.BYTES_PER_ELEMENT,\r\n dataOrLength * this._userThinInstanceBuffersStorage.strides[kind]\r\n );\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, offset * this._userThinInstanceBuffersStorage.strides[kind]);\r\n } else {\r\n buffer.updateDirectly(dataOrLength, offset);\r\n }\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype.thinInstanceGetWorldMatrices = function (): Matrix[] {\r\n if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {\r\n return [];\r\n }\r\n const matrixData = this._thinInstanceDataStorage.matrixData;\r\n\r\n if (!this._thinInstanceDataStorage.worldMatrices) {\r\n this._thinInstanceDataStorage.worldMatrices = [] as Matrix[];\r\n\r\n for (let i = 0; i < this._thinInstanceDataStorage.instancesCount; ++i) {\r\n this._thinInstanceDataStorage.worldMatrices[i] = Matrix.FromArray(matrixData, i * 16);\r\n }\r\n }\r\n\r\n return this._thinInstanceDataStorage.worldMatrices;\r\n};\r\n\r\nMesh.prototype.thinInstanceRefreshBoundingInfo = function (forceRefreshParentInfo: boolean = false, applySkeleton: boolean = false, applyMorph: boolean = false) {\r\n if (!this._thinInstanceDataStorage.matrixData || !this._thinInstanceDataStorage.matrixBuffer) {\r\n return;\r\n }\r\n\r\n const vectors = this._thinInstanceDataStorage.boundingVectors;\r\n\r\n if (forceRefreshParentInfo || !this.rawBoundingInfo) {\r\n vectors.length = 0;\r\n this.refreshBoundingInfo(applySkeleton, applyMorph);\r\n const boundingInfo = this.getBoundingInfo();\r\n this.rawBoundingInfo = new BoundingInfo(boundingInfo.minimum, boundingInfo.maximum);\r\n }\r\n\r\n const boundingInfo = this.getBoundingInfo();\r\n const matrixData = this._thinInstanceDataStorage.matrixData;\r\n\r\n if (vectors.length === 0) {\r\n for (let v = 0; v < boundingInfo.boundingBox.vectors.length; ++v) {\r\n vectors.push(boundingInfo.boundingBox.vectors[v].clone());\r\n }\r\n }\r\n\r\n TmpVectors.Vector3[0].setAll(Number.POSITIVE_INFINITY); // min\r\n TmpVectors.Vector3[1].setAll(Number.NEGATIVE_INFINITY); // max\r\n\r\n for (let i = 0; i < this._thinInstanceDataStorage.instancesCount; ++i) {\r\n Matrix.FromArrayToRef(matrixData, i * 16, TmpVectors.Matrix[0]);\r\n\r\n for (let v = 0; v < vectors.length; ++v) {\r\n Vector3.TransformCoordinatesToRef(vectors[v], TmpVectors.Matrix[0], TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[0].minimizeInPlace(TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[1].maximizeInPlace(TmpVectors.Vector3[2]);\r\n }\r\n }\r\n\r\n boundingInfo.reConstruct(TmpVectors.Vector3[0], TmpVectors.Vector3[1]);\r\n\r\n this._updateBoundingInfo();\r\n};\r\n\r\nMesh.prototype._thinInstanceRecreateBuffer = function (kind: string, staticBuffer: boolean = true) {\r\n if (kind === \"matrix\") {\r\n this._thinInstanceDataStorage.matrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer(\"world\", this._thinInstanceDataStorage.matrixData, staticBuffer);\r\n } else if (kind === \"previousMatrix\") {\r\n if (this._scene.needsPreviousWorldMatrices) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer(\r\n \"previousWorld\",\r\n this._thinInstanceDataStorage.previousMatrixData ?? this._thinInstanceDataStorage.matrixData,\r\n staticBuffer\r\n );\r\n }\r\n } else {\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]?.dispose();\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(\r\n this.getEngine(),\r\n this._userThinInstanceBuffersStorage.data[kind],\r\n kind,\r\n !staticBuffer,\r\n false,\r\n this._userThinInstanceBuffersStorage.strides[kind],\r\n true\r\n );\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n }\r\n};\r\n\r\nMesh.prototype._thinInstanceUpdateBufferSize = function (kind: string, numInstances: number = 1) {\r\n // preserve backward compatibility\r\n if (kind === VertexBuffer.ColorKind) {\r\n kind = VertexBuffer.ColorInstanceKind;\r\n }\r\n\r\n const kindIsMatrix = kind === \"matrix\";\r\n\r\n if (!kindIsMatrix && (!this._userThinInstanceBuffersStorage || !this._userThinInstanceBuffersStorage.strides[kind])) {\r\n return;\r\n }\r\n\r\n const stride = kindIsMatrix ? 16 : this._userThinInstanceBuffersStorage.strides[kind];\r\n const currentSize = kindIsMatrix ? this._thinInstanceDataStorage.matrixBufferSize : this._userThinInstanceBuffersStorage.sizes[kind];\r\n let data = kindIsMatrix ? this._thinInstanceDataStorage.matrixData : this._userThinInstanceBuffersStorage.data[kind];\r\n\r\n const bufferSize = (this._thinInstanceDataStorage.instancesCount + numInstances) * stride;\r\n\r\n let newSize = currentSize;\r\n\r\n while (newSize < bufferSize) {\r\n newSize *= 2;\r\n }\r\n\r\n if (!data || currentSize != newSize) {\r\n if (!data) {\r\n data = new Float32Array(newSize);\r\n } else {\r\n const newData = new Float32Array(newSize);\r\n newData.set(data, 0);\r\n data = newData;\r\n }\r\n\r\n if (kindIsMatrix) {\r\n this._thinInstanceDataStorage.matrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = this._thinInstanceCreateMatrixBuffer(\"world\", data, false);\r\n this._thinInstanceDataStorage.matrixData = data;\r\n this._thinInstanceDataStorage.matrixBufferSize = newSize;\r\n if (this._scene.needsPreviousWorldMatrices && !this._thinInstanceDataStorage.previousMatrixData) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer?.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = this._thinInstanceCreateMatrixBuffer(\"previousWorld\", data, false);\r\n }\r\n } else {\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind]?.dispose();\r\n\r\n this._userThinInstanceBuffersStorage.data[kind] = data;\r\n this._userThinInstanceBuffersStorage.sizes[kind] = newSize;\r\n this._userThinInstanceBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), data, kind, true, false, stride, true);\r\n\r\n this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[kind]!);\r\n }\r\n }\r\n};\r\n\r\nMesh.prototype._thinInstanceInitializeUserStorage = function () {\r\n if (!this._userThinInstanceBuffersStorage) {\r\n this._userThinInstanceBuffersStorage = {\r\n data: {},\r\n sizes: {},\r\n vertexBuffers: {},\r\n strides: {},\r\n };\r\n }\r\n};\r\n\r\nMesh.prototype._disposeThinInstanceSpecificData = function () {\r\n if (this._thinInstanceDataStorage?.matrixBuffer) {\r\n this._thinInstanceDataStorage.matrixBuffer.dispose();\r\n this._thinInstanceDataStorage.matrixBuffer = null;\r\n }\r\n if (this._thinInstanceDataStorage?.previousMatrixBuffer) {\r\n this._thinInstanceDataStorage.previousMatrixBuffer.dispose();\r\n this._thinInstanceDataStorage.previousMatrixBuffer = null;\r\n }\r\n};\r\n"]}
@@ -184,7 +184,7 @@ export class ConeParticleEmitter {
184
184
  this.angle = serializationObject.angle;
185
185
  this.directionRandomizer = serializationObject.directionRandomizer;
186
186
  this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;
187
- this.heightRange = serializationObject.radiusRange !== undefined ? serializationObject.heightRange : 1;
187
+ this.heightRange = serializationObject.heightRange !== undefined ? serializationObject.heightRange : 1;
188
188
  this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;
189
189
  }
190
190
  }
@@ -278,8 +278,8 @@ export class ConeDirectedParticleEmitter extends ConeParticleEmitter {
278
278
  */
279
279
  parse(serializationObject) {
280
280
  super.parse(serializationObject);
281
- this.direction1.copyFrom(serializationObject.direction1);
282
- this.direction2.copyFrom(serializationObject.direction2);
281
+ Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);
282
+ Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);
283
283
  }
284
284
  }
285
285
  //# sourceMappingURL=coneParticleEmitter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,iCAA6B;AAClD,OAAO,EAAE,OAAO,EAAE,mCAA+B;AACjD,OAAO,EAAE,WAAW,EAAE,6CAAyC;AAE/D;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC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E,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"core/Maths/math.vector\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"core/Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\n\r\nimport { DeepCopier } from \"core/Misc/deepCopier\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a cone.\r\n * It emits the particles alongside the cone volume from the base to the particle.\r\n * The emission direction might be randomized.\r\n */\r\nexport class ConeParticleEmitter implements IParticleEmitterType {\r\n private _radius: number;\r\n private _angle: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public radiusRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public heightRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)\r\n */\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Gets or sets the radius of the emission cone\r\n */\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._buildHeight();\r\n }\r\n\r\n /**\r\n * Gets or sets the angle of the emission cone\r\n */\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._buildHeight();\r\n }\r\n\r\n private _buildHeight() {\r\n if (this._angle !== 0) {\r\n this._height = this._radius / Math.tan(this._angle / 2);\r\n } else {\r\n this._height = 1;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance ConeParticleEmitter\r\n * @param radius the radius of the emission cone (1 by default)\r\n * @param angle the cone base angle (PI by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)\r\n */\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */\r\n public directionRandomizer = 0\r\n ) {\r\n this.angle = angle;\r\n this.radius = radius;\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const s = RandomRange(0, Math.PI * 2);\r\n let h: number;\r\n\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = RandomRange(0, this.heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n let radius = this._radius - RandomRange(0, this._radius * this.radiusRange);\r\n radius = radius * h;\r\n\r\n const randX = radius * Math.sin(s);\r\n const randZ = radius * Math.cos(s);\r\n const randY = h * this._height;\r\n\r\n if (isLocal) {\r\n positionToUpdate.x = randX;\r\n positionToUpdate.y = randY;\r\n positionToUpdate.z = randZ;\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): ConeParticleEmitter {\r\n const newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat2(\"radius\", this._radius, this.radiusRange);\r\n uboOrEffect.setFloat(\"coneAngle\", this._angle);\r\n uboOrEffect.setFloat2(\"height\", this._height, this.heightRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 2);\r\n ubo.addUniform(\"coneAngle\", 1);\r\n ubo.addUniform(\"height\", 2);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n let defines = \"#define CONEEMITTER\";\r\n\r\n if (this.emitFromSpawnPointOnly) {\r\n defines += \"\\n#define CONEEMITTERSPAWNPOINT\";\r\n }\r\n\r\n return defines;\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"ConeParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this._radius;\r\n serializationObject.angle = this._angle;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.heightRange = this.heightRange;\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.angle = serializationObject.angle;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n\r\n this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;\r\n this.heightRange = serializationObject.radiusRange !== undefined ? serializationObject.heightRange : 1;\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;\r\n }\r\n}\r\nexport class ConeDirectedParticleEmitter extends ConeParticleEmitter {\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, angle);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): ConeDirectedParticleEmitter {\r\n const newOne = new ConeDirectedParticleEmitter(this.radius, this.angle, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CONEEMITTER\\n#define DIRECTEDCONEEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"ConeDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,iCAA6B;AAClD,OAAO,EAAE,OAAO,EAAE,mCAA+B;AACjD,OAAO,EAAE,WAAW,EAAE,6CAAyC;AAE/D;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,C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AAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3E,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/E,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"core/Maths/math.vector\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"core/Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\n\r\nimport { DeepCopier } from \"core/Misc/deepCopier\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a cone.\r\n * It emits the particles alongside the cone volume from the base to the particle.\r\n * The emission direction might be randomized.\r\n */\r\nexport class ConeParticleEmitter implements IParticleEmitterType {\r\n private _radius: number;\r\n private _angle: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public radiusRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)\r\n */\r\n public heightRange = 1;\r\n\r\n /**\r\n * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)\r\n */\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Gets or sets the radius of the emission cone\r\n */\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._buildHeight();\r\n }\r\n\r\n /**\r\n * Gets or sets the angle of the emission cone\r\n */\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._buildHeight();\r\n }\r\n\r\n private _buildHeight() {\r\n if (this._angle !== 0) {\r\n this._height = this._radius / Math.tan(this._angle / 2);\r\n } else {\r\n this._height = 1;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new instance ConeParticleEmitter\r\n * @param radius the radius of the emission cone (1 by default)\r\n * @param angle the cone base angle (PI by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)\r\n */\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /** [0] defines how much to randomize the particle direction [0-1] (default is 0) */\r\n public directionRandomizer = 0\r\n ) {\r\n this.angle = angle;\r\n this.radius = radius;\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const s = RandomRange(0, Math.PI * 2);\r\n let h: number;\r\n\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = RandomRange(0, this.heightRange);\r\n // Better distribution in a cone at normal angles.\r\n h = 1 - h * h;\r\n } else {\r\n h = 0.0001;\r\n }\r\n let radius = this._radius - RandomRange(0, this._radius * this.radiusRange);\r\n radius = radius * h;\r\n\r\n const randX = radius * Math.sin(s);\r\n const randZ = radius * Math.cos(s);\r\n const randY = h * this._height;\r\n\r\n if (isLocal) {\r\n positionToUpdate.x = randX;\r\n positionToUpdate.y = randY;\r\n positionToUpdate.z = randZ;\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): ConeParticleEmitter {\r\n const newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat2(\"radius\", this._radius, this.radiusRange);\r\n uboOrEffect.setFloat(\"coneAngle\", this._angle);\r\n uboOrEffect.setFloat2(\"height\", this._height, this.heightRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 2);\r\n ubo.addUniform(\"coneAngle\", 1);\r\n ubo.addUniform(\"height\", 2);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n let defines = \"#define CONEEMITTER\";\r\n\r\n if (this.emitFromSpawnPointOnly) {\r\n defines += \"\\n#define CONEEMITTERSPAWNPOINT\";\r\n }\r\n\r\n return defines;\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"ConeParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this._radius;\r\n serializationObject.angle = this._angle;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.heightRange = this.heightRange;\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.angle = serializationObject.angle;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n\r\n this.radiusRange = serializationObject.radiusRange !== undefined ? serializationObject.radiusRange : 1;\r\n this.heightRange = serializationObject.heightRange !== undefined ? serializationObject.heightRange : 1;\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly !== undefined ? serializationObject.emitFromSpawnPointOnly : false;\r\n }\r\n}\r\nexport class ConeDirectedParticleEmitter extends ConeParticleEmitter {\r\n constructor(\r\n radius = 1,\r\n angle = Math.PI,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius, angle);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): ConeDirectedParticleEmitter {\r\n const newOne = new ConeDirectedParticleEmitter(this.radius, this.angle, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define CONEEMITTER\\n#define DIRECTEDCONEEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"ConeDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"ConeDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);\r\n Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);\r\n }\r\n}\r\n"]}
@@ -235,8 +235,8 @@ export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
235
235
  */
236
236
  parse(serializationObject) {
237
237
  super.parse(serializationObject);
238
- this.direction1.copyFrom(serializationObject.direction1);
239
- this.direction2.copyFrom(serializationObject.direction2);
238
+ Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);
239
+ Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);
240
240
  }
241
241
  }
242
242
  //# sourceMappingURL=sphereParticleEmitter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sphereParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/sphereParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAm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AAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { RandomRange } from \"../../Maths/math.scalar.functions\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles alongside the sphere radius. The emission direction might be randomized.\r\n */\r\nexport class SphereParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance SphereParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission sphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - RandomRange(0, this.radius * this.radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): SphereParticleEmitter {\r\n const newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"SphereParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class SphereDirectedParticleEmitter extends SphereParticleEmitter {\r\n /**\r\n * Creates a new instance SphereDirectedParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): SphereDirectedParticleEmitter {\r\n const newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SphereDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sphereParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/sphereParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAC9B;;;;;OAKG;IACH;IACI;;OAEG;IACI,SAAS,CAAC;IACjB;;OAEG;IACI,cAAc,CAAC;IACtB;;OAEG;IACI,sBAAsB,CAAC;QARvB,WAAM,GAAN,MAAM,CAAI;QAIV,gBAAW,GAAX,WAAW,CAAI;QAIf,wBAAmB,GAAnB,mBAAmB,CAAI;IAC/B,CAAC;IAEJ;;;;;;OAMG;IACI,sBAAsB,CAAC,WAAmB,EAAE,iBAA0B,EAAE,QAAkB,EAAE,OAAgB;QAC/G,MAAM,SAAS,GAAG,QAAQ,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AC5B,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QACjC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAChC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACa,gBAAgB;QAC5B,OAAO,sDAAsD,CAAC;IAClE,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3E,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/E,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { RandomRange } from \"../../Maths/math.scalar.functions\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles alongside the sphere radius. The emission direction might be randomized.\r\n */\r\nexport class SphereParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance SphereParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission sphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - RandomRange(0, this.radius * this.radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): SphereParticleEmitter {\r\n const newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"SphereParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class SphereDirectedParticleEmitter extends SphereParticleEmitter {\r\n /**\r\n * Creates a new instance SphereDirectedParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): SphereDirectedParticleEmitter {\r\n const newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SphereDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n Vector3.FromArrayToRef(serializationObject.direction1, 0, this.direction1);\r\n Vector3.FromArrayToRef(serializationObject.direction2, 0, this.direction2);\r\n }\r\n}\r\n"]}
@@ -12,6 +12,7 @@ import { ParticleGradientValueBlock } from "./Blocks/particleGradientValueBlock.
12
12
  import { ParticleInputBlock } from "./Blocks/particleInputBlock.js";
13
13
  import { ParticleMathBlock, ParticleMathBlockOperations } from "./Blocks/particleMathBlock.js";
14
14
  import { ParticleRandomBlock, ParticleRandomBlockLocks } from "./Blocks/particleRandomBlock.js";
15
+ import { ParticleLerpBlock } from "./Blocks/particleLerpBlock.js";
15
16
  import { ParticleTextureSourceBlock } from "./Blocks/particleSourceTextureBlock.js";
16
17
  import { ParticleVectorLengthBlock } from "./Blocks/particleVectorLengthBlock.js";
17
18
  import { SystemBlock } from "./Blocks/systemBlock.js";
@@ -184,10 +185,14 @@ function _CreateParticleColorBlockGroup(oldSystem, context) {
184
185
  return context.colorGradientValue0Output;
185
186
  }
186
187
  else {
187
- const randomColorBlock = new ParticleRandomBlock("Random color");
188
- _CreateAndConnectInput("Color 1", oldSystem.color1.clone(), randomColorBlock.min);
189
- _CreateAndConnectInput("Color 2", oldSystem.color2.clone(), randomColorBlock.max);
190
- return randomColorBlock.output;
188
+ const randomStepBlock = new ParticleRandomBlock("Random color step");
189
+ _CreateAndConnectInput("Min", 0, randomStepBlock.min);
190
+ _CreateAndConnectInput("Max", 1, randomStepBlock.max);
191
+ const lerpColorBlock = new ParticleLerpBlock("Lerp color");
192
+ _CreateAndConnectInput("Color 1", oldSystem.color1.clone(), lerpColorBlock.left);
193
+ _CreateAndConnectInput("Color 2", oldSystem.color2.clone(), lerpColorBlock.right);
194
+ randomStepBlock.output.connectTo(lerpColorBlock.gradient);
195
+ return lerpColorBlock.output;
191
196
  }
192
197
  }
193
198
  function _CreateParticleInitialValueFromGradient(gradients) {