Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Draw a box with triangles in three.js
// the box geometry to initialise
var box=new THREE.Geometry();
// the trick to make all faces: vectors i, j and k have the coordinates of the triangles in the box
var i="011010111111100101000000001011110100".split('').map(c=>(c=='0')?0:1),
// this function multiplies each of the coordinates by a transformation matrix that turns them
// into an arbitrary box,n){
var vec=MRI.multMatVec(mat,[i[n],j[n],k[n]]);
// faces are added to the box
box.faces.push(new THREE.Face3(l*3,l*3+1,l*3+2));
var material=new THREE.MeshBasicMaterial({wireframe:true});
// the final object is added to the scene
mesh=new THREE.Mesh(box,material);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.