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

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 (97) 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 +3796 -5522
  57. package/dist/dist.min.js +10 -0
  58. package/dist/index.cjs +1253 -1188
  59. package/dist/index.cjs.map +4 -4
  60. package/dist/index.d.ts +2 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -1
  63. package/package.json +6 -7
  64. package/src/.DS_Store +0 -0
  65. package/src/adapter/.DS_Store +0 -0
  66. package/src/adapter/converters/device-parameters.ts +9 -11
  67. package/src/adapter/converters/texture-formats.ts +64 -61
  68. package/src/adapter/device-helpers/webgl-device-features.ts +22 -2
  69. package/src/adapter/objects/webgl-renderbuffer.ts +1 -1
  70. package/src/adapter/objects/webgl-resource.ts +1 -1
  71. package/src/adapter/resources/webgl-external-texture.ts +3 -3
  72. package/src/adapter/resources/webgl-framebuffer.ts +29 -26
  73. package/src/adapter/resources/webgl-render-pass.ts +3 -3
  74. package/src/adapter/resources/webgl-render-pipeline.ts +13 -6
  75. package/src/adapter/resources/webgl-texture.ts +7 -3
  76. package/src/adapter/webgl-device.ts +24 -19
  77. package/src/classic/clear.ts +2 -2
  78. package/src/context/.DS_Store +0 -0
  79. package/src/context/parameters/unified-parameter-api.ts +4 -16
  80. package/src/context/state-tracker/with-parameters.ts +2 -7
  81. package/src/index.ts +4 -4
  82. package/dist/adapter/device-helpers/device-features.d.ts +0 -6
  83. package/dist/adapter/device-helpers/device-features.d.ts.map +0 -1
  84. package/dist/adapter/device-helpers/device-features.js +0 -65
  85. package/dist/adapter/device-helpers/device-limits.d.ts +0 -50
  86. package/dist/adapter/device-helpers/device-limits.d.ts.map +0 -1
  87. package/dist/adapter/device-helpers/device-limits.js +0 -92
  88. package/dist/adapter/device-helpers/get-device-info.d.ts +0 -4
  89. package/dist/adapter/device-helpers/get-device-info.d.ts.map +0 -1
  90. package/dist/adapter/device-helpers/get-device-info.js +0 -87
  91. package/dist/context/context/context-data.d.ts +0 -14
  92. package/dist/context/context/context-data.d.ts.map +0 -1
  93. package/dist/context/context/context-data.js +0 -33
  94. package/dist/context/context/create-browser-context.d.ts +0 -35
  95. package/dist/context/context/create-browser-context.d.ts.map +0 -1
  96. package/dist/context/context/create-browser-context.js +0 -66
  97. package/dist.min.js +0 -19
@@ -1,35 +0,0 @@
1
- /**
2
- * ContextProps
3
- * @param onContextLost
4
- * @param onContextRestored
5
- *
6
- * BROWSER CONTEXT PARAMETERS
7
- * @param debug Instrument context (at the expense of performance).
8
- * @param alpha Default render target has an alpha buffer.
9
- * @param depth Default render target has a depth buffer of at least 16 bits.
10
- * @param stencil Default render target has a stencil buffer of at least 8 bits.
11
- * @param antialias Boolean that indicates whether or not to perform anti-aliasing.
12
- * @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
13
- * @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten
14
- * @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
15
- */
16
- type ContextProps = {
17
- onContextLost?: (event: Event) => void;
18
- onContextRestored?: (event: Event) => void;
19
- alpha?: boolean;
20
- desynchronized?: boolean;
21
- antialias?: boolean;
22
- depth?: boolean;
23
- failIfMajorPerformanceCaveat?: boolean;
24
- powerPreference?: 'default' | 'high-performance' | 'low-power';
25
- premultipliedAlpha?: boolean;
26
- preserveDrawingBuffer?: boolean;
27
- };
28
- /**
29
- * Create a WebGL context for a canvas
30
- * Note calling this multiple time on the same canvas does return the same context
31
- * @param canvas A canvas element or offscreen canvas
32
- */
33
- export declare function createBrowserContext(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): WebGL2RenderingContext;
34
- export {};
35
- //# sourceMappingURL=create-browser-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-browser-context.d.ts","sourceRoot":"","sources":["../../../src/context/context/create-browser-context.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,KAAK,YAAY,GAAG;IAClB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,eAAe,CAAC,EAAE,SAAS,GAAG,kBAAkB,GAAG,WAAW,CAAC;IAC/D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAUF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,GAAG,eAAe,EAC3C,KAAK,EAAE,YAAY,GAClB,sBAAsB,CA+CxB"}
@@ -1,66 +0,0 @@
1
- // luma.gl, MIT license
2
- // Copyright (c) vis.gl contributors
3
- const DEFAULT_CONTEXT_PROPS = {
4
- powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons
5
- // eslint-disable-next-line no-console
6
- onContextLost: () => console.error('WebGL context lost'),
7
- // eslint-disable-next-line no-console
8
- onContextRestored: () => console.info('WebGL context restored')
9
- };
10
- /**
11
- * Create a WebGL context for a canvas
12
- * Note calling this multiple time on the same canvas does return the same context
13
- * @param canvas A canvas element or offscreen canvas
14
- */
15
- export function createBrowserContext(canvas, props) {
16
- props = { ...DEFAULT_CONTEXT_PROPS, ...props };
17
- // Try to extract any extra information about why context creation failed
18
- let errorMessage = null;
19
- const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);
20
- canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
21
- // Create the desired context
22
- let gl = null;
23
- // props.failIfMajorPerformanceCaveat = true;
24
- // We require webgl2 context
25
- gl ||= canvas.getContext('webgl2', props);
26
- // Software GPU
27
- // props.failIfMajorPerformanceCaveat = false;
28
- // if (!gl && props.webgl1) {
29
- // gl = canvas.getContext('webgl', props);
30
- // }
31
- // TODO are we removing this listener before giving it a chance to fire?
32
- canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
33
- if (!gl) {
34
- throw new Error(`Failed to create WebGL context: ${errorMessage || 'Unknown error'}`);
35
- }
36
- if (props.onContextLost) {
37
- // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.
38
- const { onContextLost } = props;
39
- canvas.addEventListener('webglcontextlost', (event) => onContextLost(event), false);
40
- }
41
- if (props.onContextRestored) {
42
- // Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.
43
- const { onContextRestored } = props;
44
- canvas.addEventListener('webglcontextrestored', (event) => onContextRestored(event), false);
45
- }
46
- return gl;
47
- }
48
- /* TODO - can we call this asynchronously to catch the error events?
49
- export async function createBrowserContextAsync(canvas: HTMLCanvasElement | OffscreenCanvas, props: ContextProps): Promise<WebGL2RenderingContext> {
50
- props = {...DEFAULT_CONTEXT_PROPS, ...props};
51
-
52
- // Try to extract any extra information about why context creation failed
53
- let errorMessage = null;
54
- const onCreateError = (error) => (errorMessage = error.statusMessage || errorMessage);
55
- canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
56
-
57
- const gl = createBrowserContext(canvas, props);
58
-
59
- // Give the listener a chance to fire
60
- await new Promise(resolve => setTimeout(resolve, 0));
61
-
62
- canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
63
-
64
- return gl;
65
- }
66
- */
package/dist.min.js DELETED
@@ -1,19 +0,0 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if (typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if (typeof define === 'function' && define.amd) define([], factory);
5
- else if (typeof exports === 'object') exports['luma'] = factory();
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)}^^^
8
- `:"";return`
9
- ${i}${s}${r.type.toUpperCase()}: ${r.message}
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=`
13
- <h1>Shader Compilation Error in ${n}</h1><br /><br />
14
- <code style="user-select:text;"><pre>
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);})();
18
- return __exports__;
19
- });