@luma.gl/webgl 9.0.10 → 9.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/webgl-device.js +3 -3
- package/dist/context/debug/spector.js +2 -2
- package/dist/dist.dev.js +22 -30
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +2 -2
- package/dist.min.js +19 -0
- package/package.json +3 -3
- package/src/adapter/webgl-device.ts +4 -4
- package/src/context/debug/spector.ts +2 -2
- package/src/.DS_Store +0 -0
- package/src/adapter/.DS_Store +0 -0
- package/src/context/.DS_Store +0 -0
package/dist.min.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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 tt=Object.defineProperty;var li=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var di=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var hi=(t,e,r)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var pi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gi=(t,e)=>{for(var r in e)tt(t,r,{get:e[r],enumerable:!0})},Mr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fi(e))!mi.call(t,i)&&i!==r&&tt(t,i,{get:()=>e[i],enumerable:!(n=li(e,i))||n.enumerable});return t};var y=(t,e,r)=>(r=t!=null?ci(di(t)):{},Mr(e||!t||!t.__esModule?tt(r,"default",{value:t,enumerable:!0}):r,t)),Ei=t=>Mr(tt({},"__esModule",{value:!0}),t);var E=(t,e,r)=>(hi(t,typeof e!="symbol"?e+"":e,r),r);var S=pi((Fc,fn)=>{fn.exports=globalThis.luma});var Ts={};gi(Ts,{Accessor:()=>ae,WEBGLBuffer:()=>H,WEBGLCommandEncoder:()=>je,WEBGLFramebuffer:()=>J,WEBGLRenderPass:()=>$e,WEBGLRenderPipeline:()=>ze,WEBGLResource:()=>Se,WEBGLSampler:()=>ce,WEBGLShader:()=>Ke,WEBGLTexture:()=>U,WEBGLTransformFeedback:()=>qe,WEBGLVertexArray:()=>Ee,WebGLCanvasContext:()=>Xe,WebGLDevice:()=>At,WebGLResource:()=>Se,_TEXTURE_FORMATS:()=>ge,_WEBGLRenderbuffer:()=>Rt,convertGLToTextureFormat:()=>Pn,getGLParameters:()=>Me,getShaderLayout:()=>Yt,popContextState:()=>q,pushContextState:()=>te,resetGLParameters:()=>En,setDeviceParameters:()=>Xt,setGLParameters:()=>X,trackContextState:()=>lt,withDeviceParameters:()=>wn,withGLParameters:()=>K});function rt(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function v(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||rt()}var bi=globalThis.self||globalThis.window||globalThis.global,St=globalThis.window||globalThis.self||globalThis.global,_i=globalThis.document||{},xt=globalThis.process||{},Ti=globalThis.console,Wr=globalThis.navigator||{};var yt="4.0.6",Cs=v();var Qt=globalThis;function Ct(t){if(!t&&!v())return"Node";if(rt(t))return"Electron";let e=t||Wr.userAgent||"";if(e.indexOf("Edge")>-1)return"Edge";let r=e.indexOf("MSIE ")!==-1,n=e.indexOf("Trident/")!==-1;return r||n?"IE":Qt.chrome?"Chrome":Qt.safari?"Safari":Qt.mozInnerScreenX?"Firefox":"Unknown"}function Li(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Gt=class{constructor(e,r,n="sessionStorage"){this.storage=Li(n),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function Hr(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function kr(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}function Pt(t,e,r,n=600){let i=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>n&&(r=Math.min(r,n/t.width));let s=t.width*r,a=t.height*r,c=["font-size:1px;",`padding:${Math.floor(a/2)}px ${Math.floor(s/2)}px;`,`line-height:${a}px;`,`background:url(${i});`,`background-size:${s}px ${a}px;`,"color:transparent;"].join("");return[`${e} %c+`,c]}var Ft;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ft||(Ft={}));var Ai=10;function Vr(t){return typeof t!="string"?t:(t=t.toUpperCase(),Ft[t]||Ft.WHITE)}function Xr(t,e,r){return!v&&typeof t=="string"&&(e&&(t=`\x1B[${Vr(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Vr(r)+Ai}m${t}\x1B[49m`)),t}function Kr(t,e=["constructor"]){let r=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(r),i=t;for(let s of n){let a=i[s];typeof a=="function"&&(e.find(c=>s===c)||(i[s]=a.bind(t)))}}function xe(t,e){if(!t)throw new Error(e||"Assertion failed")}function _e(){let t;if(v()&&St.performance)t=St?.performance?.now?.();else if("hrtime"in xt){let e=xt?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ye={debug:v()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ri={enabled:!0,level:0};function Q(){}var $r={},Yr={once:!0},de=class{constructor({id:e}={id:""}){this.VERSION=yt,this._startTs=_e(),this._deltaTs=_e(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Gt(`__probe-${this.id}__`,Ri),this.timeStamp(`${this.id} started`),Kr(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((_e()-this._startTs).toPrecision(10))}getDelta(){return Number((_e()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){xe(e,r)}warn(e){return this._getLogFunction(0,e,ye.warn,arguments,Yr)}error(e){return this._getLogFunction(0,e,ye.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,ye.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,ye.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,ye.debug||ye.info,arguments,Yr)}table(e,r,n){return r?this._getLogFunction(e,r,console.table||Q,n&&[n],{tag:Ci(r)}):Q}image({logLevel:e,priority:r,image:n,message:i="",scale:s=1}){return this._shouldLog(e||r)?v()?yi({image:n,message:i,scale:s}):xi({image:n,message:i,scale:s}):Q}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||Q)}group(e,r,n={collapsed:!1}){let i=zr({logLevel:e,message:r,opts:n}),{collapsed:s}=n;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,r,n={}){return this.group(e,r,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Q)}withGroup(e,r,n){this.group(e,r)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=jr(e)}_getLogFunction(e,r,n,i,s){if(this._shouldLog(e)){s=zr({logLevel:e,message:r,args:i,opts:s}),n=n||s.method,xe(n),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=_e();let a=s.tag||s.message;if(s.once&&a)if(!$r[a])$r[a]=_e();else return Q;return r=Si(this.id,s.message,s),n.bind(console,r,...s.args)}return Q}};de.VERSION=yt;function jr(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return xe(Number.isFinite(e)&&e>=0),e}function zr(t){let{logLevel:e,message:r}=t;t.logLevel=jr(e);let n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&n.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let i=typeof t.message;return xe(i==="string"||i==="object"),Object.assign(t,{args:n},t.opts)}function Si(t,e,r){if(typeof e=="string"){let n=r.time?kr(Hr(r.total)):"";e=r.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=Xr(e,r.color,r.background)}return e}function xi({image:t,message:e="",scale:r=1}){return console.warn("removed"),Q}function yi({image:t,message:e="",scale:r=1}){if(typeof t=="string"){let i=new Image;return i.onload=()=>{let s=Pt(i,e,r);console.log(...s)},i.src=t,Q}let n=t.nodeName||"";if(n.toLowerCase()==="img")return console.log(...Pt(t,e,r)),Q;if(n.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...Pt(i,e,r)),i.src=t.toDataURL(),Q}return Q}function Ci(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var ia=new de({id:"@probe.gl/log"});var f=new de({id:"luma.gl"});function nt(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Te=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=nt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(nt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var Ce=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,i=this.stats[r];return i||(e instanceof Te?i=e:i=new Te(r,n),this.stats[r]=i),i}};var qt=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ce({id:e})),this.stats.get(e)}},Bt=new qt;function Gi(){let t="9.0.0-beta.6",e="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==t)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${t}`);return globalThis.luma||(v()&&f.log(1,`${t} - ${e}`)(),globalThis.luma=globalThis.luma||{VERSION:t,version:t,log:f,stats:Bt}),t}var Qr=Gi();function Pi(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)?t:null}function qr(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number"?t:null:Pi(t)}var Zt={};function ee(t="id"){Zt[t]=Zt[t]||1;let e=Zt[t]++;return`${t}-${e}`}function Ge(t){let e=!0;for(let r in t){e=!1;break}return e}var _=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,r,n){if(!e)throw new Error("no device");this._device=e,this.props=Fi(r,n);let i=this.props.id!=="undefined"?this.props.id:ee(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyResource()}delete(){return this.destroy(),this}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}(${this.id})`}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e,r=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};E(_,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Fi(t,e){let r={...e};for(let n in t)t[n]!==void 0&&(r[n]=t[n]);return r}var it=class extends _{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let n={...r};(r.usage||0)&it.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?n.indexType="uint32":r.data instanceof Uint16Array&&(n.indexType="uint16")),super(e,n,it.defaultProps),this.usage=r.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}readSyncWebGL(e,r){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(e,r,n){let i=ArrayBuffer.isView(e)?e.buffer:e,s=Math.min(e?e.byteLength:n,it.DEBUG_DATA_MAX_LENGTH);e===null?this.debugData=new ArrayBuffer(s):r===0&&n===e.byteLength?this.debugData=i.slice(0,s):this.debugData=i.slice(r,r+s)}},P=it;E(P,"defaultProps",{..._.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),E(P,"MAP_READ",1),E(P,"MAP_WRITE",2),E(P,"COPY_SRC",4),E(P,"COPY_DST",8),E(P,"INDEX",16),E(P,"VERTEX",32),E(P,"UNIFORM",64),E(P,"STORAGE",128),E(P,"INDIRECT",256),E(P,"QUERY_RESOLVE",512),E(P,"DEBUG_DATA_MAX_LENGTH",32);function It(t){let e=Zr[t],r=Bi(e),n=t.includes("norm"),i=!n&&!t.startsWith("float"),s=t.startsWith("s");return{dataType:Zr[t],byteLength:r,integer:i,signed:s,normalized:n}}function Bi(t){return Ii[t]}var Zr={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ii={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Ni=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Di=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function Jr(t){return Ni.some(e=>t.startsWith(e))}function Nt(t){let e=Di.exec(t);if(e){let[,r,n,i,s,a]=e;if(r){let c=`${i}${n}`,l=It(c);return{format:r,components:r.length,srgb:s==="-srgb",unsized:a==="-unsized",webgl:a==="-webgl",...l}}}return wi(t)}var vi={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function wi(t){let e=vi[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var ot=class{},st=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},Jt=class{get[Symbol.toStringTag](){return"Device"}constructor(e){this.props={...Jt.defaultProps,...e},this.id=this.props.id||ee(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Bt;_lumaData={};isTextureFormatCompressed(e){return Jr(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)&P.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":f.warn("indices buffer content must be of integer type")()),r}},me=Jt;E(me,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(f.get("debug")),spector:Boolean(f.get("spector")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>f.error(e.message)}),E(me,"VERSION",Qr);function R(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var Oi=v()&&typeof document<"u",Dt=()=>Oi&&document.readyState==="complete",Ui={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},he=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return Dt()}constructor(e){if(this.props={...Ui,...e},e=this.props,!v()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=Hi(e.canvas):this.canvas=e.canvas;else{let r=ki(e),n=Wi(e?.container||null);n.insertBefore(r,n.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let n of r)n.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let n=this.cssToDeviceRatio(),[i,s]=this.getDrawingBufferSize();return Vi(e,n,i,s,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let n="width"in r?r.width:this.htmlCanvas.clientWidth,i="height"in r?r.height:this.htmlCanvas.clientHeight;(!n||!i)&&(f.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,n=this.htmlCanvas.width||1,i=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==n||s.clientHeight!==i||s.devicePixelRatio!==e){let a=e,c=Math.floor(n*a),l=Math.floor(i*a);this.htmlCanvas.width=c,this.htmlCanvas.height=l;let[d,m]=this.getDrawingBufferSize();(d!==c||m!==l)&&(a=Math.min(d/n,m/i),this.htmlCanvas.width=Math.floor(n*a),this.htmlCanvas.height=Math.floor(i*a),f.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=n,this._canvasSizeInfo.clientHeight=i,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};E(he,"pageLoaded",Mi());function Mi(){return Dt()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function Wi(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!Dt())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function Hi(t){let e=document.getElementById(t);if(!e&&!Dt())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function ki(t){let{width:e,height:r}=t,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=e||1,n.height=r||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(r)?`${r}px`:"100%",n}function Vi(t,e,r,n,i){let s=t,a=en(s[0],e,r),c=tn(s[1],e,n,i),l=en(s[0]+1,e,r),d=l===r-1?l:l-1;l=tn(s[1]+1,e,n,i);let m;return i?(l=l===0?l:l+1,m=c,c=l):m=l===n-1?l:l-1,{x:a,y:c,width:Math.max(d-a+1,1),height:Math.max(m-c+1,1)}}function en(t,e,r){return Math.min(Math.round(t*e),r-1)}function tn(t,e,r,n){return n?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var er=class extends _{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,n=er.defaultProps){super(e,r,n),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}},I=er;E(I,"defaultProps",{..._.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0}),E(I,"COPY_SRC",1),E(I,"COPY_DST",2),E(I,"TEXTURE_BINDING",4),E(I,"STORAGE_BINDING",8),E(I,"RENDER_ATTACHMENT",16);var tr=class extends _{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,tr.defaultProps)}},Pe=tr;E(Pe,"defaultProps",{..._.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});function nn(t,e,r){let n="",i=e.split(/\r?\n/),s=t.slice().sort((a,c)=>a.lineNum-c.lineNum);switch(r?.showSourceCode||"no"){case"all":let a=0;for(let c=1;c<=i.length;c++)for(n+=on(i[c-1],c,r);s.length>a&&s[a].lineNum===c;){let l=s[a++];n+=rn(l,i,l.lineNum,{...r,inlineSource:!1})}return n;case"issues":case"no":for(let c of t)n+=rn(c,i,c.lineNum,{inlineSource:r?.showSourceCode!=="no"});return n}}function rn(t,e,r,n){if(n?.inlineSource){let i=Xi(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
|
|
8
|
+
`:"";return`
|
|
9
|
+
${i}${s}${t.type.toUpperCase()}: ${t.message}
|
|
10
|
+
|
|
11
|
+
`}return n?.html?`<div class='luma-compiler-log-error' style="color:red;"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function Xi(t,e,r){let n="";for(let i=e-2;i<=e;i++){let s=t[i-1];s!==void 0&&(n+=on(s,e,r))}return n}function on(t,e,r){let n=r?.html?$i(t):t;return`${Ki(String(e),4)}: ${n}${r?.html?"<br/>":`
|
|
12
|
+
`}`}function Ki(t,e){let r="";for(let n=t.length;n<e;++n)r+=" ";return r+t}function $i(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function rr(t,e){return{name:Yi(t,e),language:"glsl",version:zi(t)}}function Yi(t,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return n?n[1]:e}function zi(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let n=parseInt(r[1],10);Number.isFinite(n)&&(e=n)}return e}var nr=class extends _{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:ji(r),...r},nr.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=rr(this.source).name,n=`${this.stage} ${r}`,i=nn(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource();s&&(i+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${s}</pre></code>`);let a=document.createElement("Button");a.innerHTML=`
|
|
13
|
+
<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 c=document.getElementsByClassName("luma-compiler-log-error");c[0]?.scrollIntoView&&c[0].scrollIntoView(),a.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},Fe=nr;E(Fe,"defaultProps",{..._.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"});function ji(t){return rr(t.source).name||t.id||ee(`unnamed ${t.stage}-shader`)}var ir=class extends _{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,ir.defaultProps)}},Be=ir;E(Be,"defaultProps",{..._.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var or=class extends _{get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,or.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[n,i]=Array.isArray(e)?e:[e.width,e.height];r=r||i!==this.height||n!==this.width,this.width=n,this.height=i}r&&(f.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(r=>{if(typeof r=="string"){let n=this.createColorTexture(r);return this.attachResource(n),n.view}return r instanceof I?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof I?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:I.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let i=this.device._createTexture({...this.colorAttachments[n].props,width:e,height:r});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=i.view,this.attachResource(i.view)}if(this.depthStencilAttachment){let n=this.device._createTexture({...this.depthStencilAttachment.props,width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}}},pe=or;E(pe,"defaultProps",{..._.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});var sr=class extends _{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,r){super(e,r,sr.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}setUniformsWebGL(e){throw new Error("Use uniform blocks")}},Ie=sr;E(Ie,"defaultProps",{..._.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}});var ar=class extends _{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){super(e,r,ar.defaultProps)}},Ne=ar;E(Ne,"defaultProps",{..._.defaultProps,framebuffer:null,parameters:void 0,clearColor:[0,0,0,0],clearDepth:1,clearStencil:0,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});var ur=class extends _{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,r){super(e,r,ur.defaultProps)}},De=ur;E(De,"defaultProps",{..._.defaultProps,measureExecutionTime:void 0});var cr=class extends _{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,cr.defaultProps)}},ve=cr;E(ve,"defaultProps",{..._.defaultProps});function sn(t){let[e,r]=qi[t],n=e==="i32"||e==="u32",i=e!=="u32",s=Zi[e]*r,a=Qi(e,r);return{dataType:e,components:r,defaultVertexFormat:a,byteLength:s,integer:n,signed:i}}function Qi(t,e){let r;switch(t){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?r:`${r}x${e}`}var qi={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Zi={f32:4,f16:2,i32:4,u32:4};function lr(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,n]=t.split("x"),i=r,s=n?parseInt(n):1,a=It(i),c={type:i,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return e&&(c.webglOnly=!0),c}function an(t,e){let r={};for(let n of t.attributes)r[n.name]=Ji(t,e,n.name);return r}function un(t,e,r=16){let n=an(t,e),i=new Array(r).fill(null);for(let s of Object.values(n))i[s.location]=s;return i}function Ji(t,e,r){let n=eo(t,r),i=to(e,r);if(!n)return null;let s=sn(n.type),a=i?.vertexFormat||s.defaultVertexFormat,c=lr(a);return{attributeName:i?.attributeName||n.name,bufferName:i?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:s.dataType,shaderComponents:s.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:s.integer,stepMode:i?.stepMode||n.stepMode,byteOffset:i?.byteOffset||0,byteStride:i?.byteStride||0}}function eo(t,e){let r=t.attributes.find(n=>n.name===e);return r||f.warn(`shader layout attribute "${e}" not present in shader`),r||null}function to(t,e){ro(t);let r=no(t,e);return r||(r=io(t,e),r)?r:(f.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function ro(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&f.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function no(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function io(t,e){for(let r of t){let n=r.byteStride;if(typeof r.byteStride!="number")for(let s of r.attributes||[]){let a=lr(s.format);n+=a.byteLength}let i=r.attributes?.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function fr(t,e){let r={...t,attributes:t.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let i=r.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):f.warn(`shader layout attribute ${n.name} not present in shader`)}return r}var dr=class extends _{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,dr.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=un(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}},we=dr;E(we,"defaultProps",{..._.defaultProps,renderPipeline:null});var mr=class extends _{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,mr.defaultProps)}},Oe=mr;E(Oe,"defaultProps",{..._.defaultProps,layout:void 0,buffers:{}});var hr=class extends _{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,hr.defaultProps)}},Ue=hr;E(Ue,"defaultProps",{..._.defaultProps,type:void 0,count:void 0});var vt;function cn(t){return(!vt||vt.byteLength<t)&&(vt=new ArrayBuffer(t)),vt}function pr(t,e){let r=cn(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}function gr(t){let{target:e,source:r,start:n=0,count:i=1}=t,s=r.length,a=i*s,c=0;for(let l=n;c<s;c++)e[l++]=r[c];for(;c<a;)c<a-c?(e.copyWithin(n+c,n,n+c),c*=2):(e.copyWithin(n+c,n,n+a-c),c=a);return t.target}function ln(t){return qr(t)!==null||typeof t=="number"||typeof t=="boolean"}function Er(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let n=t[r];ln(n)?e.uniforms[r]=n:e.bindings[r]=n}),e}function br(t,e,r,n){let i=`See luma.gl ${r} Upgrade Guide at https://luma.gl/docs/upgrade-guide`,s=Object.getPrototypeOf(t);n.forEach(a=>{s.methodName||(s[a]=()=>{throw f.removed(`Calling removed method ${e}.${a}: `,i)(),new Error(a)})})}function _r(t,e,r){let{removedProps:n={},deprecatedProps:i={},replacedProps:s={}}=r;for(let c in n)if(c in e){let d=n[c]?`${t}.${n[c]}`:"N/A";f.removed(`${t}.${c}`,d)()}for(let c in i)if(c in e){let l=i[c];f.deprecated(`${t}.${c}`,`${t}.${l}`)()}let a=null;for(let[c,l]of Object.entries(s))c in e&&(f.deprecated(`${t}.${c}`,`${t}.${l}`)(),a=a||Object.assign({},e),a[l]=e[c],delete a[c]);return a||e}var oo="";async function Tr(t,e){return await new Promise((r,n)=>{try{let i=new Image;i.onload=()=>r(i),i.onerror=()=>n(new Error(`Could not load image ${t}.`)),i.crossOrigin=e?.crossOrigin||"anonymous",i.src=t.startsWith("http")?t:oo+t}catch(i){n(i)}})}async function at(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),e&&(n.id=e),new Promise((i,s)=>{n.onload=i,n.onerror=a=>s(new Error(`Unable to load script '${t}': ${a}`)),r.appendChild(n)})}var o=y(S(),1),ct={[o.GL.BLEND]:!1,[o.GL.BLEND_COLOR]:new Float32Array([0,0,0,0]),[o.GL.BLEND_EQUATION_RGB]:o.GL.FUNC_ADD,[o.GL.BLEND_EQUATION_ALPHA]:o.GL.FUNC_ADD,[o.GL.BLEND_SRC_RGB]:o.GL.ONE,[o.GL.BLEND_DST_RGB]:o.GL.ZERO,[o.GL.BLEND_SRC_ALPHA]:o.GL.ONE,[o.GL.BLEND_DST_ALPHA]:o.GL.ZERO,[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([0,0,0,0]),[o.GL.COLOR_WRITEMASK]:[!0,!0,!0,!0],[o.GL.CULL_FACE]:!1,[o.GL.CULL_FACE_MODE]:o.GL.BACK,[o.GL.DEPTH_TEST]:!1,[o.GL.DEPTH_CLEAR_VALUE]:1,[o.GL.DEPTH_FUNC]:o.GL.LESS,[o.GL.DEPTH_RANGE]:new Float32Array([0,1]),[o.GL.DEPTH_WRITEMASK]:!0,[o.GL.DITHER]:!0,[o.GL.CURRENT_PROGRAM]:null,[o.GL.FRAMEBUFFER_BINDING]:null,[o.GL.RENDERBUFFER_BINDING]:null,[o.GL.VERTEX_ARRAY_BINDING]:null,[o.GL.ARRAY_BUFFER_BINDING]:null,[o.GL.FRONT_FACE]:o.GL.CCW,[o.GL.GENERATE_MIPMAP_HINT]:o.GL.DONT_CARE,[o.GL.LINE_WIDTH]:1,[o.GL.POLYGON_OFFSET_FILL]:!1,[o.GL.POLYGON_OFFSET_FACTOR]:0,[o.GL.POLYGON_OFFSET_UNITS]:0,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE]:!1,[o.GL.SAMPLE_COVERAGE_VALUE]:1,[o.GL.SAMPLE_COVERAGE_INVERT]:!1,[o.GL.SCISSOR_TEST]:!1,[o.GL.SCISSOR_BOX]:new Int32Array([0,0,1024,1024]),[o.GL.STENCIL_TEST]:!1,[o.GL.STENCIL_CLEAR_VALUE]:0,[o.GL.STENCIL_WRITEMASK]:4294967295,[o.GL.STENCIL_BACK_WRITEMASK]:4294967295,[o.GL.STENCIL_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_REF]:0,[o.GL.STENCIL_VALUE_MASK]:4294967295,[o.GL.STENCIL_BACK_FUNC]:o.GL.ALWAYS,[o.GL.STENCIL_BACK_REF]:0,[o.GL.STENCIL_BACK_VALUE_MASK]:4294967295,[o.GL.STENCIL_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.STENCIL_BACK_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:o.GL.KEEP,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:o.GL.KEEP,[o.GL.VIEWPORT]:[0,0,1024,1024],[o.GL.TRANSFORM_FEEDBACK_BINDING]:null,[o.GL.COPY_READ_BUFFER_BINDING]:null,[o.GL.COPY_WRITE_BUFFER_BINDING]:null,[o.GL.PIXEL_PACK_BUFFER_BINDING]:null,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:null,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:o.GL.DONT_CARE,[o.GL.READ_FRAMEBUFFER_BINDING]:null,[o.GL.RASTERIZER_DISCARD]:!1,[o.GL.PACK_ALIGNMENT]:4,[o.GL.UNPACK_ALIGNMENT]:4,[o.GL.UNPACK_FLIP_Y_WEBGL]:!1,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:!1,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:o.GL.BROWSER_DEFAULT_WEBGL,[o.GL.PACK_ROW_LENGTH]:0,[o.GL.PACK_SKIP_PIXELS]:0,[o.GL.PACK_SKIP_ROWS]:0,[o.GL.UNPACK_ROW_LENGTH]:0,[o.GL.UNPACK_IMAGE_HEIGHT]:0,[o.GL.UNPACK_SKIP_PIXELS]:0,[o.GL.UNPACK_SKIP_ROWS]:0,[o.GL.UNPACK_SKIP_IMAGES]:0},w=(t,e,r)=>e?t.enable(r):t.disable(r),dn=(t,e,r)=>t.hint(r,e),Y=(t,e,r)=>t.pixelStorei(r,e),mn=(t,e,r)=>{let n=r===o.GL.FRAMEBUFFER_BINDING?o.GL.DRAW_FRAMEBUFFER:o.GL.READ_FRAMEBUFFER;return t.bindFramebuffer(n,e)},ut=(t,e,r)=>{let i={[o.GL.ARRAY_BUFFER_BINDING]:o.GL.ARRAY_BUFFER,[o.GL.COPY_READ_BUFFER_BINDING]:o.GL.COPY_READ_BUFFER,[o.GL.COPY_WRITE_BUFFER_BINDING]:o.GL.COPY_WRITE_BUFFER,[o.GL.PIXEL_PACK_BUFFER_BINDING]:o.GL.PIXEL_PACK_BUFFER,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:o.GL.PIXEL_UNPACK_BUFFER}[r];t.bindBuffer(i,e)};function Lr(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var hn={[o.GL.BLEND]:w,[o.GL.BLEND_COLOR]:(t,e)=>t.blendColor(...e),[o.GL.BLEND_EQUATION_RGB]:"blendEquation",[o.GL.BLEND_EQUATION_ALPHA]:"blendEquation",[o.GL.BLEND_SRC_RGB]:"blendFunc",[o.GL.BLEND_DST_RGB]:"blendFunc",[o.GL.BLEND_SRC_ALPHA]:"blendFunc",[o.GL.BLEND_DST_ALPHA]:"blendFunc",[o.GL.COLOR_CLEAR_VALUE]:(t,e)=>t.clearColor(...e),[o.GL.COLOR_WRITEMASK]:(t,e)=>t.colorMask(...e),[o.GL.CULL_FACE]:w,[o.GL.CULL_FACE_MODE]:(t,e)=>t.cullFace(e),[o.GL.DEPTH_TEST]:w,[o.GL.DEPTH_CLEAR_VALUE]:(t,e)=>t.clearDepth(e),[o.GL.DEPTH_FUNC]:(t,e)=>t.depthFunc(e),[o.GL.DEPTH_RANGE]:(t,e)=>t.depthRange(...e),[o.GL.DEPTH_WRITEMASK]:(t,e)=>t.depthMask(e),[o.GL.DITHER]:w,[o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT]:dn,[o.GL.CURRENT_PROGRAM]:(t,e)=>t.useProgram(e),[o.GL.RENDERBUFFER_BINDING]:(t,e)=>t.bindRenderbuffer(o.GL.RENDERBUFFER,e),[o.GL.TRANSFORM_FEEDBACK_BINDING]:(t,e)=>t.bindTransformFeedback?.(o.GL.TRANSFORM_FEEDBACK,e),[o.GL.VERTEX_ARRAY_BINDING]:(t,e)=>t.bindVertexArray(e),[o.GL.FRAMEBUFFER_BINDING]:mn,[o.GL.READ_FRAMEBUFFER_BINDING]:mn,[o.GL.ARRAY_BUFFER_BINDING]:ut,[o.GL.COPY_READ_BUFFER_BINDING]:ut,[o.GL.COPY_WRITE_BUFFER_BINDING]:ut,[o.GL.PIXEL_PACK_BUFFER_BINDING]:ut,[o.GL.PIXEL_UNPACK_BUFFER_BINDING]:ut,[o.GL.FRONT_FACE]:(t,e)=>t.frontFace(e),[o.GL.GENERATE_MIPMAP_HINT]:dn,[o.GL.LINE_WIDTH]:(t,e)=>t.lineWidth(e),[o.GL.POLYGON_OFFSET_FILL]:w,[o.GL.POLYGON_OFFSET_FACTOR]:"polygonOffset",[o.GL.POLYGON_OFFSET_UNITS]:"polygonOffset",[o.GL.RASTERIZER_DISCARD]:w,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE]:w,[o.GL.SAMPLE_COVERAGE_VALUE]:"sampleCoverage",[o.GL.SAMPLE_COVERAGE_INVERT]:"sampleCoverage",[o.GL.SCISSOR_TEST]:w,[o.GL.SCISSOR_BOX]:(t,e)=>t.scissor(...e),[o.GL.STENCIL_TEST]:w,[o.GL.STENCIL_CLEAR_VALUE]:(t,e)=>t.clearStencil(e),[o.GL.STENCIL_WRITEMASK]:(t,e)=>t.stencilMaskSeparate(o.GL.FRONT,e),[o.GL.STENCIL_BACK_WRITEMASK]:(t,e)=>t.stencilMaskSeparate(o.GL.BACK,e),[o.GL.STENCIL_FUNC]:"stencilFuncFront",[o.GL.STENCIL_REF]:"stencilFuncFront",[o.GL.STENCIL_VALUE_MASK]:"stencilFuncFront",[o.GL.STENCIL_BACK_FUNC]:"stencilFuncBack",[o.GL.STENCIL_BACK_REF]:"stencilFuncBack",[o.GL.STENCIL_BACK_VALUE_MASK]:"stencilFuncBack",[o.GL.STENCIL_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_FAIL]:"stencilOpFront",[o.GL.STENCIL_PASS_DEPTH_PASS]:"stencilOpFront",[o.GL.STENCIL_BACK_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:"stencilOpBack",[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:"stencilOpBack",[o.GL.VIEWPORT]:(t,e)=>t.viewport(...e),[o.GL.DEPTH_CLAMP_EXT]:w,[o.GL.POLYGON_OFFSET_LINE_WEBGL]:w,[o.GL.CLIP_DISTANCE0_WEBGL]:w,[o.GL.CLIP_DISTANCE1_WEBGL]:w,[o.GL.CLIP_DISTANCE2_WEBGL]:w,[o.GL.CLIP_DISTANCE3_WEBGL]:w,[o.GL.CLIP_DISTANCE4_WEBGL]:w,[o.GL.CLIP_DISTANCE5_WEBGL]:w,[o.GL.CLIP_DISTANCE6_WEBGL]:w,[o.GL.CLIP_DISTANCE7_WEBGL]:w,[o.GL.PACK_ALIGNMENT]:Y,[o.GL.UNPACK_ALIGNMENT]:Y,[o.GL.UNPACK_FLIP_Y_WEBGL]:Y,[o.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL]:Y,[o.GL.UNPACK_COLORSPACE_CONVERSION_WEBGL]:Y,[o.GL.PACK_ROW_LENGTH]:Y,[o.GL.PACK_SKIP_PIXELS]:Y,[o.GL.PACK_SKIP_ROWS]:Y,[o.GL.UNPACK_ROW_LENGTH]:Y,[o.GL.UNPACK_IMAGE_HEIGHT]:Y,[o.GL.UNPACK_SKIP_PIXELS]:Y,[o.GL.UNPACK_SKIP_ROWS]:Y,[o.GL.UNPACK_SKIP_IMAGES]:Y,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(o.GL.FRAMEBUFFER,r)},blend:(t,e)=>e?t.enable(o.GL.BLEND):t.disable(o.GL.BLEND),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(o.GL.CULL_FACE):t.disable(o.GL.CULL_FACE),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(o.GL.DEPTH_TEST):t.disable(o.GL.DEPTH_TEST),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(o.GL.DITHER):t.disable(o.GL.DITHER),derivativeHint:(t,e)=>{t.hint(o.GL.FRAGMENT_SHADER_DERIVATIVE_HINT,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(o.GL.GENERATE_MIPMAP_HINT,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(o.GL.POLYGON_OFFSET_FILL):t.disable(o.GL.POLYGON_OFFSET_FILL),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(o.GL.SCISSOR_TEST):t.disable(o.GL.SCISSOR_TEST),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(o.GL.STENCIL_TEST):t.disable(o.GL.STENCIL_TEST),stencilMask:(t,e)=>{e=Lr(e)?e:[e,e];let[r,n]=e;t.stencilMaskSeparate(o.GL.FRONT,r),t.stencilMaskSeparate(o.GL.BACK,n)},stencilFunc:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;let[r,n,i,s,a,c]=e;t.stencilFuncSeparate(o.GL.FRONT,r,n,i),t.stencilFuncSeparate(o.GL.BACK,s,a,c)},stencilOp:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;let[r,n,i,s,a,c]=e;t.stencilOpSeparate(o.GL.FRONT,r,n,i),t.stencilOpSeparate(o.GL.BACK,s,a,c)},viewport:(t,e)=>t.viewport(...e)};function F(t,e,r){return e[t]!==void 0?e[t]:r[t]}var pn={blendEquation:(t,e,r)=>t.blendEquationSeparate(F(o.GL.BLEND_EQUATION_RGB,e,r),F(o.GL.BLEND_EQUATION_ALPHA,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(F(o.GL.BLEND_SRC_RGB,e,r),F(o.GL.BLEND_DST_RGB,e,r),F(o.GL.BLEND_SRC_ALPHA,e,r),F(o.GL.BLEND_DST_ALPHA,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(F(o.GL.POLYGON_OFFSET_FACTOR,e,r),F(o.GL.POLYGON_OFFSET_UNITS,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(F(o.GL.SAMPLE_COVERAGE_VALUE,e,r),F(o.GL.SAMPLE_COVERAGE_INVERT,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(o.GL.FRONT,F(o.GL.STENCIL_FUNC,e,r),F(o.GL.STENCIL_REF,e,r),F(o.GL.STENCIL_VALUE_MASK,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(o.GL.BACK,F(o.GL.STENCIL_BACK_FUNC,e,r),F(o.GL.STENCIL_BACK_REF,e,r),F(o.GL.STENCIL_BACK_VALUE_MASK,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(o.GL.FRONT,F(o.GL.STENCIL_FAIL,e,r),F(o.GL.STENCIL_PASS_DEPTH_FAIL,e,r),F(o.GL.STENCIL_PASS_DEPTH_PASS,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(o.GL.BACK,F(o.GL.STENCIL_BACK_FAIL,e,r),F(o.GL.STENCIL_BACK_PASS_DEPTH_FAIL,e,r),F(o.GL.STENCIL_BACK_PASS_DEPTH_PASS,e,r))},Ar={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[o.GL.CURRENT_PROGRAM]:e}),bindRenderbuffer:(t,e,r)=>t({[o.GL.RENDERBUFFER_BINDING]:r}),bindTransformFeedback:(t,e,r)=>t({[o.GL.TRANSFORM_FEEDBACK_BINDING]:r}),bindVertexArray:(t,e)=>t({[o.GL.VERTEX_ARRAY_BINDING]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case o.GL.FRAMEBUFFER:return t({[o.GL.DRAW_FRAMEBUFFER_BINDING]:r,[o.GL.READ_FRAMEBUFFER_BINDING]:r});case o.GL.DRAW_FRAMEBUFFER:return t({[o.GL.DRAW_FRAMEBUFFER_BINDING]:r});case o.GL.READ_FRAMEBUFFER:return t({[o.GL.READ_FRAMEBUFFER_BINDING]:r});default:return null}},bindBuffer:(t,e,r)=>{let n={[o.GL.ARRAY_BUFFER]:[o.GL.ARRAY_BUFFER_BINDING],[o.GL.COPY_READ_BUFFER]:[o.GL.COPY_READ_BUFFER_BINDING],[o.GL.COPY_WRITE_BUFFER]:[o.GL.COPY_WRITE_BUFFER_BINDING],[o.GL.PIXEL_PACK_BUFFER]:[o.GL.PIXEL_PACK_BUFFER_BINDING],[o.GL.PIXEL_UNPACK_BUFFER]:[o.GL.PIXEL_UNPACK_BUFFER_BINDING]}[e];return n?t({[n]:r}):{valueChanged:!0}},blendColor:(t,e,r,n,i)=>t({[o.GL.BLEND_COLOR]:new Float32Array([e,r,n,i])}),blendEquation:(t,e)=>t({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:e}),blendEquationSeparate:(t,e,r)=>t({[o.GL.BLEND_EQUATION_RGB]:e,[o.GL.BLEND_EQUATION_ALPHA]:r}),blendFunc:(t,e,r)=>t({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:r,[o.GL.BLEND_SRC_ALPHA]:e,[o.GL.BLEND_DST_ALPHA]:r}),blendFuncSeparate:(t,e,r,n,i)=>t({[o.GL.BLEND_SRC_RGB]:e,[o.GL.BLEND_DST_RGB]:r,[o.GL.BLEND_SRC_ALPHA]:n,[o.GL.BLEND_DST_ALPHA]:i}),clearColor:(t,e,r,n,i)=>t({[o.GL.COLOR_CLEAR_VALUE]:new Float32Array([e,r,n,i])}),clearDepth:(t,e)=>t({[o.GL.DEPTH_CLEAR_VALUE]:e}),clearStencil:(t,e)=>t({[o.GL.STENCIL_CLEAR_VALUE]:e}),colorMask:(t,e,r,n,i)=>t({[o.GL.COLOR_WRITEMASK]:[e,r,n,i]}),cullFace:(t,e)=>t({[o.GL.CULL_FACE_MODE]:e}),depthFunc:(t,e)=>t({[o.GL.DEPTH_FUNC]:e}),depthRange:(t,e,r)=>t({[o.GL.DEPTH_RANGE]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[o.GL.DEPTH_WRITEMASK]:e}),frontFace:(t,e)=>t({[o.GL.FRONT_FACE]:e}),lineWidth:(t,e)=>t({[o.GL.LINE_WIDTH]:e}),polygonOffset:(t,e,r)=>t({[o.GL.POLYGON_OFFSET_FACTOR]:e,[o.GL.POLYGON_OFFSET_UNITS]:r}),sampleCoverage:(t,e,r)=>t({[o.GL.SAMPLE_COVERAGE_VALUE]:e,[o.GL.SAMPLE_COVERAGE_INVERT]:r}),scissor:(t,e,r,n,i)=>t({[o.GL.SCISSOR_BOX]:new Int32Array([e,r,n,i])}),stencilMask:(t,e)=>t({[o.GL.STENCIL_WRITEMASK]:e,[o.GL.STENCIL_BACK_WRITEMASK]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===o.GL.FRONT?o.GL.STENCIL_WRITEMASK:o.GL.STENCIL_BACK_WRITEMASK]:r}),stencilFunc:(t,e,r,n)=>t({[o.GL.STENCIL_FUNC]:e,[o.GL.STENCIL_REF]:r,[o.GL.STENCIL_VALUE_MASK]:n,[o.GL.STENCIL_BACK_FUNC]:e,[o.GL.STENCIL_BACK_REF]:r,[o.GL.STENCIL_BACK_VALUE_MASK]:n}),stencilFuncSeparate:(t,e,r,n,i)=>t({[e===o.GL.FRONT?o.GL.STENCIL_FUNC:o.GL.STENCIL_BACK_FUNC]:r,[e===o.GL.FRONT?o.GL.STENCIL_REF:o.GL.STENCIL_BACK_REF]:n,[e===o.GL.FRONT?o.GL.STENCIL_VALUE_MASK:o.GL.STENCIL_BACK_VALUE_MASK]:i}),stencilOp:(t,e,r,n)=>t({[o.GL.STENCIL_FAIL]:e,[o.GL.STENCIL_PASS_DEPTH_FAIL]:r,[o.GL.STENCIL_PASS_DEPTH_PASS]:n,[o.GL.STENCIL_BACK_FAIL]:e,[o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:r,[o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:n}),stencilOpSeparate:(t,e,r,n,i)=>t({[e===o.GL.FRONT?o.GL.STENCIL_FAIL:o.GL.STENCIL_BACK_FAIL]:r,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_FAIL:o.GL.STENCIL_BACK_PASS_DEPTH_FAIL]:n,[e===o.GL.FRONT?o.GL.STENCIL_PASS_DEPTH_PASS:o.GL.STENCIL_BACK_PASS_DEPTH_PASS]:i}),viewport:(t,e,r,n,i)=>t({[o.GL.VIEWPORT]:[e,r,n,i]})},ie=(t,e)=>t.isEnabled(e),Rr={[o.GL.BLEND]:ie,[o.GL.CULL_FACE]:ie,[o.GL.DEPTH_TEST]:ie,[o.GL.DITHER]:ie,[o.GL.POLYGON_OFFSET_FILL]:ie,[o.GL.SAMPLE_ALPHA_TO_COVERAGE]:ie,[o.GL.SAMPLE_COVERAGE]:ie,[o.GL.SCISSOR_TEST]:ie,[o.GL.STENCIL_TEST]:ie,[o.GL.RASTERIZER_DISCARD]:ie},gn=new Set([o.GL.ACTIVE_TEXTURE,o.GL.TRANSFORM_FEEDBACK_ACTIVE,o.GL.TRANSFORM_FEEDBACK_PAUSED,o.GL.TRANSFORM_FEEDBACK_BUFFER_BINDING,o.GL.UNIFORM_BUFFER_BINDING,o.GL.ELEMENT_ARRAY_BUFFER_BINDING,o.GL.IMPLEMENTATION_COLOR_READ_FORMAT,o.GL.IMPLEMENTATION_COLOR_READ_TYPE,o.GL.READ_BUFFER,o.GL.DRAW_BUFFER0,o.GL.DRAW_BUFFER1,o.GL.DRAW_BUFFER2,o.GL.DRAW_BUFFER3,o.GL.DRAW_BUFFER4,o.GL.DRAW_BUFFER5,o.GL.DRAW_BUFFER6,o.GL.DRAW_BUFFER7,o.GL.DRAW_BUFFER8,o.GL.DRAW_BUFFER9,o.GL.DRAW_BUFFER10,o.GL.DRAW_BUFFER11,o.GL.DRAW_BUFFER12,o.GL.DRAW_BUFFER13,o.GL.DRAW_BUFFER14,o.GL.DRAW_BUFFER15,o.GL.SAMPLER_BINDING,o.GL.TEXTURE_BINDING_2D,o.GL.TEXTURE_BINDING_2D_ARRAY,o.GL.TEXTURE_BINDING_3D,o.GL.TEXTURE_BINDING_CUBE_MAP]);function X(t,e){if(so(e))return;let r={};for(let i in e){let s=Number(i),a=hn[i];a&&(typeof a=="string"?r[a]=!0:a(t,e[i],s))}let n=t.state&&t.state.cache;if(n)for(let i in r){let s=pn[i];s(t,e,n)}}function Me(t,e=ct){if(typeof e=="number"){let i=e,s=Rr[i];return s?s(t,i):t.getParameter(i)}let r=Array.isArray(e)?e:Object.keys(e),n={};for(let i of r){let s=Rr[i];n[i]=s?s(t,Number(i)):t.getParameter(Number(i))}return n}function En(t){X(t,ct)}function so(t){for(let e in t)return!1;return!0}function bn(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),n=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&n&&t.length===e.length){for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}return!1}var Sr=class{gl;program=null;stateStack=[];enable=!0;cache;log;constructor(e,{copyState:r=!1,log:n=()=>{}}={}){this.gl=e,this.cache=r?Me(e):Object.assign({},ct),this.log=n,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){R(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];X(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){R(s!==void 0);let a=e[s],c=this.cache[s];bn(a,c)||(r=!0,n=c,i&&!(s in i)&&(i[s]=c),this.cache[s]=a)}return{valueChanged:r,oldValue:n}}};function Le(t){return t.state}function lt(t,e){let{enable:r=!0,copyState:n}=e;if(R(n!==void 0),!t.state){t.state=new Sr(t,{copyState:n}),uo(t);for(let s in Ar){let a=Ar[s];ao(t,s,a)}_n(t,"getParameter"),_n(t,"isEnabled")}let i=Le(t);return i.enable=r,t}function te(t){let e=Le(t);e||(lt(t,{copyState:!1}),e=Le(t)),e.push()}function q(t){let e=Le(t);R(e),e.pop()}function _n(t,e){let r=t[e].bind(t);t[e]=function(i){if(i===void 0||gn.has(i))return r(i);let s=Le(t);return i in s.cache||(s.cache[i]=r(i)),s.enable?s.cache[i]:r(i)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function ao(t,e,r){if(!t[e])return;let n=t[e].bind(t);t[e]=function(...s){let a=Le(t),{valueChanged:c,oldValue:l}=r(a._updateCache,...s);return c&&n(...s),l},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function uo(t){let e=t.useProgram.bind(t);t.useProgram=function(n){let i=Le(t);i.program!==n&&(e(n),i.program=n)}}var co={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Tn(t,e){e={...co,...e};let r=null,n=s=>r=s.statusMessage||r;t.addEventListener("webglcontextcreationerror",n,!1);let i=null;if(i||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",n,!1),!i)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:s}=e;t.addEventListener("webglcontextlost",a=>s(a),!1)}if(e.onContextRestored){let{onContextRestored:s}=e;t.addEventListener("webglcontextrestored",a=>s(a),!1)}return i}var We=y(S(),1);function Z(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function Ln(t,e){let r=t.getParameter(We.GL.VENDOR),n=t.getParameter(We.GL.RENDERER);Z(t,"WEBGL_debug_renderer_info",e);let i=e.WEBGL_debug_renderer_info,s=t.getParameter(i?i.UNMASKED_VENDOR_WEBGL:We.GL.VENDOR),a=t.getParameter(i?i.UNMASKED_RENDERER_WEBGL:We.GL.RENDERER),c=s||r,l=a||n,d=t.getParameter(We.GL.VERSION),m=An(c,l),b=lo(c,l),g=fo(c,l);return{type:"webgl",gpu:m,gpuType:g,gpuBackend:b,vendor:c,renderer:l,version:d,shadingLanguage:"glsl",shadingLanguageVersion:300}}function An(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function lo(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function fo(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(An(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var u=y(S(),1);var z=y(S(),1);function wt(t){switch(t){case"uint8":return z.GL.UNSIGNED_BYTE;case"sint8":return z.GL.BYTE;case"unorm8":return z.GL.UNSIGNED_BYTE;case"snorm8":return z.GL.BYTE;case"uint16":return z.GL.UNSIGNED_SHORT;case"sint16":return z.GL.SHORT;case"unorm16":return z.GL.UNSIGNED_SHORT;case"snorm16":return z.GL.SHORT;case"uint32":return z.GL.UNSIGNED_INT;case"sint32":return z.GL.INT;case"float16":return z.GL.HALF_FLOAT;case"float32":return z.GL.FLOAT}throw new Error(String(t))}var M="texture-compression-bc",C="texture-compression-astc",oe="texture-compression-etc2",mo="texture-compression-etc1-webgl",Ot="texture-compression-pvrtc-webgl",xr="texture-compression-atc-webgl",ft="float32-renderable-webgl",yr="float16-renderable-webgl",ho="rgb9e5ufloat_renderable-webgl",Cr="snorm8-renderable-webgl",dt="norm16-renderable-webgl",Gr="snorm16-renderable-webgl",Ut="float32-filterable",Rn="float16-filterable-webgl",mt="WEBGL_compressed_texture_s3tc",ht="WEBGL_compressed_texture_s3tc_srgb",He="EXT_texture_compression_rgtc",ke="EXT_texture_compression_bptc",po="WEBGL_compressed_texture_etc",go="WEBGL_compressed_texture_astc",Eo="WEBGL_compressed_texture_etc1",bo="WEBGL_compressed_texture_pvrtc",_o="WEBGL_compressed_texture_atc",Sn="EXT_texture_norm16",xn="EXT_render_snorm",To="EXT_color_buffer_float",Mt={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[xn],"norm16-renderable-webgl":[Sn],"snorm16-renderable-webgl":[Sn,xn],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[mt,ht,He,ke],"texture-compression-bc5-webgl":[He],"texture-compression-bc7-webgl":[ke],"texture-compression-etc2":[po],"texture-compression-astc":[go],"texture-compression-etc1-webgl":[Eo],"texture-compression-pvrtc-webgl":[bo],"texture-compression-atc-webgl":[_o]};function yn(t){return t in Mt}function Cn(t,e,r){return(Mt[e]||[]).every(i=>Z(t,i,r))}var ge={"rgb8unorm-unsized":{gl:u.GL.RGB,b:4,c:2,bpp:4,dataFormat:u.GL.RGB,types:[u.GL.UNSIGNED_BYTE,u.GL.UNSIGNED_SHORT_5_6_5]},"rgba8unorm-unsized":{gl:u.GL.RGBA,b:4,c:2,bpp:4,dataFormat:u.GL.RGBA,types:[u.GL.UNSIGNED_BYTE,u.GL.UNSIGNED_SHORT_4_4_4_4,u.GL.UNSIGNED_SHORT_5_5_5_1]},r8unorm:{gl:u.GL.R8,b:1,c:1,rb:!0},r8snorm:{gl:u.GL.R8_SNORM,b:1,c:1,render:Cr},r8uint:{gl:u.GL.R8UI,b:1,c:1,rb:!0},r8sint:{gl:u.GL.R8I,b:1,c:1,rb:!0},rg8unorm:{gl:u.GL.RG8,b:2,c:2,rb:!0},rg8snorm:{gl:u.GL.RG8_SNORM,b:2,c:2,render:Cr},rg8uint:{gl:u.GL.RG8UI,b:2,c:2,rb:!0},rg8sint:{gl:u.GL.RG8I,b:2,c:2,rb:!0},r16uint:{gl:u.GL.R16UI,b:2,c:1,rb:!0},r16sint:{gl:u.GL.R16I,b:2,c:1,rb:!0},r16float:{gl:u.GL.R16F,b:2,c:1,render:yr,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:u.GL.R16_EXT,b:2,c:1,f:dt,rb:!0},"r16snorm-webgl":{gl:u.GL.R16_SNORM_EXT,b:2,c:1,f:Gr},"rgba4unorm-webgl":{gl:u.GL.RGBA4,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:u.GL.RGB565,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:u.GL.RGB5_A1,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:u.GL.RGB8,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:u.GL.RGB8_SNORM,b:3,c:3,wgpu:!1},rgba8unorm:{gl:u.GL.RGBA8,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:u.GL.SRGB8_ALPHA8,b:4,c:4,bpp:4},rgba8snorm:{gl:u.GL.RGBA8_SNORM,b:4,c:4,render:Cr},rgba8uint:{gl:u.GL.RGBA8UI,b:4,c:4,bpp:4},rgba8sint:{gl:u.GL.RGBA8I,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:u.GL.RG16UI,b:4,c:1,bpp:4},rg16sint:{gl:u.GL.RG16I,b:4,c:2,bpp:4},rg16float:{gl:u.GL.RG16F,bpp:4,b:4,c:2,render:yr,filter:Rn,rb:!0},"rg16unorm-webgl":{gl:u.GL.RG16_EXT,b:2,c:2,render:dt},"rg16snorm-webgl":{gl:u.GL.RG16_SNORM_EXT,b:2,c:2,render:Gr},r32uint:{gl:u.GL.R32UI,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:u.GL.R32I,b:4,c:1,bpp:4,rb:!0},r32float:{gl:u.GL.R32F,bpp:4,b:4,c:1,render:ft,filter:Ut},rgb9e5ufloat:{gl:u.GL.RGB9_E5,b:4,c:3,p:1,render:ho},rg11b10ufloat:{gl:u.GL.R11F_G11F_B10F,b:4,c:3,p:1,render:ft,rb:!0},rgb10a2unorm:{gl:u.GL.RGB10_A2,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:u.GL.RGB10_A2UI,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:u.GL.RGB16_EXT,b:2,c:3,f:dt},"rgb16snorm-webgl":{gl:u.GL.RGB16_SNORM_EXT,b:2,c:3,f:dt},rg32uint:{gl:u.GL.RG32UI,b:8,c:2,rb:!0},rg32sint:{gl:u.GL.RG32I,b:8,c:2,rb:!0},rg32float:{gl:u.GL.RG32F,b:8,c:2,render:ft,filter:Ut,rb:!0},rgba16uint:{gl:u.GL.RGBA16UI,b:8,c:4,rb:!0},rgba16sint:{gl:u.GL.RGBA16I,b:8,c:4,rb:!0},rgba16float:{gl:u.GL.RGBA16F,b:8,c:4,render:yr,filter:Rn},"rgba16unorm-webgl":{gl:u.GL.RGBA16_EXT,b:2,c:4,render:dt,rb:!0},"rgba16snorm-webgl":{gl:u.GL.RGBA16_SNORM_EXT,b:2,c:4,render:Gr},"rgb32float-webgl":{gl:u.GL.RGB32F,render:ft,filter:Ut,gl2ext:To,dataFormat:u.GL.RGB,types:[u.GL.FLOAT]},rgba32uint:{gl:u.GL.RGBA32UI,b:16,c:4,rb:!0},rgba32sint:{gl:u.GL.RGBA32I,b:16,c:4,rb:!0},rgba32float:{gl:u.GL.RGBA32F,b:16,c:4,render:ft,filter:Ut,rb:!0},stencil8:{gl:u.GL.STENCIL_INDEX8,b:1,c:1,attachment:u.GL.STENCIL_ATTACHMENT,rb:!0},depth16unorm:{gl:u.GL.DEPTH_COMPONENT16,b:2,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.UNSIGNED_SHORT],rb:!0},depth24plus:{gl:u.GL.DEPTH_COMPONENT24,b:3,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.UNSIGNED_INT]},depth32float:{gl:u.GL.DEPTH_COMPONENT32F,b:4,c:1,attachment:u.GL.DEPTH_ATTACHMENT,dataFormat:u.GL.DEPTH_COMPONENT,types:[u.GL.FLOAT],rb:!0},"depth24plus-stencil8":{gl:u.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,rb:!0,depthTexture:!0,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.UNSIGNED_INT_24_8]},"depth24unorm-stencil8":{gl:u.GL.DEPTH24_STENCIL8,b:4,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.UNSIGNED_INT_24_8],rb:!0},"depth32float-stencil8":{gl:u.GL.DEPTH32F_STENCIL8,b:5,c:2,p:1,attachment:u.GL.DEPTH_STENCIL_ATTACHMENT,dataFormat:u.GL.DEPTH_STENCIL,types:[u.GL.FLOAT_32_UNSIGNED_INT_24_8_REV],rb:!0},"bc1-rgb-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_S3TC_DXT1_EXT,x:mt,f:M},"bc1-rgb-unorm-srgb-webgl":{gl:u.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:ht,f:M},"bc1-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT1_EXT,x:mt,f:M},"bc1-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_S3TC_DXT1_EXT,x:ht,f:M},"bc2-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT3_EXT,x:mt,f:M},"bc2-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,x:ht,f:M},"bc3-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_S3TC_DXT5_EXT,x:mt,f:M},"bc3-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,x:ht,f:M},"bc4-r-unorm":{gl:u.GL.COMPRESSED_RED_RGTC1_EXT,x:He,f:M},"bc4-r-snorm":{gl:u.GL.COMPRESSED_SIGNED_RED_RGTC1_EXT,x:He,f:M},"bc5-rg-unorm":{gl:u.GL.COMPRESSED_RED_GREEN_RGTC2_EXT,x:He,f:M},"bc5-rg-snorm":{gl:u.GL.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,x:He,f:M},"bc6h-rgb-ufloat":{gl:u.GL.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,x:ke,f:M},"bc6h-rgb-float":{gl:u.GL.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,x:ke,f:M},"bc7-rgba-unorm":{gl:u.GL.COMPRESSED_RGBA_BPTC_UNORM_EXT,x:ke,f:M},"bc7-rgba-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,x:ke,f:M},"etc2-rgb8unorm":{gl:u.GL.COMPRESSED_RGB8_ETC2,f:oe},"etc2-rgb8unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ETC2,f:oe},"etc2-rgb8a1unorm":{gl:u.GL.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgb8a1unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,f:oe},"etc2-rgba8unorm":{gl:u.GL.COMPRESSED_RGBA8_ETC2_EAC,f:oe},"etc2-rgba8unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,f:oe},"eac-r11unorm":{gl:u.GL.COMPRESSED_R11_EAC,f:oe},"eac-r11snorm":{gl:u.GL.COMPRESSED_SIGNED_R11_EAC,f:oe},"eac-rg11unorm":{gl:u.GL.COMPRESSED_RG11_EAC,f:oe},"eac-rg11snorm":{gl:u.GL.COMPRESSED_SIGNED_RG11_EAC,f:oe},"astc-4x4-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_4x4_KHR,f:C},"astc-4x4-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,f:C},"astc-5x4-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_5x4_KHR,f:C},"astc-5x4-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,f:C},"astc-5x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_5x5_KHR,f:C},"astc-5x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,f:C},"astc-6x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_6x5_KHR,f:C},"astc-6x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,f:C},"astc-6x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_6x6_KHR,f:C},"astc-6x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,f:C},"astc-8x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x5_KHR,f:C},"astc-8x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,f:C},"astc-8x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x6_KHR,f:C},"astc-8x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,f:C},"astc-8x8-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_8x8_KHR,f:C},"astc-8x8-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,f:C},"astc-10x5-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x5-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-10x6-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x6_KHR,f:C},"astc-10x6-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,f:C},"astc-10x8-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x8_KHR,f:C},"astc-10x8-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,f:C},"astc-10x10-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_10x10_KHR,f:C},"astc-10x10-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,f:C},"astc-12x10-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_12x10_KHR,f:C},"astc-12x10-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,f:C},"astc-12x12-unorm":{gl:u.GL.COMPRESSED_RGBA_ASTC_12x12_KHR,f:C},"astc-12x12-unorm-srgb":{gl:u.GL.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,f:C},"pvrtc-rgb4unorm-webgl":{gl:u.GL.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,f:Ot},"pvrtc-rgba4unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,f:Ot},"pvrtc-rbg2unorm-webgl":{gl:u.GL.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,f:Ot},"pvrtc-rgba2unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,f:Ot},"etc1-rbg-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_ETC1_WEBGL,f:mo},"atc-rgb-unorm-webgl":{gl:u.GL.COMPRESSED_RGB_ATC_WEBGL,f:xr},"atc-rgba-unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,f:xr},"atc-rgbai-unorm-webgl":{gl:u.GL.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,f:xr}},Lo={[u.GL.RED]:1,[u.GL.RED_INTEGER]:1,[u.GL.RG]:2,[u.GL.RG_INTEGER]:2,[u.GL.RGB]:3,[u.GL.RGB_INTEGER]:3,[u.GL.RGBA]:4,[u.GL.RGBA_INTEGER]:4,[u.GL.DEPTH_COMPONENT]:1,[u.GL.DEPTH_STENCIL]:1,[u.GL.ALPHA]:1,[u.GL.LUMINANCE]:1,[u.GL.LUMINANCE_ALPHA]:2},Ao={[u.GL.FLOAT]:4,[u.GL.UNSIGNED_INT]:4,[u.GL.INT]:4,[u.GL.UNSIGNED_SHORT]:2,[u.GL.SHORT]:2,[u.GL.HALF_FLOAT]:2,[u.GL.BYTE]:1,[u.GL.UNSIGNED_BYTE]:1};function pt(t,e,r){let n=ge[e];if(!n||n.gl===void 0)return!1;let i=n.x||n.gl2ext;return i?Boolean(Z(t,i,r)):!0}function Gn(t,e,r){return pt(t,e,r)&&ge[e]?.rb}function Pn(t){if(typeof t=="string")return t;let e=Object.entries(ge).find(([,r])=>r.gl===t);if(!e)throw new Error(`Unknown texture format ${t}`);return e[0]}function gt(t){let r=ge[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function Fn(t,e,r){if(!pt(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(Nt(e).signed)return!1}catch{return!1}return e.endsWith("32float")?Boolean(Z(t,"OES_texture_float_linear, extensions",r)):e.endsWith("16float")?Boolean(Z(t,"OES_texture_half_float_linear, extensions",r)):!0}function Bn(t,e,r){return!(!pt(t,e,r)||typeof e=="number")}function Ve(t){let e=ge[t],r=gt(t),n=Nt(t);return{format:r,dataFormat:e?.dataFormat||Ro(n.format,n.integer,n.normalized,r),type:n.dataType?wt(n.dataType):e?.types?.[0]||u.GL.UNSIGNED_BYTE,compressed:n.compressed}}function In(t){let e=ge[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function Et(t){let e=Ve(t),r=Lo[e.dataFormat]||4,n=Ao[e.type]||1;return r*n}function Ro(t,e,r,n){if(n===u.GL.RGBA||n===u.GL.RGB)return n;switch(t){case"r":return e&&!r?u.GL.RED_INTEGER:u.GL.RED;case"rg":return e&&!r?u.GL.RG_INTEGER:u.GL.RG;case"rgb":return e&&!r?u.GL.RGB_INTEGER:u.GL.RGB;case"rgba":return e&&!r?u.GL.RGBA_INTEGER:u.GL.RGBA;default:return u.GL.RGBA}}var Nn={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},Wt=class extends st{gl;extensions;testedFeatures=new Set;constructor(e,r,n){super([],n),this.gl=e,this.extensions=r,Z(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){for(let e of Object.keys(Nn))this.has(e)&&(yield e);for(let e of Object.keys(Mt))this.has(e)&&(yield e);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),yn(e)&&Cn(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){for(let e of this);}getWebGLFeature(e){let r=Nn[e];return Boolean(typeof r=="string"?Z(this.gl,r,this.extensions):r)}};var re=y(S(),1),Ht=class extends ot{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(re.GL.MAX_TEXTURE_SIZE)}get maxTextureDimension3D(){return this.getParameter(re.GL.MAX_3D_TEXTURE_SIZE)}get maxTextureArrayLayers(){return this.getParameter(re.GL.MAX_ARRAY_TEXTURE_LAYERS)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(re.GL.MAX_VERTEX_TEXTURE_IMAGE_UNITS)}get maxSamplersPerShaderStage(){return this.getParameter(re.GL.MAX_COMBINED_TEXTURE_IMAGE_UNITS)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(re.GL.MAX_UNIFORM_BUFFER_BINDINGS)}get maxUniformBufferBindingSize(){return this.getParameter(re.GL.MAX_UNIFORM_BLOCK_SIZE)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(re.GL.UNIFORM_BUFFER_OFFSET_ALIGNMENT)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(re.GL.MAX_VERTEX_ATTRIBS)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(re.GL.MAX_VARYING_COMPONENTS)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};var B=y(S(),1);var G=y(S(),1);function K(t,e,r){if(So(e))return r(t);let{nocatch:n=!0}=e;te(t),X(t,e);let i;if(n)i=r(t),q(t);else try{i=r(t)}finally{q(t)}return i}function So(t){for(let e in t)return!1;return!0}var N=y(S(),1);var h=y(S(),1);function vn(t,e,r,n){if(Ge(e))return n(t);let i=t;te(i.gl);try{return Xt(t,e),X(i.gl,r),n(t)}finally{q(i.gl)}}function wn(t,e,r){if(Ge(e))return r(t);te(t.gl);try{return Xt(t,e),r(t)}finally{q(t.gl)}}function Xt(t,e){let r=t,{gl:n}=r;if(e.cullMode)switch(e.cullMode){case"none":n.disable(h.GL.CULL_FACE);break;case"front":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.FRONT);break;case"back":n.enable(h.GL.CULL_FACE),n.cullFace(h.GL.BACK);break}if(e.frontFace&&n.frontFace(Ae("frontFace",e.frontFace,{ccw:h.GL.CCW,cw:h.GL.CW})),e.unclippedDepth&&t.features.has("depth-clip-control")&&n.enable(h.GL.DEPTH_CLAMP_EXT),e.depthBias!==void 0&&n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0),t.features.has("provoking-vertex-webgl")){let s=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex;if(e.provokingVertex){let a=Ae("provokingVertex",e.provokingVertex,{first:h.GL.FIRST_VERTEX_CONVENTION_WEBGL,last:h.GL.LAST_VERTEX_CONVENTION_WEBGL});s?.provokingVertexWEBGL(a)}}if(t.features.has("polygon-mode-webgl")){let s=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode;if(e.polygonMode){let a=Ae("polygonMode",e.provokingVertex,{fill:h.GL.FILL_WEBGL,lint:h.GL.LINE_WEBGL});s?.polygonModeWEBGL(h.GL.FRONT,a),s?.polygonModeWEBGL(h.GL.BACK,a)}e.polygonOffsetLine&&n.enable(h.GL.POLYGON_OFFSET_LINE_WEBGL)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(h.GL.CLIP_DISTANCE0_WEBGL),e.clipDistance1&&n.enable(h.GL.CLIP_DISTANCE1_WEBGL),e.clipDistance2&&n.enable(h.GL.CLIP_DISTANCE2_WEBGL),e.clipDistance3&&n.enable(h.GL.CLIP_DISTANCE3_WEBGL),e.clipDistance4&&n.enable(h.GL.CLIP_DISTANCE4_WEBGL),e.clipDistance5&&n.enable(h.GL.CLIP_DISTANCE5_WEBGL),e.clipDistance6&&n.enable(h.GL.CLIP_DISTANCE6_WEBGL),e.clipDistance7&&n.enable(h.GL.CLIP_DISTANCE7_WEBGL)),e.depthWriteEnabled!==void 0&&n.depthMask(yo("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(h.GL.DEPTH_TEST):n.disable(h.GL.DEPTH_TEST),n.depthFunc(Vt("depthCompare",e.depthCompare))),e.stencilWriteMask){let i=e.stencilWriteMask;n.stencilMaskSeparate(h.GL.FRONT,i),n.stencilMaskSeparate(h.GL.BACK,i)}if(e.stencilReadMask&&f.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let i=e.stencilReadMask||4294967295,s=Vt("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(h.GL.STENCIL_TEST):n.disable(h.GL.STENCIL_TEST),n.stencilFuncSeparate(h.GL.FRONT,s,0,i),n.stencilFuncSeparate(h.GL.BACK,s,0,i)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let i=Pr("stencilPassOperation",e.stencilPassOperation),s=Pr("stencilFailOperation",e.stencilFailOperation),a=Pr("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(h.GL.FRONT,s,a,i),n.stencilOpSeparate(h.GL.BACK,s,a,i)}if(e.blendColorOperation||e.blendAlphaOperation){n.enable(h.GL.BLEND);let i=Dn("blendColorOperation",e.blendColorOperation||"add"),s=Dn("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let a=kt("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=kt("blendColorDstFactor",e.blendColorDstFactor||"zero"),l=kt("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),d=kt("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(a,c,l,d)}}function Vt(t,e){return Ae(t,e,{never:h.GL.NEVER,less:h.GL.LESS,equal:h.GL.EQUAL,"less-equal":h.GL.LEQUAL,greater:h.GL.GREATER,"not-equal":h.GL.NOTEQUAL,"greater-equal":h.GL.GEQUAL,always:h.GL.ALWAYS})}function Pr(t,e){return Ae(t,e,{keep:h.GL.KEEP,zero:h.GL.ZERO,replace:h.GL.REPLACE,invert:h.GL.INVERT,"increment-clamp":h.GL.INCR,"decrement-clamp":h.GL.DECR,"increment-wrap":h.GL.INCR_WRAP,"decrement-wrap":h.GL.DECR_WRAP})}function Dn(t,e){return Ae(t,e,{add:h.GL.FUNC_ADD,subtract:h.GL.FUNC_SUBTRACT,"reverse-subtract":h.GL.FUNC_REVERSE_SUBTRACT,min:h.GL.MIN,max:h.GL.MAX})}function kt(t,e){return Ae(t,e,{one:h.GL.ONE,zero:h.GL.ZERO,"src-color":h.GL.SRC_COLOR,"one-minus-src-color":h.GL.ONE_MINUS_SRC_COLOR,"dst-color":h.GL.DST_COLOR,"one-minus-dst-color":h.GL.ONE_MINUS_DST_COLOR,"src-alpha":h.GL.SRC_ALPHA,"one-minus-src-alpha":h.GL.ONE_MINUS_SRC_ALPHA,"dst-alpha":h.GL.DST_ALPHA,"one-minus-dst-alpha":h.GL.ONE_MINUS_DST_ALPHA})}function xo(t,e){return`Illegal parameter ${e} for ${t}`}function Ae(t,e,r){if(!(e in r))throw new Error(xo(t,e));return r[e]}function yo(t,e){return e}function Kt(t){let e={};return t.addressModeU&&(e[N.GL.TEXTURE_WRAP_S]=Fr(t.addressModeU)),t.addressModeV&&(e[N.GL.TEXTURE_WRAP_T]=Fr(t.addressModeV)),t.addressModeW&&(e[N.GL.TEXTURE_WRAP_R]=Fr(t.addressModeW)),t.magFilter&&(e[N.GL.TEXTURE_MAG_FILTER]=On(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[N.GL.TEXTURE_MIN_FILTER]=Co(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[N.GL.TEXTURE_MIN_LOD]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[N.GL.TEXTURE_MAX_LOD]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[N.GL.TEXTURE_COMPARE_MODE]=N.GL.COMPARE_REF_TO_TEXTURE),t.compare&&(e[N.GL.TEXTURE_COMPARE_FUNC]=Vt("compare",t.compare)),t.maxAnisotropy&&(e[N.GL.TEXTURE_MAX_ANISOTROPY_EXT]=t.maxAnisotropy),e}function Fr(t){switch(t){case"clamp-to-edge":return N.GL.CLAMP_TO_EDGE;case"repeat":return N.GL.REPEAT;case"mirror-repeat":return N.GL.MIRRORED_REPEAT}}function On(t){switch(t){case"nearest":return N.GL.NEAREST;case"linear":return N.GL.LINEAR}}function Co(t,e){if(!e)return On(t);switch(t){case"nearest":return e==="nearest"?N.GL.NEAREST_MIPMAP_NEAREST:N.GL.NEAREST_MIPMAP_LINEAR;case"linear":return e==="nearest"?N.GL.LINEAR_MIPMAP_NEAREST:N.GL.LINEAR_MIPMAP_LINEAR}}var W=y(S(),1),H=class extends P{device;gl;handle;glTarget;glUsage;glIndexType=W.GL.UNSIGNED_SHORT;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=Go(this.props.usage),this.glUsage=Po(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?W.GL.UNSIGNED_INT:W.GL.UNSIGNED_SHORT,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,n=e.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,e),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,r,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){R(e>=0);let r=e;e===0&&(r=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){let s=W.GL.COPY_WRITE_BUFFER;this.gl.bindBuffer(s,this.handle),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let n=new Uint8Array(r),i=0;return this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,this.handle),this.gl.getBufferSubData(W.GL.COPY_READ_BUFFER,e,n,i,r),this.gl.bindBuffer(W.GL.COPY_READ_BUFFER,null),this._setDebugData(n,e,r),n}};function Go(t){return t&P.INDEX?W.GL.ELEMENT_ARRAY_BUFFER:t&P.VERTEX?W.GL.ARRAY_BUFFER:t&P.UNIFORM?W.GL.UNIFORM_BUFFER:W.GL.ARRAY_BUFFER}function Po(t){return t&P.INDEX?W.GL.STATIC_DRAW:t&P.VERTEX?W.GL.STATIC_DRAW:t&P.UNIFORM?W.GL.DYNAMIC_DRAW:W.GL.STATIC_DRAW}var Br=y(S(),1);var ce=class extends Be{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=Kt(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,n]of Object.entries(e)){let i=Number(r);switch(i){case Br.GL.TEXTURE_MIN_LOD:case Br.GL.TEXTURE_MAX_LOD:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}};var se=class extends Pe{device;gl;handle;texture;constructor(e,r){super(e,{...I.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var Fo={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},$t=class extends I{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{...Fo,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=G.GL.RGBA,this.target=Bo(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Tr(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new se(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(ne=>this.initialize(Object.assign({},e,{pixels:ne,data:ne}))),this;let n=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(n&&r.readyState<HTMLVideoElement.HAVE_METADATA)return this._video=null,r.addEventListener("loadeddata",()=>this.initialize(e)),this;let{parameters:i={}}=e,{pixels:s=null,pixelStore:a={},textureUnit:c=void 0,mipmaps:l=!0}=e;r||(r=s);let{width:d,height:m,dataFormat:b,type:g,compressed:L=!1}=e,{depth:A=0}=e,D=gt(e.format);return{width:d,height:m,compressed:L,dataFormat:b,type:g}=this._deduceParameters({format:e.format,type:g,dataFormat:b,compressed:L,data:r,width:d,height:m}),this.width=d,this.height=m,this.glFormat=D,this.type=g,this.dataFormat=b,this.textureUnit=c,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(G.GL.TEXTURE0+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=l,this.setImageData({data:r,width:d,height:m,depth:A,format:D,type:g,dataFormat:b,parameters:a,compressed:L}),this.setSampler(e.sampler),this._setSamplerParameters(i),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),l&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),n&&(this._video={video:r,parameters:i,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:n={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(n)}),this}setSampler(e={}){let r;e instanceof ce?(this.sampler=e,r=e.props):(this.sampler=new ce(this.device,e),r=e);let n=Kt(r);return this._setSamplerParameters(n),this}resize(e){let{height:r,width:n,mipmaps:i=!1}=e;return n!==this.width||r!==this.height?this.initialize({width:n,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:i}):this}update(){if(this._video){let{video:e,parameters:r,lastTime:n}=this._video;if(n===e.currentTime||e.readyState<HTMLVideoElement.HAVE_CURRENT_DATA)return;this.setSubImageData({data:e,parameters:r}),this.mipmaps&&this.generateMipmap(),this._video.lastTime=e.currentTime}}generateMipmap(e={}){return this.mipmaps=!0,this.gl.bindTexture(this.target,this.handle),K(this.gl,e,()=>{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:n=null,level:i=0,glFormat:s=this.glFormat,offset:a=0,parameters:c={}}=e,{data:l=null,type:d=this.type,width:m=this.width,height:b=this.height,dataFormat:g=this.dataFormat,compressed:L=!1}=e;l||(l=n),{type:d,dataFormat:g,compressed:L,width:m,height:b}=this._deduceParameters({format:this.props.format,type:d,dataFormat:g,compressed:L,data:l,width:m,height:b});let{gl:A}=this;A.bindTexture(this.target,this.handle);let D=null;if({data:l,dataType:D}=this._getDataType({data:l,compressed:L}),K(this.gl,c,()=>{switch(D){case"null":A.texImage2D(r,i,s,m,b,0,g,d,l);break;case"typed-array":A.texImage2D(r,i,s,m,b,0,g,d,l,a);break;case"buffer":this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,l.handle||l),this.device.gl.texImage2D(r,i,s,m,b,0,g,d,a),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null);break;case"browser-object":A.texImage2D(r,i,s,m,b,0,g,d,l);break;case"compressed":for(let[ne,fe]of l.entries())A.compressedTexImage2D(r,ne,fe.format,fe.width,fe.height,0,fe.data);break;default:R(!1,"Unknown image data type")}}),l&&l.byteLength)this.trackAllocatedMemory(l.byteLength,"Texture");else{let ne=Et(this.props.format);this.trackAllocatedMemory(this.width*this.height*ne,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:n=null,x:i=0,y:s=0,width:a=this.width,height:c=this.height,level:l=0,glFormat:d=this.glFormat,type:m=this.type,dataFormat:b=this.dataFormat,compressed:g=!1,offset:L=0,parameters:A={}}){if({type:m,dataFormat:b,compressed:g,width:a,height:c}=this._deduceParameters({format:this.props.format,type:m,dataFormat:b,compressed:g,data:n,width:a,height:c}),R(this.depth===1,"texSubImage not supported for 3D textures"),n||(n=r),n&&n.data){let D=n;n=D.data,a=D.shape[0],c=D.shape[1]}n instanceof H&&(n=n.handle),this.gl.bindTexture(this.target,this.handle),K(this.gl,A,()=>{g?this.gl.compressedTexSubImage2D(e,l,i,s,a,c,d,n):n===null?this.gl.texSubImage2D(e,l,i,s,a,c,b,m,null):ArrayBuffer.isView(n)?this.gl.texSubImage2D(e,l,i,s,a,c,b,m,n,L):typeof WebGLBuffer<"u"&&n instanceof WebGLBuffer?(this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,n),this.device.gl.texSubImage2D(e,l,i,s,a,c,b,m,L),this.device.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,null)):this.device.gl.texSubImage2D(e,l,i,s,a,c,b,m,n)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return f.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(G.GL.ACTIVE_TEXTURE)-G.GL.TEXTURE0}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof H?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:n}=e,{width:i,height:s,dataFormat:a,type:c,compressed:l}=e,d=Ve(r);return a=a||d.dataFormat,c=c||d.type,l=l||d.compressed,{width:i,height:s}=this._deduceImageSize(n,i,s),{dataFormat:a,type:c,compressed:l,width:i,height:s,format:r,data:n}}_deduceImageSize(e,r,n){let i;return typeof ImageData<"u"&&e instanceof ImageData?i={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?i={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?i={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?i={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?i={width:e.videoWidth,height:e.videoHeight}:e?i={width:r,height:n}:i={width:r>=0?r:1,height:n>=0?n:1},R(i,"Could not deduced texture size"),R(r===void 0||i.width===r,"Deduced texture width does not match supplied width"),R(n===void 0||i.height===n,"Deduced texture height does not match supplied height"),i}async setCubeMapImageData(e){let{gl:r}=this,{width:n,height:i,pixels:s,data:a,format:c=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,d=s||a,m=await Promise.all($t.FACES.map(b=>{let g=d[b];return Promise.all(Array.isArray(g)?g:[g])}));this.bind(),$t.FACES.forEach((b,g)=>{m[g].length>1&&this.props.mipmaps!==!1&&f.warn(`${this.id} has mipmap and multiple LODs.`)(),m[g].forEach((L,A)=>{n&&i?r.texImage2D(b,A,c,n,i,0,c,l,L):r.texImage2D(b,A,c,c,l,L)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:n,height:i,pixels:s,data:a,format:c=G.GL.RGBA,type:l=G.GL.UNSIGNED_BYTE}=e,{gl:d}=this,m=s||a;return this.bind(),m instanceof Promise?m.then(b=>this.setImageDataForFace(Object.assign({},e,{face:r,data:b,pixels:b}))):this.width||this.height?d.texImage2D(r,0,c,n,i,0,c,l,m):d.texImage2D(r,0,c,c,l,m),this}setImageData3D(e){let{level:r=0,dataFormat:n,format:i,type:s,width:a,height:c,depth:l=1,offset:d=0,data:m,parameters:b={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let g=Ve(i);if(K(this.gl,b,()=>{ArrayBuffer.isView(m)&&this.gl.texImage3D(this.target,r,g.format,a,c,l,0,g.dataFormat,g.type,m),m instanceof H&&(this.gl.bindBuffer(G.GL.PIXEL_UNPACK_BUFFER,m.handle),this.gl.texImage3D(this.target,r,n,a,c,l,0,i,s,d))}),m&&m.byteLength)this.trackAllocatedMemory(m.byteLength,"Texture");else{let L=Et(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*L,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Ge(e)){Io(e),this.gl.bindTexture(this.target,this.handle);for(let[r,n]of Object.entries(e)){let i=Number(r),s=n;switch(i){case G.GL.TEXTURE_MIN_LOD:case G.GL.TEXTURE_MAX_LOD:this.gl.texParameterf(this.target,i,s);break;default:this.gl.texParameteri(this.target,i,s);break}}this.gl.bindTexture(this.target,null)}}},U=$t;E(U,"FACES",[G.GL.TEXTURE_CUBE_MAP_POSITIVE_X,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_X,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Y,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Y,G.GL.TEXTURE_CUBE_MAP_POSITIVE_Z,G.GL.TEXTURE_CUBE_MAP_NEGATIVE_Z]);function Bo(t){switch(t.dimension){case"2d":return G.GL.TEXTURE_2D;case"cube":return G.GL.TEXTURE_CUBE_MAP;case"2d-array":return G.GL.TEXTURE_2D_ARRAY;case"3d":return G.GL.TEXTURE_3D;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function Io(t){f.log(1,"texture sampler parameters",t)()}var J=class extends pe{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let n=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),!n){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures(),this.gl.bindFramebuffer(B.GL.FRAMEBUFFER,this.handle);for(let i=0;i<this.colorAttachments.length;++i){let s=this.colorAttachments[i],a=B.GL.COLOR_ATTACHMENT0+i;s&&this._attachOne(a,s)}if(this.depthStencilAttachment&&this._attachOne(In(this.depthStencilAttachment.props.format),this.depthStencilAttachment),r.check!==!1){let i=this.gl.checkFramebufferStatus(B.GL.FRAMEBUFFER);if(i!==B.GL.FRAMEBUFFER_COMPLETE)throw new Error(`Framebuffer ${Do(i)}`)}this.gl.bindFramebuffer(B.GL.FRAMEBUFFER,null)}}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}createDepthStencilTexture(e){return new U(this.device,{id:`${this.id}-depth-stencil`,format:e,width:this.width,height:this.height,mipmaps:!1})}resizeAttachments(e,r){if(this.handle===null)return this.width=this.gl.drawingBufferWidth,this.height=this.gl.drawingBufferHeight,this;e===void 0&&(e=this.gl.drawingBufferWidth),r===void 0&&(r=this.gl.drawingBufferHeight);for(let n of this.colorAttachments)n.texture.resize({width:e,height:r});return this.depthStencilAttachment&&this.depthStencilAttachment.texture.resize({width:e,height:r}),this}_attachOne(e,r){if(Array.isArray(r)){let[n,i=0,s=0]=r;return this._attachTexture(e,n,i,s),n}if(r instanceof U)return this._attachTexture(e,r,0,0),r;if(r instanceof se){let n=r;return this._attachTexture(e,n.texture,n.props.baseMipLevel,n.props.baseArrayLayer),r.texture}throw new Error("attach")}_attachTexture(e,r,n,i){let{gl:s}=this.device;switch(s.bindTexture(r.target,r.handle),r.target){case B.GL.TEXTURE_2D_ARRAY:case B.GL.TEXTURE_3D:s.framebufferTextureLayer(B.GL.FRAMEBUFFER,e,r.target,i,n);break;case B.GL.TEXTURE_CUBE_MAP:let a=No(n);s.framebufferTexture2D(B.GL.FRAMEBUFFER,e,a,r.handle,i);break;case B.GL.TEXTURE_2D:s.framebufferTexture2D(B.GL.FRAMEBUFFER,e,B.GL.TEXTURE_2D,r.handle,i);break;default:R(!1,"Illegal texture type")}s.bindTexture(r.target,null)}};function No(t){return t<B.GL.TEXTURE_CUBE_MAP_POSITIVE_X?t+B.GL.TEXTURE_CUBE_MAP_POSITIVE_X:t}function Do(t){switch(t){case B.GL.FRAMEBUFFER_COMPLETE:return"success";case B.GL.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"Mismatched attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"No attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"Height/width mismatch";case B.GL.FRAMEBUFFER_UNSUPPORTED:return"Unsupported or split attachments";case B.GL.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:return"Samples mismatch";default:return`${t}`}}var Xe=class extends he{device;presentationSize;_framebuffer=null;constructor(e,r){super(r),this.device=e,this.presentationSize=[-1,-1],this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this.update()}getCurrentFramebuffer(){return this.update(),this._framebuffer=this._framebuffer||new J(this.device,{handle:null}),this._framebuffer}update(){let e=this.getPixelSize();(e[0]!==this.presentationSize[0]||e[1]!==this.presentationSize[1])&&(this.presentationSize=e,this.resize())}resize(e){if(this.device.gl&&this.canvas){let r=this.getDevicePixelRatio(e?.useDevicePixels);this.setDevicePixelRatio(r,e);return}}commit(){}};var vo={spector:f.get("spector")||f.get("inspect")},wo="https://spectorcdn.babylonjs.com/spector.bundle.js",Oo=1,$=null,Un=!1;async function Mn(t){if(!globalThis.SPECTOR)try{await at(wo)}catch(e){f.warn(String(e))}}function Wn(t){if(t={...vo,...t},!t?.spector||(!$&&globalThis.SPECTOR&&(f.probe(Oo,"SPECTOR found and initialized")(),$=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=$)),!$))return null;if(Un||(Un=!0,$.spyCanvases(),$?.onCaptureStarted.add(e=>f.info("Spector capture started:",e)()),$?.onCapture.add(e=>{f.info("Spector capture complete:",e)(),$?.getResultUI(),$?.resultView.display(),$?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return $;$?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{f.info("Spector capture stopped after 2 seconds")(),$?.stopCapture()})}return $}var bt=y(S(),1);var Uo="https://unpkg.com/webgl-debug@2.0.1/index.js";function Hn(t){return t.luma=t.luma||{},t.luma}async function kn(){v()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await at(Uo))}function Vn(t,e={}){return t?e.debug?Wo(t,e):Mo(t):null}function Mo(t){let e=Hn(t);return e.realContext?e.realContext:t}function Wo(t,e){if(!globalThis.WebGLDebugUtils)return f.warn("webgl-debug not loaded")(),t;let r=Hn(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...bt.GL,...t});let n=globalThis.WebGLDebugUtils.makeDebugContext(t,Ho.bind(null,e),ko.bind(null,e));for(let a in bt.GL)!(a in n)&&typeof bt.GL[a]=="number"&&(n[a]=bt.GL[a]);class i{}Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.setPrototypeOf(i,n);let s=Object.create(i);return r.realContext=t,r.debugContext=s,s.debug=!0,s}function Ir(t,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function Ho(t,e,r,n){n=Array.from(n).map(c=>c===void 0?"undefined":c);let i=globalThis.WebGLDebugUtils.glEnumToString(e),s=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,n),a=`${i} in gl.${r}(${s})`;f.error(a)();debugger;if(t.throwOnError)throw new Error(a)}function ko(t,e,r){let n="";if(f.level>=1&&(n=Ir(e,r),f.log(1,n)()),t.break&&t.break.length>0&&(n=n||Ir(e,r),t.break.every(s=>n.indexOf(s)!==-1)))debugger;for(let i of r)if(i===void 0){if(n=n||Ir(e,r),t.throwOnError)throw new Error(`Undefined argument: ${n}`);f.error(`Undefined argument: ${n}`)();debugger}}var _t=y(S(),1);function Kn(t){let e=t.split(/\r?\n/),r=[];for(let n of e){if(n.length<=1)continue;let i=n.split(":");if(i.length===2){let[b,g]=i;r.push({message:g.trim(),type:Xn(b),lineNum:0,linePos:0});continue}let[s,a,c,...l]=i,d=parseInt(c,10);isNaN(d)&&(d=0);let m=parseInt(a,10);isNaN(m)&&(m=0),r.push({message:l.join(":").trim(),type:Xn(s),lineNum:d,linePos:m})}return r}function Xn(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var Ke=class extends Fe{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.VERTEX_SHADER);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(_t.GL.FRAGMENT_SHADER);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return Kn(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(i=>i.startsWith("#version ")?i:`#version 100
|
|
17
|
+
${i}`)(e);let{gl:n}=this.device;if(n.shaderSource(this.handle,e),n.compileShader(this.handle),f.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);this.debugShader();return}f.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),f.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,_t.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,_t.GL.COMPILE_STATUS)?"success":"error"}};var Dr=y(S(),1);var Vo=256,Xo=1024,Ko=16384,Nr=6144,$e=class extends Ne{device;glParameters;constructor(e,r){super(e,r),this.device=e,te(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){q(this.device.gl),this.props.framebuffer&&X(this.device.gl,{framebuffer:null})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[Dr.GL.RASTERIZER_DISCARD]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),r.scissorTest=Boolean(e.scissorRect),e.scissorRect&&(r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[Dr.GL.STENCIL_REF]=e.stencilReference),this.glParameters=r,X(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=Ko,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=Vo,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=Xo,e.clearStencil=this.props.clearStencil),r!==0&&K(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){K(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(Nr,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(Nr,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(Nr,e,r);break}})}};var Re=y(S(),1);var x=y(S(),1);var Ye=y(S(),1);var O=y(S(),1),$o="Failed to deduce GL constant from typed array";function $n(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return O.GL.FLOAT;case Uint16Array:return O.GL.UNSIGNED_SHORT;case Uint32Array:return O.GL.UNSIGNED_INT;case Uint8Array:return O.GL.UNSIGNED_BYTE;case Uint8ClampedArray:return O.GL.UNSIGNED_BYTE;case Int8Array:return O.GL.BYTE;case Int16Array:return O.GL.SHORT;case Int32Array:return O.GL.INT;default:throw new Error($o)}}function Tt(t,e){let{clamped:r=!0}=e||{};switch(t){case O.GL.FLOAT:return Float32Array;case O.GL.UNSIGNED_SHORT:case O.GL.UNSIGNED_SHORT_5_6_5:case O.GL.UNSIGNED_SHORT_4_4_4_4:case O.GL.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;case O.GL.UNSIGNED_INT:return Uint32Array;case O.GL.UNSIGNED_BYTE:return r?Uint8ClampedArray:Uint8Array;case O.GL.BYTE:return Int8Array;case O.GL.SHORT:return Int16Array;case O.GL.INT:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var Yo={offset:0,stride:0,type:Ye.GL.FLOAT,size:1,divisor:0,normalized:!1,integer:!1},zo={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},ae=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return Tt(e.type||Ye.GL.FLOAT).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return R(e.size),Tt(e.type||Ye.GL.FLOAT).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new ae(Yo,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return ae.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return ae.getBytesPerVertex(this)}_assign(e={}){return e=_r("Accessor",e,zo),e.type!==void 0&&(this.type=e.type,(e.type===Ye.GL.INT||e.type===Ye.GL.UNSIGNED_INT)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};var p=y(S(),1);function Yn(t){return jo.includes(t)}var jo=[p.GL.SAMPLER_2D,p.GL.SAMPLER_CUBE,p.GL.SAMPLER_3D,p.GL.SAMPLER_2D_SHADOW,p.GL.SAMPLER_2D_ARRAY,p.GL.SAMPLER_2D_ARRAY_SHADOW,p.GL.SAMPLER_CUBE_SHADOW,p.GL.INT_SAMPLER_2D,p.GL.INT_SAMPLER_3D,p.GL.INT_SAMPLER_CUBE,p.GL.INT_SAMPLER_2D_ARRAY,p.GL.UNSIGNED_INT_SAMPLER_2D,p.GL.UNSIGNED_INT_SAMPLER_3D,p.GL.UNSIGNED_INT_SAMPLER_CUBE,p.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY],zn={[p.GL.FLOAT]:[p.GL.FLOAT,1,"float","f32","float32"],[p.GL.FLOAT_VEC2]:[p.GL.FLOAT,2,"vec2","vec2<f32>","float32x2"],[p.GL.FLOAT_VEC3]:[p.GL.FLOAT,3,"vec3","vec3<f32>","float32x3"],[p.GL.FLOAT_VEC4]:[p.GL.FLOAT,4,"vec4","vec4<f32>","float32x4"],[p.GL.INT]:[p.GL.INT,1,"int","i32","sint32"],[p.GL.INT_VEC2]:[p.GL.INT,2,"ivec2","vec2<i32>","sint32x2"],[p.GL.INT_VEC3]:[p.GL.INT,3,"ivec3","vec3<i32>","sint32x3"],[p.GL.INT_VEC4]:[p.GL.INT,4,"ivec4","vec4<i32>","sint32x4"],[p.GL.UNSIGNED_INT]:[p.GL.UNSIGNED_INT,1,"uint","u32","uint32"],[p.GL.UNSIGNED_INT_VEC2]:[p.GL.UNSIGNED_INT,2,"uvec2","vec2<u32>","uint32x2"],[p.GL.UNSIGNED_INT_VEC3]:[p.GL.UNSIGNED_INT,3,"uvec3","vec3<u32>","uint32x3"],[p.GL.UNSIGNED_INT_VEC4]:[p.GL.UNSIGNED_INT,4,"uvec4","vec4<u32>","uint32x4"],[p.GL.BOOL]:[p.GL.FLOAT,1,"bool","f32","float32"],[p.GL.BOOL_VEC2]:[p.GL.FLOAT,2,"bvec2","vec2<f32>","float32x2"],[p.GL.BOOL_VEC3]:[p.GL.FLOAT,3,"bvec3","vec3<f32>","float32x3"],[p.GL.BOOL_VEC4]:[p.GL.FLOAT,4,"bvec4","vec4<f32>","float32x4"],[p.GL.FLOAT_MAT2]:[p.GL.FLOAT,8,"mat2","mat2x2<f32>"],[p.GL.FLOAT_MAT2x3]:[p.GL.FLOAT,8,"mat2x3","mat2x3<f32>"],[p.GL.FLOAT_MAT2x4]:[p.GL.FLOAT,8,"mat2x4","mat2x4<f32>"],[p.GL.FLOAT_MAT3x2]:[p.GL.FLOAT,12,"mat3x2","mat3x2<f32>"],[p.GL.FLOAT_MAT3]:[p.GL.FLOAT,12,"mat3","mat3x3<f32>"],[p.GL.FLOAT_MAT3x4]:[p.GL.FLOAT,12,"mat3x4","mat3x4<f32>"],[p.GL.FLOAT_MAT4x2]:[p.GL.FLOAT,16,"mat4x2","mat4x2<f32>"],[p.GL.FLOAT_MAT4x3]:[p.GL.FLOAT,16,"mat4x3","mat4x3<f32>"],[p.GL.FLOAT_MAT4]:[p.GL.FLOAT,16,"mat4","mat4x4<f32>"]};function vr(t){let e=zn[t];if(!e)throw new Error("uniform");let[r,n,,i]=e;return{format:i,components:n,glType:r}}function jn(t){let e=zn[t];if(!e)throw new Error("attribute");let[,r,,n,i]=e;return{attributeType:n,vertexFormat:i,components:r}}function Yt(t,e){let r={attributes:[],bindings:[]};r.attributes=Qo(t,e);let n=Jo(t,e);for(let c of n){let l=c.uniforms.map(d=>({name:d.name,format:d.format,byteOffset:d.byteOffset,byteStride:d.byteStride,arrayLength:d.arrayLength}));r.bindings.push({type:"uniform",name:c.name,location:c.location,visibility:(c.vertex?1:0)&(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let i=Zo(t,e),s=0;for(let c of i)if(Yn(c.type)){let{viewDimension:l,sampleType:d}=ts(c.type);r.bindings.push({type:"texture",name:c.name,location:s,viewDimension:l,sampleType:d}),c.textureUnit=s,s+=1}i.length&&(r.uniforms=i);let a=qo(t,e);return a?.length&&(r.varyings=a),r}function Qo(t,e){let r=[],n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let s=t.getActiveAttrib(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:c}=s,l=t.getAttribLocation(e,a);if(l>=0){let{attributeType:d}=jn(c),m=/instance/i.test(a)?"instance":"vertex";r.push({name:a,location:l,stepMode:m,type:d})}}return r.sort((i,s)=>i.location-s.location),r}function qo(t,e){let r=[],n=t.getProgramParameter(e,x.GL.TRANSFORM_FEEDBACK_VARYINGS);for(let i=0;i<n;i++){let s=t.getTransformFeedbackVarying(e,i);if(!s)throw new Error("activeInfo");let{name:a,type:c,size:l}=s,{glType:d,components:m}=vr(c),b=new ae({type:d,size:l*m}),g={location:i,name:a,accessor:b};r.push(g)}return r.sort((i,s)=>i.location-s.location),r}function Zo(t,e){let r=[],n=t.getProgramParameter(e,x.GL.ACTIVE_UNIFORMS);for(let i=0;i<n;i++){let s=t.getActiveUniform(e,i);if(!s)throw new Error("activeInfo");let{name:a,size:c,type:l}=s,{name:d,isArray:m}=rs(a),b=t.getUniformLocation(e,d),g={location:b,name:d,size:c,type:l,isArray:m};if(r.push(g),g.size>1)for(let L=0;L<g.size;L++){let A=`${d}[${L}]`;b=t.getUniformLocation(e,A);let D={...g,name:A,location:b};r.push(D)}}return r}function Jo(t,e){let r=(s,a)=>t.getActiveUniformBlockParameter(e,s,a),n=[],i=t.getProgramParameter(e,x.GL.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<i;s++){let a={name:t.getActiveUniformBlockName(e,s)||"",location:r(s,x.GL.UNIFORM_BLOCK_BINDING),byteLength:r(s,x.GL.UNIFORM_BLOCK_DATA_SIZE),vertex:r(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),fragment:r(s,x.GL.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),uniformCount:r(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORMS),uniforms:[]},c=r(s,x.GL.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)||[],l=t.getActiveUniforms(e,c,x.GL.UNIFORM_TYPE),d=t.getActiveUniforms(e,c,x.GL.UNIFORM_SIZE),m=t.getActiveUniforms(e,c,x.GL.UNIFORM_OFFSET),b=t.getActiveUniforms(e,c,x.GL.UNIFORM_ARRAY_STRIDE);for(let g=0;g<a.uniformCount;++g){let L=t.getActiveUniform(e,c[g]);if(!L)throw new Error("activeInfo");a.uniforms.push({name:L.name,format:vr(l[g]).format,type:l[g],arrayLength:d[g],byteOffset:m[g],byteStride:b[g]})}n.push(a)}return n.sort((s,a)=>s.location-a.location),n}var es={[x.GL.SAMPLER_2D]:["2d","float"],[x.GL.SAMPLER_CUBE]:["cube","float"],[x.GL.SAMPLER_3D]:["3d","float"],[x.GL.SAMPLER_2D_SHADOW]:["3d","depth"],[x.GL.SAMPLER_2D_ARRAY]:["2d-array","float"],[x.GL.SAMPLER_2D_ARRAY_SHADOW]:["2d-array","depth"],[x.GL.SAMPLER_CUBE_SHADOW]:["cube","float"],[x.GL.INT_SAMPLER_2D]:["2d","sint"],[x.GL.INT_SAMPLER_3D]:["3d","sint"],[x.GL.INT_SAMPLER_CUBE]:["cube","sint"],[x.GL.INT_SAMPLER_2D_ARRAY]:["2d-array","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D]:["2d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_3D]:["3d","uint"],[x.GL.UNSIGNED_INT_SAMPLER_CUBE]:["cube","uint"],[x.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]:["2d-array","uint"]};function ts(t){let e=es[t];if(!e)throw new Error("sampler");let[r,n]=e;return{viewDimension:r,sampleType:n}}function rs(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}var T=y(S(),1);function Qn(t,e,r,n){let i=t,s=n;s===!0&&(s=1),s===!1&&(s=0);let a=typeof s=="number"?[s]:s;switch(r){case T.GL.SAMPLER_2D:case T.GL.SAMPLER_CUBE:case T.GL.SAMPLER_3D:case T.GL.SAMPLER_2D_SHADOW:case T.GL.SAMPLER_2D_ARRAY:case T.GL.SAMPLER_2D_ARRAY_SHADOW:case T.GL.SAMPLER_CUBE_SHADOW:case T.GL.INT_SAMPLER_2D:case T.GL.INT_SAMPLER_3D:case T.GL.INT_SAMPLER_CUBE:case T.GL.INT_SAMPLER_2D_ARRAY:case T.GL.UNSIGNED_INT_SAMPLER_2D:case T.GL.UNSIGNED_INT_SAMPLER_3D:case T.GL.UNSIGNED_INT_SAMPLER_CUBE:case T.GL.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof n!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,n);case T.GL.FLOAT:return t.uniform1fv(e,a);case T.GL.FLOAT_VEC2:return t.uniform2fv(e,a);case T.GL.FLOAT_VEC3:return t.uniform3fv(e,a);case T.GL.FLOAT_VEC4:return t.uniform4fv(e,a);case T.GL.INT:return t.uniform1iv(e,a);case T.GL.INT_VEC2:return t.uniform2iv(e,a);case T.GL.INT_VEC3:return t.uniform3iv(e,a);case T.GL.INT_VEC4:return t.uniform4iv(e,a);case T.GL.BOOL:return t.uniform1iv(e,a);case T.GL.BOOL_VEC2:return t.uniform2iv(e,a);case T.GL.BOOL_VEC3:return t.uniform3iv(e,a);case T.GL.BOOL_VEC4:return t.uniform4iv(e,a);case T.GL.UNSIGNED_INT:return i.uniform1uiv(e,a,1);case T.GL.UNSIGNED_INT_VEC2:return i.uniform2uiv(e,a,2);case T.GL.UNSIGNED_INT_VEC3:return i.uniform3uiv(e,a,3);case T.GL.UNSIGNED_INT_VEC4:return i.uniform4uiv(e,a,4);case T.GL.FLOAT_MAT2:return t.uniformMatrix2fv(e,!1,a);case T.GL.FLOAT_MAT3:return t.uniformMatrix3fv(e,!1,a);case T.GL.FLOAT_MAT4:return t.uniformMatrix4fv(e,!1,a);case T.GL.FLOAT_MAT2x3:return i.uniformMatrix2x3fv(e,!1,a);case T.GL.FLOAT_MAT2x4:return i.uniformMatrix2x4fv(e,!1,a);case T.GL.FLOAT_MAT3x2:return i.uniformMatrix3x2fv(e,!1,a);case T.GL.FLOAT_MAT3x4:return i.uniformMatrix3x4fv(e,!1,a);case T.GL.FLOAT_MAT4x2:return i.uniformMatrix4x2fv(e,!1,a);case T.GL.FLOAT_MAT4x3:return i.uniformMatrix4x3fv(e,!1,a)}throw new Error("Illegal uniform")}var k=y(S(),1);function qn(t){switch(t){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINE_STRIP;case"line-loop-webgl":return k.GL.LINE_LOOP;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLE_STRIP;case"triangle-fan-webgl":return k.GL.TRIANGLE_FAN;default:throw new Error(t)}}function Zn(t){switch(t){case"point-list":return k.GL.POINTS;case"line-list":return k.GL.LINES;case"line-strip":return k.GL.LINES;case"line-loop-webgl":return k.GL.LINES;case"triangle-list":return k.GL.TRIANGLES;case"triangle-strip":return k.GL.TRIANGLES;case"triangle-fan-webgl":return k.GL.TRIANGLES;default:throw new Error(t)}}var Jn=4,ze=class extends Ie{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:n,bufferMode:i=Re.GL.SEPARATE_ATTRIBS}=r;switch(n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,i)),this._linkShaders(),f.time(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Yt(this.device.gl,this.handle),f.timeEnd(0,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=fr(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":f.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e){for(let[r,n]of Object.entries(e)){let i=this.shaderLayout.bindings.find(s=>s.name===r)||this.shaderLayout.bindings.find(s=>s.name===`${r}Uniforms`);if(!i){let s=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");f.warn(`Unknown binding "${r}" in render pipeline "${this.id}", expected one of ${s}`)();continue}switch(n||f.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(n instanceof H)&&!(n.buffer instanceof H))throw new Error("buffer value");break;case"texture":if(!(n instanceof se||n instanceof U||n instanceof J))throw new Error("texture value");break;case"sampler":f.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(i.type)}this.bindings[r]=n}}draw(e){let{renderPass:r,vertexArray:n,vertexCount:i,instanceCount:s,firstVertex:a=0,transformFeedback:c}=e,l=qn(this.props.topology),d=Boolean(n.indexBuffer),m=n.indexBuffer?.glIndexType,b=Number(s)>0;if(this.linkStatus!=="success")return f.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||i===0)return f.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(i===0)return f.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let g=r;return vn(this.device,this.props.parameters,g.glParameters,()=>{d&&b?this.device.gl.drawElementsInstanced(l,i||0,m,a,s||0):d?this.device.gl.drawElements(l,i||0,m,a):b?this.device.gl.drawArraysInstanced(l,a,i||0,s||0):this.device.gl.drawArrays(l,a,i||0),c&&c.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=Er(e);Object.keys(r).forEach(n=>{f.warn(`Unsupported value "${JSON.stringify(r[n])}" used in setUniforms() for key ${n}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),f.time(Jn,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),f.timeEnd(Jn,`linkProgram for ${this.id}`)(),f.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}f.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),f.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,e.LINK_STATUS)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,e.VALIDATE_STATUS)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,Re.GL.COMPLETION_STATUS_KHR))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof U&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,n=0;for(let i of this.shaderLayout.bindings){let s=this.bindings[i.name]||this.bindings[i.name.replace(/Uniforms$/,"")];if(!s)throw new Error(`No value for binding ${i.name} in ${this.id}`);switch(i.type){case"uniform":let{name:a}=i,c=e.getUniformBlockIndex(this.handle,a);if(c===Re.GL.INVALID_INDEX)throw new Error(`Invalid uniform block name ${a}`);e.uniformBlockBinding(this.handle,n,c),s instanceof H?e.bindBufferBase(Re.GL.UNIFORM_BUFFER,n,s.handle):e.bindBufferRange(Re.GL.UNIFORM_BUFFER,n,s.buffer.handle,s.offset||0,s.size||s.buffer.byteLength-s.offset),n+=1;break;case"texture":if(!(s instanceof se||s instanceof U||s instanceof J))throw new Error("texture");let l;if(s instanceof se)l=s.texture;else if(s instanceof U)l=s;else if(s instanceof J&&s.colorAttachments[0]instanceof U)f.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=s.colorAttachments[0];else throw new Error("No texture");e.activeTexture(Re.GL.TEXTURE0+r),e.bindTexture(l.target,l.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${i.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:n,type:i,textureUnit:s}=e,a=this.uniforms[r]??s;a!==void 0&&Qn(this.device.gl,n,i,a)}}};var j=y(S(),1);var zt=class extends ve{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":ns(this.device,r.options);break;case"copy-buffer-to-texture":is(this.device,r.options);break;case"copy-texture-to-buffer":os(this.device,r.options);break;case"copy-texture-to-texture":ss(this.device,r.options);break}}};function ns(t,e){let r=e.source,n=e.destination;t.gl.bindBuffer(j.GL.COPY_READ_BUFFER,r.handle),t.gl.bindBuffer(j.GL.COPY_WRITE_BUFFER,n.handle),t.gl.copyBufferSubData(j.GL.COPY_READ_BUFFER,j.GL.COPY_WRITE_BUFFER,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(j.GL.COPY_READ_BUFFER,null),t.gl.bindBuffer(j.GL.COPY_WRITE_BUFFER,null)}function is(t,e){throw new Error("Not implemented")}function os(t,e){let{source:r,mipLevel:n=0,aspect:i="all",width:s=e.source.width,height:a=e.source.height,depthOrArrayLayers:c=0,origin:l=[0,0],destination:d,byteOffset:m=0,bytesPerRow:b,rowsPerImage:g}=e;if(i!=="all")throw new Error("not supported");if(n!==0||c!==0||b||g)throw new Error("not implemented");let{framebuffer:L,destroyFramebuffer:A}=ei(r);try{let D=d,ne=s||L.width,fe=a||L.height,Ur=Ve(L.texture.props.format),ai=Ur.dataFormat,ui=Ur.type;t.gl.bindBuffer(j.GL.PIXEL_PACK_BUFFER,D.handle),t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,L.handle),t.gl.readPixels(l[0],l[1],ne,fe,ai,ui,m)}finally{t.gl.bindBuffer(j.GL.PIXEL_PACK_BUFFER,null),t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,null),A&&L.destroy()}}function ss(t,e){let{source:r,origin:n=[0,0],destination:i}=e,{width:s=e.destination.width,height:a=e.destination.width}=e,c=0,l=j.GL.RGBA,{framebuffer:d,destroyFramebuffer:m}=ei(r),[b,g]=n,L=!1;t.gl.bindFramebuffer(j.GL.FRAMEBUFFER,d.handle);let A=null,D;if(i instanceof U)A=i,s=Number.isFinite(s)?s:A.width,a=Number.isFinite(a)?a:A.height,A.bind(0),D=A.destination;else throw new Error("whoops");return L||t.gl.copyTexImage2D(D,c,l,b,g,s,a,0),A&&A.unbind(),m&&d.destroy(),A}function ei(t){if(t instanceof I){let{width:e,height:r,id:n}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var je=class extends De{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new zt(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,n){}};var Qe=y(S(),1);var Ee=class extends we{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Ct()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,r?r.handle:null),this.indexBuffer=r}setBuffer(e,r){let n=r;if(n.glTarget===Qe.GL.ELEMENT_ARRAY_BUFFER)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:a,offset:c,normalized:l,integer:d,divisor:m}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(Qe.GL.ARRAY_BUFFER,n.handle),d?this.device.gl.vertexAttribIPointer(e,i,s,a,c):this.device.gl.vertexAttribPointer(e,i,s,l,a,c),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,m||0),this.attributes[e]=n}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}init=!1;bindBeforeRender(){if(this.device.gl.bindVertexArray(this.handle),!this.init){let e=this.indexBuffer;this.device.gl.bindBuffer(Qe.GL.ELEMENT_ARRAY_BUFFER,e?.handle||null),this.init=!0}this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let n=wt(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let i=Ee.isConstantAttributeZeroSupported(this.device)||e!==0;(r||i)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let n=as(r),i=n.byteLength*e,s=n.length*e;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),a=a||!us(n,this.bufferValue),a){let c=pr(r.constructor,s);gr({target:c,source:n,start:0,count:s}),this.buffer.write(c),this.bufferValue=r}return this.buffer}};function as(t){return Array.isArray(t)?new Float32Array(t):t}function us(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var le=y(S(),1);var qe=class extends Oe{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zn(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse||this._unbindBuffers(),this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let n=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:a}=this._getBufferRange(r);if(n<0){this.unusedBuffers[e]=i,f.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:a},this.bindOnUse||this._bindBuffer(n,i,a,s)}getBuffer(e){if(ti(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(le.GL.TRANSFORM_FEEDBACK,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof H)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(e){if(ti(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:n,byteOffset:i}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,i,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,Number(e),null)}_bindBuffer(e,r,n=0,i){let s=r&&r.handle;!s||i===void 0?this.gl.bindBufferBase(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s):this.gl.bindBufferRange(le.GL.TRANSFORM_FEEDBACK_BUFFER,e,s,n,i)}};function ti(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var be=y(S(),1),jt=class extends Ue{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(be.GL.TIME_ELAPSED_EXT)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?be.GL.ANY_SAMPLES_PASSED_CONSERVATIVE:be.GL.ANY_SAMPLES_PASSED)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(be.GL.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,be.GL.QUERY_RESULT_AVAILABLE);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(be.GL.GPU_DISJOINT_EXT)}getResult(){return this.device.gl.getQueryParameter(this.handle,be.GL.QUERY_RESULT)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((n,i)=>{let s=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):r++>e?(i("Timed out"),this._pollingPromise=null):requestAnimationFrame(s)};requestAnimationFrame(s)}),this._pollingPromise}};var ue=y(S(),1);var V=y(S(),1);function wr(t){switch(t){case V.GL.ALPHA:case V.GL.R32F:case V.GL.RED:return 1;case V.GL.RG32F:case V.GL.RG:return 2;case V.GL.RGB:case V.GL.RGB32F:return 3;case V.GL.RGBA:case V.GL.RGBA32F:return 4;default:return R(!1),0}}function ri(t){switch(t){case V.GL.UNSIGNED_BYTE:return 1;case V.GL.UNSIGNED_SHORT_5_6_5:case V.GL.UNSIGNED_SHORT_4_4_4_4:case V.GL.UNSIGNED_SHORT_5_5_5_1:return 2;case V.GL.FLOAT:return 4;default:return R(!1),0}}function ni(t,e){let{sourceX:r=0,sourceY:n=0,sourceFormat:i=ue.GL.RGBA,sourceAttachment:s=ue.GL.COLOR_ATTACHMENT0}=e||{},{target:a=null,sourceWidth:c,sourceHeight:l,sourceType:d}=e||{},{framebuffer:m,deleteFramebuffer:b}=oi(t);R(m);let{gl:g,handle:L}=m;c=c||m.width,l=l||m.height;let A=s-ue.GL.COLOR_ATTACHMENT0;d=d||m.colorAttachments[A]?.texture?.type||ue.GL.UNSIGNED_BYTE,a=ls(a,d,i,c,l),d=d||$n(a);let D=g.bindFramebuffer(ue.GL.FRAMEBUFFER,L);return g.readPixels(r,n,c,l,i,d,a),g.bindFramebuffer(ue.GL.FRAMEBUFFER,D||null),b&&m.destroy(),a}function ii(t,e){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:s=ue.GL.RGBA,targetByteOffset:a=0}=e||{},{sourceWidth:c,sourceHeight:l,sourceType:d}=e||{},{framebuffer:m,deleteFramebuffer:b}=oi(t);R(m),c=c||m.width,l=l||m.height;let g=m;d=d||ue.GL.UNSIGNED_BYTE;let L=r;if(!L){let D=wr(s),ne=ri(d),fe=a+c*l*D*ne;L=g.device.createBuffer({byteLength:fe})}let A=t.device.createCommandEncoder();return A.copyTextureToBuffer({source:t,width:c,height:l,origin:[n,i],destination:L,byteOffset:a}),A.destroy(),b&&m.destroy(),L}function oi(t){return t instanceof pe?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:cs(t),deleteFramebuffer:!0}}function cs(t,e){let{device:r,width:n,height:i,id:s}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[t]})}function ls(t,e,r,n,i){if(t)return t;e=e||ue.GL.UNSIGNED_BYTE;let s=Tt(e,{clamped:!1}),a=wr(r);return new s(n*i*a)}var fs=256,ds=1024,ms=16384;var hs="clear: bad arguments";function si(t,e){let{framebuffer:r=null,color:n=null,depth:i=null,stencil:s=null}=e||{},a={};r&&(a.framebuffer=r);let c=0;n&&(c|=ms,n!==!0&&(a.clearColor=n)),i&&(c|=fs,i!==!0&&(a.clearDepth=i)),s&&(c|=ds,i!==!0&&(a.clearStencil=i)),R(c!==0,hs);let l=t.gl;K(l,a,()=>{l.clear(c)})}var Lt=1,Ze=class extends me{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof Ze)return e;if(e?.device instanceof me)return e.device;if(!ps(e))throw new Error("Invalid WebGL2RenderingContext");return new Ze({gl:e})}static async create(e={}){f.groupCollapsed(Lt,"WebGLDevice created")();let r=[];e.debug&&r.push(kn()),e.spector&&r.push(Mn()),typeof e.canvas=="string"&&r.push(he.pageLoaded);let n=await Promise.allSettled(r);for(let a of n)a.status==="rejected"&&f.error(`Failed to initialize debug libraries ${a.reason}`)();if(f.probe(Lt+1,"DOM is loaded")(),e.gl?.device)return f.warn("reattaching existing device")(),Ze.attach(e.gl);let i=new Ze(e),s=`Created ${i.type}${i.debug?" debug":""} context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return f.probe(Lt,s)(),f.table(Lt,i.info)(),f.groupEnd(Lt)(),i}constructor(e){super({...e,id:e.id||ee("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let n=e.gl?.canvas||e.canvas;this.canvasContext=new Xe(this,{...e,canvas:n}),this.lost=new Promise(c=>{this._resolveContextLost=c});let i=e.gl||null;if(i||=Tn(this.canvasContext.canvas,{...e,onContextLost:c=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!i)throw new Error("WebGL context creation failed");this.handle=i,this.gl=i,this.gl.device=this,this.gl._version=2,this.info=Ln(this.gl,this._extensions),this.limits=new Ht(this.gl),this.features=new Wt(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:s=!0,copyState:a=!1}=e;lt(this.gl,{enable:s,copyState:a,log:(...c)=>f.log(1,...c)()}),e.debug&&(this.gl=Vn(this.gl,{...e,throwOnError:!0}),this.debug=!0,f.level=Math.max(f.level,1),f.warn("WebGL debug mode activated. Performance reduced.")()),e.spector&&(this.spectorJS=Wn({...this.props,canvas:this.handle.canvas}))}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return pt(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return Fn(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return Bn(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new H(this,r)}_createTexture(e){return new U(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new ce(this,e)}createShader(e){return new Ke(this,e)}createFramebuffer(e){return new J(this,e)}createVertexArray(e){return new Ee(this,e)}createTransformFeedback(e){return new qe(this,e)}createQuerySet(e){return new jt(this,e)}createRenderPipeline(e){return new ze(this,e)}beginRenderPass(e){return new $e(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new je(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return ni(e,r)}readPixelsToBufferWebGL(e,r){return ii(e,r)}setParametersWebGL(e){X(this.gl,e)}getParametersWebGL(e){return Me(this.gl,e)}withParametersWebGL(e,r){K(this.gl,e,r)}clearWebGL(e){si(this,e)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){te(this.gl)}popState(){q(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let n=Number(e);for(let i in r)if(r[i]===n)return`GL.${i}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[e];switch(i&&_s(i,r)&&f.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:gs(this,e,r);break;case Int32Array:Es(this,e,r);break;case Uint32Array:bs(this,e,r);break;default:R(!1)}}getExtension(e){return Z(this.gl,e,this._extensions),this._extensions}},At=Ze;E(At,"type","webgl");function ps(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&Number.isFinite(t._version))}function gs(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:R(!1)}}function Es(t,e,r){t.gl.vertexAttribI4iv(e,r)}function bs(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function _s(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Je="Resource subclass must define virtual methods",Se=class extends _{device;gl;gl2;_handle;_bound=!1;byteLength=0;constructor(e,r,n){super(e,r,n),this.device=e;let i=this.device.gl,{id:s}=r||{};this.gl=i,this.gl2=i,this.id=s||ee(this.constructor.name),this._handle=r?.handle,this._handle===void 0&&(this._handle=this._createHandle()),this.byteLength=0}toString(){return`${this.constructor.name}(${this.id})`}get handle(){return this._handle}delete({deleteChildren:e=!1}={}){let r=this._handle&&this._deleteHandle(this._handle);return this._handle&&this.removeStats(),this._handle=null,r&&e&&r.filter(Boolean).forEach(n=>n.destroy()),this}bind(e=this.handle){if(typeof e!="function")return this._bindHandle(e),this;let r;return this._bound?r=e():(this._bindHandle(this.handle),this._bound=!0,r=e(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}stubRemovedMethods(e,r,n){return br(this,e,r,n)}initialize(e){}_createHandle(){throw new Error(Je)}_deleteHandle(){throw new Error(Je)}_bindHandle(e){throw new Error(Je)}_getOptsFromHandle(){throw new Error(Je)}_getParameter(e,r){throw new Error(Je)}_setParameter(e,r){throw new Error(Je)}};var et=y(S(),1);var Or=class extends Se{get[Symbol.toStringTag](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}glFormat;static isTextureFormatSupported(e,r){return Gn(e.gl,r,e._extensions)}constructor(e,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(e,r,Or.defaultProps),this.glFormat=gt(this.props.format),this._initialize(this.props)}resize(e){(e.width!==this.width||e.height!==this.height)&&(Object.assign(this.props,{...e,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(e){let{format:r,width:n,height:i,samples:s}=e;R(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,this.handle),s!==0?this.gl.renderbufferStorageMultisample(et.GL.RENDERBUFFER,s,this.glFormat,n,i):this.gl.renderbufferStorage(et.GL.RENDERBUFFER,this.glFormat,n,i),this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,null),this.trackAllocatedMemory(n*i*(s||1)*Et(this.format))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(e){this.gl.bindRenderbuffer(et.GL.RENDERBUFFER,e)}},Rt=Or;E(Rt,"defaultProps",{id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0});return Ei(Ts);})();
|
|
18
|
+
return __exports__;
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.12",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@luma.gl/core": "^9.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.0.
|
|
46
|
+
"@luma.gl/constants": "9.0.12",
|
|
47
47
|
"@probe.gl/env": "^4.0.2"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "961c52ac4696ffebb4a35aa94b664af143981b54"
|
|
50
50
|
}
|
|
@@ -229,6 +229,10 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
229
229
|
(this.gl as any).device = this; // Update GL context: Link webgl context back to device
|
|
230
230
|
(this.gl as any)._version = 2; // Update GL context: Store WebGL version field on gl context (HACK to identify debug contexts)
|
|
231
231
|
|
|
232
|
+
if (props.spector) {
|
|
233
|
+
this.spectorJS = initializeSpectorJS({...this.props, canvas: this.handle.canvas});
|
|
234
|
+
}
|
|
235
|
+
|
|
232
236
|
// luma Device fields
|
|
233
237
|
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
234
238
|
this.limits = new WebGLDeviceLimits(this.gl);
|
|
@@ -255,10 +259,6 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
255
259
|
log.level = Math.max(log.level, 1);
|
|
256
260
|
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
257
261
|
}
|
|
258
|
-
|
|
259
|
-
if (props.spector) {
|
|
260
|
-
this.spectorJS = initializeSpectorJS({...this.props, canvas: this.handle.canvas});
|
|
261
|
-
}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/**
|
|
@@ -15,11 +15,11 @@ type SpectorProps = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const DEFAULT_SPECTOR_PROPS: SpectorProps = {
|
|
18
|
-
spector: log.get('spector') || log.get('
|
|
18
|
+
spector: log.get('spector') || log.get('spectorjs')
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
// https://github.com/BabylonJS/Spector.js#basic-usage
|
|
22
|
-
const SPECTOR_CDN_URL = 'https://
|
|
22
|
+
const SPECTOR_CDN_URL = 'https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js';
|
|
23
23
|
const LOG_LEVEL = 1;
|
|
24
24
|
|
|
25
25
|
let spector: any = null;
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/adapter/.DS_Store
DELETED
|
Binary file
|
package/src/context/.DS_Store
DELETED
|
Binary file
|