v2.1.0,我只想简单的设置个旋转而已,为什么还要搞四元数和欧拉角度的转换……
.
.
.
在 v2.1.0 中,由于 rotationY
被警告 DEPRECATE
:相关文档
我们得从这样:
if (this.m_stNode.rotationY != iNewRotationY) {
this.m_stNode.rotationY = iNewRotationY;
}
改成这样来消除警告:
this.m_stNode.is3DNode = true; // 这个必须要有
if (this.m_stNode.eulerAngles.y != iNewRotationY) {
let newRotation: Quat = new Quat();
let newEulerAngles: Vec3 = this.m_stNode.eulerAngles;
newEulerAngles.y = iNewRotationY;
newRotation.fromEuler(newEulerAngles);
this.m_stNode.setRotation(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
}
感觉这样好不方便啊… (还是我的姿势不标准?)
这样当然是不行的:
if (this.m_stNode.eulerAngles.y != iNewRotationY) {
this.m_stNode.eulerAngles.y = iNewRotationY;
}
.
.
.
也或者,可以这样改:
保留
rotationY
的写法(但同时也保留了警告),只将当前节点的
is3DNode
设为 true
即可。