[英]Three.js Mesh position not changing on set
我正在尝试将经/纬度数据映射到一个球体。 我能够获得具有不同位置的向量,并将立方体网格的位置设置为那些。 合并并显示后,似乎只有一个多维数据集。 我假设所有的多维数据集都在同一位置。 想知道我在哪里错了。 (latLongToSphere返回一个向量);
// 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);
}
您必须在合并其几何形状之前更新网格矩阵:
cube.updateMatrix();
geom.merge(cube.geometry, cube.matrix);
jsfiddle: http : //jsfiddle.net/L0rdzbej/222/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.