scene.js 739 B

123456789101112131415161718192021222324252627
  1. import { actor } from "./actor.js";
  2. import { render_engine } from "./render-engine.js"
  3. class scene extends render_engine {
  4. constructor(initializer = null) {
  5. if (initializer !== null && typeof(initializer) !== "function") {
  6. throw new TypeError("Initializer or function.");
  7. }
  8. const player = new actor();
  9. const canvas = document.createElement("canvas");
  10. const context = canvas.getContext("webgl2");
  11. if (!context) {
  12. throw new TypeError("Browser does not support WebGL.");
  13. }
  14. canvas.classList.add("space-render");
  15. super(canvas, context, player);
  16. if (initializer) {
  17. initializer(this);
  18. }
  19. }
  20. }
  21. export { scene };