Skip to main content

PrimitiveMeshElement

PrimitiveMeshElement represents a configurable primitive mesh object in the 3D scene. Allows for procedural generation of geometry with appearance and networking options.

Example:

const box = new PrimitiveMeshElement();
box.color = "#00ff00";
box.geometryType = "Box";
box.geometryParameters = new THREE.BoxGeometry(1, 1, 1);
scene.add(box);

color: THREE.Color | string

The surface color of the primitive mesh. Accepts a THREE.Color object or a CSS-style color string (e.g., "#ff0000", "red").

Example:

box.color = "#00ff00"; // Green

geometryType: GeometryType

Specifies the type of geometry to generate for this mesh. Determines the base shape used when rendering the object.

Example:

box.geometryType = "Box";

geometryParameters: THREE.BufferGeometry

Geometry parameters used for defining shape-specific details. Varies by geometryType, e.g., radius and height for Cylinder, width and height for Plane, etc.

Example:

box.geometryParameters = new THREE.BoxGeometry(1, 1, 1);

networkable: boolean

If true, the mesh will be treated as network-synchronized, allowing its state to be replicated across clients.

Example:

box.networkable = true;