import { SmcErr } from "./errors.js"; import { SmcBuilder } from "./builder.js"; export { SmcErr }; // XXX: TODO: merge SmcBuilder into smc class smc { #canvas; #builderDelegate = _ => { }; constructor(canvas) { this.#canvas = canvas; } build(delegate) { this.#builderDelegate = delegate; return this; } onError(delegate) { this.#errorDelegate = delegate; return this; } run() { this.#canvas = canvas; const gl = this.#canvas.getContext("webgl"); if (gl == null) { this.#raiseError( SmcErr.UNSUPPORTED, Error("Unable to initialize WebGL. Your browser or machine may not support it."), ); } const builder = this.#builderDelegate(new SmcBuilder(gl, this.#raiseError)) builder.render() } }