@babylonjs/core 8.4.1 → 8.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/Collisions/gpuPicker.js +26 -15
  2. package/Collisions/gpuPicker.js.map +1 -1
  3. package/Engines/abstractEngine.js +2 -2
  4. package/Engines/abstractEngine.js.map +1 -1
  5. package/Materials/Textures/Loaders/EXR/exrLoader.decoder.js +24 -3
  6. package/Materials/Textures/Loaders/EXR/exrLoader.decoder.js.map +1 -1
  7. package/Materials/Textures/texture.js +1 -1
  8. package/Materials/Textures/texture.js.map +1 -1
  9. package/Meshes/geometry.js +30 -28
  10. package/Meshes/geometry.js.map +1 -1
  11. package/Meshes/mesh.vertexData.js +2 -2
  12. package/Meshes/mesh.vertexData.js.map +1 -1
  13. package/Particles/Queue/executionQueue.d.ts +18 -0
  14. package/Particles/Queue/executionQueue.js +28 -0
  15. package/Particles/Queue/executionQueue.js.map +1 -0
  16. package/Particles/attractor.d.ts +21 -0
  17. package/Particles/attractor.js +36 -0
  18. package/Particles/attractor.js.map +1 -0
  19. package/Particles/baseParticleSystem.d.ts +27 -13
  20. package/Particles/baseParticleSystem.js +34 -4
  21. package/Particles/baseParticleSystem.js.map +1 -1
  22. package/Particles/index.d.ts +1 -0
  23. package/Particles/index.js +1 -0
  24. package/Particles/index.js.map +1 -1
  25. package/Particles/particleSystem.d.ts +18 -0
  26. package/Particles/particleSystem.js +59 -0
  27. package/Particles/particleSystem.js.map +1 -1
  28. package/Particles/thinParticleSystem.d.ts +81 -12
  29. package/Particles/thinParticleSystem.function.d.ts +84 -0
  30. package/Particles/thinParticleSystem.function.js +340 -0
  31. package/Particles/thinParticleSystem.function.js.map +1 -0
  32. package/Particles/thinParticleSystem.js +380 -316
  33. package/Particles/thinParticleSystem.js.map +1 -1
  34. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +1 -0
  35. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
  36. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +1 -0
  37. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  38. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +1 -0
  39. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  40. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +1 -0
  41. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  42. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +1 -0
  43. package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
  44. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js +1 -0
  45. package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
  46. package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +2 -0
  47. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +22 -12
  48. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
  49. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +1 -0
  50. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  51. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +2 -0
  52. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +22 -12
  53. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
  54. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +2 -0
  55. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +28 -14
  56. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
  57. package/package.json +1 -1
@@ -12,9 +12,12 @@ import type { IAnimatable } from "../Animations/animatable.interface.js";
12
12
  import { DrawWrapper } from "../Materials/drawWrapper.js";
13
13
  import type { DataBuffer } from "../Buffers/dataBuffer.js";
14
14
  import { Color4, Color3 } from "../Maths/math.color.js";
15
+ import type { ISize } from "../Maths/math.size.js";
15
16
  import type { AbstractEngine } from "../Engines/abstractEngine.js";
16
17
  import "../Engines/Extensions/engine.alpha.js";
18
+ import type { ProceduralTexture } from "../Materials/Textures/Procedurals/proceduralTexture.js";
17
19
  import { ShaderLanguage } from "../Materials/shaderLanguage.js";
20
+ import type { _IExecutionQueueItem } from "./Queue/executionQueue.js";
18
21
  /**
19
22
  * This represents a thin particle system in Babylon.
20
23
  * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
@@ -34,18 +37,24 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
34
37
  * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
35
38
  */
36
39
  updateFunction: (particles: Particle[]) => void;
37
- private _emitterWorldMatrix;
38
- private _emitterInverseWorldMatrix;
40
+ /** @internal */
41
+ _emitterWorldMatrix: Matrix;
42
+ /** @internal */
43
+ _emitterInverseWorldMatrix: Matrix;
44
+ private _startDirectionFunction;
39
45
  /**
40
46
  * This function can be defined to specify initial direction for every new particle.
41
47
  * It by default use the emitterType defined function
42
48
  */
43
- startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
49
+ get startDirectionFunction(): Nullable<(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void>;
50
+ set startDirectionFunction(value: Nullable<(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void>);
51
+ private _startPositionFunction;
44
52
  /**
45
53
  * This function can be defined to specify initial position for every new particle.
46
54
  * It by default use the emitterType defined function
47
55
  */
48
- startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
56
+ get startPositionFunction(): Nullable<(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void>;
57
+ set startPositionFunction(value: Nullable<(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void>);
49
58
  /**
50
59
  * @internal
51
60
  */
@@ -63,6 +72,10 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
63
72
  * Sets a callback that will be triggered when the system is disposed
64
73
  */
65
74
  set onDispose(callback: () => void);
75
+ /** @internal */
76
+ _noiseTextureSize: Nullable<ISize>;
77
+ /** @internal */
78
+ _noiseTextureData: Nullable<Uint8Array>;
66
79
  private _particles;
67
80
  private _epsilon;
68
81
  private _capacity;
@@ -80,18 +93,24 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
80
93
  _customWrappers: {
81
94
  [blendMode: number]: Nullable<DrawWrapper>;
82
95
  };
83
- private _scaledColorStep;
84
- private _colorDiff;
85
- private _scaledDirection;
86
- private _scaledGravity;
96
+ /** @internal */
97
+ _scaledColorStep: Color4;
98
+ /** @internal */
99
+ _colorDiff: Color4;
100
+ /** @internal */
101
+ _scaledDirection: Vector3;
102
+ /** @internal */
103
+ _scaledGravity: Vector3;
87
104
  private _currentRenderId;
88
105
  private _alive;
89
106
  private _useInstancing;
90
107
  private _vertexArrayObject;
91
108
  private _started;
92
109
  private _stopped;
93
- private _actualFrame;
94
- private _scaledUpdateSpeed;
110
+ /** @internal */
111
+ _actualFrame: number;
112
+ /** @internal */
113
+ _scaledUpdateSpeed: number;
95
114
  private _vertexBufferSize;
96
115
  /** @internal */
97
116
  _currentEmitRateGradient: Nullable<FactorGradient>;
@@ -110,6 +129,43 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
110
129
  private readonly _rawTextureWidth;
111
130
  private _rampGradientsTexture;
112
131
  private _useRampGradients;
132
+ protected _updateQueueStart: Nullable<_IExecutionQueueItem>;
133
+ protected _colorProcessing: _IExecutionQueueItem;
134
+ protected _angularSpeedGradientProcessing: _IExecutionQueueItem;
135
+ protected _angularSpeedProcessing: _IExecutionQueueItem;
136
+ protected _velocityGradientProcessing: _IExecutionQueueItem;
137
+ protected _directionProcessing: _IExecutionQueueItem;
138
+ protected _limitVelocityGradientProcessing: _IExecutionQueueItem;
139
+ protected _positionProcessing: _IExecutionQueueItem;
140
+ protected _dragGradientProcessing: _IExecutionQueueItem;
141
+ protected _noiseProcessing: _IExecutionQueueItem;
142
+ protected _gravityProcessing: _IExecutionQueueItem;
143
+ protected _sizeGradientProcessing: _IExecutionQueueItem;
144
+ protected _remapGradientProcessing: _IExecutionQueueItem;
145
+ private _lifeTimeCreation;
146
+ private _positionCreation;
147
+ private _isLocalCreation;
148
+ private _directionCreation;
149
+ private _emitPowerCreation;
150
+ private _sizeCreation;
151
+ private _startSizeCreation;
152
+ private _angleCreation;
153
+ private _velocityCreation;
154
+ private _limitVelocityCreation;
155
+ private _dragCreation;
156
+ private _colorCreation;
157
+ private _sheetCreation;
158
+ private _rampCreation;
159
+ private _noiseCreation;
160
+ private _createQueueStart;
161
+ /** @internal */
162
+ _directionScale: number;
163
+ /** @internal */
164
+ _tempScaledUpdateSpeed: number;
165
+ /** @internal */
166
+ _ratio: number;
167
+ /** @internal */
168
+ _emitPower: number;
113
169
  /** Gets or sets a matrix to use to compute projection */
114
170
  defaultProjectionMatrix: Matrix;
115
171
  /** Gets or sets a matrix to use to compute view */
@@ -119,10 +175,12 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
119
175
  */
120
176
  get useRampGradients(): boolean;
121
177
  set useRampGradients(value: boolean);
178
+ private _isLocal;
122
179
  /**
123
180
  * Specifies if the particles are updated in emitter local space or world space
124
181
  */
125
- isLocal: boolean;
182
+ get isLocal(): boolean;
183
+ set isLocal(value: boolean);
126
184
  /** Indicates that the particle system is CPU based */
127
185
  readonly isGPU = false;
128
186
  /**
@@ -135,6 +193,9 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
135
193
  * Gets the shader language used in this material.
136
194
  */
137
195
  get shaderLanguage(): ShaderLanguage;
196
+ /** @internal */
197
+ get _isAnimationSheetEnabled(): boolean;
198
+ set _isAnimationSheetEnabled(value: boolean);
138
199
  /**
139
200
  * Gets the number of particles active at the same time.
140
201
  * @returns The number of active particles.
@@ -183,6 +244,8 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
183
244
  * Gets the index buffer used by the particle system (or null if no index buffer is used (if _useInstancing=true))
184
245
  */
185
246
  get indexBuffer(): Nullable<DataBuffer>;
247
+ get noiseTexture(): Nullable<ProceduralTexture>;
248
+ set noiseTexture(value: Nullable<ProceduralTexture>);
186
249
  /**
187
250
  * Instantiates a particle system.
188
251
  * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
@@ -206,6 +269,10 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
206
269
  clone(name: string, newEmitter: any, cloneTexture?: boolean): ThinParticleSystem;
207
270
  private _addFactorGradient;
208
271
  private _removeFactorGradient;
272
+ private _syncLifeTimeCreation;
273
+ private _syncStartSizeCreation;
274
+ get targetStopDuration(): number;
275
+ set targetStopDuration(value: number);
209
276
  /**
210
277
  * Adds a new life time gradient
211
278
  * @param gradient defines the gradient to use (between 0 and 1)
@@ -387,7 +454,8 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
387
454
  * Resets the draw wrappers cache
388
455
  */
389
456
  resetDrawCache(): void;
390
- private _fetchR;
457
+ /** @internal */
458
+ _fetchR(u: number, v: number, width: number, height: number, pixels: Uint8Array): number;
391
459
  protected _reset(): void;
392
460
  private _resetEffect;
393
461
  private _createVertexBuffers;
@@ -438,6 +506,7 @@ export declare class ThinParticleSystem extends BaseParticleSystem implements ID
438
506
  private _createParticle;
439
507
  /** @internal */
440
508
  _prepareParticle(particle: Particle): void;
509
+ private _createNewOnes;
441
510
  private _update;
442
511
  /**
443
512
  * @internal
@@ -0,0 +1,84 @@
1
+ import type { Particle } from "./particle.js";
2
+ import type { ThinParticleSystem } from "./thinParticleSystem.js";
3
+ /** Color */
4
+ /** @internal */
5
+ export declare function _CreateColorData(particle: Particle, system: ThinParticleSystem): void;
6
+ /** @internal */
7
+ export declare function _CreateColorGradientsData(particle: Particle, system: ThinParticleSystem): void;
8
+ /** @internal */
9
+ export declare function _ProcessColorGradients(particle: Particle, system: ThinParticleSystem): void;
10
+ /** @internal */
11
+ export declare function _ProcessColor(particle: Particle, system: ThinParticleSystem): void;
12
+ /** Angular speed */
13
+ /** @internal */
14
+ export declare function _ProcessAngularSpeedGradients(particle: Particle, system: ThinParticleSystem): void;
15
+ /** @internal */
16
+ export declare function _ProcessAngularSpeed(particle: Particle, system: ThinParticleSystem): void;
17
+ /** Velocity & direction */
18
+ /** @internal */
19
+ export declare function _CreateDirectionData(particle: Particle, system: ThinParticleSystem): void;
20
+ /** @internal */
21
+ export declare function _CreateCustomDirectionData(particle: Particle, system: ThinParticleSystem): void;
22
+ /** @internal */
23
+ export declare function _CreateVelocityGradients(particle: Particle, system: ThinParticleSystem): void;
24
+ /** @internal */
25
+ export declare function _CreateLimitVelocityGradients(particle: Particle, system: ThinParticleSystem): void;
26
+ /** @internal */
27
+ export declare function _ProcessVelocityGradients(particle: Particle, system: ThinParticleSystem): void;
28
+ /** @internal */
29
+ export declare function _ProcessLimitVelocityGradients(particle: Particle, system: ThinParticleSystem): void;
30
+ /** @internal */
31
+ export declare function _ProcessDirection(particle: Particle, system: ThinParticleSystem): void;
32
+ /** Position */
33
+ /** @internal */
34
+ export declare function _CreatePositionData(particle: Particle, system: ThinParticleSystem): void;
35
+ /** @internal */
36
+ export declare function _CreateCustomPositionData(particle: Particle, system: ThinParticleSystem): void;
37
+ /** @internal */
38
+ export declare function _CreateIsLocalData(particle: Particle, system: ThinParticleSystem): void;
39
+ /** @internal */
40
+ export declare function _ProcessPosition(particle: Particle, system: ThinParticleSystem): void;
41
+ /** Drag */
42
+ /** @internal */
43
+ export declare function _CreateDragData(particle: Particle, system: ThinParticleSystem): void;
44
+ /** @internal */
45
+ export declare function _ProcessDragGradients(particle: Particle, system: ThinParticleSystem): void;
46
+ /** Noise */
47
+ /** @internal */
48
+ export declare function _CreateNoiseData(particle: Particle, system: ThinParticleSystem): void;
49
+ /** @internal */
50
+ export declare function _ProcessNoise(particle: Particle, system: ThinParticleSystem): void;
51
+ /** Gravity */
52
+ /** @internal */
53
+ export declare function _ProcessGravity(particle: Particle, system: ThinParticleSystem): void;
54
+ /** Size */
55
+ /** @internal */
56
+ export declare function _CreateSizeData(particle: Particle, system: ThinParticleSystem): void;
57
+ /** @internal */
58
+ export declare function _CreateSizeGradientsData(particle: Particle, system: ThinParticleSystem): void;
59
+ /** @internal */
60
+ export declare function _CreateStartSizeGradientsData(particle: Particle, system: ThinParticleSystem): void;
61
+ /** @internal */
62
+ export declare function _ProcessSizeGradients(particle: Particle, system: ThinParticleSystem): void;
63
+ /** Ramp */
64
+ /** @internal */
65
+ export declare function _CreateRampData(particle: Particle, system: ThinParticleSystem): void;
66
+ /** Remap */
67
+ /** @internal */
68
+ export declare function _ProcessRemapGradients(particle: Particle, system: ThinParticleSystem): void;
69
+ /** Life */
70
+ /** @internal */
71
+ export declare function _CreateLifeGradientsData(particle: Particle, system: ThinParticleSystem): void;
72
+ /** @internal */
73
+ export declare function _CreateLifetimeData(particle: Particle, system: ThinParticleSystem): void;
74
+ /** Emit power */
75
+ /** @internal */
76
+ export declare function _CreateEmitPowerData(particle: Particle, system: ThinParticleSystem): void;
77
+ /** Angle */
78
+ /** @internal */
79
+ export declare function _CreateAngleData(particle: Particle, system: ThinParticleSystem): void;
80
+ /** @internal */
81
+ export declare function _CreateAngleGradientsData(particle: Particle, system: ThinParticleSystem): void;
82
+ /** Sheet */
83
+ /** @internal */
84
+ export declare function _CreateSheetData(particle: Particle, system: ThinParticleSystem): void;
@@ -0,0 +1,340 @@
1
+ import { Color4 } from "../Maths/math.color.js";
2
+ import { GradientHelper } from "../Misc/gradients.js";
3
+ import { Clamp, Lerp, RandomRange } from "../Maths/math.scalar.functions.js";
4
+ import { TmpVectors, Vector3, Vector4 } from "../Maths/math.vector.js";
5
+ /** Color */
6
+ /** @internal */
7
+ export function _CreateColorData(particle, system) {
8
+ const step = RandomRange(0, 1.0);
9
+ Color4.LerpToRef(system.color1, system.color2, step, particle.color);
10
+ system.colorDead.subtractToRef(particle.color, system._colorDiff);
11
+ system._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
12
+ }
13
+ /** @internal */
14
+ export function _CreateColorGradientsData(particle, system) {
15
+ particle._currentColorGradient = system._colorGradients[0];
16
+ particle._currentColorGradient.getColorToRef(particle.color);
17
+ particle._currentColor1.copyFrom(particle.color);
18
+ if (system._colorGradients.length > 1) {
19
+ system._colorGradients[1].getColorToRef(particle._currentColor2);
20
+ }
21
+ else {
22
+ particle._currentColor2.copyFrom(particle.color);
23
+ }
24
+ }
25
+ /** @internal */
26
+ export function _ProcessColorGradients(particle, system) {
27
+ const colorGradients = system._colorGradients;
28
+ GradientHelper.GetCurrentGradient(system._ratio, colorGradients, (currentGradient, nextGradient, scale) => {
29
+ if (currentGradient !== particle._currentColorGradient) {
30
+ particle._currentColor1.copyFrom(particle._currentColor2);
31
+ nextGradient.getColorToRef(particle._currentColor2);
32
+ particle._currentColorGradient = currentGradient;
33
+ }
34
+ Color4.LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
35
+ });
36
+ }
37
+ /** @internal */
38
+ export function _ProcessColor(particle, system) {
39
+ particle.colorStep.scaleToRef(system._scaledUpdateSpeed, system._scaledColorStep);
40
+ particle.color.addInPlace(system._scaledColorStep);
41
+ if (particle.color.a < 0) {
42
+ particle.color.a = 0;
43
+ }
44
+ }
45
+ /** Angular speed */
46
+ /** @internal */
47
+ export function _ProcessAngularSpeedGradients(particle, system) {
48
+ GradientHelper.GetCurrentGradient(system._ratio, system._angularSpeedGradients, (currentGradient, nextGradient, scale) => {
49
+ if (currentGradient !== particle._currentAngularSpeedGradient) {
50
+ particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
51
+ particle._currentAngularSpeed2 = nextGradient.getFactor();
52
+ particle._currentAngularSpeedGradient = currentGradient;
53
+ }
54
+ particle.angularSpeed = Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
55
+ });
56
+ }
57
+ /** @internal */
58
+ export function _ProcessAngularSpeed(particle, system) {
59
+ particle.angle += particle.angularSpeed * system._scaledUpdateSpeed;
60
+ }
61
+ /** Velocity & direction */
62
+ /** @internal */
63
+ export function _CreateDirectionData(particle, system) {
64
+ system.particleEmitterType.startDirectionFunction(system._emitterWorldMatrix, particle.direction, particle, system.isLocal, system._emitterInverseWorldMatrix);
65
+ }
66
+ /** @internal */
67
+ export function _CreateCustomDirectionData(particle, system) {
68
+ system.startDirectionFunction(system._emitterWorldMatrix, particle.direction, particle, system.isLocal);
69
+ }
70
+ /** @internal */
71
+ export function _CreateVelocityGradients(particle, system) {
72
+ particle._currentVelocityGradient = system._velocityGradients[0];
73
+ particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
74
+ if (system._velocityGradients.length > 1) {
75
+ particle._currentVelocity2 = system._velocityGradients[1].getFactor();
76
+ }
77
+ else {
78
+ particle._currentVelocity2 = particle._currentVelocity1;
79
+ }
80
+ }
81
+ /** @internal */
82
+ export function _CreateLimitVelocityGradients(particle, system) {
83
+ particle._currentLimitVelocityGradient = system._limitVelocityGradients[0];
84
+ particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
85
+ if (system._limitVelocityGradients.length > 1) {
86
+ particle._currentLimitVelocity2 = system._limitVelocityGradients[1].getFactor();
87
+ }
88
+ else {
89
+ particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
90
+ }
91
+ }
92
+ /** @internal */
93
+ export function _ProcessVelocityGradients(particle, system) {
94
+ GradientHelper.GetCurrentGradient(system._ratio, system._velocityGradients, (currentGradient, nextGradient, scale) => {
95
+ if (currentGradient !== particle._currentVelocityGradient) {
96
+ particle._currentVelocity1 = particle._currentVelocity2;
97
+ particle._currentVelocity2 = nextGradient.getFactor();
98
+ particle._currentVelocityGradient = currentGradient;
99
+ }
100
+ system._directionScale *= Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
101
+ });
102
+ }
103
+ /** @internal */
104
+ export function _ProcessLimitVelocityGradients(particle, system) {
105
+ GradientHelper.GetCurrentGradient(system._ratio, system._limitVelocityGradients, (currentGradient, nextGradient, scale) => {
106
+ if (currentGradient !== particle._currentLimitVelocityGradient) {
107
+ particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
108
+ particle._currentLimitVelocity2 = nextGradient.getFactor();
109
+ particle._currentLimitVelocityGradient = currentGradient;
110
+ }
111
+ const limitVelocity = Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
112
+ const currentVelocity = particle.direction.length();
113
+ if (currentVelocity > limitVelocity) {
114
+ particle.direction.scaleInPlace(system.limitVelocityDamping);
115
+ }
116
+ });
117
+ }
118
+ /** @internal */
119
+ export function _ProcessDirection(particle, system) {
120
+ particle.direction.scaleToRef(system._directionScale, system._scaledDirection);
121
+ }
122
+ /** Position */
123
+ /** @internal */
124
+ export function _CreatePositionData(particle, system) {
125
+ system.particleEmitterType.startPositionFunction(system._emitterWorldMatrix, particle.position, particle, system.isLocal);
126
+ }
127
+ /** @internal */
128
+ export function _CreateCustomPositionData(particle, system) {
129
+ system.startPositionFunction(system._emitterWorldMatrix, particle.position, particle, system.isLocal);
130
+ }
131
+ /** @internal */
132
+ export function _CreateIsLocalData(particle, system) {
133
+ if (!particle._localPosition) {
134
+ particle._localPosition = particle.position.clone();
135
+ }
136
+ else {
137
+ particle._localPosition.copyFrom(particle.position);
138
+ }
139
+ Vector3.TransformCoordinatesToRef(particle._localPosition, system._emitterWorldMatrix, particle.position);
140
+ }
141
+ /** @internal */
142
+ export function _ProcessPosition(particle, system) {
143
+ if (system.isLocal && particle._localPosition) {
144
+ particle._localPosition.addInPlace(system._scaledDirection);
145
+ Vector3.TransformCoordinatesToRef(particle._localPosition, system._emitterWorldMatrix, particle.position);
146
+ }
147
+ else {
148
+ particle.position.addInPlace(system._scaledDirection);
149
+ }
150
+ }
151
+ /** Drag */
152
+ /** @internal */
153
+ export function _CreateDragData(particle, system) {
154
+ particle._currentDragGradient = system._dragGradients[0];
155
+ particle._currentDrag1 = particle._currentDragGradient.getFactor();
156
+ if (system._dragGradients.length > 1) {
157
+ particle._currentDrag2 = system._dragGradients[1].getFactor();
158
+ }
159
+ else {
160
+ particle._currentDrag2 = particle._currentDrag1;
161
+ }
162
+ }
163
+ /** @internal */
164
+ export function _ProcessDragGradients(particle, system) {
165
+ GradientHelper.GetCurrentGradient(system._ratio, system._dragGradients, (currentGradient, nextGradient, scale) => {
166
+ if (currentGradient !== particle._currentDragGradient) {
167
+ particle._currentDrag1 = particle._currentDrag2;
168
+ particle._currentDrag2 = nextGradient.getFactor();
169
+ particle._currentDragGradient = currentGradient;
170
+ }
171
+ const drag = Lerp(particle._currentDrag1, particle._currentDrag2, scale);
172
+ system._scaledDirection.scaleInPlace(1.0 - drag);
173
+ });
174
+ }
175
+ /** Noise */
176
+ /** @internal */
177
+ export function _CreateNoiseData(particle, system) {
178
+ if (particle._randomNoiseCoordinates1) {
179
+ particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
180
+ particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
181
+ }
182
+ else {
183
+ particle._randomNoiseCoordinates1 = new Vector3(Math.random(), Math.random(), Math.random());
184
+ particle._randomNoiseCoordinates2 = new Vector3(Math.random(), Math.random(), Math.random());
185
+ }
186
+ }
187
+ /** @internal */
188
+ export function _ProcessNoise(particle, system) {
189
+ const noiseTextureData = system._noiseTextureData;
190
+ const noiseTextureSize = system._noiseTextureSize;
191
+ if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
192
+ const fetchedColorR = system._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
193
+ const fetchedColorG = system._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
194
+ const fetchedColorB = system._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
195
+ const force = TmpVectors.Vector3[0];
196
+ const scaledForce = TmpVectors.Vector3[1];
197
+ force.copyFromFloats((2 * fetchedColorR - 1) * system.noiseStrength.x, (2 * fetchedColorG - 1) * system.noiseStrength.y, (2 * fetchedColorB - 1) * system.noiseStrength.z);
198
+ force.scaleToRef(system._tempScaledUpdateSpeed, scaledForce);
199
+ particle.direction.addInPlace(scaledForce);
200
+ }
201
+ }
202
+ /** Gravity */
203
+ /** @internal */
204
+ export function _ProcessGravity(particle, system) {
205
+ system.gravity.scaleToRef(system._tempScaledUpdateSpeed, system._scaledGravity);
206
+ particle.direction.addInPlace(system._scaledGravity);
207
+ }
208
+ /** Size */
209
+ /** @internal */
210
+ export function _CreateSizeData(particle, system) {
211
+ particle.size = RandomRange(system.minSize, system.maxSize);
212
+ particle.scale.copyFromFloats(RandomRange(system.minScaleX, system.maxScaleX), RandomRange(system.minScaleY, system.maxScaleY));
213
+ }
214
+ /** @internal */
215
+ export function _CreateSizeGradientsData(particle, system) {
216
+ particle._currentSizeGradient = system._sizeGradients[0];
217
+ particle._currentSize1 = particle._currentSizeGradient.getFactor();
218
+ particle.size = particle._currentSize1;
219
+ if (system._sizeGradients.length > 1) {
220
+ particle._currentSize2 = system._sizeGradients[1].getFactor();
221
+ }
222
+ else {
223
+ particle._currentSize2 = particle._currentSize1;
224
+ }
225
+ particle.scale.copyFromFloats(RandomRange(system.minScaleX, system.maxScaleX), RandomRange(system.minScaleY, system.maxScaleY));
226
+ }
227
+ /** @internal */
228
+ export function _CreateStartSizeGradientsData(particle, system) {
229
+ const ratio = system._actualFrame / system.targetStopDuration;
230
+ GradientHelper.GetCurrentGradient(ratio, system._startSizeGradients, (currentGradient, nextGradient, scale) => {
231
+ if (currentGradient !== system._currentStartSizeGradient) {
232
+ system._currentStartSize1 = system._currentStartSize2;
233
+ system._currentStartSize2 = nextGradient.getFactor();
234
+ system._currentStartSizeGradient = currentGradient;
235
+ }
236
+ const value = Lerp(system._currentStartSize1, system._currentStartSize2, scale);
237
+ particle.scale.scaleInPlace(value);
238
+ });
239
+ }
240
+ /** @internal */
241
+ export function _ProcessSizeGradients(particle, system) {
242
+ GradientHelper.GetCurrentGradient(system._ratio, system._sizeGradients, (currentGradient, nextGradient, scale) => {
243
+ if (currentGradient !== particle._currentSizeGradient) {
244
+ particle._currentSize1 = particle._currentSize2;
245
+ particle._currentSize2 = nextGradient.getFactor();
246
+ particle._currentSizeGradient = currentGradient;
247
+ }
248
+ particle.size = Lerp(particle._currentSize1, particle._currentSize2, scale);
249
+ });
250
+ }
251
+ /** Ramp */
252
+ /** @internal */
253
+ export function _CreateRampData(particle, system) {
254
+ particle.remapData = new Vector4(0, 1, 0, 1);
255
+ }
256
+ /** Remap */
257
+ /** @internal */
258
+ export function _ProcessRemapGradients(particle, system) {
259
+ if (system._colorRemapGradients && system._colorRemapGradients.length > 0) {
260
+ GradientHelper.GetCurrentGradient(system._ratio, system._colorRemapGradients, (currentGradient, nextGradient, scale) => {
261
+ const min = Lerp(currentGradient.factor1, nextGradient.factor1, scale);
262
+ const max = Lerp(currentGradient.factor2, nextGradient.factor2, scale);
263
+ particle.remapData.x = min;
264
+ particle.remapData.y = max - min;
265
+ });
266
+ }
267
+ if (system._alphaRemapGradients && system._alphaRemapGradients.length > 0) {
268
+ GradientHelper.GetCurrentGradient(system._ratio, system._alphaRemapGradients, (currentGradient, nextGradient, scale) => {
269
+ const min = Lerp(currentGradient.factor1, nextGradient.factor1, scale);
270
+ const max = Lerp(currentGradient.factor2, nextGradient.factor2, scale);
271
+ particle.remapData.z = min;
272
+ particle.remapData.w = max - min;
273
+ });
274
+ }
275
+ }
276
+ /** Life */
277
+ /** @internal */
278
+ export function _CreateLifeGradientsData(particle, system) {
279
+ const ratio = Clamp(system._actualFrame / system.targetStopDuration);
280
+ GradientHelper.GetCurrentGradient(ratio, system._lifeTimeGradients, (currentGradient, nextGradient) => {
281
+ const factorGradient1 = currentGradient;
282
+ const factorGradient2 = nextGradient;
283
+ const lifeTime1 = factorGradient1.getFactor();
284
+ const lifeTime2 = factorGradient2.getFactor();
285
+ const gradient = (ratio - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
286
+ particle.lifeTime = Lerp(lifeTime1, lifeTime2, gradient);
287
+ });
288
+ system._emitPower = RandomRange(system.minEmitPower, system.maxEmitPower);
289
+ }
290
+ /** @internal */
291
+ export function _CreateLifetimeData(particle, system) {
292
+ particle.lifeTime = RandomRange(system.minLifeTime, system.maxLifeTime);
293
+ system._emitPower = RandomRange(system.minEmitPower, system.maxEmitPower);
294
+ }
295
+ /** Emit power */
296
+ /** @internal */
297
+ export function _CreateEmitPowerData(particle, system) {
298
+ if (system._emitPower === 0) {
299
+ if (!particle._initialDirection) {
300
+ particle._initialDirection = particle.direction.clone();
301
+ }
302
+ else {
303
+ particle._initialDirection.copyFrom(particle.direction);
304
+ }
305
+ particle.direction.set(0, 0, 0);
306
+ }
307
+ else {
308
+ particle._initialDirection = null;
309
+ particle.direction.scaleInPlace(system._emitPower);
310
+ }
311
+ // Inherited Velocity
312
+ particle.direction.addInPlace(system._inheritedVelocityOffset);
313
+ }
314
+ /** Angle */
315
+ /** @internal */
316
+ export function _CreateAngleData(particle, system) {
317
+ particle.angularSpeed = RandomRange(system.minAngularSpeed, system.maxAngularSpeed);
318
+ particle.angle = RandomRange(system.minInitialRotation, system.maxInitialRotation);
319
+ }
320
+ /** @internal */
321
+ export function _CreateAngleGradientsData(particle, system) {
322
+ particle._currentAngularSpeedGradient = system._angularSpeedGradients[0];
323
+ particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
324
+ particle._currentAngularSpeed1 = particle.angularSpeed;
325
+ if (system._angularSpeedGradients.length > 1) {
326
+ particle._currentAngularSpeed2 = system._angularSpeedGradients[1].getFactor();
327
+ }
328
+ else {
329
+ particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
330
+ }
331
+ particle.angle = RandomRange(system.minInitialRotation, system.maxInitialRotation);
332
+ }
333
+ /** Sheet */
334
+ /** @internal */
335
+ export function _CreateSheetData(particle, system) {
336
+ particle._initialStartSpriteCellID = system.startSpriteCellID;
337
+ particle._initialEndSpriteCellID = system.endSpriteCellID;
338
+ particle._initialSpriteCellLoop = system.spriteCellLoop;
339
+ }
340
+ //# sourceMappingURL=thinParticleSystem.function.js.map