@needle-tools/engine 5.0.0 → 5.1.0-experimental.1

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 (181) hide show
  1. package/components.needle.json +1 -1
  2. package/dist/generateMeshBVH.worker-DT9A2Hrc.js +1 -0
  3. package/dist/gltf-progressive-3BwW4ETO.min.js +10 -0
  4. package/dist/gltf-progressive-ByD1UX0A.umd.cjs +10 -0
  5. package/dist/{gltf-progressive-Cl167Vjx.js → gltf-progressive-DwWaVr0o.js} +412 -394
  6. package/dist/gltf-progressive.worker-DpfUjn1n.js +3 -0
  7. package/dist/{materialx-qPScBWhj.min.js → materialx-9KHBidZa.min.js} +1 -1
  8. package/dist/{materialx-4ApD6Vz5.js → materialx-BBDu8W5P.js} +1 -1
  9. package/dist/{materialx-D0XUnhBY.umd.cjs → materialx-hLP3E8AA.umd.cjs} +2 -2
  10. package/dist/{needle-engine.bundle-CoEvMwYM.min.js → needle-engine.bundle-BiCxyTBE.min.js} +110 -110
  11. package/dist/{needle-engine.bundle-BAYLGumK.umd.cjs → needle-engine.bundle-CaHKqc30.umd.cjs} +123 -123
  12. package/dist/{needle-engine.bundle-BDIyvCV6.js → needle-engine.bundle-JZXX6OjM.js} +2143 -2088
  13. package/dist/needle-engine.d.ts +102 -44
  14. package/dist/needle-engine.js +480 -476
  15. package/dist/needle-engine.min.js +1 -1
  16. package/dist/needle-engine.umd.cjs +1 -1
  17. package/dist/{postprocessing-B_9sKVU7.min.js → postprocessing-BZfyAdCY.min.js} +1 -1
  18. package/dist/{postprocessing-WDc9WwI3.js → postprocessing-CXlA3QA6.js} +1 -1
  19. package/dist/{postprocessing-B2wb6pzI.umd.cjs → postprocessing-Dwy7Hz_T.umd.cjs} +38 -38
  20. package/dist/three-examples.js +4760 -3641
  21. package/dist/three-examples.min.js +17 -35
  22. package/dist/three-examples.umd.cjs +16 -34
  23. package/dist/three.js +48533 -28562
  24. package/dist/three.min.js +716 -502
  25. package/dist/three.umd.cjs +720 -506
  26. package/dist/vendor-Bf43L3CE.min.js +1116 -0
  27. package/dist/{vendor-CntUvmJu.umd.cjs → vendor-BlyEaMTL.umd.cjs} +31 -31
  28. package/dist/{vendor-vHLk8sXu.js → vendor-D-7l5gB0.js} +2562 -2556
  29. package/lib/engine/engine_animation.js +1 -1
  30. package/lib/engine/engine_animation.js.map +1 -1
  31. package/lib/engine/engine_audio.js.map +1 -1
  32. package/lib/engine/engine_context.js +3 -6
  33. package/lib/engine/engine_context.js.map +1 -1
  34. package/lib/engine/engine_create_objects.js +0 -1
  35. package/lib/engine/engine_create_objects.js.map +1 -1
  36. package/lib/engine/engine_element.d.ts +113 -0
  37. package/lib/engine/engine_element.js +833 -0
  38. package/lib/engine/engine_element.js.map +1 -0
  39. package/lib/engine/engine_element_attributes.d.ts +72 -0
  40. package/lib/engine/engine_element_attributes.js +2 -0
  41. package/lib/engine/engine_element_attributes.js.map +1 -0
  42. package/lib/engine/engine_element_extras.d.ts +6 -0
  43. package/lib/engine/engine_element_extras.js +14 -0
  44. package/lib/engine/engine_element_extras.js.map +1 -0
  45. package/lib/engine/engine_element_loading.d.ts +44 -0
  46. package/lib/engine/engine_element_loading.js +350 -0
  47. package/lib/engine/engine_element_loading.js.map +1 -0
  48. package/lib/engine/engine_element_overlay.d.ts +21 -0
  49. package/lib/engine/engine_element_overlay.js +167 -0
  50. package/lib/engine/engine_element_overlay.js.map +1 -0
  51. package/lib/engine/engine_license.js.map +1 -1
  52. package/lib/engine/engine_pmrem.js +2 -2
  53. package/lib/engine/engine_pmrem.js.map +1 -1
  54. package/lib/engine/engine_scenetools.d.ts +62 -0
  55. package/lib/engine/engine_scenetools.js +337 -0
  56. package/lib/engine/engine_scenetools.js.map +1 -0
  57. package/lib/engine/engine_test_utils.d.ts +39 -0
  58. package/lib/engine/engine_test_utils.js +84 -0
  59. package/lib/engine/engine_test_utils.js.map +1 -0
  60. package/lib/engine/engine_three_utils.js.map +1 -1
  61. package/lib/engine/engine_time.js +4 -3
  62. package/lib/engine/engine_time.js.map +1 -1
  63. package/lib/engine/engine_ui.d.ts +25 -0
  64. package/lib/engine/engine_ui.dummy_canvas.d.ts +2 -0
  65. package/lib/engine/engine_ui.dummy_canvas.js +55 -0
  66. package/lib/engine/engine_ui.dummy_canvas.js.map +1 -0
  67. package/lib/engine/engine_ui.js +168 -0
  68. package/lib/engine/engine_ui.js.map +1 -0
  69. package/lib/engine/extensions/NEEDLE_lightmaps.js +2 -2
  70. package/lib/engine/extensions/NEEDLE_lightmaps.js.map +1 -1
  71. package/lib/engine/extensions/NEEDLE_pmrem.d.ts +1 -1
  72. package/lib/engine/webcomponents/icons.js +3 -2
  73. package/lib/engine/webcomponents/icons.js.map +1 -1
  74. package/lib/engine/webcomponents/needle-engine.attributes.d.ts +69 -0
  75. package/lib/engine/webcomponents/needle-engine.attributes.js +2 -0
  76. package/lib/engine/webcomponents/needle-engine.attributes.js.map +1 -0
  77. package/lib/engine-components/AudioSource.js +1 -1
  78. package/lib/engine-components/AudioSource.js.map +1 -1
  79. package/lib/engine-components/Light.d.ts +3 -0
  80. package/lib/engine-components/Light.js +39 -31
  81. package/lib/engine-components/Light.js.map +1 -1
  82. package/lib/engine-components/OrbitControls.js +2 -1
  83. package/lib/engine-components/OrbitControls.js.map +1 -1
  84. package/lib/engine-components/SpriteRenderer.d.ts +1 -1
  85. package/lib/engine-components/VideoPlayer.d.ts +1 -1
  86. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
  87. package/lib/engine-components/export/usdz/extensions/Animation.js +1 -0
  88. package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
  89. package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
  90. package/lib/engine-components/particlesystem/ParticleSystem.d.ts +1 -1
  91. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  92. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  93. package/lib/engine-components/ui/BaseUIComponent_Uikit.d.ts +54 -0
  94. package/lib/engine-components/ui/BaseUIComponent_Uikit.js +114 -0
  95. package/lib/engine-components/ui/BaseUIComponent_Uikit.js.map +1 -0
  96. package/lib/engine-components/ui/BaseUikitComponent.d.ts +54 -0
  97. package/lib/engine-components/ui/BaseUikitComponent.js +114 -0
  98. package/lib/engine-components/ui/BaseUikitComponent.js.map +1 -0
  99. package/lib/engine-components/ui/Button.legacy.d.ts +68 -0
  100. package/lib/engine-components/ui/Button.legacy.js +320 -0
  101. package/lib/engine-components/ui/Button.legacy.js.map +1 -0
  102. package/lib/engine-components/ui/ButtonUikit.d.ts +51 -0
  103. package/lib/engine-components/ui/ButtonUikit.js +187 -0
  104. package/lib/engine-components/ui/ButtonUikit.js.map +1 -0
  105. package/lib/engine-components/ui/Canvas.js +2 -2
  106. package/lib/engine-components/ui/Canvas.js.map +1 -1
  107. package/lib/engine-components/ui/Canvas.legacy.d.ts +76 -0
  108. package/lib/engine-components/ui/Canvas.legacy.js +409 -0
  109. package/lib/engine-components/ui/Canvas.legacy.js.map +1 -0
  110. package/lib/engine-components/ui/CanvasUikit.d.ts +68 -0
  111. package/lib/engine-components/ui/CanvasUikit.js +289 -0
  112. package/lib/engine-components/ui/CanvasUikit.js.map +1 -0
  113. package/lib/engine-components/ui/Graphic.d.ts +3 -3
  114. package/lib/engine-components/ui/Graphic.js +6 -2
  115. package/lib/engine-components/ui/Graphic.js.map +1 -1
  116. package/lib/engine-components/ui/Graphic.legacy.d.ts +55 -0
  117. package/lib/engine-components/ui/Graphic.legacy.js +268 -0
  118. package/lib/engine-components/ui/Graphic.legacy.js.map +1 -0
  119. package/lib/engine-components/ui/GraphicUikit.d.ts +21 -0
  120. package/lib/engine-components/ui/GraphicUikit.js +65 -0
  121. package/lib/engine-components/ui/GraphicUikit.js.map +1 -0
  122. package/lib/engine-components/ui/Image.js.map +1 -1
  123. package/lib/engine-components/ui/Image.legacy.d.ts +39 -0
  124. package/lib/engine-components/ui/Image.legacy.js +121 -0
  125. package/lib/engine-components/ui/Image.legacy.js.map +1 -0
  126. package/lib/engine-components/ui/ImageUikit.d.ts +22 -0
  127. package/lib/engine-components/ui/ImageUikit.js +97 -0
  128. package/lib/engine-components/ui/ImageUikit.js.map +1 -0
  129. package/lib/engine-components/ui/RenderMode.d.ts +14 -0
  130. package/lib/engine-components/ui/RenderMode.js +16 -0
  131. package/lib/engine-components/ui/RenderMode.js.map +1 -0
  132. package/lib/engine-components/ui/Text.d.ts +64 -11
  133. package/lib/engine-components/ui/Text.js +154 -45
  134. package/lib/engine-components/ui/Text.js.map +1 -1
  135. package/lib/engine-components/ui/Text.legacy.d.ts +81 -0
  136. package/lib/engine-components/ui/Text.legacy.js +548 -0
  137. package/lib/engine-components/ui/Text.legacy.js.map +1 -0
  138. package/lib/engine-components/ui/TextUikit.d.ts +42 -0
  139. package/lib/engine-components/ui/TextUikit.js +164 -0
  140. package/lib/engine-components/ui/TextUikit.js.map +1 -0
  141. package/lib/engine-components/ui/index.d.ts +1 -0
  142. package/lib/engine-components/ui/index.js +1 -0
  143. package/lib/engine-components/ui/index.js.map +1 -1
  144. package/lib/engine-components/webxr/WebARCameraBackground.d.ts +1 -1
  145. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.d.ts +6 -0
  146. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js +46 -0
  147. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
  148. package/package.json +5 -5
  149. package/plugins/common/buildinfo.d.ts +6 -0
  150. package/plugins/vite/ai.d.ts +7 -8
  151. package/plugins/vite/ai.js +95 -20
  152. package/plugins/vite/alias.js +6 -0
  153. package/plugins/vite/dependencies.js +7 -0
  154. package/src/engine/engine_animation.ts +1 -1
  155. package/src/engine/engine_audio.ts +1 -1
  156. package/src/engine/engine_context.ts +3 -6
  157. package/src/engine/engine_create_objects.ts +0 -1
  158. package/src/engine/engine_license.ts +0 -2
  159. package/src/engine/engine_pmrem.ts +3 -3
  160. package/src/engine/engine_three_utils.ts +2 -2
  161. package/src/engine/engine_time.ts +4 -3
  162. package/src/engine/extensions/NEEDLE_lightmaps.ts +3 -3
  163. package/src/engine/webcomponents/icons.ts +3 -2
  164. package/src/engine-components/AudioSource.ts +1 -1
  165. package/src/engine-components/Light.ts +39 -31
  166. package/src/engine-components/OrbitControls.ts +2 -2
  167. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2 -2
  168. package/src/engine-components/export/usdz/extensions/Animation.ts +6 -5
  169. package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +1 -1
  170. package/src/engine-components/postprocessing/PostProcessingHandler.ts +3 -3
  171. package/src/engine-components/timeline/TimelineTracks.ts +2 -2
  172. package/src/engine-components/ui/Canvas.ts +2 -2
  173. package/src/engine-components/ui/Graphic.ts +7 -3
  174. package/src/engine-components/ui/Image.ts +1 -1
  175. package/src/engine-components/ui/Text.ts +170 -52
  176. package/src/engine-components/ui/index.ts +2 -1
  177. package/dist/generateMeshBVH.worker-DiCnZlf3.js +0 -21
  178. package/dist/gltf-progressive-BryRjllq.min.js +0 -10
  179. package/dist/gltf-progressive-DJBMx-zB.umd.cjs +0 -10
  180. package/dist/gltf-progressive.worker-BqODMeeW.js +0 -23
  181. package/dist/vendor-DPbfJJ4d.min.js +0 -1116
@@ -533,7 +533,7 @@ export class Graphics {
533
533
  mesh.frustumCulled = false;
534
534
  this.scene.children.length = 0;
535
535
  this.scene.add(mesh);
536
- this.renderer.setSize(texture.image.width, texture.image.height);
536
+ this.renderer.setSize((texture.image as any).width, (texture.image as any).height);
537
537
  this.renderer.clear();
538
538
  this.renderer.render(this.scene, this.perspectiveCam);
539
539
  const tex = new Texture(this.renderer.domElement);
@@ -618,7 +618,7 @@ export class Graphics {
618
618
  if (force === true || texture["isCompressedTexture"] === true) {
619
619
  texture = copyTexture(texture);
620
620
  }
621
- const image = texture.image;
621
+ const image = texture.image as any;
622
622
  if (isImageBitmap(image)) {
623
623
  const canvas = document.createElement('canvas');
624
624
  canvas.width = image.width;
@@ -1,4 +1,4 @@
1
- import { Clock } from 'three'
1
+ import { Timer } from 'three'
2
2
 
3
3
  import { type ITime } from './engine_types.js';
4
4
  import { getParam } from './engine_utils.js';
@@ -59,7 +59,7 @@ export class Time implements ITime {
59
59
 
60
60
  /** The time in seconds it took to complete the last frame (Read Only). */
61
61
  get realtimeSinceStartup(): number {
62
- return this.clock.elapsedTime;
62
+ return this.clock.getElapsed();
63
63
  }
64
64
 
65
65
  /**
@@ -80,7 +80,7 @@ export class Time implements ITime {
80
80
  get smoothedDeltaTime() { return 1 / this._smoothedFps; }
81
81
 
82
82
 
83
- private clock = new Clock();
83
+ private clock = new Timer();
84
84
  private _smoothedFps: number = 0;
85
85
  private _smoothedDeltaTime: number = 0;
86
86
  private readonly _fpsSamples: number[] = [];
@@ -95,6 +95,7 @@ export class Time implements ITime {
95
95
  * @internal
96
96
  */
97
97
  update() {
98
+ this.clock.update();
98
99
  this.deltaTime = this.clock.getDelta();
99
100
  // clamp delta time because if tab is not active clock.getDelta can get pretty big
100
101
  this.deltaTime = Math.min(.1, this.deltaTime);
@@ -2,7 +2,7 @@ import { CubeReflectionMapping, CubeUVReflectionMapping, LinearSRGBColorSpace, S
2
2
  import { EXRLoader } from "three/examples/jsm/loaders/EXRLoader.js";
3
3
  import { type GLTF, type GLTFLoaderPlugin, GLTFParser } from "three/examples/jsm/loaders/GLTFLoader.js";
4
4
  import { KTX2Loader } from "three/examples/jsm/loaders/KTX2Loader.js";
5
- import { RGBELoader } from "three/examples/jsm/loaders/RGBELoader.js";
5
+ import { HDRLoader } from "three/examples/jsm/loaders/HDRLoader.js";
6
6
 
7
7
  import { isDevEnvironment } from "../debug/index.js";
8
8
  import { type ILightDataRegistry } from "../engine_lightdata.js";
@@ -83,11 +83,11 @@ export class NEEDLE_lightmaps implements GLTFLoaderPlugin {
83
83
  const path = resolveUrl(this.source, entry.pointer);
84
84
  const isPMREM = path.endsWith(".pmrem.ktx2");
85
85
 
86
- let loader: TextureLoader | EXRLoader | RGBELoader | KTX2Loader;
86
+ let loader: TextureLoader | EXRLoader | HDRLoader | KTX2Loader;
87
87
  if (path.endsWith(".exr"))
88
88
  loader = new EXRLoader(this.parser.options.manager);
89
89
  else if (path.endsWith(".hdr"))
90
- loader = new RGBELoader(this.parser.options.manager);
90
+ loader = new HDRLoader(this.parser.options.manager);
91
91
  else if (isPMREM)
92
92
  loader = (this.parser.options as any).ktx2Loader; // We re-use the KTX2Loader configured on the GLTFLoader, which has GPU support detection built in
93
93
  else
@@ -61,8 +61,9 @@ export async function getIconTexture(str: string): Promise<Texture | null> {
61
61
  const data = canvas.toDataURL();
62
62
  const texture = new Texture();
63
63
  texture.name = str + " icon";
64
- texture.image = new Image();
65
- texture.image.src = data;
64
+ const img = new Image();
65
+ (texture as any).image = img;
66
+ img.src = data;
66
67
  texture.needsUpdate = true;
67
68
  textures.set(str, texture);
68
69
  return texture;
@@ -451,7 +451,7 @@ export class AudioSource extends Behaviour {
451
451
  sound.stop();
452
452
 
453
453
  if (buffer) sound.setBuffer(buffer);
454
- sound.loop = this._loop;
454
+ sound.setLoop(this._loop);
455
455
  if (this.context.application.muted) sound.setVolume(0);
456
456
  else sound.setVolume(this.volume);
457
457
  sound.autoplay = this.shouldPlay && AudioSource.userInteractionRegistered;
@@ -187,8 +187,8 @@ export class Light extends Behaviour implements ILight {
187
187
  set shadowNearPlane(val: number) {
188
188
  if (val === this._shadowNearPlane) return;
189
189
  this._shadowNearPlane = val;
190
- if (this.light?.shadow?.camera !== undefined) {
191
- const cam = this.light.shadow.camera as OrthographicCamera;
190
+ if (this.shadowLight?.shadow?.camera !== undefined) {
191
+ const cam = this.shadowLight!.shadow.camera as OrthographicCamera;
192
192
  cam.near = val;
193
193
  }
194
194
  }
@@ -202,9 +202,9 @@ export class Light extends Behaviour implements ILight {
202
202
  set shadowBias(val: number) {
203
203
  if (val === this._shadowBias) return;
204
204
  this._shadowBias = val;
205
- if (this.light?.shadow?.bias !== undefined) {
206
- this.light.shadow.bias = val;
207
- this.light.shadow.needsUpdate = true;
205
+ if (this.shadowLight?.shadow?.bias !== undefined) {
206
+ this.shadowLight!.shadow.bias = val;
207
+ this.shadowLight!.shadow.needsUpdate = true;
208
208
  }
209
209
  }
210
210
  get shadowBias(): number { return this._shadowBias; }
@@ -217,9 +217,9 @@ export class Light extends Behaviour implements ILight {
217
217
  set shadowNormalBias(val: number) {
218
218
  if (val === this._shadowNormalBias) return;
219
219
  this._shadowNormalBias = val;
220
- if (this.light?.shadow?.normalBias !== undefined) {
221
- this.light.shadow.normalBias = val;
222
- this.light.shadow.needsUpdate = true;
220
+ if (this.shadowLight?.shadow?.normalBias !== undefined) {
221
+ this.shadowLight!.shadow.normalBias = val;
222
+ this.shadowLight!.shadow.needsUpdate = true;
223
223
  }
224
224
  }
225
225
  get shadowNormalBias(): number { return this._shadowNormalBias; }
@@ -268,7 +268,7 @@ export class Light extends Behaviour implements ILight {
268
268
  */
269
269
  @serializable()
270
270
  get shadowDistance(): number {
271
- const light = this.light;
271
+ const light = this.shadowLight;
272
272
  if (light?.shadow) {
273
273
  const cam = light.shadow.camera as OrthographicCamera;
274
274
  return cam.far;
@@ -277,7 +277,7 @@ export class Light extends Behaviour implements ILight {
277
277
  }
278
278
  set shadowDistance(val: number) {
279
279
  this._shadowDistance = val;
280
- const light = this.light;
280
+ const light = this.shadowLight;
281
281
  if (light?.shadow) {
282
282
  const cam = light.shadow.camera as OrthographicCamera;
283
283
  cam.far = val;
@@ -294,7 +294,7 @@ export class Light extends Behaviour implements ILight {
294
294
  */
295
295
  @serializable()
296
296
  get shadowResolution(): number {
297
- const light = this.light;
297
+ const light = this.shadowLight;
298
298
  if (light?.shadow) {
299
299
  return light.shadow.mapSize.x;
300
300
  }
@@ -303,7 +303,7 @@ export class Light extends Behaviour implements ILight {
303
303
  set shadowResolution(val: number) {
304
304
  if (val === this._shadowResolution) return;
305
305
  this._shadowResolution = val;
306
- const light = this.light;
306
+ const light = this.shadowLight;
307
307
  if (light?.shadow) {
308
308
  light.shadow.mapSize.set(val, val);
309
309
  light.shadow.needsUpdate = true;
@@ -337,6 +337,14 @@ export class Light extends Behaviour implements ILight {
337
337
  */
338
338
  private light: ThreeLight | undefined = undefined;
339
339
 
340
+ /** Access the light as a shadow-casting light (DirectionalLight, SpotLight, PointLight).
341
+ * In r183 types, the `shadow` property is only on specific light subclasses. */
342
+ private get shadowLight(): (DirectionalLight | SpotLight | PointLight) | undefined {
343
+ const l = this.light;
344
+ if (l && 'shadow' in l) return l as DirectionalLight | SpotLight | PointLight;
345
+ return undefined;
346
+ }
347
+
340
348
  /**
341
349
  * Gets the world position of the light
342
350
  * @param vec Vector3 to store the result
@@ -458,29 +466,29 @@ export class Light extends Behaviour implements ILight {
458
466
  }
459
467
  else this.light.castShadow = false;
460
468
 
461
- if (this.light.shadow) {
469
+ if (this.shadowLight?.shadow) {
462
470
  // shadow intensity is currently not a thing: https://github.com/mrdoob/three.js/pull/14087
463
471
  if (this._shadowResolution !== undefined && this._shadowResolution > 4) {
464
- this.light.shadow.mapSize.width = this._shadowResolution;
465
- this.light.shadow.mapSize.height = this._shadowResolution;
472
+ this.shadowLight!.shadow.mapSize.width = this._shadowResolution;
473
+ this.shadowLight!.shadow.mapSize.height = this._shadowResolution;
466
474
  }
467
475
  else {
468
- this.light.shadow.mapSize.width = 2048;
469
- this.light.shadow.mapSize.height = 2048;
476
+ this.shadowLight!.shadow.mapSize.width = 2048;
477
+ this.shadowLight!.shadow.mapSize.height = 2048;
470
478
  }
471
- // this.light.shadow.needsUpdate = true;
472
- // console.log(this.light.shadow.mapSize);
479
+ // this.shadowLight!.shadow.needsUpdate = true;
480
+ // console.log(this.shadowLight!.shadow.mapSize);
473
481
  // return;
474
482
 
475
483
  if (debug)
476
484
  console.log("Override shadow bias?", this._overrideShadowBiasSettings, this.shadowBias, this.shadowNormalBias);
477
485
 
478
- this.light.shadow.bias = this.shadowBias;
479
- this.light.shadow.normalBias = this.shadowNormalBias;
486
+ this.shadowLight!.shadow.bias = this.shadowBias;
487
+ this.shadowLight!.shadow.normalBias = this.shadowNormalBias;
480
488
 
481
489
  this.updateShadowSoftHard();
482
490
 
483
- const cam = this.light.shadow.camera as OrthographicCamera;
491
+ const cam = this.shadowLight!.shadow.camera as OrthographicCamera;
484
492
  cam.near = this.shadowNearPlane;
485
493
  // use shadow distance that was set explictly (if any)
486
494
  if (this._shadowDistance !== undefined && typeof this._shadowDistance === "number")
@@ -508,7 +516,7 @@ export class Light extends Behaviour implements ILight {
508
516
  cam.top *= sy;
509
517
  cam.bottom *= sy;
510
518
  }
511
- this.light.shadow.needsUpdate = true;
519
+ this.shadowLight!.shadow.needsUpdate = true;
512
520
 
513
521
  if (debug)
514
522
  this.context.scene.add(new CameraHelper(cam));
@@ -551,15 +559,15 @@ export class Light extends Behaviour implements ILight {
551
559
  */
552
560
  private updateShadowSoftHard() {
553
561
  if (!this.light) return;
554
- if (!this.light.shadow) return;
562
+ if (!this.shadowLight!.shadow) return;
555
563
  if (this.shadows === LightShadows.Soft) {
556
- // const radius = this.light.shadow.mapSize.width / 1024 * 5;
564
+ // const radius = this.shadowLight!.shadow.mapSize.width / 1024 * 5;
557
565
  // const samples = Mathf.clamp(Math.round(radius), 2, 10);
558
- // this.light.shadow.radius = radius;
559
- // this.light.shadow.blurSamples = samples;
566
+ // this.shadowLight!.shadow.radius = radius;
567
+ // this.shadowLight!.shadow.blurSamples = samples;
560
568
  // if (isMobileDevice()) {
561
- // this.light.shadow.radius *= .5;
562
- // this.light.shadow.blurSamples = Math.floor(this.light.shadow.blurSamples * .5);
569
+ // this.shadowLight!.shadow.radius *= .5;
570
+ // this.shadowLight!.shadow.blurSamples = Math.floor(this.shadowLight!.shadow.blurSamples * .5);
563
571
  // }
564
572
  // if (Light.allowChangingRendererShadowMapType) {
565
573
  // if(this.context.renderer.shadowMap.type !== VSMShadowMap){
@@ -569,8 +577,8 @@ export class Light extends Behaviour implements ILight {
569
577
  // }
570
578
  }
571
579
  else {
572
- this.light.shadow.radius = 1;
573
- this.light.shadow.blurSamples = 1;
580
+ this.shadowLight!.shadow.radius = 1;
581
+ this.shadowLight!.shadow.blurSamples = 1;
574
582
  }
575
583
  }
576
584
 
@@ -275,14 +275,14 @@ export class OrbitControls extends Behaviour implements ICameraController {
275
275
  * Set this to a different element to make the OrbitControls listen to that element instead.
276
276
  */
277
277
  get targetElement(): HTMLElement | null {
278
- return this._controls?.domElement ?? this._targetElement;
278
+ return this._controls?.domElement as HTMLElement ?? this._targetElement;
279
279
  }
280
280
  set targetElement(value: HTMLElement | null) {
281
281
  this._targetElement = value;
282
282
  if (this._controls && this._controls.domElement !== value) {
283
283
  this._controls.disconnect();
284
284
  this._controls.domElement = value;
285
- this._controls.connect();
285
+ if (value) this._controls.connect(value);
286
286
  }
287
287
  }
288
288
  private _targetElement: HTMLElement | null = null;
@@ -832,7 +832,7 @@ class USDZExporter {
832
832
 
833
833
  // Change: we need to always read back the texture now, otherwise the unpremultiplied workflow doesn't work.
834
834
  let img: ImageReadbackResult = {
835
- imageData: texture.image
835
+ imageData: texture.image as ImageData
836
836
  };
837
837
 
838
838
  Progress.report("export-usdz-textures", { message: "read back texture", autoStep: true });
@@ -1516,7 +1516,7 @@ function getGeometryName(geometry: BufferGeometry, _fallbackName: string) {
1516
1516
  }
1517
1517
 
1518
1518
  function getMaterialName(material: Material) {
1519
- return makeNameSafe(material.name || 'Material') + "_" + material.id;
1519
+ return makeNameSafe(material.name || 'Material') + "_" + (material as any).id;
1520
1520
  }
1521
1521
 
1522
1522
  function getPathToSkeleton(bone: Object3D, assumedRoot: Object3D) {
@@ -62,7 +62,7 @@ export class RegisteredAnimationInfo {
62
62
  try {
63
63
  for (const track of this.clip?.tracks ?? []) {
64
64
  const parsedPath = PropertyBinding.parseTrackName(track.name);
65
- let animationTarget = PropertyBinding.findNode(this.root, parsedPath.nodeName);
65
+ let animationTarget = PropertyBinding.findNode(this.root, parsedPath.nodeName) as Object3D | null;
66
66
  if (animationTarget) {
67
67
  if (!highestRoot) highestRoot = animationTarget;
68
68
  else {
@@ -218,9 +218,10 @@ export class TransformData {
218
218
  const scale = new Vector3(1, 1, 1);
219
219
  const object = this.target;
220
220
 
221
- const positionInterpolant: Interpolant | undefined = generatePos ? this.pos?.createInterpolant() : undefined;
222
- const rotationInterpolant: Interpolant | undefined = generateRot ? this.rot?.createInterpolant() : undefined;
223
- const scaleInterpolant: Interpolant | undefined = generateScale ? this.scale?.createInterpolant() : undefined;
221
+ // createInterpolant exists at runtime but was removed from types in r183
222
+ const positionInterpolant: Interpolant | undefined = generatePos ? (this.pos as any)?.createInterpolant() : undefined;
223
+ const rotationInterpolant: Interpolant | undefined = generateRot ? (this.rot as any)?.createInterpolant() : undefined;
224
+ const scaleInterpolant: Interpolant | undefined = generateScale ? (this.scale as any)?.createInterpolant() : undefined;
224
225
 
225
226
  if (!positionInterpolant) translation.set(object.position.x, object.position.y, object.position.z);
226
227
  if (!rotationInterpolant) rotation.set(object.quaternion.x, object.quaternion.y, object.quaternion.z, object.quaternion.w);
@@ -435,7 +436,7 @@ export class AnimationExtension implements IUSDExporterExtension {
435
436
  // const sortedTracks = clip.tracks.filter(x => !!x).sort((a, _b) => a.name.endsWith("position") || a.name.endsWith("quaternion") || a.name.endsWith("scale") ? -1 : 1);
436
437
  for (const track of clip.tracks) {
437
438
  const parsedPath = PropertyBinding.parseTrackName(track.name);
438
- const animationTarget = PropertyBinding.findNode(root, parsedPath.nodeName);
439
+ const animationTarget = PropertyBinding.findNode(root, parsedPath.nodeName) as Object3D | null;
439
440
 
440
441
  if (!animationTarget) {
441
442
  console.warn("no object found for track", track.name, "using " + root.name + " instead");
@@ -388,7 +388,7 @@ export class ChangeMaterialOnClick extends Behaviour implements IPointerClickHan
388
388
  }
389
389
 
390
390
  private static getMaterialName(material: Material) {
391
- return makeNameSafeForUSD(material.name || 'Material') + "_" + material.id;
391
+ return makeNameSafeForUSD(material.name || 'Material') + "_" + (material as any).id;
392
392
  }
393
393
 
394
394
  static variantSwitchIndex: number = 0;
@@ -1,5 +1,5 @@
1
1
  import type { Effect, EffectComposer, Pass, ToneMappingEffect as _TonemappingEffect } from "postprocessing";
2
- import { Camera as Camera3, DepthTexture, HalfFloatType, LinearFilter, NoToneMapping, Scene, Source, Texture, ToneMapping, WebGLRenderTarget } from "three";
2
+ import { Camera as Camera3, DepthTexture, HalfFloatType, LinearFilter, NoToneMapping, PixelFormat, Scene, Source, Texture, ToneMapping, WebGLRenderTarget } from "three";
3
3
 
4
4
  import { isDevEnvironment, showBalloonWarning } from "../../engine/debug/index.js";
5
5
  // import { internal_SetSharpeningEffectModule } from "./Effects/Sharpening.js";
@@ -417,7 +417,7 @@ export class PostProcessingHandler {
417
417
  this._customInputBuffer?.dispose();
418
418
 
419
419
  this._customInputBuffer = new WebGLRenderTarget(inputBuffer.width, inputBuffer.height, {
420
- format: inputBuffer.texture.format,
420
+ format: inputBuffer.texture.format as PixelFormat,
421
421
  type: HalfFloatType,
422
422
  depthBuffer: inputBuffer.depthBuffer,
423
423
  depthTexture: inputBuffer.depthTexture
@@ -577,7 +577,7 @@ export class PostProcessingHandler {
577
577
  // Assigning a new Source breaks the deduplication so they get separate GL textures.
578
578
  const composerDepthTexture = (composer as any).depthTexture as DepthTexture | null;
579
579
  if (composerDepthTexture) {
580
- composerDepthTexture.source = new Source({ width: 0, height: 0 });
580
+ composerDepthTexture.source = new Source({ width: 0, height: 0 } as any);
581
581
  composerDepthTexture.needsUpdate = true;
582
582
  }
583
583
 
@@ -700,8 +700,8 @@ export class AudioTrackHandler extends TrackHandler {
700
700
  }
701
701
  if (AudioSource.userInteractionRegistered === false) continue;
702
702
  if (audio === null || !audio.buffer) continue;
703
- audio.playbackRate = this.director.context.time.timeScale * this.director.speed;
704
- audio.loop = asset.loop;
703
+ (audio as any).playbackRate = this.director.context.time.timeScale * this.director.speed;
704
+ (audio as any).loop = asset.loop;
705
705
  if (time >= model.start && time <= model.end && time < this.director.duration) {
706
706
  if (!audio.isPlaying || !this.director.isPlaying) {
707
707
  // if the timeline is paused we trigger the audio clip once when the model is entered
@@ -132,7 +132,7 @@ export class Canvas extends UIRootComponent implements ICanvas {
132
132
  this._renderMode = val;
133
133
  this.onRenderSettingsChanged();
134
134
  }
135
- private _renderMode: RenderMode = RenderMode.Undefined;
135
+ private _renderMode: RenderMode = RenderMode.WorldSpace;
136
136
 
137
137
  private _rootCanvas!: Canvas;
138
138
 
@@ -159,7 +159,7 @@ export class Canvas extends UIRootComponent implements ICanvas {
159
159
  worldCamera?: Camera;
160
160
 
161
161
  @serializable()
162
- planeDistance: number = -1;
162
+ planeDistance: number = 100;
163
163
 
164
164
  awake() {
165
165
  //@ts-ignore
@@ -35,8 +35,12 @@ export class Graphic extends BaseUIComponent implements IGraphic, IRectTransform
35
35
  if (!this._color) this._color = new RGBAColor(1, 1, 1, 1);
36
36
  return this._color;
37
37
  }
38
- set color(col: RGBAColor) {
39
- const changed = !this._color || this._color.r !== col.r || this._color.g !== col.g || this._color.b !== col.b || this._color.alpha !== col.alpha;
38
+ set color(col: RGBAColor | Color) {
39
+ const changed = !this._color
40
+ || this._color.r !== col.r
41
+ || this._color.g !== col.g
42
+ || this._color.b !== col.b
43
+ || ("alpha" in col ? this._color.alpha !== col.alpha : this._color.alpha !== 1);
40
44
  if (!changed) return;
41
45
  if (!this._color) {
42
46
  this._color = new RGBAColor(1, 1, 1, 1);
@@ -44,6 +48,7 @@ export class Graphic extends BaseUIComponent implements IGraphic, IRectTransform
44
48
  this._color.copy(col);
45
49
  this.onColorChanged();
46
50
  }
51
+ private _color: RGBAColor = null!;
47
52
 
48
53
  private _alphaFactor: number = 1;
49
54
  setAlphaFactor(factor: number) {
@@ -88,7 +93,6 @@ export class Graphic extends BaseUIComponent implements IGraphic, IRectTransform
88
93
  raycastTarget: boolean = true;
89
94
 
90
95
  protected uiObject: ThreeMeshUI.Block | null = null;
91
- private _color: RGBAColor = null!;
92
96
 
93
97
  private _rect: RectTransform | null = null;
94
98
 
@@ -77,7 +77,7 @@ export class Image extends MaskableGraphic {
77
77
  }
78
78
  // this is a hack/workaround for production builds where the name of the sprite is missing
79
79
  // need to remove this!!!!
80
- if (!sprite?.texture?.name?.length && sprite?.texture?.image?.width === 32 && sprite?.texture?.image?.height === 32)
80
+ if (!sprite?.texture?.name?.length && (sprite?.texture?.image as any)?.width === 32 && (sprite?.texture?.image as any)?.height === 32)
81
81
  return true;
82
82
  return false;
83
83
  }