Capítulo 572 de 859

Chapter 572: MD2Character

Core Idea

This class represents a management component for animated MD2 character assets.

Key Concepts

  • activeAnimationClipName : string: The name of the active animation clip.
  • animationFPS : number: The FPS
  • meshBody : Mesh: The body mesh.
  • meshWeapon : Mesh: The weapon mesh.
  • mixer : AnimationMixer: The animation mixer.
  • root : Object3D: The root 3D object
  • scale : number: The mesh scale.
  • skinsBody : Array.<Texture>: The body skins.
  • skinsWeapon : Array.<Texture>: The weapon skins.
  • weapons : Array.<Mesh>: The weapon meshes.

Code Examples

import { MD2Character } from 'three/addons/misc/MD2Character.js';
  • What it demonstrates: Typical usage of MD2Character.

Reference Tables

Constructor

Signature
new MD2Character()

Properties

PropertyDescription
.activeAnimationClipName : stringThe name of the active animation clip.
.animationFPS : numberThe FPS
.meshBody : MeshThe body mesh.
.meshWeapon : MeshThe weapon mesh.
.mixer : AnimationMixerThe animation mixer.
.root : Object3DThe root 3D object
.scale : numberThe mesh scale.
.skinsBody : Array.<Texture>The body skins.
.skinsWeapon : Array.<Texture>The weapon skins.
.weapons : Array.<Mesh>The weapon meshes.

Methods

MethodDescription
.loadParts( config : Object )Loads the character model for the given config.
.onLoadComplete()The onLoad callback function.
.setAnimation( clipName : string )Sets the defined animation clip as the active animation.
.setPlaybackRate( rate : number )Sets the animation playback rate.
.setSkin( index : number )Sets the skin defined by the given skin index. This will result in a different texture for the body mesh.
.setWeapon( index : number )Sets the weapon defined by the given weapon index. This will result in a different weapon hold by the character.
.setWireframe( wireframeEnabled : boolean )Sets the wireframe material flag.
.syncWeaponAnimation()Synchronizes the weapon with the body animation.
.update( delta : number )Updates the animations of the mesh. Must be called inside the animation loop.

Key Takeaways

  1. Most relevant properties: activeAnimationClipName, animationFPS, meshBody, meshWeapon.
  2. Key methods: loadParts, onLoadComplete, setAnimation, setPlaybackRate.

Connects To