@needle-tools/engine 2.36.0-pre → 2.37.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/needle-engine.d.ts +171 -141
  3. package/dist/needle-engine.js +451 -437
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +82 -82
  6. package/dist/needle-engine.min.js.map +4 -4
  7. package/lib/engine/api.d.ts +1 -0
  8. package/lib/engine/api.js +1 -0
  9. package/lib/engine/api.js.map +1 -1
  10. package/lib/engine/debug/debug.d.ts +1 -0
  11. package/lib/engine/debug/debug.js +3 -0
  12. package/lib/engine/debug/debug.js.map +1 -1
  13. package/lib/engine/engine_gameobject.js +2 -1
  14. package/lib/engine/engine_gameobject.js.map +1 -1
  15. package/lib/engine/engine_physics.d.ts +33 -42
  16. package/lib/engine/engine_physics.js +431 -383
  17. package/lib/engine/engine_physics.js.map +1 -1
  18. package/lib/engine/engine_physics.types.d.ts +16 -0
  19. package/lib/engine/engine_physics.types.js +19 -0
  20. package/lib/engine/engine_physics.types.js.map +1 -0
  21. package/lib/engine/engine_serialization_core.d.ts +3 -0
  22. package/lib/engine/engine_serialization_core.js +5 -0
  23. package/lib/engine/engine_serialization_core.js.map +1 -1
  24. package/lib/engine/engine_setup.js +3 -1
  25. package/lib/engine/engine_setup.js.map +1 -1
  26. package/lib/engine/engine_types.d.ts +45 -26
  27. package/lib/engine/engine_types.js +24 -37
  28. package/lib/engine/engine_types.js.map +1 -1
  29. package/lib/engine/engine_util_decorator.d.ts +6 -0
  30. package/lib/engine/engine_util_decorator.js +54 -0
  31. package/lib/engine/engine_util_decorator.js.map +1 -0
  32. package/lib/engine/engine_utils.d.ts +1 -1
  33. package/lib/engine/engine_utils.js +1 -1
  34. package/lib/engine/engine_utils.js.map +1 -1
  35. package/lib/engine/extensions/NEEDLE_gameobject_data.js +2 -0
  36. package/lib/engine/extensions/NEEDLE_gameobject_data.js.map +1 -1
  37. package/lib/engine-components/Animation.d.ts +6 -5
  38. package/lib/engine-components/Animation.js +0 -7
  39. package/lib/engine-components/Animation.js.map +1 -1
  40. package/lib/engine-components/BoxHelperComponent.js +1 -0
  41. package/lib/engine-components/BoxHelperComponent.js.map +1 -1
  42. package/lib/engine-components/Collider.d.ts +7 -2
  43. package/lib/engine-components/Collider.js +27 -15
  44. package/lib/engine-components/Collider.js.map +1 -1
  45. package/lib/engine-components/Component.d.ts +6 -15
  46. package/lib/engine-components/Component.js +7 -112
  47. package/lib/engine-components/Component.js.map +1 -1
  48. package/lib/engine-components/DragControls.js +9 -6
  49. package/lib/engine-components/DragControls.js.map +1 -1
  50. package/lib/engine-components/NavMesh.d.ts +0 -5
  51. package/lib/engine-components/NavMesh.js +100 -10
  52. package/lib/engine-components/NavMesh.js.map +1 -1
  53. package/lib/engine-components/NestedGltf.js +2 -0
  54. package/lib/engine-components/NestedGltf.js.map +1 -1
  55. package/lib/engine-components/RigidBody.d.ts +40 -25
  56. package/lib/engine-components/RigidBody.js +253 -142
  57. package/lib/engine-components/RigidBody.js.map +1 -1
  58. package/lib/engine-components/SpatialTrigger.js +1 -1
  59. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  60. package/lib/engine-components/SpectatorCamera.d.ts +1 -0
  61. package/lib/engine-components/SpectatorCamera.js +9 -2
  62. package/lib/engine-components/SpectatorCamera.js.map +1 -1
  63. package/lib/engine-components/SpringJoint.d.ts +0 -13
  64. package/lib/engine-components/SpringJoint.js +42 -41
  65. package/lib/engine-components/SpringJoint.js.map +1 -1
  66. package/lib/engine-components/VideoPlayer.js.map +1 -1
  67. package/lib/engine-components/WebXR.d.ts +1 -0
  68. package/lib/engine-components/WebXR.js +10 -2
  69. package/lib/engine-components/WebXR.js.map +1 -1
  70. package/lib/engine-components/WebXRController.js +12 -6
  71. package/lib/engine-components/WebXRController.js.map +1 -1
  72. package/lib/engine-components/codegen/components.d.ts +1 -3
  73. package/lib/engine-components/codegen/components.js +1 -3
  74. package/lib/engine-components/codegen/components.js.map +1 -1
  75. package/package.json +3 -4
  76. package/src/engine/api.ts +2 -1
  77. package/src/engine/codegen/register_types.js +4 -12
  78. package/src/engine/debug/debug.ts +4 -0
  79. package/src/engine/engine_gameobject.ts +4 -4
  80. package/src/engine/engine_physics.ts +460 -421
  81. package/src/engine/engine_physics.types.ts +19 -0
  82. package/src/engine/engine_serialization_core.ts +8 -1
  83. package/src/engine/engine_setup.ts +5 -1
  84. package/src/engine/engine_types.ts +82 -56
  85. package/src/engine/engine_util_decorator.ts +69 -0
  86. package/src/engine/engine_utils.ts +3 -3
  87. package/src/engine/extensions/NEEDLE_gameobject_data.ts +2 -0
  88. package/src/engine-components/Animation.ts +10 -12
  89. package/src/engine-components/BoxHelperComponent.ts +1 -0
  90. package/src/engine-components/Collider.ts +29 -29
  91. package/src/engine-components/Component.ts +15 -130
  92. package/src/engine-components/DragControls.ts +9 -5
  93. package/src/engine-components/NavMesh.ts +114 -115
  94. package/src/engine-components/NestedGltf.ts +2 -0
  95. package/src/engine-components/RigidBody.ts +258 -149
  96. package/src/engine-components/SpatialTrigger.ts +1 -1
  97. package/src/engine-components/SpectatorCamera.ts +10 -2
  98. package/src/engine-components/SpringJoint.ts +41 -41
  99. package/src/engine-components/VideoPlayer.ts +1 -2
  100. package/src/engine-components/WebXR.ts +12 -2
  101. package/src/engine-components/WebXRController.ts +16 -7
  102. package/src/engine-components/codegen/components.ts +1 -3
@@ -6,7 +6,7 @@ import { Context, FrameEvent } from "../engine/engine_setup";
6
6
  import * as main from "../engine/engine_mainloop_utils";
7
7
  import { Object3D } from "three";
8
8
  import { syncDestroy, syncInstantiate } from "../engine/engine_networking_instantiate";
9
- import { ConstructorConcrete, SourceIdentifier, IComponent, IGameObject, Constructor, GuidsMap, UIDProvider, Collision } from "../engine/engine_types";
9
+ import { ConstructorConcrete, SourceIdentifier, IComponent, IGameObject, Constructor, GuidsMap, UIDProvider, Collision, ICollider } from "../engine/engine_types";
10
10
  import { addNewComponentInstance, destroyComponentInstance, findObjectOfType, findObjectsOfType, getComponent, getComponentInChildren, getComponentInParent, getComponents, getComponentsInChildren, getComponentsInParent, getOrAddComponent, moveComponentInstance, removeComponent } from "../engine/engine_components";
11
11
  import { findByGuid, destroy, InstantiateOptions, instantiate, HideFlags, foreachComponent, markAsInstancedRendered, isActiveInHierarchy, isActiveSelf, isUsingInstancing, setActive } from "../engine/engine_gameobject";
12
12
 
@@ -317,9 +317,8 @@ class Component implements IComponent, EventTarget {
317
317
  onDestroy() {
318
318
  this.__destroyed = true;
319
319
  }
320
+ onValidate?(prop?: string): void;
320
321
  start?(): void;
321
- // available update loop events:
322
- // earlyUpdate, update, lateUpdate, onBeforeRender, onAfterRender
323
322
  earlyUpdate?(): void;
324
323
  update?(): void;
325
324
  lateUpdate?(): void;
@@ -328,12 +327,11 @@ class Component implements IComponent, EventTarget {
328
327
 
329
328
  onCollisionEnter?(col: Collision);
330
329
  onCollisionExit?(col: Collision);
331
- onCollisionExitRaw?(col: Collision);
332
330
  onCollisionStay?(col: Collision);
333
-
334
- onTriggerEnter?(col: Collision);
335
- onTriggerStay?(col: Collision);
336
- onTriggerExit?(col: Collision);
331
+
332
+ onTriggerEnter?(col: ICollider);
333
+ onTriggerStay?(col: ICollider);
334
+ onTriggerExit?(col: ICollider);
337
335
 
338
336
  startCoroutine(routine: Generator, evt: FrameEvent = FrameEvent.Update): Generator {
339
337
  return this.context.registerCoroutineUpdate(this, routine, evt);
@@ -360,13 +358,19 @@ class Component implements IComponent, EventTarget {
360
358
 
361
359
  get __internalDidAwakeAndStart() { return this.__didAwake && this.__didStart; }
362
360
 
361
+
362
+ constructor() {
363
+ // super();
364
+ this.__internalNewInstanceCreated();
365
+ }
366
+
363
367
  __internalNewInstanceCreated() {
364
368
  this.__didAwake = false;
365
369
  this.__didStart = false;
366
370
  this.__didEnable = false;
367
371
  this.__isEnabled = undefined;
368
372
  this.__destroyed = false;
369
- this.__internalResetsCachedPhysicsData();
373
+ // this.__internalResetsCachedPhysicsData();
370
374
  }
371
375
 
372
376
  __internalAwake() {
@@ -397,9 +401,9 @@ class Component implements IComponent, EventTarget {
397
401
  __internalDisable() {
398
402
  if (!this.__didEnable) return;
399
403
  this.__didEnable = false;
400
- this._collisionExitRoutine = undefined;
404
+ // this._collisionExitRoutine = undefined;
401
405
  this.onDisable();
402
- this._collisions?.clear();
406
+ // this._collisions?.clear();
403
407
  // if we do this after processing the callback
404
408
  this.__isEnabled = false;
405
409
  }
@@ -437,126 +441,7 @@ class Component implements IComponent, EventTarget {
437
441
  }
438
442
  }
439
443
 
440
- constructor() {
441
- // super();
442
- this.__internalNewInstanceCreated();
443
- }
444
-
445
- private _collisionExitRoutine: any;
446
- private _collisions: Map<Object3D, { col: Collision, frame: number, exitFrame?: number }> | null = null;
447
-
448
- private _triggerExitRoutine: any;
449
- private _triggerCollisions: Map<Object3D, { col: Collision, frame: number, exitFrame?: number }> | null = null;
450
-
451
- get collisionsCount() { return this._collisions?.size ?? 0; }
452
-
453
- private __internalResetsCachedPhysicsData() {
454
- this._collisionExitRoutine = null;
455
- this._collisions = null;
456
- this._triggerExitRoutine = null;
457
- this._triggerCollisions = null;
458
- }
459
-
460
- __internalHandleCollision(col: Collision, isTriggerCollision: boolean) {
461
- if (isTriggerCollision) {
462
- if (!this.onTriggerEnter && !this.onTriggerStay && !this.onTriggerExit) return;
463
- }
464
- else {
465
- if (!this.onCollisionEnter && !this.onCollisionStay && !this.onCollisionExit) return;
466
- }
467
-
468
- const otherObject = col.gameObject;
469
-
470
- // lazily create the maps
471
- if (isTriggerCollision && !this._triggerCollisions) this._triggerCollisions = new Map();
472
- else if (!this._collisions) this._collisions = new Map();
473
-
474
- // select the correct map
475
- const collection = isTriggerCollision ? this._triggerCollisions! : this._collisions!;
476
-
477
- if (collection.has(otherObject)) {
478
- const cur = collection.get(otherObject)!;
479
- // console.log("STAY", this.name, this.context.time.frameCount)
480
- // cur.exitFrame = undefined;
481
- cur.frame = this.context.time.frameCount;
482
- cur.col = col;
483
- if (isTriggerCollision)
484
- this.onTriggerStay?.(col);
485
- else
486
- this.onCollisionStay?.call(this, col);
487
- }
488
- else {
489
- // console.log("START", this.name);
490
- const entry = { col, frame: this.context.time.frameCount };
491
- collection.set(otherObject, entry);
492
- if (isTriggerCollision)
493
- this.onTriggerEnter?.(col);
494
- else
495
- this.onCollisionEnter?.call(this, col);
496
- }
497
- }
498
-
499
- __internalHandleExitCollisionEvent(obj: Object3D, isTriggerCollision: boolean) {
500
- if (isTriggerCollision) {
501
- if (!this._triggerCollisions) return;
502
- }
503
- else {
504
- if (!this._collisions) return;
505
- }
506
-
507
- const collection = isTriggerCollision ? this._triggerCollisions! : this._collisions!;
508
-
509
- const collision = collection.get(obj);
510
- if (!collision) return;
511
- collision.exitFrame = this.context.time.frameCount;
512
- // console.log("EXIT col", this.name, this.context.time.frameCount);
513
- // if (this.onCollisionExit !== undefined)
514
- this.__waitForCollisionExit(isTriggerCollision);
515
- if (!isTriggerCollision)
516
- this.onCollisionExitRaw?.call(this, collision.col);
517
- // this._collisions.delete(obj);
518
- }
519
-
520
- private __waitForCollisionExit(isTriggerCollision: boolean) {
521
- const routine = isTriggerCollision ? this._triggerExitRoutine : this._collisionExitRoutine;
522
- if (routine) return;
523
-
524
- const collection = isTriggerCollision ? this._triggerCollisions! : this._collisions!;
525
- const self = this;
526
- const frames = 10;
527
- function* delayedExitRoutine() {
528
- while (collection && collection.size > 0) {
529
- for (let other of collection.keys()) {
530
- const entry = collection!.get(other)!;
531
- if (entry.frame !== undefined && self.context.time.frameCount - entry.frame >= frames) {
532
- // console.log("EXIT real", self.name, entry.col.gameObject.name, collection);
533
- collection!.delete(other);
534
- if (isTriggerCollision)
535
- self.onTriggerExit?.(entry.col);
536
- else
537
- self.onCollisionExit?.call(self, entry.col);
538
- }
539
- }
540
- for (let i = 0; i < frames; i++)
541
- yield;
542
- }
543
- if (isTriggerCollision)
544
- self._triggerExitRoutine = undefined;
545
- else
546
- self._collisionExitRoutine = null;
547
- // console.log("DONE", self.name);
548
- }
549
-
550
- const newRoutine = this.startCoroutine(delayedExitRoutine(), FrameEvent.OnAfterRender);
551
- if (isTriggerCollision)
552
- this._triggerExitRoutine = newRoutine;
553
- else
554
- this._collisionExitRoutine = newRoutine
555
- }
556
-
557
-
558
444
  // TODO move this to threeutils
559
-
560
445
  // we need a copy for modifying the values to local space
561
446
  private static _worldPositionBuffer: THREE.Vector3 = new THREE.Vector3();
562
447
  private static _worldQuaternionBuffer: THREE.Quaternion = new THREE.Quaternion();
@@ -230,7 +230,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
230
230
  this._dragHelper.onUpdate(this.context);
231
231
  for (const rb of this._draggingRigidbodies) {
232
232
  rb.wakeUp();
233
- rb.setBodyFromGameObject();
233
+ rb.resetVelocities();
234
234
  }
235
235
  }
236
236
 
@@ -238,6 +238,9 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
238
238
  if (!this || !this._isDragging) return;
239
239
  this._isDragging = false;
240
240
  if (!this._dragHelper) return;
241
+ for(const rb of this._draggingRigidbodies){
242
+ rb.setVelocity(rb.smoothedVelocity);
243
+ }
241
244
  this._draggingRigidbodies.length = 0;
242
245
  const selected = this._dragHelper.selected;
243
246
  if (debug)
@@ -323,8 +326,8 @@ class DragHelper {
323
326
  if (this._selected && context) {
324
327
  for (const rb of this._rbs) {
325
328
  rb.wakeUp();
326
- if (!rb.smoothedVelocity) continue;
327
- rb.setVelocity(rb.smoothedVelocity.x, rb.smoothedVelocity.y, rb.smoothedVelocity.z);
329
+ // if (!rb.smoothedVelocity) continue;
330
+ rb.setVelocity(0,0,0);
328
331
  }
329
332
  }
330
333
 
@@ -358,7 +361,7 @@ class DragHelper {
358
361
  this._groundOffset.set(0, 0, 0);
359
362
  this._requireUpdateGroundPlane = true;
360
363
 
361
- this._rbs = GameObject.getComponentsInChildren(this._selected, Rigidbody);
364
+ // this._rbs = GameObject.getComponentsInChildren(this._selected, Rigidbody);
362
365
  this.onUpdateScreenSpacePlane();
363
366
  }
364
367
  }
@@ -518,7 +521,8 @@ class DragHelper {
518
521
 
519
522
  for (const rb of this._rbs) {
520
523
  rb.wakeUp();
521
- rb.setBodyFromGameObject({ x: 0, y: 0, z: 0 });
524
+ rb.resetForcesAndTorques();
525
+ // rb.setBodyFromGameObject({ x: 0, y: 0, z: 0 });
522
526
  rb.setAngularVelocity(0, 0, 0);
523
527
  }
524
528
  }
@@ -1,118 +1,117 @@
1
1
 
2
- import { Behaviour, GameObject } from "./Component";
3
- /*
4
- import { Pathfinding, PathfindingHelper } from 'three-pathfinding';
5
- import * as THREE from 'three';
6
- import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils'
7
- */
8
- export class NavMesh extends Behaviour {
9
- /*
10
- public meshes: THREE.Object3D[] = [];
11
-
12
- private pathfinding: Pathfinding | null = null;
13
- private zones: string[] = [];
14
-
15
- onEnable(): void {
16
-
17
- this.pathfinding = new Pathfinding();
18
- const ZONE = 'zone';
19
- const geometries : THREE.BufferGeometry[] = [];
20
- if (this.meshes && this.meshes.length > 0) {
21
- for (let i = 0; i < this.meshes.length; i++) {
22
- const obj = this.meshes[i] as THREE.Mesh;
23
- if (!obj) continue;
24
- const geo = obj.geometry;
25
- if (!geo) continue;
26
- const copy : THREE.BufferGeometry = {...geo};
27
- // const copy = geo;
28
- const attributesCopy = {...copy.attributes};
29
- copy.attributes = attributesCopy;
30
- if(attributesCopy.uv2) delete attributesCopy.uv2;
31
- // copy.applyMatrix4(obj.matrixWorld);
32
- geometries.push(copy);
33
- // obj.updateMatrixWorld();
34
- // singleGeometry.merge(geo);
35
- // console.log(singleGeometry, geo);
36
- }
37
- }
38
- const mesh = mergeBufferGeometries(geometries);
39
- const zone = Pathfinding.createZone(mesh);
40
- const name = ZONE;
41
- this.zones.push(name);
42
- this.pathfinding.setZoneData(name, zone);
43
-
44
- // const target = new THREE.Vector3(2, 0, 2);
45
- // const groupID = this.pathfinding.getGroup(ZONE, target);
46
- // const path = this.pathfinding.findPath(this.worldPosition, target, ZONE, groupID);
47
- // console.log(path, this.pathfinding);
48
- }
49
-
50
- public tryFindPath(from: THREE.Vector3, to: THREE.Vector3): THREE.Vector3[] | null {
51
- const zone = this.zones[0];
52
- const groupId = this.pathfinding.getGroup(zone, to);
53
- const path = this.pathfinding.findPath(from, to, zone, groupId);
54
- return path;
55
- }
56
- */
57
- }
58
-
59
- // import { input } from "../engine/engine_input";
60
- import { Physics, RaycastOptions } from "../engine/engine_physics"
61
- // import { time } from "../engine/engine_time";
62
- // import { scene } from "../engine/engine_setup";
63
- import { Quaternion } from "math/Quaternion";
64
- import {SyncedTransform} from "./SyncedTransform";
65
-
66
- export class NavMeshAgent extends Behaviour {
67
- /*
68
- public navMesh: NavMesh | null = null;
69
-
70
- private currentPath: THREE.Vector3[] | null = null;
71
- private helper : PathfindingHelper | null = null;
72
-
73
- onEnable(): void {
74
- this.helper = new PathfindingHelper();
75
- scene.add(this.helper);
76
- }
77
-
78
- update(): void {
79
- if (input.mouseClick) {
80
- if (this.navMesh) {
81
- const from = this.worldPosition;
82
- const opts = new RaycastOptions();
83
- opts.setMask(RaycastOptions.AllLayers);
84
- const hits = Physics.raycast(opts);
85
- if (hits.length > 0) {
86
- const to = hits[0].point;
87
- this.helper.setPlayerPosition(from);
88
- this.helper.setTargetPosition(to);
89
- this.currentPath = this.navMesh.tryFindPath(from, to);
90
- this.helper.setPath(this.currentPath);
91
- // console.log(...this.currentPath);
92
-
93
- const sync = GameObject.getComponent(this.gameObject, SyncedTransform);
94
- if(sync) sync.requestOwnership();
95
- }
96
- }
97
- }
98
-
99
- if (this.currentPath && this.currentPath.length > 0) {
100
-
101
- const wp = this.worldPosition;
102
- const target = this.currentPath[0];
103
- this.worldPosition = wp.lerp(target, time.deltaTime*2);
104
-
105
- this.gameObject.lookAt(target);
106
- // const vec = target.clone().sub(wp);
107
- // const wr = this.worldQuaternion;
108
- // wr.slerp(rot, time.deltaTime*5);
109
- // this.worldQuaternion = wr;
110
-
111
- if (wp.distanceTo(this.currentPath[0]) < 0.1)
112
- this.currentPath.shift();
2
+ // import { Behaviour, GameObject } from "./Component";
3
+ // /*
4
+ // import { Pathfinding, PathfindingHelper } from 'three-pathfinding';
5
+ // import * as THREE from 'three';
6
+ // import { mergeBufferGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils'
7
+ // */
8
+ // export class NavMesh extends Behaviour {
9
+ // /*
10
+ // public meshes: THREE.Object3D[] = [];
11
+
12
+ // private pathfinding: Pathfinding | null = null;
13
+ // private zones: string[] = [];
14
+
15
+ // onEnable(): void {
16
+
17
+ // this.pathfinding = new Pathfinding();
18
+ // const ZONE = 'zone';
19
+ // const geometries : THREE.BufferGeometry[] = [];
20
+ // if (this.meshes && this.meshes.length > 0) {
21
+ // for (let i = 0; i < this.meshes.length; i++) {
22
+ // const obj = this.meshes[i] as THREE.Mesh;
23
+ // if (!obj) continue;
24
+ // const geo = obj.geometry;
25
+ // if (!geo) continue;
26
+ // const copy : THREE.BufferGeometry = {...geo};
27
+ // // const copy = geo;
28
+ // const attributesCopy = {...copy.attributes};
29
+ // copy.attributes = attributesCopy;
30
+ // if(attributesCopy.uv2) delete attributesCopy.uv2;
31
+ // // copy.applyMatrix4(obj.matrixWorld);
32
+ // geometries.push(copy);
33
+ // // obj.updateMatrixWorld();
34
+ // // singleGeometry.merge(geo);
35
+ // // console.log(singleGeometry, geo);
36
+ // }
37
+ // }
38
+ // const mesh = mergeBufferGeometries(geometries);
39
+ // const zone = Pathfinding.createZone(mesh);
40
+ // const name = ZONE;
41
+ // this.zones.push(name);
42
+ // this.pathfinding.setZoneData(name, zone);
43
+
44
+ // // const target = new THREE.Vector3(2, 0, 2);
45
+ // // const groupID = this.pathfinding.getGroup(ZONE, target);
46
+ // // const path = this.pathfinding.findPath(this.worldPosition, target, ZONE, groupID);
47
+ // // console.log(path, this.pathfinding);
48
+ // }
49
+
50
+ // public tryFindPath(from: THREE.Vector3, to: THREE.Vector3): THREE.Vector3[] | null {
51
+ // const zone = this.zones[0];
52
+ // const groupId = this.pathfinding.getGroup(zone, to);
53
+ // const path = this.pathfinding.findPath(from, to, zone, groupId);
54
+ // return path;
55
+ // }
56
+ // */
57
+ // }
58
+
59
+ // // import { input } from "../engine/engine_input";
60
+ // import { Physics, RaycastOptions } from "../engine/engine_physics"
61
+ // // import { time } from "../engine/engine_time";
62
+ // // import { scene } from "../engine/engine_setup";
63
+ // import {SyncedTransform} from "./SyncedTransform";
64
+
65
+ // export class NavMeshAgent extends Behaviour {
66
+ // /*
67
+ // public navMesh: NavMesh | null = null;
68
+
69
+ // private currentPath: THREE.Vector3[] | null = null;
70
+ // private helper : PathfindingHelper | null = null;
71
+
72
+ // onEnable(): void {
73
+ // this.helper = new PathfindingHelper();
74
+ // scene.add(this.helper);
75
+ // }
76
+
77
+ // update(): void {
78
+ // if (input.mouseClick) {
79
+ // if (this.navMesh) {
80
+ // const from = this.worldPosition;
81
+ // const opts = new RaycastOptions();
82
+ // opts.setMask(RaycastOptions.AllLayers);
83
+ // const hits = Physics.raycast(opts);
84
+ // if (hits.length > 0) {
85
+ // const to = hits[0].point;
86
+ // this.helper.setPlayerPosition(from);
87
+ // this.helper.setTargetPosition(to);
88
+ // this.currentPath = this.navMesh.tryFindPath(from, to);
89
+ // this.helper.setPath(this.currentPath);
90
+ // // console.log(...this.currentPath);
91
+
92
+ // const sync = GameObject.getComponent(this.gameObject, SyncedTransform);
93
+ // if(sync) sync.requestOwnership();
94
+ // }
95
+ // }
96
+ // }
97
+
98
+ // if (this.currentPath && this.currentPath.length > 0) {
99
+
100
+ // const wp = this.worldPosition;
101
+ // const target = this.currentPath[0];
102
+ // this.worldPosition = wp.lerp(target, time.deltaTime*2);
103
+
104
+ // this.gameObject.lookAt(target);
105
+ // // const vec = target.clone().sub(wp);
106
+ // // const wr = this.worldQuaternion;
107
+ // // wr.slerp(rot, time.deltaTime*5);
108
+ // // this.worldQuaternion = wr;
109
+
110
+ // if (wp.distanceTo(this.currentPath[0]) < 0.1)
111
+ // this.currentPath.shift();
113
112
 
114
113
 
115
- }
116
- }
117
- */
118
- }
114
+ // }
115
+ // }
116
+ // */
117
+ // }
@@ -41,6 +41,8 @@ export class NestedGltf extends Behaviour {
41
41
  res.matrix.identity();
42
42
  res.applyMatrix4(matrix);
43
43
  res.matrixAutoUpdate = true;
44
+ res.layers.disableAll();
45
+ res.layers.set(this.layer);
44
46
  }
45
47
  this.destroy();
46
48
  if (debug) console.log("Nested loading done:", this.filePath?.uri ?? this.filePath, res);