@needle-tools/engine 2.34.0-pre → 2.35.1-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 +16 -0
- package/dist/needle-engine.d.ts +3128 -2942
- package/dist/needle-engine.js +455 -455
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +54 -54
- 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 +17 -0
- package/lib/engine/engine_components.js +240 -0
- package/lib/engine/engine_components.js.map +1 -0
- package/lib/engine/engine_element.js +4 -3
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.js +4 -1
- package/lib/engine/engine_element_loading.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_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 +6 -10
- package/lib/engine/engine_networking.js +7 -11
- 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 +5 -24
- package/lib/engine/engine_physics.js +27 -61
- 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 +108 -0
- package/lib/engine/engine_types.js +50 -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/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 +3 -1
- package/lib/engine-components/Collider.js +11 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +21 -55
- package/lib/engine-components/Component.js +67 -466
- package/lib/engine-components/Component.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/Networking.d.ts +3 -1
- package/lib/engine-components/Networking.js +3 -0
- package/lib/engine-components/Networking.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 -2
- package/lib/engine-components/Renderer.js +2 -0
- 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.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +2 -1
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.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/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRController.js +28 -8
- 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 -1
- package/lib/engine-components/codegen/components.js +1 -1
- 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 +27 -50
- 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 +1 -1
- package/lib/engine-components/ui/EventSystem.js +11 -31
- 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 +12 -1
- package/src/engine/api.ts +3 -0
- package/src/engine/codegen/register_types.js +2 -2
- package/src/engine/engine_addressables.ts +12 -10
- package/src/engine/{engine_components.js → engine_components.ts} +66 -61
- package/src/engine/engine_element.ts +4 -3
- package/src/engine/engine_element_loading.ts +5 -1
- 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_lightdata.ts +1 -1
- package/src/engine/engine_mainloop_utils.ts +13 -11
- package/src/engine/engine_networking.ts +14 -17
- 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 +45 -77
- 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 +188 -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/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 +17 -2
- package/src/engine-components/Component.ts +87 -541
- 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/Networking.ts +6 -1
- package/src/engine-components/OrbitControls.ts +5 -5
- package/src/engine-components/Renderer.ts +5 -1
- package/src/engine-components/RigidBody.ts +2 -1
- package/src/engine-components/ScreenCapture.ts +1 -1
- package/src/engine-components/SpectatorCamera.ts +7 -5
- package/src/engine-components/SyncedCamera.ts +2 -1
- package/src/engine-components/SyncedTransform.ts +1 -1
- package/src/engine-components/TestRunner.ts +1 -2
- package/src/engine-components/Voip.ts +2 -1
- package/src/engine-components/WebXR.ts +2 -2
- package/src/engine-components/WebXRController.ts +30 -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 -1
- package/src/engine-components/js-extensions/ExtensionUtils.ts +66 -0
- package/src/engine-components/js-extensions/Object3D.ts +37 -61
- 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 +11 -25
- 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
|
@@ -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
|
|
|
@@ -298,6 +300,8 @@ export class EventSystem extends Behaviour {
|
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
private handleEventsArray: Array<Behaviour> = [];
|
|
303
|
+
private out: { canvasGroup?: ICanvasGroup } = {};
|
|
304
|
+
|
|
301
305
|
private handleEvents(object: THREE.Object3D, args: PointerEventData): boolean {
|
|
302
306
|
|
|
303
307
|
if (!this.testIsVisible(object)) {
|
|
@@ -318,20 +322,12 @@ export class EventSystem extends Behaviour {
|
|
|
318
322
|
// handle potential shadow dom built from three mesh ui
|
|
319
323
|
if (parent && parent.isUI) {
|
|
320
324
|
const pressedOrClicked = (args.isPressed || args.isClicked) ?? false;
|
|
321
|
-
if (parent
|
|
322
|
-
const actualGo = parent.
|
|
325
|
+
if (parent[$shadowDomOwner]) {
|
|
326
|
+
const actualGo = parent[$shadowDomOwner].gameObject;
|
|
323
327
|
if (actualGo) {
|
|
324
|
-
|
|
325
|
-
if
|
|
326
|
-
|
|
327
|
-
if (canvasGroup.interactable === false) return true;
|
|
328
|
-
}
|
|
329
|
-
// handle Graphic Raycast target
|
|
330
|
-
const graphic = GameObject.foreachComponent(actualGo, c => {
|
|
331
|
-
if (typeof (c as unknown as IGraphic).raycastTarget === "boolean") return c;
|
|
332
|
-
return undefined;
|
|
333
|
-
}, false);
|
|
334
|
-
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;
|
|
335
331
|
|
|
336
332
|
const handled = this.handleMeshUIIntersection(object, pressedOrClicked);
|
|
337
333
|
if (!clicked && handled) {
|
|
@@ -348,6 +344,8 @@ export class EventSystem extends Behaviour {
|
|
|
348
344
|
}
|
|
349
345
|
}
|
|
350
346
|
|
|
347
|
+
// if (clicked)
|
|
348
|
+
// console.log(this.context.time.frame, object);
|
|
351
349
|
this.objectsHoveredThisFrame.push(object);
|
|
352
350
|
|
|
353
351
|
if (canvasGroup === null || canvasGroup.interactable) {
|
|
@@ -429,18 +427,6 @@ export class EventSystem extends Behaviour {
|
|
|
429
427
|
if (!GameObject.isActiveSelf(obj)) return false;
|
|
430
428
|
return this.testIsVisible(obj.parent);
|
|
431
429
|
}
|
|
432
|
-
|
|
433
|
-
private tryFindCanvasGroup(obj: THREE.Object3D | null): ICanvasGroup | null {
|
|
434
|
-
if (!obj) return null;
|
|
435
|
-
// test for canvas groups
|
|
436
|
-
const res = GameObject.foreachComponent(obj, c => {
|
|
437
|
-
const gr = c as unknown as ICanvasGroup;
|
|
438
|
-
if (gr.blocksRaycasts !== undefined && gr.interactable !== undefined) return gr;
|
|
439
|
-
return undefined;
|
|
440
|
-
}, false);
|
|
441
|
-
if (res !== undefined) return res;
|
|
442
|
-
return this.tryFindCanvasGroup(obj.parent);
|
|
443
|
-
}
|
|
444
430
|
}
|
|
445
431
|
|
|
446
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
|
}
|
|
@@ -4,6 +4,7 @@ import { BaseUIComponent, includesDir } from './BaseUIComponent';
|
|
|
4
4
|
import { Text } from './Text';
|
|
5
5
|
import { getWorldScale } from '../../engine/engine_three_utils';
|
|
6
6
|
import { RectTransform } from './RectTransform';
|
|
7
|
+
import { GameObject } from '../Component';
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
enum KeymapOption {
|
|
@@ -63,7 +64,7 @@ export class Keyboard extends BaseUIComponent {
|
|
|
63
64
|
|
|
64
65
|
const fontName = this.font ? this.font : "arial";
|
|
65
66
|
|
|
66
|
-
const rt = this.gameObject
|
|
67
|
+
const rt = GameObject.getComponent(this.gameObject, RectTransform);
|
|
67
68
|
if(!rt){
|
|
68
69
|
console.error("Missing rect transform, please add this component inside a canvas");
|
|
69
70
|
return;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { foreachComponent } from "../../engine/engine_gameobject";
|
|
2
|
+
import { objectSerializer } from "../../engine/engine_serialization_builtin_serializer";
|
|
3
|
+
import { IComponent } from "../../engine/engine_types";
|
|
4
|
+
import { $shadowDomOwner } from "./BaseUIComponent";
|
|
5
|
+
import { ICanvasGroup, IGraphic } from "./Interfaces";
|
|
6
|
+
import { Object3D } from "three";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class UIRaycastUtils {
|
|
10
|
+
|
|
11
|
+
/** returns the real object when dealing with shadow UI */
|
|
12
|
+
static getObject(obj: Object3D): Object3D {
|
|
13
|
+
const shadowOwner = obj[$shadowDomOwner];
|
|
14
|
+
if(shadowOwner)
|
|
15
|
+
{
|
|
16
|
+
if((shadowOwner as IComponent).isComponent === true) obj = (shadowOwner as IComponent).gameObject;
|
|
17
|
+
else obj = shadowOwner;
|
|
18
|
+
}
|
|
19
|
+
return obj;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
static isInteractable(obj: THREE.Object3D, out?: { canvasGroup?: ICanvasGroup, graphic?: IGraphic }): boolean {
|
|
23
|
+
if(obj === null || obj === undefined || !obj.visible) return false;
|
|
24
|
+
|
|
25
|
+
obj = this.getObject(obj);
|
|
26
|
+
|
|
27
|
+
if(!obj.visible) return false;
|
|
28
|
+
|
|
29
|
+
const canvasGroup = this.tryFindCanvasGroup(obj);
|
|
30
|
+
if (canvasGroup?.isCanvasGroup === true) {
|
|
31
|
+
if (out) out.canvasGroup = canvasGroup as ICanvasGroup;
|
|
32
|
+
if (canvasGroup.blocksRaycasts === false) return false;
|
|
33
|
+
if (canvasGroup.interactable === false) return false;
|
|
34
|
+
}
|
|
35
|
+
// handle Graphic Raycast target
|
|
36
|
+
const graphic = foreachComponent(obj, c => {
|
|
37
|
+
if ((c as unknown as IGraphic).isGraphic === true) return c;
|
|
38
|
+
return undefined;
|
|
39
|
+
}, false);
|
|
40
|
+
// console.log(obj, graphic?.raycastTarget);
|
|
41
|
+
if (out) {
|
|
42
|
+
if (graphic?.isGraphic === true)
|
|
43
|
+
out.graphic = graphic as IGraphic;
|
|
44
|
+
}
|
|
45
|
+
if (graphic?.raycastTarget === false) return false;
|
|
46
|
+
|
|
47
|
+
console.log(graphic);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
private static tryFindCanvasGroup(obj: THREE.Object3D | null): ICanvasGroup | null {
|
|
53
|
+
if (!obj) return null;
|
|
54
|
+
// test for canvas groups
|
|
55
|
+
const res = foreachComponent(obj, c => {
|
|
56
|
+
const gr = c as unknown as ICanvasGroup;
|
|
57
|
+
if (gr.blocksRaycasts !== undefined && gr.interactable !== undefined) return gr;
|
|
58
|
+
return undefined;
|
|
59
|
+
}, false);
|
|
60
|
+
if (res !== undefined) return res;
|
|
61
|
+
return this.tryFindCanvasGroup(obj.parent);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Graphic } from './Graphic';
|
|
2
2
|
import * as ThreeMeshUI from 'three-mesh-ui'
|
|
3
|
-
import { includesDir } from "./BaseUIComponent";
|
|
3
|
+
import { $shadowDomOwner, includesDir } from "./BaseUIComponent";
|
|
4
4
|
import { RectTransform } from './RectTransform';
|
|
5
5
|
import { Color } from 'three';
|
|
6
6
|
import { FrameEvent } from '../../engine/engine_setup';
|
|
@@ -163,11 +163,15 @@ export class Text extends Graphic {
|
|
|
163
163
|
private _textContainer: any = null;
|
|
164
164
|
|
|
165
165
|
private getTextOpts(): object {
|
|
166
|
+
let fontSize = this.fontSize;
|
|
167
|
+
// if (this.canvas) {
|
|
168
|
+
// fontSize /= this.canvas?.scaleFactor;
|
|
169
|
+
// }
|
|
166
170
|
const textOpts = {
|
|
167
171
|
content: this.text,
|
|
168
172
|
fontColor: this.color,
|
|
169
173
|
fontOpacity: this.color.alpha,
|
|
170
|
-
fontSize:
|
|
174
|
+
fontSize: fontSize,
|
|
171
175
|
fontKerning: "normal",
|
|
172
176
|
};
|
|
173
177
|
this.font = this.font?.toLocaleLowerCase();
|
|
@@ -274,8 +278,8 @@ export class Text extends Graphic {
|
|
|
274
278
|
private ensureShadowComponentOwner() {
|
|
275
279
|
if (this.shadowComponent) {
|
|
276
280
|
this.shadowComponent.traverse(c => {
|
|
277
|
-
if (c[
|
|
278
|
-
c[
|
|
281
|
+
if (c[$shadowDomOwner] === undefined)
|
|
282
|
+
c[$shadowDomOwner] = this;
|
|
279
283
|
});
|
|
280
284
|
}
|
|
281
285
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { FrontSide, DoubleSide, BackSide, TetrahedronGeometry } from "three"
|
|
3
3
|
import { FrameEvent } from "../../engine/engine_setup";
|
|
4
4
|
import { Behaviour, GameObject } from "../Component";
|
|
5
|
+
import { $shadowDomOwner } from "./BaseUIComponent";
|
|
5
6
|
|
|
6
7
|
// export function makeNonRaycastable(obj: THREE.Object3D | null | undefined, recursive: boolean = false) {
|
|
7
8
|
// if (!obj) return;
|
|
@@ -14,7 +15,7 @@ import { Behaviour, GameObject } from "../Component";
|
|
|
14
15
|
// }
|
|
15
16
|
|
|
16
17
|
export function isUIObject(obj: THREE.Object3D) {
|
|
17
|
-
return obj["isUI"] === true || typeof obj[
|
|
18
|
+
return obj["isUI"] === true || typeof obj[$shadowDomOwner] === "object";
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type RenderSettings = {
|
|
@@ -27,7 +28,7 @@ export type RenderSettings = {
|
|
|
27
28
|
|
|
28
29
|
export function updateRenderSettings(shadowComponent: THREE.Object3D, settings: RenderSettings) {
|
|
29
30
|
if (!shadowComponent) return;
|
|
30
|
-
// const owner = shadowComponent[
|
|
31
|
+
// const owner = shadowComponent[$shadowDomOwner];
|
|
31
32
|
// if (!owner)
|
|
32
33
|
// console.log(shadowComponent)
|
|
33
34
|
const mat = shadowComponent["material"];
|
package/src/needle-engine.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import "./engine/engine_element";
|
|
2
2
|
import "./engine/engine_setup";
|
|
3
|
-
import
|
|
3
|
+
import "./engine/codegen/register_types";
|
|
4
4
|
// import "./engine/engine_mainloop";
|
|
5
5
|
// import "./engine-components/DomOverlay";
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
export { GameObject, Behaviour } from "./engine-components/Component";
|
|
8
9
|
export { serializeable } from "./engine/engine_serialization_decorator";
|
|
9
|
-
export { Collision } from "./engine/
|
|
10
|
+
export { Collision } from "./engine/engine_types";
|
|
11
|
+
export * from "./engine/api";
|
|
10
12
|
export * from "./engine-components/codegen/components";
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
export * from "./engine-components/js-extensions/Object3D";
|
|
14
16
|
|
|
17
|
+
|
|
15
18
|
// make accessible for external javascript
|
|
16
19
|
import { Context } from "./engine/engine_setup";
|
|
17
20
|
const Needle = { Context: Context };
|
|
@@ -23,6 +26,8 @@ function registerGlobal(obj: object) {
|
|
|
23
26
|
}
|
|
24
27
|
import * as Component from "./engine-components/Component";
|
|
25
28
|
registerGlobal(Component);
|
|
29
|
+
|
|
30
|
+
import * as Components from "./engine-components/codegen/components";
|
|
26
31
|
registerGlobal(Components);
|
|
27
32
|
|
|
28
33
|
import { GameObject } from "./engine-components/Component";
|