0

所以基本上,我正在使用 Three.js 在 javascript 中制作一个机器人对象,并传入我用来通过数组绘制机器人部件的 three.js 场景变量对象——但由于某种原因,场景对象不会通过进入函数(它不会绘制)-我是否缺少有关 javascript 函数的内容?

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

1 回答 1

0

也许这更像你的意图:

Robot.prototype.draw = function() {
  for (x in this.parts){
    this.sc.add(this.parts[x]); // < - spot the difference :)
    alert("hit");
  }
}
于 2013-07-11T12:16:29.903 回答