@needle-tools/engine 2.35.1-pre → 2.35.3-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 (72) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/needle-engine.d.ts +317 -292
  3. package/dist/needle-engine.js +354 -349
  4. package/dist/needle-engine.js.map +4 -4
  5. package/dist/needle-engine.min.js +38 -33
  6. package/dist/needle-engine.min.js.map +4 -4
  7. package/lib/engine/engine.d.ts +1 -0
  8. package/lib/engine/engine_components.js +12 -0
  9. package/lib/engine/engine_components.js.map +1 -1
  10. package/lib/engine/engine_element.d.ts +2 -1
  11. package/lib/engine/engine_element.js +4 -1
  12. package/lib/engine/engine_element.js.map +1 -1
  13. package/lib/engine/engine_gltf.d.ts +2 -2
  14. package/lib/engine/engine_gltf.js +5 -1
  15. package/lib/engine/engine_gltf.js.map +1 -1
  16. package/lib/engine/engine_gltf_builtin_components.d.ts +1 -0
  17. package/lib/engine/engine_gltf_builtin_components.js +5 -0
  18. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  19. package/lib/engine/engine_scenetools.d.ts +9 -0
  20. package/lib/engine/engine_scenetools.js +2 -2
  21. package/lib/engine/engine_scenetools.js.map +1 -1
  22. package/lib/engine/engine_types.d.ts +5 -0
  23. package/lib/engine/engine_types.js.map +1 -1
  24. package/lib/engine/extensions/NEEDLE_deferred_texture.js +33 -1
  25. package/lib/engine/extensions/NEEDLE_deferred_texture.js.map +1 -1
  26. package/lib/engine-components/Component.js +5 -1
  27. package/lib/engine-components/Component.js.map +1 -1
  28. package/lib/engine-components/DragControls.d.ts +1 -0
  29. package/lib/engine-components/DragControls.js +11 -6
  30. package/lib/engine-components/DragControls.js.map +1 -1
  31. package/lib/engine-components/OrbitControls.js +16 -4
  32. package/lib/engine-components/OrbitControls.js.map +1 -1
  33. package/lib/engine-components/Renderer.d.ts +2 -1
  34. package/lib/engine-components/Renderer.js +13 -4
  35. package/lib/engine-components/Renderer.js.map +1 -1
  36. package/lib/engine-components/ScreenCapture.d.ts +7 -1
  37. package/lib/engine-components/ScreenCapture.js +12 -5
  38. package/lib/engine-components/ScreenCapture.js.map +1 -1
  39. package/lib/engine-components/WebXR.d.ts +1 -1
  40. package/lib/engine-components/WebXR.js +15 -7
  41. package/lib/engine-components/WebXR.js.map +1 -1
  42. package/lib/engine-components/js-extensions/ExtensionUtils.d.ts +3 -1
  43. package/lib/engine-components/js-extensions/ExtensionUtils.js +18 -8
  44. package/lib/engine-components/js-extensions/ExtensionUtils.js.map +1 -1
  45. package/lib/engine-components/js-extensions/Object3D.js +18 -15
  46. package/lib/engine-components/js-extensions/Object3D.js.map +1 -1
  47. package/lib/engine-components/js-extensions/Vector.js +3 -3
  48. package/lib/engine-components/js-extensions/Vector.js.map +1 -1
  49. package/lib/engine-components/ui/RaycastUtils.js +0 -1
  50. package/lib/engine-components/ui/RaycastUtils.js.map +1 -1
  51. package/lib/needle-engine.d.ts +0 -1
  52. package/lib/needle-engine.js +0 -1
  53. package/lib/needle-engine.js.map +1 -1
  54. package/package.json +10 -1
  55. package/src/engine/engine_components.ts +14 -1
  56. package/src/engine/engine_element.ts +7 -2
  57. package/src/engine/engine_gltf.ts +8 -4
  58. package/src/engine/engine_gltf_builtin_components.ts +4 -0
  59. package/src/engine/engine_scenetools.ts +2 -2
  60. package/src/engine/engine_types.ts +10 -6
  61. package/src/engine/extensions/NEEDLE_deferred_texture.ts +36 -3
  62. package/src/engine-components/Component.ts +7 -1
  63. package/src/engine-components/DragControls.ts +10 -8
  64. package/src/engine-components/OrbitControls.ts +20 -7
  65. package/src/engine-components/Renderer.ts +15 -5
  66. package/src/engine-components/ScreenCapture.ts +20 -5
  67. package/src/engine-components/WebXR.ts +19 -10
  68. package/src/engine-components/js-extensions/ExtensionUtils.ts +27 -12
  69. package/src/engine-components/js-extensions/Object3D.ts +23 -16
  70. package/src/engine-components/js-extensions/Vector.ts +6 -4
  71. package/src/engine-components/ui/RaycastUtils.ts +0 -1
  72. package/src/needle-engine.ts +0 -1
@@ -113,6 +113,7 @@ abstract class GameObject extends THREE.Object3D implements THREE.Object3D, IGam
113
113
 
114
114
  public static invoke(go: THREE.Object3D | null | undefined, functionName: string, children: boolean = false, ...args: any) {
115
115
  if (!go) return;
116
+
116
117
  // console.log(go);
117
118
  this.foreachComponent(go, c => {
118
119
  const fn = c[functionName];
@@ -381,6 +382,7 @@ class Component implements IComponent, EventTarget {
381
382
  if (this.__didEnable) return false;
382
383
  // console.trace("INTERNAL ENABLE");
383
384
  this.__didEnable = true;
385
+ this.__isEnabled = true;
384
386
  this.onEnable();
385
387
  return true;
386
388
  }
@@ -389,6 +391,7 @@ class Component implements IComponent, EventTarget {
389
391
  if (!this.__didEnable) return;
390
392
  this.__didEnable = false;
391
393
  this._collisionExitRoutine = undefined;
394
+ this.__isEnabled = false;
392
395
  this.onDisable();
393
396
  this._collisions?.clear();
394
397
  }
@@ -415,7 +418,10 @@ class Component implements IComponent, EventTarget {
415
418
  }
416
419
 
417
420
  // need to check here because codegen is calling this before everything is setup
418
- if (!this.__didAwake) return;
421
+ if (!this.__didAwake) {
422
+ this.__isEnabled = val;
423
+ return;
424
+ }
419
425
  if (val) {
420
426
  this.__internalEnable();
421
427
  } else {
@@ -13,6 +13,7 @@ import { getWorldPosition, getWorldQuaternion, setWorldPosition } from "../engin
13
13
  import { KeyCode } from "../engine/engine_input";
14
14
  import { nameofFactory } from "../engine/engine_utils";
15
15
  import { InstancingUtil } from "../engine/engine_instancing";
16
+ import { OrbitControls } from "./OrbitControls";
16
17
 
17
18
  const debug = false;
18
19
 
@@ -43,7 +44,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
43
44
  // public targets: THREE.Object3D[] | null = null;
44
45
 
45
46
  // private controls: Control | null = null;
46
- // private orbit: OrbitControls | null = null;
47
+ private orbit: OrbitControls | null = null;
47
48
 
48
49
  private selectStartEventListener: ((controls: DragControls, args: SelectArgs) => void)[] = [];
49
50
  private selectEndEventListener: Array<Function> = [];
@@ -70,7 +71,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
70
71
 
71
72
 
72
73
  start() {
73
- // this.orbit = GameObject.findObjectOfType(OrbitControls, this.context);
74
+ this.orbit = GameObject.findObjectOfType(OrbitControls, this.context);
74
75
  }
75
76
 
76
77
  private static lastHovered: THREE.Object3D;
@@ -148,8 +149,11 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
148
149
  this.onUpdateDrag();
149
150
  }
150
151
 
151
- if (this._isDragging && !this._dragHelper?.hasSelected) {
152
- this.onDragEnd(null);
152
+
153
+ if (this._isDragging) {
154
+ if (this._dragHelper?.hasSelected === false) {
155
+ this.onDragEnd(null);
156
+ }
153
157
  }
154
158
  }
155
159
 
@@ -197,7 +201,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
197
201
  object = args.attached;
198
202
  this._isDragging = true;
199
203
  this._dragHelper.setSelected(object, this.context);
200
- // if (this.orbit) this.orbit.enabled = false;
204
+ if (this.orbit) this.orbit.enabled = false;
201
205
 
202
206
  const sync = GameObject.getComponentInChildren(object, SyncedTransform);
203
207
  if (debug)
@@ -239,7 +243,7 @@ export class DragControls extends Interactable implements IPointerDownHandler, I
239
243
  if (debug)
240
244
  console.log("DRAG END", selected, selected?.visible)
241
245
  this._dragHelper.setSelected(null, this.context);
242
- // if (this.orbit) this.orbit.enabled = true;
246
+ if (this.orbit) this.orbit.enabled = true;
243
247
  if (evt?.object) {
244
248
  const sync = GameObject.getComponentInChildren(evt.object, SyncedTransform);
245
249
  if (sync) {
@@ -316,7 +320,6 @@ class DragHelper {
316
320
  }
317
321
 
318
322
  setSelected(newSelected: THREE.Object3D | null, context: Context) {
319
-
320
323
  if (this._selected && context) {
321
324
  for (const rb of this._rbs) {
322
325
  rb.wakeUp();
@@ -343,7 +346,6 @@ class DragHelper {
343
346
  this._groundMarker.removeFromParent();
344
347
  }
345
348
 
346
-
347
349
  if (this._selected) {
348
350
  if (!context) {
349
351
  console.error("DragHelper: no context");
@@ -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";
@@ -17,8 +17,8 @@ export { InstancingUtil } from "../engine/engine_instancing";
17
17
  const suppressInstancing = getParam("noInstancing");
18
18
  const debugLightmap = getParam("debuglightmaps") ? true : false;
19
19
  const debugInstancing = getParam("debuginstancing");
20
- const debugProgressiveLoading = getParam("debugprogressiveload");
21
- const suppressProgressiveLoading = getParam("noprogressiveload");
20
+ const debugProgressiveLoading = getParam("debugprogressive");
21
+ const suppressProgressiveLoading = getParam("noprogressive");
22
22
 
23
23
  export class FieldWithDefault {
24
24
  public path: string | null = null;
@@ -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;
@@ -31,6 +31,12 @@ function disposeStream(str: MediaStream | null | undefined) {
31
31
  cap.stop();
32
32
  }
33
33
 
34
+ declare type ScreenCaptureOptions = {
35
+ device?: ScreenCaptureDevice,
36
+ deviceId?: string,
37
+ constraints?: MediaTrackConstraints,
38
+ }
39
+
34
40
  export class ScreenCapture extends Behaviour implements IPointerClickHandler {
35
41
 
36
42
  onPointerClick() {
@@ -82,7 +88,8 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
82
88
  private _currentMode: ScreenCaptureMode = ScreenCaptureMode.Idle;
83
89
 
84
90
  awake() {
85
- console.log(this);
91
+ if (debug)
92
+ console.log(this);
86
93
  AudioSource.registerWaitForAllowAudio(() => {
87
94
  if (this.videoPlayer && this._currentStream && this._currentMode === ScreenCaptureMode.Receiving) {
88
95
  this.videoPlayer.setVideo(this._currentStream);
@@ -105,12 +112,16 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
105
112
  this._net.addEventListener(PeerEvent.ReceiveVideo, this.onReceiveVideo.bind(this));
106
113
  }
107
114
 
108
- async share() {
115
+ async share(opts?: ScreenCaptureOptions) {
116
+
117
+ if (opts?.device)
118
+ this.device = opts.device;
119
+
109
120
  this._requestOpen = true;
110
121
  try {
111
122
  if (this.videoPlayer) {
112
123
 
113
- const settings: MediaTrackConstraints = {
124
+ const settings: MediaTrackConstraints = opts?.constraints ?? {
114
125
  echoCancellation: true,
115
126
  autoGainControl: false,
116
127
  };
@@ -122,7 +133,7 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
122
133
  switch (this.device) {
123
134
  // Capture a connected camera
124
135
  case ScreenCaptureDevice.Camera:
125
- this.tryShareUserCamera(displayMediaOptions);
136
+ this.tryShareUserCamera(displayMediaOptions, opts);
126
137
  break;
127
138
 
128
139
  // capture any screen, will show a popup
@@ -197,7 +208,7 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
197
208
 
198
209
 
199
210
 
200
- private async tryShareUserCamera(opts: DisplayMediaStreamConstraints) {
211
+ private async tryShareUserCamera(opts: DisplayMediaStreamConstraints, options?: ScreenCaptureOptions) {
201
212
 
202
213
  // let newWindow = open('', 'example', 'width=300,height=300');
203
214
  // if (window) {
@@ -212,6 +223,10 @@ export class ScreenCapture extends Behaviour implements IPointerClickHandler {
212
223
  if (!this._requestOpen) break;
213
224
  if (dev.kind !== "videoinput") continue;
214
225
  const id = dev.deviceId;
226
+ if (options?.deviceId !== undefined) {
227
+ if (id !== options.deviceId)
228
+ continue;
229
+ }
215
230
  if (opts.video !== false) {
216
231
  if (typeof opts.video === "undefined" || typeof opts.video === "boolean") {
217
232
  opts.video = {};
@@ -13,11 +13,11 @@ import { ControllerType, WebXRController } from "./WebXRController";
13
13
  import { WebARSessionRoot } from "./WebARSessionRoot";
14
14
  import { getWorldPosition, getWorldQuaternion, setWorldPosition, setWorldQuaternion } from "../engine/engine_three_utils";
15
15
  import { XRRig } from "./WebXRRig";
16
- import { EngineElement } from "../engine/engine_element";
17
16
  import { AssetReference } from "../engine/engine_addressables";
18
17
  import { serializeable } from "../engine/engine_serialization_decorator";
19
18
  import { WebXRSync } from "./WebXRSync";
20
19
  import { XRSessionMode } from "../engine/engine_setup";
20
+ import { INeedleEngineComponent } from "../engine/engine_types";
21
21
 
22
22
 
23
23
  export async function detectARSupport() {
@@ -210,7 +210,7 @@ export class WebXR extends Behaviour {
210
210
  }
211
211
 
212
212
  // VR support
213
- if (this.createVRButton && this.enableVR && (browserSupportsXR || !this.enableAR)) {
213
+ if (this.createVRButton && this.enableVR) {
214
214
  vrButton = WebXR.createVRButton(this);
215
215
  this._vrButton = vrButton;
216
216
  buttonsContainer.appendChild(vrButton);
@@ -477,14 +477,18 @@ export class WebAR {
477
477
  this._webxr = webxr;
478
478
  }
479
479
 
480
- private arDomOverlay: EngineElement | null = null;
481
- private arOverlayElement: HTMLElement | null = null;
480
+ private arDomOverlay: HTMLElement | null = null;
481
+ private arOverlayElement: INeedleEngineComponent | HTMLElement | null = null;
482
482
  private noHitTestAvailable: boolean = false;
483
483
  private didPlaceARSessionRoot: boolean = false;
484
484
 
485
485
  getAROverlayContainer(): HTMLElement | null {
486
- this.arDomOverlay = this.webxr.context.domElement as EngineElement;
487
- this.arOverlayElement = this.arDomOverlay.getAROverlayContainer();
486
+ this.arDomOverlay = this.webxr.context.domElement as HTMLElement;
487
+ // for react cases we dont have an Engine Element
488
+ const element : any = this.arDomOverlay;
489
+ if (element.getAROverlayContainer)
490
+ this.arOverlayElement = element.getAROverlayContainer();
491
+ else this.arOverlayElement = this.arDomOverlay;
488
492
  return this.arOverlayElement;
489
493
  }
490
494
 
@@ -545,13 +549,14 @@ export class WebAR {
545
549
  else console.warn("No WebARSessionRoot found in scene")
546
550
 
547
551
  if (this.arDomOverlay && this.arOverlayElement) {
548
- this.arDomOverlay.onEnterAR(session, this.arOverlayElement);
552
+ const el = this.arOverlayElement as INeedleEngineComponent;
553
+ el.onEnterAR?.call(el, session, this.arOverlayElement);
549
554
  }
550
555
 
551
556
  this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera();
552
557
  }
553
558
 
554
- onEnd(_session: THREE.XRSession) {
559
+ onEnd(session: THREE.XRSession) {
555
560
  if (this._previousParent) {
556
561
  console.log("ADD", this._previousParent);
557
562
  GameObject.addComponent(this._previousParent as GameObject, this.webxr);
@@ -562,9 +567,13 @@ export class WebAR {
562
567
  context.scene.background = this.previousBackground;
563
568
  context.scene.environment = this.previousEnvironment;
564
569
  if (this.sessionRoot) {
565
- this.sessionRoot.onEnd(this.webxr.Rig, _session);
570
+ this.sessionRoot.onEnd(this.webxr.Rig, session);
571
+ }
572
+ if (this.arDomOverlay)
573
+ {
574
+ const el = this.arOverlayElement as INeedleEngineComponent;
575
+ el.onExitAR?.call(el, session);
566
576
  }
567
- if (this.arDomOverlay) this.arDomOverlay.onExitAR(_session);
568
577
 
569
578
  this.context.mainCameraComponent?.applyClearFlagsIfIsActiveCamera();
570
579
  }
@@ -1,19 +1,32 @@
1
+ import { Object3D } from "three";
2
+ import { Constructor } from "../../engine/engine_types";
1
3
 
2
- const handlers : Map<any, ApplyPrototypeExtension> = new Map();
4
+ const handlers: Map<any, ApplyPrototypeExtension> = new Map();
3
5
 
4
- export function applyPrototypeExtensions(obj : any){
5
- if(!obj) return;
6
- const prototype = obj.prototype;
7
- if(!prototype) return;
6
+ export function applyPrototypeExtensions<T>(obj: any, prototype : Constructor<T>) {
7
+ if (!obj) return;
8
+ // const prototype = Object.getPrototypeOf(obj);
9
+ // console.log("TEST", prototype)
10
+ if (!prototype) {
11
+ console.warn("No prototype found", obj, obj.prototype, obj.constructor);
12
+ return;
13
+ }
8
14
  let handler = handlers.get(prototype);
9
- if(!handler){
10
- handler = createPrototypeExtensionHandler(prototype);
11
- handlers.set(prototype, handler);
15
+ if (handler) {
16
+ // console.log("OK", prototype);
17
+ handler.apply(obj);
12
18
  }
13
- handler.apply(obj);
19
+ // applyPrototypeExtensions(prototype);
20
+ }
21
+
22
+ export function registerPrototypeExtensions<T>(type: Constructor<T>) {
23
+ console.log("Register", type.prototype.constructor.name);
24
+ const handler = createPrototypeExtensionHandler(type.prototype);
25
+ handlers.set(type, handler);
14
26
  }
15
27
 
16
- function createPrototypeExtensionHandler(prototype: any) {
28
+
29
+ function createPrototypeExtensionHandler(prototype: any) {
17
30
  return new ApplyPrototypeExtension(prototype);
18
31
  }
19
32
 
@@ -31,9 +44,11 @@ class ApplyPrototypeExtension implements IApplyPrototypeExtension {
31
44
  this.$symbol = Symbol("prototype-extension");
32
45
  // used to decorate cloned object3D objects with the same added components defined above
33
46
  this.extensions = Object.keys(prototype);
47
+ // console.log(this.extensions);
34
48
  this.descriptors = new Array<PropertyDescriptor | undefined>();
35
49
  for (let i = 0; i < this.extensions.length; i++) {
36
50
  const key = this.extensions[i];
51
+ // console.log(key);
37
52
  const descriptor = Object.getOwnPropertyDescriptor(prototype, key);
38
53
  if (descriptor) {
39
54
  this.descriptors.push(descriptor);
@@ -41,7 +56,7 @@ class ApplyPrototypeExtension implements IApplyPrototypeExtension {
41
56
  }
42
57
  }
43
58
 
44
- apply(object: object): void {
59
+ apply(object: Object3D): void {
45
60
 
46
61
  if (object[this.$symbol]) return;
47
62
  object[this.$symbol] = true;
@@ -58,7 +73,7 @@ class ApplyPrototypeExtension implements IApplyPrototypeExtension {
58
73
  // continue;
59
74
  // }
60
75
  // }
61
- // console.trace("DEFINE", object.name, key);
76
+ // console.warn("DEFINE", object, key);
62
77
  Object.defineProperty(object, key, desc);
63
78
  }
64
79
  }
@@ -1,4 +1,4 @@
1
- import { applyPrototypeExtensions } from "./ExtensionUtils";
1
+ import { applyPrototypeExtensions, registerPrototypeExtensions } from "./ExtensionUtils";
2
2
  import { Object3D } from "three";
3
3
  import { Constructor, ConstructorConcrete, IComponent } from "../../engine/engine_types"
4
4
  import { IComponent as Component } from "../../engine/engine_types";
@@ -6,24 +6,12 @@ import { addNewComponentInstance, getComponent, getComponentInChildren, getCompo
6
6
 
7
7
  // used to decorate cloned object3D objects with the same added components defined above
8
8
  export function apply(object: Object3D) {
9
- if (object && object.isObject3D === true)
10
- applyPrototypeExtensions(object);
9
+ if (object && object.isObject3D === true) {
10
+ applyPrototypeExtensions(object, Object3D);
11
+ }
11
12
  }
12
13
 
13
14
 
14
- // this is a fix to allow gameObject active animation be applied to a three object
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
- }
26
-
27
15
 
28
16
  // do we still need this?
29
17
  Object3D.prototype["SetActive"] = function (active: boolean) {
@@ -65,3 +53,22 @@ Object3D.prototype["getComponentInParent"] = function <T extends IComponent>(typ
65
53
  Object3D.prototype["getComponentsInParent"] = function <T>(type: Constructor<T>, arr?: []) {
66
54
  return getComponentsInParent(this, type, arr);
67
55
  }
56
+
57
+ // this is a fix to allow gameObject active animation be applied to a three object
58
+ if (!Object.getOwnPropertyDescriptor(Object3D.prototype, "activeSelf")) {
59
+ Object.defineProperty(Object3D.prototype, "activeSelf", {
60
+ get: function () {
61
+ return this.visible;
62
+ },
63
+ set: function (val: boolean | number) {
64
+ const state = typeof val === "number" ? val > 0.5 : val;
65
+ this.visible = state;
66
+ }
67
+ });
68
+ }
69
+
70
+
71
+
72
+
73
+ // do this after adding the component extensions
74
+ registerPrototypeExtensions(Object3D);
@@ -1,17 +1,19 @@
1
- import { applyPrototypeExtensions } from "./ExtensionUtils";
1
+ import { applyPrototypeExtensions, registerPrototypeExtensions } from "./ExtensionUtils";
2
2
  import { Mathf } from "../../engine/engine_math";
3
3
  import { Vector3 } from "three";
4
4
 
5
5
  export function apply(object: Vector3) {
6
6
  if (object && object.isVector3 === true) {
7
- console.log(object);
8
- applyPrototypeExtensions(object);
7
+ applyPrototypeExtensions(object, Vector3);
9
8
  }
10
9
  }
11
10
 
11
+
12
12
  Vector3.prototype["slerp"] = function (end: Vector3, t: number) {
13
13
  const len1 = this.length();
14
14
  const len2 = end.length();
15
15
  const targetLen = Mathf.lerp(len1, len2, t);
16
16
  return this.lerp(end, t).normalize().multiplyScalar(targetLen);
17
- }
17
+ }
18
+
19
+ registerPrototypeExtensions(Vector3);
@@ -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