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.setPosition()

Matrix4.setPosition()方法用于设置矩阵的平移部分。该方法的参数为一个三维向量。

语法

matrix.setPosition(vector3);

参数

  • vector3:一个 THREE.Vector3 对象,表示平移向量。

示例

var matrix = new THREE.Matrix4();

var translation = new THREE.Vector3(10, 20, 30);
matrix.setPosition(translation);

console.log(matrix);

输出:

Matrix4 {
  elements: [
     1, 0, 0, 0, 
     0, 1, 0, 0, 
     0, 0, 1, 0, 
    10,20,30, 1
  ]
}

注意事项

Matrix4.setPosition() 方法不会改变矩阵的旋转部分,只会改变平移部分。如果需要同时改变矩阵的平移和旋转,可以使用 Matrix4.compose() 方法。

参考文献