2016-04-02 24 views
0

ayarında değişmiyor Lat boy/uzun veriyi bir küreye eşleştirmeye çalışıyorum. Farklı pozisyonlarda vektörler elde edebiliyorum ve küp ağının pozisyonunu bunlara ayarlayabiliyorum. Birleştirip görüntüledikten sonra sadece bir küpün olduğu anlaşılıyor. Tüm küplerin aynı pozisyonda olduğunu farz ediyorum. Burada yanlış olduğum yeri merak ediyorum. (latLongToSphere bir vektör döndürür);Three.js Kafes konumu

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

cevap

1

Bunu geometrisini birleştirme önce örgü matrisi güncelleştirmek için:

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

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

+0

Bu% 100 doğru idi. Ben üç.js için yeniyim ve bu seti daha önce ayarladım ve sonra onu çıkardım çünkü bunu otomatikleştirmeyi düşündüm. Çok teşekkür ederim! –