@needle-tools/engine 5.1.0-alpha → 5.1.0-canary.0d9f44e

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 (195) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +9 -1
  3. package/SKILL.md +39 -21
  4. package/components.needle.json +1 -1
  5. package/dist/{gltf-progressive-DJBMx-zB.umd.cjs → gltf-progressive-BmblPzFj.umd.cjs} +4 -4
  6. package/dist/{gltf-progressive-BryRjllq.min.js → gltf-progressive-CN_mbb66.min.js} +2 -2
  7. package/dist/{gltf-progressive-Cl167Vjx.js → gltf-progressive-DUlhxdv4.js} +5 -2
  8. package/dist/{needle-engine.bundle-CwhCzjep.js → needle-engine.bundle-B35n_IHX.js} +13637 -13081
  9. package/dist/{needle-engine.bundle-wM-BWPX9.umd.cjs → needle-engine.bundle-CDj15wRB.umd.cjs} +250 -174
  10. package/dist/needle-engine.bundle-D5zzggEG.min.js +1732 -0
  11. package/dist/needle-engine.d.ts +316 -26
  12. package/dist/needle-engine.js +569 -563
  13. package/dist/needle-engine.min.js +1 -1
  14. package/dist/needle-engine.umd.cjs +1 -1
  15. package/dist/{postprocessing-B_9sKVU7.min.js → postprocessing-B571qGWR.min.js} +34 -34
  16. package/dist/{postprocessing-WDc9WwI3.js → postprocessing-CfrLAbLX.js} +0 -1
  17. package/dist/{postprocessing-B2wb6pzI.umd.cjs → postprocessing-CiGkAeM9.umd.cjs} +17 -17
  18. package/dist/three-examples.js +4289 -3778
  19. package/dist/three-examples.min.js +301 -14
  20. package/dist/three-examples.umd.cjs +301 -14
  21. package/dist/{vendor-CAcsI0eU.js → vendor-BFrMaK9q.js} +8983 -9136
  22. package/dist/vendor-CJmyOrCq.min.js +1116 -0
  23. package/dist/vendor-DkMW3WY4.umd.cjs +1116 -0
  24. package/lib/engine/api.d.ts +12 -0
  25. package/lib/engine/api.js +2 -0
  26. package/lib/engine/api.js.map +1 -1
  27. package/lib/engine/debug/debug_environment.js +1 -1
  28. package/lib/engine/debug/debug_environment.js.map +1 -1
  29. package/lib/engine/engine_application.js +8 -6
  30. package/lib/engine/engine_application.js.map +1 -1
  31. package/lib/engine/engine_components.js +5 -1
  32. package/lib/engine/engine_components.js.map +1 -1
  33. package/lib/engine/engine_constants.js +6 -0
  34. package/lib/engine/engine_constants.js.map +1 -1
  35. package/lib/engine/engine_context.d.ts +31 -2
  36. package/lib/engine/engine_context.js +43 -2
  37. package/lib/engine/engine_context.js.map +1 -1
  38. package/lib/engine/engine_context_registry.js +1 -1
  39. package/lib/engine/engine_context_registry.js.map +1 -1
  40. package/lib/engine/engine_init.js +7 -0
  41. package/lib/engine/engine_init.js.map +1 -1
  42. package/lib/engine/engine_input.d.ts +3 -2
  43. package/lib/engine/engine_input.js +3 -2
  44. package/lib/engine/engine_input.js.map +1 -1
  45. package/lib/engine/engine_license.d.ts +2 -0
  46. package/lib/engine/engine_license.js +25 -15
  47. package/lib/engine/engine_license.js.map +1 -1
  48. package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
  49. package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
  50. package/lib/engine/engine_networking_blob.d.ts +1 -1
  51. package/lib/engine/engine_networking_blob.js +5 -11
  52. package/lib/engine/engine_networking_blob.js.map +1 -1
  53. package/lib/engine/engine_physics_rapier.d.ts +3 -0
  54. package/lib/engine/engine_physics_rapier.js +13 -10
  55. package/lib/engine/engine_physics_rapier.js.map +1 -1
  56. package/lib/engine/engine_pmrem.js +2 -2
  57. package/lib/engine/engine_pmrem.js.map +1 -1
  58. package/lib/engine/engine_scenedata.d.ts +34 -0
  59. package/lib/engine/engine_scenedata.js +135 -0
  60. package/lib/engine/engine_scenedata.js.map +1 -0
  61. package/lib/engine/engine_ssr.d.ts +18 -0
  62. package/lib/engine/engine_ssr.js +40 -0
  63. package/lib/engine/engine_ssr.js.map +1 -0
  64. package/lib/engine/engine_three_utils.d.ts +14 -7
  65. package/lib/engine/engine_three_utils.js +14 -7
  66. package/lib/engine/engine_three_utils.js.map +1 -1
  67. package/lib/engine/engine_types.d.ts +2 -0
  68. package/lib/engine/engine_types.js.map +1 -1
  69. package/lib/engine/engine_utils.js +4 -2
  70. package/lib/engine/engine_utils.js.map +1 -1
  71. package/lib/engine/engine_utils_hash.d.ts +9 -0
  72. package/lib/engine/engine_utils_hash.js +112 -0
  73. package/lib/engine/engine_utils_hash.js.map +1 -0
  74. package/lib/engine/webcomponents/logo-element.d.ts +10 -1
  75. package/lib/engine/webcomponents/logo-element.js +2 -1
  76. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  77. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +12 -4
  78. package/lib/engine/webcomponents/needle menu/needle-menu.js +2 -1
  79. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  80. package/lib/engine/webcomponents/needle-button.d.ts +15 -1
  81. package/lib/engine/webcomponents/needle-button.js +2 -1
  82. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  83. package/lib/engine/webcomponents/needle-engine.d.ts +7 -1
  84. package/lib/engine/webcomponents/needle-engine.js +2 -1
  85. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  86. package/lib/engine/xr/NeedleXRSession.d.ts +1 -0
  87. package/lib/engine/xr/NeedleXRSession.js +5 -5
  88. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  89. package/lib/engine/xr/events.d.ts +30 -3
  90. package/lib/engine/xr/events.js +38 -0
  91. package/lib/engine/xr/events.js.map +1 -1
  92. package/lib/engine/xr/init.js +1 -7
  93. package/lib/engine/xr/init.js.map +1 -1
  94. package/lib/engine-components/AnimatorController.d.ts +135 -2
  95. package/lib/engine-components/AnimatorController.js +218 -2
  96. package/lib/engine-components/AnimatorController.js.map +1 -1
  97. package/lib/engine-components/GroundProjection.d.ts +1 -0
  98. package/lib/engine-components/GroundProjection.js +184 -48
  99. package/lib/engine-components/GroundProjection.js.map +1 -1
  100. package/lib/engine-components/Light.d.ts +25 -8
  101. package/lib/engine-components/Light.js +132 -27
  102. package/lib/engine-components/Light.js.map +1 -1
  103. package/lib/engine-components/RigidBody.js +3 -3
  104. package/lib/engine-components/RigidBody.js.map +1 -1
  105. package/lib/engine-components/SceneSwitcher.js +2 -0
  106. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  107. package/lib/engine-components/api.d.ts +1 -0
  108. package/lib/engine-components/api.js +1 -0
  109. package/lib/engine-components/api.js.map +1 -1
  110. package/lib/engine-components/codegen/components.d.ts +1 -0
  111. package/lib/engine-components/codegen/components.js +1 -0
  112. package/lib/engine-components/codegen/components.js.map +1 -1
  113. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  114. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -2
  115. package/lib/engine-components/postprocessing/Effects/Sharpening.js.map +1 -1
  116. package/lib/engine-components/postprocessing/PostProcessingHandler.js +5 -6
  117. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  118. package/lib/engine-components/web/ScrollFollow.d.ts +0 -1
  119. package/lib/engine-components/web/ScrollFollow.js +3 -2
  120. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  121. package/lib/needle-engine.d.ts +1 -0
  122. package/lib/needle-engine.js +1 -0
  123. package/lib/needle-engine.js.map +1 -1
  124. package/package.json +7 -5
  125. package/plugins/common/logger.js +42 -19
  126. package/plugins/dts-generator/dts.codegen.js +334 -0
  127. package/plugins/dts-generator/dts.scan.js +99 -0
  128. package/plugins/dts-generator/dts.writer.js +59 -0
  129. package/plugins/dts-generator/glb.discovery.js +279 -0
  130. package/plugins/dts-generator/glb.extractor.js +215 -0
  131. package/plugins/dts-generator/glb.reader.js +167 -0
  132. package/plugins/dts-generator/index.js +36 -0
  133. package/plugins/dts-generator/manifest.types.js +174 -0
  134. package/plugins/types/index.d.ts +2 -1
  135. package/plugins/types/needle-bindings.d.ts +30 -0
  136. package/plugins/types/userconfig.d.ts +21 -2
  137. package/plugins/vite/asap.js +1 -1
  138. package/plugins/vite/dependency-watcher.d.ts +2 -2
  139. package/plugins/vite/dependency-watcher.js +3 -4
  140. package/plugins/vite/drop.d.ts +2 -2
  141. package/plugins/vite/drop.js +3 -4
  142. package/plugins/vite/dts-generator.d.ts +7 -0
  143. package/plugins/vite/dts-generator.js +191 -0
  144. package/plugins/vite/index.d.ts +10 -3
  145. package/plugins/vite/index.js +27 -10
  146. package/plugins/vite/logger.client.js +4 -3
  147. package/plugins/vite/logging.js +2 -2
  148. package/plugins/vite/meta.js +4 -2
  149. package/plugins/vite/poster.d.ts +2 -2
  150. package/plugins/vite/poster.js +3 -5
  151. package/plugins/vite/reload.d.ts +2 -2
  152. package/plugins/vite/reload.js +5 -5
  153. package/src/engine/api.ts +15 -1
  154. package/src/engine/debug/debug_environment.ts +1 -1
  155. package/src/engine/engine_application.ts +8 -6
  156. package/src/engine/engine_components.ts +7 -4
  157. package/src/engine/engine_constants.ts +11 -6
  158. package/src/engine/engine_context.ts +47 -2
  159. package/src/engine/engine_context_registry.ts +1 -1
  160. package/src/engine/engine_init.ts +6 -0
  161. package/src/engine/engine_input.ts +3 -2
  162. package/src/engine/engine_license.ts +23 -19
  163. package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
  164. package/src/engine/engine_networking_blob.ts +5 -11
  165. package/src/engine/engine_physics_rapier.ts +14 -12
  166. package/src/engine/engine_pmrem.ts +3 -3
  167. package/src/engine/engine_scenedata.ts +133 -0
  168. package/src/engine/engine_ssr.ts +48 -0
  169. package/src/engine/engine_three_utils.ts +15 -7
  170. package/src/engine/engine_types.ts +2 -0
  171. package/src/engine/engine_utils.ts +3 -2
  172. package/src/engine/engine_utils_hash.ts +65 -0
  173. package/src/engine/webcomponents/logo-element.ts +10 -1
  174. package/src/engine/webcomponents/needle menu/needle-menu.ts +11 -2
  175. package/src/engine/webcomponents/needle-button.ts +15 -1
  176. package/src/engine/webcomponents/needle-engine.ts +8 -1
  177. package/src/engine/xr/NeedleXRSession.ts +6 -6
  178. package/src/engine/xr/events.ts +44 -1
  179. package/src/engine/xr/init.ts +0 -7
  180. package/src/engine-components/AnimatorController.ts +286 -4
  181. package/src/engine-components/GroundProjection.ts +226 -52
  182. package/src/engine-components/Light.ts +132 -27
  183. package/src/engine-components/RigidBody.ts +3 -3
  184. package/src/engine-components/SceneSwitcher.ts +1 -0
  185. package/src/engine-components/api.ts +1 -0
  186. package/src/engine-components/codegen/components.ts +1 -0
  187. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  188. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -2
  189. package/src/engine-components/postprocessing/PostProcessingHandler.ts +4 -8
  190. package/src/engine-components/web/ScrollFollow.ts +2 -2
  191. package/src/needle-engine.ts +2 -0
  192. package/src/vite-env.d.ts +16 -0
  193. package/dist/needle-engine.bundle-qDahLTqW.min.js +0 -1656
  194. package/dist/vendor-CEM38hLE.umd.cjs +0 -1116
  195. package/dist/vendor-HRlxIBga.min.js +0 -1116
@@ -1,7 +1,9 @@
1
1
  import { CameraHelper, Color, DirectionalLight, DirectionalLightHelper, Light as ThreeLight, OrthographicCamera, PointLight, SpotLight, Vector3 } from "three";
2
+ import { CSM } from "three/examples/jsm/csm/CSM.js";
3
+ import { CSMHelper } from "three/examples/jsm/csm/CSMHelper.js";
2
4
 
3
5
  import { serializable } from "../engine/engine_serialization_decorator.js";
4
- import { FrameEvent } from "../engine/engine_setup.js";
6
+
5
7
  import { setWorldPositionXYZ } from "../engine/engine_three_utils.js";
6
8
  import type { ILight } from "../engine/engine_types.js";
7
9
  import { getParam } from "../engine/engine_utils.js";
@@ -106,11 +108,40 @@ enum LightShadows {
106
108
  export class Light extends Behaviour implements ILight {
107
109
 
108
110
  /**
109
- * The type of light (spot, directional, point, etc.)
110
- * Can not be changed at runtime.
111
+ * The type of light as a lowercase string: `"directional"`, `"point"`, `"spot"`.
112
+ * Implements {@link ILight.type}. Can not be changed at runtime.
111
113
  */
114
+ get type(): ILight["type"] {
115
+ return this._type;
116
+ }
117
+
118
+ /** Numeric LightType serialized from Unity/Blender — converts to string on write */
112
119
  @serializable()
113
- private type: LightType = 0;
120
+ set type(value: LightType | ILight["type"]) {
121
+ if (this.light && this.__didAwake) {
122
+ throw new Error("Changing the light type at runtime is not supported");
123
+ }
124
+ switch (value) {
125
+ case LightType.Directional:
126
+ this._type = "directional";
127
+ break;
128
+ case LightType.Point:
129
+ this._type = "point";
130
+ break;
131
+ case LightType.Spot:
132
+ this._type = "spot";
133
+ break;
134
+ case "directional":
135
+ case "point":
136
+ case "spot":
137
+ this._type = value;
138
+ break;
139
+ default:
140
+ throw new Error("Invalid light type: " + value);
141
+ }
142
+ }
143
+ private _type: ILight["type"] = "point";
144
+
114
145
 
115
146
  /**
116
147
  * The maximum distance the light affects.
@@ -174,6 +205,9 @@ export class Light extends Behaviour implements ILight {
174
205
  if (this.light !== undefined) {
175
206
  this.light.color = val;
176
207
  }
208
+ if (this._csm) {
209
+ for (const l of this._csm.lights) l.color.copy(val);
210
+ }
177
211
  }
178
212
  get color(): Color {
179
213
  if (this.light) return this.light.color;
@@ -259,6 +293,9 @@ export class Light extends Behaviour implements ILight {
259
293
  if (this.light) {
260
294
  this.light.intensity = val;
261
295
  }
296
+ if (this._csm) {
297
+ for (const l of this._csm.lights) l.intensity = val;
298
+ }
262
299
  if (debug) console.log("Set light intensity to " + this._intensity, val, this)
263
300
  }
264
301
  get intensity(): number { return this._intensity; }
@@ -312,6 +349,24 @@ export class Light extends Behaviour implements ILight {
312
349
  }
313
350
  private _shadowResolution?: number = undefined;
314
351
 
352
+ /**
353
+ * Number of shadow cascade levels (only used when `useCascades` is true)
354
+ */
355
+ @serializable()
356
+ cascades: number = 3;
357
+
358
+ /**
359
+ * Cascade split mode (only used when `useCascades` is true):
360
+ * - `practical` — balanced (default, recommended)
361
+ * - `logarithmic` — more resolution close up
362
+ * - `uniform` — equal splits
363
+ */
364
+ @serializable()
365
+ cascadeMode: "practical" | "logarithmic" | "uniform" = "practical";
366
+
367
+ private _csm?: CSM;
368
+ private _csmHelper?: CSMHelper;
369
+
315
370
  /**
316
371
  * Whether this light's illumination is entirely baked into lightmaps
317
372
  */
@@ -345,7 +400,7 @@ export class Light extends Behaviour implements ILight {
345
400
  */
346
401
  public getWorldPosition(vec: Vector3): Vector3 {
347
402
  if (this.light) {
348
- if (this.type === LightType.Directional) {
403
+ if (this.type === "directional") {
349
404
  return this.light.getWorldPosition(vec).multiplyScalar(1);
350
405
  }
351
406
  return this.light.getWorldPosition(vec);
@@ -372,12 +427,21 @@ export class Light extends Behaviour implements ILight {
372
427
  else if (this.light.parent !== this.gameObject)
373
428
  this.gameObject.add(this.light);
374
429
  }
375
- if (this.type === LightType.Directional)
376
- this.startCoroutine(this.updateMainLightRoutine(), FrameEvent.LateUpdate);
430
+ this.context.lights.add(this);
377
431
  }
378
432
 
379
433
  onDisable() {
380
434
  if (debug) console.log("DISABLE LIGHT", this.name);
435
+ this.context.lights.delete(this);
436
+ if (this._csm) {
437
+ this._csm.remove();
438
+ this._csm.dispose();
439
+ this._csm = undefined;
440
+ if (this._csmHelper) {
441
+ this._csmHelper.removeFromParent();
442
+ this._csmHelper = undefined;
443
+ }
444
+ }
381
445
  if (this.light) {
382
446
  if (this.selfIsLight)
383
447
  this.light.intensity = 0;
@@ -386,6 +450,27 @@ export class Light extends Behaviour implements ILight {
386
450
  }
387
451
  }
388
452
 
453
+ onBeforeRender() {
454
+ if (this.type === "directional" && this.shadows !== LightShadows.None) {
455
+ // context.mainLight is computed — always returns the brightest registered directional light
456
+ const isMain = this.context.mainLight === this;
457
+ if (isMain) {
458
+ if (!this._csm) this.createCSM();
459
+ } else if (this._csm) {
460
+ // this light is no longer the main light (a brighter one took over) — tear down CSM
461
+ this._csm.remove();
462
+ this._csm.dispose();
463
+ this._csm = undefined;
464
+ }
465
+ }
466
+ if (this._csm) {
467
+ // keep lightDirection in sync with the gameObject's world orientation
468
+ this._csm.lightDirection.copy(this.gameObject.worldForward);
469
+ this._csm.update();
470
+ if (this._csmHelper) this._csmHelper.update();
471
+ }
472
+ }
473
+
389
474
  /**
390
475
  * Creates the appropriate three.js light based on the configured light type
391
476
  * and applies all settings like shadows, intensity, and color.
@@ -399,14 +484,14 @@ export class Light extends Behaviour implements ILight {
399
484
  this._intensity = this.light.intensity;
400
485
 
401
486
  switch (this.type) {
402
- case LightType.Directional:
487
+ case "directional":
403
488
  this.setDirectionalLight(this.light as DirectionalLight);
404
489
  break;
405
490
  }
406
491
  }
407
492
  else if (!this.light) {
408
493
  switch (this.type) {
409
- case LightType.Directional:
494
+ case "directional":
410
495
  // console.log(this);
411
496
  const dirLight = new DirectionalLight(this.color, this.intensity * Math.PI);
412
497
  // directional light target is at 0 0 0 by default
@@ -425,7 +510,7 @@ export class Light extends Behaviour implements ILight {
425
510
  }
426
511
  break;
427
512
 
428
- case LightType.Spot:
513
+ case "spot":
429
514
  const spotLight = new SpotLight(this.color, this.intensity * Math.PI, this.range, toRadians(this.spotAngle / 2), 1 - toRadians(this.innerSpotAngle / 2) / toRadians(this.spotAngle / 2), 2);
430
515
  spotLight.position.set(0, 0, 0);
431
516
  spotLight.rotation.set(0, 0, 0);
@@ -437,7 +522,7 @@ export class Light extends Behaviour implements ILight {
437
522
  spotLightTarget.rotation.set(0, 0, 0);
438
523
  break;
439
524
 
440
- case LightType.Point:
525
+ case "point":
441
526
  const pointLight = new PointLight(this.color, this.intensity * Math.PI, this.range);
442
527
  this.light = pointLight;
443
528
 
@@ -526,22 +611,6 @@ export class Light extends Behaviour implements ILight {
526
611
 
527
612
  }
528
613
 
529
- /**
530
- * Coroutine that updates the main light reference in the context
531
- * if this directional light should be the main light
532
- */
533
- *updateMainLightRoutine() {
534
- while (true) {
535
- if (this.type === LightType.Directional) {
536
- if (!this.context.mainLight || this.intensity > this.context.mainLight.intensity) {
537
- this.context.mainLight = this;
538
- }
539
- yield;
540
- }
541
- break;
542
- }
543
- }
544
-
545
614
  /**
546
615
  * Controls whether the renderer's shadow map type can be changed when soft shadows are used
547
616
  */
@@ -598,6 +667,41 @@ export class Light extends Behaviour implements ILight {
598
667
  }
599
668
  }
600
669
 
670
+ /**
671
+ * Creates and initializes a CSM instance for this directional light.
672
+ * CSM manages its own cascade DirectionalLights internally.
673
+ */
674
+ private createCSM() {
675
+ const camera = this.context.mainCamera;
676
+ if (!camera) {
677
+ if (debug) console.warn("CSM: no main camera found, deferring");
678
+ return;
679
+ }
680
+
681
+ this._csm = new CSM({
682
+ camera,
683
+ parent: this.context.scene,
684
+ cascades: this.cascades,
685
+ mode: this.cascadeMode,
686
+ maxFar: this._shadowDistance ?? shadowMaxDistance,
687
+ shadowMapSize: this._shadowResolution ?? 2048,
688
+ shadowBias: this._shadowBias,
689
+ lightDirection: this.gameObject.worldForward.clone(),
690
+ lightIntensity: this._intensity >= 0 ? this._intensity : 1,
691
+ });
692
+ this._csm.fade = true;
693
+
694
+ // apply color to all cascade lights
695
+ for (const l of this._csm.lights) {
696
+ l.color.copy(this._color);
697
+ }
698
+
699
+ if (debug) {
700
+ this._csmHelper = new CSMHelper(this._csm);
701
+ this.context.scene.add(this._csmHelper);
702
+ }
703
+ }
704
+
601
705
  /**
602
706
  * Configures a directional light by adding and positioning its target
603
707
  * @param dirLight The directional light to set up
@@ -610,4 +714,5 @@ export class Light extends Behaviour implements ILight {
610
714
  }
611
715
 
612
716
  const vec = new Vector3(0, 0, 0);
717
+ const _csmLightDir = new Vector3();
613
718
 
@@ -382,12 +382,12 @@ export class Rigidbody extends Behaviour implements IRigidbody {
382
382
  this._watch.start(true, true);
383
383
  this.startCoroutine(this.beforePhysics(), FrameEvent.LateUpdate);
384
384
  if (isDevEnvironment()) {
385
- if (!globalThis["NEEDLE_USE_RAPIER"])
386
- console.warn(`Rigidbody could not be created: Rapier physics are explicitly disabled.`);
385
+ if (globalThis["NEEDLE_USE_RAPIER"] === false)
386
+ console.warn(`RAPIER physics are disabled in your build. Enable them by setting NEEDLE_USE_RAPIER to true in your build config: Rigidbody could not be created.`);
387
387
  else {
388
388
  MODULES.RAPIER_PHYSICS.ready().then(async () => {
389
389
  await delayForFrames(3);
390
- if (!this.context.physics.engine?.getBody(this))
390
+ if (this.activeAndEnabled && !this.context.physics.engine?.getBody(this))
391
391
  console.warn(`Rigidbody could not be created. Ensure \"${this.name}\" has a Collider component.`);
392
392
  })
393
393
  }
@@ -723,6 +723,7 @@ export class SceneSwitcher extends Behaviour {
723
723
  // unless the user defines that he wants to use the scene name
724
724
  if (this.useSceneName) {
725
725
  if (scene instanceof Object3D) queryParameterValue = scene.name;
726
+ else if (scene instanceof AssetReference && scene.asset?.name) queryParameterValue = scene.asset.name;
726
727
  else if (scene.url) queryParameterValue = sceneUriToName(scene.url);
727
728
  }
728
729
  // save the loaded scene as an url parameter
@@ -35,6 +35,7 @@
35
35
  */
36
36
 
37
37
  export * from "./codegen/components.js";
38
+ export { AnimatorControllerBuilder, type ConditionMode, type StateOptions, type TransitionOptions } from "./AnimatorController.js";
38
39
  export { Collider } from "./Collider.js"; // export abstract type
39
40
  export { Behaviour, Component, GameObject } from "./Component.js";
40
41
 
@@ -6,6 +6,7 @@ export { Animation } from "../Animation.js";
6
6
  export { Keyframe } from "../AnimationCurve.js";
7
7
  export { AnimationCurve } from "../AnimationCurve.js";
8
8
  export { Animator } from "../Animator.js";
9
+ export { AnimatorControllerBuilder } from "../AnimatorController.js";
9
10
  export { AnimatorController } from "../AnimatorController.js";
10
11
  export { AudioListener } from "../AudioListener.js";
11
12
  export { AudioSource } from "../AudioSource.js";
@@ -1,4 +1,4 @@
1
- import { BloomEffect as _BloomEffect, EffectAttribute } from "postprocessing";
1
+ import type { BloomEffect as _BloomEffect } from "postprocessing";
2
2
  import { MathUtils } from "three";
3
3
 
4
4
  import { MODULES } from "../../../engine/engine_modules.js";
@@ -1,4 +1,3 @@
1
- import { EffectAttribute } from "postprocessing";
2
1
  import { Uniform } from "three";
3
2
 
4
3
  import { MODULES } from "../../../engine/engine_modules.js";
@@ -138,7 +137,7 @@ function createSharpeningEffectType() {
138
137
  ["radius", new Uniform(1)],
139
138
  // ["threshold", new Uniform(0)],
140
139
  ]),
141
- attributes: EffectAttribute.CONVOLUTION
140
+ attributes: MODULES.POSTPROCESSING.MODULE.EffectAttribute.CONVOLUTION
142
141
  });
143
142
  }
144
143
  }
@@ -14,10 +14,6 @@ import { threeToneMappingToEffectMode } from "./Effects/Tonemapping.utils.js";
14
14
  import { PostProcessingEffect, PostProcessingEffectContext } from "./PostProcessingEffect.js";
15
15
  import { orderEffects, PostprocessingEffectData, PostProcessingEffectOrder } from "./utils.js";
16
16
 
17
- declare const NEEDLE_USE_POSTPROCESSING: boolean;
18
- globalThis["NEEDLE_USE_POSTPROCESSING"] = globalThis["NEEDLE_USE_POSTPROCESSING"] !== undefined ? globalThis["NEEDLE_USE_POSTPROCESSING"] : true;
19
-
20
-
21
17
  const debug = getParam("debugpost");
22
18
 
23
19
  const activeKey = Symbol("needle:postprocessing-handler");
@@ -58,13 +54,13 @@ export class PostProcessingHandler implements IPostProcessingHandler {
58
54
 
59
55
  apply(components: PostProcessingEffect[]): Promise<void> {
60
56
  if ("env" in import.meta && (import.meta as any /* webpack support */ ).env.VITE_NEEDLE_USE_POSTPROCESSING === "false") {
61
- if (debug) console.warn("Postprocessing is disabled via vite env setting");
62
- else console.debug("Postprocessing is disabled via vite env setting");
57
+ if (debug) console.warn("POSTPROCESSING is disabled via vite env setting");
58
+ else console.debug("POSTPROCESSING is disabled via vite env setting");
63
59
  return Promise.resolve();
64
60
  }
65
61
  if (!NEEDLE_USE_POSTPROCESSING) {
66
- if (debug) console.warn("Postprocessing is disabled via global vite define setting");
67
- else console.debug("Postprocessing is disabled via vite define");
62
+ if (debug || isDevEnvironment()) console.warn("POSTPROCESSING is disabled via global vite define setting");
63
+ else console.debug("POSTPROCESSING is disabled via vite define");
68
64
  return Promise.resolve();
69
65
  }
70
66
 
@@ -1,5 +1,5 @@
1
- // For firefox ViewTimeline support
2
- import "scroll-timeline-polyfill/dist/scroll-timeline.js";
1
+ // For firefox ViewTimeline support — dynamic import to avoid SSR crashes (polyfill accesses window at module level)
2
+ if (typeof window !== "undefined") import("scroll-timeline-polyfill/dist/scroll-timeline.js");
3
3
 
4
4
  import { Box3, Object3D } from "three";
5
5
 
@@ -1,3 +1,5 @@
1
+ /// <reference path="../plugins/types/needle-bindings.d.ts" />
2
+
1
3
  import { initEngine } from "./engine/engine_init.js";
2
4
  initEngine();
3
5
  import "./engine/webcomponents/needle-engine.js";
@@ -0,0 +1,16 @@
1
+ // Vite global defines — see plugins/vite/defines.js
2
+ // declare const entries here are picked up globally (ambient, no import/export).
3
+ // Vite sets these as globals in dev and statically replaces them at build time.
4
+ // Webpack DefinePlugin replaces them at build time too.
5
+ // The globalThis fallbacks for vanilla JS are in engine_constants.ts.
6
+
7
+ declare const NEEDLE_ENGINE_VERSION: string;
8
+ declare const NEEDLE_ENGINE_GENERATOR: string;
9
+ declare const NEEDLE_PROJECT_BUILD_TIME: string;
10
+ declare const NEEDLE_PUBLIC_KEY: string;
11
+
12
+ // #region treeshake flags
13
+ // declare var (not const) so globalThis["NEEDLE_USE_*"] access is also type-safe
14
+ declare var NEEDLE_USE_RAPIER: boolean;
15
+ declare var NEEDLE_USE_POSTPROCESSING: boolean;
16
+ // #endregion treeshake flags