Title: Passing in a three.js object into javascript
Tags: function;object;parameters;three.js
Question: 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");

Here is the accepted answer: Maybe this works more like you intended:
Robot.prototype.draw = function() {
for (x in this.parts){
this.sc.add(this.parts[x]); // < - spot the difference :)
alert("hit");
Comment for this answer: Oh ok...so I thought that the x represented the actual objects like it does in regular Java- is that not the case?


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:07/11/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<function><object><parameters><three.js>', 'Title': 'Passing in a three.js object into javascript', 'ViewCount': 338, 'id': 17585974, 'user_AboutMe': '', 'user_AccountId': 2065169.0, 'user_DisplayName': 'Skorpius', 'user_Reputation': 2103.0, 'user_Views': 131.0, 'user_id': 1840804.0}}