使用cocos creator 3D如何设置cube根据已知的旋转轴和旋转角度进行旋转?

根据鼠标的移动旋转cube。

1赞

Quat.rotateAround

    /**
     * @zh 绕世界空间下指定轴旋转四元数
     * @param axis 旋转轴,默认已归一化
     * @param rad 旋转弧度
     */
    public static rotateAround <Out extends IQuatLike, VecLike extends IVec3Like> (out: Out, rot: Out, axis: VecLike, rad: number) {
        // get inv-axis (local to rot)
        Quat.invert(qt_1, rot);
        Vec3.transformQuat(v3_1, axis, qt_1);
        // rotate by inv-axis
        Quat.fromAxisAngle(qt_1, v3_1, rad);
        Quat.multiply(out, rot, qt_1);
        return out;
    }
1赞