Capítulo 573 de 859

Chapter 573: MD2CharacterComplex

Core Idea

This class represents a management component for animated MD2 character assets. It provides a larger API compared to MD2Character.

Key Concepts

  • angularSpeed : number: The character's angular speed.
  • animationFPS : number: The FPS
  • backAcceleration : number: The character's back acceleration.
  • controls : Object: The movement controls.
  • currentSkin : Texture: The current skin.
  • frontAcceleration : number: The character's front acceleration.
  • frontDeceleration : number: The character's front deceleration.
  • maxReverseSpeed : number: The character's maximum reverse speed.
  • maxSpeed : number: The character's maximum speed.
  • meshBody : Mesh: The body mesh.

Code Examples

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

Reference Tables

Constructor

Signature
new MD2CharacterComplex()

Properties

PropertyDescription
.angularSpeed : numberThe character's angular speed.
.animationFPS : numberThe FPS
.backAcceleration : numberThe character's back acceleration.
.controls : ObjectThe movement controls.
.currentSkin : TextureThe current skin.
.frontAcceleration : numberThe character's front acceleration.
.frontDeceleration : numberThe character's front deceleration.
.maxReverseSpeed : numberThe character's maximum reverse speed.
.maxSpeed : numberThe character's maximum speed.
.meshBody : MeshThe body mesh.
.meshWeapon : MeshThe weapon mesh.
.root : Object3DThe root 3D object
.scale : numberThe mesh scale.
.skinsBody : Array.<Texture>The body skins.
.skinsWeapon : Array.<Texture>The weapon skins.
.transitionFrames : numberThe transition frames.
.weapons : Array.<Mesh>The weapon meshes.

Methods

MethodDescription
.enableShadows( enable : boolean )Toggles shadow casting and receiving on the character's meshes.
.loadParts( config : Object )Loads the character model for the given config.
.setAnimation( animationName : 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.
.setVisible( enable : boolean )Toggles visibility on the character's meshes.
.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.
.shareParts( original : MD2CharacterComplex )Shares certain resources from a different character model.
.updateAnimations( delta : number )Updates the animations of the mesh. Must be called inside the animation loop.
.updateBehaviors()Updates the animation state based on the control inputs.
.updateMovementModel( delta : number )Transforms the character model based on the control input.

Key Takeaways

  1. Most relevant properties: angularSpeed, animationFPS, backAcceleration, controls.
  2. Key methods: enableShadows, loadParts, setAnimation, setPlaybackRate.

Connects To