@onerjs/core 8.30.8 → 8.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +52 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +105 -0
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +10 -2
- package/Cameras/Inputs/geospatialCameraPointersInput.js +20 -2
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- 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/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/sphereShapeBlock.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +22 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.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/particleRandomBlock.d.ts +5 -2
- package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +12 -4
- package/Particles/Node/Blocks/systemBlock.js +16 -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 +2 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +293 -44
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +3 -3
- package/Particles/thinParticleSystem.js +4 -4
- package/Particles/thinParticleSystem.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,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAKhE;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAoB5B;;OA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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,MAAM,CAAC,KAAa;QAC3B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED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BAAmB,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;;;WAGG;QACI,iCAA4B,GAAmF,kBAAkB,CAAC;QAEzI;;;WAGG;QACI,+BAA0B,GAAmF,kBAAkB,CAAC;IAKxH,CAAC;IAEhB;;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E,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"]}
|
|
@@ -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
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { __decorate } from "../../../../tslib.es6.js";
|
|
1
2
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
2
3
|
import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
3
4
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
5
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
5
|
-
import {
|
|
6
|
+
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
7
|
+
import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
|
|
8
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
6
9
|
/**
|
|
7
10
|
* Block used to provide a flow of particles emitted from a cone shape.
|
|
8
11
|
*/
|
|
@@ -13,13 +16,19 @@ export class ConeShapeBlock extends NodeParticleBlock {
|
|
|
13
16
|
*/
|
|
14
17
|
constructor(name) {
|
|
15
18
|
super(name);
|
|
19
|
+
/**
|
|
20
|
+
* Gets or sets a boolean indicating if the system should emit only from the spawn point
|
|
21
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
22
|
+
*/
|
|
23
|
+
this.emitFromSpawnPointOnly = false;
|
|
16
24
|
this.registerInput("particle", NodeParticleBlockConnectionPointTypes.Particle);
|
|
17
25
|
this.registerInput("radius", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
18
26
|
this.registerInput("angle", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);
|
|
19
27
|
this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
20
28
|
this.registerInput("heightRange", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
21
|
-
this.registerInput("emitFromSpawnPointOnly", NodeParticleBlockConnectionPointTypes.Int, true, 0);
|
|
22
29
|
this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0);
|
|
30
|
+
this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
31
|
+
this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
23
32
|
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
|
|
24
33
|
}
|
|
25
34
|
/**
|
|
@@ -60,17 +69,23 @@ export class ConeShapeBlock extends NodeParticleBlock {
|
|
|
60
69
|
return this._inputs[4];
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
63
|
-
* Gets the
|
|
72
|
+
* Gets the directionRandomizer input component
|
|
64
73
|
*/
|
|
65
|
-
get
|
|
74
|
+
get directionRandomizer() {
|
|
66
75
|
return this._inputs[5];
|
|
67
76
|
}
|
|
68
77
|
/**
|
|
69
|
-
* Gets the
|
|
78
|
+
* Gets the direction1 input component
|
|
70
79
|
*/
|
|
71
|
-
get
|
|
80
|
+
get direction1() {
|
|
72
81
|
return this._inputs[6];
|
|
73
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the direction2 input component
|
|
85
|
+
*/
|
|
86
|
+
get direction2() {
|
|
87
|
+
return this._inputs[7];
|
|
88
|
+
}
|
|
74
89
|
/**
|
|
75
90
|
* Gets the output component
|
|
76
91
|
*/
|
|
@@ -86,29 +101,36 @@ export class ConeShapeBlock extends NodeParticleBlock {
|
|
|
86
101
|
system._directionCreation.process = (particle) => {
|
|
87
102
|
state.particleContext = particle;
|
|
88
103
|
state.systemContext = system;
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
// We always use directionRandomizer unless both directions are connected
|
|
105
|
+
if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
|
|
106
|
+
const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
|
|
107
|
+
const direction = particle.position.subtract(state.emitterPosition).normalize();
|
|
108
|
+
const randX = RandomRange(0, directionRandomizer);
|
|
109
|
+
const randY = RandomRange(0, directionRandomizer);
|
|
110
|
+
const randZ = RandomRange(0, directionRandomizer);
|
|
111
|
+
direction.x += randX;
|
|
112
|
+
direction.y += randY;
|
|
113
|
+
direction.z += randZ;
|
|
114
|
+
direction.normalize();
|
|
115
|
+
if (system.isLocal) {
|
|
116
|
+
particle.direction.copyFromFloats(direction.x, direction.y, direction.z);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix, particle.direction);
|
|
120
|
+
}
|
|
95
121
|
}
|
|
96
122
|
else {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
particle.direction.copyFromFloats(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
Vector3.TransformNormalFromFloatsToRef(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z, state.emitterWorldMatrix, particle.direction);
|
|
123
|
+
const direction1 = this.direction1.getConnectedValue(state);
|
|
124
|
+
const direction2 = this.direction2.getConnectedValue(state);
|
|
125
|
+
const randX = RandomRange(direction1.x, direction2.x);
|
|
126
|
+
const randY = RandomRange(direction1.y, direction2.y);
|
|
127
|
+
const randZ = RandomRange(direction1.z, direction2.z);
|
|
128
|
+
if (system.isLocal) {
|
|
129
|
+
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
|
|
133
|
+
}
|
|
112
134
|
}
|
|
113
135
|
particle._initialDirection = particle.direction.clone();
|
|
114
136
|
};
|
|
@@ -118,14 +140,11 @@ export class ConeShapeBlock extends NodeParticleBlock {
|
|
|
118
140
|
// Connected values
|
|
119
141
|
const radius = this.radius.getConnectedValue(state);
|
|
120
142
|
const angle = this.angle.getConnectedValue(state);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
let heightRange = this.heightRange.getConnectedValue(state);
|
|
124
|
-
heightRange = Math.max(0, Math.min(heightRange, 1));
|
|
125
|
-
const emitFromSpawnPointOnly = this.emitFromSpawnPointOnly.getConnectedValue(state) !== 0;
|
|
143
|
+
const radiusRange = this.radiusRange.getConnectedValue(state);
|
|
144
|
+
const heightRange = this.heightRange.getConnectedValue(state);
|
|
126
145
|
// Calculate position creation logic
|
|
127
146
|
let h;
|
|
128
|
-
if (!emitFromSpawnPointOnly) {
|
|
147
|
+
if (!this.emitFromSpawnPointOnly) {
|
|
129
148
|
h = RandomRange(0, heightRange);
|
|
130
149
|
// Better distribution in a cone at normal angles.
|
|
131
150
|
h = 1 - h * h;
|
|
@@ -136,17 +155,16 @@ export class ConeShapeBlock extends NodeParticleBlock {
|
|
|
136
155
|
let newRadius = radius - RandomRange(0, radius * radiusRange);
|
|
137
156
|
newRadius = newRadius * h;
|
|
138
157
|
const s = RandomRange(0, Math.PI * 2);
|
|
139
|
-
const height = this._calculateHeight(angle, radius);
|
|
140
158
|
const randX = newRadius * Math.sin(s);
|
|
141
159
|
const randZ = newRadius * Math.cos(s);
|
|
142
|
-
const randY = h *
|
|
160
|
+
const randY = h * this._calculateHeight(angle, radius);
|
|
143
161
|
if (system.isLocal) {
|
|
144
162
|
particle.position.copyFromFloats(randX, randY, randZ);
|
|
145
|
-
particle.position.addInPlace(state.emitterPosition);
|
|
146
163
|
}
|
|
147
164
|
else {
|
|
148
165
|
Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
|
|
149
166
|
}
|
|
167
|
+
_CreateLocalPositionData(particle);
|
|
150
168
|
};
|
|
151
169
|
this.output._storedValue = system;
|
|
152
170
|
}
|
|
@@ -158,6 +176,18 @@ export class ConeShapeBlock extends NodeParticleBlock {
|
|
|
158
176
|
return 1;
|
|
159
177
|
}
|
|
160
178
|
}
|
|
179
|
+
serialize() {
|
|
180
|
+
const serializationObject = super.serialize();
|
|
181
|
+
serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;
|
|
182
|
+
return serializationObject;
|
|
183
|
+
}
|
|
184
|
+
_deserialize(serializationObject) {
|
|
185
|
+
super._deserialize(serializationObject);
|
|
186
|
+
this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly;
|
|
187
|
+
}
|
|
161
188
|
}
|
|
189
|
+
__decorate([
|
|
190
|
+
editableInPropertyPage("Emit from spawn point only", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { embedded: true, notifiers: { rebuild: true } })
|
|
191
|
+
], ConeShapeBlock.prototype, "emitFromSpawnPointOnly", void 0);
|
|
162
192
|
RegisterClass("BABYLON.ConeShapeBlock", ConeShapeBlock);
|
|
163
193
|
//# sourceMappingURL=coneShapeBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coneShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/coneShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,yCAA+B;AAE7D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD;;;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,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAA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B,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,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;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;IAEO,gBAAgB,CAAC,KAAa,EAAE,MAAc;QAClD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACd,OAAO,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { IShapeBlock } from \"./IShapeBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cone shape.\r\n */\r\nexport class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new ConeShapeBlock\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(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"heightRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"emitFromSpawnPointOnly\", NodeParticleBlockConnectionPointTypes.Int, true, 0);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\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 \"ConeShapeBlock\";\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 radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the heightRange input component\r\n */\r\n public get heightRange(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the emitFromSpawnPointOnly input component\r\n */\r\n public get emitFromSpawnPointOnly(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\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 // Connected values\r\n let directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n directionRandomizer = Math.max(0, Math.min(directionRandomizer, 1));\r\n\r\n // Calculate create direction logic\r\n if (system.isLocal) {\r\n TmpVectors.Vector3[0].copyFrom(particle.position).normalize();\r\n } else {\r\n particle.position.subtractToRef(state.emitterWorldMatrix!.getTranslation(), TmpVectors.Vector3[0]).normalize();\r\n }\r\n\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n const directionToUpdate = new Vector3();\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 if (system.isLocal) {\r\n particle.direction.copyFromFloats(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(directionToUpdate.x, directionToUpdate.y, directionToUpdate.z, 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 // Connected values\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const angle = this.angle.getConnectedValue(state) as number;\r\n let radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n radiusRange = Math.max(0, Math.min(radiusRange, 1));\r\n let heightRange = this.heightRange.getConnectedValue(state) as number;\r\n heightRange = Math.max(0, Math.min(heightRange, 1));\r\n const emitFromSpawnPointOnly = (this.emitFromSpawnPointOnly.getConnectedValue(state) as number) !== 0;\r\n\r\n // Calculate position creation logic\r\n let h: number;\r\n if (!emitFromSpawnPointOnly) {\r\n h = RandomRange(0, 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\r\n let newRadius = radius - RandomRange(0, radius * radiusRange);\r\n newRadius = newRadius * h;\r\n\r\n const s = RandomRange(0, Math.PI * 2);\r\n const height = this._calculateHeight(angle, radius);\r\n\r\n const randX = newRadius * Math.sin(s);\r\n const randZ = newRadius * Math.cos(s);\r\n const randY = h * height;\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n private _calculateHeight(angle: number, radius: number): number {\r\n if (angle !== 0) {\r\n return radius / Math.tan(angle / 2);\r\n } else {\r\n return 1;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConeShapeBlock\", ConeShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"coneShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/coneShapeBlock.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,qCAAqC,EAAE,6DAAwE;AACxH,OAAO,EAAE,iBAAiB,EAAE,mCAA8C;AAC1E,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,sBAAsB,EAA0B,gDAAsC;AAC/F,OAAO,EAAE,wBAAwB,EAAE,MA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AAE,CAAC;QAE9C,mBAAmB,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC;QAEzE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,sBAAsB,GAAG,mBAAmB,CAAC,sBAAsB,CAAC;IAC7E,CAAC;CACJ;AAvMU;IADN,sBAAsB,CAAC,4BAA4B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;8DAC7G;AAyM1C,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { IShapeBlock } from \"./IShapeBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"core/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"core/Decorators/nodeDecorator\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cone shape.\r\n */\r\nexport class ConeShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Gets or sets a boolean indicating if the system should emit only from the spawn point\r\n * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.\r\n */\r\n @editableInPropertyPage(\"Emit from spawn point only\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public emitFromSpawnPointOnly = false;\r\n\r\n /**\r\n * Create a new ConeShapeBlock\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(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, Math.PI);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"heightRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true);\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 \"ConeShapeBlock\";\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 radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the heightRange input component\r\n */\r\n public get heightRange(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\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[6];\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[7];\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 // We always use directionRandomizer unless both directions are connected\r\n if (this.direction1.isConnected === false || this.direction2.isConnected === false) {\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n\r\n const direction = particle.position.subtract(state.emitterPosition!).normalize();\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, 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 (system.isLocal) {\r\n particle.direction.copyFromFloats(direction.x, direction.y, direction.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n } else {\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\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 // Connected values\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const angle = this.angle.getConnectedValue(state) as number;\r\n const radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n const heightRange = this.heightRange.getConnectedValue(state) as number;\r\n\r\n // Calculate position creation logic\r\n let h: number;\r\n if (!this.emitFromSpawnPointOnly) {\r\n h = RandomRange(0, 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\r\n let newRadius = radius - RandomRange(0, radius * radiusRange);\r\n newRadius = newRadius * h;\r\n const s = RandomRange(0, Math.PI * 2);\r\n\r\n const randX = newRadius * Math.sin(s);\r\n const randZ = newRadius * Math.cos(s);\r\n const randY = h * this._calculateHeight(angle, radius);\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 private _calculateHeight(angle: number, radius: number): number {\r\n if (angle !== 0) {\r\n return radius / Math.tan(angle / 2);\r\n } else {\r\n return 1;\r\n }\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.emitFromSpawnPointOnly = serializationObject.emitFromSpawnPointOnly;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConeShapeBlock\", ConeShapeBlock);\r\n"]}
|