本文整理汇总了TypeScript中THREE.Quaternion.toArray方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Quaternion.toArray方法的具体用法?TypeScript Quaternion.toArray怎么用?TypeScript Quaternion.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Quaternion
的用法示例。
在下文中一共展示了Quaternion.toArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setCameraRotation
export function setCameraRotation(camera: CameraProps, quaternion: number[]): CameraProps {
const orientation = new Quaternion(...quaternion);
const position = getPositionForRotation(camera, orientation);
return {
position: position.toArray(),
orientation: orientation.toArray(),
target: camera.target
};
}
示例2: rotateToBoundingBox
export function rotateToBoundingBox(camera: CameraProps, bb: BoundingBox): CameraProps {
const orientation = new Quaternion(0, 0, 0, 1);
const {center, target} = getBoundingBoxCenter(bb);
const position = getPositionForRotation({
...camera,
target: target.toArray(),
position: FORWARD.toArray()
}, orientation);
return {
position: position.toArray(),
orientation: orientation.toArray(),
target: center.toArray()
};
}
示例3: rotateCamera
export function rotateCamera(camera: CameraProps, rotation: Rotation): CameraProps {
const orientation = new Quaternion(...camera.orientation);
const rotations = Object.entries(rotation)
.filter(([, value]) => isNumber(value));
for (const [axis, value] of rotations) {
const angle = degToRad(value);
const rotation = fromAxisAngle([...axes.get(axis), angle]);
orientation.multiply(rotation);
}
const position = getPositionForRotation(camera, orientation);
return {
position: position.toArray(),
orientation: orientation.toArray(),
target: camera.target
};
}