scene.js 780 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { coordinates } from "./coordinates.js";
  2. import { actor } from "./actor.js";
  3. import { render_engine } from "./render-engine.js"
  4. class scene {
  5. #canvas;
  6. #player;
  7. #engine;
  8. constructor() {
  9. this.#player = new actor();
  10. this.#canvas = document.createElement("canvas");
  11. const context = this.#canvas.getContext("webgl2");
  12. if (!context) {
  13. throw new TypeError("Browser does not support WebGL.");
  14. }
  15. this.#engine = new render_engine(this.#canvas, context, this.#player);
  16. this.#canvas.classList.add("space-render");
  17. }
  18. get player() {
  19. return this.#player;
  20. }
  21. get canvas() {
  22. return this.#canvas;
  23. }
  24. run() {
  25. this.#engine.run();
  26. }
  27. }
  28. export { scene };