【发布时间】:2022-11-03 01:35:59
【问题描述】:
- 我在给定位置 (v0) 和旋转 (r0) 有一个头像
- 我在给定位置有一个对象 (v1)
我正在寻找将头像向 v1 旋转的角度。我需要角度我不想使用lookAt() 函数
// Get the Avatar Position
let v0 = new THREE.Vector3();
avatar.getWorldPosition(v0)
// Get the Object Position
let v1 = new THREE.Vector3();
obj.getWorldPosition(v0)
// Get the direction v0 to v1
let dir0 = new THREE.Vector3();
dir0.subVectors( v0, v1 ).normalize();
// Get the direction of avatar (where it look at)
let dir2 = new THREE.Vector3();
avatar.getWorldDirection(dir2)
// Get the angle between the 2 direction
let radians = dir0.angleTo(dir2)
它不起作用!
-
this.mesh.lookAt(v1.setY(0))工作并正确旋转网格 - 但是由于
avatar.getWorldDirection,角度计算不起作用 - 顺便说一句,因为一切都在同一个平面上,所以我不需要 3D(只有 2D)
- 顺便说一句,头像(Mixamo)似乎面朝后
我需要那个角度来触发一些动画(如果角度> 90,则触发90,如果角度> 180,则返回动画......)
【问题讨论】: