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

PropertyMixer.apply()

The PropertyMixer.apply() method is a key component of the Three.js library, which is an open-source cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in web browsers.

The PropertyMixer.apply() method is used by animators to calculate and apply the blend weights and values of animated properties to their targets. This method updates the values of the target objects with the new blend weights and values, which are calculated based on the current animation state and the weights specified by the animation data.

Syntax

The syntax for using the PropertyMixer.apply() method is as follows:

PropertyMixer.apply( time, weight );

Where:

  • time is a floating-point number representing the current time of the animation in seconds. This parameter is used to calculate the blend weights and values for the animation properties at the specified time.
  • weight is a floating-point number representing the blend weight of the animation properties. This parameter is used to interpolate the values of the animation properties between their start and end states.

Functionality

The PropertyMixer.apply() method works by iterating through all the animated properties and targets associated with the PropertyMixer instance, and updating their values based on the current animation state and the blend weights specified by the animator.

During each iteration, the method calculates the blended value of each property based on its start and end values, and the blend weight specified by the animator. This blended value is then applied to the target object associated with the property.

If a property's target object is not specified, the method will create a temporary object to store the blended value, and then discard it after the update has been applied to the original target object.

Example

The following example demonstrates how to use the PropertyMixer.apply() method to apply blended animation properties to a target object:

// create a PropertyMixer instance for a target object
var mixer = new THREE.PropertyMixer( target );

// set the blend weights and values for the properties
mixer.setBlendWeight( 'position', 1.0 );
mixer.setBlendWeight( 'rotation', 0.5 );
mixer.setBlendWeight( 'scale', 0.0 );

mixer.setBinding( 'position', target.position );
mixer.setBinding( 'rotation', target.rotation );
mixer.setBinding( 'scale', target.scale );

// update the target object with the blended properties
mixer.apply( time, weight );

In this example, we create a PropertyMixer instance for a target object, and define the blend weights and values for its animation properties. We then set the property bindings for each of the animated properties, which define the target objects they are associated with.

Finally, we call the apply() method to update the target object with the blended properties, specifying the current animation time and the blend weight to use.