@needle-tools/engine 4.16.0 → 4.16.1-next.b4c9779

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 (110) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +92 -46
  3. package/SKILL.md +25 -33
  4. package/dist/{needle-engine.bundle-CXVjO2uF.umd.cjs → needle-engine.bundle-B5gYfP-3.umd.cjs} +121 -121
  5. package/dist/{needle-engine.bundle-Cx8Qrpbp.js → needle-engine.bundle-BGxftKpt.js} +5386 -5356
  6. package/dist/{needle-engine.bundle-mHgaFC2W.min.js → needle-engine.bundle-Bpn20g7P.min.js} +131 -131
  7. package/dist/needle-engine.d.ts +16 -287
  8. package/dist/needle-engine.js +2 -2
  9. package/dist/needle-engine.min.js +1 -1
  10. package/dist/needle-engine.umd.cjs +1 -1
  11. package/lib/engine/engine_context.js +2 -0
  12. package/lib/engine/engine_context.js.map +1 -1
  13. package/lib/engine/webcomponents/logo-element.d.ts +6 -3
  14. package/lib/engine/webcomponents/logo-element.js +18 -0
  15. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  16. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +10 -7
  17. package/lib/engine/webcomponents/needle menu/needle-menu.js +13 -2
  18. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  19. package/lib/engine/webcomponents/needle-engine.d.ts +4 -1
  20. package/lib/engine/webcomponents/needle-engine.js +22 -15
  21. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  22. package/lib/engine/xr/NeedleXRSession.js +15 -3
  23. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  24. package/lib/engine-components/ReflectionProbe.d.ts +10 -3
  25. package/lib/engine-components/ReflectionProbe.js +34 -10
  26. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  27. package/package.json +17 -9
  28. package/plugins/next/next.d.ts +8 -0
  29. package/plugins/next/next.js +7 -6
  30. package/plugins/vite/ai.d.ts +17 -0
  31. package/plugins/vite/ai.js +2 -2
  32. package/plugins/vite/alias.d.ts +8 -0
  33. package/plugins/vite/alias.js +5 -2
  34. package/plugins/vite/asap.d.ts +7 -0
  35. package/plugins/vite/asap.js +3 -3
  36. package/plugins/vite/build-pipeline.d.ts +15 -0
  37. package/plugins/vite/build-pipeline.js +5 -6
  38. package/plugins/vite/build.d.ts +7 -0
  39. package/plugins/vite/build.js +5 -2
  40. package/plugins/vite/buildinfo.d.ts +7 -0
  41. package/plugins/vite/buildinfo.js +4 -2
  42. package/plugins/vite/config.d.ts +13 -0
  43. package/plugins/vite/config.js +1 -1
  44. package/plugins/vite/copyfiles.d.ts +7 -0
  45. package/plugins/vite/copyfiles.js +4 -2
  46. package/plugins/vite/custom-element-data.d.ts +25 -0
  47. package/plugins/vite/custom-element-data.js +2 -1
  48. package/plugins/vite/defines.d.ts +10 -0
  49. package/plugins/vite/defines.js +4 -3
  50. package/plugins/vite/dependencies.d.ts +21 -0
  51. package/plugins/vite/dependencies.js +3 -1
  52. package/plugins/vite/dependency-watcher.d.ts +11 -0
  53. package/plugins/vite/dependency-watcher.js +2 -1
  54. package/plugins/vite/drop-client.d.ts +1 -0
  55. package/plugins/vite/drop.d.ts +7 -0
  56. package/plugins/vite/drop.js +4 -4
  57. package/plugins/vite/editor-connection.d.ts +8 -0
  58. package/plugins/vite/editor-connection.js +6 -2
  59. package/plugins/vite/facebook-instant-games.d.ts +7 -0
  60. package/plugins/vite/facebook-instant-games.js +4 -2
  61. package/plugins/vite/gzip.d.ts +6 -0
  62. package/plugins/vite/gzip.js +5 -0
  63. package/plugins/vite/imports-logger.d.ts +13 -0
  64. package/plugins/vite/imports-logger.js +2 -1
  65. package/plugins/vite/index.d.ts +54 -0
  66. package/plugins/vite/index.js +16 -15
  67. package/plugins/vite/license.d.ts +7 -0
  68. package/plugins/vite/license.js +6 -6
  69. package/plugins/vite/local-files-analysis.d.ts +95 -0
  70. package/plugins/vite/local-files-analysis.js +2 -1
  71. package/plugins/vite/local-files-core.d.ts +51 -0
  72. package/plugins/vite/local-files-core.js +2 -2
  73. package/plugins/vite/local-files-internals.d.ts +3 -0
  74. package/plugins/vite/local-files-utils.d.ts +77 -0
  75. package/plugins/vite/local-files.d.ts +2 -0
  76. package/plugins/vite/logger.d.ts +8 -0
  77. package/plugins/vite/logger.js +1 -1
  78. package/plugins/vite/logging.d.ts +31 -0
  79. package/plugins/vite/meta.d.ts +7 -0
  80. package/plugins/vite/meta.js +4 -3
  81. package/plugins/vite/needle-app.d.ts +7 -0
  82. package/plugins/vite/needle-app.js +1 -1
  83. package/plugins/vite/npm.d.ts +4 -0
  84. package/plugins/vite/npm.js +1 -1
  85. package/plugins/vite/peer.d.ts +7 -0
  86. package/plugins/vite/peer.js +3 -1
  87. package/plugins/vite/poster-client.d.ts +1 -0
  88. package/plugins/vite/poster.d.ts +8 -0
  89. package/plugins/vite/poster.js +5 -2
  90. package/plugins/vite/pwa.d.ts +7 -0
  91. package/plugins/vite/pwa.js +4 -4
  92. package/plugins/vite/reload-client.d.ts +1 -0
  93. package/plugins/vite/reload.d.ts +7 -0
  94. package/plugins/vite/reload.js +7 -6
  95. package/plugins/vite/server.d.ts +7 -0
  96. package/plugins/vite/server.js +5 -5
  97. package/plugins/vite/transform-codegen.d.ts +8 -0
  98. package/plugins/vite/transform-codegen.js +6 -4
  99. package/plugins/vite/transform.d.ts +5 -0
  100. package/plugins/vite/transform.js +1 -1
  101. package/plugins/vite/vite-4.4-hack.d.ts +8 -0
  102. package/plugins/vite/vite-4.4-hack.js +1 -1
  103. package/src/engine/engine_context.ts +1 -0
  104. package/src/engine/webcomponents/logo-element.ts +20 -3
  105. package/src/engine/webcomponents/needle menu/needle-menu.ts +22 -9
  106. package/src/engine/webcomponents/needle-engine.ts +42 -35
  107. package/src/engine/xr/NeedleXRSession.ts +16 -3
  108. package/src/engine-components/ReflectionProbe.ts +38 -11
  109. package/plugins/types/next.d.ts +0 -3
  110. package/plugins/types/vite.d.ts +0 -14
package/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ 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
+ ## [4.16.1] - 2026-03-09
8
+ - Fix: Regression causing error in react
9
+
7
10
  ## [4.16.0] - 2026-03-05
8
11
  - **NEW**: `makeFilesLocal` build option overhauled — builds can now be fully self-contained and work offline. The plugin downloads external CDN assets at build time and bundles them locally. This is essential for playable ads, app stores that require single-origin or self-contained bundles, offline-capable PWAs, and restricted hosting environments. Supports auto-detection of used features, per-feature opt-in/opt-out, and platform presets. Covers Draco decoders, KTX2 transcoders, MaterialX, WebXR input profiles, skybox/environment textures, Google Fonts, third-party scripts, and more.
9
12
  Example in `vite.config.js`:
package/README.md CHANGED
@@ -1,63 +1,31 @@
1
- # Needle Engine
1
+ # Needle Engine
2
2
 
3
- **Needle Engine** is a web engine for high quality 3D applications with performance in mind.
3
+ **Needle Engine** is a web-first 3D framework built on [three.js](https://threejs.org/) for building games, configurators, AR/VR experiences, and interactive websites.
4
4
 
5
- Built on three.js and the glTF standard, Needle Engine delivers flexible, extensible web experiences with built-in collaboration and XR support.
5
+ `Built-in: Rapier Physics | WebXR (incl. iOS) | Multiplayer & VOIP | Blender & Unity Integration`
6
6
 
7
- ## Quick Links
8
- 🏓 [Changelog](https://github.com/needle-tools/needle-engine-support/releases) • 📑 [Documentation](https://docs.needle.tools) • 🧠 [Sample Scenes](https://samples.needle.tools) • 💎 [Showcase](https://engine.needle.tools/samples/?overlay=showcase)
9
-
10
- ## Key Features
11
-
12
- **🎮 Development Experience**
13
- - Component system with easy custom component creation
14
- - Unity and Blender integrations for familiar workflows
15
- - Multi-scene support with dynamic content loading
16
-
17
- **🌐 Web & XR Ready**
18
- - WebXR support for immersive experiences on Android and iOS ([yes! WebXR on iOS!](https://engine.needle.tools/docs/how-to-guides/xr/ios-webxr-app-clip.html))
19
- - Interactive QuickLook support for interactive AR on Vision Pro
20
- - Built-in networking and collaboration
7
+ Built on three.js and the glTF standard, Needle Engine delivers flexible, extensible web experiences with built-in collaboration and XR support. Use it standalone with npm or with powerful editor integrations for Unity and Blender.
21
8
 
22
- **⚡ Performance Optimized**
23
- - Progressive texture and mesh loading
24
- - Automatic LOD generation for textures and meshes
25
- - Advanced PBR rendering with lightmap support
26
-
27
- **🎬 Animation & Effects**
28
- - Animation state machines and timeline animations
29
- - Physics simulation
30
- - Post-processing effects
31
- - Animate anything with ease
32
-
33
- [→ See all features](https://docs.needle.tools/features)
34
-
35
- ## Editor Integrations
36
-
37
- **Powerful integrations for Unity and Blender** allow artists and developers to collaborate and manage web applications inside battle-tested 3d editors. Needle Engine integrations allow you to use editor features for exporting models, author materials, animate and sequence animations, bake lightmaps and more.
38
- - 🎲 [Download Unity Integration](https://engine.needle.tools/downloads/unity)
39
- - 🐵 [Download Blender Integration](https://engine.needle.tools/downloads/blender)
40
- - 📜 [Use with Code](https://engine.needle.tools/docs/three/)
9
+ ## Quick Links
10
+ [Changelog](https://github.com/needle-tools/needle-engine-support/releases) | [Documentation](https://docs.needle.tools) | [Samples](https://samples.needle.tools) | [Showcase](https://engine.needle.tools/samples/?overlay=showcase) | [API Reference](https://engine.needle.tools/docs/api/latest)
41
11
 
42
12
  ## Getting Started
43
13
 
44
- **Quick Start with npm:**
45
14
  ```bash
46
15
  npm install @needle-tools/engine
47
16
  ```
48
17
 
49
- **Or use our Editor Integrations:** Follow the [Getting Started Guide](https://docs.needle.tools/getting-started) to download and install Needle Engine with Unity or Blender.
50
-
51
- **Explore Examples:** [Try our interactive samples](https://engine.needle.tools/samples) to see what's possible ⚡
18
+ [Try it now on StackBlitz](https://engine.needle.tools/new) | [Getting Started Guide](https://docs.needle.tools/getting-started)
52
19
 
53
- ## Basic Usage
20
+ ## Code Examples
54
21
 
55
- ### Creating a Custom Component
22
+ ### Custom Component
56
23
 
57
24
  ```typescript
58
25
  import { Behaviour, serializable } from "@needle-tools/engine";
59
26
 
60
27
  export class MyComponent extends Behaviour {
28
+
61
29
  @serializable()
62
30
  speed: number = 1;
63
31
 
@@ -71,7 +39,42 @@ export class MyComponent extends Behaviour {
71
39
  }
72
40
  ```
73
41
 
74
- ### Using Lifecycle Hooks (without components)
42
+ ### Physics with Rapier (built-in)
43
+
44
+ ```typescript
45
+ import { Behaviour, Rigidbody, BoxCollider } from "@needle-tools/engine";
46
+
47
+ export class PhysicsBox extends Behaviour {
48
+
49
+ awake() {
50
+ // Add a physics body — Rapier is built in, no extra install needed
51
+ const rb = this.gameObject.addComponent(Rigidbody);
52
+ rb.useGravity = true;
53
+
54
+ // Add a collider
55
+ this.gameObject.addComponent(BoxCollider);
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### Multiplayer with @syncField
61
+
62
+ ```typescript
63
+ import { Behaviour, syncField } from "@needle-tools/engine";
64
+
65
+ export class SyncedCounter extends Behaviour {
66
+ // Automatically synced across all connected clients
67
+ @syncField()
68
+ count: number = 0;
69
+
70
+ onPointerClick() {
71
+ // Reassign to trigger sync (this is required for sync to work)
72
+ this.count = this.count + 1;
73
+ }
74
+ }
75
+ ```
76
+
77
+ ### Lifecycle Hooks (no component needed)
75
78
 
76
79
  ```typescript
77
80
  import { onStart, onUpdate } from "@needle-tools/engine";
@@ -85,11 +88,54 @@ onUpdate((context) => {
85
88
  });
86
89
  ```
87
90
 
88
- [→ See API Documentation](https://engine.needle.tools/docs/api/latest)
91
+ ## Key Features
92
+
93
+ **WebXR & AR** — immersive experiences on Android and iOS
94
+ - WebXR support including [WebXR on iOS](https://engine.needle.tools/docs/how-to-guides/xr/ios-webxr-app-clip.html)
95
+ - `WebXRImageTracking` — AR image targets with full tracking lifecycle
96
+ - `WebXRPlaneTracking` — AR surface detection
97
+ - Interactive QuickLook for AR on Vision Pro
98
+
99
+ **Scene & Asset Management**
100
+ - `SceneSwitcher` — load different scenes by URL
101
+ - `AssetReference` — runtime asset loading by URL
102
+ - `NestedGltf` — lazy-load GLB files on demand within a scene
103
+ - Multi-scene support with dynamic content loading
104
+
105
+ **Physics & Interaction** — Built-in [Rapier](https://rapier.rs/) physics engine
106
+ - `Rigidbody`, `BoxCollider`, `SphereCollider`, `MeshCollider` — full physics simulation
107
+ - `CharacterController` — movement with gravity, slopes, and steps
108
+ - `DragControls` — click-and-drag 3D objects with zero code
109
+ - `SpatialTrigger` — proximity and enter-zone detection
110
+
111
+ **Multiplayer & Networking** — real-time collaboration out of the box
112
+ - `SyncedRoom` + `@syncField()` — automatic state synchronization
113
+ - `Voip` — built-in WebRTC voice chat
114
+ - `PlayerSync` — player object sync on join/leave
115
+ - `SyncedCamera` — camera sync for observer sessions
116
+
117
+ **Rendering & Effects**
118
+ - Advanced PBR rendering with lightmap support
119
+ - Post-processing (Bloom, DepthOfField, SSAO, ChromaticAberration, and more)
120
+ - Progressive texture and mesh loading with automatic LOD generation
121
+
122
+ **Animation & Media**
123
+ - Animation state machines and timeline animations
124
+ - `VideoPlayer` — full video playback component
125
+ - `AudioSource` — 3D spatial audio
126
+ - Animate anything via [KHR_animation_pointer](https://github.com/nicolo-ribaudo/glTF/tree/animation-pointer/extensions/2.0/Khronos/KHR_animation_pointer)
127
+
128
+ **Framework Integration** — works with React, Vue, Svelte, or vanilla JS/TS
129
+
130
+ [See all features](https://docs.needle.tools/features)
131
+
132
+ ## Editor Integrations
89
133
 
90
- ---
134
+ Needle Engine works standalone with just npm — no editor required. For asset-heavy workflows, use our editor integrations:
91
135
 
92
- *Available under commercial and educational licenses*
136
+ - [Download Unity Integration](https://engine.needle.tools/downloads/unity)
137
+ - [Download Blender Integration](https://engine.needle.tools/downloads/blender)
138
+ - [Code-only workflow docs](https://engine.needle.tools/docs/three/)
93
139
 
94
140
  ## Examples
95
141
 
package/SKILL.md CHANGED
@@ -1,30 +1,22 @@
1
1
  ---
2
2
  name: needle-engine
3
- description: Automatically provides Needle Engine context when working in a Needle Engine web project. Use this skill when editing TypeScript components, Vite config, GLB assets, or anything related to @needle-tools/engine.
4
- metadata:
5
- reviewed-against: "@needle-tools/engine@4.15.0"
6
- last-reviewed: "2026-03"
3
+ description: >
4
+ Provides Needle Engine context for web-based 3D projects built on Three.js
5
+ with the @needle-tools/engine component system. Use this skill whenever the user
6
+ is working with Needle Engine components, GLB files exported from Unity or Blender,
7
+ Vite configs with needlePlugins, TypeScript classes extending Behaviour, or anything
8
+ involving @needle-tools/engine imports. Also trigger when the user mentions
9
+ "needle engine", "needle tools", serializable decorators (@serializable, @syncField,
10
+ @registerType), the <needle-engine> web component, or 3D scenes loaded from GLB
11
+ in a web context — even if they don't explicitly name the engine.
12
+ compatibility:
13
+ - optional: needle_search MCP tool (search Needle Engine docs, forum posts, and community answers)
7
14
  ---
8
15
 
9
16
  # Needle Engine
10
17
 
11
18
  You are an expert in Needle Engine — a web-first 3D engine built on Three.js with a component system and Unity/Blender-based workflow.
12
19
 
13
- ## When to Use This Skill
14
-
15
- **Use when the user is:**
16
- - Editing TypeScript files that import from `@needle-tools/engine`
17
- - Working on a project with `vite.config.ts` that uses `needlePlugins`
18
- - Loading or debugging `.glb` files exported from Unity or Blender
19
- - Using the Needle Engine Blender addon or Unity package
20
- - Asking about component lifecycle, serialization, XR, networking, or deployment
21
-
22
- **Do NOT use for:**
23
- - Pure Three.js projects with no Needle Engine
24
- - Non-web Unity/Blender work with no GLB export
25
-
26
- ---
27
-
28
20
  ## Quick Start
29
21
 
30
22
  ```html
@@ -48,7 +40,7 @@ export class HelloWorld extends Behaviour {
48
40
  }
49
41
  ```
50
42
 
51
- > **TypeScript config required:** `tsconfig.json` must have `"experimentalDecorators": true` and `"useDefineForClassFields": false` for decorators to work.
43
+ > ⚠️ **TypeScript config required:** `tsconfig.json` must have `"experimentalDecorators": true` and `"useDefineForClassFields": false` for decorators to work. Without `useDefineForClassFields: false`, TypeScript overwrites `@serializable()` properties with their default values *after* the decorator runs, silently breaking deserialization.
52
44
 
53
45
  ---
54
46
 
@@ -208,26 +200,26 @@ Use this *before* guessing at API details — the docs are the source of truth.
208
200
 
209
201
  ## Common Gotchas
210
202
 
211
- - `@registerType` is required or the component won't be instantiated from GLB (Unity/Blender export adds this automatically, but hand-written components need it)
212
- - GLB assets go in `assets/`, static files (fonts, images) in `public/` (configurable via `needle.config.json`)
213
- - `useDefineForClassFields: false` must be set in `tsconfig.json` — otherwise decorators silently break field initialization
214
- - `@syncField()` only triggers on reassignment — mutating an array/object in place won't sync; do `this.arr = this.arr`
215
- - Physics callbacks (`onCollisionEnter` etc.) require a Needle `Collider` component on the GameObject
216
- - `removeComponent()` does NOT call `onDestroy` — use `destroy(obj)` for full cleanup
217
- - Prefer `instantiate()` and `destroy()` functions over `GameObject.instantiate()` / `GameObject.destroy()`
203
+ - `@registerType` is required or the component won't be instantiated from GLB. Unity/Blender export adds this automatically via codegen; hand-written components need it explicitly.
204
+ - GLB assets go in `assets/`, static files (fonts, images, videos) in `public/` (configurable via `needle.config.json`)
205
+ - `useDefineForClassFields: false` must be set in `tsconfig.json` — otherwise TypeScript overwrites decorated fields with their defaults after the decorator runs, silently breaking serialization
206
+ - `@syncField()` only triggers on reassignment — mutating an array/object in place won't sync. Do `this.arr = this.arr` to force a sync event.
207
+ - Physics callbacks (`onCollisionEnter` etc.) require a Needle `Collider` component (BoxCollider, SphereCollider ...) on the GameObject — they won't fire on mesh-only objects
208
+ - `removeComponent()` does NOT call `onDestroy` — any cleanup logic in `onDestroy` (event listeners, timers, allocated resources) will be skipped. Use `destroy(obj)` for full cleanup.
209
+ - Prefer the standalone `instantiate()` and `destroy()` functions over `GameObject.instantiate()` / `GameObject.destroy()` — the standalone versions are the current API
218
210
  - `loadAsset()` returns a model wrapper (not an Object3D) — use `.scene` to get the root Object3D
219
- - `AssetReference.getOrCreateFromUrl()` caches by URL — loading the same URL twice returns the same Object3D. Use `.instantiate()` or `loadAsset()` with `{ context }` for multiple copies
211
+ - `AssetReference.getOrCreateFromUrl()` caches by URL — loading the same URL twice returns the same Object3D. Use `.instantiate()` or `loadAsset()` with `{ context }` for multiple independent copies
220
212
 
221
213
  ---
222
214
 
223
215
  ## References
224
216
 
225
- For detailed API usage, read these reference files:
217
+ Read these **only when needed** don't load them all upfront:
226
218
 
227
- - [Full API Reference](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/references/api.md) — lifecycle, decorators, context API, animation, networking, XR, physics
228
- - [Framework Integration](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/references/integration.md) — React, Svelte, Vue, vanilla JS examples + SSR patterns
229
- - [Troubleshooting](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/references/troubleshooting.md) — common errors and fixes
230
- - [Component Template](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/templates/my-component.ts) — annotated starter component
219
+ - 📖 [Full API Reference](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/references/api.md) — read when writing component code (lifecycle, decorators, context API, animation, networking, XR, physics)
220
+ - 🔗 [Framework Integration](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/references/integration.md) — read when integrating with React, Svelte, Vue, or vanilla JS
221
+ - 🐛 [Troubleshooting](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/references/troubleshooting.md) — read when debugging errors or unexpected behavior
222
+ - 🧩 [Component Template](https://raw.githubusercontent.com/needle-tools/ai/refs/heads/main/providers/claude/plugin/skills/needle-engine/templates/my-component.ts) — use as a starting point for new components
231
223
 
232
224
  ## Important URLs
233
225