@codexo/exojs 0.7.12 → 0.8.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/CHANGELOG.md +737 -0
- package/dist/esm/core/Application.d.ts +3 -1
- package/dist/esm/core/Application.js +7 -6
- package/dist/esm/core/Application.js.map +1 -1
- package/dist/esm/core/Scene.d.ts +30 -0
- package/dist/esm/core/Scene.js +56 -0
- package/dist/esm/core/Scene.js.map +1 -1
- package/dist/esm/core/SceneManager.js +2 -2
- package/dist/esm/core/SceneManager.js.map +1 -1
- package/dist/esm/debug/DebugOverlay.js +2 -2
- package/dist/esm/debug/DebugOverlay.js.map +1 -1
- package/dist/esm/debug/PointerStackLayer.js +1 -1
- package/dist/esm/debug/PointerStackLayer.js.map +1 -1
- package/dist/esm/index.js +32 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/input/ArcadeStickGamepadMapping.js +18 -19
- package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
- package/dist/esm/input/Gamepad.d.ts +164 -62
- package/dist/esm/input/Gamepad.js +290 -134
- package/dist/esm/input/Gamepad.js.map +1 -1
- package/dist/esm/input/GamepadAxis.d.ts +120 -0
- package/dist/esm/input/GamepadAxis.js +106 -0
- package/dist/esm/input/GamepadAxis.js.map +1 -0
- package/dist/esm/input/GamepadButton.d.ts +110 -0
- package/dist/esm/input/GamepadButton.js +99 -0
- package/dist/esm/input/GamepadButton.js.map +1 -0
- package/dist/esm/input/GamepadDefinitions.js +4 -0
- package/dist/esm/input/GamepadDefinitions.js.map +1 -1
- package/dist/esm/input/GamepadMapping.d.ts +28 -24
- package/dist/esm/input/GamepadMapping.js +33 -16
- package/dist/esm/input/GamepadMapping.js.map +1 -1
- package/dist/esm/input/GamepadPromptLayouts.d.ts +10 -8
- package/dist/esm/input/GamepadPromptLayouts.js +21 -20
- package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
- package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +6 -3
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js +55 -46
- package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
- package/dist/esm/input/InputBinding.d.ts +74 -0
- package/dist/esm/input/InputBinding.js +100 -0
- package/dist/esm/input/InputBinding.js.map +1 -0
- package/dist/esm/input/InputManager.d.ts +79 -33
- package/dist/esm/input/InputManager.js +229 -104
- package/dist/esm/input/InputManager.js.map +1 -1
- package/dist/esm/input/InteractionManager.d.ts +1 -1
- package/dist/esm/input/InteractionManager.js +13 -13
- package/dist/esm/input/InteractionManager.js.map +1 -1
- package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +14 -9
- package/dist/esm/input/JoyConLeftGamepadMapping.js +39 -9
- package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
- package/dist/esm/input/JoyConRightGamepadMapping.d.ts +14 -9
- package/dist/esm/input/JoyConRightGamepadMapping.js +35 -9
- package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
- package/dist/esm/input/Pointer.d.ts +84 -71
- package/dist/esm/input/Pointer.js +71 -71
- package/dist/esm/input/Pointer.js.map +1 -1
- package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
- package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
- package/dist/esm/input/index.d.ts +7 -4
- package/dist/esm/input/types.d.ts +0 -76
- package/dist/esm/input/types.js +1 -80
- package/dist/esm/input/types.js.map +1 -1
- package/dist/esm/particles/ParticleSystem.d.ts +180 -83
- package/dist/esm/particles/ParticleSystem.js +446 -133
- package/dist/esm/particles/ParticleSystem.js.map +1 -1
- package/dist/esm/particles/distributions/BoxArea.d.ts +17 -0
- package/dist/esm/particles/distributions/BoxArea.js +48 -0
- package/dist/esm/particles/distributions/BoxArea.js.map +1 -0
- package/dist/esm/particles/distributions/CircleArea.d.ts +19 -0
- package/dist/esm/particles/distributions/CircleArea.js +33 -0
- package/dist/esm/particles/distributions/CircleArea.js.map +1 -0
- package/dist/esm/particles/distributions/ConeDirection.d.ts +28 -0
- package/dist/esm/particles/distributions/ConeDirection.js +44 -0
- package/dist/esm/particles/distributions/ConeDirection.js.map +1 -0
- package/dist/esm/particles/distributions/Constant.d.ts +17 -0
- package/dist/esm/particles/distributions/Constant.js +35 -0
- package/dist/esm/particles/distributions/Constant.js.map +1 -0
- package/dist/esm/particles/distributions/Curve.d.ts +30 -0
- package/dist/esm/particles/distributions/Curve.js +53 -0
- package/dist/esm/particles/distributions/Curve.js.map +1 -0
- package/dist/esm/particles/distributions/Distribution.d.ts +45 -0
- package/dist/esm/particles/distributions/Gradient.d.ts +40 -0
- package/dist/esm/particles/distributions/Gradient.js +72 -0
- package/dist/esm/particles/distributions/Gradient.js.map +1 -0
- package/dist/esm/particles/distributions/LineSegment.d.ts +15 -0
- package/dist/esm/particles/distributions/LineSegment.js +27 -0
- package/dist/esm/particles/distributions/LineSegment.js.map +1 -0
- package/dist/esm/particles/distributions/Range.d.ts +12 -0
- package/dist/esm/particles/distributions/Range.js +19 -0
- package/dist/esm/particles/distributions/Range.js.map +1 -0
- package/dist/esm/particles/distributions/VectorRange.d.ts +20 -0
- package/dist/esm/particles/distributions/VectorRange.js +31 -0
- package/dist/esm/particles/distributions/VectorRange.js.map +1 -0
- package/dist/esm/particles/distributions/index.d.ts +12 -0
- package/dist/esm/particles/gpu/ParticleGpuState.d.ts +57 -0
- package/dist/esm/particles/gpu/ParticleGpuState.js +508 -0
- package/dist/esm/particles/gpu/ParticleGpuState.js.map +1 -0
- package/dist/esm/particles/index.d.ts +2 -10
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.d.ts +24 -0
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.js +60 -0
- package/dist/esm/particles/modules/AlphaFadeOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ApplyForce.d.ts +20 -0
- package/dist/esm/particles/modules/ApplyForce.js +48 -0
- package/dist/esm/particles/modules/ApplyForce.js.map +1 -0
- package/dist/esm/particles/modules/AttractToPoint.d.ts +27 -0
- package/dist/esm/particles/modules/AttractToPoint.js +73 -0
- package/dist/esm/particles/modules/AttractToPoint.js.map +1 -0
- package/dist/esm/particles/modules/BurstSpawn.d.ts +53 -0
- package/dist/esm/particles/modules/BurstSpawn.js +94 -0
- package/dist/esm/particles/modules/BurstSpawn.js.map +1 -0
- package/dist/esm/particles/modules/ColorOverLifetime.d.ts +22 -0
- package/dist/esm/particles/modules/ColorOverLifetime.js +65 -0
- package/dist/esm/particles/modules/ColorOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ColorOverSpeed.d.ts +27 -0
- package/dist/esm/particles/modules/ColorOverSpeed.js +86 -0
- package/dist/esm/particles/modules/ColorOverSpeed.js.map +1 -0
- package/dist/esm/particles/modules/DeathModule.d.ts +24 -0
- package/dist/esm/particles/modules/DeathModule.js +25 -0
- package/dist/esm/particles/modules/DeathModule.js.map +1 -0
- package/dist/esm/particles/modules/Drag.d.ts +20 -0
- package/dist/esm/particles/modules/Drag.js +45 -0
- package/dist/esm/particles/modules/Drag.js.map +1 -0
- package/dist/esm/particles/modules/OrbitalForce.d.ts +28 -0
- package/dist/esm/particles/modules/OrbitalForce.js +65 -0
- package/dist/esm/particles/modules/OrbitalForce.js.map +1 -0
- package/dist/esm/particles/modules/RateSpawn.d.ts +41 -0
- package/dist/esm/particles/modules/RateSpawn.js +76 -0
- package/dist/esm/particles/modules/RateSpawn.js.map +1 -0
- package/dist/esm/particles/modules/RepelFromPoint.d.ts +24 -0
- package/dist/esm/particles/modules/RepelFromPoint.js +76 -0
- package/dist/esm/particles/modules/RepelFromPoint.js.map +1 -0
- package/dist/esm/particles/modules/RotateOverLifetime.d.ts +20 -0
- package/dist/esm/particles/modules/RotateOverLifetime.js +43 -0
- package/dist/esm/particles/modules/RotateOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.d.ts +26 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.js +59 -0
- package/dist/esm/particles/modules/ScaleOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/SpawnModule.d.ts +30 -0
- package/dist/esm/particles/modules/SpawnModule.js +31 -0
- package/dist/esm/particles/modules/SpawnModule.js.map +1 -0
- package/dist/esm/particles/modules/SpawnOnDeath.d.ts +24 -0
- package/dist/esm/particles/modules/SpawnOnDeath.js +47 -0
- package/dist/esm/particles/modules/SpawnOnDeath.js.map +1 -0
- package/dist/esm/particles/modules/Turbulence.d.ts +30 -0
- package/dist/esm/particles/modules/Turbulence.js +122 -0
- package/dist/esm/particles/modules/Turbulence.js.map +1 -0
- package/dist/esm/particles/modules/UpdateModule.d.ts +95 -0
- package/dist/esm/particles/modules/UpdateModule.js +66 -0
- package/dist/esm/particles/modules/UpdateModule.js.map +1 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.d.ts +30 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.js +84 -0
- package/dist/esm/particles/modules/VelocityOverLifetime.js.map +1 -0
- package/dist/esm/particles/modules/WgslContribution.d.ts +81 -0
- package/dist/esm/particles/modules/WgslContribution.js +34 -0
- package/dist/esm/particles/modules/WgslContribution.js.map +1 -0
- package/dist/esm/particles/modules/index.d.ts +22 -0
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.d.ts +9 -14
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js +90 -61
- package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgl2/glsl/particle.vert.js +1 -1
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.d.ts +9 -0
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js +107 -23
- package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js.map +1 -1
- package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.d.ts +52 -0
- package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.d.ts +29 -0
- package/dist/esm/rendering/webgpu/compute/index.d.ts +3 -0
- package/dist/esm/resources/CacheFirstStrategy.d.ts +7 -4
- package/dist/esm/resources/CacheFirstStrategy.js +11 -8
- package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
- package/dist/esm/resources/CacheStrategy.d.ts +14 -6
- package/dist/esm/resources/Loader.d.ts +8 -3
- package/dist/esm/resources/Loader.js +19 -37
- package/dist/esm/resources/Loader.js.map +1 -1
- package/dist/esm/resources/NetworkOnlyStrategy.d.ts +3 -0
- package/dist/esm/resources/NetworkOnlyStrategy.js +8 -3
- package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
- package/dist/esm/resources/factories/ImageFactory.d.ts +2 -2
- package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
- package/dist/esm/resources/factories/TextureFactory.d.ts +2 -2
- package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
- package/dist/esm/resources/factories/VttFactory.d.ts +3 -3
- package/dist/esm/resources/factories/VttFactory.js +83 -6
- package/dist/esm/resources/factories/VttFactory.js.map +1 -1
- package/dist/exo.esm.js +4028 -1518
- package/dist/exo.esm.js.map +1 -1
- package/package.json +2 -1
- package/dist/esm/input/GamepadChannels.d.ts +0 -47
- package/dist/esm/input/GamepadChannels.js +0 -53
- package/dist/esm/input/GamepadChannels.js.map +0 -1
- package/dist/esm/input/GamepadControl.d.ts +0 -33
- package/dist/esm/input/GamepadControl.js +0 -42
- package/dist/esm/input/GamepadControl.js.map +0 -1
- package/dist/esm/input/Input.d.ts +0 -52
- package/dist/esm/input/Input.js +0 -90
- package/dist/esm/input/Input.js.map +0 -1
- package/dist/esm/particles/Particle.d.ts +0 -77
- package/dist/esm/particles/Particle.js +0 -143
- package/dist/esm/particles/Particle.js.map +0 -1
- package/dist/esm/particles/ParticleProperties.d.ts +0 -29
- package/dist/esm/particles/affectors/ColorAffector.d.ts +0 -30
- package/dist/esm/particles/affectors/ColorAffector.js +0 -55
- package/dist/esm/particles/affectors/ColorAffector.js.map +0 -1
- package/dist/esm/particles/affectors/ForceAffector.d.ts +0 -24
- package/dist/esm/particles/affectors/ForceAffector.js +0 -39
- package/dist/esm/particles/affectors/ForceAffector.js.map +0 -1
- package/dist/esm/particles/affectors/ParticleAffector.d.ts +0 -19
- package/dist/esm/particles/affectors/ScaleAffector.d.ts +0 -23
- package/dist/esm/particles/affectors/ScaleAffector.js +0 -38
- package/dist/esm/particles/affectors/ScaleAffector.js.map +0 -1
- package/dist/esm/particles/affectors/TorqueAffector.d.ts +0 -23
- package/dist/esm/particles/affectors/TorqueAffector.js +0 -37
- package/dist/esm/particles/affectors/TorqueAffector.js.map +0 -1
- package/dist/esm/particles/emitters/ParticleEmitter.d.ts +0 -19
- package/dist/esm/particles/emitters/ParticleOptions.d.ts +0 -62
- package/dist/esm/particles/emitters/ParticleOptions.js +0 -120
- package/dist/esm/particles/emitters/ParticleOptions.js.map +0 -1
- package/dist/esm/particles/emitters/UniversalEmitter.d.ts +0 -40
- package/dist/esm/particles/emitters/UniversalEmitter.js +0 -68
- package/dist/esm/particles/emitters/UniversalEmitter.js.map +0 -1
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Linearly interpolates a particle's {@link Particle.tint} from `fromColor`
|
|
3
|
-
* to `toColor` over the particle's full lifetime. The blend factor is
|
|
4
|
-
* {@link Particle.elapsedRatio} — 0 at birth, 1 at expiry — so the
|
|
5
|
-
* transition is always proportional to how long the particle has lived
|
|
6
|
-
* regardless of delta size.
|
|
7
|
-
*/
|
|
8
|
-
class ColorAffector {
|
|
9
|
-
_fromColor;
|
|
10
|
-
_toColor;
|
|
11
|
-
constructor(fromColor, toColor) {
|
|
12
|
-
this._fromColor = fromColor.clone();
|
|
13
|
-
this._toColor = toColor.clone();
|
|
14
|
-
}
|
|
15
|
-
get fromColor() {
|
|
16
|
-
return this._fromColor;
|
|
17
|
-
}
|
|
18
|
-
set fromColor(color) {
|
|
19
|
-
this.setFromColor(color);
|
|
20
|
-
}
|
|
21
|
-
get toColor() {
|
|
22
|
-
return this._toColor;
|
|
23
|
-
}
|
|
24
|
-
set toColor(color) {
|
|
25
|
-
this.setToColor(color);
|
|
26
|
-
}
|
|
27
|
-
setFromColor(color) {
|
|
28
|
-
this._fromColor.copy(color);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
setToColor(color) {
|
|
32
|
-
this._toColor.copy(color);
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Sets `particle.tint` to the RGBA value interpolated between
|
|
37
|
-
* {@link fromColor} and {@link toColor} at the particle's current
|
|
38
|
-
* {@link Particle.elapsedRatio}. `delta` is unused but required by the
|
|
39
|
-
* {@link ParticleAffector} contract.
|
|
40
|
-
*/
|
|
41
|
-
apply(particle, delta) {
|
|
42
|
-
const ratio = particle.elapsedRatio;
|
|
43
|
-
const { r: r1, g: g1, b: b1, a: a1 } = this._fromColor;
|
|
44
|
-
const { r: r2, g: g2, b: b2, a: a2 } = this._toColor;
|
|
45
|
-
particle.tint.set(((r2 - r1) * ratio) + r1, ((g2 - g1) * ratio) + g1, ((b2 - b1) * ratio) + b1, ((a2 - a1) * ratio) + a1);
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
destroy() {
|
|
49
|
-
this._fromColor.destroy();
|
|
50
|
-
this._toColor.destroy();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { ColorAffector };
|
|
55
|
-
//# sourceMappingURL=ColorAffector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ColorAffector.js","sources":["../../../../../src/particles/affectors/ColorAffector.ts"],"sourcesContent":[null],"names":[],"mappings":"AAKA;;;;;;AAMG;MACU,aAAa,CAAA;AAEL,IAAA,UAAU;AACV,IAAA,QAAQ;IAEzB,WAAA,CAAmB,SAAgB,EAAE,OAAc,EAAA;AAC/C,QAAA,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,KAAK,EAAE;AACnC,QAAA,IA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B,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,CAC3B;AAED,QAAA,OAAO,IAAI;IACf;IAEO,OAAO,GAAA;AACV,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;AACzB,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;IAC3B;AACH;;;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ParticleAffector } from '@/particles/affectors/ParticleAffector';
|
|
2
|
-
import { Vector } from '@/math/Vector';
|
|
3
|
-
import type { Particle } from '@/particles/Particle';
|
|
4
|
-
import type { Time } from '@/core/Time';
|
|
5
|
-
/**
|
|
6
|
-
* Applies a constant 2-D acceleration to every particle's
|
|
7
|
-
* {@link Particle.velocity} each tick, simulating forces such as gravity
|
|
8
|
-
* (`new ForceAffector(0, 980)`) or wind. Velocity is mutated in place;
|
|
9
|
-
* the system then integrates position from velocity in
|
|
10
|
-
* {@link ParticleSystem.updateParticle}.
|
|
11
|
-
*/
|
|
12
|
-
export declare class ForceAffector implements ParticleAffector {
|
|
13
|
-
private readonly _acceleration;
|
|
14
|
-
constructor(accelerationX: number, accelerationY: number);
|
|
15
|
-
get acceleration(): Vector;
|
|
16
|
-
set acceleration(acceleration: Vector);
|
|
17
|
-
setAcceleration(acceleration: Vector): this;
|
|
18
|
-
/**
|
|
19
|
-
* Adds `acceleration * delta.seconds` to `particle.velocity`, implementing
|
|
20
|
-
* Euler integration for the configured force vector.
|
|
21
|
-
*/
|
|
22
|
-
apply(particle: Particle, delta: Time): this;
|
|
23
|
-
destroy(): void;
|
|
24
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Vector } from '../../math/Vector.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Applies a constant 2-D acceleration to every particle's
|
|
5
|
-
* {@link Particle.velocity} each tick, simulating forces such as gravity
|
|
6
|
-
* (`new ForceAffector(0, 980)`) or wind. Velocity is mutated in place;
|
|
7
|
-
* the system then integrates position from velocity in
|
|
8
|
-
* {@link ParticleSystem.updateParticle}.
|
|
9
|
-
*/
|
|
10
|
-
class ForceAffector {
|
|
11
|
-
_acceleration;
|
|
12
|
-
constructor(accelerationX, accelerationY) {
|
|
13
|
-
this._acceleration = new Vector(accelerationX, accelerationY);
|
|
14
|
-
}
|
|
15
|
-
get acceleration() {
|
|
16
|
-
return this._acceleration;
|
|
17
|
-
}
|
|
18
|
-
set acceleration(acceleration) {
|
|
19
|
-
this.setAcceleration(acceleration);
|
|
20
|
-
}
|
|
21
|
-
setAcceleration(acceleration) {
|
|
22
|
-
this._acceleration.copy(acceleration);
|
|
23
|
-
return this;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Adds `acceleration * delta.seconds` to `particle.velocity`, implementing
|
|
27
|
-
* Euler integration for the configured force vector.
|
|
28
|
-
*/
|
|
29
|
-
apply(particle, delta) {
|
|
30
|
-
particle.velocity.add(delta.seconds * this._acceleration.x, delta.seconds * this._acceleration.y);
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
destroy() {
|
|
34
|
-
this._acceleration.destroy();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { ForceAffector };
|
|
39
|
-
//# sourceMappingURL=ForceAffector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ForceAffector.js","sources":["../../../../../src/particles/affectors/ForceAffector.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;;;;AAMG;MACU,aAAa,CAAA;AAEL,IAAA,aAAa;IAE9B,WAAA,CAAmB,aAAqB,EAAE,aAAqB,EAAA;QAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC;IACjE;AAEA,IAAA,IAAW,YAAY,GAAA;QACnB,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,IAAW,YAAY,CAAC,YAAoB,EAAA;AACxC,QAAA,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC;IACtC;AAEO,IAAA,eAAe,CAAC,YAAoB,EAAA;AACvC,QAAA,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC;AAErC,QAAA,OAAO,IAAI;IACf;AAEA;;;AAGG;IACI,KAAK,CAAC,QAAkB,EAAE,KAAW,EAAA;QACxC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CACjB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,EACpC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CACvC;AAED,QAAA,OAAO,IAAI;IACf;IAEO,OAAO,GAAA;AACV,QAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;IAChC;AACH;;;;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Particle } from '@/particles/Particle';
|
|
2
|
-
import type { Time } from '@/core/Time';
|
|
3
|
-
/**
|
|
4
|
-
* Contract for all per-particle mutators that run once per tick. Each
|
|
5
|
-
* affector is registered on a {@link ParticleSystem} and called after
|
|
6
|
-
* position integration for every live particle. Concrete implementations
|
|
7
|
-
* (e.g. {@link ColorAffector}, {@link ForceAffector}, {@link ScaleAffector},
|
|
8
|
-
* {@link TorqueAffector}) mutate one or more {@link ParticleProperties} fields
|
|
9
|
-
* in place.
|
|
10
|
-
*/
|
|
11
|
-
export interface ParticleAffector {
|
|
12
|
-
/**
|
|
13
|
-
* Mutates `particle` properties for the current `delta` timestep.
|
|
14
|
-
* Called by {@link ParticleSystem.update} for every non-expired particle.
|
|
15
|
-
*/
|
|
16
|
-
apply(particle: Particle, delta: Time): this;
|
|
17
|
-
/** Releases any resources owned by this affector. */
|
|
18
|
-
destroy(): void;
|
|
19
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ParticleAffector } from '@/particles/affectors/ParticleAffector';
|
|
2
|
-
import { Vector } from '@/math/Vector';
|
|
3
|
-
import type { Time } from '@/core/Time';
|
|
4
|
-
import type { Particle } from '@/particles/Particle';
|
|
5
|
-
/**
|
|
6
|
-
* Additively grows or shrinks a particle's {@link Particle.scale} each tick
|
|
7
|
-
* by a constant rate vector. A positive factor enlarges the sprite; a
|
|
8
|
-
* negative factor shrinks it. Use `new ScaleAffector(-1, -1)` to make
|
|
9
|
-
* particles fade out in size over one second.
|
|
10
|
-
*/
|
|
11
|
-
export declare class ScaleAffector implements ParticleAffector {
|
|
12
|
-
private readonly _scaleFactor;
|
|
13
|
-
constructor(factorX: number, factorY: number);
|
|
14
|
-
get scaleFactor(): Vector;
|
|
15
|
-
set scaleFactor(scaleFactor: Vector);
|
|
16
|
-
setScaleFactor(scaleFactor: Vector): this;
|
|
17
|
-
/**
|
|
18
|
-
* Adds `scaleFactor * delta.seconds` to `particle.scale` on both axes,
|
|
19
|
-
* implementing linear scale drift for the configured rate.
|
|
20
|
-
*/
|
|
21
|
-
apply(particle: Particle, delta: Time): this;
|
|
22
|
-
destroy(): void;
|
|
23
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Vector } from '../../math/Vector.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Additively grows or shrinks a particle's {@link Particle.scale} each tick
|
|
5
|
-
* by a constant rate vector. A positive factor enlarges the sprite; a
|
|
6
|
-
* negative factor shrinks it. Use `new ScaleAffector(-1, -1)` to make
|
|
7
|
-
* particles fade out in size over one second.
|
|
8
|
-
*/
|
|
9
|
-
class ScaleAffector {
|
|
10
|
-
_scaleFactor;
|
|
11
|
-
constructor(factorX, factorY) {
|
|
12
|
-
this._scaleFactor = new Vector(factorX, factorY);
|
|
13
|
-
}
|
|
14
|
-
get scaleFactor() {
|
|
15
|
-
return this._scaleFactor;
|
|
16
|
-
}
|
|
17
|
-
set scaleFactor(scaleFactor) {
|
|
18
|
-
this.setScaleFactor(scaleFactor);
|
|
19
|
-
}
|
|
20
|
-
setScaleFactor(scaleFactor) {
|
|
21
|
-
this._scaleFactor.copy(scaleFactor);
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Adds `scaleFactor * delta.seconds` to `particle.scale` on both axes,
|
|
26
|
-
* implementing linear scale drift for the configured rate.
|
|
27
|
-
*/
|
|
28
|
-
apply(particle, delta) {
|
|
29
|
-
particle.scale.add(delta.seconds * this._scaleFactor.x, delta.seconds * this._scaleFactor.y);
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
destroy() {
|
|
33
|
-
this._scaleFactor.destroy();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { ScaleAffector };
|
|
38
|
-
//# sourceMappingURL=ScaleAffector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScaleAffector.js","sources":["../../../../../src/particles/affectors/ScaleAffector.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;;;AAKG;MACU,aAAa,CAAA;AAEL,IAAA,YAAY;IAE7B,WAAA,CAAmB,OAAe,EAAE,OAAe,EAAA;QAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD;AAEA,IAAA,IAAW,WAAW,GAAA;QAClB,OAAO,IAAI,CAAC,YAAY;IAC5B;IAEA,IAAW,WAAW,CAAC,WAAmB,EAAA;AACtC,QAAA,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;IACpC;AAEO,IAAA,cAAc,CAAC,WAAmB,EAAA;AACrC,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC;AAEnC,QAAA,OAAO,IAAI;IACf;AAEA;;;AAGG;IACI,KAAK,CAAC,QAAkB,EAAE,KAAW,EAAA;QACxC,QAAQ,CAAC,KAAK,CAAC,GAAG,CACd,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,EACnC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CACtC;AAED,QAAA,OAAO,IAAI;IACf;IAEO,OAAO,GAAA;AACV,QAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;IAC/B;AACH;;;;"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ParticleAffector } from '@/particles/affectors/ParticleAffector';
|
|
2
|
-
import type { Particle } from '@/particles/Particle';
|
|
3
|
-
import type { Time } from '@/core/Time';
|
|
4
|
-
/**
|
|
5
|
-
* Accelerates a particle's angular velocity ({@link Particle.rotationSpeed})
|
|
6
|
-
* by a constant `angularAcceleration` (degrees per second²) each tick.
|
|
7
|
-
* The updated `rotationSpeed` is then integrated into
|
|
8
|
-
* {@link Particle.rotation} by {@link ParticleSystem.updateParticle}.
|
|
9
|
-
* Use a negative value to decelerate spin over time.
|
|
10
|
-
*/
|
|
11
|
-
export declare class TorqueAffector implements ParticleAffector {
|
|
12
|
-
private _angularAcceleration;
|
|
13
|
-
constructor(angularAcceleration: number);
|
|
14
|
-
get angularAcceleration(): number;
|
|
15
|
-
set angularAcceleration(angularAcceleration: number);
|
|
16
|
-
setAngularAcceleration(angularAcceleration: number): this;
|
|
17
|
-
/**
|
|
18
|
-
* Adds `angularAcceleration * delta.seconds` to `particle.rotationSpeed`,
|
|
19
|
-
* increasing or decreasing spin rate for this timestep.
|
|
20
|
-
*/
|
|
21
|
-
apply(particle: Particle, delta: Time): this;
|
|
22
|
-
destroy(): void;
|
|
23
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accelerates a particle's angular velocity ({@link Particle.rotationSpeed})
|
|
3
|
-
* by a constant `angularAcceleration` (degrees per second²) each tick.
|
|
4
|
-
* The updated `rotationSpeed` is then integrated into
|
|
5
|
-
* {@link Particle.rotation} by {@link ParticleSystem.updateParticle}.
|
|
6
|
-
* Use a negative value to decelerate spin over time.
|
|
7
|
-
*/
|
|
8
|
-
class TorqueAffector {
|
|
9
|
-
_angularAcceleration;
|
|
10
|
-
constructor(angularAcceleration) {
|
|
11
|
-
this._angularAcceleration = angularAcceleration;
|
|
12
|
-
}
|
|
13
|
-
get angularAcceleration() {
|
|
14
|
-
return this._angularAcceleration;
|
|
15
|
-
}
|
|
16
|
-
set angularAcceleration(angularAcceleration) {
|
|
17
|
-
this.setAngularAcceleration(angularAcceleration);
|
|
18
|
-
}
|
|
19
|
-
setAngularAcceleration(angularAcceleration) {
|
|
20
|
-
this._angularAcceleration = angularAcceleration;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Adds `angularAcceleration * delta.seconds` to `particle.rotationSpeed`,
|
|
25
|
-
* increasing or decreasing spin rate for this timestep.
|
|
26
|
-
*/
|
|
27
|
-
apply(particle, delta) {
|
|
28
|
-
particle.rotationSpeed += (delta.seconds * this._angularAcceleration);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
destroy() {
|
|
32
|
-
// no-op — pure value class, kept for Destroyable interface conformance
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { TorqueAffector };
|
|
37
|
-
//# sourceMappingURL=TorqueAffector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TorqueAffector.js","sources":["../../../../../src/particles/affectors/TorqueAffector.ts"],"sourcesContent":[null],"names":[],"mappings":"AAIA;;;;;;AAMG;MACU,cAAc,CAAA;AAEf,IAAA,oBAAoB;AAE5B,IAAA,WAAA,CAAmB,mBAA2B,EAAA;AAC1C,QAAA,IAAI,CAAC,oBAAoB,GAAG,mBAAmB;IACnD;AAEA,IAAA,IAAW,mBAAmB,GAAA;QAC1B,OAAO,IAAI,CAAC,oBAAoB;IACpC;IAEA,IAAW,mBAAmB,CAAC,mBAA2B,EAAA;AACtD,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC;IACpD;AAEO,IAAA,sBAAsB,CAAC,mBAA2B,EAAA;AACrD,QAAA,IAAI,CAAC,oBAAoB,GAAG,mBAAmB;AAE/C,QAAA,OAAO,IAAI;IACf;AAEA;;;AAGG;IACI,KAAK,CAAC,QAAkB,EAAE,KAAW,EAAA;AACxC,QAAA,QAAQ,CAAC,aAAa,KAAK,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC;AAErE,QAAA,OAAO,IAAI;IACf;IAEO,OAAO,GAAA;;IAEd;AACH;;;;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Time } from '@/core/Time';
|
|
2
|
-
import type { ParticleSystem } from '@/particles/ParticleSystem';
|
|
3
|
-
/**
|
|
4
|
-
* Contract for all particle spawners attached to a {@link ParticleSystem}.
|
|
5
|
-
* Each emitter is called once per tick via {@link ParticleSystem.update} and
|
|
6
|
-
* is responsible for requesting recycled or new {@link Particle} instances from
|
|
7
|
-
* the system, configuring them, and handing them back via
|
|
8
|
-
* {@link ParticleSystem.emitParticle}. See {@link UniversalEmitter} for the
|
|
9
|
-
* built-in rate-based implementation.
|
|
10
|
-
*/
|
|
11
|
-
export interface ParticleEmitter {
|
|
12
|
-
/**
|
|
13
|
-
* Spawns zero or more particles into `system` for the current `delta`
|
|
14
|
-
* timestep. Called once per frame by {@link ParticleSystem.update}.
|
|
15
|
-
*/
|
|
16
|
-
apply(system: ParticleSystem, delta: Time): this;
|
|
17
|
-
/** Releases any resources owned by this emitter. */
|
|
18
|
-
destroy(): void;
|
|
19
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Vector } from '@/math/Vector';
|
|
2
|
-
import { Color } from '@/core/Color';
|
|
3
|
-
import { Time } from '@/core/Time';
|
|
4
|
-
import type { ParticleProperties } from '@/particles/ParticleProperties';
|
|
5
|
-
/**
|
|
6
|
-
* Spawn-time configuration snapshot passed to {@link ParticleEmitter.apply}
|
|
7
|
-
* implementations. Implements {@link ParticleProperties} so the same affector
|
|
8
|
-
* interface can read default values when needed. All fields have sensible
|
|
9
|
-
* defaults (1 s lifetime, zero position/velocity, unit scale, white tint)
|
|
10
|
-
* and every object-valued field is deep-cloned on construction, making it
|
|
11
|
-
* safe to share one `ParticleOptions` instance across multiple emitters.
|
|
12
|
-
*/
|
|
13
|
-
export declare class ParticleOptions implements ParticleProperties {
|
|
14
|
-
private readonly _totalLifetime;
|
|
15
|
-
private readonly _elapsedLifetime;
|
|
16
|
-
private readonly _position;
|
|
17
|
-
private readonly _velocity;
|
|
18
|
-
private readonly _scale;
|
|
19
|
-
private readonly _tint;
|
|
20
|
-
private _rotation;
|
|
21
|
-
private _rotationSpeed;
|
|
22
|
-
private _textureIndex;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new options snapshot. Any omitted field falls back to its
|
|
25
|
-
* default value (1 s lifetime, zero position/velocity, unit scale,
|
|
26
|
-
* zero rotation, white tint, texture index 0). All object values are
|
|
27
|
-
* cloned so later mutations to the source objects do not affect this
|
|
28
|
-
* instance.
|
|
29
|
-
*/
|
|
30
|
-
constructor(options?: Partial<ParticleProperties>);
|
|
31
|
-
get totalLifetime(): Time;
|
|
32
|
-
set totalLifetime(totalLifetime: Time);
|
|
33
|
-
get elapsedLifetime(): Time;
|
|
34
|
-
set elapsedLifetime(elapsedLifetime: Time);
|
|
35
|
-
/**
|
|
36
|
-
* Spawn position for particles emitted with these options, expressed in
|
|
37
|
-
* the owning ParticleSystem's LOCAL coordinate space — the system's own
|
|
38
|
-
* `getGlobalTransform()` is applied on top during rendering (both the
|
|
39
|
-
* WebGL2 and WebGPU shaders do `projection * translation * rotated`).
|
|
40
|
-
*
|
|
41
|
-
* Setting a world-space value here (e.g. `system.x + offset`) will
|
|
42
|
-
* double-translate the emitter because the shader will translate again.
|
|
43
|
-
* For an emitter anchored at the system origin, use small offsets around
|
|
44
|
-
* `(0, 0)` and position the system itself via `system.setPosition(...)`.
|
|
45
|
-
*/
|
|
46
|
-
get position(): Vector;
|
|
47
|
-
set position(position: Vector);
|
|
48
|
-
get velocity(): Vector;
|
|
49
|
-
set velocity(velocity: Vector);
|
|
50
|
-
get scale(): Vector;
|
|
51
|
-
set scale(scale: Vector);
|
|
52
|
-
get rotation(): number;
|
|
53
|
-
set rotation(degrees: number);
|
|
54
|
-
get rotationSpeed(): number;
|
|
55
|
-
set rotationSpeed(rotationSpeed: number);
|
|
56
|
-
get textureIndex(): number;
|
|
57
|
-
set textureIndex(textureIndex: number);
|
|
58
|
-
get tint(): Color;
|
|
59
|
-
set tint(color: Color);
|
|
60
|
-
/** Destroys all owned value objects. Called by the owning emitter's `destroy()`. */
|
|
61
|
-
destroy(): void;
|
|
62
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Vector } from '../../math/Vector.js';
|
|
2
|
-
import { Color } from '../../core/Color.js';
|
|
3
|
-
import { Time } from '../../core/Time.js';
|
|
4
|
-
import { trimRotation } from '../../math/utils.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Spawn-time configuration snapshot passed to {@link ParticleEmitter.apply}
|
|
8
|
-
* implementations. Implements {@link ParticleProperties} so the same affector
|
|
9
|
-
* interface can read default values when needed. All fields have sensible
|
|
10
|
-
* defaults (1 s lifetime, zero position/velocity, unit scale, white tint)
|
|
11
|
-
* and every object-valued field is deep-cloned on construction, making it
|
|
12
|
-
* safe to share one `ParticleOptions` instance across multiple emitters.
|
|
13
|
-
*/
|
|
14
|
-
class ParticleOptions {
|
|
15
|
-
_totalLifetime;
|
|
16
|
-
_elapsedLifetime;
|
|
17
|
-
_position;
|
|
18
|
-
_velocity;
|
|
19
|
-
_scale;
|
|
20
|
-
_tint;
|
|
21
|
-
_rotation;
|
|
22
|
-
_rotationSpeed;
|
|
23
|
-
_textureIndex;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new options snapshot. Any omitted field falls back to its
|
|
26
|
-
* default value (1 s lifetime, zero position/velocity, unit scale,
|
|
27
|
-
* zero rotation, white tint, texture index 0). All object values are
|
|
28
|
-
* cloned so later mutations to the source objects do not affect this
|
|
29
|
-
* instance.
|
|
30
|
-
*/
|
|
31
|
-
constructor(options = {}) {
|
|
32
|
-
const { totalLifetime, elapsedLifetime, position, velocity, scale, rotation, rotationSpeed, textureIndex, tint, } = options;
|
|
33
|
-
this._totalLifetime = (totalLifetime ?? Time.oneSecond).clone();
|
|
34
|
-
this._elapsedLifetime = (elapsedLifetime ?? Time.zero).clone();
|
|
35
|
-
this._position = (position ?? Vector.zero).clone();
|
|
36
|
-
this._velocity = (velocity ?? Vector.zero).clone();
|
|
37
|
-
this._scale = (scale ?? Vector.one).clone();
|
|
38
|
-
this._tint = (tint ?? Color.white).clone();
|
|
39
|
-
this._rotation = rotation ?? 0;
|
|
40
|
-
this._rotationSpeed = rotationSpeed ?? 0;
|
|
41
|
-
this._textureIndex = textureIndex ?? 0;
|
|
42
|
-
}
|
|
43
|
-
get totalLifetime() {
|
|
44
|
-
return this._totalLifetime;
|
|
45
|
-
}
|
|
46
|
-
set totalLifetime(totalLifetime) {
|
|
47
|
-
this._totalLifetime.copy(totalLifetime);
|
|
48
|
-
}
|
|
49
|
-
get elapsedLifetime() {
|
|
50
|
-
return this._elapsedLifetime;
|
|
51
|
-
}
|
|
52
|
-
set elapsedLifetime(elapsedLifetime) {
|
|
53
|
-
this._elapsedLifetime.copy(elapsedLifetime);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Spawn position for particles emitted with these options, expressed in
|
|
57
|
-
* the owning ParticleSystem's LOCAL coordinate space — the system's own
|
|
58
|
-
* `getGlobalTransform()` is applied on top during rendering (both the
|
|
59
|
-
* WebGL2 and WebGPU shaders do `projection * translation * rotated`).
|
|
60
|
-
*
|
|
61
|
-
* Setting a world-space value here (e.g. `system.x + offset`) will
|
|
62
|
-
* double-translate the emitter because the shader will translate again.
|
|
63
|
-
* For an emitter anchored at the system origin, use small offsets around
|
|
64
|
-
* `(0, 0)` and position the system itself via `system.setPosition(...)`.
|
|
65
|
-
*/
|
|
66
|
-
get position() {
|
|
67
|
-
return this._position;
|
|
68
|
-
}
|
|
69
|
-
set position(position) {
|
|
70
|
-
this._position.copy(position);
|
|
71
|
-
}
|
|
72
|
-
get velocity() {
|
|
73
|
-
return this._velocity;
|
|
74
|
-
}
|
|
75
|
-
set velocity(velocity) {
|
|
76
|
-
this._velocity.copy(velocity);
|
|
77
|
-
}
|
|
78
|
-
get scale() {
|
|
79
|
-
return this._scale;
|
|
80
|
-
}
|
|
81
|
-
set scale(scale) {
|
|
82
|
-
this._scale.copy(scale);
|
|
83
|
-
}
|
|
84
|
-
get rotation() {
|
|
85
|
-
return this._rotation;
|
|
86
|
-
}
|
|
87
|
-
set rotation(degrees) {
|
|
88
|
-
this._rotation = trimRotation(degrees);
|
|
89
|
-
}
|
|
90
|
-
get rotationSpeed() {
|
|
91
|
-
return this._rotationSpeed;
|
|
92
|
-
}
|
|
93
|
-
set rotationSpeed(rotationSpeed) {
|
|
94
|
-
this._rotationSpeed = rotationSpeed;
|
|
95
|
-
}
|
|
96
|
-
get textureIndex() {
|
|
97
|
-
return this._textureIndex;
|
|
98
|
-
}
|
|
99
|
-
set textureIndex(textureIndex) {
|
|
100
|
-
this._textureIndex = textureIndex;
|
|
101
|
-
}
|
|
102
|
-
get tint() {
|
|
103
|
-
return this._tint;
|
|
104
|
-
}
|
|
105
|
-
set tint(color) {
|
|
106
|
-
this._tint.copy(color);
|
|
107
|
-
}
|
|
108
|
-
/** Destroys all owned value objects. Called by the owning emitter's `destroy()`. */
|
|
109
|
-
destroy() {
|
|
110
|
-
this._totalLifetime.destroy();
|
|
111
|
-
this._elapsedLifetime.destroy();
|
|
112
|
-
this._position.destroy();
|
|
113
|
-
this._velocity.destroy();
|
|
114
|
-
this._scale.destroy();
|
|
115
|
-
this._tint.destroy();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export { ParticleOptions };
|
|
120
|
-
//# sourceMappingURL=ParticleOptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParticleOptions.js","sources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AAY,CAAC,YAAoB,EAAA;AACxC,QAAA,IAAI,CAAC,aAAa,GAAG,YAAY;IACrC;AAEA,IAAA,IAAW,IAAI,GAAA;QACX,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAW,IAAI,CAAC,KAAY,EAAA;AACxB,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;IAC1B;;IAGO,OAAO,GAAA;AACV,QAAA,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;AAC7B,QAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;AAC/B,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;AACxB,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACrB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACxB;AACH;;;;"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Time } from '@/core/Time';
|
|
2
|
-
import { ParticleOptions } from '@/particles/emitters/ParticleOptions';
|
|
3
|
-
import type { ParticleEmitter } from '@/particles/emitters/ParticleEmitter';
|
|
4
|
-
import type { ParticleSystem } from '@/particles/ParticleSystem';
|
|
5
|
-
/**
|
|
6
|
-
* Rate-based concrete {@link ParticleEmitter} that spawns a fixed number of
|
|
7
|
-
* particles per second, configured via {@link UniversalEmitter.emissionRate}
|
|
8
|
-
* and {@link UniversalEmitter.particleOptions}. Sub-frame fractions are
|
|
9
|
-
* accumulated in an internal delta so that low emission rates (e.g. 0.5
|
|
10
|
-
* particles/s) remain accurate over time without integer truncation error.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const emitter = new UniversalEmitter(60, new ParticleOptions({ velocity: new Vector(0, -200) }));
|
|
14
|
-
* particleSystem.addEmitter(emitter);
|
|
15
|
-
*/
|
|
16
|
-
export declare class UniversalEmitter implements ParticleEmitter {
|
|
17
|
-
private _emissionRate;
|
|
18
|
-
private _particleOptions;
|
|
19
|
-
private _emissionDelta;
|
|
20
|
-
constructor(emissionRate: number, particleOptions?: ParticleOptions);
|
|
21
|
-
get emissionRate(): number;
|
|
22
|
-
set emissionRate(particlesPerSecond: number);
|
|
23
|
-
get particleOptions(): ParticleOptions;
|
|
24
|
-
set particleOptions(particleOptions: ParticleOptions);
|
|
25
|
-
/**
|
|
26
|
-
* Computes how many whole particles to spawn for the given `time` slice,
|
|
27
|
-
* carrying any fractional remainder into the next call. This accumulator
|
|
28
|
-
* prevents emission-rate drift when `emissionRate * delta` is not an
|
|
29
|
-
* integer (e.g. 30 fps × 0.5 particles/s = 0.5 per frame → every other
|
|
30
|
-
* frame emits one).
|
|
31
|
-
*/
|
|
32
|
-
computeParticleCount(time: Time): number;
|
|
33
|
-
/**
|
|
34
|
-
* Requests the correct number of particles from `system` for this frame,
|
|
35
|
-
* configures each one with {@link particleOptions} via
|
|
36
|
-
* {@link Particle.applyOptions}, and emits them into the live pool.
|
|
37
|
-
*/
|
|
38
|
-
apply(system: ParticleSystem, delta: Time): this;
|
|
39
|
-
destroy(): void;
|
|
40
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ParticleOptions } from './ParticleOptions.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Rate-based concrete {@link ParticleEmitter} that spawns a fixed number of
|
|
5
|
-
* particles per second, configured via {@link UniversalEmitter.emissionRate}
|
|
6
|
-
* and {@link UniversalEmitter.particleOptions}. Sub-frame fractions are
|
|
7
|
-
* accumulated in an internal delta so that low emission rates (e.g. 0.5
|
|
8
|
-
* particles/s) remain accurate over time without integer truncation error.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const emitter = new UniversalEmitter(60, new ParticleOptions({ velocity: new Vector(0, -200) }));
|
|
12
|
-
* particleSystem.addEmitter(emitter);
|
|
13
|
-
*/
|
|
14
|
-
class UniversalEmitter {
|
|
15
|
-
_emissionRate;
|
|
16
|
-
_particleOptions;
|
|
17
|
-
_emissionDelta = 0;
|
|
18
|
-
constructor(emissionRate, particleOptions) {
|
|
19
|
-
this._emissionRate = emissionRate;
|
|
20
|
-
this._particleOptions = particleOptions ?? new ParticleOptions();
|
|
21
|
-
}
|
|
22
|
-
get emissionRate() {
|
|
23
|
-
return this._emissionRate;
|
|
24
|
-
}
|
|
25
|
-
set emissionRate(particlesPerSecond) {
|
|
26
|
-
this._emissionRate = particlesPerSecond;
|
|
27
|
-
}
|
|
28
|
-
get particleOptions() {
|
|
29
|
-
return this._particleOptions;
|
|
30
|
-
}
|
|
31
|
-
set particleOptions(particleOptions) {
|
|
32
|
-
this._particleOptions = particleOptions;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Computes how many whole particles to spawn for the given `time` slice,
|
|
36
|
-
* carrying any fractional remainder into the next call. This accumulator
|
|
37
|
-
* prevents emission-rate drift when `emissionRate * delta` is not an
|
|
38
|
-
* integer (e.g. 30 fps × 0.5 particles/s = 0.5 per frame → every other
|
|
39
|
-
* frame emits one).
|
|
40
|
-
*/
|
|
41
|
-
computeParticleCount(time) {
|
|
42
|
-
const particleAmount = (this._emissionRate * time.seconds) + this._emissionDelta;
|
|
43
|
-
const particles = particleAmount | 0;
|
|
44
|
-
this._emissionDelta = (particleAmount - particles);
|
|
45
|
-
return particles;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Requests the correct number of particles from `system` for this frame,
|
|
49
|
-
* configures each one with {@link particleOptions} via
|
|
50
|
-
* {@link Particle.applyOptions}, and emits them into the live pool.
|
|
51
|
-
*/
|
|
52
|
-
apply(system, delta) {
|
|
53
|
-
const count = this.computeParticleCount(delta);
|
|
54
|
-
const options = this._particleOptions;
|
|
55
|
-
for (let i = 0; i < count; i++) {
|
|
56
|
-
const particle = system.requestParticle();
|
|
57
|
-
particle.applyOptions(options);
|
|
58
|
-
system.emitParticle(particle);
|
|
59
|
-
}
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
destroy() {
|
|
63
|
-
this._particleOptions.destroy();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { UniversalEmitter };
|
|
68
|
-
//# sourceMappingURL=UniversalEmitter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UniversalEmitter.js","sources":["../../../../../src/particles/emitters/UniversalEmitter.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;;;;;;;;AAUG;MACU,gBAAgB,CAAA;AACjB,IAAA,aAAa;AACb,IAAA,gBAAgB;IAChB,cAAc,GAAG,CAAC;IAE1B,WAAA,CAAmB,YAAoB,EAAE,eAAiC,EAAA;AACtE,QAAA,IAAI,CAAC,aAAa,GAAG,YAAY;QACjC,IAAI,CAAC,gBAAgB,GAAG,eAAe,IAAI,IAAI,eAAe,EAAE;IACpE;AAEA,IAAA,IAAW,YAAY,GAAA;QACnB,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,IAAW,YAAY,CAAC,kBAA0B,EAAA;AAC9C,QAAA,IAAI,CAAC,aAAa,GAAG,kBAAkB;IAC3C;AAEA,IAAA,IAAW,eAAe,GAAA;QACtB,OAAO,IAAI,CAAC,gBAAgB;IAChC;IAEA,IAAW,eAAe,CAAC,eAAgC,EAAA;AACvD,QAAA,IAAI,CAAC,gBAAgB,GAAG,eAAe;IAC3C;AAEA;;;;;;AAMG;AACI,IAAA,oBAAoB,CAAC,IAAU,EAAA;AAClC,QAAA,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc;AAChF,QAAA,MAAM,SAAS,GAAG,cAAc,GAAG,CAAC;QAEpC,IAAI,CAAC,cAAc,IAAI,cAAc,GAAG,SAAS,CAAC;AAElD,QAAA,OAAO,SAAS;IACpB;AAEA;;;;AAIG;IACI,KAAK,CAAC,MAAsB,EAAE,KAAW,EAAA;QAC5C,MAAM,KAAK,GAAG,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