@needle-tools/engine 2.36.0-pre → 2.38.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 (143) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/needle-engine.d.ts +248 -151
  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_addressables.d.ts +3 -1
  14. package/lib/engine/engine_addressables.js +12 -5
  15. package/lib/engine/engine_addressables.js.map +1 -1
  16. package/lib/engine/engine_element.js +3 -2
  17. package/lib/engine/engine_element.js.map +1 -1
  18. package/lib/engine/engine_element_overlay.js +4 -3
  19. package/lib/engine/engine_element_overlay.js.map +1 -1
  20. package/lib/engine/engine_gameobject.js +2 -1
  21. package/lib/engine/engine_gameobject.js.map +1 -1
  22. package/lib/engine/engine_input.d.ts +2 -0
  23. package/lib/engine/engine_input.js +14 -3
  24. package/lib/engine/engine_input.js.map +1 -1
  25. package/lib/engine/engine_physics.d.ts +35 -46
  26. package/lib/engine/engine_physics.js +479 -386
  27. package/lib/engine/engine_physics.js.map +1 -1
  28. package/lib/engine/engine_physics.types.d.ts +23 -0
  29. package/lib/engine/engine_physics.types.js +27 -0
  30. package/lib/engine/engine_physics.types.js.map +1 -0
  31. package/lib/engine/engine_serialization_core.d.ts +3 -0
  32. package/lib/engine/engine_serialization_core.js +5 -0
  33. package/lib/engine/engine_serialization_core.js.map +1 -1
  34. package/lib/engine/engine_setup.d.ts +7 -1
  35. package/lib/engine/engine_setup.js +13 -3
  36. package/lib/engine/engine_setup.js.map +1 -1
  37. package/lib/engine/engine_types.d.ts +45 -26
  38. package/lib/engine/engine_types.js +24 -37
  39. package/lib/engine/engine_types.js.map +1 -1
  40. package/lib/engine/engine_util_decorator.d.ts +6 -0
  41. package/lib/engine/engine_util_decorator.js +54 -0
  42. package/lib/engine/engine_util_decorator.js.map +1 -0
  43. package/lib/engine/engine_utils.d.ts +1 -1
  44. package/lib/engine/engine_utils.js +1 -1
  45. package/lib/engine/engine_utils.js.map +1 -1
  46. package/lib/engine/extensions/NEEDLE_gameobject_data.js +2 -0
  47. package/lib/engine/extensions/NEEDLE_gameobject_data.js.map +1 -1
  48. package/lib/engine-components/Animation.d.ts +7 -5
  49. package/lib/engine-components/Animation.js +7 -7
  50. package/lib/engine-components/Animation.js.map +1 -1
  51. package/lib/engine-components/AnimatorController.js +14 -7
  52. package/lib/engine-components/AnimatorController.js.map +1 -1
  53. package/lib/engine-components/BoxHelperComponent.js +1 -0
  54. package/lib/engine-components/BoxHelperComponent.js.map +1 -1
  55. package/lib/engine-components/Camera.d.ts +1 -0
  56. package/lib/engine-components/Camera.js +20 -5
  57. package/lib/engine-components/Camera.js.map +1 -1
  58. package/lib/engine-components/CharacterController.d.ts +31 -0
  59. package/lib/engine-components/CharacterController.js +167 -0
  60. package/lib/engine-components/CharacterController.js.map +1 -0
  61. package/lib/engine-components/Collider.d.ts +16 -5
  62. package/lib/engine-components/Collider.js +45 -23
  63. package/lib/engine-components/Collider.js.map +1 -1
  64. package/lib/engine-components/Component.d.ts +6 -15
  65. package/lib/engine-components/Component.js +7 -112
  66. package/lib/engine-components/Component.js.map +1 -1
  67. package/lib/engine-components/DragControls.js +9 -6
  68. package/lib/engine-components/DragControls.js.map +1 -1
  69. package/lib/engine-components/Light.d.ts +2 -0
  70. package/lib/engine-components/Light.js +13 -2
  71. package/lib/engine-components/Light.js.map +1 -1
  72. package/lib/engine-components/NavMesh.d.ts +0 -5
  73. package/lib/engine-components/NavMesh.js +100 -10
  74. package/lib/engine-components/NavMesh.js.map +1 -1
  75. package/lib/engine-components/NestedGltf.js +2 -0
  76. package/lib/engine-components/NestedGltf.js.map +1 -1
  77. package/lib/engine-components/Renderer.js +4 -0
  78. package/lib/engine-components/Renderer.js.map +1 -1
  79. package/lib/engine-components/RigidBody.d.ts +45 -25
  80. package/lib/engine-components/RigidBody.js +290 -142
  81. package/lib/engine-components/RigidBody.js.map +1 -1
  82. package/lib/engine-components/SmoothFollow.d.ts +2 -1
  83. package/lib/engine-components/SmoothFollow.js +25 -17
  84. package/lib/engine-components/SmoothFollow.js.map +1 -1
  85. package/lib/engine-components/SpatialTrigger.js +1 -1
  86. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  87. package/lib/engine-components/SpectatorCamera.d.ts +1 -0
  88. package/lib/engine-components/SpectatorCamera.js +9 -2
  89. package/lib/engine-components/SpectatorCamera.js.map +1 -1
  90. package/lib/engine-components/SpringJoint.d.ts +0 -13
  91. package/lib/engine-components/SpringJoint.js +42 -41
  92. package/lib/engine-components/SpringJoint.js.map +1 -1
  93. package/lib/engine-components/VideoPlayer.js.map +1 -1
  94. package/lib/engine-components/WebXR.d.ts +1 -0
  95. package/lib/engine-components/WebXR.js +13 -6
  96. package/lib/engine-components/WebXR.js.map +1 -1
  97. package/lib/engine-components/WebXRController.js +12 -6
  98. package/lib/engine-components/WebXRController.js.map +1 -1
  99. package/lib/engine-components/codegen/components.d.ts +4 -3
  100. package/lib/engine-components/codegen/components.js +4 -3
  101. package/lib/engine-components/codegen/components.js.map +1 -1
  102. package/package.json +3 -4
  103. package/src/engine/api.ts +2 -1
  104. package/src/engine/codegen/register_types.js +16 -12
  105. package/src/engine/debug/debug.ts +4 -0
  106. package/src/engine/dist/engine_physics.js +739 -0
  107. package/src/engine/dist/engine_setup.js +777 -0
  108. package/src/engine/engine_addressables.ts +18 -8
  109. package/src/engine/engine_element.ts +3 -2
  110. package/src/engine/engine_element_overlay.ts +4 -3
  111. package/src/engine/engine_gameobject.ts +4 -4
  112. package/src/engine/engine_input.ts +12 -3
  113. package/src/engine/engine_physics.ts +492 -418
  114. package/src/engine/engine_physics.types.ts +28 -0
  115. package/src/engine/engine_serialization_core.ts +8 -1
  116. package/src/engine/engine_setup.ts +31 -18
  117. package/src/engine/engine_types.ts +83 -56
  118. package/src/engine/engine_util_decorator.ts +69 -0
  119. package/src/engine/engine_utils.ts +3 -3
  120. package/src/engine/extensions/NEEDLE_gameobject_data.ts +2 -0
  121. package/src/engine-components/Animation.ts +18 -12
  122. package/src/engine-components/AnimatorController.ts +16 -11
  123. package/src/engine-components/BoxHelperComponent.ts +1 -0
  124. package/src/engine-components/Camera.ts +21 -4
  125. package/src/engine-components/CharacterController.ts +171 -0
  126. package/src/engine-components/Collider.ts +49 -39
  127. package/src/engine-components/Component.ts +15 -130
  128. package/src/engine-components/DragControls.ts +9 -5
  129. package/src/engine-components/Light.ts +17 -3
  130. package/src/engine-components/NavMesh.ts +114 -115
  131. package/src/engine-components/NestedGltf.ts +2 -0
  132. package/src/engine-components/Renderer.ts +5 -1
  133. package/src/engine-components/RigidBody.ts +292 -149
  134. package/src/engine-components/SmoothFollow.ts +21 -18
  135. package/src/engine-components/SpatialTrigger.ts +1 -1
  136. package/src/engine-components/SpectatorCamera.ts +10 -2
  137. package/src/engine-components/SpringJoint.ts +41 -41
  138. package/src/engine-components/VideoPlayer.ts +1 -2
  139. package/src/engine-components/WebXR.ts +15 -6
  140. package/src/engine-components/WebXRController.ts +16 -7
  141. package/src/engine-components/codegen/components.ts +4 -3
  142. package/src/engine-components/dist/CharacterController.js +123 -0
  143. package/src/engine-components/dist/RigidBody.js +458 -0
@@ -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);
@@ -5,7 +5,7 @@ import { RendererLightmap } from "./RendererLightmap";
5
5
  import { Context } from "../engine/engine_setup";
6
6
  import { getParam } from "../engine/engine_utils";
7
7
  import { serializeable } from "../engine/engine_serialization_decorator";
8
- import { AxesHelper, Material, Mesh, Object3D, Texture, Vector4 } from "three";
8
+ import { AxesHelper, Material, Mesh, Object3D, SkinnedMesh, Texture, Vector4 } from "three";
9
9
  import { NEEDLE_render_objects } from "../engine/extensions/NEEDLE_render_objects";
10
10
  import { NEEDLE_deferred_texture } from "../engine/extensions/NEEDLE_deferred_texture";
11
11
  import { NEED_UPDATE_INSTANCE_KEY } from "../engine/engine_instancing";
@@ -67,6 +67,7 @@ class SharedMaterialArray implements ISharedMaterials {
67
67
  case "Group":
68
68
  this._targets = [...go.children];
69
69
  break;
70
+ case "SkinnedMesh":
70
71
  case "Mesh":
71
72
  this._targets.push(go);
72
73
  break;
@@ -155,6 +156,9 @@ export class Renderer extends Behaviour implements IRenderer {
155
156
  if (this.gameObject.type === "Mesh") {
156
157
  return this.gameObject as unknown as Mesh
157
158
  }
159
+ else if (this.gameObject.type === "SkinnesMesh") {
160
+ return this.gameObject as unknown as SkinnedMesh;
161
+ }
158
162
  else if (this.gameObject.type === "Group") {
159
163
  return this.gameObject.children[0] as unknown as Mesh;
160
164
  }