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

BufferGeometry.translate()

参数

translate - 一个三维向量,指定要平移的位置。

描述

该方法根据传递的三维向量平移BufferGeometry的顶点和法向量。这对于在世界空间内转换网格非常有用。

注意

调用该方法后,BufferGeometry的位置和方向将更改。

用法示例

以下示例将BufferGeometry平移2个单位向右:

geometry.translate(new THREE.Vector3(2, 0, 0));

示例

请参考以下代码示例:

const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
const mesh = new THREE.Mesh(geometry, material);

// 平移网格
geometry.translate(new THREE.Vector3(2, 0, 0));

scene.add(mesh);

以上示例中,BoxBufferGeometry被创建,并使用MeshBasicMaterial将其渲染为红色。然后,使用translate()方法将geometry对象平移2个单位向右。 最后,将网格添加到场景中。

参考

https://threejs.org/docs/#api/zh/core/BufferGeometry.translate