@needle-tools/engine 2.35.5-pre → 2.36.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 +19 -0
- package/dist/needle-engine.d.ts +160 -110
- package/dist/needle-engine.js +370 -365
- package/dist/needle-engine.js.map +4 -4
- package/dist/needle-engine.min.js +61 -56
- package/dist/needle-engine.min.js.map +4 -4
- package/lib/engine/debug/debug_overlay.js +12 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_element_loading.js +1 -1
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.d.ts +1 -0
- package/lib/engine/engine_gameobject.js +13 -1
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +4 -0
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +1 -1
- package/lib/engine/engine_mainloop_utils.js +7 -3
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +29 -28
- package/lib/engine/engine_physics.js +85 -86
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_serialization_core.js +14 -6
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_setup.js +1 -1
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/engine_time.d.ts +1 -0
- package/lib/engine/engine_time.js +1 -0
- package/lib/engine/engine_time.js.map +1 -1
- package/lib/engine/engine_types.d.ts +1 -0
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_typestore.d.ts +1 -0
- package/lib/engine/engine_typestore.js +1 -0
- package/lib/engine/engine_typestore.js.map +1 -1
- package/lib/engine/engine_utils.js +1 -1
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_animator_controller_model.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js +5 -0
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine-components/Animation.d.ts +5 -1
- package/lib/engine-components/Animation.js +21 -0
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimatorController.d.ts +1 -0
- package/lib/engine-components/AnimatorController.js +14 -7
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/BoxHelperComponent.d.ts +2 -2
- package/lib/engine-components/BoxHelperComponent.js +27 -9
- package/lib/engine-components/BoxHelperComponent.js.map +1 -1
- package/lib/engine-components/Component.d.ts +2 -1
- package/lib/engine-components/Component.js +11 -5
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +2 -0
- package/lib/engine-components/GroundProjection.js +18 -6
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +22 -0
- package/lib/engine-components/ReflectionProbe.js +134 -0
- package/lib/engine-components/ReflectionProbe.js.map +1 -0
- package/lib/engine-components/Renderer.d.ts +13 -2
- package/lib/engine-components/Renderer.js +96 -45
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.d.ts +7 -7
- package/lib/engine-components/WebARSessionRoot.js +7 -7
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXR.d.ts +9 -8
- package/lib/engine-components/WebXR.js +40 -24
- package/lib/engine-components/WebXR.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.d.ts +4 -5
- package/lib/engine-components/WebXRAvatar.js +9 -8
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRController.d.ts +21 -21
- package/lib/engine-components/WebXRController.js +79 -63
- package/lib/engine-components/WebXRController.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.d.ts +3 -3
- package/lib/engine-components/WebXRGrabRendering.js +2 -2
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.d.ts +8 -8
- package/lib/engine-components/WebXRSync.js +15 -15
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +1 -0
- package/lib/engine-components/codegen/components.js +1 -0
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.d.ts +1 -0
- package/lib/engine-components/ui/EventSystem.js +21 -1
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/package.json +1 -1
- package/src/engine/codegen/register_types.js +293 -0
- package/src/engine/debug/debug_overlay.ts +9 -2
- package/src/engine/engine_element_loading.ts +1 -1
- package/src/engine/engine_gameobject.ts +17 -4
- package/src/engine/engine_gltf_builtin_components.ts +5 -1
- package/src/engine/engine_mainloop_utils.ts +7 -3
- package/src/engine/engine_physics.ts +130 -130
- package/src/engine/engine_serialization_core.ts +14 -7
- package/src/engine/engine_setup.ts +1 -1
- package/src/engine/engine_time.ts +2 -0
- package/src/engine/engine_types.ts +1 -0
- package/src/engine/engine_typestore.ts +2 -0
- package/src/engine/engine_utils.ts +3 -2
- package/src/engine/extensions/EXT_texture_exr.js +1 -1
- package/src/engine/extensions/NEEDLE_animator_controller_model.ts +2 -1
- package/src/engine/extensions/NEEDLE_techniques_webgl.ts +7 -0
- package/src/engine-components/Animation.ts +16 -1
- package/src/engine-components/AnimatorController.ts +19 -9
- package/src/engine-components/BoxHelperComponent.ts +29 -9
- package/src/engine-components/Component.ts +11 -5
- package/src/engine-components/GroundProjection.ts +22 -7
- package/src/engine-components/ReflectionProbe.ts +141 -0
- package/src/engine-components/Renderer.ts +796 -737
- package/src/engine-components/WebARSessionRoot.ts +16 -16
- package/src/engine-components/WebXR.ts +53 -48
- package/src/engine-components/WebXRAvatar.ts +16 -16
- package/src/engine-components/WebXRController.ts +129 -107
- package/src/engine-components/WebXRGrabRendering.ts +6 -6
- package/src/engine-components/WebXRSync.ts +20 -20
- package/src/engine-components/codegen/components.ts +1 -0
- package/src/engine-components/ui/EventSystem.ts +26 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Behaviour, GameObject } from "./Component";
|
|
2
2
|
import { RoomEvents, OwnershipModel, NetworkConnection } from "../engine/engine_networking";
|
|
3
3
|
import { WebXR, WebXREvent } from "./WebXR";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import { Group, Quaternion, Vector3, Vector4, WebXRManager, XRFrame, XRInputSource, XRRigidTransform, XRSession } from "three";
|
|
5
|
+
import { getParam } from "../engine/engine_utils";
|
|
6
6
|
import { Voip } from "./Voip";
|
|
7
7
|
import { Builder, Long } from "flatbuffers";
|
|
8
8
|
import { VrUserStateBuffer } from "../engine-schemes/vr-user-state-buffer";
|
|
@@ -17,9 +17,9 @@ import { WebXRAvatar } from "./WebXRAvatar";
|
|
|
17
17
|
// import { InteractiveGroup } from 'three/examples/jsm/interactive/InteractiveGroup.js';
|
|
18
18
|
// import { renderer, sceneData } from "../engine/engine_setup";
|
|
19
19
|
|
|
20
|
-
const debugLogs =
|
|
21
|
-
const debugAvatar =
|
|
22
|
-
// const debugAvatarVoip =
|
|
20
|
+
const debugLogs = getParam("debugxr");
|
|
21
|
+
const debugAvatar = getParam("debugavatar");
|
|
22
|
+
// const debugAvatarVoip = getParam("debugavatarvoip");
|
|
23
23
|
|
|
24
24
|
enum WebXRSyncEvent {
|
|
25
25
|
WebXR_UserJoined = "webxr-user-joined",
|
|
@@ -51,23 +51,23 @@ export class VRUserState {
|
|
|
51
51
|
public guid: string;
|
|
52
52
|
public time!: number;
|
|
53
53
|
public avatarId!: string;
|
|
54
|
-
public position:
|
|
55
|
-
public rotation:
|
|
54
|
+
public position: Vector3 = new Vector3();
|
|
55
|
+
public rotation: Vector4 = new Vector4();
|
|
56
56
|
public scale: number = 1;
|
|
57
57
|
|
|
58
|
-
public posLeftHand = new
|
|
59
|
-
public posRightHand = new
|
|
58
|
+
public posLeftHand = new Vector3();
|
|
59
|
+
public posRightHand = new Vector3();
|
|
60
60
|
|
|
61
|
-
public rotLeftHand = new
|
|
62
|
-
public rotRightHand = new
|
|
61
|
+
public rotLeftHand = new Quaternion();
|
|
62
|
+
public rotRightHand = new Quaternion();
|
|
63
63
|
|
|
64
64
|
public constructor(guid: string) {
|
|
65
65
|
this.guid = guid;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
private static invertRotation:
|
|
68
|
+
private static invertRotation: Quaternion = new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), Math.PI);
|
|
69
69
|
|
|
70
|
-
public update(rig:
|
|
70
|
+
public update(rig: Group, pos: DOMPointReadOnly, rot: DOMPointReadOnly, webXR: WebXR, avatarId: string) {
|
|
71
71
|
this.time = getTimeStampNow();
|
|
72
72
|
this.avatarId = avatarId;
|
|
73
73
|
this.position.set(pos.x, pos.y, pos.z);
|
|
@@ -117,8 +117,8 @@ export class VRUserState {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
private static quat0:
|
|
121
|
-
private static quat1:
|
|
120
|
+
private static quat0: Quaternion = new Quaternion();
|
|
121
|
+
private static quat1: Quaternion = new Quaternion();
|
|
122
122
|
|
|
123
123
|
public sendAsBuffer(builder: Builder, net: NetworkConnection) {
|
|
124
124
|
builder.clear();
|
|
@@ -379,7 +379,7 @@ export class WebXRSync extends Behaviour {
|
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
private onXRSessionStart(_evt: { session:
|
|
382
|
+
private onXRSessionStart(_evt: { session: XRSession }) {
|
|
383
383
|
console.log("XR session started");
|
|
384
384
|
this.context.connection.send(WebXRSyncEvent.WebXR_UserJoined, { id: this.context.connection.connectionId, mode: XRMode.VR });
|
|
385
385
|
|
|
@@ -399,7 +399,7 @@ export class WebXRSync extends Behaviour {
|
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
private onXRSessionEnded(_evt: { session:
|
|
402
|
+
private onXRSessionEnded(_evt: { session: XRSession }) {
|
|
403
403
|
console.log("XR session ended");
|
|
404
404
|
this.context.connection.send(WebXRSyncEvent.WebXR_UserLeft, { id: this.context.connection.connectionId, mode: XRMode.VR });
|
|
405
405
|
}
|
|
@@ -408,7 +408,7 @@ export class WebXRSync extends Behaviour {
|
|
|
408
408
|
private xrState: VRUserState | null = null;
|
|
409
409
|
private builder: Builder = new Builder(1024);
|
|
410
410
|
|
|
411
|
-
private onXRSessionUpdate(evt: { rig:
|
|
411
|
+
private onXRSessionUpdate(evt: { rig: Group, frame: XRFrame, xr: WebXRManager, input: XRInputSource[] }) {
|
|
412
412
|
|
|
413
413
|
this.xrState ??= new VRUserState(this.context.connection.connectionId ?? this.k_LocalAvatarNoNetworkingGuid);
|
|
414
414
|
this.ownership ??= new OwnershipModel(this.context.connection, this.context.connection.connectionId ?? this.k_LocalAvatarNoNetworkingGuid);
|
|
@@ -419,7 +419,7 @@ export class WebXRSync extends Behaviour {
|
|
|
419
419
|
const { frame, xr, rig } = evt;
|
|
420
420
|
const pose = frame.getViewerPose(xr.getReferenceSpace()!);
|
|
421
421
|
if (!pose) return; // e.g. if user is not wearing headset
|
|
422
|
-
const transform:
|
|
422
|
+
const transform: XRRigidTransform = pose?.transform;
|
|
423
423
|
const pos = transform.position;
|
|
424
424
|
const rot = transform.orientation;
|
|
425
425
|
this.xrState.update(rig, pos, rot, this.webXR!, this.getAvatarId());
|
|
@@ -451,7 +451,7 @@ export class WebXRSync extends Behaviour {
|
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
private getAvatarId() {
|
|
454
|
-
const urlAvatar =
|
|
454
|
+
const urlAvatar = getParam("avatar") as string;
|
|
455
455
|
const avatarId = urlAvatar ?? null;
|
|
456
456
|
return avatarId;
|
|
457
457
|
}
|
|
@@ -50,6 +50,7 @@ export { MainModule } from "../ParticleSystemModules";
|
|
|
50
50
|
export { EmissionModule } from "../ParticleSystemModules";
|
|
51
51
|
export { ShapeModule } from "../ParticleSystemModules";
|
|
52
52
|
export { PlayerColor } from "../PlayerColor";
|
|
53
|
+
export { ReflectionProbe } from "../ReflectionProbe";
|
|
53
54
|
export { FieldWithDefault } from "../Renderer";
|
|
54
55
|
export { Renderer } from "../Renderer";
|
|
55
56
|
export { MeshRenderer } from "../Renderer";
|
|
@@ -5,7 +5,7 @@ import { ControllerEvents, WebXRController } from "../WebXRController";
|
|
|
5
5
|
import * as ThreeMeshUI from 'three-mesh-ui'
|
|
6
6
|
import { Context } from "../../engine/engine_setup";
|
|
7
7
|
import { OrbitControls } from "../OrbitControls";
|
|
8
|
-
import { PointerEventData } from "./PointerEvents";
|
|
8
|
+
import { IPointerEventHandler, PointerEventData } from "./PointerEvents";
|
|
9
9
|
import { Raycaster } from "./Raycaster";
|
|
10
10
|
import { InputEvents, KeyCode } from "../../engine/engine_input";
|
|
11
11
|
import { Object3D } from "three";
|
|
@@ -83,6 +83,7 @@ export class EventSystem extends Behaviour {
|
|
|
83
83
|
|
|
84
84
|
onEnable(): void {
|
|
85
85
|
|
|
86
|
+
const grabbed: Map<any, Object3D | null> = new Map();
|
|
86
87
|
this._selectStartFn ??= (ctrl, args: { grab: THREE.Object3D | null }) => {
|
|
87
88
|
if (!args.grab) return;
|
|
88
89
|
MeshUIHelper.resetLastSelected();
|
|
@@ -92,6 +93,7 @@ export class EventSystem extends Behaviour {
|
|
|
92
93
|
opts.isUp = ctrl.selectionUp;
|
|
93
94
|
opts.isPressed = ctrl.selectionPressed;
|
|
94
95
|
opts.isClicked = false;
|
|
96
|
+
grabbed.set(ctrl, args.grab);
|
|
95
97
|
if (args.grab && !this.handleEvents(args.grab, opts)) {
|
|
96
98
|
args.grab = null;
|
|
97
99
|
};
|
|
@@ -105,6 +107,21 @@ export class EventSystem extends Behaviour {
|
|
|
105
107
|
opts.isPressed = ctrl.selectionPressed;
|
|
106
108
|
opts.isClicked = ctrl.selectionClick;
|
|
107
109
|
this.handleEvents(args.grab, opts);
|
|
110
|
+
|
|
111
|
+
const prevGrabbed = grabbed.get(ctrl);
|
|
112
|
+
grabbed.set(ctrl, null);
|
|
113
|
+
if (prevGrabbed) {
|
|
114
|
+
for (let i = 0; i < this.raisedPointerDownEvents.length; i++) {
|
|
115
|
+
const comp = this.raisedPointerDownEvents[i];
|
|
116
|
+
const obj = this.raisedPointerDownObjects[i];
|
|
117
|
+
if (obj === prevGrabbed && comp) {
|
|
118
|
+
comp.onPointerUp?.call(comp, opts);
|
|
119
|
+
this.raisedPointerDownEvents.splice(i, 1);
|
|
120
|
+
this.raisedPointerDownObjects.splice(i, 1);
|
|
121
|
+
i--;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
108
125
|
};
|
|
109
126
|
|
|
110
127
|
const controllerRcOpts = new RaycastOptions();
|
|
@@ -143,8 +160,11 @@ export class EventSystem extends Behaviour {
|
|
|
143
160
|
private lastPointerEvent: PointerEventData | null = null;
|
|
144
161
|
private objectsHoveredThisFrame: THREE.Object3D[] = [];
|
|
145
162
|
private objectsHoveredLastFrame: THREE.Object3D[] = [];
|
|
163
|
+
|
|
146
164
|
// todo: these should be listed by input source (e.g. per controller, mouse, touch)
|
|
147
|
-
private raisedPointerDownEvents:
|
|
165
|
+
private raisedPointerDownEvents: IPointerEventHandler[] = []; // << keep in sync
|
|
166
|
+
private raisedPointerDownObjects: THREE.Object3D[] = []; // < keep in sync
|
|
167
|
+
|
|
148
168
|
private _didMove: boolean = false;
|
|
149
169
|
|
|
150
170
|
onBeforeUpdate() {
|
|
@@ -216,6 +236,7 @@ export class EventSystem extends Behaviour {
|
|
|
216
236
|
}
|
|
217
237
|
}
|
|
218
238
|
this.raisedPointerDownEvents.length = 0;
|
|
239
|
+
this.raisedPointerDownObjects.length = 0;
|
|
219
240
|
}
|
|
220
241
|
|
|
221
242
|
for (const obj of this.objectsHoveredLastFrame) {
|
|
@@ -310,6 +331,7 @@ export class EventSystem extends Behaviour {
|
|
|
310
331
|
return false;
|
|
311
332
|
}
|
|
312
333
|
|
|
334
|
+
const originalObject = object;
|
|
313
335
|
args.object = object;
|
|
314
336
|
this.lastPointerEvent = args;
|
|
315
337
|
|
|
@@ -326,7 +348,7 @@ export class EventSystem extends Behaviour {
|
|
|
326
348
|
const actualGo = parent[$shadowDomOwner].gameObject;
|
|
327
349
|
if (actualGo) {
|
|
328
350
|
const res = UIRaycastUtils.isInteractable(actualGo, this.out);
|
|
329
|
-
if(!res) return this.out.canvasGroup?.interactable ?? false;
|
|
351
|
+
if (!res) return this.out.canvasGroup?.interactable ?? false;
|
|
330
352
|
canvasGroup = this.out.canvasGroup ?? null;
|
|
331
353
|
|
|
332
354
|
const handled = this.handleMeshUIIntersection(object, pressedOrClicked);
|
|
@@ -371,6 +393,7 @@ export class EventSystem extends Behaviour {
|
|
|
371
393
|
comp.onPointerDown(args);
|
|
372
394
|
// need to save this to also send pointer up event
|
|
373
395
|
this.raisedPointerDownEvents.push(comp);
|
|
396
|
+
this.raisedPointerDownObjects.push(originalObject);
|
|
374
397
|
}
|
|
375
398
|
}
|
|
376
399
|
|