NodeFrame.js 646 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. class NodeFrame {
  2. constructor() {
  3. this.time = 0;
  4. this.deltaTime = 0;
  5. this.frameId = 0;
  6. this.startTime = null;
  7. this.updateMap = new WeakMap();
  8. this.renderer = null;
  9. this.material = null;
  10. }
  11. updateNode( node ) {
  12. if ( this.updateMap.get( node ) !== this.frameId ) {
  13. this.updateMap.set( node, this.frameId );
  14. node.update( this );
  15. }
  16. }
  17. update() {
  18. this.frameId ++;
  19. if ( this.lastTime === undefined ) this.lastTime = performance.now();
  20. this.deltaTime = ( performance.now() - this.lastTime ) / 1000;
  21. this.lastTime = performance.now();
  22. this.time += this.deltaTime;
  23. }
  24. }
  25. export default NodeFrame;