custom-pixi-particles 5.2.0 → 7.1.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 +120 -82
- package/dist/index.d.ts +5 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/Particle.d.ts +15 -1
- package/dist/lib/Particle.js +29 -0
- package/dist/lib/Particle.js.map +1 -1
- package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +10 -6
- package/dist/lib/behaviour/AngularVelocityBehaviour.js +45 -14
- package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -1
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.d.ts +42 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js +78 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/BehaviourNames.d.ts +13 -2
- package/dist/lib/behaviour/BehaviourNames.js +13 -1
- package/dist/lib/behaviour/BehaviourNames.js.map +1 -1
- package/dist/lib/behaviour/CollisionBehaviour.d.ts +86 -0
- package/dist/lib/behaviour/CollisionBehaviour.js +140 -0
- package/dist/lib/behaviour/CollisionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/ColorBehaviour.d.ts +22 -0
- package/dist/lib/behaviour/ColorBehaviour.js +122 -6
- package/dist/lib/behaviour/ColorBehaviour.js.map +1 -1
- package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +14 -8
- package/dist/lib/behaviour/EmitDirectionBehaviour.js +53 -12
- package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +6 -0
- package/dist/lib/behaviour/EmitterBehaviours.js +11 -0
- package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
- package/dist/lib/behaviour/ForceFieldsBehaviour.d.ts +53 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.js +80 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.js.map +1 -0
- package/dist/lib/behaviour/GroupingBehaviour.d.ts +57 -0
- package/dist/lib/behaviour/GroupingBehaviour.js +143 -0
- package/dist/lib/behaviour/GroupingBehaviour.js.map +1 -0
- package/dist/lib/behaviour/LifeBehaviour.d.ts +0 -20
- package/dist/lib/behaviour/LifeBehaviour.js +0 -20
- package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/LightEffectBehaviour.d.ts +59 -0
- package/dist/lib/behaviour/LightEffectBehaviour.js +94 -0
- package/dist/lib/behaviour/LightEffectBehaviour.js.map +1 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.d.ts +28 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js +50 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/PositionBehaviour.d.ts +0 -13
- package/dist/lib/behaviour/PositionBehaviour.js +3 -53
- package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/RotationBehaviour.d.ts +20 -12
- package/dist/lib/behaviour/RotationBehaviour.js +50 -16
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SizeBehaviour.d.ts +33 -3
- package/dist/lib/behaviour/SizeBehaviour.js +105 -20
- package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SoundReactiveBehaviour.d.ts +58 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.js +132 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SpawnBehaviour.d.ts +89 -0
- package/dist/lib/behaviour/SpawnBehaviour.js +705 -0
- package/dist/lib/behaviour/SpawnBehaviour.js.map +1 -0
- package/dist/lib/behaviour/StretchBehaviour.d.ts +30 -0
- package/dist/lib/behaviour/StretchBehaviour.js +59 -0
- package/dist/lib/behaviour/StretchBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TemperatureBehaviour.d.ts +47 -0
- package/dist/lib/behaviour/TemperatureBehaviour.js +64 -0
- package/dist/lib/behaviour/TemperatureBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TimelineBehaviour.d.ts +73 -0
- package/dist/lib/behaviour/TimelineBehaviour.js +100 -0
- package/dist/lib/behaviour/TimelineBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +2 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.js +6 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
- package/dist/lib/behaviour/index.d.ts +12 -1
- package/dist/lib/behaviour/index.js +12 -1
- package/dist/lib/behaviour/index.js.map +1 -1
- package/dist/lib/customPixiParticlesSettingsInterface.d.ts +1 -0
- package/dist/lib/emitter/Emitter.d.ts +4 -1
- package/dist/lib/emitter/Emitter.js +40 -1
- package/dist/lib/emitter/Emitter.js.map +1 -1
- package/dist/lib/parser/BehaviourParser.js +1 -1
- package/dist/lib/parser/BehaviourParser.js.map +1 -1
- package/dist/lib/pixi/Renderer.d.ts +14 -5
- package/dist/lib/pixi/Renderer.js +128 -70
- package/dist/lib/pixi/Renderer.js.map +1 -1
- package/dist/lib/pixi/TestRenderer.d.ts +125 -0
- package/dist/lib/pixi/TestRenderer.js +560 -0
- package/dist/lib/pixi/TestRenderer.js.map +1 -0
- package/package.json +7 -5
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import Behaviour from './Behaviour';
|
|
2
2
|
import BehaviourNames from './BehaviourNames';
|
|
3
3
|
let _tmp = 0;
|
|
4
|
-
/**
|
|
5
|
-
* The EmitDirectionBehaviour class that inherits from the Behaviour class.
|
|
6
|
-
* This class is used to set the direction of a particle when it is emitted.
|
|
7
|
-
* @export
|
|
8
|
-
* @class EmitDirectionBehaviour
|
|
9
|
-
* @extends {Behaviour}
|
|
10
|
-
*/
|
|
11
4
|
export default class EmitDirectionBehaviour extends Behaviour {
|
|
12
5
|
constructor() {
|
|
13
6
|
super(...arguments);
|
|
@@ -15,15 +8,27 @@ export default class EmitDirectionBehaviour extends Behaviour {
|
|
|
15
8
|
this.priority = 0;
|
|
16
9
|
this.angle = 0;
|
|
17
10
|
this.variance = 0;
|
|
11
|
+
// New properties
|
|
12
|
+
this.oscillate = false; // Enable directional oscillation
|
|
13
|
+
this.oscillationSpeed = 1; // Speed of oscillation
|
|
14
|
+
this.oscillationAmplitude = 0; // Amplitude of oscillation
|
|
15
|
+
this.useNoise = false; // Use Perlin noise for direction changes
|
|
16
|
+
this.noiseScale = 0.1; // Scale of the noise effect
|
|
17
|
+
this.velocityScaling = false; // Scale velocity based on life progress
|
|
18
18
|
/**
|
|
19
19
|
* Initializes the particle's direction.
|
|
20
20
|
* @param {Particle} particle - The particle that is being initialized.
|
|
21
21
|
* @memberof EmitDirectionBehaviour
|
|
22
22
|
*/
|
|
23
23
|
this.init = (particle) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (!this.enabled)
|
|
25
|
+
return;
|
|
26
|
+
const baseAngle = this.angle + this.varianceFrom(this.variance);
|
|
27
|
+
particle.initialDirectionCos = Math.cos(baseAngle);
|
|
28
|
+
particle.initialDirectionSin = Math.sin(baseAngle);
|
|
29
|
+
particle.directionCos = particle.initialDirectionCos;
|
|
30
|
+
particle.directionSin = particle.initialDirectionSin;
|
|
31
|
+
particle.velocityScale = 1;
|
|
27
32
|
};
|
|
28
33
|
/**
|
|
29
34
|
* Applies the behavior to the particle.
|
|
@@ -31,13 +36,43 @@ export default class EmitDirectionBehaviour extends Behaviour {
|
|
|
31
36
|
* @param {number} deltaTime - The amount of time since the behavior was last applied.
|
|
32
37
|
* @memberof EmitDirectionBehaviour
|
|
33
38
|
*/
|
|
34
|
-
this.apply = (particle) => {
|
|
35
|
-
|
|
39
|
+
this.apply = (particle, deltaTime) => {
|
|
40
|
+
if (!this.enabled)
|
|
41
|
+
return;
|
|
42
|
+
if (particle.skipEmitDirectionBehaviour)
|
|
43
|
+
return;
|
|
44
|
+
const { x, y, directionSin, directionCos, lifeProgress } = particle;
|
|
45
|
+
// Apply directional oscillation
|
|
46
|
+
if (this.oscillate) {
|
|
47
|
+
const oscillation = Math.sin(particle.lifeTime * this.oscillationSpeed) * this.oscillationAmplitude;
|
|
48
|
+
particle.directionCos = Math.cos(oscillation);
|
|
49
|
+
particle.directionSin = Math.sin(oscillation);
|
|
50
|
+
}
|
|
51
|
+
// Apply Perlin noise-based direction changes
|
|
52
|
+
if (this.useNoise) {
|
|
53
|
+
const noiseValue = this.pseudoRandomNoise(particle.lifeTime * this.noiseScale);
|
|
54
|
+
const noiseAngle = noiseValue * 2 * Math.PI; // Map noise to full circle
|
|
55
|
+
particle.directionCos = Math.cos(noiseAngle);
|
|
56
|
+
particle.directionSin = Math.sin(noiseAngle);
|
|
57
|
+
}
|
|
58
|
+
// Scale velocity based on life progress
|
|
59
|
+
if (this.velocityScaling) {
|
|
60
|
+
particle.velocityScale = lifeProgress;
|
|
61
|
+
}
|
|
62
|
+
// Apply directional movement
|
|
36
63
|
_tmp = directionCos * x - directionSin * y;
|
|
37
64
|
particle.y = directionSin * x + directionCos * y;
|
|
38
65
|
particle.x = _tmp;
|
|
66
|
+
// Scale movement
|
|
67
|
+
particle.x *= particle.velocityScale;
|
|
68
|
+
particle.y *= particle.velocityScale;
|
|
39
69
|
};
|
|
40
70
|
}
|
|
71
|
+
pseudoRandomNoise(seed) {
|
|
72
|
+
const prime = 2654435761; // A prime constant
|
|
73
|
+
const x = Math.sin(seed * prime) * 10000; // Scale the randomness
|
|
74
|
+
return x - Math.floor(x); // Ensure result is between 0 and 1
|
|
75
|
+
}
|
|
41
76
|
/**
|
|
42
77
|
* Gets the name of the behavior.
|
|
43
78
|
* @returns {BehaviourNames.EMIT_DIRECTION}
|
|
@@ -57,6 +92,12 @@ export default class EmitDirectionBehaviour extends Behaviour {
|
|
|
57
92
|
priority: this.priority,
|
|
58
93
|
angle: this.angle,
|
|
59
94
|
variance: this.variance,
|
|
95
|
+
oscillate: this.oscillate,
|
|
96
|
+
oscillationSpeed: this.oscillationSpeed,
|
|
97
|
+
oscillationAmplitude: this.oscillationAmplitude,
|
|
98
|
+
useNoise: this.useNoise,
|
|
99
|
+
noiseScale: this.noiseScale,
|
|
100
|
+
velocityScaling: this.velocityScaling,
|
|
60
101
|
name: this.getName(),
|
|
61
102
|
};
|
|
62
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmitDirectionBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitDirectionBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C,IAAI,IAAI,GAAG,CAAC,CAAA;AAEZ
|
|
1
|
+
{"version":3,"file":"EmitDirectionBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitDirectionBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C,IAAI,IAAI,GAAG,CAAC,CAAA;AAEZ,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,SAAS;IAA7D;;QACE,YAAO,GAAG,IAAI,CAAA;QACd,aAAQ,GAAG,CAAC,CAAA;QACZ,UAAK,GAAG,CAAC,CAAA;QACT,aAAQ,GAAG,CAAC,CAAA;QAEZ,iBAAiB;QACjB,cAAS,GAAG,KAAK,CAAA,CAAC,iCAAiC;QACnD,qBAAgB,GAAG,CAAC,CAAA,CAAC,uBAAuB;QAC5C,yBAAoB,GAAG,CAAC,CAAA,CAAC,2BAA2B;QACpD,aAAQ,GAAG,KAAK,CAAA,CAAC,yCAAyC;QAC1D,eAAU,GAAG,GAAG,CAAA,CAAC,4BAA4B;QAC7C,oBAAe,GAAG,KAAK,CAAA,CAAC,wCAAwC;QAEhE;;;;WAIG;QACH,SAAI,GAAG,CAAC,QAAkB,EAAE,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AC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -60,4 +60,10 @@ export default class EmitterBehaviours {
|
|
|
60
60
|
* @param {Model} model The model
|
|
61
61
|
*/
|
|
62
62
|
apply: (particle: Particle, deltaTime: number, model: Model) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Update once per frame
|
|
65
|
+
*
|
|
66
|
+
* @param {number} deltaTime The delta time
|
|
67
|
+
*/
|
|
68
|
+
update: (deltaTime: number) => void;
|
|
63
69
|
}
|
|
@@ -100,6 +100,17 @@ export default class EmitterBehaviours {
|
|
|
100
100
|
this.behaviours[i].apply(particle, deltaTime, model);
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Update once per frame
|
|
105
|
+
*
|
|
106
|
+
* @param {number} deltaTime The delta time
|
|
107
|
+
*/
|
|
108
|
+
this.update = (deltaTime) => {
|
|
109
|
+
for (let i = 0; i < this.behaviours.length; ++i) {
|
|
110
|
+
if (this.behaviours[i].update)
|
|
111
|
+
this.behaviours[i].update(deltaTime);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
103
114
|
}
|
|
104
115
|
}
|
|
105
116
|
//# sourceMappingURL=EmitterBehaviours.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmitterBehaviours.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitterBehaviours.ts"],"names":[],"mappings":"AAA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QAAkB,EAAE,SAAiB,EAAE,KAAY,EAAE,EAAE;YAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBAChD,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;gBAC7B,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;YACtD,CAAC;QACH,CAAC,CAAA;QAED;;;;WAIG;QACH,WAAM,GAAG,CAAC,SAAiB,EAAE,EAAE;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBAChD,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM;oBAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YACrE,CAAC;QACH,CAAC,CAAA;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Behaviour } from './index';
|
|
2
|
+
import Particle from '../Particle';
|
|
3
|
+
import { Point } from '../util';
|
|
4
|
+
/**
|
|
5
|
+
* ForceFieldsBehaviour applies region-based forces (wind, gravity, turbulence) to particles.
|
|
6
|
+
* @extends Behaviour
|
|
7
|
+
*/
|
|
8
|
+
export default class ForceFieldsBehaviour extends Behaviour {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
priority: number;
|
|
11
|
+
/**
|
|
12
|
+
* List of force fields
|
|
13
|
+
*/
|
|
14
|
+
fields: {
|
|
15
|
+
position: Point;
|
|
16
|
+
radius: number;
|
|
17
|
+
strength: number;
|
|
18
|
+
type: 'wind' | 'gravity' | 'turbulence';
|
|
19
|
+
direction?: Point;
|
|
20
|
+
}[];
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the particle, but does not modify position directly.
|
|
23
|
+
* @param {Particle} particle - The particle to initialize.
|
|
24
|
+
*/
|
|
25
|
+
init: (particle: Particle) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Applies the force field behavior to particles.
|
|
28
|
+
* @param {Particle} particle - The particle to apply the behavior to.
|
|
29
|
+
* @param {number} deltaTime - Time elapsed since the last frame.
|
|
30
|
+
*/
|
|
31
|
+
apply: (particle: Particle, deltaTime: number) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the name of the behaviour.
|
|
34
|
+
* @returns {string} - The name of the behaviour.
|
|
35
|
+
*/
|
|
36
|
+
getName(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the properties of the behaviour.
|
|
39
|
+
* @returns {object} - The properties of the behaviour.
|
|
40
|
+
*/
|
|
41
|
+
getProps(): {
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
priority: number;
|
|
44
|
+
fields: {
|
|
45
|
+
position: Point;
|
|
46
|
+
radius: number;
|
|
47
|
+
strength: number;
|
|
48
|
+
type: "wind" | "gravity" | "turbulence";
|
|
49
|
+
direction?: Point;
|
|
50
|
+
}[];
|
|
51
|
+
name: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Behaviour, BehaviourNames } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* ForceFieldsBehaviour applies region-based forces (wind, gravity, turbulence) to particles.
|
|
4
|
+
* @extends Behaviour
|
|
5
|
+
*/
|
|
6
|
+
export default class ForceFieldsBehaviour extends Behaviour {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.enabled = true;
|
|
10
|
+
this.priority = 300; // Executes after initial movement behaviors
|
|
11
|
+
/**
|
|
12
|
+
* List of force fields
|
|
13
|
+
*/
|
|
14
|
+
this.fields = [];
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the particle, but does not modify position directly.
|
|
17
|
+
* @param {Particle} particle - The particle to initialize.
|
|
18
|
+
*/
|
|
19
|
+
this.init = (particle) => {
|
|
20
|
+
// Initialization logic if needed.
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Applies the force field behavior to particles.
|
|
24
|
+
* @param {Particle} particle - The particle to apply the behavior to.
|
|
25
|
+
* @param {number} deltaTime - Time elapsed since the last frame.
|
|
26
|
+
*/
|
|
27
|
+
this.apply = (particle, deltaTime) => {
|
|
28
|
+
if (!this.enabled || particle.skipPositionBehaviour)
|
|
29
|
+
return;
|
|
30
|
+
this.fields.forEach((field) => {
|
|
31
|
+
const distance = Math.sqrt(Math.pow((particle.x - field.position.x), 2) + Math.pow((particle.y - field.position.y), 2));
|
|
32
|
+
// Check if the particle is within the field's radius
|
|
33
|
+
if (distance <= field.radius) {
|
|
34
|
+
const influence = (field.radius - distance) / field.radius; // Influence factor (closer = stronger)
|
|
35
|
+
switch (field.type) {
|
|
36
|
+
case 'wind':
|
|
37
|
+
if (field.direction) {
|
|
38
|
+
particle.movement.x += field.direction.x * field.strength * influence * deltaTime;
|
|
39
|
+
particle.movement.y += field.direction.y * field.strength * influence * deltaTime;
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case 'gravity':
|
|
43
|
+
const dx = field.position.x - particle.x;
|
|
44
|
+
const dy = field.position.y - particle.y;
|
|
45
|
+
const angle = Math.atan2(dy, dx);
|
|
46
|
+
particle.movement.x += Math.cos(angle) * field.strength * influence * deltaTime;
|
|
47
|
+
particle.movement.y += Math.sin(angle) * field.strength * influence * deltaTime;
|
|
48
|
+
break;
|
|
49
|
+
case 'turbulence':
|
|
50
|
+
const randomForceX = (Math.random() - 0.5) * 2 * field.strength * influence;
|
|
51
|
+
const randomForceY = (Math.random() - 0.5) * 2 * field.strength * influence;
|
|
52
|
+
particle.movement.x += randomForceX * deltaTime;
|
|
53
|
+
particle.movement.y += randomForceY * deltaTime;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the name of the behaviour.
|
|
62
|
+
* @returns {string} - The name of the behaviour.
|
|
63
|
+
*/
|
|
64
|
+
getName() {
|
|
65
|
+
return BehaviourNames.FORCE_FIELDS_BEHAVIOUR;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Gets the properties of the behaviour.
|
|
69
|
+
* @returns {object} - The properties of the behaviour.
|
|
70
|
+
*/
|
|
71
|
+
getProps() {
|
|
72
|
+
return {
|
|
73
|
+
enabled: this.enabled,
|
|
74
|
+
priority: this.priority,
|
|
75
|
+
fields: this.fields,
|
|
76
|
+
name: this.getName(),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=ForceFieldsBehaviour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForceFieldsBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/ForceFieldsBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAInD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,SAAS;IAA3D;;QACE,YAAO,GAAG,IAAI,CAAA;QACd,aAAQ,GAAG,GAAG,CAAA,CAAC,4CAA4C;QAE3D;;WAEG;QACH,WAAM,GAMA,EAAE,CAAA;QAER;;;WAGG;QACH,SAAI,GAAG,CAAC,QAAkB,EAAE,EAAE;YAC5B,kCAAkC;QACpC,CAAC,CAAA;QAED;;;;WAIG;QACH,UAAK,GAAG,CAAC,QAAkB,EAAE,SAAiB,EAAE,EAAE;YAChD,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,qBAAqB;gBAAE,OAAM;YAE3D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC5B,MAAM,QAAQ,GA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QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;4BAC/E,MAAK;wBAEP,KAAK,YAAY;4BACf,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAA;4BAC3E,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAA;4BAC3E,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,YAAY,GAAG,SAAS,CAAA;4BAC/C,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,YAAY,GAAG,SAAS,CAAA;4BAC/C,MAAK;oBACT,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;IAsBH,CAAC;IApBC;;;OAGG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,sBAAsB,CAAA;IAC9C,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Point } from '../util';
|
|
2
|
+
import { Behaviour } from './index';
|
|
3
|
+
import Particle from '../Particle';
|
|
4
|
+
export default class GroupingBehaviour extends Behaviour {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
priority: number;
|
|
7
|
+
groupCenter: Point;
|
|
8
|
+
groupRadius: number;
|
|
9
|
+
attractionStrength: number;
|
|
10
|
+
repulsionStrength: number;
|
|
11
|
+
orbitSpeed: number;
|
|
12
|
+
randomness: number;
|
|
13
|
+
boundaryEnforcement: boolean;
|
|
14
|
+
dynamicRadiusSpeed: number;
|
|
15
|
+
maxRadius: number;
|
|
16
|
+
minRadius: number;
|
|
17
|
+
clusterPoints: Point[];
|
|
18
|
+
private particleAngles;
|
|
19
|
+
init(particle: Particle): void;
|
|
20
|
+
apply(particle: Particle, deltaTime: number): void;
|
|
21
|
+
/**
|
|
22
|
+
* Adjusts the group radius dynamically over time
|
|
23
|
+
*/
|
|
24
|
+
adjustDynamicRadius(deltaTime: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Applies repulsion forces to keep particles apart
|
|
27
|
+
*/
|
|
28
|
+
applyRepulsion(particle: Particle): void;
|
|
29
|
+
/**
|
|
30
|
+
* Enforces boundary limits to keep particles within the group radius
|
|
31
|
+
*/
|
|
32
|
+
enforceBoundary(particle: Particle): void;
|
|
33
|
+
/**
|
|
34
|
+
* Finds the nearest cluster point to a given position
|
|
35
|
+
*/
|
|
36
|
+
getNearestClusterPoint(position: Point): Point;
|
|
37
|
+
getName(): string;
|
|
38
|
+
getProps(): {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
priority: number;
|
|
41
|
+
groupCenter: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
groupRadius: number;
|
|
46
|
+
attractionStrength: number;
|
|
47
|
+
repulsionStrength: number;
|
|
48
|
+
orbitSpeed: number;
|
|
49
|
+
randomness: number;
|
|
50
|
+
boundaryEnforcement: boolean;
|
|
51
|
+
dynamicRadiusSpeed: number;
|
|
52
|
+
maxRadius: number;
|
|
53
|
+
minRadius: number;
|
|
54
|
+
clusterPoints: Point[];
|
|
55
|
+
name: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Point } from '../util';
|
|
2
|
+
import { Behaviour, BehaviourNames } from './index';
|
|
3
|
+
export default class GroupingBehaviour extends Behaviour {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.enabled = true;
|
|
7
|
+
this.priority = 0;
|
|
8
|
+
this.groupCenter = new Point(0, 0); // Shared center for the group
|
|
9
|
+
this.groupRadius = 100; // Radius of the group
|
|
10
|
+
this.attractionStrength = 0.1; // Strength of attraction toward the group center
|
|
11
|
+
this.repulsionStrength = 0; // Strength of repulsion between particles
|
|
12
|
+
this.orbitSpeed = 0; // Speed of orbiting (0 for no orbit)
|
|
13
|
+
this.randomness = 0.2; // Adds randomness to particle movement
|
|
14
|
+
this.boundaryEnforcement = false; // Enforce group boundary limits
|
|
15
|
+
this.dynamicRadiusSpeed = 0; // Speed for dynamic radius scaling
|
|
16
|
+
this.maxRadius = 150; // Maximum radius for dynamic scaling
|
|
17
|
+
this.minRadius = 50; // Minimum radius for dynamic scaling
|
|
18
|
+
this.clusterPoints = []; // Additional cluster points
|
|
19
|
+
this.particleAngles = new Map(); // Store unique angles for each particle
|
|
20
|
+
}
|
|
21
|
+
init(particle) {
|
|
22
|
+
if (!this.enabled)
|
|
23
|
+
return;
|
|
24
|
+
// Assign each particle an initial random angle within the group
|
|
25
|
+
const initialAngle = Math.random() * Math.PI * 2;
|
|
26
|
+
this.particleAngles.set(particle.uid, initialAngle);
|
|
27
|
+
}
|
|
28
|
+
apply(particle, deltaTime) {
|
|
29
|
+
if (!this.enabled)
|
|
30
|
+
return;
|
|
31
|
+
const angle = this.particleAngles.get(particle.uid) || 0;
|
|
32
|
+
// Calculate vector toward the group center or nearest cluster point
|
|
33
|
+
const targetPoint = this.getNearestClusterPoint(particle.movement);
|
|
34
|
+
const dx = targetPoint.x - particle.movement.x;
|
|
35
|
+
const dy = targetPoint.y - particle.movement.y;
|
|
36
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
37
|
+
// Apply attraction toward the target point
|
|
38
|
+
particle.movement.x += dx * this.attractionStrength * deltaTime;
|
|
39
|
+
particle.movement.y += dy * this.attractionStrength * deltaTime;
|
|
40
|
+
// Apply orbiting behavior if enabled
|
|
41
|
+
if (this.orbitSpeed !== 0) {
|
|
42
|
+
const currentAngle = angle + this.orbitSpeed * deltaTime;
|
|
43
|
+
this.particleAngles.set(particle.uid, currentAngle);
|
|
44
|
+
particle.movement.x = targetPoint.x + Math.cos(currentAngle) * Math.min(distance, this.groupRadius);
|
|
45
|
+
particle.movement.y = targetPoint.y + Math.sin(currentAngle) * Math.min(distance, this.groupRadius);
|
|
46
|
+
}
|
|
47
|
+
// Apply repulsion from other particles
|
|
48
|
+
this.applyRepulsion(particle);
|
|
49
|
+
// Add randomness for natural movement
|
|
50
|
+
particle.movement.x += (Math.random() - 0.5) * this.randomness;
|
|
51
|
+
particle.movement.y += (Math.random() - 0.5) * this.randomness;
|
|
52
|
+
// Enforce group boundary limits if enabled
|
|
53
|
+
if (this.boundaryEnforcement) {
|
|
54
|
+
this.enforceBoundary(particle);
|
|
55
|
+
}
|
|
56
|
+
// Dynamically adjust the group radius
|
|
57
|
+
this.adjustDynamicRadius(deltaTime);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Adjusts the group radius dynamically over time
|
|
61
|
+
*/
|
|
62
|
+
adjustDynamicRadius(deltaTime) {
|
|
63
|
+
if (this.dynamicRadiusSpeed !== 0) {
|
|
64
|
+
this.groupRadius += this.dynamicRadiusSpeed * deltaTime;
|
|
65
|
+
if (this.groupRadius > this.maxRadius || this.groupRadius < this.minRadius) {
|
|
66
|
+
this.dynamicRadiusSpeed *= -1; // Reverse direction
|
|
67
|
+
}
|
|
68
|
+
this.groupRadius = Math.max(this.minRadius, Math.min(this.groupRadius, this.maxRadius));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Applies repulsion forces to keep particles apart
|
|
73
|
+
*/
|
|
74
|
+
applyRepulsion(particle) {
|
|
75
|
+
if (this.repulsionStrength === 0)
|
|
76
|
+
return;
|
|
77
|
+
this.clusterPoints.forEach((point) => {
|
|
78
|
+
const dx = point.x - particle.movement.x;
|
|
79
|
+
const dy = point.y - particle.movement.y;
|
|
80
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
81
|
+
if (distance > 0 && distance < this.groupRadius) {
|
|
82
|
+
const force = Math.pow((this.repulsionStrength / distance), 2);
|
|
83
|
+
particle.movement.x -= dx * force;
|
|
84
|
+
particle.movement.y -= dy * force;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Enforces boundary limits to keep particles within the group radius
|
|
90
|
+
*/
|
|
91
|
+
enforceBoundary(particle) {
|
|
92
|
+
const dx = particle.movement.x - this.groupCenter.x;
|
|
93
|
+
const dy = particle.movement.y - this.groupCenter.y;
|
|
94
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
95
|
+
if (distance > this.groupRadius) {
|
|
96
|
+
const angle = Math.atan2(dy, dx);
|
|
97
|
+
particle.movement.x = this.groupCenter.x + Math.cos(angle) * this.groupRadius;
|
|
98
|
+
particle.movement.y = this.groupCenter.y + Math.sin(angle) * this.groupRadius;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Finds the nearest cluster point to a given position
|
|
103
|
+
*/
|
|
104
|
+
getNearestClusterPoint(position) {
|
|
105
|
+
if (this.clusterPoints.length === 0) {
|
|
106
|
+
return this.groupCenter;
|
|
107
|
+
}
|
|
108
|
+
let nearest = this.groupCenter;
|
|
109
|
+
let minDistance = Infinity;
|
|
110
|
+
for (const point of this.clusterPoints) {
|
|
111
|
+
const dx = point.x - position.x;
|
|
112
|
+
const dy = point.y - position.y;
|
|
113
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
114
|
+
if (distance < minDistance) {
|
|
115
|
+
minDistance = distance;
|
|
116
|
+
nearest = point;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return nearest;
|
|
120
|
+
}
|
|
121
|
+
getName() {
|
|
122
|
+
return BehaviourNames.GROUPING_BEHAVIOUR;
|
|
123
|
+
}
|
|
124
|
+
getProps() {
|
|
125
|
+
return {
|
|
126
|
+
enabled: this.enabled,
|
|
127
|
+
priority: this.priority,
|
|
128
|
+
groupCenter: { x: this.groupCenter.x, y: this.groupCenter.y },
|
|
129
|
+
groupRadius: this.groupRadius,
|
|
130
|
+
attractionStrength: this.attractionStrength,
|
|
131
|
+
repulsionStrength: this.repulsionStrength,
|
|
132
|
+
orbitSpeed: this.orbitSpeed,
|
|
133
|
+
randomness: this.randomness,
|
|
134
|
+
boundaryEnforcement: this.boundaryEnforcement,
|
|
135
|
+
dynamicRadiusSpeed: this.dynamicRadiusSpeed,
|
|
136
|
+
maxRadius: this.maxRadius,
|
|
137
|
+
minRadius: this.minRadius,
|
|
138
|
+
clusterPoints: this.clusterPoints,
|
|
139
|
+
name: this.getName(),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=GroupingBehaviour.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GroupingBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/GroupingBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnD,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,SAAS;IAAxD;;QACE,YAAO,GAAG,IAAI,CAAA;QACd,aAAQ,GAAG,CAAC,CAAA;QAEZ,gBAAW,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,CAAC,8BAA8B;QAC5D,gBAAW,GAAG,GAAG,CAAA,CAAC,sBAAsB;QACxC,uBAAkB,GAAG,GAAG,CAAA,CAAC,iDAAiD;QAC1E,sBAAiB,GAAG,CAAC,CAAA,CAAC,0CAA0C;QAChE,eAAU,GAAG,CAAC,CAAA,C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particle from '../Particle';
|
|
|
7
7
|
* @extends Behaviour
|
|
8
8
|
*/
|
|
9
9
|
export default class LifeBehaviour extends Behaviour {
|
|
10
|
-
/**
|
|
11
|
-
* Whether or not this behaviour is enabled.
|
|
12
|
-
*
|
|
13
|
-
* @type {boolean}
|
|
14
|
-
*/
|
|
15
10
|
enabled: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The priority of this behaviour.
|
|
18
|
-
*
|
|
19
|
-
* @type {number}
|
|
20
|
-
*/
|
|
21
11
|
priority: number;
|
|
22
|
-
/**
|
|
23
|
-
* The maximum life time of the particle that this behaviour will set.
|
|
24
|
-
*
|
|
25
|
-
* @type {number}
|
|
26
|
-
*/
|
|
27
12
|
maxLifeTime: number;
|
|
28
|
-
/**
|
|
29
|
-
* The variance of the particle's life time.
|
|
30
|
-
*
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
13
|
timeVariance: number;
|
|
34
14
|
/**
|
|
35
15
|
* Sets the particle's life time and maximum life time.
|
|
@@ -8,29 +8,9 @@ import { Behaviour, BehaviourNames } from './index';
|
|
|
8
8
|
export default class LifeBehaviour extends Behaviour {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
|
-
/**
|
|
12
|
-
* Whether or not this behaviour is enabled.
|
|
13
|
-
*
|
|
14
|
-
* @type {boolean}
|
|
15
|
-
*/
|
|
16
11
|
this.enabled = true;
|
|
17
|
-
/**
|
|
18
|
-
* The priority of this behaviour.
|
|
19
|
-
*
|
|
20
|
-
* @type {number}
|
|
21
|
-
*/
|
|
22
12
|
this.priority = 10000;
|
|
23
|
-
/**
|
|
24
|
-
* The maximum life time of the particle that this behaviour will set.
|
|
25
|
-
*
|
|
26
|
-
* @type {number}
|
|
27
|
-
*/
|
|
28
13
|
this.maxLifeTime = 0;
|
|
29
|
-
/**
|
|
30
|
-
* The variance of the particle's life time.
|
|
31
|
-
*
|
|
32
|
-
* @type {number}
|
|
33
|
-
*/
|
|
34
14
|
this.timeVariance = 0;
|
|
35
15
|
/**
|
|
36
16
|
* Sets the particle's life time and maximum life time.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifeBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/LifeBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAApD;;QACE
|
|
1
|
+
{"version":3,"file":"LifeBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/LifeBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAApD;;QACE,YAAO,GAAG,IAAI,CAAA;QACd,aAAQ,GAAG,KAAK,CAAA;QAChB,gBAAW,GAAG,CAAC,CAAA;QACf,iBAAY,GAAG,CAAC,CAAA;QAEhB;;;;;WAKG;QACH,SAAI,GAAG,CAAC,QAAkB,EAAE,EAAE;YAC5B,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAA;YACrB,QAAQ,CAAC,YAAY,GAAG,CAAC,CAAA;YACzB,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAA;QAC/F,CAAC,CAAA;QAED;;;;;;WAMG;QACH,UAAK,GAAG,CAAC,QAAkB,EAAE,SAAiB,EAAE,EAAE;YAChD,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAA;YAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAA;YAE9C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAE5B,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;gBACpB,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAAC,CAAA;YAC/D,CAAC;QACH,CAAC,CAAA;IAyBH,CAAC;IAvBC;;;;OAIG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,cAAc,CAAA;IACtC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Point } from '../util';
|
|
2
|
+
import { Behaviour } from './index';
|
|
3
|
+
import Particle from '../Particle';
|
|
4
|
+
export default class LightEffectBehaviour extends Behaviour {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
priority: number;
|
|
7
|
+
lightSource: Point;
|
|
8
|
+
lightIntensity: number;
|
|
9
|
+
lightColor: {
|
|
10
|
+
r: number;
|
|
11
|
+
g: number;
|
|
12
|
+
b: number;
|
|
13
|
+
};
|
|
14
|
+
attenuationFactor: number;
|
|
15
|
+
ambientLight: number;
|
|
16
|
+
directionalLight: boolean;
|
|
17
|
+
direction: Point;
|
|
18
|
+
spreadAngle: number;
|
|
19
|
+
volumetricLight: boolean;
|
|
20
|
+
volumetricIntensity: number;
|
|
21
|
+
fogDensity: number;
|
|
22
|
+
init: () => void;
|
|
23
|
+
apply: (particle: Particle, deltaTime: number) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the name of the behaviour
|
|
26
|
+
* @return {string} The name of the behaviour
|
|
27
|
+
*/
|
|
28
|
+
getName(): string;
|
|
29
|
+
/**
|
|
30
|
+
* @description Retrieves the properties of the object.
|
|
31
|
+
* @returns {Object} The properties of the object.
|
|
32
|
+
*/
|
|
33
|
+
getProps(): {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
priority: number;
|
|
36
|
+
lightSource: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
lightIntensity: number;
|
|
41
|
+
lightColor: {
|
|
42
|
+
r: number;
|
|
43
|
+
g: number;
|
|
44
|
+
b: number;
|
|
45
|
+
};
|
|
46
|
+
attenuationFactor: number;
|
|
47
|
+
ambientLight: number;
|
|
48
|
+
directionalLight: boolean;
|
|
49
|
+
direction: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
spreadAngle: number;
|
|
54
|
+
volumetricLight: boolean;
|
|
55
|
+
volumetricIntensity: number;
|
|
56
|
+
fogDensity: number;
|
|
57
|
+
name: string;
|
|
58
|
+
};
|
|
59
|
+
}
|