如何从Three.js中的父对象访问子对象?

时间:2012-12-29 17:24:54

标签: javascript 3d webgl three.js

我使用了网格来添加对象,然后我将网格添加到场景中。现在我想从网格访问对象,以便我可以在对应的网格中执行旋转对象及其子对象。

示例代码,但建议查找jsfiddle链接以获取详细信息:http://jsfiddle.net/sagh0900/PrVbg/3/

mesh = new THREE.Mesh(new THREE.Geometry());
scene.add(mesh);

renderer = new THREE.WebGLRenderer();

renderer.setClearColorHex(0xffffff, 1);
renderer.setSize( width, height );


for ( var i = 0; i <nSize; i++)
{
    var k = i%10,
        j = (i-k)/10;

    j = j*2 - 10;
    k = k*2 - 10;

    cone1 = lc_relationship.sensor1[i].Geometry; 
    mesh.add(cone1);
    cone2 = lc_relationship.sensor2[i].Geometry;
    mesh.add(cone2);
    cone3 = lc_relationship.sensor3[i].Geometry;
    mesh.add(cone3);
    cone1.position.set(j, k, lc_relationship.sensor1[i].z_cordinate);
    cone2.position.set(j, k, lc_relationship.sensor2[i].z_cordinate);
    cone3.position.set(j, k, lc_relationship.sensor3[i].z_cordinate);
}

enter image description here

提前致谢

0 个答案:

没有答案