2013-07-11 5 views
0

기본적으로, 나는 Three.js를 사용하여 javascript에서 로봇 객체를 만들고 있는데, 배열 객체를 통해 로봇 부품을 그리는 데 사용하고있는 three.js 장면 변수 객체를 전달하고 있습니다. 어떤 이유로, 장면 객체가 함수로 넘어 가지 않습니다 (그릴 수 없습니다) - 자바 스크립트 함수에 대해 뭔가 빠졌습니까?자바 스크립트로 three.js 객체 전달하기

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"); 
    } 
} 

답변

0

은 어쩌면 이것은 당신을위한 더 같이 작동

Robot.prototype.draw = function() { 
    for (x in this.parts){ 
    this.sc.add(this.parts[x]); // < - spot the difference :) 
    alert("hit"); 
    } 
} 
+0

이 확인 아 ... 내가 그렇지 않은 경우이다 일반 자바 -에서와 같이 x는 실제 객체를 표현한다고 생각? – Skorpius

관련 문제