@needle-tools/engine 4.16.0-next.73c93c0 → 4.16.0-next.bc4d35d
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.
- package/README.md +92 -46
- package/SKILL.md +229 -0
- package/dist/{needle-engine.bundle-75BC4qb_.min.js → needle-engine.bundle-Cqmarm0m.min.js} +115 -115
- package/dist/{needle-engine.bundle-CqSR6UY7.umd.cjs → needle-engine.bundle-DT0VwGmo.umd.cjs} +114 -114
- package/dist/{needle-engine.bundle-CwvwWDWq.js → needle-engine.bundle-KyGODqE9.js} +3305 -3283
- package/dist/needle-engine.d.ts +7 -284
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +6 -3
- package/lib/engine/webcomponents/logo-element.js +18 -0
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +10 -7
- package/lib/engine/webcomponents/needle menu/needle-menu.js +13 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +3 -0
- package/lib/engine/webcomponents/needle-engine.js +14 -5
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.js +15 -3
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/package.json +3 -3
- package/plugins/common/needle-engine-skill.md +106 -168
- package/plugins/vite/ai.js +1 -1
- package/src/engine/webcomponents/logo-element.ts +20 -3
- package/src/engine/webcomponents/needle menu/needle-menu.ts +22 -9
- package/src/engine/webcomponents/needle-engine.ts +19 -6
- package/src/engine/xr/NeedleXRSession.ts +16 -3
package/README.md
CHANGED
|
@@ -1,63 +1,31 @@
|
|
|
1
|
-
# Needle Engine
|
|
1
|
+
# Needle Engine
|
|
2
2
|
|
|
3
|
-
**Needle Engine** is a web
|
|
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
|
|
5
|
+
`Built-in: Rapier Physics | WebXR (incl. iOS) | Multiplayer & VOIP | Blender & Unity Integration`
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
23
|
-
-
|
|
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
|
-
|
|
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
|
-
##
|
|
20
|
+
## Code Examples
|
|
54
21
|
|
|
55
|
-
###
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
|
|
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
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: needle-engine
|
|
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)
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Needle Engine
|
|
17
|
+
|
|
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.
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<needle-engine src="assets/scene.glb"></needle-engine>
|
|
24
|
+
<script type="module">
|
|
25
|
+
import "@needle-tools/engine";
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Minimal TypeScript component:
|
|
30
|
+
```ts
|
|
31
|
+
import { Behaviour, serializable, registerType } from "@needle-tools/engine";
|
|
32
|
+
|
|
33
|
+
@registerType
|
|
34
|
+
export class HelloWorld extends Behaviour {
|
|
35
|
+
@serializable() message: string = "Hello!";
|
|
36
|
+
|
|
37
|
+
start() {
|
|
38
|
+
console.log(this.message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
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.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Key Concepts
|
|
48
|
+
|
|
49
|
+
**Needle Engine** ships 3D scenes from Unity or Blender as GLB files and renders them in the browser using Three.js. TypeScript components attached to objects are serialized into the GLB and re-hydrated at runtime.
|
|
50
|
+
|
|
51
|
+
- **Unity workflow:** C# MonoBehaviours → auto-generated TypeScript stubs → GLB export on play/build
|
|
52
|
+
- **Blender workflow:** Components added via the Needle Engine Blender addon → GLB export with component data embedded
|
|
53
|
+
- **Embedding:** `<needle-engine src="assets/scene.glb">` web component creates and manages a 3D context
|
|
54
|
+
- **Context access:** use `onStart(ctx => { ... })` or `onInitialize(ctx => { ... })` lifecycle hooks (preferred); `document.querySelector("needle-engine").context` works but only from UI event handlers
|
|
55
|
+
|
|
56
|
+
### `<needle-engine>` Attributes
|
|
57
|
+
|
|
58
|
+
Boolean attributes can be disabled with `="0"` (e.g. `camera-controls="0"`).
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<needle-engine
|
|
62
|
+
src="assets/scene.glb"
|
|
63
|
+
camera-controls
|
|
64
|
+
auto-rotate
|
|
65
|
+
autoplay
|
|
66
|
+
background-color="#222"
|
|
67
|
+
environment-image="studio"
|
|
68
|
+
contactshadows
|
|
69
|
+
></needle-engine>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
| Attribute | Description |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `src` | GLB/glTF file path(s) — string, array, or comma-separated |
|
|
75
|
+
| `camera-controls` | Adds default OrbitControls with auto-fit if no `OrbitControls`/`ICameraController` exists in the root GLB. Disable with `="0"` for fully custom camera. To tweak defaults, get `OrbitControls` from the main camera in `onStart` |
|
|
76
|
+
| `auto-rotate` | Auto-rotate the camera (requires `camera-controls`) |
|
|
77
|
+
| `autoplay` | Auto-play animations in the loaded scene |
|
|
78
|
+
| `background-color` | Hex or RGB background color (e.g. `#ff0000`) |
|
|
79
|
+
| `background-image` | Skybox URL or preset: `studio`, `blurred-skybox`, `quicklook`, `quicklook-ar` |
|
|
80
|
+
| `background-blurriness` | Blur intensity for background (0–1) |
|
|
81
|
+
| `environment-image` | Environment lighting image URL or preset (same presets as `background-image`) |
|
|
82
|
+
| `contactshadows` | Enable contact shadows |
|
|
83
|
+
| `tone-mapping` | `none`, `linear`, `neutral`, `agx` |
|
|
84
|
+
| `poster` | Placeholder image URL shown while loading |
|
|
85
|
+
| `loadstart` / `progress` / `loadfinished` | Callback functions for loading lifecycle |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Unity → Needle Cheat Sheet
|
|
90
|
+
|
|
91
|
+
| Unity (C#) | Needle Engine (TypeScript) |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `MonoBehaviour` | `Behaviour` |
|
|
94
|
+
| `[SerializeField]` / public field | `@serializable()` (required for all serialized fields) |
|
|
95
|
+
| `Instantiate(prefab)` | `instantiate(obj)` |
|
|
96
|
+
| `Destroy(obj)` | `destroy(obj)` |
|
|
97
|
+
| `GetComponent<T>()` | `this.gameObject.getComponent(T)` |
|
|
98
|
+
| `AddComponent<T>()` | `this.gameObject.addComponent(T)` |
|
|
99
|
+
| `FindObjectOfType<T>()` | `findObjectOfType(T, ctx)` |
|
|
100
|
+
| `transform.position` | `this.gameObject.worldPosition` (world) / `this.gameObject.position` (local) |
|
|
101
|
+
| `transform.rotation` | `this.gameObject.worldQuaternion` (world) / `this.gameObject.quaternion` (local) |
|
|
102
|
+
| `transform.localScale` | `this.gameObject.worldScale` (world) / `this.gameObject.scale` (local) |
|
|
103
|
+
| `Resources.Load<T>()` | No direct equivalent — use `@serializable(AssetReference)` to assign refs in editor, then `.instantiate()` or `.asset` at runtime |
|
|
104
|
+
| `StartCoroutine()` | `this.startCoroutine()` (in a component; unlike Unity, coroutines stop when the component is disabled) |
|
|
105
|
+
| `Time.deltaTime` | `this.context.time.deltaTime` |
|
|
106
|
+
| `Camera.main` | `this.context.mainCamera` (THREE.Camera) / `this.context.mainCameraComponent` (Needle Camera component) |
|
|
107
|
+
| `Debug.Log()` | `console.log()` |
|
|
108
|
+
| `OnCollisionEnter()` | `onCollisionEnter(col: Collision)` |
|
|
109
|
+
| `OnTriggerEnter()` | `onTriggerEnter(col: Collision)` |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Three.js → Needle Cheat Sheet
|
|
114
|
+
|
|
115
|
+
| Three.js | Needle Engine |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `new Mesh(geo, mat)` | Created in Unity/Blender, exported as GLB; access via `Renderer.sharedMesh` / `Renderer.sharedMaterials` |
|
|
118
|
+
| `scene.add(obj)` | `this.gameObject.add(obj)` or `instantiate(prefab)` |
|
|
119
|
+
| `scene.remove(obj)` | `obj.removeFromParent()` (re-parent) or `destroy(obj)` (permanent) |
|
|
120
|
+
| `obj.position` | `obj.position` (local) / `obj.worldPosition` (world — Needle extension) |
|
|
121
|
+
| `obj.quaternion` | `obj.quaternion` (local) / `obj.worldQuaternion` (world — Needle extension) |
|
|
122
|
+
| `obj.scale` | `obj.scale` (local) / `obj.worldScale` (world — Needle extension) |
|
|
123
|
+
| `obj.getWorldPosition(v)` | `obj.worldPosition` (getter, no temp vec needed) |
|
|
124
|
+
| `obj.traverse(cb)` | `obj.traverse(cb)` (same — it's Three.js underneath) |
|
|
125
|
+
| `obj.children` | `obj.children` (same) |
|
|
126
|
+
| `obj.parent` | `obj.parent` (same) |
|
|
127
|
+
| `raycaster.intersectObjects()` | `this.context.physics.raycast()` (auto BVH, faster) |
|
|
128
|
+
| `renderer.setAnimationLoop(cb)` | `update() {}` in a component, or `onUpdate(cb)` hook |
|
|
129
|
+
| `clock.getDelta()` | `this.context.time.deltaTime` |
|
|
130
|
+
| `new GLTFLoader().load(url)` | `AssetReference.getOrCreate(base, url)` then `.instantiate()`, or `loadAsset(url)` |
|
|
131
|
+
|
|
132
|
+
Needle Engine extends `Object3D` with component methods (`getComponent`, `addComponent`, `worldPosition`, `worldQuaternion`, `worldScale`, `worldForward`, `worldRight`, `worldUp`, `contains`, etc.). `this.gameObject` is the `Object3D` a component is attached to. The underlying Three.js API still works directly.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Creating a New Project
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm create needle my-app # Vite (default)
|
|
140
|
+
npm create needle my-app -t react # React + Vite
|
|
141
|
+
npm create needle my-app -t vue # Vue + Vite
|
|
142
|
+
npm create needle my-app -t sveltekit # SvelteKit
|
|
143
|
+
npm create needle my-app -t nextjs # Next.js
|
|
144
|
+
npm create needle my-app -t react-three-fiber # R3F
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Vite Plugin System
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { defineConfig } from "vite";
|
|
153
|
+
import { needlePlugins } from "@needle-tools/engine/vite";
|
|
154
|
+
|
|
155
|
+
export default defineConfig(async ({ command }) => ({
|
|
156
|
+
plugins: [
|
|
157
|
+
...(await needlePlugins(command, {}, {})),
|
|
158
|
+
],
|
|
159
|
+
}));
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Deployment
|
|
165
|
+
|
|
166
|
+
- **Needle Cloud** — `npx needle-cloud deploy`
|
|
167
|
+
- **Vercel / Netlify** — standard Vite web app
|
|
168
|
+
- **itch.io** — for games
|
|
169
|
+
- **Any static host / FTP** — `npm run build` (or `npm run build:production`) produces a standard dist folder
|
|
170
|
+
|
|
171
|
+
From Unity, built-in deployment components (e.g. `DeployToNetlify`) require a PRO license. Needle Cloud deployment works with the free tier.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Progressive Loading (`@needle-tools/gltf-progressive`)
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import { useNeedleProgressive } from "@needle-tools/gltf-progressive";
|
|
179
|
+
useNeedleProgressive(gltfLoader, renderer);
|
|
180
|
+
gltfLoader.load(url, (gltf) => scene.add(gltf.scene));
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
In Needle Engine projects this is built in — configure via **Compression & LOD Settings** in Unity.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Searching the Documentation
|
|
188
|
+
|
|
189
|
+
Use the `needle_search` MCP tool to find relevant docs, forum posts, and community answers:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
needle_search("how to play animation clip from code")
|
|
193
|
+
needle_search("SyncedTransform multiplayer")
|
|
194
|
+
needle_search("deploy to Needle Cloud CI")
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Use this *before* guessing at API details — the docs are the source of truth.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Common Gotchas
|
|
202
|
+
|
|
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
|
|
210
|
+
- `loadAsset()` returns a model wrapper (not an Object3D) — use `.scene` to get the root Object3D
|
|
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
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## References
|
|
216
|
+
|
|
217
|
+
Read these **only when needed** — don't load them all upfront:
|
|
218
|
+
|
|
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
|
|
223
|
+
|
|
224
|
+
## Important URLs
|
|
225
|
+
|
|
226
|
+
- Docs: https://engine.needle.tools/docs/
|
|
227
|
+
- Samples: https://engine.needle.tools/samples/
|
|
228
|
+
- GitHub: https://github.com/needle-tools/needle-engine-support
|
|
229
|
+
- npm: https://www.npmjs.com/package/@needle-tools/engine
|