@needle-tools/engine 2.35.0-pre → 2.35.2-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 (68) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/needle-engine.d.ts +202 -181
  3. package/dist/needle-engine.js +234 -3338
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +41 -36
  6. package/dist/needle-engine.min.js.map +4 -4
  7. package/lib/engine/engine_components.d.ts +12 -11
  8. package/lib/engine/engine_components.js +48 -24
  9. package/lib/engine/engine_components.js.map +1 -1
  10. package/lib/engine/engine_element.js +2 -1
  11. package/lib/engine/engine_element.js.map +1 -1
  12. package/lib/engine/engine_element_loading.js +4 -1
  13. package/lib/engine/engine_element_loading.js.map +1 -1
  14. package/lib/engine/engine_gltf_builtin_components.d.ts +1 -0
  15. package/lib/engine/engine_gltf_builtin_components.js +5 -0
  16. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  17. package/lib/engine/engine_networking.d.ts +5 -0
  18. package/lib/engine/engine_networking.js +6 -4
  19. package/lib/engine/engine_networking.js.map +1 -1
  20. package/lib/engine/engine_physics.d.ts +6 -1
  21. package/lib/engine/engine_physics.js +12 -2
  22. package/lib/engine/engine_physics.js.map +1 -1
  23. package/lib/engine/engine_types.d.ts +7 -2
  24. package/lib/engine/engine_types.js +6 -5
  25. package/lib/engine/engine_types.js.map +1 -1
  26. package/lib/engine-components/Collider.d.ts +3 -1
  27. package/lib/engine-components/Collider.js +11 -0
  28. package/lib/engine-components/Collider.js.map +1 -1
  29. package/lib/engine-components/Component.d.ts +7 -7
  30. package/lib/engine-components/Component.js +8 -8
  31. package/lib/engine-components/Component.js.map +1 -1
  32. package/lib/engine-components/Networking.d.ts +3 -1
  33. package/lib/engine-components/Networking.js +3 -0
  34. package/lib/engine-components/Networking.js.map +1 -1
  35. package/lib/engine-components/OrbitControls.js +16 -4
  36. package/lib/engine-components/OrbitControls.js.map +1 -1
  37. package/lib/engine-components/Renderer.d.ts +2 -1
  38. package/lib/engine-components/Renderer.js +11 -2
  39. package/lib/engine-components/Renderer.js.map +1 -1
  40. package/lib/engine-components/WebXR.js +5 -1
  41. package/lib/engine-components/WebXR.js.map +1 -1
  42. package/lib/engine-components/js-extensions/Object3D.js +13 -11
  43. package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
  44. package/lib/engine-components/ui/EventSystem.js +2 -2
  45. package/lib/engine-components/ui/EventSystem.js.map +1 -1
  46. package/lib/engine-components/ui/RaycastUtils.js +0 -1
  47. package/lib/engine-components/ui/RaycastUtils.js.map +1 -1
  48. package/lib/needle-engine.d.ts +0 -1
  49. package/lib/needle-engine.js +0 -1
  50. package/lib/needle-engine.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/engine/engine_components.ts +50 -27
  53. package/src/engine/engine_element.ts +2 -1
  54. package/src/engine/engine_element_loading.ts +5 -1
  55. package/src/engine/engine_gltf_builtin_components.ts +4 -0
  56. package/src/engine/engine_networking.ts +12 -4
  57. package/src/engine/engine_physics.ts +34 -4
  58. package/src/engine/engine_types.ts +14 -6
  59. package/src/engine-components/Collider.ts +17 -2
  60. package/src/engine-components/Component.ts +21 -22
  61. package/src/engine-components/Networking.ts +6 -1
  62. package/src/engine-components/OrbitControls.ts +20 -7
  63. package/src/engine-components/Renderer.ts +13 -3
  64. package/src/engine-components/WebXR.ts +4 -1
  65. package/src/engine-components/js-extensions/Object3D.ts +17 -15
  66. package/src/engine-components/ui/EventSystem.ts +2 -2
  67. package/src/engine-components/ui/RaycastUtils.ts +0 -1
  68. package/src/needle-engine.ts +0 -1
@@ -127,6 +127,8 @@ export class EngineLoadingView implements ILoadingViewHandler {
127
127
 
128
128
  private createLoadingElement(existing?: HTMLElement): HTMLElement {
129
129
  this._loadingElement = existing || document.createElement("div");
130
+ this._loadingElement.style.width = "100%";
131
+
130
132
  const className = this._loadingElementOptions?.className ?? "loading";
131
133
  this._loadingElement.classList.add(className);
132
134
  if (this._loadingElementOptions?.additionalClasses) {
@@ -141,7 +143,7 @@ export class EngineLoadingView implements ILoadingViewHandler {
141
143
  }
142
144
 
143
145
  const loadingBarContainer = document.createElement("div");
144
- const maxWidth = 20;
146
+ const maxWidth = 30;
145
147
  loadingBarContainer.style.display = "flex";
146
148
  loadingBarContainer.style.width = maxWidth + "%";
147
149
  loadingBarContainer.style.height = "2px";
@@ -171,6 +173,8 @@ export class EngineLoadingView implements ILoadingViewHandler {
171
173
  messageContainer.style.fontSize = ".8em";
172
174
  messageContainer.style.paddingTop = ".5em";
173
175
  messageContainer.style.color = "rgba(255,255,255,.5)";
176
+ // messageContainer.style.border = "1px solid rgba(255,255,255,.1)";
177
+ messageContainer.style.justifyContent = "center";
174
178
  this._loadingElement.appendChild(messageContainer);
175
179
 
176
180
  return this._loadingElement;
@@ -1,3 +1,4 @@
1
+ import "./codegen/register_types";
1
2
  import { TypeStore } from "./engine_typestore";
2
3
  import * as THREE from "three";
3
4
  import { Component, GameObject } from "../engine-components/Component";
@@ -11,9 +12,12 @@ import { builtinComponentKeyName } from "./engine_constants";
11
12
  import { SourceIdentifier } from "./engine_types";
12
13
  import { UIDProvider } from "./engine_types";
13
14
  import { addNewComponentInstance } from "./engine_components";
15
+ import { getParam } from "./engine_utils";
14
16
 
15
17
 
16
18
  const debug = debugExtension;
19
+ const debugTypeStore = getParam("debugtypestore");
20
+ if(debugTypeStore) console.log(TypeStore);
17
21
 
18
22
  export function writeBuiltinComponentData(comp: Component, context: SerializationContext): object | null {
19
23
 
@@ -4,8 +4,7 @@
4
4
  let serverUrl = 'wss://needle-tiny-starter.glitch.me/socket';
5
5
 
6
6
  import { Websocket, WebsocketBuilder } from 'websocket-ts';
7
- import { Behaviour, GameObject } from '../engine-components/Component';
8
- import { Networking } from '../engine-components/Networking';
7
+ // import { Networking } from '../engine-components/Networking';
9
8
  import { Context } from './engine_setup';
10
9
  import * as utils from "./engine_utils";
11
10
  import * as flatbuffers from 'flatbuffers';
@@ -16,6 +15,9 @@ import { IModel, INetworkConnection, SendQueue } from './engine_networking_types
16
15
  export const debugNet = utils.getParam("debugnet") ? true : false;
17
16
  export const debugOwner = debugNet || utils.getParam("debugowner") ? true : false;
18
17
 
18
+ export interface INetworkingWebsocketUrlProvider {
19
+ getWebsocketUrl() : string | null;
20
+ }
19
21
 
20
22
  export declare interface IConnectionData {
21
23
  id: string;
@@ -384,14 +386,20 @@ export class NetworkConnection implements INetworkConnection {
384
386
  }
385
387
  }
386
388
 
389
+ private netWebSocketUrlProvider? : INetworkingWebsocketUrlProvider;
390
+
391
+ public registerProvider(prov : INetworkingWebsocketUrlProvider){
392
+ this.netWebSocketUrlProvider = prov;
393
+ }
394
+
387
395
  public connect() {
388
396
  if (this.connected) return;
389
397
  if (debugNet)
390
398
  console.log("connecting");
391
399
  // this.channel = geckos({ port: 9208, url: 'http://127.0.0.1' });
392
400
  // this.channel.onConnect(this.onConnectGeckosIo.bind(this));
393
- const networking = GameObject.findObjectOfType(Networking, this.context, false);
394
- const overrideUrl = networking?.getWebsocketUrl();
401
+ // const networking = GameObject.findObjectOfType(Networking, this.context, false);
402
+ const overrideUrl = this.netWebSocketUrlProvider?.getWebsocketUrl();
395
403
  if (overrideUrl) {
396
404
  serverUrl = overrideUrl;
397
405
  }
@@ -4,10 +4,21 @@ import { Context } from './engine_setup';
4
4
  import cannonDebugger from 'cannon-es-debugger'
5
5
  import * as utils from "./engine_utils"
6
6
  import * as threeutils from "./engine_three_utils"
7
- import { IComponent as Component, IGameObject as GameObject, ICollider as Collider, IRigidbody as Rigidbody, ICollider, $physicsKey, Collision, CannonCollision } from './engine_types';
7
+ import {
8
+ IComponent as Component,
9
+ IGameObject as GameObject,
10
+ ICollider,
11
+ IRigidbody as Rigidbody, $physicsKey,
12
+ Collision, CannonCollision,
13
+ ICollisionContext,
14
+ IComponent
15
+ }
16
+ from './engine_types';
8
17
  import { Shape } from 'cannon-es';
9
18
  import { InstancingUtil } from './engine_instancing';
10
19
  import { foreachComponent } from './engine_gameobject';
20
+ import { getComponentInChildren } from './engine_components';
21
+
11
22
 
12
23
  const debugPhysics = utils.getParam("debugphysics");
13
24
  const debugCollisions = utils.getParam("debugcollisions");
@@ -635,8 +646,10 @@ export class Physics {
635
646
  // console.log("START");
636
647
  }
637
648
 
649
+ private readonly collisionContext: ICollisionContext = new CollisionContext();
650
+
638
651
  private raiseCollisionEvents(obj: THREE.Object3D, event: CannonCollision) {
639
- const collision = new Collision(obj, event);
652
+ const collision = new Collision(obj, event, this.collisionContext);
640
653
  if (debugCollisions)
641
654
  console.log("collision between", event.contact.bi, event.contact.bj, obj, event);
642
655
  foreachComponent(obj, (c: Component) => {
@@ -645,7 +658,7 @@ export class Physics {
645
658
 
646
659
  // handle triggers
647
660
  if (collision.collider && !collision.collider.attachedRigidbody && collision.collider.isTrigger) {
648
- const collision2 = new Collision(collision.gameObject, event, true);
661
+ const collision2 = new Collision(collision.gameObject, event, this.collisionContext, true);
649
662
  foreachComponent(collision.gameObject, (c: Component) => {
650
663
  c.__internalHandleCollision(collision2, true);
651
664
  });
@@ -659,7 +672,6 @@ export class Physics {
659
672
  const obj2 = args.bodyB[$physicsKey];
660
673
  // console.log(obj2);
661
674
 
662
-
663
675
  foreachComponent(obj2, (c: Component) => {
664
676
  c.__internalHandleExitCollisionEvent(obj1, false);
665
677
  });
@@ -676,3 +688,21 @@ export class Physics {
676
688
  }
677
689
 
678
690
  }
691
+
692
+ export interface IColliderProvider {
693
+ getCollider(obj: THREE.Object3D): ICollider;
694
+ }
695
+
696
+ let colliderProvider: IColliderProvider | null = null;
697
+ export function registerColliderProvider(prov: IColliderProvider) {
698
+ colliderProvider = prov;
699
+ }
700
+
701
+ class CollisionContext implements ICollisionContext {
702
+
703
+ getCollider(obj: THREE.Object3D<THREE.Event>): ICollider {
704
+ return colliderProvider!.getCollider(obj);
705
+ }
706
+
707
+ }
708
+
@@ -27,6 +27,7 @@ export declare interface IGameObject extends Object3D {
27
27
  export interface IComponent {
28
28
  get isComponent(): boolean;
29
29
 
30
+
30
31
  gameObject: IGameObject;
31
32
  guid: string;
32
33
  enabled: boolean;
@@ -73,6 +74,8 @@ export interface IComponent {
73
74
 
74
75
  __internalHandleCollision(col: Collision, isTriggerCollision: boolean);
75
76
  __internalHandleExitCollisionEvent(obj: Object3D, isTriggerCollision: boolean);
77
+
78
+ get forward() : Vector3;
76
79
  }
77
80
 
78
81
 
@@ -99,7 +102,7 @@ export declare interface IRenderer extends IComponent {
99
102
 
100
103
  export declare interface ICollider extends IComponent {
101
104
  get isCollider();
102
- attachedRigidbody: IRigidbody;
105
+ attachedRigidbody: IRigidbody | null;
103
106
  isTrigger: boolean;
104
107
  }
105
108
 
@@ -123,6 +126,10 @@ export declare type CannonCollision = {
123
126
  type: string;
124
127
  }
125
128
 
129
+ export declare type ICollisionContext = {
130
+ getCollider(obj : Object3D) : ICollider;
131
+ }
132
+
126
133
  export class Collision {
127
134
 
128
135
  get __internalCollision(): CannonCollision {
@@ -136,6 +143,7 @@ export class Collision {
136
143
  private readonly invert: boolean;
137
144
  private readonly collision: CannonCollision;
138
145
  private readonly targetBody: Body;
146
+ private readonly context : ICollisionContext;
139
147
 
140
148
  readonly me: Object3D;
141
149
 
@@ -151,8 +159,7 @@ export class Collision {
151
159
  private _collider?: ICollider;
152
160
  get collider(): ICollider {
153
161
  if (!this._collider) {
154
- //@ts-ignore
155
- this._collider = getComponentInChildren(this.gameObject, Collider) as ICollider;
162
+ this._collider = this.context.getCollider(this.gameObject);
156
163
  }
157
164
  return this._collider;
158
165
  }
@@ -171,10 +178,11 @@ export class Collision {
171
178
  // return this._point;
172
179
  // }
173
180
 
174
- constructor(obj: Object3D, collision: CannonCollision, invert: boolean = false) {
175
- this.invert = invert;
181
+ constructor(obj: Object3D, collision: CannonCollision, context : ICollisionContext, invert: boolean = false) {
176
182
  this.me = obj;
177
183
  this.collision = collision;
178
- this.targetBody = this.invert ? collision.target : collision.body;
184
+ this.context = context;
185
+ this.targetBody = invert ? collision.target : collision.body;
186
+ this.invert = invert;
179
187
  }
180
188
  }
@@ -1,10 +1,25 @@
1
1
  import { Behaviour } from "./Component";
2
2
  import { Rigidbody } from "./RigidBody";
3
3
  import { serializeable } from "../engine/engine_serialization_decorator";
4
- import { Vector3 } from "three"
4
+ import { Event, Object3D, Vector3 } from "three"
5
5
  import { Shape } from "cannon-es";
6
+ import { IColliderProvider, registerColliderProvider } from "../engine/engine_physics";
7
+ import { ICollider } from "../engine/engine_types";
8
+ import { getComponentInChildren } from "../engine/engine_components";
9
+
10
+ class ColliderProvider implements IColliderProvider {
11
+ getCollider(obj: Object3D): ICollider {
12
+ return getComponentInChildren<Collider>(obj, Collider);
13
+ }
14
+ }
15
+ registerColliderProvider(new ColliderProvider());
16
+
17
+ export class Collider extends Behaviour implements ICollider {
18
+
19
+ get isCollider(): any {
20
+ return true;
21
+ }
6
22
 
7
- export class Collider extends Behaviour {
8
23
  @serializeable(Rigidbody)
9
24
  attachedRigidbody: Rigidbody | null = null;
10
25
  @serializeable()
@@ -40,13 +40,13 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
40
40
  }
41
41
 
42
42
  public static markAsInstancedRendered(go: THREE.Object3D, instanced: boolean) {
43
- markAsInstancedRendered(go, instanced);
43
+ markAsInstancedRendered(go, instanced);
44
44
  }
45
45
 
46
46
  public static isUsingInstancing(instance: THREE.Object3D): boolean { return isUsingInstancing(instance); }
47
47
 
48
48
  public static foreachComponent(instance: THREE.Object3D, cb: (comp: Component) => any, recursive: boolean = true): any {
49
- return foreachComponent(instance, cb as (comp : IComponent) => any, recursive);
49
+ return foreachComponent(instance, cb as (comp: IComponent) => any, recursive);
50
50
  }
51
51
 
52
52
  public static instantiateSynced(instance: GameObject | Object3D | null, opts: InstantiateOptions): GameObject | null {
@@ -124,7 +124,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
124
124
  }, children);
125
125
  }
126
126
 
127
- public static addNewComponent<T extends Behaviour>(go: GameObject | THREE.Object3D, type: ConstructorConcrete<T>, callAwake: boolean = true): T {
127
+ public static addNewComponent<T>(go: GameObject | THREE.Object3D, type: ConstructorConcrete<T>, callAwake: boolean = true): T {
128
128
  const instance = new type();
129
129
  //@ts-ignore
130
130
  addNewComponentInstance(go, instance, callAwake);
@@ -135,7 +135,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
135
135
  if (instance.gameObject == null) {
136
136
  throw new Error("Did you mean to create a new component? Use addNewComponent");
137
137
  }
138
- moveComponentInstance(instance as any, go);
138
+ moveComponentInstance(go, instance as any);
139
139
  }
140
140
 
141
141
  public static removeComponent(instance: Component): Component {
@@ -143,7 +143,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
143
143
  return instance;
144
144
  }
145
145
 
146
- public static getOrAddComponent<T extends IComponent>(go: GameObject | THREE.Object3D, typeName: ConstructorConcrete<T>): T {
146
+ public static getOrAddComponent<T>(go: GameObject | THREE.Object3D, typeName: ConstructorConcrete<T>): T {
147
147
  return getOrAddComponent<any>(go, typeName);
148
148
  }
149
149
 
@@ -153,12 +153,12 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
153
153
  // not ideal, but I dont know a good/sane way to do this otherwise
154
154
  // const res = TypeStore.get(typeName);
155
155
  // if(res) typeName = res;
156
- return getComponent(typeName as any, go);
156
+ return getComponent(go, typeName as any);
157
157
  }
158
158
 
159
- public static getComponents<T>(go: GameObject | THREE.Object3D | null, typeName: Constructor<T> | null, arr: T[] | null = null): T[] {
159
+ public static getComponents<T>(go: GameObject | THREE.Object3D | null, typeName: Constructor<T>, arr: T[] | null = null): T[] {
160
160
  if (go === null) return arr ?? [];
161
- return getComponents(typeName, go, arr);
161
+ return getComponents(go, typeName, arr);
162
162
  }
163
163
 
164
164
  public static findByGuid(guid: string, hierarchy: THREE.Object3D): GameObject | Component | null | undefined {
@@ -166,8 +166,8 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
166
166
  return res as GameObject | Component | null | undefined;
167
167
  }
168
168
 
169
- public static findObjectOfType<T>(typeName: Constructor<T> | string, context?: Context | THREE.Object3D, includeInactive: boolean = true): T | null {
170
- return findObjectOfType(typeName, context, includeInactive);
169
+ public static findObjectOfType<T>(typeName: Constructor<T>, context?: Context | THREE.Object3D, includeInactive: boolean = true): T | null {
170
+ return findObjectOfType(typeName, context ?? Context.Current, includeInactive);
171
171
  }
172
172
 
173
173
  public static findObjectsOfType<T>(typeName: Constructor<T>, context?: Context | THREE.Object3D): Array<T> {
@@ -176,20 +176,20 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
176
176
  return arr;
177
177
  }
178
178
 
179
- public static getComponentInChildren<T>(go: GameObject | THREE.Object3D, typeName: Constructor<T> | null): T | null {
180
- return getComponentInChildren(typeName, go);
179
+ public static getComponentInChildren<T>(go: GameObject | THREE.Object3D, typeName: Constructor<T>): T | null {
180
+ return getComponentInChildren(go, typeName);
181
181
  }
182
182
 
183
- public static getComponentsInChildren<T extends IComponent>(go: GameObject | THREE.Object3D, typeName: Constructor<T>, arr: T[] | null = null): Array<T> {
184
- return getComponentsInChildren<T>(typeName, go, arr ?? undefined) as T[]
183
+ public static getComponentsInChildren<T>(go: GameObject | THREE.Object3D, typeName: Constructor<T>, arr: T[] | null = null): Array<T> {
184
+ return getComponentsInChildren<T>(go, typeName, arr ?? undefined) as T[]
185
185
  }
186
186
 
187
- public static getComponentInParent<T>(go: GameObject | THREE.Object3D | Array<Object3D>, typeName: Constructor<T>): T | null {
188
- return getComponentInParent(typeName, go);
187
+ public static getComponentInParent<T>(go: GameObject | THREE.Object3D, typeName: Constructor<T>): T | null {
188
+ return getComponentInParent(go, typeName);
189
189
  }
190
190
 
191
191
  public static getComponentsInParent<T>(go: GameObject | THREE.Object3D, typeName: Constructor<T>, arr: Array<T> | null = null): Array<T> {
192
- return getComponentsInParent(typeName, go, arr);
192
+ return getComponentsInParent(go, typeName, arr);
193
193
  }
194
194
 
195
195
  public static getAllComponents(go: GameObject | THREE.Object3D): Behaviour[] {
@@ -291,8 +291,7 @@ class Component implements IComponent, EventTarget {
291
291
  return res;
292
292
  }
293
293
 
294
- private set __isActiveInHierarchy(val: boolean)
295
- {
294
+ private set __isActiveInHierarchy(val: boolean) {
296
295
  if (!this.gameObject) return;
297
296
  this.gameObject[activeInHierarchyFieldName] = val;
298
297
  }
@@ -339,7 +338,7 @@ class Component implements IComponent, EventTarget {
339
338
  this.context.unregisterCoroutineUpdate(routine, evt);
340
339
  }
341
340
 
342
- public get destroyed() : boolean {
341
+ public get destroyed(): boolean {
343
342
  return this.__destroyed;
344
343
  }
345
344
 
@@ -378,7 +377,7 @@ class Component implements IComponent, EventTarget {
378
377
  if (this.start) this.start();
379
378
  }
380
379
 
381
- __internalEnable() : boolean {
380
+ __internalEnable(): boolean {
382
381
  if (this.__didEnable) return false;
383
382
  // console.trace("INTERNAL ENABLE");
384
383
  this.__didEnable = true;
@@ -401,7 +400,7 @@ class Component implements IComponent, EventTarget {
401
400
  // console.log("destroy", this);
402
401
  destroyComponentInstance(this as any);
403
402
  }
404
-
403
+
405
404
  // isActiveAndEnabled: boolean = false;
406
405
 
407
406
  get enabled(): boolean {
@@ -1,8 +1,9 @@
1
+ import { INetworkingWebsocketUrlProvider } from "../engine/engine_networking";
1
2
  import { isLocalNetwork } from "../engine/engine_networking_utils";
2
3
  import { getParam } from "../engine/engine_utils";
3
4
  import { Behaviour } from "./Component";
4
5
 
5
- export class Networking extends Behaviour {
6
+ export class Networking extends Behaviour implements INetworkingWebsocketUrlProvider {
6
7
 
7
8
  url: string | null = null;
8
9
  urlParameterName: string | null = null;
@@ -10,6 +11,10 @@ export class Networking extends Behaviour {
10
11
  // used when local host is detected
11
12
  localhost: string | null = null;
12
13
 
14
+ awake(){
15
+ this.context.connection.registerProvider(this);
16
+ }
17
+
13
18
  getWebsocketUrl(): string | null {
14
19
 
15
20
  let socketurl = this.url ? Networking.GetUrl(this.url, this.localhost) : null;
@@ -7,6 +7,9 @@ import { getWorldPosition } from "../engine/engine_three_utils";
7
7
  import { RaycastOptions } from "../engine/engine_physics";
8
8
  import { serializeable } from "../engine/engine_serialization_decorator";
9
9
  import { Camera } from "./Camera";
10
+ import { getParam } from "../engine/engine_utils";
11
+
12
+ const noLimits = getParam("nocamlimits");
10
13
 
11
14
  export class OrbitControls extends Behaviour {
12
15
  public get controls() {
@@ -61,7 +64,7 @@ export class OrbitControls extends Behaviour {
61
64
  }
62
65
 
63
66
  onEnable() {
64
-
67
+
65
68
  this._enableTime = this.context.time.time;
66
69
  const camGo = GameObject.getComponent(this.gameObject, Camera);
67
70
  const cam = camGo?.cam;
@@ -79,12 +82,22 @@ export class OrbitControls extends Behaviour {
79
82
  this._controls.autoRotateSpeed = this.autoRotateSpeed;
80
83
  this._controls.enableZoom = this.enableZoom;
81
84
  if (cam?.type === "PerspectiveCamera") {
82
- this._controls.minDistance = this.minZoom;
83
- this._controls.maxDistance = this.maxZoom;
85
+ if (noLimits) {
86
+ // dont set limits
87
+ }
88
+ else {
89
+ this._controls.minDistance = this.minZoom;
90
+ this._controls.maxDistance = this.maxZoom;
91
+ }
84
92
  }
85
93
  else {
86
- this._controls.minZoom = this.minZoom;
87
- this._controls.maxZoom = this.maxZoom;
94
+ if (noLimits) {
95
+ // dont set limits
96
+ }
97
+ else {
98
+ this._controls.minZoom = this.minZoom;
99
+ this._controls.maxZoom = this.maxZoom;
100
+ }
88
101
  }
89
102
  this._controls.dampingFactor = this.dampingFactor;
90
103
  this._controls.enablePan = this.enablePan;
@@ -103,8 +116,8 @@ export class OrbitControls extends Behaviour {
103
116
  // this._controls.reset();
104
117
  }
105
118
  }
106
-
107
- onDestroy(){
119
+
120
+ onDestroy() {
108
121
  this._controls?.dispose();
109
122
  }
110
123
 
@@ -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 { Material, Texture, Vector4 } from "three";
8
+ import { Material, Mesh, 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";
@@ -133,12 +133,22 @@ export class Renderer extends Behaviour implements IRenderer {
133
133
  // private _materialProperties: Array<MaterialProperties> | undefined = undefined;
134
134
  private _lightmaps?: RendererLightmap[];
135
135
 
136
+ get mesh(): Mesh | undefined {
137
+ if (this.gameObject.type === "Mesh") {
138
+ return this.gameObject as unknown as Mesh
139
+ }
140
+ else if (this.gameObject.type === "Group") {
141
+ return this.gameObject.children[0] as unknown as Mesh;
142
+ }
143
+ return undefined;
144
+ }
145
+
136
146
  get material(): THREE.Material {
137
- return this.gameObject["material"];
147
+ return this.sharedMaterials[0];
138
148
  }
139
149
 
140
150
  set material(mat: THREE.Material) {
141
- this.gameObject["material"] = mat;
151
+ this.sharedMaterials[0] = mat;
142
152
  }
143
153
 
144
154
  private _sharedMaterials!: SharedMaterialArray;
@@ -484,7 +484,10 @@ export class WebAR {
484
484
 
485
485
  getAROverlayContainer(): HTMLElement | null {
486
486
  this.arDomOverlay = this.webxr.context.domElement as EngineElement;
487
- this.arOverlayElement = this.arDomOverlay.getAROverlayContainer();
487
+ // for react cases we dont have an Engine Element
488
+ if (this.arDomOverlay.getAROverlayContainer)
489
+ this.arOverlayElement = this.arDomOverlay.getAROverlayContainer();
490
+ else this.arOverlayElement = this.arDomOverlay;
488
491
  return this.arOverlayElement;
489
492
  }
490
493
 
@@ -12,15 +12,17 @@ export function apply(object: Object3D) {
12
12
 
13
13
 
14
14
  // this is a fix to allow gameObject active animation be applied to a three object
15
- Object.defineProperty(Object3D.prototype, "activeSelf", {
16
- get: function () {
17
- return this.visible;
18
- },
19
- set: function (val: boolean | number) {
20
- const state = typeof val === "number" ? val > 0.5 : val;
21
- this.visible = state;
22
- }
23
- });
15
+ if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
16
+ Object.defineProperty(Object3D.prototype, "activeSelf", {
17
+ get: function () {
18
+ return this.visible;
19
+ },
20
+ set: function (val: boolean | number) {
21
+ const state = typeof val === "number" ? val > 0.5 : val;
22
+ this.visible = state;
23
+ }
24
+ });
25
+ }
24
26
 
25
27
 
26
28
  // do we still need this?
@@ -40,23 +42,23 @@ Object3D.prototype["getOrAddComponent"] = function <T extends IComponent>(typeNa
40
42
  return getOrAddComponent<T>(this, typeName);
41
43
  }
42
44
 
43
- Object3D.prototype["getComponent"] = function <T>(type: Constructor<T>) {
44
- return getComponent(type, this);
45
+ Object3D.prototype["getComponent"] = function <T extends IComponent>(type: Constructor<T>) {
46
+ return getComponent(this, type);
45
47
  }
46
48
 
47
- Object3D.prototype["getComponents"] = function <T>(type: Constructor<T>, arr?: []) {
49
+ Object3D.prototype["getComponents"] = function <T extends IComponent>(type: Constructor<T>, arr?: []) {
48
50
  return getComponents(this, type, arr);
49
51
  }
50
52
 
51
- Object3D.prototype["getComponentInChildren"] = function <T>(type: Constructor<T>) {
53
+ Object3D.prototype["getComponentInChildren"] = function <T extends IComponent>(type: Constructor<T>) {
52
54
  return getComponentInChildren(this, type);
53
55
  }
54
56
 
55
57
  Object3D.prototype["getComponentsInChildren"] = function <T extends IComponent>(type: Constructor<T>, arr?: []) {
56
- return getComponentsInChildren(type, this, arr);
58
+ return getComponentsInChildren(this, type, arr);
57
59
  }
58
60
 
59
- Object3D.prototype["getComponentInParent"] = function <T>(type: Constructor<T>) {
61
+ Object3D.prototype["getComponentInParent"] = function <T extends IComponent>(type: Constructor<T>) {
60
62
  return getComponentInParent(this, type);
61
63
  }
62
64
 
@@ -344,8 +344,8 @@ export class EventSystem extends Behaviour {
344
344
  }
345
345
  }
346
346
 
347
- if (clicked)
348
- console.log(this.context.time.frame, object);
347
+ // if (clicked)
348
+ // console.log(this.context.time.frame, object);
349
349
  this.objectsHoveredThisFrame.push(object);
350
350
 
351
351
  if (canvasGroup === null || canvasGroup.interactable) {
@@ -44,7 +44,6 @@ export class UIRaycastUtils {
44
44
  }
45
45
  if (graphic?.raycastTarget === false) return false;
46
46
 
47
- console.log(graphic);
48
47
  return true;
49
48
  }
50
49
 
@@ -1,6 +1,5 @@
1
1
  import "./engine/engine_element";
2
2
  import "./engine/engine_setup";
3
- import "./engine/codegen/register_types";
4
3
  // import "./engine/engine_mainloop";
5
4
  // import "./engine-components/DomOverlay";
6
5