laymur 0.3.28 → 0.3.30
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/UIElement.d.ts +3 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +302 -206
- 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 +4 -8
- package/dist/layers/UILayer.d.ts +6 -19
- package/dist/miscellaneous/UIInputEvent.d.ts +3 -2
- package/dist/miscellaneous/UIResizePolicy.d.ts +21 -0
- package/dist/miscellaneous/UIResizePolicyCross.d.ts +14 -0
- package/dist/miscellaneous/UIResizePolicyCrossInverted.d.ts +14 -0
- package/dist/miscellaneous/UIResizePolicyFixedHeight.d.ts +24 -0
- package/dist/miscellaneous/UIResizePolicyFixedWidth.d.ts +27 -0
- package/dist/miscellaneous/UIResizePolicyNone.d.ts +7 -0
- package/package.json +1 -1
- package/dist/miscellaneous/resizePolicies.d.ts +0 -99
|
@@ -160,13 +160,9 @@ export declare abstract class UIElement extends UIAnchor implements UIPlaneEleme
|
|
|
160
160
|
* the element should not be used anymore.
|
|
161
161
|
*/
|
|
162
162
|
destroy(): void;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* @param y - The y coordinate of the click
|
|
167
|
-
* @returns True if the click was within this element's bounds
|
|
168
|
-
*/
|
|
169
|
-
protected readonly onClick: (x: number, y: number) => boolean;
|
|
163
|
+
protected readonly onDown: (x: number, y: number) => boolean;
|
|
164
|
+
protected readonly onMove: (x: number, y: number) => boolean;
|
|
165
|
+
protected readonly onUp: (x: number, y: number) => boolean;
|
|
170
166
|
/**
|
|
171
167
|
* Called before each render frame to update the element's transform matrix.
|
|
172
168
|
* Applies micro-transformations (position, rotation, scale, anchor) and updates
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,6 @@ export * from "./elements/UIScene";
|
|
|
23
23
|
export * from "./elements/UIText";
|
|
24
24
|
export * from "./layers/UIFullscreenLayer";
|
|
25
25
|
export * from "./layers/UILayer";
|
|
26
|
-
export * from "./miscellaneous/resizePolicies";
|
|
27
26
|
export * from "./miscellaneous/UIColor";
|
|
28
27
|
export * from "./miscellaneous/UIExpression";
|
|
29
28
|
export * from "./miscellaneous/UIGenericInstancedPlane";
|
|
@@ -34,6 +33,12 @@ export * from "./miscellaneous/UIMode";
|
|
|
34
33
|
export * from "./miscellaneous/UIOrientation";
|
|
35
34
|
export * from "./miscellaneous/UIPriority";
|
|
36
35
|
export * from "./miscellaneous/UIRelation";
|
|
36
|
+
export * from "./miscellaneous/UIResizePolicy";
|
|
37
|
+
export * from "./miscellaneous/UIResizePolicyCross";
|
|
38
|
+
export * from "./miscellaneous/UIResizePolicyCrossInverted";
|
|
39
|
+
export * from "./miscellaneous/UIResizePolicyFixedHeight";
|
|
40
|
+
export * from "./miscellaneous/UIResizePolicyFixedWidth";
|
|
41
|
+
export * from "./miscellaneous/UIResizePolicyNone";
|
|
37
42
|
export * from "./miscellaneous/UISceneWrapperClientAPI";
|
|
38
43
|
export * from "./miscellaneous/UITextPadding";
|
|
39
44
|
export * from "./miscellaneous/UITextSpan";
|
package/dist/index.js
CHANGED
|
@@ -3062,22 +3062,31 @@ class UILayer extends i {
|
|
|
3062
3062
|
this.sceneWrapper.render(renderer);
|
|
3063
3063
|
}
|
|
3064
3064
|
}
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3065
|
+
pointerDownInternal(x, y) {
|
|
3066
|
+
if (this.mode === UIMode.INTERACTIVE) {
|
|
3067
|
+
this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
|
|
3068
|
+
for (const listener of this._private_inputListeners) {
|
|
3069
|
+
if (listener.listener.catchDown(x, y)) {
|
|
3070
|
+
return;
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
pointerMoveInternal(x, y) {
|
|
3076
|
+
if (this.mode === UIMode.INTERACTIVE) {
|
|
3077
|
+
this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
|
|
3078
|
+
for (const listener of this._private_inputListeners) {
|
|
3079
|
+
if (listener.listener.catchMove(x, y)) {
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
pointerUpInternal(x, y) {
|
|
3077
3086
|
if (this.mode === UIMode.INTERACTIVE) {
|
|
3078
3087
|
this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
|
|
3079
3088
|
for (const listener of this._private_inputListeners) {
|
|
3080
|
-
if (listener.listener.
|
|
3089
|
+
if (listener.listener.catchUp(x, y)) {
|
|
3081
3090
|
return;
|
|
3082
3091
|
}
|
|
3083
3092
|
}
|
|
@@ -4373,8 +4382,9 @@ var source$2 = "void main() {\n vec2 transformedUV = (uvTransform * vec3(io_U
|
|
|
4373
4382
|
*/
|
|
4374
4383
|
var UIInputEvent;
|
|
4375
4384
|
(function (UIInputEvent) {
|
|
4376
|
-
|
|
4377
|
-
UIInputEvent["
|
|
4385
|
+
UIInputEvent["DOWN"] = "click";
|
|
4386
|
+
UIInputEvent["MOVE"] = "move";
|
|
4387
|
+
UIInputEvent["UP"] = "up";
|
|
4378
4388
|
})(UIInputEvent || (UIInputEvent = {}));
|
|
4379
4389
|
|
|
4380
4390
|
/**
|
|
@@ -4702,7 +4712,7 @@ const axis = new Vector3(0, 0, 1);
|
|
|
4702
4712
|
* @param element - The UI element to test against
|
|
4703
4713
|
* @returns True if the point is within the element's bounds
|
|
4704
4714
|
*/
|
|
4705
|
-
function
|
|
4715
|
+
function isInsideElement(x, y, element) {
|
|
4706
4716
|
return (x > element.x &&
|
|
4707
4717
|
x < element.x + element.width &&
|
|
4708
4718
|
y > element.y &&
|
|
@@ -4747,16 +4757,24 @@ class UIElement extends UIAnchor {
|
|
|
4747
4757
|
this.transparencyInternal = UITransparencyMode.BLEND;
|
|
4748
4758
|
/** Internal storage for the z-index (depth) value. */
|
|
4749
4759
|
this.zIndexInternal = 0;
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4760
|
+
this.onDown = (x, y) => {
|
|
4761
|
+
const clicked = isInsideElement(x, y, this);
|
|
4762
|
+
if (clicked) {
|
|
4763
|
+
this.emit(UIInputEvent.DOWN, x, y, this);
|
|
4764
|
+
}
|
|
4765
|
+
return clicked;
|
|
4766
|
+
};
|
|
4767
|
+
this.onMove = (x, y) => {
|
|
4768
|
+
const clicked = isInsideElement(x, y, this);
|
|
4769
|
+
if (clicked) {
|
|
4770
|
+
this.emit(UIInputEvent.MOVE, x, y, this);
|
|
4771
|
+
}
|
|
4772
|
+
return clicked;
|
|
4773
|
+
};
|
|
4774
|
+
this.onUp = (x, y) => {
|
|
4775
|
+
const clicked = isInsideElement(x, y, this);
|
|
4758
4776
|
if (clicked) {
|
|
4759
|
-
this.emit(UIInputEvent.
|
|
4777
|
+
this.emit(UIInputEvent.UP, x, y, this);
|
|
4760
4778
|
}
|
|
4761
4779
|
return clicked;
|
|
4762
4780
|
};
|
|
@@ -4893,7 +4911,11 @@ class UIElement extends UIAnchor {
|
|
|
4893
4911
|
set mode(value) {
|
|
4894
4912
|
if (this.modeInternal !== value) {
|
|
4895
4913
|
if (value === UIMode.INTERACTIVE) {
|
|
4896
|
-
this.listener = {
|
|
4914
|
+
this.listener = {
|
|
4915
|
+
catchDown: this.onDown,
|
|
4916
|
+
catchMove: this.onMove,
|
|
4917
|
+
catchUp: this.onUp,
|
|
4918
|
+
};
|
|
4897
4919
|
this.layer["listenPointerInput"](this.listener, this.zIndexInternal);
|
|
4898
4920
|
}
|
|
4899
4921
|
else if (this.modeInternal === UIMode.INTERACTIVE && this.listener) {
|
|
@@ -6704,6 +6726,7 @@ var UIResizePolicyEvent;
|
|
|
6704
6726
|
*/
|
|
6705
6727
|
class UIResizePolicy extends i {
|
|
6706
6728
|
}
|
|
6729
|
+
|
|
6707
6730
|
/**
|
|
6708
6731
|
* No scaling applied, always returns 1:1 scale.
|
|
6709
6732
|
*/
|
|
@@ -6712,174 +6735,6 @@ class UIResizePolicyNone extends UIResizePolicy {
|
|
|
6712
6735
|
return 1;
|
|
6713
6736
|
}
|
|
6714
6737
|
}
|
|
6715
|
-
/**
|
|
6716
|
-
* Maintains fixed width, scales based on window width.
|
|
6717
|
-
*
|
|
6718
|
-
* Uses different widths for landscape vs portrait orientation.
|
|
6719
|
-
*/
|
|
6720
|
-
class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
6721
|
-
/**
|
|
6722
|
-
* @param fixedWidthLandscape - Target width for landscape (width > height)
|
|
6723
|
-
* @param fixedWidthPortrait - Target width for portrait (width <= height)
|
|
6724
|
-
*/
|
|
6725
|
-
constructor(fixedWidthLandscape, fixedWidthPortrait) {
|
|
6726
|
-
super();
|
|
6727
|
-
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6728
|
-
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6729
|
-
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6730
|
-
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6731
|
-
}
|
|
6732
|
-
get fixedWidthLandscape() {
|
|
6733
|
-
return this._private_fixedWidthLandscapeInternal;
|
|
6734
|
-
}
|
|
6735
|
-
get fixedWidthPortrait() {
|
|
6736
|
-
return this._private_fixedWidthPortraitInternal;
|
|
6737
|
-
}
|
|
6738
|
-
set fixedWidthLandscape(value) {
|
|
6739
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
6740
|
-
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6741
|
-
this._private_fixedWidthLandscapeInternal = value;
|
|
6742
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6743
|
-
}
|
|
6744
|
-
}
|
|
6745
|
-
set fixedWidthPortrait(value) {
|
|
6746
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
6747
|
-
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6748
|
-
this._private_fixedWidthPortraitInternal = value;
|
|
6749
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6750
|
-
}
|
|
6751
|
-
}
|
|
6752
|
-
calculateScaleInternal(width, height) {
|
|
6753
|
-
return width > height
|
|
6754
|
-
? this._private_fixedWidthLandscapeInternal / width
|
|
6755
|
-
: this._private_fixedWidthPortraitInternal / width;
|
|
6756
|
-
}
|
|
6757
|
-
}
|
|
6758
|
-
/**
|
|
6759
|
-
* Maintains fixed height, scales based on window height.
|
|
6760
|
-
*
|
|
6761
|
-
* Uses different heights for landscape vs portrait orientation.
|
|
6762
|
-
*/
|
|
6763
|
-
class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
6764
|
-
/**
|
|
6765
|
-
* @param fixedHeightLandscape - Target height for landscape (width > height)
|
|
6766
|
-
* @param fixedHeightPortrait - Target height for portrait (width <= height)
|
|
6767
|
-
*/
|
|
6768
|
-
constructor(fixedHeightLandscape, fixedHeightPortrait) {
|
|
6769
|
-
super();
|
|
6770
|
-
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6771
|
-
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6772
|
-
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6773
|
-
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6774
|
-
}
|
|
6775
|
-
get fixedHeightLandscape() {
|
|
6776
|
-
return this._private_fixedHeightLandscapeInternal;
|
|
6777
|
-
}
|
|
6778
|
-
get fixedHeightPortrait() {
|
|
6779
|
-
return this._private_fixedHeightPortraitInternal;
|
|
6780
|
-
}
|
|
6781
|
-
set fixedHeightLandscape(value) {
|
|
6782
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
6783
|
-
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6784
|
-
this._private_fixedHeightLandscapeInternal = value;
|
|
6785
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6786
|
-
}
|
|
6787
|
-
}
|
|
6788
|
-
set fixedHeightPortrait(value) {
|
|
6789
|
-
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
6790
|
-
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6791
|
-
this._private_fixedHeightPortraitInternal = value;
|
|
6792
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6793
|
-
}
|
|
6794
|
-
}
|
|
6795
|
-
calculateScaleInternal(width, height) {
|
|
6796
|
-
return width > height
|
|
6797
|
-
? this._private_fixedHeightLandscapeInternal / height
|
|
6798
|
-
: this._private_fixedHeightPortraitInternal / height;
|
|
6799
|
-
}
|
|
6800
|
-
}
|
|
6801
|
-
/**
|
|
6802
|
-
* Scales by width in landscape, by height in portrait.
|
|
6803
|
-
*/
|
|
6804
|
-
class UIResizePolicyCross extends UIResizePolicy {
|
|
6805
|
-
/**
|
|
6806
|
-
* @param fixedWidthLandscape - Target width for landscape
|
|
6807
|
-
* @param fixedHeightPortrait - Target height for portrait
|
|
6808
|
-
*/
|
|
6809
|
-
constructor(fixedWidthLandscape, fixedHeightPortrait) {
|
|
6810
|
-
super();
|
|
6811
|
-
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6812
|
-
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6813
|
-
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
6814
|
-
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
6815
|
-
}
|
|
6816
|
-
get fixedWidthLandscape() {
|
|
6817
|
-
return this._private_fixedWidthLandscapeInternal;
|
|
6818
|
-
}
|
|
6819
|
-
get fixedHeightPortrait() {
|
|
6820
|
-
return this._private_fixedHeightPortraitInternal;
|
|
6821
|
-
}
|
|
6822
|
-
set fixedWidthLandscape(value) {
|
|
6823
|
-
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
|
|
6824
|
-
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
6825
|
-
this._private_fixedWidthLandscapeInternal = value;
|
|
6826
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6827
|
-
}
|
|
6828
|
-
}
|
|
6829
|
-
set fixedHeightPortrait(value) {
|
|
6830
|
-
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
|
|
6831
|
-
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
6832
|
-
this._private_fixedHeightPortraitInternal = value;
|
|
6833
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6834
|
-
}
|
|
6835
|
-
}
|
|
6836
|
-
calculateScaleInternal(width, height) {
|
|
6837
|
-
return width > height
|
|
6838
|
-
? this._private_fixedWidthLandscapeInternal / width
|
|
6839
|
-
: this._private_fixedHeightPortraitInternal / height;
|
|
6840
|
-
}
|
|
6841
|
-
}
|
|
6842
|
-
/**
|
|
6843
|
-
* Scales by height in landscape, by width in portrait.
|
|
6844
|
-
*/
|
|
6845
|
-
class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
6846
|
-
/**
|
|
6847
|
-
* @param fixedHeightLandscape - Target height for landscape
|
|
6848
|
-
* @param fixedWidthPortrait - Target width for portrait
|
|
6849
|
-
*/
|
|
6850
|
-
constructor(fixedHeightLandscape, fixedWidthPortrait) {
|
|
6851
|
-
super();
|
|
6852
|
-
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6853
|
-
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6854
|
-
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
6855
|
-
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
6856
|
-
}
|
|
6857
|
-
get fixedHeightLandscape() {
|
|
6858
|
-
return this._private_fixedHeightLandscapeInternal;
|
|
6859
|
-
}
|
|
6860
|
-
get fixedWidthPortrait() {
|
|
6861
|
-
return this._private_fixedWidthPortraitInternal;
|
|
6862
|
-
}
|
|
6863
|
-
set fixedHeightLandscape(value) {
|
|
6864
|
-
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
6865
|
-
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
6866
|
-
this._private_fixedHeightLandscapeInternal = value;
|
|
6867
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6868
|
-
}
|
|
6869
|
-
}
|
|
6870
|
-
set fixedWidthPortrait(value) {
|
|
6871
|
-
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
6872
|
-
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
6873
|
-
this._private_fixedWidthPortraitInternal = value;
|
|
6874
|
-
this.emit(UIResizePolicyEvent.CHANGE);
|
|
6875
|
-
}
|
|
6876
|
-
}
|
|
6877
|
-
calculateScaleInternal(width, height) {
|
|
6878
|
-
return width > height
|
|
6879
|
-
? this._private_fixedHeightLandscapeInternal / height
|
|
6880
|
-
: this._private_fixedWidthPortraitInternal / width;
|
|
6881
|
-
}
|
|
6882
|
-
}
|
|
6883
6738
|
|
|
6884
6739
|
/**
|
|
6885
6740
|
* UI layer that covers the full browser window.
|
|
@@ -6900,16 +6755,32 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6900
6755
|
* Handles window resize. Updates layer dimensions according to resize policy.
|
|
6901
6756
|
*/
|
|
6902
6757
|
this._private_onResize = () => {
|
|
6903
|
-
const scale = this._private_resizePolicyInternal
|
|
6758
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6904
6759
|
this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
|
|
6905
6760
|
};
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6761
|
+
this._private_onDown = (event) => {
|
|
6762
|
+
const rect = event.target instanceof HTMLElement
|
|
6763
|
+
? event.target.getBoundingClientRect()
|
|
6764
|
+
: null;
|
|
6765
|
+
const x = rect ? event.clientX - rect.left : event.clientX;
|
|
6766
|
+
const y = rect
|
|
6767
|
+
? rect.bottom - event.clientY
|
|
6768
|
+
: window.innerHeight - event.clientY;
|
|
6769
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6770
|
+
this.pointerDownInternal(x * scale, y * scale);
|
|
6771
|
+
};
|
|
6772
|
+
this._private_onMove = (event) => {
|
|
6773
|
+
const rect = event.target instanceof HTMLElement
|
|
6774
|
+
? event.target.getBoundingClientRect()
|
|
6775
|
+
: null;
|
|
6776
|
+
const x = rect ? event.clientX - rect.left : event.clientX;
|
|
6777
|
+
const y = rect
|
|
6778
|
+
? rect.bottom - event.clientY
|
|
6779
|
+
: window.innerHeight - event.clientY;
|
|
6780
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6781
|
+
this.pointerMoveInternal(x * scale, y * scale);
|
|
6782
|
+
};
|
|
6783
|
+
this._private_onUp = (event) => {
|
|
6913
6784
|
const rect = event.target instanceof HTMLElement
|
|
6914
6785
|
? event.target.getBoundingClientRect()
|
|
6915
6786
|
: null;
|
|
@@ -6917,11 +6788,13 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6917
6788
|
const y = rect
|
|
6918
6789
|
? rect.bottom - event.clientY
|
|
6919
6790
|
: window.innerHeight - event.clientY;
|
|
6920
|
-
const scale = this._private_resizePolicyInternal
|
|
6921
|
-
this.
|
|
6791
|
+
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6792
|
+
this.pointerUpInternal(x * scale, y * scale);
|
|
6922
6793
|
};
|
|
6923
6794
|
window.addEventListener("resize", this._private_onResize);
|
|
6924
|
-
window.addEventListener("pointerdown", this.
|
|
6795
|
+
window.addEventListener("pointerdown", this._private_onDown);
|
|
6796
|
+
window.addEventListener("pointermove", this._private_onMove);
|
|
6797
|
+
window.addEventListener("pointerup", this._private_onUp);
|
|
6925
6798
|
this.mode = mode;
|
|
6926
6799
|
this._private_resizePolicyInternal = resizePolicy;
|
|
6927
6800
|
this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
@@ -6949,7 +6822,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6949
6822
|
*/
|
|
6950
6823
|
destroy() {
|
|
6951
6824
|
window.removeEventListener("resize", this._private_onResize);
|
|
6952
|
-
window.removeEventListener("pointerdown", this.
|
|
6825
|
+
window.removeEventListener("pointerdown", this._private_onDown);
|
|
6953
6826
|
this._private_resizePolicyInternal.off(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
6954
6827
|
}
|
|
6955
6828
|
/**
|
|
@@ -7371,6 +7244,229 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
7371
7244
|
}
|
|
7372
7245
|
}
|
|
7373
7246
|
|
|
7247
|
+
/**
|
|
7248
|
+
* Scales by width in landscape, by height in portrait.
|
|
7249
|
+
*/
|
|
7250
|
+
class UIResizePolicyCross extends UIResizePolicy {
|
|
7251
|
+
constructor(fixedWidthLandscape, fixedHeightPortrait) {
|
|
7252
|
+
super();
|
|
7253
|
+
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyCross.fixedWidthLandscape");
|
|
7254
|
+
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyCross.fixedHeightPortrait");
|
|
7255
|
+
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
7256
|
+
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
7257
|
+
}
|
|
7258
|
+
get fixedWidthLandscape() {
|
|
7259
|
+
return this._private_fixedWidthLandscapeInternal;
|
|
7260
|
+
}
|
|
7261
|
+
get fixedHeightPortrait() {
|
|
7262
|
+
return this._private_fixedHeightPortraitInternal;
|
|
7263
|
+
}
|
|
7264
|
+
set fixedWidthLandscape(value) {
|
|
7265
|
+
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedWidthLandscape");
|
|
7266
|
+
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
7267
|
+
this._private_fixedWidthLandscapeInternal = value;
|
|
7268
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7269
|
+
}
|
|
7270
|
+
}
|
|
7271
|
+
set fixedHeightPortrait(value) {
|
|
7272
|
+
assertValidPositiveNumber(value, "UIResizePolicyCross.fixedHeightPortrait");
|
|
7273
|
+
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
7274
|
+
this._private_fixedHeightPortraitInternal = value;
|
|
7275
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7276
|
+
}
|
|
7277
|
+
}
|
|
7278
|
+
calculateScaleInternal(width, height) {
|
|
7279
|
+
return width > height
|
|
7280
|
+
? this._private_fixedWidthLandscapeInternal / width
|
|
7281
|
+
: this._private_fixedHeightPortraitInternal / height;
|
|
7282
|
+
}
|
|
7283
|
+
}
|
|
7284
|
+
|
|
7285
|
+
/**
|
|
7286
|
+
* Scales by height in landscape, by width in portrait.
|
|
7287
|
+
*/
|
|
7288
|
+
class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
7289
|
+
constructor(fixedHeightLandscape, fixedWidthPortrait) {
|
|
7290
|
+
super();
|
|
7291
|
+
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
7292
|
+
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
7293
|
+
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
7294
|
+
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
7295
|
+
}
|
|
7296
|
+
get fixedHeightLandscape() {
|
|
7297
|
+
return this._private_fixedHeightLandscapeInternal;
|
|
7298
|
+
}
|
|
7299
|
+
get fixedWidthPortrait() {
|
|
7300
|
+
return this._private_fixedWidthPortraitInternal;
|
|
7301
|
+
}
|
|
7302
|
+
set fixedHeightLandscape(value) {
|
|
7303
|
+
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedHeightLandscape");
|
|
7304
|
+
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
7305
|
+
this._private_fixedHeightLandscapeInternal = value;
|
|
7306
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7307
|
+
}
|
|
7308
|
+
}
|
|
7309
|
+
set fixedWidthPortrait(value) {
|
|
7310
|
+
assertValidPositiveNumber(value, "UIResizePolicyCrossInverted.fixedWidthPortrait");
|
|
7311
|
+
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
7312
|
+
this._private_fixedWidthPortraitInternal = value;
|
|
7313
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7314
|
+
}
|
|
7315
|
+
}
|
|
7316
|
+
calculateScaleInternal(width, height) {
|
|
7317
|
+
return width > height
|
|
7318
|
+
? this._private_fixedHeightLandscapeInternal / height
|
|
7319
|
+
: this._private_fixedWidthPortraitInternal / width;
|
|
7320
|
+
}
|
|
7321
|
+
}
|
|
7322
|
+
|
|
7323
|
+
/**
|
|
7324
|
+
* Maintains fixed height, scales based on window height.
|
|
7325
|
+
*
|
|
7326
|
+
* Uses different heights for landscape vs portrait orientation,
|
|
7327
|
+
* and optionally for near-square aspect ratios.
|
|
7328
|
+
*/
|
|
7329
|
+
class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
7330
|
+
constructor(fixedHeightLandscape, fixedHeightPortrait, fixedHeightSquare = fixedHeightPortrait, squareEpsilon = 0.1) {
|
|
7331
|
+
super();
|
|
7332
|
+
assertValidPositiveNumber(fixedHeightLandscape, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
7333
|
+
assertValidPositiveNumber(fixedHeightPortrait, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
7334
|
+
assertValidPositiveNumber(fixedHeightSquare, "UIResizePolicyFixedHeight.fixedHeightSquare");
|
|
7335
|
+
assertValidPositiveNumber(squareEpsilon, "UIResizePolicy.squareEpsilon");
|
|
7336
|
+
this._private_fixedHeightLandscapeInternal = fixedHeightLandscape;
|
|
7337
|
+
this._private_fixedHeightPortraitInternal = fixedHeightPortrait;
|
|
7338
|
+
this._private_fixedHeightSquareInternal = fixedHeightSquare;
|
|
7339
|
+
this._private_squareEpsilonInternal = squareEpsilon;
|
|
7340
|
+
}
|
|
7341
|
+
get fixedHeightLandscape() {
|
|
7342
|
+
return this._private_fixedHeightLandscapeInternal;
|
|
7343
|
+
}
|
|
7344
|
+
get fixedHeightPortrait() {
|
|
7345
|
+
return this._private_fixedHeightPortraitInternal;
|
|
7346
|
+
}
|
|
7347
|
+
get fixedHeightSquare() {
|
|
7348
|
+
return this._private_fixedHeightSquareInternal;
|
|
7349
|
+
}
|
|
7350
|
+
get squareEpsilon() {
|
|
7351
|
+
return this._private_squareEpsilonInternal;
|
|
7352
|
+
}
|
|
7353
|
+
set fixedHeightLandscape(value) {
|
|
7354
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightLandscape");
|
|
7355
|
+
if (value !== this._private_fixedHeightLandscapeInternal) {
|
|
7356
|
+
this._private_fixedHeightLandscapeInternal = value;
|
|
7357
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7358
|
+
}
|
|
7359
|
+
}
|
|
7360
|
+
set fixedHeightPortrait(value) {
|
|
7361
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightPortrait");
|
|
7362
|
+
if (value !== this._private_fixedHeightPortraitInternal) {
|
|
7363
|
+
this._private_fixedHeightPortraitInternal = value;
|
|
7364
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7365
|
+
}
|
|
7366
|
+
}
|
|
7367
|
+
set fixedHeightSquare(value) {
|
|
7368
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedHeight.fixedHeightSquare");
|
|
7369
|
+
if (value !== this._private_fixedHeightSquareInternal) {
|
|
7370
|
+
this._private_fixedHeightSquareInternal = value;
|
|
7371
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
set squareEpsilon(value) {
|
|
7375
|
+
assertValidPositiveNumber(value, "UIResizePolicy.squareEpsilon");
|
|
7376
|
+
if (value !== this._private_squareEpsilonInternal) {
|
|
7377
|
+
this._private_squareEpsilonInternal = value;
|
|
7378
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7379
|
+
}
|
|
7380
|
+
}
|
|
7381
|
+
calculateScaleInternal(width, height) {
|
|
7382
|
+
if (this._private_isSquare(width, height)) {
|
|
7383
|
+
return this._private_fixedHeightSquareInternal / height;
|
|
7384
|
+
}
|
|
7385
|
+
return width > height
|
|
7386
|
+
? this._private_fixedHeightLandscapeInternal / height
|
|
7387
|
+
: this._private_fixedHeightPortraitInternal / height;
|
|
7388
|
+
}
|
|
7389
|
+
_private_isSquare(width, height) {
|
|
7390
|
+
const ratio = width / height;
|
|
7391
|
+
return Math.abs(ratio - 1) <= this._private_squareEpsilonInternal;
|
|
7392
|
+
}
|
|
7393
|
+
}
|
|
7394
|
+
|
|
7395
|
+
/**
|
|
7396
|
+
* Maintains fixed width, scales based on window width.
|
|
7397
|
+
*
|
|
7398
|
+
* Uses different widths for landscape vs portrait orientation, and optionally
|
|
7399
|
+
* a third width for near-square aspect ratios.
|
|
7400
|
+
*/
|
|
7401
|
+
class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
7402
|
+
constructor(fixedWidthLandscape, fixedWidthPortrait, fixedWidthSquare = fixedWidthPortrait, squareEpsilon = 0.1) {
|
|
7403
|
+
super();
|
|
7404
|
+
assertValidPositiveNumber(fixedWidthLandscape, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
7405
|
+
assertValidPositiveNumber(fixedWidthPortrait, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
7406
|
+
assertValidPositiveNumber(fixedWidthSquare, "UIResizePolicyFixedWidth.fixedWidthSquare");
|
|
7407
|
+
assertValidPositiveNumber(squareEpsilon, "UIResizePolicy.squareEpsilon");
|
|
7408
|
+
this._private_fixedWidthLandscapeInternal = fixedWidthLandscape;
|
|
7409
|
+
this._private_fixedWidthPortraitInternal = fixedWidthPortrait;
|
|
7410
|
+
this._private_fixedWidthSquareInternal = fixedWidthSquare;
|
|
7411
|
+
this._private_squareEpsilonInternal = squareEpsilon;
|
|
7412
|
+
}
|
|
7413
|
+
get fixedWidthLandscape() {
|
|
7414
|
+
return this._private_fixedWidthLandscapeInternal;
|
|
7415
|
+
}
|
|
7416
|
+
get fixedWidthPortrait() {
|
|
7417
|
+
return this._private_fixedWidthPortraitInternal;
|
|
7418
|
+
}
|
|
7419
|
+
get fixedWidthSquare() {
|
|
7420
|
+
return this._private_fixedWidthSquareInternal;
|
|
7421
|
+
}
|
|
7422
|
+
get squareEpsilon() {
|
|
7423
|
+
return this._private_squareEpsilonInternal;
|
|
7424
|
+
}
|
|
7425
|
+
set fixedWidthLandscape(value) {
|
|
7426
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthLandscape");
|
|
7427
|
+
if (value !== this._private_fixedWidthLandscapeInternal) {
|
|
7428
|
+
this._private_fixedWidthLandscapeInternal = value;
|
|
7429
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7430
|
+
}
|
|
7431
|
+
}
|
|
7432
|
+
set fixedWidthPortrait(value) {
|
|
7433
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthPortrait");
|
|
7434
|
+
if (value !== this._private_fixedWidthPortraitInternal) {
|
|
7435
|
+
this._private_fixedWidthPortraitInternal = value;
|
|
7436
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
set fixedWidthSquare(value) {
|
|
7440
|
+
assertValidPositiveNumber(value, "UIResizePolicyFixedWidth.fixedWidthSquare");
|
|
7441
|
+
if (value !== this._private_fixedWidthSquareInternal) {
|
|
7442
|
+
this._private_fixedWidthSquareInternal = value;
|
|
7443
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7444
|
+
}
|
|
7445
|
+
}
|
|
7446
|
+
set squareEpsilon(value) {
|
|
7447
|
+
assertValidPositiveNumber(value, "UIResizePolicy.squareEpsilon");
|
|
7448
|
+
if (value !== this._private_squareEpsilonInternal) {
|
|
7449
|
+
this._private_squareEpsilonInternal = value;
|
|
7450
|
+
this.emit(UIResizePolicyEvent.CHANGE);
|
|
7451
|
+
}
|
|
7452
|
+
}
|
|
7453
|
+
calculateScaleInternal(width, height) {
|
|
7454
|
+
if (this._private_isSquare(width, height)) {
|
|
7455
|
+
return this._private_fixedWidthSquareInternal / width;
|
|
7456
|
+
}
|
|
7457
|
+
return width > height
|
|
7458
|
+
? this._private_fixedWidthLandscapeInternal / width
|
|
7459
|
+
: this._private_fixedWidthPortraitInternal / width;
|
|
7460
|
+
}
|
|
7461
|
+
/**
|
|
7462
|
+
* Determines if viewport aspect ratio is close to 1:1.
|
|
7463
|
+
*/
|
|
7464
|
+
_private_isSquare(width, height) {
|
|
7465
|
+
const ratio = width / height;
|
|
7466
|
+
return Math.abs(ratio - 1) <= this._private_squareEpsilonInternal;
|
|
7467
|
+
}
|
|
7468
|
+
}
|
|
7469
|
+
|
|
7374
7470
|
function isUITextSpan(obj) {
|
|
7375
7471
|
return (obj !== null &&
|
|
7376
7472
|
typeof obj === "object" &&
|