MorphAnimMesh.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. console.warn( "THREE.MorphAnimMesh: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
  2. THREE.MorphAnimMesh = function ( geometry, material ) {
  3. THREE.Mesh.call( this, geometry, material );
  4. this.type = 'MorphAnimMesh';
  5. this.mixer = new THREE.AnimationMixer( this );
  6. this.activeAction = null;
  7. };
  8. THREE.MorphAnimMesh.prototype = Object.create( THREE.Mesh.prototype );
  9. THREE.MorphAnimMesh.prototype.constructor = THREE.MorphAnimMesh;
  10. THREE.MorphAnimMesh.prototype.setDirectionForward = function () {
  11. this.mixer.timeScale = 1.0;
  12. };
  13. THREE.MorphAnimMesh.prototype.setDirectionBackward = function () {
  14. this.mixer.timeScale = - 1.0;
  15. };
  16. THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) {
  17. if ( this.activeAction ) {
  18. this.activeAction.stop();
  19. this.activeAction = null;
  20. }
  21. var clip = THREE.AnimationClip.findByName( this, label );
  22. if ( clip ) {
  23. var action = this.mixer.clipAction( clip );
  24. action.timeScale = ( clip.tracks.length * fps ) / clip.duration;
  25. this.activeAction = action.play();
  26. } else {
  27. throw new Error( 'THREE.MorphAnimMesh: animations[' + label + '] undefined in .playAnimation()' );
  28. }
  29. };
  30. THREE.MorphAnimMesh.prototype.updateAnimation = function ( delta ) {
  31. this.mixer.update( delta );
  32. };
  33. THREE.MorphAnimMesh.prototype.copy = function ( source ) {
  34. THREE.Mesh.prototype.copy.call( this, source );
  35. this.mixer = new THREE.AnimationMixer( this );
  36. return this;
  37. };