1.0.4 • Published 3 years ago

rounded-box v1.0.4

Weekly downloads
-
License
Unlicense
Repository
github
Last release
3 years ago

Rounded box

Generates a rounded box mesh centered on the origin with configurable dimensions, corner and edge radius, and resolution.

Live Demo

Installation

npm i rounded-box

Example

import { generateRoundedBox } from "rounded-box";

const box = generateRoundedBox({ width: 1, height: 1.25, depth: 1.5 });

API

const box = generateRoundedBox(options?: Options)

Parameters

options

OptionTypeDefaultDescription
widthnumber1The size of the box along the x-axis.
heightnumber1The size of the box along the y-axis.
depthnumber1The size of the box along the z-axis.
radiusnumber0.125The radius of the rounded box corners and edges.
resolutionnumber5The number of segments along the rounded regions of the mesh used to approximate a curve.

Returns

box

NameTypeDescription
positionsnumberThe position of each vertex in the format [x0, y0, z0, x1, y1, z1, ...]
normalsnumberThe normal vector of each vertex in the format [x0, y0, z0, x1, y1, z1, ...]
cellsnumberThe indicies of the mesh in the format [i0, j0, k0, i1, j1, k1, ...]

Running the example

git clone https://github.com/wwwtyro/rounded-box.git
cd rounded-box
npm i
npm run dev

Open a browser to localhost:3000/example/