scene.js 744 B

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