So basically, I am making a robot object in javascript using Three.js and am passing in the three.js scene variable object I am using to draw the robot parts through the array- for some reason, though, the scene object will not pass into the function (it won't draw)- Am I missing something about 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() {
for (x in this.parts){
this.sc.add(x);
alert("hit");
}
}