Cube
A 3D cube (box) shape with equal-length sides.
Usage
ts
import { createCube } from '@ripl/3d';
const cube = createCube({
x: 0,
y: 0,
z: 0,
size: 2,
fillStyle: '#4488ff',
});Properties
| Property | Type | Default | Description |
|---|---|---|---|
x | number | 0 | X position in world space |
y | number | 0 | Y position in world space |
z | number | 0 | Z position in world space |
size | number | — | Side length of the cube |
rotationX | number | 0 | Rotation around the X axis (radians) |
rotationY | number | 0 | Rotation around the Y axis (radians) |
rotationZ | number | 0 | Rotation around the Z axis (radians) |
fillStyle | string | — | Base fill color (shading is applied per-face) |
Type Guard
ts
import { elementIsCube } from '@ripl/3d';
if (elementIsCube(element)) {
console.log(element.size);
}