Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

geo-3d-box

TatumCreative8MIT2.0.2

Generate 3d box geometry

3d, geometry, WebGL, box, cube, simplicial

readme

3d Box Geometry

Generate a 3d box, with optional segments, centered on the origin.

Spinning Box

var box = require('geo-3d-box')({
    size: [5,5,5],
    segments: [2,2,2]
})

or

var box = require('geo-3d-box')({
    size: 5,
    segments: 2
})

The returned object is in the format of a simplicial complex with positions and cell indices (faces). In addition uvs and normals are generated.

box = {
    positions: [ [x,y,z], [x,y,z], ... ],
    cells: [ [0,1,4], [4,3,0], ... ],
    uvs: [ [u,v], [u,v], ... ],
    normals: [ [x,y,z], [x,y,z], ... ],
}

Size (Array or Number)

Either an array or a single number. Sets the width, height, and depth of the box. Defaults to [1,1,1].

Segments (Array or Number)

Subdivide the cube.

Migrating from v1.x.x

The data is now all chunked in tuples like [ [x,y,z], [x,y,z], ... ] instead of [ x,y,z,x,y,z,... ] to be more in-line with stack.gl's ecosystem. In addition normals are now provided by default.

changelog

Changelog

2.0.0

Removed dependencies, and rewrote to be ES5 only. Note the require('geo-3d-box/es5') is no longer an option. The data is now all chunked in tuples like [ [x,y,z], [x,y,z], ... ] instead of [ x,y,z,x,y,z,... ] to be more in-line with stack.gl's ecosystem. In addition normals are now provided by default.

1.0.4

Noted the presence of ES6, and added an ES5 build.

1.0.3

Fixed a winding order issue

1.0.2

Fixed a few issues with the package.json dependencies

1.0.1

Fixed a few issues with the package.json dependencies