@needle-tools/engine 2.65.2-pre → 2.66.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 +23 -0
- package/dist/needle-engine.js +7866 -7756
- package/dist/needle-engine.umd.cjs +223 -223
- package/lib/engine/debug/debug_overlay.js +4 -1
- package/lib/engine/debug/debug_overlay.js.map +1 -1
- package/lib/engine/engine_addressables.js +2 -2
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_element.d.ts +1 -0
- package/lib/engine/engine_element.js +4 -1
- package/lib/engine/engine_element.js.map +1 -1
- package/lib/engine/engine_element_loading.d.ts +3 -2
- package/lib/engine/engine_element_loading.js +18 -14
- package/lib/engine/engine_element_loading.js.map +1 -1
- package/lib/engine/engine_gameobject.js +6 -3
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gizmos.js +3 -1
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +3 -1
- package/lib/engine/engine_networking.js +10 -8
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_physics.d.ts +29 -1
- package/lib/engine/engine_physics.js +99 -10
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine/engine_setup.js +3 -0
- package/lib/engine/engine_setup.js.map +1 -1
- package/lib/engine/extensions/NEEDLE_render_objects.js +9 -0
- package/lib/engine/extensions/NEEDLE_render_objects.js.map +1 -1
- package/lib/engine-components/Animator.js +0 -1
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/CharacterController.d.ts +1 -0
- package/lib/engine-components/CharacterController.js +14 -9
- package/lib/engine-components/CharacterController.js.map +1 -1
- package/lib/engine-components/Collider.js +14 -1
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/ParticleSystem.d.ts +5 -1
- package/lib/engine-components/ParticleSystem.js +41 -6
- package/lib/engine-components/ParticleSystem.js.map +1 -1
- package/lib/engine-components/ParticleSystemModules.d.ts +2 -0
- package/lib/engine-components/ParticleSystemModules.js +26 -0
- package/lib/engine-components/ParticleSystemModules.js.map +1 -1
- package/lib/engine-components/ParticleSystemSubEmitter.js +5 -2
- package/lib/engine-components/ParticleSystemSubEmitter.js.map +1 -1
- package/lib/engine-components/Renderer.js +9 -5
- package/lib/engine-components/Renderer.js.map +1 -1
- package/lib/engine-components/ScreenCapture.js +3 -3
- package/lib/engine-components/ScreenCapture.js.map +1 -1
- package/lib/engine-components/SpectatorCamera.js +3 -3
- package/lib/engine-components/SpectatorCamera.js.map +1 -1
- package/lib/engine-components/SyncedCamera.js +1 -1
- package/lib/engine-components/SyncedCamera.js.map +1 -1
- package/lib/engine-components/SyncedTransform.js +2 -2
- package/lib/engine-components/SyncedTransform.js.map +1 -1
- package/lib/engine-components/TestRunner.js +1 -1
- package/lib/engine-components/TestRunner.js.map +1 -1
- package/lib/engine-components/WebARSessionRoot.js +3 -2
- package/lib/engine-components/WebARSessionRoot.js.map +1 -1
- package/lib/engine-components/WebXRAvatar.js.map +1 -1
- package/lib/engine-components/WebXRGrabRendering.js +2 -2
- package/lib/engine-components/WebXRGrabRendering.js.map +1 -1
- package/lib/engine-components/WebXRSync.js +2 -2
- package/lib/engine-components/WebXRSync.js.map +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js +1 -1
- package/lib/engine-components-experimental/networking/PlayerSync.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite/meta.js +3 -0
- package/plugins/vite/poster-client.js +6 -4
- package/src/engine/debug/debug_overlay.ts +4 -1
- package/src/engine/engine_addressables.ts +2 -2
- package/src/engine/engine_element.ts +8 -1
- package/src/engine/engine_element_loading.ts +18 -14
- package/src/engine/engine_gameobject.ts +584 -583
- package/src/engine/engine_gizmos.ts +3 -2
- package/src/engine/engine_networking.ts +10 -8
- package/src/engine/engine_physics.ts +113 -10
- package/src/engine/engine_setup.ts +4 -0
- package/src/engine/extensions/NEEDLE_render_objects.ts +10 -1
- package/src/engine-components/Animator.ts +0 -1
- package/src/engine-components/CharacterController.ts +12 -9
- package/src/engine-components/Collider.ts +16 -2
- package/src/engine-components/ParticleSystem.ts +45 -9
- package/src/engine-components/ParticleSystemModules.ts +28 -1
- package/src/engine-components/ParticleSystemSubEmitter.ts +5 -3
- package/src/engine-components/Renderer.ts +14 -11
- package/src/engine-components/ScreenCapture.ts +3 -3
- package/src/engine-components/SpectatorCamera.ts +3 -3
- package/src/engine-components/SyncedCamera.ts +1 -1
- package/src/engine-components/SyncedTransform.ts +2 -2
- package/src/engine-components/TestRunner.ts +1 -1
- package/src/engine-components/WebARSessionRoot.ts +3 -2
- package/src/engine-components/WebXRAvatar.ts +0 -1
- package/src/engine-components/WebXRGrabRendering.ts +2 -2
- package/src/engine-components/WebXRSync.ts +2 -2
- package/src/engine-components-experimental/networking/PlayerSync.ts +1 -1
|
@@ -90,6 +90,8 @@ class SharedMaterialArray implements ISharedMaterials {
|
|
|
90
90
|
if (!target) continue;
|
|
91
91
|
const mat = target.material as Material;
|
|
92
92
|
if (!mat) continue;
|
|
93
|
+
// set the shadow side to the same as the side of the material, three flips this for some reason
|
|
94
|
+
mat.shadowSide = mat.side;
|
|
93
95
|
for (let k = 0; k < originalMaterials.length; k++) {
|
|
94
96
|
const orig = originalMaterials[k];
|
|
95
97
|
if (!orig) {
|
|
@@ -110,7 +112,7 @@ class SharedMaterialArray implements ISharedMaterials {
|
|
|
110
112
|
this._indexMap = indexMap;
|
|
111
113
|
const warningMessage = `Renderer ${renderer.name} was initialized with missing materials - this may lead to unexpected behaviour when trying to access sharedMaterials by index.`;
|
|
112
114
|
console.warn(warningMessage);
|
|
113
|
-
if(isLocalNetwork()) showBalloonWarning("Found renderer with missing materials: please check the console for details.");
|
|
115
|
+
if (isLocalNetwork()) showBalloonWarning("Found renderer with missing materials: please check the console for details.");
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
// this lets us override the javascript indexer, only works in ES6 tho
|
|
@@ -503,7 +505,7 @@ export class Renderer extends Behaviour implements IRenderer {
|
|
|
503
505
|
// console.log(this.name, this.gameObject.matrixWorldNeedsUpdate);
|
|
504
506
|
const needsUpdate: boolean = this.gameObject[NEED_UPDATE_INSTANCE_KEY] === true;// || this.gameObject.matrixWorldNeedsUpdate;
|
|
505
507
|
if (needsUpdate) {
|
|
506
|
-
if(debugInstancing)
|
|
508
|
+
if (debugInstancing)
|
|
507
509
|
console.log("UPDATE INSTANCED MATRICES", this.context.time.frame);
|
|
508
510
|
this.gameObject[NEED_UPDATE_INSTANCE_KEY] = false;
|
|
509
511
|
const remove = false;// Math.random() < .01;
|
|
@@ -712,7 +714,7 @@ class InstancingHandler {
|
|
|
712
714
|
|
|
713
715
|
public objs: InstancedMeshRenderer[] = [];
|
|
714
716
|
|
|
715
|
-
public setup(renderer:Renderer, obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
|
|
717
|
+
public setup(renderer: Renderer, obj: THREE.Object3D, context: Context, handlesArray: InstanceHandle[] | null, args: InstancingSetupArgs, level: number = 0)
|
|
716
718
|
: InstanceHandle[] | null {
|
|
717
719
|
|
|
718
720
|
const res = this.tryCreateOrAddInstance(obj, context, args);
|
|
@@ -729,6 +731,14 @@ class InstancingHandler {
|
|
|
729
731
|
handlesArray = this.setup(renderer, ch, context, handlesArray, args, nextLevel);
|
|
730
732
|
}
|
|
731
733
|
}
|
|
734
|
+
|
|
735
|
+
if (level === 0) {
|
|
736
|
+
// For multi material objects we only want to track the root object's matrix
|
|
737
|
+
if (args.useMatrixWorldAutoUpdate && handlesArray && handlesArray.length >= 0) {
|
|
738
|
+
this.autoUpdateInstanceMatrix(obj);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
732
742
|
return handlesArray;
|
|
733
743
|
}
|
|
734
744
|
|
|
@@ -755,8 +765,6 @@ class InstancingHandler {
|
|
|
755
765
|
if (i.isFull()) continue;
|
|
756
766
|
if (i.geo === geo && i.material === mat) {
|
|
757
767
|
const handle = i.addInstance(mesh);
|
|
758
|
-
if (args.useMatrixWorldAutoUpdate && handle)
|
|
759
|
-
this.autoUpdateInstanceMatrix(mesh, i, handle);
|
|
760
768
|
return handle;
|
|
761
769
|
}
|
|
762
770
|
}
|
|
@@ -764,17 +772,14 @@ class InstancingHandler {
|
|
|
764
772
|
const i = new InstancedMeshRenderer(obj.name, geo, mat, 200, context);
|
|
765
773
|
this.objs.push(i);
|
|
766
774
|
const handle = i.addInstance(mesh);
|
|
767
|
-
if (args.useMatrixWorldAutoUpdate && handle)
|
|
768
|
-
this.autoUpdateInstanceMatrix(mesh, i, handle);
|
|
769
775
|
return handle;
|
|
770
776
|
}
|
|
771
777
|
return null;
|
|
772
778
|
}
|
|
773
779
|
|
|
774
|
-
private autoUpdateInstanceMatrix(obj: Object3D
|
|
780
|
+
private autoUpdateInstanceMatrix(obj: Object3D) {
|
|
775
781
|
const original = obj.matrixWorld["multiplyMatrices"].bind(obj.matrixWorld);
|
|
776
782
|
let previousMatrix: THREE.Matrix4 = obj.matrixWorld.clone();
|
|
777
|
-
|
|
778
783
|
const matrixChangeWrapper = (a: Matrix4, b: Matrix4) => {
|
|
779
784
|
const newMatrixWorld = original(a, b);
|
|
780
785
|
// console.warn("MULT", obj.matrixWorldNeedsUpdate);
|
|
@@ -786,7 +791,6 @@ class InstancingHandler {
|
|
|
786
791
|
return newMatrixWorld;
|
|
787
792
|
};
|
|
788
793
|
obj.matrixWorld["multiplyMatrices"] = matrixChangeWrapper;
|
|
789
|
-
|
|
790
794
|
// wrap matrixWorldNeedsUpdate
|
|
791
795
|
// let originalMatrixWorldNeedsUpdate = obj.matrixWorldNeedsUpdate;
|
|
792
796
|
// Object.defineProperty(obj, "matrixWorldNeedsUpdate", {
|
|
@@ -798,7 +802,6 @@ class InstancingHandler {
|
|
|
798
802
|
// originalMatrixWorldNeedsUpdate = value;
|
|
799
803
|
// }
|
|
800
804
|
// });
|
|
801
|
-
|
|
802
805
|
}
|
|
803
806
|
}
|
|
804
807
|
const instancing: InstancingHandler = new InstancingHandler();
|
|
@@ -409,9 +409,9 @@ class PeerHandle extends EventDispatcher {
|
|
|
409
409
|
disable() {
|
|
410
410
|
if (!this._enabled) return;
|
|
411
411
|
this._enabled = false;
|
|
412
|
-
this.context.connection.
|
|
413
|
-
this.context.connection.
|
|
414
|
-
this.context.connection.
|
|
412
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.onConnectRoomFn);
|
|
413
|
+
this.context.connection.stopListen(RoomEvents.UserJoinedRoom, this.onUserJoinedOrLeftRoomFn);
|
|
414
|
+
this.context.connection.stopListen(RoomEvents.UserLeftRoom, this.onUserJoinedOrLeftRoomFn);
|
|
415
415
|
this.unsubscribePeerEvents();
|
|
416
416
|
}
|
|
417
417
|
|
|
@@ -562,9 +562,9 @@ class SpectatorCamNetworking {
|
|
|
562
562
|
}
|
|
563
563
|
|
|
564
564
|
destroy() {
|
|
565
|
-
this.context.connection.
|
|
566
|
-
this.context.connection.
|
|
567
|
-
this.context.connection.
|
|
565
|
+
this.context.connection.stopListen("spectator-follower-changed", this._followerEventMethod);
|
|
566
|
+
this.context.connection.stopListen("spectator-request-follow", this._requestFollowMethod);
|
|
567
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this._joinedRoomMethod);
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
onSpectatedObjectChanged(target: PlayerView | undefined, _prevId?: string) {
|
|
@@ -102,7 +102,7 @@ export class SyncedCamera extends Behaviour {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
onEnable(): void {
|
|
105
|
-
this._receiveCallback = this.context.connection.
|
|
105
|
+
this._receiveCallback = this.context.connection.beginListenBinary(SyncedCameraModelIdentifier, this.onReceivedRemoteCameraInfoBin.bind(this));
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
onDisable(): void {
|
|
@@ -105,7 +105,7 @@ export class SyncedTransform extends Behaviour {
|
|
|
105
105
|
this.joinedRoomCallback = this.tryGetLastState.bind(this);
|
|
106
106
|
this.context.connection.beginListen(RoomEvents.JoinedRoom, this.joinedRoomCallback);
|
|
107
107
|
this.receivedDataCallback = this.onReceivedData.bind(this);
|
|
108
|
-
this.context.connection.
|
|
108
|
+
this.context.connection.beginListenBinary(SyncedTransformIdentifier, this.receivedDataCallback);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
onDestroy(): void {
|
|
@@ -113,7 +113,7 @@ export class SyncedTransform extends Behaviour {
|
|
|
113
113
|
if (this.syncDestroy)
|
|
114
114
|
sendDestroyed(this.guid, this.context.connection);
|
|
115
115
|
this._model = null;
|
|
116
|
-
this.context.connection.
|
|
116
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.joinedRoomCallback);
|
|
117
117
|
this.context.connection.stopListenBinary(SyncedTransformIdentifier, this.receivedDataCallback);
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -21,7 +21,7 @@ export class TestSimulateUserData extends Behaviour {
|
|
|
21
21
|
|
|
22
22
|
awake(): void {
|
|
23
23
|
if (this.useFlatbuffers) {
|
|
24
|
-
this.context.connection.
|
|
24
|
+
this.context.connection.beginListenBinary(SyncedTransformIdentifier, (_mod: SyncedTransformModel) => {
|
|
25
25
|
// console.log("Received transform");
|
|
26
26
|
// const sc = SyncedTransformModel.getRootAsSyncedTransformModel(bin);
|
|
27
27
|
// console.log(mod.guid());
|
|
@@ -84,10 +84,11 @@ export class WebARSessionRoot extends Behaviour {
|
|
|
84
84
|
|
|
85
85
|
if (this._isTouching) {
|
|
86
86
|
// callbacks
|
|
87
|
-
|
|
87
|
+
const poseMatrix = new Matrix4().fromArray(pose.transform.matrix).invert();
|
|
88
|
+
this.dispatchEvent(new CustomEvent('placedSession', { detail: { pose, poseMatrix } }));
|
|
88
89
|
|
|
89
90
|
if (this.webAR) this.webAR.setReticleActive(false);
|
|
90
|
-
this.placeAt(rig,
|
|
91
|
+
this.placeAt(rig, poseMatrix);
|
|
91
92
|
return true;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -9,7 +9,6 @@ import { AssetReference } from "../engine/engine_addressables";
|
|
|
9
9
|
import { Object3D } from "three";
|
|
10
10
|
import { VRUserState } from "./WebXRSync";
|
|
11
11
|
import { getParam } from "../engine/engine_utils";
|
|
12
|
-
import { serializable } from "../engine/engine_serialization_decorator";
|
|
13
12
|
import { ViewDevice } from "../engine/engine_playerview";
|
|
14
13
|
import { InstancingUtil } from "../engine/engine_instancing";
|
|
15
14
|
|
|
@@ -54,8 +54,8 @@ export class XRGrabRendering extends Behaviour {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
onDisable(): void {
|
|
57
|
-
this.context.connection.
|
|
58
|
-
this.context.connection.
|
|
57
|
+
this.context.connection.stopListen(XRGrabEvent.StartOrUpdate, this._addOrUpdateSub);
|
|
58
|
+
this.context.connection.stopListen(XRGrabEvent.End, this._endSub);
|
|
59
59
|
AttachedObject.RemoveEventListener(AttachedObjectEvents.WillFree, this._freeSub);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -253,7 +253,7 @@ export class WebXRSync extends Behaviour {
|
|
|
253
253
|
this.avatars[evt.id] = undefined;
|
|
254
254
|
}
|
|
255
255
|
});
|
|
256
|
-
this.context.connection.
|
|
256
|
+
this.context.connection.beginListenBinary(VRUserStateBufferIdentifier, (state: VrUserStateBuffer) => {
|
|
257
257
|
// console.log("BUFFER", state);
|
|
258
258
|
const guid = state.guid();
|
|
259
259
|
if (!guid) return;
|
|
@@ -299,7 +299,7 @@ export class WebXRSync extends Behaviour {
|
|
|
299
299
|
|
|
300
300
|
onDisable() {
|
|
301
301
|
if (this.eventSub_ConnectionEvent)
|
|
302
|
-
this.context.connection.
|
|
302
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.eventSub_ConnectionEvent);
|
|
303
303
|
WebXR.removeEventListener(WebXREvent.XRStarted, this.eventSub_WebXRStartEvent);
|
|
304
304
|
WebXR.removeEventListener(WebXREvent.XRUpdate, this.eventSub_WebXRUpdateEvent);
|
|
305
305
|
WebXR.removeEventListener(WebXREvent.XRStopped, this.eventSub_WebXREndEvent);
|
|
@@ -24,7 +24,7 @@ export class PlayerSync extends Behaviour {
|
|
|
24
24
|
this.context.connection.beginListen(RoomEvents.JoinedRoom, this.joinedRoomFunction!)
|
|
25
25
|
}
|
|
26
26
|
onDisable(): void {
|
|
27
|
-
this.context.connection.
|
|
27
|
+
this.context.connection.stopListen(RoomEvents.JoinedRoom, this.joinedRoomFunction!)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
private async onUserJoined(_model) {
|