laymur 0.3.29 → 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.js +76 -36
- 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 +3 -7
- package/dist/layers/UILayer.d.ts +6 -19
- package/dist/miscellaneous/UIInputEvent.d.ts +3 -2
- package/package.json +1 -1
|
@@ -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.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
|
-
pointerClickInternal(x, y) {
|
|
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) {
|
|
3077
3076
|
if (this.mode === UIMode.INTERACTIVE) {
|
|
3078
3077
|
this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
|
|
3079
3078
|
for (const listener of this._private_inputListeners) {
|
|
3080
|
-
if (listener.listener.
|
|
3079
|
+
if (listener.listener.catchMove(x, y)) {
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
pointerUpInternal(x, y) {
|
|
3086
|
+
if (this.mode === UIMode.INTERACTIVE) {
|
|
3087
|
+
this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
|
|
3088
|
+
for (const listener of this._private_inputListeners) {
|
|
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);
|
|
4758
4769
|
if (clicked) {
|
|
4759
|
-
this.emit(UIInputEvent.
|
|
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);
|
|
4776
|
+
if (clicked) {
|
|
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) {
|
|
@@ -6736,13 +6758,29 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6736
6758
|
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6737
6759
|
this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
|
|
6738
6760
|
};
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
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) => {
|
|
6746
6784
|
const rect = event.target instanceof HTMLElement
|
|
6747
6785
|
? event.target.getBoundingClientRect()
|
|
6748
6786
|
: null;
|
|
@@ -6751,10 +6789,12 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6751
6789
|
? rect.bottom - event.clientY
|
|
6752
6790
|
: window.innerHeight - event.clientY;
|
|
6753
6791
|
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6754
|
-
this.
|
|
6792
|
+
this.pointerUpInternal(x * scale, y * scale);
|
|
6755
6793
|
};
|
|
6756
6794
|
window.addEventListener("resize", this._private_onResize);
|
|
6757
|
-
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);
|
|
6758
6798
|
this.mode = mode;
|
|
6759
6799
|
this._private_resizePolicyInternal = resizePolicy;
|
|
6760
6800
|
this._private_resizePolicyInternal.on(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
@@ -6782,7 +6822,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6782
6822
|
*/
|
|
6783
6823
|
destroy() {
|
|
6784
6824
|
window.removeEventListener("resize", this._private_onResize);
|
|
6785
|
-
window.removeEventListener("pointerdown", this.
|
|
6825
|
+
window.removeEventListener("pointerdown", this._private_onDown);
|
|
6786
6826
|
this._private_resizePolicyInternal.off(UIResizePolicyEvent.CHANGE, this._private_onResize);
|
|
6787
6827
|
}
|
|
6788
6828
|
/**
|