Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

box-geometry

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

box-geometry

cube geometry mesh generator for gl-vao

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
317
decreased by-20.95%
Maintainers
1
Weekly downloads
 
Created
Source

box-geometry

Simple cube geometry mesh generator for gl-vao

screenshot

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.

References / see also

License

MIT

Keywords

FAQs

Package last updated on 01 May 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc