
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
box-geometry
Advanced tools
Simple cube geometry mesh generator for gl-vao
Creates a Vertex Array Object for a 1x1x1 cube from (-0.5,-0.5,-0.5) to (+0.5.+0.5,+0.5). Also optionally sets UV coordinates for texturing and applies matrix transformations.
For an example, run npm start
or try the live demo.
Click and drag to rotate the cube (uses game-shell-orbit-camera).
See the avatar module for more advanced usage.
Usage:
var createBoxMesh = require('box-geometry');
var mesh = createBoxMesh(gl,
{
// mesh options
}[, globalOpts]);
will create one cube. Alternatively you can pass an array of objects to create multiple cubes in one mesh. Supported mesh options:
uv
: Array to set UV texture coordinates, for each of the six faces.
For each face: the starting U and V coordinates, the width and height (actually
offsets, may be negative to reverse),
and a rotation value (0 to 3, determines where the starting coordinate
corresponds to one of the four face corner vertices). Example using the same
whole texture everywhere:
//x y w h r
0, 0, 1, 1, 0, // back
0, 0, 1, 1, 0, // front
0, 0, 1, 1, 0, // top
0, 0, 1, 1, 0, // bottom
0, 0, 1, 1, 0, // left
0, 0, 1, 1, 0 // right
matrix
: 4x4 transformation matrix, applied to all vertices before adding to mesh
(create using gl-matrix).
Global options:
uDiv
, vDiv
: Divisors used to scale the UV coordinates in the uv
array above.
By default these are 1, but you can set them to a higher value to more conveniently
represent UV coordinates in your application (for example, set to 64 then pass
32 instead of 32/64=0.5, or 1 instead of 1/64=0.015625, etc.).
setWindex
: If true, the w
coordinate of each vertex will be set to the cube's
index. Useful if there are multiple cubes and you want to handle them differently
in the shader using this coordinate. Otherwise it set to 1.0.
BoxGeometry
class (formerly CubeGeometry
)MIT
FAQs
cube geometry mesh generator for gl-vao
The npm package box-geometry receives a total of 349 weekly downloads. As such, box-geometry popularity was classified as not popular.
We found that box-geometry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.