【发布时间】:2019-06-29 16:41:24
【问题描述】:
我有一个球体和盒子,它们应该是上面的建筑物。我想旋转盒子(围绕 x y 和 z 轴),使它们远离球体,就像普通建筑物会给出盒子的经度和纬度(也是 x、y、z 位置)。
我希望你能帮助我解决我的问题,任何帮助将不胜感激:)
我尝试了很多使用经度和纬度的旋转,但都没有奏效。 我也想过使用从球体中心到建筑物位置的向量来找出旋转但无法提出解决方案。
var lat = i; //-90 to 90
var lon = j; //-180 to 180
var height = 10;
var width = 10;
var length = 10;
var xyz = getXYZ(lat, lon, sphereradius, height);
var boxE3 = document.createElement('a-box');
boxE3.setAttribute('material', {
color: getRandomColor()
});
boxE3.setAttribute('rotation', {
x: 0,
y: lat, //Rotation that needs to be correctly set.
z: lon
});
boxE3.setAttribute('position', {
x: xyz[0],
y: xyz[1],
z: xyz[2]
});
boxE3.setAttribute('scale', {
x: length,
y: height,
z: width
});
sceneEl.appendChild(boxE3);
}
实际结果:
想要的结果:
【问题讨论】:
标签: javascript aframe