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

PropertyBinding.bind()

介绍

PropertyBinding.bind(path, object, propertyName) 方法用于将该属性或对象的子属性绑定到指定的路径上,实现动态的属性更新。

参数

  • path:需要绑定的属性路径,以"."分隔,例如:"object.property.subProperty"。
  • object:需要绑定属性的对象。
  • propertyName:需要绑定的属性名。

返回值

无。

使用示例

import * as THREE from 'three';

const object = {
  property: {
    subProperty: 0
  }
};

const binding = new THREE.PropertyBinding();

binding.bind('property.subProperty', object, 'property.subProperty');

console.log(object.property.subProperty); // 输出:0

binding.setValue(1);

console.log(object.property.subProperty); // 输出:1

注意事项

  • PropertyBinding.bind() 方法仅用于将绑定与属性值关联。
  • 在绑定后,使用 PropertyBinding.setValue() 方法可以设置绑定的值。
  • 绑定的路径必须存在于对象或其父级对象中。
  • 若绑定的属性不存在,会生成一个新的属性。
  • 如果对象没有属性,则绑定会抛出错误。
  • 请谨慎使用 PropertyBinding.bind(),不恰当的使用可能会导致不可预料的结果。