AnimationMixer.tests.js 3.3 KB

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