@needle-tools/engine 5.1.0-canary.52c25a9 → 5.1.0-canary.5c9f618

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 (121) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +47 -0
  3. package/components.needle.json +1 -1
  4. package/dist/{needle-engine.bundle-Is0BeJVS.umd.cjs → needle-engine.bundle-ChFBZKiC.umd.cjs} +142 -141
  5. package/dist/{needle-engine.bundle-IDh1TTjW.min.js → needle-engine.bundle-DAXd7JPV.min.js} +144 -143
  6. package/dist/{needle-engine.bundle-CrgBME0J.js → needle-engine.bundle-DnWOguFo.js} +7614 -7388
  7. package/dist/needle-engine.d.ts +193 -89
  8. package/dist/needle-engine.js +524 -521
  9. package/dist/needle-engine.min.js +1 -1
  10. package/dist/needle-engine.umd.cjs +1 -1
  11. package/lib/engine/api.d.ts +2 -0
  12. package/lib/engine/api.js +2 -0
  13. package/lib/engine/api.js.map +1 -1
  14. package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
  15. package/lib/engine/debug/debug_spatial_console.js +10 -7
  16. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  17. package/lib/engine/engine_addressables.d.ts +2 -0
  18. package/lib/engine/engine_addressables.js +6 -3
  19. package/lib/engine/engine_addressables.js.map +1 -1
  20. package/lib/engine/engine_audio.d.ts +68 -0
  21. package/lib/engine/engine_audio.js +172 -0
  22. package/lib/engine/engine_audio.js.map +1 -1
  23. package/lib/engine/engine_context.d.ts +20 -19
  24. package/lib/engine/engine_context.js +25 -14
  25. package/lib/engine/engine_context.js.map +1 -1
  26. package/lib/engine/engine_gameobject.js +2 -2
  27. package/lib/engine/engine_gameobject.js.map +1 -1
  28. package/lib/engine/engine_init.js +10 -0
  29. package/lib/engine/engine_init.js.map +1 -1
  30. package/lib/engine/engine_mainloop_utils.js +5 -2
  31. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  32. package/lib/engine/engine_scenedata.d.ts +12 -16
  33. package/lib/engine/engine_scenedata.js +56 -29
  34. package/lib/engine/engine_scenedata.js.map +1 -1
  35. package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
  36. package/lib/engine/engine_serialization_builtin_serializer.js +55 -41
  37. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  38. package/lib/engine/engine_types.d.ts +2 -0
  39. package/lib/engine/engine_types.js.map +1 -1
  40. package/lib/engine/webcomponents/jsx.d.ts +51 -0
  41. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  42. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +2 -3
  43. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  44. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  45. package/lib/engine/webcomponents/needle-engine.d.ts +9 -3
  46. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  47. package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
  48. package/lib/engine/xr/NeedleXRSession.js +50 -14
  49. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  50. package/lib/engine-components/Animation.js +17 -16
  51. package/lib/engine-components/Animation.js.map +1 -1
  52. package/lib/engine-components/AnimatorController.d.ts +2 -0
  53. package/lib/engine-components/AnimatorController.js +4 -1
  54. package/lib/engine-components/AnimatorController.js.map +1 -1
  55. package/lib/engine-components/AudioSource.d.ts +19 -3
  56. package/lib/engine-components/AudioSource.js +121 -68
  57. package/lib/engine-components/AudioSource.js.map +1 -1
  58. package/lib/engine-components/Light.d.ts +6 -8
  59. package/lib/engine-components/Light.js +40 -27
  60. package/lib/engine-components/Light.js.map +1 -1
  61. package/lib/engine-components/Networking.d.ts +1 -1
  62. package/lib/engine-components/Networking.js +1 -1
  63. package/lib/engine-components/ReflectionProbe.js +2 -0
  64. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  65. package/lib/engine-components/SeeThrough.js +2 -2
  66. package/lib/engine-components/SeeThrough.js.map +1 -1
  67. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
  68. package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
  69. package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
  70. package/lib/engine-components/ui/Canvas.d.ts +1 -1
  71. package/lib/engine-components/ui/Canvas.js +2 -8
  72. package/lib/engine-components/ui/Canvas.js.map +1 -1
  73. package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
  74. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  75. package/lib/needle-engine.d.ts +2 -0
  76. package/lib/needle-engine.js +1 -0
  77. package/lib/needle-engine.js.map +1 -1
  78. package/package.json +2 -1
  79. package/plugins/dts-generator/dts.codegen.js +253 -48
  80. package/plugins/dts-generator/dts.scan.js +37 -9
  81. package/plugins/dts-generator/dts.writer.js +1 -1
  82. package/plugins/dts-generator/glb.discovery.js +140 -23
  83. package/plugins/dts-generator/glb.extractor.js +48 -8
  84. package/plugins/dts-generator/glb.reader.js +80 -27
  85. package/plugins/types/needle-bindings.d.ts +19 -12
  86. package/plugins/types/userconfig.d.ts +12 -0
  87. package/plugins/vite/asap.js +17 -8
  88. package/plugins/vite/dts-generator.d.ts +2 -2
  89. package/plugins/vite/dts-generator.js +20 -3
  90. package/plugins/vite/local-files-core.js +3 -3
  91. package/plugins/vite/local-files-utils.d.ts +3 -1
  92. package/plugins/vite/local-files-utils.js +29 -5
  93. package/plugins/vite/reload.js +18 -17
  94. package/src/engine/api.ts +3 -0
  95. package/src/engine/debug/debug_spatial_console.ts +10 -7
  96. package/src/engine/engine_addressables.ts +6 -3
  97. package/src/engine/engine_audio.ts +184 -0
  98. package/src/engine/engine_context.ts +33 -19
  99. package/src/engine/engine_gameobject.ts +2 -2
  100. package/src/engine/engine_init.ts +10 -0
  101. package/src/engine/engine_mainloop_utils.ts +5 -2
  102. package/src/engine/engine_scenedata.ts +52 -26
  103. package/src/engine/engine_serialization_builtin_serializer.ts +63 -46
  104. package/src/engine/engine_types.ts +2 -0
  105. package/src/engine/webcomponents/jsx.d.ts +51 -0
  106. package/src/engine/webcomponents/logo-element.ts +1 -0
  107. package/src/engine/webcomponents/needle menu/needle-menu.ts +2 -1
  108. package/src/engine/webcomponents/needle-button.ts +1 -0
  109. package/src/engine/webcomponents/needle-engine.ts +10 -3
  110. package/src/engine/xr/NeedleXRSession.ts +48 -13
  111. package/src/engine-components/Animation.ts +19 -16
  112. package/src/engine-components/AnimatorController.ts +4 -1
  113. package/src/engine-components/AudioSource.ts +130 -79
  114. package/src/engine-components/Light.ts +40 -26
  115. package/src/engine-components/Networking.ts +1 -1
  116. package/src/engine-components/ReflectionProbe.ts +2 -0
  117. package/src/engine-components/SeeThrough.ts +2 -2
  118. package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
  119. package/src/engine-components/ui/Canvas.ts +2 -8
  120. package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
  121. package/src/needle-engine.ts +1 -0
@@ -0,0 +1,5 @@
1
+ // Auto-generated by @needle-tools/engine — do not edit
2
+ // Regenerated on each vite dev-server start and GLB change.
3
+ declare module "needle-bindings" {
4
+ interface SceneData {}
5
+ }
package/CHANGELOG.md CHANGED
@@ -4,6 +4,44 @@ All notable changes to this package will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [5.1.0-alpha.3] - 2026-04-28
8
+ - Add: `AudioClip` type with standalone playback control (play, pause, stop) — use with `@serializable(AudioClip)` for direct audio clip references
9
+ - Add: AudioSource spatial blend support (via dual-path audio graph, enabling smooth crossfade between 2D and 3D audio)
10
+ - Fix: Animation `play()` with `{ exclusive: false }` not stopping other running animations when the target clip was already playing
11
+ - Fix: AudioSource spatial audio rolloff factor not applied correctly
12
+ - Fix: AudioSource `play()` not working correctly in some cases
13
+ - Fix: UI components initializing in wrong order
14
+ - Fix: XR lifecycle — `onLeaveXR` was called spuriously for scripts that never received `onEnterXR` (e.g. during scene switching)
15
+ - Fix: VideoPlayer and URL serializer being tree-shaken out in code-only projects
16
+ - Fix: ReflectionProbe not cleaning up `envMapRotation` and `envMapIntensity` overrides when removed
17
+ - Improved: XR image tracking now includes "emulated" tracking state, preventing reticle from hiding prematurely
18
+ - Improved: AudioSource error logging when audio clips fail to load
19
+
20
+ ## [5.1.0-alpha.2] - 2026-04-13
21
+ - **NEW**: Scene Bindings (experimental) — auto-generated TypeScript types from your glTF scenes, providing typed access to nodes, components, and properties via `ctx.sceneData` or `needle.sceneData`. Types are generated automatically by a Vite plugin whenever your scene files change — no configuration needed. Works with any glTF/GLB assigned as `src` on `<needle-engine>`, including remote URLs and Needle Cloud assets. The API shape (particularly `$components` and `$object` accessors) may evolve based on feedback. Can be disabled with `dts: { enabled: false }` in your Vite plugin config.
22
+ ```ts
23
+ // fully typed, with autocomplete for every node and component
24
+ const cam = ctx.sceneData.MyScene.MainCamera.$object; // THREE.PerspectiveCamera
25
+ const orbit = ctx.sceneData.MyScene.MainCamera.$components.OrbitControls; // typed!
26
+ ```
27
+ - **NEW**: SSR support (experimental) — import Needle Engine in Node.js/SSR frameworks (SvelteKit, Next.js, Nuxt) without `ReferenceError` crashes. The engine now provides SSR-safe base classes and skips browser-dependent initialization on the server. Core rendering still happens client-side — SSR support means your app can import and reference engine code server-side without errors.
28
+ - **NEW**: JSX type declarations for `<needle-engine>` and other web components — first-class support for React, Preact, SolidJS, and other JSX-based frameworks with full autocomplete and type checking
29
+ - **NEW**: `needle` shorthand (experimental) — quick access to the current engine context from anywhere without passing `ctx` around. Works in React/Svelte/Vue components, button handlers, or plain JavaScript. SSR-safe.
30
+ ```ts
31
+ import { needle } from "@needle-tools/engine";
32
+ needle.scene.traverse(obj => { ... }); // access the three.js scene
33
+ needle.renderer; // access the WebGLRenderer
34
+ needle.sceneData.MyScene.Camera.$components.OrbitControls.autoRotate = true;
35
+ ```
36
+ - **NEW**: `context.lights` array and `context.mainLight` getter for easy access to all scene lights and the primary directional light
37
+ - Add: `needlePlugins()` can now be called without arguments — the Vite command is resolved automatically. This simplifies setup in frameworks like SvelteKit where `defineConfig` doesn't expose the command:
38
+ ```js
39
+ export default defineConfig({ plugins: [sveltekit(), needlePlugins()] });
40
+ ```
41
+ - Fix: BloomEffect and Sharpening were pulling in the entire `postprocessing` library even in projects that don't use postprocessing, increasing bundle size unnecessarily
42
+ - Fix: SceneSwitcher now shows the object name in the URL when referencing scene objects (instead of just an index)
43
+ - Improved: Vite plugin reliability (fewer unnecessary reloads, cleaner log output)
44
+
7
45
  ## [5.1.0-alpha.1] - 2026-04-10
8
46
  - Add: `AnimatorControllerBuilder` for building animator controllers from code (experimental)
9
47
  - Add: XR global events now return an unsubscribe function + `onBeforeXRSessionRequest` event
@@ -36,6 +74,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
36
74
  - Fix: HTML mobile icon not rendering
37
75
  - Fix: UI `Text` component absolute font URL handling
38
76
 
77
+ ## [5.0.4] - 2026-04-20
78
+ - Fix: VideoPlayer not working when tree-shaking is enabled due to URL serializer being removed
79
+ - Fix: ReflectionProbe not cleaning up `envMapRotation` and `envMapIntensity` overrides when removing envMap
80
+
81
+ ## [5.0.3] - 2026-04-08
82
+ - Add: PMREM / FastHDR support for GroundProjection with shader-based blurriness, blending, and alpha controls
83
+ - Fix: MaterialPropertyBlock multi-material change from opaque to transparent
84
+ - Improved: OrbitControls JSDoc for `targetBounds`
85
+
39
86
  ## [5.0.2] - 2026-04-03
40
87
  - Updated `@needle-tools/materialx` to 1.6.0:
41
88
  - UV coordinate convention handling (glTF ↔ OpenGL) — fixes UV-dependent effects like displacement and procedural noise in the browser