JSFiddle - React, Tailwind, and code Playground
by luka kupunia
JavaScript
"use strict";
function Curtains(t) {
var e;
(this.planes = [], this.shaderPasses = [], this._drawStacks = {
opaque: {
length: 0,
programs: []
},
transparent: {
length: 0,
programs: []
}
}, this._drawingEnabled = !0, this._forceRender = !1, "string" == typeof t) && (console.warn("Since v4.0 you should use an object to pass your container and other parameters. Please refer to the docs: https://www.curtainsjs.com/documentation.html"), t = {
container: e = t
});
t.container ? "string" == typeof t.container ? this.container = document.getElementById(t.container) : t.container instanceof Element && (this.container = t.container) : ((e = document.createElement("div")).setAttribute("id", "curtains-canvas"), document.body.appendChild(e), this.container = e);
if (this._autoResize = t.autoResize, null !== this._autoResize && void 0 !== this._autoResize || (this._autoResize = !0), this._autoRender = t.autoRender, null !== this._autoRender && void 0 !== this._autoRender || (this._autoRender = !0), this._watchScroll = t.watchScroll, null !== this._watchScroll && void 0 !== this._watchScroll || (this._watchScroll = !0), this.pixelRatio = t.pixelRatio || window.devicePixelRatio || 1, this.productionMode = t.production || !1, !this.container) return this.productionMode || console.warn("You must specify a valid container ID"), void(this._onErrorCallback && this._onErrorCallback());
this._init()
}
Curtains.prototype._init = function() {
if (this.glCanvas = document.createElement("canvas"), this.glContext = this.glCanvas.getContext("webgl", {
alpha: !0
}) || this.glCanvas.getContext("experimental-webgl"), !this.glContext) return this.productionMode || console.warn("WebGL context could not be created"), void(this._onErrorCallback && this._onErrorCallback());
this._drawStateManager = {
currentProgramID: null,
programs: [],
...