@needle-tools/engine 3.5.10-beta → 3.5.12-beta

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 (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/needle-engine.js +5257 -5240
  3. package/dist/needle-engine.light.js +5135 -5118
  4. package/dist/needle-engine.light.min.js +274 -273
  5. package/dist/needle-engine.light.umd.cjs +248 -247
  6. package/dist/needle-engine.min.js +276 -275
  7. package/dist/needle-engine.umd.cjs +247 -246
  8. package/lib/engine/api.d.ts +1 -1
  9. package/lib/engine/api.js +1 -1
  10. package/lib/engine/api.js.map +1 -1
  11. package/lib/engine/engine_hot_reload.d.ts +3 -3
  12. package/lib/engine/engine_hot_reload.js +6 -4
  13. package/lib/engine/engine_hot_reload.js.map +1 -1
  14. package/lib/engine/engine_license.js +2 -1
  15. package/lib/engine/engine_license.js.map +1 -1
  16. package/lib/engine/engine_physics_rapier.d.ts +3 -8
  17. package/lib/engine/engine_physics_rapier.js +30 -11
  18. package/lib/engine/engine_physics_rapier.js.map +1 -1
  19. package/lib/engine/engine_serialization_builtin_serializer.js +10 -9
  20. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  21. package/lib/engine/engine_types.d.ts +10 -3
  22. package/lib/engine/engine_types.js.map +1 -1
  23. package/lib/engine/engine_typestore.d.ts +8 -0
  24. package/lib/engine/engine_typestore.js +11 -0
  25. package/lib/engine/engine_typestore.js.map +1 -1
  26. package/lib/engine-components/Component.d.ts +12 -12
  27. package/lib/engine-components/Component.js +4 -1
  28. package/lib/engine-components/Component.js.map +1 -1
  29. package/lib/engine-components/OrbitControls.js +3 -1
  30. package/lib/engine-components/OrbitControls.js.map +1 -1
  31. package/lib/engine-components/TransformGizmo.js +1 -1
  32. package/lib/engine-components/TransformGizmo.js.map +1 -1
  33. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.d.ts +1 -0
  34. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js +1 -0
  35. package/lib/engine-components/export/usdz/extensions/behavior/Behaviour.js.map +1 -1
  36. package/package.json +1 -1
  37. package/plugins/vite/reload.js +4 -4
  38. package/src/engine/api.ts +1 -1
  39. package/src/engine/engine_hot_reload.ts +5 -5
  40. package/src/engine/engine_license.ts +2 -1
  41. package/src/engine/engine_physics_rapier.ts +26 -11
  42. package/src/engine/engine_serialization_builtin_serializer.ts +9 -9
  43. package/src/engine/engine_types.ts +13 -5
  44. package/src/engine/engine_typestore.ts +14 -1
  45. package/src/engine-components/Component.ts +16 -13
  46. package/src/engine-components/OrbitControls.ts +3 -1
  47. package/src/engine-components/TransformGizmo.ts +1 -1
  48. package/src/engine-components/export/usdz/extensions/behavior/Behaviour.ts +1 -0
@@ -185,7 +185,7 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
185
185
  * @param go component to move the component to
186
186
  * @param instance component to move to the GO
187
187
  */
188
- public static addComponent(go: IGameObject | Object3D, instance: Component): void {
188
+ public static addComponent<T extends IComponent>(go: IGameObject | Object3D, instance: T) {
189
189
  return this.moveComponent(go, instance);
190
190
  }
191
191
 
@@ -194,24 +194,24 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
194
194
  * @param go component to move the component to
195
195
  * @param instance component to move to the GO
196
196
  */
197
- public static moveComponent(go: IGameObject | Object3D, instance: Component): void {
198
- moveComponentInstance(go, instance as any);
197
+ public static moveComponent<T extends IComponent>(go: IGameObject | Object3D, instance: T) {
198
+ return moveComponentInstance(go, instance);
199
199
  }
200
200
 
201
201
  /** Removes a component from its object
202
202
  * @param instance component to remove
203
203
  */
204
- public static removeComponent(instance: Component): Component {
204
+ public static removeComponent<T extends IComponent>(instance: T): T {
205
205
  removeComponent(instance.gameObject, instance as any);
206
206
  return instance;
207
207
  }
208
208
 
209
- public static getOrAddComponent<T>(go: IGameObject | Object3D, typeName: ConstructorConcrete<T>): T {
209
+ public static getOrAddComponent<T extends IComponent>(go: IGameObject | Object3D, typeName: ConstructorConcrete<T>): T {
210
210
  return getOrAddComponent<any>(go, typeName);
211
211
  }
212
212
 
213
213
  /** Gets a component on the provided object */
214
- public static getComponent<T>(go: IGameObject | Object3D | null, typeName: Constructor<T> | null): T | null {
214
+ public static getComponent<T extends IComponent>(go: IGameObject | Object3D | null, typeName: Constructor<T> | null): T | null {
215
215
  if (go === null) return null;
216
216
  // if names are minified we could also use the type store and work with strings everywhere
217
217
  // not ideal, but I dont know a good/sane way to do this otherwise
@@ -220,7 +220,7 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
220
220
  return getComponent(go, typeName as any);
221
221
  }
222
222
 
223
- public static getComponents<T>(go: IGameObject | Object3D | null, typeName: Constructor<T>, arr: T[] | null = null): T[] {
223
+ public static getComponents<T extends IComponent>(go: IGameObject | Object3D | null, typeName: Constructor<T>, arr: T[] | null = null): T[] {
224
224
  if (go === null) return arr ?? [];
225
225
  return getComponents(go, typeName, arr);
226
226
  }
@@ -230,29 +230,29 @@ export abstract class GameObject extends Object3D implements Object3D, IGameObje
230
230
  return res as GameObject | Component | null | undefined;
231
231
  }
232
232
 
233
- public static findObjectOfType<T>(typeName: Constructor<T>, context?: Context | Object3D, includeInactive: boolean = true): T | null {
233
+ public static findObjectOfType<T extends IComponent>(typeName: Constructor<T>, context?: Context | Object3D, includeInactive: boolean = true): T | null {
234
234
  return findObjectOfType(typeName, context ?? Context.Current, includeInactive);
235
235
  }
236
236
 
237
- public static findObjectsOfType<T>(typeName: Constructor<T>, context?: Context | Object3D): Array<T> {
237
+ public static findObjectsOfType<T extends IComponent>(typeName: Constructor<T>, context?: Context | Object3D): Array<T> {
238
238
  const arr = [];
239
239
  findObjectsOfType(typeName, arr, context);
240
240
  return arr;
241
241
  }
242
242
 
243
- public static getComponentInChildren<T>(go: IGameObject | Object3D, typeName: Constructor<T>): T | null {
243
+ public static getComponentInChildren<T extends IComponent>(go: IGameObject | Object3D, typeName: Constructor<T>): T | null {
244
244
  return getComponentInChildren(go, typeName);
245
245
  }
246
246
 
247
- public static getComponentsInChildren<T>(go: IGameObject | Object3D, typeName: Constructor<T>, arr: T[] | null = null): Array<T> {
247
+ public static getComponentsInChildren<T extends IComponent>(go: IGameObject | Object3D, typeName: Constructor<T>, arr: T[] | null = null): Array<T> {
248
248
  return getComponentsInChildren<T>(go, typeName, arr ?? undefined) as T[]
249
249
  }
250
250
 
251
- public static getComponentInParent<T>(go: IGameObject | Object3D, typeName: Constructor<T>): T | null {
251
+ public static getComponentInParent<T extends IComponent>(go: IGameObject | Object3D, typeName: Constructor<T>): T | null {
252
252
  return getComponentInParent(go, typeName);
253
253
  }
254
254
 
255
- public static getComponentsInParent<T>(go: IGameObject | Object3D, typeName: Constructor<T>, arr: Array<T> | null = null): Array<T> {
255
+ public static getComponentsInParent<T extends IComponent>(go: IGameObject | Object3D, typeName: Constructor<T>, arr: Array<T> | null = null): Array<T> {
256
256
  return getComponentsInParent(go, typeName, arr);
257
257
  }
258
258
 
@@ -307,6 +307,9 @@ export class Component implements IComponent, EventTarget {
307
307
  }
308
308
 
309
309
  get name(): string {
310
+ if (this.gameObject?.name) {
311
+ return this.gameObject.name;
312
+ }
310
313
  return this.gameObject?.userData.name;
311
314
  }
312
315
  private __name?: string;
@@ -87,7 +87,9 @@ export class OrbitControls extends Behaviour implements ICameraController {
87
87
  if (camGo && !this.setFromTargetPosition()) {
88
88
  if (this.debugLog)
89
89
  console.log("NO TARGET");
90
- const forward = new Vector3(0, 0, -10).applyMatrix4(camGo.cam.matrixWorld);
90
+ const worldPosition = getWorldPosition(camGo.cam);
91
+ const distanceToCenter = worldPosition.length();
92
+ const forward = new Vector3(0, 0, -distanceToCenter).applyMatrix4(camGo.cam.matrixWorld);
91
93
  this.setTarget(forward, true);
92
94
  }
93
95
  }
@@ -4,7 +4,7 @@ import { serializable } from "../engine/engine_serialization_decorator";
4
4
  import * as params from "../engine/engine_default_parameters";
5
5
  import { Mesh, MathUtils, EventListener } from "three";
6
6
  import { TransformControls } from "three/examples/jsm/controls/TransformControls";
7
- import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
7
+ import { OrbitControls } from "./OrbitControls";
8
8
 
9
9
  export class TransformGizmo extends Behaviour {
10
10
 
@@ -11,6 +11,7 @@ export interface UsdzBehaviour {
11
11
  afterSerialize?(ext: BehaviorExtension, context: IContext): void;
12
12
  }
13
13
 
14
+ /** internal USDZ behaviours extension */
14
15
  export class BehaviorExtension implements IUSDExporterExtension {
15
16
 
16
17
  get extensionName(): string {