AnimationMixer.tests.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @author TristanVALCKE / https://github.com/Itee
  3. */
  4. /* global QUnit */
  5. import { AnimationMixer } from '../../../../src/animation/AnimationMixer';
  6. import { AnimationClip } from '../../../../src/animation/AnimationClip';
  7. import { VectorKeyframeTrack } from '../../../../src/animation/tracks/VectorKeyframeTrack';
  8. import { Object3D } from '../../../../src/core/Object3D'
  9. import {
  10. zero3,
  11. one3,
  12. two3
  13. } from '../math/Constants.tests';
  14. function getClips(pos1, pos2, scale1, scale2, dur) {
  15. const clips = [];
  16. let track = new VectorKeyframeTrack( ".scale", [ 0, dur ], [ scale1.x, scale1.y, scale1.z, scale2.x, scale2.y, scale2.z ] );
  17. clips.push( new AnimationClip( "scale", dur, [ track ] ) );
  18. track = new VectorKeyframeTrack( ".position", [ 0, dur ], [ pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z ] );
  19. clips.push( new AnimationClip( "position", dur, [ track ] ) );
  20. return clips;
  21. }
  22. export default QUnit.module( 'Animation', () => {
  23. QUnit.module( 'AnimationMixer', () => {
  24. // INHERITANCE
  25. QUnit.todo( "Extending", ( assert ) => {
  26. assert.ok( false, "everything's gonna be alright" );
  27. } );
  28. // INSTANCING
  29. QUnit.todo( "Instancing", ( assert ) => {
  30. assert.ok( false, "everything's gonna be alright" );
  31. } );
  32. // PUBLIC STUFF
  33. QUnit.todo( "clipAction", ( assert ) => {
  34. assert.ok( false, "everything's gonna be alright" );
  35. } );
  36. QUnit.todo( "existingAction", ( assert ) => {
  37. assert.ok( false, "everything's gonna be alright" );
  38. } );
  39. QUnit.test( "stopAllAction", ( assert ) => {
  40. const obj = new Object3D();
  41. const animMixer = new AnimationMixer( obj );
  42. const clips = getClips( zero3, one3, two3, one3, 1 );
  43. const actionA = animMixer.clipAction( clips[ 0 ] );
  44. const actionB = animMixer.clipAction( clips[ 1 ] );
  45. actionA.play();
  46. actionB.play();
  47. animMixer.update( 0.1 );
  48. animMixer.stopAllAction();
  49. assert.ok(
  50. !actionA.isRunning() &&
  51. !actionB.isRunning(),
  52. "All actions stopped" );
  53. assert.ok(
  54. obj.position.x == 0 &&
  55. obj.position.y == 0 &&
  56. obj.position.z == 0,
  57. "Position reset as expected"
  58. );
  59. assert.ok(
  60. obj.scale.x == 1 &&
  61. obj.scale.y == 1 &&
  62. obj.scale.z == 1,
  63. "Scale reset as expected"
  64. );
  65. } );
  66. QUnit.todo( "update", ( assert ) => {
  67. assert.ok( false, "everything's gonna be alright" );
  68. } );
  69. QUnit.test( "getRoot", ( assert ) => {
  70. const obj = new Object3D();
  71. const animMixer = new AnimationMixer( obj );
  72. assert.strictEqual( obj, animMixer.getRoot(), "Get original root object" );
  73. } );
  74. QUnit.todo( "uncacheClip", ( assert ) => {
  75. assert.ok( false, "everything's gonna be alright" );
  76. } );
  77. QUnit.todo( "uncacheRoot", ( assert ) => {
  78. assert.ok( false, "everything's gonna be alright" );
  79. } );
  80. QUnit.todo( "uncacheAction", ( assert ) => {
  81. assert.ok( false, "everything's gonna be alright" );
  82. } );
  83. } );
  84. } );