2016-04-02 8 views
0

緯度/経度データを球にマップしようとしています。私はさまざまな位置のベクトルを取得し、それらにキューブメッシュの位置を設定することができます。私がマージして表示した後は、キューブが1つしかないように見えます。私はすべての立方体が同じ位置にあると仮定しています。私がどこに間違っているのか不思議。 (latLongToSphereはベクトルを返します);Three.jsメッシュ位置がセット上で変化しない

// simple function that converts the data to the markers on screen 
function renderData() { 

    // the geometry that will contain all the cubes 
    var geom = new THREE.Geometry(); 

    // add non reflective material to cube 
    var cubeMat = new THREE.MeshLambertMaterial({color: 0xffffff,opacity:0.6, emissive:0xffffff}); 

    for (var i = quakes.length - 1; i >= 0; i--) { 

     var objectCache = quakes[i]["geometry"]["coordinates"]; 

     // calculate the position where we need to start the cube 
     var position = latLongToSphere(objectCache[0], objectCache[1], 600); 

     // create the cube 
     var cubeGeom = new THREE.BoxGeometry(2,2,2000,1,1,1), 
      cube = new THREE.Mesh(cubeGeom, cubeMat); 

     // position the cube correctly 
     cube.position.set(position.x, position.y, position.z); 
     cube.lookAt(new THREE.Vector3(0,0,0)); 

     // merge with main model 
     geom.merge(cube.geometry, cube.matrix); 
    } 

    // create a new mesh, containing all the other meshes. 
    var combined = new THREE.Mesh(geom, cubeMat); 

    // and add the total mesh to the scene 
    scene.add(combined); 
} 

答えて

1

あなたがそのジオメトリをマージする前に、メッシュ行列を更新する必要があります。

cube.updateMatrix(); 
geom.merge(cube.geometry, cube.matrix); 

jsfiddle:http://jsfiddle.net/L0rdzbej/222/

+0

これは100%正しかったです。私はthree.jsに新しいですし、私は早くそれを設定していたし、私はそれが自動更新と思ったので、私はそれを取り出した。どうもありがとうございました! –

関連する問題