@needle-tools/engine 2.33.0-pre → 2.35.0-pre
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/CHANGELOG.md +20 -0
- package/dist/needle-engine.d.ts +3045 -2855
- package/dist/needle-engine.js +457 -407
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +117 -67
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/api.d.ts +3 -0
- package/lib/engine/api.js +4 -0
- package/lib/engine/api.js.map +1 -0
- package/lib/engine/engine.d.ts +4 -3
- package/lib/engine/engine_addressables.d.ts +5 -4
- package/lib/engine/engine_addressables.js +8 -7
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_components.d.ts +16 -0
- package/lib/engine/engine_components.js +223 -0
- package/lib/engine/engine_components.js.map +1 -0
- package/lib/engine/engine_create_objects.d.ts +11 -0
- package/lib/engine/engine_create_objects.js +20 -0
- package/lib/engine/engine_create_objects.js.map +1 -0
- package/lib/engine/engine_element.js +2 -2
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +33 -0
- package/lib/engine/engine_gameobject.js +449 -0
- package/lib/engine/engine_gameobject.js.map +1 -0
- package/lib/engine/engine_gltf.d.ts +13 -2
- package/lib/engine/engine_gltf.js +7 -1
- package/lib/engine/engine_gltf.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.d.ts +3 -3
- package/lib/engine/engine_gltf_builtin_components.js +2 -3
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_instancing.d.ts +5 -0
- package/lib/engine/engine_instancing.js +22 -0
- package/lib/engine/engine_instancing.js.map +1 -0
- package/lib/engine/engine_lightdata.d.ts +1 -1
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +2 -2
- package/lib/engine/engine_mainloop_utils.js +7 -6
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +2 -11
- package/lib/engine/engine_networking.js +1 -7
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking_files.d.ts +1 -1
- package/lib/engine/engine_networking_files.js +8 -7
- package/lib/engine/engine_networking_files.js.map +1 -1
- package/lib/engine/engine_networking_files_default_components.d.ts +2 -2
- package/lib/engine/engine_networking_files_default_components.js +38 -43
- package/lib/engine/engine_networking_files_default_components.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.d.ts +8 -6
- package/lib/engine/engine_networking_instantiate.js +12 -9
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +14 -0
- package/lib/engine/engine_networking_types.js +8 -0
- package/lib/engine/engine_networking_types.js.map +1 -0
- package/lib/engine/engine_physics.d.ts +1 -23
- package/lib/engine/engine_physics.js +18 -56
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_rendererdata.d.ts +1 -1
- package/lib/engine/engine_rendererdata.js.map +1 -1
- package/lib/engine/engine_scenetools.d.ts +2 -2
- package/lib/engine/engine_scenetools.js +22 -5
- package/lib/engine/engine_scenetools.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.d.ts +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -1
- package/lib/engine/engine_serialization_decorator.d.ts +1 -1
- package/lib/engine/engine_setup.d.ts +14 -15
- package/lib/engine/engine_setup.js +34 -23
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_three_utils.js +0 -6
- package/lib/engine/engine_three_utils.js.map +1 -1
- package/lib/engine/engine_types.d.ts +103 -0
- package/lib/engine/engine_types.js +49 -0
- package/lib/engine/engine_types.js.map +1 -0
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_components.js +2 -2
- package/lib/engine/extensions/NEEDLE_components.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_deferred_texture.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_lighting_settings.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_lightmaps.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.d.ts +2 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.d.ts +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine/extensions/extensions.d.ts +1 -1
- package/lib/engine-components/Animation.js +1 -1
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AvatarLoader.js +6 -5
- package/lib/engine-components/AvatarLoader.js.map +1 -1
- package/lib/engine-components/Camera.d.ts +2 -2
- package/lib/engine-components/Camera.js +6 -12
- package/lib/engine-components/Camera.js.map +1 -1
- package/lib/engine-components/CameraUtils.d.ts +3 -0
- package/lib/engine-components/CameraUtils.js +15 -0
- package/lib/engine-components/CameraUtils.js.map +1 -0
- package/lib/engine-components/Collider.d.ts +1 -0
- package/lib/engine-components/Collider.js +4 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +16 -50
- package/lib/engine-components/Component.js +67 -465
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/DragControls.js +1 -1
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/Duplicatable.js +2 -1
- package/lib/engine-components/Duplicatable.js.map +1 -1
- package/lib/engine-components/LODGroup.js.map +1 -1
- package/lib/engine-components/Light.d.ts +2 -1
- package/lib/engine-components/Light.js +2 -2
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/NestedGltf.js +2 -1
- package/lib/engine-components/NestedGltf.js.map +1 -1
- package/lib/engine-components/OrbitControls.js +4 -2
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/Renderer.d.ts +3 -5
- package/lib/engine-components/Renderer.js +3 -20
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/{Rigidbody.d.ts → RigidBody.d.ts} +2 -1
- package/lib/engine-components/{Rigidbody.js → RigidBody.js} +1 -1
- package/lib/engine-components/{Rigidbody.js.map → RigidBody.js.map} +1 -1
- package/lib/engine-components/ScreenCapture.d.ts +0 -10
- package/lib/engine-components/ScreenCapture.js +8 -75
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +3 -2
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +1 -1
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/VideoPlayer.d.ts +14 -3
- package/lib/engine-components/VideoPlayer.js +390 -47
- package/lib/engine-components/VideoPlayer.js.map +1 -1
- package/lib/engine-components/Voip.js +2 -1
- package/lib/engine-components/Voip.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.js +1 -1
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js +1 -1
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRController.d.ts +1 -0
- package/lib/engine-components/WebXRController.js +40 -9
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.d.ts +1 -1
- package/lib/engine-components/WebXRGrabRendering.js +1 -1
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +1 -1
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -2
- package/lib/engine-components/codegen/components.js +1 -2
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/js-extensions/ExtensionUtils.d.ts +4 -0
- package/lib/engine-components/js-extensions/ExtensionUtils.js +56 -0
- package/lib/engine-components/js-extensions/ExtensionUtils.js.map +1 -0
- package/lib/engine-components/js-extensions/Object3D.js +16 -41
- package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/js-extensions/Vector.d.ts +2 -0
- package/lib/engine-components/js-extensions/Vector.js +16 -0
- package/lib/engine-components/js-extensions/Vector.js.map +1 -0
- package/lib/engine-components/timeline/PlayableDirector.d.ts +2 -1
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/ui/BaseUIComponent.d.ts +1 -0
- package/lib/engine-components/ui/BaseUIComponent.js +11 -5
- package/lib/engine-components/ui/BaseUIComponent.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +3 -0
- package/lib/engine-components/ui/Canvas.js +12 -1
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/CanvasScaler.d.ts +0 -0
- package/lib/engine-components/ui/CanvasScaler.js +17 -0
- package/lib/engine-components/ui/CanvasScaler.js.map +1 -0
- package/lib/engine-components/ui/EventSystem.d.ts +4 -1
- package/lib/engine-components/ui/EventSystem.js +28 -39
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/Graphic.js +2 -1
- package/lib/engine-components/ui/Graphic.js.map +1 -1
- package/lib/engine-components/ui/Keyboard.js +2 -1
- package/lib/engine-components/ui/Keyboard.js.map +1 -1
- package/lib/engine-components/ui/RaycastUtils.d.ts +11 -0
- package/lib/engine-components/ui/RaycastUtils.js +62 -0
- package/lib/engine-components/ui/RaycastUtils.js.map +1 -0
- package/lib/engine-components/ui/Raycaster.js.map +1 -1
- package/lib/engine-components/ui/Text.js +8 -3
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/ui/Utils.js +3 -2
- package/lib/engine-components/ui/Utils.js.map +1 -1
- package/lib/needle-engine.d.ts +3 -1
- package/lib/needle-engine.js +4 -2
- package/lib/needle-engine.js.map +1 -1
- package/package.json +13 -2
- package/src/engine/api.ts +3 -0
- package/src/engine/codegen/register_types.js +4 -6
- package/src/engine/engine_addressables.ts +12 -10
- package/src/engine/{engine_components.js → engine_components.ts} +37 -47
- package/src/engine/engine_create_objects.ts +27 -0
- package/src/engine/engine_element.ts +2 -2
- package/src/engine/engine_gameobject.ts +506 -0
- package/src/engine/engine_gltf.ts +21 -2
- package/src/engine/engine_gltf_builtin_components.ts +8 -7
- package/src/engine/engine_instancing.ts +25 -0
- package/src/engine/engine_lightdata.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +13 -11
- package/src/engine/engine_networking.ts +3 -14
- package/src/engine/engine_networking_files.ts +14 -11
- package/src/engine/engine_networking_files_default_components.ts +53 -52
- package/src/engine/engine_networking_instantiate.ts +24 -14
- package/src/engine/engine_networking_types.ts +19 -0
- package/src/engine/engine_physics.ts +21 -75
- package/src/engine/engine_rendererdata.ts +1 -1
- package/src/engine/engine_scenetools.ts +30 -6
- package/src/engine/engine_serialization_core.ts +1 -1
- package/src/engine/engine_serialization_decorator.ts +1 -1
- package/src/engine/engine_setup.ts +51 -37
- package/src/engine/engine_three_utils.ts +0 -8
- package/src/engine/engine_types.ts +180 -0
- package/src/engine/engine_utils.ts +1 -3
- package/src/engine/extensions/NEEDLE_components.ts +2 -2
- package/src/engine/extensions/NEEDLE_deferred_texture.ts +1 -1
- package/src/engine/extensions/NEEDLE_lighting_settings.ts +1 -1
- package/src/engine/extensions/NEEDLE_lightmaps.ts +1 -1
- package/src/engine/extensions/NEEDLE_render_objects.ts +4 -4
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +5 -4
- package/src/engine/extensions/extensions.ts +1 -1
- package/src/engine-components/Animation.ts +1 -1
- package/src/engine-components/Animator.ts +3 -3
- package/src/engine-components/AvatarLoader.ts +6 -5
- package/src/engine-components/Camera.ts +10 -13
- package/src/engine-components/CameraUtils.ts +15 -0
- package/src/engine-components/Collider.ts +5 -0
- package/src/engine-components/Component.ts +83 -535
- package/src/engine-components/DragControls.ts +1 -1
- package/src/engine-components/Duplicatable.ts +4 -3
- package/src/engine-components/LODGroup.ts +1 -1
- package/src/engine-components/Light.ts +3 -2
- package/src/engine-components/NestedGltf.ts +2 -1
- package/src/engine-components/OrbitControls.ts +5 -5
- package/src/engine-components/Renderer.ts +7 -21
- package/src/engine-components/RigidBody.ts +2 -1
- package/src/engine-components/ScreenCapture.ts +11 -77
- package/src/engine-components/SpectatorCamera.ts +7 -5
- package/src/engine-components/SyncedCamera.ts +3 -2
- package/src/engine-components/SyncedTransform.ts +2 -2
- package/src/engine-components/TestRunner.ts +1 -2
- package/src/engine-components/VideoPlayer.ts +401 -48
- package/src/engine-components/Voip.ts +2 -1
- package/src/engine-components/WebARSessionRoot.ts +1 -1
- package/src/engine-components/WebXR.ts +2 -2
- package/src/engine-components/WebXRAvatar.ts +1 -1
- package/src/engine-components/WebXRController.ts +40 -10
- package/src/engine-components/WebXRGrabRendering.ts +1 -1
- package/src/engine-components/WebXRSync.ts +1 -1
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +2 -1
- package/src/engine-components/codegen/components.ts +1 -2
- package/src/engine-components/js-extensions/ExtensionUtils.ts +66 -0
- package/src/engine-components/js-extensions/Object3D.ts +22 -48
- package/src/engine-components/js-extensions/Vector.ts +17 -0
- package/src/engine-components/timeline/PlayableDirector.ts +2 -1
- package/src/engine-components/ui/BaseUIComponent.ts +17 -6
- package/src/engine-components/ui/Canvas.ts +14 -2
- package/src/engine-components/ui/CanvasScaler.ts +21 -0
- package/src/engine-components/ui/EventSystem.ts +30 -35
- package/src/engine-components/ui/Graphic.ts +2 -1
- package/src/engine-components/ui/Keyboard.ts +2 -1
- package/src/engine-components/ui/RaycastUtils.ts +64 -0
- package/src/engine-components/ui/Raycaster.ts +2 -0
- package/src/engine-components/ui/Text.ts +8 -4
- package/src/engine-components/ui/Utils.ts +3 -2
- package/src/needle-engine.ts +7 -2
|
@@ -11,9 +11,11 @@ import { XRInputSource, XRSession } from "three";
|
|
|
11
11
|
import { Mathf } from "../engine/engine_math";
|
|
12
12
|
import * as utils from "../engine/engine_three_utils"
|
|
13
13
|
import { Interactable, UsageMarker } from "./Interactable";
|
|
14
|
-
import { InstancingUtil } from "
|
|
14
|
+
import { InstancingUtil } from "../engine/engine_instancing";
|
|
15
15
|
import { Rigidbody } from "./RigidBody";
|
|
16
|
-
import { getParam } from "../engine/engine_utils";
|
|
16
|
+
import { delay, getParam } from "../engine/engine_utils";
|
|
17
|
+
import { UIRaycastUtils } from "./ui/RaycastUtils";
|
|
18
|
+
import { RaycastResult } from "cannon-es";
|
|
17
19
|
|
|
18
20
|
const debug = getParam("debugwebxrcontroller");
|
|
19
21
|
|
|
@@ -119,12 +121,22 @@ export class WebXRController extends Behaviour {
|
|
|
119
121
|
return ctrl;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
// TODO: replace with component events
|
|
122
125
|
public static addEventListener(evt: ControllerEvents, callback: (controller: WebXRController, args: any) => void) {
|
|
123
126
|
const list = this.eventSubs[evt] ?? [];
|
|
124
127
|
list.push(callback);
|
|
125
128
|
this.eventSubs[evt] = list;
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
// TODO: replace with component events
|
|
132
|
+
public static removeEventListener(evt: ControllerEvents, callback: (controller: WebXRController, args: any) => void) {
|
|
133
|
+
if (!callback) return;
|
|
134
|
+
const list = this.eventSubs[evt] ?? [];
|
|
135
|
+
const idx = list.indexOf(callback);
|
|
136
|
+
if (idx >= 0) list.splice(idx, 1);
|
|
137
|
+
this.eventSubs[evt] = list;
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
private static eventSubs: { [key: string]: Function[] } = {};
|
|
129
141
|
|
|
130
142
|
public webXR!: WebXR;
|
|
@@ -558,6 +570,7 @@ export class WebXRController extends Behaviour {
|
|
|
558
570
|
if (this.webXR.Rig) {
|
|
559
571
|
factor /= this.webXR.Rig.scale.x;
|
|
560
572
|
}
|
|
573
|
+
// if (!hit) factor = 0;
|
|
561
574
|
|
|
562
575
|
if (this.raycastLine) {
|
|
563
576
|
this.raycastLine.scale.z = factor * (this.lastHit?.distance ?? 9999);
|
|
@@ -615,11 +628,11 @@ export class WebXRController extends Behaviour {
|
|
|
615
628
|
if (intersections && intersections.length > 0) {
|
|
616
629
|
for (const intersection of intersections) {
|
|
617
630
|
const object = intersection.object;
|
|
618
|
-
if (!this.testIsVisible(object)) {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
631
|
+
// if (!this.testIsVisible(object)) {
|
|
632
|
+
// if (debug)
|
|
633
|
+
// console.log("not visible");
|
|
634
|
+
// continue;
|
|
635
|
+
// }
|
|
623
636
|
this.lastSelectStartObject = object;
|
|
624
637
|
const args = { selected: object, grab: object };
|
|
625
638
|
const subs = WebXRController.eventSubs[ControllerEvents.SelectStart];
|
|
@@ -677,8 +690,12 @@ export class WebXRController extends Behaviour {
|
|
|
677
690
|
}
|
|
678
691
|
|
|
679
692
|
private testIsVisible(obj: THREE.Object3D | null): boolean {
|
|
680
|
-
if (!obj) return
|
|
681
|
-
|
|
693
|
+
if (!obj) return false;
|
|
694
|
+
if (GameObject.isActiveInHierarchy(obj) === false) return false;
|
|
695
|
+
if (UIRaycastUtils.isInteractable(obj) === false) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
return true;
|
|
682
699
|
// if (!obj.visible) return false;
|
|
683
700
|
// return this.testIsVisible(obj.parent);
|
|
684
701
|
}
|
|
@@ -719,7 +736,20 @@ export class WebXRController extends Behaviour {
|
|
|
719
736
|
opts.layerMask = new THREE.Layers();
|
|
720
737
|
opts.layerMask.set(0);
|
|
721
738
|
opts.ray = this.getRay();
|
|
722
|
-
|
|
739
|
+
const hits = this.context.physics.raycast(opts);
|
|
740
|
+
for (let i = 0; i < hits.length; i++) {
|
|
741
|
+
const hit = hits[i];
|
|
742
|
+
const obj = hit.object;
|
|
743
|
+
if (!this.testIsVisible(obj)) {
|
|
744
|
+
hits.splice(i, 1);
|
|
745
|
+
i--;
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
hit.object = UIRaycastUtils.getObject(obj);
|
|
749
|
+
break;
|
|
750
|
+
}
|
|
751
|
+
// console.log(...hits);
|
|
752
|
+
return hits;
|
|
723
753
|
}
|
|
724
754
|
}
|
|
725
755
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IModel, SendQueue } from "../engine/engine_networking";
|
|
2
1
|
import { getWorldPosition, setWorldPosition, setWorldPositionXYZ } from "../engine/engine_three_utils";
|
|
3
2
|
import { Behaviour, GameObject } from "./Component";
|
|
4
3
|
import { AttachedObject, AttachedObjectEvents } from "./WebXRController";
|
|
5
4
|
import * as THREE from "three";
|
|
6
5
|
import { PlayerColor } from "./PlayerColor";
|
|
7
6
|
import { Context } from "../engine/engine_setup";
|
|
7
|
+
import { IModel, SendQueue } from "../engine/engine_networking_types";
|
|
8
8
|
|
|
9
9
|
enum XRGrabEvent {
|
|
10
10
|
StartOrUpdate = "xr-grab-visual-start-or-update",
|
|
@@ -182,7 +182,7 @@ export class WebXRSync extends Behaviour {
|
|
|
182
182
|
|
|
183
183
|
async awake() {
|
|
184
184
|
|
|
185
|
-
if(!this.webXR) this.webXR = this.gameObject
|
|
185
|
+
if(!this.webXR) this.webXR = GameObject.getComponent(this.gameObject, WebXR);
|
|
186
186
|
if(!this.webXR) this.webXR = GameObject.findObjectOfType(WebXR, this.context);
|
|
187
187
|
|
|
188
188
|
if(!this.webXR)
|
|
@@ -3,9 +3,10 @@ import { TypeStore } from "../../engine/engine_typestore";
|
|
|
3
3
|
import { Behaviour, GameObject } from "../Component";
|
|
4
4
|
import { AvatarMarker } from "../WebXRAvatar";
|
|
5
5
|
import * as utils from "../../engine/engine_three_utils";
|
|
6
|
-
import {
|
|
6
|
+
import { OwnershipModel } from "../../engine/engine_networking";
|
|
7
7
|
import { Int8BufferAttribute } from "three";
|
|
8
8
|
import { Context } from "../../engine/engine_setup";
|
|
9
|
+
import { IModel } from "../../engine/engine_networking_types";
|
|
9
10
|
|
|
10
11
|
export class Avatar_POI {
|
|
11
12
|
|
|
@@ -16,7 +16,6 @@ export { Camera } from "../Camera";
|
|
|
16
16
|
export { Collider } from "../Collider";
|
|
17
17
|
export { SphereCollider } from "../Collider";
|
|
18
18
|
export { BoxCollider } from "../Collider";
|
|
19
|
-
export { InstantiateOptions } from "../Component";
|
|
20
19
|
export { DeleteBox } from "../DeleteBox";
|
|
21
20
|
export { Deletable } from "../DeleteBox";
|
|
22
21
|
export { DeviceFlag } from "../DeviceFlag";
|
|
@@ -55,7 +54,6 @@ export { FieldWithDefault } from "../Renderer";
|
|
|
55
54
|
export { Renderer } from "../Renderer";
|
|
56
55
|
export { MeshRenderer } from "../Renderer";
|
|
57
56
|
export { SkinnedMeshRenderer } from "../Renderer";
|
|
58
|
-
export { InstancingUtil } from "../Renderer";
|
|
59
57
|
export { RendererLightmap } from "../RendererLightmap";
|
|
60
58
|
export { Rigidbody } from "../RigidBody";
|
|
61
59
|
export { ScreenCapture } from "../ScreenCapture";
|
|
@@ -133,6 +131,7 @@ export { PointerEventData } from "../ui/PointerEvents";
|
|
|
133
131
|
export { Raycaster } from "../ui/Raycaster";
|
|
134
132
|
export { ObjectRaycaster } from "../ui/Raycaster";
|
|
135
133
|
export { GraphicRaycaster } from "../ui/Raycaster";
|
|
134
|
+
export { UIRaycastUtils } from "../ui/RaycastUtils";
|
|
136
135
|
export { Size } from "../ui/RectTransform";
|
|
137
136
|
export { Rect } from "../ui/RectTransform";
|
|
138
137
|
export { RectTransform } from "../ui/RectTransform";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
const handlers : Map<any, ApplyPrototypeExtension> = new Map();
|
|
3
|
+
|
|
4
|
+
export function applyPrototypeExtensions(obj : any){
|
|
5
|
+
if(!obj) return;
|
|
6
|
+
const prototype = obj.prototype;
|
|
7
|
+
if(!prototype) return;
|
|
8
|
+
let handler = handlers.get(prototype);
|
|
9
|
+
if(!handler){
|
|
10
|
+
handler = createPrototypeExtensionHandler(prototype);
|
|
11
|
+
handlers.set(prototype, handler);
|
|
12
|
+
}
|
|
13
|
+
handler.apply(obj);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createPrototypeExtensionHandler(prototype: any) {
|
|
17
|
+
return new ApplyPrototypeExtension(prototype);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IApplyPrototypeExtension {
|
|
21
|
+
apply(object: object): void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class ApplyPrototypeExtension implements IApplyPrototypeExtension {
|
|
25
|
+
|
|
26
|
+
private readonly $symbol: symbol;
|
|
27
|
+
private readonly extensions: string[];
|
|
28
|
+
private readonly descriptors: Array<PropertyDescriptor | undefined>;
|
|
29
|
+
|
|
30
|
+
constructor(prototype: object) {
|
|
31
|
+
this.$symbol = Symbol("prototype-extension");
|
|
32
|
+
// used to decorate cloned object3D objects with the same added components defined above
|
|
33
|
+
this.extensions = Object.keys(prototype);
|
|
34
|
+
this.descriptors = new Array<PropertyDescriptor | undefined>();
|
|
35
|
+
for (let i = 0; i < this.extensions.length; i++) {
|
|
36
|
+
const key = this.extensions[i];
|
|
37
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
|
|
38
|
+
if (descriptor) {
|
|
39
|
+
this.descriptors.push(descriptor);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
apply(object: object): void {
|
|
45
|
+
|
|
46
|
+
if (object[this.$symbol]) return;
|
|
47
|
+
object[this.$symbol] = true;
|
|
48
|
+
|
|
49
|
+
// const prototype = object.constructor.prototype;
|
|
50
|
+
|
|
51
|
+
for (let i = 0; i < this.extensions.length; i++) {
|
|
52
|
+
const key = this.extensions[i];
|
|
53
|
+
const desc = this.descriptors[i];
|
|
54
|
+
if (desc) {
|
|
55
|
+
// if (prototype) {
|
|
56
|
+
// const exists = Object.getOwnPropertyDescriptor(prototype, key);
|
|
57
|
+
// if (exists) {
|
|
58
|
+
// continue;
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
// console.trace("DEFINE", object.name, key);
|
|
62
|
+
Object.defineProperty(object, key, desc);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { applyPrototypeExtensions } from "./ExtensionUtils";
|
|
1
2
|
import { Object3D } from "three";
|
|
2
|
-
import {
|
|
3
|
+
import { Constructor, ConstructorConcrete, IComponent } from "../../engine/engine_types"
|
|
4
|
+
import { IComponent as Component } from "../../engine/engine_types";
|
|
5
|
+
import { addNewComponentInstance, getComponent, getComponentInChildren, getComponentInParent, getComponents, getComponentsInChildren, getComponentsInParent, getOrAddComponent, removeComponent } from "../../engine/engine_components";
|
|
6
|
+
|
|
7
|
+
// used to decorate cloned object3D objects with the same added components defined above
|
|
8
|
+
export function apply(object: Object3D) {
|
|
9
|
+
if (object && object.isObject3D === true)
|
|
10
|
+
applyPrototypeExtensions(object);
|
|
11
|
+
}
|
|
3
12
|
|
|
4
|
-
const decorated = Symbol("GameObject.decorated");
|
|
5
13
|
|
|
6
14
|
// this is a fix to allow gameObject active animation be applied to a three object
|
|
7
15
|
Object.defineProperty(Object3D.prototype, "activeSelf", {
|
|
@@ -20,72 +28,38 @@ Object3D.prototype["SetActive"] = function (active: boolean) {
|
|
|
20
28
|
this.visible = active;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
Object3D.prototype["addNewComponent"] = function <T extends
|
|
24
|
-
return
|
|
31
|
+
Object3D.prototype["addNewComponent"] = function <T extends Component>(type: ConstructorConcrete<T>) {
|
|
32
|
+
return addNewComponentInstance(this, new type());
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
Object3D.prototype["removeComponent"] = function (inst: Component) {
|
|
28
|
-
return
|
|
36
|
+
return removeComponent(this, inst);
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
Object3D.prototype["getOrAddComponent"] = function <T>(typeName:
|
|
32
|
-
return
|
|
39
|
+
Object3D.prototype["getOrAddComponent"] = function <T extends IComponent>(typeName: ConstructorConcrete<T>): T {
|
|
40
|
+
return getOrAddComponent<T>(this, typeName);
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
Object3D.prototype["getComponent"] = function <T>(type: Constructor<T>) {
|
|
36
|
-
return
|
|
44
|
+
return getComponent(type, this);
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
Object3D.prototype["getComponents"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
40
|
-
return
|
|
48
|
+
return getComponents(this, type, arr);
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
Object3D.prototype["getComponentInChildren"] = function <T>(type: Constructor<T>) {
|
|
44
|
-
return
|
|
52
|
+
return getComponentInChildren(this, type);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
Object3D.prototype["getComponentsInChildren"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
48
|
-
return
|
|
55
|
+
Object3D.prototype["getComponentsInChildren"] = function <T extends IComponent>(type: Constructor<T>, arr?: []) {
|
|
56
|
+
return getComponentsInChildren(type, this, arr);
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
Object3D.prototype["getComponentInParent"] = function <T>(type: Constructor<T>) {
|
|
52
|
-
return
|
|
60
|
+
return getComponentInParent(this, type);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
Object3D.prototype["getComponentsInParent"] = function <T>(type: Constructor<T>, arr?: []) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// used to decorate cloned object3D objects with the same added components defined above
|
|
61
|
-
const extensions = Object.keys(Object3D.prototype);
|
|
62
|
-
const descriptors = new Array<PropertyDescriptor | undefined>();
|
|
63
|
-
for (let i = 0; i < extensions.length; i++) {
|
|
64
|
-
const key = extensions[i];
|
|
65
|
-
const descriptor = Object.getOwnPropertyDescriptor(Object3D.prototype, key);
|
|
66
|
-
if (descriptor) {
|
|
67
|
-
descriptors.push(descriptor);
|
|
68
|
-
}
|
|
64
|
+
return getComponentsInParent(this, type, arr);
|
|
69
65
|
}
|
|
70
|
-
|
|
71
|
-
export function apply(object: Object3D) {
|
|
72
|
-
if (object[decorated]) return;
|
|
73
|
-
object[decorated] = true;
|
|
74
|
-
|
|
75
|
-
// const prototype = object.constructor.prototype;
|
|
76
|
-
|
|
77
|
-
for (let i = 0; i < extensions.length; i++) {
|
|
78
|
-
const key = extensions[i];
|
|
79
|
-
const desc = descriptors[i];
|
|
80
|
-
if (desc) {
|
|
81
|
-
// if (prototype) {
|
|
82
|
-
// const exists = Object.getOwnPropertyDescriptor(prototype, key);
|
|
83
|
-
// if (exists) {
|
|
84
|
-
// continue;
|
|
85
|
-
// }
|
|
86
|
-
// }
|
|
87
|
-
// console.trace("DEFINE", object.name, key);
|
|
88
|
-
Object.defineProperty(object, key, desc);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { applyPrototypeExtensions } from "./ExtensionUtils";
|
|
2
|
+
import { Mathf } from "../../engine/engine_math";
|
|
3
|
+
import { Vector3 } from "three";
|
|
4
|
+
|
|
5
|
+
export function apply(object: Vector3) {
|
|
6
|
+
if (object && object.isVector3 === true) {
|
|
7
|
+
console.log(object);
|
|
8
|
+
applyPrototypeExtensions(object);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Vector3.prototype["slerp"] = function (end: Vector3, t: number) {
|
|
13
|
+
const len1 = this.length();
|
|
14
|
+
const len2 = end.length();
|
|
15
|
+
const targetLen = Mathf.lerp(len1, len2, t);
|
|
16
|
+
return this.lerp(end, t).normalize().multiplyScalar(targetLen);
|
|
17
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Animator } from '../Animator';
|
|
2
|
-
import { Behaviour, GameObject
|
|
2
|
+
import { Behaviour, GameObject } from '../Component';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { AudioListener } from '../AudioListener';
|
|
5
5
|
import { AudioSource } from '../AudioSource';
|
|
@@ -7,6 +7,7 @@ import { SignalReceiver } from './SignalAsset';
|
|
|
7
7
|
import * as Models from "./TimelineModels";
|
|
8
8
|
import * as Tracks from "./TimelineTracks";
|
|
9
9
|
import { deepClone, getParam } from '../../engine/engine_utils';
|
|
10
|
+
import { GuidsMap } from '../../engine/engine_types';
|
|
10
11
|
|
|
11
12
|
const debug = getParam("debugtimeline");
|
|
12
13
|
|
|
@@ -5,6 +5,7 @@ import { EventSystem } from "./EventSystem";
|
|
|
5
5
|
import { showGizmos } from '../../engine/engine_default_parameters';
|
|
6
6
|
import { AxesHelper, Object3D } from 'three';
|
|
7
7
|
import { IGraphic } from './Interfaces';
|
|
8
|
+
import { ShadowCastingMode } from '../Renderer';
|
|
8
9
|
export const includesDir = "./include";
|
|
9
10
|
|
|
10
11
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
|
|
@@ -19,6 +20,8 @@ ThreeMeshUI.Block.prototype["interactable"] = {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
export const $shadowDomOwner = Symbol("shadowDomOwner");
|
|
24
|
+
|
|
22
25
|
export class BaseUIComponent extends Behaviour {
|
|
23
26
|
|
|
24
27
|
isRoot() { return this.Root?.gameObject === this.gameObject; }
|
|
@@ -69,7 +72,7 @@ export class BaseUIComponent extends Behaviour {
|
|
|
69
72
|
|
|
70
73
|
container.name = this.name + " (" + (this.constructor.name ?? "UI") + ")";
|
|
71
74
|
container.autoLayout = this._parentComponent.controlsChildLayout;
|
|
72
|
-
container
|
|
75
|
+
container[$shadowDomOwner] = this;
|
|
73
76
|
|
|
74
77
|
// TODO: raycastTarget doesnt work anymore -> i think we need to set the gameObject layer and then check in the raycaster if the shadowComponentOwner is on the correct layer?!
|
|
75
78
|
// const raycastTarget = (this as unknown as IGraphic).raycastTarget;
|
|
@@ -78,14 +81,17 @@ export class BaseUIComponent extends Behaviour {
|
|
|
78
81
|
|
|
79
82
|
// TODO: only traverse our own hierarchy, we can stop if we find another owner
|
|
80
83
|
container.traverse(c => {
|
|
81
|
-
if (c
|
|
82
|
-
c
|
|
84
|
+
if (c[$shadowDomOwner] === undefined) {
|
|
85
|
+
c[$shadowDomOwner] = this;
|
|
83
86
|
}
|
|
87
|
+
|
|
84
88
|
// // this makes text not render anymore when enabled again
|
|
85
89
|
// if (raycastTarget === false) {
|
|
86
90
|
// c.layers.set(2);
|
|
87
91
|
// }
|
|
88
|
-
})
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
let needsUpdate = false;
|
|
89
95
|
|
|
90
96
|
if (this.Root?.gameObject === this.gameObject) {
|
|
91
97
|
this.gameObject.add(container);
|
|
@@ -95,6 +101,7 @@ export class BaseUIComponent extends Behaviour {
|
|
|
95
101
|
if (targetShadowComponent) {
|
|
96
102
|
// console.log("ADD", this.name, "to", this._parentComponent.name, targetShadowComponent);
|
|
97
103
|
targetShadowComponent?.add(container);
|
|
104
|
+
needsUpdate = true;
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
this.shadowComponent = container;
|
|
@@ -108,7 +115,11 @@ export class BaseUIComponent extends Behaviour {
|
|
|
108
115
|
}
|
|
109
116
|
|
|
110
117
|
this.onAfterAddedToScene();
|
|
111
|
-
|
|
118
|
+
|
|
119
|
+
// make sure to update the layout when adding content
|
|
120
|
+
// otherwise it will fail when object are enabled at runtime
|
|
121
|
+
if (needsUpdate)
|
|
122
|
+
ThreeMeshUI.update();
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
|
|
@@ -127,7 +138,7 @@ export class BaseUIComponent extends Behaviour {
|
|
|
127
138
|
|
|
128
139
|
private traverseOwnedShadowComponents(current: Object3D, owner: any, callback: (obj: any) => void) {
|
|
129
140
|
if (!current) return;
|
|
130
|
-
if (current[
|
|
141
|
+
if (current[$shadowDomOwner] === owner) {
|
|
131
142
|
callback(current);
|
|
132
143
|
for (const ch of current.children) {
|
|
133
144
|
this.traverseOwnedShadowComponents(ch, owner, callback);
|
|
@@ -4,6 +4,9 @@ import { FrameEvent } from "../../engine/engine_setup";
|
|
|
4
4
|
import { BaseUIComponent, UIRootComponent } from "./BaseUIComponent";
|
|
5
5
|
import { Mathf } from "../../engine/engine_math";
|
|
6
6
|
import * as THREE from "three";
|
|
7
|
+
import { getComponentsInChildren } from "../../engine/engine_components";
|
|
8
|
+
import { IComponent } from "../../engine/engine_types";
|
|
9
|
+
import { GameObject } from "../Component";
|
|
7
10
|
|
|
8
11
|
export enum RenderMode {
|
|
9
12
|
ScreenSpaceOverlay = 0,
|
|
@@ -84,6 +87,15 @@ export class Canvas extends UIRootComponent {
|
|
|
84
87
|
return this._rootCanvas;
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
private _scaleFactor: number = 1;
|
|
91
|
+
@serializeable()
|
|
92
|
+
get scaleFactor(): number {
|
|
93
|
+
return this._scaleFactor;
|
|
94
|
+
}
|
|
95
|
+
private set scaleFactor(val: number) {
|
|
96
|
+
this._scaleFactor = val;
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
awake() {
|
|
88
100
|
this.shadowComponent = this.gameObject;
|
|
89
101
|
super.awake();
|
|
@@ -118,7 +130,7 @@ export class Canvas extends UIRootComponent {
|
|
|
118
130
|
this.updateRenderMode();
|
|
119
131
|
// this.onWillUpdateRenderSettings();
|
|
120
132
|
updateRenderSettingsRecursive(this.shadowComponent, this);
|
|
121
|
-
for (const ch of this.gameObject
|
|
133
|
+
for (const ch of GameObject.getComponentsInChildren(this.gameObject, BaseUIComponent)) {
|
|
122
134
|
updateRenderSettingsRecursive(ch.shadowComponent!, this);
|
|
123
135
|
}
|
|
124
136
|
}
|
|
@@ -126,7 +138,7 @@ export class Canvas extends UIRootComponent {
|
|
|
126
138
|
|
|
127
139
|
private _activeRenderMode: RenderMode = -1;
|
|
128
140
|
|
|
129
|
-
private get isScreenSpace()
|
|
141
|
+
private get isScreenSpace(): boolean {
|
|
130
142
|
return this._activeRenderMode === RenderMode.ScreenSpaceCamera || this._activeRenderMode === RenderMode.ScreenSpaceOverlay;
|
|
131
143
|
}
|
|
132
144
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// import { serializeable } from "../../engine/engine_serialization";
|
|
2
|
+
// import { Behaviour } from "../Component";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// export class CanvasScaler extends Behaviour {
|
|
6
|
+
|
|
7
|
+
// private _dynamicPixelsPerUnit: number = 1;
|
|
8
|
+
|
|
9
|
+
// @serializeable()
|
|
10
|
+
// get dynamicPixelsPerUnit(): number {
|
|
11
|
+
// return this._dynamicPixelsPerUnit;
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// private set dynamicPixelsPerUnit(val: number) {
|
|
15
|
+
// this._dynamicPixelsPerUnit = val;
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
// awake() {
|
|
19
|
+
// console.log(this);
|
|
20
|
+
// }
|
|
21
|
+
// }
|
|
@@ -11,6 +11,8 @@ import { InputEvents, KeyCode } from "../../engine/engine_input";
|
|
|
11
11
|
import { Object3D } from "three";
|
|
12
12
|
import { ICanvasGroup, IGraphic } from "./Interfaces";
|
|
13
13
|
import { getParam } from "../../engine/engine_utils";
|
|
14
|
+
import { UIRaycastUtils } from "./RaycastUtils";
|
|
15
|
+
import { $shadowDomOwner } from "./BaseUIComponent";
|
|
14
16
|
|
|
15
17
|
const debug = getParam("debugeventsystem");
|
|
16
18
|
|
|
@@ -75,9 +77,13 @@ export class EventSystem extends Behaviour {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
private _selectStartFn?: any;
|
|
81
|
+
private _selectEndFn?: any;
|
|
82
|
+
private _selectUpdateFn?: any;
|
|
83
|
+
|
|
78
84
|
onEnable(): void {
|
|
79
85
|
|
|
80
|
-
|
|
86
|
+
this._selectStartFn ??= (ctrl, args: { grab: THREE.Object3D | null }) => {
|
|
81
87
|
if (!args.grab) return;
|
|
82
88
|
MeshUIHelper.resetLastSelected();
|
|
83
89
|
const opts = new PointerEventData();
|
|
@@ -88,11 +94,9 @@ export class EventSystem extends Behaviour {
|
|
|
88
94
|
opts.isClicked = false;
|
|
89
95
|
if (args.grab && !this.handleEvents(args.grab, opts)) {
|
|
90
96
|
args.grab = null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const controllerRcOpts = new RaycastOptions();
|
|
95
|
-
WebXRController.addEventListener(ControllerEvents.SelectEnd, (ctrl, args: { grab: THREE.Object3D }) => {
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
this._selectEndFn ??= (ctrl, args: { grab: THREE.Object3D }) => {
|
|
96
100
|
if (!args.grab) return;
|
|
97
101
|
const opts = new PointerEventData();
|
|
98
102
|
opts.inputSource = ctrl;
|
|
@@ -101,23 +105,30 @@ export class EventSystem extends Behaviour {
|
|
|
101
105
|
opts.isPressed = ctrl.selectionPressed;
|
|
102
106
|
opts.isClicked = ctrl.selectionClick;
|
|
103
107
|
this.handleEvents(args.grab, opts);
|
|
104
|
-
}
|
|
108
|
+
};
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
const controllerRcOpts = new RaycastOptions();
|
|
111
|
+
this._selectUpdateFn ??= (_ctrl: WebXRController) => {
|
|
107
112
|
controllerRcOpts.ray = _ctrl.getRay();
|
|
108
113
|
const rc = this.performRaycast(controllerRcOpts);
|
|
109
114
|
if (!rc) return;
|
|
110
115
|
const opts = new PointerEventData();
|
|
111
116
|
opts.inputSource = _ctrl;
|
|
112
117
|
this.handleIntersections(rc, opts);
|
|
113
|
-
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
WebXRController.addEventListener(ControllerEvents.SelectStart, this._selectStartFn);
|
|
121
|
+
WebXRController.addEventListener(ControllerEvents.SelectEnd, this._selectEndFn);
|
|
122
|
+
WebXRController.addEventListener(ControllerEvents.Update, this._selectUpdateFn);
|
|
114
123
|
|
|
115
124
|
this.context.pre_update_callbacks.push(this.onBeforeUpdate.bind(this));
|
|
116
125
|
this.context.input.addEventListener(InputEvents.PointerDown, this.onPointerDown.bind(this));
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
onDisable(): void {
|
|
120
|
-
|
|
129
|
+
WebXRController.removeEventListener(ControllerEvents.SelectStart, this._selectStartFn);
|
|
130
|
+
WebXRController.removeEventListener(ControllerEvents.SelectEnd, this._selectEndFn);
|
|
131
|
+
WebXRController.removeEventListener(ControllerEvents.Update, this._selectUpdateFn);
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
onPointerDown() {
|
|
@@ -289,6 +300,8 @@ export class EventSystem extends Behaviour {
|
|
|
289
300
|
}
|
|
290
301
|
|
|
291
302
|
private handleEventsArray: Array<Behaviour> = [];
|
|
303
|
+
private out: { canvasGroup?: ICanvasGroup } = {};
|
|
304
|
+
|
|
292
305
|
private handleEvents(object: THREE.Object3D, args: PointerEventData): boolean {
|
|
293
306
|
|
|
294
307
|
if (!this.testIsVisible(object)) {
|
|
@@ -309,20 +322,12 @@ export class EventSystem extends Behaviour {
|
|
|
309
322
|
// handle potential shadow dom built from three mesh ui
|
|
310
323
|
if (parent && parent.isUI) {
|
|
311
324
|
const pressedOrClicked = (args.isPressed || args.isClicked) ?? false;
|
|
312
|
-
if (parent
|
|
313
|
-
const actualGo = parent.
|
|
325
|
+
if (parent[$shadowDomOwner]) {
|
|
326
|
+
const actualGo = parent[$shadowDomOwner].gameObject;
|
|
314
327
|
if (actualGo) {
|
|
315
|
-
|
|
316
|
-
if
|
|
317
|
-
|
|
318
|
-
if (canvasGroup.interactable === false) return true;
|
|
319
|
-
}
|
|
320
|
-
// handle Graphic Raycast target
|
|
321
|
-
const graphic = GameObject.foreachComponent(actualGo, c => {
|
|
322
|
-
if (typeof (c as unknown as IGraphic).raycastTarget === "boolean") return c;
|
|
323
|
-
return undefined;
|
|
324
|
-
}, false);
|
|
325
|
-
if (graphic?.raycastTarget === false) return false;
|
|
328
|
+
const res = UIRaycastUtils.isInteractable(actualGo, this.out);
|
|
329
|
+
if(!res) return this.out.canvasGroup?.interactable ?? false;
|
|
330
|
+
canvasGroup = this.out.canvasGroup ?? null;
|
|
326
331
|
|
|
327
332
|
const handled = this.handleMeshUIIntersection(object, pressedOrClicked);
|
|
328
333
|
if (!clicked && handled) {
|
|
@@ -339,6 +344,8 @@ export class EventSystem extends Behaviour {
|
|
|
339
344
|
}
|
|
340
345
|
}
|
|
341
346
|
|
|
347
|
+
if (clicked)
|
|
348
|
+
console.log(this.context.time.frame, object);
|
|
342
349
|
this.objectsHoveredThisFrame.push(object);
|
|
343
350
|
|
|
344
351
|
if (canvasGroup === null || canvasGroup.interactable) {
|
|
@@ -420,18 +427,6 @@ export class EventSystem extends Behaviour {
|
|
|
420
427
|
if (!GameObject.isActiveSelf(obj)) return false;
|
|
421
428
|
return this.testIsVisible(obj.parent);
|
|
422
429
|
}
|
|
423
|
-
|
|
424
|
-
private tryFindCanvasGroup(obj: THREE.Object3D | null): ICanvasGroup | null {
|
|
425
|
-
if (!obj) return null;
|
|
426
|
-
// test for canvas groups
|
|
427
|
-
const res = GameObject.foreachComponent(obj, c => {
|
|
428
|
-
const gr = c as unknown as ICanvasGroup;
|
|
429
|
-
if (gr.blocksRaycasts !== undefined && gr.interactable !== undefined) return gr;
|
|
430
|
-
return undefined;
|
|
431
|
-
}, false);
|
|
432
|
-
if (res !== undefined) return res;
|
|
433
|
-
return this.tryFindCanvasGroup(obj.parent);
|
|
434
|
-
}
|
|
435
430
|
}
|
|
436
431
|
|
|
437
432
|
|
|
@@ -6,6 +6,7 @@ import { serializeable } from '../../engine/engine_serialization_decorator';
|
|
|
6
6
|
import { Color, Texture } from 'three';
|
|
7
7
|
import { RectTransform } from './RectTransform';
|
|
8
8
|
import { onChange, scheduleAction } from "./Utils"
|
|
9
|
+
import { GameObject } from '../Component';
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
export class Graphic extends BaseUIComponent implements IGraphic {
|
|
@@ -45,7 +46,7 @@ export class Graphic extends BaseUIComponent implements IGraphic {
|
|
|
45
46
|
private _rect: RectTransform | null = null;
|
|
46
47
|
protected get rectTransform(): RectTransform {
|
|
47
48
|
if (!this._rect) {
|
|
48
|
-
this._rect = this.gameObject
|
|
49
|
+
this._rect = GameObject.getComponent(this.gameObject, RectTransform);
|
|
49
50
|
}
|
|
50
51
|
return this._rect!;
|
|
51
52
|
}
|