@luma.gl/webgl 9.0.0-beta.6 → 9.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
  2. package/dist/adapter/converters/device-parameters.js +81 -84
  3. package/dist/adapter/converters/sampler-parameters.js +17 -17
  4. package/dist/adapter/converters/shader-formats.js +12 -12
  5. package/dist/adapter/converters/texture-formats.d.ts +10 -8
  6. package/dist/adapter/converters/texture-formats.d.ts.map +1 -1
  7. package/dist/adapter/converters/texture-formats.js +175 -168
  8. package/dist/adapter/converters/vertex-formats.js +20 -20
  9. package/dist/adapter/device-helpers/webgl-device-features.d.ts +2 -1
  10. package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
  11. package/dist/adapter/device-helpers/webgl-device-features.js +14 -2
  12. package/dist/adapter/device-helpers/webgl-device-info.js +5 -5
  13. package/dist/adapter/device-helpers/webgl-device-limits.js +10 -10
  14. package/dist/adapter/helpers/decode-webgl-types.js +45 -45
  15. package/dist/adapter/helpers/get-shader-layout.js +29 -29
  16. package/dist/adapter/helpers/set-uniform.js +40 -40
  17. package/dist/adapter/helpers/webgl-topology-utils.js +38 -38
  18. package/dist/adapter/objects/webgl-renderbuffer.js +6 -6
  19. package/dist/adapter/objects/webgl-resource.js +1 -2
  20. package/dist/adapter/resources/webgl-buffer.js +14 -14
  21. package/dist/adapter/resources/webgl-command-buffer.js +25 -25
  22. package/dist/adapter/resources/webgl-external-texture.js +3 -3
  23. package/dist/adapter/resources/webgl-framebuffer.d.ts +2 -4
  24. package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
  25. package/dist/adapter/resources/webgl-framebuffer.js +41 -36
  26. package/dist/adapter/resources/webgl-query-set.js +6 -6
  27. package/dist/adapter/resources/webgl-render-pass.js +5 -5
  28. package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
  29. package/dist/adapter/resources/webgl-render-pipeline.js +19 -13
  30. package/dist/adapter/resources/webgl-sampler.js +2 -2
  31. package/dist/adapter/resources/webgl-shader.js +4 -4
  32. package/dist/adapter/resources/webgl-texture.d.ts +2 -1
  33. package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
  34. package/dist/adapter/resources/webgl-texture.js +29 -27
  35. package/dist/adapter/resources/webgl-transform-feedback.js +8 -8
  36. package/dist/adapter/resources/webgl-vertex-array.d.ts +1 -1
  37. package/dist/adapter/resources/webgl-vertex-array.js +5 -5
  38. package/dist/adapter/webgl-device.d.ts +6 -3
  39. package/dist/adapter/webgl-device.d.ts.map +1 -1
  40. package/dist/adapter/webgl-device.js +22 -17
  41. package/dist/classic/accessor.js +4 -4
  42. package/dist/classic/clear.js +2 -2
  43. package/dist/classic/copy-and-blit.js +15 -16
  44. package/dist/classic/format-utils.d.ts +2 -2
  45. package/dist/classic/format-utils.js +14 -14
  46. package/dist/classic/typed-array-utils.js +18 -18
  47. package/dist/context/parameters/unified-parameter-api.d.ts +3 -4
  48. package/dist/context/parameters/unified-parameter-api.d.ts.map +1 -1
  49. package/dist/context/parameters/unified-parameter-api.js +4 -9
  50. package/dist/context/parameters/webgl-parameter-tables.d.ts +2 -13
  51. package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
  52. package/dist/context/parameters/webgl-parameter-tables.js +292 -298
  53. package/dist/context/state-tracker/with-parameters.d.ts +1 -2
  54. package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
  55. package/dist/context/state-tracker/with-parameters.js +2 -5
  56. package/dist/dist.dev.js +877 -840
  57. package/dist/index.cjs +1253 -1188
  58. package/dist/index.cjs.map +4 -4
  59. package/dist/index.d.ts +2 -2
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +1 -1
  62. package/dist.min.js +6 -6
  63. package/package.json +4 -4
  64. package/src/adapter/converters/device-parameters.ts +9 -11
  65. package/src/adapter/converters/texture-formats.ts +64 -61
  66. package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
  67. package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
  68. package/src/adapter/objects/webgl-resource.ts +1 -1
  69. package/src/adapter/resources/webgl-external-texture.ts +3 -3
  70. package/src/adapter/resources/webgl-framebuffer.ts +29 -26
  71. package/src/adapter/resources/webgl-render-pass.ts +3 -3
  72. package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
  73. package/src/adapter/resources/webgl-texture.ts +7 -3
  74. package/src/adapter/webgl-device.ts +24 -19
  75. package/src/classic/clear.ts +2 -2
  76. package/src/context/parameters/unified-parameter-api.ts +4 -16
  77. package/src/context/state-tracker/with-parameters.ts +2 -7
  78. package/src/index.ts +4 -4
  79. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  80. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  81. package/dist/adapter/device-helpers/device-features.js +0 -65
  82. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  83. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  84. package/dist/adapter/device-helpers/device-limits.js +0 -92
  85. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  86. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  87. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  88. package/dist/context/context/context-data.d.ts +0 -14
  89. package/dist/context/context/context-data.d.ts.map +0 -1
  90. package/dist/context/context/context-data.js +0 -33
  91. package/dist/context/context/create-browser-context.d.ts +0 -35
  92. package/dist/context/context/create-browser-context.d.ts.map +0 -1
  93. package/dist/context/context/create-browser-context.js +0 -66
package/dist.min.js CHANGED
@@ -4,16 +4,16 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- var __exports__=(()=>{var ci=Object.create;var st=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var hi=(r,e,t)=>e in r?st(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var pi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),gi=(r,e)=>{for(var t in e)st(r,t,{get:e[t],enumerable:!0})},Wr=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fi(e))!mi.call(r,i)&&i!==t&&st(r,i,{get:()=>e[i],enumerable:!(n=li(e,i))||n.enumerable});return r};var y=(r,e,t)=>(t=r!=null?ci(di(r)):{},Wr(e||!r||!r.__esModule?st(t,"default",{value:r,enumerable:!0}):t,r)),Ei=r=>Wr(st({},"__esModule",{value:!0}),r);var E=(r,e,t)=>(hi(r,typeof e!="symbol"?e+"":e,t),t);var S=pi((Fc,dn)=>{dn.exports=globalThis.luma});var Ts={};gi(Ts,{Accessor:()=>ue,WEBGLBuffer:()=>H,WEBGLCommandEncoder:()=>rt,WEBGLFramebuffer:()=>ee,WEBGLRenderPass:()=>Je,WEBGLRenderPipeline:()=>tt,WEBGLRenderbuffer:()=>Ee,WEBGLResource:()=>Ce,WEBGLSampler:()=>le,WEBGLShader:()=>Ze,WEBGLTexture:()=>U,WEBGLTransformFeedback:()=>it,WEBGLVertexArray:()=>be,WebGLCanvasContext:()=>qe,WebGLDevice:()=>K,WebGLResource:()=>Ce,_TEXTURE_FORMATS:()=>Se,convertGLToTextureFormat:()=>xe,getGLParameters:()=>Xe,getShaderLayout:()=>zt,popContextState:()=>Z,pushContextState:()=>re,resetGLParameters:()=>bn,setDeviceParameters:()=>Kt,setGLParameters:()=>X,trackContextState:()=>pt,withDeviceParameters:()=>wn,withGLParameters:()=>Y});function at(r){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 e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,t=r||e;return!!(t&&t.indexOf("Electron")>=0)}function v(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||at()}var bi=globalThis.self||globalThis.window||globalThis.global,Pe=globalThis.window||globalThis.self||globalThis.global,_i=globalThis.document||{},Te=globalThis.process||{},Ti=globalThis.console,Hr=globalThis.navigator||{};var Ct=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Cs=v();var qt=globalThis;function Gt(r){if(!r&&!v())return"Node";if(at(r))return"Electron";let e=r||Hr.userAgent||"";if(e.indexOf("Edge")>-1)return"Edge";let t=e.indexOf("MSIE ")!==-1,n=e.indexOf("Trident/")!==-1;return t||n?"IE":qt.chrome?"Chrome":qt.safari?"Safari":qt.mozInnerScreenX?"Firefox":"Unknown"}function Li(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var Pt=class{constructor(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Li(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function kr(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Vr(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}function Ft(r,e,t){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,i=r.src.replace(/\(/g,"%28").replace(/\)/g,"%29");r.width>n&&(t=Math.min(t,n/r.width));let s=r.width*t,a=r.height*t,u=["font-size:1px;",`padding:${Math.floor(a/2)}px ${Math.floor(s/2)}px;`,`line-height:${a}px;`,`background:url(${i});`,`background-size:${s}px ${a}px;`,"color:transparent;"].join("");return[`${e} %c+`,u]}var Bt;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Bt||(Bt={}));var Ri=10;function Xr(r){return typeof r!="string"?r:(r=r.toUpperCase(),Bt[r]||Bt.WHITE)}function Kr(r,e,t){return!v&&typeof r=="string"&&(e&&(r=`\x1B[${Xr(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Xr(t)+Ri}m${r}\x1B[49m`)),r}function Yr(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),i=r;for(let s of n){let a=i[s];typeof a=="function"&&(e.find(u=>s===u)||(i[s]=a.bind(r)))}}function Fe(r,e){if(!r)throw new Error(e||"Assertion failed")}function Le(){let r;if(v()&&Pe.performance){var e,t;r=Pe===null||Pe===void 0||(e=Pe.performance)===null||e===void 0||(t=e.now)===null||t===void 0?void 0:t.call(e)}else if("hrtime"in Te){var n;let i=Te===null||Te===void 0||(n=Te.hrtime)===null||n===void 0?void 0:n.call(Te);r=i[0]*1e3+i[1]/1e6}else r=Date.now();return r}var Be={debug:v()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ai={enabled:!0,level:0};function q(){}var $r={},zr={once:!0},me=class{constructor(){let{id:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=Ct,this._startTs=Le(),this._deltaTs=Le(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Pt(`__probe-${this.id}__`,Ai),this.timeStamp(`${this.id} started`),Yr(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Le()-this._startTs).toPrecision(10))}getDelta(){return Number((Le()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){Fe(e,t)}warn(e){return this._getLogFunction(0,e,Be.warn,arguments,zr)}error(e){return this._getLogFunction(0,e,Be.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,Be.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Be.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Be.debug||Be.info,arguments,zr)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||q,n&&[n],{tag:Ci(t)}):q}image(e){let{logLevel:t,priority:n,image:i,message:s="",scale:a=1}=e;return this._shouldLog(t||n)?v()?yi({image:i,message:s,scale:a}):xi({image:i,message:s,scale:a}):q}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||q)}group(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},i=jr({logLevel:e,message:t,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||q)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Qr(e)}_getLogFunction(e,t,n,i,s){if(this._shouldLog(e)){s=jr({logLevel:e,message:t,args:i,opts:s}),n=n||s.method,Fe(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=Le();let a=s.tag||s.message;if(s.once&&a)if(!$r[a])$r[a]=Le();else return q;return t=Si(this.id,s.message,s),n.bind(console,t,...s.args)}return q}};me.VERSION=Ct;function Qr(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return Fe(Number.isFinite(e)&&e>=0),e}function jr(r){let{logLevel:e,message:t}=r;r.logLevel=Qr(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let i=typeof r.message;return Fe(i==="string"||i==="object"),Object.assign(r,{args:n},r.opts)}function Si(r,e,t){if(typeof e=="string"){let n=t.time?Vr(kr(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=Kr(e,t.color,t.background)}return e}function xi(r){let{image:e,message:t="",scale:n=1}=r;return console.warn("removed"),q}function yi(r){let{image:e,message:t="",scale:n=1}=r;if(typeof e=="string"){let s=new Image;return s.onload=()=>{let a=Ft(s,t,n);console.log(...a)},s.src=e,q}let i=e.nodeName||"";if(i.toLowerCase()==="img")return console.log(...Ft(e,t,n)),q;if(i.toLowerCase()==="canvas"){let s=new Image;return s.onload=()=>console.log(...Ft(s,t,n)),s.src=e.toDataURL(),q}return q}function Ci(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var ia=new me({id:"@probe.gl/log"});var m=new me({id:"luma.gl"});function ut(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var Re=class{constructor(e,t){this.name=void 0,this.type=void 0,this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=ut(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ut()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ie=class{constructor(e){this.id=void 0,this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"count";return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,i=this.stats[t];return i||(e instanceof Re?i=e:i=new Re(t,n),this.stats[t]=i),i}};var Zt=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ie({id:e})),this.stats.get(e)}},It=new Zt;function Gi(){let r="9.0.0-beta.5",e="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==r)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${r}`);return globalThis.luma||(v()&&m.log(1,`${r} - ${e}`)(),globalThis.luma=globalThis.luma||{VERSION:r,version:r,log:m,stats:It}),r}var qr=Gi();function Pi(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)?r:null}function Zr(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number"?r:null:Pi(r)}var Jt={};function te(r="id"){Jt[r]=Jt[r]||1;let e=Jt[r]++;return`${r}-${e}`}function Ne(r){let e=!0;for(let t in r){e=!1;break}return e}var _=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=Fi(t,n);let i=this.props.id!=="undefined"?this.props.id:te(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};E(_,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Fi(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var ct=class extends _{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;constructor(e,t){let n={...t};(t.usage||0)&ct.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),super(e,n,ct.defaultProps),this.usage=t.usage||0,this.indexType=n.indexType}readSyncWebGL(e,t){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let i=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:n,ct.DEBUG_DATA_MAX_LENGTH);e===null?this.debugData=new ArrayBuffer(s):t===0&&n===e.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(t,t+s)}},P=ct;E(P,"defaultProps",{..._.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),E(P,"MAP_READ",1),E(P,"MAP_WRITE",2),E(P,"COPY_SRC",4),E(P,"COPY_DST",8),E(P,"INDEX",16),E(P,"VERTEX",32),E(P,"UNIFORM",64),E(P,"STORAGE",128),E(P,"INDIRECT",256),E(P,"QUERY_RESOLVE",512),E(P,"DEBUG_DATA_MAX_LENGTH",32);function Nt(r){let e=Jr[r],t=Bi(e),n=r.includes("norm"),i=!n&&!r.startsWith("float"),s=r.startsWith("s");return{dataType:Jr[r],byteLength:t,integer:i,signed:s,normalized:n}}function Bi(r){return Ii[r]}var Jr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ii={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Ni=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Di=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function en(r){return Ni.some(e=>r.startsWith(e))}function Dt(r){let e=Di.exec(r);if(e){let[,t,n,i,s,a]=e;if(t){let u=`${i}${n}`,l=Nt(u);return{format:t,components:t.length,srgb:s==="-srgb",unsized:a==="-unsized",webgl:a==="-webgl",...l}}}return wi(r)}var vi={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function wi(r){let e=vi[r];if(!e)throw new Error(`Unknown format ${r}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var lt=class{},ft=class{features;constructor(e=[]){this.features=new Set(e)}*[Symbol.iterator](){yield*this.features}has(e){return this.features.has(e)}},er=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...er.defaultProps,...e},this.id=this.props.id||te(this[Symbol.toStringTag].toLowerCase())}id;statsManager=It;props;userData={};_lumaData={};isTextureFormatCompressed(e){return en(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};return(e.usage||0)&P.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":m.warn("indices buffer content must be of integer type")()),t}},he=er;E(he,"defaultProps",{id:null,type:"best-available",canvas:null,container:null,manageState:!0,width:800,height:600,requestMaximalLimits:!0,debug:Boolean(m.get("debug")),spector:Boolean(m.get("spector")),break:[],gl:null,onError:e=>m.error(e.message)}),E(he,"VERSION",qr);function A(r,e){if(!r)throw new Error(e||"luma.gl: assertion failed.")}var Oi=v()&&typeof document<"u",vt=()=>Oi&&document.readyState==="complete",Ui={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},pe=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return vt()}constructor(e){if(this.props={...Ui,...e},e=this.props,!v()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=Hi(e.canvas):this.canvas=e.canvas;else{let t=ki(e),n=Wi(e?.container||null);n.insertBefore(t,n.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:t}=this._canvasSizeInfo;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[i,s]=this.getDrawingBufferSize();return Vi(e,n,i,s,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let n="width"in t?t.width:this.htmlCanvas.clientWidth,i="height"in t?t.height:this.htmlCanvas.clientHeight;(!n||!i)&&(m.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==i||s.devicePixelRatio!==e){let a=e,u=Math.floor(n*a),l=Math.floor(i*a);this.htmlCanvas.width=u,this.htmlCanvas.height=l;let[f,d]=this.getDrawingBufferSize();(f!==u||d!==l)&&(a=Math.min(f/n,d/i),this.htmlCanvas.width=Math.floor(n*a),this.htmlCanvas.height=Math.floor(i*a),m.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};E(pe,"pageLoaded",Mi());function Mi(){return vt()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}function Wi(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e&&!vt())throw new Error(`Accessing '${r}' before page was loaded`);if(!e)throw new Error(`${r} is not an HTML element`);return e}else if(r)return r;return document.body}function Hi(r){let e=document.getElementById(r);if(!e&&!vt())throw new Error(`Accessing '${r}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function ki(r){let{width:e,height:t}=r,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",n}function Vi(r,e,t,n,i){let s=r,a=tn(s[0],e,t),u=rn(s[1],e,n,i),l=tn(s[0]+1,e,t),f=l===t-1?l:l-1;l=rn(s[1]+1,e,n,i);let d;return i?(l=l===0?l:l+1,d=u,u=l):d=l===n-1?l:l-1,{x:a,y:u,width:Math.max(f-a+1,1),height:Math.max(d-u+1,1)}}function tn(r,e,t){return Math.min(Math.round(r*e),t-1)}function rn(r,e,t,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var tr=class extends _{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;constructor(e,t,n=tr.defaultProps){super(e,t,n),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth}},I=tr;E(I,"defaultProps",{..._.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0}),E(I,"COPY_SRC",1),E(I,"COPY_DST",2),E(I,"TEXTURE_BINDING",4),E(I,"STORAGE_BINDING",8),E(I,"RENDER_ATTACHMENT",16);var rr=class extends _{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,rr.defaultProps)}},De=rr;E(De,"defaultProps",{..._.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function on(r,e,t){let n="",i=e.split(/\r?\n/),s=r.slice().sort((a,u)=>a.lineNum-u.lineNum);switch(t?.showSourceCode||"no"){case"all":let a=0;for(let u=1;u<=i.length;u++)for(n+=sn(i[u-1],u,t);s.length>a&&s[a].lineNum===u;){let l=s[a++];n+=nn(l,i,l.lineNum,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let u of r)n+=nn(u,i,u.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function nn(r,e,t,n){if(n?.inlineSource){let i=Xi(e,t),s=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
7
+ var __exports__=(()=>{var ci=Object.create;var tt=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var hi=(t,e,r)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gi=(t,e)=>{for(var r in e)tt(t,r,{get:e[r],enumerable:!0})},Mr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fi(e))!mi.call(t,i)&&i!==r&&tt(t,i,{get:()=>e[i],enumerable:!(n=li(e,i))||n.enumerable});return t};var y=(t,e,r)=>(r=t!=null?ci(di(t)):{},Mr(e||!t||!t.__esModule?tt(r,"default",{value:t,enumerable:!0}):r,t)),Ei=t=>Mr(tt({},"__esModule",{value:!0}),t);var E=(t,e,r)=>(hi(t,typeof e!="symbol"?e+"":e,r),r);var S=pi((Fc,fn)=>{fn.exports=globalThis.luma});var Ts={};gi(Ts,{Accessor:()=>ae,WEBGLBuffer:()=>H,WEBGLCommandEncoder:()=>je,WEBGLFramebuffer:()=>J,WEBGLRenderPass:()=>$e,WEBGLRenderPipeline:()=>ze,WEBGLResource:()=>Se,WEBGLSampler:()=>ce,WEBGLShader:()=>Ke,WEBGLTexture:()=>U,WEBGLTransformFeedback:()=>qe,WEBGLVertexArray:()=>Ee,WebGLCanvasContext:()=>Xe,WebGLDevice:()=>At,WebGLResource:()=>Se,_TEXTURE_FORMATS:()=>ge,_WEBGLRenderbuffer:()=>Rt,convertGLToTextureFormat:()=>Pn,getGLParameters:()=>Me,getShaderLayout:()=>Yt,popContextState:()=>q,pushContextState:()=>te,resetGLParameters:()=>En,setDeviceParameters:()=>Xt,setGLParameters:()=>X,trackContextState:()=>lt,withDeviceParameters:()=>wn,withGLParameters:()=>K});function rt(t){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 e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function v(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||rt()}var bi=globalThis.self||globalThis.window||globalThis.global,St=globalThis.window||globalThis.self||globalThis.global,_i=globalThis.document||{},xt=globalThis.process||{},Ti=globalThis.console,Wr=globalThis.navigator||{};var yt="4.0.6",Cs=v();var Qt=globalThis;function Ct(t){if(!t&&!v())return"Node";if(rt(t))return"Electron";let e=t||Wr.userAgent||"";if(e.indexOf("Edge")>-1)return"Edge";let r=e.indexOf("MSIE ")!==-1,n=e.indexOf("Trident/")!==-1;return r||n?"IE":Qt.chrome?"Chrome":Qt.safari?"Safari":Qt.mozInnerScreenX?"Firefox":"Unknown"}function Li(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Gt=class{constructor(e,r,n="sessionStorage"){this.storage=Li(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function Hr(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function kr(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}function Pt(t,e,r,n=600){let i=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>n&&(r=Math.min(r,n/t.width));let s=t.width*r,a=t.height*r,c=["font-size:1px;",`padding:${Math.floor(a/2)}px ${Math.floor(s/2)}px;`,`line-height:${a}px;`,`background:url(${i});`,`background-size:${s}px ${a}px;`,"color:transparent;"].join("");return[`${e} %c+`,c]}var Ft;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ft||(Ft={}));var Ai=10;function Vr(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ft[t]||Ft.WHITE)}function Xr(t,e,r){return!v&&typeof t=="string"&&(e&&(t=`\x1B[${Vr(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Vr(r)+Ai}m${t}\x1B[49m`)),t}function Kr(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),i=t;for(let s of n){let a=i[s];typeof a=="function"&&(e.find(c=>s===c)||(i[s]=a.bind(t)))}}function xe(t,e){if(!t)throw new Error(e||"Assertion failed")}function _e(){let t;if(v()&&St.performance)t=St?.performance?.now?.();else if("hrtime"in xt){let e=xt?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ye={debug:v()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ri={enabled:!0,level:0};function Q(){}var $r={},Yr={once:!0},de=class{constructor({id:e}={id:""}){this.VERSION=yt,this._startTs=_e(),this._deltaTs=_e(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Gt(`__probe-${this.id}__`,Ri),this.timeStamp(`${this.id} started`),Kr(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((_e()-this._startTs).toPrecision(10))}getDelta(){return Number((_e()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){xe(e,r)}warn(e){return this._getLogFunction(0,e,ye.warn,arguments,Yr)}error(e){return this._getLogFunction(0,e,ye.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,ye.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,ye.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,ye.debug||ye.info,arguments,Yr)}table(e,r,n){return r?this._getLogFunction(e,r,console.table||Q,n&&[n],{tag:Ci(r)}):Q}image({logLevel:e,priority:r,image:n,message:i="",scale:s=1}){return this._shouldLog(e||r)?v()?yi({image:n,message:i,scale:s}):xi({image:n,message:i,scale:s}):Q}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||Q)}group(e,r,n={collapsed:!1}){let i=zr({logLevel:e,message:r,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Q)}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=jr(e)}_getLogFunction(e,r,n,i,s){if(this._shouldLog(e)){s=zr({logLevel:e,message:r,args:i,opts:s}),n=n||s.method,xe(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=_e();let a=s.tag||s.message;if(s.once&&a)if(!$r[a])$r[a]=_e();else return Q;return r=Si(this.id,s.message,s),n.bind(console,r,...s.args)}return Q}};de.VERSION=yt;function jr(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return xe(Number.isFinite(e)&&e>=0),e}function zr(t){let{logLevel:e,message:r}=t;t.logLevel=jr(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let i=typeof t.message;return xe(i==="string"||i==="object"),Object.assign(t,{args:n},t.opts)}function Si(t,e,r){if(typeof e=="string"){let n=r.time?kr(Hr(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=Xr(e,r.color,r.background)}return e}function xi({image:t,message:e="",scale:r=1}){return console.warn("removed"),Q}function yi({image:t,message:e="",scale:r=1}){if(typeof t=="string"){let i=new Image;return i.onload=()=>{let s=Pt(i,e,r);console.log(...s)},i.src=t,Q}let n=t.nodeName||"";if(n.toLowerCase()==="img")return console.log(...Pt(t,e,r)),Q;if(n.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...Pt(i,e,r)),i.src=t.toDataURL(),Q}return Q}function Ci(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var ia=new de({id:"@probe.gl/log"});var f=new de({id:"luma.gl"});function nt(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Te=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=nt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(nt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ce=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,i=this.stats[r];return i||(e instanceof Te?i=e:i=new Te(r,n),this.stats[r]=i),i}};var qt=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ce({id:e})),this.stats.get(e)}},Bt=new qt;function Gi(){let t="9.0.0-beta.6",e="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${t}`);return globalThis.luma||(v()&&f.log(1,`${t} - ${e}`)(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:f,stats:Bt}),t}var Qr=Gi();function Pi(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)?t:null}function qr(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number"?t:null:Pi(t)}var Zt={};function ee(t="id"){Zt[t]=Zt[t]||1;let e=Zt[t]++;return`${t}-${e}`}function Ge(t){let e=!0;for(let r in t){e=!1;break}return e}var _=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,r,n){if(!e)throw new Error("no device");this._device=e,this.props=Fi(r,n);let i=this.props.id!=="undefined"?this.props.id:ee(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e,r=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};E(_,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Fi(t,e){let r={...e};for(let n in t)t[n]!==void 0&&(r[n]=t[n]);return r}var it=class extends _{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let n={...r};(r.usage||0)&it.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?n.indexType="uint32":r.data instanceof Uint16Array&&(n.indexType="uint16")),super(e,n,it.defaultProps),this.usage=r.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}readSyncWebGL(e,r){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,r,n){let i=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:n,it.DEBUG_DATA_MAX_LENGTH);e===null?this.debugData=new ArrayBuffer(s):r===0&&n===e.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(r,r+s)}},P=it;E(P,"defaultProps",{..._.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),E(P,"MAP_READ",1),E(P,"MAP_WRITE",2),E(P,"COPY_SRC",4),E(P,"COPY_DST",8),E(P,"INDEX",16),E(P,"VERTEX",32),E(P,"UNIFORM",64),E(P,"STORAGE",128),E(P,"INDIRECT",256),E(P,"QUERY_RESOLVE",512),E(P,"DEBUG_DATA_MAX_LENGTH",32);function It(t){let e=Zr[t],r=Bi(e),n=t.includes("norm"),i=!n&&!t.startsWith("float"),s=t.startsWith("s");return{dataType:Zr[t],byteLength:r,integer:i,signed:s,normalized:n}}function Bi(t){return Ii[t]}var Zr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ii={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Ni=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Di=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function Jr(t){return Ni.some(e=>t.startsWith(e))}function Nt(t){let e=Di.exec(t);if(e){let[,r,n,i,s,a]=e;if(r){let c=`${i}${n}`,l=It(c);return{format:r,components:r.length,srgb:s==="-srgb",unsized:a==="-unsized",webgl:a==="-webgl",...l}}}return wi(t)}var vi={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function wi(t){let e=vi[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var ot=class{},st=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},Jt=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...Jt.defaultProps,...e},this.id=this.props.id||ee(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Bt;_lumaData={};isTextureFormatCompressed(e){return Jr(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)&P.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":f.warn("indices buffer content must be of integer type")()),r}},me=Jt;E(me,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(f.get("debug")),spector:Boolean(f.get("spector")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>f.error(e.message)}),E(me,"VERSION",Qr);function R(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var Oi=v()&&typeof document<"u",Dt=()=>Oi&&document.readyState==="complete",Ui={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},he=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return Dt()}constructor(e){if(this.props={...Ui,...e},e=this.props,!v()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=Hi(e.canvas):this.canvas=e.canvas;else{let r=ki(e),n=Wi(e?.container||null);n.insertBefore(r,n.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let n of r)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let n=this.cssToDeviceRatio(),[i,s]=this.getDrawingBufferSize();return Vi(e,n,i,s,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let n="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!n||!i)&&(f.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==i||s.devicePixelRatio!==e){let a=e,c=Math.floor(n*a),l=Math.floor(i*a);this.htmlCanvas.width=c,this.htmlCanvas.height=l;let[d,m]=this.getDrawingBufferSize();(d!==c||m!==l)&&(a=Math.min(d/n,m/i),this.htmlCanvas.width=Math.floor(n*a),this.htmlCanvas.height=Math.floor(i*a),f.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};E(he,"pageLoaded",Mi());function Mi(){return Dt()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function Wi(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!Dt())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function Hi(t){let e=document.getElementById(t);if(!e&&!Dt())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function ki(t){let{width:e,height:r}=t,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=e||1,n.height=r||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(r)?`${r}px`:"100%",n}function Vi(t,e,r,n,i){let s=t,a=en(s[0],e,r),c=tn(s[1],e,n,i),l=en(s[0]+1,e,r),d=l===r-1?l:l-1;l=tn(s[1]+1,e,n,i);let m;return i?(l=l===0?l:l+1,m=c,c=l):m=l===n-1?l:l-1,{x:a,y:c,width:Math.max(d-a+1,1),height:Math.max(m-c+1,1)}}function en(t,e,r){return Math.min(Math.round(t*e),r-1)}function tn(t,e,r,n){return n?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var er=class extends _{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,n=er.defaultProps){super(e,r,n),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}},I=er;E(I,"defaultProps",{..._.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0}),E(I,"COPY_SRC",1),E(I,"COPY_DST",2),E(I,"TEXTURE_BINDING",4),E(I,"STORAGE_BINDING",8),E(I,"RENDER_ATTACHMENT",16);var tr=class extends _{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,tr.defaultProps)}},Pe=tr;E(Pe,"defaultProps",{..._.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function nn(t,e,r){let n="",i=e.split(/\r?\n/),s=t.slice().sort((a,c)=>a.lineNum-c.lineNum);switch(r?.showSourceCode||"no"){case"all":let a=0;for(let c=1;c<=i.length;c++)for(n+=on(i[c-1],c,r);s.length>a&&s[a].lineNum===c;){let l=s[a++];n+=rn(l,i,l.lineNum,{...r,inlineSource:!1})}return n;case"issues":case"no":for(let c of t)n+=rn(c,i,c.lineNum,{inlineSource:r?.showSourceCode!=="no"});return n}}function rn(t,e,r,n){if(n?.inlineSource){let i=Xi(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
8
8
  `:"";return`
9
- ${i}${s}${r.type.toUpperCase()}: ${r.message}
9
+ ${i}${s}${t.type.toUpperCase()}: ${t.message}
10
10
 
11
- `}return n?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Xi(r,e,t){let n="";for(let i=e-2;i<=e;i++){let s=r[i-1];s!==void 0&&(n+=sn(s,e,t))}return n}function sn(r,e,t){let n=t?.html?Yi(r):r;return`${Ki(String(e),4)}: ${n}${t?.html?"<br/>":`
12
- `}`}function Ki(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function Yi(r){return r.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function nr(r,e){return{name:$i(r,e),language:"glsl",version:zi(r)}}function $i(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}function zi(r){let e=100,t=r.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let n=parseInt(t[1],10);Number.isFinite(n)&&(e=n)}return e}var ir=class extends _{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:ji(t),...t},ir.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let t=await this.getCompilationInfo();this.props.debug==="warnings"&&t?.length===0||this._displayShaderLog(t)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let t=nr(this.source).name,n=`${this.stage} ${t}`,i=on(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource();s&&(i+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${s}</pre></code>`);let a=document.createElement("Button");a.innerHTML=`
11
+ `}return n?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function Xi(t,e,r){let n="";for(let i=e-2;i<=e;i++){let s=t[i-1];s!==void 0&&(n+=on(s,e,r))}return n}function on(t,e,r){let n=r?.html?$i(t):t;return`${Ki(String(e),4)}: ${n}${r?.html?"<br/>":`
12
+ `}`}function Ki(t,e){let r="";for(let n=t.length;n<e;++n)r+=" ";return r+t}function $i(t){return t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function rr(t,e){return{name:Yi(t,e),language:"glsl",version:zi(t)}}function Yi(t,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return n?n[1]:e}function zi(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let n=parseInt(r[1],10);Number.isFinite(n)&&(e=n)}return e}var nr=class extends _{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:ji(r),...r},nr.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=rr(this.source).name,n=`${this.stage} ${r}`,i=nn(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource();s&&(i+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${s}</pre></code>`);let a=document.createElement("Button");a.innerHTML=`
13
13
  <h1>Shader Compilation Error in ${n}</h1><br /><br />
14
14
  <code style="user-select:text;"><pre>
15
15
  ${i}
16
- </pre></code>`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a);let u=document.getElementsByClassName("luma-compiler-log-error");u[0]?.scrollIntoView&&u[0].scrollIntoView(),a.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},ve=ir;E(ve,"defaultProps",{..._.defaultProps,language:"auto",stage:"vertex",source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function ji(r){return nr(r.source).name||r.id||te(`unnamed ${r.stage}-shader`)}var or=class extends _{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,or.defaultProps)}},we=or;E(we,"defaultProps",{..._.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var sr=class extends _{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,t={}){super(e,t,sr.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||n!==this.width,this.width=n,this.height=i}t&&(m.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){this.colorAttachments=this.props.colorAttachments.map(t=>{if(typeof t=="string"){let n=this.createColorTexture(t);return this.attachResource(n),n.view}return t instanceof I?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof I?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.device._createTexture({...this.colorAttachments[n].props,width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i.view,this.attachResource(i.view)}if(this.depthStencilAttachment){let n=this.device._createTexture({...this.depthStencilAttachment.props,width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}}},ge=sr;E(ge,"defaultProps",{..._.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var ar=class extends _{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,ar.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Oe=ar;E(Oe,"defaultProps",{..._.defaultProps,vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}});var ur=class extends _{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){super(e,t,ur.defaultProps)}},Ue=ur;E(Ue,"defaultProps",{..._.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var cr=class extends _{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,cr.defaultProps)}},Me=cr;E(Me,"defaultProps",{..._.defaultProps,measureExecutionTime:void 0});var lr=class extends _{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,lr.defaultProps)}},We=lr;E(We,"defaultProps",{..._.defaultProps});function an(r){let[e,t]=qi[r],n=e==="i32"||e==="u32",i=e!=="u32",s=Zi[e]*t,a=Qi(e,t);return{dataType:e,components:t,defaultVertexFormat:a,byteLength:s,integer:n,signed:i}}function Qi(r,e){let t;switch(r){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?t:`${t}x${e}`}var qi={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Zi={f32:4,f16:2,i32:4,u32:4};function fr(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),i=t,s=n?parseInt(n):1,a=Nt(i),u={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return e&&(u.webglOnly=!0),u}function un(r,e){let t={};for(let n of r.attributes)t[n.name]=Ji(r,e,n.name);return t}function cn(r,e,t=16){let n=un(r,e),i=new Array(t).fill(null);for(let s of Object.values(n))i[s.location]=s;return i}function Ji(r,e,t){let n=eo(r,t),i=to(e,t);if(!n)return null;let s=an(n.type),a=i?.vertexFormat||s.defaultVertexFormat,u=fr(a);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:a,bufferDataType:u.type,bufferComponents:u.components,normalized:u.normalized,integer:s.integer,stepMode:i?.stepMode||n.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function eo(r,e){let t=r.attributes.find(n=>n.name===e);return t||m.warn(`shader layout attribute "${e}" not present in shader`),t||null}function to(r,e){ro(r);let t=no(r,e);return t||(t=io(r,e),t)?t:(m.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function ro(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&m.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function no(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function io(r,e){for(let t of r){let n=t.byteStride;if(typeof t.byteStride!="number")for(let s of t.attributes||[]){let a=fr(s.format);n+=a.byteLength}let i=t.attributes?.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function dr(r,e){let t={...r,attributes:r.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=t.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):m.warn(`shader layout attribute ${n.name} not present in shader`)}return t}var mr=class extends _{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,mr.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=cn(t.renderPipeline.shaderLayout,t.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}},He=mr;E(He,"defaultProps",{..._.defaultProps,renderPipeline:null});var hr=class extends _{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,hr.defaultProps)}},ke=hr;E(ke,"defaultProps",{..._.defaultProps,layout:void 0,buffers:{}});var pr=class extends _{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,pr.defaultProps)}},Ve=pr;E(Ve,"defaultProps",{..._.defaultProps,type:void 0,count:void 0});var wt;function ln(r){return(!wt||wt.byteLength<r)&&(wt=new ArrayBuffer(r)),wt}function gr(r,e){let t=ln(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}function Er(r){let{target:e,source:t,start:n=0,count:i=1}=r,s=t.length,a=i*s,u=0;for(let l=n;u<s;u++)e[l++]=t[u];for(;u<a;)u<a-u?(e.copyWithin(n+u,n,n+u),u*=2):(e.copyWithin(n+u,n,n+a-u),u=a);return r.target}function fn(r){return Zr(r)!==null||typeof r=="number"||typeof r=="boolean"}function br(r){let e={bindings:{},uniforms:{}};return Object.keys(r).forEach(t=>{let n=r[t];fn(n)?e.uniforms[t]=n:e.bindings[t]=n}),e}function _r(r,e,t,n){let i=`See luma.gl ${t} Upgrade Guide at https://luma.gl/docs/upgrade-guide`,s=Object.getPrototypeOf(r);n.forEach(a=>{s.methodName||(s[a]=()=>{throw m.removed(`Calling removed method ${e}.${a}: `,i)(),new Error(a)})})}function Tr(r,e,t){let{removedProps:n={},deprecatedProps:i={},replacedProps:s={}}=t;for(let u in n)if(u in e){let f=n[u]?`${r}.${n[u]}`:"N/A";m.removed(`${r}.${u}`,f)()}for(let u in i)if(u in e){let l=i[u];m.deprecated(`${r}.${u}`,`${r}.${l}`)()}let a=null;for(let[u,l]of Object.entries(s))u in e&&(m.deprecated(`${r}.${u}`,`${r}.${l}`)(),a=a||Object.assign({},e),a[l]=e[u],delete a[u]);return a||e}var oo="";async function Lr(r,e){return await new Promise((t,n)=>{try{let i=new Image;i.onload=()=>t(i),i.onerror=()=>n(new Error(`Could not load image ${r}.`)),i.crossOrigin=e?.crossOrigin||"anonymous",i.src=r.startsWith("http")?r:oo+r}catch(i){n(i)}})}async function dt(r,e){let t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",r),e&&(n.id=e),new Promise((i,s)=>{n.onload=i,n.onerror=a=>s(new Error(`Unable to load script '${r}': ${a}`)),t.appendChild(n)})}var o=y(S(),1),ht={[o.GL.BLEND]:!1,[o.GL.BLEND_COLOR]:new Float32Array([0,0,0,0]),[o.GL.BLEND_EQUATION_RGB]:o.GL.FUNC_ADD,[o.GL.BLEND_EQUATION_ALPHA]:o.GL.FUNC_ADD,[o.GL.BLEND_SRC_RGB]:o.GL.ONE,[o.GL.BLEND_DST_RGB]:o.GL.ZERO,[o.GL.BLEND_SRC_ALPHA]:o.GL.ONE,[o.GL.BLEND_DST_ALPHA]:o.GL.ZERO,[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([0,0,0,0]),[o.GL.COLOR_WRITEMASK]:[!0,!0,!0,!0],[o.GL.CULL_FACE]:!1,[o.GL.CULL_FACE_MODE]:o.GL.BACK,[o.GL.DEPTH_TEST]:!1,[o.GL.DEPTH_CLEAR_VALUE]:1,[o.GL.DEPTH_FUNC]:o.GL.LESS,[o.GL.DEPTH_RANGE]:new Float32Array([0,1]),[o.GL.DEPTH_WRITEMASK]:!0,[o.GL.DITHER]:!0,[o.GL.CURRENT_PROGRAM]:null,[o.GL.FRAMEBUFFER_BINDING]:null,[o.GL.RENDERBUFFER_BINDING]:null,[o.GL.VERTEX_ARRAY_BINDING]:null,[o.GL.ARRAY_BUFFER_BINDING]:null,[o.GL.FRONT_FACE]:o.GL.CCW,[o.GL.GENERATE_MIPMAP_HINT]:o.GL.DONT_CARE,[o.GL.LINE_WIDTH]:1,[o.GL.POLYGON_OFFSET_FILL]:!1,[o.GL.POLYGON_OFFSET_FACTOR]:0,[o.GL.POLYGON_OFFSET_UNITS]:0,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE_VALUE]:1,[o.GL.SAMPLE_COVERAGE_INVERT]:!1,[o.GL.SCISSOR_TEST]:!1,[o.GL.SCISSOR_BOX]:new Int32Array([0,0,1024,1024]),[o.GL.STENCIL_TEST]:!1,[o.GL.STENCIL_CLEAR_VALUE]:0,[o.GL.STENCIL_WRITEMASK]:4294967295,[o.GL.STENCIL_BACK_WRITEMASK]:4294967295,[o.GL.STENCIL_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_REF]:0,[o.GL.STENCIL_VALUE_MASK]:4294967295,[o.GL.STENCIL_BACK_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_BACK_REF]:0,[o.GL.STENCIL_BACK_VALUE_MASK]:4294967295,[o.GL.STENCIL_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.STENCIL_BACK_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.VIEWPORT]:[0,0,1024,1024],[o.GL.TRANSFORM_FEEDBACK_BINDING]:null,[o.GL.COPY_READ_BUFFER_BINDING]:null,[o.GL.COPY_WRITE_BUFFER_BINDING]:null,[o.GL.PIXEL_PACK_BUFFER_BINDING]:null,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:null,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:o.GL.DONT_CARE,[o.GL.READ_FRAMEBUFFER_BINDING]:null,[o.GL.RASTERIZER_DISCARD]:!1,[o.GL.PACK_ALIGNMENT]:4,[o.GL.UNPACK_ALIGNMENT]:4,[o.GL.UNPACK_FLIP_Y_WEBGL]:!1,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:!1,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:o.GL.BROWSER_DEFAULT_WEBGL,[o.GL.PACK_ROW_LENGTH]:0,[o.GL.PACK_SKIP_PIXELS]:0,[o.GL.PACK_SKIP_ROWS]:0,[o.GL.UNPACK_ROW_LENGTH]:0,[o.GL.UNPACK_IMAGE_HEIGHT]:0,[o.GL.UNPACK_SKIP_PIXELS]:0,[o.GL.UNPACK_SKIP_ROWS]:0,[o.GL.UNPACK_SKIP_IMAGES]:0},w=(r,e,t)=>e?r.enable(t):r.disable(t),mn=(r,e,t)=>r.hint(t,e),z=(r,e,t)=>r.pixelStorei(t,e),hn=(r,e,t)=>{let n=t===o.GL.FRAMEBUFFER_BINDING?o.GL.DRAW_FRAMEBUFFER:o.GL.READ_FRAMEBUFFER;return r.bindFramebuffer(n,e)},mt=(r,e,t)=>{let i={[o.GL.ARRAY_BUFFER_BINDING]:o.GL.ARRAY_BUFFER,[o.GL.COPY_READ_BUFFER_BINDING]:o.GL.COPY_READ_BUFFER,[o.GL.COPY_WRITE_BUFFER_BINDING]:o.GL.COPY_WRITE_BUFFER,[o.GL.PIXEL_PACK_BUFFER_BINDING]:o.GL.PIXEL_PACK_BUFFER,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:o.GL.PIXEL_UNPACK_BUFFER}[t];r.bindBuffer(i,e)};function Rr(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}var pn={[o.GL.BLEND]:w,[o.GL.BLEND_COLOR]:(r,e)=>r.blendColor(...e),[o.GL.BLEND_EQUATION_RGB]:"blendEquation",[o.GL.BLEND_EQUATION_ALPHA]:"blendEquation",[o.GL.BLEND_SRC_RGB]:"blendFunc",[o.GL.BLEND_DST_RGB]:"blendFunc",[o.GL.BLEND_SRC_ALPHA]:"blendFunc",[o.GL.BLEND_DST_ALPHA]:"blendFunc",[o.GL.COLOR_CLEAR_VALUE]:(r,e)=>r.clearColor(...e),[o.GL.COLOR_WRITEMASK]:(r,e)=>r.colorMask(...e),[o.GL.CULL_FACE]:w,[o.GL.CULL_FACE_MODE]:(r,e)=>r.cullFace(e),[o.GL.DEPTH_TEST]:w,[o.GL.DEPTH_CLEAR_VALUE]:(r,e)=>r.clearDepth(e),[o.GL.DEPTH_FUNC]:(r,e)=>r.depthFunc(e),[o.GL.DEPTH_RANGE]:(r,e)=>r.depthRange(...e),[o.GL.DEPTH_WRITEMASK]:(r,e)=>r.depthMask(e),[o.GL.DITHER]:w,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:mn,[o.GL.CURRENT_PROGRAM]:(r,e)=>r.useProgram(e),[o.GL.RENDERBUFFER_BINDING]:(r,e)=>r.bindRenderbuffer(o.GL.RENDERBUFFER,e),[o.GL.TRANSFORM_FEEDBACK_BINDING]:(r,e)=>r.bindTransformFeedback?.(o.GL.TRANSFORM_FEEDBACK,e),[o.GL.VERTEX_ARRAY_BINDING]:(r,e)=>r.bindVertexArray(e),[o.GL.FRAMEBUFFER_BINDING]:hn,[o.GL.READ_FRAMEBUFFER_BINDING]:hn,[o.GL.ARRAY_BUFFER_BINDING]:mt,[o.GL.COPY_READ_BUFFER_BINDING]:mt,[o.GL.COPY_WRITE_BUFFER_BINDING]:mt,[o.GL.PIXEL_PACK_BUFFER_BINDING]:mt,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:mt,[o.GL.FRONT_FACE]:(r,e)=>r.frontFace(e),[o.GL.GENERATE_MIPMAP_HINT]:mn,[o.GL.LINE_WIDTH]:(r,e)=>r.lineWidth(e),[o.GL.POLYGON_OFFSET_FILL]:w,[o.GL.POLYGON_OFFSET_FACTOR]:"polygonOffset",[o.GL.POLYGON_OFFSET_UNITS]:"polygonOffset",[o.GL.RASTERIZER_DISCARD]:w,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE_VALUE]:"sampleCoverage",[o.GL.SAMPLE_COVERAGE_INVERT]:"sampleCoverage",[o.GL.SCISSOR_TEST]:w,[o.GL.SCISSOR_BOX]:(r,e)=>r.scissor(...e),[o.GL.STENCIL_TEST]:w,[o.GL.STENCIL_CLEAR_VALUE]:(r,e)=>r.clearStencil(e),[o.GL.STENCIL_WRITEMASK]:(r,e)=>r.stencilMaskSeparate(o.GL.FRONT,e),[o.GL.STENCIL_BACK_WRITEMASK]:(r,e)=>r.stencilMaskSeparate(o.GL.BACK,e),[o.GL.STENCIL_FUNC]:"stencilFuncFront",[o.GL.STENCIL_REF]:"stencilFuncFront",[o.GL.STENCIL_VALUE_MASK]:"stencilFuncFront",[o.GL.STENCIL_BACK_FUNC]:"stencilFuncBack",[o.GL.STENCIL_BACK_REF]:"stencilFuncBack",[o.GL.STENCIL_BACK_VALUE_MASK]:"stencilFuncBack",[o.GL.STENCIL_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_PASS]:"stencilOpFront",[o.GL.STENCIL_BACK_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:"stencilOpBack",[o.GL.VIEWPORT]:(r,e)=>r.viewport(...e),[o.GL.DEPTH_CLAMP_EXT]:w,[o.GL.POLYGON_OFFSET_LINE_WEBGL]:w,[o.GL.CLIP_DISTANCE0_WEBGL]:w,[o.GL.CLIP_DISTANCE1_WEBGL]:w,[o.GL.CLIP_DISTANCE2_WEBGL]:w,[o.GL.CLIP_DISTANCE3_WEBGL]:w,[o.GL.CLIP_DISTANCE4_WEBGL]:w,[o.GL.CLIP_DISTANCE5_WEBGL]:w,[o.GL.CLIP_DISTANCE6_WEBGL]:w,[o.GL.CLIP_DISTANCE7_WEBGL]:w,[o.GL.PACK_ALIGNMENT]:z,[o.GL.UNPACK_ALIGNMENT]:z,[o.GL.UNPACK_FLIP_Y_WEBGL]:z,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:z,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:z,[o.GL.PACK_ROW_LENGTH]:z,[o.GL.PACK_SKIP_PIXELS]:z,[o.GL.PACK_SKIP_ROWS]:z,[o.GL.UNPACK_ROW_LENGTH]:z,[o.GL.UNPACK_IMAGE_HEIGHT]:z,[o.GL.UNPACK_SKIP_PIXELS]:z,[o.GL.UNPACK_SKIP_ROWS]:z,[o.GL.UNPACK_SKIP_IMAGES]:z,framebuffer:(r,e)=>{let t=e&&"handle"in e?e.handle:e;return r.bindFramebuffer(o.GL.FRAMEBUFFER,t)},blend:(r,e)=>e?r.enable(o.GL.BLEND):r.disable(o.GL.BLEND),blendColor:(r,e)=>r.blendColor(...e),blendEquation:(r,e)=>{let t=typeof e=="number"?[e,e]:e;r.blendEquationSeparate(...t)},blendFunc:(r,e)=>{let t=e?.length===2?[...e,...e]:e;r.blendFuncSeparate(...t)},clearColor:(r,e)=>r.clearColor(...e),clearDepth:(r,e)=>r.clearDepth(e),clearStencil:(r,e)=>r.clearStencil(e),colorMask:(r,e)=>r.colorMask(...e),cull:(r,e)=>e?r.enable(o.GL.CULL_FACE):r.disable(o.GL.CULL_FACE),cullFace:(r,e)=>r.cullFace(e),depthTest:(r,e)=>e?r.enable(o.GL.DEPTH_TEST):r.disable(o.GL.DEPTH_TEST),depthFunc:(r,e)=>r.depthFunc(e),depthMask:(r,e)=>r.depthMask(e),depthRange:(r,e)=>r.depthRange(...e),dither:(r,e)=>e?r.enable(o.GL.DITHER):r.disable(o.GL.DITHER),derivativeHint:(r,e)=>{r.hint(o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT,e)},frontFace:(r,e)=>r.frontFace(e),mipmapHint:(r,e)=>r.hint(o.GL.GENERATE_MIPMAP_HINT,e),lineWidth:(r,e)=>r.lineWidth(e),polygonOffsetFill:(r,e)=>e?r.enable(o.GL.POLYGON_OFFSET_FILL):r.disable(o.GL.POLYGON_OFFSET_FILL),polygonOffset:(r,e)=>r.polygonOffset(...e),sampleCoverage:(r,e)=>r.sampleCoverage(...e),scissorTest:(r,e)=>e?r.enable(o.GL.SCISSOR_TEST):r.disable(o.GL.SCISSOR_TEST),scissor:(r,e)=>r.scissor(...e),stencilTest:(r,e)=>e?r.enable(o.GL.STENCIL_TEST):r.disable(o.GL.STENCIL_TEST),stencilMask:(r,e)=>{e=Rr(e)?e:[e,e];let[t,n]=e;r.stencilMaskSeparate(o.GL.FRONT,t),r.stencilMaskSeparate(o.GL.BACK,n)},stencilFunc:(r,e)=>{e=Rr(e)&&e.length===3?[...e,...e]:e;let[t,n,i,s,a,u]=e;r.stencilFuncSeparate(o.GL.FRONT,t,n,i),r.stencilFuncSeparate(o.GL.BACK,s,a,u)},stencilOp:(r,e)=>{e=Rr(e)&&e.length===3?[...e,...e]:e;let[t,n,i,s,a,u]=e;r.stencilOpSeparate(o.GL.FRONT,t,n,i),r.stencilOpSeparate(o.GL.BACK,s,a,u)},viewport:(r,e)=>r.viewport(...e)};function B(r,e,t){return e[r]!==void 0?e[r]:t[r]}var gn={blendEquation:(r,e,t)=>r.blendEquationSeparate(B(o.GL.BLEND_EQUATION_RGB,e,t),B(o.GL.BLEND_EQUATION_ALPHA,e,t)),blendFunc:(r,e,t)=>r.blendFuncSeparate(B(o.GL.BLEND_SRC_RGB,e,t),B(o.GL.BLEND_DST_RGB,e,t),B(o.GL.BLEND_SRC_ALPHA,e,t),B(o.GL.BLEND_DST_ALPHA,e,t)),polygonOffset:(r,e,t)=>r.polygonOffset(B(o.GL.POLYGON_OFFSET_FACTOR,e,t),B(o.GL.POLYGON_OFFSET_UNITS,e,t)),sampleCoverage:(r,e,t)=>r.sampleCoverage(B(o.GL.SAMPLE_COVERAGE_VALUE,e,t),B(o.GL.SAMPLE_COVERAGE_INVERT,e,t)),stencilFuncFront:(r,e,t)=>r.stencilFuncSeparate(o.GL.FRONT,B(o.GL.STENCIL_FUNC,e,t),B(o.GL.STENCIL_REF,e,t),B(o.GL.STENCIL_VALUE_MASK,e,t)),stencilFuncBack:(r,e,t)=>r.stencilFuncSeparate(o.GL.BACK,B(o.GL.STENCIL_BACK_FUNC,e,t),B(o.GL.STENCIL_BACK_REF,e,t),B(o.GL.STENCIL_BACK_VALUE_MASK,e,t)),stencilOpFront:(r,e,t)=>r.stencilOpSeparate(o.GL.FRONT,B(o.GL.STENCIL_FAIL,e,t),B(o.GL.STENCIL_PASS_DEPTH_FAIL,e,t),B(o.GL.STENCIL_PASS_DEPTH_PASS,e,t)),stencilOpBack:(r,e,t)=>r.stencilOpSeparate(o.GL.BACK,B(o.GL.STENCIL_BACK_FAIL,e,t),B(o.GL.STENCIL_BACK_PASS_DEPTH_FAIL,e,t),B(o.GL.STENCIL_BACK_PASS_DEPTH_PASS,e,t))},Ar={enable:(r,e)=>r({[e]:!0}),disable:(r,e)=>r({[e]:!1}),pixelStorei:(r,e,t)=>r({[e]:t}),hint:(r,e,t)=>r({[e]:t}),useProgram:(r,e)=>r({[o.GL.CURRENT_PROGRAM]:e}),bindRenderbuffer:(r,e,t)=>r({[o.GL.RENDERBUFFER_BINDING]:t}),bindTransformFeedback:(r,e,t)=>r({[o.GL.TRANSFORM_FEEDBACK_BINDING]:t}),bindVertexArray:(r,e)=>r({[o.GL.VERTEX_ARRAY_BINDING]:e}),bindFramebuffer:(r,e,t)=>{switch(e){case o.GL.FRAMEBUFFER:return r({[o.GL.DRAW_FRAMEBUFFER_BINDING]:t,[o.GL.READ_FRAMEBUFFER_BINDING]:t});case o.GL.DRAW_FRAMEBUFFER:return r({[o.GL.DRAW_FRAMEBUFFER_BINDING]:t});case o.GL.READ_FRAMEBUFFER:return r({[o.GL.READ_FRAMEBUFFER_BINDING]:t});default:return null}},bindBuffer:(r,e,t)=>{let n={[o.GL.ARRAY_BUFFER]:[o.GL.ARRAY_BUFFER_BINDING],[o.GL.COPY_READ_BUFFER]:[o.GL.COPY_READ_BUFFER_BINDING],[o.GL.COPY_WRITE_BUFFER]:[o.GL.COPY_WRITE_BUFFER_BINDING],[o.GL.PIXEL_PACK_BUFFER]:[o.GL.PIXEL_PACK_BUFFER_BINDING],[o.GL.PIXEL_UNPACK_BUFFER]:[o.GL.PIXEL_UNPACK_BUFFER_BINDING]}[e];return n?r({[n]:t}):{valueChanged:!0}},blendColor:(r,e,t,n,i)=>r({[o.GL.BLEND_COLOR]:new Float32Array([e,t,n,i])}),blendEquation:(r,e)=>r({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:e}),blendEquationSeparate:(r,e,t)=>r({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:t}),blendFunc:(r,e,t)=>r({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:t,[o.GL.BLEND_SRC_ALPHA]:e,[o.GL.BLEND_DST_ALPHA]:t}),blendFuncSeparate:(r,e,t,n,i)=>r({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:t,[o.GL.BLEND_SRC_ALPHA]:n,[o.GL.BLEND_DST_ALPHA]:i}),clearColor:(r,e,t,n,i)=>r({[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([e,t,n,i])}),clearDepth:(r,e)=>r({[o.GL.DEPTH_CLEAR_VALUE]:e}),clearStencil:(r,e)=>r({[o.GL.STENCIL_CLEAR_VALUE]:e}),colorMask:(r,e,t,n,i)=>r({[o.GL.COLOR_WRITEMASK]:[e,t,n,i]}),cullFace:(r,e)=>r({[o.GL.CULL_FACE_MODE]:e}),depthFunc:(r,e)=>r({[o.GL.DEPTH_FUNC]:e}),depthRange:(r,e,t)=>r({[o.GL.DEPTH_RANGE]:new Float32Array([e,t])}),depthMask:(r,e)=>r({[o.GL.DEPTH_WRITEMASK]:e}),frontFace:(r,e)=>r({[o.GL.FRONT_FACE]:e}),lineWidth:(r,e)=>r({[o.GL.LINE_WIDTH]:e}),polygonOffset:(r,e,t)=>r({[o.GL.POLYGON_OFFSET_FACTOR]:e,[o.GL.POLYGON_OFFSET_UNITS]:t}),sampleCoverage:(r,e,t)=>r({[o.GL.SAMPLE_COVERAGE_VALUE]:e,[o.GL.SAMPLE_COVERAGE_INVERT]:t}),scissor:(r,e,t,n,i)=>r({[o.GL.SCISSOR_BOX]:new Int32Array([e,t,n,i])}),stencilMask:(r,e)=>r({[o.GL.STENCIL_WRITEMASK]:e,[o.GL.STENCIL_BACK_WRITEMASK]:e}),stencilMaskSeparate:(r,e,t)=>r({[e===o.GL.FRONT?o.GL.STENCIL_WRITEMASK:o.GL.STENCIL_BACK_WRITEMASK]:t}),stencilFunc:(r,e,t,n)=>r({[o.GL.STENCIL_FUNC]:e,[o.GL.STENCIL_REF]:t,[o.GL.STENCIL_VALUE_MASK]:n,[o.GL.STENCIL_BACK_FUNC]:e,[o.GL.STENCIL_BACK_REF]:t,[o.GL.STENCIL_BACK_VALUE_MASK]:n}),stencilFuncSeparate:(r,e,t,n,i)=>r({[e===o.GL.FRONT?o.GL.STENCIL_FUNC:o.GL.STENCIL_BACK_FUNC]:t,[e===o.GL.FRONT?o.GL.STENCIL_REF:o.GL.STENCIL_BACK_REF]:n,[e===o.GL.FRONT?o.GL.STENCIL_VALUE_MASK:o.GL.STENCIL_BACK_VALUE_MASK]:i}),stencilOp:(r,e,t,n)=>r({[o.GL.STENCIL_FAIL]:e,[o.GL.STENCIL_PASS_DEPTH_FAIL]:t,[o.GL.STENCIL_PASS_DEPTH_PASS]:n,[o.GL.STENCIL_BACK_FAIL]:e,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:t,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:n}),stencilOpSeparate:(r,e,t,n,i)=>r({[e===o.GL.FRONT?o.GL.STENCIL_FAIL:o.GL.STENCIL_BACK_FAIL]:t,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_FAIL:o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:n,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_PASS:o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:i}),viewport:(r,e,t,n,i)=>r({[o.GL.VIEWPORT]:[e,t,n,i]})},oe=(r,e)=>r.isEnabled(e),Sr={[o.GL.BLEND]:oe,[o.GL.CULL_FACE]:oe,[o.GL.DEPTH_TEST]:oe,[o.GL.DITHER]:oe,[o.GL.POLYGON_OFFSET_FILL]:oe,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:oe,[o.GL.SAMPLE_COVERAGE]:oe,[o.GL.SCISSOR_TEST]:oe,[o.GL.STENCIL_TEST]:oe,[o.GL.RASTERIZER_DISCARD]:oe},En=new Set([o.GL.ACTIVE_TEXTURE,o.GL.TRANSFORM_FEEDBACK_ACTIVE,o.GL.TRANSFORM_FEEDBACK_PAUSED,o.GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,o.GL.UNIFORM_BUFFER_BINDING,o.GL.ELEMENT_ARRAY_BUFFER_BINDING,o.GL.IMPLEMENTATION_COLOR_READ_FORMAT,o.GL.IMPLEMENTATION_COLOR_READ_TYPE,o.GL.READ_BUFFER,o.GL.DRAW_BUFFER0,o.GL.DRAW_BUFFER1,o.GL.DRAW_BUFFER2,o.GL.DRAW_BUFFER3,o.GL.DRAW_BUFFER4,o.GL.DRAW_BUFFER5,o.GL.DRAW_BUFFER6,o.GL.DRAW_BUFFER7,o.GL.DRAW_BUFFER8,o.GL.DRAW_BUFFER9,o.GL.DRAW_BUFFER10,o.GL.DRAW_BUFFER11,o.GL.DRAW_BUFFER12,o.GL.DRAW_BUFFER13,o.GL.DRAW_BUFFER14,o.GL.DRAW_BUFFER15,o.GL.SAMPLER_BINDING,o.GL.TEXTURE_BINDING_2D,o.GL.TEXTURE_BINDING_2D_ARRAY,o.GL.TEXTURE_BINDING_3D,o.GL.TEXTURE_BINDING_CUBE_MAP]);function X(r,e){let n=K.attach(r).gl;if(so(e))return;let i={};for(let a in e){let u=Number(a),l=pn[a];l&&(typeof l=="string"?i[l]=!0:l(n,e[a],u))}let s=n.state&&n.state.cache;if(s)for(let a in i){let u=gn[a];u(n,e,s)}}function Xe(r,e=ht){let n=K.attach(r).gl;if(typeof e=="number"){let a=e,u=Sr[a];return u?u(n,a):n.getParameter(a)}let i=Array.isArray(e)?e:Object.keys(e),s={};for(let a of i){let u=Sr[a];s[a]=u?u(n,Number(a)):n.getParameter(Number(a))}return s}function bn(r){X(r,ht)}function so(r){for(let e in r)return!1;return!0}function _n(r,e){if(r===e)return!0;let t=Array.isArray(r)||ArrayBuffer.isView(r),n=Array.isArray(e)||ArrayBuffer.isView(e);if(t&&n&&r.length===e.length){for(let i=0;i<r.length;++i)if(r[i]!==e[i])return!1;return!0}return!1}var xr=class{gl;program=null;stateStack=[];enable=!0;cache;log;constructor(e,{copyState:t=!1,log:n=()=>{}}={}){this.gl=e,this.cache=t?Xe(e):Object.assign({},ht),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){A(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];X(this.gl,e),this.stateStack.pop()}_updateCache(e){let t=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){A(s!==void 0);let a=e[s],u=this.cache[s];_n(a,u)||(t=!0,n=u,i&&!(s in i)&&(i[s]=u),this.cache[s]=a)}return{valueChanged:t,oldValue:n}}};function Ae(r){return r.state}function pt(r,e){let{enable:t=!0,copyState:n}=e;if(A(n!==void 0),!r.state){r.state=new xr(r,{copyState:n}),uo(r);for(let s in Ar){let a=Ar[s];ao(r,s,a)}Tn(r,"getParameter"),Tn(r,"isEnabled")}let i=Ae(r);return i.enable=t,r}function re(r){let e=Ae(r);e||(pt(r,{copyState:!1}),e=Ae(r)),e.push()}function Z(r){let e=Ae(r);A(e),e.pop()}function Tn(r,e){let t=r[e].bind(r);r[e]=function(i){if(i===void 0||En.has(i))return t(i);let s=Ae(r);return i in s.cache||(s.cache[i]=t(i)),s.enable?s.cache[i]:t(i)},Object.defineProperty(r[e],"name",{value:`${e}-from-cache`,configurable:!1})}function ao(r,e,t){if(!r[e])return;let n=r[e].bind(r);r[e]=function(...s){let a=Ae(r),{valueChanged:u,oldValue:l}=t(a._updateCache,...s);return u&&n(...s),l},Object.defineProperty(r[e],"name",{value:`${e}-to-cache`,configurable:!1})}function uo(r){let e=r.useProgram.bind(r);r.useProgram=function(n){let i=Ae(r);i.program!==n&&(e(n),i.program=n)}}var co={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Ln(r,e){e={...co,...e};let t=null,n=s=>t=s.statusMessage||t;r.addEventListener("webglcontextcreationerror",n,!1);let i=null;if(i||=r.getContext("webgl2",e),r.removeEventListener("webglcontextcreationerror",n,!1),!i)throw new Error(`Failed to create WebGL context: ${t||"Unknown error"}`);if(e.onContextLost){let{onContextLost:s}=e;r.addEventListener("webglcontextlost",a=>s(a),!1)}if(e.onContextRestored){let{onContextRestored:s}=e;r.addEventListener("webglcontextrestored",a=>s(a),!1)}return i}var Ke=y(S(),1);function J(r,e,t){return t[e]===void 0&&(t[e]=r.getExtension(e)||null),t[e]}function Rn(r,e){let t=r.getParameter(Ke.GL.VENDOR),n=r.getParameter(Ke.GL.RENDERER);J(r,"WEBGL_debug_renderer_info",e);let i=e.WEBGL_debug_renderer_info,s=r.getParameter(i?i.UNMASKED_VENDOR_WEBGL:Ke.GL.VENDOR),a=r.getParameter(i?i.UNMASKED_RENDERER_WEBGL:Ke.GL.RENDERER),u=s||t,l=a||n,f=r.getParameter(Ke.GL.VERSION),d=An(u,l),b=lo(u,l),g=fo(u,l);return{type:"webgl",gpu:d,gpuType:g,gpuBackend:b,vendor:u,renderer:l,version:f,shadingLanguage:"glsl",shadingLanguageVersion:300}}function An(r,e){return/NVIDIA/i.exec(r)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(r)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(r)||/Apple/i.exec(e)?"apple":/AMD/i.exec(r)||/AMD/i.exec(e)||/ATI/i.exec(r)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e)?"software":"unknown"}function lo(r,e){return/Metal/i.exec(r)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(e)?"opengl":"unknown"}function fo(r,e){if(/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e))return"cpu";switch(An(r,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var c=y(S(),1);var j=y(S(),1);function Ot(r){switch(r){case"uint8":return j.GL.UNSIGNED_BYTE;case"sint8":return j.GL.BYTE;case"unorm8":return j.GL.UNSIGNED_BYTE;case"snorm8":return j.GL.BYTE;case"uint16":return j.GL.UNSIGNED_SHORT;case"sint16":return j.GL.SHORT;case"unorm16":return j.GL.UNSIGNED_SHORT;case"snorm16":return j.GL.SHORT;case"uint32":return j.GL.UNSIGNED_INT;case"sint32":return j.GL.INT;case"float16":return j.GL.HALF_FLOAT;case"float32":return j.GL.FLOAT}throw new Error(String(r))}var M="texture-compression-bc",C="texture-compression-astc",se="texture-compression-etc2",mo="texture-compression-etc1-webgl",Ut="texture-compression-pvrtc-webgl",yr="texture-compression-atc-webgl",gt="float32-renderable-webgl",Cr="float16-renderable-webgl",ho="rgb9e5ufloat_renderable-webgl",Gr="snorm8-renderable-webgl",Et="norm16-renderable-webgl",Pr="snorm16-renderable-webgl",Mt="float32-filterable",Sn="float16-filterable-webgl",bt="WEBGL_compressed_texture_s3tc",_t="WEBGL_compressed_texture_s3tc_srgb",Ye="EXT_texture_compression_rgtc",$e="EXT_texture_compression_bptc",po="WEBGL_compressed_texture_etc",go="WEBGL_compressed_texture_astc",Eo="WEBGL_compressed_texture_etc1",bo="WEBGL_compressed_texture_pvrtc",_o="WEBGL_compressed_texture_atc",xn="EXT_texture_norm16",yn="EXT_render_snorm",To="EXT_color_buffer_float",Wt={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[yn],"norm16-renderable-webgl":[xn],"snorm16-renderable-webgl":[xn,yn],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[bt,_t,Ye,$e],"texture-compression-bc5-webgl":[Ye],"texture-compression-bc7-webgl":[$e],"texture-compression-etc2":[po],"texture-compression-astc":[go],"texture-compression-etc1-webgl":[Eo],"texture-compression-pvrtc-webgl":[bo],"texture-compression-atc-webgl":[_o]};function Cn(r){return r in Wt}function Gn(r,e,t){return(Wt[e]||[]).every(i=>J(r,i,t))}var Se={"rgb8unorm-unsized":{gl:c.GL.RGB,b:4,c:2,bpp:4,dataFormat:c.GL.RGB,types:[c.GL.UNSIGNED_BYTE,c.GL.UNSIGNED_SHORT_5_6_5]},"rgba8unorm-unsized":{gl:c.GL.RGBA,b:4,c:2,bpp:4,dataFormat:c.GL.RGBA,types:[c.GL.UNSIGNED_BYTE,c.GL.UNSIGNED_SHORT_4_4_4_4,c.GL.UNSIGNED_SHORT_5_5_5_1]},r8unorm:{gl:c.GL.R8,b:1,c:1,renderbuffer:!0},r8snorm:{gl:c.GL.R8_SNORM,b:1,c:1,render:Gr},r8uint:{gl:c.GL.R8UI,b:1,c:1,renderbuffer:!0},r8sint:{gl:c.GL.R8I,b:1,c:1,renderbuffer:!0},rg8unorm:{gl:c.GL.RG8,b:2,c:2,renderbuffer:!0},rg8snorm:{gl:c.GL.RG8_SNORM,b:2,c:2,render:Gr},rg8uint:{gl:c.GL.RG8UI,b:2,c:2,renderbuffer:!0},rg8sint:{gl:c.GL.RG8I,b:2,c:2,renderbuffer:!0},r16uint:{gl:c.GL.R16UI,b:2,c:1,renderbuffer:!0},r16sint:{gl:c.GL.R16I,b:2,c:1,renderbuffer:!0},r16float:{gl:c.GL.R16F,b:2,c:1,render:Cr,filter:"float16-filterable-webgl",renderbuffer:!0},"r16unorm-webgl":{gl:c.GL.R16_EXT,b:2,c:1,f:Et,renderbuffer:!0},"r16snorm-webgl":{gl:c.GL.R16_SNORM_EXT,b:2,c:1,f:Pr},"rgba4unorm-webgl":{gl:c.GL.RGBA4,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb565unorm-webgl":{gl:c.GL.RGB565,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb5a1unorm-webgl":{gl:c.GL.RGB5_A1,b:2,c:4,wgpu:!1,renderbuffer:!0},"rgb8unorm-webgl":{gl:c.GL.RGB8,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:c.GL.RGB8_SNORM,b:3,c:3,wgpu:!1},rgba8unorm:{gl:c.GL.RGBA8,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:c.GL.SRGB8_ALPHA8,b:4,c:4,bpp:4},rgba8snorm:{gl:c.GL.RGBA8_SNORM,b:4,c:4,render:Gr},rgba8uint:{gl:c.GL.RGBA8UI,b:4,c:4,bpp:4},rgba8sint:{gl:c.GL.RGBA8I,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:c.GL.RG16UI,b:4,c:1,bpp:4},rg16sint:{gl:c.GL.RG16I,b:4,c:2,bpp:4},rg16float:{gl:c.GL.RG16F,bpp:4,b:4,c:2,render:Cr,filter:Sn,renderbuffer:!0},"rg16unorm-webgl":{gl:c.GL.RG16_EXT,b:2,c:2,render:Et},"rg16snorm-webgl":{gl:c.GL.RG16_SNORM_EXT,b:2,c:2,render:Pr},r32uint:{gl:c.GL.R32UI,b:4,c:1,bpp:4,renderbuffer:!0},r32sint:{gl:c.GL.R32I,b:4,c:1,bpp:4,renderbuffer:!0},r32float:{gl:c.GL.R32F,bpp:4,b:4,c:1,render:gt,filter:Mt},rgb9e5ufloat:{gl:c.GL.RGB9_E5,b:4,c:3,p:1,render:ho},rg11b10ufloat:{gl:c.GL.R11F_G11F_B10F,b:4,c:3,p:1,render:gt,renderbuffer:!0},rgb10a2unorm:{gl:c.GL.RGB10_A2,b:4,c:4,p:1,renderbuffer:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:c.GL.RGB10_A2UI,p:1,wgpu:!1,bpp:4,renderbuffer:!0},"rgb16unorm-webgl":{gl:c.GL.RGB16_EXT,b:2,c:3,f:Et},"rgb16snorm-webgl":{gl:c.GL.RGB16_SNORM_EXT,b:2,c:3,f:Et},rg32uint:{gl:c.GL.RG32UI,b:8,c:2,renderbuffer:!0},rg32sint:{gl:c.GL.RG32I,b:8,c:2,renderbuffer:!0},rg32float:{gl:c.GL.RG32F,b:8,c:2,render:gt,filter:Mt,renderbuffer:!0},rgba16uint:{gl:c.GL.RGBA16UI,b:8,c:4,renderbuffer:!0},rgba16sint:{gl:c.GL.RGBA16I,b:8,c:4,renderbuffer:!0},rgba16float:{gl:c.GL.RGBA16F,b:8,c:4,render:Cr,filter:Sn},"rgba16unorm-webgl":{gl:c.GL.RGBA16_EXT,b:2,c:4,render:Et,renderbuffer:!0},"rgba16snorm-webgl":{gl:c.GL.RGBA16_SNORM_EXT,b:2,c:4,render:Pr},"rgb32float-webgl":{gl:c.GL.RGB32F,render:gt,filter:Mt,gl2ext:To,dataFormat:c.GL.RGB,types:[c.GL.FLOAT]},rgba32uint:{gl:c.GL.RGBA32UI,b:16,c:4,renderbuffer:!0},rgba32sint:{gl:c.GL.RGBA32I,b:16,c:4,renderbuffer:!0},rgba32float:{gl:c.GL.RGBA32F,b:16,c:4,render:gt,filter:Mt,renderbuffer:!0},stencil8:{gl:c.GL.STENCIL_INDEX8,b:1,c:1,attachment:c.GL.STENCIL_ATTACHMENT,renderbuffer:!0},depth16unorm:{gl:c.GL.DEPTH_COMPONENT16,b:2,c:1,attachment:c.GL.DEPTH_ATTACHMENT,renderbuffer:!0},depth24plus:{gl:c.GL.DEPTH_COMPONENT24,b:3,c:1,attachment:c.GL.DEPTH_ATTACHMENT},depth32float:{gl:c.GL.DEPTH_COMPONENT32F,b:4,c:1,attachment:c.GL.DEPTH_ATTACHMENT,renderbuffer:!0},"depth24plus-stencil8":{gl:c.GL.DEPTH_STENCIL,b:4,c:2,p:1,attachment:c.GL.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0,depthTexture:!0},"depth24unorm-stencil8":{gl:c.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:c.GL.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0},"depth32float-stencil8":{gl:c.GL.DEPTH32F_STENCIL8,b:5,c:2,p:1,attachment:c.GL.DEPTH_STENCIL_ATTACHMENT,renderbuffer:!0},"bc1-rgb-unorm-webgl":{gl:c.GL.COMPRESSED_RGB_S3TC_DXT1_EXT,x:bt,f:M},"bc1-rgb-unorm-srgb-webgl":{gl:c.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:_t,f:M},"bc1-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT,x:bt,f:M},"bc1-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:_t,f:M},"bc2-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT,x:bt,f:M},"bc2-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,x:_t,f:M},"bc3-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT,x:bt,f:M},"bc3-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,x:_t,f:M},"bc4-r-unorm":{gl:c.GL.COMPRESSED_RED_RGTC1_EXT,x:Ye,f:M},"bc4-r-snorm":{gl:c.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT,x:Ye,f:M},"bc5-rg-unorm":{gl:c.GL.COMPRESSED_RED_GREEN_RGTC2_EXT,x:Ye,f:M},"bc5-rg-snorm":{gl:c.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,x:Ye,f:M},"bc6h-rgb-ufloat":{gl:c.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,x:$e,f:M},"bc6h-rgb-float":{gl:c.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,x:$e,f:M},"bc7-rgba-unorm":{gl:c.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT,x:$e,f:M},"bc7-rgba-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,x:$e,f:M},"etc2-rgb8unorm":{gl:c.GL.COMPRESSED_RGB8_ETC2,f:se},"etc2-rgb8unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ETC2,f:se},"etc2-rgb8a1unorm":{gl:c.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:se},"etc2-rgb8a1unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:se},"etc2-rgba8unorm":{gl:c.GL.COMPRESSED_RGBA8_ETC2_EAC,f:se},"etc2-rgba8unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,f:se},"eac-r11unorm":{gl:c.GL.COMPRESSED_R11_EAC,f:se},"eac-r11snorm":{gl:c.GL.COMPRESSED_SIGNED_R11_EAC,f:se},"eac-rg11unorm":{gl:c.GL.COMPRESSED_RG11_EAC,f:se},"eac-rg11snorm":{gl:c.GL.COMPRESSED_SIGNED_RG11_EAC,f:se},"astc-4x4-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_4x4_KHR,f:C},"astc-4x4-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,f:C},"astc-5x4-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_5x4_KHR,f:C},"astc-5x4-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,f:C},"astc-5x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_5x5_KHR,f:C},"astc-5x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,f:C},"astc-6x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_6x5_KHR,f:C},"astc-6x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,f:C},"astc-6x6-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_6x6_KHR,f:C},"astc-6x6-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,f:C},"astc-8x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_8x5_KHR,f:C},"astc-8x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,f:C},"astc-8x6-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_8x6_KHR,f:C},"astc-8x6-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,f:C},"astc-8x8-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_8x8_KHR,f:C},"astc-8x8-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,f:C},"astc-10x5-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x5-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-10x6-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x6_KHR,f:C},"astc-10x6-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,f:C},"astc-10x8-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x8_KHR,f:C},"astc-10x8-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,f:C},"astc-10x10-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x10-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-12x10-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_12x10_KHR,f:C},"astc-12x10-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,f:C},"astc-12x12-unorm":{gl:c.GL.COMPRESSED_RGBA_ASTC_12x12_KHR,f:C},"astc-12x12-unorm-srgb":{gl:c.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,f:C},"pvrtc-rgb4unorm-webgl":{gl:c.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,f:Ut},"pvrtc-rgba4unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,f:Ut},"pvrtc-rbg2unorm-webgl":{gl:c.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,f:Ut},"pvrtc-rgba2unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,f:Ut},"etc1-rbg-unorm-webgl":{gl:c.GL.COMPRESSED_RGB_ETC1_WEBGL,f:mo},"atc-rgb-unorm-webgl":{gl:c.GL.COMPRESSED_RGB_ATC_WEBGL,f:yr},"atc-rgba-unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,f:yr},"atc-rgbai-unorm-webgl":{gl:c.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,f:yr}},Lo={[c.GL.RED]:1,[c.GL.RED_INTEGER]:1,[c.GL.RG]:2,[c.GL.RG_INTEGER]:2,[c.GL.RGB]:3,[c.GL.RGB_INTEGER]:3,[c.GL.RGBA]:4,[c.GL.RGBA_INTEGER]:4,[c.GL.DEPTH_COMPONENT]:1,[c.GL.DEPTH_STENCIL]:1,[c.GL.ALPHA]:1,[c.GL.LUMINANCE]:1,[c.GL.LUMINANCE_ALPHA]:2},Ro={[c.GL.FLOAT]:4,[c.GL.UNSIGNED_INT]:4,[c.GL.INT]:4,[c.GL.UNSIGNED_SHORT]:2,[c.GL.SHORT]:2,[c.GL.HALF_FLOAT]:2,[c.GL.BYTE]:1,[c.GL.UNSIGNED_BYTE]:1};function Tt(r,e,t){let n=xe(e),i=Se[n];if(!i||i.gl===void 0)return!1;let s=i.x||i.gl2ext;return s?Boolean(J(r,s,t)):!0}function Pn(r,e,t){return Tt(r,e,t)&&Se[e]?.renderbuffer}function xe(r){if(typeof r=="string")return r;let e=Object.entries(Se).find(([,t])=>t.gl===r);if(!e)throw new Error(`Unknown texture format ${r}`);return e[0]}function Lt(r){let t=Se[r]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${r}`);return t}function Fn(r,e,t){let n=xe(e);if(!Tt(r,n,t))return!1;try{if(Dt(n).signed)return!1}catch{return!1}return n.endsWith("32float")?Boolean(J(r,"OES_texture_float_linear, extensions",t)):n.endsWith("16float")?Boolean(J(r,"OES_texture_half_float_linear, extensions",t)):!0}function Bn(r,e,t){let n=xe(e);return!(!Tt(r,n,t)||typeof n=="number")}function ze(r){let e=xe(r),t=Lt(e),n=Dt(e);return{format:t,dataFormat:Ao(n.format,n.integer,n.normalized,t),type:n.dataType?Ot(n.dataType):c.GL.UNSIGNED_BYTE,compressed:n.compressed}}function In(r){let e=Se[r];if(!e?.attachment)throw new Error(`${r} is not a depth stencil format`);return e.attachment}function Rt(r){let e=xe(r),t=ze(e),n=Lo[t.dataFormat]||4,i=Ro[t.type]||1;return n*i}function Ao(r,e,t,n){if(n===c.GL.RGBA||n===c.GL.RGB)return n;switch(r){case"r":return e&&!t?c.GL.RED_INTEGER:c.GL.RED;case"rg":return e&&!t?c.GL.RG_INTEGER:c.GL.RG;case"rgb":return e&&!t?c.GL.RGB_INTEGER:c.GL.RGB;case"rgba":return e&&!t?c.GL.RGBA_INTEGER:c.GL.RGBA;default:return c.GL.RGBA}}var Nn={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Ht=class extends ft{gl;extensions;testedFeatures=new Set;constructor(e,t){super(),this.gl=e,this.extensions=t,J(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){for(let e of Object.keys(Nn))this.has(e)&&(yield e);for(let e of Object.keys(Wt))this.has(e)&&(yield e);return[]}has(e){return this.testedFeatures.has(e)||(this.testedFeatures.add(e),Cn(e)&&Gn(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e)}getWebGLFeature(e){let t=Nn[e];return Boolean(typeof t=="string"?J(this.gl,t,this.extensions):t)}};var ne=y(S(),1),kt=class extends lt{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(ne.GL.MAX_TEXTURE_SIZE)}get maxTextureDimension3D(){return this.getParameter(ne.GL.MAX_3D_TEXTURE_SIZE)}get maxTextureArrayLayers(){return this.getParameter(ne.GL.MAX_ARRAY_TEXTURE_LAYERS)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(ne.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS)}get maxSamplersPerShaderStage(){return this.getParameter(ne.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(ne.GL.MAX_UNIFORM_BUFFER_BINDINGS)}get maxUniformBufferBindingSize(){return this.getParameter(ne.GL.MAX_UNIFORM_BLOCK_SIZE)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(ne.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(ne.GL.MAX_VERTEX_ATTRIBS)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(ne.GL.MAX_VARYING_COMPONENTS)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};var F=y(S(),1);var G=y(S(),1);function Y(r,e,t){let i=K.attach(r).gl;if(So(e))return t(r);let{nocatch:s=!0}=e;re(i),X(i,e);let a;if(s)a=t(i),Z(i);else try{a=t(i)}finally{Z(i)}return a}function So(r){for(let e in r)return!1;return!0}var N=y(S(),1);var h=y(S(),1);function vn(r,e,t,n){if(Ne(e))return n(r);re(r.gl);try{return Kt(r,e),X(r,t),n(r)}finally{Z(r.gl)}}function wn(r,e,t){if(Ne(e))return t(r);re(r.gl);try{return Kt(r,e),t(r)}finally{Z(r.gl)}}function Kt(r,e){let t=K.attach(r),{gl:n}=t;if(e.cullMode)switch(e.cullMode){case"none":n.disable(h.GL.CULL_FACE);break;case"front":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.FRONT);break;case"back":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.BACK);break}if(e.frontFace&&n.frontFace(ye("frontFace",e.frontFace,{ccw:h.GL.CCW,cw:h.GL.CW})),e.unclippedDepth&&r.features.has("depth-clip-control")&&n.enable(h.GL.DEPTH_CLAMP_EXT),e.depthBias!==void 0&&n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0),r.features.has("provoking-vertex-webgl")){let s=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex;if(e.provokingVertex){let a=ye("provokingVertex",e.provokingVertex,{first:h.GL.FIRST_VERTEX_CONVENTION_WEBGL,last:h.GL.LAST_VERTEX_CONVENTION_WEBGL});s?.provokingVertexWEBGL(a)}}if(r.features.has("polygon-mode-webgl")){let s=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode;if(e.polygonMode){let a=ye("polygonMode",e.provokingVertex,{fill:h.GL.FILL_WEBGL,lint:h.GL.LINE_WEBGL});s?.polygonModeWEBGL(h.GL.FRONT,a),s?.polygonModeWEBGL(h.GL.BACK,a)}e.polygonOffsetLine&&n.enable(h.GL.POLYGON_OFFSET_LINE_WEBGL)}if(r.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(h.GL.CLIP_DISTANCE0_WEBGL),e.clipDistance1&&n.enable(h.GL.CLIP_DISTANCE1_WEBGL),e.clipDistance2&&n.enable(h.GL.CLIP_DISTANCE2_WEBGL),e.clipDistance3&&n.enable(h.GL.CLIP_DISTANCE3_WEBGL),e.clipDistance4&&n.enable(h.GL.CLIP_DISTANCE4_WEBGL),e.clipDistance5&&n.enable(h.GL.CLIP_DISTANCE5_WEBGL),e.clipDistance6&&n.enable(h.GL.CLIP_DISTANCE6_WEBGL),e.clipDistance7&&n.enable(h.GL.CLIP_DISTANCE7_WEBGL)),e.depthWriteEnabled!==void 0&&n.depthMask(yo("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(h.GL.DEPTH_TEST):n.disable(h.GL.DEPTH_TEST),n.depthFunc(Xt("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(h.GL.FRONT,i),n.stencilMaskSeparate(h.GL.BACK,i)}if(e.stencilReadMask&&m.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,s=Xt("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(h.GL.STENCIL_TEST):n.disable(h.GL.STENCIL_TEST),n.stencilFuncSeparate(h.GL.FRONT,s,0,i),n.stencilFuncSeparate(h.GL.BACK,s,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=Fr("stencilPassOperation",e.stencilPassOperation),s=Fr("stencilFailOperation",e.stencilFailOperation),a=Fr("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(h.GL.FRONT,s,a,i),n.stencilOpSeparate(h.GL.BACK,s,a,i)}if(e.blendColorOperation||e.blendAlphaOperation){n.enable(h.GL.BLEND);let i=Dn("blendColorOperation",e.blendColorOperation||"add"),s=Dn("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let a=Vt("blendColorSrcFactor",e.blendColorSrcFactor||"one"),u=Vt("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=Vt("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),f=Vt("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(a,u,l,f)}}function Xt(r,e){return ye(r,e,{never:h.GL.NEVER,less:h.GL.LESS,equal:h.GL.EQUAL,"less-equal":h.GL.LEQUAL,greater:h.GL.GREATER,"not-equal":h.GL.NOTEQUAL,"greater-equal":h.GL.GEQUAL,always:h.GL.ALWAYS})}function Fr(r,e){return ye(r,e,{keep:h.GL.KEEP,zero:h.GL.ZERO,replace:h.GL.REPLACE,invert:h.GL.INVERT,"increment-clamp":h.GL.INCR,"decrement-clamp":h.GL.DECR,"increment-wrap":h.GL.INCR_WRAP,"decrement-wrap":h.GL.DECR_WRAP})}function Dn(r,e){return ye(r,e,{add:h.GL.FUNC_ADD,subtract:h.GL.FUNC_SUBTRACT,"reverse-subtract":h.GL.FUNC_REVERSE_SUBTRACT,min:h.GL.MIN,max:h.GL.MAX})}function Vt(r,e){return ye(r,e,{one:h.GL.ONE,zero:h.GL.ZERO,"src-color":h.GL.SRC_COLOR,"one-minus-src-color":h.GL.ONE_MINUS_SRC_COLOR,"dst-color":h.GL.DST_COLOR,"one-minus-dst-color":h.GL.ONE_MINUS_DST_COLOR,"src-alpha":h.GL.SRC_ALPHA,"one-minus-src-alpha":h.GL.ONE_MINUS_SRC_ALPHA,"dst-alpha":h.GL.DST_ALPHA,"one-minus-dst-alpha":h.GL.ONE_MINUS_DST_ALPHA})}function xo(r,e){return`Illegal parameter ${e} for ${r}`}function ye(r,e,t){if(!(e in t))throw new Error(xo(r,e));return t[e]}function yo(r,e){return e}function Yt(r){let e={};return r.addressModeU&&(e[N.GL.TEXTURE_WRAP_S]=Br(r.addressModeU)),r.addressModeV&&(e[N.GL.TEXTURE_WRAP_T]=Br(r.addressModeV)),r.addressModeW&&(e[N.GL.TEXTURE_WRAP_R]=Br(r.addressModeW)),r.magFilter&&(e[N.GL.TEXTURE_MAG_FILTER]=On(r.magFilter)),(r.minFilter||r.mipmapFilter)&&(e[N.GL.TEXTURE_MIN_FILTER]=Co(r.minFilter||"linear",r.mipmapFilter)),r.lodMinClamp!==void 0&&(e[N.GL.TEXTURE_MIN_LOD]=r.lodMinClamp),r.lodMaxClamp!==void 0&&(e[N.GL.TEXTURE_MAX_LOD]=r.lodMaxClamp),r.type==="comparison-sampler"&&(e[N.GL.TEXTURE_COMPARE_MODE]=N.GL.COMPARE_REF_TO_TEXTURE),r.compare&&(e[N.GL.TEXTURE_COMPARE_FUNC]=Xt("compare",r.compare)),r.maxAnisotropy&&(e[N.GL.TEXTURE_MAX_ANISOTROPY_EXT]=r.maxAnisotropy),e}function Br(r){switch(r){case"clamp-to-edge":return N.GL.CLAMP_TO_EDGE;case"repeat":return N.GL.REPEAT;case"mirror-repeat":return N.GL.MIRRORED_REPEAT}}function On(r){switch(r){case"nearest":return N.GL.NEAREST;case"linear":return N.GL.LINEAR}}function Co(r,e){if(!e)return On(r);switch(r){case"nearest":return e==="nearest"?N.GL.NEAREST_MIPMAP_NEAREST:N.GL.NEAREST_MIPMAP_LINEAR;case"linear":return e==="nearest"?N.GL.LINEAR_MIPMAP_NEAREST:N.GL.LINEAR_MIPMAP_LINEAR}}var W=y(S(),1),H=class extends P{device;gl;handle;glTarget;glUsage;glIndexType=W.GL.UNSIGNED_SHORT;byteLength;bytesUsed;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;let n=typeof t=="object"?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Go(this.props.usage),this.glUsage=Po(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?W.GL.UNSIGNED_INT:W.GL.UNSIGNED_SHORT,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}_initWithData(e,t=0,n=e.byteLength+t){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){A(e>=0);let t=e;e===0&&(t=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,t=0){let s=W.GL.COPY_WRITE_BUFFER;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,t,e),this.gl.bindBuffer(s,null),this._setDebugData(e,t,e.byteLength)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let n=new Uint8Array(t),i=0;return this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,this.handle),this.gl.getBufferSubData(W.GL.COPY_READ_BUFFER,e,n,i,t),this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,null),this._setDebugData(n,e,t),n}};function Go(r){return r&P.INDEX?W.GL.ELEMENT_ARRAY_BUFFER:r&P.VERTEX?W.GL.ARRAY_BUFFER:r&P.UNIFORM?W.GL.UNIFORM_BUFFER:W.GL.ARRAY_BUFFER}function Po(r){return r&P.INDEX?W.GL.STATIC_DRAW:r&P.VERTEX?W.GL.STATIC_DRAW:r&P.UNIFORM?W.GL.DYNAMIC_DRAW:W.GL.STATIC_DRAW}var Ir=y(S(),1);var le=class extends we{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=Yt(t),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[t,n]of Object.entries(e)){let i=Number(t);switch(i){case Ir.GL.TEXTURE_MIN_LOD:case Ir.GL.TEXTURE_MAX_LOD:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var ae=class extends De{device;gl;handle;texture;constructor(e,t){super(e,{...I.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}};var Fo={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},$t=class extends I{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,t){super(e,{...Fo,format:"rgba8unorm",...t}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=G.GL.RGBA,this.target=Bo(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Lr(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(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let t=e.data;if(t instanceof Promise)return t.then(ie=>this.initialize(Object.assign({},e,{pixels:ie,data:ie}))),this;let n=typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement;if(n&&t.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,t.addEventListener("loadeddata",()=>this.initialize(e)),this;let{parameters:i={}}=e,{pixels:s=null,pixelStore:a={},textureUnit:u=void 0,mipmaps:l=!0}=e;t||(t=s);let{width:f,height:d,dataFormat:b,type:g,compressed:L=!1}=e,{depth:R=0}=e,D=Lt(e.format);return{width:f,height:d,compressed:L,dataFormat:b,type:g}=this._deduceParameters({format:e.format,type:g,dataFormat:b,compressed:L,data:t,width:f,height:d}),this.width=f,this.height=d,this.glFormat=D,this.type=g,this.dataFormat=b,this.textureUnit=u,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(G.GL.TEXTURE0+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=l,this.setImageData({data:t,width:f,height:d,depth:R,format:D,type:g,dataFormat:b,parameters:a,compressed:L}),this.setSampler(e.sampler),this._setSamplerParameters(i),this.view=new ae(this.device,{...this.props,texture:this}),l&&this.generateMipmap(),n&&(this._video={video:t,parameters:i,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}initializeCube(e){let{mipmaps:t=!0,parameters:n={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(n)}),this}setSampler(e={}){let t;e instanceof le?(this.sampler=e,t=e.props):(this.sampler=new le(this.device,e),t=e);let n=Yt(t);return this._setSamplerParameters(n),this}resize(e){let{height:t,width:n,mipmaps:i=!1}=e;return n!==this.width||t!==this.height?this.initialize({width:n,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:e,parameters:t,lastTime:n}=this._video;if(n===e.currentTime||e.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:e,parameters:t}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=e.currentTime}}generateMipmap(e={}){return this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),Y(this.gl,e,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:t=this.target,pixels:n=null,level:i=0,glFormat:s=this.glFormat,offset:a=0,parameters:u={}}=e,{data:l=null,type:f=this.type,width:d=this.width,height:b=this.height,dataFormat:g=this.dataFormat,compressed:L=!1}=e;l||(l=n),{type:f,dataFormat:g,compressed:L,width:d,height:b}=this._deduceParameters({format:this.props.format,type:f,dataFormat:g,compressed:L,data:l,width:d,height:b});let{gl:R}=this;R.bindTexture(this.target,this.handle);let D=null;if({data:l,dataType:D}=this._getDataType({data:l,compressed:L}),Y(this.gl,u,()=>{switch(D){case"null":R.texImage2D(t,i,s,d,b,0,g,f,l);break;case"typed-array":R.texImage2D(t,i,s,d,b,0,g,f,l,a);break;case"buffer":this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,l.handle||l),this.device.gl.texImage2D(t,i,s,d,b,0,g,f,a),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null);break;case"browser-object":R.texImage2D(t,i,s,d,b,0,g,f,l);break;case"compressed":for(let[ie,de]of l.entries())R.compressedTexImage2D(t,ie,de.format,de.width,de.height,0,de.data);break;default:A(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let ie=Rt(this.props.format);this.trackAllocatedMemory(this.width*this.height*ie,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:t=null,data:n=null,x:i=0,y:s=0,width:a=this.width,height:u=this.height,level:l=0,glFormat:f=this.glFormat,type:d=this.type,dataFormat:b=this.dataFormat,compressed:g=!1,offset:L=0,parameters:R={}}){if({type:d,dataFormat:b,compressed:g,width:a,height:u}=this._deduceParameters({format:this.props.format,type:d,dataFormat:b,compressed:g,data:n,width:a,height:u}),A(this.depth===1,"texSubImage not supported for 3D textures"),n||(n=t),n&&n.data){let D=n;n=D.data,a=D.shape[0],u=D.shape[1]}n instanceof H&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),Y(this.gl,R,()=>{g?this.gl.compressedTexSubImage2D(e,l,i,s,a,u,f,n):n===null?this.gl.texSubImage2D(e,l,i,s,a,u,b,d,null):ArrayBuffer.isView(n)?this.gl.texSubImage2D(e,l,i,s,a,u,b,d,n,L):typeof WebGLBuffer<"u"&&n instanceof WebGLBuffer?(this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,n),this.device.gl.texSubImage2D(e,l,i,s,a,u,b,d,L),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null)):this.device.gl.texSubImage2D(e,l,i,s,a,u,b,d,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return m.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(G.GL.ACTIVE_TEXTURE)-G.GL.TEXTURE0}bind(e=this.textureUnit){let{gl:t}=this;return e!==void 0&&(this.textureUnit=e,t.activeTexture(t.TEXTURE0+e)),t.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:t}=this;return e!==void 0&&(this.textureUnit=e,t.activeTexture(t.TEXTURE0+e)),t.bindTexture(this.target,null),e}_getDataType({data:e,compressed:t=!1}){return t?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof H?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:t,data:n}=e,{width:i,height:s,dataFormat:a,type:u,compressed:l}=e,f=ze(t);return a=a||f.dataFormat,u=u||f.type,l=l||f.compressed,{width:i,height:s}=this._deduceImageSize(n,i,s),{dataFormat:a,type:u,compressed:l,width:i,height:s,format:t,data:n}}_deduceImageSize(e,t,n){let i;return typeof ImageData<"u"&&e instanceof ImageData?i={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?i={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?i={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?i={width:e.videoWidth,height:e.videoHeight}:e?i={width:t,height:n}:i={width:t>=0?t:1,height:n>=0?n:1},A(i,"Could not deduced texture size"),A(t===void 0||i.width===t,"Deduced texture width does not match supplied width"),A(n===void 0||i.height===n,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(e){let{gl:t}=this,{width:n,height:i,pixels:s,data:a,format:u=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,f=s||a,d=await Promise.all($t.FACES.map(b=>{let g=f[b];return Promise.all(Array.isArray(g)?g:[g])}));this.bind(),$t.FACES.forEach((b,g)=>{d[g].length>1&&this.props.mipmaps!==!1&&m.warn(`${this.id} has mipmap and multiple LODs.`)(),d[g].forEach((L,R)=>{n&&i?t.texImage2D(b,R,u,n,i,0,u,l,L):t.texImage2D(b,R,u,u,l,L)})}),this.unbind()}setImageDataForFace(e){let{face:t,width:n,height:i,pixels:s,data:a,format:u=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,{gl:f}=this,d=s||a;return this.bind(),d instanceof Promise?d.then(b=>this.setImageDataForFace(Object.assign({},e,{face:t,data:b,pixels:b}))):this.width||this.height?f.texImage2D(t,0,u,n,i,0,u,l,d):f.texImage2D(t,0,u,u,l,d),this}setImageData3D(e){let{level:t=0,dataFormat:n,format:i,type:s,width:a,height:u,depth:l=1,offset:f=0,data:d,parameters:b={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let g=ze(i);if(Y(this.gl,b,()=>{ArrayBuffer.isView(d)&&this.gl.texImage3D(this.target,t,g.format,a,u,l,0,g.dataFormat,g.type,d),d instanceof H&&(this.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,d.handle),this.gl.texImage3D(this.target,t,n,a,u,l,0,i,s,f))}),d&&d.byteLength)this.trackAllocatedMemory(d.byteLength,"Texture");else{let L=Rt(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*L,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Ne(e)){Io(e),this.gl.bindTexture(this.target,this.handle);for(let[t,n]of Object.entries(e)){let i=Number(t),s=n;switch(i){case G.GL.TEXTURE_MIN_LOD:case G.GL.TEXTURE_MAX_LOD:this.gl.texParameterf(this.target,i,s);break;default:this.gl.texParameteri(this.target,i,s);break}}this.gl.bindTexture(this.target,null)}}},U=$t;E(U,"FACES",[G.GL.TEXTURE_CUBE_MAP_POSITIVE_X,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z]);function Bo(r){switch(r.dimension){case"2d":return G.GL.TEXTURE_2D;case"cube":return G.GL.TEXTURE_CUBE_MAP;case"2d-array":return G.GL.TEXTURE_2D_ARRAY;case"3d":return G.GL.TEXTURE_3D;case"1d":case"cube-array":default:throw new Error(r.dimension)}}function Io(r){m.log(1,"texture sampler parameters",r)()}var Qe=y(S(),1);var je="Resource subclass must define virtual methods",Ce=class extends _{device;gl;gl2;_handle;_bound=!1;byteLength=0;constructor(e,t,n){super(e,t,n),this.device=K.attach(e);let i=this.device.gl,{id:s}=t||{};this.gl=i,this.gl2=i,this.id=s||te(this.constructor.name),this._handle=t?.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({deleteChildren:e=!1}={}){let t=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,t&&e&&t.filter(Boolean).forEach(n=>n.destroy()),this}bind(e=this.handle){if(typeof e!="function")return this._bindHandle(e),this;let t;return this._bound?t=e():(this._bindHandle(this.handle),this._bound=!0,t=e(),this._bound=!1,this._bindHandle(null)),t}unbind(){this.bind(null)}stubRemovedMethods(e,t,n){return _r(this,e,t,n)}initialize(e){}_createHandle(){throw new Error(je)}_deleteHandle(){throw new Error(je)}_bindHandle(e){throw new Error(je)}_getOptsFromHandle(){throw new Error(je)}_getParameter(e,t){throw new Error(je)}_setParameter(e,t){throw new Error(je)}};var Nr=class extends Ce{get[Symbol.toStringTag](){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(){}glFormat;static isTextureFormatSupported(e,t){return Pn(e.gl,t,e._extensions)}constructor(e,t){if(typeof t.format=="number")throw new Error("Renderbuffer");super(e,t,Nr.defaultProps),this.glFormat=Lt(this.props.format),this._initialize(this.props)}resize(e){(e.width!==this.width||e.height!==this.height)&&(Object.assign(this.props,{...e,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(e){let{format:t,width:n,height:i,samples:s}=e;A(t,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(Qe.GL.RENDERBUFFER,this.handle),s!==0?this.gl.renderbufferStorageMultisample(Qe.GL.RENDERBUFFER,s,this.glFormat,n,i):this.gl.renderbufferStorage(Qe.GL.RENDERBUFFER,this.glFormat,n,i),this.gl.bindRenderbuffer(Qe.GL.RENDERBUFFER,null),this.trackAllocatedMemory(n*i*(s||1)*Rt(this.glFormat))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(e){this.gl.bindRenderbuffer(Qe.GL.RENDERBUFFER,e)}},Ee=Nr;E(Ee,"defaultProps",{id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0});var ee=class extends ge{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,t){super(e,t);let n=t.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(F.GL.FRAMEBUFFER,this.handle);for(let i=0;i<this.colorAttachments.length;++i){let s=this.colorAttachments[i],a=F.GL.COLOR_ATTACHMENT0+i;s&&this._attachOne(a,s)}if(this.depthStencilAttachment&&this._attachOne(In(this.depthStencilAttachment.props.format),this.depthStencilAttachment),t.check!==!1){let i=this.gl.checkFramebufferStatus(F.GL.FRAMEBUFFER);if(i!==F.GL.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer ${Do(i)}`)}this.gl.bindFramebuffer(F.GL.FRAMEBUFFER,null)}}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}createDepthStencilTexture(e){return new Ee(this.device,{id:`${this.id}-depth-stencil`,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;e===void 0&&(e=this.gl.drawingBufferWidth),t===void 0&&(t=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.texture.resize({width:e,height:t});return this.depthStencilAttachment&&this.depthStencilAttachment.texture.resize({width:e,height:t}),this}_attachOne(e,t){if(t instanceof Ee)return this._attachWEBGLRenderbuffer(e,t),t;if(Array.isArray(t)){let[n,i=0,s=0]=t;return this._attachTexture(e,n,i,s),n}else{if(t instanceof U)return this._attachTexture(e,t,0,0),t;if(t instanceof ae){let n=t;return this._attachTexture(e,n.texture,n.props.baseMipLevel,n.props.baseArrayLayer),t.texture}}throw new Error("attach")}_attachWEBGLRenderbuffer(e,t){this.gl.framebufferRenderbuffer(F.GL.FRAMEBUFFER,e,F.GL.RENDERBUFFER,t.handle)}_attachTexture(e,t,n,i){let{gl:s}=this.device;switch(s.bindTexture(t.target,t.handle),t.target){case F.GL.TEXTURE_2D_ARRAY:case F.GL.TEXTURE_3D:s.framebufferTextureLayer(F.GL.FRAMEBUFFER,e,t.target,i,n);break;case F.GL.TEXTURE_CUBE_MAP:let a=No(n);s.framebufferTexture2D(F.GL.FRAMEBUFFER,e,a,t.handle,i);break;case F.GL.TEXTURE_2D:s.framebufferTexture2D(F.GL.FRAMEBUFFER,e,F.GL.TEXTURE_2D,t.handle,i);break;default:A(!1,"Illegal texture type")}s.bindTexture(t.target,null)}};function No(r){return r<F.GL.TEXTURE_CUBE_MAP_POSITIVE_X?r+F.GL.TEXTURE_CUBE_MAP_POSITIVE_X:r}function Do(r){switch(r){case F.GL.FRAMEBUFFER_COMPLETE:return"success";case F.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"Mismatched attachments";case F.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"No attachments";case F.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"Height/width mismatch";case F.GL.FRAMEBUFFER_UNSUPPORTED:return"Unsupported or split attachments";case F.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:return"Samples mismatch";default:return`${r}`}}var qe=class extends pe{device;presentationSize;_framebuffer=null;constructor(e,t){super(t),this.device=e,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new ee(this.device,{handle:null}),this._framebuffer}update(){let e=this.getPixelSize();(e[0]!==this.presentationSize[0]||e[1]!==this.presentationSize[1])&&(this.presentationSize=e,this.resize())}resize(e){if(this.device.gl&&this.canvas){let t=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(t,e);return}}commit(){}};var vo={spector:m.get("spector")||m.get("inspect")},wo="https://spectorcdn.babylonjs.com/spector.bundle.js",Oo=1,$=null,Un=!1;async function Mn(r){if(!globalThis.SPECTOR)try{await dt(wo)}catch(e){m.warn(String(e))}}function Wn(r){if(r={...vo,...r},!r?.spector||(!$&&globalThis.SPECTOR&&(m.probe(Oo,"SPECTOR found and initialized")(),$=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=$)),!$))return null;if(Un||(Un=!0,$.spyCanvases(),$?.onCaptureStarted.add(e=>m.info("Spector capture started:",e)()),$?.onCapture.add(e=>{m.info("Spector capture complete:",e)(),$?.getResultUI(),$?.resultView.display(),$?.resultView.addCapture(e)})),r?.canvas){if(typeof r.spector=="string"&&r.spector!==r.canvas.id)return $;$?.startCapture(r?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{m.info("Spector capture stopped after 2 seconds")(),$?.stopCapture()})}return $}var At=y(S(),1);var Uo="https://unpkg.com/webgl-debug@2.0.1/index.js";function Hn(r){return r.luma=r.luma||{},r.luma}async function kn(){v()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await dt(Uo))}function Vn(r,e={}){return r?e.debug?Wo(r,e):Mo(r):null}function Mo(r){let e=Hn(r);return e.realContext?e.realContext:r}function Wo(r,e){if(!globalThis.WebGLDebugUtils)return m.warn("webgl-debug not loaded")(),r;let t=Hn(r);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...At.GL,...r});let n=globalThis.WebGLDebugUtils.makeDebugContext(r,Ho.bind(null,e),ko.bind(null,e));for(let a in At.GL)!(a in n)&&typeof At.GL[a]=="number"&&(n[a]=At.GL[a]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(r)),Object.setPrototypeOf(i,n);let s=Object.create(i);return t.realContext=r,t.debugContext=s,s.debug=!0,s}function Dr(r,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${r}(${t})`}function Ho(r,e,t,n){n=Array.from(n).map(u=>u===void 0?"undefined":u);let i=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),a=`${i} in gl.${t}(${s})`;m.error(a)();debugger;if(r.throwOnError)throw new Error(a)}function ko(r,e,t){let n="";if(m.level>=1&&(n=Dr(e,t),m.log(1,n)()),r.break&&r.break.length>0&&(n=n||Dr(e,t),r.break.every(s=>n.indexOf(s)!==-1)))debugger;for(let i of t)if(i===void 0){if(n=n||Dr(e,t),r.throwOnError)throw new Error(`Undefined argument: ${n}`);m.error(`Undefined argument: ${n}`)();debugger}}var St=y(S(),1);function Kn(r){let e=r.split(/\r?\n/),t=[];for(let n of e){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[b,g]=i;t.push({message:g.trim(),type:Xn(b),lineNum:0,linePos:0});continue}let[s,a,u,...l]=i,f=parseInt(u,10);isNaN(f)&&(f=0);let d=parseInt(a,10);isNaN(d)&&(d=0),t.push({message:l.join(":").trim(),type:Xn(s),lineNum:f,linePos:d})}return t}function Xn(r){let e=["warning","error","info"],t=r.toLowerCase();return e.includes(t)?t:"info"}var Ze=class extends ve{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(St.GL.VERTEX_SHADER);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(St.GL.FRAGMENT_SHADER);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 await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return Kn(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(i=>i.startsWith("#version ")?i:`#version 100
17
- ${i}`)(e);let{gl:n}=this.device;if(n.shaderSource(this.handle,e),n.compileShader(this.handle),m.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);this.debugShader();return}m.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),m.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,St.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,St.GL.COMPILE_STATUS)?"success":"error"}};var wr=y(S(),1);var Vo=256,Xo=1024,Ko=16384,vr=6144,Je=class extends Ue{device;glParameters;constructor(e,t){super(e,t),this.device=e,re(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Z(this.device.gl),this.props.framebuffer&&X(this.device,{framebuffer:null})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let t={};this.props.framebuffer&&(t.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[wr.GL.RASTERIZER_DISCARD]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),t.scissorTest=Boolean(e.scissorRect),e.scissorRect&&(t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[wr.GL.STENCIL_REF]=e.stencilReference),this.glParameters=t,X(this.device,t)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColor!==!1&&(t|=Ko,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=Vo,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=Xo,e.clearStencil=this.props.clearStencil),t!==0&&Y(this.device,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Y(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int32Array:this.device.gl.clearBufferiv(vr,e,t);break;case Uint32Array:this.device.gl.clearBufferuiv(vr,e,t);break;case Float32Array:default:this.device.gl.clearBufferfv(vr,e,t);break}})}};var Ge=y(S(),1);var x=y(S(),1);var et=y(S(),1);var O=y(S(),1),Yo="Failed to deduce GL constant from typed array";function Yn(r){switch(ArrayBuffer.isView(r)?r.constructor:r){case Float32Array:return O.GL.FLOAT;case Uint16Array:return O.GL.UNSIGNED_SHORT;case Uint32Array:return O.GL.UNSIGNED_INT;case Uint8Array:return O.GL.UNSIGNED_BYTE;case Uint8ClampedArray:return O.GL.UNSIGNED_BYTE;case Int8Array:return O.GL.BYTE;case Int16Array:return O.GL.SHORT;case Int32Array:return O.GL.INT;default:throw new Error(Yo)}}function xt(r,e){let{clamped:t=!0}=e||{};switch(r){case O.GL.FLOAT:return Float32Array;case O.GL.UNSIGNED_SHORT:case O.GL.UNSIGNED_SHORT_5_6_5:case O.GL.UNSIGNED_SHORT_4_4_4_4:case O.GL.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;case O.GL.UNSIGNED_INT:return Uint32Array;case O.GL.UNSIGNED_BYTE:return t?Uint8ClampedArray:Uint8Array;case O.GL.BYTE:return Int8Array;case O.GL.SHORT:return Int16Array;case O.GL.INT:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var $o={offset:0,stride:0,type:et.GL.FLOAT,size:1,divisor:0,normalized:!1,integer:!1},zo={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},ue=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return xt(e.type||et.GL.FLOAT).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return A(e.size),xt(e.type||et.GL.FLOAT).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new ue($o,...e)}constructor(...e){e.forEach(t=>this._assign(t)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return ue.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return ue.getBytesPerVertex(this)}_assign(e={}){return e=Tr("Accessor",e,zo),e.type!==void 0&&(this.type=e.type,(e.type===et.GL.INT||e.type===et.GL.UNSIGNED_INT)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.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}};var p=y(S(),1);function $n(r){return jo.includes(r)}var jo=[p.GL.SAMPLER_2D,p.GL.SAMPLER_CUBE,p.GL.SAMPLER_3D,p.GL.SAMPLER_2D_SHADOW,p.GL.SAMPLER_2D_ARRAY,p.GL.SAMPLER_2D_ARRAY_SHADOW,p.GL.SAMPLER_CUBE_SHADOW,p.GL.INT_SAMPLER_2D,p.GL.INT_SAMPLER_3D,p.GL.INT_SAMPLER_CUBE,p.GL.INT_SAMPLER_2D_ARRAY,p.GL.UNSIGNED_INT_SAMPLER_2D,p.GL.UNSIGNED_INT_SAMPLER_3D,p.GL.UNSIGNED_INT_SAMPLER_CUBE,p.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY],zn={[p.GL.FLOAT]:[p.GL.FLOAT,1,"float","f32","float32"],[p.GL.FLOAT_VEC2]:[p.GL.FLOAT,2,"vec2","vec2<f32>","float32x2"],[p.GL.FLOAT_VEC3]:[p.GL.FLOAT,3,"vec3","vec3<f32>","float32x3"],[p.GL.FLOAT_VEC4]:[p.GL.FLOAT,4,"vec4","vec4<f32>","float32x4"],[p.GL.INT]:[p.GL.INT,1,"int","i32","sint32"],[p.GL.INT_VEC2]:[p.GL.INT,2,"ivec2","vec2<i32>","sint32x2"],[p.GL.INT_VEC3]:[p.GL.INT,3,"ivec3","vec3<i32>","sint32x3"],[p.GL.INT_VEC4]:[p.GL.INT,4,"ivec4","vec4<i32>","sint32x4"],[p.GL.UNSIGNED_INT]:[p.GL.UNSIGNED_INT,1,"uint","u32","uint32"],[p.GL.UNSIGNED_INT_VEC2]:[p.GL.UNSIGNED_INT,2,"uvec2","vec2<u32>","uint32x2"],[p.GL.UNSIGNED_INT_VEC3]:[p.GL.UNSIGNED_INT,3,"uvec3","vec3<u32>","uint32x3"],[p.GL.UNSIGNED_INT_VEC4]:[p.GL.UNSIGNED_INT,4,"uvec4","vec4<u32>","uint32x4"],[p.GL.BOOL]:[p.GL.FLOAT,1,"bool","f32","float32"],[p.GL.BOOL_VEC2]:[p.GL.FLOAT,2,"bvec2","vec2<f32>","float32x2"],[p.GL.BOOL_VEC3]:[p.GL.FLOAT,3,"bvec3","vec3<f32>","float32x3"],[p.GL.BOOL_VEC4]:[p.GL.FLOAT,4,"bvec4","vec4<f32>","float32x4"],[p.GL.FLOAT_MAT2]:[p.GL.FLOAT,8,"mat2","mat2x2<f32>"],[p.GL.FLOAT_MAT2x3]:[p.GL.FLOAT,8,"mat2x3","mat2x3<f32>"],[p.GL.FLOAT_MAT2x4]:[p.GL.FLOAT,8,"mat2x4","mat2x4<f32>"],[p.GL.FLOAT_MAT3x2]:[p.GL.FLOAT,12,"mat3x2","mat3x2<f32>"],[p.GL.FLOAT_MAT3]:[p.GL.FLOAT,12,"mat3","mat3x3<f32>"],[p.GL.FLOAT_MAT3x4]:[p.GL.FLOAT,12,"mat3x4","mat3x4<f32>"],[p.GL.FLOAT_MAT4x2]:[p.GL.FLOAT,16,"mat4x2","mat4x2<f32>"],[p.GL.FLOAT_MAT4x3]:[p.GL.FLOAT,16,"mat4x3","mat4x3<f32>"],[p.GL.FLOAT_MAT4]:[p.GL.FLOAT,16,"mat4","mat4x4<f32>"]};function Or(r){let e=zn[r];if(!e)throw new Error("uniform");let[t,n,,i]=e;return{format:i,components:n,glType:t}}function jn(r){let e=zn[r];if(!e)throw new Error("attribute");let[,t,,n,i]=e;return{attributeType:n,vertexFormat:i,components:t}}function zt(r,e){let t={attributes:[],bindings:[]};t.attributes=Qo(r,e);let n=Jo(r,e);for(let u of n){let l=u.uniforms.map(f=>({name:f.name,format:f.format,byteOffset:f.byteOffset,byteStride:f.byteStride,arrayLength:f.arrayLength}));t.bindings.push({type:"uniform",name:u.name,location:u.location,visibility:(u.vertex?1:0)&(u.fragment?2:0),minBindingSize:u.byteLength,uniforms:l})}let i=Zo(r,e),s=0;for(let u of i)if($n(u.type)){let{viewDimension:l,sampleType:f}=ts(u.type);t.bindings.push({type:"texture",name:u.name,location:s,viewDimension:l,sampleType:f}),u.textureUnit=s,s+=1}i.length&&(t.uniforms=i);let a=qo(r,e);return a?.length&&(t.varyings=a),t}function Qo(r,e){let t=[],n=r.getProgramParameter(e,r.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=r.getActiveAttrib(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:u}=s,l=r.getAttribLocation(e,a);if(l>=0){let{attributeType:f}=jn(u),d=/instance/i.test(a)?"instance":"vertex";t.push({name:a,location:l,stepMode:d,type:f})}}return t.sort((i,s)=>i.location-s.location),t}function qo(r,e){let t=[],n=r.getProgramParameter(e,x.GL.TRANSFORM_FEEDBACK_VARYINGS);for(let i=0;i<n;i++){let s=r.getTransformFeedbackVarying(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:u,size:l}=s,{glType:f,components:d}=Or(u),b=new ue({type:f,size:l*d}),g={location:i,name:a,accessor:b};t.push(g)}return t.sort((i,s)=>i.location-s.location),t}function Zo(r,e){let t=[],n=r.getProgramParameter(e,x.GL.ACTIVE_UNIFORMS);for(let i=0;i<n;i++){let s=r.getActiveUniform(e,i);if(!s)throw new Error("activeInfo");let{name:a,size:u,type:l}=s,{name:f,isArray:d}=rs(a),b=r.getUniformLocation(e,f),g={location:b,name:f,size:u,type:l,isArray:d};if(t.push(g),g.size>1)for(let L=0;L<g.size;L++){let R=`${f}[${L}]`;b=r.getUniformLocation(e,R);let D={...g,name:R,location:b};t.push(D)}}return t}function Jo(r,e){let t=(s,a)=>r.getActiveUniformBlockParameter(e,s,a),n=[],i=r.getProgramParameter(e,x.GL.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){let a={name:r.getActiveUniformBlockName(e,s)||"",location:t(s,x.GL.UNIFORM_BLOCK_BINDING),byteLength:t(s,x.GL.UNIFORM_BLOCK_DATA_SIZE),vertex:t(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),fragment:t(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),uniformCount:t(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),uniforms:[]},u=t(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)||[],l=r.getActiveUniforms(e,u,x.GL.UNIFORM_TYPE),f=r.getActiveUniforms(e,u,x.GL.UNIFORM_SIZE),d=r.getActiveUniforms(e,u,x.GL.UNIFORM_OFFSET),b=r.getActiveUniforms(e,u,x.GL.UNIFORM_ARRAY_STRIDE);for(let g=0;g<a.uniformCount;++g){let L=r.getActiveUniform(e,u[g]);if(!L)throw new Error("activeInfo");a.uniforms.push({name:L.name,format:Or(l[g]).format,type:l[g],arrayLength:f[g],byteOffset:d[g],byteStride:b[g]})}n.push(a)}return n.sort((s,a)=>s.location-a.location),n}var es={[x.GL.SAMPLER_2D]:["2d","float"],[x.GL.SAMPLER_CUBE]:["cube","float"],[x.GL.SAMPLER_3D]:["3d","float"],[x.GL.SAMPLER_2D_SHADOW]:["3d","depth"],[x.GL.SAMPLER_2D_ARRAY]:["2d-array","float"],[x.GL.SAMPLER_2D_ARRAY_SHADOW]:["2d-array","depth"],[x.GL.SAMPLER_CUBE_SHADOW]:["cube","float"],[x.GL.INT_SAMPLER_2D]:["2d","sint"],[x.GL.INT_SAMPLER_3D]:["3d","sint"],[x.GL.INT_SAMPLER_CUBE]:["cube","sint"],[x.GL.INT_SAMPLER_2D_ARRAY]:["2d-array","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D]:["2d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_3D]:["3d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_CUBE]:["cube","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]:["2d-array","uint"]};function ts(r){let e=es[r];if(!e)throw new Error("sampler");let[t,n]=e;return{viewDimension:t,sampleType:n}}function rs(r){if(r[r.length-1]!=="]")return{name:r,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(r);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${r}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}var T=y(S(),1);function Qn(r,e,t,n){let i=r,s=n;s===!0&&(s=1),s===!1&&(s=0);let a=typeof s=="number"?[s]:s;switch(t){case T.GL.SAMPLER_2D:case T.GL.SAMPLER_CUBE:case T.GL.SAMPLER_3D:case T.GL.SAMPLER_2D_SHADOW:case T.GL.SAMPLER_2D_ARRAY:case T.GL.SAMPLER_2D_ARRAY_SHADOW:case T.GL.SAMPLER_CUBE_SHADOW:case T.GL.INT_SAMPLER_2D:case T.GL.INT_SAMPLER_3D:case T.GL.INT_SAMPLER_CUBE:case T.GL.INT_SAMPLER_2D_ARRAY:case T.GL.UNSIGNED_INT_SAMPLER_2D:case T.GL.UNSIGNED_INT_SAMPLER_3D:case T.GL.UNSIGNED_INT_SAMPLER_CUBE:case T.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof n!="number")throw new Error("samplers must be set to integers");return r.uniform1i(e,n);case T.GL.FLOAT:return r.uniform1fv(e,a);case T.GL.FLOAT_VEC2:return r.uniform2fv(e,a);case T.GL.FLOAT_VEC3:return r.uniform3fv(e,a);case T.GL.FLOAT_VEC4:return r.uniform4fv(e,a);case T.GL.INT:return r.uniform1iv(e,a);case T.GL.INT_VEC2:return r.uniform2iv(e,a);case T.GL.INT_VEC3:return r.uniform3iv(e,a);case T.GL.INT_VEC4:return r.uniform4iv(e,a);case T.GL.BOOL:return r.uniform1iv(e,a);case T.GL.BOOL_VEC2:return r.uniform2iv(e,a);case T.GL.BOOL_VEC3:return r.uniform3iv(e,a);case T.GL.BOOL_VEC4:return r.uniform4iv(e,a);case T.GL.UNSIGNED_INT:return i.uniform1uiv(e,a,1);case T.GL.UNSIGNED_INT_VEC2:return i.uniform2uiv(e,a,2);case T.GL.UNSIGNED_INT_VEC3:return i.uniform3uiv(e,a,3);case T.GL.UNSIGNED_INT_VEC4:return i.uniform4uiv(e,a,4);case T.GL.FLOAT_MAT2:return r.uniformMatrix2fv(e,!1,a);case T.GL.FLOAT_MAT3:return r.uniformMatrix3fv(e,!1,a);case T.GL.FLOAT_MAT4:return r.uniformMatrix4fv(e,!1,a);case T.GL.FLOAT_MAT2x3:return i.uniformMatrix2x3fv(e,!1,a);case T.GL.FLOAT_MAT2x4:return i.uniformMatrix2x4fv(e,!1,a);case T.GL.FLOAT_MAT3x2:return i.uniformMatrix3x2fv(e,!1,a);case T.GL.FLOAT_MAT3x4:return i.uniformMatrix3x4fv(e,!1,a);case T.GL.FLOAT_MAT4x2:return i.uniformMatrix4x2fv(e,!1,a);case T.GL.FLOAT_MAT4x3:return i.uniformMatrix4x3fv(e,!1,a)}throw new Error("Illegal uniform")}var k=y(S(),1);function qn(r){switch(r){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINE_STRIP;case"line-loop-webgl":return k.GL.LINE_LOOP;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLE_STRIP;case"triangle-fan-webgl":return k.GL.TRIANGLE_FAN;default:throw new Error(r)}}function Zn(r){switch(r){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINES;case"line-loop-webgl":return k.GL.LINES;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLES;case"triangle-fan-webgl":return k.GL.TRIANGLES;default:throw new Error(r)}}var Jn=4,tt=class extends Oe{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=t.vs,this.fs=t.fs;let{varyings:n,bufferMode:i=Ge.GL.SEPARATE_ATTRIBS}=t;switch(n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),m.time(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=zt(this.device.gl,this.handle),m.timeEnd(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=dr(this.introspectedLayout,t.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":m.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(e){for(let[t,n]of Object.entries(e)){let i=this.shaderLayout.bindings.find(s=>s.name===t)||this.shaderLayout.bindings.find(s=>s.name===`${t}Uniforms`);if(!i){let s=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");m.warn(`Unknown binding "${t}" in render pipeline "${this.id}", expected one of ${s}`)();continue}switch(n||m.warn(`Unsetting binding "${t}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(n instanceof H)&&!(n.buffer instanceof H))throw new Error("buffer value");break;case"texture":if(!(n instanceof ae||n instanceof U||n instanceof ee))throw new Error("texture value");break;case"sampler":m.warn(`Ignoring sampler ${t}`)();break;default:throw new Error(i.type)}this.bindings[t]=n}}draw(e){if(this.linkStatus!=="success")return!1;let{renderPass:t,vertexArray:n,vertexCount:i,instanceCount:s,firstVertex:a=0,transformFeedback:u}=e,l=qn(this.props.topology),f=Boolean(n.indexBuffer),d=n.indexBuffer?.glIndexType,b=Number(s)>0;if(!this._areTexturesRenderable()||i===0)return!1;this.device.gl.useProgram(this.handle),n.bindBeforeRender(t),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let g=t;return vn(this.device,this.props.parameters,g.glParameters,()=>{f&&b?this.device.gl.drawElementsInstanced(l,i||0,d,a,s||0):f?this.device.gl.drawElements(l,i||0,d,a):b?this.device.gl.drawArraysInstanced(l,a,i||0,s||0):this.device.gl.drawArrays(l,a,i||0),u&&u.end()}),n.unbindAfterRender(t),!0}setUniformsWebGL(e){let{bindings:t}=br(e);Object.keys(t).forEach(n=>{m.warn(`Unsupported value "${JSON.stringify(t[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),m.time(Jn,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),m.timeEnd(Jn,`linkProgram for ${this.id}`)(),m.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}m.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),m.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,e.LINK_STATUS)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,e.VALIDATE_STATUS)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,Ge.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,t]of Object.entries(this.bindings))t instanceof U&&(t.update(),e=e&&t.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let t=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:a}=i,u=e.getUniformBlockIndex(this.handle,a);if(u===Ge.GL.INVALID_INDEX)throw new Error(`Invalid uniform block name ${a}`);e.uniformBlockBinding(this.handle,n,u),s instanceof H?e.bindBufferBase(Ge.GL.UNIFORM_BUFFER,n,s.handle):e.bindBufferRange(Ge.GL.UNIFORM_BUFFER,n,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),n+=1;break;case"texture":if(!(s instanceof ae||s instanceof U||s instanceof ee))throw new Error("texture");let l;if(s instanceof ae)l=s.texture;else if(s instanceof U)l=s;else if(s instanceof ee&&s.colorAttachments[0]instanceof U)m.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=s.colorAttachments[0];else throw new Error("No texture");e.activeTexture(Ge.GL.TEXTURE0+t),e.bindTexture(l.target,l.handle),t+=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 e of this.shaderLayout.uniforms||[]){let{name:t,location:n,type:i,textureUnit:s}=e,a=this.uniforms[t]??s;a!==void 0&&Qn(this.device.gl,n,i,a)}}};var Q=y(S(),1);var jt=class extends We{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":ns(this.device,t.options);break;case"copy-buffer-to-texture":is(this.device,t.options);break;case"copy-texture-to-buffer":os(this.device,t.options);break;case"copy-texture-to-texture":ss(this.device,t.options);break}}};function ns(r,e){let t=e.source,n=e.destination;r.gl.bindBuffer(Q.GL.COPY_READ_BUFFER,t.handle),r.gl.bindBuffer(Q.GL.COPY_WRITE_BUFFER,n.handle),r.gl.copyBufferSubData(Q.GL.COPY_READ_BUFFER,Q.GL.COPY_WRITE_BUFFER,e.sourceOffset??0,e.destinationOffset??0,e.size),r.gl.bindBuffer(Q.GL.COPY_READ_BUFFER,null),r.gl.bindBuffer(Q.GL.COPY_WRITE_BUFFER,null)}function is(r,e){throw new Error("Not implemented")}function os(r,e){let{source:t,mipLevel:n=0,aspect:i="all",width:s=e.source.width,height:a=e.source.height,depthOrArrayLayers:u=0,origin:l=[0,0],destination:f,byteOffset:d=0,bytesPerRow:b,rowsPerImage:g}=e;if(i!=="all")throw new Error("not supported");if(n!==0||u!==0||b||g)throw new Error("not implemented");let{framebuffer:L,destroyFramebuffer:R}=ei(t);try{let D=f,ie=s||L.width,de=a||L.height,Mr=ze(L.texture.props.format),ai=Mr.dataFormat,ui=Mr.type;r.gl.bindBuffer(Q.GL.PIXEL_PACK_BUFFER,D.handle),r.gl.bindFramebuffer(Q.GL.FRAMEBUFFER,L.handle),r.gl.readPixels(l[0],l[1],ie,de,ai,ui,d)}finally{r.gl.bindBuffer(Q.GL.PIXEL_PACK_BUFFER,null),r.gl.bindFramebuffer(Q.GL.FRAMEBUFFER,null),R&&L.destroy()}}function ss(r,e){let{source:t,origin:n=[0,0],destination:i}=e,{width:s=e.destination.width,height:a=e.destination.width}=e,u=0,l=Q.GL.RGBA,{framebuffer:f,destroyFramebuffer:d}=ei(t),[b,g]=n,L=!1;r.gl.bindFramebuffer(Q.GL.FRAMEBUFFER,f.handle);let R=null,D;if(i instanceof U)R=i,s=Number.isFinite(s)?s:R.width,a=Number.isFinite(a)?a:R.height,R.bind(0),D=R.destination;else throw new Error("whoops");return L||r.gl.copyTexImage2D(D,u,l,b,g,s,a,0),R&&R.unbind(),d&&f.destroy(),R}function ei(r){if(r instanceof I){let{width:e,height:t,id:n}=r;return{framebuffer:r.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:t,colorAttachments:[r]}),destroyFramebuffer:!0}}return{framebuffer:r,destroyFramebuffer:!1}}var rt=class extends Me{device;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new jt(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,n){}};var nt=y(S(),1);var be=class extends He{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Gt()==="Chrome"}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let t=e;if(t&&t.glTarget!==nt.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(nt.GL.ELEMENT_ARRAY_BUFFER,t?t.handle:null),this.indexBuffer=t}setBuffer(e,t){let n=t;if(n.glTarget===nt.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:a,offset:u,normalized:l,integer:f,divisor:d}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(nt.GL.ARRAY_BUFFER,n.handle),f?this.device.gl.vertexAttribIPointer(e,i,s,a,u):this.device.gl.vertexAttribPointer(e,i,s,l,a,u),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,d||0),this.attributes[e]=n}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}init=!1;bindBeforeRender(){if(this.device.gl.bindVertexArray(this.handle),!this.init){let e=this.indexBuffer;this.device.gl.bindBuffer(nt.GL.ELEMENT_ARRAY_BUFFER,e?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){let t=this.attributeInfos[e];if(!t)throw new Error(`Unknown attribute location ${e}`);let n=Ot(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:t.stepMode==="instance"?1:0}}_enable(e,t=!0){let i=be.isConstantAttributeZeroSupported(this.device)||e!==0;(t||i)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),t?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){let n=as(t),i=n.byteLength*e,s=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),a=a||!us(n,this.bufferValue),a){let u=gr(t.constructor,s);Er({target:u,source:n,start:0,count:s}),this.buffer.write(u),this.bufferValue=t}return this.buffer}};function as(r){return Array.isArray(r)?new Float32Array(r):r}function us(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}var fe=y(S(),1);var it=class extends ke{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(fe.GL.TRANSFORM_FEEDBACK,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zn(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl.bindTransformFeedback(fe.GL.TRANSFORM_FEEDBACK,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:a}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=i,m.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:a},this.bindOnUse||this._bindBuffer(n,i,a,s)}getBuffer(e){if(ti(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(fe.GL.TRANSFORM_FEEDBACK,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(fe.GL.TRANSFORM_FEEDBACK,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(fe.GL.TRANSFORM_FEEDBACK,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof H)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(ti(e))return Number(e);for(let t of this.layout.varyings)if(e===t.name)return t.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:t,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(fe.GL.TRANSFORM_FEEDBACK_BUFFER,Number(e),null)}_bindBuffer(e,t,n=0,i){let s=t&&t.handle;!s||i===void 0?this.gl.bindBufferBase(fe.GL.TRANSFORM_FEEDBACK_BUFFER,e,s):this.gl.bindBufferRange(fe.GL.TRANSFORM_FEEDBACK_BUFFER,e,s,n,i)}};function ti(r){return typeof r=="number"?Number.isInteger(r):/^\d+$/.test(r)}var _e=y(S(),1),Qt=class extends Ve{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(_e.GL.TIME_ELAPSED_EXT)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?_e.GL.ANY_SAMPLES_PASSED_CONSERVATIVE:_e.GL.ANY_SAMPLES_PASSED)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(_e.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,_e.GL.QUERY_RESULT_AVAILABLE);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(_e.GL.GPU_DISJOINT_EXT)}getResult(){return this.device.gl.getQueryParameter(this.handle,_e.GL.QUERY_RESULT)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((n,i)=>{let s=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):t++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(s)};requestAnimationFrame(s)}),this._pollingPromise}};var ce=y(S(),1);var V=y(S(),1);function Ur(r){switch(r){case V.GL.ALPHA:case V.GL.R32F:case V.GL.RED:return 1;case V.GL.RG32F:case V.GL.RG:return 2;case V.GL.RGB:case V.GL.RGB32F:return 3;case V.GL.RGBA:case V.GL.RGBA32F:return 4;default:return A(!1),0}}function ri(r){switch(r){case V.GL.UNSIGNED_BYTE:return 1;case V.GL.UNSIGNED_SHORT_5_6_5:case V.GL.UNSIGNED_SHORT_4_4_4_4:case V.GL.UNSIGNED_SHORT_5_5_5_1:return 2;case V.GL.FLOAT:return 4;default:return A(!1),0}}function ni(r,e){let{sourceX:t=0,sourceY:n=0,sourceFormat:i=ce.GL.RGBA,sourceAttachment:s=ce.GL.COLOR_ATTACHMENT0}=e||{},{target:a=null,sourceWidth:u,sourceHeight:l,sourceType:f}=e||{},{framebuffer:d,deleteFramebuffer:b}=oi(r);A(d);let{gl:g,handle:L}=d;u=u||d.width,l=l||d.height;let R=s-ce.GL.COLOR_ATTACHMENT0;f=f||d.colorAttachments[R]?.texture?.type||ce.GL.UNSIGNED_BYTE,a=ls(a,f,i,u,l),f=f||Yn(a);let D=g.bindFramebuffer(ce.GL.FRAMEBUFFER,L);return g.readPixels(t,n,u,l,i,f,a),g.bindFramebuffer(ce.GL.FRAMEBUFFER,D||null),b&&d.destroy(),a}function ii(r,e){let{target:t,sourceX:n=0,sourceY:i=0,sourceFormat:s=ce.GL.RGBA,targetByteOffset:a=0}=e||{},{sourceWidth:u,sourceHeight:l,sourceType:f}=e||{},{framebuffer:d,deleteFramebuffer:b}=oi(r);A(d),u=u||d.width,l=l||d.height;let g=d;f=f||ce.GL.UNSIGNED_BYTE;let L=t;if(!L){let D=Ur(s),ie=ri(f),de=a+u*l*D*ie;L=g.device.createBuffer({byteLength:de})}let R=r.device.createCommandEncoder();return R.copyTextureToBuffer({source:r,width:u,height:l,origin:[n,i],destination:L,byteOffset:a}),R.destroy(),b&&d.destroy(),L}function oi(r){return r instanceof ge?{framebuffer:r,deleteFramebuffer:!1}:{framebuffer:cs(r),deleteFramebuffer:!0}}function cs(r,e){let{device:t,width:n,height:i,id:s}=r;return t.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[r]})}function ls(r,e,t,n,i){if(r)return r;e=e||ce.GL.UNSIGNED_BYTE;let s=xt(e,{clamped:!1}),a=Ur(t);return new s(n*i*a)}var fs=256,ds=1024,ms=16384;var hs="clear: bad arguments";function si(r,e){let{framebuffer:t=null,color:n=null,depth:i=null,stencil:s=null}=e||{},a={};t&&(a.framebuffer=t);let u=0;n&&(u|=ms,n!==!0&&(a.clearColor=n)),i&&(u|=fs,i!==!0&&(a.clearDepth=i)),s&&(u|=ds,i!==!0&&(a.clearStencil=i)),A(u!==0,hs),Y(r,a,()=>{r.gl.clear(u)})}var yt=1,ot=class extends he{static isSupported(){return typeof WebGL2RenderingContext<"u"}handle;features;limits;info;canvasContext;lost;_resolveContextLost;static attach(e){if(e instanceof ot)return e;if(e?.device instanceof he)return e.device;if(!ps(e))throw new Error("Invalid WebGL2RenderingContext");return new ot({gl:e})}static async create(e={}){m.groupCollapsed(yt,"WebGLDevice created")();let t=[];if(e.debug&&t.push(kn()),e.spector&&t.push(Mn()),typeof e.canvas=="string"&&t.push(pe.pageLoaded),await Promise.all(t),m.probe(yt+1,"DOM is loaded")(),e.gl?.device)return ot.attach(e.gl);let n=new ot(e),i=`Created ${n.info.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return m.probe(yt,i)(),m.table(yt,n.info)(),m.groupEnd(yt)(),n}constructor(e){super({...e,id:e.id||te("webgl-device")});let t=e.gl?.device;if(t)throw new Error(`WebGL context already attached to device ${t.id}`);let n=e.gl?.canvas||e.canvas;this.canvasContext=new qe(this,{...e,canvas:n}),this.lost=new Promise(u=>{this._resolveContextLost=u});let i=e.gl||null;if(i||=Ln(this.canvasContext.canvas,{...e,onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!i)throw new Error("WebGL context creation failed");this.handle=i,this.gl=i,this.gl.device=this,this.gl._version=2,this.info=Rn(this.gl,this._extensions),this.features=new Ht(this.gl,this._extensions),this.limits=new kt(this.gl),this.canvasContext.resize();let{enable:s=!0,copyState:a=!1}=e;pt(this.gl,{enable:s,copyState:a,log:(...u)=>m.log(1,...u)()}),e.debug&&(this.gl=Vn(this.gl,{...e,throwOnError:!0}),this.debug=!0,m.level=Math.max(m.level,1),m.warn("WebGL debug mode activated. Performance reduced.")()),e.spector&&(this.spectorJS=Wn({...this.props,canvas:this.handle.canvas}))}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return Tt(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return Fn(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return Bn(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let t=this._getBufferProps(e);return new H(this,t)}_createTexture(e){return new U(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new le(this,e)}createShader(e){return new Ze(this,e)}createFramebuffer(e){return new ee(this,e)}createVertexArray(e){return new be(this,e)}createTransformFeedback(e){return new it(this,e)}createQuerySet(e){return new Qt(this,e)}createRenderPipeline(e){return new tt(this,e)}beginRenderPass(e){return new Je(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;getDefaultRenderPass(){return this.renderPass=this.renderPass||this.beginRenderPass({framebuffer:this.canvasContext.getCurrentFramebuffer()}),this.renderPass}createCommandEncoder(e){return new rt(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,t){return ni(e,t)}readPixelsToBufferWebGL(e,t){return ii(e,t)}setParametersWebGL(e){X(this,e)}getParametersWebGL(e){return Xe(this,e)}withParametersWebGL(e,t){Y(this,e,t)}clearWebGL(e){si(this,e)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){re(this.gl)}popState(){Z(this.gl)}setSpectorMetadata(e,t){e.__SPECTOR_Metadata=t}getGLKey(e,t){t=t||this.gl2||this.gl;let n=Number(e);for(let i in t)if(t[i]===n)return`GL.${i}`;return String(e)}_constants;setConstantAttributeWebGL(e,t){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[e];switch(i&&_s(i,t)&&m.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:gs(this,e,t);break;case Int32Array:Es(this,e,t);break;case Uint32Array:bs(this,e,t);break;default:A(!1)}}getExtension(e){return J(this.gl,e,this._extensions),this._extensions}},K=ot;E(K,"type","webgl");function ps(r){return typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext?!0:Boolean(r&&Number.isFinite(r._version))}function gs(r,e,t){switch(t.length){case 1:r.gl.vertexAttrib1fv(e,t);break;case 2:r.gl.vertexAttrib2fv(e,t);break;case 3:r.gl.vertexAttrib3fv(e,t);break;case 4:r.gl.vertexAttrib4fv(e,t);break;default:A(!1)}}function Es(r,e,t){r.gl.vertexAttribI4iv(e,t)}function bs(r,e,t){r.gl.vertexAttribI4uiv(e,t)}function _s(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}return Ei(Ts);})();
16
+ </pre></code>`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a);let c=document.getElementsByClassName("luma-compiler-log-error");c[0]?.scrollIntoView&&c[0].scrollIntoView(),a.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},Fe=nr;E(Fe,"defaultProps",{..._.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function ji(t){return rr(t.source).name||t.id||ee(`unnamed ${t.stage}-shader`)}var ir=class extends _{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,ir.defaultProps)}},Be=ir;E(Be,"defaultProps",{..._.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var or=class extends _{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,or.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];r=r||i!==this.height||n!==this.width,this.width=n,this.height=i}r&&(f.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(r=>{if(typeof r=="string"){let n=this.createColorTexture(r);return this.attachResource(n),n.view}return r instanceof I?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof I?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.device._createTexture({...this.colorAttachments[n].props,width:e,height:r});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i.view,this.attachResource(i.view)}if(this.depthStencilAttachment){let n=this.device._createTexture({...this.depthStencilAttachment.props,width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}}},pe=or;E(pe,"defaultProps",{..._.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var sr=class extends _{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,r){super(e,r,sr.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Ie=sr;E(Ie,"defaultProps",{..._.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}});var ar=class extends _{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){super(e,r,ar.defaultProps)}},Ne=ar;E(Ne,"defaultProps",{..._.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var ur=class extends _{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,r){super(e,r,ur.defaultProps)}},De=ur;E(De,"defaultProps",{..._.defaultProps,measureExecutionTime:void 0});var cr=class extends _{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,cr.defaultProps)}},ve=cr;E(ve,"defaultProps",{..._.defaultProps});function sn(t){let[e,r]=qi[t],n=e==="i32"||e==="u32",i=e!=="u32",s=Zi[e]*r,a=Qi(e,r);return{dataType:e,components:r,defaultVertexFormat:a,byteLength:s,integer:n,signed:i}}function Qi(t,e){let r;switch(t){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?r:`${r}x${e}`}var qi={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Zi={f32:4,f16:2,i32:4,u32:4};function lr(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,n]=t.split("x"),i=r,s=n?parseInt(n):1,a=It(i),c={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return e&&(c.webglOnly=!0),c}function an(t,e){let r={};for(let n of t.attributes)r[n.name]=Ji(t,e,n.name);return r}function un(t,e,r=16){let n=an(t,e),i=new Array(r).fill(null);for(let s of Object.values(n))i[s.location]=s;return i}function Ji(t,e,r){let n=eo(t,r),i=to(e,r);if(!n)return null;let s=sn(n.type),a=i?.vertexFormat||s.defaultVertexFormat,c=lr(a);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:s.integer,stepMode:i?.stepMode||n.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function eo(t,e){let r=t.attributes.find(n=>n.name===e);return r||f.warn(`shader layout attribute "${e}" not present in shader`),r||null}function to(t,e){ro(t);let r=no(t,e);return r||(r=io(t,e),r)?r:(f.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function ro(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&f.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function no(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function io(t,e){for(let r of t){let n=r.byteStride;if(typeof r.byteStride!="number")for(let s of r.attributes||[]){let a=lr(s.format);n+=a.byteLength}let i=r.attributes?.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function fr(t,e){let r={...t,attributes:t.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=r.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):f.warn(`shader layout attribute ${n.name} not present in shader`)}return r}var dr=class extends _{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,dr.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=un(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}},we=dr;E(we,"defaultProps",{..._.defaultProps,renderPipeline:null});var mr=class extends _{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,mr.defaultProps)}},Oe=mr;E(Oe,"defaultProps",{..._.defaultProps,layout:void 0,buffers:{}});var hr=class extends _{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,hr.defaultProps)}},Ue=hr;E(Ue,"defaultProps",{..._.defaultProps,type:void 0,count:void 0});var vt;function cn(t){return(!vt||vt.byteLength<t)&&(vt=new ArrayBuffer(t)),vt}function pr(t,e){let r=cn(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}function gr(t){let{target:e,source:r,start:n=0,count:i=1}=t,s=r.length,a=i*s,c=0;for(let l=n;c<s;c++)e[l++]=r[c];for(;c<a;)c<a-c?(e.copyWithin(n+c,n,n+c),c*=2):(e.copyWithin(n+c,n,n+a-c),c=a);return t.target}function ln(t){return qr(t)!==null||typeof t=="number"||typeof t=="boolean"}function Er(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];ln(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}function br(t,e,r,n){let i=`See luma.gl ${r} Upgrade Guide at https://luma.gl/docs/upgrade-guide`,s=Object.getPrototypeOf(t);n.forEach(a=>{s.methodName||(s[a]=()=>{throw f.removed(`Calling removed method ${e}.${a}: `,i)(),new Error(a)})})}function _r(t,e,r){let{removedProps:n={},deprecatedProps:i={},replacedProps:s={}}=r;for(let c in n)if(c in e){let d=n[c]?`${t}.${n[c]}`:"N/A";f.removed(`${t}.${c}`,d)()}for(let c in i)if(c in e){let l=i[c];f.deprecated(`${t}.${c}`,`${t}.${l}`)()}let a=null;for(let[c,l]of Object.entries(s))c in e&&(f.deprecated(`${t}.${c}`,`${t}.${l}`)(),a=a||Object.assign({},e),a[l]=e[c],delete a[c]);return a||e}var oo="";async function Tr(t,e){return await new Promise((r,n)=>{try{let i=new Image;i.onload=()=>r(i),i.onerror=()=>n(new Error(`Could not load image ${t}.`)),i.crossOrigin=e?.crossOrigin||"anonymous",i.src=t.startsWith("http")?t:oo+t}catch(i){n(i)}})}async function at(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),e&&(n.id=e),new Promise((i,s)=>{n.onload=i,n.onerror=a=>s(new Error(`Unable to load script '${t}': ${a}`)),r.appendChild(n)})}var o=y(S(),1),ct={[o.GL.BLEND]:!1,[o.GL.BLEND_COLOR]:new Float32Array([0,0,0,0]),[o.GL.BLEND_EQUATION_RGB]:o.GL.FUNC_ADD,[o.GL.BLEND_EQUATION_ALPHA]:o.GL.FUNC_ADD,[o.GL.BLEND_SRC_RGB]:o.GL.ONE,[o.GL.BLEND_DST_RGB]:o.GL.ZERO,[o.GL.BLEND_SRC_ALPHA]:o.GL.ONE,[o.GL.BLEND_DST_ALPHA]:o.GL.ZERO,[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([0,0,0,0]),[o.GL.COLOR_WRITEMASK]:[!0,!0,!0,!0],[o.GL.CULL_FACE]:!1,[o.GL.CULL_FACE_MODE]:o.GL.BACK,[o.GL.DEPTH_TEST]:!1,[o.GL.DEPTH_CLEAR_VALUE]:1,[o.GL.DEPTH_FUNC]:o.GL.LESS,[o.GL.DEPTH_RANGE]:new Float32Array([0,1]),[o.GL.DEPTH_WRITEMASK]:!0,[o.GL.DITHER]:!0,[o.GL.CURRENT_PROGRAM]:null,[o.GL.FRAMEBUFFER_BINDING]:null,[o.GL.RENDERBUFFER_BINDING]:null,[o.GL.VERTEX_ARRAY_BINDING]:null,[o.GL.ARRAY_BUFFER_BINDING]:null,[o.GL.FRONT_FACE]:o.GL.CCW,[o.GL.GENERATE_MIPMAP_HINT]:o.GL.DONT_CARE,[o.GL.LINE_WIDTH]:1,[o.GL.POLYGON_OFFSET_FILL]:!1,[o.GL.POLYGON_OFFSET_FACTOR]:0,[o.GL.POLYGON_OFFSET_UNITS]:0,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE_VALUE]:1,[o.GL.SAMPLE_COVERAGE_INVERT]:!1,[o.GL.SCISSOR_TEST]:!1,[o.GL.SCISSOR_BOX]:new Int32Array([0,0,1024,1024]),[o.GL.STENCIL_TEST]:!1,[o.GL.STENCIL_CLEAR_VALUE]:0,[o.GL.STENCIL_WRITEMASK]:4294967295,[o.GL.STENCIL_BACK_WRITEMASK]:4294967295,[o.GL.STENCIL_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_REF]:0,[o.GL.STENCIL_VALUE_MASK]:4294967295,[o.GL.STENCIL_BACK_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_BACK_REF]:0,[o.GL.STENCIL_BACK_VALUE_MASK]:4294967295,[o.GL.STENCIL_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.STENCIL_BACK_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.VIEWPORT]:[0,0,1024,1024],[o.GL.TRANSFORM_FEEDBACK_BINDING]:null,[o.GL.COPY_READ_BUFFER_BINDING]:null,[o.GL.COPY_WRITE_BUFFER_BINDING]:null,[o.GL.PIXEL_PACK_BUFFER_BINDING]:null,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:null,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:o.GL.DONT_CARE,[o.GL.READ_FRAMEBUFFER_BINDING]:null,[o.GL.RASTERIZER_DISCARD]:!1,[o.GL.PACK_ALIGNMENT]:4,[o.GL.UNPACK_ALIGNMENT]:4,[o.GL.UNPACK_FLIP_Y_WEBGL]:!1,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:!1,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:o.GL.BROWSER_DEFAULT_WEBGL,[o.GL.PACK_ROW_LENGTH]:0,[o.GL.PACK_SKIP_PIXELS]:0,[o.GL.PACK_SKIP_ROWS]:0,[o.GL.UNPACK_ROW_LENGTH]:0,[o.GL.UNPACK_IMAGE_HEIGHT]:0,[o.GL.UNPACK_SKIP_PIXELS]:0,[o.GL.UNPACK_SKIP_ROWS]:0,[o.GL.UNPACK_SKIP_IMAGES]:0},w=(t,e,r)=>e?t.enable(r):t.disable(r),dn=(t,e,r)=>t.hint(r,e),Y=(t,e,r)=>t.pixelStorei(r,e),mn=(t,e,r)=>{let n=r===o.GL.FRAMEBUFFER_BINDING?o.GL.DRAW_FRAMEBUFFER:o.GL.READ_FRAMEBUFFER;return t.bindFramebuffer(n,e)},ut=(t,e,r)=>{let i={[o.GL.ARRAY_BUFFER_BINDING]:o.GL.ARRAY_BUFFER,[o.GL.COPY_READ_BUFFER_BINDING]:o.GL.COPY_READ_BUFFER,[o.GL.COPY_WRITE_BUFFER_BINDING]:o.GL.COPY_WRITE_BUFFER,[o.GL.PIXEL_PACK_BUFFER_BINDING]:o.GL.PIXEL_PACK_BUFFER,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:o.GL.PIXEL_UNPACK_BUFFER}[r];t.bindBuffer(i,e)};function Lr(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var hn={[o.GL.BLEND]:w,[o.GL.BLEND_COLOR]:(t,e)=>t.blendColor(...e),[o.GL.BLEND_EQUATION_RGB]:"blendEquation",[o.GL.BLEND_EQUATION_ALPHA]:"blendEquation",[o.GL.BLEND_SRC_RGB]:"blendFunc",[o.GL.BLEND_DST_RGB]:"blendFunc",[o.GL.BLEND_SRC_ALPHA]:"blendFunc",[o.GL.BLEND_DST_ALPHA]:"blendFunc",[o.GL.COLOR_CLEAR_VALUE]:(t,e)=>t.clearColor(...e),[o.GL.COLOR_WRITEMASK]:(t,e)=>t.colorMask(...e),[o.GL.CULL_FACE]:w,[o.GL.CULL_FACE_MODE]:(t,e)=>t.cullFace(e),[o.GL.DEPTH_TEST]:w,[o.GL.DEPTH_CLEAR_VALUE]:(t,e)=>t.clearDepth(e),[o.GL.DEPTH_FUNC]:(t,e)=>t.depthFunc(e),[o.GL.DEPTH_RANGE]:(t,e)=>t.depthRange(...e),[o.GL.DEPTH_WRITEMASK]:(t,e)=>t.depthMask(e),[o.GL.DITHER]:w,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:dn,[o.GL.CURRENT_PROGRAM]:(t,e)=>t.useProgram(e),[o.GL.RENDERBUFFER_BINDING]:(t,e)=>t.bindRenderbuffer(o.GL.RENDERBUFFER,e),[o.GL.TRANSFORM_FEEDBACK_BINDING]:(t,e)=>t.bindTransformFeedback?.(o.GL.TRANSFORM_FEEDBACK,e),[o.GL.VERTEX_ARRAY_BINDING]:(t,e)=>t.bindVertexArray(e),[o.GL.FRAMEBUFFER_BINDING]:mn,[o.GL.READ_FRAMEBUFFER_BINDING]:mn,[o.GL.ARRAY_BUFFER_BINDING]:ut,[o.GL.COPY_READ_BUFFER_BINDING]:ut,[o.GL.COPY_WRITE_BUFFER_BINDING]:ut,[o.GL.PIXEL_PACK_BUFFER_BINDING]:ut,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:ut,[o.GL.FRONT_FACE]:(t,e)=>t.frontFace(e),[o.GL.GENERATE_MIPMAP_HINT]:dn,[o.GL.LINE_WIDTH]:(t,e)=>t.lineWidth(e),[o.GL.POLYGON_OFFSET_FILL]:w,[o.GL.POLYGON_OFFSET_FACTOR]:"polygonOffset",[o.GL.POLYGON_OFFSET_UNITS]:"polygonOffset",[o.GL.RASTERIZER_DISCARD]:w,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE_VALUE]:"sampleCoverage",[o.GL.SAMPLE_COVERAGE_INVERT]:"sampleCoverage",[o.GL.SCISSOR_TEST]:w,[o.GL.SCISSOR_BOX]:(t,e)=>t.scissor(...e),[o.GL.STENCIL_TEST]:w,[o.GL.STENCIL_CLEAR_VALUE]:(t,e)=>t.clearStencil(e),[o.GL.STENCIL_WRITEMASK]:(t,e)=>t.stencilMaskSeparate(o.GL.FRONT,e),[o.GL.STENCIL_BACK_WRITEMASK]:(t,e)=>t.stencilMaskSeparate(o.GL.BACK,e),[o.GL.STENCIL_FUNC]:"stencilFuncFront",[o.GL.STENCIL_REF]:"stencilFuncFront",[o.GL.STENCIL_VALUE_MASK]:"stencilFuncFront",[o.GL.STENCIL_BACK_FUNC]:"stencilFuncBack",[o.GL.STENCIL_BACK_REF]:"stencilFuncBack",[o.GL.STENCIL_BACK_VALUE_MASK]:"stencilFuncBack",[o.GL.STENCIL_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_PASS]:"stencilOpFront",[o.GL.STENCIL_BACK_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:"stencilOpBack",[o.GL.VIEWPORT]:(t,e)=>t.viewport(...e),[o.GL.DEPTH_CLAMP_EXT]:w,[o.GL.POLYGON_OFFSET_LINE_WEBGL]:w,[o.GL.CLIP_DISTANCE0_WEBGL]:w,[o.GL.CLIP_DISTANCE1_WEBGL]:w,[o.GL.CLIP_DISTANCE2_WEBGL]:w,[o.GL.CLIP_DISTANCE3_WEBGL]:w,[o.GL.CLIP_DISTANCE4_WEBGL]:w,[o.GL.CLIP_DISTANCE5_WEBGL]:w,[o.GL.CLIP_DISTANCE6_WEBGL]:w,[o.GL.CLIP_DISTANCE7_WEBGL]:w,[o.GL.PACK_ALIGNMENT]:Y,[o.GL.UNPACK_ALIGNMENT]:Y,[o.GL.UNPACK_FLIP_Y_WEBGL]:Y,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:Y,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:Y,[o.GL.PACK_ROW_LENGTH]:Y,[o.GL.PACK_SKIP_PIXELS]:Y,[o.GL.PACK_SKIP_ROWS]:Y,[o.GL.UNPACK_ROW_LENGTH]:Y,[o.GL.UNPACK_IMAGE_HEIGHT]:Y,[o.GL.UNPACK_SKIP_PIXELS]:Y,[o.GL.UNPACK_SKIP_ROWS]:Y,[o.GL.UNPACK_SKIP_IMAGES]:Y,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(o.GL.FRAMEBUFFER,r)},blend:(t,e)=>e?t.enable(o.GL.BLEND):t.disable(o.GL.BLEND),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(o.GL.CULL_FACE):t.disable(o.GL.CULL_FACE),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(o.GL.DEPTH_TEST):t.disable(o.GL.DEPTH_TEST),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(o.GL.DITHER):t.disable(o.GL.DITHER),derivativeHint:(t,e)=>{t.hint(o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(o.GL.GENERATE_MIPMAP_HINT,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(o.GL.POLYGON_OFFSET_FILL):t.disable(o.GL.POLYGON_OFFSET_FILL),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(o.GL.SCISSOR_TEST):t.disable(o.GL.SCISSOR_TEST),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(o.GL.STENCIL_TEST):t.disable(o.GL.STENCIL_TEST),stencilMask:(t,e)=>{e=Lr(e)?e:[e,e];let[r,n]=e;t.stencilMaskSeparate(o.GL.FRONT,r),t.stencilMaskSeparate(o.GL.BACK,n)},stencilFunc:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;let[r,n,i,s,a,c]=e;t.stencilFuncSeparate(o.GL.FRONT,r,n,i),t.stencilFuncSeparate(o.GL.BACK,s,a,c)},stencilOp:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;let[r,n,i,s,a,c]=e;t.stencilOpSeparate(o.GL.FRONT,r,n,i),t.stencilOpSeparate(o.GL.BACK,s,a,c)},viewport:(t,e)=>t.viewport(...e)};function F(t,e,r){return e[t]!==void 0?e[t]:r[t]}var pn={blendEquation:(t,e,r)=>t.blendEquationSeparate(F(o.GL.BLEND_EQUATION_RGB,e,r),F(o.GL.BLEND_EQUATION_ALPHA,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(F(o.GL.BLEND_SRC_RGB,e,r),F(o.GL.BLEND_DST_RGB,e,r),F(o.GL.BLEND_SRC_ALPHA,e,r),F(o.GL.BLEND_DST_ALPHA,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(F(o.GL.POLYGON_OFFSET_FACTOR,e,r),F(o.GL.POLYGON_OFFSET_UNITS,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(F(o.GL.SAMPLE_COVERAGE_VALUE,e,r),F(o.GL.SAMPLE_COVERAGE_INVERT,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(o.GL.FRONT,F(o.GL.STENCIL_FUNC,e,r),F(o.GL.STENCIL_REF,e,r),F(o.GL.STENCIL_VALUE_MASK,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(o.GL.BACK,F(o.GL.STENCIL_BACK_FUNC,e,r),F(o.GL.STENCIL_BACK_REF,e,r),F(o.GL.STENCIL_BACK_VALUE_MASK,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(o.GL.FRONT,F(o.GL.STENCIL_FAIL,e,r),F(o.GL.STENCIL_PASS_DEPTH_FAIL,e,r),F(o.GL.STENCIL_PASS_DEPTH_PASS,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(o.GL.BACK,F(o.GL.STENCIL_BACK_FAIL,e,r),F(o.GL.STENCIL_BACK_PASS_DEPTH_FAIL,e,r),F(o.GL.STENCIL_BACK_PASS_DEPTH_PASS,e,r))},Ar={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[o.GL.CURRENT_PROGRAM]:e}),bindRenderbuffer:(t,e,r)=>t({[o.GL.RENDERBUFFER_BINDING]:r}),bindTransformFeedback:(t,e,r)=>t({[o.GL.TRANSFORM_FEEDBACK_BINDING]:r}),bindVertexArray:(t,e)=>t({[o.GL.VERTEX_ARRAY_BINDING]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case o.GL.FRAMEBUFFER:return t({[o.GL.DRAW_FRAMEBUFFER_BINDING]:r,[o.GL.READ_FRAMEBUFFER_BINDING]:r});case o.GL.DRAW_FRAMEBUFFER:return t({[o.GL.DRAW_FRAMEBUFFER_BINDING]:r});case o.GL.READ_FRAMEBUFFER:return t({[o.GL.READ_FRAMEBUFFER_BINDING]:r});default:return null}},bindBuffer:(t,e,r)=>{let n={[o.GL.ARRAY_BUFFER]:[o.GL.ARRAY_BUFFER_BINDING],[o.GL.COPY_READ_BUFFER]:[o.GL.COPY_READ_BUFFER_BINDING],[o.GL.COPY_WRITE_BUFFER]:[o.GL.COPY_WRITE_BUFFER_BINDING],[o.GL.PIXEL_PACK_BUFFER]:[o.GL.PIXEL_PACK_BUFFER_BINDING],[o.GL.PIXEL_UNPACK_BUFFER]:[o.GL.PIXEL_UNPACK_BUFFER_BINDING]}[e];return n?t({[n]:r}):{valueChanged:!0}},blendColor:(t,e,r,n,i)=>t({[o.GL.BLEND_COLOR]:new Float32Array([e,r,n,i])}),blendEquation:(t,e)=>t({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:e}),blendEquationSeparate:(t,e,r)=>t({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:r}),blendFunc:(t,e,r)=>t({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:r,[o.GL.BLEND_SRC_ALPHA]:e,[o.GL.BLEND_DST_ALPHA]:r}),blendFuncSeparate:(t,e,r,n,i)=>t({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:r,[o.GL.BLEND_SRC_ALPHA]:n,[o.GL.BLEND_DST_ALPHA]:i}),clearColor:(t,e,r,n,i)=>t({[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([e,r,n,i])}),clearDepth:(t,e)=>t({[o.GL.DEPTH_CLEAR_VALUE]:e}),clearStencil:(t,e)=>t({[o.GL.STENCIL_CLEAR_VALUE]:e}),colorMask:(t,e,r,n,i)=>t({[o.GL.COLOR_WRITEMASK]:[e,r,n,i]}),cullFace:(t,e)=>t({[o.GL.CULL_FACE_MODE]:e}),depthFunc:(t,e)=>t({[o.GL.DEPTH_FUNC]:e}),depthRange:(t,e,r)=>t({[o.GL.DEPTH_RANGE]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[o.GL.DEPTH_WRITEMASK]:e}),frontFace:(t,e)=>t({[o.GL.FRONT_FACE]:e}),lineWidth:(t,e)=>t({[o.GL.LINE_WIDTH]:e}),polygonOffset:(t,e,r)=>t({[o.GL.POLYGON_OFFSET_FACTOR]:e,[o.GL.POLYGON_OFFSET_UNITS]:r}),sampleCoverage:(t,e,r)=>t({[o.GL.SAMPLE_COVERAGE_VALUE]:e,[o.GL.SAMPLE_COVERAGE_INVERT]:r}),scissor:(t,e,r,n,i)=>t({[o.GL.SCISSOR_BOX]:new Int32Array([e,r,n,i])}),stencilMask:(t,e)=>t({[o.GL.STENCIL_WRITEMASK]:e,[o.GL.STENCIL_BACK_WRITEMASK]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===o.GL.FRONT?o.GL.STENCIL_WRITEMASK:o.GL.STENCIL_BACK_WRITEMASK]:r}),stencilFunc:(t,e,r,n)=>t({[o.GL.STENCIL_FUNC]:e,[o.GL.STENCIL_REF]:r,[o.GL.STENCIL_VALUE_MASK]:n,[o.GL.STENCIL_BACK_FUNC]:e,[o.GL.STENCIL_BACK_REF]:r,[o.GL.STENCIL_BACK_VALUE_MASK]:n}),stencilFuncSeparate:(t,e,r,n,i)=>t({[e===o.GL.FRONT?o.GL.STENCIL_FUNC:o.GL.STENCIL_BACK_FUNC]:r,[e===o.GL.FRONT?o.GL.STENCIL_REF:o.GL.STENCIL_BACK_REF]:n,[e===o.GL.FRONT?o.GL.STENCIL_VALUE_MASK:o.GL.STENCIL_BACK_VALUE_MASK]:i}),stencilOp:(t,e,r,n)=>t({[o.GL.STENCIL_FAIL]:e,[o.GL.STENCIL_PASS_DEPTH_FAIL]:r,[o.GL.STENCIL_PASS_DEPTH_PASS]:n,[o.GL.STENCIL_BACK_FAIL]:e,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:r,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:n}),stencilOpSeparate:(t,e,r,n,i)=>t({[e===o.GL.FRONT?o.GL.STENCIL_FAIL:o.GL.STENCIL_BACK_FAIL]:r,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_FAIL:o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:n,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_PASS:o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:i}),viewport:(t,e,r,n,i)=>t({[o.GL.VIEWPORT]:[e,r,n,i]})},ie=(t,e)=>t.isEnabled(e),Rr={[o.GL.BLEND]:ie,[o.GL.CULL_FACE]:ie,[o.GL.DEPTH_TEST]:ie,[o.GL.DITHER]:ie,[o.GL.POLYGON_OFFSET_FILL]:ie,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:ie,[o.GL.SAMPLE_COVERAGE]:ie,[o.GL.SCISSOR_TEST]:ie,[o.GL.STENCIL_TEST]:ie,[o.GL.RASTERIZER_DISCARD]:ie},gn=new Set([o.GL.ACTIVE_TEXTURE,o.GL.TRANSFORM_FEEDBACK_ACTIVE,o.GL.TRANSFORM_FEEDBACK_PAUSED,o.GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,o.GL.UNIFORM_BUFFER_BINDING,o.GL.ELEMENT_ARRAY_BUFFER_BINDING,o.GL.IMPLEMENTATION_COLOR_READ_FORMAT,o.GL.IMPLEMENTATION_COLOR_READ_TYPE,o.GL.READ_BUFFER,o.GL.DRAW_BUFFER0,o.GL.DRAW_BUFFER1,o.GL.DRAW_BUFFER2,o.GL.DRAW_BUFFER3,o.GL.DRAW_BUFFER4,o.GL.DRAW_BUFFER5,o.GL.DRAW_BUFFER6,o.GL.DRAW_BUFFER7,o.GL.DRAW_BUFFER8,o.GL.DRAW_BUFFER9,o.GL.DRAW_BUFFER10,o.GL.DRAW_BUFFER11,o.GL.DRAW_BUFFER12,o.GL.DRAW_BUFFER13,o.GL.DRAW_BUFFER14,o.GL.DRAW_BUFFER15,o.GL.SAMPLER_BINDING,o.GL.TEXTURE_BINDING_2D,o.GL.TEXTURE_BINDING_2D_ARRAY,o.GL.TEXTURE_BINDING_3D,o.GL.TEXTURE_BINDING_CUBE_MAP]);function X(t,e){if(so(e))return;let r={};for(let i in e){let s=Number(i),a=hn[i];a&&(typeof a=="string"?r[a]=!0:a(t,e[i],s))}let n=t.state&&t.state.cache;if(n)for(let i in r){let s=pn[i];s(t,e,n)}}function Me(t,e=ct){if(typeof e=="number"){let i=e,s=Rr[i];return s?s(t,i):t.getParameter(i)}let r=Array.isArray(e)?e:Object.keys(e),n={};for(let i of r){let s=Rr[i];n[i]=s?s(t,Number(i)):t.getParameter(Number(i))}return n}function En(t){X(t,ct)}function so(t){for(let e in t)return!1;return!0}function bn(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),n=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&n&&t.length===e.length){for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}return!1}var Sr=class{gl;program=null;stateStack=[];enable=!0;cache;log;constructor(e,{copyState:r=!1,log:n=()=>{}}={}){this.gl=e,this.cache=r?Me(e):Object.assign({},ct),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){R(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];X(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){R(s!==void 0);let a=e[s],c=this.cache[s];bn(a,c)||(r=!0,n=c,i&&!(s in i)&&(i[s]=c),this.cache[s]=a)}return{valueChanged:r,oldValue:n}}};function Le(t){return t.state}function lt(t,e){let{enable:r=!0,copyState:n}=e;if(R(n!==void 0),!t.state){t.state=new Sr(t,{copyState:n}),uo(t);for(let s in Ar){let a=Ar[s];ao(t,s,a)}_n(t,"getParameter"),_n(t,"isEnabled")}let i=Le(t);return i.enable=r,t}function te(t){let e=Le(t);e||(lt(t,{copyState:!1}),e=Le(t)),e.push()}function q(t){let e=Le(t);R(e),e.pop()}function _n(t,e){let r=t[e].bind(t);t[e]=function(i){if(i===void 0||gn.has(i))return r(i);let s=Le(t);return i in s.cache||(s.cache[i]=r(i)),s.enable?s.cache[i]:r(i)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function ao(t,e,r){if(!t[e])return;let n=t[e].bind(t);t[e]=function(...s){let a=Le(t),{valueChanged:c,oldValue:l}=r(a._updateCache,...s);return c&&n(...s),l},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function uo(t){let e=t.useProgram.bind(t);t.useProgram=function(n){let i=Le(t);i.program!==n&&(e(n),i.program=n)}}var co={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Tn(t,e){e={...co,...e};let r=null,n=s=>r=s.statusMessage||r;t.addEventListener("webglcontextcreationerror",n,!1);let i=null;if(i||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",n,!1),!i)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:s}=e;t.addEventListener("webglcontextlost",a=>s(a),!1)}if(e.onContextRestored){let{onContextRestored:s}=e;t.addEventListener("webglcontextrestored",a=>s(a),!1)}return i}var We=y(S(),1);function Z(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function Ln(t,e){let r=t.getParameter(We.GL.VENDOR),n=t.getParameter(We.GL.RENDERER);Z(t,"WEBGL_debug_renderer_info",e);let i=e.WEBGL_debug_renderer_info,s=t.getParameter(i?i.UNMASKED_VENDOR_WEBGL:We.GL.VENDOR),a=t.getParameter(i?i.UNMASKED_RENDERER_WEBGL:We.GL.RENDERER),c=s||r,l=a||n,d=t.getParameter(We.GL.VERSION),m=An(c,l),b=lo(c,l),g=fo(c,l);return{type:"webgl",gpu:m,gpuType:g,gpuBackend:b,vendor:c,renderer:l,version:d,shadingLanguage:"glsl",shadingLanguageVersion:300}}function An(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function lo(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function fo(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(An(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var u=y(S(),1);var z=y(S(),1);function wt(t){switch(t){case"uint8":return z.GL.UNSIGNED_BYTE;case"sint8":return z.GL.BYTE;case"unorm8":return z.GL.UNSIGNED_BYTE;case"snorm8":return z.GL.BYTE;case"uint16":return z.GL.UNSIGNED_SHORT;case"sint16":return z.GL.SHORT;case"unorm16":return z.GL.UNSIGNED_SHORT;case"snorm16":return z.GL.SHORT;case"uint32":return z.GL.UNSIGNED_INT;case"sint32":return z.GL.INT;case"float16":return z.GL.HALF_FLOAT;case"float32":return z.GL.FLOAT}throw new Error(String(t))}var M="texture-compression-bc",C="texture-compression-astc",oe="texture-compression-etc2",mo="texture-compression-etc1-webgl",Ot="texture-compression-pvrtc-webgl",xr="texture-compression-atc-webgl",ft="float32-renderable-webgl",yr="float16-renderable-webgl",ho="rgb9e5ufloat_renderable-webgl",Cr="snorm8-renderable-webgl",dt="norm16-renderable-webgl",Gr="snorm16-renderable-webgl",Ut="float32-filterable",Rn="float16-filterable-webgl",mt="WEBGL_compressed_texture_s3tc",ht="WEBGL_compressed_texture_s3tc_srgb",He="EXT_texture_compression_rgtc",ke="EXT_texture_compression_bptc",po="WEBGL_compressed_texture_etc",go="WEBGL_compressed_texture_astc",Eo="WEBGL_compressed_texture_etc1",bo="WEBGL_compressed_texture_pvrtc",_o="WEBGL_compressed_texture_atc",Sn="EXT_texture_norm16",xn="EXT_render_snorm",To="EXT_color_buffer_float",Mt={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[xn],"norm16-renderable-webgl":[Sn],"snorm16-renderable-webgl":[Sn,xn],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[mt,ht,He,ke],"texture-compression-bc5-webgl":[He],"texture-compression-bc7-webgl":[ke],"texture-compression-etc2":[po],"texture-compression-astc":[go],"texture-compression-etc1-webgl":[Eo],"texture-compression-pvrtc-webgl":[bo],"texture-compression-atc-webgl":[_o]};function yn(t){return t in Mt}function Cn(t,e,r){return(Mt[e]||[]).every(i=>Z(t,i,r))}var ge={"rgb8unorm-unsized":{gl:u.GL.RGB,b:4,c:2,bpp:4,dataFormat:u.GL.RGB,types:[u.GL.UNSIGNED_BYTE,u.GL.UNSIGNED_SHORT_5_6_5]},"rgba8unorm-unsized":{gl:u.GL.RGBA,b:4,c:2,bpp:4,dataFormat:u.GL.RGBA,types:[u.GL.UNSIGNED_BYTE,u.GL.UNSIGNED_SHORT_4_4_4_4,u.GL.UNSIGNED_SHORT_5_5_5_1]},r8unorm:{gl:u.GL.R8,b:1,c:1,rb:!0},r8snorm:{gl:u.GL.R8_SNORM,b:1,c:1,render:Cr},r8uint:{gl:u.GL.R8UI,b:1,c:1,rb:!0},r8sint:{gl:u.GL.R8I,b:1,c:1,rb:!0},rg8unorm:{gl:u.GL.RG8,b:2,c:2,rb:!0},rg8snorm:{gl:u.GL.RG8_SNORM,b:2,c:2,render:Cr},rg8uint:{gl:u.GL.RG8UI,b:2,c:2,rb:!0},rg8sint:{gl:u.GL.RG8I,b:2,c:2,rb:!0},r16uint:{gl:u.GL.R16UI,b:2,c:1,rb:!0},r16sint:{gl:u.GL.R16I,b:2,c:1,rb:!0},r16float:{gl:u.GL.R16F,b:2,c:1,render:yr,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:u.GL.R16_EXT,b:2,c:1,f:dt,rb:!0},"r16snorm-webgl":{gl:u.GL.R16_SNORM_EXT,b:2,c:1,f:Gr},"rgba4unorm-webgl":{gl:u.GL.RGBA4,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:u.GL.RGB565,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:u.GL.RGB5_A1,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:u.GL.RGB8,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:u.GL.RGB8_SNORM,b:3,c:3,wgpu:!1},rgba8unorm:{gl:u.GL.RGBA8,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:u.GL.SRGB8_ALPHA8,b:4,c:4,bpp:4},rgba8snorm:{gl:u.GL.RGBA8_SNORM,b:4,c:4,render:Cr},rgba8uint:{gl:u.GL.RGBA8UI,b:4,c:4,bpp:4},rgba8sint:{gl:u.GL.RGBA8I,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:u.GL.RG16UI,b:4,c:1,bpp:4},rg16sint:{gl:u.GL.RG16I,b:4,c:2,bpp:4},rg16float:{gl:u.GL.RG16F,bpp:4,b:4,c:2,render:yr,filter:Rn,rb:!0},"rg16unorm-webgl":{gl:u.GL.RG16_EXT,b:2,c:2,render:dt},"rg16snorm-webgl":{gl:u.GL.RG16_SNORM_EXT,b:2,c:2,render:Gr},r32uint:{gl:u.GL.R32UI,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:u.GL.R32I,b:4,c:1,bpp:4,rb:!0},r32float:{gl:u.GL.R32F,bpp:4,b:4,c:1,render:ft,filter:Ut},rgb9e5ufloat:{gl:u.GL.RGB9_E5,b:4,c:3,p:1,render:ho},rg11b10ufloat:{gl:u.GL.R11F_G11F_B10F,b:4,c:3,p:1,render:ft,rb:!0},rgb10a2unorm:{gl:u.GL.RGB10_A2,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:u.GL.RGB10_A2UI,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:u.GL.RGB16_EXT,b:2,c:3,f:dt},"rgb16snorm-webgl":{gl:u.GL.RGB16_SNORM_EXT,b:2,c:3,f:dt},rg32uint:{gl:u.GL.RG32UI,b:8,c:2,rb:!0},rg32sint:{gl:u.GL.RG32I,b:8,c:2,rb:!0},rg32float:{gl:u.GL.RG32F,b:8,c:2,render:ft,filter:Ut,rb:!0},rgba16uint:{gl:u.GL.RGBA16UI,b:8,c:4,rb:!0},rgba16sint:{gl:u.GL.RGBA16I,b:8,c:4,rb:!0},rgba16float:{gl:u.GL.RGBA16F,b:8,c:4,render:yr,filter:Rn},"rgba16unorm-webgl":{gl:u.GL.RGBA16_EXT,b:2,c:4,render:dt,rb:!0},"rgba16snorm-webgl":{gl:u.GL.RGBA16_SNORM_EXT,b:2,c:4,render:Gr},"rgb32float-webgl":{gl:u.GL.RGB32F,render:ft,filter:Ut,gl2ext:To,dataFormat:u.GL.RGB,types:[u.GL.FLOAT]},rgba32uint:{gl:u.GL.RGBA32UI,b:16,c:4,rb:!0},rgba32sint:{gl:u.GL.RGBA32I,b:16,c:4,rb:!0},rgba32float:{gl:u.GL.RGBA32F,b:16,c:4,render:ft,filter:Ut,rb:!0},stencil8:{gl:u.GL.STENCIL_INDEX8,b:1,c:1,attachment:u.GL.STENCIL_ATTACHMENT,rb:!0},depth16unorm:{gl:u.GL.DEPTH_COMPONENT16,b:2,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.UNSIGNED_SHORT],rb:!0},depth24plus:{gl:u.GL.DEPTH_COMPONENT24,b:3,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.UNSIGNED_INT]},depth32float:{gl:u.GL.DEPTH_COMPONENT32F,b:4,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.FLOAT],rb:!0},"depth24plus-stencil8":{gl:u.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,rb:!0,depthTexture:!0,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.UNSIGNED_INT_24_8]},"depth24unorm-stencil8":{gl:u.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.UNSIGNED_INT_24_8],rb:!0},"depth32float-stencil8":{gl:u.GL.DEPTH32F_STENCIL8,b:5,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.FLOAT_32_UNSIGNED_INT_24_8_REV],rb:!0},"bc1-rgb-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_S3TC_DXT1_EXT,x:mt,f:M},"bc1-rgb-unorm-srgb-webgl":{gl:u.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:ht,f:M},"bc1-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT,x:mt,f:M},"bc1-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:ht,f:M},"bc2-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT,x:mt,f:M},"bc2-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,x:ht,f:M},"bc3-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT,x:mt,f:M},"bc3-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,x:ht,f:M},"bc4-r-unorm":{gl:u.GL.COMPRESSED_RED_RGTC1_EXT,x:He,f:M},"bc4-r-snorm":{gl:u.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT,x:He,f:M},"bc5-rg-unorm":{gl:u.GL.COMPRESSED_RED_GREEN_RGTC2_EXT,x:He,f:M},"bc5-rg-snorm":{gl:u.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,x:He,f:M},"bc6h-rgb-ufloat":{gl:u.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,x:ke,f:M},"bc6h-rgb-float":{gl:u.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,x:ke,f:M},"bc7-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT,x:ke,f:M},"bc7-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,x:ke,f:M},"etc2-rgb8unorm":{gl:u.GL.COMPRESSED_RGB8_ETC2,f:oe},"etc2-rgb8unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ETC2,f:oe},"etc2-rgb8a1unorm":{gl:u.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgb8a1unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgba8unorm":{gl:u.GL.COMPRESSED_RGBA8_ETC2_EAC,f:oe},"etc2-rgba8unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,f:oe},"eac-r11unorm":{gl:u.GL.COMPRESSED_R11_EAC,f:oe},"eac-r11snorm":{gl:u.GL.COMPRESSED_SIGNED_R11_EAC,f:oe},"eac-rg11unorm":{gl:u.GL.COMPRESSED_RG11_EAC,f:oe},"eac-rg11snorm":{gl:u.GL.COMPRESSED_SIGNED_RG11_EAC,f:oe},"astc-4x4-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_4x4_KHR,f:C},"astc-4x4-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,f:C},"astc-5x4-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_5x4_KHR,f:C},"astc-5x4-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,f:C},"astc-5x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_5x5_KHR,f:C},"astc-5x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,f:C},"astc-6x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_6x5_KHR,f:C},"astc-6x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,f:C},"astc-6x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_6x6_KHR,f:C},"astc-6x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,f:C},"astc-8x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x5_KHR,f:C},"astc-8x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,f:C},"astc-8x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x6_KHR,f:C},"astc-8x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,f:C},"astc-8x8-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x8_KHR,f:C},"astc-8x8-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,f:C},"astc-10x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-10x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x6_KHR,f:C},"astc-10x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,f:C},"astc-10x8-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x8_KHR,f:C},"astc-10x8-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,f:C},"astc-10x10-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x10-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-12x10-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_12x10_KHR,f:C},"astc-12x10-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,f:C},"astc-12x12-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_12x12_KHR,f:C},"astc-12x12-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,f:C},"pvrtc-rgb4unorm-webgl":{gl:u.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,f:Ot},"pvrtc-rgba4unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,f:Ot},"pvrtc-rbg2unorm-webgl":{gl:u.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,f:Ot},"pvrtc-rgba2unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,f:Ot},"etc1-rbg-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_ETC1_WEBGL,f:mo},"atc-rgb-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_ATC_WEBGL,f:xr},"atc-rgba-unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,f:xr},"atc-rgbai-unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,f:xr}},Lo={[u.GL.RED]:1,[u.GL.RED_INTEGER]:1,[u.GL.RG]:2,[u.GL.RG_INTEGER]:2,[u.GL.RGB]:3,[u.GL.RGB_INTEGER]:3,[u.GL.RGBA]:4,[u.GL.RGBA_INTEGER]:4,[u.GL.DEPTH_COMPONENT]:1,[u.GL.DEPTH_STENCIL]:1,[u.GL.ALPHA]:1,[u.GL.LUMINANCE]:1,[u.GL.LUMINANCE_ALPHA]:2},Ao={[u.GL.FLOAT]:4,[u.GL.UNSIGNED_INT]:4,[u.GL.INT]:4,[u.GL.UNSIGNED_SHORT]:2,[u.GL.SHORT]:2,[u.GL.HALF_FLOAT]:2,[u.GL.BYTE]:1,[u.GL.UNSIGNED_BYTE]:1};function pt(t,e,r){let n=ge[e];if(!n||n.gl===void 0)return!1;let i=n.x||n.gl2ext;return i?Boolean(Z(t,i,r)):!0}function Gn(t,e,r){return pt(t,e,r)&&ge[e]?.rb}function Pn(t){if(typeof t=="string")return t;let e=Object.entries(ge).find(([,r])=>r.gl===t);if(!e)throw new Error(`Unknown texture format ${t}`);return e[0]}function gt(t){let r=ge[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function Fn(t,e,r){if(!pt(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(Nt(e).signed)return!1}catch{return!1}return e.endsWith("32float")?Boolean(Z(t,"OES_texture_float_linear, extensions",r)):e.endsWith("16float")?Boolean(Z(t,"OES_texture_half_float_linear, extensions",r)):!0}function Bn(t,e,r){return!(!pt(t,e,r)||typeof e=="number")}function Ve(t){let e=ge[t],r=gt(t),n=Nt(t);return{format:r,dataFormat:e?.dataFormat||Ro(n.format,n.integer,n.normalized,r),type:n.dataType?wt(n.dataType):e?.types?.[0]||u.GL.UNSIGNED_BYTE,compressed:n.compressed}}function In(t){let e=ge[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function Et(t){let e=Ve(t),r=Lo[e.dataFormat]||4,n=Ao[e.type]||1;return r*n}function Ro(t,e,r,n){if(n===u.GL.RGBA||n===u.GL.RGB)return n;switch(t){case"r":return e&&!r?u.GL.RED_INTEGER:u.GL.RED;case"rg":return e&&!r?u.GL.RG_INTEGER:u.GL.RG;case"rgb":return e&&!r?u.GL.RGB_INTEGER:u.GL.RGB;case"rgba":return e&&!r?u.GL.RGBA_INTEGER:u.GL.RGBA;default:return u.GL.RGBA}}var Nn={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Wt=class extends st{gl;extensions;testedFeatures=new Set;constructor(e,r,n){super([],n),this.gl=e,this.extensions=r,Z(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){for(let e of Object.keys(Nn))this.has(e)&&(yield e);for(let e of Object.keys(Mt))this.has(e)&&(yield e);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),yn(e)&&Cn(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){for(let e of this);}getWebGLFeature(e){let r=Nn[e];return Boolean(typeof r=="string"?Z(this.gl,r,this.extensions):r)}};var re=y(S(),1),Ht=class extends ot{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(re.GL.MAX_TEXTURE_SIZE)}get maxTextureDimension3D(){return this.getParameter(re.GL.MAX_3D_TEXTURE_SIZE)}get maxTextureArrayLayers(){return this.getParameter(re.GL.MAX_ARRAY_TEXTURE_LAYERS)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(re.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS)}get maxSamplersPerShaderStage(){return this.getParameter(re.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(re.GL.MAX_UNIFORM_BUFFER_BINDINGS)}get maxUniformBufferBindingSize(){return this.getParameter(re.GL.MAX_UNIFORM_BLOCK_SIZE)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(re.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(re.GL.MAX_VERTEX_ATTRIBS)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(re.GL.MAX_VARYING_COMPONENTS)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};var B=y(S(),1);var G=y(S(),1);function K(t,e,r){if(So(e))return r(t);let{nocatch:n=!0}=e;te(t),X(t,e);let i;if(n)i=r(t),q(t);else try{i=r(t)}finally{q(t)}return i}function So(t){for(let e in t)return!1;return!0}var N=y(S(),1);var h=y(S(),1);function vn(t,e,r,n){if(Ge(e))return n(t);let i=t;te(i.gl);try{return Xt(t,e),X(i.gl,r),n(t)}finally{q(i.gl)}}function wn(t,e,r){if(Ge(e))return r(t);te(t.gl);try{return Xt(t,e),r(t)}finally{q(t.gl)}}function Xt(t,e){let r=t,{gl:n}=r;if(e.cullMode)switch(e.cullMode){case"none":n.disable(h.GL.CULL_FACE);break;case"front":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.FRONT);break;case"back":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.BACK);break}if(e.frontFace&&n.frontFace(Ae("frontFace",e.frontFace,{ccw:h.GL.CCW,cw:h.GL.CW})),e.unclippedDepth&&t.features.has("depth-clip-control")&&n.enable(h.GL.DEPTH_CLAMP_EXT),e.depthBias!==void 0&&n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0),t.features.has("provoking-vertex-webgl")){let s=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex;if(e.provokingVertex){let a=Ae("provokingVertex",e.provokingVertex,{first:h.GL.FIRST_VERTEX_CONVENTION_WEBGL,last:h.GL.LAST_VERTEX_CONVENTION_WEBGL});s?.provokingVertexWEBGL(a)}}if(t.features.has("polygon-mode-webgl")){let s=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode;if(e.polygonMode){let a=Ae("polygonMode",e.provokingVertex,{fill:h.GL.FILL_WEBGL,lint:h.GL.LINE_WEBGL});s?.polygonModeWEBGL(h.GL.FRONT,a),s?.polygonModeWEBGL(h.GL.BACK,a)}e.polygonOffsetLine&&n.enable(h.GL.POLYGON_OFFSET_LINE_WEBGL)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(h.GL.CLIP_DISTANCE0_WEBGL),e.clipDistance1&&n.enable(h.GL.CLIP_DISTANCE1_WEBGL),e.clipDistance2&&n.enable(h.GL.CLIP_DISTANCE2_WEBGL),e.clipDistance3&&n.enable(h.GL.CLIP_DISTANCE3_WEBGL),e.clipDistance4&&n.enable(h.GL.CLIP_DISTANCE4_WEBGL),e.clipDistance5&&n.enable(h.GL.CLIP_DISTANCE5_WEBGL),e.clipDistance6&&n.enable(h.GL.CLIP_DISTANCE6_WEBGL),e.clipDistance7&&n.enable(h.GL.CLIP_DISTANCE7_WEBGL)),e.depthWriteEnabled!==void 0&&n.depthMask(yo("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(h.GL.DEPTH_TEST):n.disable(h.GL.DEPTH_TEST),n.depthFunc(Vt("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(h.GL.FRONT,i),n.stencilMaskSeparate(h.GL.BACK,i)}if(e.stencilReadMask&&f.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,s=Vt("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(h.GL.STENCIL_TEST):n.disable(h.GL.STENCIL_TEST),n.stencilFuncSeparate(h.GL.FRONT,s,0,i),n.stencilFuncSeparate(h.GL.BACK,s,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=Pr("stencilPassOperation",e.stencilPassOperation),s=Pr("stencilFailOperation",e.stencilFailOperation),a=Pr("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(h.GL.FRONT,s,a,i),n.stencilOpSeparate(h.GL.BACK,s,a,i)}if(e.blendColorOperation||e.blendAlphaOperation){n.enable(h.GL.BLEND);let i=Dn("blendColorOperation",e.blendColorOperation||"add"),s=Dn("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let a=kt("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=kt("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=kt("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),d=kt("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(a,c,l,d)}}function Vt(t,e){return Ae(t,e,{never:h.GL.NEVER,less:h.GL.LESS,equal:h.GL.EQUAL,"less-equal":h.GL.LEQUAL,greater:h.GL.GREATER,"not-equal":h.GL.NOTEQUAL,"greater-equal":h.GL.GEQUAL,always:h.GL.ALWAYS})}function Pr(t,e){return Ae(t,e,{keep:h.GL.KEEP,zero:h.GL.ZERO,replace:h.GL.REPLACE,invert:h.GL.INVERT,"increment-clamp":h.GL.INCR,"decrement-clamp":h.GL.DECR,"increment-wrap":h.GL.INCR_WRAP,"decrement-wrap":h.GL.DECR_WRAP})}function Dn(t,e){return Ae(t,e,{add:h.GL.FUNC_ADD,subtract:h.GL.FUNC_SUBTRACT,"reverse-subtract":h.GL.FUNC_REVERSE_SUBTRACT,min:h.GL.MIN,max:h.GL.MAX})}function kt(t,e){return Ae(t,e,{one:h.GL.ONE,zero:h.GL.ZERO,"src-color":h.GL.SRC_COLOR,"one-minus-src-color":h.GL.ONE_MINUS_SRC_COLOR,"dst-color":h.GL.DST_COLOR,"one-minus-dst-color":h.GL.ONE_MINUS_DST_COLOR,"src-alpha":h.GL.SRC_ALPHA,"one-minus-src-alpha":h.GL.ONE_MINUS_SRC_ALPHA,"dst-alpha":h.GL.DST_ALPHA,"one-minus-dst-alpha":h.GL.ONE_MINUS_DST_ALPHA})}function xo(t,e){return`Illegal parameter ${e} for ${t}`}function Ae(t,e,r){if(!(e in r))throw new Error(xo(t,e));return r[e]}function yo(t,e){return e}function Kt(t){let e={};return t.addressModeU&&(e[N.GL.TEXTURE_WRAP_S]=Fr(t.addressModeU)),t.addressModeV&&(e[N.GL.TEXTURE_WRAP_T]=Fr(t.addressModeV)),t.addressModeW&&(e[N.GL.TEXTURE_WRAP_R]=Fr(t.addressModeW)),t.magFilter&&(e[N.GL.TEXTURE_MAG_FILTER]=On(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[N.GL.TEXTURE_MIN_FILTER]=Co(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[N.GL.TEXTURE_MIN_LOD]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[N.GL.TEXTURE_MAX_LOD]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[N.GL.TEXTURE_COMPARE_MODE]=N.GL.COMPARE_REF_TO_TEXTURE),t.compare&&(e[N.GL.TEXTURE_COMPARE_FUNC]=Vt("compare",t.compare)),t.maxAnisotropy&&(e[N.GL.TEXTURE_MAX_ANISOTROPY_EXT]=t.maxAnisotropy),e}function Fr(t){switch(t){case"clamp-to-edge":return N.GL.CLAMP_TO_EDGE;case"repeat":return N.GL.REPEAT;case"mirror-repeat":return N.GL.MIRRORED_REPEAT}}function On(t){switch(t){case"nearest":return N.GL.NEAREST;case"linear":return N.GL.LINEAR}}function Co(t,e){if(!e)return On(t);switch(t){case"nearest":return e==="nearest"?N.GL.NEAREST_MIPMAP_NEAREST:N.GL.NEAREST_MIPMAP_LINEAR;case"linear":return e==="nearest"?N.GL.LINEAR_MIPMAP_NEAREST:N.GL.LINEAR_MIPMAP_LINEAR}}var W=y(S(),1),H=class extends P{device;gl;handle;glTarget;glUsage;glIndexType=W.GL.UNSIGNED_SHORT;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Go(this.props.usage),this.glUsage=Po(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?W.GL.UNSIGNED_INT:W.GL.UNSIGNED_SHORT,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,n=e.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,r,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){R(e>=0);let r=e;e===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=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){let s=W.GL.COPY_WRITE_BUFFER;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let n=new Uint8Array(r),i=0;return this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,this.handle),this.gl.getBufferSubData(W.GL.COPY_READ_BUFFER,e,n,i,r),this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,null),this._setDebugData(n,e,r),n}};function Go(t){return t&P.INDEX?W.GL.ELEMENT_ARRAY_BUFFER:t&P.VERTEX?W.GL.ARRAY_BUFFER:t&P.UNIFORM?W.GL.UNIFORM_BUFFER:W.GL.ARRAY_BUFFER}function Po(t){return t&P.INDEX?W.GL.STATIC_DRAW:t&P.VERTEX?W.GL.STATIC_DRAW:t&P.UNIFORM?W.GL.DYNAMIC_DRAW:W.GL.STATIC_DRAW}var Br=y(S(),1);var ce=class extends Be{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=Kt(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,n]of Object.entries(e)){let i=Number(r);switch(i){case Br.GL.TEXTURE_MIN_LOD:case Br.GL.TEXTURE_MAX_LOD:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var se=class extends Pe{device;gl;handle;texture;constructor(e,r){super(e,{...I.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var Fo={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},$t=class extends I{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{...Fo,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=G.GL.RGBA,this.target=Bo(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Tr(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})`}createView(e){return new se(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(ne=>this.initialize(Object.assign({},e,{pixels:ne,data:ne}))),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(e)),this;let{parameters:i={}}=e,{pixels:s=null,pixelStore:a={},textureUnit:c=void 0,mipmaps:l=!0}=e;r||(r=s);let{width:d,height:m,dataFormat:b,type:g,compressed:L=!1}=e,{depth:A=0}=e,D=gt(e.format);return{width:d,height:m,compressed:L,dataFormat:b,type:g}=this._deduceParameters({format:e.format,type:g,dataFormat:b,compressed:L,data:r,width:d,height:m}),this.width=d,this.height=m,this.glFormat=D,this.type=g,this.dataFormat=b,this.textureUnit=c,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(G.GL.TEXTURE0+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=l,this.setImageData({data:r,width:d,height:m,depth:A,format:D,type:g,dataFormat:b,parameters:a,compressed:L}),this.setSampler(e.sampler),this._setSamplerParameters(i),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),l&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),n&&(this._video={video:r,parameters:i,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:n={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(n)}),this}setSampler(e={}){let r;e instanceof ce?(this.sampler=e,r=e.props):(this.sampler=new ce(this.device,e),r=e);let n=Kt(r);return this._setSamplerParameters(n),this}resize(e){let{height:r,width:n,mipmaps:i=!1}=e;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:e,parameters:r,lastTime:n}=this._video;if(n===e.currentTime||e.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:e,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=e.currentTime}}generateMipmap(e={}){return this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),K(this.gl,e,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:n=null,level:i=0,glFormat:s=this.glFormat,offset:a=0,parameters:c={}}=e,{data:l=null,type:d=this.type,width:m=this.width,height:b=this.height,dataFormat:g=this.dataFormat,compressed:L=!1}=e;l||(l=n),{type:d,dataFormat:g,compressed:L,width:m,height:b}=this._deduceParameters({format:this.props.format,type:d,dataFormat:g,compressed:L,data:l,width:m,height:b});let{gl:A}=this;A.bindTexture(this.target,this.handle);let D=null;if({data:l,dataType:D}=this._getDataType({data:l,compressed:L}),K(this.gl,c,()=>{switch(D){case"null":A.texImage2D(r,i,s,m,b,0,g,d,l);break;case"typed-array":A.texImage2D(r,i,s,m,b,0,g,d,l,a);break;case"buffer":this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,l.handle||l),this.device.gl.texImage2D(r,i,s,m,b,0,g,d,a),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null);break;case"browser-object":A.texImage2D(r,i,s,m,b,0,g,d,l);break;case"compressed":for(let[ne,fe]of l.entries())A.compressedTexImage2D(r,ne,fe.format,fe.width,fe.height,0,fe.data);break;default:R(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let ne=Et(this.props.format);this.trackAllocatedMemory(this.width*this.height*ne,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:n=null,x:i=0,y:s=0,width:a=this.width,height:c=this.height,level:l=0,glFormat:d=this.glFormat,type:m=this.type,dataFormat:b=this.dataFormat,compressed:g=!1,offset:L=0,parameters:A={}}){if({type:m,dataFormat:b,compressed:g,width:a,height:c}=this._deduceParameters({format:this.props.format,type:m,dataFormat:b,compressed:g,data:n,width:a,height:c}),R(this.depth===1,"texSubImage not supported for 3D textures"),n||(n=r),n&&n.data){let D=n;n=D.data,a=D.shape[0],c=D.shape[1]}n instanceof H&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),K(this.gl,A,()=>{g?this.gl.compressedTexSubImage2D(e,l,i,s,a,c,d,n):n===null?this.gl.texSubImage2D(e,l,i,s,a,c,b,m,null):ArrayBuffer.isView(n)?this.gl.texSubImage2D(e,l,i,s,a,c,b,m,n,L):typeof WebGLBuffer<"u"&&n instanceof WebGLBuffer?(this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,n),this.device.gl.texSubImage2D(e,l,i,s,a,c,b,m,L),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null)):this.device.gl.texSubImage2D(e,l,i,s,a,c,b,m,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return f.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(G.GL.ACTIVE_TEXTURE)-G.GL.TEXTURE0}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof H?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:n}=e,{width:i,height:s,dataFormat:a,type:c,compressed:l}=e,d=Ve(r);return a=a||d.dataFormat,c=c||d.type,l=l||d.compressed,{width:i,height:s}=this._deduceImageSize(n,i,s),{dataFormat:a,type:c,compressed:l,width:i,height:s,format:r,data:n}}_deduceImageSize(e,r,n){let i;return typeof ImageData<"u"&&e instanceof ImageData?i={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?i={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?i={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?i={width:e.videoWidth,height:e.videoHeight}:e?i={width:r,height:n}:i={width:r>=0?r:1,height:n>=0?n:1},R(i,"Could not deduced texture size"),R(r===void 0||i.width===r,"Deduced texture width does not match supplied width"),R(n===void 0||i.height===n,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(e){let{gl:r}=this,{width:n,height:i,pixels:s,data:a,format:c=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,d=s||a,m=await Promise.all($t.FACES.map(b=>{let g=d[b];return Promise.all(Array.isArray(g)?g:[g])}));this.bind(),$t.FACES.forEach((b,g)=>{m[g].length>1&&this.props.mipmaps!==!1&&f.warn(`${this.id} has mipmap and multiple LODs.`)(),m[g].forEach((L,A)=>{n&&i?r.texImage2D(b,A,c,n,i,0,c,l,L):r.texImage2D(b,A,c,c,l,L)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:n,height:i,pixels:s,data:a,format:c=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,{gl:d}=this,m=s||a;return this.bind(),m instanceof Promise?m.then(b=>this.setImageDataForFace(Object.assign({},e,{face:r,data:b,pixels:b}))):this.width||this.height?d.texImage2D(r,0,c,n,i,0,c,l,m):d.texImage2D(r,0,c,c,l,m),this}setImageData3D(e){let{level:r=0,dataFormat:n,format:i,type:s,width:a,height:c,depth:l=1,offset:d=0,data:m,parameters:b={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let g=Ve(i);if(K(this.gl,b,()=>{ArrayBuffer.isView(m)&&this.gl.texImage3D(this.target,r,g.format,a,c,l,0,g.dataFormat,g.type,m),m instanceof H&&(this.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,m.handle),this.gl.texImage3D(this.target,r,n,a,c,l,0,i,s,d))}),m&&m.byteLength)this.trackAllocatedMemory(m.byteLength,"Texture");else{let L=Et(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*L,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Ge(e)){Io(e),this.gl.bindTexture(this.target,this.handle);for(let[r,n]of Object.entries(e)){let i=Number(r),s=n;switch(i){case G.GL.TEXTURE_MIN_LOD:case G.GL.TEXTURE_MAX_LOD:this.gl.texParameterf(this.target,i,s);break;default:this.gl.texParameteri(this.target,i,s);break}}this.gl.bindTexture(this.target,null)}}},U=$t;E(U,"FACES",[G.GL.TEXTURE_CUBE_MAP_POSITIVE_X,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z]);function Bo(t){switch(t.dimension){case"2d":return G.GL.TEXTURE_2D;case"cube":return G.GL.TEXTURE_CUBE_MAP;case"2d-array":return G.GL.TEXTURE_2D_ARRAY;case"3d":return G.GL.TEXTURE_3D;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function Io(t){f.log(1,"texture sampler parameters",t)()}var J=class extends pe{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let n=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(B.GL.FRAMEBUFFER,this.handle);for(let i=0;i<this.colorAttachments.length;++i){let s=this.colorAttachments[i],a=B.GL.COLOR_ATTACHMENT0+i;s&&this._attachOne(a,s)}if(this.depthStencilAttachment&&this._attachOne(In(this.depthStencilAttachment.props.format),this.depthStencilAttachment),r.check!==!1){let i=this.gl.checkFramebufferStatus(B.GL.FRAMEBUFFER);if(i!==B.GL.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer ${Do(i)}`)}this.gl.bindFramebuffer(B.GL.FRAMEBUFFER,null)}}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}createDepthStencilTexture(e){return new U(this.device,{id:`${this.id}-depth-stencil`,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;e===void 0&&(e=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.texture.resize({width:e,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.texture.resize({width:e,height:r}),this}_attachOne(e,r){if(Array.isArray(r)){let[n,i=0,s=0]=r;return this._attachTexture(e,n,i,s),n}if(r instanceof U)return this._attachTexture(e,r,0,0),r;if(r instanceof se){let n=r;return this._attachTexture(e,n.texture,n.props.baseMipLevel,n.props.baseArrayLayer),r.texture}throw new Error("attach")}_attachTexture(e,r,n,i){let{gl:s}=this.device;switch(s.bindTexture(r.target,r.handle),r.target){case B.GL.TEXTURE_2D_ARRAY:case B.GL.TEXTURE_3D:s.framebufferTextureLayer(B.GL.FRAMEBUFFER,e,r.target,i,n);break;case B.GL.TEXTURE_CUBE_MAP:let a=No(n);s.framebufferTexture2D(B.GL.FRAMEBUFFER,e,a,r.handle,i);break;case B.GL.TEXTURE_2D:s.framebufferTexture2D(B.GL.FRAMEBUFFER,e,B.GL.TEXTURE_2D,r.handle,i);break;default:R(!1,"Illegal texture type")}s.bindTexture(r.target,null)}};function No(t){return t<B.GL.TEXTURE_CUBE_MAP_POSITIVE_X?t+B.GL.TEXTURE_CUBE_MAP_POSITIVE_X:t}function Do(t){switch(t){case B.GL.FRAMEBUFFER_COMPLETE:return"success";case B.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"Mismatched attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"No attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"Height/width mismatch";case B.GL.FRAMEBUFFER_UNSUPPORTED:return"Unsupported or split attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:return"Samples mismatch";default:return`${t}`}}var Xe=class extends he{device;presentationSize;_framebuffer=null;constructor(e,r){super(r),this.device=e,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new J(this.device,{handle:null}),this._framebuffer}update(){let e=this.getPixelSize();(e[0]!==this.presentationSize[0]||e[1]!==this.presentationSize[1])&&(this.presentationSize=e,this.resize())}resize(e){if(this.device.gl&&this.canvas){let r=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(r,e);return}}commit(){}};var vo={spector:f.get("spector")||f.get("inspect")},wo="https://spectorcdn.babylonjs.com/spector.bundle.js",Oo=1,$=null,Un=!1;async function Mn(t){if(!globalThis.SPECTOR)try{await at(wo)}catch(e){f.warn(String(e))}}function Wn(t){if(t={...vo,...t},!t?.spector||(!$&&globalThis.SPECTOR&&(f.probe(Oo,"SPECTOR found and initialized")(),$=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=$)),!$))return null;if(Un||(Un=!0,$.spyCanvases(),$?.onCaptureStarted.add(e=>f.info("Spector capture started:",e)()),$?.onCapture.add(e=>{f.info("Spector capture complete:",e)(),$?.getResultUI(),$?.resultView.display(),$?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return $;$?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{f.info("Spector capture stopped after 2 seconds")(),$?.stopCapture()})}return $}var bt=y(S(),1);var Uo="https://unpkg.com/webgl-debug@2.0.1/index.js";function Hn(t){return t.luma=t.luma||{},t.luma}async function kn(){v()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await at(Uo))}function Vn(t,e={}){return t?e.debug?Wo(t,e):Mo(t):null}function Mo(t){let e=Hn(t);return e.realContext?e.realContext:t}function Wo(t,e){if(!globalThis.WebGLDebugUtils)return f.warn("webgl-debug not loaded")(),t;let r=Hn(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...bt.GL,...t});let n=globalThis.WebGLDebugUtils.makeDebugContext(t,Ho.bind(null,e),ko.bind(null,e));for(let a in bt.GL)!(a in n)&&typeof bt.GL[a]=="number"&&(n[a]=bt.GL[a]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.setPrototypeOf(i,n);let s=Object.create(i);return r.realContext=t,r.debugContext=s,s.debug=!0,s}function Ir(t,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Ho(t,e,r,n){n=Array.from(n).map(c=>c===void 0?"undefined":c);let i=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,n),a=`${i} in gl.${r}(${s})`;f.error(a)();debugger;if(t.throwOnError)throw new Error(a)}function ko(t,e,r){let n="";if(f.level>=1&&(n=Ir(e,r),f.log(1,n)()),t.break&&t.break.length>0&&(n=n||Ir(e,r),t.break.every(s=>n.indexOf(s)!==-1)))debugger;for(let i of r)if(i===void 0){if(n=n||Ir(e,r),t.throwOnError)throw new Error(`Undefined argument: ${n}`);f.error(`Undefined argument: ${n}`)();debugger}}var _t=y(S(),1);function Kn(t){let e=t.split(/\r?\n/),r=[];for(let n of e){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[b,g]=i;r.push({message:g.trim(),type:Xn(b),lineNum:0,linePos:0});continue}let[s,a,c,...l]=i,d=parseInt(c,10);isNaN(d)&&(d=0);let m=parseInt(a,10);isNaN(m)&&(m=0),r.push({message:l.join(":").trim(),type:Xn(s),lineNum:d,linePos:m})}return r}function Xn(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var Ke=class extends Fe{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.VERTEX_SHADER);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.FRAGMENT_SHADER);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 await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return Kn(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(i=>i.startsWith("#version ")?i:`#version 100
17
+ ${i}`)(e);let{gl:n}=this.device;if(n.shaderSource(this.handle,e),n.compileShader(this.handle),f.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);this.debugShader();return}f.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),f.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,_t.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,_t.GL.COMPILE_STATUS)?"success":"error"}};var Dr=y(S(),1);var Vo=256,Xo=1024,Ko=16384,Nr=6144,$e=class extends Ne{device;glParameters;constructor(e,r){super(e,r),this.device=e,te(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){q(this.device.gl),this.props.framebuffer&&X(this.device.gl,{framebuffer:null})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let 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[Dr.GL.RASTERIZER_DISCARD]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),r.scissorTest=Boolean(e.scissorRect),e.scissorRect&&(r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[Dr.GL.STENCIL_REF]=e.stencilReference),this.glParameters=r,X(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=Ko,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=Vo,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=Xo,e.clearStencil=this.props.clearStencil),r!==0&&K(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){K(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(Nr,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(Nr,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(Nr,e,r);break}})}};var Re=y(S(),1);var x=y(S(),1);var Ye=y(S(),1);var O=y(S(),1),$o="Failed to deduce GL constant from typed array";function $n(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return O.GL.FLOAT;case Uint16Array:return O.GL.UNSIGNED_SHORT;case Uint32Array:return O.GL.UNSIGNED_INT;case Uint8Array:return O.GL.UNSIGNED_BYTE;case Uint8ClampedArray:return O.GL.UNSIGNED_BYTE;case Int8Array:return O.GL.BYTE;case Int16Array:return O.GL.SHORT;case Int32Array:return O.GL.INT;default:throw new Error($o)}}function Tt(t,e){let{clamped:r=!0}=e||{};switch(t){case O.GL.FLOAT:return Float32Array;case O.GL.UNSIGNED_SHORT:case O.GL.UNSIGNED_SHORT_5_6_5:case O.GL.UNSIGNED_SHORT_4_4_4_4:case O.GL.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;case O.GL.UNSIGNED_INT:return Uint32Array;case O.GL.UNSIGNED_BYTE:return r?Uint8ClampedArray:Uint8Array;case O.GL.BYTE:return Int8Array;case O.GL.SHORT:return Int16Array;case O.GL.INT:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var Yo={offset:0,stride:0,type:Ye.GL.FLOAT,size:1,divisor:0,normalized:!1,integer:!1},zo={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},ae=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return Tt(e.type||Ye.GL.FLOAT).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return R(e.size),Tt(e.type||Ye.GL.FLOAT).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new ae(Yo,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return ae.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return ae.getBytesPerVertex(this)}_assign(e={}){return e=_r("Accessor",e,zo),e.type!==void 0&&(this.type=e.type,(e.type===Ye.GL.INT||e.type===Ye.GL.UNSIGNED_INT)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.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}};var p=y(S(),1);function Yn(t){return jo.includes(t)}var jo=[p.GL.SAMPLER_2D,p.GL.SAMPLER_CUBE,p.GL.SAMPLER_3D,p.GL.SAMPLER_2D_SHADOW,p.GL.SAMPLER_2D_ARRAY,p.GL.SAMPLER_2D_ARRAY_SHADOW,p.GL.SAMPLER_CUBE_SHADOW,p.GL.INT_SAMPLER_2D,p.GL.INT_SAMPLER_3D,p.GL.INT_SAMPLER_CUBE,p.GL.INT_SAMPLER_2D_ARRAY,p.GL.UNSIGNED_INT_SAMPLER_2D,p.GL.UNSIGNED_INT_SAMPLER_3D,p.GL.UNSIGNED_INT_SAMPLER_CUBE,p.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY],zn={[p.GL.FLOAT]:[p.GL.FLOAT,1,"float","f32","float32"],[p.GL.FLOAT_VEC2]:[p.GL.FLOAT,2,"vec2","vec2<f32>","float32x2"],[p.GL.FLOAT_VEC3]:[p.GL.FLOAT,3,"vec3","vec3<f32>","float32x3"],[p.GL.FLOAT_VEC4]:[p.GL.FLOAT,4,"vec4","vec4<f32>","float32x4"],[p.GL.INT]:[p.GL.INT,1,"int","i32","sint32"],[p.GL.INT_VEC2]:[p.GL.INT,2,"ivec2","vec2<i32>","sint32x2"],[p.GL.INT_VEC3]:[p.GL.INT,3,"ivec3","vec3<i32>","sint32x3"],[p.GL.INT_VEC4]:[p.GL.INT,4,"ivec4","vec4<i32>","sint32x4"],[p.GL.UNSIGNED_INT]:[p.GL.UNSIGNED_INT,1,"uint","u32","uint32"],[p.GL.UNSIGNED_INT_VEC2]:[p.GL.UNSIGNED_INT,2,"uvec2","vec2<u32>","uint32x2"],[p.GL.UNSIGNED_INT_VEC3]:[p.GL.UNSIGNED_INT,3,"uvec3","vec3<u32>","uint32x3"],[p.GL.UNSIGNED_INT_VEC4]:[p.GL.UNSIGNED_INT,4,"uvec4","vec4<u32>","uint32x4"],[p.GL.BOOL]:[p.GL.FLOAT,1,"bool","f32","float32"],[p.GL.BOOL_VEC2]:[p.GL.FLOAT,2,"bvec2","vec2<f32>","float32x2"],[p.GL.BOOL_VEC3]:[p.GL.FLOAT,3,"bvec3","vec3<f32>","float32x3"],[p.GL.BOOL_VEC4]:[p.GL.FLOAT,4,"bvec4","vec4<f32>","float32x4"],[p.GL.FLOAT_MAT2]:[p.GL.FLOAT,8,"mat2","mat2x2<f32>"],[p.GL.FLOAT_MAT2x3]:[p.GL.FLOAT,8,"mat2x3","mat2x3<f32>"],[p.GL.FLOAT_MAT2x4]:[p.GL.FLOAT,8,"mat2x4","mat2x4<f32>"],[p.GL.FLOAT_MAT3x2]:[p.GL.FLOAT,12,"mat3x2","mat3x2<f32>"],[p.GL.FLOAT_MAT3]:[p.GL.FLOAT,12,"mat3","mat3x3<f32>"],[p.GL.FLOAT_MAT3x4]:[p.GL.FLOAT,12,"mat3x4","mat3x4<f32>"],[p.GL.FLOAT_MAT4x2]:[p.GL.FLOAT,16,"mat4x2","mat4x2<f32>"],[p.GL.FLOAT_MAT4x3]:[p.GL.FLOAT,16,"mat4x3","mat4x3<f32>"],[p.GL.FLOAT_MAT4]:[p.GL.FLOAT,16,"mat4","mat4x4<f32>"]};function vr(t){let e=zn[t];if(!e)throw new Error("uniform");let[r,n,,i]=e;return{format:i,components:n,glType:r}}function jn(t){let e=zn[t];if(!e)throw new Error("attribute");let[,r,,n,i]=e;return{attributeType:n,vertexFormat:i,components:r}}function Yt(t,e){let r={attributes:[],bindings:[]};r.attributes=Qo(t,e);let n=Jo(t,e);for(let c of n){let l=c.uniforms.map(d=>({name:d.name,format:d.format,byteOffset:d.byteOffset,byteStride:d.byteStride,arrayLength:d.arrayLength}));r.bindings.push({type:"uniform",name:c.name,location:c.location,visibility:(c.vertex?1:0)&(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let i=Zo(t,e),s=0;for(let c of i)if(Yn(c.type)){let{viewDimension:l,sampleType:d}=ts(c.type);r.bindings.push({type:"texture",name:c.name,location:s,viewDimension:l,sampleType:d}),c.textureUnit=s,s+=1}i.length&&(r.uniforms=i);let a=qo(t,e);return a?.length&&(r.varyings=a),r}function Qo(t,e){let r=[],n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=t.getActiveAttrib(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:c}=s,l=t.getAttribLocation(e,a);if(l>=0){let{attributeType:d}=jn(c),m=/instance/i.test(a)?"instance":"vertex";r.push({name:a,location:l,stepMode:m,type:d})}}return r.sort((i,s)=>i.location-s.location),r}function qo(t,e){let r=[],n=t.getProgramParameter(e,x.GL.TRANSFORM_FEEDBACK_VARYINGS);for(let i=0;i<n;i++){let s=t.getTransformFeedbackVarying(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:c,size:l}=s,{glType:d,components:m}=vr(c),b=new ae({type:d,size:l*m}),g={location:i,name:a,accessor:b};r.push(g)}return r.sort((i,s)=>i.location-s.location),r}function Zo(t,e){let r=[],n=t.getProgramParameter(e,x.GL.ACTIVE_UNIFORMS);for(let i=0;i<n;i++){let s=t.getActiveUniform(e,i);if(!s)throw new Error("activeInfo");let{name:a,size:c,type:l}=s,{name:d,isArray:m}=rs(a),b=t.getUniformLocation(e,d),g={location:b,name:d,size:c,type:l,isArray:m};if(r.push(g),g.size>1)for(let L=0;L<g.size;L++){let A=`${d}[${L}]`;b=t.getUniformLocation(e,A);let D={...g,name:A,location:b};r.push(D)}}return r}function Jo(t,e){let r=(s,a)=>t.getActiveUniformBlockParameter(e,s,a),n=[],i=t.getProgramParameter(e,x.GL.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){let a={name:t.getActiveUniformBlockName(e,s)||"",location:r(s,x.GL.UNIFORM_BLOCK_BINDING),byteLength:r(s,x.GL.UNIFORM_BLOCK_DATA_SIZE),vertex:r(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),fragment:r(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),uniformCount:r(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),uniforms:[]},c=r(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)||[],l=t.getActiveUniforms(e,c,x.GL.UNIFORM_TYPE),d=t.getActiveUniforms(e,c,x.GL.UNIFORM_SIZE),m=t.getActiveUniforms(e,c,x.GL.UNIFORM_OFFSET),b=t.getActiveUniforms(e,c,x.GL.UNIFORM_ARRAY_STRIDE);for(let g=0;g<a.uniformCount;++g){let L=t.getActiveUniform(e,c[g]);if(!L)throw new Error("activeInfo");a.uniforms.push({name:L.name,format:vr(l[g]).format,type:l[g],arrayLength:d[g],byteOffset:m[g],byteStride:b[g]})}n.push(a)}return n.sort((s,a)=>s.location-a.location),n}var es={[x.GL.SAMPLER_2D]:["2d","float"],[x.GL.SAMPLER_CUBE]:["cube","float"],[x.GL.SAMPLER_3D]:["3d","float"],[x.GL.SAMPLER_2D_SHADOW]:["3d","depth"],[x.GL.SAMPLER_2D_ARRAY]:["2d-array","float"],[x.GL.SAMPLER_2D_ARRAY_SHADOW]:["2d-array","depth"],[x.GL.SAMPLER_CUBE_SHADOW]:["cube","float"],[x.GL.INT_SAMPLER_2D]:["2d","sint"],[x.GL.INT_SAMPLER_3D]:["3d","sint"],[x.GL.INT_SAMPLER_CUBE]:["cube","sint"],[x.GL.INT_SAMPLER_2D_ARRAY]:["2d-array","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D]:["2d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_3D]:["3d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_CUBE]:["cube","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]:["2d-array","uint"]};function ts(t){let e=es[t];if(!e)throw new Error("sampler");let[r,n]=e;return{viewDimension:r,sampleType:n}}function rs(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}var T=y(S(),1);function Qn(t,e,r,n){let i=t,s=n;s===!0&&(s=1),s===!1&&(s=0);let a=typeof s=="number"?[s]:s;switch(r){case T.GL.SAMPLER_2D:case T.GL.SAMPLER_CUBE:case T.GL.SAMPLER_3D:case T.GL.SAMPLER_2D_SHADOW:case T.GL.SAMPLER_2D_ARRAY:case T.GL.SAMPLER_2D_ARRAY_SHADOW:case T.GL.SAMPLER_CUBE_SHADOW:case T.GL.INT_SAMPLER_2D:case T.GL.INT_SAMPLER_3D:case T.GL.INT_SAMPLER_CUBE:case T.GL.INT_SAMPLER_2D_ARRAY:case T.GL.UNSIGNED_INT_SAMPLER_2D:case T.GL.UNSIGNED_INT_SAMPLER_3D:case T.GL.UNSIGNED_INT_SAMPLER_CUBE:case T.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof n!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,n);case T.GL.FLOAT:return t.uniform1fv(e,a);case T.GL.FLOAT_VEC2:return t.uniform2fv(e,a);case T.GL.FLOAT_VEC3:return t.uniform3fv(e,a);case T.GL.FLOAT_VEC4:return t.uniform4fv(e,a);case T.GL.INT:return t.uniform1iv(e,a);case T.GL.INT_VEC2:return t.uniform2iv(e,a);case T.GL.INT_VEC3:return t.uniform3iv(e,a);case T.GL.INT_VEC4:return t.uniform4iv(e,a);case T.GL.BOOL:return t.uniform1iv(e,a);case T.GL.BOOL_VEC2:return t.uniform2iv(e,a);case T.GL.BOOL_VEC3:return t.uniform3iv(e,a);case T.GL.BOOL_VEC4:return t.uniform4iv(e,a);case T.GL.UNSIGNED_INT:return i.uniform1uiv(e,a,1);case T.GL.UNSIGNED_INT_VEC2:return i.uniform2uiv(e,a,2);case T.GL.UNSIGNED_INT_VEC3:return i.uniform3uiv(e,a,3);case T.GL.UNSIGNED_INT_VEC4:return i.uniform4uiv(e,a,4);case T.GL.FLOAT_MAT2:return t.uniformMatrix2fv(e,!1,a);case T.GL.FLOAT_MAT3:return t.uniformMatrix3fv(e,!1,a);case T.GL.FLOAT_MAT4:return t.uniformMatrix4fv(e,!1,a);case T.GL.FLOAT_MAT2x3:return i.uniformMatrix2x3fv(e,!1,a);case T.GL.FLOAT_MAT2x4:return i.uniformMatrix2x4fv(e,!1,a);case T.GL.FLOAT_MAT3x2:return i.uniformMatrix3x2fv(e,!1,a);case T.GL.FLOAT_MAT3x4:return i.uniformMatrix3x4fv(e,!1,a);case T.GL.FLOAT_MAT4x2:return i.uniformMatrix4x2fv(e,!1,a);case T.GL.FLOAT_MAT4x3:return i.uniformMatrix4x3fv(e,!1,a)}throw new Error("Illegal uniform")}var k=y(S(),1);function qn(t){switch(t){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINE_STRIP;case"line-loop-webgl":return k.GL.LINE_LOOP;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLE_STRIP;case"triangle-fan-webgl":return k.GL.TRIANGLE_FAN;default:throw new Error(t)}}function Zn(t){switch(t){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINES;case"line-loop-webgl":return k.GL.LINES;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLES;case"triangle-fan-webgl":return k.GL.TRIANGLES;default:throw new Error(t)}}var Jn=4,ze=class extends Ie{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:n,bufferMode:i=Re.GL.SEPARATE_ATTRIBS}=r;switch(n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),f.time(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Yt(this.device.gl,this.handle),f.timeEnd(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=fr(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":f.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(e){for(let[r,n]of Object.entries(e)){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(a=>`"${a.name}"`).join(", ");f.warn(`Unknown binding "${r}" in render pipeline "${this.id}", expected one of ${s}`)();continue}switch(n||f.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(n instanceof H)&&!(n.buffer instanceof H))throw new Error("buffer value");break;case"texture":if(!(n instanceof se||n instanceof U||n instanceof J))throw new Error("texture value");break;case"sampler":f.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(i.type)}this.bindings[r]=n}}draw(e){let{renderPass:r,vertexArray:n,vertexCount:i,instanceCount:s,firstVertex:a=0,transformFeedback:c}=e,l=qn(this.props.topology),d=Boolean(n.indexBuffer),m=n.indexBuffer?.glIndexType,b=Number(s)>0;if(this.linkStatus!=="success")return f.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||i===0)return f.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(i===0)return f.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let g=r;return vn(this.device,this.props.parameters,g.glParameters,()=>{d&&b?this.device.gl.drawElementsInstanced(l,i||0,m,a,s||0):d?this.device.gl.drawElements(l,i||0,m,a):b?this.device.gl.drawArraysInstanced(l,a,i||0,s||0):this.device.gl.drawArrays(l,a,i||0),c&&c.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=Er(e);Object.keys(r).forEach(n=>{f.warn(`Unsupported value "${JSON.stringify(r[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),f.time(Jn,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),f.timeEnd(Jn,`linkProgram for ${this.id}`)(),f.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}f.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),f.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,e.LINK_STATUS)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,e.VALIDATE_STATUS)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,Re.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof U&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);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:a}=i,c=e.getUniformBlockIndex(this.handle,a);if(c===Re.GL.INVALID_INDEX)throw new Error(`Invalid uniform block name ${a}`);e.uniformBlockBinding(this.handle,n,c),s instanceof H?e.bindBufferBase(Re.GL.UNIFORM_BUFFER,n,s.handle):e.bindBufferRange(Re.GL.UNIFORM_BUFFER,n,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),n+=1;break;case"texture":if(!(s instanceof se||s instanceof U||s instanceof J))throw new Error("texture");let l;if(s instanceof se)l=s.texture;else if(s instanceof U)l=s;else if(s instanceof J&&s.colorAttachments[0]instanceof U)f.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=s.colorAttachments[0];else throw new Error("No texture");e.activeTexture(Re.GL.TEXTURE0+r),e.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 e of this.shaderLayout.uniforms||[]){let{name:r,location:n,type:i,textureUnit:s}=e,a=this.uniforms[r]??s;a!==void 0&&Qn(this.device.gl,n,i,a)}}};var j=y(S(),1);var zt=class extends ve{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":ns(this.device,r.options);break;case"copy-buffer-to-texture":is(this.device,r.options);break;case"copy-texture-to-buffer":os(this.device,r.options);break;case"copy-texture-to-texture":ss(this.device,r.options);break}}};function ns(t,e){let r=e.source,n=e.destination;t.gl.bindBuffer(j.GL.COPY_READ_BUFFER,r.handle),t.gl.bindBuffer(j.GL.COPY_WRITE_BUFFER,n.handle),t.gl.copyBufferSubData(j.GL.COPY_READ_BUFFER,j.GL.COPY_WRITE_BUFFER,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(j.GL.COPY_READ_BUFFER,null),t.gl.bindBuffer(j.GL.COPY_WRITE_BUFFER,null)}function is(t,e){throw new Error("Not implemented")}function os(t,e){let{source:r,mipLevel:n=0,aspect:i="all",width:s=e.source.width,height:a=e.source.height,depthOrArrayLayers:c=0,origin:l=[0,0],destination:d,byteOffset:m=0,bytesPerRow:b,rowsPerImage:g}=e;if(i!=="all")throw new Error("not supported");if(n!==0||c!==0||b||g)throw new Error("not implemented");let{framebuffer:L,destroyFramebuffer:A}=ei(r);try{let D=d,ne=s||L.width,fe=a||L.height,Ur=Ve(L.texture.props.format),ai=Ur.dataFormat,ui=Ur.type;t.gl.bindBuffer(j.GL.PIXEL_PACK_BUFFER,D.handle),t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,L.handle),t.gl.readPixels(l[0],l[1],ne,fe,ai,ui,m)}finally{t.gl.bindBuffer(j.GL.PIXEL_PACK_BUFFER,null),t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,null),A&&L.destroy()}}function ss(t,e){let{source:r,origin:n=[0,0],destination:i}=e,{width:s=e.destination.width,height:a=e.destination.width}=e,c=0,l=j.GL.RGBA,{framebuffer:d,destroyFramebuffer:m}=ei(r),[b,g]=n,L=!1;t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,d.handle);let A=null,D;if(i instanceof U)A=i,s=Number.isFinite(s)?s:A.width,a=Number.isFinite(a)?a:A.height,A.bind(0),D=A.destination;else throw new Error("whoops");return L||t.gl.copyTexImage2D(D,c,l,b,g,s,a,0),A&&A.unbind(),m&&d.destroy(),A}function ei(t){if(t instanceof I){let{width:e,height:r,id:n}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var je=class extends De{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new zt(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,n){}};var Qe=y(S(),1);var Ee=class extends we{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Ct()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,r?r.handle:null),this.indexBuffer=r}setBuffer(e,r){let n=r;if(n.glTarget===Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:a,offset:c,normalized:l,integer:d,divisor:m}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ARRAY_BUFFER,n.handle),d?this.device.gl.vertexAttribIPointer(e,i,s,a,c):this.device.gl.vertexAttribPointer(e,i,s,l,a,c),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,m||0),this.attributes[e]=n}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}init=!1;bindBeforeRender(){if(this.device.gl.bindVertexArray(this.handle),!this.init){let e=this.indexBuffer;this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,e?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let n=wt(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(e,r=!0){let i=Ee.isConstantAttributeZeroSupported(this.device)||e!==0;(r||i)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let n=as(r),i=n.byteLength*e,s=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),a=a||!us(n,this.bufferValue),a){let c=pr(r.constructor,s);gr({target:c,source:n,start:0,count:s}),this.buffer.write(c),this.bufferValue=r}return this.buffer}};function as(t){return Array.isArray(t)?new Float32Array(t):t}function us(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var le=y(S(),1);var qe=class extends Oe{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zn(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let n=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:a}=this._getBufferRange(r);if(n<0){this.unusedBuffers[e]=i,f.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:a},this.bindOnUse||this._bindBuffer(n,i,a,s)}getBuffer(e){if(ti(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof H)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(ti(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,Number(e),null)}_bindBuffer(e,r,n=0,i){let s=r&&r.handle;!s||i===void 0?this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s):this.gl.bindBufferRange(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s,n,i)}};function ti(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var be=y(S(),1),jt=class extends Ue{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(be.GL.TIME_ELAPSED_EXT)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?be.GL.ANY_SAMPLES_PASSED_CONSERVATIVE:be.GL.ANY_SAMPLES_PASSED)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(be.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,be.GL.QUERY_RESULT_AVAILABLE);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(be.GL.GPU_DISJOINT_EXT)}getResult(){return this.device.gl.getQueryParameter(this.handle,be.GL.QUERY_RESULT)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((n,i)=>{let s=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):r++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(s)};requestAnimationFrame(s)}),this._pollingPromise}};var ue=y(S(),1);var V=y(S(),1);function wr(t){switch(t){case V.GL.ALPHA:case V.GL.R32F:case V.GL.RED:return 1;case V.GL.RG32F:case V.GL.RG:return 2;case V.GL.RGB:case V.GL.RGB32F:return 3;case V.GL.RGBA:case V.GL.RGBA32F:return 4;default:return R(!1),0}}function ri(t){switch(t){case V.GL.UNSIGNED_BYTE:return 1;case V.GL.UNSIGNED_SHORT_5_6_5:case V.GL.UNSIGNED_SHORT_4_4_4_4:case V.GL.UNSIGNED_SHORT_5_5_5_1:return 2;case V.GL.FLOAT:return 4;default:return R(!1),0}}function ni(t,e){let{sourceX:r=0,sourceY:n=0,sourceFormat:i=ue.GL.RGBA,sourceAttachment:s=ue.GL.COLOR_ATTACHMENT0}=e||{},{target:a=null,sourceWidth:c,sourceHeight:l,sourceType:d}=e||{},{framebuffer:m,deleteFramebuffer:b}=oi(t);R(m);let{gl:g,handle:L}=m;c=c||m.width,l=l||m.height;let A=s-ue.GL.COLOR_ATTACHMENT0;d=d||m.colorAttachments[A]?.texture?.type||ue.GL.UNSIGNED_BYTE,a=ls(a,d,i,c,l),d=d||$n(a);let D=g.bindFramebuffer(ue.GL.FRAMEBUFFER,L);return g.readPixels(r,n,c,l,i,d,a),g.bindFramebuffer(ue.GL.FRAMEBUFFER,D||null),b&&m.destroy(),a}function ii(t,e){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:s=ue.GL.RGBA,targetByteOffset:a=0}=e||{},{sourceWidth:c,sourceHeight:l,sourceType:d}=e||{},{framebuffer:m,deleteFramebuffer:b}=oi(t);R(m),c=c||m.width,l=l||m.height;let g=m;d=d||ue.GL.UNSIGNED_BYTE;let L=r;if(!L){let D=wr(s),ne=ri(d),fe=a+c*l*D*ne;L=g.device.createBuffer({byteLength:fe})}let A=t.device.createCommandEncoder();return A.copyTextureToBuffer({source:t,width:c,height:l,origin:[n,i],destination:L,byteOffset:a}),A.destroy(),b&&m.destroy(),L}function oi(t){return t instanceof pe?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:cs(t),deleteFramebuffer:!0}}function cs(t,e){let{device:r,width:n,height:i,id:s}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[t]})}function ls(t,e,r,n,i){if(t)return t;e=e||ue.GL.UNSIGNED_BYTE;let s=Tt(e,{clamped:!1}),a=wr(r);return new s(n*i*a)}var fs=256,ds=1024,ms=16384;var hs="clear: bad arguments";function si(t,e){let{framebuffer:r=null,color:n=null,depth:i=null,stencil:s=null}=e||{},a={};r&&(a.framebuffer=r);let c=0;n&&(c|=ms,n!==!0&&(a.clearColor=n)),i&&(c|=fs,i!==!0&&(a.clearDepth=i)),s&&(c|=ds,i!==!0&&(a.clearStencil=i)),R(c!==0,hs);let l=t.gl;K(l,a,()=>{l.clear(c)})}var Lt=1,Ze=class extends me{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof Ze)return e;if(e?.device instanceof me)return e.device;if(!ps(e))throw new Error("Invalid WebGL2RenderingContext");return new Ze({gl:e})}static async create(e={}){f.groupCollapsed(Lt,"WebGLDevice created")();let r=[];e.debug&&r.push(kn()),e.spector&&r.push(Mn()),typeof e.canvas=="string"&&r.push(he.pageLoaded);let n=await Promise.allSettled(r);for(let a of n)a.status==="rejected"&&f.error(`Failed to initialize debug libraries ${a.reason}`)();if(f.probe(Lt+1,"DOM is loaded")(),e.gl?.device)return f.warn("reattaching existing device")(),Ze.attach(e.gl);let i=new Ze(e),s=`Created ${i.type}${i.debug?" debug":""} context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return f.probe(Lt,s)(),f.table(Lt,i.info)(),f.groupEnd(Lt)(),i}constructor(e){super({...e,id:e.id||ee("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let n=e.gl?.canvas||e.canvas;this.canvasContext=new Xe(this,{...e,canvas:n}),this.lost=new Promise(c=>{this._resolveContextLost=c});let i=e.gl||null;if(i||=Tn(this.canvasContext.canvas,{...e,onContextLost:c=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!i)throw new Error("WebGL context creation failed");this.handle=i,this.gl=i,this.gl.device=this,this.gl._version=2,this.info=Ln(this.gl,this._extensions),this.limits=new Ht(this.gl),this.features=new Wt(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:s=!0,copyState:a=!1}=e;lt(this.gl,{enable:s,copyState:a,log:(...c)=>f.log(1,...c)()}),e.debug&&(this.gl=Vn(this.gl,{...e,throwOnError:!0}),this.debug=!0,f.level=Math.max(f.level,1),f.warn("WebGL debug mode activated. Performance reduced.")()),e.spector&&(this.spectorJS=Wn({...this.props,canvas:this.handle.canvas}))}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return pt(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return Fn(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return Bn(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new H(this,r)}_createTexture(e){return new U(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ce(this,e)}createShader(e){return new Ke(this,e)}createFramebuffer(e){return new J(this,e)}createVertexArray(e){return new Ee(this,e)}createTransformFeedback(e){return new qe(this,e)}createQuerySet(e){return new jt(this,e)}createRenderPipeline(e){return new ze(this,e)}beginRenderPass(e){return new $e(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new je(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return ni(e,r)}readPixelsToBufferWebGL(e,r){return ii(e,r)}setParametersWebGL(e){X(this.gl,e)}getParametersWebGL(e){return Me(this.gl,e)}withParametersWebGL(e,r){K(this.gl,e,r)}clearWebGL(e){si(this,e)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){te(this.gl)}popState(){q(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let n=Number(e);for(let i in r)if(r[i]===n)return`GL.${i}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[e];switch(i&&_s(i,r)&&f.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:gs(this,e,r);break;case Int32Array:Es(this,e,r);break;case Uint32Array:bs(this,e,r);break;default:R(!1)}}getExtension(e){return Z(this.gl,e,this._extensions),this._extensions}},At=Ze;E(At,"type","webgl");function ps(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&Number.isFinite(t._version))}function gs(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:R(!1)}}function Es(t,e,r){t.gl.vertexAttribI4iv(e,r)}function bs(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function _s(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Je="Resource subclass must define virtual methods",Se=class extends _{device;gl;gl2;_handle;_bound=!1;byteLength=0;constructor(e,r,n){super(e,r,n),this.device=e;let i=this.device.gl,{id:s}=r||{};this.gl=i,this.gl2=i,this.id=s||ee(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({deleteChildren:e=!1}={}){let r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,r&&e&&r.filter(Boolean).forEach(n=>n.destroy()),this}bind(e=this.handle){if(typeof e!="function")return this._bindHandle(e),this;let r;return this._bound?r=e():(this._bindHandle(this.handle),this._bound=!0,r=e(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}stubRemovedMethods(e,r,n){return br(this,e,r,n)}initialize(e){}_createHandle(){throw new Error(Je)}_deleteHandle(){throw new Error(Je)}_bindHandle(e){throw new Error(Je)}_getOptsFromHandle(){throw new Error(Je)}_getParameter(e,r){throw new Error(Je)}_setParameter(e,r){throw new Error(Je)}};var et=y(S(),1);var Or=class extends Se{get[Symbol.toStringTag](){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(){}glFormat;static isTextureFormatSupported(e,r){return Gn(e.gl,r,e._extensions)}constructor(e,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(e,r,Or.defaultProps),this.glFormat=gt(this.props.format),this._initialize(this.props)}resize(e){(e.width!==this.width||e.height!==this.height)&&(Object.assign(this.props,{...e,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(e){let{format:r,width:n,height:i,samples:s}=e;R(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,this.handle),s!==0?this.gl.renderbufferStorageMultisample(et.GL.RENDERBUFFER,s,this.glFormat,n,i):this.gl.renderbufferStorage(et.GL.RENDERBUFFER,this.glFormat,n,i),this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,null),this.trackAllocatedMemory(n*i*(s||1)*Et(this.format))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(e){this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,e)}},Rt=Or;E(Rt,"defaultProps",{id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0});return Ei(Ts);})();
18
18
  return __exports__;
19
19
  });