githubEdit

Needle Engine + three.js

Welcome! If you're here because you know three.js, you're in the right place. Needle Engine is a web-based 3D engine built on top of three.js that makes it easier and faster to create interactive 3D experiences for the web.

What is Needle Engine?

Think of Needle Engine as three.js with superpowers:

  • All the power of three.js (since it's built on it)

  • Plus a component system for better code organization

  • Plus built-in features like physics, XR, networking, and particles

  • Plus visual editing tools (Unity and Blender integrations)

  • Plus automatic optimization and compression

All three.js APIs remain fully accessible – you can write vanilla three.js code, use any three.js-compatible library, or mix and match as needed.

:::tip Try It in 30 Seconds Want to see what Needle Engine can do? Create a new project instantly:

🚀 engine.needle.tools/newarrow-up-right - Opens a ready-to-go project in StackBlitz

No installation, no setup. Just click and start experimenting with three.js + Needle Engine in your browser! :::

Why Choose Needle Engine Over Vanilla three.js?

Enhanced Developer Experience:

  • 🧩 Component system for organizing and reusing 3D logic

  • Built-in features like physics, XR, networking, particles, and UI

  • 🎨 Editor integrations with Unity and Blender for visual scene creation

  • 🚀 Optimized build pipeline with automatic 3D asset compression and optimization

  • 💨 Faster development with less boilerplate and better tooling

Full Flexibility: Whether you're building a simple scene with pure three.js or a complex application with Needle's components, you have complete freedom. The component system is an enhancement, not a replacement – use what makes sense for your project.

:::tip Want Visual Editing? Check out our editor integrations for powerful visual creation workflows:

:::tip Inspect and Debug Use the Needle Inspector Chrome extension to inspect, debug, and edit any three.js scene directly in your browser – perfect for development and learning. :::

[[toc]]


Quick Start: Web Component

The easiest way to get started is using the <needle-engine> web component. Display rich, interactive 3D scenes directly in HTML with just a few lines of code.

Basic Example

Open this example on StackBlitzarrow-up-rightView all web component attributes


Extending with Vanilla three.js

The web component works seamlessly with vanilla three.js code. Use Needle Engine's lifecycle hooks to access the scene and add your own three.js objects, modify materials, or write custom logic.

Adding Objects with onStart

Animating Objects with onUpdate

Modifying Loaded Scene Objects

Available Lifecycle Hooks

Hook
When it's called

onInitialized(callback)

When the context is initialized (before first frame)

onStart(callback)

At the beginning of the first frame after scene loads

onUpdate(callback)

Every frame (perfect for animations)

onBeforeRender(callback)

Before the scene renders

onAfterRender(callback)

After the scene renders

Context Object Properties:

All hooks provide the context object with access to:

  • context.scene - The three.js Scene

  • context.camera - The active Camera

  • context.renderer - The WebGLRenderer

  • context.time - Time data (deltaTime, frame count, etc.)

  • And much more...

:::tip Learn More About Scripting


Installation Options

Install from CDN

Use Needle Engine directly with vanilla JavaScript – no bundler required. The prebundled version includes core components, physics, particles, networking, XR, and more.

When to use:

  • Quick prototypes and experiments

  • Simple integrations into existing websites

  • Learning and exploring Needle Engine

  • Projects without a build pipeline

Install from NPM

For projects using modern JavaScript tooling and bundlers:

When to use:

  • Production applications

  • Projects using bundlers (Vite, Webpack, etc.)

  • TypeScript projects

  • When you need tree-shaking and optimal bundle size

Example usage:


Development Setup

Rapid Prototyping on StackBlitz

For quick experiments, create a new project instantly:

🚀 engine.needle.tools/newarrow-up-right - Start a new project in seconds

📚 StackBlitz Collectionarrow-up-right - Browse example projects

Perfect for:

  • Learning and experimentation

  • Sharing code snippets

  • Quick proof-of-concepts

  • Testing ideas without local setup

Local Development with VS Code

For more control and offline development:

Setup:

  1. Open your project folder in Visual Studio Code

  2. Click Go Live in the VSCode footer

  3. Open http://localhost:5500 in your browser (usually opens automatically)

Benefits:

  • Full control over your development environment

  • Works offline

  • Better performance for large projects

  • Easier integration with version control

:::tip Sample glTF Files Need a test scene? Download this sample glbarrow-up-right to get started quickly. :::


Complete HTML Example

Here's a minimal but complete example showing how to use Needle Engine with vanilla HTML:

@codearrow-up-right

View on GitHubarrow-up-rightView on StackBlitzarrow-up-right


three.js Compatibility

Needle Engine uses a fork of three.jsarrow-up-right that includes additional features and improvements, especially for:

  • WebXR - Enhanced XR session management and features

  • Animation - Improved animation playback and blending

  • USDZ Export - Better support for iOS AR

Full Compatibility: All standard three.js functionality is available in Needle Engine. You can:

  • Use any three.js-compatible library

  • Follow three.js tutorials and examples

  • Import existing three.js code

  • Mix vanilla three.js with Needle components


Next Steps

Learn More:

Build Bigger:

Get Help:


:::tip Using Editor Integrations Did you know that Needle Engine seamlessly integrates with Blender and Unity? Create complex 3D scenes visually and export them directly to the web. Perfect for large projects and team collaboration.

Learn about Unity Integrationarrow-up-rightLearn about Blender Integrationarrow-up-right :::

Last updated