laymur 0.26.0 → 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.
Files changed (134) hide show
  1. package/README.md +79 -35
  2. package/dist/core/constraints/UICustomConstraint.d.ts +1 -1
  3. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +1 -1
  4. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +1 -1
  5. package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +2 -3
  6. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +2 -2
  7. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +24 -12
  8. package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +10 -0
  9. package/dist/core/elements/UIDummy/UIDummy.d.ts +42 -5
  10. package/dist/core/elements/UIDummy/UIDummy.js +119 -25
  11. package/dist/core/elements/UIElement/UIElement.Internal.d.ts +1 -1
  12. package/dist/core/elements/UIElement/UIElement.d.ts +14 -0
  13. package/dist/core/elements/UIElement/UIElement.js +34 -3
  14. package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +1 -1
  15. package/dist/core/elements/UIGraphics/UIGraphics.d.ts +1 -1
  16. package/dist/core/elements/UIGraphics/UIGraphics.js +2 -2
  17. package/dist/core/elements/UIImage/UIImage.d.ts +2 -2
  18. package/dist/core/elements/UIImage/UIImage.js +10 -8
  19. package/dist/core/elements/UINineSlice/UINineSlice.d.ts +4 -4
  20. package/dist/core/elements/UINineSlice/UINineSlice.js +11 -9
  21. package/dist/core/elements/UIProgress/UIProgress.d.ts +2 -2
  22. package/dist/core/elements/UIProgress/UIProgress.js +15 -10
  23. package/dist/core/elements/UIScene/UIScene.Internal.d.ts +1 -1
  24. package/dist/core/elements/UIScene/UIScene.d.ts +3 -2
  25. package/dist/core/elements/UIScene/UIScene.js +18 -12
  26. package/dist/core/elements/UIText/UIText.Measuring.d.ts +1 -1
  27. package/dist/core/elements/UIText/UIText.d.ts +3 -3
  28. package/dist/core/elements/UIText/UIText.js +6 -6
  29. package/dist/core/index.d.ts +44 -41
  30. package/dist/core/index.js +12 -9
  31. package/dist/core/layers/UILayer/UILayer.d.ts +40 -4
  32. package/dist/core/layers/UILayer/UILayer.js +70 -9
  33. package/dist/core/layers/UIViewportLayer/UIViewportLayer.Internal.d.ts +27 -0
  34. package/dist/core/layers/{UIFullscreenLayer/UIFullscreenLayer.Internal.js → UIViewportLayer/UIViewportLayer.Internal.js} +1 -1
  35. package/dist/core/layers/UIViewportLayer/UIViewportLayer.d.ts +98 -0
  36. package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +251 -0
  37. package/dist/core/miscellaneous/asserts.d.ts +14 -0
  38. package/dist/core/miscellaneous/asserts.js +28 -0
  39. package/dist/core/miscellaneous/canvas.js +7 -2
  40. package/dist/core/miscellaneous/color/UIColor.js +4 -2
  41. package/dist/core/miscellaneous/computeTransform.d.ts +12 -0
  42. package/dist/core/miscellaneous/computeTransform.js +20 -0
  43. package/dist/core/miscellaneous/context-monitor/UIContextMonitor.d.ts +1 -0
  44. package/dist/core/miscellaneous/context-monitor/UIContextMonitor.js +60 -0
  45. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +1 -1
  46. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.d.ts +7 -4
  47. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +13 -6
  48. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +2 -2
  49. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +2 -2
  50. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +2 -2
  51. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +2 -2
  52. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +2 -2
  53. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +2 -2
  54. package/dist/core/miscellaneous/text-style/UITextStyle.js +2 -2
  55. package/dist/core/miscellaneous/texture/UITextureView.d.ts +4 -1
  56. package/dist/core/miscellaneous/texture/UITextureView.js +10 -7
  57. package/dist/core/miscellaneous/viewport/UIElementViewport.d.ts +31 -0
  58. package/dist/core/miscellaneous/viewport/UIElementViewport.js +54 -0
  59. package/dist/core/miscellaneous/viewport/UIViewport.d.ts +37 -0
  60. package/dist/core/miscellaneous/viewport/UIViewport.js +31 -0
  61. package/dist/core/miscellaneous/viewport/UIWindowViewport.d.ts +13 -0
  62. package/dist/core/miscellaneous/viewport/UIWindowViewport.js +25 -0
  63. package/dist/core/miscellaneous/webglCapabilities.js +61 -55
  64. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +36 -5
  65. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +23 -2
  66. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +153 -15
  67. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
  68. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +2 -0
  69. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +3 -0
  70. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +36 -16
  71. package/dist/debug/UIAspectDebug.js +4 -0
  72. package/dist/debug/UIHeightDebug.js +4 -0
  73. package/dist/debug/UIHorizontalDistanceDebug.js +5 -0
  74. package/dist/debug/UIHorizontalInterpolationDebug.js +5 -0
  75. package/dist/debug/UILayerDebug.d.ts +7 -0
  76. package/dist/debug/UILayerDebug.js +21 -0
  77. package/dist/debug/UIVerticalDistanceDebug.js +5 -0
  78. package/dist/debug/UIVerticalInterpolationDebug.js +5 -0
  79. package/dist/debug/UIWidthDebug.js +4 -0
  80. package/dist/debug/index.d.ts +1 -1
  81. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +1 -1
  82. package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +5 -1
  83. package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +2 -2
  84. package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +13 -10
  85. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +1 -1
  86. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +6 -4
  87. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +1 -1
  88. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +4 -3
  89. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +2 -2
  90. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +8 -8
  91. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +4 -3
  92. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +8 -5
  93. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +1 -1
  94. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +8 -8
  95. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +7 -5
  96. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +12 -8
  97. package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -2
  98. package/dist/particles/elements/UIEmitter.Internal.js +6 -0
  99. package/dist/particles/elements/UIEmitter.d.ts +19 -3
  100. package/dist/particles/elements/UIEmitter.js +100 -54
  101. package/dist/particles/index.d.ts +3 -2
  102. package/dist/particles/index.js +1 -0
  103. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +8 -2
  104. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +16 -11
  105. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -0
  106. package/dist/particles/instancedParticle/UIInstancedParticle.js +37 -2
  107. package/dist/particles/miscellaneous/miscellaneous.d.ts +34 -0
  108. package/dist/particles/miscellaneous/miscellaneous.js +72 -0
  109. package/dist/particles/renderingModules/UIRenderingColorOverLife.js +2 -2
  110. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +2 -3
  111. package/dist/particles/renderingModules/UIRenderingModule.d.ts +3 -2
  112. package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
  113. package/dist/particles/renderingModules/UIRenderingTexture.js +2 -1
  114. package/dist/particles/shaders/UIRenderingColorOverLife.d.ts +1 -2
  115. package/dist/particles/shaders/UIRenderingColorOverLife.js +5 -3
  116. package/dist/particles/shaders/UIRenderingColorOverVelocity.d.ts +1 -9
  117. package/dist/particles/shaders/UIRenderingColorOverVelocity.js +6 -13
  118. package/dist/particles/spawnModules/UISpawnModule.d.ts +5 -2
  119. package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +2 -2
  120. package/dist/particles/spawnModules/UISpawnRandomLifetime.js +5 -5
  121. package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +1 -1
  122. package/dist/particles/spawnModules/UISpawnRandomRotation.js +5 -3
  123. package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +1 -1
  124. package/dist/particles/spawnModules/UISpawnRandomScale.js +4 -3
  125. package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +1 -1
  126. package/dist/particles/spawnModules/UISpawnRandomTorque.js +5 -3
  127. package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +1 -1
  128. package/dist/particles/spawnModules/UISpawnRandomVelocity.js +6 -4
  129. package/dist/particles/spawnModules/UISpawnRectangle.d.ts +1 -1
  130. package/dist/particles/spawnModules/UISpawnRectangle.js +6 -4
  131. package/package.json +13 -4
  132. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -21
  133. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
  134. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +0 -144
@@ -1,24 +1,32 @@
1
1
  export class UIInputWrapper {
2
2
  constructor() {
3
- /** @internal */
4
- this.dirty = false;
3
+ this.versionInternal = 0;
5
4
  this.zIndicesDirty = false;
6
5
  this.catchers = [];
6
+ /** Pressed pointers: the input wrapper is the one place that knows of them */
7
+ this.pointers = new Map();
8
+ /** Pointers seen moving while not pressed, such as a hovering mouse */
9
+ this.hoveringPointers = new Set();
7
10
  this.lastHandler = 0;
8
11
  }
9
- createInputCatcher(catchPointerDown, catchPointerMove, catchPointerUp, zIndex) {
12
+ /** Bumped by every change to the draw order; compare with the last seen value */
13
+ get version() {
14
+ return this.versionInternal;
15
+ }
16
+ createInputCatcher(callbacks, zIndex) {
10
17
  const handler = this.lastHandler++;
11
18
  this.catchers.push({
12
19
  handler,
13
- catchPointerDown,
14
- catchPointerMove,
15
- catchPointerUp,
20
+ catchPointerDown: callbacks.catchPointerDown,
21
+ catchPointerMove: callbacks.catchPointerMove,
22
+ catchPointerUp: callbacks.catchPointerUp,
23
+ catchPointerCancel: callbacks.catchPointerCancel,
16
24
  zIndex,
17
25
  depth: 0,
18
26
  active: true,
19
27
  });
20
28
  this.zIndicesDirty = true;
21
- this.dirty = true;
29
+ this.versionInternal++;
22
30
  return handler;
23
31
  }
24
32
  destroyInputCatcher(handler) {
@@ -27,9 +35,10 @@ export class UIInputWrapper {
27
35
  throw new Error(`UIInputWrapper.destroyInputCatcher.handler: handler ${handler} not found; its element may be destroyed`);
28
36
  }
29
37
  this.catchers[index].active = false;
38
+ this.releaseCaptures(this.catchers[index]);
30
39
  this.catchers.splice(index, 1);
31
40
  this.zIndicesDirty = true;
32
- this.dirty = true;
41
+ this.versionInternal++;
33
42
  }
34
43
  getZIndex(handler) {
35
44
  const found = this.catchers.find((item) => item.handler === handler);
@@ -54,7 +63,7 @@ export class UIInputWrapper {
54
63
  if (found.zIndex !== zIndex) {
55
64
  found.zIndex = zIndex;
56
65
  this.zIndicesDirty = true;
57
- this.dirty = true;
66
+ this.versionInternal++;
58
67
  }
59
68
  }
60
69
  getActive(handler) {
@@ -71,37 +80,162 @@ export class UIInputWrapper {
71
80
  }
72
81
  if (found.active !== active) {
73
82
  found.active = active;
83
+ if (!active) {
84
+ this.releaseCaptures(found);
85
+ }
74
86
  }
75
87
  }
76
88
  /** @internal */
77
89
  onPointerDown(x, y, identifier) {
78
- this.dispatch(x, y, identifier, "catchPointerDown");
90
+ // Pressed again without a release seen, as when released outside the page: the old press
91
+ // ends as cancelled
92
+ if (this.pointers.get(identifier)?.catcher) {
93
+ this.onPointerCancel(identifier);
94
+ }
95
+ // Known before the dispatch, so that a handler cancelling the pointers of the layer cancels
96
+ // this one too
97
+ this.hoveringPointers.delete(identifier);
98
+ const pointer = { catcher: null, x, y };
99
+ this.pointers.set(identifier, pointer);
100
+ const caught = this.dispatch(x, y, identifier, "catchPointerDown", pointer);
101
+ if (this.pointers.get(identifier) !== pointer) {
102
+ return;
103
+ }
104
+ // A handler may have deactivated or destroyed the catcher
105
+ const catcher = caught?.active === true ? caught : null;
106
+ pointer.catcher = catcher;
107
+ if (catcher !== null) {
108
+ // Catchers above that saw the press without catching it would never see the pointer
109
+ // again: for them it is gone
110
+ this.broadcastCancel(identifier, catcher);
111
+ }
79
112
  }
80
113
  /** @internal */
81
114
  onPointerMove(x, y, identifier) {
82
- this.dispatch(x, y, identifier, "catchPointerMove");
115
+ const pointer = this.pointers.get(identifier);
116
+ if (pointer !== undefined) {
117
+ pointer.x = x;
118
+ pointer.y = y;
119
+ }
120
+ if (pointer?.catcher) {
121
+ pointer.catcher.catchPointerMove(x, y, identifier);
122
+ return;
123
+ }
124
+ if (pointer === undefined) {
125
+ this.hoveringPointers.add(identifier);
126
+ }
127
+ this.cancelBelow(identifier, this.dispatch(x, y, identifier, "catchPointerMove"));
83
128
  }
84
129
  /** @internal */
85
130
  onPointerUp(x, y, identifier) {
86
- this.dispatch(x, y, identifier, "catchPointerUp");
131
+ const pointer = this.pointers.get(identifier);
132
+ this.pointers.delete(identifier);
133
+ this.hoveringPointers.delete(identifier);
134
+ if (pointer?.catcher) {
135
+ pointer.catcher.catchPointerUp(x, y, identifier);
136
+ return;
137
+ }
138
+ this.cancelBelow(identifier, this.dispatch(x, y, identifier, "catchPointerUp"));
139
+ }
140
+ /**
141
+ * A captured pointer is cancelled at its catcher. Any other one goes to every active catcher,
142
+ * top one first: the browser cancels a pointer for its own reasons (a system gesture,
143
+ * scrolling, a popup) and reports no useful position, so there is no hit test, and each
144
+ * catcher that tracks the pointer has to drop it.
145
+ * @internal
146
+ */
147
+ onPointerCancel(identifier) {
148
+ const pointer = this.pointers.get(identifier);
149
+ this.pointers.delete(identifier);
150
+ this.hoveringPointers.delete(identifier);
151
+ if (pointer?.catcher) {
152
+ pointer.catcher.catchPointerCancel(identifier);
153
+ return;
154
+ }
155
+ this.broadcastCancel(identifier, null);
156
+ }
157
+ /**
158
+ * Cancels every pressed pointer, for a layer that will not see their releases: it stops
159
+ * taking input, or the page is hidden. Hovering pointers leave the catchers too.
160
+ * @param onCancel Called for each pressed pointer before the catchers are, with its last
161
+ * position
162
+ * @internal
163
+ */
164
+ cancelPointers(onCancel) {
165
+ for (const [identifier, pointer] of [...this.pointers]) {
166
+ // A handler may have ended the pointer already
167
+ if (this.pointers.get(identifier) === pointer) {
168
+ onCancel(pointer.x, pointer.y, identifier);
169
+ this.onPointerCancel(identifier);
170
+ }
171
+ }
172
+ for (const identifier of [...this.hoveringPointers]) {
173
+ this.onPointerCancel(identifier);
174
+ }
87
175
  }
88
176
  /**
89
177
  * Passes a pointer event from the top catcher down until one catches it. A handler may
90
178
  * destroy elements, so the catchers are walked over a copy and a destroyed one is skipped.
179
+ * @param pointer Pressed pointer the event belongs to: the walk stops once a handler ends it
180
+ * @returns The catcher that caught the event, or null
91
181
  */
92
- dispatch(x, y, identifier, name) {
182
+ dispatch(x, y, identifier, name, pointer) {
93
183
  this.ensureSorted();
94
184
  const catchers = this.catchers.slice();
95
185
  for (let index = catchers.length - 1; index >= 0; index--) {
186
+ if (pointer !== undefined && this.pointers.get(identifier) !== pointer) {
187
+ return null;
188
+ }
96
189
  const item = catchers[index];
97
190
  if (item.active && item[name](x, y, identifier)) {
98
- break;
191
+ return item;
192
+ }
193
+ }
194
+ return null;
195
+ }
196
+ /**
197
+ * Passes a cancel to the active catchers below one that caught an event: they did not see it,
198
+ * and the pointer is over the catcher above them now, or released
199
+ */
200
+ cancelBelow(identifier, caught) {
201
+ if (caught === null) {
202
+ return;
203
+ }
204
+ // By draw order rather than by position in the list: a handler may have destroyed the
205
+ // catcher that caught the event
206
+ const catchers = this.catchers.slice();
207
+ for (let index = catchers.length - 1; index >= 0; index--) {
208
+ const item = catchers[index];
209
+ if (item.active && compareCatchers(item, caught) < 0) {
210
+ item.catchPointerCancel(identifier);
211
+ }
212
+ }
213
+ }
214
+ /** Passes a cancel to every active catcher but one, top one first */
215
+ broadcastCancel(identifier, except) {
216
+ this.ensureSorted();
217
+ const catchers = this.catchers.slice();
218
+ for (let index = catchers.length - 1; index >= 0; index--) {
219
+ const item = catchers[index];
220
+ if (item.active && item !== except) {
221
+ item.catchPointerCancel(identifier);
222
+ }
223
+ }
224
+ }
225
+ /**
226
+ * Frees the pointers held by a catcher that stops taking input; it resets its own state. The
227
+ * pointers stay pressed, for the layer, with no catcher.
228
+ */
229
+ releaseCaptures(catcher) {
230
+ for (const pointer of this.pointers.values()) {
231
+ if (pointer.catcher === catcher) {
232
+ pointer.catcher = null;
99
233
  }
100
234
  }
101
235
  }
102
236
  ensureSorted() {
103
237
  if (this.zIndicesDirty) {
104
- this.catchers.sort((a, b) => a.zIndex - b.zIndex || a.handler - b.handler);
238
+ this.catchers.sort(compareCatchers);
105
239
  const count = this.catchers.length;
106
240
  const step = count < 1024 ? 1 : 1024 / count;
107
241
  for (let index = 0; index < count; index++) {
@@ -111,3 +245,7 @@ export class UIInputWrapper {
111
245
  }
112
246
  }
113
247
  }
248
+ /** Draw order of catchers, bottom first: by zIndex, then by creation */
249
+ function compareCatchers(a, b) {
250
+ return a.zIndex - b.zIndex || a.handler - b.handler;
251
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Matrix4, Object3D } from "three";
2
- import type { UITransparencyMode } from "../../miscellaneous/UITransparencyMode.js";
3
2
  import type { HSLAdjustment, UIProperty } from "../../miscellaneous/generic-plane/shared.js";
3
+ import type { UITransparencyMode } from "../../miscellaneous/UITransparencyMode.js";
4
4
  export interface UISceneWrapperView {
5
5
  createPlane(source: string, properties: Record<string, UIProperty>, transform: Matrix4, visibility: boolean, transparency: UITransparencyMode, blend: number, hsl: HSLAdjustment): number;
6
6
  destroyPlane(handler: number): void;
@@ -3,6 +3,8 @@ import type { UIExpression } from "../../miscellaneous/UIExpression.js";
3
3
  import type { UIPriority } from "../../miscellaneous/UIPriority.js";
4
4
  import type { UIRelation } from "../../miscellaneous/UIRelation.js";
5
5
  export interface UISolverWrapperView {
6
+ /** Bumped by every change to the variables or constraints; compare with the last seen value */
7
+ readonly version: number;
6
8
  createVariable(value: number, priority: UIPriority): number;
7
9
  removeVariable(index: number): void;
8
10
  hasVariable(index: number): boolean;
@@ -23,6 +23,7 @@ import type { UISolverWrapperView } from "./UISolverWrapper.Internal.js";
23
23
  * @see {@link UIRelation} - Relational operators for constraints
24
24
  */
25
25
  export declare class UISolverWrapper implements UISolverWrapperView {
26
+ private versionInternal;
26
27
  /** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */
27
28
  private solver?;
28
29
  /** Flag indicating whether variable values need recalculation. */
@@ -35,6 +36,8 @@ export declare class UISolverWrapper implements UISolverWrapperView {
35
36
  private readonly constraints;
36
37
  /** Counter for generating unique constraint indices. */
37
38
  private lastConstraintIndex;
39
+ /** Bumped by every change to the variables or constraints; compare with the last seen value */
40
+ get version(): number;
38
41
  /**
39
42
  * Creates a new solver variable with the specified value and priority.
40
43
  *
@@ -24,8 +24,7 @@ import { convertRelation, UIRelation } from "../../miscellaneous/UIRelation.js";
24
24
  */
25
25
  export class UISolverWrapper {
26
26
  constructor() {
27
- /** @internal */
28
- this.dirty = false;
27
+ this.versionInternal = 0;
29
28
  /** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */
30
29
  this.solver = new Solver();
31
30
  /** Flag indicating whether variable values need recalculation. */
@@ -39,6 +38,10 @@ export class UISolverWrapper {
39
38
  /** Counter for generating unique constraint indices. */
40
39
  this.lastConstraintIndex = 0;
41
40
  }
41
+ /** Bumped by every change to the variables or constraints; compare with the last seen value */
42
+ get version() {
43
+ return this.versionInternal;
44
+ }
42
45
  /**
43
46
  * Creates a new solver variable with the specified value and priority.
44
47
  *
@@ -75,7 +78,7 @@ export class UISolverWrapper {
75
78
  }
76
79
  }
77
80
  this.recalculationRequired = true;
78
- this.dirty = true;
81
+ this.versionInternal++;
79
82
  return index;
80
83
  }
81
84
  /**
@@ -107,7 +110,7 @@ export class UISolverWrapper {
107
110
  }
108
111
  this.variables.delete(index);
109
112
  this.recalculationRequired = true;
110
- this.dirty = true;
113
+ this.versionInternal++;
111
114
  }
112
115
  /**
113
116
  * Checks whether a variable exists.
@@ -143,7 +146,7 @@ export class UISolverWrapper {
143
146
  this.solver?.suggestValue(description.variable, value);
144
147
  }
145
148
  this.recalculationRequired = true;
146
- this.dirty = true;
149
+ this.versionInternal++;
147
150
  }
148
151
  }
149
152
  /**
@@ -165,6 +168,14 @@ export class UISolverWrapper {
165
168
  if (priority !== description.priority) {
166
169
  description.priority = priority;
167
170
  if (description.priority === UIPriority.P0) {
171
+ try {
172
+ if (this.solver?.hasEditVariable(description.variable) === true) {
173
+ this.solver.removeEditVariable(description.variable);
174
+ }
175
+ }
176
+ catch {
177
+ this.solver = undefined;
178
+ }
168
179
  const lhs = new UIExpression().plus(index, 1);
169
180
  const rhs = new UIExpression(description.value);
170
181
  description.constraint = this.buildConstraint(lhs, rhs, UIRelation.EQUAL, description.priority);
@@ -188,7 +199,7 @@ export class UISolverWrapper {
188
199
  this.rebuildVariable(index, description);
189
200
  }
190
201
  this.recalculationRequired = true;
191
- this.dirty = true;
202
+ this.versionInternal++;
192
203
  }
193
204
  }
194
205
  /**
@@ -247,7 +258,7 @@ export class UISolverWrapper {
247
258
  this.solver = undefined;
248
259
  }
249
260
  this.recalculationRequired = true;
250
- this.dirty = true;
261
+ this.versionInternal++;
251
262
  }
252
263
  return index;
253
264
  }
@@ -275,7 +286,7 @@ export class UISolverWrapper {
275
286
  }
276
287
  this.constraints.delete(index);
277
288
  this.recalculationRequired = true;
278
- this.dirty = true;
289
+ this.versionInternal++;
279
290
  }
280
291
  /**
281
292
  * Checks whether a constraint references a variable in either of its expressions.
@@ -310,7 +321,7 @@ export class UISolverWrapper {
310
321
  description.lhs.copy(lhs);
311
322
  this.rebuildConstraintByDescription(description);
312
323
  this.recalculationRequired = true;
313
- this.dirty = true;
324
+ this.versionInternal++;
314
325
  }
315
326
  /**
316
327
  * Updates the right-hand side expression of an existing constraint.
@@ -330,7 +341,7 @@ export class UISolverWrapper {
330
341
  description.rhs.copy(rhs);
331
342
  this.rebuildConstraintByDescription(description);
332
343
  this.recalculationRequired = true;
333
- this.dirty = true;
344
+ this.versionInternal++;
334
345
  }
335
346
  /**
336
347
  * Updates the relational operator of an existing constraint.
@@ -351,7 +362,7 @@ export class UISolverWrapper {
351
362
  description.relation = relation;
352
363
  this.rebuildConstraintByDescription(description);
353
364
  this.recalculationRequired = true;
354
- this.dirty = true;
365
+ this.versionInternal++;
355
366
  }
356
367
  }
357
368
  /**
@@ -373,7 +384,7 @@ export class UISolverWrapper {
373
384
  description.priority = priority;
374
385
  this.rebuildConstraintByDescription(description);
375
386
  this.recalculationRequired = true;
376
- this.dirty = true;
387
+ this.versionInternal++;
377
388
  }
378
389
  }
379
390
  /**
@@ -402,7 +413,7 @@ export class UISolverWrapper {
402
413
  this.solver = undefined;
403
414
  }
404
415
  this.recalculationRequired = true;
405
- this.dirty = true;
416
+ this.versionInternal++;
406
417
  }
407
418
  }
408
419
  /**
@@ -425,8 +436,17 @@ export class UISolverWrapper {
425
436
  dependConstraints.push(cDescription);
426
437
  }
427
438
  }
428
- this.solver?.removeEditVariable(description.variable);
429
- this.solver?.addEditVariable(description.variable, convertPriority(description.priority));
439
+ // A variable that was required (P0) has no edit variable yet
440
+ try {
441
+ if (this.solver?.hasEditVariable(description.variable) === true) {
442
+ this.solver.removeEditVariable(description.variable);
443
+ }
444
+ this.solver?.addEditVariable(description.variable, convertPriority(description.priority));
445
+ this.solver?.suggestValue(description.variable, description.value);
446
+ }
447
+ catch {
448
+ this.solver = undefined;
449
+ }
430
450
  for (const cDescription of dependConstraints) {
431
451
  cDescription.constraint = this.buildConstraint(cDescription.lhs, cDescription.rhs, cDescription.relation, cDescription.priority);
432
452
  }
@@ -539,6 +559,6 @@ export class UISolverWrapper {
539
559
  }
540
560
  this.solver = solver;
541
561
  this.recalculationRequired = true;
542
- this.dirty = true;
562
+ this.versionInternal++;
543
563
  }
544
564
  }
@@ -23,6 +23,8 @@ export class UIAspectDebug {
23
23
  this.updateContainerVisibility();
24
24
  };
25
25
  this.onRendering = (renderer) => {
26
+ // Also on creation: a constraint is announced before its orientation is set
27
+ this.updateContainerVisibility();
26
28
  const tintDirty = this.tint.dirty;
27
29
  if (tintDirty) {
28
30
  this.tint.toThreeColor(this.diagonalMaterial.color);
@@ -95,6 +97,8 @@ export class UIAspectDebug {
95
97
  this.constraint.layer.sceneWrapper.removeCustomObject(this.container);
96
98
  this.diagonalGeometry.dispose();
97
99
  this.textTexture.dispose();
100
+ this.diagonalMaterial.dispose();
101
+ this.spriteMaterial.dispose();
98
102
  }
99
103
  updateContainerVisibility() {
100
104
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -23,6 +23,8 @@ export class UIHeightDebug {
23
23
  this.updateContainerVisibility();
24
24
  };
25
25
  this.onRendering = (renderer) => {
26
+ // Also on creation: a constraint is announced before its orientation is set
27
+ this.updateContainerVisibility();
26
28
  const tintDirty = this.tint.dirty;
27
29
  if (tintDirty) {
28
30
  this.tint.toThreeColor(this.lineMaterial.color);
@@ -88,6 +90,8 @@ export class UIHeightDebug {
88
90
  this.constraint.layer.sceneWrapper.removeCustomObject(this.container);
89
91
  this.lineGeometry.dispose();
90
92
  this.textTexture.dispose();
93
+ this.lineMaterial.dispose();
94
+ this.spriteMaterial.dispose();
91
95
  }
92
96
  updateContainerVisibility() {
93
97
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -34,6 +34,8 @@ export class UIHorizontalDistanceDebug {
34
34
  this.updateContainerVisibility();
35
35
  };
36
36
  this.onRendering = (renderer) => {
37
+ // Also on creation: a constraint is announced before its orientation is set
38
+ this.updateContainerVisibility();
37
39
  const tintDirty = this.tint.dirty;
38
40
  if (tintDirty) {
39
41
  this.tint.toThreeColor(this.lineMaterial.color);
@@ -134,6 +136,9 @@ export class UIHorizontalDistanceDebug {
134
136
  this.lineGeometry.dispose();
135
137
  this.tickGeometry.dispose();
136
138
  this.textTexture.dispose();
139
+ this.lineMaterial.dispose();
140
+ this.tickMaterial.dispose();
141
+ this.spriteMaterial.dispose();
137
142
  }
138
143
  updateContainerVisibility() {
139
144
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -32,6 +32,8 @@ export class UIHorizontalInterpolationDebug {
32
32
  this.updateContainerVisibility();
33
33
  };
34
34
  this.onRendering = (renderer) => {
35
+ // Also on creation: a constraint is announced before its orientation is set
36
+ this.updateContainerVisibility();
35
37
  const tintDirty = this.tint.dirty;
36
38
  if (tintDirty) {
37
39
  this.tint.toThreeColor(this.baseLineMaterial.color);
@@ -122,6 +124,9 @@ export class UIHorizontalInterpolationDebug {
122
124
  this.baseLineGeometry.dispose();
123
125
  this.markerGeometry.dispose();
124
126
  this.textTexture.dispose();
127
+ this.baseLineMaterial.dispose();
128
+ this.markerMaterial.dispose();
129
+ this.spriteMaterial.dispose();
125
130
  }
126
131
  updateContainerVisibility() {
127
132
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -19,6 +19,13 @@ export declare class UILayerDebug {
19
19
  private showVerticalDistanceInternal;
20
20
  private showVerticalInterpolationInternal;
21
21
  constructor(layer: UILayer, options?: Partial<UILayerDebugOptions>);
22
+ get showAspect(): boolean;
23
+ get showHeight(): boolean;
24
+ get showWidth(): boolean;
25
+ get showHorizontalDistance(): boolean;
26
+ get showHorizontalInterpolation(): boolean;
27
+ get showVerticalDistance(): boolean;
28
+ get showVerticalInterpolation(): boolean;
22
29
  set showAspect(value: boolean);
23
30
  set showHeight(value: boolean);
24
31
  set showWidth(value: boolean);
@@ -33,6 +33,27 @@ export class UILayerDebug {
33
33
  this.layer.signalConstraintAdded.on(this.onConstraintAdded);
34
34
  this.layer.signalConstraintRemoved.on(this.onConstraintRemoved);
35
35
  }
36
+ get showAspect() {
37
+ return this.showAspectInternal;
38
+ }
39
+ get showHeight() {
40
+ return this.showHeightInternal;
41
+ }
42
+ get showWidth() {
43
+ return this.showWidthInternal;
44
+ }
45
+ get showHorizontalDistance() {
46
+ return this.showHorizontalDistanceInternal;
47
+ }
48
+ get showHorizontalInterpolation() {
49
+ return this.showHorizontalInterpolationInternal;
50
+ }
51
+ get showVerticalDistance() {
52
+ return this.showVerticalDistanceInternal;
53
+ }
54
+ get showVerticalInterpolation() {
55
+ return this.showVerticalInterpolationInternal;
56
+ }
36
57
  set showAspect(value) {
37
58
  this.showAspectInternal = value;
38
59
  this.setVisibility(UIAspectConstraint, value);
@@ -34,6 +34,8 @@ export class UIVerticalDistanceDebug {
34
34
  this.updateContainerVisibility();
35
35
  };
36
36
  this.onRendering = (renderer) => {
37
+ // Also on creation: a constraint is announced before its orientation is set
38
+ this.updateContainerVisibility();
37
39
  const tintDirty = this.tint.dirty;
38
40
  if (tintDirty) {
39
41
  this.tint.toThreeColor(this.lineMaterial.color);
@@ -134,6 +136,9 @@ export class UIVerticalDistanceDebug {
134
136
  this.lineGeometry.dispose();
135
137
  this.tickGeometry.dispose();
136
138
  this.textTexture.dispose();
139
+ this.lineMaterial.dispose();
140
+ this.tickMaterial.dispose();
141
+ this.spriteMaterial.dispose();
137
142
  }
138
143
  updateContainerVisibility() {
139
144
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -32,6 +32,8 @@ export class UIVerticalInterpolationDebug {
32
32
  this.updateContainerVisibility();
33
33
  };
34
34
  this.onRendering = (renderer) => {
35
+ // Also on creation: a constraint is announced before its orientation is set
36
+ this.updateContainerVisibility();
35
37
  const tintDirty = this.tint.dirty;
36
38
  if (tintDirty) {
37
39
  this.tint.toThreeColor(this.baseLineMaterial.color);
@@ -122,6 +124,9 @@ export class UIVerticalInterpolationDebug {
122
124
  this.baseLineGeometry.dispose();
123
125
  this.markerGeometry.dispose();
124
126
  this.textTexture.dispose();
127
+ this.baseLineMaterial.dispose();
128
+ this.markerMaterial.dispose();
129
+ this.spriteMaterial.dispose();
125
130
  }
126
131
  updateContainerVisibility() {
127
132
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -23,6 +23,8 @@ export class UIWidthDebug {
23
23
  this.updateContainerVisibility();
24
24
  };
25
25
  this.onRendering = (renderer) => {
26
+ // Also on creation: a constraint is announced before its orientation is set
27
+ this.updateContainerVisibility();
26
28
  const tintDirty = this.tint.dirty;
27
29
  if (tintDirty) {
28
30
  this.tint.toThreeColor(this.lineMaterial.color);
@@ -88,6 +90,8 @@ export class UIWidthDebug {
88
90
  this.constraint.layer.sceneWrapper.removeCustomObject(this.container);
89
91
  this.lineGeometry.dispose();
90
92
  this.textTexture.dispose();
93
+ this.lineMaterial.dispose();
94
+ this.spriteMaterial.dispose();
91
95
  }
92
96
  updateContainerVisibility() {
93
97
  const orientationActive = this.constraint.orientation === UIOrientation.ALWAYS ||
@@ -3,8 +3,8 @@ export type { UIConstraintDebug } from "./UIConstraintDebug.js";
3
3
  export { UIHeightDebug } from "./UIHeightDebug.js";
4
4
  export { UIHorizontalDistanceDebug } from "./UIHorizontalDistanceDebug.js";
5
5
  export { UIHorizontalInterpolationDebug } from "./UIHorizontalInterpolationDebug.js";
6
- export { UILayerDebug } from "./UILayerDebug.js";
7
6
  export type { UILayerDebugOptions } from "./UILayerDebug.js";
7
+ export { UILayerDebug } from "./UILayerDebug.js";
8
8
  export { UIVerticalDistanceDebug } from "./UIVerticalDistanceDebug.js";
9
9
  export { UIVerticalInterpolationDebug } from "./UIVerticalInterpolationDebug.js";
10
10
  export { UIWidthDebug } from "./UIWidthDebug.js";
@@ -17,7 +17,7 @@ export declare class UIBehaviorDirectionalGravity extends UIBehaviorModule<{
17
17
  /**
18
18
  * @param direction - Acceleration vector in units/second^2
19
19
  */
20
- constructor(direction: Vector2Like);
20
+ constructor(direction: UIVector2Config);
21
21
  /** Acceleration vector in units/second^2 */
22
22
  get direction(): Vector2Like;
23
23
  /** Acceleration vector in units/second^2 */
@@ -12,9 +12,13 @@ export declare abstract class UIBehaviorModule<T extends Record<string, UIProper
12
12
  /**
13
13
  * Advances the particles in [0, instanceCount) by deltaTime seconds.
14
14
  * @param properties Per-particle buffers of the required properties
15
+ * @param instanceCount Number of live particles
16
+ * @param deltaTime Frame step in seconds
17
+ * @param randomSalt Salt for `particleRandomStream`: random values of the module are
18
+ * independent of those of other modules, also of another instance of the same module
15
19
  */
16
20
  abstract update(properties: {
17
21
  [K in keyof T]: InstancedBufferAttribute;
18
- }, instanceCount: number, deltaTime: number): void;
22
+ }, instanceCount: number, deltaTime: number, randomSalt: number): void;
19
23
  destroy?(): void;
20
24
  }
@@ -23,7 +23,7 @@ export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
23
23
  * @param exponent - Distance power exponent range. Accepts number, tuple, or range object
24
24
  * @param threshold - Minimum distance range. Accepts number, tuple, or range object
25
25
  */
26
- constructor(center: Vector2Like, strength: UIRangeConfig, exponent?: UIRangeConfig, threshold?: UIRangeConfig);
26
+ constructor(center: UIVector2Config, strength: UIRangeConfig, exponent?: UIRangeConfig, threshold?: UIRangeConfig);
27
27
  /** Gravity center position */
28
28
  get center(): Vector2Like;
29
29
  /** Force multiplier range */
@@ -42,5 +42,5 @@ export declare class UIBehaviorPointGravity extends UIBehaviorModule<{
42
42
  set threshold(value: UIRangeConfig);
43
43
  update(properties: {
44
44
  builtin: InstancedBufferAttribute;
45
- }, instanceCount: number, deltaTime: number): void;
45
+ }, instanceCount: number, deltaTime: number, randomSalt: number): void;
46
46
  }