RogueRapier.ts 590 B

123456789101112131415161718192021
  1. import RAPIER from '@dimforge/rapier3d-compat';
  2. export default class RogueRapier {
  3. static world: RAPIER.World;
  4. static eventQueue: RAPIER.EventQueue;
  5. static initialized = false;
  6. static init(onDone: () => void) {
  7. this.initialized = false;
  8. const done = this.doInit();
  9. done.then(() => onDone());
  10. }
  11. private static async doInit() {
  12. await RAPIER.init();
  13. this.world = new RAPIER.World({x: 0, y: -9.81, z: 0});
  14. this.eventQueue && this.eventQueue.clear();
  15. this.eventQueue = this.eventQueue || new RAPIER.EventQueue(true);
  16. this.initialized = true;
  17. }
  18. }