How geometries and meshes are related
In each of the examples so far, you’ve seen geometries and meshes being used. For instance, to create a sphere and add it to the scene, we used the following:
const sphereGeometry = new THREE.SphereGeometry(4, 20, 20); const sphereMaterial = new THREE.MeshBasicMaterial({color: 0x7777ff); const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial); scene.add(sphere);
We defined the geometry (THREE.SphereGeometry
), which is the shape of an object, and its material (THREE.MeshBasicMaterial
), and we combined these two in a mesh (THREE.Mesh
) that can be added to a scene. In this section, we’ll take a closer look at geometries and meshes. We’ll start with geometries.
The properties and functions of a geometry
Three.js comes with a large set of geometries out of the box that you can use in your 3D scene. Just add a material, create a mesh, and you’re pretty much done. The following screenshot...