@jscad/regl-renderer 2.2.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/demo.html +52 -7
  3. package/dist/jscad-regl-renderer.min.js +3 -3
  4. package/package.json +6 -4
  5. package/src/rendering/commands/drawMesh/index.js +13 -15
  6. package/src/rendering/commands/drawMesh/vColorShaders.js +3 -3
  7. package/types/bound-utils/boundingBox.d.ts +2 -0
  8. package/types/bound-utils/boundingSphere.d.ts +2 -0
  9. package/types/bound-utils/computeBounds.d.ts +10 -0
  10. package/types/cameras/camera.d.ts +4 -0
  11. package/types/cameras/index.d.ts +3 -0
  12. package/types/cameras/orthographicCamera.d.ts +18 -0
  13. package/types/cameras/perspectiveCamera.d.ts +19 -0
  14. package/types/controls/orbitControls.d.ts +125 -0
  15. package/types/geometry-utils-V2/entitiesFromSolids.d.ts +13 -0
  16. package/types/geometry-utils-V2/geom2ToGeometries.d.ts +4 -0
  17. package/types/geometry-utils-V2/geom3ToGeometries.d.ts +4 -0
  18. package/types/geometry-utils-V2/path2ToGeometries.d.ts +4 -0
  19. package/types/index.d.ts +16 -0
  20. package/types/rendering/commands/drawAxis/index.d.ts +4 -0
  21. package/types/rendering/commands/drawExps/drawConnector/arcGeo.d.ts +6 -0
  22. package/types/rendering/commands/drawExps/drawConnector/index.d.ts +2 -0
  23. package/types/rendering/commands/drawExps/drawMesh.d.ts +2 -0
  24. package/types/rendering/commands/drawExps/drawMeshNoNormals.d.ts +2 -0
  25. package/types/rendering/commands/drawExps/drawNormals.d.ts +2 -0
  26. package/types/rendering/commands/drawExps/drawNormals2.d.ts +2 -0
  27. package/types/rendering/commands/drawGrid/index.d.ts +4 -0
  28. package/types/rendering/commands/drawGrid/multi.d.ts +2 -0
  29. package/types/rendering/commands/drawLines/index.d.ts +4 -0
  30. package/types/rendering/commands/drawMesh/index.d.ts +4 -0
  31. package/types/rendering/render.d.ts +4 -0
  32. package/types/rendering/renderContext.d.ts +7 -0
  33. package/types/rendering/renderDefaults.d.ts +9 -0
  34. package/types/utils.d.ts +8 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,47 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.5.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.4.1...@jscad/regl-renderer@2.5.0) (2021-10-17)
7
+
8
+
9
+ ### Features
10
+
11
+ * **web:** changed default serialize to false, eliminating JSON serialize/deserialize ([#928](https://github.com/jscad/OpenJSCAD.org/issues/928)) ([b29993a](https://github.com/jscad/OpenJSCAD.org/commit/b29993a8fd3da3bd43a5f871edae4c60d7f56fc7))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.4.1](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.4.0...@jscad/regl-renderer@2.4.1) (2021-10-04)
18
+
19
+ **Note:** Version bump only for package @jscad/regl-renderer
20
+
21
+
22
+
23
+
24
+
25
+ # [2.4.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.3.0...@jscad/regl-renderer@2.4.0) (2021-09-27)
26
+
27
+
28
+ ### Features
29
+
30
+ * **regl-renderer:** enhanced rendering to use the matrix as provided with the geometry ([#871](https://github.com/jscad/OpenJSCAD.org/issues/871)) ([40802af](https://github.com/jscad/OpenJSCAD.org/commit/40802afeb9a2a45cf3eb4f1b9dc774b8670d8259))
31
+
32
+
33
+
34
+
35
+
36
+ # [2.3.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.2.0...@jscad/regl-renderer@2.3.0) (2021-09-09)
37
+
38
+
39
+ ### Features
40
+
41
+ * **regl-renderer:** typescript definitions and generator. ([#801](https://github.com/jscad/OpenJSCAD.org/issues/801)) ([1616876](https://github.com/jscad/OpenJSCAD.org/commit/16168761c53bbb6ffb604aa69c9c80dcc13eaad3))
42
+
43
+
44
+
45
+
46
+
6
47
  # [2.2.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/regl-renderer@2.1.3...@jscad/regl-renderer@2.2.0) (2021-06-20)
7
48
 
8
49
 
package/demo.html CHANGED
@@ -123,12 +123,29 @@ const renderOptions = {
123
123
  let updateView = true
124
124
 
125
125
  const doRotatePanZoom = () => {
126
+
126
127
  if (rotateDelta[0] || rotateDelta[1]) {
127
128
  const updated = orbitControls.rotate({ controls: state.controls, camera: state.camera, speed: rotateSpeed }, rotateDelta)
128
129
  state.controls = { ...state.controls, ...updated.controls }
129
130
  updateView = true
130
131
  rotateDelta = [0, 0]
131
132
  }
133
+
134
+ if (panDelta[0] || panDelta[1]) {
135
+ const updated = orbitControls.pan({ controls:state.controls, camera:state.camera, speed: panSpeed }, panDelta)
136
+ state.controls = { ...state.controls, ...updated.controls }
137
+ panDelta = [0, 0]
138
+ state.camera.position = updated.camera.position
139
+ state.camera.target = updated.camera.target
140
+ updateView = true
141
+ }
142
+
143
+ if (zoomDelta) {
144
+ const updated = orbitControls.zoom({ controls:state.controls, camera:state.camera, speed: zoomSpeed }, zoomDelta)
145
+ state.controls = { ...state.controls, ...updated.controls }
146
+ zoomDelta = 0
147
+ updateView = true
148
+ }
132
149
  }
133
150
 
134
151
  const updateAndRender = (timestamp) => {
@@ -153,27 +170,55 @@ let lastX = 0
153
170
  let lastY = 0
154
171
 
155
172
  const rotateSpeed = 0.002
173
+ const panSpeed = 1
174
+ const zoomSpeed = 0.08
156
175
  let rotateDelta = [0, 0]
176
+ let panDelta = [0, 0]
177
+ let zoomDelta = 0
178
+ let pointerDown = false
179
+
180
+ const moveHandler = (ev) => {
181
+ if(!pointerDown) return
182
+ const dx = lastX - ev.pageX
183
+ const dy = ev.pageY - lastY
184
+
185
+ const shiftKey = (ev.shiftKey === true) || (ev.touches && ev.touches.length > 2)
186
+ if (shiftKey) {
187
+ panDelta[0] += dx
188
+ panDelta[1] += dy
189
+ } else {
190
+ rotateDelta[0] -= dx
191
+ rotateDelta[1] -= dy
192
+ }
157
193
 
158
- const enterHandler = (ev) => {
159
194
  lastX = ev.pageX
160
195
  lastY = ev.pageY
161
196
 
162
197
  ev.preventDefault()
163
198
  }
164
-
165
- const moveHandler = (ev) => {
166
- rotateDelta[0] += ev.pageX - lastX
167
- rotateDelta[1] += lastY - ev.pageY
168
-
199
+ const downHandler = (ev) => {
200
+ pointerDown = true
169
201
  lastX = ev.pageX
170
202
  lastY = ev.pageY
203
+ containerElement.setPointerCapture(ev.pointerId)
204
+ ev.preventDefault()
205
+ }
206
+
207
+ const upHandler = (ev) => {
208
+ pointerDown = false
209
+ containerElement.releasePointerCapture(ev.pointerId)
210
+ ev.preventDefault()
211
+ }
171
212
 
213
+ const wheelHandler = (ev) => {
214
+ zoomDelta += ev.deltaY
172
215
  ev.preventDefault()
173
216
  }
174
217
 
175
- containerElement.onpointerenter = enterHandler
176
218
  containerElement.onpointermove = moveHandler
219
+ containerElement.onpointerdown = downHandler
220
+ containerElement.onpointerup = upHandler
221
+ containerElement.onwheel = wheelHandler
177
222
 
178
223
  </script>
179
224
  </body>
@@ -257,7 +257,7 @@ function transformMat4(r,t,a){var n=t[0],o=t[1],e=t[2],f=a[3]*n+a[7]*o+a[11]*e+a
257
257
  function transformQuat(r,t,a){var n=t[0],o=t[1],u=t[2],e=a[0],f=a[1],m=a[2],s=a[3],Q=s*n+f*u-m*o,c=s*o+m*n-e*u,d=s*u+e*o-f*n,i=-e*n-f*o-m*u;return r[0]=Q*s+i*-e+c*-m-d*-f,r[1]=c*s+i*-f+d*-e-Q*-m,r[2]=d*s+i*-m+Q*-f-c*-e,r}module.exports=transformQuat;
258
258
 
259
259
  },{}],87:[function(require,module,exports){
260
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.createREGL=t()}(this,function(){function e(e,t){this.id=W++,this.type=e,this.data=t}function t(e){return"["+function e(t){if(0===t.length)return[];var r=t.charAt(0),n=t.charAt(t.length-1);if(1<t.length&&r===n&&('"'===r||"'"===r))return['"'+t.substr(1,t.length-2).replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];if(r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t))return e(t.substr(0,r.index)).concat(e(r[1])).concat(e(t.substr(r.index+r[0].length)));if(1===(r=t.split(".")).length)return['"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];for(t=[],n=0;n<r.length;++n)t=t.concat(e(r[n]));return t}(e).join("][")+"]"}function r(e){return"string"==typeof e?e.split():e}function n(e){return"string"==typeof e?document.querySelector(e):e}function i(e){var t,i,a,f,o=e||{};e={};var u=[],s=[],c="undefined"==typeof window?1:window.devicePixelRatio,l=!1,p=function(e){},h=function(){};if("string"==typeof o?t=document.querySelector(o):"object"==typeof o&&("string"==typeof o.nodeName&&"function"==typeof o.appendChild&&"function"==typeof o.getBoundingClientRect?t=o:"function"==typeof o.drawArrays||"function"==typeof o.drawElements?a=(f=o).canvas:("gl"in o?f=o.gl:"canvas"in o?a=n(o.canvas):"container"in o&&(i=n(o.container)),"attributes"in o&&(e=o.attributes),"extensions"in o&&(u=r(o.extensions)),"optionalExtensions"in o&&(s=r(o.optionalExtensions)),"onDone"in o&&(p=o.onDone),"profile"in o&&(l=!!o.profile),"pixelRatio"in o&&(c=+o.pixelRatio))),t&&("canvas"===t.nodeName.toLowerCase()?a=t:i=t),!f){if(!a){if(!(t=function(e,t,r){function n(){var t=window.innerWidth,n=window.innerHeight;e!==document.body&&(t=(n=e.getBoundingClientRect()).right-n.left,n=n.bottom-n.top),a.width=r*t,a.height=r*n,H(a.style,{width:t+"px",height:n+"px"})}var i,a=document.createElement("canvas");return H(a.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(a),e===document.body&&(a.style.position="absolute",H(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver(function(){setTimeout(n)})).observe(e):window.addEventListener("resize",n,!1),n(),{canvas:a,onDestroy:function(){i?i.disconnect():window.removeEventListener("resize",n),e.removeChild(a)}}}(i||document.body,0,c)))return null;a=t.canvas,h=t.onDestroy}void 0===e.premultipliedAlpha&&(e.premultipliedAlpha=!0),f=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(a,e)}return f?{gl:f,canvas:a,container:i,extensions:u,optionalExtensions:s,pixelRatio:c,profile:l,onDone:p,onDestroy:h}:(h(),p("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function a(e,t){for(var r=Array(e),n=0;n<e;++n)r[n]=t(n);return r}function f(e){var t,r;return t=(65535<e)<<4,t|=r=(255<(e>>>=t))<<3,(t|=r=(15<(e>>>=r))<<2)|(r=(3<(e>>>=r))<<1)|e>>>r>>1}function o(){function e(e){e:{for(var t=16;268435456>=t;t*=16)if(e<=t){e=t;break e}e=0}return 0<(t=r[f(e)>>2]).length?t.pop():new ArrayBuffer(e)}function t(e){r[f(e.byteLength)>>2].push(e)}var r=a(8,function(){return[]});return{alloc:e,free:t,allocType:function(t,r){var n=null;switch(t){case 5120:n=new Int8Array(e(r),0,r);break;case 5121:n=new Uint8Array(e(r),0,r);break;case 5122:n=new Int16Array(e(2*r),0,r);break;case 5123:n=new Uint16Array(e(2*r),0,r);break;case 5124:n=new Int32Array(e(4*r),0,r);break;case 5125:n=new Uint32Array(e(4*r),0,r);break;case 5126:n=new Float32Array(e(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(e){t(e.buffer)}}}function u(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||Y(e.data))}function s(e,t,r,n,i,a){for(var f=0;f<t;++f)for(var o=e[f],u=0;u<r;++u)for(var s=o[u],c=0;c<n;++c)i[a++]=s[c]}function c(e){return 0|K[Object.prototype.toString.call(e)]}function l(e,t){for(var r=0;r<t.length;++r)e[r]=t[r]}function p(e,t,r,n,i,a,f){for(var o=0,u=0;u<r;++u)for(var s=0;s<n;++s)e[o++]=t[i*u+a*s+f]}function h(e,t,r,n){function i(t){this.id=s++,this.buffer=e.createBuffer(),this.type=t,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=5121,this.persistentData=null,r.profile&&(this.stats={size:0})}function a(t,r,n){t.byteLength=r.byteLength,e.bufferData(t.type,r,n)}function f(e,t,r,n,i,f){if(e.usage=r,Array.isArray(t)){if(e.dtype=n||5126,0<t.length)if(Array.isArray(t[0])){i=te(t);for(var o=n=1;o<i.length;++o)n*=i[o];e.dimension=n,a(e,t=ee(t,i,e.dtype),r),f?e.persistentData=t:Q.freeType(t)}else"number"==typeof t[0]?(e.dimension=i,l(i=Q.allocType(e.dtype,t.length),t),a(e,i,r),f?e.persistentData=i:Q.freeType(i)):Y(t[0])&&(e.dimension=t[0].length,e.dtype=n||c(t[0])||5126,a(e,t=ee(t,[t.length,t[0].length],e.dtype),r),f?e.persistentData=t:Q.freeType(t))}else if(Y(t))e.dtype=n||c(t),e.dimension=i,a(e,t,r),f&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(u(t)){i=t.shape;var s=t.stride,h=(o=t.offset,0),d=0,b=0,m=0;1===i.length?(h=i[0],d=1,b=s[0],m=0):2===i.length&&(h=i[0],d=i[1],b=s[0],m=s[1]),e.dtype=n||c(t.data)||5126,e.dimension=d,p(i=Q.allocType(e.dtype,h*d),t.data,h,d,b,m,o),a(e,i,r),f?e.persistentData=i:Q.freeType(i)}else t instanceof ArrayBuffer&&(e.dtype=5121,e.dimension=i,a(e,t,r),f&&(e.persistentData=new Uint8Array(new Uint8Array(t))))}function o(r){t.bufferCount--,n(r),e.deleteBuffer(r.buffer),r.buffer=null,delete h[r.id]}var s=0,h={};i.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},i.prototype.destroy=function(){o(this)};var d=[];return r.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(h).forEach(function(t){e+=h[t].stats.size}),e}),{create:function(n,a,s,d){function b(t){var n=35044,i=null,a=0,o=0,s=1;return Array.isArray(t)||Y(t)||u(t)||t instanceof ArrayBuffer?i=t:"number"==typeof t?a=0|t:t&&("data"in t&&(i=t.data),"usage"in t&&(n=$[t.usage]),"type"in t&&(o=Z[t.type]),"dimension"in t&&(s=0|t.dimension),"length"in t&&(a=0|t.length)),m.bind(),i?f(m,i,n,o,s,d):(a&&e.bufferData(m.type,a,n),m.dtype=o||5121,m.usage=n,m.dimension=s,m.byteLength=a),r.profile&&(m.stats.size=m.byteLength*re[m.dtype]),b}t.bufferCount++;var m=new i(a);return h[m.id]=m,s||b(n),b._reglType="buffer",b._buffer=m,b.subdata=function(t,r){var n,i=0|(r||0);if(m.bind(),Y(t)||t instanceof ArrayBuffer)e.bufferSubData(m.type,i,t);else if(Array.isArray(t)){if(0<t.length)if("number"==typeof t[0]){var a=Q.allocType(m.dtype,t.length);l(a,t),e.bufferSubData(m.type,i,a),Q.freeType(a)}else(Array.isArray(t[0])||Y(t[0]))&&(n=te(t),a=ee(t,n,m.dtype),e.bufferSubData(m.type,i,a),Q.freeType(a))}else if(u(t)){n=t.shape;var f=t.stride,o=a=0,s=0,h=0;1===n.length?(a=n[0],o=1,s=f[0],h=0):2===n.length&&(a=n[0],o=n[1],s=f[0],h=f[1]),n=Array.isArray(t.data)?m.dtype:c(t.data),p(n=Q.allocType(n,a*o),t.data,a,o,s,h,t.offset),e.bufferSubData(m.type,i,n),Q.freeType(n)}return b},r.profile&&(b.stats=m.stats),b.destroy=function(){o(m)},b},createStream:function(e,t){var r=d.pop();return r||(r=new i(e)),r.bind(),f(r,t,35040,0,1,!1),r},destroyStream:function(e){d.push(e)},clear:function(){X(h).forEach(o),d.forEach(o)},getBuffer:function(e){return e&&e._buffer instanceof i?e._buffer:null},restore:function(){X(h).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:f}}function d(e,t,r,n){function i(e){this.id=s++,o[this.id]=this,this.buffer=e,this.primType=4,this.type=this.vertCount=0}function a(n,i,a,f,o,s,c){var l;if(n.buffer.bind(),i?((l=c)||Y(i)&&(!u(i)||Y(i.data))||(l=t.oes_element_index_uint?5125:5123),r._initBuffer(n.buffer,i,a,l,3)):(e.bufferData(34963,s,a),n.buffer.dtype=l||5121,n.buffer.usage=a,n.buffer.dimension=3,n.buffer.byteLength=s),l=c,!c){switch(n.buffer.dtype){case 5121:case 5120:l=5121;break;case 5123:case 5122:l=5123;break;case 5125:case 5124:l=5125}n.buffer.dtype=l}n.type=l,0>(i=o)&&(i=n.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),n.vertCount=i,i=f,0>f&&(i=4,1===(f=n.buffer.dimension)&&(i=0),2===f&&(i=1),3===f&&(i=4)),n.primType=i}function f(e){n.elementsCount--,delete o[e.id],e.buffer.destroy(),e.buffer=null}var o={},s=0,c={uint8:5121,uint16:5123};t.oes_element_index_uint&&(c.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var l=[];return{create:function(e,t){function o(e){if(e)if("number"==typeof e)s(e),l.primType=4,l.vertCount=0|e,l.type=5121;else{var t=null,r=35044,n=-1,i=-1,f=0,p=0;Array.isArray(e)||Y(e)||u(e)?t=e:("data"in e&&(t=e.data),"usage"in e&&(r=$[e.usage]),"primitive"in e&&(n=ne[e.primitive]),"count"in e&&(i=0|e.count),"type"in e&&(p=c[e.type]),"length"in e?f=0|e.length:(f=i,5123===p||5122===p?f*=2:5125!==p&&5124!==p||(f*=4))),a(l,t,r,n,i,f,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return o}var s=r.create(null,34963,!0),l=new i(s._buffer);return n.elementsCount++,o(e),o._reglType="elements",o._elements=l,o.subdata=function(e,t){return s.subdata(e,t),o},o.destroy=function(){f(l)},o},createStream:function(e){var t=l.pop();return t||(t=new i(r.create(null,34963,!0,!1)._buffer)),a(t,e,35040,-1,-1,0,0),t},destroyStream:function(e){l.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof i?e._elements:null},clear:function(){X(o).forEach(f)}}}function b(e){for(var t=Q.allocType(5123,e.length),r=0;r<e.length;++r)if(isNaN(e[r]))t[r]=65535;else if(1/0===e[r])t[r]=31744;else if(-1/0===e[r])t[r]=64512;else{ie[0]=e[r];var n=(a=ae[0])>>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;t[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15<i?n+31744:n+(i+15<<10)+a}return t}function m(e){return Array.isArray(e)||Y(e)}function g(e){return"[object "+e+"]"}function y(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function v(e){return!(!Array.isArray(e)||0===e.length||!m(e[0]))}function x(e){return Object.prototype.toString.call(e)}function w(e){if(!e)return!1;var t=x(e);return 0<=be.indexOf(t)||(y(e)||v(e)||u(e))}function A(e,t){36193===e.type?(e.data=b(t),Q.freeType(t)):e.data=t}function k(e,t,r,n,i,a){if(e=void 0!==ge[e]?ge[e]:ue[e]*me[t],a&&(e*=6),i){for(n=0;1<=r;)n+=e*r*r,r/=2;return n}return e*r*n}function _(e,t,r,n,i,a,f){function o(){this.format=this.internalformat=6408,this.type=5121,this.flipY=this.premultiplyAlpha=this.compressed=!1,this.unpackAlignment=1,this.colorSpace=37444,this.channels=this.height=this.width=0}function s(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function c(e,t){if("object"==typeof t&&t){"premultiplyAlpha"in t&&(e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(e.flipY=t.flipY),"alignment"in t&&(e.unpackAlignment=t.alignment),"colorSpace"in t&&(e.colorSpace=U[t.colorSpace]),"type"in t&&(e.type=N[t.type]);var r=e.width,n=e.height,i=e.channels,a=!1;"shape"in t?(r=t.shape[0],n=t.shape[1],3===t.shape.length&&(i=t.shape[2],a=!0)):("radius"in t&&(r=n=t.radius),"width"in t&&(r=t.width),"height"in t&&(n=t.height),"channels"in t&&(i=t.channels,a=!0)),e.width=0|r,e.height=0|n,e.channels=0|i,r=!1,"format"in t&&(r=t.format,n=e.internalformat=q[r],e.format=ae[n],r in N&&!("type"in t)&&(e.type=N[r]),r in G&&(e.compressed=!0),r=!0),!a&&r?e.channels=ue[e.format]:a&&!r&&e.channels!==oe[e.format]&&(e.format=e.internalformat=oe[e.channels])}}function l(t){e.pixelStorei(37440,t.flipY),e.pixelStorei(37441,t.premultiplyAlpha),e.pixelStorei(37443,t.colorSpace),e.pixelStorei(3317,t.unpackAlignment)}function p(){o.call(this),this.yOffset=this.xOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function h(e,t){var r=null;if(w(t)?r=t:t&&(c(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),w(t.data)&&(r=t.data)),t.copy){var n=i.viewportWidth,a=i.viewportHeight;e.width=e.width||n-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0}else if(r){if(Y(r))e.channels=e.channels||4,e.data=r,"type"in t||5121!==e.type||(e.type=0|K[Object.prototype.toString.call(r)]);else if(y(r)){switch(e.channels=e.channels||4,a=(n=r).length,e.type){case 5121:case 5123:case 5125:case 5126:(a=Q.allocType(e.type,a)).set(n),e.data=a;break;case 36193:e.data=b(n)}e.alignment=1,e.needsFree=!0}else if(u(r)){n=r.data,Array.isArray(n)||5121!==e.type||(e.type=0|K[Object.prototype.toString.call(n)]);a=r.shape;var f,o,s,l,p=r.stride;3===a.length?(s=a[2],l=p[2]):l=s=1,f=a[0],o=a[1],a=p[0],p=p[1],e.alignment=1,e.width=f,e.height=o,e.channels=s,e.format=e.internalformat=oe[s],e.needsFree=!0,f=l,r=r.offset,s=e.width,l=e.height,o=e.channels;for(var h=Q.allocType(36193===e.type?5126:e.type,s*l*o),d=0,g=0;g<l;++g)for(var k=0;k<s;++k)for(var _=0;_<o;++_)h[d++]=n[a*k+p*g+f*_+r];A(e,h)}else if(x(r)===se||x(r)===ce||x(r)===le)x(r)===se||x(r)===ce?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(x(r)===pe)e.element=r,e.width=r.width,e.height=r.height,e.channels=4;else if(x(r)===he)e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(x(r)===de)e.element=r,e.width=r.videoWidth,e.height=r.videoHeight,e.channels=4;else if(v(r)){for(n=e.width||r[0].length,a=e.height||r.length,p=e.channels,p=m(r[0][0])?p||r[0][0].length:p||1,f=J.shape(r),s=1,l=0;l<f.length;++l)s*=f[l];s=Q.allocType(36193===e.type?5126:e.type,s),J.flatten(r,f,"",s),A(e,s),e.alignment=1,e.width=n,e.height=a,e.channels=p,e.format=e.internalformat=oe[p],e.needsFree=!0}}else e.width=e.width||1,e.height=e.height||1,e.channels=e.channels||4}function d(t,r,i,a,f){var o=t.element,u=t.data,s=t.internalformat,c=t.format,p=t.type,h=t.width,d=t.height;l(t),o?e.texSubImage2D(r,f,i,a,c,p,o):t.compressed?e.compressedTexSubImage2D(r,f,i,a,s,h,d,u):t.needsCopy?(n(),e.copyTexSubImage2D(r,f,i,a,t.xOffset,t.yOffset,h,d)):e.texSubImage2D(r,f,i,a,h,d,c,p,u)}function g(){return be.pop()||new p}function _(e){e.needsFree&&Q.freeType(e.data),p.call(e),be.push(e)}function O(){o.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)}function E(e,t,r){var n=e.images[0]=g();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function T(e,t){var r=null;if(w(t))s(r=e.images[0]=g(),e),h(r,t),e.mipmask=1;else if(c(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,i=0;i<n.length;++i)s(r=e.images[i]=g(),e),r.width>>=i,r.height>>=i,h(r,n[i]),e.mipmask|=1<<i;else s(r=e.images[0]=g(),e),h(r,t),e.mipmask=1;s(e,e.images[0])}function D(t,r){for(var i=t.images,a=0;a<i.length&&i[a];++a){var f=i[a],o=r,u=a,s=f.element,c=f.data,p=f.internalformat,h=f.format,d=f.type,b=f.width,m=f.height;l(f),s?e.texImage2D(o,u,h,h,d,s):f.compressed?e.compressedTexImage2D(o,u,p,b,m,0,c):f.needsCopy?(n(),e.copyTexImage2D(o,u,h,f.xOffset,f.yOffset,b,m,0)):e.texImage2D(o,u,h,b,m,0,h,d,c||null)}}function S(){var e=me.pop()||new O;o.call(e);for(var t=e.mipmask=0;16>t;++t)e.images[t]=null;return e}function j(e){for(var t=e.images,r=0;r<t.length;++r)t[r]&&_(t[r]),t[r]=null;me.push(e)}function C(){this.magFilter=this.minFilter=9728,this.wrapT=this.wrapS=33071,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=4352}function F(e,t){"min"in t&&(e.minFilter=W[t.min],0<=fe.indexOf(e.minFilter)&&!("faces"in t)&&(e.genMipmaps=!0)),"mag"in t&&(e.magFilter=R[t.mag]);var r=e.wrapS,n=e.wrapT;if("wrap"in t){var i=t.wrap;"string"==typeof i?r=n=M[i]:Array.isArray(i)&&(r=M[i[0]],n=M[i[1]])}else"wrapS"in t&&(r=M[t.wrapS]),"wrapT"in t&&(n=M[t.wrapT]);if(e.wrapS=r,e.wrapT=n,"anisotropic"in t&&(e.anisotropic=t.anisotropic),"mipmap"in t){switch(r=!1,typeof t.mipmap){case"string":e.mipmapHint=L[t.mipmap],r=e.genMipmaps=!0;break;case"boolean":r=e.genMipmaps=t.mipmap;break;case"object":e.genMipmaps=!1,r=!0}!r||"min"in t||(e.minFilter=9984)}}function V(r,n){e.texParameteri(n,10241,r.minFilter),e.texParameteri(n,10240,r.magFilter),e.texParameteri(n,10242,r.wrapS),e.texParameteri(n,10243,r.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(n,34046,r.anisotropic),r.genMipmaps&&(e.hint(33170,r.mipmapHint),e.generateMipmap(n))}function B(t){o.call(this),this.mipmask=0,this.internalformat=6408,this.id=ge++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new C,f.profile&&(this.stats={size:0})}function z(t){e.activeTexture(33984),e.bindTexture(t.target,t.texture)}function P(){var t=xe[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(3553,null)}function I(t){var r=t.texture,n=t.unit,i=t.target;0<=n&&(e.activeTexture(33984+n),e.bindTexture(i,null),xe[n]=null),e.deleteTexture(r),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete ye[t.id],a.textureCount--}var L={"don't care":4352,"dont care":4352,nice:4354,fast:4353},M={repeat:10497,clamp:33071,mirror:33648},R={nearest:9728,linear:9729},W=H({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},R),U={none:0,browser:37444},N={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},q={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},G={};t.ext_srgb&&(q.srgb=35904,q.srgba=35906),t.oes_texture_float&&(N.float32=N.float=5126),t.oes_texture_half_float&&(N.float16=N["half float"]=36193),t.webgl_depth_texture&&(H(q,{depth:6402,"depth stencil":34041}),H(N,{uint16:5123,uint32:5125,"depth stencil":34042})),t.webgl_compressed_texture_s3tc&&H(G,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),t.webgl_compressed_texture_atc&&H(G,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),t.webgl_compressed_texture_pvrtc&&H(G,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),t.webgl_compressed_texture_etc1&&(G["rgb etc1"]=36196);var Z=Array.prototype.slice.call(e.getParameter(34467));Object.keys(G).forEach(function(e){var t=G[e];0<=Z.indexOf(t)&&(q[e]=t)});var $=Object.keys(q);r.textureFormats=$;var ee=[];Object.keys(q).forEach(function(e){ee[q[e]]=e});var te=[];Object.keys(N).forEach(function(e){te[N[e]]=e});var re=[];Object.keys(R).forEach(function(e){re[R[e]]=e});var ne=[];Object.keys(W).forEach(function(e){ne[W[e]]=e});var ie=[];Object.keys(M).forEach(function(e){ie[M[e]]=e});var ae=$.reduce(function(e,r){var n=q[r];return 6409===n||6406===n||6409===n||6410===n||6402===n||34041===n||t.ext_srgb&&(35904===n||35906===n)?e[n]=n:32855===n||0<=r.indexOf("rgba")?e[n]=6408:e[n]=6407,e},{}),be=[],me=[],ge=0,ye={},ve=r.maxTextureUnits,xe=Array(ve).map(function(){return null});return H(B.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(0>t){for(var r=0;r<ve;++r){var n=xe[r];if(n){if(0<n.bindCount)continue;n.unit=-1}xe[r]=this,t=r;break}f.profile&&a.maxTextureUnits<t+1&&(a.maxTextureUnits=t+1),this.unit=t,e.activeTexture(33984+t),e.bindTexture(this.target,this.texture)}return t},unbind:function(){--this.bindCount},decRef:function(){0>=--this.refCount&&I(this)}}),f.profile&&(a.getTotalTextureSize=function(){var e=0;return Object.keys(ye).forEach(function(t){e+=ye[t].stats.size}),e}),{create2D:function(t,r){function n(e,t){var r=i.texInfo;C.call(r);var a=S();return"number"==typeof e?E(a,0|e,"number"==typeof t?0|t:0|e):e?(F(r,e),T(a,e)):E(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,s(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,z(i),D(a,3553),V(r,3553),P(),j(a),f.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=ee[i.internalformat],n.type=te[i.type],n.mag=re[r.magFilter],n.min=ne[r.minFilter],n.wrapS=ie[r.wrapS],n.wrapT=ie[r.wrapT],n}var i=new B(3553);return ye[i.id]=i,a.textureCount++,n(t,r),n.subimage=function(e,t,r,a){t|=0,r|=0,a|=0;var f=g();return s(f,i),f.width=0,f.height=0,h(f,e),f.width=f.width||(i.width>>a)-t,f.height=f.height||(i.height>>a)-r,z(i),d(f,3553,t,r,a),P(),_(f),n},n.resize=function(t,r){var a=0|t,o=0|r||a;if(a===i.width&&o===i.height)return n;n.width=i.width=a,n.height=i.height=o,z(i);for(var u=0;i.mipmask>>u;++u){var s=a>>u,c=o>>u;if(!s||!c)break;e.texImage2D(3553,u,i.format,s,c,0,i.format,i.type,null)}return P(),f.profile&&(i.stats.size=k(i.internalformat,i.type,a,o,!1,!1)),n},n._reglType="texture2d",n._texture=i,f.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(t,r,n,i,o,u){function l(e,t,r,n,i,a){var o,u=p.texInfo;for(C.call(u),o=0;6>o;++o)b[o]=S();if("number"!=typeof e&&e){if("object"==typeof e)if(t)T(b[0],e),T(b[1],t),T(b[2],r),T(b[3],n),T(b[4],i),T(b[5],a);else if(F(u,e),c(p,e),"faces"in e)for(e=e.faces,o=0;6>o;++o)s(b[o],p),T(b[o],e[o]);else for(o=0;6>o;++o)T(b[o],e)}else for(e=0|e||1,o=0;6>o;++o)E(b[o],e,e);for(s(p,b[0]),p.mipmask=u.genMipmaps?(b[0].width<<1)-1:b[0].mipmask,p.internalformat=b[0].internalformat,l.width=b[0].width,l.height=b[0].height,z(p),o=0;6>o;++o)D(b[o],34069+o);for(V(u,34067),P(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=ee[p.internalformat],l.type=te[p.type],l.mag=re[u.magFilter],l.min=ne[u.minFilter],l.wrapS=ie[u.wrapS],l.wrapT=ie[u.wrapT],o=0;6>o;++o)j(b[o]);return l}var p=new B(34067);ye[p.id]=p,a.cubeCount++;var b=Array(6);return l(t,r,n,i,o,u),l.subimage=function(e,t,r,n,i){r|=0,n|=0,i|=0;var a=g();return s(a,p),a.width=0,a.height=0,h(a,t),a.width=a.width||(p.width>>i)-r,a.height=a.height||(p.height>>i)-n,z(p),d(a,34069+e,r,n,i),P(),_(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,z(p);for(var r=0;6>r;++r)for(var n=0;p.mipmask>>n;++n)e.texImage2D(34069+r,n,p.format,t>>n,t>>n,0,p.format,p.type,null);return P(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,!1,!0)),l}},l._reglType="textureCube",l._texture=p,f.profile&&(l.stats=p.stats),l.destroy=function(){p.decRef()},l},clear:function(){for(var t=0;t<ve;++t)e.activeTexture(33984+t),e.bindTexture(3553,null),xe[t]=null;X(ye).forEach(I),a.cubeCount=0,a.textureCount=0},getTexture:function(e){return null},restore:function(){for(var t=0;t<ve;++t){var r=xe[t];r&&(r.bindCount=0,r.unit=-1,xe[t]=null)}X(ye).forEach(function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var r=0;32>r;++r)if(0!=(t.mipmask&1<<r))if(3553===t.target)e.texImage2D(3553,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;6>n;++n)e.texImage2D(34069+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);V(t.texInfo,t.target)})}}}function O(e,t,r,n,i,a){function f(e,t,r){this.target=e,this.texture=t,this.renderbuffer=r;var n=e=0;t?(e=t.width,n=t.height):r&&(e=r.width,n=r.height),this.width=e,this.height=n}function o(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function u(e,t,r){e&&(e.texture?e.texture._texture.refCount+=1:e.renderbuffer._renderbuffer.refCount+=1)}function s(t,r){r&&(r.texture?e.framebufferTexture2D(36160,t,r.target,r.texture._texture.texture,0):e.framebufferRenderbuffer(36160,t,36161,r.renderbuffer._renderbuffer.renderbuffer))}function c(e){var t=3553,r=null,n=null,i=e;return"object"==typeof e&&(i=e.data,"target"in e&&(t=0|e.target)),"texture2d"===(e=i._reglType)?r=i:"textureCube"===e?r=i:"renderbuffer"===e&&(n=i,t=36161),new f(t,r,n)}function l(e,t,r,a,o){return r?((e=n.create2D({width:e,height:t,format:a,type:o}))._texture.refCount=0,new f(3553,e,null)):((e=i.create({width:e,height:t,format:a}))._renderbuffer.refCount=0,new f(36161,null,e))}function p(e){return e&&(e.texture||e.renderbuffer)}function h(e,t,r){e&&(e.texture?e.texture.resize(t,r):e.renderbuffer&&e.renderbuffer.resize(t,r),e.width=t,e.height=r)}function d(){this.id=k++,_[this.id]=this,this.framebuffer=e.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function b(e){e.colorAttachments.forEach(o),o(e.depthAttachment),o(e.stencilAttachment),o(e.depthStencilAttachment)}function m(t){e.deleteFramebuffer(t.framebuffer),t.framebuffer=null,a.framebufferCount--,delete _[t.id]}function g(t){var n;e.bindFramebuffer(36160,t.framebuffer);var i=t.colorAttachments;for(n=0;n<i.length;++n)s(36064+n,i[n]);for(n=i.length;n<r.maxColorAttachments;++n)e.framebufferTexture2D(36160,36064+n,3553,null,0);e.framebufferTexture2D(36160,33306,3553,null,0),e.framebufferTexture2D(36160,36096,3553,null,0),e.framebufferTexture2D(36160,36128,3553,null,0),s(36096,t.depthAttachment),s(36128,t.stencilAttachment),s(33306,t.depthStencilAttachment),e.checkFramebufferStatus(36160),e.isContextLost(),e.bindFramebuffer(36160,v.next?v.next.framebuffer:null),v.cur=v.next,e.getError()}function y(e,t){function r(e,t){var i,a=0,f=0,o=!0,s=!0;i=null;var h=!0,d="rgba",m="uint8",y=1,v=null,A=null,k=null,_=!1;"number"==typeof e?(a=0|e,f=0|t||a):e?("shape"in e?(a=(f=e.shape)[0],f=f[1]):("radius"in e&&(a=f=e.radius),"width"in e&&(a=e.width),"height"in e&&(f=e.height)),("color"in e||"colors"in e)&&(i=e.color||e.colors,Array.isArray(i)),i||("colorCount"in e&&(y=0|e.colorCount),"colorTexture"in e&&(h=!!e.colorTexture,d="rgba4"),"colorType"in e&&(m=e.colorType,!h)&&("half float"===m||"float16"===m?d="rgba16f":"float"!==m&&"float32"!==m||(d="rgba32f")),"colorFormat"in e&&(d=e.colorFormat,0<=x.indexOf(d)?h=!0:0<=w.indexOf(d)&&(h=!1))),("depthTexture"in e||"depthStencilTexture"in e)&&(_=!(!e.depthTexture&&!e.depthStencilTexture)),"depth"in e&&("boolean"==typeof e.depth?o=e.depth:(v=e.depth,s=!1)),"stencil"in e&&("boolean"==typeof e.stencil?s=e.stencil:(A=e.stencil,o=!1)),"depthStencil"in e&&("boolean"==typeof e.depthStencil?o=s=e.depthStencil:(k=e.depthStencil,s=o=!1))):a=f=1;var O=null,E=null,T=null,D=null;if(Array.isArray(i))O=i.map(c);else if(i)O=[c(i)];else for(O=Array(y),i=0;i<y;++i)O[i]=l(a,f,h,d,m);for(a=a||O[0].width,f=f||O[0].height,v?E=c(v):o&&!s&&(E=l(a,f,_,"depth","uint32")),A?T=c(A):s&&!o&&(T=l(a,f,!1,"stencil","uint8")),k?D=c(k):!v&&!A&&s&&o&&(D=l(a,f,_,"depth stencil","depth stencil")),o=null,i=0;i<O.length;++i)u(O[i]),O[i]&&O[i].texture&&(s=xe[O[i].texture._texture.format]*we[O[i].texture._texture.type],null===o&&(o=s));return u(E),u(T),u(D),b(n),n.width=a,n.height=f,n.colorAttachments=O,n.depthAttachment=E,n.stencilAttachment=T,n.depthStencilAttachment=D,r.color=O.map(p),r.depth=p(E),r.stencil=p(T),r.depthStencil=p(D),r.width=n.width,r.height=n.height,g(n),r}var n=new d;return a.framebufferCount++,r(e,t),H(r,{resize:function(e,t){var i=Math.max(0|e,1),a=Math.max(0|t||i,1);if(i===n.width&&a===n.height)return r;for(var f=n.colorAttachments,o=0;o<f.length;++o)h(f[o],i,a);return h(n.depthAttachment,i,a),h(n.stencilAttachment,i,a),h(n.depthStencilAttachment,i,a),n.width=r.width=i,n.height=r.height=a,g(n),r},_reglType:"framebuffer",_framebuffer:n,destroy:function(){m(n),b(n)},use:function(e){v.setFBO({framebuffer:r},e)}})}var v={cur:null,next:null,dirty:!1,setFBO:null},x=["rgba"],w=["rgba4","rgb565","rgb5 a1"];t.ext_srgb&&w.push("srgba"),t.ext_color_buffer_half_float&&w.push("rgba16f","rgb16f"),t.webgl_color_buffer_float&&w.push("rgba32f");var A=["uint8"];t.oes_texture_half_float&&A.push("half float","float16"),t.oes_texture_float&&A.push("float","float32");var k=0,_={};return H(v,{getFramebuffer:function(e){return"function"==typeof e&&"framebuffer"===e._reglType&&(e=e._framebuffer)instanceof d?e:null},create:y,createCube:function(e){function t(e){var i,a={color:null},f=0,o=null;i="rgba";var u="uint8",s=1;if("number"==typeof e?f=0|e:e?("shape"in e?f=e.shape[0]:("radius"in e&&(f=0|e.radius),"width"in e?f=0|e.width:"height"in e&&(f=0|e.height)),("color"in e||"colors"in e)&&(o=e.color||e.colors,Array.isArray(o)),o||("colorCount"in e&&(s=0|e.colorCount),"colorType"in e&&(u=e.colorType),"colorFormat"in e&&(i=e.colorFormat)),"depth"in e&&(a.depth=e.depth),"stencil"in e&&(a.stencil=e.stencil),"depthStencil"in e&&(a.depthStencil=e.depthStencil)):f=1,o)if(Array.isArray(o))for(e=[],i=0;i<o.length;++i)e[i]=o[i];else e=[o];else for(e=Array(s),o={radius:f,format:i,type:u},i=0;i<s;++i)e[i]=n.createCube(o);for(a.color=Array(e.length),i=0;i<e.length;++i)s=e[i],f=f||s.width,a.color[i]={target:34069,data:e[i]};for(i=0;6>i;++i){for(s=0;s<e.length;++s)a.color[s].target=34069+i;0<i&&(a.depth=r[0].depth,a.stencil=r[0].stencil,a.depthStencil=r[0].depthStencil),r[i]?r[i](a):r[i]=y(a)}return H(t,{width:f,height:f,color:e})}var r=Array(6);return t(e),H(t,{faces:r,resize:function(e){var n=0|e;if(n===t.width)return t;var i=t.color;for(e=0;e<i.length;++e)i[e].resize(n);for(e=0;6>e;++e)r[e].resize(n);return t.width=t.height=n,t},_reglType:"framebufferCube",destroy:function(){r.forEach(function(e){e.destroy()})}})},clear:function(){X(_).forEach(m)},restore:function(){v.cur=null,v.next=null,v.dirty=!0,X(_).forEach(function(t){t.framebuffer=e.createFramebuffer(),g(t)})}})}function E(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function T(e,t,r,n,i){function a(){this.id=++s,this.attributes=[];var e=t.oes_vertex_array_object;this.vao=e?e.createVertexArrayOES():null,c[this.id]=this,this.buffers=[]}var f=r.maxAttributes,o=Array(f);for(r=0;r<f;++r)o[r]=new E;var s=0,c={},l={Record:E,scope:{},state:o,currentVAO:null,targetVAO:null,restore:t.oes_vertex_array_object?function(){t.oes_vertex_array_object&&X(c).forEach(function(e){e.refresh()})}:function(){},createVAO:function(e){function t(e){for(var n=0;n<r.buffers.length;++n)r.buffers[n].destroy();r.buffers.length=0,(n=r.attributes).length=e.length;for(var a=0;a<e.length;++a){var f=e[a],o=n[a]=new E;Array.isArray(f)||Y(f)||u(f)?(f=i.create(f,34962,!1,!0),o.buffer=i.getBuffer(f),o.size=0|o.buffer.dimension,o.normalized=!1,o.type=o.buffer.dtype,o.offset=0,o.stride=0,o.divisor=0,o.state=1,r.buffers.push(f)):i.getBuffer(f)?(o.buffer=i.getBuffer(f),o.size=0|o.buffer.dimension,o.normalized=!1,o.type=o.buffer.dtype,o.offset=0,o.stride=0,o.divisor=0,o.state=1):i.getBuffer(f.buffer)?(o.buffer=i.getBuffer(f.buffer),o.size=0|(+f.size||o.buffer.dimension),o.normalized=!!f.normalized||!1,o.type="type"in f?Z[f.type]:o.buffer.dtype,o.offset=0|(f.offset||0),o.stride=0|(f.stride||0),o.divisor=0|(f.divisor||0),o.state=1):"x"in f&&(o.x=+f.x||0,o.y=+f.y||0,o.z=+f.z||0,o.w=+f.w||0,o.state=2)}return r.refresh(),t}var r=new a;return n.vaoCount+=1,t.destroy=function(){r.destroy()},t._vao=r,t._reglType="vao",t(e)},getVAO:function(e){return"function"==typeof e&&e._vao?e._vao:null},destroyBuffer:function(t){for(var r=0;r<o.length;++r){var n=o[r];n.buffer===t&&(e.disableVertexAttribArray(r),n.buffer=null)}},setVAO:t.oes_vertex_array_object?function(e){if(e!==l.currentVAO){var r=t.oes_vertex_array_object;e?r.bindVertexArrayOES(e.vao):r.bindVertexArrayOES(null),l.currentVAO=e}}:function(r){if(r!==l.currentVAO){if(r)r.bindAttrs();else for(var n=t.angle_instanced_arrays,i=0;i<o.length;++i){var a=o[i];a.buffer?(e.enableVertexAttribArray(i),e.vertexAttribPointer(i,a.size,a.type,a.normalized,a.stride,a.offfset),n&&n.vertexAttribDivisorANGLE(i,a.divisor)):(e.disableVertexAttribArray(i),e.vertexAttrib4f(i,a.x,a.y,a.z,a.w))}l.currentVAO=r}},clear:t.oes_vertex_array_object?function(){X(c).forEach(function(e){e.destroy()})}:function(){}};return a.prototype.bindAttrs=function(){for(var r=t.angle_instanced_arrays,n=this.attributes,i=0;i<n.length;++i){var a=n[i];a.buffer?(e.enableVertexAttribArray(i),e.bindBuffer(34962,a.buffer.buffer),e.vertexAttribPointer(i,a.size,a.type,a.normalized,a.stride,a.offset),r&&r.vertexAttribDivisorANGLE(i,a.divisor)):(e.disableVertexAttribArray(i),e.vertexAttrib4f(i,a.x,a.y,a.z,a.w))}for(r=n.length;r<f;++r)e.disableVertexAttribArray(r)},a.prototype.refresh=function(){var e=t.oes_vertex_array_object;e&&(e.bindVertexArrayOES(this.vao),this.bindAttrs(),l.currentVAO=this)},a.prototype.destroy=function(){if(this.vao){var e=t.oes_vertex_array_object;this===l.currentVAO&&(l.currentVAO=null,e.bindVertexArrayOES(null)),e.deleteVertexArrayOES(this.vao),this.vao=null}c[this.id]&&(delete c[this.id],--n.vaoCount)},l}function D(e,t,r,n){function i(e,t,r,n){this.name=e,this.id=t,this.location=r,this.info=n}function a(e,t){for(var r=0;r<e.length;++r)if(e[r].id===t.id)return void(e[r].location=t.location);e.push(t)}function f(r,n,i){if(!(f=(i=35632===r?s:c)[n])){var a=t.str(n),f=e.createShader(r);e.shaderSource(f,a),e.compileShader(f),i[n]=f}return f}function o(e,t){this.id=h++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],n.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function u(r,o,u){var s;s=f(35632,r.fragId);var c=f(35633,r.vertId);if(o=r.program=e.createProgram(),e.attachShader(o,s),e.attachShader(o,c),u)for(s=0;s<u.length;++s)c=u[s],e.bindAttribLocation(o,c[0],c[1]);e.linkProgram(o),c=e.getProgramParameter(o,35718),n.profile&&(r.stats.uniformsCount=c);var l=r.uniforms;for(s=0;s<c;++s)if(u=e.getActiveUniform(o,s))if(1<u.size)for(var p=0;p<u.size;++p){var h=u.name.replace("[0]","["+p+"]");a(l,new i(h,t.id(h),e.getUniformLocation(o,h),u))}else a(l,new i(u.name,t.id(u.name),e.getUniformLocation(o,u.name),u));for(c=e.getProgramParameter(o,35721),n.profile&&(r.stats.attributesCount=c),r=r.attributes,s=0;s<c;++s)(u=e.getActiveAttrib(o,s))&&a(r,new i(u.name,t.id(u.name),e.getAttribLocation(o,u.name),u))}var s={},c={},l={},p=[],h=0;return n.profile&&(r.getMaxUniformsCount=function(){var e=0;return p.forEach(function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)}),e},r.getMaxAttributesCount=function(){var e=0;return p.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);X(s).forEach(t),s={},X(c).forEach(t),c={},p.forEach(function(t){e.deleteProgram(t.program)}),p.length=0,l={},r.shaderCount=0},program:function(e,t,n,i){var a=l[t];a||(a=l[t]={});var f=a[e];return f&&!i?f:(t=new o(t,e),r.shaderCount++,u(t,n,i),f||(a[e]=t),p.push(t),t)},restore:function(){s={},c={};for(var e=0;e<p.length;++e)u(p[e],null,p[e].attributes.map(function(e){return[e.location,e.name]}))},shader:f,frag:-1,vert:-1}}function S(e,t,r,n,i,a,f){function o(i){var a;a=null===t.next?5121:t.next.colorAttachments[0].texture._texture.type;var f=0,o=0,u=n.framebufferWidth,s=n.framebufferHeight,c=null;return Y(i)?c=i:i&&(f=0|i.x,o=0|i.y,u=0|(i.width||n.framebufferWidth-f),s=0|(i.height||n.framebufferHeight-o),c=i.data||null),r(),i=u*s*4,c||(5121===a?c=new Uint8Array(i):5126===a&&(c=c||new Float32Array(i))),e.pixelStorei(3333,4),e.readPixels(f,o,u,s,6408,a,c),c}return function(e){return e&&"framebuffer"in e?function(e){var r;return t.setFBO({framebuffer:e.framebuffer},function(){r=o(e)}),r}(e):o(e)}}function j(e){return Array.prototype.slice.call(e)}function C(e){return j(e).join("")}function F(){function e(){var e=[],t=[];return H(function(){e.push.apply(e,j(arguments))},{def:function(){var n="v"+r++;return t.push(n),0<arguments.length&&(e.push(n,"="),e.push.apply(e,j(arguments)),e.push(";")),n},toString:function(){return C([0<t.length?"var "+t.join(",")+";":"",C(e)])}})}function t(){function t(e,t){n(e,t,"=",r.def(e,t),";")}var r=e(),n=e(),i=r.toString,a=n.toString;return H(function(){r.apply(r,j(arguments))},{def:r.def,entry:r,exit:n,save:t,set:function(e,n,i){t(e,n),r(e,n,"=",i,";")},toString:function(){return i()+a()}})}var r=0,n=[],i=[],a=e(),f={};return{global:a,link:function(e){for(var t=0;t<i.length;++t)if(i[t]===e)return n[t];return t="g"+r++,n.push(t),i.push(e),t},block:e,proc:function(e,r){function n(){var e="a"+i.length;return i.push(e),e}var i=[];r=r||0;for(var a=0;a<r;++a)n();var o=(a=t()).toString;return f[e]=H(a,{arg:n,toString:function(){return C(["function(",i.join(),"){",o(),"}"])}})},scope:t,cond:function(){var e=C(arguments),r=t(),n=t(),i=r.toString,a=n.toString;return H(r,{then:function(){return r.apply(r,j(arguments)),this},else:function(){return n.apply(n,j(arguments)),this},toString:function(){var t=a();return t&&(t="else{"+t+"}"),C(["if(",e,"){",i(),"}",t])}})},compile:function(){var e=['"use strict";',a,"return {"];Object.keys(f).forEach(function(t){e.push('"',t,'":',f[t].toString(),",")}),e.push("}");var t=C(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,n.concat(t)).apply(null,i)}}}function V(e){return Array.isArray(e)||Y(e)||u(e)}function B(e){return e.sort(function(e,t){return"viewport"===e?-1:"viewport"===t?1:e<t?-1:1})}function z(e,t,r,n){this.thisDep=e,this.contextDep=t,this.propDep=r,this.append=n}function P(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function I(e){return new z(!1,!1,!1,e)}function L(e,t){var r=e.type;return 0===r?new z(!0,1<=(r=e.data.length),2<=r,t):4===r?new z((r=e.data).thisDep,r.contextDep,r.propDep,t):new z(3===r,2===r,1===r,t)}function M(e,t,r,n,i,f,o,u,s,c,l,p,h,d,b){function g(e){return e.replace(".","_")}function y(e,t,r){var n=g(e);re.push(e),te[n]=ee[n]=!!r,ie[n]=t}function v(e,t,r){var n=g(e);re.push(e),Array.isArray(r)?(ee[n]=r.slice(),te[n]=r.slice()):ee[n]=te[n]=r,ae[n]=t}function x(){var e=F(),r=e.link,n=e.global;e.id=ue++,e.batchId="0";var i=r(fe),a=e.shared={props:"a0"};Object.keys(fe).forEach(function(e){a[e]=n.def(i,".",e)});var f=e.next={},o=e.current={};Object.keys(ae).forEach(function(e){Array.isArray(ee[e])&&(f[e]=n.def(a.next,".",e),o[e]=n.def(a.current,".",e))});var u=e.constants={};Object.keys(oe).forEach(function(e){u[e]=n.def(JSON.stringify(oe[e]))}),e.invoke=function(t,n){switch(n.type){case 0:var i=["this",a.context,a.props,e.batchId];return t.def(r(n.data),".call(",i.slice(0,Math.max(n.data.length+1,4)),")");case 1:return t.def(a.props,n.data);case 2:return t.def(a.context,n.data);case 3:return t.def("this",n.data);case 4:return n.data.append(e,t),n.data.ref}},e.attribCache={};var s={};return e.scopeAttrib=function(e){if((e=t.id(e))in s)return s[e];var n=c.scope[e];return n||(n=c.scope[e]=new X),s[e]=r(n)},e}function w(e,t){var r=e.static,n=e.dynamic;if("framebuffer"in r){var i=r.framebuffer;return i?(i=u.getFramebuffer(i),I(function(e,t){var r=e.link(i),n=e.shared;return t.set(n.framebuffer,".next",r),n=n.context,t.set(n,".framebufferWidth",r+".width"),t.set(n,".framebufferHeight",r+".height"),r})):I(function(e,t){var r=e.shared;return t.set(r.framebuffer,".next","null"),r=r.context,t.set(r,".framebufferWidth",r+".drawingBufferWidth"),t.set(r,".framebufferHeight",r+".drawingBufferHeight"),"null"})}if("framebuffer"in n){var a=n.framebuffer;return L(a,function(e,t){var r=e.invoke(t,a),n=e.shared,i=n.framebuffer;r=t.def(i,".getFramebuffer(",r,")");return t.set(i,".next",r),n=n.context,t.set(n,".framebufferWidth",r+"?"+r+".width:"+n+".drawingBufferWidth"),t.set(n,".framebufferHeight",r+"?"+r+".height:"+n+".drawingBufferHeight"),r})}return null}function A(e,r,n){function i(e){if(e in a){var r=t.id(a[e]);return(e=I(function(){return r})).id=r,e}if(e in f){var n=f[e];return L(n,function(e,t){var r=e.invoke(t,n);return t.def(e.shared.strings,".id(",r,")")})}return null}var a=e.static,f=e.dynamic,o=i("frag"),u=i("vert"),s=null;return P(o)&&P(u)?(s=l.program(u.id,o.id,null,n),e=I(function(e,t){return e.link(s)})):e=new z(o&&o.thisDep||u&&u.thisDep,o&&o.contextDep||u&&u.contextDep,o&&o.propDep||u&&u.propDep,function(e,t){var r,n,i=e.shared.shader;return r=o?o.append(e,t):t.def(i,".","frag"),n=u?u.append(e,t):t.def(i,".","vert"),t.def(i+".program("+n+","+r+")")}),{frag:o,vert:u,progVar:e,program:s}}function k(e,t){function r(e,t){if(e in n){var r=0|n[e];return I(function(e,n){return t&&(e.OFFSET=r),r})}if(e in i){var f=i[e];return L(f,function(e,r){var n=e.invoke(r,f);return t&&(e.OFFSET=n),n})}return t&&a?I(function(e,t){return e.OFFSET="0",0}):null}var n=e.static,i=e.dynamic,a=function(){if("elements"in n){var e=n.elements;V(e)?e=f.getElements(f.create(e,!0)):e&&(e=f.getElements(e));var t=I(function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n}return t.ELEMENTS=null});return t.value=e,t}if("elements"in i){var r=i.elements;return L(r,function(e,t){var n=(i=e.shared).isBufferArgs,i=i.elements,a=e.invoke(t,r),f=t.def("null");n=t.def(n,"(",a,")"),a=e.cond(n).then(f,"=",i,".createStream(",a,");").else(f,"=",i,".getElements(",a,");");return t.entry(a),t.exit(e.cond(n).then(i,".destroyStream(",f,");")),e.ELEMENTS=f})}return null}(),o=r("offset",!0);return{elements:a,primitive:function(){if("primitive"in n){var e=n.primitive;return I(function(t,r){return ne[e]})}if("primitive"in i){var t=i.primitive;return L(t,function(e,r){var n=e.constants.primTypes,i=e.invoke(r,t);return r.def(n,"[",i,"]")})}return a?P(a)?a.value?I(function(e,t){return t.def(e.ELEMENTS,".primType")}):I(function(){return 4}):new z(a.thisDep,a.contextDep,a.propDep,function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",4)}):null}(),count:function(){if("count"in n){var e=0|n.count;return I(function(){return e})}if("count"in i){var t=i.count;return L(t,function(e,r){return e.invoke(r,t)})}return a?P(a)?a?o?new z(o.thisDep,o.contextDep,o.propDep,function(e,t){return t.def(e.ELEMENTS,".vertCount-",e.OFFSET)}):I(function(e,t){return t.def(e.ELEMENTS,".vertCount")}):I(function(){return-1}):new z(a.thisDep||o.thisDep,a.contextDep||o.contextDep,a.propDep||o.propDep,function(e,t){var r=e.ELEMENTS;return e.OFFSET?t.def(r,"?",r,".vertCount-",e.OFFSET,":-1"):t.def(r,"?",r,".vertCount:-1")}):null}(),instances:r("instances",!1),offset:o}}function _(e,r){var n=e.static,a=e.dynamic,f={};return Object.keys(n).forEach(function(e){var r=n[e],a=t.id(e),o=new X;if(V(r))o.state=1,o.buffer=i.getBuffer(i.create(r,34962,!1,!0)),o.type=0;else if(s=i.getBuffer(r))o.state=1,o.buffer=s,o.type=0;else if("constant"in r){var u=r.constant;o.buffer="null",o.state=2,"number"==typeof u?o.x=u:Ae.forEach(function(e,t){t<u.length&&(o[e]=u[t])})}else{var s=V(r.buffer)?i.getBuffer(i.create(r.buffer,34962,!1,!0)):i.getBuffer(r.buffer),c=0|r.offset,l=0|r.stride,p=0|r.size,h=!!r.normalized,d=0;"type"in r&&(d=Z[r.type]),r=0|r.divisor,o.buffer=s,o.state=1,o.size=p,o.normalized=h,o.type=d||s.dtype,o.offset=c,o.stride=l,o.divisor=r}f[e]=I(function(e,t){var r=e.attribCache;if(a in r)return r[a];var n={isStream:!1};return Object.keys(o).forEach(function(e){n[e]=o[e]}),o.buffer&&(n.buffer=e.link(o.buffer),n.type=n.type||n.buffer+".dtype"),r[a]=n})}),Object.keys(a).forEach(function(e){var t=a[e];f[e]=L(t,function(e,r){function n(e){r(u[e],"=",i,".",e,"|0;")}var i=e.invoke(r,t),a=e.shared,f=e.constants,o=a.isBufferArgs,u=(a=a.buffer,{isStream:r.def(!1)}),s=new X;s.state=1,Object.keys(s).forEach(function(e){u[e]=r.def(""+s[e])});var c=u.buffer,l=u.type;return r("if(",o,"(",i,")){",u.isStream,"=true;",c,"=",a,".createStream(",34962,",",i,");",l,"=",c,".dtype;","}else{",c,"=",a,".getBuffer(",i,");","if(",c,"){",l,"=",c,".dtype;",'}else if("constant" in ',i,"){",u.state,"=",2,";","if(typeof "+i+'.constant === "number"){',u[Ae[0]],"=",i,".constant;",Ae.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",Ae.map(function(e,t){return u[e]+"="+i+".constant.length>"+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",o,"(",i,".buffer)){",c,"=",a,".createStream(",34962,",",i,".buffer);","}else{",c,"=",a,".getBuffer(",i,".buffer);","}",l,'="type" in ',i,"?",f.glTypes,"[",i,".type]:",c,".dtype;",u.normalized,"=!!",i,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",u.isStream,"){",a,".destroyStream(",c,");","}"),u})}),f}function O(e,t,n,i,f){function o(e){var t=s[e];t&&(p[e]=t)}var u=function(e,t){if("string"==typeof(r=e.static).frag&&"string"==typeof r.vert){if(0<Object.keys(t.dynamic).length)return null;var r=t.static,n=Object.keys(r);if(0<n.length&&"number"==typeof r[n[0]]){for(var i=[],a=0;a<n.length;++a)i.push([0|r[n[a]],n[a]]);return i}}return null}(e,t),s=function(e,t,r){function n(e){if(e in i){var r=i[e];e=!0;var n,f,o=0|r.x,u=0|r.y;return"width"in r?n=0|r.width:e=!1,"height"in r?f=0|r.height:e=!1,new z(!e&&t&&t.thisDep,!e&&t&&t.contextDep,!e&&t&&t.propDep,function(e,t){var i=e.shared.context,a=n;"width"in r||(a=t.def(i,".","framebufferWidth","-",o));var s=f;return"height"in r||(s=t.def(i,".","framebufferHeight","-",u)),[o,u,a,s]})}if(e in a){var s=a[e];return e=L(s,function(e,t){var r=e.invoke(t,s),n=e.shared.context,i=t.def(r,".x|0"),a=t.def(r,".y|0");return[i,a,t.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",i,")"),r=t.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",a,")")]}),t&&(e.thisDep=e.thisDep||t.thisDep,e.contextDep=e.contextDep||t.contextDep,e.propDep=e.propDep||t.propDep),e}return t?new z(t.thisDep,t.contextDep,t.propDep,function(e,t){var r=e.shared.context;return[0,0,t.def(r,".","framebufferWidth"),t.def(r,".","framebufferHeight")]}):null}var i=e.static,a=e.dynamic;if(e=n("viewport")){var f=e;e=new z(e.thisDep,e.contextDep,e.propDep,function(e,t){var r=f.append(e,t),n=e.shared.context;return t.set(n,".viewportWidth",r[2]),t.set(n,".viewportHeight",r[3]),r})}return{viewport:e,scissor_box:n("scissor.box")}}(e,d=w(e)),l=k(e),p=function(e,t){var r=e.static,n=e.dynamic,i={};return re.forEach(function(e){function t(t,a){if(e in r){var o=t(r[e]);i[f]=I(function(){return o})}else if(e in n){var u=n[e];i[f]=L(u,function(e,t){return a(e,t,e.invoke(t,u))})}}var f=g(e);switch(e){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return t(function(e){return e},function(e,t,r){return r});case"depth.func":return t(function(e){return Oe[e]},function(e,t,r){return t.def(e.constants.compareFuncs,"[",r,"]")});case"depth.range":return t(function(e){return e},function(e,t,r){return[t.def("+",r,"[0]"),t=t.def("+",r,"[1]")]});case"blend.func":return t(function(e){return[_e["srcRGB"in e?e.srcRGB:e.src],_e["dstRGB"in e?e.dstRGB:e.dst],_e["srcAlpha"in e?e.srcAlpha:e.src],_e["dstAlpha"in e?e.dstAlpha:e.dst]]},function(e,t,r){function n(e,n){return t.def('"',e,n,'" in ',r,"?",r,".",e,n,":",r,".",e)}e=e.constants.blendFuncs;var i=n("src","RGB"),a=n("dst","RGB"),f=(i=t.def(e,"[",i,"]"),t.def(e,"[",n("src","Alpha"),"]"));return[i,a=t.def(e,"[",a,"]"),f,e=t.def(e,"[",n("dst","Alpha"),"]")]});case"blend.equation":return t(function(e){return"string"==typeof e?[J[e],J[e]]:"object"==typeof e?[J[e.rgb],J[e.alpha]]:void 0},function(e,t,r){var n=e.constants.blendEquations,i=t.def(),a=t.def();return(e=e.cond("typeof ",r,'==="string"')).then(i,"=",a,"=",n,"[",r,"];"),e.else(i,"=",n,"[",r,".rgb];",a,"=",n,"[",r,".alpha];"),t(e),[i,a]});case"blend.color":return t(function(e){return a(4,function(t){return+e[t]})},function(e,t,r){return a(4,function(e){return t.def("+",r,"[",e,"]")})});case"stencil.mask":return t(function(e){return 0|e},function(e,t,r){return t.def(r,"|0")});case"stencil.func":return t(function(e){return[Oe[e.cmp||"keep"],e.ref||0,"mask"in e?e.mask:-1]},function(e,t,r){return[e=t.def('"cmp" in ',r,"?",e.constants.compareFuncs,"[",r,".cmp]",":",7680),t.def(r,".ref|0"),t=t.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return t(function(t){return["stencil.opBack"===e?1029:1028,Ee[t.fail||"keep"],Ee[t.zfail||"keep"],Ee[t.zpass||"keep"]]},function(t,r,n){function i(e){return r.def('"',e,'" in ',n,"?",a,"[",n,".",e,"]:",7680)}var a=t.constants.stencilOps;return["stencil.opBack"===e?1029:1028,i("fail"),i("zfail"),i("zpass")]});case"polygonOffset.offset":return t(function(e){return[0|e.factor,0|e.units]},function(e,t,r){return[t.def(r,".factor|0"),t=t.def(r,".units|0")]});case"cull.face":return t(function(e){var t=0;return"front"===e?t=1028:"back"===e&&(t=1029),t},function(e,t,r){return t.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return t(function(e){return e},function(e,t,r){return r});case"frontFace":return t(function(e){return Te[e]},function(e,t,r){return t.def(r+'==="cw"?2304:2305')});case"colorMask":return t(function(e){return e.map(function(e){return!!e})},function(e,t,r){return a(4,function(e){return"!!"+r+"["+e+"]"})});case"sample.coverage":return t(function(e){return["value"in e?e.value:1,!!e.invert]},function(e,t,r){return[t.def('"value" in ',r,"?+",r,".value:1"),t=t.def("!!",r,".invert")]})}}),i}(e),h=A(e,0,u);o("viewport"),o(g("scissor.box"));var d,b=0<Object.keys(p).length;if((d={framebuffer:d,draw:l,shader:h,state:p,dirty:b,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}}).profile=function(e){var t,r=e.static;if(e=e.dynamic,"profile"in r){var n=!!r.profile;(t=I(function(e,t){return n})).enable=n}else if("profile"in e){var i=e.profile;t=L(i,function(e,t){return e.invoke(t,i)})}return t}(e),d.uniforms=function(e,t){var r=e.static,n=e.dynamic,i={};return Object.keys(r).forEach(function(e){var t,n=r[e];if("number"==typeof n||"boolean"==typeof n)t=I(function(){return n});else if("function"==typeof n){var f=n._reglType;"texture2d"===f||"textureCube"===f?t=I(function(e){return e.link(n)}):"framebuffer"!==f&&"framebufferCube"!==f||(t=I(function(e){return e.link(n.color[0])}))}else m(n)&&(t=I(function(e){return e.global.def("[",a(n.length,function(e){return n[e]}),"]")}));t.value=n,i[e]=t}),Object.keys(n).forEach(function(e){var t=n[e];i[e]=L(t,function(e,r){return e.invoke(r,t)})}),i}(n),d.drawVAO=d.scopeVAO=function(e,t){var r=e.static,n=e.dynamic;if("vao"in r){var i=r.vao;return null!==i&&null===c.getVAO(i)&&(i=c.createVAO(i)),I(function(e){return e.link(c.getVAO(i))})}if("vao"in n){var a=n.vao;return L(a,function(e,t){var r=e.invoke(t,a);return t.def(e.shared.vao+".getVAO("+r+")")})}return null}(e),!d.drawVAO&&h.program&&!u&&r.angle_instanced_arrays){var y=!0;if(e=h.program.attributes.map(function(e){return e=t.static[e],y=y&&!!e,e}),y&&0<e.length){var v=c.getVAO(c.createVAO(e));d.drawVAO=new z(null,null,null,function(e,t){return e.link(v)}),d.useVAO=!0}}return u?d.useVAO=!0:d.attributes=_(t),d.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach(function(e){var r=t[e];n[e]=I(function(e,t){return"number"==typeof r||"boolean"==typeof r?""+r:e.link(r)})}),Object.keys(r).forEach(function(e){var t=r[e];n[e]=L(t,function(e,r){return e.invoke(r,t)})}),n}(i),d}function E(e,t,r){var n=e.shared.context,i=e.scope();Object.keys(r).forEach(function(a){t.save(n,"."+a),i(n,".",a,"=",r[a].append(e,t),";")}),t(i)}function T(e,t,r,n){var i,a=(o=e.shared).gl,f=o.framebuffer;$&&(i=t.def(o.extensions,".webgl_draw_buffers"));var o=(u=e.constants).drawBuffer,u=u.backBuffer;e=r?r.append(e,t):t.def(f,".next"),n||t("if(",e,"!==",f,".cur){"),t("if(",e,"){",a,".bindFramebuffer(",36160,",",e,".framebuffer);"),$&&t(i,".drawBuffersWEBGL(",o,"[",e,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",36160,",null);"),$&&t(i,".drawBuffersWEBGL(",u,");"),t("}",f,".cur=",e,";"),n||t("}")}function D(e,t,r){var n=e.shared,i=n.gl,f=e.current,o=e.next,u=n.current,s=n.next,c=e.cond(u,".dirty");re.forEach(function(t){var n,l;if(!((t=g(t))in r.state))if(t in o){n=o[t],l=f[t];var p=a(ee[t].length,function(e){return c.def(n,"[",e,"]")});c(e.cond(p.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(i,".",ae[t],"(",p,");",p.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else n=c.def(s,".",t),p=e.cond(n,"!==",u,".",t),c(p),t in ie?p(e.cond(n).then(i,".enable(",ie[t],");").else(i,".disable(",ie[t],");"),u,".",t,"=",n,";"):p(i,".",ae[t],"(",n,");",u,".",t,"=",n,";")}),0===Object.keys(r.state).length&&c(u,".dirty=false;"),t(c)}function S(e,t,r,n){var i=e.shared,a=e.current,f=i.current,o=i.gl;B(Object.keys(r)).forEach(function(i){var u=r[i];if(!n||n(u)){var s=u.append(e,t);if(ie[i]){var c=ie[i];P(u)?t(o,s?".enable(":".disable(",c,");"):t(e.cond(s).then(o,".enable(",c,");").else(o,".disable(",c,");")),t(f,".",i,"=",s,";")}else if(m(s)){var l=a[i];t(o,".",ae[i],"(",s,");",s.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(o,".",ae[i],"(",s,");",f,".",i,"=",s,";")}})}function j(e,t){K&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function C(e,t,r,n,i){function a(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function f(e){e(s=t.def(),"=",a(),";"),"string"==typeof i?e(p,".count+=",i,";"):e(p,".count++;"),d&&(n?e(c=t.def(),"=",b,".getNumPendingQueries();"):e(b,".beginQuery(",p,");"))}function o(e){e(p,".cpuTime+=",a(),"-",s,";"),d&&(n?e(b,".pushScopeStats(",c,",",b,".getNumPendingQueries(),",p,");"):e(b,".endQuery();"))}function u(e){var r=t.def(h,".profile");t(h,".profile=",e,";"),t.exit(h,".profile=",r,";")}var s,c,l=e.shared,p=e.stats,h=l.current,b=l.timer;if(r=r.profile){if(P(r))return void(r.enable?(f(t),o(t.exit),u("true")):u("false"));u(r=r.append(e,t))}else r=t.def(h,".profile");f(l=e.block()),t("if(",r,"){",l,"}"),o(e=e.block()),t.exit("if(",r,"){",e,"}")}function M(e,t,r,n,i){function a(r,n,i){function a(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var r,a=i.type;r=i.size?t.def(i.size,"||",n):n,t("if(",c,".type!==",a,"||",c,".size!==",r,"||",h.map(function(e){return c+"."+e+"!=="+i[e]}).join("||"),"){",u,".bindBuffer(",34962,",",l,".buffer);",u,".vertexAttribPointer(",[s,r,a,i.normalized,i.stride,i.offset],");",c,".type=",a,";",c,".size=",r,";",h.map(function(e){return c+"."+e+"="+i[e]+";"}).join(""),"}"),K&&(a=i.divisor,t("if(",c,".divisor!==",a,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,a],");",c,".divisor=",a,";}"))}function o(){t("if(",c,".buffer){",u,".disableVertexAttribArray(",s,");",c,".buffer=null;","}if(",Ae.map(function(e,t){return c+"."+e+"!=="+p[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",p,");",Ae.map(function(e,t){return c+"."+e+"="+p[t]+";"}).join(""),"}")}var u=f.gl,s=t.def(r,".location"),c=t.def(f.attributes,"[",s,"]");r=i.state;var l=i.buffer,p=[i.x,i.y,i.z,i.w],h=["buffer","normalized","offset","stride"];1===r?a():2===r?o():(t("if(",r,"===",1,"){"),a(),t("}else{"),o(),t("}"))}var f=e.shared;n.forEach(function(n){var f,o=n.name,u=r.attributes[o];if(u){if(!i(u))return;f=u.append(e,t)}else{if(!i(De))return;var s=e.scopeAttrib(o);f={},Object.keys(new X).forEach(function(e){f[e]=t.def(s,".",e)})}a(e.link(n),function(e){switch(e){case 35664:case 35667:case 35671:return 2;case 35665:case 35668:case 35672:return 3;case 35666:case 35669:case 35673:return 4;default:return 1}}(n.info.type),f)})}function R(e,r,n,i,f){for(var o,u=e.shared,s=u.gl,c=0;c<i.length;++c){var l,p=(b=i[c]).name,h=b.info.type,d=n.uniforms[p],b=e.link(b)+".location";if(d){if(!f(d))continue;if(P(d)){if(p=d.value,35678===h||35680===h)r(s,".uniform1i(",b,",",(h=e.link(p._texture||p.color[0]._texture))+".bind());"),r.exit(h,".unbind();");else if(35674===h||35675===h||35676===h)d=2,35675===h?d=3:35676===h&&(d=4),r(s,".uniformMatrix",d,"fv(",b,",false,",p=e.global.def("new Float32Array(["+Array.prototype.slice.call(p)+"])"),");");else{switch(h){case 5126:o="1f";break;case 35664:o="2f";break;case 35665:o="3f";break;case 35666:o="4f";break;case 35670:case 5124:o="1i";break;case 35671:case 35667:o="2i";break;case 35672:case 35668:o="3i";break;case 35673:o="4i";break;case 35669:o="4i"}r(s,".uniform",o,"(",b,",",m(p)?Array.prototype.slice.call(p):p,");")}continue}l=d.append(e,r)}else{if(!f(De))continue;l=r.def(u.uniforms,"[",t.id(p),"]")}switch(35678===h?r("if(",l,"&&",l,'._reglType==="framebuffer"){',l,"=",l,".color[0];","}"):35680===h&&r("if(",l,"&&",l,'._reglType==="framebufferCube"){',l,"=",l,".color[0];","}"),p=1,h){case 35678:case 35680:h=r.def(l,"._texture"),r(s,".uniform1i(",b,",",h,".bind());"),r.exit(h,".unbind();");continue;case 5124:case 35670:o="1i";break;case 35667:case 35671:o="2i",p=2;break;case 35668:case 35672:o="3i",p=3;break;case 35669:case 35673:o="4i",p=4;break;case 5126:o="1f";break;case 35664:o="2f",p=2;break;case 35665:o="3f",p=3;break;case 35666:o="4f",p=4;break;case 35674:o="Matrix2fv";break;case 35675:o="Matrix3fv";break;case 35676:o="Matrix4fv"}if(r(s,".uniform",o,"(",b,","),"M"===o.charAt(0)){b=Math.pow(h-35674+2,2);var g=e.global.def("new Float32Array(",b,")");r("false,(Array.isArray(",l,")||",l," instanceof Float32Array)?",l,":(",a(b,function(e){return g+"["+e+"]="+l+"["+e+"]"}),",",g,")")}else r(1<p?a(p,function(e){return l+"["+e+"]"}):l);r(");")}}function H(e,t,r,n){function i(i){var a=p[i];return a?a.contextDep&&n.contextDynamic||a.propDep?a.append(e,r):a.append(e,t):t.def(l,".",i)}function a(){function e(){r(u,".drawElementsInstancedANGLE(",[d,m,g,b+"<<(("+g+"-5121)>>1)",o],");")}function t(){r(u,".drawArraysInstancedANGLE(",[d,b,m,o],");")}h?y?e():(r("if(",h,"){"),e(),r("}else{"),t(),r("}")):t()}function f(){function e(){r(c+".drawElements("+[d,m,g,b+"<<(("+g+"-5121)>>1)"]+");")}function t(){r(c+".drawArrays("+[d,b,m]+");")}h?y?e():(r("if(",h,"){"),e(),r("}else{"),t(),r("}")):t()}var o,u,s=e.shared,c=s.gl,l=s.draw,p=n.draw,h=function(){var i=p.elements,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a)):i=a.def(l,".","elements"),i&&a("if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);"),i}(),d=i("primitive"),b=i("offset"),m=function(){var i=p.count,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a)):i=a.def(l,".","count"),i}();if("number"==typeof m){if(0===m)return}else r("if(",m,"){"),r.exit("}");K&&(o=i("instances"),u=e.instancing);var g=h+".type",y=p.elements&&P(p.elements);K&&("number"!=typeof o||0<=o)?"string"==typeof o?(r("if(",o,">0){"),a(),r("}else if(",o,"<0){"),f(),r("}")):a():f()}function W(e,t,r,n,i){return i=(t=x()).proc("body",i),K&&(t.instancing=i.def(t.shared.extensions,".angle_instanced_arrays")),e(t,i,r,n),t.compile().body}function N(e,t,r,n){j(e,t),r.useVAO?r.drawVAO?t(e.shared.vao,".setVAO(",r.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),M(e,t,r,n.attributes,function(){return!0})),R(e,t,r,n.uniforms,function(){return!0}),H(e,t,t,r)}function q(e,t,r,n){function i(){return!0}e.batchId="a1",j(e,t),M(e,t,r,n.attributes,i),R(e,t,r,n.uniforms,i),H(e,t,t,r)}function Q(e,t,r,n){function i(e){return e.contextDep&&f||e.propDep}function a(e){return!i(e)}j(e,t);var f=r.contextDep,o=t.def(),u=t.def();e.shared.props=u,e.batchId=o;var s=e.scope(),c=e.scope();t(s.entry,"for(",o,"=0;",o,"<","a1",";++",o,"){",u,"=","a0","[",o,"];",c,"}",s.exit),r.needsContext&&E(e,c,r.context),r.needsFramebuffer&&T(e,c,r.framebuffer),S(e,c,r.state,i),r.profile&&i(r.profile)&&C(e,c,r,!1,!0),n?(r.useVAO?r.drawVAO?i(r.drawVAO)?c(e.shared.vao,".setVAO(",r.drawVAO.append(e,c),");"):s(e.shared.vao,".setVAO(",r.drawVAO.append(e,s),");"):s(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(s(e.shared.vao,".setVAO(null);"),M(e,s,r,n.attributes,a),M(e,c,r,n.attributes,i)),R(e,s,r,n.uniforms,a),R(e,c,r,n.uniforms,i),H(e,s,c,r)):(t=e.global.def("{}"),n=r.shader.progVar.append(e,c),u=c.def(n,".id"),s=c.def(t,"[",u,"]"),c(e.shared.gl,".useProgram(",n,".program);","if(!",s,"){",s,"=",t,"[",u,"]=",e.link(function(t){return W(q,e,r,t,2)}),"(",n,");}",s,".call(this,a0[",o,"],",o,");"))}function G(e,r){function n(t){var n=r.shader[t];n&&i.set(a.shader,"."+t,n.append(e,i))}var i=e.proc("scope",3);e.batchId="a2";var a=e.shared,f=a.current;E(e,i,r.context),r.framebuffer&&r.framebuffer.append(e,i),B(Object.keys(r.state)).forEach(function(t){var n=r.state[t].append(e,i);m(n)?n.forEach(function(r,n){i.set(e.next[t],"["+n+"]",r)}):i.set(a.next,"."+t,n)}),C(e,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(t){var n=r.draw[t];n&&i.set(a.draw,"."+t,""+n.append(e,i))}),Object.keys(r.uniforms).forEach(function(n){i.set(a.uniforms,"["+t.id(n)+"]",r.uniforms[n].append(e,i))}),Object.keys(r.attributes).forEach(function(t){var n=r.attributes[t].append(e,i),a=e.scopeAttrib(t);Object.keys(new X).forEach(function(e){i.set(a,"."+e,n[e])})}),r.scopeVAO&&i.set(a.vao,".targetVAO",r.scopeVAO.append(e,i)),n("vert"),n("frag"),0<Object.keys(r.state).length&&(i(f,".dirty=true;"),i.exit(f,".dirty=true;")),i("a1(",e.shared.context,",a0,",e.batchId,");")}function Y(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!m(e)){for(var t=Object.keys(e),r=0;r<t.length;++r)if(U.isDynamic(e[t[r]]))return!0;return!1}}(n)){var i=e.global,a=Object.keys(n),f=!1,o=!1,u=!1,s=e.global.def("{}");a.forEach(function(t){var r=n[t];if(U.isDynamic(r))"function"==typeof r&&(r=n[t]=U.unbox(r)),t=L(r,null),f=f||t.thisDep,u=u||t.propDep,o=o||t.contextDep;else{switch(i(s,".",t,"="),typeof r){case"number":i(r);break;case"string":i('"',r,'"');break;case"object":Array.isArray(r)&&i("[",r.join(),"]");break;default:i(e.link(r))}i(";")}}),t.dynamic[r]=new U.DynamicVariable(4,{thisDep:f,contextDep:o,propDep:u,ref:s,append:function(e,t){a.forEach(function(r){var i=n[r];U.isDynamic(i)&&(i=e.invoke(t,i),t(s,".",r,"=",i,";"))})}}),delete t.static[r]}}var X=c.Record,J={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(J.min=32775,J.max=32776);var K=r.angle_instanced_arrays,$=r.webgl_draw_buffers,ee={dirty:!0,profile:b.profile},te={},re=[],ie={},ae={};y("dither",3024),y("blend.enable",3042),v("blend.color","blendColor",[0,0,0,0]),v("blend.equation","blendEquationSeparate",[32774,32774]),v("blend.func","blendFuncSeparate",[1,0,1,0]),y("depth.enable",2929,!0),v("depth.func","depthFunc",513),v("depth.range","depthRange",[0,1]),v("depth.mask","depthMask",!0),v("colorMask","colorMask",[!0,!0,!0,!0]),y("cull.enable",2884),v("cull.face","cullFace",1029),v("frontFace","frontFace",2305),v("lineWidth","lineWidth",1),y("polygonOffset.enable",32823),v("polygonOffset.offset","polygonOffset",[0,0]),y("sample.alpha",32926),y("sample.enable",32928),v("sample.coverage","sampleCoverage",[1,!1]),y("stencil.enable",2960),v("stencil.mask","stencilMask",-1),v("stencil.func","stencilFunc",[519,0,-1]),v("stencil.opFront","stencilOpSeparate",[1028,7680,7680,7680]),v("stencil.opBack","stencilOpSeparate",[1029,7680,7680,7680]),y("scissor.enable",3089),v("scissor.box","scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),v("viewport","viewport",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var fe={gl:e,context:h,strings:t,next:te,current:ee,draw:p,elements:f,buffer:i,shader:l,attributes:c.state,vao:c,uniforms:s,framebuffer:u,extensions:r,timer:d,isBufferArgs:V},oe={primTypes:ne,compareFuncs:Oe,blendFuncs:_e,blendEquations:J,stencilOps:Ee,glTypes:Z,orientationType:Te};$&&(oe.backBuffer=[1029],oe.drawBuffer=a(n.maxDrawbuffers,function(e){return 0===e?[0]:a(e,function(e){return 36064+e})}));var ue=0;return{next:te,current:ee,procs:function(){var e=x(),t=e.proc("poll"),i=e.proc("refresh"),f=e.block();t(f),i(f);var o,u=e.shared,s=u.gl,c=u.next,l=u.current;f(l,".dirty=false;"),T(e,t),T(e,i,null,!0),K&&(o=e.link(K)),r.oes_vertex_array_object&&i(e.link(r.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var p=0;p<n.maxAttributes;++p){var h=i.def(u.attributes,"[",p,"]"),d=e.cond(h,".buffer");d.then(s,".enableVertexAttribArray(",p,");",s,".bindBuffer(",34962,",",h,".buffer.buffer);",s,".vertexAttribPointer(",p,",",h,".size,",h,".type,",h,".normalized,",h,".stride,",h,".offset);").else(s,".disableVertexAttribArray(",p,");",s,".vertexAttrib4f(",p,",",h,".x,",h,".y,",h,".z,",h,".w);",h,".buffer=null;"),i(d),K&&i(o,".vertexAttribDivisorANGLE(",p,",",h,".divisor);")}return i(e.shared.vao,".currentVAO=null;",e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"),Object.keys(ie).forEach(function(r){var n=ie[r],a=f.def(c,".",r),o=e.block();o("if(",a,"){",s,".enable(",n,")}else{",s,".disable(",n,")}",l,".",r,"=",a,";"),i(o),t("if(",a,"!==",l,".",r,"){",o,"}")}),Object.keys(ae).forEach(function(r){var n,o,u=ae[r],p=ee[r],h=e.block();h(s,".",u,"("),m(p)?(u=p.length,n=e.global.def(c,".",r),o=e.global.def(l,".",r),h(a(u,function(e){return n+"["+e+"]"}),");",a(u,function(e){return o+"["+e+"]="+n+"["+e+"];"}).join("")),t("if(",a(u,function(e){return n+"["+e+"]!=="+o+"["+e+"]"}).join("||"),"){",h,"}")):(n=f.def(c,".",r),o=f.def(l,".",r),h(n,");",l,".",r,"=",n,";"),t("if(",n,"!==",o,"){",h,"}")),i(h)}),e.compile()}(),compile:function(e,t,r,n,i){var a=x();return a.stats=a.link(i),Object.keys(t.static).forEach(function(e){Y(a,t,e)}),ke.forEach(function(t){Y(a,e,t)}),r=O(e,t,r,n),function(e,t){var r=e.proc("draw",1);j(e,r),E(e,r,t.context),T(e,r,t.framebuffer),D(e,r,t),S(e,r,t.state),C(e,r,t,!1,!0);var n=t.shader.progVar.append(e,r);if(r(e.shared.gl,".useProgram(",n,".program);"),t.shader.program)N(e,r,t,t.shader.program);else{r(e.shared.vao,".setVAO(null);");var i=e.global.def("{}"),a=r.def(n,".id"),f=r.def(i,"[",a,"]");r(e.cond(f).then(f,".call(this,a0);").else(f,"=",i,"[",a,"]=",e.link(function(r){return W(N,e,t,r,1)}),"(",n,");",f,".call(this,a0);"))}0<Object.keys(t.state).length&&r(e.shared.current,".dirty=true;")}(a,r),G(a,r),function(e,t){function r(e){return e.contextDep&&i||e.propDep}var n=e.proc("batch",2);e.batchId="0",j(e,n);var i=!1,a=!0;Object.keys(t.context).forEach(function(e){i=i||t.context[e].propDep}),i||(E(e,n,t.context),a=!1);var f=!1;if((o=t.framebuffer)?(o.propDep?i=f=!0:o.contextDep&&i&&(f=!0),f||T(e,n,o)):T(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),D(e,n,t),S(e,n,t.state,function(e){return!r(e)}),t.profile&&r(t.profile)||C(e,n,t,!1,"a1"),t.contextDep=i,t.needsContext=a,t.needsFramebuffer=f,(a=t.shader.progVar).contextDep&&i||a.propDep)Q(e,n,t,null);else if(a=a.append(e,n),n(e.shared.gl,".useProgram(",a,".program);"),t.shader.program)Q(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var o=e.global.def("{}"),u=(f=n.def(a,".id"),n.def(o,"[",f,"]"));n(e.cond(u).then(u,".call(this,a0,a1);").else(u,"=",o,"[",f,"]=",e.link(function(r){return W(Q,e,t,r,2)}),"(",a,");",u,".call(this,a0,a1);"))}0<Object.keys(t.state).length&&n(e.shared.current,".dirty=true;")}(a,r),a.compile()}}}function R(e,t){for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1}var H=function(e,t){for(var r=Object.keys(t),n=0;n<r.length;++n)e[r[n]]=t[r[n]];return e},W=0,U={DynamicVariable:e,define:function(r,n){return new e(r,t(n+""))},isDynamic:function(t){return"function"==typeof t&&!t._reglType||t instanceof e},unbox:function(t,r){return"function"==typeof t?new e(0,t):t},accessor:t},N={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},q="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},Q=o();Q.zero=o();var G=function(e,t){var r=1;t.ext_texture_filter_anisotropic&&(r=e.getParameter(34047));var n=1,i=1;t.webgl_draw_buffers&&(n=e.getParameter(34852),i=e.getParameter(36063));var a=!!t.oes_texture_float;if(a){a=e.createTexture(),e.bindTexture(3553,a),e.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var f=e.createFramebuffer();if(e.bindFramebuffer(36160,f),e.framebufferTexture2D(36160,36064,3553,a,0),e.bindTexture(3553,null),36053!==e.checkFramebufferStatus(36160))a=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var o=Q.allocType(5126,4);e.readPixels(0,0,1,1,6408,5126,o),e.getError()?a=!1:(e.deleteFramebuffer(f),e.deleteTexture(a),a=1===o[0]),Q.freeType(o)}}return o=!0,"undefined"!=typeof navigator&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))||(o=e.createTexture(),f=Q.allocType(5121,36),e.activeTexture(33984),e.bindTexture(34067,o),e.texImage2D(34069,0,6408,3,3,0,6408,5121,f),Q.freeType(f),e.bindTexture(34067,null),e.deleteTexture(o),o=!e.getError()),{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter(function(e){return!!t[e]}),maxAnisotropic:r,maxDrawbuffers:n,maxColorAttachments:i,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938),readFloat:a,npotTextureCube:o}},Y=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},X=function(e){return Object.keys(e).map(function(t){return e[t]})},J={shape:function(e){for(var t=[];e.length;e=e[0])t.push(e.length);return t},flatten:function(e,t,r,n){var i=1;if(t.length)for(var a=0;a<t.length;++a)i*=t[a];else i=0;switch(r=n||Q.allocType(r,i),t.length){case 0:break;case 1:for(n=t[0],t=0;t<n;++t)r[t]=e[t];break;case 2:for(n=t[0],t=t[1],a=i=0;a<n;++a)for(var f=e[a],o=0;o<t;++o)r[i++]=f[o];break;case 3:s(e,t[0],t[1],t[2],r,0);break;default:!function e(t,r,n,i,a){for(var f=1,o=n+1;o<r.length;++o)f*=r[o];var u=r[n];if(4==r.length-n){var c=r[n+1],l=r[n+2];for(r=r[n+3],o=0;o<u;++o)s(t[o],c,l,r,i,a),a+=f}else for(o=0;o<u;++o)e(t[o],r,n+1,i,a),a+=f}(e,t,0,r,0)}return r}},K={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Z={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},$={dynamic:35048,stream:35040,static:35044},ee=J.flatten,te=J.shape,re=[];re[5120]=1,re[5122]=2,re[5124]=4,re[5121]=1,re[5123]=2,re[5125]=4,re[5126]=4;var ne={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},ie=new Float32Array(1),ae=new Uint32Array(ie.buffer),fe=[9984,9986,9985,9987],oe=[0,6409,6410,6407,6408],ue={};ue[6409]=ue[6406]=ue[6402]=1,ue[34041]=ue[6410]=2,ue[6407]=ue[35904]=3,ue[6408]=ue[35906]=4;var se=g("HTMLCanvasElement"),ce=g("OffscreenCanvas"),le=g("CanvasRenderingContext2D"),pe=g("ImageBitmap"),he=g("HTMLImageElement"),de=g("HTMLVideoElement"),be=Object.keys(K).concat([se,ce,le,pe,he,de]),me=[];me[5121]=1,me[5126]=4,me[36193]=2,me[5123]=2,me[5125]=4;var ge=[];ge[32854]=2,ge[32855]=2,ge[36194]=2,ge[34041]=4,ge[33776]=.5,ge[33777]=.5,ge[33778]=1,ge[33779]=1,ge[35986]=.5,ge[35987]=1,ge[34798]=1,ge[35840]=.5,ge[35841]=.25,ge[35842]=.5,ge[35843]=.25,ge[36196]=.5;var ye=[];ye[32854]=2,ye[32855]=2,ye[36194]=2,ye[33189]=2,ye[36168]=1,ye[34041]=4,ye[35907]=4,ye[34836]=16,ye[34842]=8,ye[34843]=6;var ve=function(e,t,r,n,i){function a(e){this.id=s++,this.refCount=1,this.renderbuffer=e,this.format=32854,this.height=this.width=0,i.profile&&(this.stats={size:0})}function f(t){var r=t.renderbuffer;e.bindRenderbuffer(36161,null),e.deleteRenderbuffer(r),t.renderbuffer=null,t.refCount=0,delete c[t.id],n.renderbufferCount--}var o={rgba4:32854,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};t.ext_srgb&&(o.srgba=35907),t.ext_color_buffer_half_float&&(o.rgba16f=34842,o.rgb16f=34843),t.webgl_color_buffer_float&&(o.rgba32f=34836);var u=[];Object.keys(o).forEach(function(e){u[o[e]]=e});var s=0,c={};return a.prototype.decRef=function(){0>=--this.refCount&&f(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var e=0;return Object.keys(c).forEach(function(t){e+=c[t].stats.size}),e}),{create:function(t,r){function f(t,r){var n=0,a=0,c=32854;if("object"==typeof t&&t?("shape"in t?(n=0|(a=t.shape)[0],a=0|a[1]):("radius"in t&&(n=a=0|t.radius),"width"in t&&(n=0|t.width),"height"in t&&(a=0|t.height)),"format"in t&&(c=o[t.format])):"number"==typeof t?(n=0|t,a="number"==typeof r?0|r:n):t||(n=a=1),n!==s.width||a!==s.height||c!==s.format)return f.width=s.width=n,f.height=s.height=a,s.format=c,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,c,n,a),i.profile&&(s.stats.size=ye[s.format]*s.width*s.height),f.format=u[s.format],f}var s=new a(e.createRenderbuffer());return c[s.id]=s,n.renderbufferCount++,f(t,r),f.resize=function(t,r){var n=0|t,a=0|r||n;return n===s.width&&a===s.height?f:(f.width=s.width=n,f.height=s.height=a,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,s.format,n,a),i.profile&&(s.stats.size=ye[s.format]*s.width*s.height),f)},f._reglType="renderbuffer",f._renderbuffer=s,i.profile&&(f.stats=s.stats),f.destroy=function(){s.decRef()},f},clear:function(){X(c).forEach(f)},restore:function(){X(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,t.renderbuffer),e.renderbufferStorage(36161,t.format,t.width,t.height)}),e.bindRenderbuffer(36161,null)}}},xe=[];xe[6408]=4,xe[6407]=3;var we=[];we[5121]=1,we[5126]=4,we[36193]=2;var Ae=["x","y","z","w"],ke="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),_e={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Oe={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Ee={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Te={cw:2304,ccw:2305},De=new z(!1,!1,!1,function(){});return function(e){function t(){if(0===J.length)A&&A.update(),ee=null;else{ee=N.next(t),l();for(var e=J.length-1;0<=e;--e){var r=J[e];r&&r(C,null,0)}m.flush(),A&&A.update()}}function r(){!ee&&0<J.length&&(ee=N.next(t))}function n(){ee&&(N.cancel(t),ee=null)}function a(e){e.preventDefault(),n(),K.forEach(function(e){e()})}function f(e){m.getError(),y.restore(),P.restore(),V.restore(),I.restore(),L.restore(),W.restore(),B.restore(),A&&A.restore(),Q.procs.refresh(),r(),Z.forEach(function(e){e()})}function o(e){function t(e){var t={},r={};return Object.keys(e).forEach(function(n){var i=e[n];U.isDynamic(i)?r[n]=U.unbox(i,n):t[n]=i}),{dynamic:r,static:t}}var r=t(e.context||{}),n=t(e.uniforms||{}),i=t(e.attributes||{}),a=t(function(e){function t(e){if(e in r){var t=r[e];delete r[e],Object.keys(t).forEach(function(n){r[e+"."+n]=t[n]})}}var r=H({},e);return delete r.uniforms,delete r.attributes,delete r.context,delete r.vao,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),"vao"in e&&(r.vao=e.vao),r}(e));e={gpuTime:0,cpuTime:0,count:0};var f=(r=Q.compile(a,i,n,r,e)).draw,o=r.batch,u=r.scope,s=[];return H(function(e,t){var r;if("function"==typeof e)return u.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(r=0;r<e;++r)u.call(this,null,t,r);else{if(!Array.isArray(e))return u.call(this,e,t,0);for(r=0;r<e.length;++r)u.call(this,e[r],t,r)}else if("number"==typeof e){if(0<e)return o.call(this,function(e){for(;s.length<e;)s.push(null);return s}(0|e),0|e)}else{if(!Array.isArray(e))return f.call(this,e);if(e.length)return o.call(this,e,e.length)}},{stats:e})}function u(e,t){var r=0;Q.procs.poll();var n=t.color;n&&(m.clearColor(+n[0]||0,+n[1]||0,+n[2]||0,+n[3]||0),r|=16384),"depth"in t&&(m.clearDepth(+t.depth),r|=256),"stencil"in t&&(m.clearStencil(0|t.stencil),r|=1024),m.clear(r)}function s(e){return J.push(e),r(),{cancel:function(){var t=R(J,e);J[t]=function e(){var t=R(J,e);J[t]=J[J.length-1],--J.length,0>=J.length&&n()}}}}function c(){var e=Y.viewport,t=Y.scissor_box;e[0]=e[1]=t[0]=t[1]=0,C.viewportWidth=C.framebufferWidth=C.drawingBufferWidth=e[2]=t[2]=m.drawingBufferWidth,C.viewportHeight=C.framebufferHeight=C.drawingBufferHeight=e[3]=t[3]=m.drawingBufferHeight}function l(){C.tick+=1,C.time=b(),c(),Q.procs.poll()}function p(){c(),Q.procs.refresh(),A&&A.update()}function b(){return(q()-k)/1e3}if(!(e=i(e)))return null;var m=e.gl,g=m.getContextAttributes();m.isContextLost();var y=function(e,t){function r(t){var r;t=t.toLowerCase();try{r=n[t]=e.getExtension(t)}catch(e){}return!!r}for(var n={},i=0;i<t.extensions.length;++i){var a=t.extensions[i];if(!r(a))return t.onDestroy(),t.onDone('"'+a+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(r),{extensions:n,restore:function(){Object.keys(n).forEach(function(e){if(n[e]&&!r(e))throw Error("(regl): error restoring extension "+e)})}}}(m,e);if(!y)return null;var v=function(){var e={"":0},t=[""];return{id:function(r){var n=e[r];return n||(n=e[r]=t.length,t.push(r),n)},str:function(e){return t[e]}}}(),x={vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},w=y.extensions,A=function(e,t){function r(){this.endQueryIndex=this.startQueryIndex=-1,this.sum=0,this.stats=null}function n(e,t,n){var i=f.pop()||new r;i.startQueryIndex=e,i.endQueryIndex=t,i.sum=0,i.stats=n,o.push(i)}if(!t.ext_disjoint_timer_query)return null;var i=[],a=[],f=[],o=[],u=[],s=[];return{beginQuery:function(e){var r=i.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(35007,r),a.push(r),n(a.length-1,a.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:n,update:function(){var e,r;if(0!==(e=a.length)){s.length=Math.max(s.length,e+1),u.length=Math.max(u.length,e+1),u[0]=0;var n=s[0]=0;for(r=e=0;r<a.length;++r){var c=a[r];t.ext_disjoint_timer_query.getQueryObjectEXT(c,34919)?(n+=t.ext_disjoint_timer_query.getQueryObjectEXT(c,34918),i.push(c)):a[e++]=c,u[r+1]=n,s[r+1]=e}for(a.length=e,r=e=0;r<o.length;++r){var l=(n=o[r]).startQueryIndex;c=n.endQueryIndex,n.sum+=u[c]-u[l],l=s[l],(c=s[c])===l?(n.stats.gpuTime+=n.sum/1e6,f.push(n)):(n.startQueryIndex=l,n.endQueryIndex=c,o[e++]=n)}o.length=e}},getNumPendingQueries:function(){return a.length},clear:function(){i.push.apply(i,a);for(var e=0;e<i.length;e++)t.ext_disjoint_timer_query.deleteQueryEXT(i[e]);a.length=0,i.length=0},restore:function(){a.length=0,i.length=0}}}(0,w),k=q(),E=m.drawingBufferWidth,j=m.drawingBufferHeight,C={tick:0,time:0,viewportWidth:E,viewportHeight:j,framebufferWidth:E,framebufferHeight:j,drawingBufferWidth:E,drawingBufferHeight:j,pixelRatio:e.pixelRatio},F=G(m,w),V=h(m,x,e,function(e){return B.destroyBuffer(e)}),B=T(m,w,F,x,V),z=d(m,w,V,x),P=D(m,v,x,e),I=_(m,w,F,function(){Q.procs.poll()},C,x,e),L=ve(m,w,0,x,e),W=O(m,w,F,I,L,x),Q=M(m,v,w,F,V,z,0,W,{},B,P,{elements:null,primitive:4,count:-1,offset:0,instances:-1},C,A,e),Y=(v=S(m,W,Q.procs.poll,C),Q.next),X=m.canvas,J=[],K=[],Z=[],$=[e.onDestroy],ee=null;X&&(X.addEventListener("webglcontextlost",a,!1),X.addEventListener("webglcontextrestored",f,!1));var te=W.setFBO=o({framebuffer:U.define.call(null,1,"framebuffer")});return p(),g=H(o,{clear:function(e){if("framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var t=0;6>t;++t)te(H({framebuffer:e.framebuffer.faces[t]},e),u);else te(e,u);else u(0,e)},prop:U.define.bind(null,1),context:U.define.bind(null,2),this:U.define.bind(null,3),draw:o({}),buffer:function(e){return V.create(e,34962,!1,!1)},elements:function(e){return z.create(e,!1)},texture:I.create2D,cube:I.createCube,renderbuffer:L.create,framebuffer:W.create,framebufferCube:W.createCube,vao:B.createVAO,attributes:g,frame:s,on:function(e,t){var r;switch(e){case"frame":return s(t);case"lost":r=K;break;case"restore":r=Z;break;case"destroy":r=$}return r.push(t),{cancel:function(){for(var e=0;e<r.length;++e)if(r[e]===t){r[e]=r[r.length-1],r.pop();break}}}},limits:F,hasExtension:function(e){return 0<=F.extensions.indexOf(e.toLowerCase())},read:v,destroy:function(){J.length=0,n(),X&&(X.removeEventListener("webglcontextlost",a),X.removeEventListener("webglcontextrestored",f)),P.clear(),W.clear(),L.clear(),I.clear(),z.clear(),V.clear(),B.clear(),A&&A.clear(),$.forEach(function(e){e()})},_gl:m,_refresh:p,poll:function(){l(),A&&A.update()},now:b,stats:x}),e.onDone(null,g),g}});
260
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.createREGL=t()}(this,function(){function e(e,t){this.id=H++,this.type=e,this.data=t}function t(e){return"["+function e(t){if(0===t.length)return[];var r=t.charAt(0),n=t.charAt(t.length-1);if(1<t.length&&r===n&&('"'===r||"'"===r))return['"'+t.substr(1,t.length-2).replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];if(r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t))return e(t.substr(0,r.index)).concat(e(r[1])).concat(e(t.substr(r.index+r[0].length)));if(1===(r=t.split(".")).length)return['"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];for(t=[],n=0;n<r.length;++n)t=t.concat(e(r[n]));return t}(e).join("][")+"]"}function r(e){return"string"==typeof e?e.split():e}function n(e){return"string"==typeof e?document.querySelector(e):e}function i(e){var t,i,a,f,o=e||{};e={};var u=[],s=[],c="undefined"==typeof window?1:window.devicePixelRatio,l=!1,p=function(e){},d=function(){};if("string"==typeof o?t=document.querySelector(o):"object"==typeof o&&("string"==typeof o.nodeName&&"function"==typeof o.appendChild&&"function"==typeof o.getBoundingClientRect?t=o:"function"==typeof o.drawArrays||"function"==typeof o.drawElements?a=(f=o).canvas:("gl"in o?f=o.gl:"canvas"in o?a=n(o.canvas):"container"in o&&(i=n(o.container)),"attributes"in o&&(e=o.attributes),"extensions"in o&&(u=r(o.extensions)),"optionalExtensions"in o&&(s=r(o.optionalExtensions)),"onDone"in o&&(p=o.onDone),"profile"in o&&(l=!!o.profile),"pixelRatio"in o&&(c=+o.pixelRatio))),t&&("canvas"===t.nodeName.toLowerCase()?a=t:i=t),!f){if(!a){if(!(t=function(e,t,r){function n(){var t=window.innerWidth,n=window.innerHeight;e!==document.body&&(t=(n=a.getBoundingClientRect()).right-n.left,n=n.bottom-n.top),a.width=r*t,a.height=r*n}var i,a=document.createElement("canvas");return R(a.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),e.appendChild(a),e===document.body&&(a.style.position="absolute",R(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver(function(){setTimeout(n)})).observe(e):window.addEventListener("resize",n,!1),n(),{canvas:a,onDestroy:function(){i?i.disconnect():window.removeEventListener("resize",n),e.removeChild(a)}}}(i||document.body,0,c)))return null;a=t.canvas,d=t.onDestroy}void 0===e.premultipliedAlpha&&(e.premultipliedAlpha=!0),f=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(a,e)}return f?{gl:f,canvas:a,container:i,extensions:u,optionalExtensions:s,pixelRatio:c,profile:l,onDone:p,onDestroy:d}:(d(),p("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function a(e,t){for(var r=Array(e),n=0;n<e;++n)r[n]=t(n);return r}function f(e){var t,r;return t=(65535<e)<<4,t|=r=(255<(e>>>=t))<<3,(t|=r=(15<(e>>>=r))<<2)|(r=(3<(e>>>=r))<<1)|e>>>r>>1}function o(){function e(e){e:{for(var t=16;268435456>=t;t*=16)if(e<=t){e=t;break e}e=0}return 0<(t=r[f(e)>>2]).length?t.pop():new ArrayBuffer(e)}function t(e){r[f(e.byteLength)>>2].push(e)}var r=a(8,function(){return[]});return{alloc:e,free:t,allocType:function(t,r){var n=null;switch(t){case 5120:n=new Int8Array(e(r),0,r);break;case 5121:n=new Uint8Array(e(r),0,r);break;case 5122:n=new Int16Array(e(2*r),0,r);break;case 5123:n=new Uint16Array(e(2*r),0,r);break;case 5124:n=new Int32Array(e(4*r),0,r);break;case 5125:n=new Uint32Array(e(4*r),0,r);break;case 5126:n=new Float32Array(e(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(e){t(e.buffer)}}}function u(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||G(e.data))}function s(e,t,r,n,i,a){for(var f=0;f<t;++f)for(var o=e[f],u=0;u<r;++u)for(var s=o[u],c=0;c<n;++c)i[a++]=s[c]}function c(e){return 0|J[Object.prototype.toString.call(e)]}function l(e,t){for(var r=0;r<t.length;++r)e[r]=t[r]}function p(e,t,r,n,i,a,f){for(var o=0,u=0;u<r;++u)for(var s=0;s<n;++s)e[o++]=t[i*u+a*s+f]}function d(e,t,r,n){function i(t){this.id=s++,this.buffer=e.createBuffer(),this.type=t,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=5121,this.persistentData=null,r.profile&&(this.stats={size:0})}function a(t,r,n){t.byteLength=r.byteLength,e.bufferData(t.type,r,n)}function f(e,t,r,n,i,f){if(e.usage=r,Array.isArray(t)){if(e.dtype=n||5126,0<t.length)if(Array.isArray(t[0])){i=ee(t);for(var o=n=1;o<i.length;++o)n*=i[o];e.dimension=n,a(e,t=$(t,i,e.dtype),r),f?e.persistentData=t:q.freeType(t)}else"number"==typeof t[0]?(e.dimension=i,l(i=q.allocType(e.dtype,t.length),t),a(e,i,r),f?e.persistentData=i:q.freeType(i)):G(t[0])&&(e.dimension=t[0].length,e.dtype=n||c(t[0])||5126,a(e,t=$(t,[t.length,t[0].length],e.dtype),r),f?e.persistentData=t:q.freeType(t))}else if(G(t))e.dtype=n||c(t),e.dimension=i,a(e,t,r),f&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(u(t)){i=t.shape;var s=t.stride,d=(o=t.offset,0),h=0,m=0,b=0;1===i.length?(d=i[0],h=1,m=s[0],b=0):2===i.length&&(d=i[0],h=i[1],m=s[0],b=s[1]),e.dtype=n||c(t.data)||5126,e.dimension=h,p(i=q.allocType(e.dtype,d*h),t.data,d,h,m,b,o),a(e,i,r),f?e.persistentData=i:q.freeType(i)}else t instanceof ArrayBuffer&&(e.dtype=5121,e.dimension=i,a(e,t,r),f&&(e.persistentData=new Uint8Array(new Uint8Array(t))))}function o(r){t.bufferCount--,n(r),e.deleteBuffer(r.buffer),r.buffer=null,delete d[r.id]}var s=0,d={};i.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},i.prototype.destroy=function(){o(this)};var h=[];return r.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(d).forEach(function(t){e+=d[t].stats.size}),e}),{create:function(n,a,s,h){function m(t){var n=35044,i=null,a=0,o=0,s=1;return Array.isArray(t)||G(t)||u(t)||t instanceof ArrayBuffer?i=t:"number"==typeof t?a=0|t:t&&("data"in t&&(i=t.data),"usage"in t&&(n=Z[t.usage]),"type"in t&&(o=K[t.type]),"dimension"in t&&(s=0|t.dimension),"length"in t&&(a=0|t.length)),b.bind(),i?f(b,i,n,o,s,h):(a&&e.bufferData(b.type,a,n),b.dtype=o||5121,b.usage=n,b.dimension=s,b.byteLength=a),r.profile&&(b.stats.size=b.byteLength*te[b.dtype]),m}t.bufferCount++;var b=new i(a);return d[b.id]=b,s||m(n),m._reglType="buffer",m._buffer=b,m.subdata=function(t,r){var n,i=0|(r||0);if(b.bind(),G(t)||t instanceof ArrayBuffer)e.bufferSubData(b.type,i,t);else if(Array.isArray(t)){if(0<t.length)if("number"==typeof t[0]){var a=q.allocType(b.dtype,t.length);l(a,t),e.bufferSubData(b.type,i,a),q.freeType(a)}else(Array.isArray(t[0])||G(t[0]))&&(n=ee(t),a=$(t,n,b.dtype),e.bufferSubData(b.type,i,a),q.freeType(a))}else if(u(t)){n=t.shape;var f=t.stride,o=a=0,s=0,d=0;1===n.length?(a=n[0],o=1,s=f[0],d=0):2===n.length&&(a=n[0],o=n[1],s=f[0],d=f[1]),n=Array.isArray(t.data)?b.dtype:c(t.data),p(n=q.allocType(n,a*o),t.data,a,o,s,d,t.offset),e.bufferSubData(b.type,i,n),q.freeType(n)}return m},r.profile&&(m.stats=b.stats),m.destroy=function(){o(b)},m},createStream:function(e,t){var r=h.pop();return r||(r=new i(e)),r.bind(),f(r,t,35040,0,1,!1),r},destroyStream:function(e){h.push(e)},clear:function(){Y(d).forEach(o),h.forEach(o)},getBuffer:function(e){return e&&e._buffer instanceof i?e._buffer:null},restore:function(){Y(d).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:f}}function h(e,t,r,n){function i(e){this.id=s++,o[this.id]=this,this.buffer=e,this.primType=4,this.type=this.vertCount=0}function a(n,i,a,f,o,s,c){var l;if(n.buffer.bind(),i?((l=c)||G(i)&&(!u(i)||G(i.data))||(l=t.oes_element_index_uint?5125:5123),r._initBuffer(n.buffer,i,a,l,3)):(e.bufferData(34963,s,a),n.buffer.dtype=l||5121,n.buffer.usage=a,n.buffer.dimension=3,n.buffer.byteLength=s),l=c,!c){switch(n.buffer.dtype){case 5121:case 5120:l=5121;break;case 5123:case 5122:l=5123;break;case 5125:case 5124:l=5125}n.buffer.dtype=l}n.type=l,0>(i=o)&&(i=n.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),n.vertCount=i,i=f,0>f&&(i=4,1===(f=n.buffer.dimension)&&(i=0),2===f&&(i=1),3===f&&(i=4)),n.primType=i}function f(e){n.elementsCount--,delete o[e.id],e.buffer.destroy(),e.buffer=null}var o={},s=0,c={uint8:5121,uint16:5123};t.oes_element_index_uint&&(c.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var l=[];return{create:function(e,t){function o(e){if(e)if("number"==typeof e)s(e),l.primType=4,l.vertCount=0|e,l.type=5121;else{var t=null,r=35044,n=-1,i=-1,f=0,p=0;Array.isArray(e)||G(e)||u(e)?t=e:("data"in e&&(t=e.data),"usage"in e&&(r=Z[e.usage]),"primitive"in e&&(n=re[e.primitive]),"count"in e&&(i=0|e.count),"type"in e&&(p=c[e.type]),"length"in e?f=0|e.length:(f=i,5123===p||5122===p?f*=2:5125!==p&&5124!==p||(f*=4))),a(l,t,r,n,i,f,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return o}var s=r.create(null,34963,!0),l=new i(s._buffer);return n.elementsCount++,o(e),o._reglType="elements",o._elements=l,o.subdata=function(e,t){return s.subdata(e,t),o},o.destroy=function(){f(l)},o},createStream:function(e){var t=l.pop();return t||(t=new i(r.create(null,34963,!0,!1)._buffer)),a(t,e,35040,-1,-1,0,0),t},destroyStream:function(e){l.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof i?e._elements:null},clear:function(){Y(o).forEach(f)}}}function m(e){for(var t=q.allocType(5123,e.length),r=0;r<e.length;++r)if(isNaN(e[r]))t[r]=65535;else if(1/0===e[r])t[r]=31744;else if(-1/0===e[r])t[r]=64512;else{ne[0]=e[r];var n=(a=ie[0])>>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;t[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15<i?n+31744:n+(i+15<<10)+a}return t}function b(e){return Array.isArray(e)||G(e)}function g(e){return"[object "+e+"]"}function y(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function v(e){return!(!Array.isArray(e)||0===e.length||!b(e[0]))}function x(e){return Object.prototype.toString.call(e)}function w(e){if(!e)return!1;var t=x(e);return 0<=he.indexOf(t)||(y(e)||v(e)||u(e))}function A(e,t){36193===e.type?(e.data=m(t),q.freeType(t)):e.data=t}function k(e,t,r,n,i,a){if(e=void 0!==be[e]?be[e]:oe[e]*me[t],a&&(e*=6),i){for(n=0;1<=r;)n+=e*r*r,r/=2;return n}return e*r*n}function _(e,t,r,n,i,a,f){function o(){this.format=this.internalformat=6408,this.type=5121,this.flipY=this.premultiplyAlpha=this.compressed=!1,this.unpackAlignment=1,this.colorSpace=37444,this.channels=this.height=this.width=0}function s(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function c(e,t){if("object"==typeof t&&t){"premultiplyAlpha"in t&&(e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(e.flipY=t.flipY),"alignment"in t&&(e.unpackAlignment=t.alignment),"colorSpace"in t&&(e.colorSpace=U[t.colorSpace]),"type"in t&&(e.type=N[t.type]);var r=e.width,n=e.height,i=e.channels,a=!1;"shape"in t?(r=t.shape[0],n=t.shape[1],3===t.shape.length&&(i=t.shape[2],a=!0)):("radius"in t&&(r=n=t.radius),"width"in t&&(r=t.width),"height"in t&&(n=t.height),"channels"in t&&(i=t.channels,a=!0)),e.width=0|r,e.height=0|n,e.channels=0|i,r=!1,"format"in t&&(r=t.format,n=e.internalformat=Q[r],e.format=he[n],r in N&&!("type"in t)&&(e.type=N[r]),r in K&&(e.compressed=!0),r=!0),!a&&r?e.channels=oe[e.format]:a&&!r&&e.channels!==fe[e.format]&&(e.format=e.internalformat=fe[e.channels])}}function l(t){e.pixelStorei(37440,t.flipY),e.pixelStorei(37441,t.premultiplyAlpha),e.pixelStorei(37443,t.colorSpace),e.pixelStorei(3317,t.unpackAlignment)}function p(){o.call(this),this.yOffset=this.xOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function d(e,t){var r=null;if(w(t)?r=t:t&&(c(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),w(t.data)&&(r=t.data)),t.copy){var n=i.viewportWidth,a=i.viewportHeight;e.width=e.width||n-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0}else if(r){if(G(r))e.channels=e.channels||4,e.data=r,"type"in t||5121!==e.type||(e.type=0|J[Object.prototype.toString.call(r)]);else if(y(r)){switch(e.channels=e.channels||4,a=(n=r).length,e.type){case 5121:case 5123:case 5125:case 5126:(a=q.allocType(e.type,a)).set(n),e.data=a;break;case 36193:e.data=m(n)}e.alignment=1,e.needsFree=!0}else if(u(r)){n=r.data,Array.isArray(n)||5121!==e.type||(e.type=0|J[Object.prototype.toString.call(n)]);a=r.shape;var f,o,s,l,p=r.stride;3===a.length?(s=a[2],l=p[2]):l=s=1,f=a[0],o=a[1],a=p[0],p=p[1],e.alignment=1,e.width=f,e.height=o,e.channels=s,e.format=e.internalformat=fe[s],e.needsFree=!0,f=l,r=r.offset,s=e.width,l=e.height,o=e.channels;for(var d=q.allocType(36193===e.type?5126:e.type,s*l*o),h=0,g=0;g<l;++g)for(var k=0;k<s;++k)for(var _=0;_<o;++_)d[h++]=n[a*k+p*g+f*_+r];A(e,d)}else if(x(r)===ue||x(r)===se||x(r)===ce)x(r)===ue||x(r)===se?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(x(r)===le)e.element=r,e.width=r.width,e.height=r.height,e.channels=4;else if(x(r)===pe)e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(x(r)===de)e.element=r,e.width=r.videoWidth,e.height=r.videoHeight,e.channels=4;else if(v(r)){for(n=e.width||r[0].length,a=e.height||r.length,p=e.channels,p=b(r[0][0])?p||r[0][0].length:p||1,f=X.shape(r),s=1,l=0;l<f.length;++l)s*=f[l];s=q.allocType(36193===e.type?5126:e.type,s),X.flatten(r,f,"",s),A(e,s),e.alignment=1,e.width=n,e.height=a,e.channels=p,e.format=e.internalformat=fe[p],e.needsFree=!0}}else e.width=e.width||1,e.height=e.height||1,e.channels=e.channels||4}function h(t,r,i,a,f){var o=t.element,u=t.data,s=t.internalformat,c=t.format,p=t.type,d=t.width,h=t.height;l(t),o?e.texSubImage2D(r,f,i,a,c,p,o):t.compressed?e.compressedTexSubImage2D(r,f,i,a,s,d,h,u):t.needsCopy?(n(),e.copyTexSubImage2D(r,f,i,a,t.xOffset,t.yOffset,d,h)):e.texSubImage2D(r,f,i,a,d,h,c,p,u)}function g(){return me.pop()||new p}function _(e){e.needsFree&&q.freeType(e.data),p.call(e),me.push(e)}function O(){o.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)}function E(e,t,r){var n=e.images[0]=g();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function D(e,t){var r=null;if(w(t))s(r=e.images[0]=g(),e),d(r,t),e.mipmask=1;else if(c(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,i=0;i<n.length;++i)s(r=e.images[i]=g(),e),r.width>>=i,r.height>>=i,d(r,n[i]),e.mipmask|=1<<i;else s(r=e.images[0]=g(),e),d(r,t),e.mipmask=1;s(e,e.images[0])}function T(t,r){for(var i=t.images,a=0;a<i.length&&i[a];++a){var f=i[a],o=r,u=a,s=f.element,c=f.data,p=f.internalformat,d=f.format,h=f.type,m=f.width,b=f.height;l(f),s?e.texImage2D(o,u,d,d,h,s):f.compressed?e.compressedTexImage2D(o,u,p,m,b,0,c):f.needsCopy?(n(),e.copyTexImage2D(o,u,d,f.xOffset,f.yOffset,m,b,0)):e.texImage2D(o,u,d,m,b,0,d,h,c||null)}}function S(){var e=be.pop()||new O;o.call(e);for(var t=e.mipmask=0;16>t;++t)e.images[t]=null;return e}function j(e){for(var t=e.images,r=0;r<t.length;++r)t[r]&&_(t[r]),t[r]=null;be.push(e)}function C(){this.magFilter=this.minFilter=9728,this.wrapT=this.wrapS=33071,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=4352}function V(e,t){"min"in t&&(e.minFilter=W[t.min],0<=ae.indexOf(e.minFilter)&&!("faces"in t)&&(e.genMipmaps=!0)),"mag"in t&&(e.magFilter=H[t.mag]);var r=e.wrapS,n=e.wrapT;if("wrap"in t){var i=t.wrap;"string"==typeof i?r=n=M[i]:Array.isArray(i)&&(r=M[i[0]],n=M[i[1]])}else"wrapS"in t&&(r=M[t.wrapS]),"wrapT"in t&&(n=M[t.wrapT]);if(e.wrapS=r,e.wrapT=n,"anisotropic"in t&&(e.anisotropic=t.anisotropic),"mipmap"in t){switch(r=!1,typeof t.mipmap){case"string":e.mipmapHint=L[t.mipmap],r=e.genMipmaps=!0;break;case"boolean":r=e.genMipmaps=t.mipmap;break;case"object":e.genMipmaps=!1,r=!0}!r||"min"in t||(e.minFilter=9984)}}function F(r,n){e.texParameteri(n,10241,r.minFilter),e.texParameteri(n,10240,r.magFilter),e.texParameteri(n,10242,r.wrapS),e.texParameteri(n,10243,r.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(n,34046,r.anisotropic),r.genMipmaps&&(e.hint(33170,r.mipmapHint),e.generateMipmap(n))}function B(t){o.call(this),this.mipmask=0,this.internalformat=6408,this.id=ge++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new C,f.profile&&(this.stats={size:0})}function z(t){e.activeTexture(33984),e.bindTexture(t.target,t.texture)}function I(){var t=xe[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(3553,null)}function P(t){var r=t.texture,n=t.unit,i=t.target;0<=n&&(e.activeTexture(33984+n),e.bindTexture(i,null),xe[n]=null),e.deleteTexture(r),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete ye[t.id],a.textureCount--}var L={"don't care":4352,"dont care":4352,nice:4354,fast:4353},M={repeat:10497,clamp:33071,mirror:33648},H={nearest:9728,linear:9729},W=R({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},H),U={none:0,browser:37444},N={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},Q={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},K={};t.ext_srgb&&(Q.srgb=35904,Q.srgba=35906),t.oes_texture_float&&(N.float32=N.float=5126),t.oes_texture_half_float&&(N.float16=N["half float"]=36193),t.webgl_depth_texture&&(R(Q,{depth:6402,"depth stencil":34041}),R(N,{uint16:5123,uint32:5125,"depth stencil":34042})),t.webgl_compressed_texture_s3tc&&R(K,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),t.webgl_compressed_texture_atc&&R(K,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),t.webgl_compressed_texture_pvrtc&&R(K,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),t.webgl_compressed_texture_etc1&&(K["rgb etc1"]=36196);var Z=Array.prototype.slice.call(e.getParameter(34467));Object.keys(K).forEach(function(e){var t=K[e];0<=Z.indexOf(t)&&(Q[e]=t)});var $=Object.keys(Q);r.textureFormats=$;var ee=[];Object.keys(Q).forEach(function(e){ee[Q[e]]=e});var te=[];Object.keys(N).forEach(function(e){te[N[e]]=e});var re=[];Object.keys(H).forEach(function(e){re[H[e]]=e});var ne=[];Object.keys(W).forEach(function(e){ne[W[e]]=e});var ie=[];Object.keys(M).forEach(function(e){ie[M[e]]=e});var he=$.reduce(function(e,r){var n=Q[r];return 6409===n||6406===n||6409===n||6410===n||6402===n||34041===n||t.ext_srgb&&(35904===n||35906===n)?e[n]=n:32855===n||0<=r.indexOf("rgba")?e[n]=6408:e[n]=6407,e},{}),me=[],be=[],ge=0,ye={},ve=r.maxTextureUnits,xe=Array(ve).map(function(){return null});return R(B.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(0>t){for(var r=0;r<ve;++r){var n=xe[r];if(n){if(0<n.bindCount)continue;n.unit=-1}xe[r]=this,t=r;break}f.profile&&a.maxTextureUnits<t+1&&(a.maxTextureUnits=t+1),this.unit=t,e.activeTexture(33984+t),e.bindTexture(this.target,this.texture)}return t},unbind:function(){--this.bindCount},decRef:function(){0>=--this.refCount&&P(this)}}),f.profile&&(a.getTotalTextureSize=function(){var e=0;return Object.keys(ye).forEach(function(t){e+=ye[t].stats.size}),e}),{create2D:function(t,r){function n(e,t){var r=i.texInfo;C.call(r);var a=S();return"number"==typeof e?E(a,0|e,"number"==typeof t?0|t:0|e):e?(V(r,e),D(a,e)):E(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,s(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,z(i),T(a,3553),F(r,3553),I(),j(a),f.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=ee[i.internalformat],n.type=te[i.type],n.mag=re[r.magFilter],n.min=ne[r.minFilter],n.wrapS=ie[r.wrapS],n.wrapT=ie[r.wrapT],n}var i=new B(3553);return ye[i.id]=i,a.textureCount++,n(t,r),n.subimage=function(e,t,r,a){t|=0,r|=0,a|=0;var f=g();return s(f,i),f.width=0,f.height=0,d(f,e),f.width=f.width||(i.width>>a)-t,f.height=f.height||(i.height>>a)-r,z(i),h(f,3553,t,r,a),I(),_(f),n},n.resize=function(t,r){var a=0|t,o=0|r||a;if(a===i.width&&o===i.height)return n;n.width=i.width=a,n.height=i.height=o,z(i);for(var u=0;i.mipmask>>u;++u){var s=a>>u,c=o>>u;if(!s||!c)break;e.texImage2D(3553,u,i.format,s,c,0,i.format,i.type,null)}return I(),f.profile&&(i.stats.size=k(i.internalformat,i.type,a,o,!1,!1)),n},n._reglType="texture2d",n._texture=i,f.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(t,r,n,i,o,u){function l(e,t,r,n,i,a){var o,u=p.texInfo;for(C.call(u),o=0;6>o;++o)m[o]=S();if("number"!=typeof e&&e){if("object"==typeof e)if(t)D(m[0],e),D(m[1],t),D(m[2],r),D(m[3],n),D(m[4],i),D(m[5],a);else if(V(u,e),c(p,e),"faces"in e)for(e=e.faces,o=0;6>o;++o)s(m[o],p),D(m[o],e[o]);else for(o=0;6>o;++o)D(m[o],e)}else for(e=0|e||1,o=0;6>o;++o)E(m[o],e,e);for(s(p,m[0]),p.mipmask=u.genMipmaps?(m[0].width<<1)-1:m[0].mipmask,p.internalformat=m[0].internalformat,l.width=m[0].width,l.height=m[0].height,z(p),o=0;6>o;++o)T(m[o],34069+o);for(F(u,34067),I(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=ee[p.internalformat],l.type=te[p.type],l.mag=re[u.magFilter],l.min=ne[u.minFilter],l.wrapS=ie[u.wrapS],l.wrapT=ie[u.wrapT],o=0;6>o;++o)j(m[o]);return l}var p=new B(34067);ye[p.id]=p,a.cubeCount++;var m=Array(6);return l(t,r,n,i,o,u),l.subimage=function(e,t,r,n,i){r|=0,n|=0,i|=0;var a=g();return s(a,p),a.width=0,a.height=0,d(a,t),a.width=a.width||(p.width>>i)-r,a.height=a.height||(p.height>>i)-n,z(p),h(a,34069+e,r,n,i),I(),_(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,z(p);for(var r=0;6>r;++r)for(var n=0;p.mipmask>>n;++n)e.texImage2D(34069+r,n,p.format,t>>n,t>>n,0,p.format,p.type,null);return I(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,!1,!0)),l}},l._reglType="textureCube",l._texture=p,f.profile&&(l.stats=p.stats),l.destroy=function(){p.decRef()},l},clear:function(){for(var t=0;t<ve;++t)e.activeTexture(33984+t),e.bindTexture(3553,null),xe[t]=null;Y(ye).forEach(P),a.cubeCount=0,a.textureCount=0},getTexture:function(e){return null},restore:function(){for(var t=0;t<ve;++t){var r=xe[t];r&&(r.bindCount=0,r.unit=-1,xe[t]=null)}Y(ye).forEach(function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var r=0;32>r;++r)if(0!=(t.mipmask&1<<r))if(3553===t.target)e.texImage2D(3553,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;6>n;++n)e.texImage2D(34069+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);F(t.texInfo,t.target)})},refresh:function(){for(var t=0;t<ve;++t){var r=xe[t];r&&(r.bindCount=0,r.unit=-1,xe[t]=null),e.activeTexture(33984+t),e.bindTexture(3553,null),e.bindTexture(34067,null)}}}}function O(e,t,r,n,i,a){function f(e,t,r){this.target=e,this.texture=t,this.renderbuffer=r;var n=e=0;t?(e=t.width,n=t.height):r&&(e=r.width,n=r.height),this.width=e,this.height=n}function o(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function u(e,t,r){e&&(e.texture?e.texture._texture.refCount+=1:e.renderbuffer._renderbuffer.refCount+=1)}function s(t,r){r&&(r.texture?e.framebufferTexture2D(36160,t,r.target,r.texture._texture.texture,0):e.framebufferRenderbuffer(36160,t,36161,r.renderbuffer._renderbuffer.renderbuffer))}function c(e){var t=3553,r=null,n=null,i=e;return"object"==typeof e&&(i=e.data,"target"in e&&(t=0|e.target)),"texture2d"===(e=i._reglType)?r=i:"textureCube"===e?r=i:"renderbuffer"===e&&(n=i,t=36161),new f(t,r,n)}function l(e,t,r,a,o){return r?((e=n.create2D({width:e,height:t,format:a,type:o}))._texture.refCount=0,new f(3553,e,null)):((e=i.create({width:e,height:t,format:a}))._renderbuffer.refCount=0,new f(36161,null,e))}function p(e){return e&&(e.texture||e.renderbuffer)}function d(e,t,r){e&&(e.texture?e.texture.resize(t,r):e.renderbuffer&&e.renderbuffer.resize(t,r),e.width=t,e.height=r)}function h(){this.id=k++,_[this.id]=this,this.framebuffer=e.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function m(e){e.colorAttachments.forEach(o),o(e.depthAttachment),o(e.stencilAttachment),o(e.depthStencilAttachment)}function b(t){e.deleteFramebuffer(t.framebuffer),t.framebuffer=null,a.framebufferCount--,delete _[t.id]}function g(t){var n;e.bindFramebuffer(36160,t.framebuffer);var i=t.colorAttachments;for(n=0;n<i.length;++n)s(36064+n,i[n]);for(n=i.length;n<r.maxColorAttachments;++n)e.framebufferTexture2D(36160,36064+n,3553,null,0);e.framebufferTexture2D(36160,33306,3553,null,0),e.framebufferTexture2D(36160,36096,3553,null,0),e.framebufferTexture2D(36160,36128,3553,null,0),s(36096,t.depthAttachment),s(36128,t.stencilAttachment),s(33306,t.depthStencilAttachment),e.checkFramebufferStatus(36160),e.isContextLost(),e.bindFramebuffer(36160,v.next?v.next.framebuffer:null),v.cur=v.next,e.getError()}function y(e,t){function r(e,t){var i,a=0,f=0,o=!0,s=!0;i=null;var d=!0,h="rgba",b="uint8",y=1,v=null,A=null,k=null,_=!1;"number"==typeof e?(a=0|e,f=0|t||a):e?("shape"in e?(a=(f=e.shape)[0],f=f[1]):("radius"in e&&(a=f=e.radius),"width"in e&&(a=e.width),"height"in e&&(f=e.height)),("color"in e||"colors"in e)&&(i=e.color||e.colors,Array.isArray(i)),i||("colorCount"in e&&(y=0|e.colorCount),"colorTexture"in e&&(d=!!e.colorTexture,h="rgba4"),"colorType"in e&&(b=e.colorType,!d)&&("half float"===b||"float16"===b?h="rgba16f":"float"!==b&&"float32"!==b||(h="rgba32f")),"colorFormat"in e&&(h=e.colorFormat,0<=x.indexOf(h)?d=!0:0<=w.indexOf(h)&&(d=!1))),("depthTexture"in e||"depthStencilTexture"in e)&&(_=!(!e.depthTexture&&!e.depthStencilTexture)),"depth"in e&&("boolean"==typeof e.depth?o=e.depth:(v=e.depth,s=!1)),"stencil"in e&&("boolean"==typeof e.stencil?s=e.stencil:(A=e.stencil,o=!1)),"depthStencil"in e&&("boolean"==typeof e.depthStencil?o=s=e.depthStencil:(k=e.depthStencil,s=o=!1))):a=f=1;var O=null,E=null,D=null,T=null;if(Array.isArray(i))O=i.map(c);else if(i)O=[c(i)];else for(O=Array(y),i=0;i<y;++i)O[i]=l(a,f,d,h,b);for(a=a||O[0].width,f=f||O[0].height,v?E=c(v):o&&!s&&(E=l(a,f,_,"depth","uint32")),A?D=c(A):s&&!o&&(D=l(a,f,!1,"stencil","uint8")),k?T=c(k):!v&&!A&&s&&o&&(T=l(a,f,_,"depth stencil","depth stencil")),o=null,i=0;i<O.length;++i)u(O[i]),O[i]&&O[i].texture&&(s=ve[O[i].texture._texture.format]*xe[O[i].texture._texture.type],null===o&&(o=s));return u(E),u(D),u(T),m(n),n.width=a,n.height=f,n.colorAttachments=O,n.depthAttachment=E,n.stencilAttachment=D,n.depthStencilAttachment=T,r.color=O.map(p),r.depth=p(E),r.stencil=p(D),r.depthStencil=p(T),r.width=n.width,r.height=n.height,g(n),r}var n=new h;return a.framebufferCount++,r(e,t),R(r,{resize:function(e,t){var i=Math.max(0|e,1),a=Math.max(0|t||i,1);if(i===n.width&&a===n.height)return r;for(var f=n.colorAttachments,o=0;o<f.length;++o)d(f[o],i,a);return d(n.depthAttachment,i,a),d(n.stencilAttachment,i,a),d(n.depthStencilAttachment,i,a),n.width=r.width=i,n.height=r.height=a,g(n),r},_reglType:"framebuffer",_framebuffer:n,destroy:function(){b(n),m(n)},use:function(e){v.setFBO({framebuffer:r},e)}})}var v={cur:null,next:null,dirty:!1,setFBO:null},x=["rgba"],w=["rgba4","rgb565","rgb5 a1"];t.ext_srgb&&w.push("srgba"),t.ext_color_buffer_half_float&&w.push("rgba16f","rgb16f"),t.webgl_color_buffer_float&&w.push("rgba32f");var A=["uint8"];t.oes_texture_half_float&&A.push("half float","float16"),t.oes_texture_float&&A.push("float","float32");var k=0,_={};return R(v,{getFramebuffer:function(e){return"function"==typeof e&&"framebuffer"===e._reglType&&(e=e._framebuffer)instanceof h?e:null},create:y,createCube:function(e){function t(e){var i,a={color:null},f=0,o=null;i="rgba";var u="uint8",s=1;if("number"==typeof e?f=0|e:e?("shape"in e?f=e.shape[0]:("radius"in e&&(f=0|e.radius),"width"in e?f=0|e.width:"height"in e&&(f=0|e.height)),("color"in e||"colors"in e)&&(o=e.color||e.colors,Array.isArray(o)),o||("colorCount"in e&&(s=0|e.colorCount),"colorType"in e&&(u=e.colorType),"colorFormat"in e&&(i=e.colorFormat)),"depth"in e&&(a.depth=e.depth),"stencil"in e&&(a.stencil=e.stencil),"depthStencil"in e&&(a.depthStencil=e.depthStencil)):f=1,o)if(Array.isArray(o))for(e=[],i=0;i<o.length;++i)e[i]=o[i];else e=[o];else for(e=Array(s),o={radius:f,format:i,type:u},i=0;i<s;++i)e[i]=n.createCube(o);for(a.color=Array(e.length),i=0;i<e.length;++i)s=e[i],f=f||s.width,a.color[i]={target:34069,data:e[i]};for(i=0;6>i;++i){for(s=0;s<e.length;++s)a.color[s].target=34069+i;0<i&&(a.depth=r[0].depth,a.stencil=r[0].stencil,a.depthStencil=r[0].depthStencil),r[i]?r[i](a):r[i]=y(a)}return R(t,{width:f,height:f,color:e})}var r=Array(6);return t(e),R(t,{faces:r,resize:function(e){var n=0|e;if(n===t.width)return t;var i=t.color;for(e=0;e<i.length;++e)i[e].resize(n);for(e=0;6>e;++e)r[e].resize(n);return t.width=t.height=n,t},_reglType:"framebufferCube",destroy:function(){r.forEach(function(e){e.destroy()})}})},clear:function(){Y(_).forEach(b)},restore:function(){v.cur=null,v.next=null,v.dirty=!0,Y(_).forEach(function(t){t.framebuffer=e.createFramebuffer(),g(t)})}})}function E(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function D(e,t,r,n,i,a,f){function o(){this.id=++l,this.attributes=[],this.elements=null,this.ownsElements=!1,this.offset=this.count=0,this.instances=-1,this.primitive=4;var e=t.oes_vertex_array_object;this.vao=e?e.createVertexArrayOES():null,p[this.id]=this,this.buffers=[]}var s=r.maxAttributes,c=Array(s);for(r=0;r<s;++r)c[r]=new E;var l=0,p={},d={Record:E,scope:{},state:c,currentVAO:null,targetVAO:null,restore:t.oes_vertex_array_object?function(){t.oes_vertex_array_object&&Y(p).forEach(function(e){e.refresh()})}:function(){},createVAO:function(e){function t(e){var n;Array.isArray(e)?(n=e,r.elements&&r.ownsElements&&r.elements.destroy(),r.elements=null,r.ownsElements=!1,r.offset=0,r.count=0,r.instances=-1,r.primitive=4):(e.elements?(n=e.elements,r.ownsElements?("function"==typeof n&&"elements"===n._reglType?r.elements.destroy():r.elements(n),r.ownsElements=!1):a.getElements(e.elements)?(r.elements=e.elements,r.ownsElements=!1):(r.elements=a.create(e.elements),r.ownsElements=!0)):(r.elements=null,r.ownsElements=!1),n=e.attributes,r.offset=0,r.count=-1,r.instances=-1,r.primitive=4,r.elements&&(r.count=r.elements._elements.vertCount,r.primitive=r.elements._elements.primType),"offset"in e&&(r.offset=0|e.offset),"count"in e&&(r.count=0|e.count),"instances"in e&&(r.instances=0|e.instances),"primitive"in e&&(r.primitive=re[e.primitive])),e={};var f=r.attributes;f.length=n.length;for(var o=0;o<n.length;++o){var s,c=n[o],l=f[o]=new E,p=c.data||c;if(Array.isArray(p)||G(p)||u(p))r.buffers[o]&&(s=r.buffers[o],G(p)&&s._buffer.byteLength>=p.byteLength?s.subdata(p):(s.destroy(),r.buffers[o]=null)),r.buffers[o]||(s=r.buffers[o]=i.create(c,34962,!1,!0)),l.buffer=i.getBuffer(s),l.size=0|l.buffer.dimension,l.normalized=!1,l.type=l.buffer.dtype,l.offset=0,l.stride=0,l.divisor=0,l.state=1,e[o]=1;else i.getBuffer(c)?(l.buffer=i.getBuffer(c),l.size=0|l.buffer.dimension,l.normalized=!1,l.type=l.buffer.dtype,l.offset=0,l.stride=0,l.divisor=0,l.state=1):i.getBuffer(c.buffer)?(l.buffer=i.getBuffer(c.buffer),l.size=0|(+c.size||l.buffer.dimension),l.normalized=!!c.normalized||!1,l.type="type"in c?K[c.type]:l.buffer.dtype,l.offset=0|(c.offset||0),l.stride=0|(c.stride||0),l.divisor=0|(c.divisor||0),l.state=1):"x"in c&&(l.x=+c.x||0,l.y=+c.y||0,l.z=+c.z||0,l.w=+c.w||0,l.state=2)}for(s=0;s<r.buffers.length;++s)!e[s]&&r.buffers[s]&&(r.buffers[s].destroy(),r.buffers[s]=null);return r.refresh(),t}var r=new o;return n.vaoCount+=1,t.destroy=function(){for(var e=0;e<r.buffers.length;++e)r.buffers[e]&&r.buffers[e].destroy();r.buffers.length=0,r.ownsElements&&(r.elements.destroy(),r.elements=null,r.ownsElements=!1),r.destroy()},t._vao=r,t._reglType="vao",t(e)},getVAO:function(e){return"function"==typeof e&&e._vao?e._vao:null},destroyBuffer:function(t){for(var r=0;r<c.length;++r){var n=c[r];n.buffer===t&&(e.disableVertexAttribArray(r),n.buffer=null)}},setVAO:t.oes_vertex_array_object?function(e){if(e!==d.currentVAO){var r=t.oes_vertex_array_object;e?r.bindVertexArrayOES(e.vao):r.bindVertexArrayOES(null),d.currentVAO=e}}:function(r){if(r!==d.currentVAO){if(r)r.bindAttrs();else{for(var n=t.angle_instanced_arrays,i=0;i<c.length;++i){var a=c[i];a.buffer?(e.enableVertexAttribArray(i),a.buffer.bind(),e.vertexAttribPointer(i,a.size,a.type,a.normalized,a.stride,a.offfset),n&&a.divisor&&n.vertexAttribDivisorANGLE(i,a.divisor)):(e.disableVertexAttribArray(i),e.vertexAttrib4f(i,a.x,a.y,a.z,a.w))}f.elements?e.bindBuffer(34963,f.elements.buffer.buffer):e.bindBuffer(34963,null)}d.currentVAO=r}},clear:t.oes_vertex_array_object?function(){Y(p).forEach(function(e){e.destroy()})}:function(){}};return o.prototype.bindAttrs=function(){for(var r=t.angle_instanced_arrays,n=this.attributes,i=0;i<n.length;++i){var f=n[i];f.buffer?(e.enableVertexAttribArray(i),e.bindBuffer(34962,f.buffer.buffer),e.vertexAttribPointer(i,f.size,f.type,f.normalized,f.stride,f.offset),r&&f.divisor&&r.vertexAttribDivisorANGLE(i,f.divisor)):(e.disableVertexAttribArray(i),e.vertexAttrib4f(i,f.x,f.y,f.z,f.w))}for(r=n.length;r<s;++r)e.disableVertexAttribArray(r);(r=a.getElements(this.elements))?e.bindBuffer(34963,r.buffer.buffer):e.bindBuffer(34963,null)},o.prototype.refresh=function(){var e=t.oes_vertex_array_object;e&&(e.bindVertexArrayOES(this.vao),this.bindAttrs(),d.currentVAO=null,e.bindVertexArrayOES(null))},o.prototype.destroy=function(){if(this.vao){var e=t.oes_vertex_array_object;this===d.currentVAO&&(d.currentVAO=null,e.bindVertexArrayOES(null)),e.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),p[this.id]&&(delete p[this.id],--n.vaoCount)},d}function T(e,t,r,n){function i(e,t,r,n){this.name=e,this.id=t,this.location=r,this.info=n}function a(e,t){for(var r=0;r<e.length;++r)if(e[r].id===t.id)return void(e[r].location=t.location);e.push(t)}function f(r,n,i){if(!(f=(i=35632===r?s:c)[n])){var a=t.str(n),f=e.createShader(r);e.shaderSource(f,a),e.compileShader(f),i[n]=f}return f}function o(e,t){this.id=d++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,n.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function u(r,o,u){var s;s=f(35632,r.fragId);var c=f(35633,r.vertId);if(o=r.program=e.createProgram(),e.attachShader(o,s),e.attachShader(o,c),u)for(s=0;s<u.length;++s)c=u[s],e.bindAttribLocation(o,c[0],c[1]);e.linkProgram(o),c=e.getProgramParameter(o,35718),n.profile&&(r.stats.uniformsCount=c);var l=r.uniforms;for(s=0;s<c;++s)if(u=e.getActiveUniform(o,s)){if(1<u.size)for(var p=0;p<u.size;++p){var d=u.name.replace("[0]","["+p+"]");a(l,new i(d,t.id(d),e.getUniformLocation(o,d),u))}p=u.name,1<u.size&&(p=p.replace("[0]","")),a(l,new i(p,t.id(p),e.getUniformLocation(o,p),u))}for(c=e.getProgramParameter(o,35721),n.profile&&(r.stats.attributesCount=c),r=r.attributes,s=0;s<c;++s)(u=e.getActiveAttrib(o,s))&&a(r,new i(u.name,t.id(u.name),e.getAttribLocation(o,u.name),u))}var s={},c={},l={},p=[],d=0;return n.profile&&(r.getMaxUniformsCount=function(){var e=0;return p.forEach(function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)}),e},r.getMaxAttributesCount=function(){var e=0;return p.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);Y(s).forEach(t),s={},Y(c).forEach(t),c={},p.forEach(function(t){e.deleteProgram(t.program)}),p.length=0,l={},r.shaderCount=0},program:function(t,n,i,a){var f=l[n];f||(f=l[n]={});var d=f[t];if(d&&(d.refCount++,!a))return d;var h=new o(n,t);return r.shaderCount++,u(h,i,a),d||(f[t]=h),p.push(h),R(h,{destroy:function(){if(h.refCount--,0>=h.refCount){e.deleteProgram(h.program);var t=p.indexOf(h);p.splice(t,1),r.shaderCount--}0>=f[h.vertId].refCount&&(e.deleteShader(c[h.vertId]),delete c[h.vertId],delete l[h.fragId][h.vertId]),Object.keys(l[h.fragId]).length||(e.deleteShader(s[h.fragId]),delete s[h.fragId],delete l[h.fragId])}})},restore:function(){s={},c={};for(var e=0;e<p.length;++e)u(p[e],null,p[e].attributes.map(function(e){return[e.location,e.name]}))},shader:f,frag:-1,vert:-1}}function S(e,t,r,n,i,a,f){function o(i){var a;a=null===t.next?5121:t.next.colorAttachments[0].texture._texture.type;var f=0,o=0,u=n.framebufferWidth,s=n.framebufferHeight,c=null;return G(i)?c=i:i&&(f=0|i.x,o=0|i.y,u=0|(i.width||n.framebufferWidth-f),s=0|(i.height||n.framebufferHeight-o),c=i.data||null),r(),i=u*s*4,c||(5121===a?c=new Uint8Array(i):5126===a&&(c=c||new Float32Array(i))),e.pixelStorei(3333,4),e.readPixels(f,o,u,s,6408,a,c),c}return function(e){return e&&"framebuffer"in e?function(e){var r;return t.setFBO({framebuffer:e.framebuffer},function(){r=o(e)}),r}(e):o(e)}}function j(e){return Array.prototype.slice.call(e)}function C(e){return j(e).join("")}function V(e){return Array.isArray(e)||G(e)||u(e)}function F(e){return e.sort(function(e,t){return"viewport"===e?-1:"viewport"===t?1:e<t?-1:1})}function B(e,t,r,n){this.thisDep=e,this.contextDep=t,this.propDep=r,this.append=n}function z(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function I(e){return new B(!1,!1,!1,e)}function P(e,t){var r=e.type;if(0===r)return new B(!0,1<=(r=e.data.length),2<=r,t);if(4===r)return new B((r=e.data).thisDep,r.contextDep,r.propDep,t);if(5===r)return new B(!1,!1,!1,t);if(6===r){for(var n=r=!1,i=!1,a=0;a<e.data.length;++a){var f=e.data[a];1===f.type?i=!0:2===f.type?n=!0:3===f.type?r=!0:0===f.type?(r=!0,1<=(f=f.data)&&(n=!0),2<=f&&(i=!0)):4===f.type&&(r=r||f.data.thisDep,n=n||f.data.contextDep,i=i||f.data.propDep)}return new B(r,n,i,t)}return new B(3===r,2===r,1===r,t)}function L(e,t,r,n,i,f,o,u,s,c,l,p,d,h,m){function g(e){return e.replace(".","_")}function y(e,t,r){var n=g(e);fe.push(e),ae[n]=ie[n]=!!r,oe[n]=t}function v(e,t,r){var n=g(e);fe.push(e),Array.isArray(r)?(ie[n]=r.slice(),ae[n]=r.slice()):ie[n]=ae[n]=r,ue[n]=t}function x(){var e=function(){function e(){var e=[],t=[];return R(function(){e.push.apply(e,j(arguments))},{def:function(){var n="v"+r++;return t.push(n),0<arguments.length&&(e.push(n,"="),e.push.apply(e,j(arguments)),e.push(";")),n},toString:function(){return C([0<t.length?"var "+t.join(",")+";":"",C(e)])}})}function t(){function t(e,t){n(e,t,"=",r.def(e,t),";")}var r=e(),n=e(),i=r.toString,a=n.toString;return R(function(){r.apply(r,j(arguments))},{def:r.def,entry:r,exit:n,save:t,set:function(e,n,i){t(e,n),r(e,n,"=",i,";")},toString:function(){return i()+a()}})}var r=0,n=[],i=[],a=e(),f={};return{global:a,link:function(e){for(var t=0;t<i.length;++t)if(i[t]===e)return n[t];return t="g"+r++,n.push(t),i.push(e),t},block:e,proc:function(e,r){function n(){var e="a"+i.length;return i.push(e),e}var i=[];r=r||0;for(var a=0;a<r;++a)n();var o=(a=t()).toString;return f[e]=R(a,{arg:n,toString:function(){return C(["function(",i.join(),"){",o(),"}"])}})},scope:t,cond:function(){var e=C(arguments),r=t(),n=t(),i=r.toString,a=n.toString;return R(r,{then:function(){return r.apply(r,j(arguments)),this},else:function(){return n.apply(n,j(arguments)),this},toString:function(){var t=a();return t&&(t="else{"+t+"}"),C(["if(",e,"){",i(),"}",t])}})},compile:function(){var e=['"use strict";',a,"return {"];Object.keys(f).forEach(function(t){e.push('"',t,'":',f[t].toString(),",")}),e.push("}");var t=C(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,n.concat(t)).apply(null,i)}}}(),r=e.link,n=e.global;e.id=le++,e.batchId="0";var i=r(se),a=e.shared={props:"a0"};Object.keys(se).forEach(function(e){a[e]=n.def(i,".",e)});var f=e.next={},o=e.current={};Object.keys(ue).forEach(function(e){Array.isArray(ie[e])&&(f[e]=n.def(a.next,".",e),o[e]=n.def(a.current,".",e))});var u=e.constants={};Object.keys(ce).forEach(function(e){u[e]=n.def(JSON.stringify(ce[e]))}),e.invoke=function(t,n){switch(n.type){case 0:var i=["this",a.context,a.props,e.batchId];return t.def(r(n.data),".call(",i.slice(0,Math.max(n.data.length+1,4)),")");case 1:return t.def(a.props,n.data);case 2:return t.def(a.context,n.data);case 3:return t.def("this",n.data);case 4:return n.data.append(e,t),n.data.ref;case 5:return n.data.toString();case 6:return n.data.map(function(r){return e.invoke(t,r)})}},e.attribCache={};var s={};return e.scopeAttrib=function(e){if((e=t.id(e))in s)return s[e];var n=c.scope[e];return n||(n=c.scope[e]=new Z),s[e]=r(n)},e}function w(e,t){var r=e.static,n=e.dynamic;if("framebuffer"in r){var i=r.framebuffer;return i?(i=u.getFramebuffer(i),I(function(e,t){var r=e.link(i),n=e.shared;return t.set(n.framebuffer,".next",r),n=n.context,t.set(n,".framebufferWidth",r+".width"),t.set(n,".framebufferHeight",r+".height"),r})):I(function(e,t){var r=e.shared;return t.set(r.framebuffer,".next","null"),r=r.context,t.set(r,".framebufferWidth",r+".drawingBufferWidth"),t.set(r,".framebufferHeight",r+".drawingBufferHeight"),"null"})}if("framebuffer"in n){var a=n.framebuffer;return P(a,function(e,t){var r=e.invoke(t,a),n=e.shared,i=n.framebuffer;r=t.def(i,".getFramebuffer(",r,")");return t.set(i,".next",r),n=n.context,t.set(n,".framebufferWidth",r+"?"+r+".width:"+n+".drawingBufferWidth"),t.set(n,".framebufferHeight",r+"?"+r+".height:"+n+".drawingBufferHeight"),r})}return null}function A(e,r,n){function i(e){if(e in a){var r=t.id(a[e]);return(e=I(function(){return r})).id=r,e}if(e in f){var n=f[e];return P(n,function(e,t){var r=e.invoke(t,n);return t.def(e.shared.strings,".id(",r,")")})}return null}var a=e.static,f=e.dynamic,o=i("frag"),u=i("vert"),s=null;return z(o)&&z(u)?(s=l.program(u.id,o.id,null,n),e=I(function(e,t){return e.link(s)})):e=new B(o&&o.thisDep||u&&u.thisDep,o&&o.contextDep||u&&u.contextDep,o&&o.propDep||u&&u.propDep,function(e,t){var r,n,i=e.shared.shader;return r=o?o.append(e,t):t.def(i,".","frag"),n=u?u.append(e,t):t.def(i,".","vert"),t.def(i+".program("+n+","+r+")")}),{frag:o,vert:u,progVar:e,program:s}}function k(e,t){function r(e,t){if(e in n){var r=0|n[e];return t?a.offset=r:a.instances=r,I(function(e,n){return t&&(e.OFFSET=r),r})}if(e in i){var f=i[e];return P(f,function(e,r){var n=e.invoke(r,f);return t&&(e.OFFSET=n),n})}if(t){if(s)return I(function(e,t){return e.OFFSET=0});if(o)return new B(u.thisDep,u.contextDep,u.propDep,function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.offset:0")})}else if(o)return new B(u.thisDep,u.contextDep,u.propDep,function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.instances:-1")});return null}var n=e.static,i=e.dynamic,a={},o=!1,u=function(){if("vao"in n){var e=n.vao;return null!==e&&null===c.getVAO(e)&&(e=c.createVAO(e)),o=!0,a.vao=e,I(function(t){var r=c.getVAO(e);return r?t.link(r):"null"})}if("vao"in i){o=!0;var t=i.vao;return P(t,function(e,r){var n=e.invoke(r,t);return r.def(e.shared.vao+".getVAO("+n+")")})}return null}(),s=!1,l=function(){if("elements"in n){var e=n.elements;if(a.elements=e,V(e)){var t=a.elements=f.create(e,!0);e=f.getElements(t);s=!0}else e&&(e=f.getElements(e),s=!0);return(t=I(function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n}return t.ELEMENTS=null})).value=e,t}if("elements"in i){s=!0;var r=i.elements;return P(r,function(e,t){var n=(i=e.shared).isBufferArgs,i=i.elements,a=e.invoke(t,r),f=t.def("null");n=t.def(n,"(",a,")"),a=e.cond(n).then(f,"=",i,".createStream(",a,");").else(f,"=",i,".getElements(",a,");");return t.entry(a),t.exit(e.cond(n).then(i,".destroyStream(",f,");")),e.ELEMENTS=f})}return o?new B(u.thisDep,u.contextDep,u.propDep,function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.elements+".getElements("+e.shared.vao+".currentVAO.elements):null")}):null}(),p=r("offset",!0),d=function(){if("primitive"in n){var e=n.primitive;return a.primitive=e,I(function(t,r){return re[e]})}if("primitive"in i){var t=i.primitive;return P(t,function(e,r){var n=e.constants.primTypes,i=e.invoke(r,t);return r.def(n,"[",i,"]")})}return s?z(l)?l.value?I(function(e,t){return t.def(e.ELEMENTS,".primType")}):I(function(){return 4}):new B(l.thisDep,l.contextDep,l.propDep,function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",4)}):o?new B(u.thisDep,u.contextDep,u.propDep,function(e,t){return t.def(e.shared.vao+".currentVAO?"+e.shared.vao+".currentVAO.primitive:4")}):null}(),h=function(){if("count"in n){var e=0|n.count;return a.count=e,I(function(){return e})}if("count"in i){var t=i.count;return P(t,function(e,r){return e.invoke(r,t)})}return s?z(l)?l?p?new B(p.thisDep,p.contextDep,p.propDep,function(e,t){return t.def(e.ELEMENTS,".vertCount-",e.OFFSET)}):I(function(e,t){return t.def(e.ELEMENTS,".vertCount")}):I(function(){return-1}):new B(l.thisDep||p.thisDep,l.contextDep||p.contextDep,l.propDep||p.propDep,function(e,t){var r=e.ELEMENTS;return e.OFFSET?t.def(r,"?",r,".vertCount-",e.OFFSET,":-1"):t.def(r,"?",r,".vertCount:-1")}):o?new B(u.thisDep,u.contextDep,u.propDep,function(e,t){return t.def(e.shared.vao,".currentVAO?",e.shared.vao,".currentVAO.count:-1")}):null}(),m=r("instances",!1);return{elements:l,primitive:d,count:h,instances:m,offset:p,vao:u,vaoActive:o,elementsActive:s,static:a}}function _(e,r){var n=e.static,a=e.dynamic,f={};return Object.keys(n).forEach(function(e){var r=n[e],a=t.id(e),o=new Z;if(V(r))o.state=1,o.buffer=i.getBuffer(i.create(r,34962,!1,!0)),o.type=0;else if(s=i.getBuffer(r))o.state=1,o.buffer=s,o.type=0;else if("constant"in r){var u=r.constant;o.buffer="null",o.state=2,"number"==typeof u?o.x=u:we.forEach(function(e,t){t<u.length&&(o[e]=u[t])})}else{var s=V(r.buffer)?i.getBuffer(i.create(r.buffer,34962,!1,!0)):i.getBuffer(r.buffer),c=0|r.offset,l=0|r.stride,p=0|r.size,d=!!r.normalized,h=0;"type"in r&&(h=K[r.type]),r=0|r.divisor,o.buffer=s,o.state=1,o.size=p,o.normalized=d,o.type=h||s.dtype,o.offset=c,o.stride=l,o.divisor=r}f[e]=I(function(e,t){var r=e.attribCache;if(a in r)return r[a];var n={isStream:!1};return Object.keys(o).forEach(function(e){n[e]=o[e]}),o.buffer&&(n.buffer=e.link(o.buffer),n.type=n.type||n.buffer+".dtype"),r[a]=n})}),Object.keys(a).forEach(function(e){var t=a[e];f[e]=P(t,function(e,r){function n(e){r(u[e],"=",i,".",e,"|0;")}var i=e.invoke(r,t),a=e.shared,f=e.constants,o=a.isBufferArgs,u=(a=a.buffer,{isStream:r.def(!1)}),s=new Z;s.state=1,Object.keys(s).forEach(function(e){u[e]=r.def(""+s[e])});var c=u.buffer,l=u.type;return r("if(",o,"(",i,")){",u.isStream,"=true;",c,"=",a,".createStream(",34962,",",i,");",l,"=",c,".dtype;","}else{",c,"=",a,".getBuffer(",i,");","if(",c,"){",l,"=",c,".dtype;",'}else if("constant" in ',i,"){",u.state,"=",2,";","if(typeof "+i+'.constant === "number"){',u[we[0]],"=",i,".constant;",we.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",we.map(function(e,t){return u[e]+"="+i+".constant.length>"+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",o,"(",i,".buffer)){",c,"=",a,".createStream(",34962,",",i,".buffer);","}else{",c,"=",a,".getBuffer(",i,".buffer);","}",l,'="type" in ',i,"?",f.glTypes,"[",i,".type]:",c,".dtype;",u.normalized,"=!!",i,".normalized;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",u.isStream,"){",a,".destroyStream(",c,");","}"),u})}),f}function O(e,t,n,i,f){function o(e){var t=s[e];t&&(p[e]=t)}var u=function(e,t){if("string"==typeof(r=e.static).frag&&"string"==typeof r.vert){if(0<Object.keys(t.dynamic).length)return null;var r=t.static,n=Object.keys(r);if(0<n.length&&"number"==typeof r[n[0]]){for(var i=[],a=0;a<n.length;++a)i.push([0|r[n[a]],n[a]]);return i}}return null}(e,t),s=function(e,t,r){function n(e){if(e in i){var r=i[e];e=!0;var n,f,o=0|r.x,u=0|r.y;return"width"in r?n=0|r.width:e=!1,"height"in r?f=0|r.height:e=!1,new B(!e&&t&&t.thisDep,!e&&t&&t.contextDep,!e&&t&&t.propDep,function(e,t){var i=e.shared.context,a=n;"width"in r||(a=t.def(i,".","framebufferWidth","-",o));var s=f;return"height"in r||(s=t.def(i,".","framebufferHeight","-",u)),[o,u,a,s]})}if(e in a){var s=a[e];return e=P(s,function(e,t){var r=e.invoke(t,s),n=e.shared.context,i=t.def(r,".x|0"),a=t.def(r,".y|0");return[i,a,t.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",i,")"),r=t.def('"height" in ',r,"?",r,".height|0:","(",n,".","framebufferHeight","-",a,")")]}),t&&(e.thisDep=e.thisDep||t.thisDep,e.contextDep=e.contextDep||t.contextDep,e.propDep=e.propDep||t.propDep),e}return t?new B(t.thisDep,t.contextDep,t.propDep,function(e,t){var r=e.shared.context;return[0,0,t.def(r,".","framebufferWidth"),t.def(r,".","framebufferHeight")]}):null}var i=e.static,a=e.dynamic;if(e=n("viewport")){var f=e;e=new B(e.thisDep,e.contextDep,e.propDep,function(e,t){var r=f.append(e,t),n=e.shared.context;return t.set(n,".viewportWidth",r[2]),t.set(n,".viewportHeight",r[3]),r})}return{viewport:e,scissor_box:n("scissor.box")}}(e,h=w(e)),l=k(e),p=function(e,t){var r=e.static,n=e.dynamic,i={};return fe.forEach(function(e){function t(t,a){if(e in r){var o=t(r[e]);i[f]=I(function(){return o})}else if(e in n){var u=n[e];i[f]=P(u,function(e,t){return a(e,t,e.invoke(t,u))})}}var f=g(e);switch(e){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return t(function(e){return e},function(e,t,r){return r});case"depth.func":return t(function(e){return _e[e]},function(e,t,r){return t.def(e.constants.compareFuncs,"[",r,"]")});case"depth.range":return t(function(e){return e},function(e,t,r){return[t.def("+",r,"[0]"),t=t.def("+",r,"[1]")]});case"blend.func":return t(function(e){return[ke["srcRGB"in e?e.srcRGB:e.src],ke["dstRGB"in e?e.dstRGB:e.dst],ke["srcAlpha"in e?e.srcAlpha:e.src],ke["dstAlpha"in e?e.dstAlpha:e.dst]]},function(e,t,r){function n(e,n){return t.def('"',e,n,'" in ',r,"?",r,".",e,n,":",r,".",e)}e=e.constants.blendFuncs;var i=n("src","RGB"),a=n("dst","RGB"),f=(i=t.def(e,"[",i,"]"),t.def(e,"[",n("src","Alpha"),"]"));return[i,a=t.def(e,"[",a,"]"),f,e=t.def(e,"[",n("dst","Alpha"),"]")]});case"blend.equation":return t(function(e){return"string"==typeof e?[$[e],$[e]]:"object"==typeof e?[$[e.rgb],$[e.alpha]]:void 0},function(e,t,r){var n=e.constants.blendEquations,i=t.def(),a=t.def();return(e=e.cond("typeof ",r,'==="string"')).then(i,"=",a,"=",n,"[",r,"];"),e.else(i,"=",n,"[",r,".rgb];",a,"=",n,"[",r,".alpha];"),t(e),[i,a]});case"blend.color":return t(function(e){return a(4,function(t){return+e[t]})},function(e,t,r){return a(4,function(e){return t.def("+",r,"[",e,"]")})});case"stencil.mask":return t(function(e){return 0|e},function(e,t,r){return t.def(r,"|0")});case"stencil.func":return t(function(e){return[_e[e.cmp||"keep"],e.ref||0,"mask"in e?e.mask:-1]},function(e,t,r){return[e=t.def('"cmp" in ',r,"?",e.constants.compareFuncs,"[",r,".cmp]",":",7680),t.def(r,".ref|0"),t=t.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return t(function(t){return["stencil.opBack"===e?1029:1028,Oe[t.fail||"keep"],Oe[t.zfail||"keep"],Oe[t.zpass||"keep"]]},function(t,r,n){function i(e){return r.def('"',e,'" in ',n,"?",a,"[",n,".",e,"]:",7680)}var a=t.constants.stencilOps;return["stencil.opBack"===e?1029:1028,i("fail"),i("zfail"),i("zpass")]});case"polygonOffset.offset":return t(function(e){return[0|e.factor,0|e.units]},function(e,t,r){return[t.def(r,".factor|0"),t=t.def(r,".units|0")]});case"cull.face":return t(function(e){var t=0;return"front"===e?t=1028:"back"===e&&(t=1029),t},function(e,t,r){return t.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return t(function(e){return e},function(e,t,r){return r});case"frontFace":return t(function(e){return Ee[e]},function(e,t,r){return t.def(r+'==="cw"?2304:2305')});case"colorMask":return t(function(e){return e.map(function(e){return!!e})},function(e,t,r){return a(4,function(e){return"!!"+r+"["+e+"]"})});case"sample.coverage":return t(function(e){return["value"in e?e.value:1,!!e.invert]},function(e,t,r){return[t.def('"value" in ',r,"?+",r,".value:1"),t=t.def("!!",r,".invert")]})}}),i}(e),d=A(e,0,u);o("viewport"),o(g("scissor.box"));var h,m=0<Object.keys(p).length;if((h={framebuffer:h,draw:l,shader:d,state:p,dirty:m,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}}).profile=function(e){var t,r=e.static;if(e=e.dynamic,"profile"in r){var n=!!r.profile;(t=I(function(e,t){return n})).enable=n}else if("profile"in e){var i=e.profile;t=P(i,function(e,t){return e.invoke(t,i)})}return t}(e),h.uniforms=function(e,t){var r=e.static,n=e.dynamic,i={};return Object.keys(r).forEach(function(e){var t,n=r[e];if("number"==typeof n||"boolean"==typeof n)t=I(function(){return n});else if("function"==typeof n){var f=n._reglType;"texture2d"===f||"textureCube"===f?t=I(function(e){return e.link(n)}):"framebuffer"!==f&&"framebufferCube"!==f||(t=I(function(e){return e.link(n.color[0])}))}else b(n)&&(t=I(function(e){return e.global.def("[",a(n.length,function(e){return n[e]}),"]")}));t.value=n,i[e]=t}),Object.keys(n).forEach(function(e){var t=n[e];i[e]=P(t,function(e,r){return e.invoke(r,t)})}),i}(n),h.drawVAO=h.scopeVAO=l.vao,!h.drawVAO&&d.program&&!u&&r.angle_instanced_arrays&&l.static.elements){var y=!0;if(e=d.program.attributes.map(function(e){return e=t.static[e],y=y&&!!e,e}),y&&0<e.length){var v=c.getVAO(c.createVAO({attributes:e,elements:l.static.elements}));h.drawVAO=new B(null,null,null,function(e,t){return e.link(v)}),h.useVAO=!0}}return u?h.useVAO=!0:h.attributes=_(t),h.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach(function(e){var r=t[e];n[e]=I(function(e,t){return"number"==typeof r||"boolean"==typeof r?""+r:e.link(r)})}),Object.keys(r).forEach(function(e){var t=r[e];n[e]=P(t,function(e,r){return e.invoke(r,t)})}),n}(i),h}function E(e,t,r){var n=e.shared.context,i=e.scope();Object.keys(r).forEach(function(a){t.save(n,"."+a);var f=r[a].append(e,t);Array.isArray(f)?i(n,".",a,"=[",f.join(),"];"):i(n,".",a,"=",f,";")}),t(i)}function D(e,t,r,n){var i,a=(o=e.shared).gl,f=o.framebuffer;te&&(i=t.def(o.extensions,".webgl_draw_buffers"));var o=(u=e.constants).drawBuffer,u=u.backBuffer;e=r?r.append(e,t):t.def(f,".next"),n||t("if(",e,"!==",f,".cur){"),t("if(",e,"){",a,".bindFramebuffer(",36160,",",e,".framebuffer);"),te&&t(i,".drawBuffersWEBGL(",o,"[",e,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",36160,",null);"),te&&t(i,".drawBuffersWEBGL(",u,");"),t("}",f,".cur=",e,";"),n||t("}")}function T(e,t,r){var n=e.shared,i=n.gl,f=e.current,o=e.next,u=n.current,s=n.next,c=e.cond(u,".dirty");fe.forEach(function(t){var n,l;if(!((t=g(t))in r.state))if(t in o){n=o[t],l=f[t];var p=a(ie[t].length,function(e){return c.def(n,"[",e,"]")});c(e.cond(p.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(i,".",ue[t],"(",p,");",p.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else n=c.def(s,".",t),p=e.cond(n,"!==",u,".",t),c(p),t in oe?p(e.cond(n).then(i,".enable(",oe[t],");").else(i,".disable(",oe[t],");"),u,".",t,"=",n,";"):p(i,".",ue[t],"(",n,");",u,".",t,"=",n,";")}),0===Object.keys(r.state).length&&c(u,".dirty=false;"),t(c)}function S(e,t,r,n){var i=e.shared,a=e.current,f=i.current,o=i.gl;F(Object.keys(r)).forEach(function(i){var u=r[i];if(!n||n(u)){var s=u.append(e,t);if(oe[i]){var c=oe[i];z(u)?t(o,s?".enable(":".disable(",c,");"):t(e.cond(s).then(o,".enable(",c,");").else(o,".disable(",c,");")),t(f,".",i,"=",s,";")}else if(b(s)){var l=a[i];t(o,".",ue[i],"(",s,");",s.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(o,".",ue[i],"(",s,");",f,".",i,"=",s,";")}})}function L(e,t){ee&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function M(e,t,r,n,i){function a(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function f(e){e(s=t.def(),"=",a(),";"),"string"==typeof i?e(p,".count+=",i,";"):e(p,".count++;"),h&&(n?e(c=t.def(),"=",m,".getNumPendingQueries();"):e(m,".beginQuery(",p,");"))}function o(e){e(p,".cpuTime+=",a(),"-",s,";"),h&&(n?e(m,".pushScopeStats(",c,",",m,".getNumPendingQueries(),",p,");"):e(m,".endQuery();"))}function u(e){var r=t.def(d,".profile");t(d,".profile=",e,";"),t.exit(d,".profile=",r,";")}var s,c,l=e.shared,p=e.stats,d=l.current,m=l.timer;if(r=r.profile){if(z(r))return void(r.enable?(f(t),o(t.exit),u("true")):u("false"));u(r=r.append(e,t))}else r=t.def(d,".profile");f(l=e.block()),t("if(",r,"){",l,"}"),o(e=e.block()),t.exit("if(",r,"){",e,"}")}function H(e,t,r,n,i){function a(r,n,i){function a(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var r,a=i.type;r=i.size?t.def(i.size,"||",n):n,t("if(",c,".type!==",a,"||",c,".size!==",r,"||",d.map(function(e){return c+"."+e+"!=="+i[e]}).join("||"),"){",u,".bindBuffer(",34962,",",l,".buffer);",u,".vertexAttribPointer(",[s,r,a,i.normalized,i.stride,i.offset],");",c,".type=",a,";",c,".size=",r,";",d.map(function(e){return c+"."+e+"="+i[e]+";"}).join(""),"}"),ee&&(a=i.divisor,t("if(",c,".divisor!==",a,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,a],");",c,".divisor=",a,";}"))}function o(){t("if(",c,".buffer){",u,".disableVertexAttribArray(",s,");",c,".buffer=null;","}if(",we.map(function(e,t){return c+"."+e+"!=="+p[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",p,");",we.map(function(e,t){return c+"."+e+"="+p[t]+";"}).join(""),"}")}var u=f.gl,s=t.def(r,".location"),c=t.def(f.attributes,"[",s,"]");r=i.state;var l=i.buffer,p=[i.x,i.y,i.z,i.w],d=["buffer","normalized","offset","stride"];1===r?a():2===r?o():(t("if(",r,"===",1,"){"),a(),t("}else{"),o(),t("}"))}var f=e.shared;n.forEach(function(n){var f,o=n.name,u=r.attributes[o];if(u){if(!i(u))return;f=u.append(e,t)}else{if(!i(De))return;var s=e.scopeAttrib(o);f={},Object.keys(new Z).forEach(function(e){f[e]=t.def(s,".",e)})}a(e.link(n),function(e){switch(e){case 35664:case 35667:case 35671:return 2;case 35665:case 35668:case 35672:return 3;case 35666:case 35669:case 35673:return 4;default:return 1}}(n.info.type),f)})}function U(e,r,n,i,f,o){for(var u,s=e.shared,c=s.gl,l={},p=0;p<i.length;++p){var d=(x=i[p]).name,h=x.info.type,m=x.info.size,g=n.uniforms[d];if(1<m){if(!g)continue;var y=d.replace("[0]","");if(l[y])continue;l[y]=1}var v,x=e.link(x)+".location";if(g){if(!f(g))continue;if(z(g)){if(d=g.value,35678===h||35680===h)r(c,".uniform1i(",x,",",(h=e.link(d._texture||d.color[0]._texture))+".bind());"),r.exit(h,".unbind();");else if(35674===h||35675===h||35676===h)m=e.global.def("new Float32Array(["+Array.prototype.slice.call(d)+"])"),d=2,35675===h?d=3:35676===h&&(d=4),r(c,".uniformMatrix",d,"fv(",x,",false,",m,");");else{switch(h){case 5126:u="1f";break;case 35664:u="2f";break;case 35665:u="3f";break;case 35666:u="4f";break;case 35670:case 5124:u="1i";break;case 35671:case 35667:u="2i";break;case 35672:case 35668:u="3i";break;case 35673:u="4i";break;case 35669:u="4i"}1<m?(u+="v",d=e.global.def("["+Array.prototype.slice.call(d)+"]")):d=b(d)?Array.prototype.slice.call(d):d,r(c,".uniform",u,"(",x,",",d,");")}continue}v=g.append(e,r)}else{if(!f(De))continue;v=r.def(s.uniforms,"[",t.id(d),"]")}switch(35678===h?r("if(",v,"&&",v,'._reglType==="framebuffer"){',v,"=",v,".color[0];","}"):35680===h&&r("if(",v,"&&",v,'._reglType==="framebufferCube"){',v,"=",v,".color[0];","}"),d=1,h){case 35678:case 35680:h=r.def(v,"._texture"),r(c,".uniform1i(",x,",",h,".bind());"),r.exit(h,".unbind();");continue;case 5124:case 35670:u="1i";break;case 35667:case 35671:u="2i",d=2;break;case 35668:case 35672:u="3i",d=3;break;case 35669:case 35673:u="4i",d=4;break;case 5126:u="1f";break;case 35664:u="2f",d=2;break;case 35665:u="3f",d=3;break;case 35666:u="4f",d=4;break;case 35674:u="Matrix2fv";break;case 35675:u="Matrix3fv";break;case 35676:u="Matrix4fv"}if(-1===u.indexOf("Matrix")&&1<m&&(u+="v",d=1),"M"===u.charAt(0)){r(c,".uniform",u,"(",x,",");x=Math.pow(h-35674+2,2);var w=e.global.def("new Float32Array(",x,")");Array.isArray(v)?r("false,(",a(x,function(e){return w+"["+e+"]="+v[e]}),",",w,")"):r("false,(Array.isArray(",v,")||",v," instanceof Float32Array)?",v,":(",a(x,function(e){return w+"["+e+"]="+v+"["+e+"]"}),",",w,")"),r(");")}else{if(1<d){h=[];var A=[];for(m=0;m<d;++m)Array.isArray(v)?A.push(v[m]):A.push(r.def(v+"["+m+"]")),o&&h.push(r.def());o&&r("if(!",e.batchId,"||",h.map(function(e,t){return e+"!=="+A[t]}).join("||"),"){",h.map(function(e,t){return e+"="+A[t]+";"}).join("")),r(c,".uniform",u,"(",x,",",A.join(","),");")}else o&&(h=r.def(),r("if(!",e.batchId,"||",h,"!==",v,"){",h,"=",v,";")),r(c,".uniform",u,"(",x,",",v,");");o&&r("}")}}}function N(e,t,r,n){function i(i){var a=p[i];return a?a.contextDep&&n.contextDynamic||a.propDep?a.append(e,r):a.append(e,t):t.def(l,".",i)}function a(){function e(){r(u,".drawElementsInstancedANGLE(",[h,b,g,m+"<<(("+g+"-5121)>>1)",o],");")}function t(){r(u,".drawArraysInstancedANGLE(",[h,m,b,o],");")}d&&"null"!==d?y?e():(r("if(",d,"){"),e(),r("}else{"),t(),r("}")):t()}function f(){function e(){r(c+".drawElements("+[h,b,g,m+"<<(("+g+"-5121)>>1)"]+");")}function t(){r(c+".drawArrays("+[h,m,b]+");")}d&&"null"!==d?y?e():(r("if(",d,"){"),e(),r("}else{"),t(),r("}")):t()}var o,u,s=e.shared,c=s.gl,l=s.draw,p=n.draw,d=function(){var i=p.elements,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a),p.elementsActive&&a("if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);")):(i=a.def(),a(i,"=",l,".","elements",";","if(",i,"){",c,".bindBuffer(",34963,",",i,".buffer.buffer);}","else if(",s.vao,".currentVAO){",i,"=",e.shared.elements+".getElements("+s.vao,".currentVAO.elements);",ne?"":"if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);","}")),i}(),h=i("primitive"),m=i("offset"),b=function(){var i=p.count,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a)):i=a.def(l,".","count"),i}();if("number"==typeof b){if(0===b)return}else r("if(",b,"){"),r.exit("}");ee&&(o=i("instances"),u=e.instancing);var g=d+".type",y=p.elements&&z(p.elements)&&!p.vaoActive;ee&&("number"!=typeof o||0<=o)?"string"==typeof o?(r("if(",o,">0){"),a(),r("}else if(",o,"<0){"),f(),r("}")):a():f()}function q(e,t,r,n,i){return i=(t=x()).proc("body",i),ee&&(t.instancing=i.def(t.shared.extensions,".angle_instanced_arrays")),e(t,i,r,n),t.compile().body}function Q(e,t,r,n){L(e,t),r.useVAO?r.drawVAO?t(e.shared.vao,".setVAO(",r.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),H(e,t,r,n.attributes,function(){return!0})),U(e,t,r,n.uniforms,function(){return!0},!1),N(e,t,t,r)}function G(e,t,r,n){function i(){return!0}e.batchId="a1",L(e,t),H(e,t,r,n.attributes,i),U(e,t,r,n.uniforms,i,!1),N(e,t,t,r)}function Y(e,t,r,n){function i(e){return e.contextDep&&f||e.propDep}function a(e){return!i(e)}L(e,t);var f=r.contextDep,o=t.def(),u=t.def();e.shared.props=u,e.batchId=o;var s=e.scope(),c=e.scope();t(s.entry,"for(",o,"=0;",o,"<","a1",";++",o,"){",u,"=","a0","[",o,"];",c,"}",s.exit),r.needsContext&&E(e,c,r.context),r.needsFramebuffer&&D(e,c,r.framebuffer),S(e,c,r.state,i),r.profile&&i(r.profile)&&M(e,c,r,!1,!0),n?(r.useVAO?r.drawVAO?i(r.drawVAO)?c(e.shared.vao,".setVAO(",r.drawVAO.append(e,c),");"):s(e.shared.vao,".setVAO(",r.drawVAO.append(e,s),");"):s(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(s(e.shared.vao,".setVAO(null);"),H(e,s,r,n.attributes,a),H(e,c,r,n.attributes,i)),U(e,s,r,n.uniforms,a,!1),U(e,c,r,n.uniforms,i,!0),N(e,s,c,r)):(t=e.global.def("{}"),n=r.shader.progVar.append(e,c),u=c.def(n,".id"),s=c.def(t,"[",u,"]"),c(e.shared.gl,".useProgram(",n,".program);","if(!",s,"){",s,"=",t,"[",u,"]=",e.link(function(t){return q(G,e,r,t,2)}),"(",n,");}",s,".call(this,a0[",o,"],",o,");"))}function X(e,r){function n(t){var n=r.shader[t];n&&i.set(a.shader,"."+t,n.append(e,i))}var i=e.proc("scope",3);e.batchId="a2";var a=e.shared,f=a.current;E(e,i,r.context),r.framebuffer&&r.framebuffer.append(e,i),F(Object.keys(r.state)).forEach(function(t){var n=r.state[t].append(e,i);b(n)?n.forEach(function(r,n){i.set(e.next[t],"["+n+"]",r)}):i.set(a.next,"."+t,n)}),M(e,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(t){var n=r.draw[t];n&&i.set(a.draw,"."+t,""+n.append(e,i))}),Object.keys(r.uniforms).forEach(function(n){var f=r.uniforms[n].append(e,i);Array.isArray(f)&&(f="["+f.join()+"]"),i.set(a.uniforms,"["+t.id(n)+"]",f)}),Object.keys(r.attributes).forEach(function(t){var n=r.attributes[t].append(e,i),a=e.scopeAttrib(t);Object.keys(new Z).forEach(function(e){i.set(a,"."+e,n[e])})}),r.scopeVAO&&i.set(a.vao,".targetVAO",r.scopeVAO.append(e,i)),n("vert"),n("frag"),0<Object.keys(r.state).length&&(i(f,".dirty=true;"),i.exit(f,".dirty=true;")),i("a1(",e.shared.context,",a0,",e.batchId,");")}function J(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!b(e)){for(var t=Object.keys(e),r=0;r<t.length;++r)if(W.isDynamic(e[t[r]]))return!0;return!1}}(n)){var i=e.global,a=Object.keys(n),f=!1,o=!1,u=!1,s=e.global.def("{}");a.forEach(function(t){var r=n[t];if(W.isDynamic(r))"function"==typeof r&&(r=n[t]=W.unbox(r)),t=P(r,null),f=f||t.thisDep,u=u||t.propDep,o=o||t.contextDep;else{switch(i(s,".",t,"="),typeof r){case"number":i(r);break;case"string":i('"',r,'"');break;case"object":Array.isArray(r)&&i("[",r.join(),"]");break;default:i(e.link(r))}i(";")}}),t.dynamic[r]=new W.DynamicVariable(4,{thisDep:f,contextDep:o,propDep:u,ref:s,append:function(e,t){a.forEach(function(r){var i=n[r];W.isDynamic(i)&&(i=e.invoke(t,i),t(s,".",r,"=",i,";"))})}}),delete t.static[r]}}var Z=c.Record,$={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&($.min=32775,$.max=32776);var ee=r.angle_instanced_arrays,te=r.webgl_draw_buffers,ne=r.oes_vertex_array_object,ie={dirty:!0,profile:m.profile},ae={},fe=[],oe={},ue={};y("dither",3024),y("blend.enable",3042),v("blend.color","blendColor",[0,0,0,0]),v("blend.equation","blendEquationSeparate",[32774,32774]),v("blend.func","blendFuncSeparate",[1,0,1,0]),y("depth.enable",2929,!0),v("depth.func","depthFunc",513),v("depth.range","depthRange",[0,1]),v("depth.mask","depthMask",!0),v("colorMask","colorMask",[!0,!0,!0,!0]),y("cull.enable",2884),v("cull.face","cullFace",1029),v("frontFace","frontFace",2305),v("lineWidth","lineWidth",1),y("polygonOffset.enable",32823),v("polygonOffset.offset","polygonOffset",[0,0]),y("sample.alpha",32926),y("sample.enable",32928),v("sample.coverage","sampleCoverage",[1,!1]),y("stencil.enable",2960),v("stencil.mask","stencilMask",-1),v("stencil.func","stencilFunc",[519,0,-1]),v("stencil.opFront","stencilOpSeparate",[1028,7680,7680,7680]),v("stencil.opBack","stencilOpSeparate",[1029,7680,7680,7680]),y("scissor.enable",3089),v("scissor.box","scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),v("viewport","viewport",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var se={gl:e,context:d,strings:t,next:ae,current:ie,draw:p,elements:f,buffer:i,shader:l,attributes:c.state,vao:c,uniforms:s,framebuffer:u,extensions:r,timer:h,isBufferArgs:V},ce={primTypes:re,compareFuncs:_e,blendFuncs:ke,blendEquations:$,stencilOps:Oe,glTypes:K,orientationType:Ee};te&&(ce.backBuffer=[1029],ce.drawBuffer=a(n.maxDrawbuffers,function(e){return 0===e?[0]:a(e,function(e){return 36064+e})}));var le=0;return{next:ae,current:ie,procs:function(){var e=x(),t=e.proc("poll"),i=e.proc("refresh"),f=e.block();t(f),i(f);var o,u=e.shared,s=u.gl,c=u.next,l=u.current;f(l,".dirty=false;"),D(e,t),D(e,i,null,!0),ee&&(o=e.link(ee)),r.oes_vertex_array_object&&i(e.link(r.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var p=0;p<n.maxAttributes;++p){var d=i.def(u.attributes,"[",p,"]"),h=e.cond(d,".buffer");h.then(s,".enableVertexAttribArray(",p,");",s,".bindBuffer(",34962,",",d,".buffer.buffer);",s,".vertexAttribPointer(",p,",",d,".size,",d,".type,",d,".normalized,",d,".stride,",d,".offset);").else(s,".disableVertexAttribArray(",p,");",s,".vertexAttrib4f(",p,",",d,".x,",d,".y,",d,".z,",d,".w);",d,".buffer=null;"),i(h),ee&&i(o,".vertexAttribDivisorANGLE(",p,",",d,".divisor);")}return i(e.shared.vao,".currentVAO=null;",e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"),Object.keys(oe).forEach(function(r){var n=oe[r],a=f.def(c,".",r),o=e.block();o("if(",a,"){",s,".enable(",n,")}else{",s,".disable(",n,")}",l,".",r,"=",a,";"),i(o),t("if(",a,"!==",l,".",r,"){",o,"}")}),Object.keys(ue).forEach(function(r){var n,o,u=ue[r],p=ie[r],d=e.block();d(s,".",u,"("),b(p)?(u=p.length,n=e.global.def(c,".",r),o=e.global.def(l,".",r),d(a(u,function(e){return n+"["+e+"]"}),");",a(u,function(e){return o+"["+e+"]="+n+"["+e+"];"}).join("")),t("if(",a(u,function(e){return n+"["+e+"]!=="+o+"["+e+"]"}).join("||"),"){",d,"}")):(n=f.def(c,".",r),o=f.def(l,".",r),d(n,");",l,".",r,"=",n,";"),t("if(",n,"!==",o,"){",d,"}")),i(d)}),e.compile()}(),compile:function(e,t,r,n,i){var a=x();a.stats=a.link(i),Object.keys(t.static).forEach(function(e){J(a,t,e)}),Ae.forEach(function(t){J(a,e,t)});var f=O(e,t,r,n);return function(e,t){var r=e.proc("draw",1);L(e,r),E(e,r,t.context),D(e,r,t.framebuffer),T(e,r,t),S(e,r,t.state),M(e,r,t,!1,!0);var n=t.shader.progVar.append(e,r);if(r(e.shared.gl,".useProgram(",n,".program);"),t.shader.program)Q(e,r,t,t.shader.program);else{r(e.shared.vao,".setVAO(null);");var i=e.global.def("{}"),a=r.def(n,".id"),f=r.def(i,"[",a,"]");r(e.cond(f).then(f,".call(this,a0);").else(f,"=",i,"[",a,"]=",e.link(function(r){return q(Q,e,t,r,1)}),"(",n,");",f,".call(this,a0);"))}0<Object.keys(t.state).length&&r(e.shared.current,".dirty=true;"),e.shared.vao&&r(e.shared.vao,".setVAO(null);")}(a,f),X(a,f),function(e,t){function r(e){return e.contextDep&&i||e.propDep}var n=e.proc("batch",2);e.batchId="0",L(e,n);var i=!1,a=!0;Object.keys(t.context).forEach(function(e){i=i||t.context[e].propDep}),i||(E(e,n,t.context),a=!1);var f=!1;if((o=t.framebuffer)?(o.propDep?i=f=!0:o.contextDep&&i&&(f=!0),f||D(e,n,o)):D(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),T(e,n,t),S(e,n,t.state,function(e){return!r(e)}),t.profile&&r(t.profile)||M(e,n,t,!1,"a1"),t.contextDep=i,t.needsContext=a,t.needsFramebuffer=f,(a=t.shader.progVar).contextDep&&i||a.propDep)Y(e,n,t,null);else if(a=a.append(e,n),n(e.shared.gl,".useProgram(",a,".program);"),t.shader.program)Y(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var o=e.global.def("{}"),u=(f=n.def(a,".id"),n.def(o,"[",f,"]"));n(e.cond(u).then(u,".call(this,a0,a1);").else(u,"=",o,"[",f,"]=",e.link(function(r){return q(Y,e,t,r,2)}),"(",a,");",u,".call(this,a0,a1);"))}0<Object.keys(t.state).length&&n(e.shared.current,".dirty=true;"),e.shared.vao&&n(e.shared.vao,".setVAO(null);")}(a,f),R(a.compile(),{destroy:function(){f.shader.program.destroy()}})}}}function M(e,t){for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1}var R=function(e,t){for(var r=Object.keys(t),n=0;n<r.length;++n)e[r[n]]=t[r[n]];return e},H=0,W={DynamicVariable:e,define:function(r,n){return new e(r,t(n+""))},isDynamic:function(t){return"function"==typeof t&&!t._reglType||t instanceof e},unbox:function t(r,n){return"function"==typeof r?new e(0,r):"number"==typeof r||"boolean"==typeof r?new e(5,r):Array.isArray(r)?new e(6,r.map(function(e,r){return t(e,n+"["+r+"]")})):r instanceof e?r:void 0},accessor:t},U={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},N="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},q=o();q.zero=o();var Q=function(e,t){var r=1;t.ext_texture_filter_anisotropic&&(r=e.getParameter(34047));var n=1,i=1;t.webgl_draw_buffers&&(n=e.getParameter(34852),i=e.getParameter(36063));var a=!!t.oes_texture_float;if(a){a=e.createTexture(),e.bindTexture(3553,a),e.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var f=e.createFramebuffer();if(e.bindFramebuffer(36160,f),e.framebufferTexture2D(36160,36064,3553,a,0),e.bindTexture(3553,null),36053!==e.checkFramebufferStatus(36160))a=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var o=q.allocType(5126,4);e.readPixels(0,0,1,1,6408,5126,o),e.getError()?a=!1:(e.deleteFramebuffer(f),e.deleteTexture(a),a=1===o[0]),q.freeType(o)}}return o=!0,"undefined"!=typeof navigator&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))||(o=e.createTexture(),f=q.allocType(5121,36),e.activeTexture(33984),e.bindTexture(34067,o),e.texImage2D(34069,0,6408,3,3,0,6408,5121,f),q.freeType(f),e.bindTexture(34067,null),e.deleteTexture(o),o=!e.getError()),{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter(function(e){return!!t[e]}),maxAnisotropic:r,maxDrawbuffers:n,maxColorAttachments:i,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938),readFloat:a,npotTextureCube:o}},G=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},Y=function(e){return Object.keys(e).map(function(t){return e[t]})},X={shape:function(e){for(var t=[];e.length;e=e[0])t.push(e.length);return t},flatten:function(e,t,r,n){var i=1;if(t.length)for(var a=0;a<t.length;++a)i*=t[a];else i=0;switch(r=n||q.allocType(r,i),t.length){case 0:break;case 1:for(n=t[0],t=0;t<n;++t)r[t]=e[t];break;case 2:for(n=t[0],t=t[1],a=i=0;a<n;++a)for(var f=e[a],o=0;o<t;++o)r[i++]=f[o];break;case 3:s(e,t[0],t[1],t[2],r,0);break;default:!function e(t,r,n,i,a){for(var f=1,o=n+1;o<r.length;++o)f*=r[o];var u=r[n];if(4==r.length-n){var c=r[n+1],l=r[n+2];for(r=r[n+3],o=0;o<u;++o)s(t[o],c,l,r,i,a),a+=f}else for(o=0;o<u;++o)e(t[o],r,n+1,i,a),a+=f}(e,t,0,r,0)}return r}},J={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},K={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},Z={dynamic:35048,stream:35040,static:35044},$=X.flatten,ee=X.shape,te=[];te[5120]=1,te[5122]=2,te[5124]=4,te[5121]=1,te[5123]=2,te[5125]=4,te[5126]=4;var re={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},ne=new Float32Array(1),ie=new Uint32Array(ne.buffer),ae=[9984,9986,9985,9987],fe=[0,6409,6410,6407,6408],oe={};oe[6409]=oe[6406]=oe[6402]=1,oe[34041]=oe[6410]=2,oe[6407]=oe[35904]=3,oe[6408]=oe[35906]=4;var ue=g("HTMLCanvasElement"),se=g("OffscreenCanvas"),ce=g("CanvasRenderingContext2D"),le=g("ImageBitmap"),pe=g("HTMLImageElement"),de=g("HTMLVideoElement"),he=Object.keys(J).concat([ue,se,ce,le,pe,de]),me=[];me[5121]=1,me[5126]=4,me[36193]=2,me[5123]=2,me[5125]=4;var be=[];be[32854]=2,be[32855]=2,be[36194]=2,be[34041]=4,be[33776]=.5,be[33777]=.5,be[33778]=1,be[33779]=1,be[35986]=.5,be[35987]=1,be[34798]=1,be[35840]=.5,be[35841]=.25,be[35842]=.5,be[35843]=.25,be[36196]=.5;var ge=[];ge[32854]=2,ge[32855]=2,ge[36194]=2,ge[33189]=2,ge[36168]=1,ge[34041]=4,ge[35907]=4,ge[34836]=16,ge[34842]=8,ge[34843]=6;var ye=function(e,t,r,n,i){function a(e){this.id=s++,this.refCount=1,this.renderbuffer=e,this.format=32854,this.height=this.width=0,i.profile&&(this.stats={size:0})}function f(t){var r=t.renderbuffer;e.bindRenderbuffer(36161,null),e.deleteRenderbuffer(r),t.renderbuffer=null,t.refCount=0,delete c[t.id],n.renderbufferCount--}var o={rgba4:32854,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};t.ext_srgb&&(o.srgba=35907),t.ext_color_buffer_half_float&&(o.rgba16f=34842,o.rgb16f=34843),t.webgl_color_buffer_float&&(o.rgba32f=34836);var u=[];Object.keys(o).forEach(function(e){u[o[e]]=e});var s=0,c={};return a.prototype.decRef=function(){0>=--this.refCount&&f(this)},i.profile&&(n.getTotalRenderbufferSize=function(){var e=0;return Object.keys(c).forEach(function(t){e+=c[t].stats.size}),e}),{create:function(t,r){function f(t,r){var n=0,a=0,c=32854;if("object"==typeof t&&t?("shape"in t?(n=0|(a=t.shape)[0],a=0|a[1]):("radius"in t&&(n=a=0|t.radius),"width"in t&&(n=0|t.width),"height"in t&&(a=0|t.height)),"format"in t&&(c=o[t.format])):"number"==typeof t?(n=0|t,a="number"==typeof r?0|r:n):t||(n=a=1),n!==s.width||a!==s.height||c!==s.format)return f.width=s.width=n,f.height=s.height=a,s.format=c,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,c,n,a),i.profile&&(s.stats.size=ge[s.format]*s.width*s.height),f.format=u[s.format],f}var s=new a(e.createRenderbuffer());return c[s.id]=s,n.renderbufferCount++,f(t,r),f.resize=function(t,r){var n=0|t,a=0|r||n;return n===s.width&&a===s.height?f:(f.width=s.width=n,f.height=s.height=a,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,s.format,n,a),i.profile&&(s.stats.size=ge[s.format]*s.width*s.height),f)},f._reglType="renderbuffer",f._renderbuffer=s,i.profile&&(f.stats=s.stats),f.destroy=function(){s.decRef()},f},clear:function(){Y(c).forEach(f)},restore:function(){Y(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,t.renderbuffer),e.renderbufferStorage(36161,t.format,t.width,t.height)}),e.bindRenderbuffer(36161,null)}}},ve=[];ve[6408]=4,ve[6407]=3;var xe=[];xe[5121]=1,xe[5126]=4,xe[36193]=2;var we=["x","y","z","w"],Ae="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),ke={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},_e={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Oe={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Ee={cw:2304,ccw:2305},De=new B(!1,!1,!1,function(){});return function(e){function t(){if(0===J.length)A&&A.update(),ee=null;else{ee=U.next(t),l();for(var e=J.length-1;0<=e;--e){var r=J[e];r&&r(C,null,0)}b.flush(),A&&A.update()}}function r(){!ee&&0<J.length&&(ee=U.next(t))}function n(){ee&&(U.cancel(t),ee=null)}function a(e){e.preventDefault(),n(),K.forEach(function(e){e()})}function f(e){b.getError(),y.restore(),I.restore(),F.restore(),P.restore(),H.restore(),q.restore(),z.restore(),A&&A.restore(),G.procs.refresh(),r(),Z.forEach(function(e){e()})}function o(e){function t(e,t){var r={},n={};return Object.keys(e).forEach(function(i){var a=e[i];if(W.isDynamic(a))n[i]=W.unbox(a,i);else{if(t&&Array.isArray(a))for(var f=0;f<a.length;++f)if(W.isDynamic(a[f]))return void(n[i]=W.unbox(a,i));r[i]=a}}),{dynamic:n,static:r}}var r=t(e.context||{},!0),n=t(e.uniforms||{},!0),i=t(e.attributes||{},!1);e=t(function(e){function t(e){if(e in r){var t=r[e];delete r[e],Object.keys(t).forEach(function(n){r[e+"."+n]=t[n]})}}var r=R({},e);return delete r.uniforms,delete r.attributes,delete r.context,delete r.vao,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),"vao"in e&&(r.vao=e.vao),r}(e),!1);var a={gpuTime:0,cpuTime:0,count:0},f=G.compile(e,i,n,r,a),o=f.draw,u=f.batch,s=f.scope,c=[];return R(function(e,t){var r;if("function"==typeof e)return s.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(r=0;r<e;++r)s.call(this,null,t,r);else{if(!Array.isArray(e))return s.call(this,e,t,0);for(r=0;r<e.length;++r)s.call(this,e[r],t,r)}else if("number"==typeof e){if(0<e)return u.call(this,function(e){for(;c.length<e;)c.push(null);return c}(0|e),0|e)}else{if(!Array.isArray(e))return o.call(this,e);if(e.length)return u.call(this,e,e.length)}},{stats:a,destroy:function(){f.destroy()}})}function u(e,t){var r=0;G.procs.poll();var n=t.color;n&&(b.clearColor(+n[0]||0,+n[1]||0,+n[2]||0,+n[3]||0),r|=16384),"depth"in t&&(b.clearDepth(+t.depth),r|=256),"stencil"in t&&(b.clearStencil(0|t.stencil),r|=1024),b.clear(r)}function s(e){return J.push(e),r(),{cancel:function(){var t=M(J,e);J[t]=function e(){var t=M(J,e);J[t]=J[J.length-1],--J.length,0>=J.length&&n()}}}}function c(){var e=Y.viewport,t=Y.scissor_box;e[0]=e[1]=t[0]=t[1]=0,C.viewportWidth=C.framebufferWidth=C.drawingBufferWidth=e[2]=t[2]=b.drawingBufferWidth,C.viewportHeight=C.framebufferHeight=C.drawingBufferHeight=e[3]=t[3]=b.drawingBufferHeight}function l(){C.tick+=1,C.time=m(),c(),G.procs.poll()}function p(){P.refresh(),c(),G.procs.refresh(),A&&A.update()}function m(){return(N()-k)/1e3}if(!(e=i(e)))return null;var b=e.gl,g=b.getContextAttributes();b.isContextLost();var y=function(e,t){function r(t){var r;t=t.toLowerCase();try{r=n[t]=e.getExtension(t)}catch(e){}return!!r}for(var n={},i=0;i<t.extensions.length;++i){var a=t.extensions[i];if(!r(a))return t.onDestroy(),t.onDone('"'+a+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(r),{extensions:n,restore:function(){Object.keys(n).forEach(function(e){if(n[e]&&!r(e))throw Error("(regl): error restoring extension "+e)})}}}(b,e);if(!y)return null;var v=function(){var e={"":0},t=[""];return{id:function(r){var n=e[r];return n||(n=e[r]=t.length,t.push(r),n)},str:function(e){return t[e]}}}(),x={vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},w=y.extensions,A=function(e,t){function r(){this.endQueryIndex=this.startQueryIndex=-1,this.sum=0,this.stats=null}function n(e,t,n){var i=f.pop()||new r;i.startQueryIndex=e,i.endQueryIndex=t,i.sum=0,i.stats=n,o.push(i)}if(!t.ext_disjoint_timer_query)return null;var i=[],a=[],f=[],o=[],u=[],s=[];return{beginQuery:function(e){var r=i.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(35007,r),a.push(r),n(a.length-1,a.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:n,update:function(){var e,r;if(0!==(e=a.length)){s.length=Math.max(s.length,e+1),u.length=Math.max(u.length,e+1),u[0]=0;var n=s[0]=0;for(r=e=0;r<a.length;++r){var c=a[r];t.ext_disjoint_timer_query.getQueryObjectEXT(c,34919)?(n+=t.ext_disjoint_timer_query.getQueryObjectEXT(c,34918),i.push(c)):a[e++]=c,u[r+1]=n,s[r+1]=e}for(a.length=e,r=e=0;r<o.length;++r){var l=(n=o[r]).startQueryIndex;c=n.endQueryIndex,n.sum+=u[c]-u[l],l=s[l],(c=s[c])===l?(n.stats.gpuTime+=n.sum/1e6,f.push(n)):(n.startQueryIndex=l,n.endQueryIndex=c,o[e++]=n)}o.length=e}},getNumPendingQueries:function(){return a.length},clear:function(){i.push.apply(i,a);for(var e=0;e<i.length;e++)t.ext_disjoint_timer_query.deleteQueryEXT(i[e]);a.length=0,i.length=0},restore:function(){a.length=0,i.length=0}}}(0,w),k=N(),E=b.drawingBufferWidth,j=b.drawingBufferHeight,C={tick:0,time:0,viewportWidth:E,viewportHeight:j,framebufferWidth:E,framebufferHeight:j,drawingBufferWidth:E,drawingBufferHeight:j,pixelRatio:e.pixelRatio},V=(E={elements:null,primitive:4,count:-1,offset:0,instances:-1},Q(b,w)),F=d(b,x,e,function(e){return z.destroyBuffer(e)}),B=h(b,w,F,x),z=D(b,w,V,x,F,B,E),I=T(b,v,x,e),P=_(b,w,V,function(){G.procs.poll()},C,x,e),H=ye(b,w,0,x,e),q=O(b,w,V,P,H,x),G=L(b,v,w,V,F,B,0,q,{},z,I,E,C,A,e),Y=(v=S(b,q,G.procs.poll,C),G.next),X=b.canvas,J=[],K=[],Z=[],$=[e.onDestroy],ee=null;X&&(X.addEventListener("webglcontextlost",a,!1),X.addEventListener("webglcontextrestored",f,!1));var te=q.setFBO=o({framebuffer:W.define.call(null,1,"framebuffer")});return p(),g=R(o,{clear:function(e){if("framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var t=0;6>t;++t)te(R({framebuffer:e.framebuffer.faces[t]},e),u);else te(e,u);else u(0,e)},prop:W.define.bind(null,1),context:W.define.bind(null,2),this:W.define.bind(null,3),draw:o({}),buffer:function(e){return F.create(e,34962,!1,!1)},elements:function(e){return B.create(e,!1)},texture:P.create2D,cube:P.createCube,renderbuffer:H.create,framebuffer:q.create,framebufferCube:q.createCube,vao:z.createVAO,attributes:g,frame:s,on:function(e,t){var r;switch(e){case"frame":return s(t);case"lost":r=K;break;case"restore":r=Z;break;case"destroy":r=$}return r.push(t),{cancel:function(){for(var e=0;e<r.length;++e)if(r[e]===t){r[e]=r[r.length-1],r.pop();break}}}},limits:V,hasExtension:function(e){return 0<=V.extensions.indexOf(e.toLowerCase())},read:v,destroy:function(){J.length=0,n(),X&&(X.removeEventListener("webglcontextlost",a),X.removeEventListener("webglcontextrestored",f)),I.clear(),q.clear(),H.clear(),z.clear(),P.clear(),B.clear(),F.clear(),A&&A.clear(),$.forEach(function(e){e()})},_gl:b,_refresh:p,poll:function(){l(),A&&A.update()},now:m,stats:x}),e.onDone(null,g),g}});
261
261
 
262
262
  },{}],88:[function(require,module,exports){
263
263
  const boundingBox=r=>{if(0===r.length)return[[0,0,0],[0,0,0]];const e=Array.isArray(r)&&Array.isArray(r[0]),n=e?r[0].length:3,o=new Array(n),t=new Array(n);for(let r=0;r<n;r+=1)o[r]=1/0,t[r]=-1/0;if(e)r.forEach(r=>{for(let l=0;l<n;l+=1){const n=e?r[l]:r;t[l]=n>t[l]?n:t[l],o[l]=n<o[l]?n:o[l]}});else for(let e=0;e<r.length;e+=n)for(let l=0;l<n;l+=1){const n=r[l+e];t[l]=n>t[l]?n:t[l],o[l]=n<o[l]?n:o[l]}return[o,t]};module.exports=boundingBox;
@@ -311,13 +311,13 @@ const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefault
311
311
  const meshFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal;\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform vec4 ucolor;\nuniform vec3 lightDirection;\nuniform vec3 opacity;\n\nvarying vec4 _worldSpacePosition;\n\nuniform vec2 printableArea;\n\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n\n float v = 0.8; // shadow value\n vec4 endColor = ucolor;\n\n vec3 ambient = ambientLightAmount * endColor.rgb;\n float cosTheta = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(cosTheta , 0.0, 1.0 );\n\n float cosTheta2 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(cosTheta2 , 0.0, 1.0 );\n\n gl_FragColor = vec4((ambient + diffuse + diffuse2 * v), endColor.a);\n}",meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\n\nvoid main() {\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n";module.exports={vert:meshVert,frag:meshFrag};
312
312
 
313
313
  },{}],105:[function(require,module,exports){
314
- const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawMesh=(e,r={extras:{}})=>{const t={useVertexColors:!0,dynamicCulling:!1,geometry:void 0,color:meshColor};let{geometry:s,dynamicCulling:a,useVertexColors:o,color:l}=Object.assign({},t,r);const n=e.buffer([]),i=!!(s.indices&&s.indices.length>0),c=!!(s.normals&&s.normals.length>0),m=!!(o&&s.colors&&s.colors.length>0),u=a?(e,r)=>{return 1&[r.model[0],r.model[5],r.model[10]].filter(e=>e<0).length?"front":"back"}:"back";let d={primitive:"triangles",vert:m?require("./vColorShaders").vert:require("./meshShaders").vert,frag:m?require("./vColorShaders").frag:require("./meshShaders").frag,uniforms:{model:(e,r)=>r.model||s.transforms||mat4.create(),ucolor:(e,r)=>r&&r.color?r.color:l,vColorToggler:(e,r)=>r&&r.useVertexColors&&!0===r.useVertexColors?1:0,unormal:(e,r)=>{const t=mat4.create(),s=mat4.multiply(mat4.create(),t,r.camera.view),a=mat4.create();return mat4.invert(a,s),mat4.transpose(a,a),a}},attributes:{position:e.buffer({usage:"static",type:"float",data:s.positions}),ao:n},cull:{enable:!0,face:u},depth:{enable:!0},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}};return s.cells?d.elements=s.cells:i?d.elements=e.elements({usage:"static",type:"uint16",data:s.indices}):s.triangles?d.elements=s.triangles:d.count=s.positions.length/3,c&&(d.attributes.normal=e.buffer({usage:"static",type:"float",data:s.normals})),m&&(d.attributes.color=e.buffer({usage:"static",type:"float",data:s.colors})),e(d=Object.assign({},d,r.extras))};module.exports=drawMesh;
314
+ const mat4=require("gl-mat4"),{meshColor:meshColor}=require("../../renderDefaults"),drawMesh=(e,r={extras:{}})=>{const t={useVertexColors:!0,dynamicCulling:!0,geometry:void 0,color:meshColor},{geometry:a,dynamicCulling:s,useVertexColors:o,color:l}=Object.assign({},t,r),n=e.buffer([]),i=!!(a.indices&&a.indices.length>0),c=!!(a.normals&&a.normals.length>0),m=!!(o&&a.colors&&a.colors.length>0),u=a.transforms||mat4.create(),d=mat4.determinant(u)<0,g=s&&d?"front":"back",f=m?require("./vColorShaders").vert:require("./meshShaders").vert,h=m?require("./vColorShaders").frag:require("./meshShaders").frag,b=mat4.invert(mat4.create(),u);let p={primitive:"triangles",vert:f,frag:h,uniforms:{model:(e,r)=>u,ucolor:(e,r)=>r&&r.color?r.color:l,vColorToggler:(e,r)=>r&&r.useVertexColors&&!0===r.useVertexColors?1:0,unormal:(e,r)=>{const t=mat4.invert(mat4.create(),r.camera.view);return mat4.multiply(t,b,t),mat4.transpose(t,t),t}},attributes:{position:e.buffer({usage:"static",type:"float",data:a.positions}),ao:n},cull:{enable:!0,face:g},depth:{enable:!0},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"}}};return a.cells?p.elements=a.cells:i?p.elements=e.elements({usage:"static",type:"uint16",data:a.indices}):a.triangles?p.elements=a.triangles:p.count=a.positions.length/3,c&&(p.attributes.normal=e.buffer({usage:"static",type:"float",data:a.normals})),m&&(p.attributes.color=e.buffer({usage:"static",type:"float",data:a.colors})),e(p=Object.assign({},p,r.extras))};module.exports=drawMesh;
315
315
 
316
316
  },{"../../renderDefaults":110,"./meshShaders":106,"./vColorShaders":107,"gl-mat4":26}],106:[function(require,module,exports){
317
317
  const meshFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal;\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform vec4 ucolor;\nuniform vec3 lightDirection;\nuniform vec3 opacity;\n\nvarying vec4 _worldSpacePosition;\n\nuniform vec2 printableArea;\n\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n\n float v = 0.8; // shadow value\n vec4 endColor = ucolor;\n\n vec3 ambient = ambientLightAmount * endColor.rgb;\n float cosTheta = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(cosTheta , 0.0, 1.0 );\n\n float cosTheta2 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(cosTheta2 , 0.0, 1.0 );\n\n gl_FragColor = vec4((ambient + diffuse + diffuse2 * v), endColor.a);\n}",meshVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection;\n\nattribute vec3 position, normal;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\n\nvoid main() {\n surfacePosition = position;\n surfaceNormal = normal;\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n}\n";module.exports={vert:meshVert,frag:meshFrag};
318
318
 
319
319
  },{}],107:[function(require,module,exports){
320
- const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection, unormal;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nattribute float ao;\nvarying float ambientAo;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n surfacePosition = position;\n surfaceNormal = (unormal * vec4(normal, 1.0)).xyz; //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n //gl_Position = projection * view * worldSpacePosition;\n\n vColor = color;\n\n //ambientAo = (1. - ao) * (0.5 * max(normal.x, 0.) + 0.5);\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n //gl_Position = zBufferAdjust(glPosition, camNear, camFar);\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal, surfacePosition;\n\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform float specularLightAmount;\n\nuniform vec3 lightDirection;\nuniform vec4 lightColor;\nuniform vec3 opacity;\nuniform float uMaterialShininess;\n\nvarying vec4 vColor;\nuniform vec4 ucolor;\nuniform float vColorToggler;\n\nuniform vec2 printableArea;\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);//vec4(0.15, 0.15, 0.15, 0.3);\nvarying vec4 _worldSpacePosition;\nvarying float ambientAo;\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n vec4 endColor = vColor * vColorToggler + ucolor * (1.0 - vColorToggler);\n\n vec3 ambient = ambientLightAmount * endColor.rgb ; //ambientAo * \n\n float diffuseWeight = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight , 0.0, 1.0 );\n\n //specular\n \n vec4 specularColor = vec4(lightColor);\n vec3 eyeDirection = normalize(surfacePosition.xyz);\n vec3 reflectionDirection = reflect(-lightDirection, surfaceNormal);\n float specularLightWeight = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n vec3 specular = specularColor.rgb * specularLightWeight * specularLightAmount;\n\n /*float light2Multiplier = 0.2;\n float diffuseWeight2 = dot(surfaceNormal, vec3(-lightDirection.x, lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight2 , 0.0, 1.0 ) * light2Multiplier;\n\n float light3Multiplier = 0.2; \n float diffuseWeight3 = dot(surfaceNormal, vec3(lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse3 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight3 , 0.0, 1.0 ) * light3Multiplier;\n\n float light4Multiplier = 0.2; \n float diffuseWeight4 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse4 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight4 , 0.0, 1.0 ) * light4Multiplier;*/\n \n gl_FragColor = vec4((ambient + diffuse + specular), endColor.a);\n //gl_FragColor = vec4((ambient + diffuse + diffuse2 + diffuse3 + diffuse4), endColor.a);\n}\n";module.exports={frag:vColorFrag,vert:vColorVert};
320
+ const vColorVert="\nprecision mediump float;\n\nuniform float camNear, camFar;\nuniform mat4 model, view, projection, unormal;\n\nattribute vec3 position, normal;\nattribute vec4 color;\n\nattribute float ao;\nvarying float ambientAo;\n\nvarying vec3 surfaceNormal, surfacePosition;\nvarying vec4 _worldSpacePosition;\nvarying vec4 vColor;\n\nvoid main() {\n surfacePosition = (unormal * vec4(position, 1.0)).xyz;\n surfaceNormal = normalize((unormal * vec4(normal, 1.0)).xyz); //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);\n vec4 worldSpacePosition = model * vec4(position, 1);\n _worldSpacePosition = worldSpacePosition;\n //gl_Position = projection * view * worldSpacePosition;\n\n vColor = color;\n\n //ambientAo = (1. - ao) * (0.5 * max(normal.x, 0.) + 0.5);\n\n vec4 glPosition = projection * view * model * vec4(position, 1);\n gl_Position = glPosition;\n //gl_Position = zBufferAdjust(glPosition, camNear, camFar);\n}\n",vColorFrag="\nprecision mediump float;\nvarying vec3 surfaceNormal, surfacePosition;\n\nuniform float ambientLightAmount;\nuniform float diffuseLightAmount;\nuniform float specularLightAmount;\n\nuniform vec3 lightDirection;\nuniform vec4 lightColor;\nuniform vec3 opacity;\nuniform float uMaterialShininess;\n\nvarying vec4 vColor;\nuniform vec4 ucolor;\nuniform float vColorToggler;\n\nuniform vec2 printableArea;\nvec4 errorColor = vec4(0.15, 0.15, 0.15, 0.3);//vec4(0.15, 0.15, 0.15, 0.3);\nvarying vec4 _worldSpacePosition;\nvarying float ambientAo;\n\nvoid main () {\n vec4 depth = gl_FragCoord;\n vec4 endColor = vColor * vColorToggler + ucolor * (1.0 - vColorToggler);\n\n vec3 ambient = ambientLightAmount * endColor.rgb ; //ambientAo * \n\n float diffuseWeight = dot(surfaceNormal, lightDirection);\n vec3 diffuse = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight , 0.0, 1.0 );\n\n //specular\n \n vec4 specularColor = vec4(lightColor);\n vec3 eyeDirection = normalize(surfacePosition.xyz);\n vec3 reflectionDirection = reflect(-lightDirection, -surfaceNormal);\n float specularLightWeight = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);\n vec3 specular = specularColor.rgb * specularLightWeight * specularLightAmount;\n\n /*float light2Multiplier = 0.2;\n float diffuseWeight2 = dot(surfaceNormal, vec3(-lightDirection.x, lightDirection.y, lightDirection.z));\n vec3 diffuse2 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight2 , 0.0, 1.0 ) * light2Multiplier;\n\n float light3Multiplier = 0.2; \n float diffuseWeight3 = dot(surfaceNormal, vec3(lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse3 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight3 , 0.0, 1.0 ) * light3Multiplier;\n\n float light4Multiplier = 0.2; \n float diffuseWeight4 = dot(surfaceNormal, vec3(-lightDirection.x, -lightDirection.y, lightDirection.z));\n vec3 diffuse4 = diffuseLightAmount * endColor.rgb * clamp(diffuseWeight4 , 0.0, 1.0 ) * light4Multiplier;*/\n \n gl_FragColor = vec4((ambient + diffuse + specular), endColor.a);\n //gl_FragColor = vec4((ambient + diffuse + diffuse2 + diffuse3 + diffuse4), endColor.a);\n}\n";module.exports={frag:vColorFrag,vert:vColorVert};
321
321
 
322
322
  },{}],108:[function(require,module,exports){
323
323
  const renderContext=require("./renderContext"),renderDefaults=require("./renderDefaults"),prepareRender=e=>{const r=Object.assign({},{},e.glOptions,{onDone:(e,r)=>{if(e)throw e}}),n=require("regl")(r),a=new Map;return function(e){var r;n.poll(),(r=e).rendering=Object.assign({},renderDefaults,r.rendering),renderContext(n)(r,e=>{n.clear({color:r.rendering.background,depth:1}),r.entities&&r.entities.sort((e,r)=>{const n="transparent"in e.visuals&&e.visuals.transparent;return n===("transparent"in r.visuals&&r.visuals.transparent)?0:n?1:-1}).forEach(e=>{const{visuals:t}=e;if((!("show"in t)||t.show)&&t.drawCmd&&r.drawCommands[t.drawCmd]){let s;t.cacheId?s=a.get(t.cacheId):(t.cacheId=a.size,s=r.drawCommands[t.drawCmd](n,e),a.set(t.cacheId,s)),s({...e,...t,camera:r.camera})}})})}};module.exports=prepareRender;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/regl-renderer",
3
- "version": "2.2.0",
3
+ "version": "2.5.0",
4
4
  "description": "Renderer for JSCAD Geometries",
5
5
  "repository": "https://github.com/jscad/OpenJSCAD.org",
6
6
  "main": "src/index.js",
@@ -25,21 +25,23 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
+ "types": "types",
28
29
  "dependencies": {
29
30
  "@jscad/array-utils": "2.1.0",
30
31
  "camera-unproject": "1.0.1",
31
32
  "gl-mat4": "1.2.0",
32
33
  "gl-vec3": "1.1.3",
33
- "regl": "1.6.1"
34
+ "regl": "2.1.0"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@jscad/img-utils": "2.0.1",
37
- "@jscad/modeling": "2.5.0",
38
+ "@jscad/modeling": "2.6.0",
38
39
  "ava": "3.15.0",
39
40
  "browserify": "16.5.1",
40
41
  "budo": "11.6.4",
41
42
  "nyc": "15.1.0",
43
+ "typescript": "^4.0.0",
42
44
  "uglifyify": "5.0.2"
43
45
  },
44
- "gitHead": "18d1d0b53cf676c6349fa24be2253fd7c21e676b"
46
+ "gitHead": "3d1d02f2863c65fd95406c7098c09297b3be1c10"
45
47
  }
@@ -5,11 +5,11 @@ const { meshColor } = require('../../renderDefaults')
5
5
  const drawMesh = (regl, params = { extras: {} }) => {
6
6
  const defaults = {
7
7
  useVertexColors: true,
8
- dynamicCulling: false,
8
+ dynamicCulling: true,
9
9
  geometry: undefined,
10
10
  color: meshColor
11
11
  }
12
- let { geometry, dynamicCulling, useVertexColors, color } = Object.assign({}, defaults, params)
12
+ const { geometry, dynamicCulling, useVertexColors, color } = Object.assign({}, defaults, params)
13
13
 
14
14
  // let ambientOcclusion = vao(geometry.indices, geometry.positions, 64, 64)
15
15
  const ambientOcclusion = regl.buffer([])
@@ -18,15 +18,15 @@ const drawMesh = (regl, params = { extras: {} }) => {
18
18
  const hasIndices = !!(geometry.indices && geometry.indices.length > 0)
19
19
  const hasNormals = !!(geometry.normals && geometry.normals.length > 0)
20
20
  const hasVertexColors = !!(useVertexColors && geometry.colors && geometry.colors.length > 0)
21
+ const transforms = geometry.transforms || mat4.create()
22
+ const flip = mat4.determinant(transforms) < 0
21
23
  const cullFace = dynamicCulling
22
- ? (context, props) => {
23
- const isOdd = ([props.model[0], props.model[5], props.model[10]].filter((x) => x < 0).length) & 1 // count the number of negative components & deterine if that is odd or even
24
- return isOdd ? 'front' : 'back'
25
- }
24
+ ? (flip ? 'front' : 'back')
26
25
  : 'back'
27
26
 
28
27
  const vert = hasVertexColors ? require('./vColorShaders').vert : require('./meshShaders').vert
29
- let frag = hasVertexColors ? require('./vColorShaders').frag : require('./meshShaders').frag
28
+ const frag = hasVertexColors ? require('./vColorShaders').frag : require('./meshShaders').frag
29
+ const modelMatrixInv = mat4.invert(mat4.create(), transforms)
30
30
 
31
31
  // console.log('type', geometry.type, 'color', color, hasVertexColors)
32
32
 
@@ -36,18 +36,16 @@ const drawMesh = (regl, params = { extras: {} }) => {
36
36
  frag,
37
37
 
38
38
  uniforms: {
39
- model: (context, props) => props.model || geometry.transforms || mat4.create(),
39
+ model: (context, props) => transforms ,
40
40
  ucolor: (context, props) => (props && props.color) ? props.color : color,
41
- // semi hack, woraround to enable/disable vertex colors!!!
41
+ // semi hack, woraround to enable/disable vertex colors !!!
42
42
  vColorToggler: (context, props) => (props && props.useVertexColors && props.useVertexColors === true) ? 1.0 : 0.0,
43
43
  // experimental
44
44
  unormal: (context, props) => {
45
- const model = mat4.create()
46
- const modelViewMatrix = mat4.multiply(mat4.create(), model, props.camera.view)
47
- const normalMatrix = mat4.create()
48
- mat4.invert(normalMatrix, modelViewMatrix)
49
- mat4.transpose(normalMatrix, normalMatrix)
50
- return normalMatrix
45
+ const modelViewMatrix = mat4.invert(mat4.create(), props.camera.view)
46
+ mat4.multiply(modelViewMatrix, modelMatrixInv, modelViewMatrix)
47
+ mat4.transpose(modelViewMatrix, modelViewMatrix)
48
+ return modelViewMatrix
51
49
  }
52
50
  },
53
51
  attributes: {
@@ -15,8 +15,8 @@ varying vec4 _worldSpacePosition;
15
15
  varying vec4 vColor;
16
16
 
17
17
  void main() {
18
- surfacePosition = position;
19
- surfaceNormal = (unormal * vec4(normal, 1.0)).xyz; //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
18
+ surfacePosition = (unormal * vec4(position, 1.0)).xyz;
19
+ surfaceNormal = normalize((unormal * vec4(normal, 1.0)).xyz); //vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);
20
20
  vec4 worldSpacePosition = model * vec4(position, 1);
21
21
  _worldSpacePosition = worldSpacePosition;
22
22
  //gl_Position = projection * view * worldSpacePosition;
@@ -65,7 +65,7 @@ void main () {
65
65
 
66
66
  vec4 specularColor = vec4(lightColor);
67
67
  vec3 eyeDirection = normalize(surfacePosition.xyz);
68
- vec3 reflectionDirection = reflect(-lightDirection, surfaceNormal);
68
+ vec3 reflectionDirection = reflect(-lightDirection, -surfaceNormal);
69
69
  float specularLightWeight = pow(max(dot(reflectionDirection, eyeDirection), 0.0), uMaterialShininess);
70
70
  vec3 specular = specularColor.rgb * specularLightWeight * specularLightAmount;
71
71
 
@@ -0,0 +1,2 @@
1
+ export = boundingBox;
2
+ declare function boundingBox(positions: number[][]): number[][];
@@ -0,0 +1,2 @@
1
+ export = boundingSphere;
2
+ declare function boundingSphere(center: number[], positions: number[][]): number;
@@ -0,0 +1,10 @@
1
+ import { Geometry } from '@jscad/modeling/src/geometries/types'
2
+
3
+ export = computeBounds;
4
+ declare function computeBounds(...geometries: Geometry[]): {
5
+ dia: number;
6
+ center: number[];
7
+ min: number[];
8
+ max: number[];
9
+ size: number[];
10
+ };
@@ -0,0 +1,4 @@
1
+ export function toPerspectiveView({ camera }: { camera: typeof import('./perspectiveCamera').cameraState }): { view: Float32Array; position: Float32Array };
2
+ export function toPresetView(viewName: string, { camera }: { camera: typeof import('./orthographicCamera').cameraState | typeof import('./perspectiveCamera').cameraState }): { view: Float32Array; position: Float32Array };
3
+ export function fromOrthographicToPerspective(orthographicCamera: typeof import('./orthographicCamera').cameraState): typeof import('./perspectiveCamera').cameraState;
4
+ export function fromPerspectiveToOrthographic(perspectiveCamera: typeof import('./perspectiveCamera').cameraState): typeof import('./orthographicCamera').cameraState;
@@ -0,0 +1,3 @@
1
+ export const camera: typeof import('./camera')
2
+ export const orthographic: typeof import('./orthographicCamera')
3
+ export const perspective: typeof import('./perspectiveCamera')
@@ -0,0 +1,18 @@
1
+ export namespace cameraState {
2
+ const view: Float32Array
3
+ const projection: Float32Array
4
+ const matrix: Float32Array
5
+ const near: number
6
+ const far: number
7
+ const up: number[]
8
+ const eye: Float32Array
9
+ const position: number[]
10
+ const target: number[]
11
+ const fov: number
12
+ const aspect: number
13
+ const viewport: number[]
14
+ const zoom: number
15
+ const projectionType: string
16
+ }
17
+ export const cameraProps: {};
18
+ export function setProjection(camera: typeof cameraState, input: { width: number; height: number }): typeof cameraState;
@@ -0,0 +1,19 @@
1
+ export namespace cameraState {
2
+ const view: Float32Array
3
+ const projection: Float32Array
4
+ const matrix: Float32Array
5
+ const near: number
6
+ const far: number
7
+ const up: number[]
8
+ const eye: Float32Array
9
+ const position: number[]
10
+ const target: number[]
11
+ const fov: number
12
+ const aspect: number
13
+ const viewport: number[]
14
+ const projectionType: string
15
+ }
16
+ export const cameraProps: {};
17
+ export const defaults: any;
18
+ export function setProjection(output: typeof cameraState | null, camera: typeof cameraState, input: { width: number; height: number }): typeof cameraState;
19
+ export function update(output: typeof cameraState, camera?: typeof cameraState): typeof cameraState;
@@ -0,0 +1,125 @@
1
+ import { Geometry } from '@jscad/modeling/src/geometries/types'
2
+
3
+ export namespace controlsProps {
4
+ namespace limits {
5
+ const minDistance: number
6
+ const maxDistance: number
7
+ }
8
+ const drag: number
9
+ const EPS: number
10
+ namespace zoomToFit {
11
+ const auto: boolean
12
+ const targets: string
13
+ const tightness: number
14
+ }
15
+ namespace userControl {
16
+ const zoom: boolean
17
+ const zoomSpeed: number
18
+ const rotate: boolean
19
+ const rotateSpeed: number
20
+ const pan: boolean
21
+ const panSpeed: number
22
+ }
23
+ namespace autoRotate {
24
+ const enabled: boolean
25
+ const speed: number
26
+ }
27
+ const autoAdjustPlanes: boolean
28
+ }
29
+ export namespace controlsState {
30
+ const thetaDelta: number
31
+ const phiDelta: number
32
+ const scale: number
33
+ }
34
+ export const defaults: any;
35
+ export function update({ controls, camera }: {
36
+ controls: typeof controlsState;
37
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
38
+ }, output?: any): {
39
+ controls: {
40
+ thetaDelta: number;
41
+ phiDelta: number;
42
+ scale: number;
43
+ changed: boolean;
44
+ };
45
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
46
+ };
47
+ /**
48
+ * compute camera state to rotate the camera
49
+ * @param {Object} controls the controls data/state
50
+ * @param {Object} camera the camera data/state
51
+ * @param {Float} angle value of the angle to rotate
52
+ * @return {Object} the updated camera data/state
53
+ */
54
+ export function rotate({ controls, camera, speed }: {
55
+ controls: typeof controlsState;
56
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
57
+ speed?: number;
58
+ }, angle: number[]): {
59
+ controls: typeof controlsState;
60
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
61
+ };
62
+ /**
63
+ * compute camera state to zoom the camera
64
+ * @param {Object} controls the controls data/state
65
+ * @param {Object} camera the camera data/state
66
+ * @param {Float} zoomDelta value of the zoom
67
+ * @return {Object} the updated camera data/state
68
+ */
69
+ export function zoom({ controls, camera, speed }: {
70
+ controls: typeof controlsState;
71
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
72
+ speed?: number;
73
+ }, zoomDelta?: number): {
74
+ controls: typeof controlsState;
75
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
76
+ };
77
+ /**
78
+ * compute camera state to pan the camera
79
+ * @param {Object} controls the controls data/state
80
+ * @param {Object} camera the camera data/state
81
+ * @param {Float} delta value of the raw pan delta
82
+ * @return {Object} the updated camera data/state
83
+ */
84
+ export function pan({ controls, camera, speed }: {
85
+ controls: typeof controlsState;
86
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
87
+ speed?: number;
88
+ }, delta: number[]): {
89
+ controls: typeof controlsState;
90
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
91
+ };
92
+ /**
93
+ * compute camera state to 'fit' an object on screen
94
+ * Note1: this is a non optimal but fast & easy implementation
95
+ * @param {Object} controls the controls data/state
96
+ * @param {Object} camera the camera data/state
97
+ * @param {Array} entities - an array of entities (see entitiesFromSolids)
98
+ * @return {Object} the updated camera data/state
99
+ */
100
+ export function zoomToFit({ controls, camera, entities }: {
101
+ controls: typeof controlsState;
102
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
103
+ entities: { geometry: Geometry; visuals: { drawCmd: string; show: boolean; transparent: boolean; useVertexColors: boolean } }[];
104
+ }): {
105
+ controls: typeof controlsState;
106
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
107
+ };
108
+ /**
109
+ * compute controls state to 'reset it' to the given state
110
+ * Note1: this is a non optimal but fast & easy implementation
111
+ * @param {Object} controls the controls data/state
112
+ * @param {Object} camera the camera data/state
113
+ * @param {Object} desiredState the state to reset the camera to: defaults to default values
114
+ * @return {Object} the updated camera data/state
115
+ */
116
+ export function reset({ controls, camera }: {
117
+ controls: typeof controlsState;
118
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
119
+ }, desiredState: {
120
+ controls: typeof controlsState;
121
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
122
+ }): {
123
+ controls: typeof controlsState;
124
+ camera: typeof import('../cameras/orthographicCamera').cameraState | typeof import('../cameras/perspectiveCamera').cameraState;
125
+ };
@@ -0,0 +1,13 @@
1
+ import { Geom2, Geom3, Geometry } from '@jscad/modeling/src/geometries/types'
2
+
3
+ export = entitiesFromSolids;
4
+ /**
5
+ * Convert the given solids into renderable entities.
6
+ * Each 'solid' (V2 geometry) is converted to a WEBGL renderable 'geometry'.
7
+ * The resulting entities are passed as properities to the render.
8
+ * @param {Object} options - options for construction
9
+ * @param {Array} [options.color] - color for rendering, if the solid does not provide a color
10
+ * @param {Boolean} [options.smoothNormals=true] - smooth the normals of 3d solids, rendering a smooth surface
11
+ * @returns {Array} an array of renderable entities
12
+ */
13
+ declare function entitiesFromSolids(options: { color?: number[]; smoothNormals?: boolean }, ...solids:Geom2[] | Geom3[]): Geometry[];
@@ -0,0 +1,4 @@
1
+ import { Geom2, Geometry } from '@jscad/modeling/src/geometries/types'
2
+
3
+ export = geom2ToGeometries;
4
+ declare function geom2ToGeometries(options: any, solid: Geom2): Geometry[];
@@ -0,0 +1,4 @@
1
+ import { Geom3, Geometry } from '@jscad/modeling/src/geometries/types'
2
+
3
+ export = geom3ToGeometries;
4
+ declare function geom3ToGeometries(options: any, solid: Geom3): Geometry[];
@@ -0,0 +1,4 @@
1
+ import { Geometry, Path2 } from '@jscad/modeling/src/geometries/types'
2
+
3
+ export = path2ToGeometries;
4
+ declare function path2ToGeometries(options: any, solid: Path2): Geometry[];
@@ -0,0 +1,16 @@
1
+ export const prepareRender: typeof import('./rendering/render')
2
+ export namespace drawCommands {
3
+ const drawGrid: typeof import('./rendering/commands/drawGrid')
4
+ const drawAxis: typeof import('./rendering/commands/drawAxis')
5
+ const drawMesh: typeof import('./rendering/commands/drawMesh')
6
+ const drawLines: typeof import('./rendering/commands/drawLines')
7
+ }
8
+ export namespace cameras {
9
+ const camera: typeof import('./cameras/camera')
10
+ const orthographic: typeof import('./cameras/orthographicCamera')
11
+ const perspective: typeof import('./cameras/perspectiveCamera')
12
+ }
13
+ export namespace controls {
14
+ const orbit: typeof import('./controls/orbitControls')
15
+ }
16
+ export const entitiesFromSolids: typeof import('./geometry-utils-V2/entitiesFromSolids')
@@ -0,0 +1,4 @@
1
+ import { DefaultContext, DrawCommand, Regl } from 'regl'
2
+
3
+ export = drawAxis;
4
+ declare function drawAxis(regl: Regl, params: any): (props: any) => DrawCommand<DefaultContext, {}>;
@@ -0,0 +1,6 @@
1
+ export = geoArc;
2
+ declare function geoArc(options: any): {
3
+ positions: any[];
4
+ cells: any[];
5
+ uvs: any[];
6
+ };
@@ -0,0 +1,2 @@
1
+ export = drawConnector;
2
+ declare function drawConnector(regl: any, params: any): () => void;
@@ -0,0 +1,2 @@
1
+ export = drawMesh;
2
+ declare function drawMesh(regl: any, params: any): any;
@@ -0,0 +1,2 @@
1
+ export = drawMesh;
2
+ declare function drawMesh(regl: any, params: any): any;
@@ -0,0 +1,2 @@
1
+ export = drawNormals;
2
+ declare function drawNormals(regl: any, params: any): () => any;
@@ -0,0 +1,2 @@
1
+ export = drawNormals;
2
+ declare function drawNormals(regl: any, params: any): () => any;
@@ -0,0 +1,4 @@
1
+ import { DefaultContext, DrawCommand, Regl } from 'regl'
2
+
3
+ export = makeDrawGrid;
4
+ declare function makeDrawGrid(regl: Regl, params?: {}): DrawCommand<DefaultContext, {}>;
@@ -0,0 +1,2 @@
1
+ export = makeDrawMultiGrid;
2
+ declare function makeDrawMultiGrid(regl: any, params: any): (props: any) => void;
@@ -0,0 +1,4 @@
1
+ import { DefaultContext, DrawCommand, Regl } from 'regl'
2
+
3
+ export = drawLines;
4
+ declare function drawLines(regl: Regl, params?: {}): DrawCommand<DefaultContext, {}>;
@@ -0,0 +1,4 @@
1
+ import { DefaultContext, DrawCommand, Regl } from 'regl'
2
+
3
+ export = drawMesh;
4
+ declare function drawMesh(regl: Regl, params?: { extras: {} }): DrawCommand<DefaultContext, {}>;
@@ -0,0 +1,4 @@
1
+ import { InitializationOptions } from 'regl'
2
+
3
+ export = prepareRender;
4
+ declare function prepareRender(params: { glOptions: InitializationOptions}): (data: any) => void;
@@ -0,0 +1,7 @@
1
+ export = renderWrapper;
2
+ /** function that injects most of the uniforms into the regl context:
3
+ * ie keeps track of all regl global state.
4
+ * @param {} regl
5
+ * @param {} params={}
6
+ */
7
+ declare function renderWrapper(regl: any, params?: any): any;
@@ -0,0 +1,9 @@
1
+ export const background: number[]
2
+ export const meshColor: number[]
3
+ export const lightColor: number[]
4
+ export const lightDirection: number[]
5
+ export const lightPosition: number[]
6
+ export const ambientLightAmount: number
7
+ export const diffuseLightAmount: number
8
+ export const specularLightAmount: number
9
+ export const materialShininess: number
@@ -0,0 +1,8 @@
1
+ /** kinda, sorta like a nested object.assign, so that nested object values
2
+ * do not get lost
3
+ * note : this is NOT actually making anything immutable !
4
+ * @param {} output={}
5
+ * @param {} currentState
6
+ * @param {} options
7
+ */
8
+ export function merge(output: any, currentState: any, options: any): any;