Saturday, 15 June 2013

javascript - Trying to push vertices inside of a function with Three js -



javascript - Trying to push vertices inside of a function with Three js -

i trying create template function force multiple equilateral triangles scene based on parameters passed through function. current method using:

function createequitri(x, y, sidelength){ var geometry = new three.geometry(); geometry.verticies.push( new three.vector3(x,(math.sqrt(3)/2*sidelength)-(sidelength/2),0)); geometry.verticies.push( new three.vector3(x-(sidelength/2),y-(sidelength/2),0)); geometry.verticies.push( new three.vector3(x+(sidelength/2),y-(sidelength/2),0)); geometry.faces.push( new three.face3( 0, 1, 2 )); var redmat = new three.meshbasicmaterial({color: 0xff0000}); var triangle = new three.mesh(geometry, redmat); scene.add(triangle) } createequitri(0,0,20);

however in console receiving error can attribute scope saying says: "uncaught typeerror: cannot read property 'push' of undefined". dont know why undefined due geometry variable beingness in same function.

javascript three.js

No comments:

Post a Comment