@deck.gl/extensions 9.0.0-alpha.7 → 9.0.0-beta.2
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.
- package/dist/dist.dev.js +3379 -392
- package/dist/es5/collision-filter/collision-filter-pass.js +4 -2
- package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -1
- package/dist/es5/terrain/shader-module.js +3 -1
- package/dist/es5/terrain/shader-module.js.map +1 -1
- package/dist/esm/collision-filter/collision-filter-pass.js +4 -2
- package/dist/esm/collision-filter/collision-filter-pass.js.map +1 -1
- package/dist/esm/terrain/shader-module.js +3 -1
- package/dist/esm/terrain/shader-module.js.map +1 -1
- package/dist.min.js +77 -74
- package/package.json +8 -8
- package/src/collision-filter/collision-filter-pass.ts +4 -2
- package/src/terrain/shader-module.ts +2 -2
- package/typed/collision-filter/collision-filter-pass.d.ts +4 -2
- package/typed/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/typed/terrain/shader-module.d.ts +3 -1
- package/typed/terrain/shader-module.d.ts.map +1 -1
package/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['deck'] = factory();
|
|
6
6
|
else root['deck'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var
|
|
7
|
+
"use strict";var __exports__=(()=>{var Ml=Object.create;var Xt=Object.defineProperty;var Cl=Object.getOwnPropertyDescriptor;var Bl=Object.getOwnPropertyNames;var Dl=Object.getPrototypeOf,kl=Object.prototype.hasOwnProperty;var ss=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),os=(e,t)=>{for(var r in t)Xt(e,r,{get:t[r],enumerable:!0})},Lt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Bl(t))!kl.call(e,i)&&i!==r&&Xt(e,i,{get:()=>t[i],enumerable:!(n=Cl(t,i))||n.enumerable});return e},Re=(e,t,r)=>(Lt(e,t,"default"),r&&Lt(r,t,"default")),v=(e,t,r)=>(r=e!=null?Ml(Dl(e)):{},Lt(t||!e||!e.__esModule?Xt(r,"default",{value:e,enumerable:!0}):r,e)),Ul=e=>Lt(Xt({},"__esModule",{value:!0}),e);var w=ss((kh,as)=>{as.exports=globalThis.deck});var x=ss((Xh,hs)=>{hs.exports=globalThis.luma});var Wt={};os(Wt,{BrushingExtension:()=>Kt,ClipExtension:()=>rn,CollisionFilterExtension:()=>_n,DataFilterExtension:()=>Xr,FillStyleExtension:()=>Gr,Fp64Extension:()=>zi,MaskExtension:()=>pn,PathStyleExtension:()=>Zr,_TerrainExtension:()=>Sn,project64:()=>zr});var se={},ls=v(w());Re(se,v(w()));if(!ls.Layer)throw new Error("@deck.gl/core is not found");Re(Wt,se);var us=v(w());var fs=v(w()),Vl=`
|
|
8
8
|
uniform bool brushing_enabled;
|
|
9
9
|
uniform int brushing_target;
|
|
10
10
|
uniform vec2 brushing_mousePos;
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
void brushing_setVisible(bool visible) {
|
|
37
37
|
brushing_isVisible = float(visible);
|
|
38
38
|
}
|
|
39
|
-
`,
|
|
39
|
+
`,Wl=`
|
|
40
40
|
uniform bool brushing_enabled;
|
|
41
41
|
in float brushing_isVisible;
|
|
42
|
-
`,
|
|
42
|
+
`,Hl={source:0,target:1,custom:2,source_target:3},Ll={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
43
43
|
vec2 brushingTarget;
|
|
44
44
|
vec2 brushingSource;
|
|
45
45
|
if (brushing_target == 3) {
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
if (brushing_enabled && brushing_isVisible < 0.5) {
|
|
68
68
|
discard;
|
|
69
69
|
}
|
|
70
|
-
`},Ui={name:"brushing",dependencies:[wi.project],vs:ca,fs:ua,inject:da,getUniforms:function(t){if(!t||!("viewport"in t))return{};var r=t.brushingEnabled,i=r===void 0?!0:r,n=t.brushingRadius,o=n===void 0?1e4:n,s=t.brushingTarget,a=s===void 0?"source":s,f=t.mousePosition,l=t.viewport;return{brushing_enabled:Boolean(i&&f&&l.containsPixel(f)),brushing_radius:o,brushing_target:_a[a]||0,brushing_mousePos:f?l.unproject([f.x-l.x,f.y-l.y]):[0,0]}}};function At(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?At=function(r){return typeof r}:At=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},At(e)}function pa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ha(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ur(e,t)}function Ur(e,t){return Ur=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},Ur(e,t)}function ga(e){var t=Ra();return function(){var i=Rt(e),n;if(t){var o=Rt(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return Ta(this,n)}}function Ta(e,t){if(t&&(At(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Aa(e)}function Aa(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ra(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Rt(e){return Rt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Rt(e)}var ba={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},bt=function(e){ha(r,e);var t=ga(r);function r(){return pa(this,r),t.apply(this,arguments)}var i=r.prototype;return i.getShaders=function(){return{modules:[Ui]}},i.initializeState=function(o,s){var a=this,f=this.getAttributeManager();f&&f.add({brushingTargets:{size:2,accessor:"getBrushingTarget",shaderAttributes:{brushingTargets:{divisor:0},instanceBrushingTargets:{divisor:1}}}});var l=function(){var u;(u=a.getCurrentLayer())===null||u===void 0||u.setNeedsRedraw()};this.state.onMouseMove=l,o.deck&&o.deck.eventManager.on({pointermove:l,pointerleave:l})},i.finalizeState=function(o,s){if(o.deck){var a=this.state.onMouseMove;o.deck.eventManager.off({pointermove:a,pointerleave:a})}},r}(Vi.LayerExtension);bt.defaultProps=ba;bt.extensionName="BrushingExtension";var Ea="Failed to create WebGL context in Node.js, headless gl returned null",va=" luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.",ma={width:1,height:1,debug:!0,throwOnError:!1},Vr=null;function ki(){return Vr!==null}function Wi(e){e={...ma,...e};let{width:t,height:r,webgl1:i,webgl2:n}=e;if(n&&!i)throw new Error("headless-gl does not support WebGL2");if(!Vr)throw new Error(va);let o=Vr(t,r,e);if(!o)throw new Error(Ea);return o}var O=T(E(),1);function We(e){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}function L(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||We()}var Rd=globalThis.self||globalThis.window||globalThis.global,bd=globalThis.window||globalThis.self||globalThis.global,Ed=globalThis.document||{},vd=globalThis.process||{},md=globalThis.console,Xi=globalThis.navigator||{};var kr=globalThis;function Et(e){if(!e&&!L())return"Node";if(We(e))return"Electron";let t=e||Xi.userAgent||"";if(t.indexOf("Edge")>-1)return"Edge";let r=t.indexOf("MSIE ")!==-1,i=t.indexOf("Trident/")!==-1;return r||i?"IE":kr.chrome?"Chrome":kr.safari?"Safari":kr.mozInnerScreenX?"Firefox":"Unknown"}var Qi=T(E(),1);var He={};function Sa(e){globalThis.console&&globalThis.console.error&&globalThis.console.error(e)}function ya(e){globalThis.console&&globalThis.console.log&&globalThis.console.log(e)}function Oa(e,t){He[e]=!0,t!==void 0&&Sa(t)}function xa(e){let t=e.getError;e.getError=function(){let i;do i=t.apply(e),i!==0&&(He[i]=!0);while(i!==0);for(i in He)if(He[i])return delete He[i],parseInt(i,10);return 0}}var Xe=function e(t){let r=t.gl;this.ext=t,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(t.maxVertexAttribs);for(let i=0;i<this.attribs.length;i++){let n=new e.VertexAttrib(r);this.attribs[i]=n}this.maxAttrib=0};Xe.VertexAttrib=function(t){this.enabled=!1,this.buffer=null,this.size=4,this.type=5126,this.normalized=!1,this.stride=16,this.offset=0,this.cached="",this.recache()};Xe.VertexAttrib.prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};var Ae=function(t){let r=this;this.gl=t,xa(t);let i=this.original={getParameter:t.getParameter,enableVertexAttribArray:t.enableVertexAttribArray,disableVertexAttribArray:t.disableVertexAttribArray,bindBuffer:t.bindBuffer,getVertexAttrib:t.getVertexAttrib,vertexAttribPointer:t.vertexAttribPointer};t.getParameter=function(o){return o===r.VERTEX_ARRAY_BINDING_OES?r.currentVertexArrayObject===r.defaultVertexArrayObject?null:r.currentVertexArrayObject:i.getParameter.apply(this,arguments)},t.enableVertexAttribArray=function(o){let s=r.currentVertexArrayObject;s.maxAttrib=Math.max(s.maxAttrib,o);let a=s.attribs[o];return a.enabled=!0,i.enableVertexAttribArray.apply(this,arguments)},t.disableVertexAttribArray=function(o){let s=r.currentVertexArrayObject;s.maxAttrib=Math.max(s.maxAttrib,o);let a=s.attribs[o];return a.enabled=!1,i.disableVertexAttribArray.apply(this,arguments)},t.bindBuffer=function(o,s){switch(o){case 34962:r.currentArrayBuffer=s;break;case 34963:r.currentVertexArrayObject.elementArrayBuffer=s;break;default:}return i.bindBuffer.apply(this,arguments)},t.getVertexAttrib=function(o,s){let f=r.currentVertexArrayObject.attribs[o];switch(s){case 34975:return f.buffer;case 34338:return f.enabled;case 34339:return f.size;case 34340:return f.stride;case 34341:return f.type;case 34922:return f.normalized;default:return i.getVertexAttrib.apply(this,arguments)}},t.vertexAttribPointer=function(o,s,a,f,l,c){let u=r.currentVertexArrayObject;u.maxAttrib=Math.max(u.maxAttrib,o);let _=u.attribs[o];return _.buffer=r.currentArrayBuffer,_.size=s,_.type=a,_.normalized=f,_.stride=l,_.offset=c,_.recache(),i.vertexAttribPointer.apply(this,arguments)},t.instrumentExtension&&t.instrumentExtension(this,"OES_vertex_array_object"),t.canvas&&t.canvas.addEventListener("webglcontextrestored",()=>{ya("OESVertexArrayObject emulation library context restored"),r.reset_()},!0),this.reset_()};Ae.prototype.VERTEX_ARRAY_BINDING_OES=34229;Ae.prototype.reset_=function(){if(this.vertexArrayObjects!==void 0)for(let i=0;i<this.vertexArrayObjects.length;++i)this.vertexArrayObjects.isAlive=!1;let r=this.gl;this.maxVertexAttribs=r.getParameter(34921),this.defaultVertexArrayObject=new Xe(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)};Ae.prototype.createVertexArrayOES=function(){let t=new Xe(this);return this.vertexArrayObjects.push(t),t};Ae.prototype.deleteVertexArrayOES=function(t){t.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(t),1),this.currentVertexArrayObject===t&&this.bindVertexArrayOES(null)};Ae.prototype.isVertexArrayOES=function(t){return!!(t&&t instanceof Xe&&t.hasBeenBound&&t.ext===this)};Ae.prototype.bindVertexArrayOES=function(t){let r=this.gl;if(t&&!t.isAlive){Oa(1282,"bindVertexArrayOES: attempt to bind deleted arrayObject");return}let i=this.original,n=this.currentVertexArrayObject;this.currentVertexArrayObject=t||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;let o=this.currentVertexArrayObject;if(n===o)return;(!n||o.elementArrayBuffer!==n.elementArrayBuffer)&&i.bindBuffer.call(r,34963,o.elementArrayBuffer);let s=this.currentArrayBuffer,a=Math.max(n?n.maxAttrib:0,o.maxAttrib);for(let f=0;f<=a;f++){let l=o.attribs[f],c=n?n.attribs[f]:null;if((!n||l.enabled!==c.enabled)&&(l.enabled?i.enableVertexAttribArray.call(r,f):i.disableVertexAttribArray.call(r,f)),l.enabled){let u=!1;(!n||l.buffer!==c.buffer)&&(s!==l.buffer&&(i.bindBuffer.call(r,34962,l.buffer),s=l.buffer),u=!0),(u||l.cached!==c.cached)&&i.vertexAttribPointer.call(r,f,l.size,l.type,l.normalized,l.stride,l.offset)}}this.currentArrayBuffer!==s&&i.bindBuffer.call(r,34962,this.currentArrayBuffer)};function Li(e){if(typeof e.createVertexArray=="function")return;let t=e.getSupportedExtensions;e.getSupportedExtensions=function(){let n=t.call(this)||[];return n.indexOf("OES_vertex_array_object")<0&&n.push("OES_vertex_array_object"),n};let r=e.getExtension;e.getExtension=function(n){let o=r.call(this,n);return o||(n!=="OES_vertex_array_object"?null:(e.__OESVertexArrayObject||(this.__OESVertexArrayObject=new Ae(this)),this.__OESVertexArrayObject))}}var Re=T(E(),1);var ji=T(E(),1),Pa="Invalid WebGLRenderingContext";function Fa(e){return typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function b(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&e._version===2)}function Wr(e){return b(e)?e:null}function Ki(e){return(0,ji.assert)(Fa(e),Pa),e}var zi="OES_element_index",Yi="WEBGL_draw_buffers",Ia="EXT_disjoint_timer_query",Ca="EXT_disjoint_timer_query_webgl2",Ma="EXT_texture_filter_anisotropic",$i="WEBGL_debug_renderer_info",Na=35723,Ba=4352,Da=36795,wa=34047,Ua=37445,Va=37446,y=e=>b(e)?void 0:0,ka={[3074]:e=>b(e)?void 0:36064,[Na]:e=>b(e)?void 0:Ba,[35977]:y,[32937]:y,[Da]:(e,t)=>{let r=b(e)?e.getExtension(Ca):e.getExtension(Ia);return r&&r.GPU_DISJOINT_EXT?t(r.GPU_DISJOINT_EXT):0},[Ua]:(e,t)=>{let r=e.getExtension($i);return t(r&&r.UNMASKED_VENDOR_WEBGL||7936)},[Va]:(e,t)=>{let r=e.getExtension($i);return t(r&&r.UNMASKED_RENDERER_WEBGL||7937)},[wa]:(e,t)=>{var r;let i=((r=e.luma)===null||r===void 0||(r=r.extensions)===null||r===void 0?void 0:r[Ma])||e.getExtension("EXT_texture_filter_anisotropic");return i?t(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1},[32883]:y,[35071]:y,[37447]:y,[36063]:(e,t)=>{if(!b(e)){let r=e.getExtension(Yi);return r?t(r.MAX_COLOR_ATTACHMENTS_WEBGL):0}},[35379]:y,[35374]:y,[35377]:y,[34852]:e=>{if(!b(e)){let t=e.getExtension(Yi);return t?t.MAX_DRAW_BUFFERS_WEBGL:0}},[36203]:e=>e.getExtension(zi)?2147483647:65535,[33001]:e=>e.getExtension(zi)?16777216:65535,[33e3]:e=>16777216,[37157]:y,[35373]:y,[35657]:y,[36183]:y,[37137]:y,[34045]:y,[35978]:y,[35979]:y,[35968]:y,[35376]:y,[35375]:y,[35659]:y,[37154]:y,[35371]:y,[35658]:y,[35076]:y,[35077]:y,[35380]:y};function qi(e,t,r){let i=ka[r],n=typeof i=="function"?i(e,t,r):i;return n!==void 0?n:t(r)}function Oe(e){if(!e.luma){let r={_polyfilled:!1,_extensions:{}};e.luma=r}return e.luma}var Wa="OES_vertex_array_object",Zi="ANGLE_instanced_arrays",Ha="WEBGL_draw_buffers",Xa="EXT_disjoint_timer_query",La="EXT_texture_filter_anisotropic",ja="VertexArray requires WebGL2 or OES_vertex_array_object extension";function Ka(e,t){return{webgl2:b(e),ext:e.getExtension(t)}}var Hr={[Wa]:{meta:{suffix:"OES"},createVertexArray:()=>{(0,Re.assert)(!1,ja)},deleteVertexArray:()=>{},bindVertexArray:()=>{},isVertexArray:()=>!1},[Zi]:{meta:{suffix:"ANGLE"},vertexAttribDivisor(e,t){(0,Re.assert)(t===0,"WebGL instanced rendering not supported")},drawElementsInstanced:()=>{},drawArraysInstanced:()=>{}},[Ha]:{meta:{suffix:"WEBGL"},drawBuffers:()=>{(0,Re.assert)(!1)}},[Xa]:{meta:{suffix:"EXT"},createQuery:()=>{(0,Re.assert)(!1)},deleteQuery:()=>{(0,Re.assert)(!1)},beginQuery:()=>{(0,Re.assert)(!1)},endQuery:()=>{},getQuery(e,t){return this.getQueryObject(e,t)},getQueryParameter(e,t){return this.getQueryObject(e,t)},getQueryObject:(e,t)=>{}}},vt={readBuffer:(e,t,r)=>{b(e)&&t(r)},getVertexAttrib:(e,t,r,i)=>{let{webgl2:n,ext:o}=Ka(e,Zi),s;switch(i){case 35069:s=n?void 0:!1;break;case 35070:s=!n&&!o?0:void 0;break;default:}return s!==void 0?s:t(r,i)},getProgramParameter:(e,t,r,i)=>{if(!b(e))switch(i){case 35967:return 35981;case 35971:return 0;case 35382:return 0;default:}return t(r,i)},getInternalformatParameter:(e,t,r,i,n)=>{if(!b(e))switch(n){case 32937:return new Int32Array([0]);default:}return e.getInternalformatParameter(r,i,n)},getTexParameter(e,t,r,i){switch(i){case 34046:let n=Oe(e),{_extensions:o}=n,s=o[La];i=s&&s.TEXTURE_MAX_ANISOTROPY_EXT||34046;break;default:}return t(r,i)},getParameter:qi,hint(e,t,r,i){return t(r,i)}};function Ji(e){let t=Oe(e);return t._polyfilled||(Li(e),za(e),Ya(e,Hr),qa(e,{target:t,target2:e}),t._polyfilled=!0),e}function za(e){let t=Oe(e),r=e.getSupportedExtensions()||[],i=["WEBGL_polygon_mode"];for(let n of r)if(!i.includes(n)){let o=e.getExtension(n);t._extensions[n]=o}}function Ya(e,t){let r=Oe(e);for(let i of Object.getOwnPropertyNames(t))i!=="overrides"&&$a(e,{extension:i,target:r,target2:e})}function $a(e,t){let{extension:r,target:i,target2:n}=t,o=Hr[r];(0,Qi.assert)(o);let{meta:s={}}=o,{suffix:a=""}=s,f=e.getExtension(r);for(let l of Object.keys(o)){let c=`${l}${a}`,u=null;l==="meta"||typeof e[l]=="function"||(f&&typeof f[c]=="function"?u=function(){return f[c](...arguments)}:typeof o[l]=="function"&&(u=o[l].bind(i))),u&&(i[l]=u,n[l]=u)}}function qa(e,t){let{target:r,target2:i}=t;Object.keys(vt).forEach(n=>{if(typeof vt[n]=="function"){let o=e[n]?e[n].bind(e):()=>{},s=vt[n].bind(null,e,o);r[n]=s,i[n]=s}})}var je=T(E(),1);var mt={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},J=(e,t,r)=>t?e.enable(r):e.disable(r),Gi=(e,t,r)=>e.hint(r,t),H=(e,t,r)=>e.pixelStorei(r,t),en=(e,t,r)=>{let i;return r===36006?i=b(e)?36009:36160:i=36008,e.bindFramebuffer(i,t)},Le=(e,t,r)=>{let n={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];e.bindBuffer(n,t)};function Xr(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var tn={[3042]:J,[32773]:(e,t)=>e.blendColor(...t),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(e,t)=>e.clearColor(...t),[3107]:(e,t)=>e.colorMask(...t),[2884]:J,[2885]:(e,t)=>e.cullFace(t),[2929]:J,[2931]:(e,t)=>e.clearDepth(t),[2932]:(e,t)=>e.depthFunc(t),[2928]:(e,t)=>e.depthRange(...t),[2930]:(e,t)=>e.depthMask(t),[3024]:J,[35723]:Gi,[35725]:(e,t)=>e.useProgram(t),[36007]:(e,t)=>e.bindRenderbuffer(36161,t),[36389]:(e,t)=>{var r,i;return(r=(i=e).bindTransformFeedback)===null||r===void 0?void 0:r.call(i,36386,t)},[34229]:(e,t)=>e.bindVertexArray(t),[36006]:en,[36010]:en,[34964]:Le,[36662]:Le,[36663]:Le,[35053]:Le,[35055]:Le,[2886]:(e,t)=>e.frontFace(t),[33170]:Gi,[2849]:(e,t)=>e.lineWidth(t),[32823]:J,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:J,[32926]:J,[32928]:J,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:J,[3088]:(e,t)=>e.scissor(...t),[2960]:J,[2961]:(e,t)=>e.clearStencil(t),[2968]:(e,t)=>e.stencilMaskSeparate(1028,t),[36005]:(e,t)=>e.stencilMaskSeparate(1029,t),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(e,t)=>e.viewport(...t),[3333]:H,[3317]:H,[37440]:H,[37441]:H,[37443]:H,[3330]:H,[3332]:H,[3331]:H,[3314]:H,[32878]:H,[3316]:H,[3315]:H,[32877]:H,framebuffer:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Xr(t)?t:[t,t];let[r,i]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{t=Xr(t)&&t.length===3?[...t,...t]:t;let[r,i,n,o,s,a]=t;e.stencilFuncSeparate(1028,r,i,n),e.stencilFuncSeparate(1029,o,s,a)},stencilOp:(e,t)=>{t=Xr(t)&&t.length===3?[...t,...t]:t;let[r,i,n,o,s,a]=t;e.stencilOpSeparate(1028,r,i,n),e.stencilOpSeparate(1029,o,s,a)},viewport:(e,t)=>e.viewport(...t)};function x(e,t,r){return t[e]!==void 0?t[e]:r[e]}var rn={blendEquation:(e,t,r)=>e.blendEquationSeparate(x(32777,t,r),x(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(x(32969,t,r),x(32968,t,r),x(32971,t,r),x(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(x(32824,t,r),x(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(x(32938,t,r),x(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,x(2962,t,r),x(2967,t,r),x(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,x(34816,t,r),x(36003,t,r),x(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,x(2964,t,r),x(2965,t,r),x(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,x(34817,t,r),x(34818,t,r),x(34819,t,r))},Lr={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({[35725]:t}),bindRenderbuffer:(e,t,r)=>e({[36007]:r}),bindTransformFeedback:(e,t,r)=>e({[36389]:r}),bindVertexArray:(e,t)=>e({[34229]:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({[36006]:r,[36010]:r});case 36009:return e({[36006]:r});case 36008:return e({[36010]:r});default:return null}},bindBuffer:(e,t,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[t];return i?e({[i]:r}):{valueChanged:!0}},blendColor:(e,t,r,i,n)=>e({[32773]:new Float32Array([t,r,i,n])}),blendEquation:(e,t)=>e({[32777]:t,[34877]:t}),blendEquationSeparate:(e,t,r)=>e({[32777]:t,[34877]:r}),blendFunc:(e,t,r)=>e({[32969]:t,[32968]:r,[32971]:t,[32970]:r}),blendFuncSeparate:(e,t,r,i,n)=>e({[32969]:t,[32968]:r,[32971]:i,[32970]:n}),clearColor:(e,t,r,i,n)=>e({[3106]:new Float32Array([t,r,i,n])}),clearDepth:(e,t)=>e({[2931]:t}),clearStencil:(e,t)=>e({[2961]:t}),colorMask:(e,t,r,i,n)=>e({[3107]:[t,r,i,n]}),cullFace:(e,t)=>e({[2885]:t}),depthFunc:(e,t)=>e({[2932]:t}),depthRange:(e,t,r)=>e({[2928]:new Float32Array([t,r])}),depthMask:(e,t)=>e({[2930]:t}),frontFace:(e,t)=>e({[2886]:t}),lineWidth:(e,t)=>e({[2849]:t}),polygonOffset:(e,t,r)=>e({[32824]:t,[10752]:r}),sampleCoverage:(e,t,r)=>e({[32938]:t,[32939]:r}),scissor:(e,t,r,i,n)=>e({[3088]:new Int32Array([t,r,i,n])}),stencilMask:(e,t)=>e({[2968]:t,[36005]:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,i)=>e({[2962]:t,[2967]:r,[2963]:i,[34816]:t,[36003]:r,[36004]:i}),stencilFuncSeparate:(e,t,r,i,n)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:i,[t===1028?2963:36004]:n}),stencilOp:(e,t,r,i)=>e({[2964]:t,[2965]:r,[2966]:i,[34817]:t,[34818]:r,[34819]:i}),stencilOpSeparate:(e,t,r,i,n)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:i,[t===1028?2966:34819]:n}),viewport:(e,t,r,i,n)=>e({[2978]:[t,r,i,n]})},G=(e,t)=>e.isEnabled(t),jr={[3042]:G,[2884]:G,[2929]:G,[3024]:G,[32823]:G,[32926]:G,[32928]:G,[3089]:G,[2960]:G,[35977]:G},nn=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function oe(e,t){let i=M.attach(e).gl;if(Za(t))return;let n={};for(let s in t){let a=Number(s),f=tn[s];f&&(typeof f=="string"?n[f]=!0:f(i,t[s],a))}let o=i.state&&i.state.cache;if(o)for(let s in n){let a=rn[s];a(i,t,o)}}function on(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mt,i=M.attach(e).gl;if(typeof t=="number"){let s=t,a=jr[s];return a?a(i,s):i.getParameter(s)}let n=Array.isArray(t)?t:Object.keys(t),o={};for(let s of n){let a=jr[s];o[s]=a?a(i,Number(s)):i.getParameter(Number(s))}return o}function Za(e){for(let t in e)return!1;return!0}function sn(e,t){if(e===t)return!0;let r=Array.isArray(e)||ArrayBuffer.isView(e),i=Array.isArray(t)||ArrayBuffer.isView(t);if(r&&i&&e.length===t.length){for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}var Kr=class{constructor(t){let{copyState:r=!1,log:i=()=>{}}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.gl=void 0,this.program=null,this.stateStack=[],this.enable=!0,this.cache=void 0,this.log=void 0,this.gl=t,this.cache=r?on(t):Object.assign({},mt),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.stateStack.push({})}pop(){(0,je.assert)(this.stateStack.length>0);let t=this.stateStack[this.stateStack.length-1];oe(this.gl,t),this.stateStack.pop()}_updateCache(t){let r=!1,i,n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let o in t){(0,je.assert)(o!==void 0);let s=t[o],a=this.cache[o];sn(s,a)||(r=!0,i=a,n&&!(o in n)&&(n[o]=a),this.cache[o]=s)}return{valueChanged:r,oldValue:i}}};function be(e){return e.state}function zr(e,t){let{enable:r=!0,copyState:i}=t;if((0,je.assert)(i!==void 0),!e.state){e.state=new Kr(e,{copyState:i}),Ja(e);for(let o in Lr){let s=Lr[o];Qa(e,o,s)}an(e,"getParameter"),an(e,"isEnabled")}let n=be(e);return n.enable=r,e}function _e(e){let t=be(e);t||(zr(e,{copyState:!1}),t=be(e)),t.push()}function se(e){let t=be(e);(0,je.assert)(t),t.pop()}function an(e,t){let r=e[t].bind(e);e[t]=function(n){if(n===void 0||nn.has(n))return r(n);let o=be(e);return n in o.cache||(o.cache[n]=r(n)),o.enable?o.cache[n]:r(n)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Qa(e,t,r){if(!e[t])return;let i=e[t].bind(e);e[t]=function(){let o=be(e);for(var s=arguments.length,a=new Array(s),f=0;f<s;f++)a[f]=arguments[f];let{valueChanged:l,oldValue:c}=r(o._updateCache,...a);return l&&i(...a),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function Ja(e){let t=e.useProgram.bind(e);e.useProgram=function(i){let n=be(e);n.program!==i&&(t(i),n.program=i)}}var Ga={webgl2:!0,webgl1:!0,powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function fn(e,t){t={...Ga,...t};let r=null,i=o=>r=o.statusMessage||r;e.addEventListener("webglcontextcreationerror",i,!1);let n=null;if(t.type==="webgl2"&&(t={...t,webgl1:!1}),t.type==="webgl1"&&(t={...t,webgl2:!1}),!n&&t.webgl2&&(n=e.getContext("webgl2",t)),!n&&t.webgl1&&(n=e.getContext("webgl",t)),e.removeEventListener("webglcontextcreationerror",i,!1),!n)throw new Error(`Failed to create ${t.webgl2&&!t.webgl1?"WebGL2":"WebGL"} context: ${r||"Unknown error"}`);if(t.onContextLost){let{onContextLost:o}=t;e.addEventListener("webglcontextlost",s=>o(s),!1)}if(t.onContextRestored){let{onContextRestored:o}=t;e.addEventListener("webglcontextrestored",s=>o(s),!1)}return n}function ln(e){let t=e.getParameter(7936),r=e.getParameter(7937),i=e.getExtension("WEBGL_debug_renderer_info"),n=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),s=n||t,a=o||r,f=e.getParameter(7938),l=cn(s,a),c=ef(s,a),u=tf(s,a),_="glsl",d=b(e)?300:100;return{type:b(e)?"webgl2":"webgl",gpu:l,gpuType:u,gpuBackend:c,vendor:s,renderer:a,version:f,shadingLanguage:_,shadingLanguageVersion:d}}function cn(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function ef(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function tf(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(cn(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function un(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=typeof window<"u"?window.navigator||{}:{},r=e.userAgent||t.userAgent||"",i=r.indexOf("MSIE ")!==-1,n=r.indexOf("Trident/")!==-1;return i||n}var qr=T(E(),1);function St(e){switch(e){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}var w="texture-compression-bc",v="texture-compression-astc",ee="texture-compression-etc2",rf="texture-compression-etc1-webgl",yt="texture-compression-pvrtc-webgl",Yr="texture-compression-atc-webgl",Ke="WEBGL_compressed_texture_s3tc",ze="WEBGL_compressed_texture_s3tc_srgb",xe="EXT_texture_compression_rgtc",Ye="EXT_texture_compression_bptc",nf="WEBGL_compressed_texture_etc",of="WEBGL_compressed_texture_astc",sf="WEBGL_compressed_texture_etc1",af="WEBGL_compressed_texture_pvrtc",ff="WEBGL_compressed_texture_atc",_n="EXT_sRGB",ae="EXT_texture_norm16",lf="WEBGL_color_buffer_float",cf="EXT_color_buffer_float",j=(e,t)=>e.getExtension(t),Ee=(e,t)=>t.every(r=>e.getExtension(r)),$r={"texture-blend-float-webgl1":e=>b(e)?!0:j(e,"EXT_float_blend"),"texture-formats-srgb-webgl1":e=>b(e)?!0:j(e,_n),"texture-formats-depth-webgl1":e=>b(e)?!0:j(e,"WEBGL_depth_texture"),"texture-formats-float32-webgl1":e=>b(e)?!0:j(e,"OES_texture_float"),"texture-formats-float16-webgl1":e=>b(e)?!0:j(e,"OES_texture_half_float"),"texture-formats-norm16-webgl":e=>b(e)?j(e,ae):!1,"texture-filter-linear-float32-webgl":e=>j(e,"OES_texture_float_linear"),"texture-filter-linear-float16-webgl":e=>j(e,"OES_texture_half_float_linear"),"texture-filter-anisotropic-webgl":e=>j(e,"EXT_texture_filter_anisotropic"),"texture-renderable-float32-webgl":e=>j(e,"EXT_color_buffer_float"),"texture-renderable-float16-webgl":e=>j(e,"EXT_color_buffer_half_float"),"texture-compression-bc":e=>Ee(e,[Ke,ze,xe,Ye]),"texture-compression-bc5-webgl":e=>Ee(e,[xe]),"texture-compression-etc2":e=>Ee(e,[nf]),"texture-compression-astc":e=>Ee(e,[of]),"texture-compression-etc1-webgl":e=>Ee(e,[sf]),"texture-compression-pvrtc-webgl":e=>Ee(e,[af]),"texture-compression-atc-webgl":e=>Ee(e,[ff])};function uf(e,t){var r;return((r=$r[t])===null||r===void 0?void 0:r.call($r,e))||!1}function dn(e){return Object.keys($r).filter(r=>uf(e,r))}var $e={"rgb8unorm-unsized":{gl:6407,gl1:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,gl1:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,renderbuffer:!0},r8snorm:{gl:36756,b:1,c:1},r8uint:{gl:33330,b:1,c:1,renderbuffer:!0},r8sint:{gl:33329,b:1,c:1,renderbuffer:!0},rg8unorm:{gl:33323,b:2,c:2,renderbuffer:!0},rg8snorm:{gl:36757,b:2,c:2},rg8uint:{gl:33336,b:2,c:2,renderbuffer:!0},rg8sint:{gl:33335,b:2,c:2,renderbuffer:!0},r16uint:{gl:33332,b:2,c:1,renderbuffer:!0},r16sint:{gl:33331,b:2,c:1,renderbuffer:!0},r16float:{gl:33325,b:2,c:1,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl",renderbuffer:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:"texture-formats-norm16-webgl",renderbuffer:!0,x:ae},"r16snorm-webgl":{gl:36760,b:2,c:1,f:"texture-formats-norm16-webgl",x:ae},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,gl1:6408,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,gl1:35906,b:4,c:4,gl1ext:_n,bpp:4},rgba8snorm:{gl:36759,b:4,c:4},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl",renderbuffer:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,f:"texture-formats-norm16-webgl",x:ae},"rg16snorm-webgl":{gl:36761,b:2,c:2,f:"texture-formats-norm16-webgl",x:ae},r32uint:{gl:33334,b:4,c:1,bpp:4,renderbuffer:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,renderbuffer:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl"},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl"},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:"texture-renderable-float32-webgl",renderbuffer:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,renderbuffer:!0},"rgb10a2unorm-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,renderbuffer:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:"texture-formats-norm16-webgl",x:ae},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:"texture-formats-norm16-webgl",x:ae},rg32uint:{gl:33340,b:8,c:2,renderbuffer:!0},rg32sint:{gl:33339,b:8,c:2,renderbuffer:!0},rg32float:{gl:33328,b:8,c:2,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",renderbuffer:!0},rgba16uint:{gl:36214,b:8,c:4,renderbuffer:!0},rgba16sint:{gl:36232,b:8,c:4,renderbuffer:!0},rgba16float:{gl:34842,gl1:6408,b:8,c:4,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl"},"rgba16unorm-webgl":{gl:32859,b:2,c:4,f:"texture-formats-norm16-webgl",renderbuffer:!0,x:ae},"rgba16snorm-webgl":{gl:36763,b:2,c:4,f:"texture-formats-norm16-webgl",x:ae},"rgb32float-webgl":{gl:34837,gl1:6407,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",gl2ext:cf,gl1ext:lf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,renderbuffer:!0},rgba32sint:{gl:36226,b:16,c:4,renderbuffer:!0},rgba32float:{gl:34836,b:16,c:4,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",renderbuffer:!0},stencil8:{gl:36168,gl1:36168,b:1,c:1,attachment:36128,renderbuffer:!0},depth16unorm:{gl:33189,gl1:33189,b:2,c:1,attachment:36096,renderbuffer:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096},depth32float:{gl:36012,b:4,c:1,attachment:36096,renderbuffer:!0},"depth24plus-stencil8":{gl:34041,gl1:34041,b:4,c:2,p:1,attachment:33306,renderbuffer:!0,depthTexture:!0},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,renderbuffer:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,renderbuffer:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Ke,f:w},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:ze,f:w},"bc1-rgba-unorm":{gl:33777,x:Ke,f:w},"bc1-rgba-unorm-srgb":{gl:35916,x:ze,f:w},"bc2-rgba-unorm":{gl:33778,x:Ke,f:w},"bc2-rgba-unorm-srgb":{gl:35918,x:ze,f:w},"bc3-rgba-unorm":{gl:33779,x:Ke,f:w},"bc3-rgba-unorm-srgb":{gl:35919,x:ze,f:w},"bc4-r-unorm":{gl:36283,x:xe,f:w},"bc4-r-snorm":{gl:36284,x:xe,f:w},"bc5-rg-unorm":{gl:36285,x:xe,f:w},"bc5-rg-snorm":{gl:36286,x:xe,f:w},"bc6h-rgb-ufloat":{gl:36495,x:Ye,f:w},"bc6h-rgb-float":{gl:36494,x:Ye,f:w},"bc7-rgba-unorm":{gl:36492,x:Ye,f:w},"bc7-rgba-unorm-srgb":{gl:36493,x:Ye,f:w},"etc2-rgb8unorm":{gl:37492,f:ee},"etc2-rgb8unorm-srgb":{gl:37494,f:ee},"etc2-rgb8a1unorm":{gl:37496,f:ee},"etc2-rgb8a1unorm-srgb":{gl:37497,f:ee},"etc2-rgba8unorm":{gl:37493,f:ee},"etc2-rgba8unorm-srgb":{gl:37495,f:ee},"eac-r11unorm":{gl:37488,f:ee},"eac-r11snorm":{gl:37489,f:ee},"eac-rg11unorm":{gl:37490,f:ee},"eac-rg11snorm":{gl:37491,f:ee},"astc-4x4-unorm":{gl:37808,f:v},"astc-4x4-unorm-srgb":{gl:37840,f:v},"astc-5x4-unorm":{gl:37809,f:v},"astc-5x4-unorm-srgb":{gl:37841,f:v},"astc-5x5-unorm":{gl:37810,f:v},"astc-5x5-unorm-srgb":{gl:37842,f:v},"astc-6x5-unorm":{gl:37811,f:v},"astc-6x5-unorm-srgb":{gl:37843,f:v},"astc-6x6-unorm":{gl:37812,f:v},"astc-6x6-unorm-srgb":{gl:37844,f:v},"astc-8x5-unorm":{gl:37813,f:v},"astc-8x5-unorm-srgb":{gl:37845,f:v},"astc-8x6-unorm":{gl:37814,f:v},"astc-8x6-unorm-srgb":{gl:37846,f:v},"astc-8x8-unorm":{gl:37815,f:v},"astc-8x8-unorm-srgb":{gl:37847,f:v},"astc-10x5-unorm":{gl:37819,f:v},"astc-10x5-unorm-srgb":{gl:37851,f:v},"astc-10x6-unorm":{gl:37817,f:v},"astc-10x6-unorm-srgb":{gl:37849,f:v},"astc-10x8-unorm":{gl:37818,f:v},"astc-10x8-unorm-srgb":{gl:37850,f:v},"astc-10x10-unorm":{gl:37819,f:v},"astc-10x10-unorm-srgb":{gl:37851,f:v},"astc-12x10-unorm":{gl:37820,f:v},"astc-12x10-unorm-srgb":{gl:37852,f:v},"astc-12x12-unorm":{gl:37821,f:v},"astc-12x12-unorm-srgb":{gl:37853,f:v},"pvrtc-rgb4unorm-webgl":{gl:35840,f:yt},"pvrtc-rgba4unorm-webgl":{gl:35842,f:yt},"pvrtc-rbg2unorm-webgl":{gl:35841,f:yt},"pvrtc-rgba2unorm-webgl":{gl:35843,f:yt},"etc1-rbg-unorm-webgl":{gl:36196,f:rf},"atc-rgb-unorm-webgl":{gl:35986,f:Yr},"atc-rgba-unorm-webgl":{gl:35986,f:Yr},"atc-rgbai-unorm-webgl":{gl:34798,f:Yr}},_f={[6403]:1,[36244]:1,[33319]:2,[33320]:2,[6407]:3,[36248]:3,[6408]:4,[36249]:4,[6402]:1,[34041]:1,[6406]:1,[6409]:1,[6410]:2},df={[5126]:4,[5125]:4,[5124]:4,[5123]:2,[5122]:2,[5131]:2,[5120]:1,[5121]:1};function qe(e,t){let r=Ze(t),i=$e[r];if(!i||(b(e)?i.gl===void 0:i.gl1===void 0))return!1;let n=i.x||b(e)&&i.gl2ext||i.gl1ext;return n?Boolean(e.getExtension(n)):!0}function pn(e,t){var r;return qe(e,t)&&((r=$e[t])===null||r===void 0?void 0:r.renderbuffer)}function Ze(e){if(typeof e=="string")return e;let t=Object.entries($e).find(r=>{let[,i]=r;return i.gl===e||i.gl1===e});if(!t)throw new Error(`Unknown texture format ${e}`);return t[0]}function Qe(e,t){let r=$e[e],i=t?r?.gl:r?.gl1;if(i===void 0)throw new Error(`Unsupported texture format ${e}`);return i}function hn(e,t){let r=Ze(t);if(!qe(e,r))return!1;try{if((0,qr.decodeTextureFormat)(r).signed)return!1}catch{return!1}return r.endsWith("32float")?Boolean(e.getExtension("OES_texture_float_linear")):r.endsWith("16float")?Boolean(e.getExtension("OES_texture_half_float_linear")):!0}function gn(e,t){let r=Ze(t);return!(!qe(e,r)||typeof r=="number")}function Pe(e,t){let r=Ze(e),i=Qe(r,t),n=(0,qr.decodeTextureFormat)(r);return{format:i,dataFormat:pf(n.format,n.integer,n.normalized,i),type:n.dataType?St(n.dataType):5121,compressed:n.compressed}}function Tn(e){let t=$e[e];if(!(t!=null&&t.attachment))throw new Error(`${e} is not a depth stencil format`);return t.attachment}function An(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6408,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:6408,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:5121,n=null,o=null;try{n=e.createTexture(),e.bindTexture(3553,n);let s=0,a=1,f=1,l=0,c=new Uint8Array([0,0,255,255]);e.texImage2D(3553,s,t,a,f,l,r,i,c),o=e.createFramebuffer(),e.bindFramebuffer(36160,o),e.framebufferTexture2D(36160,36064,3553,n,0);let u=e.checkFramebufferStatus(36160)===36053;return e.bindTexture(3553,null),u}finally{e.deleteTexture(n),e.deleteFramebuffer(o)}}function Je(e,t){let r=Ze(e),i=Pe(r,t),n=_f[i.dataFormat]||4,o=df[i.type]||1;return n*o}function pf(e,t,r,i){if(i===6408||i===6407)return i;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;default:return 6408}}function Rn(e){let t=hf(e);for(let r of dn(e))t.add(r);return t}function hf(e){e.getExtension("EXT_color_buffer_float"),e.getExtension("WEBGL_color_buffer_float"),e.getExtension("EXT_float_blend");let t=new Set;for(let r of Object.keys(bn))gf(e,r)&&t.add(r);return t}function gf(e,t){let r=bn[t];if(!r)return!1;let[i,n]=r||[],o=b(e)?n:i;if(typeof o=="boolean")return o;switch(t){case"texture-renderable-rgba32float-webgl":return b(e)?Boolean(e.getExtension(o)):An(e);case"glsl-derivatives":return Qr(e,o);case"glsl-frag-data":return Qr(e,o,{behavior:"require"});case"glsl-frag-depth":return Qr(e,o);default:return Boolean(e.getExtension(o))}}var Zr={};function Qr(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!un(r))return!0;if(t in Zr)return Zr[t];let i=r.behavior||"enable",n=`#extension GL_${t} : ${i}
|
|
71
|
-
void main(void) {}`,o=e.createShader(35633);if(!o)throw new Error("shader");e.shaderSource(o,n),e.compileShader(o);let s=e.getShaderParameter(o,35713);return e.deleteShader(o),Zr[t]=s,s}var bn={webgl:[!0,!0],webgl2:[!1,!0],"timer-query-webgl":["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"],"transform-feedback-webgl2":[!1,!0],"vertex-array-object-webgl1":["OES_vertex_array_object",!0],"instanced-rendering-webgl1":["ANGLE_instanced_arrays",!0],"multiple-render-targets-webgl1":["WEBGL_draw_buffers",!0],"index-uint32-webgl1":["OES_element_index_uint",!0],"blend-minmax-webgl1":["EXT_blend_minmax",!0],"texture-blend-float-webgl1":["EXT_float_blend","EXT_float_blend"],"texture-formats-srgb-webgl1":["EXT_sRGB",!0],"texture-formats-depth-webgl1":["WEBGL_depth_texture",!0],"texture-formats-float32-webgl1":["OES_texture_float",!0],"texture-formats-float16-webgl1":["OES_texture_half_float",!0],"texture-filter-linear-float32-webgl":["OES_texture_float_linear","OES_texture_float_linear"],"texture-filter-linear-float16-webgl":["OES_texture_half_float_linear","OES_texture_half_float_linear"],"texture-filter-anisotropic-webgl":["EXT_texture_filter_anisotropic","EXT_texture_filter_anisotropic"],"texture-renderable-rgba32float-webgl":["WEBGL_color_buffer_float","EXT_color_buffer_float"],"texture-renderable-float32-webgl":[!1,"EXT_color_buffer_float"],"texture-renderable-float16-webgl":["EXT_color_buffer_half_float","EXT_color_buffer_half_float"],"glsl-frag-data":["WEBGL_draw_buffers",!0],"glsl-frag-depth":["EXT_frag_depth",!0],"glsl-derivatives":["OES_standard_derivatives",!0],"glsl-texture-lod":["EXT_shader_texture_lod",!0]};function En(e){let t=Wr(e);return{maxTextureDimension1D:0,maxTextureDimension2D:e.getParameter(3379),maxTextureDimension3D:t?t.getParameter(32883):0,maxTextureArrayLayers:t?t.getParameter(35071):0,maxBindGroups:1,maxDynamicUniformBuffersPerPipelineLayout:0,maxDynamicStorageBuffersPerPipelineLayout:0,maxSampledTexturesPerShaderStage:e.getParameter(35660),maxSamplersPerShaderStage:e.getParameter(35661),maxStorageBuffersPerShaderStage:0,maxStorageTexturesPerShaderStage:0,maxUniformBuffersPerShaderStage:t?t.getParameter(35375):0,maxUniformBufferBindingSize:t?t.getParameter(35376):0,maxStorageBufferBindingSize:0,minUniformBufferOffsetAlignment:t?t.getParameter(35380):0,minStorageBufferOffsetAlignment:0,maxVertexBuffers:0,maxVertexAttributes:e.getParameter(34921),maxVertexBufferArrayStride:2048,maxInterStageShaderComponents:t?t.getParameter(35659):0,maxComputeWorkgroupStorageSize:0,maxComputeInvocationsPerWorkgroup:0,maxComputeWorkgroupSizeX:0,maxComputeWorkgroupSizeY:0,maxComputeWorkgroupSizeZ:0,maxComputeWorkgroupsPerDimension:0}}function vn(e){let t=Wr(e);function r(n){return e.getParameter(n)}function i(n,o){return t?t.getParameter(n):o||0}return{[33902]:r(33902),[33901]:r(33901),[3379]:r(3379),[34076]:r(34076),[34930]:r(34930),[35661]:r(35661),[35660]:r(35660),[34024]:r(34024),[36348]:r(36348),[34921]:r(34921),[36347]:r(36347),[36349]:r(36349),[3386]:r(3386),[34047]:r(34047),[32883]:i(32883),[35071]:i(35071),[37447]:i(37447),[36063]:i(36063),[35379]:i(35379),[35374]:i(35374),[35377]:i(35377),[34852]:i(34852),[36203]:i(36203),[33001]:i(33001),[33e3]:i(33e3),[37157]:i(37157),[35373]:i(35373),[35657]:i(35657),[36183]:i(36183),[37137]:i(37137),[34045]:i(34045),[35978]:i(35978),[35979]:i(35979),[35968]:i(35968),[35376]:i(35376),[35375]:i(35375),[35659]:i(35659),[37154]:i(37154),[35371]:i(35371),[35658]:i(35658),[35076]:i(35076),[35077]:i(35077),[35380]:i(35380)}}var Cn=T(E(),1);var Nt=T(E(),1);var F=T(E(),1);function P(e,t,r){let n=M.attach(e).gl;if(Tf(t))return r(e);let{nocatch:o=!0}=t;_e(n),oe(n,t);let s;if(o)s=r(n),se(n);else try{s=r(n)}finally{se(n)}return s}function Tf(e){for(let t in e)return!1;return!0}var Pt=T(E(),1);function Sn(e,t,r,i){if((0,Pt.isObjectEmpty)(t))return i(e);_e(e.gl);try{return Af(e,t),oe(e,r),i(e)}finally{se(e.gl)}}function Af(e,t){let r=M.attach(e),{gl:i}=r;if(t.cullMode)switch(t.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(t.frontFace&&i.frontFace(Ge("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.depthBias!==void 0&&i.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0),t.depthWriteEnabled!==void 0&&i.depthMask(bf("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(xt("depthCompare",t.depthCompare))),t.stencilWriteMask){let n=t.stencilWriteMask;i.stencilMaskSeparate(1028,n),i.stencilMaskSeparate(1029,n)}if(t.stencilReadMask&&Pt.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let n=t.stencilReadMask||4294967295,o=xt("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,o,0,n),i.stencilFuncSeparate(1029,o,0,n)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let n=Jr("stencilPassOperation",t.stencilPassOperation),o=Jr("stencilFailOperation",t.stencilFailOperation),s=Jr("stencilDepthFailOperation",t.stencilDepthFailOperation);i.stencilOpSeparate(1028,o,s,n),i.stencilOpSeparate(1029,o,s,n)}if(t.blendColorOperation||t.blendAlphaOperation){i.enable(3042);let n=mn("blendColorOperation",t.blendColorOperation||"add"),o=mn("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(n,o);let s=Ot("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=Ot("blendColorDstFactor",t.blendColorDstFactor||"zero"),f=Ot("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=Ot("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(s,a,f,l)}}function xt(e,t){return Ge(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Jr(e,t){return Ge(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function mn(e,t){return Ge(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Ot(e,t){return Ge(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773})}function Rf(e,t){return`Illegal parameter ${t} for ${e}`}function Ge(e,t,r){if(!(t in r))throw new Error(Rf(e,t));return r[t]}function bf(e,t){return t}function Ft(e){let t={};return e.addressModeU&&(t[10242]=Gr(e.addressModeU)),e.addressModeV&&(t[10243]=Gr(e.addressModeV)),e.addressModeW&&(t[32882]=Gr(e.addressModeW)),e.magFilter&&(t[10240]=On(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=Ef(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=xt("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function yn(e){let t={...e};return e[10241]!==9728&&(t[10241]=9729),t[10242]=33071,t[10243]=33071,t}function Gr(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function On(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function Ef(e,t){if(!t)return On(e);switch(e){case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var K=T(E(),1),vf=10,V=class extends K.Buffer{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t,r),this.device=void 0,this.gl=void 0,this.gl2=void 0,this.handle=void 0,this.glTarget=void 0,this.glUsage=void 0,this.glIndexType=5123,this.byteLength=void 0,this.bytesUsed=void 0,this.debugData=null,this.device=t,this.gl=this.device.gl,this.gl2=this.device.gl2;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),t.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=mf(this.props.usage),this.glUsage=Sf(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,this.debugData=null,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.byteLength+r;(0,K.assert)(ArrayBuffer.isView(t));let n=this._getWriteTarget();return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.glUsage),this.gl.bufferSubData(n,r,t),this.gl.bindBuffer(n,null),this.debugData=t.slice(0,vf),this.bytesUsed=i,this.byteLength=i,this.trackAllocatedMemory(i),this}_initWithByteLength(t){(0,K.assert)(t>=0);let r=t;t===0&&(r=new Float32Array(0));let i=this._getWriteTarget();return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.debugData=null,this.bytesUsed=t,this.byteLength=t,this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=0,n=void 0,o=this.device.isWebGL2?36663:this.glTarget;this.gl.bindBuffer(o,this.handle),i!==0||n!==void 0?(this.device.assertWebGL2(),this.gl2.bufferSubData(o,r,t,i,n)):this.gl.bufferSubData(o,r,t),this.gl.bindBuffer(o,null)}async readAsync(){var t;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,i=arguments.length>1?arguments[1]:void 0;this.device.assertWebGL2(),i=(t=i)!==null&&t!==void 0?t:this.byteLength;let n=new Uint8Array(i),o=0;return this.gl.bindBuffer(36662,this.handle),this.gl2.getBufferSubData(36662,r,n,o,i),this.gl.bindBuffer(36662,null),n}_invalidateDebugData(){this.debugData=null}_getWriteTarget(){return this.glTarget}_getReadTarget(){return this.glTarget}};function mf(e){return e&K.Buffer.INDEX?34963:e&K.Buffer.VERTEX?34962:e&K.Buffer.UNIFORM?35345:34962}function Sf(e){return e&K.Buffer.INDEX||e&K.Buffer.VERTEX?35044:e&K.Buffer.UNIFORM?35048:35044}var xn=T(E(),1);var ve=class extends xn.Sampler{constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.parameters=void 0,this.device=t,this.parameters=Ft(r),this.device.isWebGL2&&(this.handle=this.handle||this.device.gl2.createSampler(),this._setSamplerParameters(this.parameters))}destroy(){this.handle&&(this.device.gl2.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(let[r,i]of Object.entries(t)){let n=Number(r);switch(n){case 33082:case 33083:this.device.gl2.samplerParameterf(this.handle,n,i);break;default:this.device.gl2.samplerParameteri(this.handle,n,i);break}}}};var yf={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},N=class extends F.Texture{constructor(t,r){var i;super(t,{...yf,format:"rgba8unorm",...r}),this.MAX_ATTRIBUTES=void 0,this.device=void 0,this.gl=void 0,this.gl2=void 0,this.handle=void 0,this.sampler=void 0,this.glFormat=void 0,this.type=void 0,this.dataFormat=void 0,this.mipmaps=void 0,this.target=void 0,this.textureUnit=void 0,this.loaded=!1,this._video=void 0,this.device=t,this.gl=this.device.gl,this.gl2=this.device.gl2,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=Of(this.props),this.loaded=!1,typeof((i=this.props)===null||i===void 0?void 0:i.data)=="string"&&Object.assign(this.props,{data:(0,F.loadImage)(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}initialize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.props.dimension==="cube")return this.initializeCube(t);let r=t.data;if(r instanceof Promise)return r.then(h=>this.initialize(Object.assign({},t,{pixels:h,data:h}))),this;let i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(i&&r.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,r.addEventListener("loadeddata",()=>this.initialize(t)),this;let{parameters:n={}}=t,{pixels:o=null,pixelStore:s={},textureUnit:a=void 0}=t;r||(r=o);let{width:f,height:l,dataFormat:c,type:u,compressed:_=!1,mipmaps:d=!0}=t,{depth:p=0}=t,g=Qe(t.format,this.device.isWebGL2);return{width:f,height:l,compressed:_,dataFormat:c,type:u}=this._deduceParameters({format:t.format,type:u,dataFormat:c,compressed:_,data:r,width:f,height:l}),this.width=f,this.height=l,this.glFormat=g,this.type=u,this.dataFormat=c,this.textureUnit=a,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),d&&this.device.isWebGL1&&It(this.width,this.height)&&(F.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaps`)(),d=!1),this.mipmaps=d,this.setImageData({data:r,width:f,height:l,depth:p,format:g,type:u,dataFormat:c,parameters:s,compressed:_}),this.setSampler(t.sampler),this._setSamplerParameters(n),d&&this.generateMipmap(),i&&(this._video={video:r,parameters:n,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(t){let{mipmaps:r=!0,parameters:i={}}=t;return this.setCubeMapImageData(t).then(()=>{this.loaded=!0,r&&this.generateMipmap(t),this.setSampler(t.sampler),this._setSamplerParameters(i)}),this}setSampler(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r;t instanceof ve?(this.sampler=t,r=t.props):(this.sampler=new ve(this.device,t),r=t);let i=Ft(r);return this._setSamplerParameters(i),this}resize(t){let{height:r,width:i,mipmaps:n=!1}=t;return i!==this.width||r!==this.height?this.initialize({width:i,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:n}):this}update(){if(this._video){let{video:t,parameters:r,lastTime:i}=this._video;if(i===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}generateMipmap(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.device.isWebGL1&&It(this.width,this.height)?(F.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaping`)(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),P(this.gl,t,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this)}setImageData(t){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(t);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:i=null,level:n=0,glFormat:o=this.glFormat,offset:s=0,parameters:a={}}=t,{data:f=null,type:l=this.type,width:c=this.width,height:u=this.height,dataFormat:_=this.dataFormat,compressed:d=!1}=t;f||(f=i),{type:l,dataFormat:_,compressed:d,width:c,height:u}=this._deduceParameters({format:this.props.format,type:l,dataFormat:_,compressed:d,data:f,width:c,height:u});let{gl:p}=this;p.bindTexture(this.target,this.handle);let g=null;({data:f,dataType:g}=this._getDataType({data:f,compressed:d}));let h;if(P(this.gl,a,()=>{switch(g){case"null":p.texImage2D(r,n,o,c,u,0,_,l,f);break;case"typed-array":p.texImage2D(r,n,o,c,u,0,_,l,f,s);break;case"buffer":h=this.device.assertWebGL2(),h.bindBuffer(35052,f.handle||f),h.texImage2D(r,n,o,c,u,0,_,l,s),h.bindBuffer(35052,null);break;case"browser-object":this.device.isWebGL2?p.texImage2D(r,n,o,c,u,0,_,l,f):p.texImage2D(r,n,o,_,l,f);break;case"compressed":for(let[R,A]of f.entries())p.compressedTexImage2D(r,R,A.format,A.width,A.height,0,A.data);break;default:(0,F.assert)(!1,"Unknown image data type")}}),f&&f.byteLength)this.trackAllocatedMemory(f.byteLength,"Texture");else{let R=Je(this.props.format,this.device.isWebGL2);this.trackAllocatedMemory(this.width*this.height*R,"Texture")}return this.loaded=!0,this}setSubImageData(t){let{target:r=this.target,pixels:i=null,data:n=null,x:o=0,y:s=0,width:a=this.width,height:f=this.height,level:l=0,glFormat:c=this.glFormat,type:u=this.type,dataFormat:_=this.dataFormat,compressed:d=!1,offset:p=0,parameters:g={}}=t;if({type:u,dataFormat:_,compressed:d,width:a,height:f}=this._deduceParameters({format:this.props.format,type:u,dataFormat:_,compressed:d,data:n,width:a,height:f}),(0,F.assert)(this.depth===1,"texSubImage not supported for 3D textures"),n||(n=i),n&&n.data){let h=n;n=h.data,a=h.shape[0],f=h.shape[1]}n instanceof V&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),P(this.gl,g,()=>{if(d)this.gl.compressedTexSubImage2D(r,l,o,s,a,f,c,n);else if(n===null)this.gl.texSubImage2D(r,l,o,s,a,f,_,u,null);else if(ArrayBuffer.isView(n))this.gl.texSubImage2D(r,l,o,s,a,f,_,u,n,p);else if(typeof WebGLBuffer<"u"&&n instanceof WebGLBuffer){let h=this.device.assertWebGL2();h.bindBuffer(35052,n),h.texSubImage2D(r,l,o,s,a,f,_,u,p),h.bindBuffer(35052,null)}else this.device.isWebGL2?this.device.assertWebGL2().texSubImage2D(r,l,o,s,a,f,_,u,n):this.gl.texSubImage2D(r,l,o,s,_,u,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return F.log.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.textureUnit,{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,this.handle),t}unbind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.textureUnit,{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,null),t}_getDataType(t){let{data:r,compressed:i=!1}=t;return i?{data:r,dataType:"compressed"}:r===null?{data:r,dataType:"null"}:ArrayBuffer.isView(r)?{data:r,dataType:"typed-array"}:r instanceof V?{data:r.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&r instanceof WebGLBuffer?{data:r,dataType:"buffer"}:{data:r,dataType:"browser-object"}}_deduceParameters(t){let{format:r,data:i}=t,{width:n,height:o,dataFormat:s,type:a,compressed:f}=t,l=Pe(r,this.device.isWebGL2);return s=s||l.dataFormat,a=a||l.type,f=f||l.compressed,{width:n,height:o}=this._deduceImageSize(i,n,o),{dataFormat:s,type:a,compressed:f,width:n,height:o,format:r,data:i}}_deduceImageSize(t,r,i){let n;return typeof ImageData<"u"&&t instanceof ImageData?n={width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?n={width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?n={width:t.width,height:t.height}:typeof ImageBitmap<"u"&&t instanceof ImageBitmap?n={width:t.width,height:t.height}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?n={width:t.videoWidth,height:t.videoHeight}:t?n={width:r,height:i}:n={width:r>=0?r:1,height:i>=0?i:1},(0,F.assert)(n,"Could not deduced texture size"),(0,F.assert)(r===void 0||n.width===r,"Deduced texture width does not match supplied width"),(0,F.assert)(i===void 0||n.height===i,"Deduced texture height does not match supplied height"),n}async setCubeMapImageData(t){let{gl:r}=this,{width:i,height:n,pixels:o,data:s,format:a=6408,type:f=5121}=t,l=o||s,c=await Promise.all(N.FACES.map(u=>{let _=l[u];return Promise.all(Array.isArray(_)?_:[_])}));this.bind(),N.FACES.forEach((u,_)=>{c[_].length>1&&this.props.mipmaps!==!1&&F.log.warn(`${this.id} has mipmap and multiple LODs.`)(),c[_].forEach((d,p)=>{i&&n?r.texImage2D(u,p,a,i,n,0,a,f,d):r.texImage2D(u,p,a,a,f,d)})}),this.unbind()}setImageDataForFace(t){let{face:r,width:i,height:n,pixels:o,data:s,format:a=6408,type:f=5121}=t,{gl:l}=this,c=o||s;return this.bind(),c instanceof Promise?c.then(u=>this.setImageDataForFace(Object.assign({},t,{face:r,data:u,pixels:u}))):this.width||this.height?l.texImage2D(r,0,a,i,n,0,a,f,c):l.texImage2D(r,0,a,a,f,c),this}setImageData3D(t){let{level:r=0,dataFormat:i,format:n,type:o,width:s,height:a,depth:f=1,offset:l=0,data:c,parameters:u={}}=t;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let _=Pe(n,this.device.isWebGL2);if(P(this.gl,u,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,r,_.format,s,a,f,0,_.dataFormat,_.type,c),c instanceof V&&(this.gl.bindBuffer(35052,c.handle),this.gl.texImage3D(this.target,r,i,s,a,f,0,n,o,l))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let d=Je(this.props.format,this.device.isWebGL2);this.trackAllocatedMemory(this.width*this.height*this.depth*d,"Texture")}return this.loaded=!0,this}_setSamplerParameters(t){if(this.device.isWebGL1&&It(this.width,this.height)&&(t=yn(t)),!(0,F.isObjectEmpty)(t)){xf(t),this.gl.bindTexture(this.target,this.handle);for(let[r,i]of Object.entries(t)){let n=Number(r),o=i;switch(n){case 33082:case 33083:this.gl.texParameterf(this.target,n,o);break;default:this.gl.texParameteri(this.target,n,o);break}}this.gl.bindTexture(this.target,null)}}_getWebGL1NPOTParameterOverride(t,r){if(this.device.isWebGL1&&It(this.width,this.height))switch(t){case 10241:if(r!==9729&&r!==9728)return 9729;break;case 10242:case 10243:return 33071;default:break}return r}};N.FACES=[34069,34070,34071,34072,34073,34074];function Of(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(e.dimension)}}function It(e,t){return!e||!t?!1:!(0,F.isPowerOfTwo)(e)||!(0,F.isPowerOfTwo)(t)}function xf(e){F.log.log(1,"texture sampler parameters",e)()}var In=T(E(),1);var fe=T(E(),1);var Pn=T(E(),1);function Ct(e,t){if(typeof t!="string")return t;let r=Number(t);if(!isNaN(r))return r;t=t.replace(/^.*\./,"");let i=e[t];return(0,Pn.assert)(i!==void 0,`Accessing undefined constant GL.${t}`),i}var Fe="Resource subclass must define virtual methods",Mt=class extends fe.Resource{constructor(t,r,i){super(t,r,i),this.device=void 0,this.gl=void 0,this.gl2=void 0,this._handle=void 0,this._bound=!1,this.byteLength=0,this.device=M.attach(t);let n=this.device.gl;Ki(n);let{id:o}=r||{};this.gl=n,this.gl2=n,this.id=o||(0,fe.uid)(this.constructor.name),this._handle=r?.handle,this._handle===void 0&&(this._handle=this._createHandle()),this.byteLength=0}toString(){return`${this.constructor.name}(${this.id})`}get handle(){return this._handle}delete(){let{deleteChildren:t=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,r&&t&&r.filter(Boolean).forEach(i=>i.destroy()),this}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.handle;if(typeof t!="function")return this._bindHandle(t),this;let r;return this._bound?r=t():(this._bindHandle(this.handle),this._bound=!0,r=t(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}getParameter(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=Ct(this.gl,t),(0,fe.assert)(t);let n=(this.constructor.PARAMETERS||{})[t];if(n){let o=b(this.gl);if(!((!("webgl2"in n)||o)&&(!("extension"in n)||this.gl.getExtension(n.extension)))){let a=n.webgl1,f="webgl2"in n?n.webgl2:n.webgl1;return o?f:a}}return this._getParameter(t,r)}getParameters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{parameters:r,keys:i}=t,n=this.constructor.PARAMETERS||{},o=b(this.gl),s={},a=r||Object.keys(n);for(let f of a){let l=n[f];if(l&&(!("webgl2"in l)||o)&&(!("extension"in l)||this.gl.getExtension(l.extension))){let u=i?this.device.getGLKey(f):f;s[u]=this.getParameter(f,t),i&&l.type==="GLenum"&&(s[u]=this.device.getGLKey(s[u]))}}return s}setParameter(t,r){t=Ct(this.gl,t),(0,fe.assert)(t);let n=(this.constructor.PARAMETERS||{})[t];if(n){let o=b(this.gl);if(!((!("webgl2"in n)||o)&&(!("extension"in n)||this.gl.getExtension(n.extension))))throw new Error("Parameter not available on this platform");n.type==="GLenum"&&(r=Ct(r))}return this._setParameter(t,r),this}setParameters(t){for(let r in t)this.setParameter(r,t[r]);return this}stubRemovedMethods(t,r,i){return(0,fe.stubRemovedMethods)(this,t,r,i)}initialize(t){}_createHandle(){throw new Error(Fe)}_deleteHandle(){throw new Error(Fe)}_bindHandle(t){throw new Error(Fe)}_getOptsFromHandle(){throw new Error(Fe)}_getParameter(t,r){throw new Error(Fe)}_setParameter(t,r){throw new Error(Fe)}};var Fn;Fn=Symbol.toStringTag;var z=class extends Mt{get[Fn](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}static isTextureFormatSupported(t,r){return pn(t.gl,r)}constructor(t,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(t,r,z.defaultProps),this.glFormat=void 0,this.glFormat=Qe(this.props.format,t.isWebGL2),this._initialize(this.props)}resize(t){(t.width!==this.width||t.height!==this.height)&&(Object.assign(this.props,{...t,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(t){let{format:r,width:i,height:n,samples:o}=t;(0,In.assert)(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),o!==0&&this.device.isWebGL2?this.gl2.renderbufferStorageMultisample(36161,o,this.glFormat,i,n):this.gl.renderbufferStorage(36161,this.glFormat,i,n),this.gl.bindRenderbuffer(36161,null),this.trackAllocatedMemory(i*n*(o||1)*Je(this.glFormat,this.device.isWebGL2))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(t){this.gl.bindRenderbuffer(36161,t)}};z.defaultProps={id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0};var te=class extends Nt.Framebuffer{get texture(){return this.colorAttachments[0]}constructor(t,r){super(t,r),this.device=void 0,this.gl=void 0,this.handle=void 0;let i=r.handle===null;if(this.device=t,this.gl=t.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){t.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(36160,this.handle);for(let n=0;n<this.colorAttachments.length;++n){let o=this.colorAttachments[n],s=36064+n;o&&this._attachOne(s,o)}this.depthStencilAttachment&&this._attachOne(Tn(this.depthStencilAttachment.format),this.depthStencilAttachment),this.gl.bindFramebuffer(36160,null)}r.check!==!1&&this._checkStatus()}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}_checkStatus(){let{gl:t}=this,r=t.bindFramebuffer(36160,this.handle),i=t.checkFramebufferStatus(36160);if(t.bindFramebuffer(36160,r||null),i!==36053)throw new Error(`Framebuffer ${Ff(i)}`)}createDepthStencilTexture(t){return new z(this.device,{id:`${this.id}-depth-stencil`,format:t,width:this.width,height:this.height})}resizeAttachments(t,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;t===void 0&&(t=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let i of this.colorAttachments)i.resize({width:t,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.resize({width:t,height:r}),this}_attachOne(t,r){if(r instanceof z)return this._attachWEBGLRenderbuffer(t,r),r;if(Array.isArray(r)){let[i,n=0,o=0]=r;return this._attachTexture(t,i,n,o),i}else if(r instanceof N)return this._attachTexture(t,r,0,0),r;throw new Error("attach")}_attachWEBGLRenderbuffer(t,r){this.gl.framebufferRenderbuffer(36160,t,36161,r.handle)}_attachTexture(t,r,i,n){let{gl:o,gl2:s}=this.device;switch(o.bindTexture(r.target,r.handle),r.target){case 35866:case 32879:this.device.assertWebGL2(),s?.framebufferTextureLayer(36160,t,r.target,n,i);break;case 34067:let a=Pf(i);o.framebufferTexture2D(36160,t,a,r.handle,n);break;case 3553:o.framebufferTexture2D(36160,t,3553,r.handle,n);break;default:(0,Nt.assert)(!1,"Illegal texture type")}o.bindTexture(r.target,null)}};function Pf(e){return e<34069?e+34069:e}function Ff(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}var Bt=class extends Cn.CanvasContext{constructor(t,r){super(r),this.device=void 0,this.presentationSize=void 0,this._framebuffer=null,this.device=t,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new te(this.device,{handle:null}),this._framebuffer}update(){let t=this.getPixelSize();(t[0]!==this.presentationSize[0]||t[1]!==this.presentationSize[1])&&(this.presentationSize=t)}resize(t){if(this.canvas){let i=this.getDevicePixelRatio(t?.useDevicePixels);this.setDevicePixelRatio(i,t);return}let r=this.device.gl.getExtension("STACKGL_resize_drawingbuffer");r&&t&&"width"in t&&"height"in t&&r.resize(t.width,t.height)}commit(){}};var re=T(E(),1),If={spector:re.log.get("spector")||re.log.get("inspect")},Cf="https://spectorcdn.babylonjs.com/spector.bundle.js",Mf=1,k=null,Mn=!1;async function Nn(e){if(!globalThis.SPECTOR)try{await(0,re.loadScript)(Cf)}catch(t){re.log.warn(String(t))}}function Bn(e){var t,r;if(e={...If,...e},!((t=e)!==null&&t!==void 0&&t.spector)||(!k&&globalThis.SPECTOR&&(re.log.probe(Mf,"SPECTOR found and initialized")(),k=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=k)),!k))return null;if(!Mn){var i,n;Mn=!0,k.spyCanvases(),(i=k)===null||i===void 0||i.onCaptureStarted.add(a=>re.log.info("Spector capture started:",a)()),(n=k)===null||n===void 0||n.onCapture.add(a=>{var f,l,c;re.log.info("Spector capture complete:",a)(),(f=k)===null||f===void 0||f.getResultUI(),(l=k)===null||l===void 0||l.resultView.display(),(c=k)===null||c===void 0||c.resultView.addCapture(a)})}if((r=e)!==null&&r!==void 0&&r.canvas){var o,s;if(typeof e.spector=="string"&&e.spector!==e.canvas.id)return k;(o=k)===null||o===void 0||o.startCapture((s=e)===null||s===void 0?void 0:s.canvas,500),new Promise(a=>setTimeout(a,2e3)).then(a=>{var f;re.log.info("Spector capture stopped after 2 seconds")(),(f=k)===null||f===void 0||f.stopCapture()})}return k}var de=T(E(),1);var me=function(e){return e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e}(me||{});var Nf="https://unpkg.com/webgl-debug@2.0.1/index.js";function Dn(e){return e.luma=e.luma||{},e.luma}async function wn(){L()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await(0,de.loadScript)(Nf))}function Un(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e?t.debug?Df(e,t):Bf(e):null}function Bf(e){let t=Dn(e);return t.realContext?t.realContext:e}function Df(e,t){if(!globalThis.WebGLDebugUtils)return de.log.warn("webgl-debug not loaded")(),e;let r=Dn(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...me,...e});let i=globalThis.WebGLDebugUtils.makeDebugContext(e,wf.bind(null,t),Uf.bind(null,t));for(let s in me)!(s in i)&&typeof me[s]=="number"&&(i[s]=me[s]);class n{}Object.setPrototypeOf(i,Object.getPrototypeOf(e)),Object.setPrototypeOf(n,i);let o=Object.create(n);return r.realContext=e,r.debugContext=o,o.debug=!0,o}function ei(e,t){t=Array.from(t).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function wf(e,t,r,i){i=Array.from(i).map(f=>f===void 0?"undefined":f);let n=globalThis.WebGLDebugUtils.glEnumToString(t),o=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),s=e.webgl2?"gl2":"gl1",a=`${n} in ${s}.${r}(${o})`;de.log.error(a)();debugger;if(e.throwOnError)throw new Error(a)}function Uf(e,t,r){let i="";if(de.log.level>=1&&(i=ei(t,r),de.log.log(1,i)()),e.break&&e.break.length>0&&(i=i||ei(t,r),e.break.every(o=>i.indexOf(o)!==-1)))debugger;for(let n of r)if(n===void 0){if(i=i||ei(t,r),e.throwOnError)throw new Error(`Undefined argument: ${i}`);de.log.error(`Undefined argument: ${i}`)();debugger}}var Wn=T(E(),1);function kn(e){let t=e.split(/\r?\n/),r=[];for(let i of t){if(i.length<=1)continue;let n=i.split(":");if(n.length===2){let[u,_]=n;r.push({message:_.trim(),type:Vn(u),lineNum:0,linePos:0});continue}let[o,s,a,...f]=n,l=parseInt(a,10);isNaN(l)&&(l=0);let c=parseInt(s,10);isNaN(c)&&(c=0),r.push({message:f.join(":").trim(),type:Vn(o),lineNum:l,linePos:c})}return r}function Vn(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var Dt=class extends Wn.Shader{constructor(t,r){switch(super(t,r),this.device=void 0,this.handle=void 0,this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return this.getCompilationInfoSync()}getCompilationInfoSync(){let t=this.device.gl.getShaderInfoLog(this.handle);return kn(t)}_compile(t){t=(n=>n.startsWith("#version ")?n:`#version 100
|
|
72
|
-
${n}`)(t);let{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),this.compilationStatus=i.getShaderParameter(this.handle,35713)?"success":"error",this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}};var Hn=T(E(),1);var Vf=256,kf=1024,Wf=16384,ti=6144,wt=class extends Hn.RenderPass{constructor(t,r){super(t,r),this.device=void 0,this.glParameters=void 0,this.device=t,_e(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){se(this.device.gl),this.props.framebuffer&&oe(this.device,{framebuffer:null})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),r.scissorTest=Boolean(t.scissorRect),t.scissorRect&&(r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=t.stencilReference),this.glParameters=r,oe(this.device,r)}clear(){let t={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=Wf,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=Vf,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=kf,t.clearStencil=this.props.clearStencil),r!==0&&P(this.device,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0,0,0];P(this.device.gl2,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl2.clearBufferiv(ti,t,r);break;case Uint32Array:this.device.gl2.clearBufferuiv(ti,t,r);break;case Float32Array:default:this.device.gl2.clearBufferfv(ti,t,r);break}})}};var U=T(E(),1),Qn=T(E(),1);var Ut=T(E(),1);var Hf="Failed to deduce GL constant from typed array";function Xn(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(Hf)}}function et(e,t){let{clamped:r=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var Xf={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},Lf={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},pe=class{static getBytesPerElement(t){return et(t.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(t){return(0,Ut.assert)(t.size),et(t.type||5126).BYTES_PER_ELEMENT*t.size}static resolve(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return new pe(Xf,...r)}constructor(){this.offset=void 0,this.stride=void 0,this.type=void 0,this.size=void 0,this.divisor=void 0,this.normalized=void 0,this.integer=void 0,this.buffer=void 0,this.index=void 0;for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach(n=>this._assign(n)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return pe.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return pe.getBytesPerVertex(this)}_assign(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return t=(0,Ut.checkProps)("Accessor",t,Lf),t.type!==void 0&&(this.type=t.type,(t.type===5124||t.type===5125)&&(this.integer=!0)),t.size!==void 0&&(this.size=t.size),t.offset!==void 0&&(this.offset=t.offset),t.stride!==void 0&&(this.stride=t.stride),t.normalize!==void 0&&(this.normalized=t.normalize),t.normalized!==void 0&&(this.normalized=t.normalized),t.integer!==void 0&&(this.integer=t.integer),t.divisor!==void 0&&(this.divisor=t.divisor),t.buffer!==void 0&&(this.buffer=t.buffer),t.index!==void 0&&(typeof t.index=="boolean"?this.index=t.index?1:0:this.index=t.index),t.instanced!==void 0&&(this.divisor=t.instanced?1:0),t.isInstanced!==void 0&&(this.divisor=t.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function Ln(e){return jf.includes(e)}var jf=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],jn={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2<f32>","float32x2"],[35665]:[5126,3,"vec3","vec3<f32>","float32x3"],[35666]:[5126,4,"vec4","vec4<f32>","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2<i32>","sint32x2"],[35668]:[5124,3,"ivec3","vec3<i32>","sint32x3"],[35669]:[5124,4,"ivec4","vec4<i32>","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2<u32>","uint32x2"],[36295]:[5125,3,"uvec3","vec3<u32>","uint32x3"],[36296]:[5125,4,"uvec4","vec4<u32>","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2<f32>","float32x2"],[35672]:[5126,3,"bvec3","vec3<f32>","float32x3"],[35673]:[5126,4,"bvec4","vec4<f32>","float32x4"],[35674]:[5126,8,"mat2","mat2x2<f32>"],[35685]:[5126,8,"mat2x3","mat2x3<f32>"],[35686]:[5126,8,"mat2x4","mat2x4<f32>"],[35687]:[5126,12,"mat3x2","mat3x2<f32>"],[35675]:[5126,12,"mat3","mat3x3<f32>"],[35688]:[5126,12,"mat3x4","mat3x4<f32>"],[35689]:[5126,16,"mat4x2","mat4x2<f32>"],[35690]:[5126,16,"mat4x3","mat4x3<f32>"],[35676]:[5126,16,"mat4","mat4x4<f32>"]};function ri(e){let t=jn[e];if(!t)throw new Error("uniform");let[r,i,,n]=t;return{format:n,components:i,glType:r}}function Kn(e){let t=jn[e];if(!t)throw new Error("attribute");let[,r,,i,n]=t;return{attributeType:i,vertexFormat:n,components:r}}function zn(e,t){let r={attributes:[],bindings:[]};r.attributes=Kf(e,t);let i=$f(e,t);for(let a of i){let f=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:f})}let n=Yf(e,t),o=0;for(let a of n)if(Ln(a.type)){let{viewDimension:f,sampleType:l}=Zf(a.type);r.bindings.push({type:"texture",name:a.name,location:o,viewDimension:f,sampleType:l}),a.textureUnit=o,o+=1}n.length&&(r.uniforms=n);let s=zf(e,t);return s!=null&&s.length&&(r.varyings=s),r}function Kf(e,t){let r=[],i=e.getProgramParameter(t,35721);for(let n=0;n<i;n++){let o=e.getActiveAttrib(t,n);if(!o)throw new Error("activeInfo");let{name:s,type:a}=o,f=e.getAttribLocation(t,s);if(f>=0){let{attributeType:l}=Kn(a),c=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:f,stepMode:c,type:l})}}return r.sort((n,o)=>n.location-o.location),r}function zf(e,t){if(!b(e))return[];let r=e,i=[],n=e.getProgramParameter(t,35971);for(let o=0;o<n;o++){let s=r.getTransformFeedbackVarying(t,o);if(!s)throw new Error("activeInfo");let{name:a,type:f,size:l}=s,{glType:c,components:u}=ri(f),_=new pe({type:c,size:l*u}),d={location:o,name:a,accessor:_};i.push(d)}return i.sort((o,s)=>o.location-s.location),i}function Yf(e,t){let r=[],i=e.getProgramParameter(t,35718);for(let n=0;n<i;n++){let o=e.getActiveUniform(t,n);if(!o)throw new Error("activeInfo");let{name:s,size:a,type:f}=o,{name:l,isArray:c}=Qf(s),u=e.getUniformLocation(t,l),_={location:u,name:l,size:a,type:f,isArray:c};if(r.push(_),_.size>1)for(let d=0;d<_.size;d++){let p=`${l}[${d}]`;u=e.getUniformLocation(t,p);let g={..._,name:p,location:u};r.push(g)}}return r}function $f(e,t){if(!b(e))return[];let r=e,i=(s,a)=>r.getActiveUniformBlockParameter(t,s,a),n=[],o=r.getProgramParameter(t,35382);for(let s=0;s<o;s++){let a={name:r.getActiveUniformBlockName(t,s)||"",location:i(s,35391),byteLength:i(s,35392),vertex:i(s,35396),fragment:i(s,35398),uniformCount:i(s,35394),uniforms:[]},f=i(s,35395)||[],l=r.getActiveUniforms(t,f,35383),c=r.getActiveUniforms(t,f,35384),u=r.getActiveUniforms(t,f,35387),_=r.getActiveUniforms(t,f,35388);for(let d=0;d<a.uniformCount;++d){let p=r.getActiveUniform(t,f[d]);if(!p)throw new Error("activeInfo");a.uniforms.push({name:p.name,format:ri(l[d]).format,type:l[d],arrayLength:c[d],byteOffset:u[d],byteStride:_[d]})}n.push(a)}return n.sort((s,a)=>s.location-a.location),n}var qf={[35678]:["2d","float"],[35680]:["cube","float"],[35679]:["3d","float"],[35682]:["3d","depth"],[36289]:["2d-array","float"],[36292]:["2d-array","depth"],[36293]:["cube","float"],[36298]:["2d","sint"],[36299]:["3d","sint"],[36300]:["cube","sint"],[36303]:["2d-array","uint"],[36306]:["2d","uint"],[36307]:["3d","uint"],[36308]:["cube","uint"],[36311]:["2d-array","uint"]};function Zf(e){let t=qf[e];if(!t)throw new Error("sampler");let[r,i]=t;return{viewDimension:r,sampleType:i}}function Qf(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function Yn(e,t,r,i){let n=e,o=i;o===!0&&(o=1),o===!1&&(o=0);let s=typeof o=="number"?[o]:o;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,i);case 5126:return e.uniform1fv(t,s);case 35664:return e.uniform2fv(t,s);case 35665:return e.uniform3fv(t,s);case 35666:return e.uniform4fv(t,s);case 5124:return e.uniform1iv(t,s);case 35667:return e.uniform2iv(t,s);case 35668:return e.uniform3iv(t,s);case 35669:return e.uniform4iv(t,s);case 35670:return e.uniform1iv(t,s);case 35671:return e.uniform2iv(t,s);case 35672:return e.uniform3iv(t,s);case 35673:return e.uniform4iv(t,s);case 5125:return n.uniform1uiv(t,s,1);case 36294:return n.uniform2uiv(t,s,2);case 36295:return n.uniform3uiv(t,s,3);case 36296:return n.uniform4uiv(t,s,4);case 35674:return e.uniformMatrix2fv(t,!1,s);case 35675:return e.uniformMatrix3fv(t,!1,s);case 35676:return e.uniformMatrix4fv(t,!1,s);case 35685:return n.uniformMatrix2x3fv(t,!1,s);case 35686:return n.uniformMatrix2x4fv(t,!1,s);case 35687:return n.uniformMatrix3x2fv(t,!1,s);case 35688:return n.uniformMatrix3x4fv(t,!1,s);case 35689:return n.uniformMatrix4x2fv(t,!1,s);case 35690:return n.uniformMatrix4x3fv(t,!1,s)}throw new Error("Illegal uniform")}function $n(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}function qn(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(e)}}var Zn=4,Vt=class extends U.RenderPipeline{constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.vs=void 0,this.fs=void 0,this.introspectedLayout=void 0,this.uniforms={},this.bindings={},this.varyings=null,this._uniformCount=0,this._uniformSetters={},this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=(0,U.cast)(r.vs),this.fs=(0,U.cast)(r.fs);let{varyings:i,bufferMode:n=35981}=r;if(i&&i.length>0){var o;this.device.assertWebGL2(),this.varyings=i,(o=this.device.gl2)===null||o===void 0||o.transformFeedbackVaryings(this.handle,i,n)}this._compileAndLink(),this.introspectedLayout=zn(this.device.gl,this.handle),this.shaderLayout=(0,Qn.mergeShaderLayout)(this.introspectedLayout,r.shaderLayout)}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(t){for(let[r,i]of Object.entries(t)){let n=this.shaderLayout.bindings.find(o=>o.name===r)||this.shaderLayout.bindings.find(o=>o.name===`${r}Uniforms`);if(!n){let o=this.shaderLayout.bindings.map(s=>`"${s.name}"`).join(", ");U.log.warn(`Unknown binding "${r}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(i||U.log.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(i instanceof V)&&!(i.buffer instanceof V))throw new Error("buffer value");break;case"texture":if(!(i instanceof N||i instanceof te))throw new Error("texture value");break;case"sampler":U.log.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(n.type)}this.bindings[r]=i}}setUniforms(t){let{bindings:r}=(0,U.splitUniformsAndBindings)(t);Object.keys(r).forEach(i=>{U.log.warn(`Unsupported value "${JSON.stringify(r[i])}" used in setUniforms() for key ${i}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,t)}draw(t){var r;let{renderPass:i,vertexArray:n,vertexCount:o,instanceCount:s,firstVertex:a=0,transformFeedback:f}=t,l=$n(this.props.topology),c=Boolean(n.indexBuffer),u=(r=n.indexBuffer)===null||r===void 0?void 0:r.glIndexType,_=Number(s)>0;if(!this._areTexturesRenderable()||o===0)return!1;this.device.gl.useProgram(this.handle),n.bindBeforeRender(i),f&&f.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let d=i;return Sn(this.device,this.props.parameters,d.glParameters,()=>{if(c&&_){var p;(p=this.device.gl2)===null||p===void 0||p.drawElementsInstanced(l,o||0,u,a,s||0)}else if(c)this.device.gl.drawElements(l,o||0,u,a);else if(_){var g;(g=this.device.gl2)===null||g===void 0||g.drawArraysInstanced(l,a,o||0,s||0)}else this.device.gl.drawArrays(l,a,o||0);f&&f.end()}),n.unbindAfterRender(i),!0}_compileAndLink(){let{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),U.log.time(Zn,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),U.log.timeEnd(Zn,`linkProgram for ${this.id}`)(),!t.debug&&U.log.level,!t.getProgramParameter(this.handle,35714))throw new Error(`Error linking: ${t.getProgramInfoLog(this.handle)}`);if(t.validateProgram(this.handle),!t.getProgramParameter(this.handle,35715))throw new Error(`Error validating: ${t.getProgramInfoLog(this.handle)}`)}_areTexturesRenderable(){let t=!0;for(let[,r]of Object.entries(this.bindings))r instanceof N&&(r.update(),t=t&&r.loaded);return t}_applyBindings(){this.device.gl.useProgram(this.handle);let{gl2:t}=this.device;if(!t)throw new Error("bindings");let r=0,i=0;for(let n of this.shaderLayout.bindings){let o=this.bindings[n.name]||this.bindings[n.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":let{name:s}=n,a=t.getUniformBlockIndex(this.handle,s);if(a===4294967295)throw new Error(`Invalid uniform block name ${s}`);t.uniformBlockBinding(this.handle,i,a),o instanceof V?t.bindBufferBase(35345,i,o.handle):t.bindBufferRange(35345,i,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),i+=1;break;case"texture":if(!(o instanceof N||o instanceof te))throw new Error("texture");let f;if(o instanceof N)f=o;else if(o instanceof te&&o.colorAttachments[0]instanceof N)U.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=o.colorAttachments[0];else throw new Error("No texture");t.activeTexture(33984+r),t.bindTexture(f.target,f.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(){for(let r of this.shaderLayout.uniforms||[]){var t;let{name:i,location:n,type:o,textureUnit:s}=r,a=(t=this.uniforms[i])!==null&&t!==void 0?t:s;a!==void 0&&Yn(this.device.gl,n,o,a)}}};var Gn=T(E(),1);var Wt=T(E(),1);var kt=class extends Wt.CommandBuffer{constructor(t){super(t,{}),this.device=void 0,this.commands=[],this.device=t}submitCommands(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.commands;for(let r of t)switch(r.name){case"copy-buffer-to-buffer":Jf(this.device,r.options);break;case"copy-buffer-to-texture":Gf(this.device,r.options);break;case"copy-texture-to-buffer":el(this.device,r.options);break;case"copy-texture-to-texture":tl(this.device,r.options);break}}};function Jf(e,t){let r=t.source,i=t.destination,n=e.assertWebGL2();if(n){var o,s;n.bindBuffer(36662,r.handle),n.bindBuffer(36663,i.handle),n.copyBufferSubData(36662,36663,(o=t.sourceOffset)!==null&&o!==void 0?o:0,(s=t.destinationOffset)!==null&&s!==void 0?s:0,t.size),n.bindBuffer(36662,null),n.bindBuffer(36663,null)}else throw new Error("copyBufferToBuffer not implemented in WebGL1")}function Gf(e,t){throw new Error("Not implemented")}function el(e,t){let{source:r,mipLevel:i=0,aspect:n="all",width:o=t.source.width,height:s=t.source.height,depthOrArrayLayers:a=0,origin:f=[0,0],destination:l,byteOffset:c=0,bytesPerRow:u,rowsPerImage:_}=t;if(n!=="all")throw new Error("not supported");if(i!==0||a!==0||u||_)throw new Error("not implemented");let d=e.assertWebGL2(),{framebuffer:p,destroyFramebuffer:g}=Jn(r);try{let h=l,R=o||p.width,A=s||p.height,m=Pe(p.texture.format,!0),B=m.dataFormat,X=m.type;d.bindBuffer(35051,h.handle),d.bindFramebuffer(36160,p.handle),d.readPixels(f[0],f[1],R,A,B,X,c)}finally{d.bindBuffer(35051,null),d.bindFramebuffer(36160,null),g&&p.destroy()}}function tl(e,t){let{source:r,origin:i=[0,0],destination:n}=t,{width:o=t.destination.width,height:s=t.destination.width}=t,a=0,f=6408,{framebuffer:l,destroyFramebuffer:c}=Jn(r),[u,_]=i,d=!1;e.gl.bindFramebuffer(36160,l.handle);let p=null,g;if(n instanceof N)p=n,o=Number.isFinite(o)?o:p.width,s=Number.isFinite(s)?s:p.height,p.bind(0),g=p.destination;else throw new Error("whoops");return d||e.gl.copyTexImage2D(g,a,f,u,_,o,s,0),p&&p.unbind(),c&&l.destroy(),p}function Jn(e){if(e instanceof Wt.Texture){let{width:t,height:r,id:i}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var Ht=class extends Gn.CommandEncoder{constructor(t,r){super(t,r),this.device=void 0,this.commandBuffer=void 0,this.device=t,this.commandBuffer=new kt(t)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}};var Ce=T(E(),1);var eo;eo=Symbol.toStringTag;var Ie=class extends Ce.VertexArray{get[eo](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return t.info.type==="webgl2"||Et()==="Chrome"}constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.buffer=null,this.bufferValue=null,this.init=!1,this.device=t,this.handle=this.device.gl2.createVertexArray()}destroy(){if(super.destroy(),this.buffer){var t;(t=this.buffer)===null||t===void 0||t.destroy()}this.handle&&(this.device.gl2.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){let r=t;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl2.bindVertexArray(this.handle),this.device.gl2.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r}setBuffer(t,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:n,type:o,stride:s,offset:a,normalized:f,integer:l,divisor:c}=this._getAccessor(t);this.device.gl2.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?(this.device.assertWebGL2(),this.device.gl2.vertexAttribIPointer(t,n,o,s,a)):this.device.gl.vertexAttribPointer(t,n,o,f,s,a),this.device.gl.enableVertexAttribArray(t),this.device.gl2.vertexAttribDivisor(t,c||0),this.attributes[t]=i}setConstant(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){if(this.device.gl2.bindVertexArray(this.handle),!this.init){let t=this.indexBuffer;this.device.gl2.bindBuffer(34963,t?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl2.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){let r=this.attributes[t];ArrayBuffer.isView(r)&&this.device.setConstantAttribute(t,r)}}_getAccessor(t){let r=this.attributeInfos[t];if(!r)throw new Error(`Unknown attribute location ${t}`);let i=St(r.bufferDataType);return{size:r.bufferComponents,type:i,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=Ie.isConstantAttributeZeroSupported(this.device)||t!==0;(r||n)&&(t=Number(t),this.device.gl2.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl2.bindVertexArray(null))}getConstantBuffer(t,r){let i=rl(r),n=i.byteLength*t,o=i.length*t;if(this.buffer&&n!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${n} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:n}),s=s||!il(i,this.bufferValue),s){let a=(0,Ce.getScratchArray)(r.constructor,o);(0,Ce.fillArray)({target:a,source:i,start:0,count:o}),this.buffer.write(a),this.bufferValue=r}return this.buffer}};function rl(e){return Array.isArray(e)?new Float32Array(e):e}function il(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var Lt=T(E(),1);var Xt=class extends Lt.TransformFeedback{constructor(t,r){super(t,r),this.device=void 0,this.gl2=void 0,this.handle=void 0,this.layout=void 0,this.buffers={},this.unusedBuffers={},this.bindOnUse=!0,this._bound=!1,t.assertWebGL2(),this.device=t,this.gl2=t.gl2,this.handle=this.props.handle||this.gl2.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl2.deleteTransformFeedback(this.handle),super.destroy()}begin(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"point-list";this.gl2.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl2.beginTransformFeedback(qn(t))}end(){this.gl2.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl2.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let r in t)this.setBuffer(r,t[r])})}setBuffer(t,r){let i=this._getVaryingIndex(t),{buffer:n,byteLength:o,byteOffset:s}=this._getBufferRange(r);if(i<0){this.unusedBuffers[t]=n,Lt.log.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[i]={buffer:n,byteLength:o,byteOffset:s},this.bindOnUse||this._bindBuffer(i,n,s,o)}getBuffer(t){if(to(t))return this.buffers[t]||null;let r=this._getVaryingIndex(t);return r>=0?this.buffers[r]:null}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.handle;if(typeof t!="function")return this.gl2.bindTransformFeedback(36386,t),this;let r;return this._bound?r=t():(this.gl2.bindTransformFeedback(36386,this.handle),this._bound=!0,r=t(),this._bound=!1,this.gl2.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof V)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:i=0,byteLength:n=t.buffer.byteLength}=t;return{buffer:r,byteOffset:i,byteLength:n}}_getVaryingIndex(t){if(to(t))return Number(t);for(let r of this.layout.varyings)if(t===r.name)return r.location;return-1}_bindBuffers(){for(let t in this.buffers){let{buffer:r,byteLength:i,byteOffset:n}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),r,n,i)}}_unbindBuffers(){for(let t in this.buffers)this.gl2.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=arguments.length>3?arguments[3]:void 0,o=r&&r.handle;!o||n===void 0?this.gl2.bindBufferBase(35982,t,o):this.gl2.bindBufferRange(35982,t,o,i,n)}};function to(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var tt=1,M=class extends O.Device{static isSupported(){return typeof WebGLRenderingContext<"u"||ki()}get features(){return this._features=this._features||Rn(this.gl),this._features}get limits(){return this._limits=this._limits||En(this.gl),this._limits}static attach(t){if(t instanceof M)return t;if(t?.device instanceof O.Device)return t.device;if(!nl(t))throw new Error("Invalid WebGLRenderingContext");return new M({gl:t})}static async create(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};O.log.groupCollapsed(tt,"WebGLDevice created")(),typeof t.canvas=="string"&&await O.CanvasContext.pageLoaded,(O.log.get("debug")||t.debug)&&await wn();let{spector:r}=t;if((O.log.get("spector")||r)&&await Nn(),O.log.probe(tt+1,"DOM is loaded")(),t.gl&&t.gl.device)return M.attach(t.gl);let i=new M(t),n=`Created ${i.info.type}${i.debug?" debug":""} context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return O.log.probe(tt,n)(),O.log.table(tt,i.info)(),O.log.groupEnd(tt)(),i}constructor(t){var r;super({...t,id:t.id||(0,O.uid)("webgl-device")}),this.info=void 0,this.canvasContext=void 0,this.handle=void 0,this.lost=void 0,this._resolveContextLost=void 0,this._features=void 0,this._limits=void 0,this.renderPass=null,this.gl=void 0,this.gl2=null,this.debug=!1,this.isWebGL1=void 0,this.isWebGL2=void 0,this._canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1},this._extensions={},this._polyfilled=!1,this.spector=void 0,this._webglLimits=void 0,this._constants=void 0;let i=(r=t.gl)===null||r===void 0?void 0:r.device;if(i)throw new Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new Bt(this,t),this.lost=new Promise(f=>{this._resolveContextLost=f});let n=f=>{var l;return(l=this._resolveContextLost)===null||l===void 0?void 0:l.call(this,{reason:"destroyed",message:"Computer entered sleep mode, or too many apps or browser tabs are using the GPU."})},o=t.gl||null;if(o=o||(L()?fn(this.canvasContext.canvas,{...t,onContextLost:n}):null),o=o||(L()?null:Wi({...t,onContextLost:n})),!o)throw new Error("WebGL context creation failed");this.handle=o,this.gl=this.handle,this.gl2=this.gl,this.isWebGL2=ol(this.gl),this.isWebGL1=!this.isWebGL2,this.info=ln(this.gl),this.gl.device=this,this.gl._version=this.isWebGL2?2:1,Ji(this.gl);let{enable:s=!0,copyState:a=!1}=t;if(zr(this.gl,{enable:s,copyState:a,log:function(){for(var f=arguments.length,l=new Array(f),c=0;c<f;c++)l[c]=arguments[c];return O.log.log(1,...l)()}}),L()&&t.debug&&(this.gl=Un(this.gl,{...t,webgl2:this.isWebGL2,throwOnError:!0}),this.gl2=this.gl,this.debug=!0,O.log.level=Math.max(O.log.level,1),O.log.warn("WebGL debug mode activated. Performance reduced.")()),L()&&t.spector){let f=this.handle.canvas||t.canvas;this.spector=Bn({...this.props,canvas:f})}}destroy(){let t=this.gl.getExtension("STACKGL_destroy_context");t&&t.destroy()}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(t){return qe(this.gl,t)}isTextureFormatFilterable(t){return hn(this.gl,t)}isTextureFormatRenderable(t){return gn(this.gl,t)}assertWebGL2(){if(!this.gl2)throw new Error("Requires WebGL2");return this.gl2}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){let r=this._getBufferProps(t);return new V(this,r)}_createTexture(t){return new N(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new ve(this,t)}createShader(t){return new Dt(this,t)}createFramebuffer(t){return new te(this,t)}createRenderPipeline(t){return new Vt(this,t)}createVertexArray(t){return new Ie(this,t)}beginRenderPass(t){return new wt(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}createTransformFeedback(t){return new Xt(this,t)}getDefaultRenderPass(){return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:this.canvasContext.getCurrentFramebuffer()}),this.renderPass}createCommandEncoder(t){return new Ht(this,t)}submit(){var t;(t=this.renderPass)===null||t===void 0||t.end(),this.renderPass=null}get webglLimits(){return this._webglLimits=this._webglLimits||vn(this.gl),this._webglLimits}loseDevice(){var t;let r=!1,i=this.gl.getExtension("WEBGL_lose_context");return i&&(r=!0,i.loseContext()),(t=this._resolveContextLost)===null||t===void 0||t.call(this,{reason:"destroyed",message:"Application triggered context loss"}),r}pushState(){_e(this.gl)}popState(){se(this.gl)}setSpectorMetadata(t,r){t.__SPECTOR_Metadata=r}getGLKey(t,r){r=r||this.gl2||this.gl;let i=Number(t);for(let n in r)if(r[n]===i)return`GL.${n}`;return String(t)}setConstantAttribute(t,r){this._constants=this._constants||new Array(this.limits.maxVertexAttributes).fill(null);let i=this._constants[t];switch(i&&ll(i,r)&&O.log.info(1,`setConstantAttribute(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:sl(this,t,r);break;case Int32Array:al(this,t,r);break;case Uint32Array:fl(this,t,r);break;default:(0,O.assert)(!1)}}};M.type="webgl";function nl(e){return typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function ol(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&e._version===2)}function sl(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:(0,O.assert)(!1)}}function al(e,t,r){var i;e.assertWebGL2(),(i=e.gl2)===null||i===void 0||i.vertexAttribI4iv(t,r)}function fl(e,t,r){var i;e.assertWebGL2(),(i=e.gl2)===null||i===void 0||i.vertexAttribI4uiv(t,r)}function ll(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var ro=T(E(),1);var cl=256,ul=1024,_l=16384;var dl="clear: bad arguments";function ii(e,t){let r=M.attach(e),{framebuffer:i=null,color:n=null,depth:o=null,stencil:s=null}=t||{},a={};i&&(a.framebuffer=i);let f=0;n&&(f|=_l,n!==!0&&(a.clearColor=n)),o&&(f|=cl,o!==!0&&(a.clearDepth=o)),s&&(f|=ul,o!==!0&&(a.clearStencil=o)),(0,ro.assert)(f!==0,dl),P(r.gl,a,()=>{r.gl.clear(f)})}var rt=T(E(),1);var io=T(E(),1);function no(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return(0,io.assert)(!1),0}}function ni(e,t){var r;let{sourceX:i=0,sourceY:n=0,sourceFormat:o=6408,sourceAttachment:s=36064}=t||{},{target:a=null,sourceWidth:f,sourceHeight:l,sourceType:c}=t||{},{framebuffer:u,deleteFramebuffer:_}=pl(e);(0,rt.assert)(u);let{gl:d,handle:p}=u;f=f||u.width,l=l||u.height;let g=s-36064;c=c||((r=u.colorAttachments[g])===null||r===void 0?void 0:r.type)||5121,a=gl(a,c,o,f,l),c=c||Xn(a);let h=d.bindFramebuffer(36160,p);return d.readPixels(i,n,f,l,o,c,a),d.bindFramebuffer(36160,h||null),_&&u.destroy(),a}function pl(e){return e instanceof rt.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:hl(e),deleteFramebuffer:!0}}function hl(e,t){let{device:r,width:i,height:n,id:o}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${o}`,width:i,height:n,colorAttachments:[e]})}function gl(e,t,r,i,n){if(e)return e;t=t||5121;let o=et(t,{clamped:!1}),s=no(r);return new o(i*n*s)}var as=T(S());function oo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function so(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?oo(Object(r),!0).forEach(function(i){Tl(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oo(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Tl(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ao=`
|
|
70
|
+
`},cs={name:"brushing",dependencies:[fs.project],vs:Vl,fs:Wl,inject:Ll,getUniforms:function(t){if(!t||!("viewport"in t))return{};var r=t.brushingEnabled,n=r===void 0?!0:r,i=t.brushingRadius,s=i===void 0?1e4:i,o=t.brushingTarget,a=o===void 0?"source":o,l=t.mousePosition,f=t.viewport;return{brushing_enabled:Boolean(n&&l&&f.containsPixel(l)),brushing_radius:s,brushing_target:Hl[a]||0,brushing_mousePos:l?f.unproject([l.x-f.x,l.y-f.y]):[0,0]}}};function jt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jt=function(r){return typeof r}:jt=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},jt(e)}function Xl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jl(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&On(e,t)}function On(e,t){return On=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},On(e,t)}function zl(e){var t=$l();return function(){var n=zt(e),i;if(t){var s=zt(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Kl(this,i)}}function Kl(e,t){if(t&&(jt(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Yl(e)}function Yl(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $l(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function zt(e){return zt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},zt(e)}var ql={getBrushingTarget:{type:"accessor",value:[0,0]},brushingTarget:"source",brushingEnabled:!0,brushingRadius:1e4},Kt=function(e){jl(r,e);var t=zl(r);function r(){return Xl(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){return{modules:[cs]}},n.initializeState=function(s,o){var a=this,l=this.getAttributeManager();l&&l.add({brushingTargets:{size:2,accessor:"getBrushingTarget",shaderAttributes:{brushingTargets:{divisor:0},instanceBrushingTargets:{divisor:1}}}});var f=function(){var _;(_=a.getCurrentLayer())===null||_===void 0||_.setNeedsRedraw()};this.state.onMouseMove=f,s.deck&&s.deck.eventManager.on({pointermove:f,pointerleave:f})},n.finalizeState=function(s,o){if(s.deck){var a=this.state.onMouseMove;s.deck.eventManager.off({pointermove:a,pointerleave:a})}},r}(us.LayerExtension);Kt.defaultProps=ql;Kt.extensionName="BrushingExtension";var Zl="Failed to create WebGL context in Node.js, headless gl returned null",Ql=" luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.",Jl={width:1,height:1,debug:!0,throwOnError:!1},wn=null;function _s(){return wn!==null}function ds(e){e={...Jl,...e};let{width:t,height:r,webgl1:n,webgl2:i}=e;if(i&&!n)throw new Error("headless-gl does not support WebGL2");if(!wn)throw new Error(Ql);let s=wn(t,r,e);if(!s)throw new Error(Zl);return s}var N=v(x(),1);function ct(e){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}function J(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||ct()}var Yh=globalThis.self||globalThis.window||globalThis.global,$h=globalThis.window||globalThis.self||globalThis.global,qh=globalThis.document||{},Zh=globalThis.process||{},Qh=globalThis.console,ps=globalThis.navigator||{};var Pn=globalThis;function Yt(e){if(!e&&!J())return"Node";if(ct(e))return"Electron";let t=e||ps.userAgent||"";if(t.indexOf("Edge")>-1)return"Edge";let r=t.indexOf("MSIE ")!==-1,n=t.indexOf("Trident/")!==-1;return r||n?"IE":Pn.chrome?"Chrome":Pn.safari?"Safari":Pn.mozInnerScreenX?"Firefox":"Unknown"}var Es=v(x(),1);var ut={};function Gl(e){globalThis.console&&globalThis.console.error&&globalThis.console.error(e)}function ef(e){globalThis.console&&globalThis.console.log&&globalThis.console.log(e)}function tf(e,t){ut[e]=!0,t!==void 0&&Gl(t)}function rf(e){let t=e.getError;e.getError=function(){let n;do n=t.apply(e),n!==0&&(ut[n]=!0);while(n!==0);for(n in ut)if(ut[n])return delete ut[n],parseInt(n,10);return 0}}var _t=function e(t){let r=t.gl;this.ext=t,this.isAlive=!0,this.hasBeenBound=!1,this.elementArrayBuffer=null,this.attribs=new Array(t.maxVertexAttribs);for(let n=0;n<this.attribs.length;n++){let i=new e.VertexAttrib(r);this.attribs[n]=i}this.maxAttrib=0};_t.VertexAttrib=function(t){this.enabled=!1,this.buffer=null,this.size=4,this.type=5126,this.normalized=!1,this.stride=16,this.offset=0,this.cached="",this.recache()};_t.VertexAttrib.prototype.recache=function(){this.cached=[this.size,this.type,this.normalized,this.stride,this.offset].join(":")};var Ce=function(t){let r=this;this.gl=t,rf(t);let n=this.original={getParameter:t.getParameter,enableVertexAttribArray:t.enableVertexAttribArray,disableVertexAttribArray:t.disableVertexAttribArray,bindBuffer:t.bindBuffer,getVertexAttrib:t.getVertexAttrib,vertexAttribPointer:t.vertexAttribPointer};t.getParameter=function(s){return s===r.VERTEX_ARRAY_BINDING_OES?r.currentVertexArrayObject===r.defaultVertexArrayObject?null:r.currentVertexArrayObject:n.getParameter.apply(this,arguments)},t.enableVertexAttribArray=function(s){let o=r.currentVertexArrayObject;o.maxAttrib=Math.max(o.maxAttrib,s);let a=o.attribs[s];return a.enabled=!0,n.enableVertexAttribArray.apply(this,arguments)},t.disableVertexAttribArray=function(s){let o=r.currentVertexArrayObject;o.maxAttrib=Math.max(o.maxAttrib,s);let a=o.attribs[s];return a.enabled=!1,n.disableVertexAttribArray.apply(this,arguments)},t.bindBuffer=function(s,o){switch(s){case 34962:r.currentArrayBuffer=o;break;case 34963:r.currentVertexArrayObject.elementArrayBuffer=o;break;default:}return n.bindBuffer.apply(this,arguments)},t.getVertexAttrib=function(s,o){let l=r.currentVertexArrayObject.attribs[s];switch(o){case 34975:return l.buffer;case 34338:return l.enabled;case 34339:return l.size;case 34340:return l.stride;case 34341:return l.type;case 34922:return l.normalized;default:return n.getVertexAttrib.apply(this,arguments)}},t.vertexAttribPointer=function(s,o,a,l,f,u){let _=r.currentVertexArrayObject;_.maxAttrib=Math.max(_.maxAttrib,s);let p=_.attribs[s];return p.buffer=r.currentArrayBuffer,p.size=o,p.type=a,p.normalized=l,p.stride=f,p.offset=u,p.recache(),n.vertexAttribPointer.apply(this,arguments)},t.instrumentExtension&&t.instrumentExtension(this,"OES_vertex_array_object"),t.canvas&&t.canvas.addEventListener("webglcontextrestored",()=>{ef("OESVertexArrayObject emulation library context restored"),r.reset_()},!0),this.reset_()};Ce.prototype.VERTEX_ARRAY_BINDING_OES=34229;Ce.prototype.reset_=function(){if(this.vertexArrayObjects!==void 0)for(let n=0;n<this.vertexArrayObjects.length;++n)this.vertexArrayObjects.isAlive=!1;let r=this.gl;this.maxVertexAttribs=r.getParameter(34921),this.defaultVertexArrayObject=new _t(this),this.currentVertexArrayObject=null,this.currentArrayBuffer=null,this.vertexArrayObjects=[this.defaultVertexArrayObject],this.bindVertexArrayOES(null)};Ce.prototype.createVertexArrayOES=function(){let t=new _t(this);return this.vertexArrayObjects.push(t),t};Ce.prototype.deleteVertexArrayOES=function(t){t.isAlive=!1,this.vertexArrayObjects.splice(this.vertexArrayObjects.indexOf(t),1),this.currentVertexArrayObject===t&&this.bindVertexArrayOES(null)};Ce.prototype.isVertexArrayOES=function(t){return!!(t&&t instanceof _t&&t.hasBeenBound&&t.ext===this)};Ce.prototype.bindVertexArrayOES=function(t){let r=this.gl;if(t&&!t.isAlive){tf(1282,"bindVertexArrayOES: attempt to bind deleted arrayObject");return}let n=this.original,i=this.currentVertexArrayObject;this.currentVertexArrayObject=t||this.defaultVertexArrayObject,this.currentVertexArrayObject.hasBeenBound=!0;let s=this.currentVertexArrayObject;if(i===s)return;(!i||s.elementArrayBuffer!==i.elementArrayBuffer)&&n.bindBuffer.call(r,34963,s.elementArrayBuffer);let o=this.currentArrayBuffer,a=Math.max(i?i.maxAttrib:0,s.maxAttrib);for(let l=0;l<=a;l++){let f=s.attribs[l],u=i?i.attribs[l]:null;if((!i||f.enabled!==u.enabled)&&(f.enabled?n.enableVertexAttribArray.call(r,l):n.disableVertexAttribArray.call(r,l)),f.enabled){let _=!1;(!i||f.buffer!==u.buffer)&&(o!==f.buffer&&(n.bindBuffer.call(r,34962,f.buffer),o=f.buffer),_=!0),(_||f.cached!==u.cached)&&n.vertexAttribPointer.call(r,l,f.size,f.type,f.normalized,f.stride,f.offset)}}this.currentArrayBuffer!==o&&n.bindBuffer.call(r,34962,this.currentArrayBuffer)};function gs(e){if(typeof e.createVertexArray=="function")return;let t=e.getSupportedExtensions;e.getSupportedExtensions=function(){let i=t.call(this)||[];return i.indexOf("OES_vertex_array_object")<0&&i.push("OES_vertex_array_object"),i};let r=e.getExtension;e.getExtension=function(i){let s=r.call(this,i);return s||(i!=="OES_vertex_array_object"?null:(e.__OESVertexArrayObject||(this.__OESVertexArrayObject=new Ce(this)),this.__OESVertexArrayObject))}}var Be=v(x(),1);var ms=v(x(),1),nf="Invalid WebGLRenderingContext";function sf(e){return typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function E(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&e._version===2)}function In(e){return E(e)?e:null}function bs(e){return(0,ms.assert)(sf(e),nf),e}var Ts="OES_element_index",As="WEBGL_draw_buffers",of="EXT_disjoint_timer_query",af="EXT_disjoint_timer_query_webgl2",lf="EXT_texture_filter_anisotropic",vs="WEBGL_debug_renderer_info",ff=35723,cf=4352,uf=36795,_f=34047,df=37445,hf=37446,P=e=>E(e)?void 0:0,pf={[3074]:e=>E(e)?void 0:36064,[ff]:e=>E(e)?void 0:cf,[35977]:P,[32937]:P,[uf]:(e,t)=>{let r=E(e)?e.getExtension(af):e.getExtension(of);return r&&r.GPU_DISJOINT_EXT?t(r.GPU_DISJOINT_EXT):0},[df]:(e,t)=>{let r=e.getExtension(vs);return t(r&&r.UNMASKED_VENDOR_WEBGL||7936)},[hf]:(e,t)=>{let r=e.getExtension(vs);return t(r&&r.UNMASKED_RENDERER_WEBGL||7937)},[_f]:(e,t)=>{var r;let n=((r=e.luma)===null||r===void 0||(r=r.extensions)===null||r===void 0?void 0:r[lf])||e.getExtension("EXT_texture_filter_anisotropic");return n?t(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1},[32883]:P,[35071]:P,[37447]:P,[36063]:(e,t)=>{if(!E(e)){let r=e.getExtension(As);return r?t(r.MAX_COLOR_ATTACHMENTS_WEBGL):0}},[35379]:P,[35374]:P,[35377]:P,[34852]:e=>{if(!E(e)){let t=e.getExtension(As);return t?t.MAX_DRAW_BUFFERS_WEBGL:0}},[36203]:e=>e.getExtension(Ts)?2147483647:65535,[33001]:e=>e.getExtension(Ts)?16777216:65535,[33e3]:e=>16777216,[37157]:P,[35373]:P,[35657]:P,[36183]:P,[37137]:P,[34045]:P,[35978]:P,[35979]:P,[35968]:P,[35376]:P,[35375]:P,[35659]:P,[37154]:P,[35371]:P,[35658]:P,[35076]:P,[35077]:P,[35380]:P};function ys(e,t,r){let n=pf[r],i=typeof n=="function"?n(e,t,r):n;return i!==void 0?i:t(r)}function je(e){if(!e.luma){let r={_polyfilled:!1,_extensions:{}};e.luma=r}return e.luma}var gf="OES_vertex_array_object",Rs="ANGLE_instanced_arrays",mf="WEBGL_draw_buffers",bf="EXT_disjoint_timer_query",Tf="EXT_texture_filter_anisotropic",Af="VertexArray requires WebGL2 or OES_vertex_array_object extension";function vf(e,t){return{webgl2:E(e),ext:e.getExtension(t)}}var Fn={[gf]:{meta:{suffix:"OES"},createVertexArray:()=>{(0,Be.assert)(!1,Af)},deleteVertexArray:()=>{},bindVertexArray:()=>{},isVertexArray:()=>!1},[Rs]:{meta:{suffix:"ANGLE"},vertexAttribDivisor(e,t){(0,Be.assert)(t===0,"WebGL instanced rendering not supported")},drawElementsInstanced:()=>{},drawArraysInstanced:()=>{}},[mf]:{meta:{suffix:"WEBGL"},drawBuffers:()=>{(0,Be.assert)(!1)}},[bf]:{meta:{suffix:"EXT"},createQuery:()=>{(0,Be.assert)(!1)},deleteQuery:()=>{(0,Be.assert)(!1)},beginQuery:()=>{(0,Be.assert)(!1)},endQuery:()=>{},getQuery(e,t){return this.getQueryObject(e,t)},getQueryParameter(e,t){return this.getQueryObject(e,t)},getQueryObject:(e,t)=>{}}},$t={readBuffer:(e,t,r)=>{E(e)&&t(r)},getVertexAttrib:(e,t,r,n)=>{let{webgl2:i,ext:s}=vf(e,Rs),o;switch(n){case 35069:o=i?void 0:!1;break;case 35070:o=!i&&!s?0:void 0;break;default:}return o!==void 0?o:t(r,n)},getProgramParameter:(e,t,r,n)=>{if(!E(e))switch(n){case 35967:return 35981;case 35971:return 0;case 35382:return 0;default:}return t(r,n)},getInternalformatParameter:(e,t,r,n,i)=>{if(!E(e))switch(i){case 32937:return new Int32Array([0]);default:}return e.getInternalformatParameter(r,n,i)},getTexParameter(e,t,r,n){switch(n){case 34046:let i=je(e),{_extensions:s}=i,o=s[Tf];n=o&&o.TEXTURE_MAX_ANISOTROPY_EXT||34046;break;default:}return t(r,n)},getParameter:ys,hint(e,t,r,n){return t(r,n)}};function xs(e){let t=je(e);return t._polyfilled||(gs(e),yf(e),Rf(e,Fn),xf(e,{target:t,target2:e}),t._polyfilled=!0),e}function yf(e){let t=je(e),r=e.getSupportedExtensions()||[],n=["WEBGL_polygon_mode"];for(let i of r)if(!n.includes(i)){let s=e.getExtension(i);t._extensions[i]=s}}function Rf(e,t){let r=je(e);for(let n of Object.getOwnPropertyNames(t))n!=="overrides"&&Ef(e,{extension:n,target:r,target2:e})}function Ef(e,t){let{extension:r,target:n,target2:i}=t,s=Fn[r];(0,Es.assert)(s);let{meta:o={}}=s,{suffix:a=""}=o,l=e.getExtension(r);for(let f of Object.keys(s)){let u=`${f}${a}`,_=null;f==="meta"||typeof e[f]=="function"||(l&&typeof l[u]=="function"?_=function(){return l[u](...arguments)}:typeof s[f]=="function"&&(_=s[f].bind(n))),_&&(n[f]=_,i[f]=_)}}function xf(e,t){let{target:r,target2:n}=t;Object.keys($t).forEach(i=>{if(typeof $t[i]=="function"){let s=e[i]?e[i].bind(e):()=>{},o=$t[i].bind(null,e,s);r[i]=o,n[i]=o}})}var ht=v(x(),1);var qt={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},oe=(e,t,r)=>t?e.enable(r):e.disable(r),Ss=(e,t,r)=>e.hint(r,t),Y=(e,t,r)=>e.pixelStorei(r,t),Os=(e,t,r)=>{let n;return r===36006?n=E(e)?36009:36160:n=36008,e.bindFramebuffer(n,t)},dt=(e,t,r)=>{let i={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];e.bindBuffer(i,t)};function Nn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var ws={[3042]:oe,[32773]:(e,t)=>e.blendColor(...t),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(e,t)=>e.clearColor(...t),[3107]:(e,t)=>e.colorMask(...t),[2884]:oe,[2885]:(e,t)=>e.cullFace(t),[2929]:oe,[2931]:(e,t)=>e.clearDepth(t),[2932]:(e,t)=>e.depthFunc(t),[2928]:(e,t)=>e.depthRange(...t),[2930]:(e,t)=>e.depthMask(t),[3024]:oe,[35723]:Ss,[35725]:(e,t)=>e.useProgram(t),[36007]:(e,t)=>e.bindRenderbuffer(36161,t),[36389]:(e,t)=>{var r,n;return(r=(n=e).bindTransformFeedback)===null||r===void 0?void 0:r.call(n,36386,t)},[34229]:(e,t)=>e.bindVertexArray(t),[36006]:Os,[36010]:Os,[34964]:dt,[36662]:dt,[36663]:dt,[35053]:dt,[35055]:dt,[2886]:(e,t)=>e.frontFace(t),[33170]:Ss,[2849]:(e,t)=>e.lineWidth(t),[32823]:oe,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:oe,[32926]:oe,[32928]:oe,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:oe,[3088]:(e,t)=>e.scissor(...t),[2960]:oe,[2961]:(e,t)=>e.clearStencil(t),[2968]:(e,t)=>e.stencilMaskSeparate(1028,t),[36005]:(e,t)=>e.stencilMaskSeparate(1029,t),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(e,t)=>e.viewport(...t),[3333]:Y,[3317]:Y,[37440]:Y,[37441]:Y,[37443]:Y,[3330]:Y,[3332]:Y,[3331]:Y,[3314]:Y,[32878]:Y,[3316]:Y,[3315]:Y,[32877]:Y,framebuffer:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Nn(t)?t:[t,t];let[r,n]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=Nn(t)&&t.length===3?[...t,...t]:t;let[r,n,i,s,o,a]=t;e.stencilFuncSeparate(1028,r,n,i),e.stencilFuncSeparate(1029,s,o,a)},stencilOp:(e,t)=>{t=Nn(t)&&t.length===3?[...t,...t]:t;let[r,n,i,s,o,a]=t;e.stencilOpSeparate(1028,r,n,i),e.stencilOpSeparate(1029,s,o,a)},viewport:(e,t)=>e.viewport(...t)};function M(e,t,r){return t[e]!==void 0?t[e]:r[e]}var Ps={blendEquation:(e,t,r)=>e.blendEquationSeparate(M(32777,t,r),M(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(M(32969,t,r),M(32968,t,r),M(32971,t,r),M(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(M(32824,t,r),M(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(M(32938,t,r),M(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,M(2962,t,r),M(2967,t,r),M(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,M(34816,t,r),M(36003,t,r),M(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,M(2964,t,r),M(2965,t,r),M(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,M(34817,t,r),M(34818,t,r),M(34819,t,r))},Mn={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({[35725]:t}),bindRenderbuffer:(e,t,r)=>e({[36007]:r}),bindTransformFeedback:(e,t,r)=>e({[36389]:r}),bindVertexArray:(e,t)=>e({[34229]:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({[36006]:r,[36010]:r});case 36009:return e({[36006]:r});case 36008:return e({[36010]:r});default:return null}},bindBuffer:(e,t,r)=>{let n={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[t];return n?e({[n]:r}):{valueChanged:!0}},blendColor:(e,t,r,n,i)=>e({[32773]:new Float32Array([t,r,n,i])}),blendEquation:(e,t)=>e({[32777]:t,[34877]:t}),blendEquationSeparate:(e,t,r)=>e({[32777]:t,[34877]:r}),blendFunc:(e,t,r)=>e({[32969]:t,[32968]:r,[32971]:t,[32970]:r}),blendFuncSeparate:(e,t,r,n,i)=>e({[32969]:t,[32968]:r,[32971]:n,[32970]:i}),clearColor:(e,t,r,n,i)=>e({[3106]:new Float32Array([t,r,n,i])}),clearDepth:(e,t)=>e({[2931]:t}),clearStencil:(e,t)=>e({[2961]:t}),colorMask:(e,t,r,n,i)=>e({[3107]:[t,r,n,i]}),cullFace:(e,t)=>e({[2885]:t}),depthFunc:(e,t)=>e({[2932]:t}),depthRange:(e,t,r)=>e({[2928]:new Float32Array([t,r])}),depthMask:(e,t)=>e({[2930]:t}),frontFace:(e,t)=>e({[2886]:t}),lineWidth:(e,t)=>e({[2849]:t}),polygonOffset:(e,t,r)=>e({[32824]:t,[10752]:r}),sampleCoverage:(e,t,r)=>e({[32938]:t,[32939]:r}),scissor:(e,t,r,n,i)=>e({[3088]:new Int32Array([t,r,n,i])}),stencilMask:(e,t)=>e({[2968]:t,[36005]:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,n)=>e({[2962]:t,[2967]:r,[2963]:n,[34816]:t,[36003]:r,[36004]:n}),stencilFuncSeparate:(e,t,r,n,i)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:n,[t===1028?2963:36004]:i}),stencilOp:(e,t,r,n)=>e({[2964]:t,[2965]:r,[2966]:n,[34817]:t,[34818]:r,[34819]:n}),stencilOpSeparate:(e,t,r,n,i)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:n,[t===1028?2966:34819]:i}),viewport:(e,t,r,n,i)=>e({[2978]:[t,r,n,i]})},ae=(e,t)=>e.isEnabled(t),Cn={[3042]:ae,[2884]:ae,[2929]:ae,[3024]:ae,[32823]:ae,[32926]:ae,[32928]:ae,[3089]:ae,[2960]:ae,[35977]:ae},Is=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function he(e,t){let n=k.attach(e).gl;if(Sf(t))return;let i={};for(let o in t){let a=Number(o),l=ws[o];l&&(typeof l=="string"?i[l]=!0:l(n,t[o],a))}let s=n.state&&n.state.cache;if(s)for(let o in i){let a=Ps[o];a(n,t,s)}}function Fs(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qt,n=k.attach(e).gl;if(typeof t=="number"){let o=t,a=Cn[o];return a?a(n,o):n.getParameter(o)}let i=Array.isArray(t)?t:Object.keys(t),s={};for(let o of i){let a=Cn[o];s[o]=a?a(n,Number(o)):n.getParameter(Number(o))}return s}function Sf(e){for(let t in e)return!1;return!0}function Ns(e,t){if(e===t)return!0;let r=Array.isArray(e)||ArrayBuffer.isView(e),n=Array.isArray(t)||ArrayBuffer.isView(t);if(r&&n&&e.length===t.length){for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}return!1}var Bn=class{constructor(t){let{copyState:r=!1,log:n=()=>{}}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.gl=void 0,this.program=null,this.stateStack=[],this.enable=!0,this.cache=void 0,this.log=void 0,this.gl=t,this.cache=r?Fs(t):Object.assign({},qt),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.stateStack.push({})}pop(){(0,ht.assert)(this.stateStack.length>0);let t=this.stateStack[this.stateStack.length-1];he(this.gl,t),this.stateStack.pop()}_updateCache(t){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in t){(0,ht.assert)(s!==void 0);let o=t[s],a=this.cache[s];Ns(o,a)||(r=!0,n=a,i&&!(s in i)&&(i[s]=a),this.cache[s]=o)}return{valueChanged:r,oldValue:n}}};function De(e){return e.state}function Dn(e,t){let{enable:r=!0,copyState:n}=t;if((0,ht.assert)(n!==void 0),!e.state){e.state=new Bn(e,{copyState:n}),wf(e);for(let s in Mn){let o=Mn[s];Of(e,s,o)}Ms(e,"getParameter"),Ms(e,"isEnabled")}let i=De(e);return i.enable=r,e}function Ee(e){let t=De(e);t||(Dn(e,{copyState:!1}),t=De(e)),t.push()}function pe(e){let t=De(e);(0,ht.assert)(t),t.pop()}function Ms(e,t){let r=e[t].bind(e);e[t]=function(i){if(i===void 0||Is.has(i))return r(i);let s=De(e);return i in s.cache||(s.cache[i]=r(i)),s.enable?s.cache[i]:r(i)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Of(e,t,r){if(!e[t])return;let n=e[t].bind(e);e[t]=function(){let s=De(e);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];let{valueChanged:f,oldValue:u}=r(s._updateCache,...a);return f&&n(...a),u},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function wf(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let i=De(e);i.program!==n&&(t(n),i.program=n)}}var Pf={webgl2:!0,webgl1:!0,powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Cs(e,t){t={...Pf,...t};let r=null,n=s=>r=s.statusMessage||r;e.addEventListener("webglcontextcreationerror",n,!1);let i=null;if(t.type==="webgl2"&&(t={...t,webgl1:!1}),t.type==="webgl1"&&(t={...t,webgl2:!1}),!i&&t.webgl2&&(i=e.getContext("webgl2",t)),!i&&t.webgl1&&(i=e.getContext("webgl",t)),e.removeEventListener("webglcontextcreationerror",n,!1),!i)throw new Error(`Failed to create ${t.webgl2&&!t.webgl1?"WebGL2":"WebGL"} context: ${r||"Unknown error"}`);if(t.onContextLost){let{onContextLost:s}=t;e.addEventListener("webglcontextlost",o=>s(o),!1)}if(t.onContextRestored){let{onContextRestored:s}=t;e.addEventListener("webglcontextrestored",o=>s(o),!1)}return i}function Bs(e){let t=e.getParameter(7936),r=e.getParameter(7937),n=e.getExtension("WEBGL_debug_renderer_info"),i=e.getParameter(n?n.UNMASKED_VENDOR_WEBGL:7936),s=e.getParameter(n?n.UNMASKED_RENDERER_WEBGL:7937),o=i||t,a=s||r,l=e.getParameter(7938),f=Ds(o,a),u=If(o,a),_=Ff(o,a),p="glsl",g=E(e)?300:100;return{type:E(e)?"webgl2":"webgl",gpu:f,gpuType:_,gpuBackend:u,vendor:o,renderer:a,version:l,shadingLanguage:p,shadingLanguageVersion:g}}function Ds(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function If(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function Ff(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(Ds(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function ks(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=typeof window<"u"?window.navigator||{}:{},r=e.userAgent||t.userAgent||"",n=r.indexOf("MSIE ")!==-1,i=r.indexOf("Trident/")!==-1;return n||i}var Vn=v(x(),1);function Zt(e){switch(e){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}var X="texture-compression-bc",S="texture-compression-astc",le="texture-compression-etc2",Nf="texture-compression-etc1-webgl",Qt="texture-compression-pvrtc-webgl",kn="texture-compression-atc-webgl",pt="WEBGL_compressed_texture_s3tc",gt="WEBGL_compressed_texture_s3tc_srgb",ze="EXT_texture_compression_rgtc",mt="EXT_texture_compression_bptc",Mf="WEBGL_compressed_texture_etc",Cf="WEBGL_compressed_texture_astc",Bf="WEBGL_compressed_texture_etc1",Df="WEBGL_compressed_texture_pvrtc",kf="WEBGL_compressed_texture_atc",Us="EXT_sRGB",ge="EXT_texture_norm16",Uf="WEBGL_color_buffer_float",Vf="EXT_color_buffer_float",G=(e,t)=>e.getExtension(t),ke=(e,t)=>t.every(r=>e.getExtension(r)),Un={"texture-blend-float-webgl1":e=>E(e)?!0:G(e,"EXT_float_blend"),"texture-formats-srgb-webgl1":e=>E(e)?!0:G(e,Us),"texture-formats-depth-webgl1":e=>E(e)?!0:G(e,"WEBGL_depth_texture"),"texture-formats-float32-webgl1":e=>E(e)?!0:G(e,"OES_texture_float"),"texture-formats-float16-webgl1":e=>E(e)?!0:G(e,"OES_texture_half_float"),"texture-formats-norm16-webgl":e=>E(e)?G(e,ge):!1,"texture-filter-linear-float32-webgl":e=>G(e,"OES_texture_float_linear"),"texture-filter-linear-float16-webgl":e=>G(e,"OES_texture_half_float_linear"),"texture-filter-anisotropic-webgl":e=>G(e,"EXT_texture_filter_anisotropic"),"texture-renderable-float32-webgl":e=>G(e,"EXT_color_buffer_float"),"texture-renderable-float16-webgl":e=>G(e,"EXT_color_buffer_half_float"),"texture-compression-bc":e=>ke(e,[pt,gt,ze,mt]),"texture-compression-bc5-webgl":e=>ke(e,[ze]),"texture-compression-etc2":e=>ke(e,[Mf]),"texture-compression-astc":e=>ke(e,[Cf]),"texture-compression-etc1-webgl":e=>ke(e,[Bf]),"texture-compression-pvrtc-webgl":e=>ke(e,[Df]),"texture-compression-atc-webgl":e=>ke(e,[kf])};function Wf(e,t){var r;return((r=Un[t])===null||r===void 0?void 0:r.call(Un,e))||!1}function Vs(e){return Object.keys(Un).filter(r=>Wf(e,r))}var bt={"rgb8unorm-unsized":{gl:6407,gl1:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,gl1:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,renderbuffer:!0},r8snorm:{gl:36756,b:1,c:1},r8uint:{gl:33330,b:1,c:1,renderbuffer:!0},r8sint:{gl:33329,b:1,c:1,renderbuffer:!0},rg8unorm:{gl:33323,b:2,c:2,renderbuffer:!0},rg8snorm:{gl:36757,b:2,c:2},rg8uint:{gl:33336,b:2,c:2,renderbuffer:!0},rg8sint:{gl:33335,b:2,c:2,renderbuffer:!0},r16uint:{gl:33332,b:2,c:1,renderbuffer:!0},r16sint:{gl:33331,b:2,c:1,renderbuffer:!0},r16float:{gl:33325,b:2,c:1,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl",renderbuffer:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:"texture-formats-norm16-webgl",renderbuffer:!0,x:ge},"r16snorm-webgl":{gl:36760,b:2,c:1,f:"texture-formats-norm16-webgl",x:ge},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,gl1:6408,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,gl1:35906,b:4,c:4,gl1ext:Us,bpp:4},rgba8snorm:{gl:36759,b:4,c:4},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl",renderbuffer:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,f:"texture-formats-norm16-webgl",x:ge},"rg16snorm-webgl":{gl:36761,b:2,c:2,f:"texture-formats-norm16-webgl",x:ge},r32uint:{gl:33334,b:4,c:1,bpp:4,renderbuffer:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,renderbuffer:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl"},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl"},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:"texture-renderable-float32-webgl",renderbuffer:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,renderbuffer:!0},"rgb10a2unorm-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,renderbuffer:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:"texture-formats-norm16-webgl",x:ge},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:"texture-formats-norm16-webgl",x:ge},rg32uint:{gl:33340,b:8,c:2,renderbuffer:!0},rg32sint:{gl:33339,b:8,c:2,renderbuffer:!0},rg32float:{gl:33328,b:8,c:2,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",renderbuffer:!0},rgba16uint:{gl:36214,b:8,c:4,renderbuffer:!0},rgba16sint:{gl:36232,b:8,c:4,renderbuffer:!0},rgba16float:{gl:34842,gl1:6408,b:8,c:4,render:"texture-renderable-float16-webgl",filter:"texture-filter-linear-float16-webgl"},"rgba16unorm-webgl":{gl:32859,b:2,c:4,f:"texture-formats-norm16-webgl",renderbuffer:!0,x:ge},"rgba16snorm-webgl":{gl:36763,b:2,c:4,f:"texture-formats-norm16-webgl",x:ge},"rgb32float-webgl":{gl:34837,gl1:6407,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",gl2ext:Vf,gl1ext:Uf,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,renderbuffer:!0},rgba32sint:{gl:36226,b:16,c:4,renderbuffer:!0},rgba32float:{gl:34836,b:16,c:4,render:"texture-renderable-float32-webgl",filter:"texture-filter-linear-float32-webgl",renderbuffer:!0},stencil8:{gl:36168,gl1:36168,b:1,c:1,attachment:36128,renderbuffer:!0},depth16unorm:{gl:33189,gl1:33189,b:2,c:1,attachment:36096,renderbuffer:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096},depth32float:{gl:36012,b:4,c:1,attachment:36096,renderbuffer:!0},"depth24plus-stencil8":{gl:34041,gl1:34041,b:4,c:2,p:1,attachment:33306,renderbuffer:!0,depthTexture:!0},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,renderbuffer:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,renderbuffer:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:pt,f:X},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:gt,f:X},"bc1-rgba-unorm":{gl:33777,x:pt,f:X},"bc1-rgba-unorm-srgb":{gl:35916,x:gt,f:X},"bc2-rgba-unorm":{gl:33778,x:pt,f:X},"bc2-rgba-unorm-srgb":{gl:35918,x:gt,f:X},"bc3-rgba-unorm":{gl:33779,x:pt,f:X},"bc3-rgba-unorm-srgb":{gl:35919,x:gt,f:X},"bc4-r-unorm":{gl:36283,x:ze,f:X},"bc4-r-snorm":{gl:36284,x:ze,f:X},"bc5-rg-unorm":{gl:36285,x:ze,f:X},"bc5-rg-snorm":{gl:36286,x:ze,f:X},"bc6h-rgb-ufloat":{gl:36495,x:mt,f:X},"bc6h-rgb-float":{gl:36494,x:mt,f:X},"bc7-rgba-unorm":{gl:36492,x:mt,f:X},"bc7-rgba-unorm-srgb":{gl:36493,x:mt,f:X},"etc2-rgb8unorm":{gl:37492,f:le},"etc2-rgb8unorm-srgb":{gl:37494,f:le},"etc2-rgb8a1unorm":{gl:37496,f:le},"etc2-rgb8a1unorm-srgb":{gl:37497,f:le},"etc2-rgba8unorm":{gl:37493,f:le},"etc2-rgba8unorm-srgb":{gl:37495,f:le},"eac-r11unorm":{gl:37488,f:le},"eac-r11snorm":{gl:37489,f:le},"eac-rg11unorm":{gl:37490,f:le},"eac-rg11snorm":{gl:37491,f:le},"astc-4x4-unorm":{gl:37808,f:S},"astc-4x4-unorm-srgb":{gl:37840,f:S},"astc-5x4-unorm":{gl:37809,f:S},"astc-5x4-unorm-srgb":{gl:37841,f:S},"astc-5x5-unorm":{gl:37810,f:S},"astc-5x5-unorm-srgb":{gl:37842,f:S},"astc-6x5-unorm":{gl:37811,f:S},"astc-6x5-unorm-srgb":{gl:37843,f:S},"astc-6x6-unorm":{gl:37812,f:S},"astc-6x6-unorm-srgb":{gl:37844,f:S},"astc-8x5-unorm":{gl:37813,f:S},"astc-8x5-unorm-srgb":{gl:37845,f:S},"astc-8x6-unorm":{gl:37814,f:S},"astc-8x6-unorm-srgb":{gl:37846,f:S},"astc-8x8-unorm":{gl:37815,f:S},"astc-8x8-unorm-srgb":{gl:37847,f:S},"astc-10x5-unorm":{gl:37819,f:S},"astc-10x5-unorm-srgb":{gl:37851,f:S},"astc-10x6-unorm":{gl:37817,f:S},"astc-10x6-unorm-srgb":{gl:37849,f:S},"astc-10x8-unorm":{gl:37818,f:S},"astc-10x8-unorm-srgb":{gl:37850,f:S},"astc-10x10-unorm":{gl:37819,f:S},"astc-10x10-unorm-srgb":{gl:37851,f:S},"astc-12x10-unorm":{gl:37820,f:S},"astc-12x10-unorm-srgb":{gl:37852,f:S},"astc-12x12-unorm":{gl:37821,f:S},"astc-12x12-unorm-srgb":{gl:37853,f:S},"pvrtc-rgb4unorm-webgl":{gl:35840,f:Qt},"pvrtc-rgba4unorm-webgl":{gl:35842,f:Qt},"pvrtc-rbg2unorm-webgl":{gl:35841,f:Qt},"pvrtc-rgba2unorm-webgl":{gl:35843,f:Qt},"etc1-rbg-unorm-webgl":{gl:36196,f:Nf},"atc-rgb-unorm-webgl":{gl:35986,f:kn},"atc-rgba-unorm-webgl":{gl:35986,f:kn},"atc-rgbai-unorm-webgl":{gl:34798,f:kn}},Hf={[6403]:1,[36244]:1,[33319]:2,[33320]:2,[6407]:3,[36248]:3,[6408]:4,[36249]:4,[6402]:1,[34041]:1,[6406]:1,[6409]:1,[6410]:2},Lf={[5126]:4,[5125]:4,[5124]:4,[5123]:2,[5122]:2,[5131]:2,[5120]:1,[5121]:1};function Tt(e,t){let r=At(t),n=bt[r];if(!n||(E(e)?n.gl===void 0:n.gl1===void 0))return!1;let i=n.x||E(e)&&n.gl2ext||n.gl1ext;return i?Boolean(e.getExtension(i)):!0}function Ws(e,t){var r;return Tt(e,t)&&((r=bt[t])===null||r===void 0?void 0:r.renderbuffer)}function At(e){if(typeof e=="string")return e;let t=Object.entries(bt).find(r=>{let[,n]=r;return n.gl===e||n.gl1===e});if(!t)throw new Error(`Unknown texture format ${e}`);return t[0]}function vt(e,t){let r=bt[e],n=t?r?.gl:r?.gl1;if(n===void 0)throw new Error(`Unsupported texture format ${e}`);return n}function Hs(e,t){let r=At(t);if(!Tt(e,r))return!1;try{if((0,Vn.decodeTextureFormat)(r).signed)return!1}catch{return!1}return r.endsWith("32float")?Boolean(e.getExtension("OES_texture_float_linear")):r.endsWith("16float")?Boolean(e.getExtension("OES_texture_half_float_linear")):!0}function Ls(e,t){let r=At(t);return!(!Tt(e,r)||typeof r=="number")}function Ke(e,t){let r=At(e),n=vt(r,t),i=(0,Vn.decodeTextureFormat)(r);return{format:n,dataFormat:Xf(i.format,i.integer,i.normalized,n),type:i.dataType?Zt(i.dataType):5121,compressed:i.compressed}}function Xs(e){let t=bt[e];if(!(t!=null&&t.attachment))throw new Error(`${e} is not a depth stencil format`);return t.attachment}function js(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6408,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:6408,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:5121,i=null,s=null;try{i=e.createTexture(),e.bindTexture(3553,i);let o=0,a=1,l=1,f=0,u=new Uint8Array([0,0,255,255]);e.texImage2D(3553,o,t,a,l,f,r,n,u),s=e.createFramebuffer(),e.bindFramebuffer(36160,s),e.framebufferTexture2D(36160,36064,3553,i,0);let _=e.checkFramebufferStatus(36160)===36053;return e.bindTexture(3553,null),_}finally{e.deleteTexture(i),e.deleteFramebuffer(s)}}function yt(e,t){let r=At(e),n=Ke(r,t),i=Hf[n.dataFormat]||4,s=Lf[n.type]||1;return i*s}function Xf(e,t,r,n){if(n===6408||n===6407)return n;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;default:return 6408}}function zs(e){let t=jf(e);for(let r of Vs(e))t.add(r);return t}function jf(e){e.getExtension("EXT_color_buffer_float"),e.getExtension("WEBGL_color_buffer_float"),e.getExtension("EXT_float_blend");let t=new Set;for(let r of Object.keys(Ks))zf(e,r)&&t.add(r);return t}function zf(e,t){let r=Ks[t];if(!r)return!1;let[n,i]=r||[],s=E(e)?i:n;if(typeof s=="boolean")return s;switch(t){case"texture-renderable-rgba32float-webgl":return E(e)?Boolean(e.getExtension(s)):js(e);case"glsl-derivatives":return Hn(e,s);case"glsl-frag-data":return Hn(e,s,{behavior:"require"});case"glsl-frag-depth":return Hn(e,s);default:return Boolean(e.getExtension(s))}}var Wn={};function Hn(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!ks(r))return!0;if(t in Wn)return Wn[t];let n=r.behavior||"enable",i=`#extension GL_${t} : ${n}
|
|
71
|
+
void main(void) {}`,s=e.createShader(35633);if(!s)throw new Error("shader");e.shaderSource(s,i),e.compileShader(s);let o=e.getShaderParameter(s,35713);return e.deleteShader(s),Wn[t]=o,o}var Ks={webgl:[!0,!0],webgl2:[!1,!0],"timer-query-webgl":["EXT_disjoint_timer_query","EXT_disjoint_timer_query_webgl2"],"transform-feedback-webgl2":[!1,!0],"vertex-array-object-webgl1":["OES_vertex_array_object",!0],"instanced-rendering-webgl1":["ANGLE_instanced_arrays",!0],"multiple-render-targets-webgl1":["WEBGL_draw_buffers",!0],"index-uint32-webgl1":["OES_element_index_uint",!0],"blend-minmax-webgl1":["EXT_blend_minmax",!0],"texture-blend-float-webgl1":["EXT_float_blend","EXT_float_blend"],"texture-formats-srgb-webgl1":["EXT_sRGB",!0],"texture-formats-depth-webgl1":["WEBGL_depth_texture",!0],"texture-formats-float32-webgl1":["OES_texture_float",!0],"texture-formats-float16-webgl1":["OES_texture_half_float",!0],"texture-filter-linear-float32-webgl":["OES_texture_float_linear","OES_texture_float_linear"],"texture-filter-linear-float16-webgl":["OES_texture_half_float_linear","OES_texture_half_float_linear"],"texture-filter-anisotropic-webgl":["EXT_texture_filter_anisotropic","EXT_texture_filter_anisotropic"],"texture-renderable-rgba32float-webgl":["WEBGL_color_buffer_float","EXT_color_buffer_float"],"texture-renderable-float32-webgl":[!1,"EXT_color_buffer_float"],"texture-renderable-float16-webgl":["EXT_color_buffer_half_float","EXT_color_buffer_half_float"],"glsl-frag-data":["WEBGL_draw_buffers",!0],"glsl-frag-depth":["EXT_frag_depth",!0],"glsl-derivatives":["OES_standard_derivatives",!0],"glsl-texture-lod":["EXT_shader_texture_lod",!0]};function Ys(e){let t=In(e);return{maxTextureDimension1D:0,maxTextureDimension2D:e.getParameter(3379),maxTextureDimension3D:t?t.getParameter(32883):0,maxTextureArrayLayers:t?t.getParameter(35071):0,maxBindGroups:1,maxDynamicUniformBuffersPerPipelineLayout:0,maxDynamicStorageBuffersPerPipelineLayout:0,maxSampledTexturesPerShaderStage:e.getParameter(35660),maxSamplersPerShaderStage:e.getParameter(35661),maxStorageBuffersPerShaderStage:0,maxStorageTexturesPerShaderStage:0,maxUniformBuffersPerShaderStage:t?t.getParameter(35375):0,maxUniformBufferBindingSize:t?t.getParameter(35376):0,maxStorageBufferBindingSize:0,minUniformBufferOffsetAlignment:t?t.getParameter(35380):0,minStorageBufferOffsetAlignment:0,maxVertexBuffers:0,maxVertexAttributes:e.getParameter(34921),maxVertexBufferArrayStride:2048,maxInterStageShaderComponents:t?t.getParameter(35659):0,maxComputeWorkgroupStorageSize:0,maxComputeInvocationsPerWorkgroup:0,maxComputeWorkgroupSizeX:0,maxComputeWorkgroupSizeY:0,maxComputeWorkgroupSizeZ:0,maxComputeWorkgroupsPerDimension:0}}function $s(e){let t=In(e);function r(i){return e.getParameter(i)}function n(i,s){return t?t.getParameter(i):s||0}return{[33902]:r(33902),[33901]:r(33901),[3379]:r(3379),[34076]:r(34076),[34930]:r(34930),[35661]:r(35661),[35660]:r(35660),[34024]:r(34024),[36348]:r(36348),[34921]:r(34921),[36347]:r(36347),[36349]:r(36349),[3386]:r(3386),[34047]:r(34047),[32883]:n(32883),[35071]:n(35071),[37447]:n(37447),[36063]:n(36063),[35379]:n(35379),[35374]:n(35374),[35377]:n(35377),[34852]:n(34852),[36203]:n(36203),[33001]:n(33001),[33e3]:n(33e3),[37157]:n(37157),[35373]:n(35373),[35657]:n(35657),[36183]:n(36183),[37137]:n(37137),[34045]:n(34045),[35978]:n(35978),[35979]:n(35979),[35968]:n(35968),[35376]:n(35376),[35375]:n(35375),[35659]:n(35659),[37154]:n(37154),[35371]:n(35371),[35658]:n(35658),[35076]:n(35076),[35077]:n(35077),[35380]:n(35380)}}var no=v(x(),1);var sr=v(x(),1);var B=v(x(),1);function C(e,t,r){let i=k.attach(e).gl;if(Kf(t))return r(e);let{nocatch:s=!0}=t;Ee(i),he(i,t);let o;if(s)o=r(i),pe(i);else try{o=r(i)}finally{pe(i)}return o}function Kf(e){for(let t in e)return!1;return!0}var er=v(x(),1);function Zs(e,t,r,n){if((0,er.isObjectEmpty)(t))return n(e);Ee(e.gl);try{return Yf(e,t),he(e,r),n(e)}finally{pe(e.gl)}}function Yf(e,t){let r=k.attach(e),{gl:n}=r;if(t.cullMode)switch(t.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(t.frontFace&&n.frontFace(Rt("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.depthBias!==void 0&&n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0),t.depthWriteEnabled!==void 0&&n.depthMask(qf("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(Gt("depthCompare",t.depthCompare))),t.stencilWriteMask){let i=t.stencilWriteMask;n.stencilMaskSeparate(1028,i),n.stencilMaskSeparate(1029,i)}if(t.stencilReadMask&&er.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let i=t.stencilReadMask||4294967295,s=Gt("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,s,0,i),n.stencilFuncSeparate(1029,s,0,i)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let i=Ln("stencilPassOperation",t.stencilPassOperation),s=Ln("stencilFailOperation",t.stencilFailOperation),o=Ln("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(1028,s,o,i),n.stencilOpSeparate(1029,s,o,i)}if(t.blendColorOperation||t.blendAlphaOperation){n.enable(3042);let i=qs("blendColorOperation",t.blendColorOperation||"add"),s=qs("blendAlphaOperation",t.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let o=Jt("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=Jt("blendColorDstFactor",t.blendColorDstFactor||"zero"),l=Jt("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),f=Jt("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");n.blendFuncSeparate(o,a,l,f)}}function Gt(e,t){return Rt(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Ln(e,t){return Rt(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function qs(e,t){return Rt(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Jt(e,t){return Rt(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773})}function $f(e,t){return`Illegal parameter ${t} for ${e}`}function Rt(e,t,r){if(!(t in r))throw new Error($f(e,t));return r[t]}function qf(e,t){return t}function tr(e){let t={};return e.addressModeU&&(t[10242]=Xn(e.addressModeU)),e.addressModeV&&(t[10243]=Xn(e.addressModeV)),e.addressModeW&&(t[32882]=Xn(e.addressModeW)),e.magFilter&&(t[10240]=Js(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=Zf(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=Gt("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function Qs(e){let t={...e};return e[10241]!==9728&&(t[10241]=9729),t[10242]=33071,t[10243]=33071,t}function Xn(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Js(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function Zf(e,t){if(!t)return Js(e);switch(e){case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var fe=v(x(),1),j=class extends fe.Buffer{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t,r),this.device=void 0,this.gl=void 0,this.gl2=void 0,this.handle=void 0,this.glTarget=void 0,this.glUsage=void 0,this.glIndexType=5123,this.byteLength=void 0,this.bytesUsed=void 0,this.device=t,this.gl=this.device.gl,this.gl2=this.device.gl2;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),t.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Qf(this.props.usage),this.glUsage=Jf(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.byteLength+r,i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,t),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(t,r,n),this.trackAllocatedMemory(n)}_initWithByteLength(t){(0,fe.assert)(t>=0);let r=t;t===0&&(r=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=0,i=void 0,s=this.device.isWebGL2?36663:this.glTarget;this.gl.bindBuffer(s,this.handle),n!==0||i!==void 0?(this.device.assertWebGL2(),this.gl2.bufferSubData(s,r,t,n,i)):this.gl.bufferSubData(s,r,t),this.gl.bindBuffer(s,null),this._setDebugData(t,r,t.byteLength)}async readAsync(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1?arguments[1]:void 0;return this.readSyncWebGL2(t,r)}readSyncWebGL2(){var t;let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1?arguments[1]:void 0;this.device.assertWebGL2(),n=(t=n)!==null&&t!==void 0?t:this.byteLength-r;let i=new Uint8Array(n),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl2.getBufferSubData(36662,r,i,s,n),this.gl.bindBuffer(36662,null),this._setDebugData(i,r,n),i}};function Qf(e){return e&fe.Buffer.INDEX?34963:e&fe.Buffer.VERTEX?34962:e&fe.Buffer.UNIFORM?35345:34962}function Jf(e){return e&fe.Buffer.INDEX||e&fe.Buffer.VERTEX?35044:e&fe.Buffer.UNIFORM?35048:35044}var Gs=v(x(),1);var Ue=class extends Gs.Sampler{constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.parameters=void 0,this.device=t,this.parameters=tr(r),this.device.isWebGL2&&(this.handle=this.handle||this.device.gl2.createSampler(),this._setSamplerParameters(this.parameters))}destroy(){this.handle&&(this.device.gl2.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(let[r,n]of Object.entries(t)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl2.samplerParameterf(this.handle,i,n);break;default:this.device.gl2.samplerParameteri(this.handle,i,n);break}}}};var Gf={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},U=class extends B.Texture{constructor(t,r){var n;super(t,{...Gf,format:"rgba8unorm",...r}),this.MAX_ATTRIBUTES=void 0,this.device=void 0,this.gl=void 0,this.gl2=void 0,this.handle=void 0,this.sampler=void 0,this.glFormat=void 0,this.type=void 0,this.dataFormat=void 0,this.mipmaps=void 0,this.target=void 0,this.textureUnit=void 0,this.loaded=!1,this._video=void 0,this.device=t,this.gl=this.device.gl,this.gl2=this.device.gl2,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=ec(this.props),this.loaded=!1,typeof((n=this.props)===null||n===void 0?void 0:n.data)=="string"&&Object.assign(this.props,{data:(0,B.loadImage)(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}initialize(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.props.dimension==="cube")return this.initializeCube(t);let r=t.data;if(r instanceof Promise)return r.then(T=>this.initialize(Object.assign({},t,{pixels:T,data:T}))),this;let n=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(n&&r.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,r.addEventListener("loadeddata",()=>this.initialize(t)),this;let{parameters:i={}}=t,{pixels:s=null,pixelStore:o={},textureUnit:a=void 0}=t;r||(r=s);let{width:l,height:f,dataFormat:u,type:_,compressed:p=!1,mipmaps:g=!0}=t,{depth:b=0}=t,A=vt(t.format,this.device.isWebGL2);return{width:l,height:f,compressed:p,dataFormat:u,type:_}=this._deduceParameters({format:t.format,type:_,dataFormat:u,compressed:p,data:r,width:l,height:f}),this.width=l,this.height=f,this.glFormat=A,this.type=_,this.dataFormat=u,this.textureUnit=a,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),g&&this.device.isWebGL1&&rr(this.width,this.height)&&(B.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaps`)(),g=!1),this.mipmaps=g,this.setImageData({data:r,width:l,height:f,depth:b,format:A,type:_,dataFormat:u,parameters:o,compressed:p}),this.setSampler(t.sampler),this._setSamplerParameters(i),g&&this.generateMipmap(),n&&(this._video={video:r,parameters:i,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(t){let{mipmaps:r=!0,parameters:n={}}=t;return this.setCubeMapImageData(t).then(()=>{this.loaded=!0,r&&this.generateMipmap(t),this.setSampler(t.sampler),this._setSamplerParameters(n)}),this}setSampler(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r;t instanceof Ue?(this.sampler=t,r=t.props):(this.sampler=new Ue(this.device,t),r=t);let n=tr(r);return this._setSamplerParameters(n),this}resize(t){let{height:r,width:n,mipmaps:i=!1}=t;return n!==this.width||r!==this.height?this.initialize({width:n,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:t,parameters:r,lastTime:n}=this._video;if(n===t.currentTime||t.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:t,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=t.currentTime}}generateMipmap(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.device.isWebGL1&&rr(this.width,this.height)?(B.log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaping`)(),this):(this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),C(this.gl,t,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this)}setImageData(t){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(t);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:n=null,level:i=0,glFormat:s=this.glFormat,offset:o=0,parameters:a={}}=t,{data:l=null,type:f=this.type,width:u=this.width,height:_=this.height,dataFormat:p=this.dataFormat,compressed:g=!1}=t;l||(l=n),{type:f,dataFormat:p,compressed:g,width:u,height:_}=this._deduceParameters({format:this.props.format,type:f,dataFormat:p,compressed:g,data:l,width:u,height:_});let{gl:b}=this;b.bindTexture(this.target,this.handle);let A=null;({data:l,dataType:A}=this._getDataType({data:l,compressed:g}));let T;if(C(this.gl,a,()=>{switch(A){case"null":b.texImage2D(r,i,s,u,_,0,p,f,l);break;case"typed-array":b.texImage2D(r,i,s,u,_,0,p,f,l,o);break;case"buffer":T=this.device.assertWebGL2(),T.bindBuffer(35052,l.handle||l),T.texImage2D(r,i,s,u,_,0,p,f,o),T.bindBuffer(35052,null);break;case"browser-object":this.device.isWebGL2?b.texImage2D(r,i,s,u,_,0,p,f,l):b.texImage2D(r,i,s,p,f,l);break;case"compressed":for(let[R,y]of l.entries())b.compressedTexImage2D(r,R,y.format,y.width,y.height,0,y.data);break;default:(0,B.assert)(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let R=yt(this.props.format,this.device.isWebGL2);this.trackAllocatedMemory(this.width*this.height*R,"Texture")}return this.loaded=!0,this}setSubImageData(t){let{target:r=this.target,pixels:n=null,data:i=null,x:s=0,y:o=0,width:a=this.width,height:l=this.height,level:f=0,glFormat:u=this.glFormat,type:_=this.type,dataFormat:p=this.dataFormat,compressed:g=!1,offset:b=0,parameters:A={}}=t;if({type:_,dataFormat:p,compressed:g,width:a,height:l}=this._deduceParameters({format:this.props.format,type:_,dataFormat:p,compressed:g,data:i,width:a,height:l}),(0,B.assert)(this.depth===1,"texSubImage not supported for 3D textures"),i||(i=n),i&&i.data){let T=i;i=T.data,a=T.shape[0],l=T.shape[1]}i instanceof j&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),C(this.gl,A,()=>{if(g)this.gl.compressedTexSubImage2D(r,f,s,o,a,l,u,i);else if(i===null)this.gl.texSubImage2D(r,f,s,o,a,l,p,_,null);else if(ArrayBuffer.isView(i))this.gl.texSubImage2D(r,f,s,o,a,l,p,_,i,b);else if(typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer){let T=this.device.assertWebGL2();T.bindBuffer(35052,i),T.texSubImage2D(r,f,s,o,a,l,p,_,b),T.bindBuffer(35052,null)}else this.device.isWebGL2?this.device.assertWebGL2().texSubImage2D(r,f,s,o,a,l,p,_,i):this.gl.texSubImage2D(r,f,s,o,p,_,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return B.log.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.textureUnit,{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,this.handle),t}unbind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.textureUnit,{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,null),t}_getDataType(t){let{data:r,compressed:n=!1}=t;return n?{data:r,dataType:"compressed"}:r===null?{data:r,dataType:"null"}:ArrayBuffer.isView(r)?{data:r,dataType:"typed-array"}:r instanceof j?{data:r.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&r instanceof WebGLBuffer?{data:r,dataType:"buffer"}:{data:r,dataType:"browser-object"}}_deduceParameters(t){let{format:r,data:n}=t,{width:i,height:s,dataFormat:o,type:a,compressed:l}=t,f=Ke(r,this.device.isWebGL2);return o=o||f.dataFormat,a=a||f.type,l=l||f.compressed,{width:i,height:s}=this._deduceImageSize(n,i,s),{dataFormat:o,type:a,compressed:l,width:i,height:s,format:r,data:n}}_deduceImageSize(t,r,n){let i;return typeof ImageData<"u"&&t instanceof ImageData?i={width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?i={width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?i={width:t.width,height:t.height}:typeof ImageBitmap<"u"&&t instanceof ImageBitmap?i={width:t.width,height:t.height}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?i={width:t.videoWidth,height:t.videoHeight}:t?i={width:r,height:n}:i={width:r>=0?r:1,height:n>=0?n:1},(0,B.assert)(i,"Could not deduced texture size"),(0,B.assert)(r===void 0||i.width===r,"Deduced texture width does not match supplied width"),(0,B.assert)(n===void 0||i.height===n,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(t){let{gl:r}=this,{width:n,height:i,pixels:s,data:o,format:a=6408,type:l=5121}=t,f=s||o,u=await Promise.all(U.FACES.map(_=>{let p=f[_];return Promise.all(Array.isArray(p)?p:[p])}));this.bind(),U.FACES.forEach((_,p)=>{u[p].length>1&&this.props.mipmaps!==!1&&B.log.warn(`${this.id} has mipmap and multiple LODs.`)(),u[p].forEach((g,b)=>{n&&i?r.texImage2D(_,b,a,n,i,0,a,l,g):r.texImage2D(_,b,a,a,l,g)})}),this.unbind()}setImageDataForFace(t){let{face:r,width:n,height:i,pixels:s,data:o,format:a=6408,type:l=5121}=t,{gl:f}=this,u=s||o;return this.bind(),u instanceof Promise?u.then(_=>this.setImageDataForFace(Object.assign({},t,{face:r,data:_,pixels:_}))):this.width||this.height?f.texImage2D(r,0,a,n,i,0,a,l,u):f.texImage2D(r,0,a,a,l,u),this}setImageData3D(t){let{level:r=0,dataFormat:n,format:i,type:s,width:o,height:a,depth:l=1,offset:f=0,data:u,parameters:_={}}=t;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let p=Ke(i,this.device.isWebGL2);if(C(this.gl,_,()=>{ArrayBuffer.isView(u)&&this.gl.texImage3D(this.target,r,p.format,o,a,l,0,p.dataFormat,p.type,u),u instanceof j&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,r,n,o,a,l,0,i,s,f))}),u&&u.byteLength)this.trackAllocatedMemory(u.byteLength,"Texture");else{let g=yt(this.props.format,this.device.isWebGL2);this.trackAllocatedMemory(this.width*this.height*this.depth*g,"Texture")}return this.loaded=!0,this}_setSamplerParameters(t){if(this.device.isWebGL1&&rr(this.width,this.height)&&(t=Qs(t)),!(0,B.isObjectEmpty)(t)){tc(t),this.gl.bindTexture(this.target,this.handle);for(let[r,n]of Object.entries(t)){let i=Number(r),s=n;switch(i){case 33082:case 33083:this.gl.texParameterf(this.target,i,s);break;default:this.gl.texParameteri(this.target,i,s);break}}this.gl.bindTexture(this.target,null)}}_getWebGL1NPOTParameterOverride(t,r){if(this.device.isWebGL1&&rr(this.width,this.height))switch(t){case 10241:if(r!==9729&&r!==9728)return 9729;break;case 10242:case 10243:return 33071;default:break}return r}};U.FACES=[34069,34070,34071,34072,34073,34074];function ec(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(e.dimension)}}function rr(e,t){return!e||!t?!1:!(0,B.isPowerOfTwo)(e)||!(0,B.isPowerOfTwo)(t)}function tc(e){B.log.log(1,"texture sampler parameters",e)()}var ro=v(x(),1);var me=v(x(),1);var eo=v(x(),1);function nr(e,t){if(typeof t!="string")return t;let r=Number(t);if(!isNaN(r))return r;t=t.replace(/^.*\./,"");let n=e[t];return(0,eo.assert)(n!==void 0,`Accessing undefined constant GL.${t}`),n}var Ye="Resource subclass must define virtual methods",ir=class extends me.Resource{constructor(t,r,n){super(t,r,n),this.device=void 0,this.gl=void 0,this.gl2=void 0,this._handle=void 0,this._bound=!1,this.byteLength=0,this.device=k.attach(t);let i=this.device.gl;bs(i);let{id:s}=r||{};this.gl=i,this.gl2=i,this.id=s||(0,me.uid)(this.constructor.name),this._handle=r?.handle,this._handle===void 0&&(this._handle=this._createHandle()),this.byteLength=0}toString(){return`${this.constructor.name}(${this.id})`}get handle(){return this._handle}delete(){let{deleteChildren:t=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,r&&t&&r.filter(Boolean).forEach(n=>n.destroy()),this}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.handle;if(typeof t!="function")return this._bindHandle(t),this;let r;return this._bound?r=t():(this._bindHandle(this.handle),this._bound=!0,r=t(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}getParameter(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t=nr(this.gl,t),(0,me.assert)(t);let i=(this.constructor.PARAMETERS||{})[t];if(i){let s=E(this.gl);if(!((!("webgl2"in i)||s)&&(!("extension"in i)||this.gl.getExtension(i.extension)))){let a=i.webgl1,l="webgl2"in i?i.webgl2:i.webgl1;return s?l:a}}return this._getParameter(t,r)}getParameters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{parameters:r,keys:n}=t,i=this.constructor.PARAMETERS||{},s=E(this.gl),o={},a=r||Object.keys(i);for(let l of a){let f=i[l];if(f&&(!("webgl2"in f)||s)&&(!("extension"in f)||this.gl.getExtension(f.extension))){let _=n?this.device.getGLKey(l):l;o[_]=this.getParameter(l,t),n&&f.type==="GLenum"&&(o[_]=this.device.getGLKey(o[_]))}}return o}setParameter(t,r){t=nr(this.gl,t),(0,me.assert)(t);let i=(this.constructor.PARAMETERS||{})[t];if(i){let s=E(this.gl);if(!((!("webgl2"in i)||s)&&(!("extension"in i)||this.gl.getExtension(i.extension))))throw new Error("Parameter not available on this platform");i.type==="GLenum"&&(r=nr(r))}return this._setParameter(t,r),this}setParameters(t){for(let r in t)this.setParameter(r,t[r]);return this}stubRemovedMethods(t,r,n){return(0,me.stubRemovedMethods)(this,t,r,n)}initialize(t){}_createHandle(){throw new Error(Ye)}_deleteHandle(){throw new Error(Ye)}_bindHandle(t){throw new Error(Ye)}_getOptsFromHandle(){throw new Error(Ye)}_getParameter(t,r){throw new Error(Ye)}_setParameter(t,r){throw new Error(Ye)}};var to;to=Symbol.toStringTag;var ee=class extends ir{get[to](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}static isTextureFormatSupported(t,r){return Ws(t.gl,r)}constructor(t,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(t,r,ee.defaultProps),this.glFormat=void 0,this.glFormat=vt(this.props.format,t.isWebGL2),this._initialize(this.props)}resize(t){(t.width!==this.width||t.height!==this.height)&&(Object.assign(this.props,{...t,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(t){let{format:r,width:n,height:i,samples:s}=t;(0,ro.assert)(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),s!==0&&this.device.isWebGL2?this.gl2.renderbufferStorageMultisample(36161,s,this.glFormat,n,i):this.gl.renderbufferStorage(36161,this.glFormat,n,i),this.gl.bindRenderbuffer(36161,null),this.trackAllocatedMemory(n*i*(s||1)*yt(this.glFormat,this.device.isWebGL2))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(t){this.gl.bindRenderbuffer(36161,t)}};ee.defaultProps={id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0};var ce=class extends sr.Framebuffer{get texture(){return this.colorAttachments[0]}constructor(t,r){super(t,r),this.device=void 0,this.gl=void 0,this.handle=void 0;let n=r.handle===null;if(this.device=t,this.gl=t.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){t.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(36160,this.handle);for(let i=0;i<this.colorAttachments.length;++i){let s=this.colorAttachments[i],o=36064+i;s&&this._attachOne(o,s)}this.depthStencilAttachment&&this._attachOne(Xs(this.depthStencilAttachment.format),this.depthStencilAttachment),this.gl.bindFramebuffer(36160,null)}r.check!==!1&&this._checkStatus()}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}_checkStatus(){let{gl:t}=this,r=t.bindFramebuffer(36160,this.handle),n=t.checkFramebufferStatus(36160);if(t.bindFramebuffer(36160,r||null),n!==36053)throw new Error(`Framebuffer ${nc(n)}`)}createDepthStencilTexture(t){return new ee(this.device,{id:`${this.id}-depth-stencil`,format:t,width:this.width,height:this.height})}resizeAttachments(t,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;t===void 0&&(t=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.resize({width:t,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.resize({width:t,height:r}),this}_attachOne(t,r){if(r instanceof ee)return this._attachWEBGLRenderbuffer(t,r),r;if(Array.isArray(r)){let[n,i=0,s=0]=r;return this._attachTexture(t,n,i,s),n}else if(r instanceof U)return this._attachTexture(t,r,0,0),r;throw new Error("attach")}_attachWEBGLRenderbuffer(t,r){this.gl.framebufferRenderbuffer(36160,t,36161,r.handle)}_attachTexture(t,r,n,i){let{gl:s,gl2:o}=this.device;switch(s.bindTexture(r.target,r.handle),r.target){case 35866:case 32879:this.device.assertWebGL2(),o?.framebufferTextureLayer(36160,t,r.target,i,n);break;case 34067:let a=rc(n);s.framebufferTexture2D(36160,t,a,r.handle,i);break;case 3553:s.framebufferTexture2D(36160,t,3553,r.handle,i);break;default:(0,sr.assert)(!1,"Illegal texture type")}s.bindTexture(r.target,null)}};function rc(e){return e<34069?e+34069:e}function nc(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}var or=class extends no.CanvasContext{constructor(t,r){super(r),this.device=void 0,this.presentationSize=void 0,this._framebuffer=null,this.device=t,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new ce(this.device,{handle:null}),this._framebuffer}update(){let t=this.getPixelSize();(t[0]!==this.presentationSize[0]||t[1]!==this.presentationSize[1])&&(this.presentationSize=t,this.resize())}resize(t){if(!this.device.gl)return;if(this.canvas){let n=this.getDevicePixelRatio(t?.useDevicePixels);this.setDevicePixelRatio(n,t);return}let r=this.device.gl.getExtension("STACKGL_resize_drawingbuffer");r&&t&&"width"in t&&"height"in t&&r.resize(t.width,t.height)}commit(){}};var ue=v(x(),1),ic={spector:ue.log.get("spector")||ue.log.get("inspect")},sc="https://spectorcdn.babylonjs.com/spector.bundle.js",oc=1,z=null,io=!1;async function so(e){if(!globalThis.SPECTOR)try{await(0,ue.loadScript)(sc)}catch(t){ue.log.warn(String(t))}}function oo(e){var t,r;if(e={...ic,...e},!((t=e)!==null&&t!==void 0&&t.spector)||(!z&&globalThis.SPECTOR&&(ue.log.probe(oc,"SPECTOR found and initialized")(),z=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=z)),!z))return null;if(!io){var n,i;io=!0,z.spyCanvases(),(n=z)===null||n===void 0||n.onCaptureStarted.add(a=>ue.log.info("Spector capture started:",a)()),(i=z)===null||i===void 0||i.onCapture.add(a=>{var l,f,u;ue.log.info("Spector capture complete:",a)(),(l=z)===null||l===void 0||l.getResultUI(),(f=z)===null||f===void 0||f.resultView.display(),(u=z)===null||u===void 0||u.resultView.addCapture(a)})}if((r=e)!==null&&r!==void 0&&r.canvas){var s,o;if(typeof e.spector=="string"&&e.spector!==e.canvas.id)return z;(s=z)===null||s===void 0||s.startCapture((o=e)===null||o===void 0?void 0:o.canvas,500),new Promise(a=>setTimeout(a,2e3)).then(a=>{var l;ue.log.info("Spector capture stopped after 2 seconds")(),(l=z)===null||l===void 0||l.stopCapture()})}return z}var xe=v(x(),1);var Ve=function(e){return e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e}(Ve||{});var ac="https://unpkg.com/webgl-debug@2.0.1/index.js";function ao(e){return e.luma=e.luma||{},e.luma}async function lo(){J()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await(0,xe.loadScript)(ac))}function fo(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e?t.debug?fc(e,t):lc(e):null}function lc(e){let t=ao(e);return t.realContext?t.realContext:e}function fc(e,t){if(!globalThis.WebGLDebugUtils)return xe.log.warn("webgl-debug not loaded")(),e;let r=ao(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Ve,...e});let n=globalThis.WebGLDebugUtils.makeDebugContext(e,cc.bind(null,t),uc.bind(null,t));for(let o in Ve)!(o in n)&&typeof Ve[o]=="number"&&(n[o]=Ve[o]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.setPrototypeOf(i,n);let s=Object.create(i);return r.realContext=e,r.debugContext=s,s.debug=!0,s}function jn(e,t){t=Array.from(t).map(n=>n===void 0?"undefined":n);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function cc(e,t,r,n){n=Array.from(n).map(l=>l===void 0?"undefined":l);let i=globalThis.WebGLDebugUtils.glEnumToString(t),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,n),o=e.webgl2?"gl2":"gl1",a=`${i} in ${o}.${r}(${s})`;xe.log.error(a)();debugger;if(e.throwOnError)throw new Error(a)}function uc(e,t,r){let n="";if(xe.log.level>=1&&(n=jn(t,r),xe.log.log(1,n)()),e.break&&e.break.length>0&&(n=n||jn(t,r),e.break.every(s=>n.indexOf(s)!==-1)))debugger;for(let i of r)if(i===void 0){if(n=n||jn(t,r),e.throwOnError)throw new Error(`Undefined argument: ${n}`);xe.log.error(`Undefined argument: ${n}`)();debugger}}var _o=v(x(),1);function uo(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[_,p]=i;r.push({message:p.trim(),type:co(_),lineNum:0,linePos:0});continue}let[s,o,a,...l]=i,f=parseInt(a,10);isNaN(f)&&(f=0);let u=parseInt(o,10);isNaN(u)&&(u=0),r.push({message:l.join(":").trim(),type:co(s),lineNum:f,linePos:u})}return r}function co(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var ar=class extends _o.Shader{constructor(t,r){switch(super(t,r),this.device=void 0,this.handle=void 0,this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return this.getCompilationInfoSync()}getCompilationInfoSync(){let t=this.device.gl.getShaderInfoLog(this.handle);return uo(t)}_compile(t){t=(i=>i.startsWith("#version ")?i:`#version 100
|
|
72
|
+
${i}`)(t);let{gl:n}=this.device;if(n.shaderSource(this.handle,t),n.compileShader(this.handle),this.compilationStatus=n.getShaderParameter(this.handle,35713)?"success":"error",this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}};var ho=v(x(),1);var _c=256,dc=1024,hc=16384,zn=6144,lr=class extends ho.RenderPass{constructor(t,r){super(t,r),this.device=void 0,this.glParameters=void 0,this.device=t,Ee(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){pe(this.device.gl),this.props.framebuffer&&he(this.device,{framebuffer:null})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),r.scissorTest=Boolean(t.scissorRect),t.scissorRect&&(r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=t.stencilReference),this.glParameters=r,he(this.device,r)}clear(){let t={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=hc,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=_c,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=dc,t.clearStencil=this.props.clearStencil),r!==0&&C(this.device,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0,0,0];C(this.device.gl2,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl2.clearBufferiv(zn,t,r);break;case Uint32Array:this.device.gl2.clearBufferuiv(zn,t,r);break;case Float32Array:default:this.device.gl2.clearBufferfv(zn,t,r);break}})}};var H=v(x(),1),Eo=v(x(),1);var fr=v(x(),1);var pc="Failed to deduce GL constant from typed array";function po(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(pc)}}function Et(e,t){let{clamped:r=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var gc={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},mc={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},Se=class{static getBytesPerElement(t){return Et(t.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(t){return(0,fr.assert)(t.size),Et(t.type||5126).BYTES_PER_ELEMENT*t.size}static resolve(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return new Se(gc,...r)}constructor(){this.offset=void 0,this.stride=void 0,this.type=void 0,this.size=void 0,this.divisor=void 0,this.normalized=void 0,this.integer=void 0,this.buffer=void 0,this.index=void 0;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(i=>this._assign(i)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return Se.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return Se.getBytesPerVertex(this)}_assign(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return t=(0,fr.checkProps)("Accessor",t,mc),t.type!==void 0&&(this.type=t.type,(t.type===5124||t.type===5125)&&(this.integer=!0)),t.size!==void 0&&(this.size=t.size),t.offset!==void 0&&(this.offset=t.offset),t.stride!==void 0&&(this.stride=t.stride),t.normalize!==void 0&&(this.normalized=t.normalize),t.normalized!==void 0&&(this.normalized=t.normalized),t.integer!==void 0&&(this.integer=t.integer),t.divisor!==void 0&&(this.divisor=t.divisor),t.buffer!==void 0&&(this.buffer=t.buffer),t.index!==void 0&&(typeof t.index=="boolean"?this.index=t.index?1:0:this.index=t.index),t.instanced!==void 0&&(this.divisor=t.instanced?1:0),t.isInstanced!==void 0&&(this.divisor=t.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function go(e){return bc.includes(e)}var bc=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],mo={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2<f32>","float32x2"],[35665]:[5126,3,"vec3","vec3<f32>","float32x3"],[35666]:[5126,4,"vec4","vec4<f32>","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2<i32>","sint32x2"],[35668]:[5124,3,"ivec3","vec3<i32>","sint32x3"],[35669]:[5124,4,"ivec4","vec4<i32>","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2<u32>","uint32x2"],[36295]:[5125,3,"uvec3","vec3<u32>","uint32x3"],[36296]:[5125,4,"uvec4","vec4<u32>","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2<f32>","float32x2"],[35672]:[5126,3,"bvec3","vec3<f32>","float32x3"],[35673]:[5126,4,"bvec4","vec4<f32>","float32x4"],[35674]:[5126,8,"mat2","mat2x2<f32>"],[35685]:[5126,8,"mat2x3","mat2x3<f32>"],[35686]:[5126,8,"mat2x4","mat2x4<f32>"],[35687]:[5126,12,"mat3x2","mat3x2<f32>"],[35675]:[5126,12,"mat3","mat3x3<f32>"],[35688]:[5126,12,"mat3x4","mat3x4<f32>"],[35689]:[5126,16,"mat4x2","mat4x2<f32>"],[35690]:[5126,16,"mat4x3","mat4x3<f32>"],[35676]:[5126,16,"mat4","mat4x4<f32>"]};function Kn(e){let t=mo[e];if(!t)throw new Error("uniform");let[r,n,,i]=t;return{format:i,components:n,glType:r}}function bo(e){let t=mo[e];if(!t)throw new Error("attribute");let[,r,,n,i]=t;return{attributeType:n,vertexFormat:i,components:r}}function To(e,t){let r={attributes:[],bindings:[]};r.attributes=Tc(e,t);let n=yc(e,t);for(let a of n){let l=a.uniforms.map(f=>({name:f.name,format:f.format,byteOffset:f.byteOffset,byteStride:f.byteStride,arrayLength:f.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:l})}let i=vc(e,t),s=0;for(let a of i)if(go(a.type)){let{viewDimension:l,sampleType:f}=Ec(a.type);r.bindings.push({type:"texture",name:a.name,location:s,viewDimension:l,sampleType:f}),a.textureUnit=s,s+=1}i.length&&(r.uniforms=i);let o=Ac(e,t);return o!=null&&o.length&&(r.varyings=o),r}function Tc(e,t){let r=[],n=e.getProgramParameter(t,35721);for(let i=0;i<n;i++){let s=e.getActiveAttrib(t,i);if(!s)throw new Error("activeInfo");let{name:o,type:a}=s,l=e.getAttribLocation(t,o);if(l>=0){let{attributeType:f}=bo(a),u=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:l,stepMode:u,type:f})}}return r.sort((i,s)=>i.location-s.location),r}function Ac(e,t){if(!E(e))return[];let r=e,n=[],i=e.getProgramParameter(t,35971);for(let s=0;s<i;s++){let o=r.getTransformFeedbackVarying(t,s);if(!o)throw new Error("activeInfo");let{name:a,type:l,size:f}=o,{glType:u,components:_}=Kn(l),p=new Se({type:u,size:f*_}),g={location:s,name:a,accessor:p};n.push(g)}return n.sort((s,o)=>s.location-o.location),n}function vc(e,t){let r=[],n=e.getProgramParameter(t,35718);for(let i=0;i<n;i++){let s=e.getActiveUniform(t,i);if(!s)throw new Error("activeInfo");let{name:o,size:a,type:l}=s,{name:f,isArray:u}=xc(o),_=e.getUniformLocation(t,f),p={location:_,name:f,size:a,type:l,isArray:u};if(r.push(p),p.size>1)for(let g=0;g<p.size;g++){let b=`${f}[${g}]`;_=e.getUniformLocation(t,b);let A={...p,name:b,location:_};r.push(A)}}return r}function yc(e,t){if(!E(e))return[];let r=e,n=(o,a)=>r.getActiveUniformBlockParameter(t,o,a),i=[],s=r.getProgramParameter(t,35382);for(let o=0;o<s;o++){let a={name:r.getActiveUniformBlockName(t,o)||"",location:n(o,35391),byteLength:n(o,35392),vertex:n(o,35396),fragment:n(o,35398),uniformCount:n(o,35394),uniforms:[]},l=n(o,35395)||[],f=r.getActiveUniforms(t,l,35383),u=r.getActiveUniforms(t,l,35384),_=r.getActiveUniforms(t,l,35387),p=r.getActiveUniforms(t,l,35388);for(let g=0;g<a.uniformCount;++g){let b=r.getActiveUniform(t,l[g]);if(!b)throw new Error("activeInfo");a.uniforms.push({name:b.name,format:Kn(f[g]).format,type:f[g],arrayLength:u[g],byteOffset:_[g],byteStride:p[g]})}i.push(a)}return i.sort((o,a)=>o.location-a.location),i}var Rc={[35678]:["2d","float"],[35680]:["cube","float"],[35679]:["3d","float"],[35682]:["3d","depth"],[36289]:["2d-array","float"],[36292]:["2d-array","depth"],[36293]:["cube","float"],[36298]:["2d","sint"],[36299]:["3d","sint"],[36300]:["cube","sint"],[36303]:["2d-array","uint"],[36306]:["2d","uint"],[36307]:["3d","uint"],[36308]:["cube","uint"],[36311]:["2d-array","uint"]};function Ec(e){let t=Rc[e];if(!t)throw new Error("sampler");let[r,n]=t;return{viewDimension:r,sampleType:n}}function xc(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function Ao(e,t,r,n){let i=e,s=n;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof n!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}function vo(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}function yo(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(e)}}var Ro=4,cr=class extends H.RenderPipeline{constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.vs=void 0,this.fs=void 0,this.introspectedLayout=void 0,this.uniforms={},this.bindings={},this.varyings=null,this._uniformCount=0,this._uniformSetters={},this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=(0,H.cast)(r.vs),this.fs=(0,H.cast)(r.fs);let{varyings:n,bufferMode:i=35981}=r;if(n&&n.length>0){var s;this.device.assertWebGL2(),this.varyings=n,(s=this.device.gl2)===null||s===void 0||s.transformFeedbackVaryings(this.handle,n,i)}switch(this._compileAndLink(),this.introspectedLayout=To(this.device.gl,this.handle),this.shaderLayout=(0,Eo.mergeShaderLayout)(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":H.log.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(t){for(let[r,n]of Object.entries(t)){let i=this.shaderLayout.bindings.find(s=>s.name===r)||this.shaderLayout.bindings.find(s=>s.name===`${r}Uniforms`);if(!i){let s=this.shaderLayout.bindings.map(o=>`"${o.name}"`).join(", ");H.log.warn(`Unknown binding "${r}" in render pipeline "${this.id}", expected one of ${s}`)();continue}switch(n||H.log.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(n instanceof j)&&!(n.buffer instanceof j))throw new Error("buffer value");break;case"texture":if(!(n instanceof U||n instanceof ce))throw new Error("texture value");break;case"sampler":H.log.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(i.type)}this.bindings[r]=n}}setUniforms(t){let{bindings:r}=(0,H.splitUniformsAndBindings)(t);Object.keys(r).forEach(n=>{H.log.warn(`Unsupported value "${JSON.stringify(r[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,t)}draw(t){var r;let{renderPass:n,vertexArray:i,vertexCount:s,instanceCount:o,firstVertex:a=0,transformFeedback:l}=t,f=vo(this.props.topology),u=Boolean(i.indexBuffer),_=(r=i.indexBuffer)===null||r===void 0?void 0:r.glIndexType,p=Number(o)>0;if(!this._areTexturesRenderable()||s===0)return!1;this.device.gl.useProgram(this.handle),i.bindBeforeRender(n),l&&l.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let g=n;return Zs(this.device,this.props.parameters,g.glParameters,()=>{if(u&&p){var b;(b=this.device.gl2)===null||b===void 0||b.drawElementsInstanced(f,s||0,_,a,o||0)}else if(u)this.device.gl.drawElements(f,s||0,_,a);else if(p){var A;(A=this.device.gl2)===null||A===void 0||A.drawArraysInstanced(f,a,s||0,o||0)}else this.device.gl.drawArrays(f,a,s||0);l&&l.end()}),i.unbindAfterRender(n),!0}_compileAndLink(){let{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),H.log.time(Ro,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),H.log.timeEnd(Ro,`linkProgram for ${this.id}`)(),!t.debug&&H.log.level,!t.getProgramParameter(this.handle,35714))throw new Error(`Error linking: ${t.getProgramInfoLog(this.handle)}`);if(t.validateProgram(this.handle),!t.getProgramParameter(this.handle,35715))throw new Error(`Error validating: ${t.getProgramInfoLog(this.handle)}`)}_areTexturesRenderable(){let t=!0;for(let[,r]of Object.entries(this.bindings))r instanceof U&&(r.update(),t=t&&r.loaded);return t}_applyBindings(){this.device.gl.useProgram(this.handle);let{gl2:t}=this.device;if(!t)throw new Error("bindings");let r=0,n=0;for(let i of this.shaderLayout.bindings){let s=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!s)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:o}=i,a=t.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);t.uniformBlockBinding(this.handle,n,a),s instanceof j?t.bindBufferBase(35345,n,s.handle):t.bindBufferRange(35345,n,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),n+=1;break;case"texture":if(!(s instanceof U||s instanceof ce))throw new Error("texture");let l;if(s instanceof U)l=s;else if(s instanceof ce&&s.colorAttachments[0]instanceof U)H.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=s.colorAttachments[0];else throw new Error("No texture");t.activeTexture(33984+r),t.bindTexture(l.target,l.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let r of this.shaderLayout.uniforms||[]){var t;let{name:n,location:i,type:s,textureUnit:o}=r,a=(t=this.uniforms[n])!==null&&t!==void 0?t:o;a!==void 0&&Ao(this.device.gl,i,s,a)}}};var So=v(x(),1);var _r=v(x(),1);var ur=class extends _r.CommandBuffer{constructor(t){super(t,{}),this.device=void 0,this.commands=[],this.device=t}submitCommands(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.commands;for(let r of t)switch(r.name){case"copy-buffer-to-buffer":Sc(this.device,r.options);break;case"copy-buffer-to-texture":Oc(this.device,r.options);break;case"copy-texture-to-buffer":wc(this.device,r.options);break;case"copy-texture-to-texture":Pc(this.device,r.options);break}}};function Sc(e,t){let r=t.source,n=t.destination,i=e.assertWebGL2();if(i){var s,o;i.bindBuffer(36662,r.handle),i.bindBuffer(36663,n.handle),i.copyBufferSubData(36662,36663,(s=t.sourceOffset)!==null&&s!==void 0?s:0,(o=t.destinationOffset)!==null&&o!==void 0?o:0,t.size),i.bindBuffer(36662,null),i.bindBuffer(36663,null)}else throw new Error("copyBufferToBuffer not implemented in WebGL1")}function Oc(e,t){throw new Error("Not implemented")}function wc(e,t){let{source:r,mipLevel:n=0,aspect:i="all",width:s=t.source.width,height:o=t.source.height,depthOrArrayLayers:a=0,origin:l=[0,0],destination:f,byteOffset:u=0,bytesPerRow:_,rowsPerImage:p}=t;if(i!=="all")throw new Error("not supported");if(n!==0||a!==0||_||p)throw new Error("not implemented");let g=e.assertWebGL2(),{framebuffer:b,destroyFramebuffer:A}=xo(r);try{let T=f,R=s||b.width,y=o||b.height,O=Ke(b.texture.format,!0),W=O.dataFormat,$=O.type;g.bindBuffer(35051,T.handle),g.bindFramebuffer(36160,b.handle),g.readPixels(l[0],l[1],R,y,W,$,u)}finally{g.bindBuffer(35051,null),g.bindFramebuffer(36160,null),A&&b.destroy()}}function Pc(e,t){let{source:r,origin:n=[0,0],destination:i}=t,{width:s=t.destination.width,height:o=t.destination.width}=t,a=0,l=6408,{framebuffer:f,destroyFramebuffer:u}=xo(r),[_,p]=n,g=!1;e.gl.bindFramebuffer(36160,f.handle);let b=null,A;if(i instanceof U)b=i,s=Number.isFinite(s)?s:b.width,o=Number.isFinite(o)?o:b.height,b.bind(0),A=b.destination;else throw new Error("whoops");return g||e.gl.copyTexImage2D(A,a,l,_,p,s,o,0),b&&b.unbind(),u&&f.destroy(),b}function xo(e){if(e instanceof _r.Texture){let{width:t,height:r,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var dr=class extends So.CommandEncoder{constructor(t,r){super(t,r),this.device=void 0,this.commandBuffer=void 0,this.device=t,this.commandBuffer=new ur(t)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}};var qe=v(x(),1);var Oo;Oo=Symbol.toStringTag;var $e=class extends qe.VertexArray{get[Oo](){return"VertexArray"}static isConstantAttributeZeroSupported(t){return t.info.type==="webgl2"||Yt()==="Chrome"}constructor(t,r){super(t,r),this.device=void 0,this.handle=void 0,this.buffer=null,this.bufferValue=null,this.init=!1,this.device=t,this.handle=this.device.gl2.createVertexArray()}destroy(){if(super.destroy(),this.buffer){var t;(t=this.buffer)===null||t===void 0||t.destroy()}this.handle&&(this.device.gl2.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){let r=t;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl2.bindVertexArray(this.handle),this.device.gl2.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r}setBuffer(t,r){let n=r;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:o,offset:a,normalized:l,integer:f,divisor:u}=this._getAccessor(t);this.device.gl2.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),f?(this.device.assertWebGL2(),this.device.gl2.vertexAttribIPointer(t,i,s,o,a)):this.device.gl.vertexAttribPointer(t,i,s,l,o,a),this.device.gl.enableVertexAttribArray(t),this.device.gl2.vertexAttribDivisor(t,u||0),this.attributes[t]=n}setConstant(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){if(this.device.gl2.bindVertexArray(this.handle),!this.init){let t=this.indexBuffer;this.device.gl2.bindBuffer(34963,t?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl2.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){let r=this.attributes[t];ArrayBuffer.isView(r)&&this.device.setConstantAttribute(t,r)}}_getAccessor(t){let r=this.attributeInfos[t];if(!r)throw new Error(`Unknown attribute location ${t}`);let n=Zt(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i=$e.isConstantAttributeZeroSupported(this.device)||t!==0;(r||i)&&(t=Number(t),this.device.gl2.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl2.bindVertexArray(null))}getConstantBuffer(t,r){let n=Ic(r),i=n.byteLength*t,s=n.length*t;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),o=o||!Fc(n,this.bufferValue),o){let a=(0,qe.getScratchArray)(r.constructor,s);(0,qe.fillArray)({target:a,source:n,start:0,count:s}),this.buffer.write(a),this.bufferValue=r}return this.buffer}};function Ic(e){return Array.isArray(e)?new Float32Array(e):e}function Fc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var pr=v(x(),1);var hr=class extends pr.TransformFeedback{constructor(t,r){super(t,r),this.device=void 0,this.gl2=void 0,this.handle=void 0,this.layout=void 0,this.buffers={},this.unusedBuffers={},this.bindOnUse=!0,this._bound=!1,t.assertWebGL2(),this.device=t,this.gl2=t.gl2,this.handle=this.props.handle||this.gl2.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl2.deleteTransformFeedback(this.handle),super.destroy()}begin(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"point-list";this.gl2.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl2.beginTransformFeedback(yo(t))}end(){this.gl2.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl2.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let r in t)this.setBuffer(r,t[r])})}setBuffer(t,r){let n=this._getVaryingIndex(t),{buffer:i,byteLength:s,byteOffset:o}=this._getBufferRange(r);if(n<0){this.unusedBuffers[t]=i,pr.log.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(n,i,o,s)}getBuffer(t){if(wo(t))return this.buffers[t]||null;let r=this._getVaryingIndex(t);return r>=0?this.buffers[r]:null}bind(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.handle;if(typeof t!="function")return this.gl2.bindTransformFeedback(36386,t),this;let r;return this._bound?r=t():(this.gl2.bindTransformFeedback(36386,this.handle),this._bound=!0,r=t(),this._bound=!1,this.gl2.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof j)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=t.buffer.byteLength}=t;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(t){if(wo(t))return Number(t);for(let r of this.layout.varyings)if(t===r.name)return r.location;return-1}_bindBuffers(){for(let t in this.buffers){let{buffer:r,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),r,i,n)}}_unbindBuffers(){for(let t in this.buffers)this.gl2.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0,s=r&&r.handle;!s||i===void 0?this.gl2.bindBufferBase(35982,t,s):this.gl2.bindBufferRange(35982,t,s,n,i)}};function wo(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var Ze=v(x(),1);var Yn=v(x(),1);function $n(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return(0,Yn.assert)(!1),0}}function Po(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return(0,Yn.assert)(!1),0}}function xt(e,t){var r;let{sourceX:n=0,sourceY:i=0,sourceFormat:s=6408,sourceAttachment:o=36064}=t||{},{target:a=null,sourceWidth:l,sourceHeight:f,sourceType:u}=t||{},{framebuffer:_,deleteFramebuffer:p}=Io(e);(0,Ze.assert)(_);let{gl:g,handle:b}=_;l=l||_.width,f=f||_.height;let A=o-36064;u=u||((r=_.colorAttachments[A])===null||r===void 0?void 0:r.type)||5121,a=Mc(a,u,s,l,f),u=u||po(a);let T=g.bindFramebuffer(36160,b);return g.readPixels(n,i,l,f,s,u,a),g.bindFramebuffer(36160,T||null),p&&_.destroy(),a}function qn(e,t){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:s=6408,targetByteOffset:o=0}=t||{},{sourceWidth:a,sourceHeight:l,sourceType:f}=t||{},{framebuffer:u,deleteFramebuffer:_}=Io(e);(0,Ze.assert)(u),a=a||u.width,l=l||u.height;let p=u;f=f||5121;let g=r;if(!g){let A=$n(s),T=Po(f),R=o+a*l*A*T;g=p.device.createBuffer({byteLength:R})}let b=e.device.createCommandEncoder();return b.copyTextureToBuffer({source:e,width:a,height:l,origin:[n,i],destination:g,byteOffset:o}),b.destroy(),_&&u.destroy(),g}function Io(e){return e instanceof Ze.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Nc(e),deleteFramebuffer:!0}}function Nc(e,t){let{device:r,width:n,height:i,id:s}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[e]})}function Mc(e,t,r,n,i){if(e)return e;t=t||5121;let s=Et(t,{clamped:!1}),o=$n(r);return new s(n*i*o)}var St=1,k=class extends N.Device{static isSupported(){return typeof WebGLRenderingContext<"u"||_s()}get features(){return this._features=this._features||zs(this.gl),this._features}get limits(){return this._limits=this._limits||Ys(this.gl),this._limits}static attach(t){if(t instanceof k)return t;if(t?.device instanceof N.Device)return t.device;if(!Cc(t))throw new Error("Invalid WebGLRenderingContext");return new k({gl:t})}static async create(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};N.log.groupCollapsed(St,"WebGLDevice created")(),typeof t.canvas=="string"&&await N.CanvasContext.pageLoaded,(N.log.get("debug")||t.debug)&&await lo();let{spector:r}=t;if((N.log.get("spector")||r)&&await so(),N.log.probe(St+1,"DOM is loaded")(),t.gl&&t.gl.device)return k.attach(t.gl);let n=new k(t),i=`Created ${n.info.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return N.log.probe(St,i)(),N.log.table(St,n.info)(),N.log.groupEnd(St)(),n}constructor(t){var r,n;super({...t,id:t.id||(0,N.uid)("webgl-device")}),this.info=void 0,this.canvasContext=void 0,this.handle=void 0,this.lost=void 0,this._resolveContextLost=void 0,this._features=void 0,this._limits=void 0,this.renderPass=null,this.gl=void 0,this.gl2=null,this.debug=!1,this.isWebGL1=void 0,this.isWebGL2=void 0,this._canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1},this._extensions={},this._polyfilled=!1,this.spector=void 0,this._webglLimits=void 0,this._constants=void 0;let i=(r=t.gl)===null||r===void 0?void 0:r.device;if(i)throw new Error(`WebGL context already attached to device ${i.id}`);let s=t.canvas||((n=t.gl)===null||n===void 0?void 0:n.canvas);this.canvasContext=new or(this,{...t,canvas:s}),this.lost=new Promise(u=>{this._resolveContextLost=u});let o=u=>{var _;return(_=this._resolveContextLost)===null||_===void 0?void 0:_.call(this,{reason:"destroyed",message:"Computer entered sleep mode, or too many apps or browser tabs are using the GPU."})},a=t.gl||null;if(a=a||(J()?Cs(this.canvasContext.canvas,{...t,onContextLost:o}):null),a=a||(J()?null:ds({...t,onContextLost:o})),!a)throw new Error("WebGL context creation failed");this.handle=a,this.gl=this.handle,this.gl2=this.gl,this.isWebGL2=Bc(this.gl),this.isWebGL1=!this.isWebGL2,this.canvasContext.resize(),this.info=Bs(this.gl),this.gl.device=this,this.gl._version=this.isWebGL2?2:1,xs(this.gl);let{enable:l=!0,copyState:f=!1}=t;if(Dn(this.gl,{enable:l,copyState:f,log:function(){for(var u=arguments.length,_=new Array(u),p=0;p<u;p++)_[p]=arguments[p];return N.log.log(1,..._)()}}),J()&&t.debug&&(this.gl=fo(this.gl,{...t,webgl2:this.isWebGL2,throwOnError:!0}),this.gl2=this.gl,this.debug=!0,N.log.level=Math.max(N.log.level,1),N.log.warn("WebGL debug mode activated. Performance reduced.")()),J()&&t.spector){let u=this.handle.canvas||t.canvas;this.spector=oo({...this.props,canvas:u})}}destroy(){let t=this.gl.getExtension("STACKGL_destroy_context");t&&t.destroy()}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(t){return Tt(this.gl,t)}isTextureFormatFilterable(t){return Hs(this.gl,t)}isTextureFormatRenderable(t){return Ls(this.gl,t)}assertWebGL2(){if(!this.gl2)throw new Error("Requires WebGL2");return this.gl2}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){let r=this._getBufferProps(t);return new j(this,r)}_createTexture(t){return new U(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Ue(this,t)}createShader(t){return new ar(this,t)}createFramebuffer(t){return new ce(this,t)}createRenderPipeline(t){return new cr(this,t)}createVertexArray(t){return new $e(this,t)}beginRenderPass(t){return new lr(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}createTransformFeedback(t){return new hr(this,t)}getDefaultRenderPass(){return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:this.canvasContext.getCurrentFramebuffer()}),this.renderPass}createCommandEncoder(t){return new dr(this,t)}submit(){var t;(t=this.renderPass)===null||t===void 0||t.end(),this.renderPass=null}readPixelsToArrayWebGL(t,r){return xt(t,r)}readPixelsToBufferWebGL2(t,r){return qn(t,r)}get webglLimits(){return this._webglLimits=this._webglLimits||$s(this.gl),this._webglLimits}loseDevice(){var t;let r=!1,n=this.gl.getExtension("WEBGL_lose_context");return n&&(r=!0,n.loseContext()),(t=this._resolveContextLost)===null||t===void 0||t.call(this,{reason:"destroyed",message:"Application triggered context loss"}),r}pushState(){Ee(this.gl)}popState(){pe(this.gl)}setSpectorMetadata(t,r){t.__SPECTOR_Metadata=r}getGLKey(t,r){r=r||this.gl2||this.gl;let n=Number(t);for(let i in r)if(r[i]===n)return`GL.${i}`;return String(t)}setConstantAttribute(t,r){this._constants=this._constants||new Array(this.limits.maxVertexAttributes).fill(null);let n=this._constants[t];switch(n&&Vc(n,r)&&N.log.info(1,`setConstantAttribute(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:Dc(this,t,r);break;case Int32Array:kc(this,t,r);break;case Uint32Array:Uc(this,t,r);break;default:(0,N.assert)(!1)}}};k.type="webgl";function Cc(e){return typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext||typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function Bc(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&e._version===2)}function Dc(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:(0,N.assert)(!1)}}function kc(e,t,r){var n;e.assertWebGL2(),(n=e.gl2)===null||n===void 0||n.vertexAttribI4iv(t,r)}function Uc(e,t,r){var n;e.assertWebGL2(),(n=e.gl2)===null||n===void 0||n.vertexAttribI4uiv(t,r)}function Vc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var Fo=v(x(),1);var Wc=256,Hc=1024,Lc=16384;var Xc="clear: bad arguments";function Zn(e,t){let r=k.attach(e),{framebuffer:n=null,color:i=null,depth:s=null,stencil:o=null}=t||{},a={};n&&(a.framebuffer=n);let l=0;i&&(l|=Lc,i!==!0&&(a.clearColor=i)),s&&(l|=Wc,s!==!0&&(a.clearDepth=s)),o&&(l|=Hc,s!==!0&&(a.clearStencil=s)),(0,Fo.assert)(l!==0,Xc),C(r.gl,a,()=>{r.gl.clear(l)})}var Da=v(w());function No(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Mo(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?No(Object(r),!0).forEach(function(n){jc(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):No(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function jc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Co=`
|
|
73
73
|
uniform DATAFILTER_TYPE filter_min;
|
|
74
74
|
uniform DATAFILTER_TYPE filter_softMin;
|
|
75
75
|
uniform DATAFILTER_TYPE filter_softMax;
|
|
@@ -124,10 +124,10 @@ void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFrom
|
|
|
124
124
|
dataFilter_value = 1.0;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
`,
|
|
127
|
+
`,Bo=`
|
|
128
128
|
uniform bool filter_transformColor;
|
|
129
129
|
in float dataFilter_value;
|
|
130
|
-
`;function
|
|
130
|
+
`;function Do(e){if(!e||!("extensions"in e))return{};var t=e.filterRange,r=t===void 0?[-1,1]:t,n=e.filterEnabled,i=n===void 0?!0:n,s=e.filterTransformSize,o=s===void 0?!0:s,a=e.filterTransformColor,l=a===void 0?!0:a,f=e.filterSoftRange||r;return Mo(Mo({},Number.isFinite(r[0])?{filter_min:r[0],filter_softMin:f[0],filter_softMax:f[1],filter_max:r[1]}:{filter_min:r.map(function(u){return u[0]}),filter_softMin:f.map(function(u){return u[0]}),filter_softMax:f.map(function(u){return u[1]}),filter_max:r.map(function(u){return u[1]})}),{},{filter_enabled:i,filter_useSoftMargin:Boolean(e.filterSoftRange),filter_transformSize:i&&o,filter_transformColor:i&&l})}function zc(e){if(!e||!("extensions"in e))return{};var t=Do(e);if(Number.isFinite(t.filter_min)){var r=Math.fround(t.filter_min);t.filter_min-=r,t.filter_softMin-=r,t.filter_min64High=r;var n=Math.fround(t.filter_max);t.filter_max-=n,t.filter_softMax-=n,t.filter_max64High=n}else{var i=t.filter_min.map(Math.fround);t.filter_min=t.filter_min.map(function(o,a){return o-i[a]}),t.filter_softMin=t.filter_softMin.map(function(o,a){return o-i[a]}),t.filter_min64High=i;var s=t.filter_max.map(Math.fround);t.filter_max=t.filter_max.map(function(o,a){return o-s[a]}),t.filter_softMax=t.filter_softMax.map(function(o,a){return o-s[a]}),t.filter_max64High=s}return t}var ko={"vs:#main-start":`
|
|
131
131
|
#ifdef DATAFILTER_DOUBLE
|
|
132
132
|
dataFilter_setValue(
|
|
133
133
|
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
|
|
@@ -149,11 +149,11 @@ in float dataFilter_value;
|
|
|
149
149
|
if (filter_transformColor) {
|
|
150
150
|
color.a *= dataFilter_value;
|
|
151
151
|
}
|
|
152
|
-
`},
|
|
152
|
+
`},Uo={name:"data-filter",vs:Co,fs:Bo,inject:ko,getUniforms:Do},Vo={name:"data-filter-fp64",vs:Co,fs:Bo,inject:ko,getUniforms:zc};var Ne=v(x(),1),I=v(x(),1),wa=v(x(),1);var D=e=>`${e}`;function _e(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}var Qn={number:{type:"number",validate(e,t){return Number.isFinite(e)&&typeof t=="object"&&(t.max===void 0||e<=t.max)&&(t.min===void 0||e>=t.min)}},array:{type:"array",validate(e,t){return Array.isArray(e)||ArrayBuffer.isView(e)}}};function Ho(e){let t={};for(let[r,n]of Object.entries(e))t[r]=Kc(n);return t}function Lo(e,t,r){let n={};for(let[i,s]of Object.entries(t))e&&i in e&&!s.private?(s.validate&&_e(s.validate(e[i],s),`${r}: invalid ${i}`),n[i]=e[i]):n[i]=s.value;return n}function Kc(e){let t=Wo(e);if(t!=="object")return{value:e,...Qn[t],type:t};if(typeof e=="object")return e?e.type!==void 0?{...e,...Qn[e.type],type:e.type}:e.value===void 0?{type:"object",value:e}:(t=Wo(e.value),{...e,...Qn[t],type:t}):{type:"object",value:null};throw new Error("props")}function Wo(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}var Xo=D`\
|
|
153
153
|
#ifdef MODULE_LOGDEPTH
|
|
154
154
|
logdepth_adjustPosition(gl_Position);
|
|
155
155
|
#endif
|
|
156
|
-
`,
|
|
156
|
+
`,jo=D`\
|
|
157
157
|
#ifdef MODULE_MATERIAL
|
|
158
158
|
gl_FragColor = material_filterColor(gl_FragColor);
|
|
159
159
|
#endif
|
|
@@ -174,25 +174,25 @@ in float dataFilter_value;
|
|
|
174
174
|
#ifdef MODULE_LOGDEPTH
|
|
175
175
|
logdepth_setFragDepth();
|
|
176
176
|
#endif
|
|
177
|
-
`;var
|
|
177
|
+
`;var Yc={vertex:Xo,fragment:jo},zo=/void\s+main\s*\([^)]*\)\s*\{\n?/,Ko=/}\n?[^{}]*$/,Jn=[],Ot="__LUMA_INJECT_DECLARATIONS__";function Yo(e){let t={vertex:{},fragment:{}};for(let r in e){let n=e[r],i=$c(r);typeof n=="string"&&(n={order:0,injection:n}),t[i][r]=n}return t}function $c(e){let t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function wt(e,t,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=t==="vertex";for(let s in r){let o=r[s];o.sort((l,f)=>l.order-f.order),Jn.length=o.length;for(let l=0,f=o.length;l<f;++l)Jn[l]=o[l].injection;let a=`${Jn.join(`
|
|
178
178
|
`)}
|
|
179
|
-
`;switch(
|
|
179
|
+
`;switch(s){case"vs:#decl":i&&(e=e.replace(Ot,a));break;case"vs:#main-start":i&&(e=e.replace(zo,l=>l+a));break;case"vs:#main-end":i&&(e=e.replace(Ko,l=>a+l));break;case"fs:#decl":i||(e=e.replace(Ot,a));break;case"fs:#main-start":i||(e=e.replace(zo,l=>l+a));break;case"fs:#main-end":i||(e=e.replace(Ko,l=>a+l));break;default:e=e.replace(s,l=>l+a)}}return e=e.replace(Ot,""),n&&(e=e.replace(/\}\s*$/,s=>s+Yc[t])),e}var qc=1,te=class{static instantiateModules(t){return t.map(r=>{if(r instanceof te)return r;_e(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${qc++}`);let n=new te(r);return n.dependencies=te.instantiateModules(r.dependencies||[]),n})}constructor(t){this.name=void 0,this.vs=void 0,this.fs=void 0,this.getModuleUniforms=void 0,this.dependencies=void 0,this.deprecations=void 0,this.defines=void 0,this.injections=void 0,this.uniforms={},this.uniformTypes={};let{name:r,vs:n,fs:i,dependencies:s=[],uniformPropTypes:o={},getUniforms:a,deprecations:l=[],defines:f={},inject:u={}}=t;_e(typeof r=="string"),this.name=r,this.vs=n,this.fs=i,this.getModuleUniforms=a,this.dependencies=te.instantiateModules(s),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=f,this.injections=Yo(u),o&&(this.uniforms=Ho(o))}getModuleSource(t){let r;switch(t){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:_e(!1)}let n=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------
|
|
180
180
|
|
|
181
|
-
#define MODULE_${
|
|
181
|
+
#define MODULE_${n}
|
|
182
182
|
${r}
|
|
183
183
|
|
|
184
|
-
`}getUniforms(t,r){return this.getModuleUniforms?this.getModuleUniforms(t,r):
|
|
184
|
+
`}getUniforms(t,r){return this.getModuleUniforms?this.getModuleUniforms(t,r):Lo(t,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(t,r){this.deprecations.forEach(n=>{var i;(i=n.regex)!==null&&i!==void 0&&i.test(t)&&(n.deprecated?r.deprecated(n.old,n.new)():r.removed(n.old,n.new)())})}_parseDeprecationDefinitions(t){return t.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),t}_defaultGetUniforms(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={},n=this.uniforms;for(let i in n){let s=n[i];i in t&&!s.private?(s.validate&&_e(s.validate(t[i],s),`${this.name}: invalid ${i}`),r[i]=t[i]):r[i]=s.value}return r}};function Pt(e){let t=te.instantiateModules(e);return Zc(t)}function Zc(e){let t={},r={};return $o({modules:e,level:0,moduleMap:t,moduleDepth:r}),Object.keys(r).sort((n,i)=>r[i]-r[n]).map(n=>t[n])}function $o(e){let{modules:t,level:r,moduleMap:n,moduleDepth:i}=e;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let s of t)n[s.name]=s,(i[s.name]===void 0||i[s.name]<r)&&(i[s.name]=r);for(let s of t)s.dependencies&&$o({modules:s.dependencies,level:r+1,moduleMap:n,moduleDepth:i})}function qo(e){switch(e?.gpu.toLowerCase()){case"apple":return D`\
|
|
185
185
|
#define APPLE_GPU
|
|
186
186
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
187
187
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
188
188
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
189
189
|
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
|
|
190
190
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
191
|
-
`;case"nvidia":return
|
|
191
|
+
`;case"nvidia":return D`\
|
|
192
192
|
#define NVIDIA_GPU
|
|
193
193
|
// Nvidia optimizes away the calculation necessary for emulated fp64
|
|
194
194
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
195
|
-
`;case"intel":return
|
|
195
|
+
`;case"intel":return D`\
|
|
196
196
|
#define INTEL_GPU
|
|
197
197
|
// Intel optimizes away the calculation necessary for emulated fp64
|
|
198
198
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
@@ -200,9 +200,9 @@ ${r}
|
|
|
200
200
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
201
201
|
// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow
|
|
202
202
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
203
|
-
`;case"amd":return
|
|
203
|
+
`;case"amd":return D`\
|
|
204
204
|
#define AMD_GPU
|
|
205
|
-
`;default:return
|
|
205
|
+
`;default:return D`\
|
|
206
206
|
#define DEFAULT_GPU
|
|
207
207
|
// Prevent driver from optimizing away the calculation necessary for emulated fp64
|
|
208
208
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
@@ -210,12 +210,12 @@ ${r}
|
|
|
210
210
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
211
211
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
212
212
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
213
|
-
`}}function
|
|
213
|
+
`}}function Zo(e){let t="";return e.features.has("webgl2")&&(t+=D`\
|
|
214
214
|
# define FEATURE_GLSL_DERIVATIVES
|
|
215
215
|
# define FEATURE_GLSL_DRAW_BUFFERS
|
|
216
216
|
# define FEATURE_GLSL_FRAG_DEPTH
|
|
217
217
|
# define FEATURE_GLSL_TEXTURE_LOD
|
|
218
|
-
`),e.features.has("webgl2")||(e.features.has("glsl-frag-depth")&&(t+=
|
|
218
|
+
`),e.features.has("webgl2")||(e.features.has("glsl-frag-depth")&&(t+=D`\
|
|
219
219
|
|
|
220
220
|
// FEATURE_GLSL_FRAG_DEPTH => gl_FragDepth is available
|
|
221
221
|
#ifdef GL_EXT_frag_depth
|
|
@@ -224,57 +224,60 @@ ${r}
|
|
|
224
224
|
# define FRAG_DEPTH
|
|
225
225
|
# define gl_FragDepth gl_FragDepthEXT
|
|
226
226
|
#endif
|
|
227
|
-
`),e!=null&&e.features.has("glsl-derivatives")&&(t+=
|
|
227
|
+
`),e!=null&&e.features.has("glsl-derivatives")&&(t+=D`\
|
|
228
228
|
|
|
229
229
|
// FEATURE_GLSL_DERIVATIVES => dxdF, dxdY and fwidth are available
|
|
230
230
|
#if defined(GL_OES_standard_derivatives) || defined(FEATURE_GLSL_DERIVATIVES)
|
|
231
231
|
# extension GL_OES_standard_derivatives : enable
|
|
232
232
|
# define FEATURE_GLSL_DERIVATIVES
|
|
233
233
|
#endif
|
|
234
|
-
`),e!=null&&e.features.has("glsl-frag-data")&&(t+=
|
|
234
|
+
`),e!=null&&e.features.has("glsl-frag-data")&&(t+=D`\
|
|
235
235
|
|
|
236
236
|
// FEATURE_GLSL_DRAW_BUFFERS => gl_FragData[] is available
|
|
237
237
|
#ifdef GL_EXT_draw_buffers
|
|
238
238
|
# extension GL_EXT_draw_buffers : require
|
|
239
239
|
# define FEATURE_GLSL_DRAW_BUFFERS
|
|
240
240
|
#endif
|
|
241
|
-
`),e!=null&&e.features.has("glsl-texture-lod")&&(t+=
|
|
241
|
+
`),e!=null&&e.features.has("glsl-texture-lod")&&(t+=D`\
|
|
242
242
|
// TEXTURE_LOD => texture2DLod etc are available
|
|
243
243
|
#ifdef GL_EXT_shader_texture_lod
|
|
244
244
|
# extension GL_EXT_shader_texture_lod : enable
|
|
245
245
|
# define FEATURE_GLSL_TEXTURE_LOD
|
|
246
246
|
# define TEXTURE_LOD
|
|
247
247
|
#endif
|
|
248
|
-
`)),t}function
|
|
249
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
250
|
-
`,
|
|
251
|
-
`}
|
|
252
|
-
`}return r}function
|
|
253
|
-
|
|
254
|
-
${
|
|
255
|
-
`,
|
|
248
|
+
`)),t}function Jo(e,t,r){var n;if(Number(((n=e.match(/^#version[ \t]+(\d+)/m))===null||n===void 0?void 0:n[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case 300:switch(r){case"vertex":return e=It(e,Qc),e;case"fragment":return e=It(e,Jc),e;default:throw new Error(r)}case 100:switch(r){case"vertex":return e=It(e,Gc),e;case"fragment":return e=It(e,ta),e=tu(e),e;default:throw new Error(r)}default:throw new Error(String(t))}}var Go=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
249
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Qc=[...Go,[Qe("attribute"),"in $1"],[Qe("varying"),"out $1"]],Jc=[...Go,[Qe("varying"),"in $1"]],ea=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],Gc=[...ea,[Qe("in"),"attribute $1"],[Qe("out"),"varying $1"]],ta=[...ea,[Qe("in"),"varying $1"]],eu="gl_FragColor",Qo=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/;function It(e,t){for(let[r,n]of t)e=e.replace(r,n);return e}function tu(e){e=It(e,ta);let t=Qo.exec(e);if(t){let r=t[1];e=e.replace(Qo,"").replace(new RegExp(`\\b${r}\\b`,"g"),eu)}return e}function Qe(e){return new RegExp(`\\b${e}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Gn(e,t){let r="";for(let n in e){let i=e[n];if(r+=`void ${i.signature} {
|
|
250
|
+
`,i.header&&(r+=` ${i.header}`),t[n]){let s=t[n];s.sort((o,a)=>o.order-a.order);for(let o of s)r+=` ${o.injection}
|
|
251
|
+
`}i.footer&&(r+=` ${i.footer}`),r+=`}
|
|
252
|
+
`}return r}function ei(e){let t={vertex:{},fragment:{}};for(let r of e){let n,i;typeof r!="string"?(n=r,i=n.hook):(n={},i=r),i=i.trim();let[s,o]=i.split(":"),a=i.replace(/\(.+/,""),l=Object.assign(n,{signature:o});switch(s){case"vs":t.vertex[a]=l;break;case"fs":t.fragment[a]=l;break;default:throw new Error(s)}}return t}function ra(e,t){return{name:ru(e,t),language:"glsl",version:nu(e)}}function ru(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"unnamed",n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return n?n[1]:t}function nu(e){let t=100,r=e.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let n=parseInt(r[1],10);Number.isFinite(n)&&(t=n)}if(t!==100&&t!==300)throw new Error(`Invalid GLSL version ${t}`);return t}var oa=`
|
|
253
|
+
|
|
254
|
+
${Ot}
|
|
255
|
+
`,iu=D`\
|
|
256
256
|
precision highp float;
|
|
257
|
-
`;function
|
|
257
|
+
`;function aa(e){let{vs:t,fs:r}=e,n=Pt(e.modules||[]);switch(e.platformInfo.shaderLanguage){case"glsl":return{vs:ia(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:ia(e.platformInfo,{...e,source:r,stage:"fragment",modules:n}),getUniforms:sa(n)};case"wgsl":return{vs:na(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:na(e.platformInfo,{...e,source:r,stage:"fragment",modules:n}),getUniforms:sa(n)}}}function na(e,t){let{source:r,stage:n,modules:i,defines:s={},hookFunctions:o=[],inject:a={},log:l}=t;_e(typeof r=="string","shader source must be a string");let f=r,u={};i.forEach(T=>{Object.assign(u,T.getDefines())}),Object.assign(u,s);let _="",p=ei(o),g={},b={},A={};for(let T in a){let R=typeof a[T]=="string"?{injection:a[T],order:0}:a[T],y=/^(v|f)s:(#)?([\w-]+)$/.exec(T);if(y){let O=y[2],W=y[3];O?W==="decl"?b[T]=[R]:A[T]=[R]:g[T]=[R]}else A[T]=[R]}for(let T of i){l&&T.checkDeprecations(f,l);let R=T.getModuleSource(n,"wgsl");_+=R;let y=T.injections[n];for(let O in y){let W=/^(v|f)s:#([\w-]+)$/.exec(O);if(W){let ne=W[2]==="decl"?b:A;ne[O]=ne[O]||[],ne[O].push(y[O])}else g[O]=g[O]||[],g[O].push(y[O])}}return _+=oa,_=wt(_,n,b),_+=Gn(p[n],g),_+=f,_=wt(_,n,A),_}function ia(e,t){let{id:r,source:n,stage:i,language:s="glsl",modules:o,defines:a={},hookFunctions:l=[],inject:f={},prologue:u=!0,log:_}=t;_e(typeof n=="string","shader source must be a string");let p=s==="glsl"?ra(n).version:-1,g=e.shaderLanguageVersion,b=p===100?"#version 100":"#version 300 es",T=n.split(`
|
|
258
258
|
`).slice(1).join(`
|
|
259
|
-
`),R={};
|
|
259
|
+
`),R={};o.forEach(L=>{Object.assign(R,L.getDefines())}),Object.assign(R,a);let y="";switch(s){case"wgsl":break;case"glsl":y=u?`${b}
|
|
260
260
|
|
|
261
261
|
// ----- PROLOGUE -------------------------
|
|
262
|
-
${
|
|
263
|
-
${`#define SHADER_TYPE_${
|
|
264
|
-
${
|
|
265
|
-
${
|
|
266
|
-
${
|
|
262
|
+
${su({id:r,source:n,stage:i})}
|
|
263
|
+
${`#define SHADER_TYPE_${i.toUpperCase()}`}
|
|
264
|
+
${qo(e)}
|
|
265
|
+
${Zo(e)}
|
|
266
|
+
${i==="fragment"?iu:""}
|
|
267
267
|
|
|
268
268
|
// ----- APPLICATION DEFINES -------------------------
|
|
269
269
|
|
|
270
|
-
${
|
|
270
|
+
${ou(R)}
|
|
271
271
|
|
|
272
|
-
`:`${
|
|
273
|
-
`;break}let
|
|
274
|
-
#define SHADER_NAME ${t}_${
|
|
272
|
+
`:`${b}
|
|
273
|
+
`;break}let O=ei(l),W={},$={},ne={};for(let L in f){let ye=typeof f[L]=="string"?{injection:f[L],order:0}:f[L],ie=/^(v|f)s:(#)?([\w-]+)$/.exec(L);if(ie){let K=ie[2],Le=ie[3];K?Le==="decl"?$[L]=[ye]:ne[L]=[ye]:W[L]=[ye]}else ne[L]=[ye]}for(let L of o){_&&L.checkDeprecations(T,_);let ye=L.getModuleSource(i);y+=ye;let ie=L.injections[i];for(let K in ie){let Le=/^(v|f)s:#([\w-]+)$/.exec(K);if(Le){let Xe=Le[2]==="decl"?$:ne;Xe[K]=Xe[K]||[],Xe[K].push(ie[K])}else W[K]=W[K]||[],W[K].push(ie[K])}}return y+="// ----- MAIN SHADER SOURCE -------------------------",y+=oa,y=wt(y,i,$),y+=Gn(O[i],W),y+=T,y=wt(y,i,ne),s==="glsl"&&p!==g&&(y=Jo(y,g,i)),y.trim()}function sa(e){return function(r){let n={};for(let i of e){let s=i.getUniforms(r,n);Object.assign(n,s)}return n}}function su(e){let{id:t,source:r,stage:n}=e;return t&&r.indexOf("SHADER_NAME")===-1?`
|
|
274
|
+
#define SHADER_NAME ${t}_${n}
|
|
275
275
|
|
|
276
|
-
`:""}function
|
|
277
|
-
`)}return t}function Uo(e){if(!e.vs)throw new Error("no vertex shader");let t=wo(e.platformInfo,e.vs),r;return e.fs&&(r=wo(e.platformInfo,e.fs)),{...e,vs:t,fs:r}}function wo(e,t){if(typeof t=="string")return t;switch(e.type){case"webgpu":if(t!=null&&t.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(t!=null&&t.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}}var $=class{constructor(){this._hookFunctions=[],this._defaultModules=[]}static getDefaultShaderAssembler(){return $.defaultShaderAssembler=$.defaultShaderAssembler||new $,$.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(r=>r.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let r=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(t,r){r&&(t=Object.assign(r,{hook:t})),this._hookFunctions.push(t)}assembleShaders(t){let r=this._getModuleList(t.modules),i=this._hookFunctions,n=Uo(t);return{...Do({platformInfo:t.platformInfo,...n,modules:r,hookFunctions:i}),modules:r}}_getModuleList(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=new Array(this._defaultModules.length+t.length),i={},n=0;for(let o=0,s=this._defaultModules.length;o<s;++o){let a=this._defaultModules[o],f=a.name;r[n++]=a,i[f]=!0}for(let o=0,s=t.length;o<s;++o){let a=t[o],f=a.name;i[f]||(r[n++]=a,i[f]=!0)}return r.length=n,Y.instantiateModules(r)}};$.defaultShaderAssembler=void 0;function jt(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=Math.fround(e),n=e-i;return t[r]=i,t[r+1]=n,t}function li(e){return e-Math.fround(e)}function ci(e){let t=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let n=r*4+i;jt(e[i*4+r],t,n*2)}return t}var Vo=I`\
|
|
276
|
+
`:""}function ou(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t="";for(let r in e){let n=e[r];(n||Number.isFinite(n))&&(t+=`#define ${r.toUpperCase()} ${e[r]}
|
|
277
|
+
`)}return t}function fa(e){if(!e.vs)throw new Error("no vertex shader");let t=la(e.platformInfo,e.vs),r;return e.fs&&(r=la(e.platformInfo,e.fs)),{...e,vs:t,fs:r}}function la(e,t){if(typeof t=="string")return t;switch(e.type){case"webgpu":if(t!=null&&t.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(t!=null&&t.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}}var re=class{constructor(){this._hookFunctions=[],this._defaultModules=[]}static getDefaultShaderAssembler(){return re.defaultShaderAssembler=re.defaultShaderAssembler||new re,re.defaultShaderAssembler}addDefaultModule(t){this._defaultModules.find(r=>r.name===(typeof t=="string"?t:t.name))||this._defaultModules.push(t)}removeDefaultModule(t){let r=typeof t=="string"?t:t.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==r)}addShaderHook(t,r){r&&(t=Object.assign(r,{hook:t})),this._hookFunctions.push(t)}assembleShaders(t){let r=this._getModuleList(t.modules),n=this._hookFunctions,i=fa(t);return{...aa({platformInfo:t.platformInfo,...i,modules:r,hookFunctions:n}),modules:r}}_getModuleList(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=new Array(this._defaultModules.length+t.length),n={},i=0;for(let s=0,o=this._defaultModules.length;s<o;++s){let a=this._defaultModules[s],l=a.name;r[i++]=a,n[l]=!0}for(let s=0,o=t.length;s<o;++s){let a=t[s],l=a.name;n[l]||(r[i++]=a,n[l]=!0)}return r.length=i,te.instantiateModules(r)}};re.defaultShaderAssembler=void 0;var ti=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},Te=class{constructor(){}get isAstNode(){return!0}get astNodeType(){return""}evaluate(t){throw new Error("Cannot evaluate node")}evaluateString(t){return this.evaluate(t).toString()}},F=class extends Te{constructor(){super()}},gr=class extends F{constructor(t,r,n,i){super(),this.name=t,this.args=r,this.returnType=n,this.body=i}get astNodeType(){return"function"}},ri=class extends F{constructor(t){super(),this.expression=t}get astNodeType(){return"staticAssert"}},ni=class extends F{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"while"}},ii=class extends F{constructor(t){super(),this.body=t}get astNodeType(){return"continuing"}},si=class extends F{constructor(t,r,n,i){super(),this.init=t,this.condition=r,this.increment=n,this.body=i}get astNodeType(){return"for"}},we=class extends F{constructor(t,r,n,i,s){super(),this.name=t,this.type=r,this.storage=n,this.access=i,this.value=s}get astNodeType(){return"var"}},mr=class extends F{constructor(t,r,n){super(),this.name=t,this.type=r,this.value=n}get astNodeType(){return"override"}},br=class extends F{constructor(t,r,n,i,s){super(),this.name=t,this.type=r,this.storage=n,this.access=i,this.value=s}get astNodeType(){return"let"}},Tr=class extends F{constructor(t,r,n,i,s){super(),this.name=t,this.type=r,this.storage=n,this.access=i,this.value=s}get astNodeType(){return"const"}evaluate(t){return this.value.evaluate(t)}},tt;(function(e){e.increment="++",e.decrement="--"})(tt||(tt={}));(function(e){function t(r){let n=r;if(n=="parse")throw new Error("Invalid value for IncrementOperator");return e[n]}e.parse=t})(tt||(tt={}));var oi=class extends F{constructor(t,r){super(),this.operator=t,this.variable=r}get astNodeType(){return"increment"}},Nt;(function(e){e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})(Nt||(Nt={}));(function(e){function t(r){let n=r;if(n=="parse")throw new Error("Invalid value for AssignOperator");return e[n]}e.parse=t})(Nt||(Nt={}));var ai=class extends F{constructor(t,r,n){super(),this.operator=t,this.variable=r,this.value=n}get astNodeType(){return"assign"}},li=class extends F{constructor(t,r){super(),this.name=t,this.args=r}get astNodeType(){return"call"}},fi=class extends F{constructor(t,r){super(),this.body=t,this.continuing=r}get astNodeType(){return"loop"}},ci=class extends F{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"body"}},ui=class extends F{constructor(t,r,n,i){super(),this.condition=t,this.body=r,this.elseif=n,this.else=i}get astNodeType(){return"if"}},_i=class extends F{constructor(t){super(),this.value=t}get astNodeType(){return"return"}},di=class extends F{constructor(t){super(),this.name=t}get astNodeType(){return"enable"}},Ar=class extends F{constructor(t,r){super(),this.name=t,this.type=r}get astNodeType(){return"alias"}},hi=class extends F{constructor(){super()}get astNodeType(){return"discard"}},pi=class extends F{constructor(){super()}get astNodeType(){return"break"}},gi=class extends F{constructor(){super()}get astNodeType(){return"continue"}},Ae=class extends F{constructor(t){super(),this.name=t}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}},be=class extends Ae{constructor(t,r){super(t),this.members=r}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(t){for(let r=0;r<this.members.length;r++)if(this.members[r].name==t)return r;return-1}},vr=class extends Ae{constructor(t,r,n){super(t),this.format=r,this.access=n}get astNodeType(){return"template"}},mi=class extends Ae{constructor(t,r,n,i){super(t),this.storage=r,this.type=n,this.access=i}get astNodeType(){return"pointer"}},yr=class extends Ae{constructor(t,r,n,i){super(t),this.attributes=r,this.format=n,this.count=i}get astNodeType(){return"array"}get isArray(){return!0}},We=class extends Ae{constructor(t,r,n){super(t),this.format=r,this.access=n}get astNodeType(){return"sampler"}},Q=class extends Te{constructor(){super()}},Rr=class extends Q{constructor(t){super(),this.value=t}get astNodeType(){return"stringExpr"}toString(){return this.value}evaluateString(){return this.value}},He=class extends Q{constructor(t,r){super(),this.type=t,this.args=r}get astNodeType(){return"createExpr"}},bi=class extends Q{constructor(t,r){super(),this.name=t,this.args=r}get astNodeType(){return"callExpr"}evaluate(t){switch(this.name){case"abs":return Math.abs(this.args[0].evaluate(t));case"acos":return Math.acos(this.args[0].evaluate(t));case"acosh":return Math.acosh(this.args[0].evaluate(t));case"asin":return Math.asin(this.args[0].evaluate(t));case"asinh":return Math.asinh(this.args[0].evaluate(t));case"atan":return Math.atan(this.args[0].evaluate(t));case"atan2":return Math.atan2(this.args[0].evaluate(t),this.args[1].evaluate(t));case"atanh":return Math.atanh(this.args[0].evaluate(t));case"ceil":return Math.ceil(this.args[0].evaluate(t));case"clamp":return Math.min(Math.max(this.args[0].evaluate(t),this.args[1].evaluate(t)),this.args[2].evaluate(t));case"cos":return Math.cos(this.args[0].evaluate(t));case"degrees":return this.args[0].evaluate(t)*180/Math.PI;case"distance":return Math.sqrt(Math.pow(this.args[0].evaluate(t)-this.args[1].evaluate(t),2));case"dot":case"exp":return Math.exp(this.args[0].evaluate(t));case"exp2":return Math.pow(2,this.args[0].evaluate(t));case"floor":return Math.floor(this.args[0].evaluate(t));case"fma":return this.args[0].evaluate(t)*this.args[1].evaluate(t)+this.args[2].evaluate(t);case"fract":return this.args[0].evaluate(t)-Math.floor(this.args[0].evaluate(t));case"inverseSqrt":return 1/Math.sqrt(this.args[0].evaluate(t));case"log":return Math.log(this.args[0].evaluate(t));case"log2":return Math.log2(this.args[0].evaluate(t));case"max":return Math.max(this.args[0].evaluate(t),this.args[1].evaluate(t));case"min":return Math.min(this.args[0].evaluate(t),this.args[1].evaluate(t));case"mix":return this.args[0].evaluate(t)*(1-this.args[2].evaluate(t))+this.args[1].evaluate(t)*this.args[2].evaluate(t);case"modf":return this.args[0].evaluate(t)-Math.floor(this.args[0].evaluate(t));case"pow":return Math.pow(this.args[0].evaluate(t),this.args[1].evaluate(t));case"radians":return this.args[0].evaluate(t)*Math.PI/180;case"round":return Math.round(this.args[0].evaluate(t));case"sign":return Math.sign(this.args[0].evaluate(t));case"sin":return Math.sin(this.args[0].evaluate(t));case"sinh":return Math.sinh(this.args[0].evaluate(t));case"saturate":return Math.min(Math.max(this.args[0].evaluate(t),0),1);case"smoothstep":return this.args[0].evaluate(t)*this.args[0].evaluate(t)*(3-2*this.args[0].evaluate(t));case"sqrt":return Math.sqrt(this.args[0].evaluate(t));case"step":return this.args[0].evaluate(t)<this.args[1].evaluate(t)?0:1;case"tan":return Math.tan(this.args[0].evaluate(t));case"tanh":return Math.tanh(this.args[0].evaluate(t));case"trunc":return Math.trunc(this.args[0].evaluate(t));default:throw new Error("Non const function: "+this.name)}}},Ti=class extends Q{constructor(t){super(),this.name=t}get astNodeType(){return"varExpr"}},Er=class extends Q{constructor(t,r){super(),this.name=t,this.initializer=r}get astNodeType(){return"constExpr"}evaluate(t){var r,n;if(this.initializer instanceof He){let i=(r=this.postfix)===null||r===void 0?void 0:r.evaluateString(t),s=(n=this.initializer.type)===null||n===void 0?void 0:n.name,o=t.structs.get(s),a=o?.getMemberIndex(i);if(a!=-1)return this.initializer.args[a].evaluate(t);console.log(a)}return this.initializer.evaluate(t)}},xr=class extends Q{constructor(t){super(),this.value=t}get astNodeType(){return"literalExpr"}evaluate(){return this.value}},Ai=class extends Q{constructor(t,r){super(),this.type=t,this.value=r}get astNodeType(){return"bitcastExpr"}},vi=class extends Q{constructor(t,r){super(),this.type=t,this.args=r}get astNodeType(){return"typecastExpr"}evaluate(t){return this.args[0].evaluate(t)}},Sr=class extends Q{constructor(t){super(),this.contents=t}get astNodeType(){return"groupExpr"}evaluate(t){return this.contents[0].evaluate(t)}},Or=class extends Q{constructor(){super()}},yi=class extends Or{constructor(t,r){super(),this.operator=t,this.right=r}get astNodeType(){return"unaryOp"}evaluate(t){switch(this.operator){case"+":return this.right.evaluate(t);case"-":return-this.right.evaluate(t);case"!":return this.right.evaluate(t)?0:1;case"~":return~this.right.evaluate(t);default:throw new Error("Unknown unary operator: "+this.operator)}}},q=class extends Or{constructor(t,r,n){super(),this.operator=t,this.left=r,this.right=n}get astNodeType(){return"binaryOp"}evaluate(t){switch(this.operator){case"+":return this.left.evaluate(t)+this.right.evaluate(t);case"-":return this.left.evaluate(t)-this.right.evaluate(t);case"*":return this.left.evaluate(t)*this.right.evaluate(t);case"/":return this.left.evaluate(t)/this.right.evaluate(t);case"%":return this.left.evaluate(t)%this.right.evaluate(t);case"==":return this.left.evaluate(t)==this.right.evaluate(t)?1:0;case"!=":return this.left.evaluate(t)!=this.right.evaluate(t)?1:0;case"<":return this.left.evaluate(t)<this.right.evaluate(t)?1:0;case">":return this.left.evaluate(t)>this.right.evaluate(t)?1:0;case"<=":return this.left.evaluate(t)<=this.right.evaluate(t)?1:0;case">=":return this.left.evaluate(t)>=this.right.evaluate(t)?1:0;case"&&":return this.left.evaluate(t)&&this.right.evaluate(t)?1:0;case"||":return this.left.evaluate(t)||this.right.evaluate(t)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}},wr=class extends Te{constructor(){super()}},Ri=class extends wr{constructor(t,r){super(),this.selector=t,this.body=r}get astNodeType(){return"case"}},Ei=class extends wr{constructor(t){super(),this.body=t}get astNodeType(){return"default"}},xi=class extends Te{constructor(t,r,n){super(),this.name=t,this.type=r,this.attributes=n}get astNodeType(){return"argument"}},Si=class extends Te{constructor(t,r){super(),this.condition=t,this.body=r}get astNodeType(){return"elseif"}},Oi=class extends Te{constructor(t,r,n){super(),this.name=t,this.type=r,this.attributes=n}get astNodeType(){return"member"}},Pr=class extends Te{constructor(t,r){super(),this.name=t,this.value=r}get astNodeType(){return"attribute"}},m,h;(function(e){e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(h||(h={}));var d=class{constructor(t,r,n){this.name=t,this.type=r,this.rule=n}toString(){return this.name}},c=class{};m=c;c.none=new d("",h.reserved,"");c.eof=new d("EOF",h.token,"");c.reserved={asm:new d("asm",h.reserved,"asm"),bf16:new d("bf16",h.reserved,"bf16"),do:new d("do",h.reserved,"do"),enum:new d("enum",h.reserved,"enum"),f16:new d("f16",h.reserved,"f16"),f64:new d("f64",h.reserved,"f64"),handle:new d("handle",h.reserved,"handle"),i8:new d("i8",h.reserved,"i8"),i16:new d("i16",h.reserved,"i16"),i64:new d("i64",h.reserved,"i64"),mat:new d("mat",h.reserved,"mat"),premerge:new d("premerge",h.reserved,"premerge"),regardless:new d("regardless",h.reserved,"regardless"),typedef:new d("typedef",h.reserved,"typedef"),u8:new d("u8",h.reserved,"u8"),u16:new d("u16",h.reserved,"u16"),u64:new d("u64",h.reserved,"u64"),unless:new d("unless",h.reserved,"unless"),using:new d("using",h.reserved,"using"),vec:new d("vec",h.reserved,"vec"),void:new d("void",h.reserved,"void")};c.keywords={array:new d("array",h.keyword,"array"),atomic:new d("atomic",h.keyword,"atomic"),bool:new d("bool",h.keyword,"bool"),f32:new d("f32",h.keyword,"f32"),i32:new d("i32",h.keyword,"i32"),mat2x2:new d("mat2x2",h.keyword,"mat2x2"),mat2x3:new d("mat2x3",h.keyword,"mat2x3"),mat2x4:new d("mat2x4",h.keyword,"mat2x4"),mat3x2:new d("mat3x2",h.keyword,"mat3x2"),mat3x3:new d("mat3x3",h.keyword,"mat3x3"),mat3x4:new d("mat3x4",h.keyword,"mat3x4"),mat4x2:new d("mat4x2",h.keyword,"mat4x2"),mat4x3:new d("mat4x3",h.keyword,"mat4x3"),mat4x4:new d("mat4x4",h.keyword,"mat4x4"),ptr:new d("ptr",h.keyword,"ptr"),sampler:new d("sampler",h.keyword,"sampler"),sampler_comparison:new d("sampler_comparison",h.keyword,"sampler_comparison"),struct:new d("struct",h.keyword,"struct"),texture_1d:new d("texture_1d",h.keyword,"texture_1d"),texture_2d:new d("texture_2d",h.keyword,"texture_2d"),texture_2d_array:new d("texture_2d_array",h.keyword,"texture_2d_array"),texture_3d:new d("texture_3d",h.keyword,"texture_3d"),texture_cube:new d("texture_cube",h.keyword,"texture_cube"),texture_cube_array:new d("texture_cube_array",h.keyword,"texture_cube_array"),texture_multisampled_2d:new d("texture_multisampled_2d",h.keyword,"texture_multisampled_2d"),texture_storage_1d:new d("texture_storage_1d",h.keyword,"texture_storage_1d"),texture_storage_2d:new d("texture_storage_2d",h.keyword,"texture_storage_2d"),texture_storage_2d_array:new d("texture_storage_2d_array",h.keyword,"texture_storage_2d_array"),texture_storage_3d:new d("texture_storage_3d",h.keyword,"texture_storage_3d"),texture_depth_2d:new d("texture_depth_2d",h.keyword,"texture_depth_2d"),texture_depth_2d_array:new d("texture_depth_2d_array",h.keyword,"texture_depth_2d_array"),texture_depth_cube:new d("texture_depth_cube",h.keyword,"texture_depth_cube"),texture_depth_cube_array:new d("texture_depth_cube_array",h.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new d("texture_depth_multisampled_2d",h.keyword,"texture_depth_multisampled_2d"),texture_external:new d("texture_external",h.keyword,"texture_external"),u32:new d("u32",h.keyword,"u32"),vec2:new d("vec2",h.keyword,"vec2"),vec3:new d("vec3",h.keyword,"vec3"),vec4:new d("vec4",h.keyword,"vec4"),bitcast:new d("bitcast",h.keyword,"bitcast"),block:new d("block",h.keyword,"block"),break:new d("break",h.keyword,"break"),case:new d("case",h.keyword,"case"),continue:new d("continue",h.keyword,"continue"),continuing:new d("continuing",h.keyword,"continuing"),default:new d("default",h.keyword,"default"),discard:new d("discard",h.keyword,"discard"),else:new d("else",h.keyword,"else"),enable:new d("enable",h.keyword,"enable"),fallthrough:new d("fallthrough",h.keyword,"fallthrough"),false:new d("false",h.keyword,"false"),fn:new d("fn",h.keyword,"fn"),for:new d("for",h.keyword,"for"),function:new d("function",h.keyword,"function"),if:new d("if",h.keyword,"if"),let:new d("let",h.keyword,"let"),const:new d("const",h.keyword,"const"),loop:new d("loop",h.keyword,"loop"),while:new d("while",h.keyword,"while"),private:new d("private",h.keyword,"private"),read:new d("read",h.keyword,"read"),read_write:new d("read_write",h.keyword,"read_write"),return:new d("return",h.keyword,"return"),storage:new d("storage",h.keyword,"storage"),switch:new d("switch",h.keyword,"switch"),true:new d("true",h.keyword,"true"),alias:new d("alias",h.keyword,"alias"),type:new d("type",h.keyword,"type"),uniform:new d("uniform",h.keyword,"uniform"),var:new d("var",h.keyword,"var"),override:new d("override",h.keyword,"override"),workgroup:new d("workgroup",h.keyword,"workgroup"),write:new d("write",h.keyword,"write"),r8unorm:new d("r8unorm",h.keyword,"r8unorm"),r8snorm:new d("r8snorm",h.keyword,"r8snorm"),r8uint:new d("r8uint",h.keyword,"r8uint"),r8sint:new d("r8sint",h.keyword,"r8sint"),r16uint:new d("r16uint",h.keyword,"r16uint"),r16sint:new d("r16sint",h.keyword,"r16sint"),r16float:new d("r16float",h.keyword,"r16float"),rg8unorm:new d("rg8unorm",h.keyword,"rg8unorm"),rg8snorm:new d("rg8snorm",h.keyword,"rg8snorm"),rg8uint:new d("rg8uint",h.keyword,"rg8uint"),rg8sint:new d("rg8sint",h.keyword,"rg8sint"),r32uint:new d("r32uint",h.keyword,"r32uint"),r32sint:new d("r32sint",h.keyword,"r32sint"),r32float:new d("r32float",h.keyword,"r32float"),rg16uint:new d("rg16uint",h.keyword,"rg16uint"),rg16sint:new d("rg16sint",h.keyword,"rg16sint"),rg16float:new d("rg16float",h.keyword,"rg16float"),rgba8unorm:new d("rgba8unorm",h.keyword,"rgba8unorm"),rgba8unorm_srgb:new d("rgba8unorm_srgb",h.keyword,"rgba8unorm_srgb"),rgba8snorm:new d("rgba8snorm",h.keyword,"rgba8snorm"),rgba8uint:new d("rgba8uint",h.keyword,"rgba8uint"),rgba8sint:new d("rgba8sint",h.keyword,"rgba8sint"),bgra8unorm:new d("bgra8unorm",h.keyword,"bgra8unorm"),bgra8unorm_srgb:new d("bgra8unorm_srgb",h.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new d("rgb10a2unorm",h.keyword,"rgb10a2unorm"),rg11b10float:new d("rg11b10float",h.keyword,"rg11b10float"),rg32uint:new d("rg32uint",h.keyword,"rg32uint"),rg32sint:new d("rg32sint",h.keyword,"rg32sint"),rg32float:new d("rg32float",h.keyword,"rg32float"),rgba16uint:new d("rgba16uint",h.keyword,"rgba16uint"),rgba16sint:new d("rgba16sint",h.keyword,"rgba16sint"),rgba16float:new d("rgba16float",h.keyword,"rgba16float"),rgba32uint:new d("rgba32uint",h.keyword,"rgba32uint"),rgba32sint:new d("rgba32sint",h.keyword,"rgba32sint"),rgba32float:new d("rgba32float",h.keyword,"rgba32float"),static_assert:new d("static_assert",h.keyword,"static_assert")};c.tokens={decimal_float_literal:new d("decimal_float_literal",h.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new d("hex_float_literal",h.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new d("int_literal",h.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new d("uint_literal",h.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new d("ident",h.token,/[a-zA-Z][0-9a-zA-Z_]*/),and:new d("and",h.token,"&"),and_and:new d("and_and",h.token,"&&"),arrow:new d("arrow ",h.token,"->"),attr:new d("attr",h.token,"@"),attr_left:new d("attr_left",h.token,"[["),attr_right:new d("attr_right",h.token,"]]"),forward_slash:new d("forward_slash",h.token,"/"),bang:new d("bang",h.token,"!"),bracket_left:new d("bracket_left",h.token,"["),bracket_right:new d("bracket_right",h.token,"]"),brace_left:new d("brace_left",h.token,"{"),brace_right:new d("brace_right",h.token,"}"),colon:new d("colon",h.token,":"),comma:new d("comma",h.token,","),equal:new d("equal",h.token,"="),equal_equal:new d("equal_equal",h.token,"=="),not_equal:new d("not_equal",h.token,"!="),greater_than:new d("greater_than",h.token,">"),greater_than_equal:new d("greater_than_equal",h.token,">="),shift_right:new d("shift_right",h.token,">>"),less_than:new d("less_than",h.token,"<"),less_than_equal:new d("less_than_equal",h.token,"<="),shift_left:new d("shift_left",h.token,"<<"),modulo:new d("modulo",h.token,"%"),minus:new d("minus",h.token,"-"),minus_minus:new d("minus_minus",h.token,"--"),period:new d("period",h.token,"."),plus:new d("plus",h.token,"+"),plus_plus:new d("plus_plus",h.token,"++"),or:new d("or",h.token,"|"),or_or:new d("or_or",h.token,"||"),paren_left:new d("paren_left",h.token,"("),paren_right:new d("paren_right",h.token,")"),semicolon:new d("semicolon",h.token,";"),star:new d("star",h.token,"*"),tilde:new d("tilde",h.token,"~"),underscore:new d("underscore",h.token,"_"),xor:new d("xor",h.token,"^"),plus_equal:new d("plus_equal",h.token,"+="),minus_equal:new d("minus_equal",h.token,"-="),times_equal:new d("times_equal",h.token,"*="),division_equal:new d("division_equal",h.token,"/="),modulo_equal:new d("modulo_equal",h.token,"%="),and_equal:new d("and_equal",h.token,"&="),or_equal:new d("or_equal",h.token,"|="),xor_equal:new d("xor_equal",h.token,"^="),shift_right_equal:new d("shift_right_equal",h.token,">>="),shift_left_equal:new d("shift_left_equal",h.token,"<<=")};c.storage_class=[m.keywords.function,m.keywords.private,m.keywords.workgroup,m.keywords.uniform,m.keywords.storage];c.access_mode=[m.keywords.read,m.keywords.write,m.keywords.read_write];c.sampler_type=[m.keywords.sampler,m.keywords.sampler_comparison];c.sampled_texture_type=[m.keywords.texture_1d,m.keywords.texture_2d,m.keywords.texture_2d_array,m.keywords.texture_3d,m.keywords.texture_cube,m.keywords.texture_cube_array];c.multisampled_texture_type=[m.keywords.texture_multisampled_2d];c.storage_texture_type=[m.keywords.texture_storage_1d,m.keywords.texture_storage_2d,m.keywords.texture_storage_2d_array,m.keywords.texture_storage_3d];c.depth_texture_type=[m.keywords.texture_depth_2d,m.keywords.texture_depth_2d_array,m.keywords.texture_depth_cube,m.keywords.texture_depth_cube_array,m.keywords.texture_depth_multisampled_2d];c.texture_external_type=[m.keywords.texture_external];c.any_texture_type=[...m.sampled_texture_type,...m.multisampled_texture_type,...m.storage_texture_type,...m.depth_texture_type,...m.texture_external_type];c.texel_format=[m.keywords.r8unorm,m.keywords.r8snorm,m.keywords.r8uint,m.keywords.r8sint,m.keywords.r16uint,m.keywords.r16sint,m.keywords.r16float,m.keywords.rg8unorm,m.keywords.rg8snorm,m.keywords.rg8uint,m.keywords.rg8sint,m.keywords.r32uint,m.keywords.r32sint,m.keywords.r32float,m.keywords.rg16uint,m.keywords.rg16sint,m.keywords.rg16float,m.keywords.rgba8unorm,m.keywords.rgba8unorm_srgb,m.keywords.rgba8snorm,m.keywords.rgba8uint,m.keywords.rgba8sint,m.keywords.bgra8unorm,m.keywords.bgra8unorm_srgb,m.keywords.rgb10a2unorm,m.keywords.rg11b10float,m.keywords.rg32uint,m.keywords.rg32sint,m.keywords.rg32float,m.keywords.rgba16uint,m.keywords.rgba16sint,m.keywords.rgba16float,m.keywords.rgba32uint,m.keywords.rgba32sint,m.keywords.rgba32float];c.const_literal=[m.tokens.int_literal,m.tokens.uint_literal,m.tokens.decimal_float_literal,m.tokens.hex_float_literal,m.keywords.true,m.keywords.false];c.literal_or_ident=[m.tokens.ident,m.tokens.int_literal,m.tokens.uint_literal,m.tokens.decimal_float_literal,m.tokens.hex_float_literal];c.element_count_expression=[m.tokens.int_literal,m.tokens.uint_literal,m.tokens.ident];c.template_types=[m.keywords.vec2,m.keywords.vec3,m.keywords.vec4,m.keywords.mat2x2,m.keywords.mat2x3,m.keywords.mat2x4,m.keywords.mat3x2,m.keywords.mat3x3,m.keywords.mat3x4,m.keywords.mat4x2,m.keywords.mat4x3,m.keywords.mat4x4,m.keywords.atomic,m.keywords.bitcast,...m.any_texture_type];c.attribute_name=[m.tokens.ident,m.keywords.block];c.assignment_operators=[m.tokens.equal,m.tokens.plus_equal,m.tokens.minus_equal,m.tokens.times_equal,m.tokens.division_equal,m.tokens.modulo_equal,m.tokens.and_equal,m.tokens.or_equal,m.tokens.xor_equal,m.tokens.shift_right_equal,m.tokens.shift_left_equal];c.increment_operators=[m.tokens.plus_plus,m.tokens.minus_minus];var Ir=class{constructor(t,r,n){this.type=t,this.lexeme=r,this.line=n}toString(){return this.lexeme}isTemplateType(){return c.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==c.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},wi=class{constructor(t){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=t??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Ir(c.eof,"",this._line)),this._tokens}scanToken(){let t=this._advance();if(t==`
|
|
278
|
+
`)return this._line++,!0;if(this._isWhitespace(t))return!0;if(t=="/"){if(this._peekAhead()=="/"){for(;t!=`
|
|
279
|
+
`;){if(this._isAtEnd())return!0;t=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let n=1;for(;n>0;){if(this._isAtEnd())return!0;if(t=this._advance(),t==`
|
|
280
|
+
`)this._line++;else if(t=="*"){if(this._peekAhead()=="/"&&(this._advance(),n--,n==0))return!0}else t=="/"&&this._peekAhead()=="*"&&(this._advance(),n++)}return!0}}let r=c.none;for(;;){let n=this._findType(t),i=this._peekAhead();if(t==">"&&(i==">"||i=="=")){let s=!1,o=this._tokens.length-1;for(let a=0;a<5&&o>=0;++a,--o)if(this._tokens[o].type===c.tokens.less_than){o>0&&this._tokens[o-1].isArrayOrTemplateType()&&(s=!0);break}if(s)return this._addToken(n),!0}if(n===c.none){let s=t,o=0,a=2;for(let l=0;l<a;++l)if(s+=this._peekAhead(l),n=this._findType(s),n!==c.none){o=l;break}if(n===c.none)return r===c.none?!1:(this._current--,this._addToken(r),!0);t=s,this._current+=o+1}if(r=n,this._isAtEnd())break;t+=this._advance()}return r===c.none?!1:(this._addToken(r),!0)}_findType(t){for(let r in c.keywords){let n=c.keywords[r];if(this._match(t,n.rule))return n}for(let r in c.tokens){let n=c.tokens[r];if(this._match(t,n.rule))return n}return c.none}_match(t,r){if(typeof r=="string"){if(r==t)return!0}else{let n=r.exec(t);if(n&&n.index==0&&n[0]==t)return!0}return!1}_isAtEnd(){return this._current>=this._source.length}_isWhitespace(t){return t==" "||t==" "||t=="\r"}_advance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=this._source[this._current];return t=t||0,t++,this._current+=t,r}_peekAhead(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return t=t||0,this._current+t>=this._source.length?"\0":this._source[this._current+t]}_addToken(t){let r=this._source.substring(this._start,this._current);this._tokens.push(new Ir(t,r,this._line))}},Pi=class{constructor(){this._tokens=[],this._current=0,this._context=new ti}parse(t){this._initialize(t);let r=[];for(;!this._isAtEnd();){let n=this._global_decl_or_directive();if(!n)break;r.push(n)}return r}_initialize(t){if(t)if(typeof t=="string"){let r=new wi(t);this._tokens=r.scanTokens()}else this._tokens=t;else this._tokens=[];this._current=0}_error(t,r){return console.error(t,r),{token:t,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==c.eof}_match(t){if(t instanceof d)return this._check(t)?(this._advance(),!0):!1;for(let r=0,n=t.length;r<n;++r){let i=t[r];if(this._check(i))return this._advance(),!0}return!1}_consume(t,r){if(this._check(t))return this._advance();throw this._error(this._peek(),r)}_check(t){if(this._isAtEnd())return!1;let r=this._peek();if(t instanceof Array){let n=r.type;return t.indexOf(n)!=-1}return r.type==t}_advance(){return this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(c.tokens.semicolon)&&!this._isAtEnd(););if(this._match(c.keywords.alias)){let r=this._type_alias();return this._consume(c.tokens.semicolon,"Expected ';'"),r}if(this._match(c.keywords.enable)){let r=this._enable_directive();return this._consume(c.tokens.semicolon,"Expected ';'"),r}let t=this._attribute();if(this._check(c.keywords.var)){let r=this._global_variable_decl();return r!=null&&(r.attributes=t),this._consume(c.tokens.semicolon,"Expected ';'."),r}if(this._check(c.keywords.override)){let r=this._override_variable_decl();return r!=null&&(r.attributes=t),this._consume(c.tokens.semicolon,"Expected ';'."),r}if(this._check(c.keywords.let)){let r=this._global_let_decl();return r!=null&&(r.attributes=t),this._consume(c.tokens.semicolon,"Expected ';'."),r}if(this._check(c.keywords.const)){let r=this._global_const_decl();return r!=null&&(r.attributes=t),this._consume(c.tokens.semicolon,"Expected ';'."),r}if(this._check(c.keywords.struct)){let r=this._struct_decl();return r!=null&&(r.attributes=t),r}if(this._check(c.keywords.fn)){let r=this._function_decl();return r!=null&&(r.attributes=t),r}return null}_function_decl(){if(!this._match(c.keywords.fn))return null;let t=this._consume(c.tokens.ident,"Expected function name.").toString();this._consume(c.tokens.paren_left,"Expected '(' for function arguments.");let r=[];if(!this._check(c.tokens.paren_right))do{if(this._check(c.tokens.paren_right))break;let s=this._attribute(),o=this._consume(c.tokens.ident,"Expected argument name.").toString();this._consume(c.tokens.colon,"Expected ':' for argument type.");let a=this._attribute(),l=this._type_decl();l!=null&&(l.attributes=a,r.push(new xi(o,l,s)))}while(this._match(c.tokens.comma));this._consume(c.tokens.paren_right,"Expected ')' after function arguments.");let n=null;if(this._match(c.tokens.arrow)){let s=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=s)}let i=this._compound_statement();return new gr(t,r,n,i)}_compound_statement(){let t=[];for(this._consume(c.tokens.brace_left,"Expected '{' for block.");!this._check(c.tokens.brace_right);){let r=this._statement();r!==null&&t.push(r)}return this._consume(c.tokens.brace_right,"Expected '}' for block."),t}_statement(){for(;this._match(c.tokens.semicolon)&&!this._isAtEnd(););if(this._check(c.keywords.if))return this._if_statement();if(this._check(c.keywords.switch))return this._switch_statement();if(this._check(c.keywords.loop))return this._loop_statement();if(this._check(c.keywords.for))return this._for_statement();if(this._check(c.keywords.while))return this._while_statement();if(this._check(c.keywords.continuing))return this._continuing_statement();if(this._check(c.keywords.static_assert))return this._static_assert_statement();if(this._check(c.tokens.brace_left))return this._compound_statement();let t=null;return this._check(c.keywords.return)?t=this._return_statement():this._check([c.keywords.var,c.keywords.let,c.keywords.const])?t=this._variable_statement():this._match(c.keywords.discard)?t=new hi:this._match(c.keywords.break)?t=new pi:this._match(c.keywords.continue)?t=new gi:t=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement(),t!=null&&this._consume(c.tokens.semicolon,"Expected ';' after statement."),t}_static_assert_statement(){if(!this._match(c.keywords.static_assert))return null;let t=this._optional_paren_expression();return new ri(t)}_while_statement(){if(!this._match(c.keywords.while))return null;let t=this._optional_paren_expression(),r=this._compound_statement();return new ni(t,r)}_continuing_statement(){if(!this._match(c.keywords.continuing))return null;let t=this._compound_statement();return new ii(t)}_for_statement(){if(!this._match(c.keywords.for))return null;this._consume(c.tokens.paren_left,"Expected '('.");let t=this._check(c.tokens.semicolon)?null:this._for_init();this._consume(c.tokens.semicolon,"Expected ';'.");let r=this._check(c.tokens.semicolon)?null:this._short_circuit_or_expression();this._consume(c.tokens.semicolon,"Expected ';'.");let n=this._check(c.tokens.paren_right)?null:this._for_increment();this._consume(c.tokens.paren_right,"Expected ')'.");let i=this._compound_statement();return new si(t,r,n,i)}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(c.keywords.var)){let t=this._variable_decl();if(t===null)throw this._error(this._peek(),"Variable declaration expected.");let r=null;return this._match(c.tokens.equal)&&(r=this._short_circuit_or_expression()),new we(t.name,t.type,t.storage,t.access,r)}if(this._match(c.keywords.let)){let t=this._consume(c.tokens.ident,"Expected name for let.").toString(),r=null;if(this._match(c.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}this._consume(c.tokens.equal,"Expected '=' for let.");let n=this._short_circuit_or_expression();return new br(t,r,null,null,n)}if(this._match(c.keywords.const)){let t=this._consume(c.tokens.ident,"Expected name for const.").toString(),r=null;if(this._match(c.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}this._consume(c.tokens.equal,"Expected '=' for const.");let n=this._short_circuit_or_expression();return new Tr(t,r,null,null,n)}return null}_increment_decrement_statement(){let t=this._current,r=this._unary_expression();if(r==null)return null;if(!this._check(c.increment_operators))return this._current=t,null;let n=this._consume(c.increment_operators,"Expected increment operator");return new oi(n.type===c.tokens.plus_plus?tt.increment:tt.decrement,r)}_assignment_statement(){let t=null;if(this._check(c.tokens.brace_right))return null;let r=this._match(c.tokens.underscore);if(r||(t=this._unary_expression()),!r&&t==null)return null;let n=this._consume(c.assignment_operators,"Expected assignment operator."),i=this._short_circuit_or_expression();return new ai(Nt.parse(n.lexeme),t,i)}_func_call_statement(){if(!this._check(c.tokens.ident))return null;let t=this._current,r=this._consume(c.tokens.ident,"Expected function name."),n=this._argument_expression_list();return n===null?(this._current=t,null):new li(r.lexeme,n)}_loop_statement(){if(!this._match(c.keywords.loop))return null;this._consume(c.tokens.brace_left,"Expected '{' for loop.");let t=[],r=this._statement();for(;r!==null;){if(Array.isArray(r))for(let i of r)t.push(i);else t.push(r);r=this._statement()}let n=null;return this._match(c.keywords.continuing)&&(n=this._compound_statement()),this._consume(c.tokens.brace_right,"Expected '}' for loop."),new fi(t,n)}_switch_statement(){if(!this._match(c.keywords.switch))return null;let t=this._optional_paren_expression();this._consume(c.tokens.brace_left,"Expected '{' for switch.");let r=this._switch_body();if(r==null||r.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(c.tokens.brace_right,"Expected '}' for switch."),new ci(t,r)}_switch_body(){let t=[];if(this._match(c.keywords.case)){let r=this._case_selectors();this._match(c.tokens.colon),this._consume(c.tokens.brace_left,"Exected '{' for switch case.");let n=this._case_body();this._consume(c.tokens.brace_right,"Exected '}' for switch case."),t.push(new Ri(r,n))}if(this._match(c.keywords.default)){this._match(c.tokens.colon),this._consume(c.tokens.brace_left,"Exected '{' for switch default.");let r=this._case_body();this._consume(c.tokens.brace_right,"Exected '}' for switch default."),t.push(new Ei(r))}if(this._check([c.keywords.default,c.keywords.case])){let r=this._switch_body();t.push(r[0])}return t}_case_selectors(){var t,r,n,i;let s=[(r=(t=this._shift_expression())===null||t===void 0?void 0:t.evaluate(this._context).toString())!==null&&r!==void 0?r:""];for(;this._match(c.tokens.comma);)s.push((i=(n=this._shift_expression())===null||n===void 0?void 0:n.evaluate(this._context).toString())!==null&&i!==void 0?i:"");return s}_case_body(){if(this._match(c.keywords.fallthrough))return this._consume(c.tokens.semicolon,"Expected ';'"),[];let t=this._statement();if(t==null)return[];t instanceof Array||(t=[t]);let r=this._case_body();return r.length==0?t:[...t,r[0]]}_if_statement(){if(!this._match(c.keywords.if))return null;let t=this._optional_paren_expression(),r=this._compound_statement(),n=[];this._match_elseif()&&(n=this._elseif_statement(n));let i=null;return this._match(c.keywords.else)&&(i=this._compound_statement()),new ui(t,r,n,i)}_match_elseif(){return this._tokens[this._current].type===c.keywords.else&&this._tokens[this._current+1].type===c.keywords.if?(this._advance(),this._advance(),!0):!1}_elseif_statement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=this._optional_paren_expression(),n=this._compound_statement();return t.push(new Si(r,n)),this._match_elseif()&&this._elseif_statement(t),t}_return_statement(){if(!this._match(c.keywords.return))return null;let t=this._short_circuit_or_expression();return new _i(t)}_short_circuit_or_expression(){let t=this._short_circuit_and_expr();for(;this._match(c.tokens.or_or);)t=new q(this._previous().toString(),t,this._short_circuit_and_expr());return t}_short_circuit_and_expr(){let t=this._inclusive_or_expression();for(;this._match(c.tokens.and_and);)t=new q(this._previous().toString(),t,this._inclusive_or_expression());return t}_inclusive_or_expression(){let t=this._exclusive_or_expression();for(;this._match(c.tokens.or);)t=new q(this._previous().toString(),t,this._exclusive_or_expression());return t}_exclusive_or_expression(){let t=this._and_expression();for(;this._match(c.tokens.xor);)t=new q(this._previous().toString(),t,this._and_expression());return t}_and_expression(){let t=this._equality_expression();for(;this._match(c.tokens.and);)t=new q(this._previous().toString(),t,this._equality_expression());return t}_equality_expression(){let t=this._relational_expression();return this._match([c.tokens.equal_equal,c.tokens.not_equal])?new q(this._previous().toString(),t,this._relational_expression()):t}_relational_expression(){let t=this._shift_expression();for(;this._match([c.tokens.less_than,c.tokens.greater_than,c.tokens.less_than_equal,c.tokens.greater_than_equal]);)t=new q(this._previous().toString(),t,this._shift_expression());return t}_shift_expression(){let t=this._additive_expression();for(;this._match([c.tokens.shift_left,c.tokens.shift_right]);)t=new q(this._previous().toString(),t,this._additive_expression());return t}_additive_expression(){let t=this._multiplicative_expression();for(;this._match([c.tokens.plus,c.tokens.minus]);)t=new q(this._previous().toString(),t,this._multiplicative_expression());return t}_multiplicative_expression(){let t=this._unary_expression();for(;this._match([c.tokens.star,c.tokens.forward_slash,c.tokens.modulo]);)t=new q(this._previous().toString(),t,this._unary_expression());return t}_unary_expression(){return this._match([c.tokens.minus,c.tokens.bang,c.tokens.tilde,c.tokens.star,c.tokens.and])?new yi(this._previous().toString(),this._unary_expression()):this._singular_expression()}_singular_expression(){let t=this._primary_expression(),r=this._postfix_expression();return r&&(t.postfix=r),t}_postfix_expression(){if(this._match(c.tokens.bracket_left)){let t=this._short_circuit_or_expression();this._consume(c.tokens.bracket_right,"Expected ']'.");let r=this._postfix_expression();return r&&(t.postfix=r),t}if(this._match(c.tokens.period)){let t=this._consume(c.tokens.ident,"Expected member name."),r=this._postfix_expression(),n=new Rr(t.lexeme);return r&&(n.postfix=r),n}return null}_getStruct(t){return this._context.aliases.has(t)?this._context.aliases.get(t).type:this._context.structs.has(t)?this._context.structs.get(t):null}_primary_expression(){if(this._match(c.tokens.ident)){let n=this._previous().toString();if(this._check(c.tokens.paren_left)){let i=this._argument_expression_list(),s=this._getStruct(n);return s!=null?new He(s,i):new bi(n,i)}if(this._context.constants.has(n)){let i=this._context.constants.get(n);return new Er(n,i.value)}return new Ti(n)}if(this._match(c.const_literal))return new xr(parseFloat(this._previous().toString()));if(this._check(c.tokens.paren_left))return this._paren_expression();if(this._match(c.keywords.bitcast)){this._consume(c.tokens.less_than,"Expected '<'.");let n=this._type_decl();this._consume(c.tokens.greater_than,"Expected '>'.");let i=this._paren_expression();return new Ai(n,i)}let t=this._type_decl(),r=this._argument_expression_list();return new vi(t,r)}_argument_expression_list(){if(!this._match(c.tokens.paren_left))return null;let t=[];do{if(this._check(c.tokens.paren_right))break;let r=this._short_circuit_or_expression();t.push(r)}while(this._match(c.tokens.comma));return this._consume(c.tokens.paren_right,"Expected ')' for agument list"),t}_optional_paren_expression(){this._match(c.tokens.paren_left);let t=this._short_circuit_or_expression();return this._match(c.tokens.paren_right),new Sr([t])}_paren_expression(){this._consume(c.tokens.paren_left,"Expected '('.");let t=this._short_circuit_or_expression();return this._consume(c.tokens.paren_right,"Expected ')'."),new Sr([t])}_struct_decl(){if(!this._match(c.keywords.struct))return null;let t=this._consume(c.tokens.ident,"Expected name for struct.").toString();this._consume(c.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(c.tokens.brace_right);){let i=this._attribute(),s=this._consume(c.tokens.ident,"Expected variable name.").toString();this._consume(c.tokens.colon,"Expected ':' for struct member type.");let o=this._attribute(),a=this._type_decl();a!=null&&(a.attributes=o),this._check(c.tokens.brace_right)?this._match(c.tokens.comma):this._consume(c.tokens.comma,"Expected ',' for struct member."),r.push(new Oi(s,a,i))}this._consume(c.tokens.brace_right,"Expected '}' after struct body.");let n=new be(t,r);return this._context.structs.set(t,n),n}_global_variable_decl(){let t=this._variable_decl();return t&&this._match(c.tokens.equal)&&(t.value=this._const_expression()),t}_override_variable_decl(){let t=this._override_decl();return t&&this._match(c.tokens.equal)&&(t.value=this._const_expression()),t}_global_const_decl(){if(!this._match(c.keywords.const))return null;let t=this._consume(c.tokens.ident,"Expected variable name"),r=null;if(this._match(c.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}let n=null;if(this._match(c.tokens.equal)){let s=this._short_circuit_or_expression();if(s instanceof He)n=s;else if(s instanceof Er&&s.initializer instanceof He)n=s.initializer;else try{let o=s.evaluate(this._context);n=new xr(o)}catch{n=s}}let i=new Tr(t.toString(),r,"","",n);return this._context.constants.set(i.name,i),i}_global_let_decl(){if(!this._match(c.keywords.let))return null;let t=this._consume(c.tokens.ident,"Expected variable name"),r=null;if(this._match(c.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}let n=null;return this._match(c.tokens.equal)&&(n=this._const_expression()),new br(t.toString(),r,"","",n)}_const_expression(){if(this._match(c.const_literal))return new Rr(this._previous().toString());let t=this._type_decl();this._consume(c.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(c.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(c.tokens.comma));)this._advance();return this._consume(c.tokens.paren_right,"Expected ')'."),new He(t,r)}_variable_decl(){if(!this._match(c.keywords.var))return null;let t="",r="";this._match(c.tokens.less_than)&&(t=this._consume(c.storage_class,"Expected storage_class.").toString(),this._match(c.tokens.comma)&&(r=this._consume(c.access_mode,"Expected access_mode.").toString()),this._consume(c.tokens.greater_than,"Expected '>'."));let n=this._consume(c.tokens.ident,"Expected variable name"),i=null;if(this._match(c.tokens.colon)){let s=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=s)}return new we(n.toString(),i,t,r,null)}_override_decl(){if(!this._match(c.keywords.override))return null;let t=this._consume(c.tokens.ident,"Expected variable name"),r=null;if(this._match(c.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}return new mr(t.toString(),r,null)}_enable_directive(){let t=this._consume(c.tokens.ident,"identity expected.");return new di(t.toString())}_type_alias(){let t=this._consume(c.tokens.ident,"identity expected.");this._consume(c.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let n=new Ar(t.toString(),r);return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([c.tokens.ident,...c.texel_format,c.keywords.bool,c.keywords.f32,c.keywords.i32,c.keywords.u32])){let n=this._advance(),i=n.toString();return this._context.structs.has(i)?this._context.structs.get(i):this._context.aliases.has(i)?this._context.aliases.get(i).type:new Ae(n.toString())}let t=this._texture_sampler_types();if(t)return t;if(this._check(c.template_types)){let n=this._advance().toString(),i=null,s=null;return this._match(c.tokens.less_than)&&(i=this._type_decl(),s=null,this._match(c.tokens.comma)&&(s=this._consume(c.access_mode,"Expected access_mode for pointer").toString()),this._consume(c.tokens.greater_than,"Expected '>' for type.")),new vr(n,i,s)}if(this._match(c.keywords.ptr)){let n=this._previous().toString();this._consume(c.tokens.less_than,"Expected '<' for pointer.");let i=this._consume(c.storage_class,"Expected storage_class for pointer");this._consume(c.tokens.comma,"Expected ',' for pointer.");let s=this._type_decl(),o=null;return this._match(c.tokens.comma)&&(o=this._consume(c.access_mode,"Expected access_mode for pointer").toString()),this._consume(c.tokens.greater_than,"Expected '>' for pointer."),new mi(n,i.toString(),s,o)}let r=this._attribute();if(this._match(c.keywords.array)){let n=null,i=-1,s=this._previous();if(this._match(c.tokens.less_than)){n=this._type_decl(),this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let o="";this._match(c.tokens.comma)&&(o=this._shift_expression().evaluate(this._context).toString()),this._consume(c.tokens.greater_than,"Expected '>' for array."),i=o?parseInt(o):0}return new yr(s.toString(),r,n,i)}return null}_texture_sampler_types(){if(this._match(c.sampler_type))return new We(this._previous().toString(),null,null);if(this._match(c.depth_texture_type))return new We(this._previous().toString(),null,null);if(this._match(c.sampled_texture_type)||this._match(c.multisampled_texture_type)){let t=this._previous();this._consume(c.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(c.tokens.greater_than,"Expected '>' for sampler type."),new We(t.toString(),r,null)}if(this._match(c.storage_texture_type)){let t=this._previous();this._consume(c.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(c.texel_format,"Invalid texel format.").toString();this._consume(c.tokens.comma,"Expected ',' after texel format.");let n=this._consume(c.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(c.tokens.greater_than,"Expected '>' for sampler type."),new We(t.toString(),r,n)}return null}_attribute(){let t=[];for(;this._match(c.tokens.attr);){let r=this._consume(c.attribute_name,"Expected attribute name"),n=new Pr(r.toString(),null);if(this._match(c.tokens.paren_left)){if(n.value=this._consume(c.literal_or_ident,"Expected attribute value").toString(),this._check(c.tokens.comma)){this._advance();do{let i=this._consume(c.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(i)}while(this._match(c.tokens.comma))}this._consume(c.tokens.paren_right,"Expected ')'")}t.push(n)}for(;this._match(c.tokens.attr_left);){if(!this._check(c.tokens.attr_right))do{let r=this._consume(c.attribute_name,"Expected attribute name"),n=new Pr(r.toString(),null);if(this._match(c.tokens.paren_left)){if(n.value=[this._consume(c.literal_or_ident,"Expected attribute value").toString()],this._check(c.tokens.comma)){this._advance();do{let i=this._consume(c.literal_or_ident,"Expected attribute value").toString();n.value.push(i)}while(this._match(c.tokens.comma))}this._consume(c.tokens.paren_right,"Expected ')'")}t.push(n)}while(this._match(c.tokens.comma));this._consume(c.tokens.attr_right,"Expected ']]' after attribute declarations")}return t.length==0?null:t}},Pe=class{constructor(t,r){this.name=t,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Fr=class{constructor(t,r,n){this.name=t,this.type=r,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Je=class extends Pe{constructor(t,r){super(t,r),this.members=[],this.align=0}get isStruct(){return!0}},Ft=class extends Pe{constructor(t,r){super(t,r),this.count=0,this.stride=0}get isArray(){return!0}},Nr=class extends Pe{constructor(t,r,n,i){super(t,n),this.format=r,this.access=i}get isTemplate(){return!0}},Oe;(function(e){e[e.Uniform=0]="Uniform",e[e.Storage=1]="Storage",e[e.Texture=2]="Texture",e[e.Sampler=3]="Sampler",e[e.StorageTexture=4]="StorageTexture"})(Oe||(Oe={}));var Ge=class{constructor(t,r,n,i,s,o,a){this.name=t,this.type=r,this.group=n,this.binding=i,this.attributes=s,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Ii=class{constructor(t,r){this.name=t,this.type=r}},et=class{constructor(t,r){this.align=t,this.size=r}},Fi=class{constructor(t,r,n,i){this.name=t,this.type=r,this.locationType=n,this.location=i,this.interpolation=null}},Mr=class{constructor(t,r,n,i){this.name=t,this.type=r,this.locationType=n,this.location=i}},Ni=class{constructor(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.stage=null,this.inputs=[],this.outputs=[],this.name=t,this.stage=r}},Mi=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},Ci=class{constructor(t,r,n,i){this.name=t,this.type=r,this.attributes=n,this.id=i}},Z=class{constructor(t){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Mi,this._types=new Map,t&&this.update(t)}_isStorageTexture(t){return t.name=="texture_storage_1d"||t.name=="texture_storage_2d"||t.name=="texture_storage_2d_array"||t.name=="texture_storage_3d"}update(t){let n=new Pi().parse(t);for(let i of n){if(i instanceof be){let s=this._getTypeInfo(i,null);s instanceof Je&&this.structs.push(s);continue}if(i instanceof Ar){this.aliases.push(this._getAliasInfo(i));continue}if(i instanceof mr){let s=i,o=this._getAttributeNum(s.attributes,"id",0),a=s.type!=null?this._getTypeInfo(s.type,s.attributes):null;this.overrides.push(new Ci(s.name,a,s.attributes,o));continue}if(this._isUniformVar(i)){let s=i,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),l=this._getTypeInfo(s.type,s.attributes),f=new Ge(s.name,l,o,a,s.attributes,Oe.Uniform,s.access);this.uniforms.push(f);continue}if(this._isStorageVar(i)){let s=i,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),l=this._getTypeInfo(s.type,s.attributes),f=this._isStorageTexture(l),u=new Ge(s.name,l,o,a,s.attributes,f?Oe.StorageTexture:Oe.Storage,s.access);this.storage.push(u);continue}if(this._isTextureVar(i)){let s=i,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),l=this._getTypeInfo(s.type,s.attributes),f=this._isStorageTexture(l),u=new Ge(s.name,l,o,a,s.attributes,f?Oe.StorageTexture:Oe.Texture,s.access);f?this.storage.push(u):this.textures.push(u);continue}if(this._isSamplerVar(i)){let s=i,o=this._getAttributeNum(s.attributes,"group",0),a=this._getAttributeNum(s.attributes,"binding",0),l=this._getTypeInfo(s.type,s.attributes),f=new Ge(s.name,l,o,a,s.attributes,Oe.Sampler,s.access);this.samplers.push(f);continue}if(i instanceof gr){let s=this._getAttribute(i,"vertex"),o=this._getAttribute(i,"fragment"),a=this._getAttribute(i,"compute"),l=s||o||a;if(l){let f=new Ni(i.name,l.name);f.inputs=this._getInputs(i.args),f.outputs=this._getOutputs(i.returnType),this.entry[l.name].push(f)}continue}}}getBindGroups(){let t=[];function r(n,i){n>=t.length&&(t.length=n+1),t[n]===void 0&&(t[n]=[]),i>=t[n].length&&(t[n].length=i+1)}for(let n of this.uniforms){r(n.group,n.binding);let i=t[n.group];i[n.binding]=n}for(let n of this.storage){r(n.group,n.binding);let i=t[n.group];i[n.binding]=n}for(let n of this.textures){r(n.group,n.binding);let i=t[n.group];i[n.binding]=n}for(let n of this.samplers){r(n.group,n.binding);let i=t[n.group];i[n.binding]=n}return t}_getOutputs(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;if(r===void 0&&(r=[]),t instanceof be)this._getStructOutputs(t,r);else{let n=this._getOutputInfo(t);n!==null&&r.push(n)}return r}_getStructOutputs(t,r){for(let n of t.members)if(n.type instanceof be)this._getStructOutputs(n.type,r);else{let i=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(i!==null){let s=this._getTypeInfo(n.type,n.type.attributes),o=this._parseInt(i.value),a=new Mr(n.name,s,i.name,o);r.push(a)}}}_getOutputInfo(t){let r=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(r!==null){let n=this._getTypeInfo(t,t.attributes),i=this._parseInt(r.value);return new Mr("",n,r.name,i)}return null}_getInputs(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0;r===void 0&&(r=[]);for(let n of t)if(n.type instanceof be)this._getStructInputs(n.type,r);else{let i=this._getInputInfo(n);i!==null&&r.push(i)}return r}_getStructInputs(t,r){for(let n of t.members)if(n.type instanceof be)this._getStructInputs(n.type,r);else{let i=this._getInputInfo(n);i!==null&&r.push(i)}}_getInputInfo(t){let r=this._getAttribute(t,"location")||this._getAttribute(t,"builtin");if(r!==null){let n=this._getAttribute(t,"interpolation"),i=this._getTypeInfo(t.type,t.attributes),s=this._parseInt(r.value),o=new Fi(t.name,i,r.name,s);return n!==null&&(o.interpolation=this._parseString(n.value)),o}return null}_parseString(t){return t instanceof Array&&(t=t[0]),t}_parseInt(t){t instanceof Array&&(t=t[0]);let r=parseInt(t);return isNaN(r)?t:r}_getAlias(t){for(let r of this.aliases)if(r.name==t)return r.type;return null}_getAliasInfo(t){return new Ii(t.name,this._getTypeInfo(t.type,null))}_getTypeInfo(t,r){if(this._types.has(t))return this._types.get(t);if(t instanceof yr){let i=t,s=this._getTypeInfo(i.format,i.attributes),o=new Ft(i.name,r);return o.format=s,o.count=i.count,this._types.set(t,o),this._updateTypeInfo(o),o}if(t instanceof be){let i=t,s=new Je(i.name,r);for(let o of i.members){let a=this._getTypeInfo(o.type,o.attributes);s.members.push(new Fr(o.name,a,o.attributes))}return this._types.set(t,s),this._updateTypeInfo(s),s}if(t instanceof We){let i=t,s=i.format instanceof Ae,o=i.format?s?this._getTypeInfo(i.format,null):new Pe(i.format,null):null,a=new Nr(i.name,o,r,i.access);return this._types.set(t,a),this._updateTypeInfo(a),a}if(t instanceof vr){let i=t,s=i.format?this._getTypeInfo(i.format,null):null,o=new Nr(i.name,s,r,i.access);return this._types.set(t,o),this._updateTypeInfo(o),o}let n=new Pe(t.name,r);return this._types.set(t,n),this._updateTypeInfo(n),n}_updateTypeInfo(t){var r,n;let i=this._getTypeSize(t);if(t.size=(r=i?.size)!==null&&r!==void 0?r:0,t instanceof Ft){let s=this._getTypeSize(t.format);t.stride=(n=s?.size)!==null&&n!==void 0?n:0,this._updateTypeInfo(t.format)}t instanceof Je&&this._updateStructInfo(t)}_updateStructInfo(t){var r;let n=0,i=0,s=0,o=0;for(let a=0,l=t.members.length;a<l;++a){let f=t.members[a],u=this._getTypeSize(f);if(!u)continue;(r=this._getAlias(f.type.name))!==null&&r!==void 0||f.type;let _=u.align,p=u.size;n=this._roundUp(_,n+i),i=p,s=n,o=Math.max(o,_),f.offset=n,f.size=p,this._updateTypeInfo(f.type)}t.size=this._roundUp(o,s+i),t.align=o}_getTypeSize(t){var r;if(t==null)return null;let n=this._getAttributeNum(t.attributes,"size",0),i=this._getAttributeNum(t.attributes,"align",0);if(t instanceof Fr&&(t=t.type),t instanceof Pe){let s=this._getAlias(t.name);s!==null&&(t=s)}{let s=Z._typeInfo[t.name];if(s!==void 0){let o=t.format==="f16"?2:1;return new et(Math.max(i,s.align/o),Math.max(n,s.size/o))}}{let s=Z._typeInfo[t.name.substring(0,t.name.length-1)];if(s){let o=t.name[t.name.length-1]==="h"?2:1;return new et(Math.max(i,s.align/o),Math.max(n,s.size/o))}}if(t instanceof Ft){let s=t,o=8,a=8,l=this._getTypeSize(s.format);l!==null&&(a=l.size,o=l.align);let f=s.count,u=this._getAttributeNum((r=t?.attributes)!==null&&r!==void 0?r:null,"stride",this._roundUp(o,a));return a=f*u,n&&(a=n),new et(Math.max(i,o),Math.max(n,a))}if(t instanceof Je){let s=0,o=0,a=0,l=0,f=0;for(let u of t.members){let _=this._getTypeSize(u.type);_!==null&&(s=Math.max(_.align,s),a=this._roundUp(_.align,a+l),l=_.size,f=a)}return o=this._roundUp(s,f+l),new et(Math.max(i,s),Math.max(n,o))}return null}_isUniformVar(t){return t instanceof we&&t.storage=="uniform"}_isStorageVar(t){return t instanceof we&&t.storage=="storage"}_isTextureVar(t){return t instanceof we&&t.type!==null&&Z._textureTypes.indexOf(t.type.name)!=-1}_isSamplerVar(t){return t instanceof we&&t.type!==null&&Z._samplerTypes.indexOf(t.type.name)!=-1}_getAttribute(t,r){let n=t;if(!n||!n.attributes)return null;let i=n.attributes;for(let s of i)if(s.name==r)return s;return null}_getAttributeNum(t,r,n){if(t===null)return n;for(let i of t)if(i.name==r){let s=i!==null&&i.value!==null?i.value:n;return s instanceof Array&&(s=s[0]),typeof s=="number"?s:typeof s=="string"?parseInt(s):n}return n}_roundUp(t,r){return Math.ceil(r/t)*t}};Z._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}};Z._textureTypes=c.any_texture_type.map(e=>e.name);Z._samplerTypes=c.sampler_type.map(e=>e.name);function Cr(e){let t={attributes:[],bindings:[]},r=au(e);for(let s of r.uniforms){let o=[];for(let a of s.type.members)o.push({name:a.name,type:ca(a.type)});t.bindings.push({type:"uniform",name:s.name,location:s.binding,group:s.group,members:o})}let n=r.entry.vertex[0],i=n.inputs.length;for(let s=0;s<i;s++){let o=n.inputs[s];if(o.locationType==="location"){let a=ca(o.type);t.attributes.push({name:o.name,location:o.location,type:a})}}return t}function ca(e){return e.format?`${e.name}<${e.format.name}>`:e.name}function au(e){try{return new Z(e)}catch(t){if(t instanceof Error)throw t;let r="WGSL parse error";throw typeof t=="object"&&t!==null&&t!==void 0&&t.message&&(r+=`: ${t.message} `),typeof t=="object"&&t!==null&&t!==void 0&&t.token&&(r+=t.token.line||""),new Error(r,{cause:t})}}function Br(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,n=Math.fround(e),i=e-n;return t[r]=n,t[r+1]=i,t}function Bi(e){return e-Math.fround(e)}function Di(e){let t=new Float32Array(32);for(let r=0;r<4;++r)for(let n=0;n<4;++n){let i=r*4+n;Br(e[n*4+r],t,i*2)}return t}var ua=D`\
|
|
278
281
|
uniform float ONE;
|
|
279
282
|
|
|
280
283
|
/*
|
|
@@ -440,7 +443,7 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
440
443
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
441
444
|
#endif
|
|
442
445
|
}
|
|
443
|
-
`;var
|
|
446
|
+
`;var _a=D`\
|
|
444
447
|
const vec2 E_FP64 = vec2(2.7182817459106445e+00, 8.254840366817007e-08);
|
|
445
448
|
const vec2 LOG2_FP64 = vec2(0.6931471824645996e+00, -1.9046542121259336e-09);
|
|
446
449
|
const vec2 PI_FP64 = vec2(3.1415927410125732, -8.742278012618954e-8);
|
|
@@ -1110,7 +1113,7 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
|
|
|
1110
1113
|
vec4_dot_fp64(a, tmp, out_val[i]);
|
|
1111
1114
|
}
|
|
1112
1115
|
}
|
|
1113
|
-
`;var Bl={ONE:1};function Dl(){return Bl}var Wo={name:"fp64-arithmetic",vs:Vo,getUniforms:Dl,fp64ify:jt,fp64LowPart:li,fp64ifyMatrix4:ci},at={name:"fp64",vs:ko,dependencies:[Wo],fp64ify:jt,fp64LowPart:li,fp64ifyMatrix4:ci};var pT=1/Math.PI*180,hT=1/180*Math.PI,wl={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...wl}};var ft=globalThis.mathgl.config;function ui(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ne(e,t,r){let i=ft.EPSILON;r&&(ft.EPSILON=r);try{if(e===t)return!0;if(ui(e)&&ui(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!Ne(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=ft.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{ft.EPSILON=i}}var lt=typeof Float32Array<"u"?Float32Array:Array,_i=Math.random;function Kt(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var TT=Math.PI/180;var zt={};Ni(zt,{add:()=>Xl,angle:()=>uc,bezier:()=>ic,ceil:()=>Ll,clone:()=>Vl,copy:()=>Wl,create:()=>Ho,cross:()=>Gl,dist:()=>Rc,distance:()=>zo,div:()=>Ac,divide:()=>Ko,dot:()=>pi,equals:()=>hc,exactEquals:()=>pc,floor:()=>jl,forEach:()=>mc,fromValues:()=>kl,hermite:()=>rc,inverse:()=>Ql,len:()=>Ec,length:()=>Xo,lerp:()=>ec,max:()=>zl,min:()=>Kl,mul:()=>Tc,multiply:()=>jo,negate:()=>Zl,normalize:()=>Jl,random:()=>nc,rotateX:()=>fc,rotateY:()=>lc,rotateZ:()=>cc,round:()=>Yl,scale:()=>$l,scaleAndAdd:()=>ql,set:()=>Hl,slerp:()=>tc,sqrDist:()=>bc,sqrLen:()=>vc,squaredDistance:()=>Yo,squaredLength:()=>$o,str:()=>dc,sub:()=>gc,subtract:()=>Lo,transformMat3:()=>sc,transformMat4:()=>oc,transformQuat:()=>ac,zero:()=>_c});function Ho(){let e=new lt(3);return lt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Vl(e){let t=new lt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Xo(e){let t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function kl(e,t,r){let i=new lt(3);return i[0]=e,i[1]=t,i[2]=r,i}function Wl(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Hl(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e}function Xl(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Lo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function jo(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Ko(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function Ll(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function jl(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Kl(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function zl(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Yl(e,t){return e[0]=Kt(t[0]),e[1]=Kt(t[1]),e[2]=Kt(t[2]),e}function $l(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function ql(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function zo(e,t){let r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(r*r+i*i+n*n)}function Yo(e,t){let r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return r*r+i*i+n*n}function $o(e){let t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i}function Zl(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Ql(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Jl(e,t){let r=t[0],i=t[1],n=t[2],o=r*r+i*i+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function pi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Gl(e,t,r){let i=t[0],n=t[1],o=t[2],s=r[0],a=r[1],f=r[2];return e[0]=n*f-o*a,e[1]=o*s-i*f,e[2]=i*a-n*s,e}function ec(e,t,r,i){let n=t[0],o=t[1],s=t[2];return e[0]=n+i*(r[0]-n),e[1]=o+i*(r[1]-o),e[2]=s+i*(r[2]-s),e}function tc(e,t,r,i){let n=Math.acos(Math.min(Math.max(pi(t,r),-1),1)),o=Math.sin(n),s=Math.sin((1-i)*n)/o,a=Math.sin(i*n)/o;return e[0]=s*t[0]+a*r[0],e[1]=s*t[1]+a*r[1],e[2]=s*t[2]+a*r[2],e}function rc(e,t,r,i,n,o){let s=o*o,a=s*(2*o-3)+1,f=s*(o-2)+o,l=s*(o-1),c=s*(3-2*o);return e[0]=t[0]*a+r[0]*f+i[0]*l+n[0]*c,e[1]=t[1]*a+r[1]*f+i[1]*l+n[1]*c,e[2]=t[2]*a+r[2]*f+i[2]*l+n[2]*c,e}function ic(e,t,r,i,n,o){let s=1-o,a=s*s,f=o*o,l=a*s,c=3*o*a,u=3*f*s,_=f*o;return e[0]=t[0]*l+r[0]*c+i[0]*u+n[0]*_,e[1]=t[1]*l+r[1]*c+i[1]*u+n[1]*_,e[2]=t[2]*l+r[2]*c+i[2]*u+n[2]*_,e}function nc(e,t){t=t===void 0?1:t;let r=_i()*2*Math.PI,i=_i()*2-1,n=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(r)*n,e[1]=Math.sin(r)*n,e[2]=i*t,e}function oc(e,t,r){let i=t[0],n=t[1],o=t[2],s=r[3]*i+r[7]*n+r[11]*o+r[15];return s=s||1,e[0]=(r[0]*i+r[4]*n+r[8]*o+r[12])/s,e[1]=(r[1]*i+r[5]*n+r[9]*o+r[13])/s,e[2]=(r[2]*i+r[6]*n+r[10]*o+r[14])/s,e}function sc(e,t,r){let i=t[0],n=t[1],o=t[2];return e[0]=i*r[0]+n*r[3]+o*r[6],e[1]=i*r[1]+n*r[4]+o*r[7],e[2]=i*r[2]+n*r[5]+o*r[8],e}function ac(e,t,r){let i=r[0],n=r[1],o=r[2],s=r[3],a=t[0],f=t[1],l=t[2],c=n*l-o*f,u=o*a-i*l,_=i*f-n*a,d=n*_-o*u,p=o*c-i*_,g=i*u-n*c,h=s*2;return c*=h,u*=h,_*=h,d*=2,p*=2,g*=2,e[0]=a+c+d,e[1]=f+u+p,e[2]=l+_+g,e}function fc(e,t,r,i){let n=[],o=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],o[0]=n[0],o[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),o[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function lc(e,t,r,i){let n=[],o=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],o[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),o[1]=n[1],o[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function cc(e,t,r,i){let n=[],o=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],o[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),o[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),o[2]=n[2],e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function uc(e,t){let r=e[0],i=e[1],n=e[2],o=t[0],s=t[1],a=t[2],f=Math.sqrt((r*r+i*i+n*n)*(o*o+s*s+a*a)),l=f&&pi(e,t)/f;return Math.acos(Math.min(Math.max(l,-1),1))}function _c(e){return e[0]=0,e[1]=0,e[2]=0,e}function dc(e){return"vec3(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")}function pc(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function hc(e,t){let r=e[0],i=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))}var gc=Lo,Tc=jo,Ac=Ko,Rc=zo,bc=Yo,Ec=Xo,vc=$o,mc=function(){let e=Ho();return function(t,r,i,n,o,s){let a,f;for(r||(r=3),i||(i=0),n?f=Math.min(n*r+i,t.length):f=t.length,a=i;a<f;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,s),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}}();var hi=T(E(),1);var Yt=class{constructor(t){this.modules=void 0,this.moduleUniforms=void 0,this.moduleBindings=void 0,this.moduleUniformsChanged=void 0;let r=ot(Object.values(t));hi.log.log(1,"Creating ShaderInputs with modules",r.map(i=>i.name))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[i,n]of Object.entries(t)){let o=i;this.moduleUniforms[o]=n.defaultUniforms||{},this.moduleBindings[o]={}}}destroy(){}setProps(t){for(let i of Object.keys(t)){var r;let n=i,o=t[n],s=this.modules[n];if(!s){hi.log.warn(`Module ${i} not found`)();continue}let a=this.moduleUniforms[n],f=((r=s.getUniforms)===null||r===void 0?void 0:r.call(s,o,this.moduleUniforms[n]))||o;this.moduleUniforms[n]={...a,...f}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let t={};for(let r of Object.values(this.moduleBindings))Object.assign(t,r);return t}getDebugTable(){let t={};for(let[i,n]of Object.entries(this.moduleUniforms))for(let[o,s]of Object.entries(n)){var r;t[`${i}.${o}`]={type:(r=this.modules[i].uniformTypes)===null||r===void 0?void 0:r[o],value:String(s)}}return t}};var le=T(E(),1),$t=class{constructor(t){this.id=void 0,this.userData={},this.topology=void 0,this.bufferLayout=[],this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.id=t.id||(0,le.uid)("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&(0,le.assert)(this.indices.usage===le.Buffer.INDEX)}destroy(){var t;this.indices.destroy(),this.attributes.positions.destroy(),this.attributes.normals.destroy(),this.attributes.texCoords.destroy(),(t=this.attributes.colors)===null||t===void 0||t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(t){return t.byteLength/12}};function qo(e,t){if(t instanceof $t)return t;let r=Sc(e,t),{attributes:i,bufferLayout:n}=yc(e,t);return new $t({topology:t.topology||"triangle-list",bufferLayout:n,vertexCount:t.vertexCount,indices:r,attributes:i})}function Sc(e,t){if(!t.indices)return;let r=t.indices.value;return e.createBuffer({usage:le.Buffer.INDEX,data:r})}function yc(e,t){let r=[],i={};for(let[o,s]of Object.entries(t.attributes)){let a=o;switch(o){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}i[a]=e.createBuffer({data:s.value,id:`${o}-buffer`});let{value:f,size:l,normalized:c}=s;r.push({name:a,format:(0,le.getVertexFormatFromAttribute)(f,l,c)})}let n=t._calculateVertexCount(t.attributes,t.indices);return{attributes:i,bufferLayout:r,vertexCount:n}}var Zo=T(E(),1),he=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new he(t),t._lumaData.defaultPipelineFactory}constructor(t){this.device=void 0,this._hashCounter=0,this._hashes={},this._useCounts={},this._pipelineCache={},this.device=t}createRenderPipeline(t){let r={...he.defaultProps,...t},i=this._hashRenderPipeline({...r});if(!this._pipelineCache[i]){let n=this.device.createRenderPipeline({...r,vs:this.device.createShader({stage:"vertex",source:r.vs}),fs:r.fs?this.device.createShader({stage:"fragment",source:r.fs}):null});n.hash=i,this._pipelineCache[i]=n,this._useCounts[i]=0}return this._useCounts[i]++,this._pipelineCache[i]}release(t){let r=t.hash;this._useCounts[r]--,this._useCounts[r]===0&&(this._pipelineCache[r].destroy(),delete this._pipelineCache[r],delete this._useCounts[r])}_createRenderPipeline(t){if(!t.fs)throw new Error("fs");return this.device.createRenderPipeline({...t,vs:this.device.createShader({stage:"vertex",source:t.vs}),fs:t.fs?this.device.createShader({stage:"fragment",source:t.fs}):null})}_hashRenderPipeline(t){let r=this._getHash(t.vs),i=t.fs?this._getHash(t.fs):0,n="-";switch(this.device.info.type){case"webgpu":let o=this._getHash(JSON.stringify(t.parameters)),s=this._getHash(JSON.stringify(t.bufferLayout));return`${r}/${i}V${n}T${t.topology}P${o}BL${s}}`;default:return`${r}/${i}V${n}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}};he.defaultProps={...Zo.RenderPipeline.defaultProps,vs:void 0,fs:void 0};function Qo(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r={},i=`Shader Layout for ${t}`;for(let n of e.attributes)if(n){let o=`${n.location} ${n.name}: ${n.type}`;r[`in ${o}`]={[i]:n.stepMode||"vertex"}}for(let n of e.varyings||[]){let o=`${n.location} ${n.name}`;r[`out ${o}`]={[i]:JSON.stringify(n.accessor)}}return r}var qt=2,Oc=1e4,ge=class{constructor(t,r){var i,n,o;this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.vertexArray=void 0,this.transformFeedback=null,this.pipeline=void 0,this.shaderInputs=void 0,this._uniformStore=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this._lastLogTime=0,this._logOpen=!1,this.props={...ge.defaultProps,...r},r=this.props,this.id=r.id||(0,C.uid)("model"),this.device=t,Object.assign(this.userData,r.userData);let s=Object.fromEntries(((i=this.props.modules)===null||i===void 0?void 0:i.map(_=>[_.name,_]))||[]);this.setShaderInputs(r.shaderInputs||new Yt(s));let a=xc(t),f=(((n=this.props.modules)===null||n===void 0?void 0:n.length)>0?this.props.modules:(o=this.shaderInputs)===null||o===void 0?void 0:o.getModules())||[],{vs:l,fs:c,getUniforms:u}=this.props.shaderAssembler.assembleShaders({platformInfo:a,...this.props,modules:f});if(this.vs=l,this.fs=c,this._getModuleUniforms=u,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&(this._gpuGeometry=this.setGeometry(r.geometry)),this.pipelineFactory=r.pipelineFactory||he.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),r.vertexCount&&this.setVertexCount(r.vertexCount),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&(C.log.warn("Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()")(),this.updateModuleSettings(r.moduleSettings)),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){this.pipelineFactory.release(this.pipeline),this._uniformStore.destroy()}predraw(){this.updateShaderInputs()}draw(t){this.predraw();try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount,transformFeedback:this.transformFeedback})}finally{this._logDrawCallEnd()}}setGeometry(t){let r=t&&qo(this.device,t);return this.setTopology(r.topology||"triangle-list"),this.bufferLayout=Jo(this.bufferLayout,r.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r),r}_setGeometryAttributes(t){this.vertexCount=t.vertexCount,this.setAttributes(t.attributes,"ignore-unknown"),this.setIndexBuffer(t.indices)}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){this.bufferLayout=this._gpuGeometry?Jo(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){(0,C.deepEqual)(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setVertexCount(t){this.vertexCount=t}setInstanceCount(t){this.instanceCount=t}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new Zt.UniformStore(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues())}updateModuleSettings(t){C.log.warn("Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()")();let{bindings:r,uniforms:i}=(0,C.splitUniformsAndBindings)(this._getModuleUniforms(t));Object.assign(this.bindings,r),Object.assign(this.uniforms,i)}setBindings(t){Object.assign(this.bindings,t)}setUniforms(t){this.pipeline.setUniforms(t),Object.assign(this.uniforms,t)}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t)}setTransformFeedback(t){this.transformFeedback=t}setAttributes(t,r){t.indices&&C.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[n,o]of Object.entries(t)){var i;let s=this.bufferLayout.find(l=>l.name===n);if(!s){C.log.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}let a=s.attributes?(i=s.attributes)===null||i===void 0?void 0:i.map(l=>l.attribute):[s.name],f=!1;for(let l of a){let c=this._attributeInfos[l];c&&(this.vertexArray.setBuffer(c.location,o),f=!0)}!f&&r!=="ignore-unknown"&&C.log.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${n}"`)()}}setConstantAttributes(t){for(let[r,i]of Object.entries(t)){let n=this._attributeInfos[r];n?this.vertexArray.setConstant(n.location,i):C.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||t}_updatePipeline(){return this._pipelineNeedsUpdate&&(this.pipeline&&C.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),this._pipelineNeedsUpdate=!1,this.pipeline=this.device.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:this.device.createShader({id:"{$this.id}-vertex",stage:"vertex",source:this.vs}),fs:this.fs?this.device.createShader({id:"{$this.id}-fragment",stage:"fragment",source:this.fs}):null}),this._attributeInfos=(0,Go.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout,this.bufferLayout)),this.pipeline}_logDrawCallStart(){let t=C.log.level>3?0:Oc;Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,C.log.group(qt,`>>> DRAWING MODEL ${this.id}`,{collapsed:C.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Qo(this.pipeline.shaderLayout);C.log.table(qt,t)();let r=this.shaderInputs.getDebugTable();for(let[i,n]of Object.entries(this.uniforms))r[i]={value:n};C.log.table(qt,r)(),C.log.groupEnd(qt)(),this._logOpen=!1}}};ge.defaultProps={...Zt.RenderPipeline.defaultProps,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],shaderInputs:void 0,pipelineFactory:void 0,transformFeedback:void 0,shaderAssembler:$.getDefaultShaderAssembler()};function Jo(e,t){let r=[...e];for(let i of t){let n=r.findIndex(o=>o.name===i.name);n<0?r.push(i):r[n]=i}return r}function xc(e){return{type:e.info.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}function es(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function Pc(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?es(Object(r),!0).forEach(function(i){Fc(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):es(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Fc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ic=`#version 300 es
|
|
1116
|
+
`;var lu={ONE:1};function fu(){return lu}var da={name:"fp64-arithmetic",vs:ua,getUniforms:fu,fp64ify:Br,fp64LowPart:Bi,fp64ifyMatrix4:Di},Mt={name:"fp64",vs:_a,dependencies:[da],fp64ify:Br,fp64LowPart:Bi,fp64ifyMatrix4:Di};var jb=1/Math.PI*180,zb=1/180*Math.PI,cu={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...cu}};var Ct=globalThis.mathgl.config;function ki(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rt(e,t,r){let n=Ct.EPSILON;r&&(Ct.EPSILON=r);try{if(e===t)return!0;if(ki(e)&&ki(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!rt(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=Ct.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{Ct.EPSILON=n}}var Bt=typeof Float32Array<"u"?Float32Array:Array,Ui=Math.random;function Dr(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var Yb=Math.PI/180;var kr={};os(kr,{add:()=>gu,angle:()=>Vu,bezier:()=>Fu,ceil:()=>mu,clone:()=>_u,copy:()=>hu,create:()=>ha,cross:()=>Ou,dist:()=>Yu,distance:()=>Ta,div:()=>Ku,divide:()=>ba,dot:()=>Wi,equals:()=>Xu,exactEquals:()=>Lu,floor:()=>bu,forEach:()=>Qu,fromValues:()=>du,hermite:()=>Iu,inverse:()=>xu,len:()=>qu,length:()=>pa,lerp:()=>wu,max:()=>Au,min:()=>Tu,mul:()=>zu,multiply:()=>ma,negate:()=>Eu,normalize:()=>Su,random:()=>Nu,rotateX:()=>Du,rotateY:()=>ku,rotateZ:()=>Uu,round:()=>vu,scale:()=>yu,scaleAndAdd:()=>Ru,set:()=>pu,slerp:()=>Pu,sqrDist:()=>$u,sqrLen:()=>Zu,squaredDistance:()=>Aa,squaredLength:()=>va,str:()=>Hu,sub:()=>ju,subtract:()=>ga,transformMat3:()=>Cu,transformMat4:()=>Mu,transformQuat:()=>Bu,zero:()=>Wu});function ha(){let e=new Bt(3);return Bt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function _u(e){let t=new Bt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function pa(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function du(e,t,r){let n=new Bt(3);return n[0]=e,n[1]=t,n[2]=r,n}function hu(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function pu(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function gu(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function ga(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function ma(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function ba(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function mu(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function bu(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Tu(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Au(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function vu(e,t){return e[0]=Dr(t[0]),e[1]=Dr(t[1]),e[2]=Dr(t[2]),e}function yu(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Ru(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function Ta(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function Aa(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function va(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function Eu(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function xu(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Su(e,t){let r=t[0],n=t[1],i=t[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function Wi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ou(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],l=r[2];return e[0]=i*l-s*a,e[1]=s*o-n*l,e[2]=n*a-i*o,e}function wu(e,t,r,n){let i=t[0],s=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e}function Pu(e,t,r,n){let i=Math.acos(Math.min(Math.max(Wi(t,r),-1),1)),s=Math.sin(i),o=Math.sin((1-n)*i)/s,a=Math.sin(n*i)/s;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function Iu(e,t,r,n,i,s){let o=s*s,a=o*(2*s-3)+1,l=o*(s-2)+s,f=o*(s-1),u=o*(3-2*s);return e[0]=t[0]*a+r[0]*l+n[0]*f+i[0]*u,e[1]=t[1]*a+r[1]*l+n[1]*f+i[1]*u,e[2]=t[2]*a+r[2]*l+n[2]*f+i[2]*u,e}function Fu(e,t,r,n,i,s){let o=1-s,a=o*o,l=s*s,f=a*o,u=3*s*a,_=3*l*o,p=l*s;return e[0]=t[0]*f+r[0]*u+n[0]*_+i[0]*p,e[1]=t[1]*f+r[1]*u+n[1]*_+i[1]*p,e[2]=t[2]*f+r[2]*u+n[2]*_+i[2]*p,e}function Nu(e,t){t=t===void 0?1:t;let r=Ui()*2*Math.PI,n=Ui()*2-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e}function Mu(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,e}function Cu(e,t,r){let n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function Bu(e,t,r){let n=r[0],i=r[1],s=r[2],o=r[3],a=t[0],l=t[1],f=t[2],u=i*f-s*l,_=s*a-n*f,p=n*l-i*a,g=i*p-s*_,b=s*u-n*p,A=n*_-i*u,T=o*2;return u*=T,_*=T,p*=T,g*=2,b*=2,A*=2,e[0]=a+u+g,e[1]=l+_+b,e[2]=f+p+A,e}function Du(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function ku(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Uu(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Vu(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2],l=Math.sqrt((r*r+n*n+i*i)*(s*s+o*o+a*a)),f=l&&Wi(e,t)/l;return Math.acos(Math.min(Math.max(f,-1),1))}function Wu(e){return e[0]=0,e[1]=0,e[2]=0,e}function Hu(e){return"vec3(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")}function Lu(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Xu(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}var ju=ga,zu=ma,Ku=ba,Yu=Ta,$u=Aa,qu=pa,Zu=va,Qu=function(){let e=ha();return function(t,r,n,i,s,o){let a,l;for(r||(r=3),n||(n=0),i?l=Math.min(i*r+n,t.length):l=t.length,a=n;a<l;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}}();var Hi=v(x(),1);var Ur=class{constructor(t){this.modules=void 0,this.moduleUniforms=void 0,this.moduleBindings=void 0,this.moduleUniformsChanged=void 0;let r=Pt(Object.values(t));Hi.log.log(1,"Creating ShaderInputs with modules",r.map(n=>n.name))(),this.modules=t,this.moduleUniforms={},this.moduleBindings={};for(let[n,i]of Object.entries(t)){let s=n;this.moduleUniforms[s]=i.defaultUniforms||{},this.moduleBindings[s]={}}}destroy(){}setProps(t){for(let n of Object.keys(t)){var r;let i=n,s=t[i],o=this.modules[i];if(!o){Hi.log.warn(`Module ${n} not found`)();continue}let a=this.moduleUniforms[i],l=((r=o.getUniforms)===null||r===void 0?void 0:r.call(o,s,this.moduleUniforms[i]))||s;this.moduleUniforms[i]={...a,...l}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let t={};for(let r of Object.values(this.moduleBindings))Object.assign(t,r);return t}getDebugTable(){let t={};for(let[n,i]of Object.entries(this.moduleUniforms))for(let[s,o]of Object.entries(i)){var r;t[`${n}.${s}`]={type:(r=this.modules[n].uniformTypes)===null||r===void 0?void 0:r[s],value:String(o)}}return t}};var ve=v(x(),1),Vr=class{constructor(t){this.id=void 0,this.userData={},this.topology=void 0,this.bufferLayout=[],this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.id=t.id||(0,ve.uid)("geometry"),this.topology=t.topology,this.indices=t.indices||null,this.attributes=t.attributes,this.vertexCount=t.vertexCount,this.bufferLayout=t.bufferLayout||[],this.indices&&(0,ve.assert)(this.indices.usage===ve.Buffer.INDEX)}destroy(){var t;this.indices.destroy(),this.attributes.positions.destroy(),this.attributes.normals.destroy(),this.attributes.texCoords.destroy(),(t=this.attributes.colors)===null||t===void 0||t.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(t){return t.byteLength/12}};function ya(e,t){if(t instanceof Vr)return t;let r=Ju(e,t),{attributes:n,bufferLayout:i}=Gu(e,t);return new Vr({topology:t.topology||"triangle-list",bufferLayout:i,vertexCount:t.vertexCount,indices:r,attributes:n})}function Ju(e,t){if(!t.indices)return;let r=t.indices.value;return e.createBuffer({usage:ve.Buffer.INDEX,data:r})}function Gu(e,t){let r=[],n={};for(let[s,o]of Object.entries(t.attributes)){let a=s;switch(s){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}n[a]=e.createBuffer({data:o.value,id:`${s}-buffer`});let{value:l,size:f,normalized:u}=o;r.push({name:a,format:(0,ve.getVertexFormatFromAttribute)(l,f,u)})}let i=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:r,vertexCount:i}}var Ra=v(x(),1),Ie=class{static getDefaultPipelineFactory(t){return t._lumaData.defaultPipelineFactory=t._lumaData.defaultPipelineFactory||new Ie(t),t._lumaData.defaultPipelineFactory}constructor(t){this.device=void 0,this._hashCounter=0,this._hashes={},this._useCounts={},this._pipelineCache={},this.device=t}createRenderPipeline(t){let r={...Ie.defaultProps,...t},n=this._hashRenderPipeline({...r});if(!this._pipelineCache[n]){let i=this.device.createRenderPipeline({...r,vs:this.device.createShader({stage:"vertex",source:r.vs}),fs:r.fs?this.device.createShader({stage:"fragment",source:r.fs}):null});i.hash=n,this._pipelineCache[n]=i,this._useCounts[n]=0}return this._useCounts[n]++,this._pipelineCache[n]}release(t){let r=t.hash;this._useCounts[r]--,this._useCounts[r]===0&&(this._pipelineCache[r].destroy(),delete this._pipelineCache[r],delete this._useCounts[r])}_createRenderPipeline(t){if(!t.fs)throw new Error("fs");return this.device.createRenderPipeline({...t,vs:this.device.createShader({stage:"vertex",source:t.vs}),fs:t.fs?this.device.createShader({stage:"fragment",source:t.fs}):null})}_hashRenderPipeline(t){let r=this._getHash(t.vs),n=t.fs?this._getHash(t.fs):0,i="-";switch(this.device.info.type){case"webgpu":let s=this._getHash(JSON.stringify(t.parameters)),o=this._getHash(JSON.stringify(t.bufferLayout));return`${r}/${n}V${i}T${t.topology}P${s}BL${o}}`;default:return`${r}/${n}V${i}`}}_getHash(t){return this._hashes[t]===void 0&&(this._hashes[t]=this._hashCounter++),this._hashes[t]}};Ie.defaultProps={...Ra.RenderPipeline.defaultProps,vs:void 0,fs:void 0};function Ea(e,t){var r;let n={},i="Values";if(e.attributes.length===0&&!((r=e.varyings)!==null&&r!==void 0&&r.length))return{"No attributes or varyings":{[i]:"N/A"}};for(let s of e.attributes)if(s){let o=`${s.location} ${s.name}: ${s.type}`;n[`in ${o}`]={[i]:s.stepMode||"vertex"}}for(let s of e.varyings||[]){let o=`${s.location} ${s.name}`;n[`out ${o}`]={[i]:JSON.stringify(s.accessor)}}return n}var V=null,Li=null;function xa(e,t){let{id:r,minimap:n,opaque:i,top:s="0",left:o="0",rgbaScale:a=1}=t;V||(V=document.createElement("canvas"),V.id=r,V.title=r,V.style.zIndex="100",V.style.position="absolute",V.style.top=s,V.style.left=o,V.style.border="blue 1px solid",V.style.transform="scaleY(-1)",document.body.appendChild(V),Li=V.getContext("2d")),(V.width!==e.width||V.height!==e.height)&&(V.width=e.width/2,V.height=e.height/2,V.style.width="400px",V.style.height="400px");let l=e.device.readPixelsToArrayWebGL(e),f=Li.createImageData(e.width,e.height),u=0;for(let _=0;_<l.length;_+=4)f.data[u+_+0]=l[_+0]*a,f.data[u+_+1]=l[_+1]*a,f.data[u+_+2]=l[_+2]*a,f.data[u+_+3]=i?255:l[_+3]*a;Li.putImageData(f,0,0)}var nt=2,e_=1e4,Fe=class{constructor(t,r){var n,i,s;this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.vertexArray=void 0,this.transformFeedback=null,this.pipeline=void 0,this.shaderInputs=void 0,this._uniformStore=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this._lastLogTime=0,this._logOpen=!1,this._drawCount=0,this.props={...Fe.defaultProps,...r},r=this.props,this.id=r.id||(0,I.uid)("model"),this.device=t,Object.assign(this.userData,r.userData);let o=Object.fromEntries(((n=this.props.modules)===null||n===void 0?void 0:n.map(A=>[A.name,A]))||[]);this.setShaderInputs(r.shaderInputs||new Ur(o));let a=this.device.info.type==="webgpu";if(this.props.source){if(a){var l;(l=this.props).shaderLayout||(l.shaderLayout=Cr(this.props.source))}this.props.fs=this.props.source,this.props.vs=this.props.source}if(a&&typeof this.props.vs!="string"){var f;(f=this.props).shaderLayout||(f.shaderLayout=Cr(this.props.vs.wgsl))}let u=t_(t),_=(((i=this.props.modules)===null||i===void 0?void 0:i.length)>0?this.props.modules:(s=this.shaderInputs)===null||s===void 0?void 0:s.getModules())||[],{vs:p,fs:g,getUniforms:b}=this.props.shaderAssembler.assembleShaders({platformInfo:u,...this.props,modules:_});if(this.vs=p,this.fs=g,this._getModuleUniforms=b,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&(this._gpuGeometry=this.setGeometry(r.geometry)),this.pipelineFactory=r.pipelineFactory||Ie.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=t.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),r.vertexCount&&this.setVertexCount(r.vertexCount),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&(I.log.warn("Model.props.moduleSettings is deprecated. Use Model.shaderInputs.setProps()")(),this.updateModuleSettings(r.moduleSettings)),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){this.pipelineFactory.release(this.pipeline),this._uniformStore.destroy()}predraw(){this.updateShaderInputs()}draw(t){this.predraw();try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:t,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount,transformFeedback:this.transformFeedback})}finally{this._logDrawCallEnd()}this._logFramebuffer(t)}setGeometry(t){let r=t&&ya(this.device,t);return this.setTopology(r.topology||"triangle-list"),this.bufferLayout=Sa(this.bufferLayout,r.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r),r}_setGeometryAttributes(t){let r={...t.attributes};for(let[n]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(i=>i.name===n)&&n!=="positions"&&delete r[n];this.vertexCount=t.vertexCount,this.setIndexBuffer(t.indices),this.setAttributes(t.attributes,"ignore-unknown"),this.setAttributes(r)}setTopology(t){t!==this.topology&&(this.topology=t,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(t){this.bufferLayout=this._gpuGeometry?Sa(t,this._gpuGeometry.bufferLayout):t,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(t){(0,I.deepEqual)(t,this.parameters,2)||(this.parameters=t,this._setPipelineNeedsUpdate("parameters"))}setVertexCount(t){this.vertexCount=t}setInstanceCount(t){this.instanceCount=t}setShaderInputs(t){this.shaderInputs=t,this._uniformStore=new Ne.UniformStore(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let n=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=n}}setShaderModuleProps(t){let r=this._getModuleUniforms(t),n=Object.keys(r).filter(s=>{let o=r[s];return!(0,I.isNumberArray)(o)&&typeof o!="number"&&typeof o!="boolean"}),i={};for(let s of n)i[s]=r[s],delete r[s]}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues())}updateModuleSettings(t){I.log.warn("Model.updateModuleSettings is deprecated. Use Model.shaderInputs.setProps()")();let{bindings:r,uniforms:n}=(0,I.splitUniformsAndBindings)(this._getModuleUniforms(t));Object.assign(this.bindings,r),Object.assign(this.uniforms,n)}setBindings(t){Object.assign(this.bindings,t)}setUniforms(t){this.pipeline.setUniforms(t),Object.assign(this.uniforms,t)}setIndexBuffer(t){this.vertexArray.setIndexBuffer(t)}setTransformFeedback(t){this.transformFeedback=t}setAttributes(t,r){t.indices&&I.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[n,i]of Object.entries(t)){let s=this.bufferLayout.find(l=>Oa(l).includes(n));if(!s){I.log.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}let o=Oa(s),a=!1;for(let l of o){let f=this._attributeInfos[l];f&&(this.vertexArray.setBuffer(f.location,i),a=!0)}!a&&r!=="ignore-unknown"&&I.log.warn(`Model(${this.id}): Ignoring buffer "${i.id}" for unknown attribute "${n}"`)()}}setConstantAttributes(t){for(let[r,n]of Object.entries(t)){let i=this._attributeInfos[r];i?this.vertexArray.setConstant(i.location,n):I.log.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}}_setPipelineNeedsUpdate(t){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||t}_updatePipeline(){if(this._pipelineNeedsUpdate){this.pipeline&&I.log.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),this._pipelineNeedsUpdate=!1;let t=this.device.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.vs}),r=this.fs?this.device.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.fs}):null;this.pipeline=this.device.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:t,fs:r}),this._attributeInfos=(0,wa.getAttributeInfosFromLayouts)(this.pipeline.shaderLayout,this.bufferLayout)}return this.pipeline}_logDrawCallStart(){let t=I.log.level>3?0:e_;I.log.level<2||Date.now()-this._lastLogTime<t||(this._lastLogTime=Date.now(),this._logOpen=!0,I.log.group(nt,`>>> DRAWING MODEL ${this.id}`,{collapsed:I.log.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let t=Ea(this.pipeline.shaderLayout,this.id);I.log.table(nt,t)();let r=this.shaderInputs.getDebugTable();for(let[i,s]of Object.entries(this.uniforms))r[i]={value:s};I.log.table(nt,r)();let n=this._getAttributeDebugTable();I.log.table(nt,this._attributeInfos)(),I.log.table(nt,n)(),I.log.groupEnd(nt)(),this._logOpen=!1}}_logFramebuffer(t){let r=I.log.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let n=t.props.framebuffer;n&&xa(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let t={};for(let[r,n]of Object.entries(this._attributeInfos))t[n.location]={name:r,type:n.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[n.location],n.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,n=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);t.indices={name:"indices",type:r.indexType,values:n.toString()}}return t}_getBufferOrConstantValues(t,r){let n=(0,Ne.getTypedArrayFromDataType)(r);return(t instanceof Ne.Buffer?new n(t.debugData):t).toString()}};Fe.defaultProps={...Ne.RenderPipeline.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],shaderInputs:void 0,pipelineFactory:void 0,transformFeedback:void 0,shaderAssembler:re.getDefaultShaderAssembler()};function Sa(e,t){let r=[...e];for(let n of t){let i=r.findIndex(s=>s.name===n.name);i<0?r.push(n):r[i]=n}return r}function t_(e){return{type:e.info.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}function Oa(e){var t;return e.attributes?(t=e.attributes)===null||t===void 0?void 0:t.map(r=>r.attribute):[e.name]}function Pa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function r_(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Pa(Object(r),!0).forEach(function(n){n_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pa(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function n_(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i_=`#version 300 es
|
|
1114
1117
|
#define SHADER_NAME data-filter-vertex-shader
|
|
1115
1118
|
|
|
1116
1119
|
#ifdef FLOAT_TARGET
|
|
@@ -1141,7 +1144,7 @@ void main() {
|
|
|
1141
1144
|
#endif
|
|
1142
1145
|
gl_PointSize = 1.0;
|
|
1143
1146
|
}
|
|
1144
|
-
`,
|
|
1147
|
+
`,s_=`#version 300 es
|
|
1145
1148
|
#define SHADER_NAME data-filter-fragment-shader
|
|
1146
1149
|
precision highp float;
|
|
1147
1150
|
|
|
@@ -1155,7 +1158,7 @@ void main() {
|
|
|
1155
1158
|
}
|
|
1156
1159
|
fragColor = vColor;
|
|
1157
1160
|
}
|
|
1158
|
-
`;function
|
|
1161
|
+
`;function Ia(e){var t=e.gl;return Boolean(t.getExtension("EXT_float_blend")&&(t.getExtension("EXT_color_buffer_float")||t.getExtension("WEBGL_color_buffer_float")))}function Fa(e,t){return t?e.createFramebuffer({width:1,height:1,colorAttachments:[e.createTexture({format:e.info.type==="webgl2"?"rgba32float":"rgba8unorm",type:5126,mipmaps:!1})]}):e.createFramebuffer({width:256,height:64,colorAttachments:[e.createTexture({format:"rgba8unorm",type:5126,mipmaps:!1})]})}function Na(e,t,r){return t.defines.NON_INSTANCED_MODEL=1,r&&(t.defines.FLOAT_TARGET=1),new Fe(e,r_({id:"data-filter-aggregation-model",vertexCount:1,isInstanced:!1,drawMode:0,vs:i_,fs:s_},t))}var Ma={blend:!0,blendFunc:[1,1,1,1],blendEquation:[32774,32774],depthTest:!1};function Hr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Hr=function(r){return typeof r}:Hr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Hr(e)}function Ca(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Wr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ca(Object(r),!0).forEach(function(n){a_(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ca(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function a_(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Xi(e,t)}function Xi(e,t){return Xi=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Xi(e,t)}function c_(e){var t=d_();return function(){var n=Lr(e),i;if(t){var s=Lr(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return u_(this,i)}}function u_(e,t){if(t&&(Hr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return __(e)}function __(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Lr(e){return Lr=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Lr(e)}var h_={getFilterValue:{type:"accessor",value:0},onFilteredItemsChange:{type:"function",value:null,optional:!0},filterEnabled:!0,filterRange:[-1,1],filterSoftRange:null,filterTransformSize:!0,filterTransformColor:!0},Ba={1:"float",2:"vec2",3:"vec3",4:"vec4"},Xr=function(e){f_(r,e);var t=c_(r);function r(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=i.filterSize,o=s===void 0?1:s,a=i.fp64,l=a===void 0?!1:a,f=i.countItems,u=f===void 0?!1:f;if(l_(this,r),!Ba[o])throw new Error("filterSize out of range");return t.call(this,{filterSize:o,fp64:l,countItems:u})}var n=r.prototype;return n.getShaders=function(s){var o=s.opts,a=o.filterSize,l=o.fp64;return{modules:[l?Vo:Uo],defines:{DATAFILTER_TYPE:Ba[a],DATAFILTER_DOUBLE:Boolean(l)}}},n.initializeState=function(s,o){var a=this.getAttributeManager();a&&a.add({filterValues:{size:o.opts.filterSize,type:o.opts.fp64?5130:5126,accessor:"getFilterValue",shaderAttributes:{filterValues:{divisor:0},instanceFilterValues:{divisor:1}}}});var l=this.context.device;if(a&&o.opts.countItems){var f=Ia(l);a.add({filterIndices:{size:f?1:2,vertexOffset:1,type:5121,normalized:!0,accessor:function(g,b){var A=b.index,T=g&&g.__source?g.__source.index:A;return f?(T+1)%255:[(T+1)%255,Math.floor(T/255)%255]},shaderAttributes:{filterPrevIndices:{vertexOffset:0},filterIndices:{vertexOffset:1}}}});var u=Fa(l,f),_=Na(l,o.getShaders.call(this,o),f);this.setState({filterFBO:u,filterModel:_})}},n.updateState=function(s){var o=s.props,a=s.oldProps;if(this.state.filterModel){var l=this.getAttributeManager(),f=l.attributes.filterValues.needsUpdate()||o.filterEnabled!==a.filterEnabled||o.filterRange!==a.filterRange||o.filterSoftRange!==a.filterSoftRange;f&&this.setState({filterNeedsUpdate:f})}},n.draw=function(s,o){var a=this,l=this.state.filterFBO,f=this.state.filterModel,u=this.state.filterNeedsUpdate,_=this.props.onFilteredItemsChange;if(u&&_&&f){var p=this.getAttributeManager(),g=p.attributes,b=g.filterValues,A=g.filterIndices;f.setVertexCount(this.getNumInstances()),Zn(this.context.device,{framebuffer:l,color:[0,0,0,0]}),f.updateModuleSettings(s.moduleParameters),f.setAttributes(Wr(Wr({},b.getValue()),A?.getValue())),C(f.device,Wr(Wr({framebuffer:l},Ma),{},{viewport:[0,0,l.width,l.height]}),function(){f.draw(a.context.renderPass)});for(var T=xt(l),R=0,y=0;y<T.length;y++)R+=T[y];_({id:this.id,count:R}),this.state.filterNeedsUpdate=!1}},n.finalizeState=function(){var s=this.state.filterFBO,o=this.state.filterModel;s?.destroy(),o?.destroy()},r}(Da.LayerExtension);Xr.defaultProps=h_;Xr.extensionName="DataFilterExtension";var Dt=v(w());var jr=v(w());var ka=`
|
|
1159
1162
|
const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
1160
1163
|
|
|
1161
1164
|
uniform vec2 project_uViewProjectionMatrixFP64[16];
|
|
@@ -1229,7 +1232,7 @@ vec4 project_position_to_clipspace(
|
|
|
1229
1232
|
position, position64xyLow, offset, commonPosition
|
|
1230
1233
|
);
|
|
1231
1234
|
}
|
|
1232
|
-
`;var
|
|
1235
|
+
`;var p_=Mt.fp64ify,g_=Mt.fp64ifyMatrix4,zr={name:"project64",dependencies:[jr.project,Mt],vs:ka,getUniforms:b_},m_=(0,jr._memoize)(T_);function b_(e){if(e&&"viewport"in e){var t=e.viewport,r=t.viewProjectionMatrix,n=t.scale;return m_({viewProjectionMatrix:r,scale:n})}return{}}function T_(e){var t=e.viewProjectionMatrix,r=e.scale,n=g_(t),i=p_(r);return{project_uViewProjectionMatrixFP64:n,project64_uViewProjectionMatrix:n,project64_uScale:i}}function Kr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Kr=function(r){return typeof r}:Kr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Kr(e)}function A_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ji(e,t)}function ji(e,t){return ji=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},ji(e,t)}function y_(e){var t=x_();return function(){var n=Yr(e),i;if(t){var s=Yr(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return R_(this,i)}}function R_(e,t){if(t&&(Kr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return E_(e)}function E_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Yr(e){return Yr=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Yr(e)}var zi=function(e){v_(r,e);var t=y_(r);function r(){return A_(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){var s=this.props.coordinateSystem;if(s!==Dt.COORDINATE_SYSTEM.LNGLAT&&s!==Dt.COORDINATE_SYSTEM.DEFAULT)throw new Error("fp64: coordinateSystem must be LNGLAT");return{modules:[zr]}},r}(Dt.LayerExtension);zi.extensionName="Fp64Extension";var kt=v(w());var Ua={inject:{"vs:#decl":`
|
|
1233
1236
|
in vec2 instanceDashArrays;
|
|
1234
1237
|
in float instanceDashOffsets;
|
|
1235
1238
|
out vec2 vDashArray;
|
|
@@ -1278,7 +1281,7 @@ in float vDashOffset;
|
|
|
1278
1281
|
}
|
|
1279
1282
|
}
|
|
1280
1283
|
}
|
|
1281
|
-
`}},
|
|
1284
|
+
`}},Va={inject:{"vs:#decl":`
|
|
1282
1285
|
in float instanceOffsets;
|
|
1283
1286
|
`,"vs:DECKGL_FILTER_SIZE":`
|
|
1284
1287
|
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
@@ -1295,7 +1298,7 @@ in float instanceOffsets;
|
|
|
1295
1298
|
if (isInside == 0.0) {
|
|
1296
1299
|
discard;
|
|
1297
1300
|
}
|
|
1298
|
-
`}};function
|
|
1301
|
+
`}};function $r(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?$r=function(r){return typeof r}:$r=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},$r(e)}function S_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function O_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ki(e,t)}function Ki(e,t){return Ki=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Ki(e,t)}function w_(e){var t=F_();return function(){var n=qr(e),i;if(t){var s=qr(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return P_(this,i)}}function P_(e,t){if(t&&($r(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return I_(e)}function I_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function F_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function qr(e){return qr=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},qr(e)}var N_={getDashArray:{type:"accessor",value:[0,0]},getOffset:{type:"accessor",value:0},dashJustified:!1,dashGapPickable:!1},Zr=function(e){O_(r,e);var t=w_(r);function r(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=i.dash,o=s===void 0?!1:s,a=i.offset,l=a===void 0?!1:a,f=i.highPrecisionDash,u=f===void 0?!1:f;return S_(this,r),t.call(this,{dash:o||u,offset:l,highPrecisionDash:u})}var n=r.prototype;return n.isEnabled=function(s){return"pathTesselator"in s.state},n.getShaders=function(s){if(!s.isEnabled(this))return null;var o={};return s.opts.dash&&(o=(0,kt._mergeShaders)(o,Ua)),s.opts.offset&&(o=(0,kt._mergeShaders)(o,Va)),o},n.initializeState=function(s,o){var a=this.getAttributeManager();!a||!o.isEnabled(this)||(o.opts.dash&&a.addInstanced({instanceDashArrays:{size:2,accessor:"getDashArray"},instanceDashOffsets:o.opts.highPrecisionDash?{size:1,accessor:"getPath",transform:o.getDashOffsets.bind(this)}:{size:1,update:function(f){f.constant=!0,f.value=[0]}}}),o.opts.offset&&a.addInstanced({instanceOffsets:{size:1,accessor:"getOffset"}}))},n.updateState=function(s,o){var a;if(o.isEnabled(this)){var l={};o.opts.dash&&(l.dashAlignMode=this.props.dashJustified?1:0,l.dashGapPickable=Boolean(this.props.dashGapPickable)),(a=this.state.model)===null||a===void 0||a.setUniforms(l)}},n.getDashOffsets=function(s){for(var o=[0],a=this.props.positionFormat==="XY"?2:3,l=Array.isArray(s[0]),f=l?s.length:s.length/a,u,_,p=0;p<f-1;p++)u=l?s[p]:s.slice(p*a,p*a+a),u=this.projectPosition(u),p>0&&(o[p]=o[p-1]+kr.dist(_,u)),_=u;return o},r}(kt.LayerExtension);Zr.defaultProps=N_;Zr.extensionName="PathStyleExtension";var Ha=v(w());var Ut=v(w()),M_=`
|
|
1299
1302
|
#ifdef NON_INSTANCED_MODEL
|
|
1300
1303
|
#define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames
|
|
1301
1304
|
#define FILL_PATTERN_SCALE_ATTRIB fillPatternScales
|
|
@@ -1316,7 +1319,7 @@ uniform vec2 fill_patternTextureSize;
|
|
|
1316
1319
|
out vec2 fill_uv;
|
|
1317
1320
|
out vec4 fill_patternBounds;
|
|
1318
1321
|
out vec4 fill_patternPlacement;
|
|
1319
|
-
`,
|
|
1322
|
+
`,C_=`
|
|
1320
1323
|
uniform bool fill_patternEnabled;
|
|
1321
1324
|
uniform bool fill_patternMask;
|
|
1322
1325
|
uniform sampler2D fill_patternTexture;
|
|
@@ -1328,7 +1331,7 @@ in vec4 fill_patternPlacement;
|
|
|
1328
1331
|
in vec2 fill_uv;
|
|
1329
1332
|
|
|
1330
1333
|
const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
1331
|
-
`,
|
|
1334
|
+
`,B_={"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1332
1335
|
fill_uv = geometry.position.xy;
|
|
1333
1336
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1334
1337
|
if (fill_patternEnabled) {
|
|
@@ -1350,13 +1353,13 @@ const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
|
1350
1353
|
color.rgb = patternColor.rgb;
|
|
1351
1354
|
}
|
|
1352
1355
|
}
|
|
1353
|
-
`};function
|
|
1356
|
+
`};function D_(e,t){if(!e)return{};if("fillPatternTexture"in e){var r=e.fillPatternTexture;return{fill_patternTexture:r,fill_patternTextureSize:[r.width,r.height]}}if("viewport"in e){var n=e.fillPatternMask,i=n===void 0?!0:n,s=e.fillPatternEnabled,o=s===void 0?!0:s,a=t,l=a.project_uCommonOrigin,f=[(0,Ut.fp64LowPart)(l[0]),(0,Ut.fp64LowPart)(l[1])];return{fill_uvCoordinateOrigin:l.slice(0,2),fill_uvCoordinateOrigin64Low:f,fill_patternMask:i,fill_patternEnabled:o}}return{}}var Wa={name:"fill-pattern",vs:M_,fs:C_,inject:B_,dependencies:[Ut.project],getUniforms:D_};function Qr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Qr=function(r){return typeof r}:Qr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Qr(e)}function k_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Yi(e,t)}function Yi(e,t){return Yi=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Yi(e,t)}function V_(e){var t=L_();return function(){var n=Jr(e),i;if(t){var s=Jr(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return W_(this,i)}}function W_(e,t){if(t&&(Qr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return H_(e)}function H_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function L_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Jr(e){return Jr=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Jr(e)}var X_={fillPatternEnabled:!0,fillPatternAtlas:{type:"image",value:null,async:!0,parameters:{minFilter:"linear"}},fillPatternMapping:{type:"object",value:{},async:!0},fillPatternMask:!0,getFillPattern:{type:"accessor",value:function(t){return t.pattern}},getFillPatternScale:{type:"accessor",value:1},getFillPatternOffset:{type:"accessor",value:[0,0]}},Gr=function(e){U_(r,e);var t=V_(r);function r(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=i.pattern,o=s===void 0?!1:s;return k_(this,r),t.call(this,{pattern:o})}var n=r.prototype;return n.isEnabled=function(s){return s.getAttributeManager()!==null&&!("pathTesselator"in s.state)},n.getShaders=function(s){return s.isEnabled(this)?{modules:[s.opts.pattern&&Wa].filter(Boolean)}:null},n.initializeState=function(s,o){if(o.isEnabled(this)){var a=this.getAttributeManager();o.opts.pattern&&a.add({fillPatternFrames:{size:4,accessor:"getFillPattern",transform:o.getPatternFrame.bind(this),shaderAttributes:{fillPatternFrames:{divisor:0},instanceFillPatternFrames:{divisor:1}}},fillPatternScales:{size:1,accessor:"getFillPatternScale",defaultValue:1,shaderAttributes:{fillPatternScales:{divisor:0},instanceFillPatternScales:{divisor:1}}},fillPatternOffsets:{size:2,accessor:"getFillPatternOffset",shaderAttributes:{fillPatternOffsets:{divisor:0},instanceFillPatternOffsets:{divisor:1}}}}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}},n.updateState=function(s,o){var a=s.props,l=s.oldProps;o.isEnabled(this)&&a.fillPatternMapping&&a.fillPatternMapping!==l.fillPatternMapping&&this.getAttributeManager().invalidate("getFillPattern")},n.draw=function(s,o){if(o.isEnabled(this)){var a=this.props.fillPatternAtlas;this.setModuleParameters({fillPatternTexture:a||this.state.emptyTexture})}},n.finalizeState=function(){var s=this.state.emptyTexture;s?.delete()},n.getPatternFrame=function(s){var o=this.getCurrentLayer().props.fillPatternMapping,a=o&&o[s];return a?[a.x,a.y,a.width,a.height]:[0,0,0,0]},r}(Ha.LayerExtension);Gr.defaultProps=X_;Gr.extensionName="FillStyleExtension";var La=v(w());function en(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?en=function(r){return typeof r}:en=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},en(e)}function j_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function z_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&$i(e,t)}function $i(e,t){return $i=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},$i(e,t)}function K_(e){var t=q_();return function(){var n=tn(e),i;if(t){var s=tn(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Y_(this,i)}}function Y_(e,t){if(t&&(en(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $_(e)}function $_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function q_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function tn(e){return tn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},tn(e)}var Z_={clipBounds:[0,0,1,1],clipByInstance:void 0},Xa=`
|
|
1354
1357
|
uniform vec4 clip_bounds;
|
|
1355
1358
|
|
|
1356
1359
|
bool clip_isInBounds(vec2 position) {
|
|
1357
1360
|
return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];
|
|
1358
1361
|
}
|
|
1359
|
-
`,
|
|
1362
|
+
`,Q_={name:"clip-vs",vs:Xa},J_={"vs:#decl":`
|
|
1360
1363
|
out float clip_isVisible;
|
|
1361
1364
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1362
1365
|
clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
|
|
@@ -1364,7 +1367,7 @@ out float clip_isVisible;
|
|
|
1364
1367
|
in float clip_isVisible;
|
|
1365
1368
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1366
1369
|
if (clip_isVisible < 0.5) discard;
|
|
1367
|
-
`},
|
|
1370
|
+
`},G_={name:"clip-fs",fs:Xa},ed={"vs:#decl":`
|
|
1368
1371
|
out vec2 clip_commonPosition;
|
|
1369
1372
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1370
1373
|
clip_commonPosition = geometry.position.xy;
|
|
@@ -1372,7 +1375,7 @@ out vec2 clip_commonPosition;
|
|
|
1372
1375
|
in vec2 clip_commonPosition;
|
|
1373
1376
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1374
1377
|
if (!clip_isInBounds(clip_commonPosition)) discard;
|
|
1375
|
-
`},
|
|
1378
|
+
`},rn=function(e){z_(r,e);var t=K_(r);function r(){return j_(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){var s="instancePositions"in this.getAttributeManager().attributes;return this.props.clipByInstance!==void 0&&(s=Boolean(this.props.clipByInstance)),this.state.clipByInstance=s,s?{modules:[Q_],inject:J_}:{modules:[G_],inject:ed}},n.draw=function(s){var o=s.uniforms,a=this.props.clipBounds;if(this.state.clipByInstance)o.clip_bounds=a;else{var l=this.projectPosition([a[0],a[1],0]),f=this.projectPosition([a[2],a[3],0]);o.clip_bounds=[Math.min(l[0],f[0]),Math.min(l[1],f[1]),Math.max(l[0],f[0]),Math.max(l[1],f[1])]}},r}(La.LayerExtension);rn.defaultProps=Z_;rn.extensionName="ClipExtension";var al=v(w());var ja=v(w()),td=`
|
|
1376
1379
|
#ifdef NON_INSTANCED_MODEL
|
|
1377
1380
|
in float collisionPriorities;
|
|
1378
1381
|
#else
|
|
@@ -1421,7 +1424,7 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1421
1424
|
float W = 2.0 * floatN + 1.0;
|
|
1422
1425
|
return pow(accumulator / (W * W), 2.2);
|
|
1423
1426
|
}
|
|
1424
|
-
`,
|
|
1427
|
+
`,rd={"vs:#decl":`
|
|
1425
1428
|
float collision_fade = 1.0;
|
|
1426
1429
|
`,"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1427
1430
|
if (collision_sort) {
|
|
@@ -1444,18 +1447,18 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
|
|
|
1444
1447
|
}
|
|
1445
1448
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
1446
1449
|
color.a *= collision_fade;
|
|
1447
|
-
`},
|
|
1448
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
1449
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
1450
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
1451
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
1452
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
1450
|
+
`},nd=function(t,r){if(!t||!("dummyCollisionMap"in t))return{};var n=t.collisionFBO,i=t.drawToCollisionMap,s=t.dummyCollisionMap;return{collision_sort:Boolean(i),collision_texture:!i&&n?n.colorAttachments[0]:s}},za={name:"collision",dependencies:[ja.project],vs:td,inject:rd,getUniforms:nd};var sl=v(w());var $a=v(w());function nn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?nn=function(r){return typeof r}:nn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},nn(e)}function Ka(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Ya(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ka(Object(r),!0).forEach(function(n){id(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ka(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function id(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function od(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&qi(e,t)}function qi(e,t){return qi=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},qi(e,t)}function ad(e){var t=cd();return function(){var n=sn(e),i;if(t){var s=sn(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return ld(this,i)}}function ld(e,t){if(t&&(nn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fd(e)}function fd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sn(e){return sn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},sn(e)}var qa=function(e){od(r,e);var t=ad(r);function r(){return sd(this,r),t.apply(this,arguments)}var n=r.prototype;return n.renderCollisionMap=function(s,o){var a=this,l=1,f=[0,0,0,0];return C(this.device,{scissorTest:!0,scissor:[l,l,s.width-2*l,s.height-2*l],blend:!1,depthTest:!0,depthRange:[0,1]},function(){return a.render(Ya(Ya({},o),{},{clearColor:f,target:s,pass:"collision"}))})},n.getModuleParameters=function(){return{drawToCollisionMap:!0,picking:{isActive:1,isAttribute:!1},lightSources:{}}},r}($a._LayersPass);var Qi=v(w());var Ja=v(w());function on(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?on=function(r){return typeof r}:on=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},on(e)}function Za(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Qa(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Za(Object(r),!0).forEach(function(n){ud(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Za(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ud(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function an(e,t,r){return typeof Reflect<"u"&&Reflect.get?an=Reflect.get:an=function(i,s,o){var a=dd(i,s);if(a){var l=Object.getOwnPropertyDescriptor(a,s);return l.get?l.get.call(o):l.value}},an(e,t,r||e)}function dd(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=it(e),e!==null););return e}function hd(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Zi(e,t)}function Zi(e,t){return Zi=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Zi(e,t)}function pd(e){var t=bd();return function(){var n=it(e),i;if(t){var s=it(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return gd(this,i)}}function gd(e,t){if(t&&(on(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return md(e)}function md(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function it(e){return it=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},it(e)}var Ga=function(e){hd(r,e);var t=pd(r);function r(i,s){var o;_d(this,r),o=t.call(this,i,s),o.maskMap=void 0,o.fbo=void 0;var a=s.mapSize,l=a===void 0?2048:a;return o.maskMap=i.createTexture({format:"rgba8unorm",width:l,height:l,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),o.fbo=i.createFramebuffer({id:"maskmap",width:l,height:l,colorAttachments:[o.maskMap]}),o}var n=r.prototype;return n.render=function(s){var o=this,a=[!1,!1,!1,!1];a[s.channel]=!0;var l=[255,255,255,255];return C(this.device,{blend:!0,blendFunc:[0,1],blendEquation:32778,colorMask:a,depthTest:!1},function(){return an(it(r.prototype),"render",o).call(o,Qa(Qa({},s),{},{clearColor:l,target:o.fbo,pass:"mask"}))})},n.shouldDrawLayer=function(s){return s.props.operation.includes("mask")},n.delete=function(){this.fbo.delete(),this.maskMap.delete()},r}(Ja._LayersPass);var ln=v(w());function Td(e,t){return yd(e)||vd(e,t)||tl(e,t)||Ad()}function Ad(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1451
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vd(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,s=!1,o,a;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));i=!0);}catch(l){s=!0,a=l}finally{try{!i&&r.return!=null&&r.return()}finally{if(s)throw a}}return n}}function yd(e){if(Array.isArray(e))return e}function Rd(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=tl(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1452
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return s=f.done,f},e:function(f){o=!0,a=f},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function tl(e,t){if(e){if(typeof e=="string")return el(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return el(e,t)}}function el(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function st(e,t){var r=[1/0,1/0,-1/0,-1/0],n=Rd(e),i;try{for(n.s();!(i=n.n()).done;){var s=i.value,o=s.getBounds();if(o){var a=s.projectPosition(o[0],{viewport:t,autoOffset:!1}),l=s.projectPosition(o[1],{viewport:t,autoOffset:!1});r[0]=Math.min(r[0],a[0]),r[1]=Math.min(r[1],a[1]),r[2]=Math.max(r[2],l[0]),r[3]=Math.max(r[3],l[1])}}}catch(f){n.e(f)}finally{n.f()}return Number.isFinite(r[0])?r:null}var Ed=2048;function ot(e){var t=e.bounds,r=e.viewport,n=e.border,i=n===void 0?0:n,s=r.isGeospatial;if(t[2]<=t[0]||t[3]<=t[1])return null;var o=r.unprojectPosition([(t[0]+t[2])/2,(t[1]+t[3])/2,0]),a=e.width,l=e.height,f=e.zoom;if(f===void 0){a=a-i*2,l=l-i*2;var u=Math.min(a/(t[2]-t[0]),l/(t[3]-t[1]));f=Math.min(Math.log2(u),20)}else if(!a||!l){var _=Math.pow(2,f);a=Math.round(Math.abs(t[2]-t[0])*_),l=Math.round(Math.abs(t[3]-t[1])*_);var p=Ed-i*2;if(a>p||l>p){var g=p/Math.max(a,l);a=Math.round(a*g),l=Math.round(l*g),f+=Math.log2(g)}}return s?new ln.WebMercatorViewport({id:r.id,x:i,y:i,width:a,height:l,longitude:o[0],latitude:o[1],zoom:f,orthographic:!0}):new ln.OrthographicViewport({id:r.id,x:i,y:i,width:a,height:l,target:o,zoom:f,flipY:!1})}function xd(e,t){var r;if(t&&t.length===2){var n=Td(t,2),i=n[0],s=n[1],o=e.getBounds({z:i}),a=e.getBounds({z:s});r=[Math.min(o[0],a[0]),Math.min(o[1],a[1]),Math.max(o[2],a[2]),Math.max(o[3],a[3])]}else r=e.getBounds();var l=e.projectPosition(r.slice(0,2)),f=e.projectPosition(r.slice(2,4));return[l[0],l[1],f[0],f[1]]}function at(e,t,r){if(!e)return[0,0,1,1];var n=xd(t,r),i=Sd(n);return e[2]-e[0]<=i[2]-i[0]&&e[3]-e[1]<=i[3]-i[1]?e:[Math.max(e[0],i[0]),Math.max(e[1],i[1]),Math.min(e[2],i[2]),Math.min(e[3],i[3])]}function Sd(e){var t=e[2]-e[0],r=e[3]-e[1],n=(e[0]+e[2])/2,i=(e[1]+e[3])/2;return[n-t,i-r,n+t,i+r]}function Od(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=wd(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1453
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return s=f.done,f},e:function(f){o=!0,a=f},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function wd(e,t){if(e){if(typeof e=="string")return rl(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return rl(e,t)}}function rl(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Pd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var fn=function(){function e(){Pd(this,e),this.id="mask-effect",this.props=null,this.useInPicking=!0,this.order=0,this.dummyMaskMap=void 0,this.channels=[],this.masks=null,this.maskPass=void 0,this.maskMap=void 0,this.lastViewport=void 0}var t=e.prototype;return t.preRender=function(n,i){var s=i.layers,o=i.layerFilter,a=i.viewports,l=i.onViewportActive,f=i.views,u=i.isPicking,_=!1;if(this.dummyMaskMap||(this.dummyMaskMap=n.createTexture({width:1,height:1})),u)return{didRender:_};var p=s.filter(function(y){return y.props.visible&&y.props.operation.includes("mask")});if(p.length===0)return this.masks=null,this.channels.length=0,{didRender:_};this.masks={},this.maskPass||(this.maskPass=new Ga(n,{id:"default-mask"}),this.maskMap=this.maskPass.maskMap);var g=this._sortMaskChannels(p),b=a[0],A=!this.lastViewport||!this.lastViewport.equals(b);if(b.resolution!==void 0)return Qi.log.warn("MaskExtension is not supported in GlobeView")(),{didRender:_};for(var T in g){var R=this._renderChannel(g[T],{layerFilter:o,onViewportActive:l,views:f,viewport:b,viewportChanged:A});_||(_=R)}return{didRender:_}},t._renderChannel=function(n,i){var s=i.layerFilter,o=i.onViewportActive,a=i.views,l=i.viewport,f=i.viewportChanged,u=!1,_=this.channels[n.index];if(!_)return u;var p=n===_||n.layers.length!==_.layers.length||n.layers.some(function(R,y){return R!==_.layers[y]||R.props.transitions})||n.layerBounds.some(function(R,y){return R!==_.layerBounds[y]});if(n.bounds=_.bounds,n.maskBounds=_.maskBounds,this.channels[n.index]=n,p||f){this.lastViewport=l;var g=st(n.layers,l);if(n.bounds=g&&at(g,l),p||!rt(n.bounds,_.bounds)){var b=this.maskPass,A=this.maskMap,T=g&&ot({bounds:n.bounds,viewport:l,width:A.width,height:A.height,border:1});n.maskBounds=T?T.getBounds():[0,0,1,1],b.render({pass:"mask",channel:n.index,layers:n.layers,layerFilter:s,viewports:T?[T]:[],onViewportActive:o,views:a,moduleParameters:{devicePixelRatio:1}}),u=!0}}return this.masks[n.id]={index:n.index,bounds:n.maskBounds,coordinateOrigin:n.coordinateOrigin,coordinateSystem:n.coordinateSystem},u},t._sortMaskChannels=function(n){var i=this,s={},o=0,a=Od(n),l;try{var f=function(){var T=l.value,R=T.root.id,y=s[R];if(!y){if(++o>4)return Qi.log.warn("Too many mask layers. The max supported is 4")(),"continue";y={id:R,index:i.channels.findIndex(function(O){return O?.id===R}),layers:[],layerBounds:[],coordinateOrigin:T.root.props.coordinateOrigin,coordinateSystem:T.root.props.coordinateSystem},s[R]=y}y.layers.push(T),y.layerBounds.push(T.getBounds())};for(a.s();!(l=a.n()).done;)var u=f()}catch(A){a.e(A)}finally{a.f()}for(var _=0;_<4;_++){var p=this.channels[_];(!p||!(p.id in s))&&(this.channels[_]=null)}for(var g in s){var b=s[g];b.index<0&&(b.index=this.channels.findIndex(function(A){return!A}),this.channels[b.index]=b)}return s},t.getModuleParameters=function(){return{maskMap:this.masks?this.maskMap:this.dummyMaskMap,maskChannels:this.masks}},t.cleanup=function(){this.dummyMaskMap&&(this.dummyMaskMap.delete(),this.dummyMaskMap=void 0),this.maskPass&&(this.maskPass.delete(),this.maskPass=void 0,this.maskMap=void 0),this.lastViewport=void 0,this.masks=null,this.channels.length=0},e}();function Id(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=il(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1454
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return s=f.done,f},e:function(f){o=!0,a=f},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function Fd(e,t){return Cd(e)||Md(e,t)||il(e,t)||Nd()}function Nd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1455
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function il(e,t){if(e){if(typeof e=="string")return nl(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return nl(e,t)}}function nl(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Md(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,s=!1,o,a;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));i=!0);}catch(l){s=!0,a=l}finally{try{!i&&r.return!=null&&r.return()}finally{if(s)throw a}}return n}}function Cd(e){if(Array.isArray(e))return e}function Bd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Ji=2,ol=function(){function e(){Bd(this,e),this.id="collision-filter-effect",this.props=null,this.useInPicking=!0,this.order=1,this.channels={},this.collisionFilterPass=void 0,this.collisionFBOs={},this.dummyCollisionMap=void 0,this.lastViewport=void 0}var t=e.prototype;return t.preRender=function(n,i){var s,o=i.effects,a=i.layers,l=i.layerFilter,f=i.viewports,u=i.onViewportActive,_=i.views,p=i.isPicking,g=i.preRenderStats,b=g===void 0?{}:g;if(this.dummyCollisionMap||(this.dummyCollisionMap=n.createTexture({width:1,height:1})),!p){var A=a.filter(function(Ht){var Xe=Ht.props,Fl=Xe.visible,Nl=Xe.collisionEnabled;return Fl&&Nl});if(A.length===0){this.channels={};return}this.collisionFilterPass||(this.collisionFilterPass=new qa(n,{id:"default-collision-filter"}));var T=o?.filter(function(Ht){return Ht.constructor===fn}),R=(s=b["mask-effect"])===null||s===void 0?void 0:s.didRender,y=this._groupByCollisionGroup(n,A),O=f[0],W=!this.lastViewport||!this.lastViewport.equals(O)||R;for(var $ in y){var ne=this.collisionFBOs[$],L=y[$],ye=n.canvasContext.getPixelSize(),ie=Fd(ye,2),K=ie[0],Le=ie[1];ne.resize({width:K/Ji,height:Le/Ji}),this._render(L,{effects:T,layerFilter:l,onViewportActive:u,views:_,viewport:O,viewportChanged:W})}}},t._render=function(n,i){var s=i.effects,o=i.layerFilter,a=i.onViewportActive,l=i.views,f=i.viewport,u=i.viewportChanged,_=n.collisionGroup,p=this.channels[_];if(p){var g=u||n===p||!(0,sl._deepEqual)(p.layers,n.layers,1)||n.layerBounds.some(function(A,T){return!rt(A,p.layerBounds[T])})||n.allLayersLoaded!==p.allLayersLoaded||n.layers.some(function(A){return A.props.transitions});if(this.channels[_]=n,g){this.lastViewport=f;var b=this.collisionFBOs[_];this.collisionFilterPass.renderCollisionMap(b,{pass:"collision-filter",isPicking:!0,layers:n.layers,effects:s,layerFilter:o,viewports:f?[f]:[],onViewportActive:a,views:l,moduleParameters:{dummyCollisionMap:this.dummyCollisionMap,devicePixelRatio:b.device.canvasContext.getDevicePixelRatio()/Ji}})}}},t._groupByCollisionGroup=function(n,i){var s={},o=Id(i),a;try{for(o.s();!(a=o.n()).done;){var l=a.value,f=l.props.collisionGroup,u=s[f];u||(u={collisionGroup:f,layers:[],layerBounds:[],allLayersLoaded:!0},s[f]=u),u.layers.push(l),u.layerBounds.push(l.getBounds()),l.isLoaded||(u.allLayersLoaded=!1)}}catch(R){o.e(R)}finally{o.f()}for(var _=0,p=Object.keys(s);_<p.length;_++){var g=p[_];this.collisionFBOs[g]||this.createFBO(n,g),this.channels[g]||(this.channels[g]=s[g])}for(var b=0,A=Object.keys(this.collisionFBOs);b<A.length;b++){var T=A[b];s[T]||this.destroyFBO(T)}return s},t.getModuleParameters=function(n){var i=n.props.collisionGroup,s=this.collisionFBOs,o=this.dummyCollisionMap;return{collisionFBO:s[i],dummyCollisionMap:o}},t.cleanup=function(){this.dummyCollisionMap&&(this.dummyCollisionMap.delete(),this.dummyCollisionMap=void 0),this.channels={};for(var n=0,i=Object.keys(this.collisionFBOs);n<i.length;n++){var s=i[n];this.destroyFBO(s)}this.collisionFBOs={},this.lastViewport=void 0},t.createFBO=function(n,i){var s=n.gl.canvas,o=s.width,a=s.height,l=n.createTexture({format:"rgba8unorm",width:o,height:a,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),f=new ee(n,{format:"depth16unorm",width:o,height:a});this.collisionFBOs[i]=n.createFramebuffer({id:"collision-".concat(i),width:o,height:a,colorAttachments:[l],depthStencilAttachment:f})},t.destroyFBO=function(n){var i,s,o=this.collisionFBOs[n];(i=o.colorAttachments[0])===null||i===void 0||i.destroy(),(s=o.depthStencilAttachment)===null||s===void 0||s.destroy(),o.destroy(),delete this.collisionFBOs[n]},e}();function cn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?cn=function(r){return typeof r}:cn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},cn(e)}function Dd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function kd(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Gi(e,t)}function Gi(e,t){return Gi=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},Gi(e,t)}function Ud(e){var t=Hd();return function(){var n=un(e),i;if(t){var s=un(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Vd(this,i)}}function Vd(e,t){if(t&&(cn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wd(e)}function Wd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Hd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function un(e){return un=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},un(e)}var Ld={getCollisionPriority:{type:"accessor",value:0},collisionEnabled:!0,collisionGroup:{type:"string",value:"default"},collisionTestProps:{}},_n=function(e){kd(r,e);var t=Ud(r);function r(){return Dd(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){return{modules:[za]}},n.draw=function(s){var o=s.uniforms,a=s.context,l=s.moduleParameters,f=this.props.collisionEnabled,u=l.collisionFBO,_=l.drawToCollisionMap,p=f&&Boolean(u);o.collision_enabled=p,_&&(this.props=this.clone(this.props.collisionTestProps).props)},n.initializeState=function(s,o){var a;if(this.getAttributeManager()!==null){(a=this.context.deck)===null||a===void 0||a._addDefaultEffect(new ol);var l=this.getAttributeManager();l.add({collisionPriorities:{size:1,accessor:"getCollisionPriority",shaderAttributes:{collisionPriorities:{divisor:0},instanceCollisionPriorities:{divisor:1}}}})}},n.getNeedsPickingBuffer=function(){return this.props.collisionEnabled},r}(al.LayerExtension);_n.defaultProps=Ld;_n.extensionName="CollisionFilterExtension";var Me=v(w());var ll=v(w()),Xd=`
|
|
1453
1456
|
uniform vec4 mask_bounds;
|
|
1454
1457
|
uniform bool mask_maskByInstance;
|
|
1455
1458
|
vec2 mask_getCoords(vec4 position) {
|
|
1456
1459
|
return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
|
|
1457
1460
|
}
|
|
1458
|
-
`,
|
|
1461
|
+
`,jd=`
|
|
1459
1462
|
uniform sampler2D mask_texture;
|
|
1460
1463
|
uniform int mask_channel;
|
|
1461
1464
|
uniform bool mask_enabled;
|
|
@@ -1482,7 +1485,7 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
1482
1485
|
return maskValue < 0.5;
|
|
1483
1486
|
}
|
|
1484
1487
|
}
|
|
1485
|
-
`,
|
|
1488
|
+
`,zd={"vs:#decl":`
|
|
1486
1489
|
out vec2 mask_texCoords;
|
|
1487
1490
|
`,"vs:#main-end":`
|
|
1488
1491
|
vec4 mask_common_position;
|
|
@@ -1504,13 +1507,13 @@ in vec2 mask_texCoords;
|
|
|
1504
1507
|
|
|
1505
1508
|
if (!mask) discard;
|
|
1506
1509
|
}
|
|
1507
|
-
`},
|
|
1508
|
-
`),
|
|
1510
|
+
`},Kd=function(t){return t&&"maskMap"in t?{mask_texture:t.maskMap}:{}},fl={name:"mask",dependencies:[ll.project],vs:Xd,fs:jd,inject:zd,getUniforms:Kd};function dn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?dn=function(r){return typeof r}:dn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},dn(e)}function Yd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function $d(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&es(e,t)}function es(e,t){return es=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},es(e,t)}function qd(e){var t=Jd();return function(){var n=hn(e),i;if(t){var s=hn(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Zd(this,i)}}function Zd(e,t){if(t&&(dn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Qd(e)}function Qd(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Jd(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function hn(e){return hn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},hn(e)}var Gd={maskId:"",maskByInstance:void 0,maskInverted:!1},pn=function(e){$d(r,e);var t=qd(r);function r(){return Yd(this,r),t.apply(this,arguments)}var n=r.prototype;return n.initializeState=function(){var s;(s=this.context.deck)===null||s===void 0||s._addDefaultEffect(new fn)},n.getShaders=function(){var s="instancePositions"in this.getAttributeManager().attributes;return this.props.maskByInstance!==void 0&&(s=Boolean(this.props.maskByInstance)),this.state.maskByInstance=s,{modules:[fl]}},n.draw=function(s){var o=s.uniforms,a=s.context,l=s.moduleParameters;o.mask_maskByInstance=this.state.maskByInstance;var f=this.props,u=f.maskId,_=f.maskInverted,p=l.maskChannels,g=a.viewport;if(p&&p[u]){var b=p[u],A=b.index,T=b.bounds,R=b.coordinateOrigin,y=p[u].coordinateSystem;o.mask_enabled=!0,o.mask_channel=A,o.mask_inverted=_,y===Me.COORDINATE_SYSTEM.DEFAULT&&(y=g.isGeospatial?Me.COORDINATE_SYSTEM.LNGLAT:Me.COORDINATE_SYSTEM.CARTESIAN);var O={modelMatrix:null,fromCoordinateOrigin:R,fromCoordinateSystem:y},W=this.projectPosition([T[0],T[1],0],O),$=this.projectPosition([T[2],T[3],0],O);o.mask_bounds=[W[0],W[1],$[0],$[1]]}else u&&Me.log.warn("Could not find a mask layer with id: ".concat(u))(),o.mask_enabled=!1},r}(Me.LayerExtension);pn.defaultProps=Gd;pn.extensionName="MaskExtension";var Il=v(w());var Rn=v(w());var ul=v(w()),de={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},cl=Object.keys(de).map(function(e){return"const float TERRAIN_MODE_".concat(e," = ").concat(de[e],".0;")}).join(`
|
|
1511
|
+
`),gn={name:"terrain",dependencies:[ul.project],inject:{"vs:#decl":`
|
|
1509
1512
|
uniform float terrain_mode;
|
|
1510
1513
|
uniform sampler2D terrain_map;
|
|
1511
1514
|
uniform vec4 terrain_bounds;
|
|
1512
1515
|
out vec3 commonPos;
|
|
1513
|
-
`.concat(
|
|
1516
|
+
`.concat(cl,`
|
|
1514
1517
|
`),"vs:#main-start":`
|
|
1515
1518
|
if (terrain_mode == TERRAIN_MODE_SKIP) {
|
|
1516
1519
|
gl_Position = vec4(0.0);
|
|
@@ -1539,7 +1542,7 @@ uniform float terrain_mode;
|
|
|
1539
1542
|
uniform sampler2D terrain_map;
|
|
1540
1543
|
uniform vec4 terrain_bounds;
|
|
1541
1544
|
in vec3 commonPos;
|
|
1542
|
-
`.concat(
|
|
1545
|
+
`.concat(cl,`
|
|
1543
1546
|
`),"fs:#main-start":`
|
|
1544
1547
|
if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
1545
1548
|
fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
|
|
@@ -1557,9 +1560,9 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
1557
1560
|
}
|
|
1558
1561
|
return;
|
|
1559
1562
|
}
|
|
1560
|
-
`},getUniforms:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if("dummyHeightMap"in t){var
|
|
1561
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){r=r.call(e)},n:function(){var l=r.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw a}}}}function P_(e,t){if(e){if(typeof e=="string")return ks(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ks(e,t)}}function ks(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function F_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ws(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function I_(e,t,r){return t&&Ws(e.prototype,t),r&&Ws(e,r),e}var Hs=function(){function e(r){F_(this,e),this.isDirty=!0,this.targetLayer=void 0,this.renderViewport=null,this.bounds=null,this.fbo=void 0,this.pickingFbo=void 0,this.layers=[],this.tile=void 0,this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=r,this.tile=Xs(r)}var t=e.prototype;return t.shouldUpdate=function(i){var n=i.targetLayer,o=i.viewport,s=i.layers,a=i.layerNeedsRedraw;n&&(this.targetLayer=n);var f=o?this._updateViewport(o):!1,l=s?this._updateLayers(s):!1;if(a){var c=x_(this.layers),u;try{for(c.s();!(u=c.n()).done;){var _=u.value;if(a[_]){l=!0;break}}}catch(d){c.e(d)}finally{c.f()}}return l||f},t._updateLayers=function(i){var n=!1;if(i=this.tile?C_(this.tile,i):i,i.length!==this.layers.length)n=!0;else for(var o=0;o<i.length;o++){var s=i[o].id;if(s!==this.layers[o]){n=!0;break}}return n&&(this.layers=i.map(function(a){return a.id})),n},t._updateViewport=function(i){var n=this.targetLayer,o=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){o=!0,this.targetBounds=this.tile.boundingBox;var s=i.projectPosition(this.targetBounds[0]),a=i.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[s[0],s[1],a[0],a[1]]}}else this.targetBounds!==n.getBounds()&&(o=!0,this.targetBounds=n.getBounds(),this.targetBoundsCommon=De([n],i));if(!this.targetBoundsCommon)return!1;var f=Math.ceil(i.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{var l,c=(l=this.renderViewport)===null||l===void 0?void 0:l.zoom;o=o||f!==c;var u=Ue(this.targetBoundsCommon,i),_=this.bounds;o=o||!_||u.some(function(d,p){return d!==_[p]}),this.bounds=u}return o&&(this.renderViewport=we({bounds:this.bounds,zoom:f,viewport:i})),o},t.getRenderFramebuffer=function(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=dt(this.targetLayer.context.device,{id:this.id})),this.fbo)},t.getPickingFramebuffer=function(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=dt(this.targetLayer.context.device,{id:"".concat(this.id,"-picking")})),this.pickingFbo)},t.filterLayers=function(i){var n=this;return i.filter(function(o){var s=o.id;return n.layers.includes(s)})},t.delete=function(){var i=this.fbo,n=this.pickingFbo;i&&(i.colorAttachments[0].destroy(),i.destroy()),n&&(n.colorAttachments[0].destroy(),n.destroy())},I_(e,[{key:"id",get:function(){return this.targetLayer.id}},{key:"isActive",get:function(){return Boolean(this.targetLayer.getCurrentLayer())}}]),e}();function C_(e,t){return t.filter(function(r){var i=Xs(r);return i?M_(e.boundingBox,i.boundingBox):!0})}function Xs(e){for(;e;){var t=e.props.tile;if(t)return t;e=e.parent}return null}function M_(e,t){return e&&t?e[0][0]<t[1][0]&&t[0][0]<e[1][0]&&e[0][1]<t[1][1]&&t[0][1]<e[1][1]:!1}var js=T(S());function Pr(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Pr=function(r){return typeof r}:Pr=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Pr(e)}function Ls(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function xr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ls(Object(r),!0).forEach(function(i){N_(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ls(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function N_(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function B_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Pi(e,t)}function Pi(e,t){return Pi=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},Pi(e,t)}function w_(e){var t=k_();return function(){var i=Fr(e),n;if(t){var o=Fr(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return U_(this,n)}}function U_(e,t){if(t&&(Pr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return V_(e)}function V_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Fr(e){return Fr=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Fr(e)}var Ks=function(e){D_(r,e);var t=w_(r);function r(){return B_(this,r),t.apply(this,arguments)}var i=r.prototype;return i.getRenderableLayers=function(o,s){for(var a=s.layers,f=[],l=this._getDrawLayerParams(o,s,!0),c=0;c<a.length;c++){var u=a[c];!u.isComposite&&l[c].shouldDrawLayer&&f.push(u)}return f},i.renderHeightMap=function(o,s){var a=this,f=o.getRenderFramebuffer(),l=o.renderViewport;!f||!l||(f.resize(l),P(this.device,{clearColor:[0,0,0,0],blend:!0,blendFunc:[1,1],blendEquation:32776,depthTest:!1},function(){return a.render(xr(xr({},s),{},{target:f,pass:"terrain-height-map",layers:s.layers,viewports:[l],effects:[]}))}))},i.renderTerrainCover=function(o,s){var a=this,f=o.getRenderFramebuffer(),l=o.renderViewport;if(!(!f||!l)){var c=o.filterLayers(s.layers);f.resize(l),P(this.device,{clearColor:[0,0,0,0],depthTest:!1},function(){return a.render(xr(xr({},s),{},{target:f,pass:"terrain-cover-".concat(o.id),layers:c,effects:[],viewports:[l]}))})}},r}(js._LayersPass);var $s=T(S());function Ir(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ir=function(r){return typeof r}:Ir=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ir(e)}function zs(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,i)}return r}function Ys(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zs(Object(r),!0).forEach(function(i){W_(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zs(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function W_(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function H_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Cr(e,t,r){return typeof Reflect<"u"&&Reflect.get?Cr=Reflect.get:Cr=function(n,o,s){var a=X_(n,o);if(a){var f=Object.getOwnPropertyDescriptor(a,o);return f.get?f.get.call(s):f.value}},Cr(e,t,r||e)}function X_(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Ve(e),e!==null););return e}function L_(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Fi(e,t)}function Fi(e,t){return Fi=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},Fi(e,t)}function j_(e){var t=Y_();return function(){var i=Ve(e),n;if(t){var o=Ve(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return K_(this,n)}}function K_(e,t){if(t&&(Ir(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return z_(e)}function z_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Y_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ve(e){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Ve(e)}var qs=function(e){L_(r,e);var t=j_(r);function r(){var n;H_(this,r);for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];return n=t.call.apply(t,[this].concat(s)),n.drawParameters={},n}var i=r.prototype;return i.getRenderableLayers=function(o,s){var a=s.layers,f=[];this.drawParameters={},this._resetColorEncoder(s.pickZ);for(var l=this._getDrawLayerParams(o,s),c=0;c<a.length;c++){var u=a[c];!u.isComposite&&l[c].shouldDrawLayer&&(f.push(u),this.drawParameters[u.id]=l[c].layerParameters)}return f},i.renderTerrainCover=function(o,s){var a=this,f=o.getPickingFramebuffer(),l=o.renderViewport;if(!(!f||!l)){var c=o.filterLayers(s.layers),u=o.targetLayer;u.props.pickable&&c.unshift(u),f.resize(l),P(this.device,{depthTest:!1},function(){return a.render(Ys(Ys({},s),{},{pickingFBO:f,pass:"terrain-cover-picking-".concat(o.id),layers:c,effects:[],viewports:[l],cullRect:void 0,deviceRect:l,pickZ:!1}))})}},i.getLayerParameters=function(o,s,a){if(this.drawParameters[o.id])return this.drawParameters[o.id];var f=Cr(Ve(r.prototype),"getLayerParameters",this).call(this,o,s,a);return f.blend=!0,f},r}($s._PickLayersPass);function $_(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Zs=2048,Ii=function(){e.isSupported=function(i){return i.isTextureFormatRenderable("rgba32float")};function e(r){$_(this,e),this.renderViewport=null,this.bounds=null,this.fbo=void 0,this.device=void 0,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=r}var t=e.prototype;return t.getRenderFramebuffer=function(){return this.renderViewport?(this.fbo||(this.fbo=dt(this.device,{id:"height-map",float:!0})),this.fbo):null},t.shouldUpdate=function(i){var n=this,o=i.layers,s=i.viewport,a=o.length!==this.layers.length||o.some(function(d,p){return d!==n.layers[p]||d.props.transitions||d.getBounds()!==n.layersBounds[p]});a&&(this.layers=o,this.layersBounds=o.map(function(d){return d.getBounds()}),this.layersBoundsCommon=De(o,s));var f=!this.lastViewport||!s.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(a||f){var l=Ue(this.layersBoundsCommon,s);if(l[2]<=l[0]||l[3]<=l[1])return this.renderViewport=null,!1;this.bounds=l,this.lastViewport=s;var c=s.scale,u=(l[2]-l[0])*c,_=(l[3]-l[1])*c;return this.renderViewport=u>0||_>0?we({bounds:[s.center[0]-1,s.center[1]-1,s.center[0]+1,s.center[1]+1],zoom:s.zoom,width:Math.min(u,Zs),height:Math.min(_,Zs),viewport:s}):null,!0}return!1},t.delete=function(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())},e}();function q_(e,t){return J_(e)||Q_(e,t)||Gs(e,t)||Z_()}function Z_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1562
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
1563
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
1563
|
+
`},getUniforms:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if("dummyHeightMap"in t){var n=t.drawToTerrainHeightMap,i=t.heightMap,s=t.heightMapBounds,o=t.dummyHeightMap,a=t.terrainCover,l=t.useTerrainHeightMap,f=t.terrainSkipRender,u=r.project_uCommonOrigin,_=f?de.SKIP:de.NONE,p=o,g=null;if(n)_=de.WRITE_HEIGHT_MAP,g=s;else if(l&&i)_=de.USE_HEIGHT_MAP,p=i,g=s;else if(a){var b,A=(b=t.picking)===null||b===void 0?void 0:b.isActive;p=A?a.getPickingFramebuffer():a.getRenderFramebuffer(),A&&(_=de.SKIP),p?(_=_===de.SKIP?de.USE_COVER_ONLY:de.USE_COVER,g=a.bounds):p=o}return{terrain_mode:_,terrain_map:p,terrain_bounds:g?[g[0]-u[0],g[1]-u[1],g[2]-g[0],g[3]-g[1]]:[0,0,0,0]}}return null}};function _l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function dl(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_l(Object(r),!0).forEach(function(n){eh(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_l(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function eh(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Vt(e,t){return e.createFramebuffer({id:t.id,colorAttachments:[e.createTexture(dl(dl({},t.float&&{format:e.info.type==="webgl2"?"rgba32float":"rgba8unorm",type:5126}),{},{mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}))]})}function th(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=rh(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1564
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return s=f.done,f},e:function(f){o=!0,a=f},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function rh(e,t){if(e){if(typeof e=="string")return hl(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return hl(e,t)}}function hl(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function nh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pl(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ih(e,t,r){return t&&pl(e.prototype,t),r&&pl(e,r),e}var gl=function(){function e(r){nh(this,e),this.isDirty=!0,this.targetLayer=void 0,this.renderViewport=null,this.bounds=null,this.fbo=void 0,this.pickingFbo=void 0,this.layers=[],this.tile=void 0,this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=r,this.tile=ml(r)}var t=e.prototype;return t.shouldUpdate=function(n){var i=n.targetLayer,s=n.viewport,o=n.layers,a=n.layerNeedsRedraw;i&&(this.targetLayer=i);var l=s?this._updateViewport(s):!1,f=o?this._updateLayers(o):!1;if(a){var u=th(this.layers),_;try{for(u.s();!(_=u.n()).done;){var p=_.value;if(a[p]){f=!0;break}}}catch(g){u.e(g)}finally{u.f()}}return f||l},t._updateLayers=function(n){var i=!1;if(n=this.tile?sh(this.tile,n):n,n.length!==this.layers.length)i=!0;else for(var s=0;s<n.length;s++){var o=n[s].id;if(o!==this.layers[s]){i=!0;break}}return i&&(this.layers=n.map(function(a){return a.id})),i},t._updateViewport=function(n){var i=this.targetLayer,s=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){s=!0,this.targetBounds=this.tile.boundingBox;var o=n.projectPosition(this.targetBounds[0]),a=n.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[o[0],o[1],a[0],a[1]]}}else this.targetBounds!==i.getBounds()&&(s=!0,this.targetBounds=i.getBounds(),this.targetBoundsCommon=st([i],n));if(!this.targetBoundsCommon)return!1;var l=Math.ceil(n.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{var f,u=(f=this.renderViewport)===null||f===void 0?void 0:f.zoom;s=s||l!==u;var _=at(this.targetBoundsCommon,n),p=this.bounds;s=s||!p||_.some(function(g,b){return g!==p[b]}),this.bounds=_}return s&&(this.renderViewport=ot({bounds:this.bounds,zoom:l,viewport:n})),s},t.getRenderFramebuffer=function(){return!this.renderViewport||this.layers.length===0?null:(this.fbo||(this.fbo=Vt(this.targetLayer.context.device,{id:this.id})),this.fbo)},t.getPickingFramebuffer=function(){return!this.renderViewport||this.layers.length===0&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=Vt(this.targetLayer.context.device,{id:"".concat(this.id,"-picking")})),this.pickingFbo)},t.filterLayers=function(n){var i=this;return n.filter(function(s){var o=s.id;return i.layers.includes(o)})},t.delete=function(){var n=this.fbo,i=this.pickingFbo;n&&(n.colorAttachments[0].destroy(),n.destroy()),i&&(i.colorAttachments[0].destroy(),i.destroy())},ih(e,[{key:"id",get:function(){return this.targetLayer.id}},{key:"isActive",get:function(){return Boolean(this.targetLayer.getCurrentLayer())}}]),e}();function sh(e,t){return t.filter(function(r){var n=ml(r);return n?oh(e.boundingBox,n.boundingBox):!0})}function ml(e){for(;e;){var t=e.props.tile;if(t)return t;e=e.parent}return null}function oh(e,t){return e&&t?e[0][0]<t[1][0]&&t[0][0]<e[1][0]&&e[0][1]<t[1][1]&&t[0][1]<e[1][1]:!1}var Tl=v(w());function bn(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?bn=function(r){return typeof r}:bn=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},bn(e)}function bl(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function mn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bl(Object(r),!0).forEach(function(n){ah(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bl(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ah(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function lh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function fh(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ts(e,t)}function ts(e,t){return ts=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},ts(e,t)}function ch(e){var t=dh();return function(){var n=Tn(e),i;if(t){var s=Tn(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return uh(this,i)}}function uh(e,t){if(t&&(bn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _h(e)}function _h(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function dh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Tn(e){return Tn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},Tn(e)}var Al=function(e){fh(r,e);var t=ch(r);function r(){return lh(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getRenderableLayers=function(s,o){for(var a=o.layers,l=[],f=this._getDrawLayerParams(s,o,!0),u=0;u<a.length;u++){var _=a[u];!_.isComposite&&f[u].shouldDrawLayer&&l.push(_)}return l},n.renderHeightMap=function(s,o){var a=this,l=s.getRenderFramebuffer(),f=s.renderViewport;!l||!f||(l.resize(f),C(this.device,{clearColor:[0,0,0,0],blend:!0,blendFunc:[1,1],blendEquation:32776,depthTest:!1},function(){return a.render(mn(mn({},o),{},{target:l,pass:"terrain-height-map",layers:o.layers,viewports:[f],effects:[]}))}))},n.renderTerrainCover=function(s,o){var a=this,l=s.getRenderFramebuffer(),f=s.renderViewport;if(!(!l||!f)){var u=s.filterLayers(o.layers);l.resize(f),C(this.device,{clearColor:[0,0,0,0],depthTest:!1},function(){return a.render(mn(mn({},o),{},{target:l,pass:"terrain-cover-".concat(s.id),layers:u,effects:[],viewports:[f]}))})}},r}(Tl._LayersPass);var Rl=v(w());function An(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?An=function(r){return typeof r}:An=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},An(e)}function vl(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function yl(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?vl(Object(r),!0).forEach(function(n){hh(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vl(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function hh(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ph(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vn(e,t,r){return typeof Reflect<"u"&&Reflect.get?vn=Reflect.get:vn=function(i,s,o){var a=gh(i,s);if(a){var l=Object.getOwnPropertyDescriptor(a,s);return l.get?l.get.call(o):l.value}},vn(e,t,r||e)}function gh(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=lt(e),e!==null););return e}function mh(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&rs(e,t)}function rs(e,t){return rs=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},rs(e,t)}function bh(e){var t=vh();return function(){var n=lt(e),i;if(t){var s=lt(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Th(this,i)}}function Th(e,t){if(t&&(An(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ah(e)}function Ah(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function lt(e){return lt=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},lt(e)}var El=function(e){mh(r,e);var t=bh(r);function r(){var i;ph(this,r);for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return i=t.call.apply(t,[this].concat(o)),i.drawParameters={},i}var n=r.prototype;return n.getRenderableLayers=function(s,o){var a=o.layers,l=[];this.drawParameters={},this._resetColorEncoder(o.pickZ);for(var f=this._getDrawLayerParams(s,o),u=0;u<a.length;u++){var _=a[u];!_.isComposite&&f[u].shouldDrawLayer&&(l.push(_),this.drawParameters[_.id]=f[u].layerParameters)}return l},n.renderTerrainCover=function(s,o){var a=this,l=s.getPickingFramebuffer(),f=s.renderViewport;if(!(!l||!f)){var u=s.filterLayers(o.layers),_=s.targetLayer;_.props.pickable&&u.unshift(_),l.resize(f),C(this.device,{depthTest:!1},function(){return a.render(yl(yl({},o),{},{pickingFBO:l,pass:"terrain-cover-picking-".concat(s.id),layers:u,effects:[],viewports:[f],cullRect:void 0,deviceRect:f,pickZ:!1}))})}},n.getLayerParameters=function(s,o,a){if(this.drawParameters[s.id])return this.drawParameters[s.id];var l=vn(lt(r.prototype),"getLayerParameters",this).call(this,s,o,a);return l.blend=!0,l},r}(Rl._PickLayersPass);function yh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var xl=2048,ns=function(){e.isSupported=function(n){return n.isTextureFormatRenderable("rgba32float")};function e(r){yh(this,e),this.renderViewport=null,this.bounds=null,this.fbo=void 0,this.device=void 0,this.layers=[],this.layersBounds=[],this.layersBoundsCommon=null,this.lastViewport=null,this.device=r}var t=e.prototype;return t.getRenderFramebuffer=function(){return this.renderViewport?(this.fbo||(this.fbo=Vt(this.device,{id:"height-map",float:!0})),this.fbo):null},t.shouldUpdate=function(n){var i=this,s=n.layers,o=n.viewport,a=s.length!==this.layers.length||s.some(function(g,b){return g!==i.layers[b]||g.props.transitions||g.getBounds()!==i.layersBounds[b]});a&&(this.layers=s,this.layersBounds=s.map(function(g){return g.getBounds()}),this.layersBoundsCommon=st(s,o));var l=!this.lastViewport||!o.equals(this.lastViewport);if(!this.layersBoundsCommon)this.renderViewport=null;else if(a||l){var f=at(this.layersBoundsCommon,o);if(f[2]<=f[0]||f[3]<=f[1])return this.renderViewport=null,!1;this.bounds=f,this.lastViewport=o;var u=o.scale,_=(f[2]-f[0])*u,p=(f[3]-f[1])*u;return this.renderViewport=_>0||p>0?ot({bounds:[o.center[0]-1,o.center[1]-1,o.center[0]+1,o.center[1]+1],zoom:o.zoom,width:Math.min(_,xl),height:Math.min(p,xl),viewport:o}):null,!0}return!1},t.delete=function(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())},e}();function Rh(e,t){return Sh(e)||xh(e,t)||wl(e,t)||Eh()}function Eh(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1565
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xh(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,s=!1,o,a;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));i=!0);}catch(l){s=!0,a=l}finally{try{!i&&r.return!=null&&r.return()}finally{if(s)throw a}}return n}}function Sh(e){if(Array.isArray(e))return e}function Sl(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function yn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Sl(Object(r),!0).forEach(function(n){Oh(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Sl(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Oh(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ft(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=wl(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1566
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return s=f.done,f},e:function(f){o=!0,a=f},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function wl(e,t){if(e){if(typeof e=="string")return Ol(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ol(e,t)}}function Ol(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function wh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var Pl=function(){function e(){wh(this,e),this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.dummyHeightMap=void 0,this.heightMap=void 0,this.terrainPass=void 0,this.terrainPickingPass=void 0,this.terrainCovers=new Map}var t=e.prototype;return t.initialize=function(n){this.dummyHeightMap=n.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new Al(n,{id:"terrain"}),this.terrainPickingPass=new El(n,{id:"terrain-picking"}),ns.isSupported(n)?this.heightMap=new ns(n):Rn.log.warn("Terrain offset mode is not supported by this browser")(),(0,Rn.getShaderAssembler)().addDefaultModule(gn)},t.preRender=function(n,i){if(!this.dummyHeightMap){this.initialize(n);var s=ft(i.layers),o;try{for(s.s();!(o=s.n()).done;){var a=o.value;a.props.operation.includes("terrain")&&a.setChangeFlags({extensionsChanged:!0})}}catch(T){s.e(T)}finally{s.f()}}if(i.pickZ){this.isDrapingEnabled=!1;return}var l=i.viewports,f=i.isPicking,u=f===void 0?!1:f;this.isPicking=u,this.isDrapingEnabled=!0;var _=l[0],p=(u?this.terrainPickingPass:this.terrainPass).getRenderableLayers(_,i),g=p.filter(function(T){return T.props.operation.includes("terrain")});if(g.length!==0){if(!u){var b=p.filter(function(T){return T.state.terrainDrawMode==="offset"});b.length>0&&this._updateHeightMap(g,_,i)}var A=p.filter(function(T){return T.state.terrainDrawMode==="drape"});this._updateTerrainCovers(g,A,_,i)}},t.getModuleParameters=function(n){var i,s,o=n.state.terrainDrawMode;return{heightMap:(i=this.heightMap)===null||i===void 0?void 0:i.getRenderFramebuffer(),heightMapBounds:(s=this.heightMap)===null||s===void 0?void 0:s.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(n.id):null,useTerrainHeightMap:o==="offset",terrainSkipRender:o==="drape"||!n.props.operation.includes("draw")}},t.cleanup=function(){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);var n=ft(this.terrainCovers.values()),i;try{for(n.s();!(i=n.n()).done;){var s=i.value;s.delete()}}catch(o){n.e(o)}finally{n.f()}this.terrainCovers.clear()},t._updateHeightMap=function(n,i,s){if(this.heightMap){var o=this.heightMap.shouldUpdate({layers:n,viewport:i});o&&this.terrainPass.renderHeightMap(this.heightMap,yn(yn({},s),{},{layers:n,moduleParameters:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,devicePixelRatio:1,drawToTerrainHeightMap:!0}}))}},t._updateTerrainCovers=function(n,i,s,o){var a={},l=ft(i),f;try{for(l.s();!(f=l.n()).done;){var u=f.value;u.state.terrainCoverNeedsRedraw&&(a[u.id]=!0,u.state.terrainCoverNeedsRedraw=!1)}}catch(R){l.e(R)}finally{l.f()}var _=ft(this.terrainCovers.values()),p;try{for(_.s();!(p=_.n()).done;){var g=p.value;g.isDirty=g.isDirty||g.shouldUpdate({layerNeedsRedraw:a})}}catch(R){_.e(R)}finally{_.f()}var b=ft(n),A;try{for(b.s();!(A=b.n()).done;){var T=A.value;this._updateTerrainCover(T,i,s,o)}}catch(R){b.e(R)}finally{b.f()}this.isPicking||this._pruneTerrainCovers()},t._updateTerrainCover=function(n,i,s,o){var a=this.isPicking?this.terrainPickingPass:this.terrainPass,l=this.terrainCovers.get(n.id);l||(l=new gl(n),this.terrainCovers.set(n.id,l));try{var f=l.shouldUpdate({targetLayer:n,viewport:s,layers:i});(this.isPicking||l.isDirty||f)&&(a.renderTerrainCover(l,yn(yn({},o),{},{layers:i,moduleParameters:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1,devicePixelRatio:1}})),l.isDirty=!1)}catch(u){n.raiseError(u,"Error rendering terrain cover ".concat(l.id))}},t._pruneTerrainCovers=function(){var n=[],i=ft(this.terrainCovers),s;try{for(i.s();!(s=i.n()).done;){var o=Rh(s.value,2),a=o[0],l=o[1];l.isActive||n.push(a)}}catch(p){i.e(p)}finally{i.f()}for(var f=0,u=n;f<u.length;f++){var _=u[f];this.terrainCovers.delete(_)}},e}();function En(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?En=function(r){return typeof r}:En=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},En(e)}function Ph(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ih(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&is(e,t)}function is(e,t){return is=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},is(e,t)}function Fh(e){var t=Ch();return function(){var n=xn(e),i;if(t){var s=xn(this).constructor;i=Reflect.construct(n,arguments,s)}else i=n.apply(this,arguments);return Nh(this,i)}}function Nh(e,t){if(t&&(En(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mh(e)}function Mh(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ch(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function xn(e){return xn=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},xn(e)}var Bh={terrainDrawMode:void 0},Sn=function(e){Ih(r,e);var t=Fh(r);function r(){return Ph(this,r),t.apply(this,arguments)}var n=r.prototype;return n.getShaders=function(){return{modules:[gn]}},n.initializeState=function(){var s;(s=this.context.deck)===null||s===void 0||s._addDefaultEffect(new Pl)},n.updateState=function(s){var o=s.props,a=s.oldProps;if(!(this.state.terrainDrawMode&&o.terrainDrawMode===a.terrainDrawMode&&o.extruded===a.extruded)){var l=o.terrainDrawMode;if(!l){var f,u=this.props.extruded,_=(f=this.getAttributeManager())===null||f===void 0?void 0:f.attributes,p=_&&"instancePositions"in _;l=u||p?"offset":"drape"}this.setState({terrainDrawMode:l})}},n.onNeedsRedraw=function(){var s=this.state;s.terrainDrawMode==="drape"&&(s.terrainCoverNeedsRedraw=!0)},r}(Il.LayerExtension);Sn.defaultProps=Bh;Sn.extensionName="TerrainExtension";return Ul(Wt);})();
|
|
1564
1567
|
return __exports__;
|
|
1565
1568
|
});
|