问题描述
我使用 FlyControls.js
作为我的相机视图
我正在尝试向我的对象添加 projectile
弹丸应使用从相机位置到十字准线/十字线位置的角度,并在 3D 空间中自由流动
我尝试使用 camera.position.angleTo(crosshair.position)
但它只返回一个浮点值。在 2D 中我会使用 sin
和 cos
,但 3D 是不同的
此外,射弹是 cylinder
,我该如何旋转圆柱体使其朝向它的方向?
//how to get this information?
projectile.angle = {
x: ?,y: ?,z: ?,};
//how to get this information?
projectile.rotation = faceTowardsDestination;
function animate(){
//projectile movement
projectile.position.x += projectile.angle.x * projectile.speed;
projectile.position.y += projectile.angle.y * projectile.speed;
projectile.position.z += projectile.angle.z * projectile.speed;
requestAnimationFrame(animate);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)