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

Matrix4.decompose()

Matrix4.decompose()方法将Matrix4转换为位置、缩放和旋转三个元素的分解形式。

语法

decompose( position: Vector3, quaternion: Quaternion, scale: Vector3 )

参数

  • position- 必需,类型为Vector3,代表物体的位置。
  • quaternion- 必需,类型为Quaternion,代表物体的旋转。
  • scale- 必需,类型为Vector3,代表物体的缩放。

返回值

如果成功分解,返回true,否则返回false。

示例

const matrix = new THREE.Matrix4();
const position = new THREE.Vector3();
const scale = new THREE.Vector3();
const quaternion = new THREE.Quaternion();

matrix.decompose( position, quaternion, scale );

console.log( position );
console.log( scale );
console.log( quaternion );

注意事项

  • 该方法将当前矩阵的所有元素替换为与位置、旋转和缩放相对应的值,因此请确保备份矩阵。
  • 由于旋转和缩放矩阵可能对正交性和行列式的要求存在差异,因此请注意在不同环境中使用时可能会产生误差。

参考文献