BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Quaternion.fromArray()

Quaternion.fromArray() 是一个方法,用于从数组中创建四元数。

语法

static fromArray(array: ArrayLike<number>, offset?: number, quaternion?: Quaternion): Quaternion;

参数

  • array:规定由四个数字组成的数组。
  • offset:可选参数,规定数组中处理取值时的偏移量。默认值为 0。
  • quaternion:可选参数,规定要创建的四元数。如果未定义,将创建一个新的四元数。

返回值

返回一个四元数。

示例

const array = [0.7071067811865475, 0, 0, 0.7071067811865475];
const quaternion = new THREE.Quaternion();

THREE.Quaternion.fromArray(array, 0, quaternion);
console.log(quaternion); //Quaternion {_x: 0.7071067811865475, _y: 0, _z: 0, _w: 0.7071067811865475}

const newQuaternion = THREE.Quaternion.fromArray(array);
console.log(newQuaternion); //Quaternion {_x: 0.7071067811865475, _y: 0, _z: 0, _w: 0.7071067811865475}

说明

Quaternion.fromArray() 方法可以通过一个含有四个数字的数组来创建一个四元数(x,y,z,w)。偏移量可选,如果没有提供偏移量,offset默认值为0.

如果提供的四元数未定义,将创建一个新的四元数。

参考文献