sparcoon 0.7.2 → 0.9.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/README.md +124 -76
- package/dist/artifact/FXArtifact.d.ts +120 -0
- package/dist/artifact/FXArtifact.js +1 -0
- package/dist/coreLayout.d.ts +22 -0
- package/dist/coreLayout.js +32 -0
- package/dist/effect/FXEffect.d.ts +77 -0
- package/dist/effect/FXEffect.js +454 -0
- package/dist/effect/FXEffectSampling.Internal.d.ts +24 -0
- package/dist/effect/FXEffectSampling.Internal.js +165 -0
- package/dist/effect/FXEffectSpec.d.ts +115 -0
- package/dist/effect/FXEffectSpec.js +1 -0
- package/dist/emitter/FXEmitter.Internal.d.ts +23 -58
- package/dist/emitter/FXEmitter.Internal.js +13 -29
- package/dist/emitter/FXEmitter.d.ts +46 -48
- package/dist/emitter/FXEmitter.js +355 -186
- package/dist/emitter/FXFromArtifactsOptions.d.ts +13 -0
- package/dist/emitter/FXFromArtifactsOptions.js +1 -0
- package/dist/emitter/FXObjectMotion.Internal.d.ts +33 -0
- package/dist/emitter/FXObjectMotion.Internal.js +87 -0
- package/dist/emitter/FXSimulationHolder.d.ts +1 -0
- package/dist/emitter/FXSimulationHolder.js +43 -0
- package/dist/index.d.ts +10 -39
- package/dist/index.js +13 -36
- package/dist/instancedParticle/FXInstancedParticle.d.ts +1 -22
- package/dist/instancedParticle/FXInstancedParticle.js +145 -85
- package/dist/instancedParticle/glTypeInfo.d.ts +5 -0
- package/dist/instancedParticle/glTypeInfo.js +3 -0
- package/dist/instancedParticle/primitiveGeometry.d.ts +1 -0
- package/dist/instancedParticle/primitiveGeometry.js +30 -0
- package/dist/miscellaneous/asserts.d.ts +1 -18
- package/dist/miscellaneous/asserts.js +21 -28
- package/dist/miscellaneous/fxMath.d.ts +26 -0
- package/dist/miscellaneous/fxMath.js +261 -0
- package/dist/miscellaneous/math.d.ts +2 -7
- package/dist/miscellaneous/math.js +8 -9
- package/dist/miscellaneous/texture/fxDataTexture.d.ts +26 -0
- package/dist/miscellaneous/texture/fxDataTexture.js +20 -0
- package/dist/render/FXArtifactMaterial.Internal.d.ts +16 -0
- package/dist/render/FXArtifactMaterial.Internal.js +944 -0
- package/dist/render/FXArtifactMaterial.d.ts +1 -0
- package/dist/render/FXArtifactMaterial.js +79 -0
- package/dist/render/FXMaterialOptions.d.ts +27 -0
- package/dist/render/FXMaterialOptions.js +5 -0
- package/dist/render/FXMeshMaterial.d.ts +40 -0
- package/dist/render/FXMeshMaterial.js +77 -0
- package/dist/world/FXWorld.d.ts +42 -0
- package/dist/world/FXWorld.js +103 -0
- package/package.json +45 -29
- package/dist/_virtual/2d.js +0 -3
- package/dist/_virtual/3d.js +0 -3
- package/dist/_virtual/4d.js +0 -3
- package/dist/_virtual/mod.js +0 -5
- package/dist/_virtual/mod2.js +0 -3
- package/dist/emitter/behavior/FXBehavior.d.ts +0 -24
- package/dist/emitter/behavior/FXBehavior.js +0 -10
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.d.ts +0 -23
- package/dist/emitter/behavior/FXBehaviorDirectionalForce.js +0 -72
- package/dist/emitter/behavior/FXBehaviorPointForce.d.ts +0 -36
- package/dist/emitter/behavior/FXBehaviorPointForce.js +0 -94
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.d.ts +0 -24
- package/dist/emitter/behavior/FXBehaviorScaleOverLife.js +0 -55
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.d.ts +0 -20
- package/dist/emitter/behavior/FXBehaviorTorqueDamping.js +0 -48
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.d.ts +0 -25
- package/dist/emitter/behavior/FXBehaviorTorqueNoise.js +0 -67
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.d.ts +0 -19
- package/dist/emitter/behavior/FXBehaviorTorqueOverLife.js +0 -41
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.d.ts +0 -20
- package/dist/emitter/behavior/FXBehaviorVelocityDamping.js +0 -50
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.d.ts +0 -25
- package/dist/emitter/behavior/FXBehaviorVelocityNoise.js +0 -76
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.d.ts +0 -22
- package/dist/emitter/behavior/FXBehaviorVelocityOverLife.js +0 -55
- package/dist/emitter/spawn/FXSpawn.d.ts +0 -11
- package/dist/emitter/spawn/FXSpawn.js +0 -10
- package/dist/emitter/spawn/FXSpawnBox.d.ts +0 -18
- package/dist/emitter/spawn/FXSpawnBox.js +0 -50
- package/dist/emitter/spawn/FXSpawnLifetime.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnLifetime.js +0 -44
- package/dist/emitter/spawn/FXSpawnOffset.d.ts +0 -21
- package/dist/emitter/spawn/FXSpawnOffset.js +0 -49
- package/dist/emitter/spawn/FXSpawnPoint.d.ts +0 -18
- package/dist/emitter/spawn/FXSpawnPoint.js +0 -46
- package/dist/emitter/spawn/FXSpawnRotation.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnRotation.js +0 -42
- package/dist/emitter/spawn/FXSpawnScale.d.ts +0 -22
- package/dist/emitter/spawn/FXSpawnScale.js +0 -56
- package/dist/emitter/spawn/FXSpawnSphere.d.ts +0 -36
- package/dist/emitter/spawn/FXSpawnSphere.js +0 -87
- package/dist/emitter/spawn/FXSpawnTorque.d.ts +0 -17
- package/dist/emitter/spawn/FXSpawnTorque.js +0 -42
- package/dist/emitter/spawn/FXSpawnVelocity.d.ts +0 -29
- package/dist/emitter/spawn/FXSpawnVelocity.js +0 -91
- package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +0 -2
- package/dist/instancedParticle/shared.d.ts +0 -19
- package/dist/instancedParticle/shared.js +0 -116
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +0 -24
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +0 -275
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.d.ts +0 -75
- package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +0 -63
- package/dist/materials/FXMaterial/FXBlending.Internal.d.ts +0 -24
- package/dist/materials/FXMaterial/FXBlending.Internal.js +0 -64
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.d.ts +0 -4
- package/dist/materials/FXMaterial/FXDepthMaterial.Internal.js +0 -144
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.d.ts +0 -4
- package/dist/materials/FXMaterial/FXDistanceMaterial.Internal.js +0 -175
- package/dist/materials/FXMaterial/FXMaterial.d.ts +0 -70
- package/dist/materials/FXMaterial/FXMaterial.js +0 -51
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +0 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +0 -103
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.d.ts +0 -7
- package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +0 -21
- package/dist/miscellaneous/color/FXColor.Internal.d.ts +0 -7
- package/dist/miscellaneous/color/FXColor.Internal.js +0 -42
- package/dist/miscellaneous/color/FXColor.d.ts +0 -234
- package/dist/miscellaneous/color/FXColor.js +0 -636
- package/dist/miscellaneous/curve/FXCurve1D.Internal.d.ts +0 -20
- package/dist/miscellaneous/curve/FXCurve1D.d.ts +0 -17
- package/dist/miscellaneous/curve/FXCurve1D.js +0 -94
- package/dist/miscellaneous/miscellaneous.d.ts +0 -34
- package/dist/miscellaneous/miscellaneous.js +0 -85
- package/dist/miscellaneous/texture/FXTextureView.Internal.d.ts +0 -49
- package/dist/miscellaneous/texture/FXTextureView.Internal.js +0 -6
- package/dist/miscellaneous/texture/FXTextureView.d.ts +0 -72
- package/dist/miscellaneous/texture/FXTextureView.js +0 -234
- package/dist/miscellaneous/webglCapabilities.d.ts +0 -1
- package/dist/miscellaneous/webglCapabilities.js +0 -45
- package/dist/node_modules/fast-simplex-noise/lib/2d.js +0 -93
- package/dist/node_modules/fast-simplex-noise/lib/3d.js +0 -142
- package/dist/node_modules/fast-simplex-noise/lib/4d.js +0 -196
- package/dist/node_modules/fast-simplex-noise/lib/mod.js +0 -24
- package/dist/nodes/FXNode.d.ts +0 -5
- package/dist/nodes/FXNode.js +0 -10
- package/dist/nodes/blending/FXNodeBlending.d.ts +0 -6
- package/dist/nodes/blending/FXNodeBlending.js +0 -9
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.d.ts +0 -19
- package/dist/nodes/blending/FXNodeLightnessBlendingMask.js +0 -65
- package/dist/nodes/color/FXNodeColor.d.ts +0 -6
- package/dist/nodes/color/FXNodeColor.js +0 -9
- package/dist/nodes/color/FXNodeColorOverLife.d.ts +0 -22
- package/dist/nodes/color/FXNodeColorOverLife.js +0 -64
- package/dist/nodes/color/FXNodeSphericalClip.d.ts +0 -21
- package/dist/nodes/color/FXNodeSphericalClip.js +0 -54
- package/dist/nodes/normal/FXNodeFlatNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeFlatNormal.js +0 -17
- package/dist/nodes/normal/FXNodeNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeNormal.js +0 -9
- package/dist/nodes/normal/FXNodeSphericalNormal.d.ts +0 -6
- package/dist/nodes/normal/FXNodeSphericalNormal.js +0 -24
- package/dist/nodes/texture/FXNodeAnimatedTexture.d.ts +0 -52
- package/dist/nodes/texture/FXNodeAnimatedTexture.js +0 -151
- package/dist/nodes/texture/FXNodeStaticTexture.d.ts +0 -20
- package/dist/nodes/texture/FXNodeStaticTexture.js +0 -67
- package/dist/nodes/texture/FXNodeTexture.d.ts +0 -6
- package/dist/nodes/texture/FXNodeTexture.js +0 -9
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Vector3Like } from "../../miscellaneous/math";
|
|
2
|
-
import type { FXVector3Config } from "../../miscellaneous/miscellaneous";
|
|
3
|
-
import { FXBehavior } from "./FXBehavior";
|
|
4
|
-
/**
|
|
5
|
-
* Applies attraction or repulsion toward a point
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Particles closer than `threshold` are unaffected.
|
|
9
|
-
*/
|
|
10
|
-
export declare class FXBehaviorPointForce extends FXBehavior<{
|
|
11
|
-
builtin: "Matrix4";
|
|
12
|
-
}> {
|
|
13
|
-
private centerInternal;
|
|
14
|
-
private strengthInternal;
|
|
15
|
-
private exponentInternal;
|
|
16
|
-
private thresholdInternal;
|
|
17
|
-
/**
|
|
18
|
-
* @param center - Force center position
|
|
19
|
-
* @param strength - Force multiplier
|
|
20
|
-
* @param exponent - Distance power exponent
|
|
21
|
-
* @param threshold - Minimum distance
|
|
22
|
-
*/
|
|
23
|
-
constructor(center: Vector3Like, strength: number, exponent?: number, threshold?: number);
|
|
24
|
-
/** Force center position */
|
|
25
|
-
get center(): Vector3Like;
|
|
26
|
-
/** Force multiplier */
|
|
27
|
-
get strength(): number;
|
|
28
|
-
/** Distance power exponent */
|
|
29
|
-
get exponent(): number;
|
|
30
|
-
/** Minimum distance */
|
|
31
|
-
get threshold(): number;
|
|
32
|
-
set center(value: FXVector3Config);
|
|
33
|
-
set strength(value: number);
|
|
34
|
-
set exponent(value: number);
|
|
35
|
-
set threshold(value: number);
|
|
36
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { assertValidNumber } from '../../miscellaneous/asserts.js';
|
|
2
|
-
import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
|
|
3
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Applies attraction or repulsion toward a point
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Particles closer than `threshold` are unaffected.
|
|
10
|
-
*/
|
|
11
|
-
class FXBehaviorPointForce extends FXBehavior {
|
|
12
|
-
/**
|
|
13
|
-
* @param center - Force center position
|
|
14
|
-
* @param strength - Force multiplier
|
|
15
|
-
* @param exponent - Distance power exponent
|
|
16
|
-
* @param threshold - Minimum distance
|
|
17
|
-
*/
|
|
18
|
-
constructor(center, strength, exponent = 2, threshold = 0.1) {
|
|
19
|
-
super();
|
|
20
|
-
/** @internal */
|
|
21
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
22
|
-
this._private_centerInternal = resolveFXVector3Config(center);
|
|
23
|
-
assertValidNumber(this._private_centerInternal.x, "FXBehaviorPointForce.constructor.center.x");
|
|
24
|
-
assertValidNumber(this._private_centerInternal.y, "FXBehaviorPointForce.constructor.center.y");
|
|
25
|
-
assertValidNumber(this._private_centerInternal.z, "FXBehaviorPointForce.constructor.center.z");
|
|
26
|
-
assertValidNumber(strength, "FXBehaviorPointForce.constructor.strength");
|
|
27
|
-
this._private_strengthInternal = strength;
|
|
28
|
-
assertValidNumber(exponent, "FXBehaviorPointForce.constructor.exponent");
|
|
29
|
-
this._private_exponentInternal = exponent;
|
|
30
|
-
assertValidNumber(threshold, "FXBehaviorPointForce.constructor.threshold");
|
|
31
|
-
this._private_thresholdInternal = threshold;
|
|
32
|
-
}
|
|
33
|
-
/** Force center position */
|
|
34
|
-
get center() {
|
|
35
|
-
return this._private_centerInternal;
|
|
36
|
-
}
|
|
37
|
-
/** Force multiplier */
|
|
38
|
-
get strength() {
|
|
39
|
-
return this._private_strengthInternal;
|
|
40
|
-
}
|
|
41
|
-
/** Distance power exponent */
|
|
42
|
-
get exponent() {
|
|
43
|
-
return this._private_exponentInternal;
|
|
44
|
-
}
|
|
45
|
-
/** Minimum distance */
|
|
46
|
-
get threshold() {
|
|
47
|
-
return this._private_thresholdInternal;
|
|
48
|
-
}
|
|
49
|
-
set center(value) {
|
|
50
|
-
this._private_centerInternal = resolveFXVector3Config(value);
|
|
51
|
-
assertValidNumber(this._private_centerInternal.x, "FXBehaviorPointForce.center.x");
|
|
52
|
-
assertValidNumber(this._private_centerInternal.y, "FXBehaviorPointForce.center.y");
|
|
53
|
-
assertValidNumber(this._private_centerInternal.z, "FXBehaviorPointForce.center.z");
|
|
54
|
-
}
|
|
55
|
-
set strength(value) {
|
|
56
|
-
assertValidNumber(value, "FXBehaviorPointForce.strength");
|
|
57
|
-
this._private_strengthInternal = value;
|
|
58
|
-
}
|
|
59
|
-
set exponent(value) {
|
|
60
|
-
assertValidNumber(value, "FXBehaviorPointForce.exponent");
|
|
61
|
-
this._private_exponentInternal = value;
|
|
62
|
-
}
|
|
63
|
-
set threshold(value) {
|
|
64
|
-
assertValidNumber(value, "FXBehaviorPointForce.threshold");
|
|
65
|
-
this._private_thresholdInternal = value;
|
|
66
|
-
}
|
|
67
|
-
/** @internal */
|
|
68
|
-
update(properties, instanceCount, deltaTime) {
|
|
69
|
-
const { builtin } = properties;
|
|
70
|
-
const { array, itemSize } = builtin;
|
|
71
|
-
const thresholdSquared = this._private_thresholdInternal * this._private_thresholdInternal;
|
|
72
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
73
|
-
const itemOffset = i * itemSize;
|
|
74
|
-
const dx = this._private_centerInternal.x - array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
75
|
-
const dy = this._private_centerInternal.y - array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
76
|
-
const dz = this._private_centerInternal.z - array[itemOffset + BUILTIN_OFFSET_POSITION_Z];
|
|
77
|
-
const distanceSquared = dx * dx + dy * dy + dz * dz;
|
|
78
|
-
if (distanceSquared < thresholdSquared) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const distance = Math.sqrt(distanceSquared);
|
|
82
|
-
const forceMagnitude = this._private_strengthInternal / Math.pow(distance, this._private_exponentInternal);
|
|
83
|
-
const directionX = dx / distance;
|
|
84
|
-
const directionY = dy / distance;
|
|
85
|
-
const directionZ = dz / distance;
|
|
86
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += directionX * forceMagnitude * deltaTime;
|
|
87
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += directionY * forceMagnitude * deltaTime;
|
|
88
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] += directionZ * forceMagnitude * deltaTime;
|
|
89
|
-
}
|
|
90
|
-
builtin.needsUpdate = true;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { FXBehaviorPointForce };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { FXCurve1DConfig } from "../../miscellaneous/curve/FXCurve1D";
|
|
2
|
-
import { FXCurve1D } from "../../miscellaneous/curve/FXCurve1D";
|
|
3
|
-
import type { FXAspectConfig, FXRange } from "../../miscellaneous/miscellaneous";
|
|
4
|
-
import { FXBehavior } from "./FXBehavior";
|
|
5
|
-
/**
|
|
6
|
-
* Animates particle scale over lifetime using a {@link FXCurve1D}
|
|
7
|
-
*/
|
|
8
|
-
export declare class FXBehaviorScaleOverLife extends FXBehavior<{
|
|
9
|
-
builtin: "Matrix4";
|
|
10
|
-
}> {
|
|
11
|
-
private curveInternal;
|
|
12
|
-
private aspectInternal;
|
|
13
|
-
/**
|
|
14
|
-
* @param curve - Scale curve; accepts a {@link FXCurve1D} instance or a `FXRange[]` shorthand
|
|
15
|
-
* @param aspect - Width/height ratio; must be positive. Defaults to `1`
|
|
16
|
-
*/
|
|
17
|
-
constructor(curve: FXCurve1DConfig<FXRange>, aspect?: FXAspectConfig);
|
|
18
|
-
/** Active scale curve */
|
|
19
|
-
get curve(): FXCurve1D<FXRange>;
|
|
20
|
-
/** Width/height aspect ratio */
|
|
21
|
-
get aspect(): number;
|
|
22
|
-
set curve(value: FXCurve1DConfig<FXRange>);
|
|
23
|
-
set aspect(value: FXAspectConfig);
|
|
24
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
-
import { FXCurve1D } from '../../miscellaneous/curve/FXCurve1D.js';
|
|
4
|
-
import { resolveAspect, BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../../miscellaneous/miscellaneous.js';
|
|
5
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Animates particle scale over lifetime using a {@link FXCurve1D}
|
|
9
|
-
*/
|
|
10
|
-
class FXBehaviorScaleOverLife extends FXBehavior {
|
|
11
|
-
/**
|
|
12
|
-
* @param curve - Scale curve; accepts a {@link FXCurve1D} instance or a `FXRange[]` shorthand
|
|
13
|
-
* @param aspect - Width/height ratio; must be positive. Defaults to `1`
|
|
14
|
-
*/
|
|
15
|
-
constructor(curve, aspect = 1) {
|
|
16
|
-
super();
|
|
17
|
-
/** @internal */
|
|
18
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
19
|
-
this._private_curveInternal = new FXCurve1D(curve);
|
|
20
|
-
this._private_aspectInternal = resolveAspect(aspect);
|
|
21
|
-
assertValidPositiveNumber(this._private_aspectInternal, "FXBehaviorScaleOverLife.constructor.aspect");
|
|
22
|
-
}
|
|
23
|
-
/** Active scale curve */
|
|
24
|
-
get curve() {
|
|
25
|
-
return this._private_curveInternal;
|
|
26
|
-
}
|
|
27
|
-
/** Width/height aspect ratio */
|
|
28
|
-
get aspect() {
|
|
29
|
-
return this._private_aspectInternal;
|
|
30
|
-
}
|
|
31
|
-
set curve(value) {
|
|
32
|
-
this._private_curveInternal = new FXCurve1D(value);
|
|
33
|
-
}
|
|
34
|
-
set aspect(value) {
|
|
35
|
-
this._private_aspectInternal = resolveAspect(value);
|
|
36
|
-
assertValidPositiveNumber(this._private_aspectInternal, "FXBehaviorScaleOverLife.aspect");
|
|
37
|
-
}
|
|
38
|
-
/** @internal */
|
|
39
|
-
update(properties, instanceCount) {
|
|
40
|
-
const { builtin } = properties;
|
|
41
|
-
const { array, itemSize } = builtin;
|
|
42
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
43
|
-
const itemOffset = i * itemSize;
|
|
44
|
-
const lifeT = Math.min(array[itemOffset + BUILTIN_OFFSET_AGE] / array[itemOffset + BUILTIN_OFFSET_LIFETIME], 1);
|
|
45
|
-
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
46
|
-
const { a, b, t: localT } = this._private_curveInternal.sample(lifeT);
|
|
47
|
-
const scale = MathUtils.lerp(MathUtils.lerp(a.min, a.max, scaleT), MathUtils.lerp(b.min, b.max, scaleT), localT);
|
|
48
|
-
array[itemOffset + BUILTIN_OFFSET_SCALE_X] = scale * this._private_aspectInternal;
|
|
49
|
-
array[itemOffset + BUILTIN_OFFSET_SCALE_Y] = scale;
|
|
50
|
-
}
|
|
51
|
-
builtin.needsUpdate = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { FXBehaviorScaleOverLife };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
-
import { FXBehavior } from "./FXBehavior";
|
|
3
|
-
/**
|
|
4
|
-
* Reduces particle angular velocity over time
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* A damping value of `0` has no effect; `1` stops the particle instantly.
|
|
8
|
-
*/
|
|
9
|
-
export declare class FXBehaviorTorqueDamping extends FXBehavior<{
|
|
10
|
-
builtin: "Matrix4";
|
|
11
|
-
}> {
|
|
12
|
-
private dampingInternal;
|
|
13
|
-
/**
|
|
14
|
-
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
15
|
-
*/
|
|
16
|
-
constructor(damping: FXRangeConfig);
|
|
17
|
-
/** Damping coefficient range (0-1) */
|
|
18
|
-
get damping(): FXRange;
|
|
19
|
-
set damping(value: FXRangeConfig);
|
|
20
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reduces particle angular velocity over time
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* A damping value of `0` has no effect; `1` stops the particle instantly.
|
|
11
|
-
*/
|
|
12
|
-
class FXBehaviorTorqueDamping extends FXBehavior {
|
|
13
|
-
/**
|
|
14
|
-
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
15
|
-
*/
|
|
16
|
-
constructor(damping) {
|
|
17
|
-
super();
|
|
18
|
-
/** @internal */
|
|
19
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
20
|
-
this._private_dampingInternal = resolveFXRangeConfig(damping);
|
|
21
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.min, `FXBehaviorTorqueDamping.constructor.damping.min`);
|
|
22
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.max, `FXBehaviorTorqueDamping.constructor.damping.max`);
|
|
23
|
-
}
|
|
24
|
-
/** Damping coefficient range (0-1) */
|
|
25
|
-
get damping() {
|
|
26
|
-
return this._private_dampingInternal;
|
|
27
|
-
}
|
|
28
|
-
set damping(value) {
|
|
29
|
-
this._private_dampingInternal = resolveFXRangeConfig(value);
|
|
30
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.min, `FXBehaviorTorqueDamping.damping.min`);
|
|
31
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.max, `FXBehaviorTorqueDamping.damping.max`);
|
|
32
|
-
}
|
|
33
|
-
/** @internal */
|
|
34
|
-
update(properties, instanceCount, deltaTime) {
|
|
35
|
-
const { builtin } = properties;
|
|
36
|
-
const { array, itemSize } = builtin;
|
|
37
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
38
|
-
const itemOffset = i * itemSize;
|
|
39
|
-
// Constant over the life of a particle but different for each particle
|
|
40
|
-
const dampingT = array[itemOffset + BUILTIN_OFFSET_RANDOM_B];
|
|
41
|
-
const dampingFactor = Math.pow(1 - MathUtils.lerp(this._private_dampingInternal.min, this._private_dampingInternal.max, dampingT), deltaTime);
|
|
42
|
-
array[itemOffset + BUILTIN_OFFSET_TORQUE] *= dampingFactor;
|
|
43
|
-
}
|
|
44
|
-
builtin.needsUpdate = true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { FXBehaviorTorqueDamping };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
-
import { FXBehavior } from "./FXBehavior";
|
|
3
|
-
/**
|
|
4
|
-
* Applies noise-based angular acceleration to particles
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Higher `scale` values produce finer noise detail.
|
|
8
|
-
*/
|
|
9
|
-
export declare class FXBehaviorTorqueNoise extends FXBehavior<{
|
|
10
|
-
builtin: "Matrix4";
|
|
11
|
-
}> {
|
|
12
|
-
private scaleInternal;
|
|
13
|
-
private strengthInternal;
|
|
14
|
-
/**
|
|
15
|
-
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
16
|
-
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
17
|
-
*/
|
|
18
|
-
constructor(scale: FXRangeConfig, strength: FXRangeConfig);
|
|
19
|
-
/** Noise frequency range */
|
|
20
|
-
get scale(): FXRange;
|
|
21
|
-
/** Force multiplier range */
|
|
22
|
-
get strength(): FXRange;
|
|
23
|
-
set scale(value: FXRangeConfig);
|
|
24
|
-
set strength(value: FXRangeConfig);
|
|
25
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { m as modExports } from '../../_virtual/mod.js';
|
|
2
|
-
import { MathUtils } from 'three';
|
|
3
|
-
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
4
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
|
|
5
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
6
|
-
|
|
7
|
-
const generateNoise3D = modExports.makeNoise3D();
|
|
8
|
-
/**
|
|
9
|
-
* Applies noise-based angular acceleration to particles
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* Higher `scale` values produce finer noise detail.
|
|
13
|
-
*/
|
|
14
|
-
class FXBehaviorTorqueNoise extends FXBehavior {
|
|
15
|
-
/**
|
|
16
|
-
* @param scale - Noise frequency range. Accepts number, tuple, or range object
|
|
17
|
-
* @param strength - Force multiplier range. Accepts number, tuple, or range object
|
|
18
|
-
*/
|
|
19
|
-
constructor(scale, strength) {
|
|
20
|
-
super();
|
|
21
|
-
/** @internal */
|
|
22
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
23
|
-
this._private_scaleInternal = resolveFXRangeConfig(scale);
|
|
24
|
-
assertValidPositiveNumber(this._private_scaleInternal.min, `FXBehaviorTorqueNoise.constructor.scale.min`);
|
|
25
|
-
assertValidPositiveNumber(this._private_scaleInternal.max, `FXBehaviorTorqueNoise.constructor.scale.max`);
|
|
26
|
-
this._private_strengthInternal = resolveFXRangeConfig(strength);
|
|
27
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.min, `FXBehaviorTorqueNoise.constructor.strength.min`);
|
|
28
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.max, `FXBehaviorTorqueNoise.constructor.strength.max`);
|
|
29
|
-
}
|
|
30
|
-
/** Noise frequency range */
|
|
31
|
-
get scale() {
|
|
32
|
-
return this._private_scaleInternal;
|
|
33
|
-
}
|
|
34
|
-
/** Force multiplier range */
|
|
35
|
-
get strength() {
|
|
36
|
-
return this._private_strengthInternal;
|
|
37
|
-
}
|
|
38
|
-
set scale(value) {
|
|
39
|
-
this._private_scaleInternal = resolveFXRangeConfig(value);
|
|
40
|
-
assertValidPositiveNumber(this._private_scaleInternal.min, `FXBehaviorTorqueNoise.scale.min`);
|
|
41
|
-
assertValidPositiveNumber(this._private_scaleInternal.max, `FXBehaviorTorqueNoise.scale.max`);
|
|
42
|
-
}
|
|
43
|
-
set strength(value) {
|
|
44
|
-
this._private_strengthInternal = resolveFXRangeConfig(value);
|
|
45
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.min, `FXBehaviorTorqueNoise.strength.min`);
|
|
46
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.max, `FXBehaviorTorqueNoise.strength.max`);
|
|
47
|
-
}
|
|
48
|
-
/** @internal */
|
|
49
|
-
update(properties, instanceCount, deltaTime) {
|
|
50
|
-
const { builtin } = properties;
|
|
51
|
-
const { array, itemSize } = builtin;
|
|
52
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
53
|
-
const itemOffset = i * itemSize;
|
|
54
|
-
// Constant over the life of a particle but different for each particle
|
|
55
|
-
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
|
|
56
|
-
const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
|
|
57
|
-
const noise = generateNoise3D(array[itemOffset + BUILTIN_OFFSET_POSITION_X] * scale, array[itemOffset + BUILTIN_OFFSET_POSITION_Y] * scale, array[itemOffset + BUILTIN_OFFSET_POSITION_Z] * scale);
|
|
58
|
-
// Constant over the life of a particle but different for each particle
|
|
59
|
-
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
60
|
-
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
61
|
-
array[itemOffset + BUILTIN_OFFSET_TORQUE] += noise * strength * deltaTime;
|
|
62
|
-
}
|
|
63
|
-
builtin.needsUpdate = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { FXBehaviorTorqueNoise };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { FXCurve1DConfig } from "../../miscellaneous/curve/FXCurve1D";
|
|
2
|
-
import { FXCurve1D } from "../../miscellaneous/curve/FXCurve1D";
|
|
3
|
-
import type { FXRange } from "../../miscellaneous/miscellaneous";
|
|
4
|
-
import { FXBehavior } from "./FXBehavior";
|
|
5
|
-
/**
|
|
6
|
-
* Animates particle angular velocity over lifetime using a {@link FXCurve1D}
|
|
7
|
-
*/
|
|
8
|
-
export declare class FXBehaviorTorqueOverLife extends FXBehavior<{
|
|
9
|
-
builtin: "Matrix4";
|
|
10
|
-
}> {
|
|
11
|
-
private curveInternal;
|
|
12
|
-
/**
|
|
13
|
-
* @param curve - Torque curve; accepts a {@link FXCurve1D} instance or a `FXRange[]` shorthand
|
|
14
|
-
*/
|
|
15
|
-
constructor(curve: FXCurve1DConfig<FXRange>);
|
|
16
|
-
/** Active torque curve */
|
|
17
|
-
get curve(): FXCurve1D<FXRange>;
|
|
18
|
-
set curve(value: FXCurve1DConfig<FXRange>);
|
|
19
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { MathUtils } from 'three';
|
|
2
|
-
import { FXCurve1D } from '../../miscellaneous/curve/FXCurve1D.js';
|
|
3
|
-
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Animates particle angular velocity over lifetime using a {@link FXCurve1D}
|
|
8
|
-
*/
|
|
9
|
-
class FXBehaviorTorqueOverLife extends FXBehavior {
|
|
10
|
-
/**
|
|
11
|
-
* @param curve - Torque curve; accepts a {@link FXCurve1D} instance or a `FXRange[]` shorthand
|
|
12
|
-
*/
|
|
13
|
-
constructor(curve) {
|
|
14
|
-
super();
|
|
15
|
-
/** @internal */
|
|
16
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
17
|
-
this._private_curveInternal = new FXCurve1D(curve);
|
|
18
|
-
}
|
|
19
|
-
/** Active torque curve */
|
|
20
|
-
get curve() {
|
|
21
|
-
return this._private_curveInternal;
|
|
22
|
-
}
|
|
23
|
-
set curve(value) {
|
|
24
|
-
this._private_curveInternal = new FXCurve1D(value);
|
|
25
|
-
}
|
|
26
|
-
/** @internal */
|
|
27
|
-
update(properties, instanceCount) {
|
|
28
|
-
const { builtin } = properties;
|
|
29
|
-
const { array, itemSize } = builtin;
|
|
30
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
31
|
-
const itemOffset = i * itemSize;
|
|
32
|
-
const lifeT = Math.min(array[itemOffset + BUILTIN_OFFSET_AGE] / array[itemOffset + BUILTIN_OFFSET_LIFETIME], 1);
|
|
33
|
-
const torqueT = array[itemOffset + BUILTIN_OFFSET_RANDOM_B];
|
|
34
|
-
const { a, b, t: localT } = this._private_curveInternal.sample(lifeT);
|
|
35
|
-
array[itemOffset + BUILTIN_OFFSET_TORQUE] = MathUtils.lerp(MathUtils.lerp(a.min, a.max, torqueT), MathUtils.lerp(b.min, b.max, torqueT), localT);
|
|
36
|
-
}
|
|
37
|
-
builtin.needsUpdate = true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { FXBehaviorTorqueOverLife };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
-
import { FXBehavior } from "./FXBehavior";
|
|
3
|
-
/**
|
|
4
|
-
* Reduces particle velocity over time
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* A damping value of `0` has no effect; `1` stops the particle instantly.
|
|
8
|
-
*/
|
|
9
|
-
export declare class FXBehaviorVelocityDamping extends FXBehavior<{
|
|
10
|
-
builtin: "Matrix4";
|
|
11
|
-
}> {
|
|
12
|
-
private dampingInternal;
|
|
13
|
-
/**
|
|
14
|
-
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
15
|
-
*/
|
|
16
|
-
constructor(damping: FXRangeConfig);
|
|
17
|
-
/** Damping coefficient range (0-1) */
|
|
18
|
-
get damping(): FXRange;
|
|
19
|
-
set damping(value: FXRangeConfig);
|
|
20
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { MathUtils } from 'three';
|
|
2
|
-
import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
3
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
|
|
4
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reduces particle velocity over time
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* A damping value of `0` has no effect; `1` stops the particle instantly.
|
|
11
|
-
*/
|
|
12
|
-
class FXBehaviorVelocityDamping extends FXBehavior {
|
|
13
|
-
/**
|
|
14
|
-
* @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
|
|
15
|
-
*/
|
|
16
|
-
constructor(damping) {
|
|
17
|
-
super();
|
|
18
|
-
/** @internal */
|
|
19
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
20
|
-
this._private_dampingInternal = resolveFXRangeConfig(damping);
|
|
21
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.min, `FXBehaviorVelocityDamping.constructor.damping.min`);
|
|
22
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.max, `FXBehaviorVelocityDamping.constructor.damping.max`);
|
|
23
|
-
}
|
|
24
|
-
/** Damping coefficient range (0-1) */
|
|
25
|
-
get damping() {
|
|
26
|
-
return this._private_dampingInternal;
|
|
27
|
-
}
|
|
28
|
-
set damping(value) {
|
|
29
|
-
this._private_dampingInternal = resolveFXRangeConfig(value);
|
|
30
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.min, `FXBehaviorVelocityDamping.damping.min`);
|
|
31
|
-
assertValidNonNegativeNumber(this._private_dampingInternal.max, `FXBehaviorVelocityDamping.damping.max`);
|
|
32
|
-
}
|
|
33
|
-
/** @internal */
|
|
34
|
-
update(properties, instanceCount, deltaTime) {
|
|
35
|
-
const { builtin } = properties;
|
|
36
|
-
const { array, itemSize } = builtin;
|
|
37
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
38
|
-
const itemOffset = i * itemSize;
|
|
39
|
-
// Constant over the life of a particle but different for each particle
|
|
40
|
-
const dampingT = array[itemOffset + BUILTIN_OFFSET_RANDOM_B];
|
|
41
|
-
const dampingFactor = Math.pow(1 - MathUtils.lerp(this._private_dampingInternal.min, this._private_dampingInternal.max, dampingT), deltaTime);
|
|
42
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] *= dampingFactor;
|
|
43
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] *= dampingFactor;
|
|
44
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] *= dampingFactor;
|
|
45
|
-
}
|
|
46
|
-
builtin.needsUpdate = true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { FXBehaviorVelocityDamping };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
|
|
2
|
-
import { FXBehavior } from "./FXBehavior";
|
|
3
|
-
/**
|
|
4
|
-
* Applies noise-based acceleration to particles
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Higher `scale` values produce finer noise detail.
|
|
8
|
-
*/
|
|
9
|
-
export declare class FXBehaviorVelocityNoise extends FXBehavior<{
|
|
10
|
-
builtin: "Matrix4";
|
|
11
|
-
}> {
|
|
12
|
-
private scaleInternal;
|
|
13
|
-
private strengthInternal;
|
|
14
|
-
/**
|
|
15
|
-
* @param scale - Noise frequency range; must be positive.
|
|
16
|
-
* @param strength - Force multiplier range; must be non-negative.
|
|
17
|
-
*/
|
|
18
|
-
constructor(scale: FXRangeConfig, strength: FXRangeConfig);
|
|
19
|
-
/** Noise frequency range */
|
|
20
|
-
get scale(): FXRange;
|
|
21
|
-
/** Force multiplier range */
|
|
22
|
-
get strength(): FXRange;
|
|
23
|
-
set scale(value: FXRangeConfig);
|
|
24
|
-
set strength(value: FXRangeConfig);
|
|
25
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { m as modExports } from '../../_virtual/mod.js';
|
|
2
|
-
import { MathUtils } from 'three';
|
|
3
|
-
import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
|
|
4
|
-
import { resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
|
|
5
|
-
import { FXBehavior } from './FXBehavior.js';
|
|
6
|
-
|
|
7
|
-
const generateNoise3D0 = modExports.makeNoise3D();
|
|
8
|
-
const generateNoise3D1 = modExports.makeNoise3D();
|
|
9
|
-
const generateNoise3D2 = modExports.makeNoise3D();
|
|
10
|
-
/**
|
|
11
|
-
* Applies noise-based acceleration to particles
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* Higher `scale` values produce finer noise detail.
|
|
15
|
-
*/
|
|
16
|
-
class FXBehaviorVelocityNoise extends FXBehavior {
|
|
17
|
-
/**
|
|
18
|
-
* @param scale - Noise frequency range; must be positive.
|
|
19
|
-
* @param strength - Force multiplier range; must be non-negative.
|
|
20
|
-
*/
|
|
21
|
-
constructor(scale, strength) {
|
|
22
|
-
super();
|
|
23
|
-
/** @internal */
|
|
24
|
-
this.requiredProperties = { builtin: "Matrix4" };
|
|
25
|
-
this._private_scaleInternal = resolveFXRangeConfig(scale);
|
|
26
|
-
assertValidPositiveNumber(this._private_scaleInternal.min, `FXBehaviorVelocityNoise.constructor.scale.min`);
|
|
27
|
-
assertValidPositiveNumber(this._private_scaleInternal.max, `FXBehaviorVelocityNoise.constructor.scale.max`);
|
|
28
|
-
this._private_strengthInternal = resolveFXRangeConfig(strength);
|
|
29
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.min, `FXBehaviorVelocityNoise.constructor.strength.min`);
|
|
30
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.max, `FXBehaviorVelocityNoise.constructor.strength.max`);
|
|
31
|
-
}
|
|
32
|
-
/** Noise frequency range */
|
|
33
|
-
get scale() {
|
|
34
|
-
return this._private_scaleInternal;
|
|
35
|
-
}
|
|
36
|
-
/** Force multiplier range */
|
|
37
|
-
get strength() {
|
|
38
|
-
return this._private_strengthInternal;
|
|
39
|
-
}
|
|
40
|
-
set scale(value) {
|
|
41
|
-
this._private_scaleInternal = resolveFXRangeConfig(value);
|
|
42
|
-
assertValidPositiveNumber(this._private_scaleInternal.min, `FXBehaviorVelocityNoise.scale.min`);
|
|
43
|
-
assertValidPositiveNumber(this._private_scaleInternal.max, `FXBehaviorVelocityNoise.scale.max`);
|
|
44
|
-
}
|
|
45
|
-
set strength(value) {
|
|
46
|
-
this._private_strengthInternal = resolveFXRangeConfig(value);
|
|
47
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.min, `FXBehaviorVelocityNoise.strength.min`);
|
|
48
|
-
assertValidNonNegativeNumber(this._private_strengthInternal.max, `FXBehaviorVelocityNoise.strength.max`);
|
|
49
|
-
}
|
|
50
|
-
/** @internal */
|
|
51
|
-
update(properties, instanceCount, deltaTime) {
|
|
52
|
-
const { builtin } = properties;
|
|
53
|
-
const { array, itemSize } = builtin;
|
|
54
|
-
for (let i = 0; i < instanceCount; i++) {
|
|
55
|
-
const itemOffset = i * itemSize;
|
|
56
|
-
const x = array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
57
|
-
const y = array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
58
|
-
const z = array[itemOffset + BUILTIN_OFFSET_POSITION_Z];
|
|
59
|
-
// Constant over the life of a particle but different for each particle
|
|
60
|
-
const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
|
|
61
|
-
const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
|
|
62
|
-
const noiseX = generateNoise3D0(x * scale, y * scale, z * scale);
|
|
63
|
-
const noiseY = generateNoise3D1(x * scale, y * scale, z * scale);
|
|
64
|
-
const noiseZ = generateNoise3D2(x * scale, y * scale, z * scale);
|
|
65
|
-
// Constant over the life of a particle but different for each particle
|
|
66
|
-
const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
|
|
67
|
-
const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
|
|
68
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += noiseX * strength * deltaTime;
|
|
69
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += noiseY * strength * deltaTime;
|
|
70
|
-
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] += noiseZ * strength * deltaTime;
|
|
71
|
-
}
|
|
72
|
-
builtin.needsUpdate = true;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export { FXBehaviorVelocityNoise };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { FXCurve1DConfig } from "../../miscellaneous/curve/FXCurve1D";
|
|
2
|
-
import { FXCurve1D } from "../../miscellaneous/curve/FXCurve1D";
|
|
3
|
-
import type { FXRange } from "../../miscellaneous/miscellaneous";
|
|
4
|
-
import { FXBehavior } from "./FXBehavior";
|
|
5
|
-
/**
|
|
6
|
-
* Animates particle speed over lifetime using a {@link FXCurve1D}
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Particles with zero velocity are not affected.
|
|
10
|
-
*/
|
|
11
|
-
export declare class FXBehaviorVelocityOverLife extends FXBehavior<{
|
|
12
|
-
builtin: "Matrix4";
|
|
13
|
-
}> {
|
|
14
|
-
private curveInternal;
|
|
15
|
-
/**
|
|
16
|
-
* @param curve - Speed curve; accepts a {@link FXCurve1D} instance or a `FXRange[]` shorthand
|
|
17
|
-
*/
|
|
18
|
-
constructor(curve: FXCurve1DConfig<FXRange>);
|
|
19
|
-
/** Active speed curve */
|
|
20
|
-
get curve(): FXCurve1D<FXRange>;
|
|
21
|
-
set curve(value: FXCurve1DConfig<FXRange>);
|
|
22
|
-
}
|