laymur 0.25.2 → 0.26.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.
Files changed (118) hide show
  1. package/README.md +41 -5
  2. package/dist/core/elements/UIAnchor/UIAnchor.d.ts +2 -2
  3. package/dist/core/elements/UIAnchor/UIAnchor.js +3 -2
  4. package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +3 -0
  5. package/dist/core/elements/UIDummy/UIDummy.d.ts +32 -0
  6. package/dist/core/elements/UIDummy/UIDummy.js +101 -2
  7. package/dist/core/elements/UIElement/UIElement.d.ts +23 -1
  8. package/dist/core/elements/UIElement/UIElement.js +50 -3
  9. package/dist/core/elements/UIGraphics/UIGraphics.js +2 -2
  10. package/dist/core/elements/UIProgress/UIProgress.js +2 -5
  11. package/dist/core/elements/UIScene/UIScene.js +3 -2
  12. package/dist/core/elements/UIText/UIText.js +2 -2
  13. package/dist/core/index.d.ts +48 -2
  14. package/dist/core/index.js +13 -1
  15. package/dist/core/layers/UILayer/UILayer.d.ts +5 -1
  16. package/dist/core/layers/UILayer/UILayer.js +33 -1
  17. package/dist/core/miscellaneous/UIAffineMatrix3.d.ts +13 -0
  18. package/dist/core/miscellaneous/UIAffineMatrix3.js +13 -0
  19. package/dist/core/miscellaneous/area/UIArea.d.ts +10 -1
  20. package/dist/core/miscellaneous/area/UIArea.js +4 -1
  21. package/dist/core/miscellaneous/area/UIAreaCircle.d.ts +1 -0
  22. package/dist/core/miscellaneous/area/UIAreaCircle.js +0 -1
  23. package/dist/core/miscellaneous/area/UIAreaPolygon.d.ts +1 -0
  24. package/dist/core/miscellaneous/area/UIAreaPolygon.js +0 -1
  25. package/dist/core/miscellaneous/area/UIAreaRectangle.d.ts +1 -0
  26. package/dist/core/miscellaneous/area/UIAreaRectangle.js +0 -1
  27. package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.d.ts +1 -0
  28. package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +0 -1
  29. package/dist/core/miscellaneous/asserts.d.ts +9 -0
  30. package/dist/core/miscellaneous/asserts.js +16 -0
  31. package/dist/core/miscellaneous/color/UIColor.js +1 -0
  32. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +17 -3
  33. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +88 -26
  34. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.d.ts +9 -0
  35. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.js +29 -6
  36. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +51 -11
  37. package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +2 -0
  38. package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +47 -6
  39. package/dist/core/miscellaneous/generic-plane/shared.d.ts +15 -3
  40. package/dist/core/miscellaneous/generic-plane/shared.js +38 -7
  41. package/dist/core/miscellaneous/generic-plane/varyingPacking.d.ts +46 -0
  42. package/dist/core/miscellaneous/generic-plane/varyingPacking.js +170 -0
  43. package/dist/core/miscellaneous/mask/UIMask.Internal.d.ts +61 -0
  44. package/dist/core/miscellaneous/mask/UIMask.Internal.js +56 -0
  45. package/dist/core/miscellaneous/mask/UIMask.d.ts +84 -0
  46. package/dist/core/miscellaneous/mask/UIMask.js +265 -0
  47. package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.d.ts +50 -0
  48. package/dist/core/miscellaneous/mask/UIMaskMaterialPatch.js +233 -0
  49. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +10 -1
  50. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +7 -1
  51. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +2 -0
  52. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +0 -1
  53. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +2 -0
  54. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +0 -1
  55. package/dist/core/miscellaneous/micro/UIMicro.Internal.d.ts +3 -0
  56. package/dist/core/miscellaneous/micro/UIMicro.Internal.js +1 -0
  57. package/dist/core/miscellaneous/micro/UIMicro.d.ts +18 -1
  58. package/dist/core/miscellaneous/micro/UIMicro.js +23 -2
  59. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +16 -1
  60. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +8 -2
  61. package/dist/core/miscellaneous/texture/UITextureView.d.ts +2 -1
  62. package/dist/core/miscellaneous/texture/UITextureView.js +3 -2
  63. package/dist/core/shaders/UIMask.d.ts +15 -0
  64. package/dist/core/shaders/UIMask.js +45 -0
  65. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +2 -0
  66. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +1 -0
  67. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +3 -0
  68. package/dist/debug/index.d.ts +2 -0
  69. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +7 -0
  70. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +0 -2
  71. package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +7 -1
  72. package/dist/particles/behaviorModules/UIBehaviorModule.js +2 -1
  73. package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +7 -0
  74. package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +0 -2
  75. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +7 -0
  76. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +0 -2
  77. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -0
  78. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +0 -2
  79. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +7 -0
  80. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +0 -2
  81. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +7 -0
  82. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +0 -2
  83. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +7 -0
  84. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +0 -2
  85. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +7 -0
  86. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +0 -2
  87. package/dist/particles/elements/UIEmitter.Internal.d.ts +7 -0
  88. package/dist/particles/elements/UIEmitter.d.ts +1 -8
  89. package/dist/particles/index.d.ts +5 -0
  90. package/dist/particles/index.js +3 -0
  91. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +11 -2
  92. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +101 -72
  93. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +1 -0
  94. package/dist/particles/instancedParticle/UIInstancedParticle.js +4 -2
  95. package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +4 -0
  96. package/dist/particles/renderingModules/UIRenderingColorOverLife.js +0 -2
  97. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +4 -0
  98. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +0 -2
  99. package/dist/particles/renderingModules/UIRenderingModule.d.ts +10 -1
  100. package/dist/particles/renderingModules/UIRenderingModule.js +3 -1
  101. package/dist/particles/renderingModules/UIRenderingTexture.d.ts +4 -0
  102. package/dist/particles/spawnModules/UISpawnModule.d.ts +13 -1
  103. package/dist/particles/spawnModules/UISpawnModule.js +3 -1
  104. package/dist/particles/spawnModules/UISpawnOffset.d.ts +7 -0
  105. package/dist/particles/spawnModules/UISpawnOffset.js +0 -2
  106. package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +7 -0
  107. package/dist/particles/spawnModules/UISpawnRandomLifetime.js +0 -2
  108. package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +7 -0
  109. package/dist/particles/spawnModules/UISpawnRandomRotation.js +0 -2
  110. package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +7 -0
  111. package/dist/particles/spawnModules/UISpawnRandomScale.js +0 -2
  112. package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +7 -0
  113. package/dist/particles/spawnModules/UISpawnRandomTorque.js +0 -2
  114. package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +7 -0
  115. package/dist/particles/spawnModules/UISpawnRandomVelocity.js +0 -2
  116. package/dist/particles/spawnModules/UISpawnRectangle.d.ts +7 -0
  117. package/dist/particles/spawnModules/UISpawnRectangle.js +0 -2
  118. package/package.json +1 -1
@@ -1,5 +1,11 @@
1
1
  import type { UIMicroAnchorMode, UIMicroConfig } from "./UIMicro.Internal.js";
2
- /** Transforms that don't affect constraints */
2
+ /**
3
+ * Transforms that don't affect constraints.
4
+ *
5
+ * Input follows them by default: a moved, rotated or scaled element is hit where it is drawn.
6
+ * Turn {@link affectsInput} off for effects such as shrinking a button while it is pressed,
7
+ * where the hit area should stay put under the finger.
8
+ */
3
9
  export declare class UIMicro {
4
10
  private xInternal;
5
11
  private yInternal;
@@ -9,6 +15,7 @@ export declare class UIMicro {
9
15
  private scaleYInternal;
10
16
  private rotationInternal;
11
17
  private anchorModeInternal;
18
+ private affectsInputInternal;
12
19
  private dirtyInternal;
13
20
  /**
14
21
  * Creates UIMicro instance.
@@ -34,6 +41,11 @@ export declare class UIMicro {
34
41
  get anchorMode(): UIMicroAnchorMode;
35
42
  /** Rotation in radians */
36
43
  get rotation(): number;
44
+ /**
45
+ * Whether input follows the transformed element instead of its layout rectangle. Not a
46
+ * transform itself, so `reset` and `copy` leave it as is.
47
+ */
48
+ get affectsInput(): boolean;
37
49
  /** X offset in world units */
38
50
  set x(value: number);
39
51
  /** Y offset in world units */
@@ -52,6 +64,11 @@ export declare class UIMicro {
52
64
  set rotation(value: number);
53
65
  /** Which transforms apply relative to anchor */
54
66
  set anchorMode(value: UIMicroAnchorMode);
67
+ /**
68
+ * Whether input follows the transformed element instead of its layout rectangle. Not a
69
+ * transform itself, so `reset` and `copy` leave it as is.
70
+ */
71
+ set affectsInput(value: boolean);
55
72
  /** Sets the same scale for X and Y */
56
73
  setUnifiedScale(scale: number): void;
57
74
  /** Sets the same anchor for X and Y */
@@ -1,7 +1,13 @@
1
1
  import { MathUtils } from "three";
2
2
  import { assertValidNumber } from "../asserts.js";
3
- import { MICRO_DEFAULT_ANCHOR, MICRO_DEFAULT_ANCHOR_MODE, MICRO_DEFAULT_POSITION, MICRO_DEFAULT_ROTATION, MICRO_DEFAULT_SCALE, } from "./UIMicro.Internal.js";
4
- /** Transforms that don't affect constraints */
3
+ import { MICRO_DEFAULT_AFFECTS_INPUT, MICRO_DEFAULT_ANCHOR, MICRO_DEFAULT_ANCHOR_MODE, MICRO_DEFAULT_POSITION, MICRO_DEFAULT_ROTATION, MICRO_DEFAULT_SCALE, } from "./UIMicro.Internal.js";
4
+ /**
5
+ * Transforms that don't affect constraints.
6
+ *
7
+ * Input follows them by default: a moved, rotated or scaled element is hit where it is drawn.
8
+ * Turn {@link affectsInput} off for effects such as shrinking a button while it is pressed,
9
+ * where the hit area should stay put under the finger.
10
+ */
5
11
  export class UIMicro {
6
12
  /**
7
13
  * Creates UIMicro instance.
@@ -18,6 +24,7 @@ export class UIMicro {
18
24
  this.scaleYInternal = config?.scaleY ?? MICRO_DEFAULT_SCALE;
19
25
  this.rotationInternal = config?.rotation ?? MICRO_DEFAULT_ROTATION;
20
26
  this.anchorModeInternal = config?.anchorMode ?? MICRO_DEFAULT_ANCHOR_MODE;
27
+ this.affectsInputInternal = config?.affectsInput ?? MICRO_DEFAULT_AFFECTS_INPUT;
21
28
  }
22
29
  /** X offset in world units */
23
30
  get x() {
@@ -55,6 +62,13 @@ export class UIMicro {
55
62
  get rotation() {
56
63
  return this.rotationInternal;
57
64
  }
65
+ /**
66
+ * Whether input follows the transformed element instead of its layout rectangle. Not a
67
+ * transform itself, so `reset` and `copy` leave it as is.
68
+ */
69
+ get affectsInput() {
70
+ return this.affectsInputInternal;
71
+ }
58
72
  /** @internal */
59
73
  get dirty() {
60
74
  return this.dirtyInternal;
@@ -131,6 +145,13 @@ export class UIMicro {
131
145
  this.dirtyInternal = true;
132
146
  }
133
147
  }
148
+ /**
149
+ * Whether input follows the transformed element instead of its layout rectangle. Not a
150
+ * transform itself, so `reset` and `copy` leave it as is.
151
+ */
152
+ set affectsInput(value) {
153
+ this.affectsInputInternal = value;
154
+ }
134
155
  /** Sets the same scale for X and Y */
135
156
  setUnifiedScale(scale) {
136
157
  assertValidNumber(scale, "UIMicro.setUnifiedScale.scale");
@@ -1,3 +1,18 @@
1
- /** Base class for viewport resize policies */
1
+ /**
2
+ * Base class for viewport resize policies. Subclass it for a custom scaling rule and pass it to
3
+ * `UIFullscreenLayer`.
4
+ */
2
5
  export declare abstract class UIResizePolicy {
6
+ /**
7
+ * Set it to true when a parameter of the policy changes; the layer then resizes on its next
8
+ * render and resets the flag.
9
+ */
10
+ dirty: boolean;
11
+ /**
12
+ * Scale from screen pixels to world units: the layer is the viewport size times this value.
13
+ * @param width Viewport width in pixels
14
+ * @param height Viewport height in pixels
15
+ * @returns World units per pixel
16
+ */
17
+ abstract calculateScale(width: number, height: number): number;
3
18
  }
@@ -1,7 +1,13 @@
1
- /** Base class for viewport resize policies */
1
+ /**
2
+ * Base class for viewport resize policies. Subclass it for a custom scaling rule and pass it to
3
+ * `UIFullscreenLayer`.
4
+ */
2
5
  export class UIResizePolicy {
3
6
  constructor() {
4
- /** @internal */
7
+ /**
8
+ * Set it to true when a parameter of the policy changes; the layer then resizes on its next
9
+ * render and resets the flag.
10
+ */
5
11
  this.dirty = false;
6
12
  }
7
13
  }
@@ -1,5 +1,6 @@
1
1
  import type { FerrsignView3 } from "ferrsign";
2
- import { Matrix3, Texture, Vector2 } from "three";
2
+ import type { Matrix3 } from "three";
3
+ import { Texture, Vector2 } from "three";
3
4
  import type { UITextureConfig, UITextureTrim } from "./UITextureView.Internal.js";
4
5
  /** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
5
6
  export declare class UITextureView {
@@ -1,6 +1,7 @@
1
1
  import { Ferrsign3 } from "ferrsign";
2
- import { Matrix3, Texture, Vector2 } from "three";
2
+ import { Texture, Vector2 } from "three";
3
3
  import { assertValidNonNegativeNumber, assertValidPositiveNumber } from "../asserts.js";
4
+ import { UIAffineMatrix3 } from "../UIAffineMatrix3.js";
4
5
  import { getTextureImageSize, TEXTURE_DEFAULT_SIZE, TEXTURE_DEFAULT_TEXTURE, } from "./UITextureView.Internal.js";
5
6
  /** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
6
7
  export class UITextureView {
@@ -97,7 +98,7 @@ export class UITextureView {
97
98
  * @param result Matrix to store result in
98
99
  * @returns UV transform matrix
99
100
  */
100
- calculateUVTransform(result = new Matrix3()) {
101
+ calculateUVTransform(result = new UIAffineMatrix3()) {
101
102
  const { w: atlasWidth, h: atlasHeight } = getTextureImageSize(this.textureInternal);
102
103
  if (this.rotatedInternal) {
103
104
  const physicalWidth = this.frameHeight;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Coverage of an analytic mask, shared by masked planes and patched external materials.
3
+ *
4
+ * Arguments:
5
+ * - p: point in mask-local space (centered, world units)
6
+ * - shape: (half width, half height, corner radius, softness); the radius is already clamped
7
+ * - mode: shape (0 = rectangle, 1 = ellipse) + 2 when inverted
8
+ *
9
+ * The edge is antialiased over a pixel through screen-space derivatives. On WebGL1 they need
10
+ * OES_standard_derivatives enabled for the program: the includer defines LAYMUR_MASK_DERIVATIVES
11
+ * only where it asked three.js to enable it. Without derivatives a world unit is taken as the
12
+ * pixel size.
13
+ */
14
+ declare const source: string;
15
+ export default source;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Coverage of an analytic mask, shared by masked planes and patched external materials.
3
+ *
4
+ * Arguments:
5
+ * - p: point in mask-local space (centered, world units)
6
+ * - shape: (half width, half height, corner radius, softness); the radius is already clamped
7
+ * - mode: shape (0 = rectangle, 1 = ellipse) + 2 when inverted
8
+ *
9
+ * The edge is antialiased over a pixel through screen-space derivatives. On WebGL1 they need
10
+ * OES_standard_derivatives enabled for the program: the includer defines LAYMUR_MASK_DERIVATIVES
11
+ * only where it asked three.js to enable it. Without derivatives a world unit is taken as the
12
+ * pixel size.
13
+ */
14
+ const source = `
15
+ float laymurMaskDistance(vec2 p, vec4 shape, float kind) {
16
+ if (kind > 0.5) {
17
+ // Divided one axis at a time: radii squared overflow mediump on large masks
18
+ vec2 radii = max(shape.xy, vec2(1e-4));
19
+ vec2 normalized = p / radii;
20
+ float k0 = length(normalized);
21
+ float k1 = length(normalized / radii);
22
+ return k1 > 0.0 ? k0 * (k0 - 1.0) / k1 : -min(radii.x, radii.y);
23
+ }
24
+ vec2 q = abs(p) - shape.xy + shape.z;
25
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - shape.z;
26
+ }
27
+
28
+ float laymurMaskCoverage(vec2 p, vec4 shape, float mode) {
29
+ bool inverted = mode > 1.5;
30
+ float kind = inverted ? mode - 2.0 : mode;
31
+ float signedDistance = laymurMaskDistance(p, shape, kind);
32
+
33
+ #if __VERSION__ >= 300 || (defined(LAYMUR_MASK_DERIVATIVES) && defined(GL_OES_standard_derivatives))
34
+ // Euclidean per axis, so the band stays a pixel wide on rotated masks
35
+ float pixel = max(max(length(dFdx(p)), length(dFdy(p))), 1e-4);
36
+ #else
37
+ float pixel = 1.0;
38
+ #endif
39
+
40
+ float coverage = clamp((0.5 * pixel - signedDistance) / (shape.w + pixel), 0.0, 1.0);
41
+ coverage = coverage * coverage * (3.0 - 2.0 * coverage);
42
+ return inverted ? 1.0 - coverage : coverage;
43
+ }
44
+ `;
45
+ export default source;
@@ -10,6 +10,8 @@ export interface UISceneWrapperView {
10
10
  setTransparency(handler: number, transparency: UITransparencyMode): void;
11
11
  setBlend(handler: number, blend: number): void;
12
12
  setHSL(handler: number, hsl: HSLAdjustment): void;
13
+ /** Packed mask data (see UIMask.Internal.ts) or null to remove the mask */
14
+ setMask(handler: number, mask: Readonly<Float32Array> | null): void;
13
15
  insertOrderedObject(object: Object3D, depth: number): void;
14
16
  setOrderedObjectDepth(object: Object3D, depth: number): void;
15
17
  removeOrderedObject(object: Object3D): void;
@@ -15,6 +15,7 @@ export declare class UISceneWrapper implements UISceneWrapperView {
15
15
  setTransparency(handler: number, transparency: UITransparencyMode): void;
16
16
  setBlend(handler: number, blend: number): void;
17
17
  setHSL(handler: number, hsl: HSLAdjustment): void;
18
+ setMask(handler: number, mask: Readonly<Float32Array> | null): void;
18
19
  /** Adds an object drawn between planes by depth, on the same scale as plane zIndex */
19
20
  insertOrderedObject(object: Object3D, depth: number): this;
20
21
  /** Moves an ordered object to the given depth */
@@ -38,6 +38,9 @@ export class UISceneWrapper {
38
38
  setHSL(handler, hsl) {
39
39
  this.planeRegistry.setHSL(handler, hsl);
40
40
  }
41
+ setMask(handler, mask) {
42
+ this.planeRegistry.setMask(handler, mask);
43
+ }
41
44
  /** Adds an object drawn between planes by depth, on the same scale as plane zIndex */
42
45
  insertOrderedObject(object, depth) {
43
46
  this.planeRegistry.insertOrderedObject(object, depth);
@@ -1,8 +1,10 @@
1
1
  export { UIAspectDebug } from "./UIAspectDebug.js";
2
+ export type { UIConstraintDebug } from "./UIConstraintDebug.js";
2
3
  export { UIHeightDebug } from "./UIHeightDebug.js";
3
4
  export { UIHorizontalDistanceDebug } from "./UIHorizontalDistanceDebug.js";
4
5
  export { UIHorizontalInterpolationDebug } from "./UIHorizontalInterpolationDebug.js";
5
6
  export { UILayerDebug } from "./UILayerDebug.js";
7
+ export type { UILayerDebugOptions } from "./UILayerDebug.js";
6
8
  export { UIVerticalDistanceDebug } from "./UIVerticalDistanceDebug.js";
7
9
  export { UIVerticalInterpolationDebug } from "./UIVerticalInterpolationDebug.js";
8
10
  export { UIWidthDebug } from "./UIWidthDebug.js";
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { Vector2Like } from "../../core/miscellaneous/math.js";
2
3
  import type { UIVector2Config } from "../miscellaneous/miscellaneous.js";
3
4
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
@@ -9,6 +10,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
9
10
  export declare class UIBehaviorDirectionalGravity extends UIBehaviorModule<{
10
11
  builtin: "Matrix4";
11
12
  }> {
13
+ readonly requiredProperties: {
14
+ readonly builtin: "Matrix4";
15
+ };
12
16
  private directionInternal;
13
17
  /**
14
18
  * @param direction - Acceleration vector in units/second^2
@@ -18,4 +22,7 @@ export declare class UIBehaviorDirectionalGravity extends UIBehaviorModule<{
18
22
  get direction(): Vector2Like;
19
23
  /** Acceleration vector in units/second^2 */
20
24
  set direction(value: UIVector2Config);
25
+ update(properties: {
26
+ builtin: InstancedBufferAttribute;
27
+ }, instanceCount: number, deltaTime: number): void;
21
28
  }
@@ -12,7 +12,6 @@ export class UIBehaviorDirectionalGravity extends UIBehaviorModule {
12
12
  */
13
13
  constructor(direction) {
14
14
  super();
15
- /** @internal */
16
15
  this.requiredProperties = { builtin: "Matrix4" };
17
16
  this.directionInternal = resolveUIVector2Config(direction);
18
17
  assertValidNumber(this.directionInternal.x, "UIBehaviorDirectionalGravity.constructor.direction.x");
@@ -28,7 +27,6 @@ export class UIBehaviorDirectionalGravity extends UIBehaviorModule {
28
27
  assertValidNumber(this.directionInternal.x, "UIBehaviorDirectionalGravity.direction.x");
29
28
  assertValidNumber(this.directionInternal.y, "UIBehaviorDirectionalGravity.direction.y");
30
29
  }
31
- /** @internal */
32
30
  update(properties, instanceCount, deltaTime) {
33
31
  const { builtin } = properties;
34
32
  const { array, itemSize } = builtin;
@@ -3,10 +3,16 @@ import type { UIPropertyName } from "../../core/miscellaneous/generic-plane/shar
3
3
  /**
4
4
  * Base class for particle behavior modules.
5
5
  *
6
- * Behavior modules update particle properties each frame.
6
+ * Behavior modules update particle properties each frame. Declare the per-particle properties
7
+ * the module touches in `requiredProperties` and change them in `update`.
7
8
  */
8
9
  export declare abstract class UIBehaviorModule<T extends Record<string, UIPropertyName> = Record<string, UIPropertyName>> {
10
+ /** Per-particle properties the module reads and writes, by name and type */
9
11
  abstract readonly requiredProperties: T;
12
+ /**
13
+ * Advances the particles in [0, instanceCount) by deltaTime seconds.
14
+ * @param properties Per-particle buffers of the required properties
15
+ */
10
16
  abstract update(properties: {
11
17
  [K in keyof T]: InstancedBufferAttribute;
12
18
  }, instanceCount: number, deltaTime: number): void;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Base class for particle behavior modules.
3
3
  *
4
- * Behavior modules update particle properties each frame.
4
+ * Behavior modules update particle properties each frame. Declare the per-particle properties
5
+ * the module touches in `requiredProperties` and change them in `update`.
5
6
  */
6
7
  export class UIBehaviorModule {
7
8
  }
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { Vector2Like } from "../../core/miscellaneous/math.js";
2
3
  import { type UIRange, type UIRangeConfig, type UIVector2Config } from "../miscellaneous/miscellaneous.js";
3
4
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
@@ -9,6 +10,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
9
10
  export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
10
11
  builtin: "Matrix4";
11
12
  }> {
13
+ readonly requiredProperties: {
14
+ readonly builtin: "Matrix4";
15
+ };
12
16
  private centerInternal;
13
17
  private strengthInternal;
14
18
  private exponentInternal;
@@ -36,4 +40,7 @@ export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
36
40
  set exponent(value: UIRangeConfig);
37
41
  /** Minimum distance range */
38
42
  set threshold(value: UIRangeConfig);
43
+ update(properties: {
44
+ builtin: InstancedBufferAttribute;
45
+ }, instanceCount: number, deltaTime: number): void;
39
46
  }
@@ -16,7 +16,6 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
16
16
  */
17
17
  constructor(center, strength, exponent = 2, threshold = 1) {
18
18
  super();
19
- /** @internal */
20
19
  this.requiredProperties = { builtin: "Matrix4" };
21
20
  this.centerInternal = resolveUIVector2Config(center);
22
21
  assertValidNumber(this.centerInternal.x, "UIBehaviorPointGravity.constructor.center.x");
@@ -71,7 +70,6 @@ export class UIBehaviorPointGravity extends UIBehaviorModule {
71
70
  assertValidNumber(this.thresholdInternal.min, "UIBehaviorPointGravity.threshold.min");
72
71
  assertValidNumber(this.thresholdInternal.max, "UIBehaviorPointGravity.threshold.max");
73
72
  }
74
- /** @internal */
75
73
  update(properties, instanceCount, deltaTime) {
76
74
  const { builtin } = properties;
77
75
  const { array, itemSize } = builtin;
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { UIAspectConfig, UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
2
3
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
3
4
  /** Axis whose scale oscillates */
@@ -13,6 +14,9 @@ export type UIScaleOscillationAxis = "x" | "y";
13
14
  export declare class UIBehaviorScaleOscillation extends UIBehaviorModule<{
14
15
  builtin: "Matrix4";
15
16
  }> {
17
+ readonly requiredProperties: {
18
+ readonly builtin: "Matrix4";
19
+ };
16
20
  private readonly axisInternal;
17
21
  private frequencyInternal;
18
22
  private depthInternal;
@@ -38,4 +42,7 @@ export declare class UIBehaviorScaleOscillation extends UIBehaviorModule<{
38
42
  set depth(value: number);
39
43
  /** Width/height aspect ratio */
40
44
  set aspect(value: UIAspectConfig);
45
+ update(properties: {
46
+ builtin: InstancedBufferAttribute;
47
+ }, instanceCount: number): void;
41
48
  }
@@ -19,7 +19,6 @@ export class UIBehaviorScaleOscillation extends UIBehaviorModule {
19
19
  */
20
20
  constructor(axis, frequency, depth = 1, aspect = 1) {
21
21
  super();
22
- /** @internal */
23
22
  this.requiredProperties = { builtin: "Matrix4" };
24
23
  this.axisInternal = axis;
25
24
  this.frequencyInternal = resolveUIRangeConfig(frequency);
@@ -62,7 +61,6 @@ export class UIBehaviorScaleOscillation extends UIBehaviorModule {
62
61
  this.aspectInternal = resolveAspect(value);
63
62
  assertValidPositiveNumber(this.aspectInternal, "UIBehaviorScaleOscillation.aspect");
64
63
  }
65
- /** @internal */
66
64
  update(properties, instanceCount) {
67
65
  const { builtin } = properties;
68
66
  const { array, itemSize } = builtin;
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { UIAspectConfig, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
2
3
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
3
4
  /**
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
8
9
  export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
9
10
  builtin: "Matrix4";
10
11
  }> {
12
+ readonly requiredProperties: {
13
+ readonly builtin: "Matrix4";
14
+ };
11
15
  private readonly scales;
12
16
  private aspectInternal;
13
17
  /**
@@ -19,4 +23,7 @@ export declare class UIBehaviorScaleOverLife extends UIBehaviorModule<{
19
23
  get aspect(): number;
20
24
  /** Width/height aspect ratio */
21
25
  set aspect(value: UIAspectConfig);
26
+ update(properties: {
27
+ builtin: InstancedBufferAttribute;
28
+ }, instanceCount: number): void;
22
29
  }
@@ -14,7 +14,6 @@ export class UIBehaviorScaleOverLife extends UIBehaviorModule {
14
14
  */
15
15
  constructor(scales, aspect = 1) {
16
16
  super();
17
- /** @internal */
18
17
  this.requiredProperties = { builtin: "Matrix4" };
19
18
  this.scales = [];
20
19
  if (scales.length < 2) {
@@ -38,7 +37,6 @@ export class UIBehaviorScaleOverLife extends UIBehaviorModule {
38
37
  this.aspectInternal = resolveAspect(value);
39
38
  assertValidPositiveNumber(this.aspectInternal, "UIBehaviorScaleOverLife.aspect");
40
39
  }
41
- /** @internal */
42
40
  update(properties, instanceCount) {
43
41
  const { builtin } = properties;
44
42
  const { array, itemSize } = builtin;
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
2
3
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
3
4
  /**
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
8
9
  export declare class UIBehaviorTorqueDamping extends UIBehaviorModule<{
9
10
  builtin: "Matrix4";
10
11
  }> {
12
+ readonly requiredProperties: {
13
+ readonly builtin: "Matrix4";
14
+ };
11
15
  private dampingInternal;
12
16
  /**
13
17
  * @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
@@ -17,4 +21,7 @@ export declare class UIBehaviorTorqueDamping extends UIBehaviorModule<{
17
21
  get damping(): UIRange;
18
22
  /** Damping coefficient range (0-1) */
19
23
  set damping(value: UIRangeConfig);
24
+ update(properties: {
25
+ builtin: InstancedBufferAttribute;
26
+ }, instanceCount: number, deltaTime: number): void;
20
27
  }
@@ -13,7 +13,6 @@ export class UIBehaviorTorqueDamping extends UIBehaviorModule {
13
13
  */
14
14
  constructor(damping) {
15
15
  super();
16
- /** @internal */
17
16
  this.requiredProperties = { builtin: "Matrix4" };
18
17
  this.dampingInternal = resolveUIRangeConfig(damping);
19
18
  assertValidNonNegativeNumber(this.dampingInternal.min, `UIBehaviorTorqueDamping.constructor.damping.min`);
@@ -29,7 +28,6 @@ export class UIBehaviorTorqueDamping extends UIBehaviorModule {
29
28
  assertValidNonNegativeNumber(this.dampingInternal.min, `UIBehaviorTorqueDamping.damping.min`);
30
29
  assertValidNonNegativeNumber(this.dampingInternal.max, `UIBehaviorTorqueDamping.damping.max`);
31
30
  }
32
- /** @internal */
33
31
  update(properties, instanceCount, deltaTime) {
34
32
  const { builtin } = properties;
35
33
  const { array, itemSize } = builtin;
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
2
3
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
3
4
  /**
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
8
9
  export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
9
10
  builtin: "Matrix4";
10
11
  }> {
12
+ readonly requiredProperties: {
13
+ readonly builtin: "Matrix4";
14
+ };
11
15
  private scaleInternal;
12
16
  private strengthInternal;
13
17
  /**
@@ -23,4 +27,7 @@ export declare class UIBehaviorTorqueNoise extends UIBehaviorModule<{
23
27
  set scale(value: UIRangeConfig);
24
28
  /** Force multiplier range */
25
29
  set strength(value: UIRangeConfig);
30
+ update(properties: {
31
+ builtin: InstancedBufferAttribute;
32
+ }, instanceCount: number, deltaTime: number): void;
26
33
  }
@@ -14,7 +14,6 @@ export class UIBehaviorTorqueNoise extends UIBehaviorModule {
14
14
  */
15
15
  constructor(scale, strength) {
16
16
  super();
17
- /** @internal */
18
17
  this.requiredProperties = { builtin: "Matrix4" };
19
18
  this.scaleInternal = resolveUIRangeConfig(scale);
20
19
  assertValidPositiveNumber(this.scaleInternal.min, `UIBehaviorTorqueNoise.constructor.scale.min`);
@@ -43,7 +42,6 @@ export class UIBehaviorTorqueNoise extends UIBehaviorModule {
43
42
  assertValidNonNegativeNumber(this.strengthInternal.min, `UIBehaviorTorqueNoise.strength.min`);
44
43
  assertValidNonNegativeNumber(this.strengthInternal.max, `UIBehaviorTorqueNoise.strength.max`);
45
44
  }
46
- /** @internal */
47
45
  update(properties, instanceCount, deltaTime) {
48
46
  const { builtin } = properties;
49
47
  const { array, itemSize } = builtin;
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import type { UIRange, UIRangeConfig } from "../miscellaneous/miscellaneous.js";
2
3
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
3
4
  /**
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
8
9
  export declare class UIBehaviorVelocityDamping extends UIBehaviorModule<{
9
10
  builtin: "Matrix4";
10
11
  }> {
12
+ readonly requiredProperties: {
13
+ readonly builtin: "Matrix4";
14
+ };
11
15
  private dampingInternal;
12
16
  /**
13
17
  * @param damping - Damping coefficient range (0-1). Accepts number, tuple, or range object
@@ -17,4 +21,7 @@ export declare class UIBehaviorVelocityDamping extends UIBehaviorModule<{
17
21
  get damping(): UIRange;
18
22
  /** Damping coefficient range (0-1) */
19
23
  set damping(value: UIRangeConfig);
24
+ update(properties: {
25
+ builtin: InstancedBufferAttribute;
26
+ }, instanceCount: number, deltaTime: number): void;
20
27
  }
@@ -13,7 +13,6 @@ export class UIBehaviorVelocityDamping extends UIBehaviorModule {
13
13
  */
14
14
  constructor(damping) {
15
15
  super();
16
- /** @internal */
17
16
  this.requiredProperties = { builtin: "Matrix4" };
18
17
  this.dampingInternal = resolveUIRangeConfig(damping);
19
18
  assertValidNonNegativeNumber(this.dampingInternal.min, `UIBehaviorVelocityDamping.constructor.damping.min`);
@@ -29,7 +28,6 @@ export class UIBehaviorVelocityDamping extends UIBehaviorModule {
29
28
  assertValidNonNegativeNumber(this.dampingInternal.min, `UIBehaviorVelocityDamping.damping.min`);
30
29
  assertValidNonNegativeNumber(this.dampingInternal.max, `UIBehaviorVelocityDamping.damping.max`);
31
30
  }
32
- /** @internal */
33
31
  update(properties, instanceCount, deltaTime) {
34
32
  const { builtin } = properties;
35
33
  const { array, itemSize } = builtin;
@@ -1,3 +1,4 @@
1
+ import type { InstancedBufferAttribute } from "three";
1
2
  import { type UIRange, type UIRangeConfig } from "../miscellaneous/miscellaneous.js";
2
3
  import { UIBehaviorModule } from "./UIBehaviorModule.js";
3
4
  /**
@@ -8,6 +9,9 @@ import { UIBehaviorModule } from "./UIBehaviorModule.js";
8
9
  export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
9
10
  builtin: "Matrix4";
10
11
  }> {
12
+ readonly requiredProperties: {
13
+ readonly builtin: "Matrix4";
14
+ };
11
15
  private scaleInternal;
12
16
  private strengthInternal;
13
17
  /**
@@ -23,4 +27,7 @@ export declare class UIBehaviorVelocityNoise extends UIBehaviorModule<{
23
27
  set scale(value: UIRangeConfig);
24
28
  /** Force multiplier range */
25
29
  set strength(value: UIRangeConfig);
30
+ update(properties: {
31
+ builtin: InstancedBufferAttribute;
32
+ }, instanceCount: number, deltaTime: number): void;
26
33
  }
@@ -14,7 +14,6 @@ export class UIBehaviorVelocityNoise extends UIBehaviorModule {
14
14
  */
15
15
  constructor(scale = 100, strength = 500) {
16
16
  super();
17
- /** @internal */
18
17
  this.requiredProperties = { builtin: "Matrix4" };
19
18
  this.scaleInternal = resolveUIRangeConfig(scale);
20
19
  assertValidPositiveNumber(this.scaleInternal.min, `UIBehaviorVelocityNoise.constructor.scale.min`);
@@ -43,7 +42,6 @@ export class UIBehaviorVelocityNoise extends UIBehaviorModule {
43
42
  assertValidNonNegativeNumber(this.strengthInternal.min, `UIBehaviorVelocityNoise.strength.min`);
44
43
  assertValidNonNegativeNumber(this.strengthInternal.max, `UIBehaviorVelocityNoise.strength.max`);
45
44
  }
46
- /** @internal */
47
45
  update(properties, instanceCount, deltaTime) {
48
46
  const { builtin } = properties;
49
47
  const { array, itemSize } = builtin;
@@ -1,8 +1,15 @@
1
1
  import { UIMode } from "../../core/index.js";
2
2
  import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal.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
+ /** Number of particles the buffers grow by */
5
10
  capacityStep: number;
11
+ /** Whether to call destroy() on all modules when the emitter is destroyed */
12
+ automaticallyDestroyModules: boolean;
6
13
  }
7
14
  export interface UIEmitterPlayOptions {
8
15
  duration: number;
@@ -1,16 +1,9 @@
1
1
  import type { UILayer } from "../../core/index.js";
2
2
  import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor.js";
3
- import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal.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
  *