Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
2,617 changes: 2,617 additions & 0 deletions docs/llms-full.txt

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions docs/llms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Three.js

> Three.js is a cross-browser JavaScript library for creating 3D graphics using WebGL and WebGPU.

## Instructions for Large Language Models

When generating Three.js code, follow these guidelines:

### 1. Use Import Maps (Not Old CDN Patterns)

WRONG - outdated pattern:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
```

CORRECT - modern pattern (always use latest version):
```html
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
</script>
```

### 2. Choosing Between WebGLRenderer and WebGPURenderer

Three.js maintains both renderers:

**Use WebGLRenderer** (default, mature):
- Maximum browser compatibility
- Well-established, many years of development
- Most examples and tutorials use this

```js
import * as THREE from 'three';
const renderer = new THREE.WebGLRenderer();
```

**Use WebGPURenderer** when you need:
- Custom shaders/materials using TSL (Three.js Shading Language)
- Compute shaders
- Advanced node-based materials

```js
import * as THREE from 'three/webgpu';
const renderer = new THREE.WebGPURenderer();
await renderer.init();
```

### 3. TSL (Three.js Shading Language)

When using WebGPURenderer, use TSL instead of raw GLSL for custom materials:

```js
import { texture, uv, color } from 'three/tsl';

const material = new THREE.MeshStandardNodeMaterial();
material.colorNode = texture( myTexture ).mul( color( 0xff0000 ) );
```

TSL benefits:
- Works with both WebGL and WebGPU backends
- No string manipulation or onBeforeCompile hacks
- Type-safe, composable shader nodes
- Automatic optimization

### 4. NodeMaterial Classes (for WebGPU/TSL)

When using TSL, use node-based materials:
- MeshBasicNodeMaterial
- MeshStandardNodeMaterial
- MeshPhysicalNodeMaterial
- LineBasicNodeMaterial
- SpriteNodeMaterial

## Getting Started

- [Installation](https://threejs.org/manual/#en/installation)
- [Creating a Scene](https://threejs.org/manual/#en/creating-a-scene)
- [Fundamentals](https://threejs.org/manual/#en/fundamentals)
- [Responsive Design](https://threejs.org/manual/#en/responsive)

## Renderer Guides

- [WebGPURenderer](https://threejs.org/manual/#en/webgpurenderer)

## Core Concepts

- [TSL Specification](https://threejs.org/docs/#api/en/nodes/TSL): Complete shader language reference
- [Animation System](https://threejs.org/manual/#en/animation-system)
- [Loading 3D Models](https://threejs.org/manual/#en/loading-3d-models)
- [Scene Graph](https://threejs.org/manual/#en/scenegraph)
- [Materials](https://threejs.org/manual/#en/materials)
- [Textures](https://threejs.org/manual/#en/textures)
- [Lights](https://threejs.org/manual/#en/lights)
- [Cameras](https://threejs.org/manual/#en/cameras)
- [Shadows](https://threejs.org/manual/#en/shadows)

## Essential API

### Core
- [Object3D](https://threejs.org/docs/#api/en/core/Object3D)
- [BufferGeometry](https://threejs.org/docs/#api/en/core/BufferGeometry)
- [BufferAttribute](https://threejs.org/docs/#api/en/core/BufferAttribute)

### Scenes
- [Scene](https://threejs.org/docs/#api/en/scenes/Scene)

### Cameras
- [PerspectiveCamera](https://threejs.org/docs/#api/en/cameras/PerspectiveCamera)
- [OrthographicCamera](https://threejs.org/docs/#api/en/cameras/OrthographicCamera)

### Renderers
- [WebGLRenderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer)
- [WebGPURenderer](https://threejs.org/docs/#api/en/renderers/webgpu/WebGPURenderer)

### Objects
- [Mesh](https://threejs.org/docs/#api/en/objects/Mesh)
- [InstancedMesh](https://threejs.org/docs/#api/en/objects/InstancedMesh)
- [Group](https://threejs.org/docs/#api/en/objects/Group)

### Materials
- [MeshBasicMaterial](https://threejs.org/docs/#api/en/materials/MeshBasicMaterial)
- [MeshStandardMaterial](https://threejs.org/docs/#api/en/materials/MeshStandardMaterial)
- [MeshPhysicalMaterial](https://threejs.org/docs/#api/en/materials/MeshPhysicalMaterial)

### Geometries
- [BoxGeometry](https://threejs.org/docs/#api/en/geometries/BoxGeometry)
- [SphereGeometry](https://threejs.org/docs/#api/en/geometries/SphereGeometry)
- [PlaneGeometry](https://threejs.org/docs/#api/en/geometries/PlaneGeometry)

### Lights
- [AmbientLight](https://threejs.org/docs/#api/en/lights/AmbientLight)
- [DirectionalLight](https://threejs.org/docs/#api/en/lights/DirectionalLight)
- [PointLight](https://threejs.org/docs/#api/en/lights/PointLight)
- [SpotLight](https://threejs.org/docs/#api/en/lights/SpotLight)

### Loaders
- [TextureLoader](https://threejs.org/docs/#api/en/loaders/TextureLoader)
- [GLTFLoader](https://threejs.org/docs/#examples/en/loaders/GLTFLoader)

### Controls
- [OrbitControls](https://threejs.org/docs/#examples/en/controls/OrbitControls)
- [TransformControls](https://threejs.org/docs/#examples/en/controls/TransformControls)

### Math
- [Vector2](https://threejs.org/docs/#api/en/math/Vector2)
- [Vector3](https://threejs.org/docs/#api/en/math/Vector3)
- [Matrix4](https://threejs.org/docs/#api/en/math/Matrix4)
- [Quaternion](https://threejs.org/docs/#api/en/math/Quaternion)
- [Color](https://threejs.org/docs/#api/en/math/Color)
73 changes: 73 additions & 0 deletions docs/pages/AMFLoader.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
*Inheritance: Loader →*

# AMFLoader

A loader for the AMF format.

The loader supports materials, color and ZIP compressed files. No constellation support (yet).

## Code Example

```js
const loader = new AMFLoader();
const object = await loader.loadAsync( './models/amf/rook.amf' );
scene.add( object );
```

## Import

AMFLoader is an addon, and must be imported explicitly, see [Installation#Addons](https://threejs.org/manual/#en/installation).

```js
import { AMFLoader } from 'three/addons/loaders/AMFLoader.js';
```

## Constructor

### new AMFLoader( manager : LoadingManager )

Constructs a new AMF loader.

**manager**

The loading manager.

## Methods

### .load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )

Starts loading from the given URL and passes the loaded AMF asset to the `onLoad()` callback.

**url**

The path/URL of the file to be loaded. This can also be a data URI.

**onLoad**

Executed when the loading process has been finished.

**onProgress**

Executed while the loading is in progress.

**onError**

Executed when errors occur.

**Overrides:** [Loader#load](Loader.html#load)

### .parse( data : ArrayBuffer ) : Group

Parses the given AMF data and returns the resulting group.

**data**

The raw AMF asset data as an array buffer.

**Overrides:** [Loader#parse](Loader.html#parse)

**Returns:** A group representing the parsed asset.

## Source

[examples/jsm/loaders/AMFLoader.js](https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/AMFLoader.js)
29 changes: 29 additions & 0 deletions docs/pages/AONode.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
*Inheritance: EventDispatcher → Node → LightingNode →*

# AONode

A generic class that can be used by nodes which contribute ambient occlusion to the scene. E.g. an ambient occlusion map node can be used as input for this module. Used in [NodeMaterial](NodeMaterial.html).

## Constructor

### new AONode( aoNode : Node.<float> )

Constructs a new AO node.

**aoNode**

The ambient occlusion node.

Default is `null`.

## Properties

### .aoNode : Node.<float>

The ambient occlusion node.

Default is `null`.

## Source

[src/nodes/lighting/AONode.js](https://github.com/mrdoob/three.js/blob/master/src/nodes/lighting/AONode.js)
37 changes: 37 additions & 0 deletions docs/pages/ARButton.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ARButton

A utility class for creating a button that allows to initiate immersive AR sessions based on WebXR. The button can be created with a factory method and then appended ot the website's DOM.

## Code Example

```js
document.body.appendChild( ARButton.createButton( renderer ) );
```

## Import

ARButton is an addon, and must be imported explicitly, see [Installation#Addons](https://threejs.org/manual/#en/installation).

```js
import { ARButton } from 'three/addons/webxr/ARButton.js';
```

## Static Methods

### .createButton( renderer : WebGLRenderer | WebGPURenderer, sessionInit : XRSessionInit ) : HTMLElement

Constructs a new AR button.

**renderer**

The renderer.

**sessionInit**

The a configuration object for the AR session.

**Returns:** The button or an error message if `immersive-ar` isn't supported.

## Source

[examples/jsm/webxr/ARButton.js](https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/ARButton.js)
Loading
Loading