Clock.js 746 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @author simonThiele / https://github.com/simonThiele
  3. */
  4. QUnit.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. QUnit.test( "clock with performance", function( assert ) {
  17. mockPerformance();
  18. var clock = new THREE.Clock( false );
  19. clock.start();
  20. self.performance.next( 123 );
  21. assert.numEqual( clock.getElapsedTime(), 0.123, "okay" );
  22. self.performance.next( 100 );
  23. assert.numEqual( clock.getElapsedTime(), 0.223, "okay" );
  24. clock.stop();
  25. self.performance.next( 1000 );
  26. assert.numEqual( clock.getElapsedTime(), 0.223, "don't update time if the clock was stopped" );
  27. });
粤ICP备19079148号