function - Passing in a three.js object into javascript -
so basically, making robot object in javascript using three.js , passing in three.js scene variable object using draw robot parts through array- reason, though, scene object not pass function (it won't draw)- missing javascript functions?
function robot(sc){ this.sc=sc; var robtexture = new three.meshlambertmaterial({ map: three.imageutils.loadtexture('tex/dmetal.png') }); this.parts = []; var current; //make body current=new three.mesh(new three.cubegeometry(10,15,10), robtexture); this.parts.push(current); alert("hit"); //make legs } robot.prototype.draw = function() { (x in this.parts){ this.sc.add(x); alert("hit"); } }
maybe works more intended:
robot.prototype.draw = function() { (x in this.parts){ this.sc.add(this.parts[x]); // < - spot difference :) alert("hit"); } }
Comments
Post a Comment