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

AnimationClip.validate()

The AnimationClip.validate() method in Three.js is used to validate an animation clip by checking for duplicate AnimationMixer instance names and ensuring that all the defined tracks are valid.

Syntax

AnimationClip.validate(clip: AnimationClip): boolean

Parameters

Return Value

  • boolean - Returns true if the animation clip is valid, otherwise false is returned.

Description

The AnimationClip.validate() method checks an animation clip for any issues that could arise when using it with an AnimationMixer. It is recommended to always validate an animation clip before using it in the AnimationMixer to avoid unexpected behavior.

The method checks for any duplicate AnimationMixer instance names defined in the clip. If any duplicates are found, an error will be thrown indicating which instance names are duplicates.

The method also checks all the defined tracks in the clip to ensure that they are valid. Invalid tracks are those that have an undefined target object or no keys defined. If any invalid tracks are found, they will be removed from the clip.

Examples

import { AnimationClip } from 'three';

const animationClip = new AnimationClip('my clip', /* duration */ 5.0, [
  /* array of AnimationTracks */
]);

const isValid = AnimationClip.validate(animationClip);

if (!isValid) {
  console.error('Animation clip is invalid');
}

In the above example, a new animation clip is created and then validated using the AnimationClip.validate() method. If the clip is invalid, an error message is logged to the console.

See Also