laymur 0.27.0 → 0.28.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 +48 -3
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +2 -1
- package/dist/core/constraints/UICustomConstraint.js +1 -1
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +2 -1
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +2 -1
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +2 -1
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +2 -1
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +2 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +2 -1
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +2 -1
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +2 -1
- package/dist/core/constraints/constraintAsserts.d.ts +41 -0
- package/dist/core/constraints/constraintAsserts.js +171 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +8 -5
- package/dist/core/elements/UIDummy/UIDummy.js +21 -10
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +6 -5
- package/dist/core/elements/UIElement/UIElement.Internal.js +0 -4
- package/dist/core/elements/UIElement/UIElement.d.ts +12 -6
- package/dist/core/elements/UIElement/UIElement.js +14 -7
- package/dist/core/elements/UIText/UIText.d.ts +6 -1
- package/dist/core/elements/UIText/UIText.js +22 -12
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +1 -1
- package/dist/core/miscellaneous/UIBlendMode.d.ts +5 -0
- package/dist/core/miscellaneous/UIBlendMode.js +7 -0
- package/dist/core/miscellaneous/asserts.d.ts +0 -41
- package/dist/core/miscellaneous/asserts.js +0 -170
- package/dist/core/miscellaneous/canvas.js +3 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +2 -1
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +2 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +10 -7
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +11 -8
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +1 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +1 -1
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.d.ts +4 -1
- package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +4 -1
- package/dist/core/miscellaneous/text-style/UITextStyle.js +4 -1
- package/dist/core/shaders/UIProgressMaskFunctionCircular.js +1 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +6 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +1 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +18 -9
- package/dist/debug/UIAspectDebug.js +4 -7
- package/dist/debug/UIHeightDebug.js +4 -4
- package/dist/debug/UIHorizontalDistanceDebug.js +4 -7
- package/dist/debug/UIHorizontalInterpolationDebug.js +11 -10
- package/dist/debug/UIVerticalDistanceDebug.js +4 -7
- package/dist/debug/UIVerticalInterpolationDebug.js +11 -10
- package/dist/debug/UIWidthDebug.js +4 -4
- package/dist/debug/miscellaneous.d.ts +7 -0
- package/dist/debug/miscellaneous.js +11 -1
- package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.d.ts +44 -0
- package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.js +75 -0
- package/dist/particles/behaviorModules/UIBehaviorBounce.d.ts +51 -0
- package/dist/particles/behaviorModules/UIBehaviorBounce.js +107 -0
- package/dist/particles/behaviorModules/UIBehaviorOrbit.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorOrbit.js +73 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -2
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +9 -5
- package/dist/particles/behaviorModules/UIBehaviorSeek.d.ts +38 -0
- package/dist/particles/behaviorModules/UIBehaviorSeek.js +75 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +45 -1
- package/dist/particles/elements/UIEmitter.Internal.js +25 -1
- package/dist/particles/elements/UIEmitter.Schedule.d.ts +31 -0
- package/dist/particles/elements/UIEmitter.Schedule.js +81 -0
- package/dist/particles/elements/UIEmitter.d.ts +79 -9
- package/dist/particles/elements/UIEmitter.js +239 -82
- package/dist/particles/index.d.ts +13 -1
- package/dist/particles/index.js +11 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +6 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +27 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.js +12 -1
- package/dist/particles/miscellaneous/miscellaneous.d.ts +22 -0
- package/dist/particles/miscellaneous/miscellaneous.js +38 -0
- package/dist/particles/renderingModules/UIRenderingFlipbook.d.ts +41 -0
- package/dist/particles/renderingModules/UIRenderingFlipbook.js +70 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +2 -1
- package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
- package/dist/particles/renderingModules/UIRenderingRandomColor.d.ts +19 -0
- package/dist/particles/renderingModules/UIRenderingRandomColor.js +28 -0
- package/dist/particles/renderingModules/UIRenderingShape.d.ts +31 -0
- package/dist/particles/renderingModules/UIRenderingShape.js +54 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +1 -1
- package/dist/particles/renderingModules/UIRenderingTexture.js +4 -28
- package/dist/particles/shaders/UIRenderingFlipbook.d.ts +5 -0
- package/dist/particles/shaders/UIRenderingFlipbook.js +19 -0
- package/dist/particles/shaders/UIRenderingRandomColor.d.ts +2 -0
- package/dist/particles/shaders/UIRenderingRandomColor.js +10 -0
- package/dist/particles/shaders/UIRenderingShape.d.ts +6 -0
- package/dist/particles/shaders/UIRenderingShape.js +15 -0
- package/dist/particles/shaders/UIRenderingTexture.d.ts +4 -2
- package/dist/particles/shaders/UIRenderingTexture.js +27 -2
- package/dist/particles/spawnModules/UISpawnCircle.d.ts +44 -0
- package/dist/particles/spawnModules/UISpawnCircle.js +81 -0
- package/dist/particles/spawnModules/UISpawnRadialVelocity.d.ts +37 -0
- package/dist/particles/spawnModules/UISpawnRadialVelocity.js +75 -0
- package/package.json +24 -21
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MathUtils } from "three";
|
|
2
|
+
import { assertValidNumber } from "../../core/miscellaneous/asserts.js";
|
|
3
|
+
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, particleRandom, particleRandomStream, resolveUIRangeConfig, resolveUIVector2Config, } from "../miscellaneous/miscellaneous.js";
|
|
4
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
|
+
/**
|
|
6
|
+
* Turns the motion of particles around a center: position and velocity rotate together at an
|
|
7
|
+
* angular speed, so a particle at rest circles the center at its distance and one moving outward
|
|
8
|
+
* spirals.
|
|
9
|
+
*
|
|
10
|
+
* The rotation is kinematic, not a force: the distance to the center stays unless the velocity
|
|
11
|
+
* changes it. The center is in the particle space of the emitter.
|
|
12
|
+
*/
|
|
13
|
+
export class UIBehaviorOrbit extends UIBehaviorModule {
|
|
14
|
+
/**
|
|
15
|
+
* @param angularSpeed - Radians per second, counter-clockwise for positive values. Accepts
|
|
16
|
+
* number, tuple, or range object
|
|
17
|
+
* @param center - Center of the rotation
|
|
18
|
+
*/
|
|
19
|
+
constructor(angularSpeed, center = 0) {
|
|
20
|
+
super();
|
|
21
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
22
|
+
this.angularSpeedInternal = resolveUIRangeConfig(angularSpeed);
|
|
23
|
+
this.centerInternal = resolveUIVector2Config(center);
|
|
24
|
+
this.assertValid("UIBehaviorOrbit.constructor");
|
|
25
|
+
}
|
|
26
|
+
/** Radians per second, counter-clockwise for positive values */
|
|
27
|
+
get angularSpeed() {
|
|
28
|
+
return this.angularSpeedInternal;
|
|
29
|
+
}
|
|
30
|
+
/** Center of the rotation */
|
|
31
|
+
get center() {
|
|
32
|
+
return this.centerInternal;
|
|
33
|
+
}
|
|
34
|
+
/** Radians per second, counter-clockwise for positive values */
|
|
35
|
+
set angularSpeed(value) {
|
|
36
|
+
this.angularSpeedInternal = resolveUIRangeConfig(value);
|
|
37
|
+
this.assertValid("UIBehaviorOrbit");
|
|
38
|
+
}
|
|
39
|
+
/** Center of the rotation */
|
|
40
|
+
set center(value) {
|
|
41
|
+
this.centerInternal = resolveUIVector2Config(value);
|
|
42
|
+
this.assertValid("UIBehaviorOrbit");
|
|
43
|
+
}
|
|
44
|
+
update(properties, instanceCount, deltaTime, randomSalt) {
|
|
45
|
+
const { builtin } = properties;
|
|
46
|
+
const { array, itemSize } = builtin;
|
|
47
|
+
const { x: centerX, y: centerY } = this.centerInternal;
|
|
48
|
+
const { min: speedMin, max: speedMax } = this.angularSpeedInternal;
|
|
49
|
+
const speedStream = particleRandomStream(randomSalt, 0);
|
|
50
|
+
for (let i = 0; i < instanceCount; i++) {
|
|
51
|
+
const itemOffset = i * itemSize;
|
|
52
|
+
const angle = MathUtils.lerp(speedMin, speedMax, particleRandom(array, itemOffset, speedStream)) *
|
|
53
|
+
deltaTime;
|
|
54
|
+
const cos = Math.cos(angle);
|
|
55
|
+
const sin = Math.sin(angle);
|
|
56
|
+
const offsetX = array[itemOffset + BUILTIN_OFFSET_POSITION_X] - centerX;
|
|
57
|
+
const offsetY = array[itemOffset + BUILTIN_OFFSET_POSITION_Y] - centerY;
|
|
58
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_X] = centerX + offsetX * cos - offsetY * sin;
|
|
59
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] = centerY + offsetX * sin + offsetY * cos;
|
|
60
|
+
const velocityX = array[itemOffset + BUILTIN_OFFSET_VELOCITY_X];
|
|
61
|
+
const velocityY = array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y];
|
|
62
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] = velocityX * cos - velocityY * sin;
|
|
63
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] = velocityX * sin + velocityY * cos;
|
|
64
|
+
}
|
|
65
|
+
builtin.needsUpdate = true;
|
|
66
|
+
}
|
|
67
|
+
assertValid(subject) {
|
|
68
|
+
assertValidNumber(this.angularSpeedInternal.min, `${subject}.angularSpeed.min`);
|
|
69
|
+
assertValidNumber(this.angularSpeedInternal.max, `${subject}.angularSpeed.max`);
|
|
70
|
+
assertValidNumber(this.centerInternal.x, `${subject}.center.x`);
|
|
71
|
+
assertValidNumber(this.centerInternal.y, `${subject}.center.y`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { InstancedBufferAttribute } from "three";
|
|
2
2
|
import type { UIAspectConfig, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
import { UIEasing } from "../miscellaneous/miscellaneous.js";
|
|
3
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
4
5
|
/**
|
|
5
6
|
* Animates particle scale over lifetime.
|
|
6
7
|
*
|
|
7
|
-
* Interpolates between scale anchors based on particle age
|
|
8
|
+
* Interpolates between scale anchors based on particle age, with the easing within each span
|
|
9
|
+
* between two anchors. Requires at least 2 anchors.
|
|
8
10
|
*/
|
|
9
11
|
export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
|
|
10
12
|
builtin: "Matrix4";
|
|
@@ -12,13 +14,16 @@ export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
|
|
|
12
14
|
readonly requiredProperties: {
|
|
13
15
|
readonly builtin: "Matrix4";
|
|
14
16
|
};
|
|
17
|
+
/** Easing within each span between two anchors */
|
|
18
|
+
easing: UIEasing;
|
|
15
19
|
private readonly scales;
|
|
16
20
|
private aspectInternal;
|
|
17
21
|
/**
|
|
18
22
|
* @param scales - Scale anchor points. Each accepts number, tuple, or range object
|
|
19
23
|
* @param aspect - Width/height ratio. Accepts number or texture
|
|
24
|
+
* @param easing - Easing within each span between two anchors
|
|
20
25
|
*/
|
|
21
|
-
constructor(scales: UIRangeConfig[], aspect?: UIAspectConfig);
|
|
26
|
+
constructor(scales: UIRangeConfig[], aspect?: UIAspectConfig, easing?: UIEasing);
|
|
22
27
|
/** Width/height aspect ratio */
|
|
23
28
|
get aspect(): number;
|
|
24
29
|
/** Width/height aspect ratio */
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
2
|
import { assertValidNonNegativeNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
3
|
-
import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, particleRandom, particleRandomStream, resolveAspect, resolveUIRangeConfig, } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
import { applyEasing, BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, particleRandom, particleRandomStream, resolveAspect, resolveUIRangeConfig, UIEasing, } from "../miscellaneous/miscellaneous.js";
|
|
4
4
|
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
5
|
/**
|
|
6
6
|
* Animates particle scale over lifetime.
|
|
7
7
|
*
|
|
8
|
-
* Interpolates between scale anchors based on particle age
|
|
8
|
+
* Interpolates between scale anchors based on particle age, with the easing within each span
|
|
9
|
+
* between two anchors. Requires at least 2 anchors.
|
|
9
10
|
*/
|
|
10
11
|
export class UIBehaviorScaleOverLife extends UIBehaviorModule {
|
|
11
12
|
/**
|
|
12
13
|
* @param scales - Scale anchor points. Each accepts number, tuple, or range object
|
|
13
14
|
* @param aspect - Width/height ratio. Accepts number or texture
|
|
15
|
+
* @param easing - Easing within each span between two anchors
|
|
14
16
|
*/
|
|
15
|
-
constructor(scales, aspect = 1) {
|
|
17
|
+
constructor(scales, aspect = 1, easing = UIEasing.LINEAR) {
|
|
16
18
|
super();
|
|
17
19
|
this.requiredProperties = { builtin: "Matrix4" };
|
|
18
20
|
this.scales = [];
|
|
21
|
+
this.easing = easing;
|
|
19
22
|
if (scales.length < 2) {
|
|
20
23
|
throw new Error(`UIBehaviorScaleOverLife.constructor.scales: at least two scale anchors are required, got ${scales.length}`);
|
|
21
24
|
}
|
|
@@ -45,9 +48,10 @@ export class UIBehaviorScaleOverLife extends UIBehaviorModule {
|
|
|
45
48
|
const itemOffset = i * itemSize;
|
|
46
49
|
const lifeT = Math.min(array[itemOffset + BUILTIN_OFFSET_AGE] / array[itemOffset + BUILTIN_OFFSET_LIFETIME], 1);
|
|
47
50
|
const segment = (this.scales.length - 1) * lifeT;
|
|
48
|
-
|
|
51
|
+
// The last span also takes lifeT = 1, of a particle that outlives its lifetime this frame
|
|
52
|
+
const index = Math.min(Math.floor(segment), this.scales.length - 2);
|
|
49
53
|
const scaleT = particleRandom(array, itemOffset, scaleStream);
|
|
50
|
-
const localT = segment - index;
|
|
54
|
+
const localT = applyEasing(this.easing, segment - index);
|
|
51
55
|
const scaleRange0 = this.scales[index];
|
|
52
56
|
const scaleRange1 = this.scales[index + 1];
|
|
53
57
|
const scale0 = MathUtils.lerp(scaleRange0.min, scaleRange0.max, scaleT);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { InstancedBufferAttribute } from "three";
|
|
2
|
+
import type { Vector2Like } from "../../core/miscellaneous/math.js";
|
|
3
|
+
import type { UIVector2Config } from "../miscellaneous/miscellaneous.js";
|
|
4
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
5
|
+
/**
|
|
6
|
+
* Steers particles into a target point at the end of their life, such as coins flying into a
|
|
7
|
+
* counter. With `UIEmitter.signalParticleDied` the death of a particle marks its arrival.
|
|
8
|
+
*
|
|
9
|
+
* Each frame the particle gets the constant acceleration that would bring it from its position and
|
|
10
|
+
* velocity to the target in the life left, so it keeps its initial motion and curves into the
|
|
11
|
+
* target. Put it last in the behavior sequence: modules after it move the particle off course.
|
|
12
|
+
* The target is in the particle space of the emitter.
|
|
13
|
+
*/
|
|
14
|
+
export declare class UIBehaviorSeek extends UIBehaviorModule<{
|
|
15
|
+
builtin: "Matrix4";
|
|
16
|
+
}> {
|
|
17
|
+
readonly requiredProperties: {
|
|
18
|
+
readonly builtin: "Matrix4";
|
|
19
|
+
};
|
|
20
|
+
private targetInternal;
|
|
21
|
+
private delayInternal;
|
|
22
|
+
/**
|
|
23
|
+
* @param target - Point the particles arrive at
|
|
24
|
+
* @param delay - Part of the life before steering starts, from 0 to 1
|
|
25
|
+
*/
|
|
26
|
+
constructor(target: UIVector2Config, delay?: number);
|
|
27
|
+
/** Point the particles arrive at */
|
|
28
|
+
get target(): Vector2Like;
|
|
29
|
+
/** Part of the life before steering starts */
|
|
30
|
+
get delay(): number;
|
|
31
|
+
/** Point the particles arrive at */
|
|
32
|
+
set target(value: UIVector2Config);
|
|
33
|
+
/** Part of the life before steering starts */
|
|
34
|
+
set delay(value: number);
|
|
35
|
+
update(properties: {
|
|
36
|
+
builtin: InstancedBufferAttribute;
|
|
37
|
+
}, instanceCount: number, deltaTime: number): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assertValidNumber } from "../../core/miscellaneous/asserts.js";
|
|
2
|
+
import { assertValidUnitNumber, BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, resolveUIVector2Config, } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
import { UIBehaviorModule } from "./UIBehaviorModule.js";
|
|
4
|
+
/**
|
|
5
|
+
* Steers particles into a target point at the end of their life, such as coins flying into a
|
|
6
|
+
* counter. With `UIEmitter.signalParticleDied` the death of a particle marks its arrival.
|
|
7
|
+
*
|
|
8
|
+
* Each frame the particle gets the constant acceleration that would bring it from its position and
|
|
9
|
+
* velocity to the target in the life left, so it keeps its initial motion and curves into the
|
|
10
|
+
* target. Put it last in the behavior sequence: modules after it move the particle off course.
|
|
11
|
+
* The target is in the particle space of the emitter.
|
|
12
|
+
*/
|
|
13
|
+
export class UIBehaviorSeek extends UIBehaviorModule {
|
|
14
|
+
/**
|
|
15
|
+
* @param target - Point the particles arrive at
|
|
16
|
+
* @param delay - Part of the life before steering starts, from 0 to 1
|
|
17
|
+
*/
|
|
18
|
+
constructor(target, delay = 0) {
|
|
19
|
+
super();
|
|
20
|
+
this.requiredProperties = { builtin: "Matrix4" };
|
|
21
|
+
this.targetInternal = resolveUIVector2Config(target);
|
|
22
|
+
assertValidNumber(this.targetInternal.x, "UIBehaviorSeek.constructor.target.x");
|
|
23
|
+
assertValidNumber(this.targetInternal.y, "UIBehaviorSeek.constructor.target.y");
|
|
24
|
+
assertValidUnitNumber(delay, "UIBehaviorSeek.constructor.delay");
|
|
25
|
+
this.delayInternal = delay;
|
|
26
|
+
}
|
|
27
|
+
/** Point the particles arrive at */
|
|
28
|
+
get target() {
|
|
29
|
+
return this.targetInternal;
|
|
30
|
+
}
|
|
31
|
+
/** Part of the life before steering starts */
|
|
32
|
+
get delay() {
|
|
33
|
+
return this.delayInternal;
|
|
34
|
+
}
|
|
35
|
+
/** Point the particles arrive at */
|
|
36
|
+
set target(value) {
|
|
37
|
+
this.targetInternal = resolveUIVector2Config(value);
|
|
38
|
+
assertValidNumber(this.targetInternal.x, "UIBehaviorSeek.target.x");
|
|
39
|
+
assertValidNumber(this.targetInternal.y, "UIBehaviorSeek.target.y");
|
|
40
|
+
}
|
|
41
|
+
/** Part of the life before steering starts */
|
|
42
|
+
set delay(value) {
|
|
43
|
+
assertValidUnitNumber(value, "UIBehaviorSeek.delay");
|
|
44
|
+
this.delayInternal = value;
|
|
45
|
+
}
|
|
46
|
+
update(properties, instanceCount, deltaTime) {
|
|
47
|
+
const { builtin } = properties;
|
|
48
|
+
const { array, itemSize } = builtin;
|
|
49
|
+
const { x: targetX, y: targetY } = this.targetInternal;
|
|
50
|
+
for (let i = 0; i < instanceCount; i++) {
|
|
51
|
+
const itemOffset = i * itemSize;
|
|
52
|
+
const lifetime = array[itemOffset + BUILTIN_OFFSET_LIFETIME];
|
|
53
|
+
const age = array[itemOffset + BUILTIN_OFFSET_AGE];
|
|
54
|
+
if (age < lifetime * this.delayInternal) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const offsetX = targetX - array[itemOffset + BUILTIN_OFFSET_POSITION_X];
|
|
58
|
+
const offsetY = targetY - array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
|
|
59
|
+
const timeLeft = lifetime - age;
|
|
60
|
+
if (timeLeft <= deltaTime) {
|
|
61
|
+
// The last frame of the life: the particle lands on the target at its end.
|
|
62
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] = offsetX / deltaTime;
|
|
63
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] = offsetY / deltaTime;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// p + v * t + a * t^2 / 2 = target at t = timeLeft
|
|
67
|
+
const velocityX = array[itemOffset + BUILTIN_OFFSET_VELOCITY_X];
|
|
68
|
+
const velocityY = array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y];
|
|
69
|
+
const scale = (2 * deltaTime) / (timeLeft * timeLeft);
|
|
70
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += (offsetX - velocityX * timeLeft) * scale;
|
|
71
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += (offsetY - velocityY * timeLeft) * scale;
|
|
72
|
+
}
|
|
73
|
+
builtin.needsUpdate = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal.js";
|
|
2
|
-
import { UIMode } from "../../core/index.js";
|
|
2
|
+
import { UIBlendMode, UIMode } from "../../core/index.js";
|
|
3
|
+
/** Coordinate space of particle positions */
|
|
4
|
+
export declare enum UIEmitterSpace {
|
|
5
|
+
/** Relative to the emitter: live particles move with it */
|
|
6
|
+
LOCAL = 0,
|
|
7
|
+
/** Layer coordinates: a particle stays where it was spawned when the emitter moves */
|
|
8
|
+
WORLD = 1
|
|
9
|
+
}
|
|
3
10
|
/** Configuration options for UIEmitter */
|
|
4
11
|
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
5
12
|
/** Whether the particles are drawn */
|
|
6
13
|
mode: UIEmitterMode;
|
|
14
|
+
/** Color blending of the particles with what is drawn under them */
|
|
15
|
+
blendMode: UIBlendMode;
|
|
16
|
+
/**
|
|
17
|
+
* Coordinate space of particle positions, and of the points behavior modules take, such as a
|
|
18
|
+
* gravity center. Spawn modules always write positions relative to the emitter.
|
|
19
|
+
*/
|
|
20
|
+
space: UIEmitterSpace;
|
|
7
21
|
/** Number of particles to allocate for up front; a hint, not a limit */
|
|
8
22
|
expectedCapacity: number;
|
|
9
23
|
/** Capacity is kept a multiple of this; the buffers double when they grow */
|
|
@@ -18,18 +32,48 @@ export interface UIEmitterOptions extends UIAnchorOptions {
|
|
|
18
32
|
/** Whether to call destroy() on all modules when the emitter is destroyed */
|
|
19
33
|
automaticallyDestroyModules: boolean;
|
|
20
34
|
}
|
|
35
|
+
/** Options of `UIEmitter.play` */
|
|
21
36
|
export interface UIEmitterPlayOptions {
|
|
37
|
+
/** Seconds of emission, endless by default */
|
|
22
38
|
duration: number;
|
|
39
|
+
/** Particles per unit of distance the emitter moves, on top of the particles per second */
|
|
40
|
+
ratePerDistance: number;
|
|
41
|
+
/** Particles per burst, the first burst at the start. No bursts by default. */
|
|
42
|
+
burstCount: number;
|
|
43
|
+
/** Seconds between bursts, a single burst by default */
|
|
44
|
+
burstInterval: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Path of the emitter over a frame of `time` seconds, in layer coordinates. Particles spawned at a
|
|
48
|
+
* moment of the frame start at the point of that moment, interpolated linearly.
|
|
49
|
+
*/
|
|
50
|
+
export interface UISpawnPath {
|
|
51
|
+
time: number;
|
|
52
|
+
fromX: number;
|
|
53
|
+
fromY: number;
|
|
54
|
+
toX: number;
|
|
55
|
+
toY: number;
|
|
23
56
|
}
|
|
24
57
|
export declare function ignoreInput(): boolean;
|
|
25
58
|
export type UIEmitterMode = UIMode.HIDDEN | UIMode.VISIBLE;
|
|
26
59
|
export declare const EMITTER_DEFAULT_MODE: UIEmitterMode;
|
|
60
|
+
export declare const EMITTER_DEFAULT_BLEND_MODE = UIBlendMode.NORMAL;
|
|
61
|
+
export declare const EMITTER_DEFAULT_SPACE = UIEmitterSpace.LOCAL;
|
|
27
62
|
export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
28
63
|
export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
29
64
|
export declare const EMITTER_DEFAULT_MAX_DELTA_TIME = 0.1;
|
|
30
65
|
export declare const EMITTER_DEFAULT_LIFETIME = 1;
|
|
66
|
+
export declare const EMITTER_DEFAULT_PREWARM_STEP: number;
|
|
31
67
|
export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
32
68
|
/** Salts the emitter hands out: one for the builtin values the shaders read, one per module */
|
|
33
69
|
export declare const EMITTER_SHADER_SALT = 0;
|
|
34
70
|
export declare const EMITTER_SPAWN_SALT_BASE = 256;
|
|
35
71
|
export declare const EMITTER_BEHAVIOR_SALT_BASE = 512;
|
|
72
|
+
/**
|
|
73
|
+
* Moves a particle along its velocity and torque for `time` seconds, negative to move it back
|
|
74
|
+
* @param array Builtin buffer
|
|
75
|
+
* @param itemOffset Offset of the particle in the builtin buffer
|
|
76
|
+
*/
|
|
77
|
+
export declare function advanceParticle(array: {
|
|
78
|
+
[index: number]: number;
|
|
79
|
+
}, itemOffset: number, time: number): void;
|
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
import { UIMode } from "../../core/index.js";
|
|
1
|
+
import { UIBlendMode, UIMode } from "../../core/index.js";
|
|
2
|
+
import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
/** Coordinate space of particle positions */
|
|
4
|
+
export var UIEmitterSpace;
|
|
5
|
+
(function (UIEmitterSpace) {
|
|
6
|
+
/** Relative to the emitter: live particles move with it */
|
|
7
|
+
UIEmitterSpace[UIEmitterSpace["LOCAL"] = 0] = "LOCAL";
|
|
8
|
+
/** Layer coordinates: a particle stays where it was spawned when the emitter moves */
|
|
9
|
+
UIEmitterSpace[UIEmitterSpace["WORLD"] = 1] = "WORLD";
|
|
10
|
+
})(UIEmitterSpace || (UIEmitterSpace = {}));
|
|
2
11
|
export function ignoreInput() {
|
|
3
12
|
return false;
|
|
4
13
|
}
|
|
5
14
|
export const EMITTER_DEFAULT_MODE = UIMode.VISIBLE;
|
|
15
|
+
export const EMITTER_DEFAULT_BLEND_MODE = UIBlendMode.NORMAL;
|
|
16
|
+
export const EMITTER_DEFAULT_SPACE = UIEmitterSpace.LOCAL;
|
|
6
17
|
export const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
7
18
|
export const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
8
19
|
export const EMITTER_DEFAULT_MAX_DELTA_TIME = 0.1;
|
|
9
20
|
export const EMITTER_DEFAULT_LIFETIME = 1;
|
|
21
|
+
export const EMITTER_DEFAULT_PREWARM_STEP = 1 / 30;
|
|
10
22
|
export const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
11
23
|
/** Salts the emitter hands out: one for the builtin values the shaders read, one per module */
|
|
12
24
|
export const EMITTER_SHADER_SALT = 0;
|
|
13
25
|
export const EMITTER_SPAWN_SALT_BASE = 0x100;
|
|
14
26
|
export const EMITTER_BEHAVIOR_SALT_BASE = 0x200;
|
|
27
|
+
/**
|
|
28
|
+
* Moves a particle along its velocity and torque for `time` seconds, negative to move it back
|
|
29
|
+
* @param array Builtin buffer
|
|
30
|
+
* @param itemOffset Offset of the particle in the builtin buffer
|
|
31
|
+
*/
|
|
32
|
+
export function advanceParticle(array, itemOffset, time) {
|
|
33
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_X] +=
|
|
34
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] * time;
|
|
35
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] +=
|
|
36
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] * time;
|
|
37
|
+
array[itemOffset + BUILTIN_OFFSET_ROTATION] += array[itemOffset + BUILTIN_OFFSET_TORQUE] * time;
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { UIEmitterPlayOptions } from "./UIEmitter.Internal.js";
|
|
2
|
+
/**
|
|
3
|
+
* Receives the particles due within a frame: `count` of them, at `firstMoment + k * interval`
|
|
4
|
+
* seconds from the frame start
|
|
5
|
+
*/
|
|
6
|
+
export type UIEmissionSpawn = (count: number, firstMoment: number, interval: number) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Timing of an emission: a stream by time and by distance, and bursts at an interval. Knows when
|
|
9
|
+
* particles are due, not where or how they are spawned.
|
|
10
|
+
*/
|
|
11
|
+
export declare class UIEmissionSchedule {
|
|
12
|
+
private playing;
|
|
13
|
+
private rate;
|
|
14
|
+
private ratePerDistance;
|
|
15
|
+
private duration;
|
|
16
|
+
private burstInterval;
|
|
17
|
+
private burstCount;
|
|
18
|
+
private elapsed;
|
|
19
|
+
/** Particles of the stream due but not spawned yet, below 1 after each frame */
|
|
20
|
+
private accumulator;
|
|
21
|
+
private nextBurst;
|
|
22
|
+
/** Whether the emission has not ended yet */
|
|
23
|
+
get isPlaying(): boolean;
|
|
24
|
+
start(rate: number, options: Partial<UIEmitterPlayOptions>): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Advances the emission by a frame and hands the particles due within it to `spawn`
|
|
28
|
+
* @param distance Distance the emitter moved during the frame
|
|
29
|
+
*/
|
|
30
|
+
advance(deltaTime: number, distance: number, spawn: UIEmissionSpawn): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { assertValidNonNegativeNumber, assertValidPositiveNumber, } from "../../core/miscellaneous/asserts.js";
|
|
2
|
+
import { assertValidNonNegativeInteger } from "../miscellaneous/miscellaneous.js";
|
|
3
|
+
/**
|
|
4
|
+
* Timing of an emission: a stream by time and by distance, and bursts at an interval. Knows when
|
|
5
|
+
* particles are due, not where or how they are spawned.
|
|
6
|
+
*/
|
|
7
|
+
export class UIEmissionSchedule {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.playing = false;
|
|
10
|
+
this.rate = 0;
|
|
11
|
+
this.ratePerDistance = 0;
|
|
12
|
+
this.duration = Infinity;
|
|
13
|
+
this.burstInterval = Infinity;
|
|
14
|
+
this.burstCount = 0;
|
|
15
|
+
this.elapsed = 0;
|
|
16
|
+
/** Particles of the stream due but not spawned yet, below 1 after each frame */
|
|
17
|
+
this.accumulator = 0;
|
|
18
|
+
this.nextBurst = 0;
|
|
19
|
+
}
|
|
20
|
+
/** Whether the emission has not ended yet */
|
|
21
|
+
get isPlaying() {
|
|
22
|
+
return this.playing;
|
|
23
|
+
}
|
|
24
|
+
start(rate, options) {
|
|
25
|
+
assertValidNonNegativeNumber(rate, "UIEmitter.play.rate");
|
|
26
|
+
this.ratePerDistance = options.ratePerDistance ?? 0;
|
|
27
|
+
assertValidNonNegativeNumber(this.ratePerDistance, "UIEmitter.play.options.ratePerDistance");
|
|
28
|
+
// Infinite unless given: endless emission, a single burst
|
|
29
|
+
this.duration = options.duration ?? Infinity;
|
|
30
|
+
if (options.duration !== undefined) {
|
|
31
|
+
assertValidNonNegativeNumber(options.duration, "UIEmitter.play.options.duration");
|
|
32
|
+
}
|
|
33
|
+
this.burstInterval = options.burstInterval ?? Infinity;
|
|
34
|
+
if (options.burstInterval !== undefined) {
|
|
35
|
+
assertValidPositiveNumber(options.burstInterval, "UIEmitter.play.options.burstInterval");
|
|
36
|
+
}
|
|
37
|
+
this.burstCount = options.burstCount ?? 0;
|
|
38
|
+
assertValidNonNegativeInteger(this.burstCount, "UIEmitter.play.options.burstCount");
|
|
39
|
+
this.playing = true;
|
|
40
|
+
this.rate = rate;
|
|
41
|
+
this.elapsed = 0;
|
|
42
|
+
this.accumulator = 0;
|
|
43
|
+
this.nextBurst = 0;
|
|
44
|
+
}
|
|
45
|
+
stop() {
|
|
46
|
+
this.playing = false;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Advances the emission by a frame and hands the particles due within it to `spawn`
|
|
50
|
+
* @param distance Distance the emitter moved during the frame
|
|
51
|
+
*/
|
|
52
|
+
advance(deltaTime, distance, spawn) {
|
|
53
|
+
if (!this.playing) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const before = this.elapsed;
|
|
57
|
+
this.elapsed += deltaTime;
|
|
58
|
+
const end = Math.min(this.elapsed, this.duration);
|
|
59
|
+
const emittingTime = end - before;
|
|
60
|
+
while (this.burstCount > 0 && this.nextBurst <= end) {
|
|
61
|
+
spawn(this.burstCount, this.nextBurst - before, 0);
|
|
62
|
+
this.nextBurst += this.burstInterval;
|
|
63
|
+
}
|
|
64
|
+
if (emittingTime > 0) {
|
|
65
|
+
// The emitter is taken to move at a constant speed within the frame.
|
|
66
|
+
const added = this.rate * emittingTime + (this.ratePerDistance * distance * emittingTime) / deltaTime;
|
|
67
|
+
const accumulatorBefore = this.accumulator;
|
|
68
|
+
this.accumulator += added;
|
|
69
|
+
const count = Math.floor(this.accumulator);
|
|
70
|
+
if (count > 0) {
|
|
71
|
+
// The k-th particle of the frame, from 0, is due once the accumulator reaches k + 1.
|
|
72
|
+
const interval = emittingTime / added;
|
|
73
|
+
spawn(count, (1 - accumulatorBefore) * interval, interval);
|
|
74
|
+
this.accumulator -= count;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (this.elapsed >= this.duration) {
|
|
78
|
+
this.playing = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import type { FerrsignView2 } from "ferrsign";
|
|
1
2
|
import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor.js";
|
|
2
|
-
import type { UILayer } from "../../core/index.js";
|
|
3
|
+
import type { UIBlendMode, UILayer } from "../../core/index.js";
|
|
3
4
|
import type { UIBehaviorModule } from "../behaviorModules/UIBehaviorModule.js";
|
|
4
5
|
import type { UIRenderingModule } from "../renderingModules/UIRenderingModule.js";
|
|
5
6
|
import type { UISpawnModule } from "../spawnModules/UISpawnModule.js";
|
|
6
7
|
import type { UIEmitterMode, UIEmitterOptions, UIEmitterPlayOptions } from "./UIEmitter.Internal.js";
|
|
8
|
+
import { UIEmitterSpace } from "./UIEmitter.Internal.js";
|
|
7
9
|
/**
|
|
8
10
|
* Particle emitter element.
|
|
9
11
|
*
|
|
10
|
-
* Spawns, updates, and renders particles using modular spawn/behavior/rendering pipeline.
|
|
12
|
+
* Spawns, updates, and renders particles using modular spawn/behavior/rendering pipeline. Each
|
|
13
|
+
* frame ages the particles and removes the dead ones, spawns the particles due, runs the behavior
|
|
14
|
+
* modules and moves the particles along their velocity.
|
|
11
15
|
*/
|
|
12
16
|
export declare class UIEmitter extends UIAnchor {
|
|
13
17
|
private readonly spawnSequence;
|
|
@@ -17,15 +21,26 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
17
21
|
automaticallyDestroyModules: boolean;
|
|
18
22
|
private readonly mesh;
|
|
19
23
|
private readonly catcherHandler;
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
+
private readonly emission;
|
|
25
|
+
/** Path of the emitter over the current frame, along which emission places particles */
|
|
26
|
+
private readonly framePath;
|
|
27
|
+
/** Path of a single point and moment, for bursts */
|
|
28
|
+
private readonly pointPath;
|
|
29
|
+
/** Layer positions of the particles that died this frame, x and y in turn */
|
|
30
|
+
private readonly deadPositions;
|
|
31
|
+
private readonly signalParticleDiedInternal;
|
|
24
32
|
private modeInternal;
|
|
33
|
+
private blendModeInternal;
|
|
34
|
+
private spaceInternal;
|
|
25
35
|
private maxDeltaTimeInternal;
|
|
26
36
|
private seedInternal;
|
|
27
37
|
/** Particles spawned since the seed was set; picks the seed of the next particle */
|
|
28
38
|
private spawnedCount;
|
|
39
|
+
/** Emitter position at the end of the last frame, where the emission of this frame starts */
|
|
40
|
+
private previousX;
|
|
41
|
+
private previousY;
|
|
42
|
+
/** Whether `play` was called since the last frame: its emission starts at the current position */
|
|
43
|
+
private emissionStarted;
|
|
29
44
|
/**
|
|
30
45
|
* @param layer - Layer containing this emitter
|
|
31
46
|
* @param spawnSequence - Modules that initialize new particles
|
|
@@ -34,19 +49,38 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
34
49
|
* @param options - Configuration options
|
|
35
50
|
*/
|
|
36
51
|
constructor(layer: UILayer, spawnSequence: UISpawnModule[], behaviorSequence: readonly UIBehaviorModule[], renderingSequence: readonly UIRenderingModule[], options?: Partial<UIEmitterOptions>);
|
|
52
|
+
/**
|
|
53
|
+
* Fires for every particle that dies, with its position in layer coordinates. Fires after the
|
|
54
|
+
* frame removed its dead particles, so a callback may spawn particles, also on this emitter.
|
|
55
|
+
*/
|
|
56
|
+
get signalParticleDied(): FerrsignView2<number, number>;
|
|
37
57
|
/** Seed of the random values */
|
|
38
58
|
get seed(): number;
|
|
39
59
|
/** Longest frame step in seconds; longer frames are clamped */
|
|
40
60
|
get maxDeltaTime(): number;
|
|
41
61
|
/** Visibility mode */
|
|
42
62
|
get mode(): UIEmitterMode;
|
|
63
|
+
/** Color blending of the particles with what is drawn under them */
|
|
64
|
+
get blendMode(): UIBlendMode;
|
|
65
|
+
/** Coordinate space of particle positions */
|
|
66
|
+
get space(): UIEmitterSpace;
|
|
43
67
|
/**
|
|
44
68
|
* Rendering order among the elements of the layer. Higher values on top; elements with equal
|
|
45
69
|
* values keep the order of creation, a later one on top.
|
|
46
70
|
*/
|
|
47
71
|
get zIndex(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Layer point particle positions are relative to: the emitter in LOCAL space, where live
|
|
74
|
+
* particles move with it, the layer origin in WORLD space
|
|
75
|
+
*/
|
|
76
|
+
private get originX();
|
|
77
|
+
private get originY();
|
|
48
78
|
/** Visibility mode */
|
|
49
79
|
set mode(value: UIEmitterMode);
|
|
80
|
+
/** Color blending of the particles with what is drawn under them */
|
|
81
|
+
set blendMode(value: UIBlendMode);
|
|
82
|
+
/** Coordinate space of particle positions. Live particles keep their place on the layer. */
|
|
83
|
+
set space(value: UIEmitterSpace);
|
|
50
84
|
/** Longest frame step in seconds; longer frames are clamped */
|
|
51
85
|
set maxDeltaTime(value: number);
|
|
52
86
|
/**
|
|
@@ -66,18 +100,54 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
66
100
|
* @param count - Number of particles to create, a non-negative integer
|
|
67
101
|
*/
|
|
68
102
|
burst(count: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* Spawns particles immediately as if the emitter stood at a point, such as where a particle of
|
|
105
|
+
* another emitter died
|
|
106
|
+
*
|
|
107
|
+
* @param count - Number of particles to create, a non-negative integer
|
|
108
|
+
* @param x - Point in layer coordinates
|
|
109
|
+
* @param y - Point in layer coordinates
|
|
110
|
+
*/
|
|
111
|
+
burstAt(count: number, x: number, y: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* Runs the simulation ahead without drawing, so that an emission started with `play` shows
|
|
114
|
+
* its particles in full from the first frame. The emitter stays where it is meanwhile.
|
|
115
|
+
*
|
|
116
|
+
* @param duration - Seconds to simulate
|
|
117
|
+
* @param step - Simulation step in seconds; the last step is shorter if needed
|
|
118
|
+
*/
|
|
119
|
+
prewarm(duration: number, step?: number): void;
|
|
69
120
|
/** Removes all active particles */
|
|
70
121
|
clear(): void;
|
|
71
122
|
/**
|
|
72
|
-
* Starts
|
|
123
|
+
* Starts particle emission: a stream by time and by distance moved, and bursts. Particles due
|
|
124
|
+
* within a frame are spread over it.
|
|
73
125
|
*
|
|
74
126
|
* @param rate - Particles per second
|
|
75
|
-
* @param options -
|
|
127
|
+
* @param options - Duration, particles per distance and bursts
|
|
76
128
|
*/
|
|
77
129
|
play(rate: number, options?: Partial<UIEmitterPlayOptions>): void;
|
|
78
|
-
/** Stops
|
|
130
|
+
/** Stops particle emission; live particles play out */
|
|
79
131
|
stop(): void;
|
|
80
132
|
/** Frees the particles and the input catcher, optionally destroys modules */
|
|
81
133
|
protected destroyInternal(): void;
|
|
134
|
+
/** Sets the point path to a point at the end of the last frame */
|
|
135
|
+
private setPointPath;
|
|
136
|
+
/**
|
|
137
|
+
* Spawns particles at moments `firstMoment + k * interval` seconds from the start of a frame.
|
|
138
|
+
* Spawn modules write a particle relative to the emitter; it is then placed at the point of the
|
|
139
|
+
* path at its moment and aged by the rest of the frame.
|
|
140
|
+
*/
|
|
141
|
+
private spawnParticles;
|
|
142
|
+
/** Spawns the particles the emission schedule hands out, along the frame path */
|
|
143
|
+
private readonly spawnDue;
|
|
144
|
+
/** Spawns the particles of the emission due within a frame of `deltaTime` seconds */
|
|
145
|
+
private emit;
|
|
146
|
+
/** Removes the dead particles and reports them through the signal */
|
|
147
|
+
private removeDeadParticles;
|
|
148
|
+
/** Records the layer position of a dead particle */
|
|
149
|
+
private readonly collectDeadParticle;
|
|
150
|
+
/** Advances the particles and the emission by `deltaTime` seconds */
|
|
151
|
+
private simulate;
|
|
82
152
|
private readonly onRendering;
|
|
83
153
|
}
|