laymur 0.11.5 → 0.12.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 (47) hide show
  1. package/README.md +33 -29
  2. package/dist/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +1 -1
  3. package/dist/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +1 -1
  4. package/dist/constraints/UIConstraint.d.ts +2 -2
  5. package/dist/constraints/UICustomConstraint.d.ts +3 -3
  6. package/dist/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +1 -1
  7. package/dist/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +1 -1
  8. package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +1 -1
  9. package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +1 -1
  10. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +1 -1
  11. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +1 -1
  12. package/dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +1 -1
  13. package/dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +1 -1
  14. package/dist/constraints/{UISingleParameterConstraint.Internal.d.ts → UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts} +5 -3
  15. package/dist/constraints/{UISingleParameterConstraint.d.ts → UISingleParameterConstraint/UISingleParameterConstraint.d.ts} +5 -5
  16. package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +1 -1
  17. package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +1 -1
  18. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +1 -1
  19. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +1 -1
  20. package/dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +1 -1
  21. package/dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +1 -1
  22. package/dist/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +1 -1
  23. package/dist/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +1 -1
  24. package/dist/elements/UIAnchor/UIAnchor.d.ts +1 -1
  25. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +15 -3
  26. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +12 -6
  27. package/dist/elements/UIElement/UIElement.d.ts +1 -1
  28. package/dist/elements/UIGraphics/UIGraphics.d.ts +1 -1
  29. package/dist/elements/UIImage/UIImage.d.ts +1 -1
  30. package/dist/elements/UIInputDummy/UIInputDummy.d.ts +1 -1
  31. package/dist/elements/UINineSlice/UINineSlice.d.ts +10 -6
  32. package/dist/elements/UIProgress/UIProgress.d.ts +1 -1
  33. package/dist/elements/UIScene/UIScene.d.ts +1 -1
  34. package/dist/elements/UIText/UIText.d.ts +2 -2
  35. package/dist/index.d.ts +3 -2
  36. package/dist/index.js +185 -98
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.min.js +1 -1
  39. package/dist/index.min.js.map +1 -1
  40. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +9 -0
  41. package/dist/layers/{UIFullscreenLayer.d.ts → UIFullscreenLayer/UIFullscreenLayer.d.ts} +4 -8
  42. package/dist/layers/UILayer/UILayer.Internal.d.ts +29 -0
  43. package/dist/layers/{UILayer.d.ts → UILayer/UILayer.d.ts} +4 -9
  44. package/dist/miscellaneous/asserts.d.ts +1 -1
  45. package/dist/miscellaneous/shared.d.ts +1 -1
  46. package/package.json +1 -1
  47. package/dist/layers/UILayer.Internal.d.ts +0 -15
package/dist/index.js CHANGED
@@ -3995,28 +3995,35 @@ var UILayerEvent;
3995
3995
  /** Fired during rendering */
3996
3996
  UILayerEvent["RENDERING"] = "rendering";
3997
3997
  })(UILayerEvent || (UILayerEvent = {}));
3998
+ const LAYER_DEFAULT_SIZE = 1024;
3999
+ const LAYER_DEFAULT_NAME = "";
4000
+ const LAYER_DEFAULT_MODE = UIMode.VISIBLE;
3998
4001
 
3999
4002
  /** Base layer for UI rendering and layout management */
4000
4003
  class UILayer extends i {
4001
- /**
4002
- * @param w Initial width in world units
4003
- * @param h Initial height in world units
4004
- * @param mode Initial visibility and interactivity mode
4005
- */
4006
- constructor(w, h, mode) {
4004
+ constructor(options) {
4007
4005
  super();
4008
4006
  /** Optional layer name */
4009
4007
  this.name = "";
4010
4008
  this.inputWrapperInternal = new UIInputWrapper();
4011
4009
  this._private_solverWrapperInternal = new UISolverWrapper();
4012
- this._private_sceneWrapperInternal = new UISceneWrapper(w, h);
4013
- this._private_modeInternal = mode;
4010
+ if (options.width !== undefined) {
4011
+ assertValidPositiveNumber(options.width, "UILayer.constructor.options.width");
4012
+ }
4013
+ if (options.height !== undefined) {
4014
+ assertValidPositiveNumber(options.height, "UILayer.constructor.options.height");
4015
+ }
4016
+ const width = options.width ?? LAYER_DEFAULT_SIZE;
4017
+ const height = options.height ?? LAYER_DEFAULT_SIZE;
4018
+ this._private_sceneWrapperInternal = new UISceneWrapper(width, height);
4019
+ this.name = options.name ?? LAYER_DEFAULT_NAME;
4020
+ this._private_modeInternal = options.mode ?? LAYER_DEFAULT_MODE;
4014
4021
  this._private_orientationInternal =
4015
- w > h ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
4022
+ width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
4016
4023
  this.xVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
4017
4024
  this.yVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
4018
- this.wVariable = this._private_solverWrapperInternal.createVariable(w, UIPriority.P0);
4019
- this.hVariable = this._private_solverWrapperInternal.createVariable(h, UIPriority.P0);
4025
+ this.wVariable = this._private_solverWrapperInternal.createVariable(width, UIPriority.P0);
4026
+ this.hVariable = this._private_solverWrapperInternal.createVariable(height, UIPriority.P0);
4020
4027
  }
4021
4028
  /** @internal */
4022
4029
  get sceneWrapper() {
@@ -4289,11 +4296,10 @@ function assertValidInterpolationConstraintArguments(subject, a, b, c, anchorA,
4289
4296
  /** Base class for layout constraints */
4290
4297
  class UIConstraint {
4291
4298
  /** @param layer Layer containing this constraint */
4292
- constructor(layer) {
4299
+ constructor(layer, name) {
4293
4300
  this.layer = layer;
4294
- /** Optional constraint name */
4295
- this.name = "";
4296
4301
  this.solverWrapper = this.layer.solverWrapper;
4302
+ this.name = name ?? "";
4297
4303
  }
4298
4304
  }
4299
4305
 
@@ -4304,7 +4310,7 @@ class UISingleParameterConstraint extends UIConstraint {
4304
4310
  * @param options Constraint configuration
4305
4311
  */
4306
4312
  constructor(layer, options) {
4307
- super(layer);
4313
+ super(layer, options?.name);
4308
4314
  /** Updates constraint enabled state when layer orientation changes */
4309
4315
  this._private_onOrientationChange = () => {
4310
4316
  this.solverWrapper.setConstraintEnabled(this.constraint, this.isConstraintEnabled());
@@ -6098,8 +6104,19 @@ var UIAnimatedImageEvent;
6098
6104
  /** Animation stopped and reset */
6099
6105
  UIAnimatedImageEvent[UIAnimatedImageEvent["STOPPED"] = 2] = "STOPPED";
6100
6106
  })(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
6107
+ /** Animation loop behavior */
6108
+ var UILoopMode;
6109
+ (function (UILoopMode) {
6110
+ /** No looping, stops at boundary frame */
6111
+ UILoopMode[UILoopMode["NONE"] = 0] = "NONE";
6112
+ /** Loops back to opposite frame */
6113
+ UILoopMode[UILoopMode["LOOP"] = 1] = "LOOP";
6114
+ /** Reverses direction at boundaries */
6115
+ UILoopMode[UILoopMode["PING_PONG"] = 2] = "PING_PONG";
6116
+ })(UILoopMode || (UILoopMode = {}));
6101
6117
  const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;
6102
- const ANIMATED_IMAGE_DEFAULT_LOOP = true;
6118
+ const ANIMATED_IMAGE_DEFAULT_TIME_SCALE = 1;
6119
+ const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UILoopMode.LOOP;
6103
6120
 
6104
6121
  /** Frame-based texture animation element */
6105
6122
  class UIAnimatedImage extends UIElement {
@@ -6138,7 +6155,10 @@ class UIAnimatedImage extends UIElement {
6138
6155
  this._private_textureTransform = textureTransform;
6139
6156
  this._private_frameRateInternal =
6140
6157
  options.frameRate ?? ANIMATED_IMAGE_DEFAULT_FRAME_RATE;
6141
- this._private_loopInternal = options.loop ?? ANIMATED_IMAGE_DEFAULT_LOOP;
6158
+ this._private_timeScaleInternal =
6159
+ options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
6160
+ this._private_loopModeInternal =
6161
+ options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
6142
6162
  this.color = color;
6143
6163
  this._private_subscribeSequenceEvents();
6144
6164
  if (options.playByDefault === true) {
@@ -6153,9 +6173,13 @@ class UIAnimatedImage extends UIElement {
6153
6173
  get frameRate() {
6154
6174
  return this._private_frameRateInternal;
6155
6175
  }
6156
- /** Whether animation repeats after completion */
6157
- get loop() {
6158
- return this._private_loopInternal;
6176
+ /** Playback speed multiplier. Can be negative for reverse playback. */
6177
+ get timeScale() {
6178
+ return this._private_timeScaleInternal;
6179
+ }
6180
+ /** Loop behavior */
6181
+ get loopMode() {
6182
+ return this._private_loopModeInternal;
6159
6183
  }
6160
6184
  /** Total animation duration in seconds */
6161
6185
  get duration() {
@@ -6185,9 +6209,14 @@ class UIAnimatedImage extends UIElement {
6185
6209
  assertValidPositiveNumber(value, "UIAnimatedImage.frameRate");
6186
6210
  this._private_frameRateInternal = value;
6187
6211
  }
6188
- /** Whether animation repeats after completion */
6189
- set loop(value) {
6190
- this._private_loopInternal = value;
6212
+ /** Playback speed multiplier. Can be negative for reverse playback. */
6213
+ set timeScale(value) {
6214
+ assertValidNumber(value, "UIAnimatedImage.timeScale");
6215
+ this._private_timeScaleInternal = value;
6216
+ }
6217
+ /** Loop behavior */
6218
+ set loopMode(value) {
6219
+ this._private_loopModeInternal = value;
6191
6220
  }
6192
6221
  /** Removes element and frees resources */
6193
6222
  destroy() {
@@ -6221,22 +6250,54 @@ class UIAnimatedImage extends UIElement {
6221
6250
  }
6222
6251
  }
6223
6252
  onWillRender(renderer, deltaTime) {
6224
- if (this._private_isPlaying) {
6225
- this._private_accumulatedTime += deltaTime;
6253
+ if (this._private_isPlaying && this._private_timeScaleInternal !== 0) {
6254
+ this._private_accumulatedTime += deltaTime * this._private_timeScaleInternal;
6226
6255
  const frameDuration = 1 / this._private_frameRateInternal;
6227
- while (this._private_accumulatedTime >= frameDuration) {
6228
- this._private_accumulatedTime -= frameDuration;
6229
- this._private_sequenceFrameIndex += 1;
6230
- if (this._private_loopInternal) {
6231
- this._private_sequenceFrameIndex %= this._private_sequenceInternal.length;
6256
+ const sequenceLength = this._private_sequenceInternal.length;
6257
+ const lastFrameIndex = sequenceLength - 1;
6258
+ if (this._private_timeScaleInternal > 0) {
6259
+ while (this._private_accumulatedTime >= frameDuration) {
6260
+ this._private_accumulatedTime -= frameDuration;
6261
+ this._private_sequenceFrameIndex += 1;
6262
+ if (this._private_sequenceFrameIndex >= sequenceLength) {
6263
+ if (this._private_loopModeInternal === UILoopMode.LOOP) {
6264
+ this._private_sequenceFrameIndex = 0;
6265
+ }
6266
+ else if (this._private_loopModeInternal === UILoopMode.PING_PONG) {
6267
+ this._private_sequenceFrameIndex = lastFrameIndex;
6268
+ this._private_timeScaleInternal = -this._private_timeScaleInternal;
6269
+ }
6270
+ else {
6271
+ this._private_sequenceFrameIndex = lastFrameIndex;
6272
+ this._private_isPlaying = false;
6273
+ this.emit(UIAnimatedImageEvent.PAUSED);
6274
+ break;
6275
+ }
6276
+ }
6277
+ this._private_currentFrameIndexDirty = true;
6232
6278
  }
6233
- else if (this._private_sequenceFrameIndex >= this._private_sequenceInternal.length) {
6234
- this._private_sequenceFrameIndex = this._private_sequenceInternal.length - 1;
6235
- this._private_isPlaying = false;
6236
- this.emit(UIAnimatedImageEvent.PAUSED);
6237
- break;
6279
+ }
6280
+ else {
6281
+ while (this._private_accumulatedTime <= -frameDuration) {
6282
+ this._private_accumulatedTime += frameDuration;
6283
+ this._private_sequenceFrameIndex -= 1;
6284
+ if (this._private_sequenceFrameIndex < 0) {
6285
+ if (this._private_loopModeInternal === UILoopMode.LOOP) {
6286
+ this._private_sequenceFrameIndex = lastFrameIndex;
6287
+ }
6288
+ else if (this._private_loopModeInternal === UILoopMode.PING_PONG) {
6289
+ this._private_sequenceFrameIndex = 0;
6290
+ this._private_timeScaleInternal = -this._private_timeScaleInternal;
6291
+ }
6292
+ else {
6293
+ this._private_sequenceFrameIndex = 0;
6294
+ this._private_isPlaying = false;
6295
+ this.emit(UIAnimatedImageEvent.PAUSED);
6296
+ break;
6297
+ }
6298
+ }
6299
+ this._private_currentFrameIndexDirty = true;
6238
6300
  }
6239
- this._private_currentFrameIndexDirty = true;
6240
6301
  }
6241
6302
  }
6242
6303
  super.onWillRender(renderer, deltaTime);
@@ -6688,9 +6749,13 @@ class UINineSlice extends UIElement {
6688
6749
  sliceBorders: sliceBordersVector,
6689
6750
  sliceRegions: sliceRegionsVector,
6690
6751
  }, options);
6691
- this._private_regionModeDirty = false;
6752
+ this._private_regionModeDirty = true;
6692
6753
  this._private_sliceBordersVector = new Vector4();
6693
6754
  this._private_sliceRegionsVector = new Vector4();
6755
+ this._private_textureDimensionsDirty = true;
6756
+ this._private_onTextureDimensionsChanged = () => {
6757
+ this._private_textureDimensionsDirty = true;
6758
+ };
6694
6759
  this.texture = textureView;
6695
6760
  this._private_textureTransform = textureTransform;
6696
6761
  this.color = color;
@@ -6699,8 +6764,9 @@ class UINineSlice extends UIElement {
6699
6764
  this._private_regionModeInternal = regionMode;
6700
6765
  this._private_sliceBordersVector = sliceBordersVector;
6701
6766
  this._private_sliceRegionsVector = sliceRegionsVector;
6702
- this._private_lastWidth = this.width;
6703
- this._private_lastHeight = this.height;
6767
+ this._private_lastElementWidth = this.width;
6768
+ this._private_lastElementHeight = this.height;
6769
+ this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6704
6770
  }
6705
6771
  /** Controls how sliceRegions values are interpreted */
6706
6772
  get regionMode() {
@@ -6713,44 +6779,60 @@ class UINineSlice extends UIElement {
6713
6779
  this._private_regionModeDirty = true;
6714
6780
  }
6715
6781
  }
6782
+ /** Removes nine slice and frees resources */
6783
+ destroy() {
6784
+ this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6785
+ super.destroy();
6786
+ }
6716
6787
  setPlaneTransform() {
6717
- if (this._private_regionModeDirty ||
6718
- this.texture.textureDirty ||
6719
- this.texture.uvTransformDirty ||
6720
- this.texture.trimDirty ||
6721
- this.color.dirty ||
6788
+ let properties;
6789
+ const sliceBordersDirty = this._private_textureDimensionsDirty ||
6722
6790
  this.sliceBorders.dirty ||
6723
- this.sliceRegions.dirty ||
6791
+ this.texture.trimDirty;
6792
+ if (sliceBordersDirty) {
6793
+ properties ?? (properties = {});
6794
+ properties["sliceBorders"] = this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
6795
+ this.sliceBorders.setDirtyFalse();
6796
+ this._private_textureDimensionsDirty = false;
6797
+ }
6798
+ const sliceRegionsDirty = this.sliceRegions.dirty || this._private_regionModeDirty ||
6724
6799
  (this._private_regionModeInternal === UINineSliceRegionMode.WORLD &&
6725
- this._private_checkDimensionsDirty())) {
6726
- this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
6727
- this._private_calculateSliceRegionsForShader(this._private_sliceRegionsVector);
6728
- this.sceneWrapper.setProperties(this.planeHandler, {
6729
- texture: this.texture.texture,
6730
- textureTransform: this.texture.calculateUVTransform(this._private_textureTransform),
6731
- color: this.color,
6732
- sliceBorders: this._private_sliceBordersVector,
6733
- sliceRegions: this._private_sliceRegionsVector,
6734
- });
6800
+ this._private_checkElementDimensionsDirty());
6801
+ if (sliceRegionsDirty) {
6802
+ properties ?? (properties = {});
6803
+ properties["sliceRegions"] = this._private_calculateSliceRegionsForShader(this._private_sliceRegionsVector);
6804
+ this.sliceRegions.setDirtyFalse();
6735
6805
  this._private_regionModeDirty = false;
6806
+ this._private_setElementDimensionsDirtyFalse();
6807
+ }
6808
+ if (this.color.dirty) {
6809
+ properties ?? (properties = {});
6810
+ properties["color"] = this.color;
6736
6811
  this.color.setDirtyFalse();
6737
- this.sliceBorders.setDirtyFalse();
6738
- this.sliceRegions.setDirtyFalse();
6739
- this._private_setDimensionsDirtyFalse();
6740
6812
  }
6741
- if (this.texture.textureDirty ||
6742
- this.texture.uvTransformDirty ||
6813
+ if (this.texture.textureDirty) {
6814
+ properties ?? (properties = {});
6815
+ properties["texture"] = this.texture.texture;
6816
+ this.texture.setTextureDirtyFalse();
6817
+ }
6818
+ if (this.texture.uvTransformDirty) {
6819
+ properties ?? (properties = {});
6820
+ properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
6821
+ this.texture.setUVTransformDirtyFalse();
6822
+ }
6823
+ if (properties) {
6824
+ this.sceneWrapper.setProperties(this.planeHandler, properties);
6825
+ }
6826
+ const isTransformDirty = this.micro.dirty ||
6743
6827
  this.texture.trimDirty ||
6744
- this.micro.dirty ||
6745
6828
  this.inputWrapper.dirty ||
6746
- this.solverWrapper.dirty) {
6747
- const trim = this.texture.trim;
6829
+ this.solverWrapper.dirty;
6830
+ if (isTransformDirty) {
6748
6831
  const micro = this.micro;
6749
- this.sceneWrapper.setTransform(this.planeHandler, computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, trim.left, trim.right, trim.top, trim.bottom));
6750
- this.texture.setTextureDirtyFalse();
6751
- this.texture.setUVTransformDirtyFalse();
6752
- this.texture.setTrimDirtyFalse();
6832
+ const textureTrim = this.texture.trim;
6833
+ this.sceneWrapper.setTransform(this.planeHandler, computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, textureTrim.left, textureTrim.right, textureTrim.top, textureTrim.bottom));
6753
6834
  this.micro.setDirtyFalse();
6835
+ this.texture.setTrimDirtyFalse();
6754
6836
  }
6755
6837
  }
6756
6838
  _private_calculateSliceBordersForShader(result) {
@@ -6783,14 +6865,14 @@ class UINineSlice extends UIElement {
6783
6865
  const height = this.height;
6784
6866
  return result.set(this.sliceRegions.left / width, this.sliceRegions.right / width, this.sliceRegions.top / height, this.sliceRegions.bottom / height);
6785
6867
  }
6786
- _private_checkDimensionsDirty() {
6868
+ _private_checkElementDimensionsDirty() {
6787
6869
  return (this.solverWrapper.dirty &&
6788
- (this._private_lastWidth !== Math.round(this.width) ||
6789
- this._private_lastHeight !== Math.round(this.height)));
6870
+ (this._private_lastElementWidth !== Math.round(this.width) ||
6871
+ this._private_lastElementHeight !== Math.round(this.height)));
6790
6872
  }
6791
- _private_setDimensionsDirtyFalse() {
6792
- this._private_lastWidth = Math.round(this.width);
6793
- this._private_lastHeight = Math.round(this.height);
6873
+ _private_setElementDimensionsDirtyFalse() {
6874
+ this._private_lastElementWidth = Math.round(this.width);
6875
+ this._private_lastElementHeight = Math.round(this.height);
6794
6876
  }
6795
6877
  }
6796
6878
 
@@ -7886,10 +7968,6 @@ class UIText extends UIElement {
7886
7968
  super.destroy();
7887
7969
  }
7888
7970
  onWillRender(renderer, deltaTime) {
7889
- if (this.color.dirty) {
7890
- this.sceneWrapper.setProperties(this.planeHandler, { color: this.color });
7891
- this.color.setDirtyFalse();
7892
- }
7893
7971
  switch (this._private_resizeModeInternal) {
7894
7972
  case UITextResizeMode.SCALE:
7895
7973
  this._private_tryToRenderTextScaleMode();
@@ -7929,9 +8007,7 @@ class UIText extends UIElement {
7929
8007
  this._private_canvas.width = desiredWidth;
7930
8008
  }
7931
8009
  renderTextLines(this.padding.top, this.padding.left, lines, this._private_context);
7932
- if (resolutionDirty) {
7933
- this._private_rebuildTexture();
7934
- }
8010
+ this._private_updateProperties(resolutionDirty);
7935
8011
  this._private_resizeModeDirty = false;
7936
8012
  this._private_maxLineWidthDirty = false;
7937
8013
  this.padding.setDirtyFalse();
@@ -7966,23 +8042,31 @@ class UIText extends UIElement {
7966
8042
  this._private_canvas.height = safeHeight;
7967
8043
  }
7968
8044
  renderTextLines(this.padding.top, this.padding.left, realTextLines, this._private_context);
7969
- if (resolutionDirty) {
7970
- this._private_rebuildTexture();
7971
- }
8045
+ this._private_updateProperties(resolutionDirty);
7972
8046
  this._private_resizeModeDirty = false;
7973
8047
  this._private_maxLineWidthDirty = false;
7974
8048
  this.padding.setDirtyFalse();
7975
8049
  this._private_setDimensionsDirtyFalse();
7976
8050
  this._private_setContentDirtyFalse();
7977
8051
  }
7978
- _private_rebuildTexture() {
7979
- this._private_texture.dispose();
7980
- this._private_texture = new CanvasTexture(this._private_canvas);
7981
- this._private_texture.colorSpace = SRGBColorSpace;
7982
- this._private_texture.needsUpdate = true;
7983
- this.sceneWrapper.setProperties(this.planeHandler, {
7984
- texture: this._private_texture,
7985
- });
8052
+ _private_updateProperties(resolutionDirty) {
8053
+ let properties;
8054
+ if (this.color.dirty) {
8055
+ properties ?? (properties = {});
8056
+ properties["color"] = this.color;
8057
+ this.color.setDirtyFalse();
8058
+ }
8059
+ if (resolutionDirty) {
8060
+ this._private_texture.dispose();
8061
+ this._private_texture = new CanvasTexture(this._private_canvas);
8062
+ this._private_texture.colorSpace = SRGBColorSpace;
8063
+ this._private_texture.needsUpdate = true;
8064
+ properties ?? (properties = {});
8065
+ properties["texture"] = this._private_texture;
8066
+ }
8067
+ if (properties) {
8068
+ this.sceneWrapper.setProperties(this.planeHandler, properties);
8069
+ }
7986
8070
  }
7987
8071
  _private_buildTextChunks() {
7988
8072
  if (this._private_textChunksDirty) {
@@ -8028,15 +8112,18 @@ class UIResizePolicyNone extends UIResizePolicy {
8028
8112
  }
8029
8113
  }
8030
8114
 
8115
+ const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY = new UIResizePolicyNone();
8116
+
8031
8117
  /** Layer that automatically handles browser window resizing and input events */
8032
8118
  class UIFullscreenLayer extends UILayer {
8033
- /**
8034
- * @param resizePolicy Strategy for handling window resize
8035
- * @param mode Initial visibility and interactivity mode
8036
- */
8037
- constructor(resizePolicy = new UIResizePolicyNone(), mode = UIMode.VISIBLE) {
8119
+ constructor(options) {
8120
+ const resizePolicy = options?.resizePolicy ?? FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;
8038
8121
  const scale = resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
8039
- super(window.innerWidth * scale, window.innerHeight * scale, mode);
8122
+ super({
8123
+ width: window.innerWidth * scale,
8124
+ height: window.innerHeight * scale,
8125
+ ...options,
8126
+ });
8040
8127
  this._private_resizePolicyDirty = false;
8041
8128
  this._private_onResize = () => {
8042
8129
  const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
@@ -8609,5 +8696,5 @@ class UIResizePolicyFixedWidth extends UIResizePolicy {
8609
8696
  }
8610
8697
  }
8611
8698
 
8612
- export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
8699
+ export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UILoopMode, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
8613
8700
  //# sourceMappingURL=index.js.map