@needle-tools/engine 2.65.1-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 +27 -0
- package/dist/needle-engine.js +7945 -7782
- 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/extensions/NEEDLE_techniques_webgl.js +5 -2
- package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
- package/lib/engine-components/Animator.d.ts +25 -1
- package/lib/engine-components/Animator.js +63 -37
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.d.ts +14 -12
- package/lib/engine-components/AnimatorController.js +15 -13
- package/lib/engine-components/AnimatorController.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/extensions/NEEDLE_techniques_webgl.ts +5 -2
- package/src/engine-components/Animator.ts +53 -27
- package/src/engine-components/AnimatorController.ts +15 -13
- 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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Behaviour } from "./Component";
|
|
2
2
|
import { Rigidbody } from "./RigidBody";
|
|
3
3
|
import { serializable } from "../engine/engine_serialization_decorator";
|
|
4
|
-
import { Event, Mesh, Object3D, Vector3 } from "three"
|
|
4
|
+
import { Event, Group, Mesh, Object3D, Vector3 } from "three"
|
|
5
5
|
// import { IColliderProvider, registerColliderProvider } from "../engine/engine_physics";
|
|
6
6
|
import { ICollider } from "../engine/engine_types";
|
|
7
7
|
import { getWorldScale } from "../engine/engine_three_utils";
|
|
@@ -77,6 +77,7 @@ export class MeshCollider extends Collider {
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
sharedMesh?: Mesh;
|
|
80
|
+
|
|
80
81
|
@serializable()
|
|
81
82
|
convex: boolean = false;
|
|
82
83
|
|
|
@@ -88,8 +89,21 @@ export class MeshCollider extends Collider {
|
|
|
88
89
|
this.sharedMesh = this.gameObject;
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
if (this.sharedMesh?.isMesh)
|
|
92
|
+
if (this.sharedMesh?.isMesh) {
|
|
92
93
|
this.context.physics.addMeshCollider(this, this.sharedMesh, this.convex, getWorldScale(this.gameObject));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const group = this.sharedMesh as any as Group;
|
|
97
|
+
if (group?.isGroup) {
|
|
98
|
+
console.warn(`MeshCollider mesh is a group \"${this.sharedMesh?.name}\", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`, this)
|
|
99
|
+
for (const ch in group.children) {
|
|
100
|
+
const child = group.children[ch] as Mesh;
|
|
101
|
+
if (child.isMesh) {
|
|
102
|
+
this.context.physics.addMeshCollider(this, child, this.convex, getWorldScale(this.gameObject));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
|
|
@@ -330,7 +330,7 @@ class SizeBehaviour extends ParticleSystemBaseBehaviour {
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
const $particleLife = Symbol("particleLife");
|
|
333
|
+
export const $particleLife = Symbol("particleLife");
|
|
334
334
|
const $trailLifetime = Symbol("trailLifetime");
|
|
335
335
|
const $trailStartLength = Symbol("trailStartLength");
|
|
336
336
|
|
|
@@ -340,7 +340,6 @@ class TrailBehaviour extends ParticleSystemBaseBehaviour {
|
|
|
340
340
|
initialize(particle: Particle) {
|
|
341
341
|
if (particle instanceof TrailParticle) {
|
|
342
342
|
particle[$particleLife] = particle.life;
|
|
343
|
-
particle[$trailLifetime] = particle.life;
|
|
344
343
|
if (this.system.trails.enabled && this.system.trails.dieWithParticles === false) {
|
|
345
344
|
particle[$trailLifetime] = this.system.trails.lifetime.evaluate(Math.random(), Math.random());
|
|
346
345
|
particle.life += particle[$trailLifetime];
|
|
@@ -418,7 +417,7 @@ class VelocityBehaviour extends ParticleSystemBaseBehaviour {
|
|
|
418
417
|
if (gravityFactor !== 0) {
|
|
419
418
|
// gravityFactor *= -1;
|
|
420
419
|
temp3.copy(this._gravityDirection).multiplyScalar(gravityFactor);
|
|
421
|
-
if(debug) Gizmos.DrawDirection(particle.position, temp3, 0x0000ff, 0, false, 10);
|
|
420
|
+
if (debug) Gizmos.DrawDirection(particle.position, temp3, 0x0000ff, 0, false, 10);
|
|
422
421
|
baseVelocity.add(temp3);
|
|
423
422
|
}
|
|
424
423
|
particle.velocity.copy(baseVelocity);
|
|
@@ -747,6 +746,7 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
747
746
|
private _time: number = 0;
|
|
748
747
|
private _isPlaying: boolean = true;
|
|
749
748
|
private _isUsedAsSubsystem: boolean = false;
|
|
749
|
+
private _didPreWarm: boolean = false;
|
|
750
750
|
|
|
751
751
|
/** called from deserialization */
|
|
752
752
|
private set bursts(arr: ParticleBurst[]) {
|
|
@@ -779,7 +779,8 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
779
779
|
}
|
|
780
780
|
private _subEmitterSystems?: SubEmitterSystem[];
|
|
781
781
|
|
|
782
|
-
onAfterDeserialize(_){
|
|
782
|
+
onAfterDeserialize(_) {
|
|
783
|
+
// doing this here to get a chance to resolve the subemitter guid
|
|
783
784
|
if (this._subEmitterSystems && Array.isArray(this._subEmitterSystems)) {
|
|
784
785
|
for (const sub of this._subEmitterSystems) {
|
|
785
786
|
sub._deserialize(this.context, this.gameObject);
|
|
@@ -788,7 +789,6 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
788
789
|
}
|
|
789
790
|
|
|
790
791
|
awake(): void {
|
|
791
|
-
|
|
792
792
|
this._renderer = this.gameObject.getComponent(ParticleSystemRenderer) as ParticleSystemRenderer;
|
|
793
793
|
|
|
794
794
|
this._container = new Object3D();
|
|
@@ -837,16 +837,42 @@ export class ParticleSystem extends Behaviour implements IParticleSystem {
|
|
|
837
837
|
onEnable() {
|
|
838
838
|
if (this.inheritVelocity)
|
|
839
839
|
this.inheritVelocity.system = this;
|
|
840
|
+
if (this._batchSystem)
|
|
841
|
+
this._batchSystem.visible = true;
|
|
840
842
|
this.play();
|
|
841
843
|
}
|
|
842
844
|
|
|
843
845
|
onDisable() {
|
|
846
|
+
if (this._batchSystem)
|
|
847
|
+
this._batchSystem.visible = false;
|
|
844
848
|
}
|
|
845
849
|
|
|
846
850
|
onBeforeRender() {
|
|
851
|
+
if (this._didPreWarm === false && this.main?.prewarm === true) {
|
|
852
|
+
this._didPreWarm = true;
|
|
853
|
+
this.preWarm();
|
|
854
|
+
}
|
|
847
855
|
this.onUpdate();
|
|
848
|
-
|
|
856
|
+
this.onSimulate(this.deltaTime);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
private preWarm() {
|
|
860
|
+
const dt = 1 / 60;
|
|
861
|
+
const duration = this.main.duration;
|
|
862
|
+
const lifetime = this.main.startLifetime.getMax();
|
|
863
|
+
const maxDurationToPrewarm = 1000;
|
|
864
|
+
const timeToSimulate = Math.min(duration, lifetime, maxDurationToPrewarm);
|
|
865
|
+
const framesToSimulate = Math.ceil(timeToSimulate / dt);
|
|
866
|
+
if (debug)
|
|
867
|
+
console.log(`Particles ${this.name} - Prewarm for ${framesToSimulate} frames (${timeToSimulate} sec). Duration: ${duration}, Lifetime: ${lifetime}`);
|
|
868
|
+
for (let i = 0; i < framesToSimulate; i++) {
|
|
869
|
+
if (this.currentParticles >= this.maxParticles) break;
|
|
870
|
+
this.onUpdate();
|
|
871
|
+
this.onSimulate(dt);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
849
874
|
|
|
875
|
+
private onSimulate(dt: number) {
|
|
850
876
|
if (this._batchSystem) {
|
|
851
877
|
// Updating layers on batches
|
|
852
878
|
// TODO: figure out a better way to do this
|
|
@@ -942,10 +968,20 @@ export class SubEmitterSystem {
|
|
|
942
968
|
properties?: number;
|
|
943
969
|
type?: SubEmitterType;
|
|
944
970
|
|
|
945
|
-
_deserialize(
|
|
971
|
+
_deserialize(_context: Context, gameObject: GameObject) {
|
|
946
972
|
const ps = this.particleSystem;
|
|
947
|
-
if (ps
|
|
948
|
-
|
|
973
|
+
if (ps instanceof ParticleSystem) return;
|
|
974
|
+
|
|
975
|
+
let guid = "";
|
|
976
|
+
|
|
977
|
+
if (ps && typeof ps["guid"] === "string") {
|
|
978
|
+
guid = ps["guid"];
|
|
979
|
+
// subemitter MUST be a child of the particle system
|
|
980
|
+
this.particleSystem = GameObject.findByGuid(guid, gameObject) as ParticleSystem;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
if (debug && !(this.particleSystem instanceof ParticleSystem)) {
|
|
984
|
+
console.warn("Could not find particle system for sub emitter", guid, gameObject, this);
|
|
949
985
|
}
|
|
950
986
|
}
|
|
951
987
|
}
|
|
@@ -199,6 +199,33 @@ export class MinMaxCurve {
|
|
|
199
199
|
}
|
|
200
200
|
return 0;
|
|
201
201
|
}
|
|
202
|
+
|
|
203
|
+
getMax(): number {
|
|
204
|
+
switch (this.mode) {
|
|
205
|
+
case ParticleSystemCurveMode.Constant:
|
|
206
|
+
return this.constant;
|
|
207
|
+
case ParticleSystemCurveMode.Curve:
|
|
208
|
+
return this.getMaxFromCurve(this.curve!) * this.curveMultiplier!;
|
|
209
|
+
case ParticleSystemCurveMode.TwoCurves:
|
|
210
|
+
return Math.max(this.getMaxFromCurve(this.curveMin), this.getMaxFromCurve(this.curveMax)) * this.curveMultiplier!;
|
|
211
|
+
case ParticleSystemCurveMode.TwoConstants:
|
|
212
|
+
return Math.max(this.constantMin, this.constantMax);
|
|
213
|
+
default:
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private getMaxFromCurve(curve?: AnimationCurve) {
|
|
219
|
+
if (!curve) return 0;
|
|
220
|
+
let maxNumber = Number.MIN_VALUE;
|
|
221
|
+
for (let i = 0; i < curve!.keys.length; i++) {
|
|
222
|
+
const key = curve!.keys[i];
|
|
223
|
+
if (key.value > maxNumber) {
|
|
224
|
+
maxNumber = key.value;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return maxNumber;
|
|
228
|
+
}
|
|
202
229
|
}
|
|
203
230
|
|
|
204
231
|
export class MinMaxGradient {
|
|
@@ -571,7 +598,7 @@ export class ShapeModule implements EmitterShape {
|
|
|
571
598
|
if (this.enabled) {
|
|
572
599
|
switch (this.shapeType) {
|
|
573
600
|
case ParticleSystemShapeType.Box:
|
|
574
|
-
if(debug) Gizmos.DrawBox(this.position, this.scale, 0xdddddd, 1);
|
|
601
|
+
if (debug) Gizmos.DrawBox(this.position, this.scale, 0xdddddd, 1);
|
|
575
602
|
this._vector.x = Math.random() * this.scale.x - this.scale.x / 2;
|
|
576
603
|
this._vector.y = Math.random() * this.scale.y - this.scale.y / 2;
|
|
577
604
|
this._vector.z = Math.random() * this.scale.z - this.scale.z / 2;
|
|
@@ -2,7 +2,7 @@ import { Behavior, Particle, EmissionState, ParticleSystem, ParticleEmitter } fr
|
|
|
2
2
|
import { Vector3, Quaternion, Matrix4 } from "three";
|
|
3
3
|
import { IParticleSystem } from "./ParticleSystemModules";
|
|
4
4
|
import { CircularBuffer } from "../engine/engine_utils";
|
|
5
|
-
import { SubEmitterType } from "./ParticleSystem";
|
|
5
|
+
import { $particleLife, SubEmitterType } from "./ParticleSystem";
|
|
6
6
|
|
|
7
7
|
const VECTOR_ONE = new Vector3(1, 1, 1);
|
|
8
8
|
const VECTOR_Z = new Vector3(0, 0, 1);
|
|
@@ -73,13 +73,15 @@ export class ParticleSubEmitter implements Behavior {
|
|
|
73
73
|
if (!this.subParticleSystem || !particle.emissionState)
|
|
74
74
|
return;
|
|
75
75
|
|
|
76
|
-
if(this.emitterProbability && Math.random() > this.emitterProbability)
|
|
76
|
+
if (this.emitterProbability && Math.random() > this.emitterProbability)
|
|
77
77
|
return;
|
|
78
78
|
|
|
79
79
|
const delta = this.system.deltaTime;
|
|
80
80
|
|
|
81
81
|
if (this.emitterType === SubEmitterType.Death) {
|
|
82
|
-
|
|
82
|
+
let lifeTime = particle.life;
|
|
83
|
+
if (particle[$particleLife] !== undefined) lifeTime = particle[$particleLife];
|
|
84
|
+
const willDie = particle.age + delta * 1.2 >= lifeTime;
|
|
83
85
|
if (!willDie) return;
|
|
84
86
|
// Just emit all for now, we should probably add a way to get the amount from the subsystem emission module
|
|
85
87
|
const maxAmount = this.subSystem.main.maxParticles - this.subSystem.currentParticles;
|
|
@@ -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) {
|