Three.js: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
A very useful JavaScript graphics library which uses WebGL build by Mr. Doob (Ricardo Cabello, Google). | A very useful JavaScript graphics library which uses WebGL build by Mr. Doob (Ricardo Cabello, Google). |
Latest revision as of 17:10, 31 December 2021
A very useful JavaScript graphics library which uses WebGL build by Mr. Doob (Ricardo Cabello, Google).
Getting Started
- Install
three
using npm:- npm i three
- Import into your main JS script
import * as THREE from 'three'; // or const THREE = require('three');
You can import specific components from examples as follows:
import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls.js';
import {Stats} from 'three/examples/jsm/libs/stats.module.js';
Instancing
See instancing example.
There are two main ways of instancing in three.js:
- Using an InstancedMesh
- Merging geometries (since we don't have a geometry shader)
Shaders
See ShaderMaterial.