let startRotate = this.cube.rotation.clone();
let axis = this.cube
.getComponent(cc.UITransform)
.convertToWorldSpaceAR(cc.v3(0, 1, 0))
.subtract(this.cube.worldPosition)
.normalize();
let quat = cc.quat();
cc.Quat.rotateAround(
quat,
startRotate,
axis,
cc.misc.degreesToRadians(angle)
);
this.cube.rotation = quat;
- this.cube: 旋转对象
- axis: 旋转轴,示例为对象的 cc.v3(0, 1, 0) 到对象位置的方向向量
- angle: 旋转角度