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

Matrix4.copy()是Three.js库中的一个Matrix4类方法。Matrix4是一个四阶正方形矩阵,用于在3D空间中表示3D图形对象的变换,如平移、旋转和缩放。

该方法用于将一个Matrix4类对象的值复制到另一个Matrix4类对象中。它不改变任何一个Matrix4的属性。

语法

copy(matrix: Matrix4): Matrix4

参数

  • matrix - 要复制的Matrix4类对象。

返回值

Matrix4 - 一个新的Matrix4对象,其值与参数中的Matrix4对象相同。

例子

以下示例创建两个Matrix4类对象matrix1matrix2,并将matrix1的值复制到matrix2中。

const matrix1 = new THREE.Matrix4();
matrix1.set(
  1, 0, 0, 0,
  0, 1, 0, 0,
  0, 0, 1, 0,
  0, 0, 0, 1
);

const matrix2 = new THREE.Matrix4();

matrix2.copy(matrix1);

console.log(matrix2.elements); // 输出 [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]

注意事项

  • 如果没有指定要复制的Matrix4类对象,则copy()方法返回一个新的空Matrix4类对象。
  • 调用copy()方法时,必须传递一个有效的Matrix4类对象作为参数。如果传递一个非法参数,将会抛出一个异常。