Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/flo-bit/shapecraft. flo-bit.dev/shapecraft
Something went wrong. Try again.
804 B · 31 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829303132import * as THREE from 'three'import { Mesh } from '../core/mesh'import type { Vec3 } from '../core/types'
export interface BoxOptions { width?: number height?: number depth?: number size?: Vec3 | number widthSegments?: number heightSegments?: number depthSegments?: number}
export function box(options: BoxOptions = {}): Mesh { let { width = 1, height = 1, depth = 1 } = options if (options.size !== undefined) { if (typeof options.size === 'number') { width = height = depth = options.size } else { width = options.size[0] height = options.size[1] depth = options.size[2] } } const geo = new THREE.BoxGeometry( width, height, depth, options.widthSegments, options.heightSegments, options.depthSegments ) return new Mesh(geo)}