docs
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help

UnityFor Unity Developers

From UnityC#Unity to three.jsthree.js with Needle EngineNeedle Engine

Needle Engine provides tight integration with the Unity Editor, allowing developers and designers to work together in a familiar environment and deliver fast, performant, and lightweight web experiences.

Who is this guide for?

  • Unity developers learning web development
  • Web developers understanding Needle Engine's Unity integration
  • Teams bridging Unity and three.js workflows

Getting Started

Make sure you have Needle Engine installed in Unity: Unity Installation


The Basics

three.jsBuilt on three.js

Needle Engine is a 3D web engine built on three.js, one of the most popular WebGL rendering libraries.

Key concept: In Needle Engine, a gameObject is a three.js Object3D. These terms are interchangeable.

Benefits:

  • Full three.js compatibility - use any three.js code or library
  • Access to the entire three.js ecosystem
  • No learning curve if you already know three.js

How Needle Engine Works

Needle Engine does NOT compile C# code to WebAssembly.

Instead:

  • Unity defines scene structure, components, and data
  • Export process converts to glTF format
  • TypeScript/JavaScript powers runtime behavior

Why? Fast iteration speed and maximum flexibility for web experiences. Read more: Vision • Technical Overview

How to create a new Unity project with Needle Engine? (Video)

Learning Path

This tutorial is split into two focused guides to help you learn efficiently:

1. UnityWorking with Unity Integration

Start here to understand how Needle Engine integrates with Unity:

  • How the Unity workflow translates to web
  • Creating and structuring components
  • Understanding glTF export
  • Managing web projects and packages
  • Editor sync and hot reload

Read: Working with Unity Integration →

What you'll learn:

  • Unity Editor workflow with Needle Engine
  • Component system and @serializable decorator
  • GameObject/Object3D hierarchy and scene structure
  • Type mappings (Unity → three.js)
  • glTF export process (what gets exported, what doesn't)
  • Web project structure on disk
  • Package management (npm vs Unity Package Manager)
  • Build tools and framework integration

2. C#C# to TypeScriptTypeScript Translation

Continue here to translate your C# knowledge to TypeScript:

  • Value types vs reference types (structs vs objects)
  • Vector math without operator overloading
  • Time, input, and raycasting APIs
  • Debug logging and gizmos
  • Common utility methods

Read: C# to TypeScript Translation →

What you'll learn:

  • Critical differences in how vectors work (copy vs reference)
  • Using method calls instead of operators (vector.add() not vector +)
  • Accessing time via this.context.time
  • Input polling and event subscription
  • Raycasting with and without physics
  • Console logging and runtime gizmos
  • Platform detection utilities

Quick Reference

Core Type Mappings:

Unity TypeNeedle Engine TypeNotes
MonoBehaviourBehaviourBase class for components
GameObjectObject3DSame as three.js Object3D
TransformObject3DNo separate Transform component
Time.deltaTimethis.context.time.deltaTimeAccess via context
Inputthis.context.inputAccess via context
Physics.Raycastthis.context.physics.raycast()Access via context
UnityEventEventListUse @serializable(EventList)
ColorRGBAColorCustom type with alpha

Key Difference

In Unity, position is world space by default. In three.js/Needle Engine, position is local space.

Use worldPosition for world coordinates!


New to TypeScript?

If you're not familiar with TypeScript or JavaScript fundamentals, start here:

TypeScript Essentials →

Learn the core language concepts:

  • Variables (let, const, var)
  • Functions and arrow functions
  • Objects and classes
  • Imports and modules
  • How references work in JavaScript

What's Next?

After completing both guides:

  • Create Components - Build interactive components
  • Lifecycle Methods - Complete lifecycle API reference
  • Component Reference - Built-in components
  • Scripting Examples - Code examples and patterns

Additional Resources:

  • three.js Documentation - Core rendering library
  • TypeScript Handbook - Language reference
  • Needle Engine Samples - Example projects
Suggest changes
Last Updated: 1/28/26, 10:33 AM

Extras

ChatGPT Ask ChatGPT Claude Ask Claude
Copy Markdown

Navigation

  • Getting Started
  • Tutorials
  • How-To Guides
  • Explanation
  • Reference
  • Help

Extras

ChatGPT Ask ChatGPT Claude Ask Claude
Copy Markdown