@onerjs/core 8.30.7 → 8.30.9
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.
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +5 -1
- package/AudioV2/audioParameter.js +4 -0
- package/AudioV2/audioParameter.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/targetCamera.js +0 -4
- package/Cameras/targetCamera.js.map +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -7
- package/Decorators/nodeDecorator.js +9 -7
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
- package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
- package/FrameGraph/Passes/objectListPass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +6 -2
- package/FrameGraph/Passes/renderPass.js +14 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +10 -4
- package/FrameGraph/frameGraph.js +22 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +3 -3
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -1
- package/FrameGraph/index.js +1 -1
- package/FrameGraph/index.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +19 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +9 -0
- package/Materials/shaderMaterial.js +35 -0
- package/Materials/shaderMaterial.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +6 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
- package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +16 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +67 -14
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +4 -4
- package/Particles/Node/Blocks/systemBlock.js +8 -12
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +5 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +188 -27
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.function.d.ts +2 -2
- package/Particles/thinParticleSystem.function.js +2 -2
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -1
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -3
- package/scene.js +8 -7
- package/scene.js.map +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Matrix } from "../../Maths/math.vector.js";
|
|
2
|
-
import {
|
|
3
|
-
import type { Particle } from "../../Particles/particle.js";
|
|
4
|
-
import type { IParticleEmitterType } from "./IParticleEmitterType.js";
|
|
2
|
+
import type { Particle } from "../particle.js";
|
|
5
3
|
import type { UniformBufferEffectCommonAccessor } from "../../Materials/uniformBufferEffectCommonAccessor.js";
|
|
6
4
|
import type { UniformBuffer } from "../../Materials/uniformBuffer.js";
|
|
5
|
+
import type { IParticleEmitterType } from "./IParticleEmitterType.js";
|
|
6
|
+
import { Vector3 } from "../../Maths/math.vector.js";
|
|
7
7
|
/**
|
|
8
8
|
* Particle emitter emitting particles from the inside of a cone.
|
|
9
9
|
* It emits the particles alongside the cone volume from the base to the particle.
|
|
@@ -121,8 +121,10 @@ export declare class ConeDirectedParticleEmitter extends ConeParticleEmitter {
|
|
|
121
121
|
* Called by the particle System when the direction is computed for the created particle.
|
|
122
122
|
* @param worldMatrix is the world matrix of the particle system
|
|
123
123
|
* @param directionToUpdate is the direction vector to update with the result
|
|
124
|
+
* @param particle is the particle we are computed the position for
|
|
125
|
+
* @param isLocal defines if the direction should be set in local space
|
|
124
126
|
*/
|
|
125
|
-
startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void;
|
|
127
|
+
startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
|
|
126
128
|
/**
|
|
127
129
|
* Clones the current emitter and returns a copy of it
|
|
128
130
|
* @returns the new emitter
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepCopier } from "../../Misc/deepCopier.js";
|
|
2
|
-
import { Vector3
|
|
2
|
+
import { Vector3 } from "../../Maths/math.vector.js";
|
|
3
3
|
import { RandomRange } from "../../Maths/math.scalar.functions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Particle emitter emitting particles from the inside of a cone.
|
|
@@ -68,19 +68,19 @@ export class ConeParticleEmitter {
|
|
|
68
68
|
* @param isLocal defines if the direction should be set in local space
|
|
69
69
|
*/
|
|
70
70
|
startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {
|
|
71
|
-
|
|
72
|
-
TmpVectors.Vector3[0].copyFrom(particle._localPosition).normalize();
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
particle.position.subtractToRef(worldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();
|
|
76
|
-
}
|
|
71
|
+
const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
|
|
77
72
|
const randX = RandomRange(0, this.directionRandomizer);
|
|
78
73
|
const randY = RandomRange(0, this.directionRandomizer);
|
|
79
74
|
const randZ = RandomRange(0, this.directionRandomizer);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
direction.x += randX;
|
|
76
|
+
direction.y += randY;
|
|
77
|
+
direction.z += randZ;
|
|
78
|
+
direction.normalize();
|
|
79
|
+
if (isLocal) {
|
|
80
|
+
directionToUpdate.copyFrom(direction);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Called by the particle System when the position is computed for the created particle.
|
|
@@ -206,11 +206,17 @@ export class ConeDirectedParticleEmitter extends ConeParticleEmitter {
|
|
|
206
206
|
* Called by the particle System when the direction is computed for the created particle.
|
|
207
207
|
* @param worldMatrix is the world matrix of the particle system
|
|
208
208
|
* @param directionToUpdate is the direction vector to update with the result
|
|
209
|
+
* @param particle is the particle we are computed the position for
|
|
210
|
+
* @param isLocal defines if the direction should be set in local space
|
|
209
211
|
*/
|
|
210
|
-
startDirectionFunction(worldMatrix, directionToUpdate) {
|
|
212
|
+
startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {
|
|
211
213
|
const randX = RandomRange(this.direction1.x, this.direction2.x);
|
|
212
214
|
const randY = RandomRange(this.direction1.y, this.direction2.y);
|
|
213
215
|
const randZ = RandomRange(this.direction1.z, this.direction2.z);
|
|
216
|
+
if (isLocal) {
|
|
217
|
+
directionToUpdate.copyFromFloats(randX, randY, randZ);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
214
220
|
Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
|
|
215
221
|
}
|
|
216
222
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coneParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/coneParticleEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB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AAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACa,gBAAgB;QAC5B,OAAO,kDAAkD,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,6BAA6B,CAAC;IACzC,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,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 { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } 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 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 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 if (isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle._localPosition!).normalize();\r\n } else {\r\n particle.position.subtractToRef(worldMatrix.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\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 directionToUpdate.x = TmpVectors.Vector3[0].x + randX;\r\n directionToUpdate.y = TmpVectors.Vector3[0].y + randY;\r\n directionToUpdate.z = TmpVectors.Vector3[0].z + randZ;\r\n directionToUpdate.normalize();\r\n }\r\n\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 */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): 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 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,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AA6B,CAAC;IACzC,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,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,10 +1,12 @@
|
|
|
1
|
+
import type { Nullable } from "../../types.js";
|
|
1
2
|
import type { Matrix } from "../../Maths/math.vector.js";
|
|
2
|
-
import { Vector3 } from "../../Maths/math.vector.js";
|
|
3
3
|
import type { Particle } from "../particle.js";
|
|
4
|
-
import type { IParticleEmitterType } from "./IParticleEmitterType.js";
|
|
5
|
-
import type { Nullable } from "../../types.js";
|
|
6
4
|
import type { UniformBufferEffectCommonAccessor } from "../../Materials/uniformBufferEffectCommonAccessor.js";
|
|
7
5
|
import type { UniformBuffer } from "../../Materials/uniformBuffer.js";
|
|
6
|
+
import type { IParticleEmitterType } from "./IParticleEmitterType.js";
|
|
7
|
+
import { Vector3 } from "../../Maths/math.vector.js";
|
|
8
|
+
/** Represents and empty generator function */
|
|
9
|
+
export declare const EmptyGeneratorFunc: () => void;
|
|
8
10
|
/**
|
|
9
11
|
* Particle emitter emitting particles from a custom list of positions.
|
|
10
12
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DeepCopier } from "../../Misc/deepCopier.js";
|
|
2
2
|
import { Vector3, TmpVectors } from "../../Maths/math.vector.js";
|
|
3
|
+
/** Represents and empty generator function */
|
|
4
|
+
export const EmptyGeneratorFunc = () => { };
|
|
3
5
|
/**
|
|
4
6
|
* Particle emitter emitting particles from a custom list of positions.
|
|
5
7
|
*/
|
|
@@ -12,17 +14,17 @@ export class CustomParticleEmitter {
|
|
|
12
14
|
* Gets or sets the position generator that will create the initial position of each particle.
|
|
13
15
|
* Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
|
|
14
16
|
*/
|
|
15
|
-
this.particlePositionGenerator =
|
|
17
|
+
this.particlePositionGenerator = EmptyGeneratorFunc;
|
|
16
18
|
/**
|
|
17
19
|
* Gets or sets the destination generator that will create the final destination of each particle.
|
|
18
20
|
* * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
|
|
19
21
|
*/
|
|
20
|
-
this.particleDestinationGenerator =
|
|
22
|
+
this.particleDestinationGenerator = EmptyGeneratorFunc;
|
|
21
23
|
/**
|
|
22
24
|
* Gets or sets the direction generator that will create the initial direction of each particle.
|
|
23
25
|
* * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
|
|
24
26
|
*/
|
|
25
|
-
this.particleDirectionGenerator =
|
|
27
|
+
this.particleDirectionGenerator = EmptyGeneratorFunc;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Called by the particle System when the direction is computed for the created particle.
|
|
@@ -33,10 +35,10 @@ export class CustomParticleEmitter {
|
|
|
33
35
|
*/
|
|
34
36
|
startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {
|
|
35
37
|
const tmpVector = TmpVectors.Vector3[0];
|
|
36
|
-
if (this.particleDirectionGenerator) {
|
|
38
|
+
if (this.particleDirectionGenerator && this.particleDirectionGenerator !== EmptyGeneratorFunc) {
|
|
37
39
|
this.particleDirectionGenerator(-1, particle, tmpVector);
|
|
38
40
|
}
|
|
39
|
-
else if (this.particleDestinationGenerator) {
|
|
41
|
+
else if (this.particleDestinationGenerator && this.particleDestinationGenerator !== EmptyGeneratorFunc) {
|
|
40
42
|
this.particleDestinationGenerator(-1, particle, tmpVector);
|
|
41
43
|
// Get direction
|
|
42
44
|
const diffVector = TmpVectors.Vector3[1];
|
|
@@ -61,7 +63,7 @@ export class CustomParticleEmitter {
|
|
|
61
63
|
*/
|
|
62
64
|
startPositionFunction(worldMatrix, positionToUpdate, particle, isLocal) {
|
|
63
65
|
const tmpVector = TmpVectors.Vector3[0];
|
|
64
|
-
if (this.particlePositionGenerator) {
|
|
66
|
+
if (this.particlePositionGenerator && this.particlePositionGenerator !== EmptyGeneratorFunc) {
|
|
65
67
|
this.particlePositionGenerator(-1, particle, tmpVector);
|
|
66
68
|
}
|
|
67
69
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/customParticleEmitter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"customParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/customParticleEmitter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,iCAA6B;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mCAA+B;AAE7D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAmB9B;;OAEG;IACH;QArBA;;;WAGG;QACI,8BAAyB,GAAgF,kBAAkB,CAAC;QAEnI;;;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F,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,mBAAwB;QACjC,IAAI,mBAAmB,CAAC,yBAAyB,EAAE,CAAC;YAChD,IAAI,CAAC,yBAAyB,GAAG,mBAAmB,CAAC,yBAAyB,CAAC;QACnF,CAAC;QAED,IAAI,mBAAmB,CAAC,4BAA4B,EAAE,CAAC;YACnD,IAAI,CAAC,4BAA4B,GAAG,mBAAmB,CAAC,4BAA4B,CAAC;QACzF,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport 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, TmpVectors } from \"core/Maths/math.vector\";\r\n\r\n/** Represents and empty generator function */\r\nexport const EmptyGeneratorFunc = () => {};\r\n\r\n/**\r\n * Particle emitter emitting particles from a custom list of positions.\r\n */\r\nexport class CustomParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Gets or sets the position generator that will create the initial position of each particle.\r\n * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles\r\n */\r\n public particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void = EmptyGeneratorFunc;\r\n\r\n /**\r\n * Gets or sets the destination generator that will create the final destination of each particle.\r\n * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles\r\n */\r\n public particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void = EmptyGeneratorFunc;\r\n\r\n /**\r\n * Gets or sets the direction generator that will create the initial direction of each particle.\r\n * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles\r\n */\r\n public particleDirectionGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void = EmptyGeneratorFunc;\r\n\r\n /**\r\n * Creates a new instance CustomParticleEmitter\r\n */\r\n constructor() {}\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 tmpVector = TmpVectors.Vector3[0];\r\n\r\n if (this.particleDirectionGenerator && this.particleDirectionGenerator !== EmptyGeneratorFunc) {\r\n this.particleDirectionGenerator(-1, particle, tmpVector);\r\n } else if (this.particleDestinationGenerator && this.particleDestinationGenerator !== EmptyGeneratorFunc) {\r\n this.particleDestinationGenerator(-1, particle, tmpVector);\r\n\r\n // Get direction\r\n const diffVector = TmpVectors.Vector3[1];\r\n tmpVector.subtractToRef(particle.position, diffVector);\r\n\r\n diffVector.scaleToRef(1 / particle.lifeTime, tmpVector);\r\n } else {\r\n tmpVector.set(0, 0, 0);\r\n }\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(tmpVector);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalToRef(tmpVector, 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 tmpVector = TmpVectors.Vector3[0];\r\n\r\n if (this.particlePositionGenerator && this.particlePositionGenerator !== EmptyGeneratorFunc) {\r\n this.particlePositionGenerator(-1, particle, tmpVector);\r\n } else {\r\n tmpVector.set(0, 0, 0);\r\n }\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFrom(tmpVector);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesToRef(tmpVector, 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(): CustomParticleEmitter {\r\n const newOne = new CustomParticleEmitter();\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {}\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public buildUniformLayout(ubo: UniformBuffer): void {}\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 CUSTOMEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"PointParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"CustomParticleEmitter\";\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.particlePositionGenerator = this.particlePositionGenerator;\r\n serializationObject.particleDestinationGenerator = this.particleDestinationGenerator;\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 if (serializationObject.particlePositionGenerator) {\r\n this.particlePositionGenerator = serializationObject.particlePositionGenerator;\r\n }\r\n\r\n if (serializationObject.particleDestinationGenerator) {\r\n this.particleDestinationGenerator = serializationObject.particleDestinationGenerator;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -124,8 +124,10 @@ export declare class SphereDirectedParticleEmitter extends SphereParticleEmitter
|
|
|
124
124
|
* Called by the particle System when the direction is computed for the created particle.
|
|
125
125
|
* @param worldMatrix is the world matrix of the particle system
|
|
126
126
|
* @param directionToUpdate is the direction vector to update with the result
|
|
127
|
+
* @param particle is the particle we are computed the position for
|
|
128
|
+
* @param isLocal defines if the direction should be set in local space
|
|
127
129
|
*/
|
|
128
|
-
startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void;
|
|
130
|
+
startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
|
|
129
131
|
/**
|
|
130
132
|
* Clones the current emitter and returns a copy of it
|
|
131
133
|
* @returns the new emitter
|
|
@@ -163,11 +163,17 @@ export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
|
|
|
163
163
|
* Called by the particle System when the direction is computed for the created particle.
|
|
164
164
|
* @param worldMatrix is the world matrix of the particle system
|
|
165
165
|
* @param directionToUpdate is the direction vector to update with the result
|
|
166
|
+
* @param particle is the particle we are computed the position for
|
|
167
|
+
* @param isLocal defines if the direction should be set in local space
|
|
166
168
|
*/
|
|
167
|
-
startDirectionFunction(worldMatrix, directionToUpdate) {
|
|
169
|
+
startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {
|
|
168
170
|
const randX = RandomRange(this.direction1.x, this.direction2.x);
|
|
169
171
|
const randY = RandomRange(this.direction1.y, this.direction2.y);
|
|
170
172
|
const randZ = RandomRange(this.direction1.z, this.direction2.z);
|
|
173
|
+
if (isLocal) {
|
|
174
|
+
directionToUpdate.copyFromFloats(randX, randY, randZ);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
171
177
|
Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
|
|
172
178
|
}
|
|
173
179
|
/**
|
|
@@ -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,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,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;QACvF,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvD,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC;QACrB,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC;QACrB,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC;QACrB,SAAS,CAAC,SAAS,EAAE,CAAC;QAEtB,IAAI,OAAO,EAAE,CAAC;YACV,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACtC,OAAO;QACX,CAA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,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,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 */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): 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 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,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;QACvF,MAAM,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AE,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,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 \"../../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,7 +1,7 @@
|
|
|
1
1
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
2
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
-
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
3
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
4
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
/**
|
|
6
6
|
* Block used to provide a flow of particles emitted from a box shape.
|
|
7
7
|
*/
|
|
@@ -3,6 +3,7 @@ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleB
|
|
|
3
3
|
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
4
4
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
6
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
6
7
|
/**
|
|
7
8
|
* Block used to provide a flow of particles emitted from a box shape.
|
|
8
9
|
*/
|
|
@@ -95,11 +96,11 @@ export class BoxShapeBlock extends NodeParticleBlock {
|
|
|
95
96
|
const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);
|
|
96
97
|
if (system.isLocal) {
|
|
97
98
|
particle.position.copyFromFloats(randX, randY, randZ);
|
|
98
|
-
particle.position.addInPlace(state.emitterPosition);
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
101
|
Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
|
|
102
102
|
}
|
|
103
|
+
_CreateLocalPositionData(particle);
|
|
103
104
|
};
|
|
104
105
|
this.output._storedValue = system;
|
|
105
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACrH,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE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CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
|
|
@@ -6,6 +6,11 @@ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
|
6
6
|
* Block used to provide a flow of particles emitted from a cone shape.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {
|
|
9
|
+
/**
|
|
10
|
+
* Gets or sets a boolean indicating if the system should emit only from the spawn point
|
|
11
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
12
|
+
*/
|
|
13
|
+
emitFromSpawnPointOnly: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Create a new ConeShapeBlock
|
|
11
16
|
* @param name defines the block name
|
|
@@ -36,14 +41,18 @@ export declare class ConeShapeBlock extends NodeParticleBlock implements IShapeB
|
|
|
36
41
|
* Gets the heightRange input component
|
|
37
42
|
*/
|
|
38
43
|
get heightRange(): NodeParticleConnectionPoint;
|
|
39
|
-
/**
|
|
40
|
-
* Gets the emitFromSpawnPointOnly input component
|
|
41
|
-
*/
|
|
42
|
-
get emitFromSpawnPointOnly(): NodeParticleConnectionPoint;
|
|
43
44
|
/**
|
|
44
45
|
* Gets the directionRandomizer input component
|
|
45
46
|
*/
|
|
46
47
|
get directionRandomizer(): NodeParticleConnectionPoint;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the direction1 input component
|
|
50
|
+
*/
|
|
51
|
+
get direction1(): NodeParticleConnectionPoint;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the direction2 input component
|
|
54
|
+
*/
|
|
55
|
+
get direction2(): NodeParticleConnectionPoint;
|
|
47
56
|
/**
|
|
48
57
|
* Gets the output component
|
|
49
58
|
*/
|
|
@@ -54,4 +63,6 @@ export declare class ConeShapeBlock extends NodeParticleBlock implements IShapeB
|
|
|
54
63
|
*/
|
|
55
64
|
_build(state: NodeParticleBuildState): void;
|
|
56
65
|
private _calculateHeight;
|
|
66
|
+
serialize(): any;
|
|
67
|
+
_deserialize(serializationObject: any): void;
|
|
57
68
|
}
|