1.1.0 • Published 8 years ago

gl-cube v1.1.0

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

gl-cube

Generate all you need to build an webgl cube based on stack.gl

example

npm.io

how to use

var createCube = require("gl-cube");
var cube = createCube(
	gl,
	{
		dimension: {x: 2.0, y: 5.0, z: 2.0},
		position: {x: 3.5, y: 0.0, z: -9.0},
		rotation: {x: 0, y: Math.PI / 2, z: 0},
		color: {r: 0.8, g: 0.1, b: 0.2, a: 1.0}
	}
);


/*In your render method*/
render() {
	/*......*/
	shader.uniforms.uModelView = cube.matrix;
	cube.vertices.bind();
	shader.attributes.aPosition.pointer();
	cube.colors.bind();
	shader.attributes.aColor.pointer();
	cube.normals.bind();
	shader.attributes.aNormal.pointer();
	cube.indices.bind();
	gl.drawElements(gl.TRIANGLES, cube.length, gl.UNSIGNED_SHORT, 0);
	/*......*/
}

how to run demo

npm install
npm run start-example

After running npm start, a wzrd server should start running on http://localhost:9966/ Enjoy!

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago