Capítulo 816 de 859
The first lesson in the manual series: three.js is a higher-level 3D library built on WebGL that handles scenes, cameras, lights, materials and math so you don't have to write raw WebGL, illustrated with a minimal spinning-cube app.
Scene and Camera and draws (renders) into a canvas.Scene at the root, containing Mesh, Light, Group and other Object3D-derived nodes.Mesh draws a specific Geometry (vertex data) with a specific Material (surface appearance); both can be reused across multiple meshes.<script type="module"> and an import map is the supported way to bring in the library and its addons.<script type="importmap">
{
"imports": {
"three": "./path/to/three.module.js",
"three/addons/": "./different/path/to/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
</script>
Scene, a Camera, and a WebGLRenderer, plus at least one Mesh (geometry + material) to see anything.Scene; lights, meshes and groups are all nodes in that tree.<script type="module"> and an import map — this is the current supported approach as of r147.MeshBasicMaterial ignores lights entirely; switch to a lit material like MeshPhongMaterial once lighting is added to a scene.