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

BoxHelper.update()

BoxHelper.update()Three.js 库中的一个方法,用于更新框架辅助盒的属性。

语法

BoxHelper.update() 方法可直接调用,不需要传入任何参数。

boxHelper.update();

参数说明

该方法没有任何参数。

方法描述

BoxHelper.update() 方法用于更新传入对象的边框辅助盒的属性。当调用 BoxHelper 构造函数创建一个边框辅助盒对象时,该对象的属性为:

{
    box: new THREE.Box3(),
    matrix: new THREE.Matrix4(),
    geometry: new THREE.BoxBufferGeometry(1, 1, 1),
    material: new THREE.MeshBasicMaterial({ color: 0xffff00, wireframe: true }),
    matrixAutoUpdate: false
}

当传入对象发生变化,例如尺寸改变、旋转、平移等操作时,必须通过调用 BoxHelper.update() 方法来更新边框辅助盒的属性,以保证边框辅助盒仍然能够精确包裹传入对象。

示例

以下示例展示了如何创建一个 BoxHelper 对象,并使用 BoxHelper.update() 方法更新其属性。

const cubeGeometry = new THREE.BoxGeometry(10, 10, 10);
const cubeMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 });
const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);
scene.add(cube);

const boxHelper = new THREE.BoxHelper(cube, 0xffff00);
scene.add(boxHelper);

// 改变模型尺寸
cube.scale.set(2, 2, 2);

// 更新边框辅助盒的属性
boxHelper.update();

参考链接