babylon.animation.tests.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Describes the test suite.
  3. */
  4. describe('Babylon Animation', function() {
  5. let subject: BABYLON.Engine;
  6. /**
  7. * Loads the dependencies.
  8. */
  9. before(function(done) {
  10. this.timeout(180000);
  11. (BABYLONDEVTOOLS).Loader
  12. .useDist()
  13. .testMode()
  14. .load(function() {
  15. // Force apply promise polyfill for consistent behavior between chrome headless, IE11, and other browsers.
  16. BABYLON.PromisePolyfill.Apply(true);
  17. done();
  18. });
  19. });
  20. /**
  21. * Create a new engine subject before each test.
  22. */
  23. beforeEach(function() {
  24. subject = new BABYLON.NullEngine({
  25. renderHeight: 256,
  26. renderWidth: 256,
  27. textureSize: 256,
  28. deterministicLockstep: false,
  29. lockstepMaxSteps: 1
  30. });
  31. // Avoid creating normals in PBR materials.
  32. subject.getCaps().standardDerivatives = true;
  33. });
  34. /**
  35. * Animation tests.
  36. */
  37. describe('#Animation', () => {
  38. it('one key', () => {
  39. const scene = new BABYLON.Scene(subject);
  40. const box = BABYLON.Mesh.CreateBox("box", 1, scene);
  41. scene.createDefaultCamera();
  42. const animation = new BABYLON.Animation("anim", "position.x", 1, BABYLON.Animation.ANIMATIONTYPE_FLOAT);
  43. animation.setKeys([{ frame: 0, value: 1 }]);
  44. box.animations.push(animation);
  45. scene.beginAnimation(box, 0, 0);
  46. scene.render();
  47. expect(box.position.x, "box.position.x").to.equal(1);
  48. });
  49. });
  50. });