Geometry & Material basics

Back to Modules

Geometry & Material basics

In Three.js, 3D objects are typically created by combining a Geometry (which defines the shape of the object) and a Material (which defines its appearance, like color, texture, and how it reacts to light). These two components are then combined into a Mesh object, which can be added to your scene.

Geometries

Geometries define the shape and structure of a 3D object. They consist of vertices (points in 3D space) and faces (triangles that connect the vertices to form surfaces).

BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments)

Creates a rectangular cuboid.

SphereGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength)

Creates a sphere.

PlaneGeometry(width, height, widthSegments, heightSegments)

Creates a flat rectangular plane.

Materials

Materials define the visual properties of a geometry, such as color, transparency, shininess, and how it interacts with light.

MeshBasicMaterial(parameters)

A non-photorealistic material that doesn't react to light. It's good for simple colored objects or when you don't have lights in your scene.

MeshStandardMaterial(parameters)

A physically based rendering (PBR) material that accurately simulates how light interacts with surfaces. It requires lights in the scene to be visible.

Example: Basic Geometries with Materials

Here's a complete example demonstrating how to create and display a box, sphere, and plane with different materials in Three.js: