Clock.js 683 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @author simonThiele / https://github.com/simonThiele
  3. */
  4. module( "Clock" );
  5. function mockPerformance() {
  6. self.performance = {
  7. deltaTime: 0,
  8. next: function( delta ) {
  9. this.deltaTime += delta;
  10. },
  11. now: function() {
  12. return this.deltaTime;
  13. }
  14. };
  15. }
  16. test( "clock with performance", function() {
  17. mockPerformance();
  18. var clock = new THREE.Clock();
  19. clock.start();
  20. self.performance.next(123);
  21. ok( clock.getElapsedTime() === 0.123 , "okay");
  22. self.performance.next(100);
  23. ok( clock.getElapsedTime() === 0.223 , "okay");
  24. clock.stop();
  25. self.performance.next(1000);
  26. ok( clock.getElapsedTime() === 0.223 , "don't update time if the clock was stopped");
  27. });