laymur 0.25.2 → 0.27.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 +114 -34
- package/dist/core/constraints/UICustomConstraint.d.ts +1 -1
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +1 -1
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +1 -1
- package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +2 -3
- package/dist/core/elements/UIAnchor/UIAnchor.d.ts +2 -2
- package/dist/core/elements/UIAnchor/UIAnchor.js +3 -2
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +2 -2
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +24 -12
- package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +13 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +74 -5
- package/dist/core/elements/UIDummy/UIDummy.js +222 -29
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +1 -1
- package/dist/core/elements/UIElement/UIElement.d.ts +37 -1
- package/dist/core/elements/UIElement/UIElement.js +84 -6
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +1 -1
- package/dist/core/elements/UIGraphics/UIGraphics.d.ts +1 -1
- package/dist/core/elements/UIGraphics/UIGraphics.js +4 -4
- package/dist/core/elements/UIImage/UIImage.d.ts +2 -2
- package/dist/core/elements/UIImage/UIImage.js +10 -8
- package/dist/core/elements/UINineSlice/UINineSlice.d.ts +4 -4
- package/dist/core/elements/UINineSlice/UINineSlice.js +11 -9
- package/dist/core/elements/UIProgress/UIProgress.d.ts +2 -2
- package/dist/core/elements/UIProgress/UIProgress.js +17 -15
- package/dist/core/elements/UIScene/UIScene.Internal.d.ts +1 -1
- package/dist/core/elements/UIScene/UIScene.d.ts +3 -2
- package/dist/core/elements/UIScene/UIScene.js +21 -14
- package/dist/core/elements/UIText/UIText.Measuring.d.ts +1 -1
- package/dist/core/elements/UIText/UIText.d.ts +3 -3
- package/dist/core/elements/UIText/UIText.js +8 -8
- package/dist/core/index.d.ts +60 -11
- package/dist/core/index.js +22 -7
- package/dist/core/layers/UILayer/UILayer.d.ts +45 -5
- package/dist/core/layers/UILayer/UILayer.js +103 -10
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.Internal.d.ts +27 -0
- package/dist/core/layers/{UIFullscreenLayer/UIFullscreenLayer.Internal.js → UIViewportLayer/UIViewportLayer.Internal.js} +1 -1
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.d.ts +98 -0
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +251 -0
- package/dist/core/miscellaneous/UIAffineMatrix3.d.ts +13 -0
- package/dist/core/miscellaneous/UIAffineMatrix3.js +13 -0
- package/dist/core/miscellaneous/area/UIArea.d.ts +10 -1
- package/dist/core/miscellaneous/area/UIArea.js +4 -1
- package/dist/core/miscellaneous/area/UIAreaCircle.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +0 -1
- package/dist/core/miscellaneous/area/UIAreaPolygon.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +0 -1
- package/dist/core/miscellaneous/area/UIAreaRectangle.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +0 -1
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.d.ts +1 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +0 -1
- package/dist/core/miscellaneous/asserts.d.ts +23 -0
- package/dist/core/miscellaneous/asserts.js +44 -0
- package/dist/core/miscellaneous/canvas.js +7 -2
- package/dist/core/miscellaneous/color/UIColor.js +5 -2
- package/dist/core/miscellaneous/computeTransform.d.ts +12 -0
- package/dist/core/miscellaneous/computeTransform.js +20 -0
- package/dist/core/miscellaneous/context-monitor/UIContextMonitor.d.ts +1 -0
- package/dist/core/miscellaneous/context-monitor/UIContextMonitor.js +60 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +17 -3
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +88 -26
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.d.ts +9 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.js +29 -6
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +51 -11
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +2 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +47 -6
- package/dist/core/miscellaneous/generic-plane/shared.d.ts +15 -3
- package/dist/core/miscellaneous/generic-plane/shared.js +38 -7
- package/dist/core/miscellaneous/generic-plane/varyingPacking.d.ts +46 -0
- package/dist/core/miscellaneous/generic-plane/varyingPacking.js +170 -0
- package/dist/core/miscellaneous/mask/UIMask.Internal.d.ts +61 -0
- package/dist/core/miscellaneous/mask/UIMask.Internal.js +56 -0
- package/dist/core/miscellaneous/mask/UIMask.d.ts +84 -0
- package/dist/core/miscellaneous/mask/UIMask.js +265 -0
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.d.ts +50 -0
- package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +233 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +10 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +7 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +2 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +0 -1
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +2 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +0 -1
- package/dist/core/miscellaneous/micro/UIMicro.Internal.d.ts +3 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +1 -0
- package/dist/core/miscellaneous/micro/UIMicro.d.ts +18 -1
- package/dist/core/miscellaneous/micro/UIMicro.js +23 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +19 -1
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +16 -3
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +2 -2
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +2 -2
- package/dist/core/miscellaneous/text-style/UITextStyle.js +2 -2
- package/dist/core/miscellaneous/texture/UITextureView.d.ts +6 -2
- package/dist/core/miscellaneous/texture/UITextureView.js +13 -9
- package/dist/core/miscellaneous/viewport/UIElementViewport.d.ts +31 -0
- package/dist/core/miscellaneous/viewport/UIElementViewport.js +54 -0
- package/dist/core/miscellaneous/viewport/UIViewport.d.ts +37 -0
- package/dist/core/miscellaneous/viewport/UIViewport.js +31 -0
- package/dist/core/miscellaneous/viewport/UIWindowViewport.d.ts +13 -0
- package/dist/core/miscellaneous/viewport/UIWindowViewport.js +25 -0
- package/dist/core/miscellaneous/webglCapabilities.js +61 -55
- package/dist/core/shaders/UIMask.d.ts +15 -0
- package/dist/core/shaders/UIMask.js +45 -0
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +36 -5
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +23 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +153 -15
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +3 -1
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +1 -0
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +3 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +2 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +3 -0
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +36 -16
- package/dist/debug/UIAspectDebug.js +4 -0
- package/dist/debug/UIHeightDebug.js +4 -0
- package/dist/debug/UIHorizontalDistanceDebug.js +5 -0
- package/dist/debug/UIHorizontalInterpolationDebug.js +5 -0
- package/dist/debug/UILayerDebug.d.ts +7 -0
- package/dist/debug/UILayerDebug.js +21 -0
- package/dist/debug/UIVerticalDistanceDebug.js +5 -0
- package/dist/debug/UIVerticalInterpolationDebug.js +5 -0
- package/dist/debug/UIWidthDebug.js +4 -0
- package/dist/debug/index.d.ts +2 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +8 -1
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +0 -2
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +12 -2
- package/dist/particles/behaviorModules/UIBehaviorModule.js +2 -1
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +8 -1
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +13 -12
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +6 -6
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +4 -5
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +8 -1
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +8 -10
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +10 -2
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +8 -7
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +7 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +8 -10
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +13 -4
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +12 -10
- package/dist/particles/elements/UIEmitter.Internal.d.ts +21 -1
- package/dist/particles/elements/UIEmitter.Internal.js +6 -0
- package/dist/particles/elements/UIEmitter.d.ts +20 -11
- package/dist/particles/elements/UIEmitter.js +100 -54
- package/dist/particles/index.d.ts +7 -1
- package/dist/particles/index.js +4 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +19 -4
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +117 -83
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +8 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +41 -4
- package/dist/particles/miscellaneous/miscellaneous.d.ts +34 -0
- package/dist/particles/miscellaneous/miscellaneous.js +72 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +2 -4
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +2 -5
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +11 -1
- package/dist/particles/renderingModules/UIRenderingModule.js +4 -1
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +4 -0
- package/dist/particles/renderingModules/UIRenderingTexture.js +2 -1
- package/dist/particles/shaders/UIRenderingColorOverLife.d.ts +1 -2
- package/dist/particles/shaders/UIRenderingColorOverLife.js +5 -3
- package/dist/particles/shaders/UIRenderingColorOverVelocity.d.ts +1 -9
- package/dist/particles/shaders/UIRenderingColorOverVelocity.js +6 -13
- package/dist/particles/spawnModules/UISpawnModule.d.ts +16 -1
- package/dist/particles/spawnModules/UISpawnModule.js +3 -1
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnOffset.js +0 -2
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +8 -1
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +5 -7
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +5 -5
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +4 -5
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +5 -5
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +6 -6
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +7 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +6 -6
- package/package.json +13 -4
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -21
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +0 -144
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
import { UIMode } from "../../core/index.js";
|
|
2
1
|
import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal.js";
|
|
2
|
+
import { UIMode } from "../../core/index.js";
|
|
3
|
+
/** Configuration options for UIEmitter */
|
|
3
4
|
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
5
|
+
/** Whether the particles are drawn */
|
|
6
|
+
mode: UIEmitterMode;
|
|
7
|
+
/** Number of particles to allocate for up front; a hint, not a limit */
|
|
4
8
|
expectedCapacity: number;
|
|
9
|
+
/** Capacity is kept a multiple of this; the buffers double when they grow */
|
|
5
10
|
capacityStep: number;
|
|
11
|
+
/** Longest frame step in seconds; longer frames, such as after a hidden tab, are clamped */
|
|
12
|
+
maxDeltaTime: number;
|
|
13
|
+
/**
|
|
14
|
+
* Seed of the random values, a non-negative integer. Emitters with one seed and one sequence
|
|
15
|
+
* of spawns produce the same particles. Random by default.
|
|
16
|
+
*/
|
|
17
|
+
seed: number;
|
|
18
|
+
/** Whether to call destroy() on all modules when the emitter is destroyed */
|
|
19
|
+
automaticallyDestroyModules: boolean;
|
|
6
20
|
}
|
|
7
21
|
export interface UIEmitterPlayOptions {
|
|
8
22
|
duration: number;
|
|
@@ -12,4 +26,10 @@ export type UIEmitterMode = UIMode.HIDDEN | UIMode.VISIBLE;
|
|
|
12
26
|
export declare const EMITTER_DEFAULT_MODE: UIEmitterMode;
|
|
13
27
|
export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
14
28
|
export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
29
|
+
export declare const EMITTER_DEFAULT_MAX_DELTA_TIME = 0.1;
|
|
30
|
+
export declare const EMITTER_DEFAULT_LIFETIME = 1;
|
|
15
31
|
export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
32
|
+
/** Salts the emitter hands out: one for the builtin values the shaders read, one per module */
|
|
33
|
+
export declare const EMITTER_SHADER_SALT = 0;
|
|
34
|
+
export declare const EMITTER_SPAWN_SALT_BASE = 256;
|
|
35
|
+
export declare const EMITTER_BEHAVIOR_SALT_BASE = 512;
|
|
@@ -5,4 +5,10 @@ export function ignoreInput() {
|
|
|
5
5
|
export const EMITTER_DEFAULT_MODE = UIMode.VISIBLE;
|
|
6
6
|
export const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
|
|
7
7
|
export const EMITTER_DEFAULT_CAPACITY_STEP = 32;
|
|
8
|
+
export const EMITTER_DEFAULT_MAX_DELTA_TIME = 0.1;
|
|
9
|
+
export const EMITTER_DEFAULT_LIFETIME = 1;
|
|
8
10
|
export const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
|
|
11
|
+
/** Salts the emitter hands out: one for the builtin values the shaders read, one per module */
|
|
12
|
+
export const EMITTER_SHADER_SALT = 0;
|
|
13
|
+
export const EMITTER_SPAWN_SALT_BASE = 0x100;
|
|
14
|
+
export const EMITTER_BEHAVIOR_SALT_BASE = 0x200;
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import type { UILayer } from "../../core/index.js";
|
|
2
1
|
import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor.js";
|
|
3
|
-
import type {
|
|
2
|
+
import type { UILayer } from "../../core/index.js";
|
|
4
3
|
import type { UIBehaviorModule } from "../behaviorModules/UIBehaviorModule.js";
|
|
5
4
|
import type { UIRenderingModule } from "../renderingModules/UIRenderingModule.js";
|
|
6
5
|
import type { UISpawnModule } from "../spawnModules/UISpawnModule.js";
|
|
7
|
-
import type { UIEmitterMode, UIEmitterPlayOptions } from "./UIEmitter.Internal.js";
|
|
8
|
-
export interface UIEmitterOptions extends UIAnchorOptions {
|
|
9
|
-
mode: UIEmitterMode;
|
|
10
|
-
expectedCapacity: number;
|
|
11
|
-
capacityStep: number;
|
|
12
|
-
automaticallyDestroyModules: boolean;
|
|
13
|
-
}
|
|
6
|
+
import type { UIEmitterMode, UIEmitterOptions, UIEmitterPlayOptions } from "./UIEmitter.Internal.js";
|
|
14
7
|
/**
|
|
15
8
|
* Particle emitter element.
|
|
16
9
|
*
|
|
@@ -29,6 +22,10 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
29
22
|
private emissionDuration;
|
|
30
23
|
private emissionElapsed;
|
|
31
24
|
private modeInternal;
|
|
25
|
+
private maxDeltaTimeInternal;
|
|
26
|
+
private seedInternal;
|
|
27
|
+
/** Particles spawned since the seed was set; picks the seed of the next particle */
|
|
28
|
+
private spawnedCount;
|
|
32
29
|
/**
|
|
33
30
|
* @param layer - Layer containing this emitter
|
|
34
31
|
* @param spawnSequence - Modules that initialize new particles
|
|
@@ -37,6 +34,10 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
37
34
|
* @param options - Configuration options
|
|
38
35
|
*/
|
|
39
36
|
constructor(layer: UILayer, spawnSequence: UISpawnModule[], behaviorSequence: readonly UIBehaviorModule[], renderingSequence: readonly UIRenderingModule[], options?: Partial<UIEmitterOptions>);
|
|
37
|
+
/** Seed of the random values */
|
|
38
|
+
get seed(): number;
|
|
39
|
+
/** Longest frame step in seconds; longer frames are clamped */
|
|
40
|
+
get maxDeltaTime(): number;
|
|
40
41
|
/** Visibility mode */
|
|
41
42
|
get mode(): UIEmitterMode;
|
|
42
43
|
/**
|
|
@@ -46,15 +47,23 @@ export declare class UIEmitter extends UIAnchor {
|
|
|
46
47
|
get zIndex(): number;
|
|
47
48
|
/** Visibility mode */
|
|
48
49
|
set mode(value: UIEmitterMode);
|
|
50
|
+
/** Longest frame step in seconds; longer frames are clamped */
|
|
51
|
+
set maxDeltaTime(value: number);
|
|
52
|
+
/**
|
|
53
|
+
* Sets the seed and restarts its sequence: the next particles repeat those spawned after the
|
|
54
|
+
* same seed was set before
|
|
55
|
+
*/
|
|
56
|
+
set seed(value: number);
|
|
49
57
|
/**
|
|
50
58
|
* Rendering order among the elements of the layer. Higher values on top; elements with equal
|
|
51
59
|
* values keep the order of creation, a later one on top.
|
|
52
60
|
*/
|
|
53
61
|
set zIndex(value: number);
|
|
54
62
|
/**
|
|
55
|
-
* Spawns a specific number of particles immediately.
|
|
63
|
+
* Spawns a specific number of particles immediately. Before the spawn modules run, every
|
|
64
|
+
* property of a new particle is 0, except scale 1 and lifetime 1 second.
|
|
56
65
|
*
|
|
57
|
-
* @param count - Number of particles to create
|
|
66
|
+
* @param count - Number of particles to create, a non-negative integer
|
|
58
67
|
*/
|
|
59
68
|
burst(count: number): void;
|
|
60
69
|
/** Removes all active particles */
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { Vector2 } from "three";
|
|
2
2
|
import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor.js";
|
|
3
|
-
import { assertValidNumber } from "../../core/miscellaneous/asserts.js";
|
|
3
|
+
import { assertValidNumber, assertValidPositiveNumber } from "../../core/miscellaneous/asserts.js";
|
|
4
4
|
import { resolveGLSLTypeInfo } from "../../core/miscellaneous/generic-plane/shared.js";
|
|
5
5
|
import { isUIModeVisible } from "../../core/miscellaneous/UIMode.js";
|
|
6
|
+
import { collectProperties, collectRenderingUniforms, } from "../instancedParticle/UIInstancedParticle.Internal.js";
|
|
6
7
|
import { UIInstancedParticle } from "../instancedParticle/UIInstancedParticle.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { assertValidNonNegativeInteger, BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_D, BUILTIN_OFFSET_RANDOM_E, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, computeParticleSeed, particleRandom, particleRandomStream, writeParticleSeed, } from "../miscellaneous/miscellaneous.js";
|
|
9
|
+
import { EMITTER_BEHAVIOR_SALT_BASE, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_LIFETIME, EMITTER_DEFAULT_MAX_DELTA_TIME, EMITTER_DEFAULT_MODE, EMITTER_SHADER_SALT, EMITTER_SPAWN_SALT_BASE, ignoreInput, } from "./UIEmitter.Internal.js";
|
|
10
|
+
/** Builtin slots of the random values the shaders read, each with its stream */
|
|
11
|
+
const SHADER_RANDOM_SLOTS = [
|
|
12
|
+
BUILTIN_OFFSET_RANDOM_A,
|
|
13
|
+
BUILTIN_OFFSET_RANDOM_B,
|
|
14
|
+
BUILTIN_OFFSET_RANDOM_C,
|
|
15
|
+
BUILTIN_OFFSET_RANDOM_D,
|
|
16
|
+
BUILTIN_OFFSET_RANDOM_E,
|
|
17
|
+
].map((offset, channel) => ({
|
|
18
|
+
offset,
|
|
19
|
+
stream: particleRandomStream(EMITTER_SHADER_SALT, channel),
|
|
20
|
+
}));
|
|
10
21
|
/**
|
|
11
22
|
* Particle emitter element.
|
|
12
23
|
*
|
|
@@ -29,30 +40,31 @@ export class UIEmitter extends UIAnchor {
|
|
|
29
40
|
this.emissionAccumulator = 0;
|
|
30
41
|
this.emissionDuration = Infinity;
|
|
31
42
|
this.emissionElapsed = 0;
|
|
32
|
-
|
|
43
|
+
/** Particles spawned since the seed was set; picks the seed of the next particle */
|
|
44
|
+
this.spawnedCount = 0;
|
|
45
|
+
this.onRendering = (renderer, rawDeltaTime) => {
|
|
33
46
|
this.layer.sceneWrapper.setOrderedObjectDepth(this.mesh, this.layer.inputWrapper.getDepth(this.catcherHandler));
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const { array, itemSize } = builtin;
|
|
47
|
+
const deltaTime = Math.min(rawDeltaTime, this.maxDeltaTimeInternal);
|
|
48
|
+
if (this.mesh.instanceCount > 0) {
|
|
49
|
+
const { array, itemSize } = this.mesh.propertyBuffers.builtin;
|
|
37
50
|
for (let i = 0; i < this.mesh.instanceCount; i++) {
|
|
38
51
|
array[i * itemSize + BUILTIN_OFFSET_AGE] += deltaTime;
|
|
39
52
|
}
|
|
40
|
-
builtin.needsUpdate = true;
|
|
41
53
|
this.mesh.removeDeadParticles();
|
|
42
54
|
}
|
|
43
55
|
if (this.emissionRate > 0) {
|
|
56
|
+
const emittedBefore = this.emissionElapsed;
|
|
44
57
|
this.emissionElapsed += deltaTime;
|
|
58
|
+
this.emissionAccumulator +=
|
|
59
|
+
this.emissionRate * (Math.min(this.emissionElapsed, this.emissionDuration) - emittedBefore);
|
|
60
|
+
const particlesToSpawn = Math.floor(this.emissionAccumulator);
|
|
61
|
+
if (particlesToSpawn > 0) {
|
|
62
|
+
this.burst(particlesToSpawn);
|
|
63
|
+
this.emissionAccumulator -= particlesToSpawn;
|
|
64
|
+
}
|
|
45
65
|
if (this.emissionElapsed >= this.emissionDuration) {
|
|
46
66
|
this.stop();
|
|
47
67
|
}
|
|
48
|
-
else {
|
|
49
|
-
this.emissionAccumulator += this.emissionRate * deltaTime;
|
|
50
|
-
const particlesToSpawn = Math.floor(this.emissionAccumulator);
|
|
51
|
-
if (particlesToSpawn > 0) {
|
|
52
|
-
this.burst(particlesToSpawn);
|
|
53
|
-
this.emissionAccumulator -= particlesToSpawn;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
68
|
}
|
|
57
69
|
if (this.mesh.instanceCount === 0) {
|
|
58
70
|
return;
|
|
@@ -60,30 +72,23 @@ export class UIEmitter extends UIAnchor {
|
|
|
60
72
|
this.mesh.setOrigin(this.x, this.y);
|
|
61
73
|
{
|
|
62
74
|
const { propertyBuffers, instanceCount } = this.mesh;
|
|
63
|
-
for (
|
|
64
|
-
|
|
75
|
+
for (let index = 0; index < this.behaviorSequence.length; index++) {
|
|
76
|
+
this.behaviorSequence[index].update(propertyBuffers, instanceCount, deltaTime, EMITTER_BEHAVIOR_SALT_BASE + index);
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
79
|
const { builtin } = this.mesh.propertyBuffers;
|
|
68
80
|
const { array, itemSize } = builtin;
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
array[itemOffset +
|
|
73
|
-
|
|
74
|
-
array[itemOffset +
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
builtin.needsUpdate = true;
|
|
78
|
-
}
|
|
79
|
-
{
|
|
80
|
-
for (let i = 0; i < this.mesh.instanceCount; i++) {
|
|
81
|
-
const itemOffset = i * itemSize;
|
|
82
|
-
array[itemOffset + BUILTIN_OFFSET_ROTATION] +=
|
|
83
|
-
array[itemOffset + BUILTIN_OFFSET_TORQUE] * deltaTime;
|
|
84
|
-
}
|
|
85
|
-
builtin.needsUpdate = true;
|
|
81
|
+
for (let i = 0; i < this.mesh.instanceCount; i++) {
|
|
82
|
+
const itemOffset = i * itemSize;
|
|
83
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_X] +=
|
|
84
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] * deltaTime;
|
|
85
|
+
array[itemOffset + BUILTIN_OFFSET_POSITION_Y] +=
|
|
86
|
+
array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] * deltaTime;
|
|
87
|
+
array[itemOffset + BUILTIN_OFFSET_ROTATION] +=
|
|
88
|
+
array[itemOffset + BUILTIN_OFFSET_TORQUE] * deltaTime;
|
|
86
89
|
}
|
|
90
|
+
builtin.needsUpdate = true;
|
|
91
|
+
this.mesh.limitUploadToLiveInstances();
|
|
87
92
|
};
|
|
88
93
|
const collectedProperties = {
|
|
89
94
|
builtin: resolveGLSLTypeInfo("Matrix4"),
|
|
@@ -92,8 +97,8 @@ export class UIEmitter extends UIAnchor {
|
|
|
92
97
|
// 4, 5 scaleX, scaleY
|
|
93
98
|
// 6, 7 rotation, torque
|
|
94
99
|
// 8, 9 lifetime, age
|
|
95
|
-
// 10
|
|
96
|
-
//
|
|
100
|
+
// 10-14 random values A-E for shaders
|
|
101
|
+
// 15 seed, read by shaders as random value F
|
|
97
102
|
};
|
|
98
103
|
collectProperties(collectedProperties, spawnSequence, "UIEmitter.constructor.spawnSequence");
|
|
99
104
|
collectProperties(collectedProperties, behaviorSequence, "UIEmitter.constructor.behaviorSequence");
|
|
@@ -101,15 +106,33 @@ export class UIEmitter extends UIAnchor {
|
|
|
101
106
|
const collectedUniforms = {
|
|
102
107
|
origin: { value: new Vector2(), glslTypeInfo: resolveGLSLTypeInfo("Vector2") },
|
|
103
108
|
};
|
|
104
|
-
|
|
109
|
+
const renderingSources = collectRenderingUniforms(collectedUniforms, renderingSequence, "UIEmitter.constructor.renderingSequence");
|
|
105
110
|
const zIndex = 0;
|
|
106
|
-
this.catcherHandler = this.layer.inputWrapper.createInputCatcher(
|
|
107
|
-
|
|
111
|
+
this.catcherHandler = this.layer.inputWrapper.createInputCatcher({
|
|
112
|
+
catchPointerDown: ignoreInput,
|
|
113
|
+
catchPointerMove: ignoreInput,
|
|
114
|
+
catchPointerUp: ignoreInput,
|
|
115
|
+
catchPointerCancel: ignoreInput,
|
|
116
|
+
}, zIndex);
|
|
117
|
+
this.mesh = new UIInstancedParticle(renderingSources, collectedUniforms, collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP);
|
|
108
118
|
this.layer.signalRendering.on(this.onRendering);
|
|
109
119
|
this.layer.sceneWrapper.insertOrderedObject(this.mesh, this.layer.inputWrapper.getDepth(this.catcherHandler));
|
|
110
120
|
this.automaticallyDestroyModules =
|
|
111
121
|
options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
|
|
112
122
|
this.modeInternal = options.mode ?? EMITTER_DEFAULT_MODE;
|
|
123
|
+
this.mesh.visible = isUIModeVisible(this.modeInternal);
|
|
124
|
+
this.maxDeltaTimeInternal = options.maxDeltaTime ?? EMITTER_DEFAULT_MAX_DELTA_TIME;
|
|
125
|
+
assertValidPositiveNumber(this.maxDeltaTimeInternal, "UIEmitter.constructor.maxDeltaTime");
|
|
126
|
+
this.seedInternal = options.seed ?? Math.floor(Math.random() * 0x100000000);
|
|
127
|
+
assertValidNonNegativeInteger(this.seedInternal, "UIEmitter.constructor.seed");
|
|
128
|
+
}
|
|
129
|
+
/** Seed of the random values */
|
|
130
|
+
get seed() {
|
|
131
|
+
return this.seedInternal;
|
|
132
|
+
}
|
|
133
|
+
/** Longest frame step in seconds; longer frames are clamped */
|
|
134
|
+
get maxDeltaTime() {
|
|
135
|
+
return this.maxDeltaTimeInternal;
|
|
113
136
|
}
|
|
114
137
|
/** Visibility mode */
|
|
115
138
|
get mode() {
|
|
@@ -130,6 +153,22 @@ export class UIEmitter extends UIAnchor {
|
|
|
130
153
|
this.mesh.visible = isUIModeVisible(value);
|
|
131
154
|
}
|
|
132
155
|
}
|
|
156
|
+
/** Longest frame step in seconds; longer frames are clamped */
|
|
157
|
+
set maxDeltaTime(value) {
|
|
158
|
+
this.assertNotDestroyed("UIEmitter.maxDeltaTime");
|
|
159
|
+
assertValidPositiveNumber(value, "UIEmitter.maxDeltaTime");
|
|
160
|
+
this.maxDeltaTimeInternal = value;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Sets the seed and restarts its sequence: the next particles repeat those spawned after the
|
|
164
|
+
* same seed was set before
|
|
165
|
+
*/
|
|
166
|
+
set seed(value) {
|
|
167
|
+
this.assertNotDestroyed("UIEmitter.seed");
|
|
168
|
+
assertValidNonNegativeInteger(value, "UIEmitter.seed");
|
|
169
|
+
this.seedInternal = value;
|
|
170
|
+
this.spawnedCount = 0;
|
|
171
|
+
}
|
|
133
172
|
/**
|
|
134
173
|
* Rendering order among the elements of the layer. Higher values on top; elements with equal
|
|
135
174
|
* values keep the order of creation, a later one on top.
|
|
@@ -140,32 +179,39 @@ export class UIEmitter extends UIAnchor {
|
|
|
140
179
|
this.layer.inputWrapper.setZIndex(this.catcherHandler, value);
|
|
141
180
|
}
|
|
142
181
|
/**
|
|
143
|
-
* Spawns a specific number of particles immediately.
|
|
182
|
+
* Spawns a specific number of particles immediately. Before the spawn modules run, every
|
|
183
|
+
* property of a new particle is 0, except scale 1 and lifetime 1 second.
|
|
144
184
|
*
|
|
145
|
-
* @param count - Number of particles to create
|
|
185
|
+
* @param count - Number of particles to create, a non-negative integer
|
|
146
186
|
*/
|
|
147
187
|
burst(count) {
|
|
148
188
|
this.assertNotDestroyed("UIEmitter.burst");
|
|
189
|
+
assertValidNonNegativeInteger(count, "UIEmitter.burst.count");
|
|
190
|
+
if (count === 0) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
149
193
|
const instanceBegin = this.mesh.instanceCount;
|
|
150
194
|
this.mesh.createInstances(count);
|
|
151
195
|
const instanceEnd = this.mesh.instanceCount;
|
|
196
|
+
// A slot may hold a dead particle's values.
|
|
197
|
+
this.mesh.resetInstances(instanceBegin, instanceEnd);
|
|
152
198
|
{
|
|
153
|
-
const {
|
|
154
|
-
const { array, itemSize } = builtin;
|
|
199
|
+
const { array, itemSize } = this.mesh.propertyBuffers.builtin;
|
|
155
200
|
for (let i = instanceBegin; i < instanceEnd; i++) {
|
|
156
201
|
const itemOffset = i * itemSize;
|
|
157
|
-
array[itemOffset +
|
|
158
|
-
array[itemOffset +
|
|
159
|
-
array[itemOffset +
|
|
160
|
-
array
|
|
161
|
-
|
|
162
|
-
|
|
202
|
+
array[itemOffset + BUILTIN_OFFSET_SCALE_X] = 1;
|
|
203
|
+
array[itemOffset + BUILTIN_OFFSET_SCALE_Y] = 1;
|
|
204
|
+
array[itemOffset + BUILTIN_OFFSET_LIFETIME] = EMITTER_DEFAULT_LIFETIME;
|
|
205
|
+
writeParticleSeed(array, itemOffset, computeParticleSeed(this.seedInternal, this.spawnedCount++));
|
|
206
|
+
for (const { offset, stream } of SHADER_RANDOM_SLOTS) {
|
|
207
|
+
array[itemOffset + offset] = particleRandom(array, itemOffset, stream);
|
|
208
|
+
}
|
|
163
209
|
}
|
|
164
|
-
builtin.needsUpdate = true;
|
|
165
210
|
}
|
|
166
|
-
for (
|
|
167
|
-
|
|
211
|
+
for (let index = 0; index < this.spawnSequence.length; index++) {
|
|
212
|
+
this.spawnSequence[index].spawn(this.mesh.propertyBuffers, instanceBegin, instanceEnd, EMITTER_SPAWN_SALT_BASE + index);
|
|
168
213
|
}
|
|
214
|
+
this.mesh.limitUploadToLiveInstances();
|
|
169
215
|
}
|
|
170
216
|
/** Removes all active particles */
|
|
171
217
|
clear() {
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
export { UIBehaviorDirectionalGravity } from "./behaviorModules/UIBehaviorDirectionalGravity.js";
|
|
2
|
+
export { UIBehaviorModule } from "./behaviorModules/UIBehaviorModule.js";
|
|
2
3
|
export { UIBehaviorPointGravity } from "./behaviorModules/UIBehaviorPointGravity.js";
|
|
3
|
-
export { UIBehaviorScaleOscillation } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
4
4
|
export type { UIScaleOscillationAxis } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
5
|
+
export { UIBehaviorScaleOscillation } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
5
6
|
export { UIBehaviorScaleOverLife } from "./behaviorModules/UIBehaviorScaleOverLife.js";
|
|
6
7
|
export { UIBehaviorTorqueDamping } from "./behaviorModules/UIBehaviorTorqueDamping.js";
|
|
7
8
|
export { UIBehaviorTorqueNoise } from "./behaviorModules/UIBehaviorTorqueNoise.js";
|
|
8
9
|
export { UIBehaviorVelocityDamping } from "./behaviorModules/UIBehaviorVelocityDamping.js";
|
|
9
10
|
export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoise.js";
|
|
11
|
+
export type { UIEmitterMode, UIEmitterOptions, UIEmitterPlayOptions, } from "./elements/UIEmitter.Internal.js";
|
|
10
12
|
export { UIEmitter } from "./elements/UIEmitter.js";
|
|
13
|
+
export type { UIAspectConfig, UIRange, UIRangeConfig, UIVector2Config, } from "./miscellaneous/miscellaneous.js";
|
|
14
|
+
export { particleRandom, particleRandomStream } from "./miscellaneous/miscellaneous.js";
|
|
11
15
|
export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife.js";
|
|
12
16
|
export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity.js";
|
|
17
|
+
export { UIRenderingModule } from "./renderingModules/UIRenderingModule.js";
|
|
13
18
|
export { UIRenderingTexture } from "./renderingModules/UIRenderingTexture.js";
|
|
19
|
+
export { UISpawnModule } from "./spawnModules/UISpawnModule.js";
|
|
14
20
|
export { UISpawnOffset } from "./spawnModules/UISpawnOffset.js";
|
|
15
21
|
export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime.js";
|
|
16
22
|
export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation.js";
|
package/dist/particles/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { UIBehaviorDirectionalGravity } from "./behaviorModules/UIBehaviorDirectionalGravity.js";
|
|
2
|
+
export { UIBehaviorModule } from "./behaviorModules/UIBehaviorModule.js";
|
|
2
3
|
export { UIBehaviorPointGravity } from "./behaviorModules/UIBehaviorPointGravity.js";
|
|
3
4
|
export { UIBehaviorScaleOscillation } from "./behaviorModules/UIBehaviorScaleOscillation.js";
|
|
4
5
|
export { UIBehaviorScaleOverLife } from "./behaviorModules/UIBehaviorScaleOverLife.js";
|
|
@@ -7,9 +8,12 @@ export { UIBehaviorTorqueNoise } from "./behaviorModules/UIBehaviorTorqueNoise.j
|
|
|
7
8
|
export { UIBehaviorVelocityDamping } from "./behaviorModules/UIBehaviorVelocityDamping.js";
|
|
8
9
|
export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoise.js";
|
|
9
10
|
export { UIEmitter } from "./elements/UIEmitter.js";
|
|
11
|
+
export { particleRandom, particleRandomStream } from "./miscellaneous/miscellaneous.js";
|
|
10
12
|
export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife.js";
|
|
11
13
|
export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity.js";
|
|
14
|
+
export { UIRenderingModule } from "./renderingModules/UIRenderingModule.js";
|
|
12
15
|
export { UIRenderingTexture } from "./renderingModules/UIRenderingTexture.js";
|
|
16
|
+
export { UISpawnModule } from "./spawnModules/UISpawnModule.js";
|
|
13
17
|
export { UISpawnOffset } from "./spawnModules/UISpawnOffset.js";
|
|
14
18
|
export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime.js";
|
|
15
19
|
export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation.js";
|
|
@@ -4,9 +4,24 @@ export declare const INSTANCED_PARTICLE_GEOMETRY: InstancedBufferGeometry;
|
|
|
4
4
|
export declare function collectProperties(keeper: Record<string, GLTypeInfo>, modules: readonly {
|
|
5
5
|
requiredProperties?: Record<string, UIPropertyName>;
|
|
6
6
|
}[], debugContext: string): void;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Collects the uniforms of rendering modules under per-module names, `p_<name>` of module i
|
|
9
|
+
* becoming `p_m<i>_<name>`, so modules of one type keep their own values.
|
|
10
|
+
* @returns Sources with their uniform references renamed accordingly
|
|
11
|
+
*/
|
|
12
|
+
export declare function collectRenderingUniforms(keeper: Record<string, GLProperty>, modules: readonly {
|
|
8
13
|
requiredUniforms: Record<string, UIProperty>;
|
|
9
|
-
|
|
14
|
+
source: string;
|
|
15
|
+
}[], debugContext: string): string[];
|
|
10
16
|
export declare function buildParticleVertexShader(uniformDeclarations: string[], attributeDeclarations: string[], varyingDeclarations: string[], vertexAssignments: string[]): string;
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Builds the fragment shader of a particle mesh. Sources read particle values through the
|
|
19
|
+
* PARTICLE_* macros and properties as p_* globals, all filled from packed varyings.
|
|
20
|
+
* @param fieldDeclarations Packed varyings, p_* globals and PARTICLE_* macros
|
|
21
|
+
* @param fieldAssignments Statements filling the p_* globals at the start of main
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildParticleFragmentShader(uniformDeclarations: string[], fieldDeclarations: string[], fieldAssignments: string[], sources: string[]): string;
|
|
24
|
+
export declare function buildParticleMaterial(sources: string[], uniformProperties: Record<string, GLProperty>, varyingProperties: Record<string, GLTypeInfo>): {
|
|
25
|
+
material: ShaderMaterial;
|
|
26
|
+
varyingRowCount: number;
|
|
27
|
+
};
|