本文整理汇总了TypeScript中THREE.Quaternion.setFromAxisAngle方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Quaternion.setFromAxisAngle方法的具体用法?TypeScript Quaternion.setFromAxisAngle怎么用?TypeScript Quaternion.setFromAxisAngle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Quaternion
的用法示例。
在下文中一共展示了Quaternion.setFromAxisAngle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addElement
function addElement( elem ) {
const scene = elem.getScene();
const geo = elem.getAttribute( "geo" );
const type = geo.type.split( "Buffer" )[ 0 ];
let sceneIndex = sceneList.indexOf( scene );
if ( sceneIndex === -1 ) {
exportData.createWorld( scene );
sceneIndex = sceneList.indexOf( scene );
}
objectList[ sceneIndex ].push( elem );
const position = elem.coreObject.getWorldPosition();
const quaternion = elem.coreObject.getWorldQuaternion();
const scale = elem.coreObject.getWorldScale();
if ( type === "Cylinder" ) {
quaternion.multiply( tmpQuat.multiplyQuaternions(
cylinderQuat,
rotateQuat.setFromAxisAngle( rotateVec, Math.PI / cylinderAngle( geo.value[ 3 ] ) )
) );
}
return {
position: { x: position.x, y: position.y, z: position.z },
quaternion: { w: quaternion.w, x: quaternion.x, y: quaternion.y, z: quaternion.z },
scale: { x: scale.x, y: scale.y, z: scale.z },
sceneIndex,
size: geo.value.slice( 0, type === "Cylinder" ? 4 : type === "Box" ? 3 : type === "Plane" ? 2 : 1/*Sphere*/ ),
type,
};
}
示例2: function
objects.forEach( function( object, I ) {
if ( object.getAttribute( "physics" ).mass === 0 ) { return; }
let i = I + 1; // index of GroundPlane == 0
object.coreObject.position.set(
e.data.dataList[ index ].positions[ 3 * i ],
e.data.dataList[ index ].positions[ 3 * i + 1 ],
e.data.dataList[ index ].positions[ 3 * i + 2 ]
);
object.coreObject.quaternion.set(
e.data.dataList[ index ].quaternions[ 4 * i ],
e.data.dataList[ index ].quaternions[ 4 * i + 1 ],
e.data.dataList[ index ].quaternions[ 4 * i + 2 ],
e.data.dataList[ index ].quaternions[ 4 * i + 3 ]
);
if ( /^Cylinder/.test( object.getAttribute( "geo" ).type ) ) {
object.coreObject.quaternion.multiply( tmpQuat.multiplyQuaternions(
cylinderQuat,
rotateQuat.setFromAxisAngle( rotateVec, Math.PI / cylinderAngle( object.getAttribute( "geo" ).value[ 3 ] ) )
).inverse() );
}
});
示例3: _createQuaternion
_createQuaternion(dimension: MTNX.Dimension, degrees: number) {
const quaternion = new THREE.Quaternion();
const rads = degreesToRadians(degrees);
const Dimension = MTNX.Dimension;
switch (dimension) {
case Dimension.X:
quaternion.setFromAxisAngle(new THREE.Vector3(1, 0, 0), rads);
break;
case Dimension.Y:
quaternion.setFromAxisAngle(new THREE.Vector3(0, 1, 0), rads);
break;
case Dimension.Z:
quaternion.setFromAxisAngle(new THREE.Vector3(0, 0, 1), rads);
break;
default:
console.warn(`Didn't set quaternion value for ${$$hex(dimension)}`);
}
return quaternion;
}