BoxGeometry - Verge3D User Manual - Soft8Soft
Description: Learn how to use BoxGeometry in your interactive 3D apps made with Verge3D

BufferGeometry →

# BoxGeometry

BoxGeometry is a geometry class for a rectangular cuboid with a given width, height, and depth. On creation, the cuboid is centred on the origin, with each edge parallel to one of the axes.

## Code Example

`const geometry = new v3d.BoxGeometry(1, 1, 1); const material = new v3d.MeshBasicMaterial({color: 0x00ff00}); const cube = new v3d.Mesh(geometry, material); app.scene.add(cube);`

## Constructor

### BoxGeometry(width : Float, height : Float, depth : Float, widthSegments : Integer, heightSegments : Integer, depthSegments : Integer)

- width — width; that is, the length of the edges parallel to the X axis. Optional; defaults to `1`.
- height — height; that is, the length of the edges parallel to the Y axis. Optional; defaults to `1`.
- depth — depth; that is, the length of the edges parallel to the Z axis. Optional; defaults to `1`.
- widthSegments — number of segmented rectangular faces along the width of the sides. Optional; defaults to `1`.
- heightSegments — number of segmented rectangular faces along the height of the sides. Optional; defaults to `1`.
- depthSegments — number of segmented rectangular faces along the depth of the sides. Optional; defaults to `1`.

Procedural geometry is fun. However, in real life applications this feature is rarely needed. It would be more efficient do design boxes in the preferred modelling suite and export/load to Verge3D via glTF.

## Properties

See the base BufferGeometry class for inherited properties.

### # .parameters : Object

An object with a property for each of the constructor parameters. Any modification after instantiation does not change the geometry.

## Methods

See the base BufferGeometry class for inherited methods.

## Puzzles

The create object puzzle can be used to create boxes in a code-less manner.

## Source

For more info on how to obtain the source code of this module see this page.