laymur 0.3.16 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/UIAnimatedImage.d.ts +119 -0
- package/dist/elements/UIGraphics.d.ts +122 -0
- package/dist/elements/UIText.d.ts +5 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.js +743 -229
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layers/UIFullscreenLayer.d.ts +25 -84
- package/dist/miscellaneous/UIMicro.d.ts +6 -1
- package/dist/miscellaneous/UITextPadding.d.ts +2 -2
- package/dist/miscellaneous/resizePolicies.d.ts +99 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlaneGeometry, Color, Scene, OrthographicCamera, ShaderMaterial, Vector4, Mesh, Texture, Vector2, Vector3, Matrix2, Matrix3, Matrix4, MathUtils, Quaternion, WebGLRenderTarget, UnsignedByteType,
|
|
1
|
+
import { PlaneGeometry, Color, Scene, OrthographicCamera, ShaderMaterial, Vector4, Mesh, Texture, Vector2, Vector3, Matrix2, Matrix3, Matrix4, MathUtils, Quaternion, CanvasTexture, LinearFilter, WebGLRenderTarget, UnsignedByteType, RGBAFormat, PerspectiveCamera, InstancedBufferGeometry, InstancedBufferAttribute } from 'three';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Mathematical expression builder for constraint equations in the UI layout system.
|
|
@@ -2108,18 +2108,29 @@ class UIColor extends i {
|
|
|
2108
2108
|
*/
|
|
2109
2109
|
copy(color) {
|
|
2110
2110
|
if (color instanceof UIColor) {
|
|
2111
|
-
this.rInternal
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2111
|
+
if (this.rInternal !== color.rInternal &&
|
|
2112
|
+
this.gInternal !== color.gInternal &&
|
|
2113
|
+
this.bInternal !== color.bInternal &&
|
|
2114
|
+
this.aInternal !== color.aInternal) {
|
|
2115
|
+
this.rInternal = color.rInternal;
|
|
2116
|
+
this.gInternal = color.gInternal;
|
|
2117
|
+
this.bInternal = color.bInternal;
|
|
2118
|
+
this.aInternal = color.aInternal;
|
|
2119
|
+
this.emit(UIColorEvent.CHANGE, this);
|
|
2120
|
+
}
|
|
2115
2121
|
}
|
|
2116
2122
|
else {
|
|
2117
|
-
this.rInternal
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2123
|
+
if (this.rInternal !== color.r &&
|
|
2124
|
+
this.gInternal !== color.g &&
|
|
2125
|
+
this.bInternal !== color.b &&
|
|
2126
|
+
this.aInternal !== 1) {
|
|
2127
|
+
this.rInternal = color.r;
|
|
2128
|
+
this.gInternal = color.g;
|
|
2129
|
+
this.bInternal = color.b;
|
|
2130
|
+
this.aInternal = 1;
|
|
2131
|
+
this.emit(UIColorEvent.CHANGE, this);
|
|
2132
|
+
}
|
|
2121
2133
|
}
|
|
2122
|
-
this.emit(UIColorEvent.CHANGE, this);
|
|
2123
2134
|
return this;
|
|
2124
2135
|
}
|
|
2125
2136
|
/**
|
|
@@ -4345,91 +4356,7 @@ class UIAnchor extends i {
|
|
|
4345
4356
|
}
|
|
4346
4357
|
}
|
|
4347
4358
|
|
|
4348
|
-
|
|
4349
|
-
const DEFAULT_SIZE = 100;
|
|
4350
|
-
/**
|
|
4351
|
-
* Abstract UI element that extends UIAnchor with dimensions but without rendering.
|
|
4352
|
-
*
|
|
4353
|
-
* UIDummy represents a rectangular area in the UI layout system that has position
|
|
4354
|
-
* and dimensions (width and height) but does not perform any visual rendering.
|
|
4355
|
-
* It serves as a placeholder or spacer element in constraint-based layouts,
|
|
4356
|
-
* useful for defining layout structure without visual content.
|
|
4357
|
-
*
|
|
4358
|
-
* @see {@link UIAnchor} - Base class providing position functionality
|
|
4359
|
-
* @see {@link UIPlaneElement} - Interface defining dimensional element behavior
|
|
4360
|
-
* @see {@link UILayer} - Container layer for UI elements
|
|
4361
|
-
*/
|
|
4362
|
-
class UIDummy extends UIAnchor {
|
|
4363
|
-
/**
|
|
4364
|
-
* Creates a new UIDummy instance with position and dimensions.
|
|
4365
|
-
*
|
|
4366
|
-
* @param layer - The UI layer that contains this dummy element
|
|
4367
|
-
* @param x - Initial x-coordinate position
|
|
4368
|
-
* @param y - Initial y-coordinate position
|
|
4369
|
-
* @param width - Initial width dimension (defaults to 100)
|
|
4370
|
-
* @param height - Initial height dimension (defaults to 100)
|
|
4371
|
-
* @throws Will throw an error if width or height are not valid positive numbers
|
|
4372
|
-
* @see {@link assertValidPositiveNumber}
|
|
4373
|
-
*/
|
|
4374
|
-
constructor(layer, options = {}) {
|
|
4375
|
-
const x = options.x ?? 0;
|
|
4376
|
-
const y = options.y ?? 0;
|
|
4377
|
-
const w = options.width ?? DEFAULT_SIZE;
|
|
4378
|
-
const h = options.height ?? DEFAULT_SIZE;
|
|
4379
|
-
assertValidPositiveNumber(w, "UIDummy width");
|
|
4380
|
-
assertValidPositiveNumber(h, "UIDummy height");
|
|
4381
|
-
super(layer, x, y);
|
|
4382
|
-
this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);
|
|
4383
|
-
this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);
|
|
4384
|
-
}
|
|
4385
|
-
/**
|
|
4386
|
-
* Gets the current width value from the solver.
|
|
4387
|
-
* @returns The current width dimension
|
|
4388
|
-
*/
|
|
4389
|
-
get width() {
|
|
4390
|
-
return this.solverWrapper.readVariableValue(this.wVariable);
|
|
4391
|
-
}
|
|
4392
|
-
/**
|
|
4393
|
-
* Gets the current height value from the solver.
|
|
4394
|
-
* @returns The current height dimension
|
|
4395
|
-
*/
|
|
4396
|
-
get height() {
|
|
4397
|
-
return this.solverWrapper.readVariableValue(this.hVariable);
|
|
4398
|
-
}
|
|
4399
|
-
/**
|
|
4400
|
-
* Sets the width value through the solver system.
|
|
4401
|
-
* @param value - The new width dimension (must be positive)
|
|
4402
|
-
* @throws Will throw an error if value is not a valid positive number
|
|
4403
|
-
* @see {@link assertValidPositiveNumber}
|
|
4404
|
-
*/
|
|
4405
|
-
set width(value) {
|
|
4406
|
-
assertValidPositiveNumber(value, "UIDummy width");
|
|
4407
|
-
this.solverWrapper.suggestVariableValue(this.wVariable, value);
|
|
4408
|
-
}
|
|
4409
|
-
/**
|
|
4410
|
-
* Sets the height value through the solver system.
|
|
4411
|
-
* @param value - The new height dimension (must be positive)
|
|
4412
|
-
* @throws Will throw an error if value is not a valid positive number
|
|
4413
|
-
* @see {@link assertValidPositiveNumber}
|
|
4414
|
-
*/
|
|
4415
|
-
set height(value) {
|
|
4416
|
-
assertValidPositiveNumber(value, "UIDummy height");
|
|
4417
|
-
this.solverWrapper.suggestVariableValue(this.hVariable, value);
|
|
4418
|
-
}
|
|
4419
|
-
/**
|
|
4420
|
-
* Destroys the dummy element by removing its solver variables.
|
|
4421
|
-
*
|
|
4422
|
-
* This method cleans up the dimension solver variables (width and height)
|
|
4423
|
-
* associated with this dummy element, then calls the parent destroy method
|
|
4424
|
-
* to clean up position variables. After calling this method, the dummy
|
|
4425
|
-
* element should not be used anymore.
|
|
4426
|
-
*/
|
|
4427
|
-
destroy() {
|
|
4428
|
-
this.solverWrapper.removeVariable(this.hVariable);
|
|
4429
|
-
this.solverWrapper.removeVariable(this.wVariable);
|
|
4430
|
-
super.destroy();
|
|
4431
|
-
}
|
|
4432
|
-
}
|
|
4359
|
+
var source$2 = "void main() {\n vec2 transformedUV = (uvTransform * vec3(io_UV, 1.0)).xy;\n vec4 diffuseColor = texture(map, transformedUV) * color;\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <colorspace_fragment>\n}\n";
|
|
4433
4360
|
|
|
4434
4361
|
/**
|
|
4435
4362
|
* Events that can be emitted by UI elements.
|
|
@@ -4451,6 +4378,10 @@ var UIMicroAnchorMode;
|
|
|
4451
4378
|
UIMicroAnchorMode[UIMicroAnchorMode["POSITION_ROTATION_SCALE"] = 1] = "POSITION_ROTATION_SCALE";
|
|
4452
4379
|
})(UIMicroAnchorMode || (UIMicroAnchorMode = {}));
|
|
4453
4380
|
|
|
4381
|
+
var UIMicroEvent;
|
|
4382
|
+
(function (UIMicroEvent) {
|
|
4383
|
+
UIMicroEvent[UIMicroEvent["CHANGE"] = 0] = "CHANGE";
|
|
4384
|
+
})(UIMicroEvent || (UIMicroEvent = {}));
|
|
4454
4385
|
/** Default position value for x and y coordinates. */
|
|
4455
4386
|
const DEFAULT_POSITION = 0;
|
|
4456
4387
|
/** Default anchor point value for anchorX and anchorY. */
|
|
@@ -4473,8 +4404,9 @@ const DEFAULT_ROTATION = 0;
|
|
|
4473
4404
|
*
|
|
4474
4405
|
* @see {@link UIElement} - Elements that use micro transformations
|
|
4475
4406
|
*/
|
|
4476
|
-
class UIMicro {
|
|
4407
|
+
class UIMicro extends i {
|
|
4477
4408
|
constructor() {
|
|
4409
|
+
super(...arguments);
|
|
4478
4410
|
/** Internal storage for x-coordinate offset. */
|
|
4479
4411
|
this._private_xInternal = DEFAULT_POSITION;
|
|
4480
4412
|
/** Internal storage for y-coordinate offset. */
|
|
@@ -4572,6 +4504,7 @@ class UIMicro {
|
|
|
4572
4504
|
if (value !== this._private_xInternal) {
|
|
4573
4505
|
this._private_xInternal = value;
|
|
4574
4506
|
this._private_recalculationRequired = true;
|
|
4507
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4575
4508
|
}
|
|
4576
4509
|
}
|
|
4577
4510
|
/**
|
|
@@ -4582,6 +4515,7 @@ class UIMicro {
|
|
|
4582
4515
|
if (value !== this._private_yInternal) {
|
|
4583
4516
|
this._private_yInternal = value;
|
|
4584
4517
|
this._private_recalculationRequired = true;
|
|
4518
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4585
4519
|
}
|
|
4586
4520
|
}
|
|
4587
4521
|
/**
|
|
@@ -4592,6 +4526,7 @@ class UIMicro {
|
|
|
4592
4526
|
if (value !== this._private_anchorXInternal) {
|
|
4593
4527
|
this._private_anchorXInternal = value;
|
|
4594
4528
|
this._private_recalculationRequired = true;
|
|
4529
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4595
4530
|
}
|
|
4596
4531
|
}
|
|
4597
4532
|
/**
|
|
@@ -4602,6 +4537,7 @@ class UIMicro {
|
|
|
4602
4537
|
if (value !== this._private_anchorYInternal) {
|
|
4603
4538
|
this._private_anchorYInternal = value;
|
|
4604
4539
|
this._private_recalculationRequired = true;
|
|
4540
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4605
4541
|
}
|
|
4606
4542
|
}
|
|
4607
4543
|
/**
|
|
@@ -4612,6 +4548,7 @@ class UIMicro {
|
|
|
4612
4548
|
if (value !== this._private_scaleXInternal) {
|
|
4613
4549
|
this._private_scaleXInternal = value;
|
|
4614
4550
|
this._private_recalculationRequired = true;
|
|
4551
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4615
4552
|
}
|
|
4616
4553
|
}
|
|
4617
4554
|
/**
|
|
@@ -4622,6 +4559,7 @@ class UIMicro {
|
|
|
4622
4559
|
if (value !== this._private_scaleYInternal) {
|
|
4623
4560
|
this._private_scaleYInternal = value;
|
|
4624
4561
|
this._private_recalculationRequired = true;
|
|
4562
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4625
4563
|
}
|
|
4626
4564
|
}
|
|
4627
4565
|
/**
|
|
@@ -4633,6 +4571,7 @@ class UIMicro {
|
|
|
4633
4571
|
this._private_scaleXInternal = value;
|
|
4634
4572
|
this._private_scaleYInternal = value;
|
|
4635
4573
|
this._private_recalculationRequired = true;
|
|
4574
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4636
4575
|
}
|
|
4637
4576
|
}
|
|
4638
4577
|
/**
|
|
@@ -4644,6 +4583,7 @@ class UIMicro {
|
|
|
4644
4583
|
if (rotation !== this._private_rotationInternal) {
|
|
4645
4584
|
this._private_rotationInternal = rotation;
|
|
4646
4585
|
this._private_recalculationRequired = true;
|
|
4586
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4647
4587
|
}
|
|
4648
4588
|
}
|
|
4649
4589
|
/**
|
|
@@ -4654,6 +4594,7 @@ class UIMicro {
|
|
|
4654
4594
|
if (value !== this._private_rotationInternal) {
|
|
4655
4595
|
this._private_rotationInternal = value;
|
|
4656
4596
|
this._private_recalculationRequired = true;
|
|
4597
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4657
4598
|
}
|
|
4658
4599
|
}
|
|
4659
4600
|
/**
|
|
@@ -4664,6 +4605,7 @@ class UIMicro {
|
|
|
4664
4605
|
if (value !== this._private_anchorModeInternal) {
|
|
4665
4606
|
this._private_anchorModeInternal = value;
|
|
4666
4607
|
this._private_recalculationRequired = true;
|
|
4608
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4667
4609
|
}
|
|
4668
4610
|
}
|
|
4669
4611
|
/**
|
|
@@ -4689,6 +4631,28 @@ class UIMicro {
|
|
|
4689
4631
|
this._private_scaleYInternal = DEFAULT_SCALE;
|
|
4690
4632
|
this._private_rotationInternal = DEFAULT_ROTATION;
|
|
4691
4633
|
this._private_recalculationRequired = true;
|
|
4634
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4637
|
+
copy(value) {
|
|
4638
|
+
if (this._private_xInternal !== value._private_xInternal &&
|
|
4639
|
+
this._private_yInternal !== value._private_yInternal &&
|
|
4640
|
+
this._private_anchorXInternal !== value._private_anchorXInternal &&
|
|
4641
|
+
this._private_anchorYInternal !== value._private_anchorYInternal &&
|
|
4642
|
+
this._private_scaleXInternal !== value._private_scaleXInternal &&
|
|
4643
|
+
this._private_scaleYInternal !== value._private_scaleYInternal &&
|
|
4644
|
+
this._private_rotationInternal !== value._private_rotationInternal &&
|
|
4645
|
+
this._private_anchorModeInternal !== value._private_anchorModeInternal) {
|
|
4646
|
+
this._private_xInternal = value._private_xInternal;
|
|
4647
|
+
this._private_yInternal = value._private_yInternal;
|
|
4648
|
+
this._private_anchorXInternal = value._private_anchorXInternal;
|
|
4649
|
+
this._private_anchorYInternal = value._private_anchorYInternal;
|
|
4650
|
+
this._private_scaleXInternal = value._private_scaleXInternal;
|
|
4651
|
+
this._private_scaleYInternal = value._private_scaleYInternal;
|
|
4652
|
+
this._private_rotationInternal = value._private_rotationInternal;
|
|
4653
|
+
this._private_anchorModeInternal = value._private_anchorModeInternal;
|
|
4654
|
+
this.emit(UIMicroEvent.CHANGE, this);
|
|
4655
|
+
this._private_recalculationRequired = true;
|
|
4692
4656
|
}
|
|
4693
4657
|
}
|
|
4694
4658
|
/**
|
|
@@ -4973,7 +4937,462 @@ class UIElement extends UIAnchor {
|
|
|
4973
4937
|
}
|
|
4974
4938
|
}
|
|
4975
4939
|
|
|
4976
|
-
var
|
|
4940
|
+
var UIAnimatedImageEvent;
|
|
4941
|
+
(function (UIAnimatedImageEvent) {
|
|
4942
|
+
UIAnimatedImageEvent[UIAnimatedImageEvent["PLAY"] = 0] = "PLAY";
|
|
4943
|
+
UIAnimatedImageEvent[UIAnimatedImageEvent["PAUSE"] = 1] = "PAUSE";
|
|
4944
|
+
UIAnimatedImageEvent[UIAnimatedImageEvent["STOP"] = 2] = "STOP";
|
|
4945
|
+
})(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
|
|
4946
|
+
/**
|
|
4947
|
+
* UI element for displaying textured images.
|
|
4948
|
+
*
|
|
4949
|
+
* UIAnimatedImage is a concrete implementation of UIElement that renders a textured
|
|
4950
|
+
* image using shader-based planes. It automatically sizes itself
|
|
4951
|
+
* to match the texture dimensions and provides control over visual properties
|
|
4952
|
+
* such as color tinting.
|
|
4953
|
+
*
|
|
4954
|
+
* @see {@link UIElement} - Base class providing UI element functionality
|
|
4955
|
+
* @see {@link Texture} - Three.js texture for image data
|
|
4956
|
+
*/
|
|
4957
|
+
class UIAnimatedImage extends UIElement {
|
|
4958
|
+
/**
|
|
4959
|
+
* Creates a new UIAnimatedImage instance.
|
|
4960
|
+
*
|
|
4961
|
+
* The image will automatically size itself to match the texture's dimensions.
|
|
4962
|
+
* All options have default values if not specified.
|
|
4963
|
+
*
|
|
4964
|
+
* @param layer - The UI layer that contains this image
|
|
4965
|
+
* @param texture - The Three.js texture to display
|
|
4966
|
+
* @param options - Configuration options for the image
|
|
4967
|
+
* @throws Will throw an error if the texture dimensions are not valid positive numbers
|
|
4968
|
+
*/
|
|
4969
|
+
constructor(layer, sequence, options = {}) {
|
|
4970
|
+
const w = options.width ?? 100;
|
|
4971
|
+
const h = options.height ?? 100;
|
|
4972
|
+
const color = options.color ?? new UIColor();
|
|
4973
|
+
let tempSequence;
|
|
4974
|
+
if (Array.isArray(sequence)) {
|
|
4975
|
+
tempSequence = sequence.map((texture) => {
|
|
4976
|
+
texture.updateMatrix();
|
|
4977
|
+
return {
|
|
4978
|
+
texture,
|
|
4979
|
+
uvTransform: texture.matrix,
|
|
4980
|
+
};
|
|
4981
|
+
});
|
|
4982
|
+
}
|
|
4983
|
+
else {
|
|
4984
|
+
tempSequence = sequence.transforms.map((transform) => {
|
|
4985
|
+
return {
|
|
4986
|
+
texture: sequence.texture,
|
|
4987
|
+
uvTransform: transform,
|
|
4988
|
+
};
|
|
4989
|
+
});
|
|
4990
|
+
}
|
|
4991
|
+
super(layer, options.x ?? 0, options.y ?? 0, w, h, source$2, {
|
|
4992
|
+
map: tempSequence[0].texture,
|
|
4993
|
+
uvTransform: tempSequence[0].uvTransform,
|
|
4994
|
+
color,
|
|
4995
|
+
});
|
|
4996
|
+
this._private_intervalHandler = undefined;
|
|
4997
|
+
this._private_currentFrameIndex = 0;
|
|
4998
|
+
/** Event handler for when the color changes */
|
|
4999
|
+
this._private_onColorChange = (color) => {
|
|
5000
|
+
this.sceneWrapper.setUniform(this.planeHandler, "color", color);
|
|
5001
|
+
};
|
|
5002
|
+
this._private_sequenceInternal = tempSequence;
|
|
5003
|
+
this._private_colorInternal = color;
|
|
5004
|
+
const defaultFrameRate = 24;
|
|
5005
|
+
this._private_frameRateInternal = options.frameRate ?? defaultFrameRate;
|
|
5006
|
+
this._private_loopInternal = options.loop ?? true;
|
|
5007
|
+
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5008
|
+
}
|
|
5009
|
+
/**
|
|
5010
|
+
* Gets the current color tint applied to the image.
|
|
5011
|
+
* @returns The UIColor instance
|
|
5012
|
+
*/
|
|
5013
|
+
get color() {
|
|
5014
|
+
return this._private_colorInternal;
|
|
5015
|
+
}
|
|
5016
|
+
/**
|
|
5017
|
+
* Gets the frame rate for animation.
|
|
5018
|
+
* @returns The frame rate in frames per second
|
|
5019
|
+
*/
|
|
5020
|
+
get frameRate() {
|
|
5021
|
+
return this._private_frameRateInternal;
|
|
5022
|
+
}
|
|
5023
|
+
/**
|
|
5024
|
+
* Gets whether the animation loops.
|
|
5025
|
+
* @returns True if animation loops
|
|
5026
|
+
*/
|
|
5027
|
+
get loop() {
|
|
5028
|
+
return this._private_loopInternal;
|
|
5029
|
+
}
|
|
5030
|
+
/**
|
|
5031
|
+
* Gets the total duration of the animation in seconds.
|
|
5032
|
+
* @returns The duration in seconds
|
|
5033
|
+
*/
|
|
5034
|
+
get duration() {
|
|
5035
|
+
return this._private_sequenceInternal.length / this._private_frameRateInternal;
|
|
5036
|
+
}
|
|
5037
|
+
/**
|
|
5038
|
+
* Sets the color tint applied to the image.
|
|
5039
|
+
* @param value - The UIColor instance
|
|
5040
|
+
*/
|
|
5041
|
+
set color(value) {
|
|
5042
|
+
this._private_colorInternal.copy(value);
|
|
5043
|
+
}
|
|
5044
|
+
/**
|
|
5045
|
+
* Sets the frame rate for animation.
|
|
5046
|
+
* @param value - The frame rate in frames per second
|
|
5047
|
+
*/
|
|
5048
|
+
set frameRate(value) {
|
|
5049
|
+
if (value <= 0) {
|
|
5050
|
+
throw new Error("Frame rate must be greater than zero");
|
|
5051
|
+
}
|
|
5052
|
+
const wasPlaying = this._private_intervalHandler !== undefined;
|
|
5053
|
+
if (wasPlaying) {
|
|
5054
|
+
this.pause();
|
|
5055
|
+
}
|
|
5056
|
+
this._private_frameRateInternal = value;
|
|
5057
|
+
if (wasPlaying) {
|
|
5058
|
+
this.play();
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
/**
|
|
5062
|
+
* Sets whether the animation loops.
|
|
5063
|
+
* @param value - True to enable looping
|
|
5064
|
+
*/
|
|
5065
|
+
set loop(value) {
|
|
5066
|
+
this._private_loopInternal = value;
|
|
5067
|
+
}
|
|
5068
|
+
/**
|
|
5069
|
+
* Starts or resumes playback of the animation.
|
|
5070
|
+
*/
|
|
5071
|
+
play() {
|
|
5072
|
+
if (this._private_intervalHandler !== undefined) {
|
|
5073
|
+
return;
|
|
5074
|
+
}
|
|
5075
|
+
this._private_intervalHandler = setInterval(() => {
|
|
5076
|
+
this._private_currentFrameIndex++;
|
|
5077
|
+
if (this._private_loopInternal) {
|
|
5078
|
+
this._private_currentFrameIndex %= this._private_sequenceInternal.length;
|
|
5079
|
+
}
|
|
5080
|
+
else if (this._private_currentFrameIndex >= this._private_sequenceInternal.length) {
|
|
5081
|
+
this._private_currentFrameIndex = this._private_sequenceInternal.length - 1;
|
|
5082
|
+
this.pause();
|
|
5083
|
+
return;
|
|
5084
|
+
}
|
|
5085
|
+
this._private_updateFrame();
|
|
5086
|
+
}, 1000 / this._private_frameRateInternal);
|
|
5087
|
+
this.emit(UIAnimatedImageEvent.PLAY);
|
|
5088
|
+
}
|
|
5089
|
+
/**
|
|
5090
|
+
* Pauses the animation at the current frame.
|
|
5091
|
+
*/
|
|
5092
|
+
pause() {
|
|
5093
|
+
if (this._private_intervalHandler === undefined) {
|
|
5094
|
+
return;
|
|
5095
|
+
}
|
|
5096
|
+
clearInterval(this._private_intervalHandler);
|
|
5097
|
+
this._private_intervalHandler = undefined;
|
|
5098
|
+
this.emit(UIAnimatedImageEvent.PAUSE);
|
|
5099
|
+
}
|
|
5100
|
+
/**
|
|
5101
|
+
* Stops the animation and resets to the first frame.
|
|
5102
|
+
*/
|
|
5103
|
+
stop() {
|
|
5104
|
+
if (this._private_intervalHandler !== undefined) {
|
|
5105
|
+
clearInterval(this._private_intervalHandler);
|
|
5106
|
+
this._private_intervalHandler = undefined;
|
|
5107
|
+
}
|
|
5108
|
+
this._private_currentFrameIndex = 0;
|
|
5109
|
+
this._private_updateFrame();
|
|
5110
|
+
this.emit(UIAnimatedImageEvent.STOP);
|
|
5111
|
+
}
|
|
5112
|
+
/**
|
|
5113
|
+
* Destroys the UI image by cleaning up color event listeners and all associated resources.
|
|
5114
|
+
*/
|
|
5115
|
+
destroy() {
|
|
5116
|
+
this.stop();
|
|
5117
|
+
this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5118
|
+
super.destroy();
|
|
5119
|
+
}
|
|
5120
|
+
_private_updateFrame() {
|
|
5121
|
+
const frame = this._private_sequenceInternal[this._private_currentFrameIndex];
|
|
5122
|
+
this.sceneWrapper.setUniform(this.planeHandler, "map", frame.texture);
|
|
5123
|
+
this.sceneWrapper.setUniform(this.planeHandler, "uvTransform", frame.uvTransform);
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
|
|
5127
|
+
/** Default width and height value for UIDummy elements. */
|
|
5128
|
+
const DEFAULT_SIZE = 100;
|
|
5129
|
+
/**
|
|
5130
|
+
* Abstract UI element that extends UIAnchor with dimensions but without rendering.
|
|
5131
|
+
*
|
|
5132
|
+
* UIDummy represents a rectangular area in the UI layout system that has position
|
|
5133
|
+
* and dimensions (width and height) but does not perform any visual rendering.
|
|
5134
|
+
* It serves as a placeholder or spacer element in constraint-based layouts,
|
|
5135
|
+
* useful for defining layout structure without visual content.
|
|
5136
|
+
*
|
|
5137
|
+
* @see {@link UIAnchor} - Base class providing position functionality
|
|
5138
|
+
* @see {@link UIPlaneElement} - Interface defining dimensional element behavior
|
|
5139
|
+
* @see {@link UILayer} - Container layer for UI elements
|
|
5140
|
+
*/
|
|
5141
|
+
class UIDummy extends UIAnchor {
|
|
5142
|
+
/**
|
|
5143
|
+
* Creates a new UIDummy instance with position and dimensions.
|
|
5144
|
+
*
|
|
5145
|
+
* @param layer - The UI layer that contains this dummy element
|
|
5146
|
+
* @param x - Initial x-coordinate position
|
|
5147
|
+
* @param y - Initial y-coordinate position
|
|
5148
|
+
* @param width - Initial width dimension (defaults to 100)
|
|
5149
|
+
* @param height - Initial height dimension (defaults to 100)
|
|
5150
|
+
* @throws Will throw an error if width or height are not valid positive numbers
|
|
5151
|
+
* @see {@link assertValidPositiveNumber}
|
|
5152
|
+
*/
|
|
5153
|
+
constructor(layer, options = {}) {
|
|
5154
|
+
const x = options.x ?? 0;
|
|
5155
|
+
const y = options.y ?? 0;
|
|
5156
|
+
const w = options.width ?? DEFAULT_SIZE;
|
|
5157
|
+
const h = options.height ?? DEFAULT_SIZE;
|
|
5158
|
+
assertValidPositiveNumber(w, "UIDummy width");
|
|
5159
|
+
assertValidPositiveNumber(h, "UIDummy height");
|
|
5160
|
+
super(layer, x, y);
|
|
5161
|
+
this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);
|
|
5162
|
+
this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);
|
|
5163
|
+
}
|
|
5164
|
+
/**
|
|
5165
|
+
* Gets the current width value from the solver.
|
|
5166
|
+
* @returns The current width dimension
|
|
5167
|
+
*/
|
|
5168
|
+
get width() {
|
|
5169
|
+
return this.solverWrapper.readVariableValue(this.wVariable);
|
|
5170
|
+
}
|
|
5171
|
+
/**
|
|
5172
|
+
* Gets the current height value from the solver.
|
|
5173
|
+
* @returns The current height dimension
|
|
5174
|
+
*/
|
|
5175
|
+
get height() {
|
|
5176
|
+
return this.solverWrapper.readVariableValue(this.hVariable);
|
|
5177
|
+
}
|
|
5178
|
+
/**
|
|
5179
|
+
* Sets the width value through the solver system.
|
|
5180
|
+
* @param value - The new width dimension (must be positive)
|
|
5181
|
+
* @throws Will throw an error if value is not a valid positive number
|
|
5182
|
+
* @see {@link assertValidPositiveNumber}
|
|
5183
|
+
*/
|
|
5184
|
+
set width(value) {
|
|
5185
|
+
assertValidPositiveNumber(value, "UIDummy width");
|
|
5186
|
+
this.solverWrapper.suggestVariableValue(this.wVariable, value);
|
|
5187
|
+
}
|
|
5188
|
+
/**
|
|
5189
|
+
* Sets the height value through the solver system.
|
|
5190
|
+
* @param value - The new height dimension (must be positive)
|
|
5191
|
+
* @throws Will throw an error if value is not a valid positive number
|
|
5192
|
+
* @see {@link assertValidPositiveNumber}
|
|
5193
|
+
*/
|
|
5194
|
+
set height(value) {
|
|
5195
|
+
assertValidPositiveNumber(value, "UIDummy height");
|
|
5196
|
+
this.solverWrapper.suggestVariableValue(this.hVariable, value);
|
|
5197
|
+
}
|
|
5198
|
+
/**
|
|
5199
|
+
* Destroys the dummy element by removing its solver variables.
|
|
5200
|
+
*
|
|
5201
|
+
* This method cleans up the dimension solver variables (width and height)
|
|
5202
|
+
* associated with this dummy element, then calls the parent destroy method
|
|
5203
|
+
* to clean up position variables. After calling this method, the dummy
|
|
5204
|
+
* element should not be used anymore.
|
|
5205
|
+
*/
|
|
5206
|
+
destroy() {
|
|
5207
|
+
this.solverWrapper.removeVariable(this.hVariable);
|
|
5208
|
+
this.solverWrapper.removeVariable(this.wVariable);
|
|
5209
|
+
super.destroy();
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
|
|
5213
|
+
/**
|
|
5214
|
+
* UI element for drawing graphics using 2D canvas API.
|
|
5215
|
+
*
|
|
5216
|
+
* UIGraphics uses an OffscreenCanvas for rendering 2D graphics and converts it
|
|
5217
|
+
* to a Three.js texture for display. It provides access to the canvas context
|
|
5218
|
+
* for custom drawing operations.
|
|
5219
|
+
*/
|
|
5220
|
+
class UIGraphics extends UIElement {
|
|
5221
|
+
/**
|
|
5222
|
+
* Creates a new UIGraphics instance.
|
|
5223
|
+
*
|
|
5224
|
+
* @param layer - The UI layer that contains this graphics element
|
|
5225
|
+
* @param options - Configuration options for the graphics element
|
|
5226
|
+
*/
|
|
5227
|
+
constructor(layer, options = {}) {
|
|
5228
|
+
const defaultCanvasSize = 512;
|
|
5229
|
+
const width = options.width ?? defaultCanvasSize;
|
|
5230
|
+
const height = options.height ?? defaultCanvasSize;
|
|
5231
|
+
const color = options.color ?? new UIColor();
|
|
5232
|
+
// Create OffscreenCanvas
|
|
5233
|
+
const canvas = new OffscreenCanvas(width, height);
|
|
5234
|
+
const ctx = canvas.getContext("2d");
|
|
5235
|
+
if (!ctx) {
|
|
5236
|
+
throw new Error("Failed to get 2D context from OffscreenCanvas");
|
|
5237
|
+
}
|
|
5238
|
+
// Create texture from canvas
|
|
5239
|
+
const canvasTexture = new CanvasTexture(canvas);
|
|
5240
|
+
canvasTexture.minFilter = LinearFilter;
|
|
5241
|
+
canvasTexture.magFilter = LinearFilter;
|
|
5242
|
+
super(layer, options.x ?? 0, options.y ?? 0, width, height, source$2, {
|
|
5243
|
+
map: canvasTexture,
|
|
5244
|
+
uvTransform: canvasTexture.matrix,
|
|
5245
|
+
color,
|
|
5246
|
+
});
|
|
5247
|
+
/** Event handler for when the color changes */
|
|
5248
|
+
this._private_onColorChange = (color) => {
|
|
5249
|
+
this.sceneWrapper.setUniform(this.planeHandler, "color", color);
|
|
5250
|
+
};
|
|
5251
|
+
this._private_canvas = canvas;
|
|
5252
|
+
this._private_ctx = ctx;
|
|
5253
|
+
this._private_canvasTexture = canvasTexture;
|
|
5254
|
+
this._private_colorInternal = color;
|
|
5255
|
+
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5256
|
+
}
|
|
5257
|
+
/**
|
|
5258
|
+
* Gets the canvas width.
|
|
5259
|
+
*/
|
|
5260
|
+
get canvasWidth() {
|
|
5261
|
+
return this._private_canvas.width;
|
|
5262
|
+
}
|
|
5263
|
+
/**
|
|
5264
|
+
* Gets the canvas height.
|
|
5265
|
+
*/
|
|
5266
|
+
get canvasHeight() {
|
|
5267
|
+
return this._private_canvas.height;
|
|
5268
|
+
}
|
|
5269
|
+
/**
|
|
5270
|
+
* Gets the current color tint applied to the graphics.
|
|
5271
|
+
*/
|
|
5272
|
+
get color() {
|
|
5273
|
+
return this._private_colorInternal;
|
|
5274
|
+
}
|
|
5275
|
+
/**
|
|
5276
|
+
* Sets the color tint applied to the graphics.
|
|
5277
|
+
*/
|
|
5278
|
+
set color(value) {
|
|
5279
|
+
this._private_colorInternal.copy(value);
|
|
5280
|
+
}
|
|
5281
|
+
/**
|
|
5282
|
+
* Clears the canvas with optional fill color.
|
|
5283
|
+
*
|
|
5284
|
+
* @param fillColor - Optional color to fill after clearing (CSS color string)
|
|
5285
|
+
*/
|
|
5286
|
+
clear(fillColor) {
|
|
5287
|
+
this._private_ctx.clearRect(0, 0, this._private_canvas.width, this._private_canvas.height);
|
|
5288
|
+
if (fillColor !== undefined) {
|
|
5289
|
+
this._private_ctx.fillStyle = fillColor;
|
|
5290
|
+
this._private_ctx.fillRect(0, 0, this._private_canvas.width, this._private_canvas.height);
|
|
5291
|
+
}
|
|
5292
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5293
|
+
}
|
|
5294
|
+
/**
|
|
5295
|
+
* Draws a rectangle on the canvas.
|
|
5296
|
+
*/
|
|
5297
|
+
rect(x, y, width, height) {
|
|
5298
|
+
this._private_ctx.rect(x, y, width, height);
|
|
5299
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5300
|
+
}
|
|
5301
|
+
/**
|
|
5302
|
+
* Draws a filled rectangle on the canvas.
|
|
5303
|
+
*/
|
|
5304
|
+
fillRect(x, y, width, height) {
|
|
5305
|
+
this._private_ctx.fillRect(x, y, width, height);
|
|
5306
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5307
|
+
}
|
|
5308
|
+
/**
|
|
5309
|
+
* Draws a stroked rectangle on the canvas.
|
|
5310
|
+
*/
|
|
5311
|
+
strokeRect(x, y, width, height) {
|
|
5312
|
+
this._private_ctx.strokeRect(x, y, width, height);
|
|
5313
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5314
|
+
}
|
|
5315
|
+
/**
|
|
5316
|
+
* Draws a circle on the canvas.
|
|
5317
|
+
*/
|
|
5318
|
+
circle(x, y, radius) {
|
|
5319
|
+
this._private_ctx.beginPath();
|
|
5320
|
+
this._private_ctx.arc(x, y, radius, 0, Math.PI * 2);
|
|
5321
|
+
this._private_ctx.closePath();
|
|
5322
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5323
|
+
}
|
|
5324
|
+
/**
|
|
5325
|
+
* Begins a new path.
|
|
5326
|
+
*/
|
|
5327
|
+
beginPath() {
|
|
5328
|
+
this._private_ctx.beginPath();
|
|
5329
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5330
|
+
}
|
|
5331
|
+
/**
|
|
5332
|
+
* Closes the current path.
|
|
5333
|
+
*/
|
|
5334
|
+
closePath() {
|
|
5335
|
+
this._private_ctx.closePath();
|
|
5336
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5337
|
+
}
|
|
5338
|
+
/**
|
|
5339
|
+
* Fills the current path.
|
|
5340
|
+
*/
|
|
5341
|
+
fill() {
|
|
5342
|
+
this._private_ctx.fill();
|
|
5343
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5344
|
+
}
|
|
5345
|
+
/**
|
|
5346
|
+
* Strokes the current path.
|
|
5347
|
+
*/
|
|
5348
|
+
stroke() {
|
|
5349
|
+
this._private_ctx.stroke();
|
|
5350
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5351
|
+
}
|
|
5352
|
+
/**
|
|
5353
|
+
* Moves the path to a point.
|
|
5354
|
+
*/
|
|
5355
|
+
moveTo(x, y) {
|
|
5356
|
+
this._private_ctx.moveTo(x, y);
|
|
5357
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5358
|
+
}
|
|
5359
|
+
/**
|
|
5360
|
+
* Draws a line to a point.
|
|
5361
|
+
*/
|
|
5362
|
+
lineTo(x, y) {
|
|
5363
|
+
this._private_ctx.lineTo(x, y);
|
|
5364
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5365
|
+
}
|
|
5366
|
+
/**
|
|
5367
|
+
* Sets the fill style.
|
|
5368
|
+
*/
|
|
5369
|
+
setFillStyle(style) {
|
|
5370
|
+
this._private_ctx.fillStyle = style;
|
|
5371
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5372
|
+
}
|
|
5373
|
+
/**
|
|
5374
|
+
* Sets the stroke style.
|
|
5375
|
+
*/
|
|
5376
|
+
setStrokeStyle(style) {
|
|
5377
|
+
this._private_ctx.strokeStyle = style;
|
|
5378
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5379
|
+
}
|
|
5380
|
+
/**
|
|
5381
|
+
* Sets the line width.
|
|
5382
|
+
*/
|
|
5383
|
+
setLineWidth(width) {
|
|
5384
|
+
this._private_ctx.lineWidth = width;
|
|
5385
|
+
this._private_canvasTexture.needsUpdate = true;
|
|
5386
|
+
}
|
|
5387
|
+
/**
|
|
5388
|
+
* Destroys the graphics element by cleaning up resources.
|
|
5389
|
+
*/
|
|
5390
|
+
destroy() {
|
|
5391
|
+
this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5392
|
+
this._private_canvasTexture.dispose();
|
|
5393
|
+
super.destroy();
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
4977
5396
|
|
|
4978
5397
|
/**
|
|
4979
5398
|
* UI element for displaying textured images.
|
|
@@ -6053,7 +6472,7 @@ const DEFAULT_MAX_WIDTH = 1024;
|
|
|
6053
6472
|
* @see {@link UIElement} - Base class providing UI element functionality
|
|
6054
6473
|
* @see {@link UITextContent} - Text content structure
|
|
6055
6474
|
* @see {@link UITextStyle} - Text styling options
|
|
6056
|
-
* @see {@link
|
|
6475
|
+
* @see {@link UIPadding} - Padding configuration
|
|
6057
6476
|
*/
|
|
6058
6477
|
class UIText extends UIElement {
|
|
6059
6478
|
/**
|
|
@@ -6220,153 +6639,281 @@ class UIText extends UIElement {
|
|
|
6220
6639
|
}
|
|
6221
6640
|
}
|
|
6222
6641
|
|
|
6642
|
+
var UIResizePolicyEvent;
|
|
6643
|
+
(function (UIResizePolicyEvent) {
|
|
6644
|
+
UIResizePolicyEvent[UIResizePolicyEvent["CHANGE"] = 0] = "CHANGE";
|
|
6645
|
+
})(UIResizePolicyEvent || (UIResizePolicyEvent = {}));
|
|
6223
6646
|
/**
|
|
6224
|
-
*
|
|
6647
|
+
* Base class for UI resize policies.
|
|
6225
6648
|
*
|
|
6226
|
-
*
|
|
6227
|
-
*
|
|
6228
|
-
|
|
6229
|
-
|
|
6649
|
+
* Calculates scale factors based on viewport dimensions. Different policies
|
|
6650
|
+
* implement different scaling strategies.
|
|
6651
|
+
*/
|
|
6652
|
+
class UIResizePolicy extends i {
|
|
6653
|
+
}
|
|
6654
|
+
/**
|
|
6655
|
+
* No scaling applied, always returns 1:1 scale.
|
|
6656
|
+
*/
|
|
6657
|
+
class UIResizePolicyNone extends UIResizePolicy {
|
|
6658
|
+
calculateScaleInternal(width, height) {
|
|
6659
|
+
return 1;
|
|
6660
|
+
}
|
|
6661
|
+
}
|
|
6662
|
+
/**
|
|
6663
|
+
* Maintains fixed width, scales based on window width.
|
|
6230
6664
|
*
|
|
6231
|
-
*
|
|
6232
|
-
|
|
6233
|
-
|
|
6665
|
+
* Uses different widths for landscape vs portrait orientation.
|
|
6666
|
+
*/
|
|
6667
|
+
class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
6668
|
+
/**
|
|
6669
|
+
* @param fixedWidthLandscape - Target width for landscape (width > height)
|
|
6670
|
+
* @param fixedWidthPortrait - Target width for portrait (width <= height)
|
|
6671
|
+
*/
|
|
6672
|
+
constructor(fixedWidthLandscape, fixedWidthPortrait) {
|
|
6673
|
+
super();
|
|
6674
|
+
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6675
|
+
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6676
|
+
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6677
|
+
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6678
|
+
}
|
|
6679
|
+
get fixedWidthLandscape() {
|
|
6680
|
+
return this._private_fixedWidthLandscapeInternal;
|
|
6681
|
+
}
|
|
6682
|
+
get fixedWidthPortrait() {
|
|
6683
|
+
return this._private_fixedWidthPortraitInternal;
|
|
6684
|
+
}
|
|
6685
|
+
set fixedWidthLandscape(value) {
|
|
6686
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6687
|
+
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6688
|
+
this._private_fixedWidthLandscapeInternal = value;
|
|
6689
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6690
|
+
}
|
|
6691
|
+
}
|
|
6692
|
+
set fixedWidthPortrait(value) {
|
|
6693
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6694
|
+
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6695
|
+
this._private_fixedWidthPortraitInternal = value;
|
|
6696
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6697
|
+
}
|
|
6698
|
+
}
|
|
6699
|
+
calculateScaleInternal(width, height) {
|
|
6700
|
+
return width > height
|
|
6701
|
+
? this._private_fixedWidthLandscapeInternal / width
|
|
6702
|
+
: this._private_fixedWidthPortraitInternal / width;
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
/**
|
|
6706
|
+
* Maintains fixed height, scales based on window height.
|
|
6234
6707
|
*
|
|
6235
|
-
*
|
|
6236
|
-
* @see {@link UIOrientation} - Orientation-based scaling behavior
|
|
6708
|
+
* Uses different heights for landscape vs portrait orientation.
|
|
6237
6709
|
*/
|
|
6238
|
-
class
|
|
6710
|
+
class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
6239
6711
|
/**
|
|
6240
|
-
*
|
|
6241
|
-
*
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6712
|
+
* @param fixedHeightLandscape - Target height for landscape (width > height)
|
|
6713
|
+
* @param fixedHeightPortrait - Target height for portrait (width <= height)
|
|
6714
|
+
*/
|
|
6715
|
+
constructor(fixedHeightLandscape, fixedHeightPortrait) {
|
|
6716
|
+
super();
|
|
6717
|
+
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6718
|
+
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6719
|
+
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6720
|
+
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6721
|
+
}
|
|
6722
|
+
get fixedHeightLandscape() {
|
|
6723
|
+
return this._private_fixedHeightLandscapeInternal;
|
|
6724
|
+
}
|
|
6725
|
+
get fixedHeightPortrait() {
|
|
6726
|
+
return this._private_fixedHeightPortraitInternal;
|
|
6727
|
+
}
|
|
6728
|
+
set fixedHeightLandscape(value) {
|
|
6729
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6730
|
+
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6731
|
+
this._private_fixedHeightLandscapeInternal = value;
|
|
6732
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
set fixedHeightPortrait(value) {
|
|
6736
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6737
|
+
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6738
|
+
this._private_fixedHeightPortraitInternal = value;
|
|
6739
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6740
|
+
}
|
|
6741
|
+
}
|
|
6742
|
+
calculateScaleInternal(width, height) {
|
|
6743
|
+
return width > height
|
|
6744
|
+
? this._private_fixedHeightLandscapeInternal / height
|
|
6745
|
+
: this._private_fixedHeightPortraitInternal / height;
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
/**
|
|
6749
|
+
* Scales by width in landscape, by height in portrait.
|
|
6750
|
+
*/
|
|
6751
|
+
class UIResizePolicyCross extends UIResizePolicy {
|
|
6752
|
+
/**
|
|
6753
|
+
* @param fixedWidthLandscape - Target width for landscape
|
|
6754
|
+
* @param fixedHeightPortrait - Target height for portrait
|
|
6755
|
+
*/
|
|
6756
|
+
constructor(fixedWidthLandscape, fixedHeightPortrait) {
|
|
6757
|
+
super();
|
|
6758
|
+
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6759
|
+
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6760
|
+
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6761
|
+
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6762
|
+
}
|
|
6763
|
+
get fixedWidthLandscape() {
|
|
6764
|
+
return this._private_fixedWidthLandscapeInternal;
|
|
6765
|
+
}
|
|
6766
|
+
get fixedHeightPortrait() {
|
|
6767
|
+
return this._private_fixedHeightPortraitInternal;
|
|
6768
|
+
}
|
|
6769
|
+
set fixedWidthLandscape(value) {
|
|
6770
|
+
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6771
|
+
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6772
|
+
this._private_fixedWidthLandscapeInternal = value;
|
|
6773
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6774
|
+
}
|
|
6775
|
+
}
|
|
6776
|
+
set fixedHeightPortrait(value) {
|
|
6777
|
+
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6778
|
+
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6779
|
+
this._private_fixedHeightPortraitInternal = value;
|
|
6780
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6781
|
+
}
|
|
6782
|
+
}
|
|
6783
|
+
calculateScaleInternal(width, height) {
|
|
6784
|
+
return width > height
|
|
6785
|
+
? this._private_fixedWidthLandscapeInternal / width
|
|
6786
|
+
: this._private_fixedHeightPortraitInternal / height;
|
|
6787
|
+
}
|
|
6788
|
+
}
|
|
6789
|
+
/**
|
|
6790
|
+
* Scales by height in landscape, by width in portrait.
|
|
6791
|
+
*/
|
|
6792
|
+
class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
6793
|
+
/**
|
|
6794
|
+
* @param fixedHeightLandscape - Target height for landscape
|
|
6795
|
+
* @param fixedWidthPortrait - Target width for portrait
|
|
6250
6796
|
*/
|
|
6251
|
-
constructor(
|
|
6252
|
-
|
|
6253
|
-
|
|
6797
|
+
constructor(fixedHeightLandscape, fixedWidthPortrait) {
|
|
6798
|
+
super();
|
|
6799
|
+
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6800
|
+
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6801
|
+
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6802
|
+
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6803
|
+
}
|
|
6804
|
+
get fixedHeightLandscape() {
|
|
6805
|
+
return this._private_fixedHeightLandscapeInternal;
|
|
6806
|
+
}
|
|
6807
|
+
get fixedWidthPortrait() {
|
|
6808
|
+
return this._private_fixedWidthPortraitInternal;
|
|
6809
|
+
}
|
|
6810
|
+
set fixedHeightLandscape(value) {
|
|
6811
|
+
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6812
|
+
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6813
|
+
this._private_fixedHeightLandscapeInternal = value;
|
|
6814
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6254
6815
|
}
|
|
6255
|
-
|
|
6256
|
-
|
|
6816
|
+
}
|
|
6817
|
+
set fixedWidthPortrait(value) {
|
|
6818
|
+
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6819
|
+
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6820
|
+
this._private_fixedWidthPortraitInternal = value;
|
|
6821
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6257
6822
|
}
|
|
6823
|
+
}
|
|
6824
|
+
calculateScaleInternal(width, height) {
|
|
6825
|
+
return width > height
|
|
6826
|
+
? this._private_fixedHeightLandscapeInternal / height
|
|
6827
|
+
: this._private_fixedWidthPortraitInternal / width;
|
|
6828
|
+
}
|
|
6829
|
+
}
|
|
6830
|
+
|
|
6831
|
+
/**
|
|
6832
|
+
* UI layer that covers the full browser window.
|
|
6833
|
+
*
|
|
6834
|
+
* Handles window resize and pointer events automatically. Scaling is controlled
|
|
6835
|
+
* by the assigned resize policy.
|
|
6836
|
+
*
|
|
6837
|
+
* @see {@link UILayer}
|
|
6838
|
+
* @see {@link UIResizePolicy}
|
|
6839
|
+
*/
|
|
6840
|
+
class UIFullscreenLayer extends UILayer {
|
|
6841
|
+
/**
|
|
6842
|
+
* Creates a fullscreen layer and sets up window event listeners.
|
|
6843
|
+
*/
|
|
6844
|
+
constructor(resizePolicy = new UIResizePolicyNone()) {
|
|
6258
6845
|
super(window.innerWidth, window.innerHeight);
|
|
6259
6846
|
/**
|
|
6260
|
-
*
|
|
6261
|
-
*
|
|
6262
|
-
* Recalculates the scaling factor and updates the layer dimensions
|
|
6263
|
-
* based on the new window size and fixed dimension constraints.
|
|
6847
|
+
* Handles window resize. Updates layer dimensions according to resize policy.
|
|
6264
6848
|
*/
|
|
6265
6849
|
this._private_onResize = () => {
|
|
6266
|
-
const scale = this.
|
|
6850
|
+
const scale = this._private_resizePolicyInternal.calculateScaleInternal(window.innerWidth, window.innerHeight);
|
|
6267
6851
|
this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
|
|
6268
6852
|
};
|
|
6269
6853
|
/**
|
|
6270
|
-
*
|
|
6854
|
+
* Handles pointer down. Converts browser coordinates to layer space.
|
|
6855
|
+
* Y-coordinate is flipped to match UI coordinate system.
|
|
6271
6856
|
*
|
|
6272
|
-
*
|
|
6273
|
-
* for element positioning and applying the appropriate scaling factor.
|
|
6274
|
-
* The y-coordinate is flipped to match the UI coordinate system.
|
|
6275
|
-
*
|
|
6276
|
-
* @param event - The pointer event from the browser
|
|
6857
|
+
* @param event - Browser pointer event
|
|
6277
6858
|
*/
|
|
6278
6859
|
this._private_onClick = (event) => {
|
|
6279
|
-
const
|
|
6860
|
+
const rect = event.target instanceof HTMLElement
|
|
6280
6861
|
? event.target.getBoundingClientRect()
|
|
6281
6862
|
: null;
|
|
6282
|
-
const x =
|
|
6283
|
-
const y =
|
|
6284
|
-
|
|
6863
|
+
const x = rect ? event.clientX - rect.left : event.clientX;
|
|
6864
|
+
const y = rect
|
|
6865
|
+
? rect.bottom - event.clientY
|
|
6866
|
+
: window.innerHeight - event.clientY;
|
|
6867
|
+
const scale = this._private_resizePolicyInternal.calculateScaleInternal(window.innerWidth, window.innerHeight);
|
|
6285
6868
|
this.pointerClickInternal(x * scale, y * scale);
|
|
6286
6869
|
};
|
|
6287
|
-
this._private_fixedWidthInternal = fixedWidth;
|
|
6288
|
-
this._private_fixedHeightInternal = fixedHeight;
|
|
6289
6870
|
window.addEventListener("resize", this._private_onResize);
|
|
6290
6871
|
window.addEventListener("pointerdown", this._private_onClick);
|
|
6872
|
+
this._private_resizePolicyInternal = resizePolicy;
|
|
6873
|
+
this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
6291
6874
|
this._private_onResize();
|
|
6292
6875
|
}
|
|
6293
6876
|
/**
|
|
6294
|
-
* Gets the current
|
|
6295
|
-
* @returns The fixed width in pixels, or undefined if not set
|
|
6296
|
-
*/
|
|
6297
|
-
get fixedWidth() {
|
|
6298
|
-
return this._private_fixedWidthInternal;
|
|
6299
|
-
}
|
|
6300
|
-
/**
|
|
6301
|
-
* Gets the current fixed height constraint.
|
|
6302
|
-
* @returns The fixed height in pixels, or undefined if not set
|
|
6877
|
+
* Gets the current resize policy.
|
|
6303
6878
|
*/
|
|
6304
|
-
get
|
|
6305
|
-
return this.
|
|
6306
|
-
}
|
|
6307
|
-
/**
|
|
6308
|
-
* Sets a new fixed width constraint and triggers resize recalculation.
|
|
6309
|
-
* @param value - The new fixed width in pixels, or undefined to remove constraint
|
|
6310
|
-
* @throws Will throw an error if value is not a valid positive number
|
|
6311
|
-
* @see {@link assertValidPositiveNumber}
|
|
6312
|
-
*/
|
|
6313
|
-
set fixedWidth(value) {
|
|
6314
|
-
if (value !== undefined) {
|
|
6315
|
-
assertValidPositiveNumber(value, "UIFullscreenLayer.fixedWidth");
|
|
6316
|
-
}
|
|
6317
|
-
if (value !== this._private_fixedWidthInternal) {
|
|
6318
|
-
this._private_fixedWidthInternal = value;
|
|
6319
|
-
this._private_onResize();
|
|
6320
|
-
}
|
|
6879
|
+
get resizePolicy() {
|
|
6880
|
+
return this._private_resizePolicyInternal;
|
|
6321
6881
|
}
|
|
6322
6882
|
/**
|
|
6323
|
-
* Sets a new
|
|
6324
|
-
* @param value - The new fixed height in pixels, or undefined to remove constraint
|
|
6325
|
-
* @throws Will throw an error if value is not a valid positive number
|
|
6326
|
-
* @see {@link assertValidPositiveNumber}
|
|
6883
|
+
* Sets a new resize policy. Unsubscribes from old policy and subscribes to new one.
|
|
6327
6884
|
*/
|
|
6328
|
-
set
|
|
6329
|
-
if (
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
this._private_fixedHeightInternal = value;
|
|
6885
|
+
set resizePolicy(value) {
|
|
6886
|
+
if (this._private_resizePolicyInternal !== value) {
|
|
6887
|
+
this._private_resizePolicyInternal.off(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
6888
|
+
this._private_resizePolicyInternal = value;
|
|
6889
|
+
this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
6334
6890
|
this._private_onResize();
|
|
6335
6891
|
}
|
|
6336
6892
|
}
|
|
6337
6893
|
/**
|
|
6338
|
-
*
|
|
6339
|
-
*
|
|
6340
|
-
* This method cleans up window event listeners for resize and pointer events.
|
|
6341
|
-
* After calling this method, the layer will no longer respond to window
|
|
6342
|
-
* changes and should not be used anymore.
|
|
6894
|
+
* Removes window event listeners. The layer should not be used after this.
|
|
6343
6895
|
*/
|
|
6344
6896
|
destroy() {
|
|
6345
6897
|
window.removeEventListener("resize", this._private_onResize);
|
|
6346
6898
|
window.removeEventListener("pointerdown", this._private_onClick);
|
|
6899
|
+
this._private_resizePolicyInternal.off(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
6347
6900
|
}
|
|
6348
6901
|
/**
|
|
6349
|
-
* Renders the
|
|
6902
|
+
* Renders the layer.
|
|
6350
6903
|
*
|
|
6351
|
-
*
|
|
6352
|
-
*
|
|
6353
|
-
* and buffer management for fullscreen interfaces.
|
|
6354
|
-
*
|
|
6355
|
-
* @param renderer - The WebGL renderer instance
|
|
6356
|
-
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
6357
|
-
* @throws Will throw an error if deltaTime is not a valid number
|
|
6358
|
-
* @see {@link assertValidNumber}
|
|
6904
|
+
* @param renderer - WebGL renderer
|
|
6905
|
+
* @param deltaTime - Time since last frame in seconds
|
|
6359
6906
|
*/
|
|
6360
6907
|
render(renderer, deltaTime) {
|
|
6361
6908
|
assertValidNumber(deltaTime, "UIFullscreenLayer.deltaTime");
|
|
6362
6909
|
super.renderInternal(renderer, deltaTime);
|
|
6363
6910
|
}
|
|
6364
6911
|
/**
|
|
6365
|
-
* Projects
|
|
6912
|
+
* Projects 3D world position to 2D layer coordinates.
|
|
6366
6913
|
*
|
|
6367
|
-
* @param position -
|
|
6368
|
-
* @param camera -
|
|
6369
|
-
* @returns
|
|
6914
|
+
* @param position - 3D world position
|
|
6915
|
+
* @param camera - Camera for projection
|
|
6916
|
+
* @returns 2D position in layer space
|
|
6370
6917
|
*/
|
|
6371
6918
|
projectWorldPosition(position, camera) {
|
|
6372
6919
|
const projectedPosition = position.project(camera);
|
|
@@ -6374,39 +6921,6 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6374
6921
|
projectedPosition.y = MathUtils.mapLinear(projectedPosition.y, -1, 1, this.y, this.height);
|
|
6375
6922
|
return projectedPosition;
|
|
6376
6923
|
}
|
|
6377
|
-
/**
|
|
6378
|
-
* Calculates the scaling factor based on orientation and fixed dimensions.
|
|
6379
|
-
*
|
|
6380
|
-
* The scaling factor is determined by the current orientation and which
|
|
6381
|
-
* fixed dimension constraint is active. In horizontal orientation, fixed
|
|
6382
|
-
* width takes precedence; in vertical orientation, fixed height takes precedence.
|
|
6383
|
-
*
|
|
6384
|
-
* @returns The scaling factor to apply to window dimensions
|
|
6385
|
-
*/
|
|
6386
|
-
_private_calculateScale() {
|
|
6387
|
-
if (this.orientation === UIOrientation.HORIZONTAL) {
|
|
6388
|
-
if (this.fixedWidth !== undefined) {
|
|
6389
|
-
return this.fixedWidth / window.innerWidth;
|
|
6390
|
-
}
|
|
6391
|
-
else if (this.fixedHeight !== undefined) {
|
|
6392
|
-
return this.fixedHeight / window.innerHeight;
|
|
6393
|
-
}
|
|
6394
|
-
else {
|
|
6395
|
-
return 1;
|
|
6396
|
-
}
|
|
6397
|
-
}
|
|
6398
|
-
else {
|
|
6399
|
-
if (this.fixedHeight !== undefined) {
|
|
6400
|
-
return this.fixedHeight / window.innerHeight;
|
|
6401
|
-
}
|
|
6402
|
-
else if (this.fixedWidth !== undefined) {
|
|
6403
|
-
return this.fixedWidth / window.innerWidth;
|
|
6404
|
-
}
|
|
6405
|
-
else {
|
|
6406
|
-
return 1;
|
|
6407
|
-
}
|
|
6408
|
-
}
|
|
6409
|
-
}
|
|
6410
6924
|
}
|
|
6411
6925
|
|
|
6412
6926
|
const INSTANCED_GEOMETRY = (() => {
|
|
@@ -6811,5 +7325,5 @@ function isUITextSpan(obj) {
|
|
|
6811
7325
|
(!("style" in obj) || isUITextStyle(obj.style)));
|
|
6812
7326
|
}
|
|
6813
7327
|
|
|
6814
|
-
export { UIAnchor, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
|
|
7328
|
+
export { UIAnchor, UIAnimatedImage, UIAnimatedImageEvent, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMicroEvent, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIResizePolicy, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyEvent, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
|
|
6815
7329
|
//# sourceMappingURL=index.js.map
|