@luma.gl/core
Version:
The luma.gl core Device API
8 lines • 92.3 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if (typeof define === 'function' && define.amd) define([], factory);
else if (typeof exports === 'object') exports['luma'] = factory();
else root['luma'] = factory();})(globalThis, function () {
"use strict";var __exports__=(()=>{var xe=Object.defineProperty;var Cr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var Er=Object.prototype.hasOwnProperty;var Rr=(r,e,t)=>e in r?xe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Lr=(r,e)=>{for(var t in e)xe(r,t,{get:e[t],enumerable:!0})},Br=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ar(e))!Er.call(r,s)&&s!==t&&xe(r,s,{get:()=>e[s],enumerable:!(i=Cr(e,s))||i.enumerable});return r};var Mr=r=>Br(xe({},"__esModule",{value:!0}),r);var u=(r,e,t)=>(Rr(r,typeof e!="symbol"?e+"":e,t),t);var os={};Lr(os,{Adapter:()=>Ue,Buffer:()=>p,CanvasContext:()=>ie,CommandBuffer:()=>fe,CommandEncoder:()=>le,ComputePass:()=>ue,ComputePipeline:()=>$,Device:()=>G,DeviceFeatures:()=>De,DeviceLimits:()=>Me,ExternalTexture:()=>ne,Fence:()=>ge,Framebuffer:()=>oe,PipelineFactory:()=>ae,PipelineLayout:()=>be,PresentationContext:()=>We,QuerySet:()=>pe,RenderPass:()=>I,RenderPipeline:()=>T,Resource:()=>l,Sampler:()=>F,Shader:()=>W,ShaderBlockWriter:()=>Y,ShaderFactory:()=>ce,SharedRenderPipeline:()=>Ne,Texture:()=>g,TextureView:()=>se,TransformFeedback:()=>me,UniformBlock:()=>X,UniformStore:()=>Xe,VertexArray:()=>he,_getDefaultBindGroupFactory:()=>dr,_getTextureFormatDefinition:()=>te,_getTextureFormatTable:()=>Re,assert:()=>Ge,assertDefined:()=>Fe,dataTypeDecoder:()=>B,flattenBindingsByGroup:()=>fr,getAttributeInfosFromLayouts:()=>Rt,getAttributeShaderTypeInfo:()=>Et,getExternalImageSize:()=>Be,getScratchArray:()=>wr,getShaderLayoutBinding:()=>vt,getTextureImageView:()=>Ot,getTypedArrayConstructor:()=>pr,getVariableShaderTypeInfo:()=>de,isExternalImage:()=>Le,log:()=>d,luma:()=>nr,makeShaderBlockLayout:()=>Qe,normalizeBindingsByGroup:()=>He,readPixel:()=>Sr,setTextureImageData:()=>Pr,shaderTypeDecoder:()=>je,textureFormatDecoder:()=>x,vertexFormatDecoder:()=>M,writePixel:()=>Tr});function K(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var U=class{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=K(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(K()-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 N=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:i}=e,s=this.stats[t];return s||(e instanceof U?s=e:s=new U(t,i),this.stats[t]=s),s}};var Dr="GPU Time and Memory",$r=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],Gt=new WeakMap,Ft=new WeakMap,Je=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new N({id:e}));let t=this.stats.get(e);return e===Dr&&Ir(t,$r),t}},we=new Je;function Ir(r,e){let t=r.stats,i=!1;for(let c of e)t[c]||(r.get(c),i=!0);let s=Object.keys(t).length,n=Gt.get(r);if(!i&&n?.orderedStatNames===e&&n.statCount===s)return;let o={},a=Ft.get(e);a||(a=new Set(e),Ft.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,f]of Object.entries(t))a.has(c)||(o[c]=f);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),Gt.set(r,{orderedStatNames:e,statCount:s})}var _e=globalThis,kr=globalThis.document||{},ve=globalThis.process||{},Ur=globalThis.console,xs=globalThis.navigator||{};function Wt(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}function v(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Wt()}var Ke="4.1.1";function H(r,e){if(!r)throw new Error(e||"Assertion failed")}function Ze(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return H(Number.isFinite(e)&&e>=0),e}function zt(r){let{logLevel:e,message:t}=r;r.logLevel=Ze(e);let i=r.args?Array.from(r.args):[];for(;i.length&&i.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&i.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let s=typeof r.message;return H(s==="string"||s==="object"),Object.assign(r,{args:i},r.opts)}var O=()=>{},Pe=class{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...i){return this._log("log",e,t,i)}info(e,t,...i){return this._log("info",e,t,i)}once(e,t,...i){return this._log("once",e,t,i,{once:!0})}_log(e,t,i,s,n={}){let o=zt({logLevel:t,message:i,args:this._buildArgs(t,i,s),opts:n});return this._createLogFunction(e,o,n)}_buildArgs(e,t,i){return[e,t,...i]}_createLogFunction(e,t,i){if(!this._shouldLog(t.logLevel))return O;let s=this._getOnceTag(i.tag??t.tag??t.message);if((i.once||t.once)&&s!==void 0){if(this._onceCache.has(s))return O;this._onceCache.add(s)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=Ze(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}};function Gr(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var Se=class{constructor(e,t,i="sessionStorage"){this.storage=Gr(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}};function Nt(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Ht(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var Te;(function(r){r[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Te||(Te={}));var Fr=10;function Vt(r){return typeof r!="string"?r:(r=r.toUpperCase(),Te[r]||Te.WHITE)}function jt(r,e,t){return!v&&typeof r=="string"&&(e&&(r=`\x1B[${Vt(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Vt(t)+Fr}m${r}\x1B[49m`)),r}function Qt(r,e=["constructor"]){let t=Object.getPrototypeOf(r),i=Object.getOwnPropertyNames(t),s=r;for(let n of i){let o=s[n];typeof o=="function"&&(e.find(a=>n===a)||(s[n]=o.bind(r)))}}function V(){let r;if(v()&&_e.performance)r=_e?.performance?.now?.();else if("hrtime"in ve){let e=ve?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var j={debug:v()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},et={enabled:!0,level:0},E=class extends Pe{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Ke,this._startTs=V(),this._deltaTs=V(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Se(`__probe-${this.id}__`,{[this.id]:et}),this.timeStamp(`${this.id} started`),Qt(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((V()-this._startTs).toPrecision(10))}getDelta(){return Number((V()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:j.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:j.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...i){return this._log("log",e,t,i,{method:j.log,time:!0,once:!0})}log(e,t,...i){return this._log("log",e,t,i,{method:j.debug})}info(e,t,...i){return this._log("info",e,t,i,{method:console.info})}once(e,t,...i){return this._log("once",e,t,i,{method:j.debug||j.info,once:!0})}table(e,t,i){return t?this._log("table",e,t,i&&[i]||[],{method:console.table||O,tag:zr(t)}):O}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||O})}group(e,t,i={collapsed:!1}){let s=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:s})}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||O})}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let i=t.method;H(i),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=V();let s=Wr(this.id,t.message,t);return i.bind(console,s,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(et),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...et};this._storage.setConfiguration({[this.id]:{...t,...e}})}};E.VERSION=Ke;function Wr(r,e,t){if(typeof e=="string"){let i=t.time?Ht(Nt(t.total)):"";e=t.time?`${r}: ${i} ${e}`:`${r}: ${e}`,e=jt(e,t.color,t.background)}return e}function zr(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}globalThis.probe={};var Xs=new E({id:"@probe.gl/log"});var d=new E({id:"luma.gl"});var tt={};function P(r="id"){tt[r]=tt[r]||1;let e=tt[r]++;return`${r}-${e}`}var Nr="cpu-hotspot-profiler",Yt="GPU Resource Counts",Xt="Resource Counts",qt="GPU Time and Memory",Hr=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],Vr=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],jr=Hr.flatMap(r=>[`${r} Created`,`${r} Active`]),Qr=Vr.flatMap(r=>[`${r} Created`,`${r} Active`]),Jt=new WeakMap,Kt=new WeakMap,l=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,t,i){if(!e)throw new Error("no device");this._device=e,this.props=Yr(t,i);let s=this.props.id!=="undefined"?this.props.id:P(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}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 this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=Z(this._device),t=e?L():0,i=[this._device.statsManager.getStats(Yt),this._device.statsManager.getStats(Xt)],s=er(this._device);for(let o of i)Zt(o,s);let n=this.getStatsName();for(let o of i)o.get("Resources Active").decrementCount(),o.get(`${n}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(L()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let i=Z(this._device),s=i?L():0,n=this._device.statsManager.getStats(qt);this.allocatedBytes>0&&this.allocatedBytesName&&(n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(L()-s)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let t=Z(this._device),i=t?L():0,s=this._device.statsManager.getStats(qt);s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(L()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=Z(this._device),i=t?L():0,s=[this._device.statsManager.getStats(Yt),this._device.statsManager.getStats(Xt)],n=er(this._device);for(let o of s)Zt(o,n);for(let o of s)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(L()-i)),Xr(this._device,e)}getStatsName(){return qr(this)}};u(l,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Yr(r,e){let t={...e};for(let i in r)r[i]!==void 0&&(t[i]=r[i]);return t}function Zt(r,e){let t=r.stats,i=!1;for(let c of e)t[c]||(r.get(c),i=!0);let s=Object.keys(t).length,n=Jt.get(r);if(!i&&n?.orderedStatNames===e&&n.statCount===s)return;let o={},a=Kt.get(e);a||(a=new Set(e),Kt.set(e,a));for(let c of e)t[c]&&(o[c]=t[c]);for(let[c,f]of Object.entries(t))a.has(c)||(o[c]=f);for(let c of Object.keys(t))delete t[c];Object.assign(t,o),Jt.set(r,{orderedStatNames:e,statCount:s})}function er(r){return r.type==="webgl"?Qr:jr}function Z(r){let e=r.userData[Nr];return e?.enabled?e:null}function L(){return globalThis.performance?.now?.()??Date.now()}function Xr(r,e){let t=Z(r);if(!(!t||!t.activeDefaultFramebufferAcquireDepth))switch(t.transientCanvasResourceCreates=(t.transientCanvasResourceCreates||0)+1,e){case"Texture":t.transientCanvasTextureCreates=(t.transientCanvasTextureCreates||0)+1;break;case"TextureView":t.transientCanvasTextureViewCreates=(t.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":t.transientCanvasSamplerCreates=(t.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":t.transientCanvasFramebufferCreates=(t.transientCanvasFramebufferCreates||0)+1;break;default:break}}function qr(r){let e=Object.getPrototypeOf(r);for(;e;){let t=Object.getPrototypeOf(e);if(!t||t===l.prototype)return Jr(e)||r[Symbol.toStringTag]||r.constructor.name;e=t}return r[Symbol.toStringTag]||r.constructor.name}function Jr(r){let e=Object.getOwnPropertyDescriptor(r,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(r):typeof e?.value=="string"?e.value:null}var ee=class extends l{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let i={...t};(t.usage||0)&ee.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?i.indexType="uint32":t.data instanceof Uint16Array?i.indexType="uint16":t.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,ee.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,t,i){let s=null,n;ArrayBuffer.isView(e)?(s=e,n=e.buffer):n=e;let o=Math.min(e?e.byteLength:i,ee.DEBUG_DATA_MAX_LENGTH);if(n===null)this.debugData=new ArrayBuffer(o);else{let a=Math.min(s?.byteOffset||0,n.byteLength),c=Math.max(0,n.byteLength-a),f=Math.min(o,c);this.debugData=new Uint8Array(n,a,f).slice().buffer}}},p=ee;u(p,"INDEX",16),u(p,"VERTEX",32),u(p,"UNIFORM",64),u(p,"STORAGE",128),u(p,"INDIRECT",256),u(p,"QUERY_RESOLVE",512),u(p,"MAP_READ",1),u(p,"MAP_WRITE",2),u(p,"COPY_SRC",4),u(p,"COPY_DST",8),u(p,"DEBUG_DATA_MAX_LENGTH",32),u(p,"defaultProps",{...l.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});var it=class{getDataTypeInfo(e){let[t,i,s]=rt[e],n=e.includes("norm"),o=!n&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:t,primitiveType:i,byteLength:s,normalized:n,integer:o,signed:a}}getNormalizedDataType(e){let t=e;switch(t){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return t}}alignTo(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let t=ArrayBuffer.isView(e)?e.constructor:e;if(t===Uint8ClampedArray)return"uint8";let i=Object.values(rt).find(s=>t===s[4]);if(!i)throw new Error(t.name);return i[0]}getTypedArrayConstructor(e){let[,,,,t]=rt[e];return t}},B=new it,rt={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};var st=class{getVertexFormatInfo(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);let[i,s]=e.split("x"),n=i,o=s?parseInt(s):1,a=B.getDataTypeInfo(n),c={type:n,components:o,byteLength:a.byteLength*o,integer:a.integer,signed:a.signed,normalized:a.normalized};return t&&(c.webglOnly=!0),c}makeVertexFormat(e,t,i){let s=i?B.getNormalizedDataType(e):e;switch(s){case"unorm8":return t===1?"unorm8":t===3?"unorm8x3-webgl":`${s}x${t}`;case"snorm8":return t===1?"snorm8":t===3?"snorm8x3-webgl":`${s}x${t}`;case"uint8":case"sint8":if(t===1||t===3)throw new Error(`size: ${t}`);return`${s}x${t}`;case"uint16":return t===1?"uint16":t===3?"uint16x3-webgl":`${s}x${t}`;case"sint16":return t===1?"sint16":t===3?"sint16x3-webgl":`${s}x${t}`;case"unorm16":return t===1?"unorm16":t===3?"unorm16x3-webgl":`${s}x${t}`;case"snorm16":return t===1?"snorm16":t===3?"snorm16x3-webgl":`${s}x${t}`;case"float16":if(t===1||t===3)throw new Error(`size: ${t}`);return`${s}x${t}`;default:return t===1?s:`${s}x${t}`}}getVertexFormatFromAttribute(e,t,i){if(!t||t>4)throw new Error(`size ${t}`);let s=t,n=B.getDataType(e);return this.makeVertexFormat(n,s,i)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?t:`${t}x${e.components}`}},M=new st;var y="texture-compression-bc",m="texture-compression-astc",S="texture-compression-etc2",Kr="texture-compression-etc1-webgl",Ce="texture-compression-pvrtc-webgl",nt="texture-compression-atc-webgl",Ae="float32-renderable-webgl",ot="float16-renderable-webgl",Zr="rgb9e5ufloat-renderable-webgl",at="snorm8-renderable-webgl",D="norm16-webgl",ct="norm16-renderable-webgl",ut="snorm16-renderable-webgl",Ee="float32-filterable",tr="float16-filterable-webgl";function te(r){let e=rr[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}function Re(){return rr}var ei={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:at},rg8snorm:{render:at},"rgb8snorm-webgl":{},rgba8snorm:{render:at},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:D,render:ct},rg16unorm:{f:D,render:ct},"rgb16unorm-webgl":{f:D,render:!1},rgba16unorm:{f:D,render:ct},r16snorm:{f:D,render:ut},rg16snorm:{f:D,render:ut},"rgb16snorm-webgl":{f:D,render:!1},rgba16snorm:{f:D,render:ut},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:ot,filter:"float16-filterable-webgl"},rg16float:{render:ot,filter:tr},rgba16float:{render:ot,filter:tr},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Ae,filter:Ee},rg32float:{render:!1,filter:Ee},"rgb32float-webgl":{render:Ae,filter:Ee},rgba32float:{render:Ae,filter:Ee},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:Zr},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Ae},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},ti={"bc1-rgb-unorm-webgl":{f:y},"bc1-rgb-unorm-srgb-webgl":{f:y},"bc1-rgba-unorm":{f:y},"bc1-rgba-unorm-srgb":{f:y},"bc2-rgba-unorm":{f:y},"bc2-rgba-unorm-srgb":{f:y},"bc3-rgba-unorm":{f:y},"bc3-rgba-unorm-srgb":{f:y},"bc4-r-unorm":{f:y},"bc4-r-snorm":{f:y},"bc5-rg-unorm":{f:y},"bc5-rg-snorm":{f:y},"bc6h-rgb-ufloat":{f:y},"bc6h-rgb-float":{f:y},"bc7-rgba-unorm":{f:y},"bc7-rgba-unorm-srgb":{f:y},"etc2-rgb8unorm":{f:S},"etc2-rgb8unorm-srgb":{f:S},"etc2-rgb8a1unorm":{f:S},"etc2-rgb8a1unorm-srgb":{f:S},"etc2-rgba8unorm":{f:S},"etc2-rgba8unorm-srgb":{f:S},"eac-r11unorm":{f:S},"eac-r11snorm":{f:S},"eac-rg11unorm":{f:S},"eac-rg11snorm":{f:S},"astc-4x4-unorm":{f:m},"astc-4x4-unorm-srgb":{f:m},"astc-5x4-unorm":{f:m},"astc-5x4-unorm-srgb":{f:m},"astc-5x5-unorm":{f:m},"astc-5x5-unorm-srgb":{f:m},"astc-6x5-unorm":{f:m},"astc-6x5-unorm-srgb":{f:m},"astc-6x6-unorm":{f:m},"astc-6x6-unorm-srgb":{f:m},"astc-8x5-unorm":{f:m},"astc-8x5-unorm-srgb":{f:m},"astc-8x6-unorm":{f:m},"astc-8x6-unorm-srgb":{f:m},"astc-8x8-unorm":{f:m},"astc-8x8-unorm-srgb":{f:m},"astc-10x5-unorm":{f:m},"astc-10x5-unorm-srgb":{f:m},"astc-10x6-unorm":{f:m},"astc-10x6-unorm-srgb":{f:m},"astc-10x8-unorm":{f:m},"astc-10x8-unorm-srgb":{f:m},"astc-10x10-unorm":{f:m},"astc-10x10-unorm-srgb":{f:m},"astc-12x10-unorm":{f:m},"astc-12x10-unorm-srgb":{f:m},"astc-12x12-unorm":{f:m},"astc-12x12-unorm-srgb":{f:m},"pvrtc-rgb4unorm-webgl":{f:Ce},"pvrtc-rgba4unorm-webgl":{f:Ce},"pvrtc-rgb2unorm-webgl":{f:Ce},"pvrtc-rgba2unorm-webgl":{f:Ce},"etc1-rbg-unorm-webgl":{f:Kr},"atc-rgb-unorm-webgl":{f:nt},"atc-rgba-unorm-webgl":{f:nt},"atc-rgbai-unorm-webgl":{f:nt}},rr={...ei,...ti};var ri=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,ii=["rgb","rgba","bgra"],si=["depth","stencil"],ni=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],lt=class{isColor(e){return ii.some(t=>e.startsWith(t))}isDepthStencil(e){return si.some(t=>e.startsWith(t))}isCompressed(e){return ni.some(t=>e.startsWith(t))}getInfo(e){return ir(e)}getCapabilities(e){return ai(e)}computeMemoryLayout(e){return oi(e)}},x=new lt;function oi({format:r,width:e,height:t,depth:i,byteAlignment:s}){let n=x.getInfo(r),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:f=1,compressed:h=!1}=n,b=h?Math.ceil(e/c):e,A=h?Math.ceil(t/f):t,qe=b*a,_=Math.ceil(qe/s)*s,q=A,J=_*q*i;return{bytesPerPixel:o,bytesPerRow:_,rowsPerImage:q,depthOrArrayLayers:i,bytesPerImage:_*q,byteLength:J}}function ai(r){let e=te(r),t={format:r,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=ir(r),s=r.startsWith("depth")||r.startsWith("stencil"),n=i?.signed,o=i?.integer,a=i?.webgl,c=Boolean(i?.compressed);return t.render&&=!s&&!c,t.filter&&=!s&&!n&&!o&&!a,t}function ir(r){let e=ci(r);if(x.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=li(r);let i=ui(r);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let t=e.packed?null:ri.exec(r);if(t){let[,i,s,n,o,a]=t,c=`${n}${s}`,f=B.getDataTypeInfo(c),h=f.byteLength*8,b=i?.length??1,A=[h,b>=2?h:0,b>=3?h:0,b>=4?h:0];e={format:r,attachment:e.attachment,dataType:f.signedType,components:b,channels:i,integer:f.integer,signed:f.signed,normalized:f.normalized,bitsPerChannel:A,bytesPerPixel:f.byteLength*b,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function ci(r){let e=te(r),t=e.bytesPerPixel||1,i=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:i,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function ui(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,i,s]=t;return{blockWidth:Number(i),blockHeight:Number(s)}}return r.startsWith("bc")||r.startsWith("etc1")||r.startsWith("etc2")||r.startsWith("eac")||r.startsWith("atc")?{blockWidth:4,blockHeight:4}:r.startsWith("pvrtc-rgb4")||r.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:r.startsWith("pvrtc-rgb2")||r.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function li(r){return r.startsWith("bc1")||r.startsWith("bc4")||r.startsWith("etc1")||r.startsWith("etc2-rgb8")||r.startsWith("etc2-rgb8a1")||r.startsWith("eac-r11")||r==="atc-rgb-unorm-webgl"?8:r.startsWith("bc2")||r.startsWith("bc3")||r.startsWith("bc5")||r.startsWith("bc6h")||r.startsWith("bc7")||r.startsWith("etc2-rgba8")||r.startsWith("eac-rg11")||r.startsWith("astc")||r==="atc-rgba-unorm-webgl"||r==="atc-rgbai-unorm-webgl"?16:r.startsWith("pvrtc")?8:16}function Le(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function Be(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var Me=class{};function fi(r,e){let t=ft(r),i=e.map(ft).filter(s=>s!==void 0);return[t,...i].filter(s=>s!==void 0)}function ft(r){if(r!==void 0){if(r===null||typeof r=="string"||typeof r=="number"||typeof r=="boolean")return r;if(r instanceof Error)return r.message;if(Array.isArray(r))return r.map(ft);if(typeof r=="object"){if(di(r)){let e=String(r);if(e!=="[object Object]")return e}return hi(r)?mi(r):r.constructor?.name||"Object"}return String(r)}}function di(r){return"toString"in r&&typeof r.toString=="function"&&r.toString!==Object.prototype.toString}function hi(r){return"message"in r&&"type"in r}function mi(r){let e=typeof r.type=="string"?r.type:"message",t=typeof r.message=="string"?r.message:"",i=typeof r.lineNum=="number"?r.lineNum:null,s=typeof r.linePos=="number"?r.linePos:null,n=i!==null&&s!==null?` @ ${i}:${s}`:i!==null?` @ ${i}`:"";return`${e}${n}: ${t}`.trim()}var De=class{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},dt=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=we;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...dt.defaultProps,...e},this.id=this.props.id||P(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return M.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return x.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let i=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,i=1){let s=Math.max(e,t,i);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return Le(e)}getExternalImageSize(e){return Be(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return x.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(Re()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let n=fi(t,i);return d.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...n)}return()=>{}}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
or create a device with the 'debug: true' prop.`;d.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,i,s,n){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=x.getCapabilities(e),i=n=>(typeof n=="string"?this.features.has(n):n)??!0,s=i(t.create);return{format:e,create:s,render:s&&i(t.render),filter:s&&i(t.filter),blend:s&&i(t.blend),store:s&&i(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&p.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}},G=dt;u(G,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[i,s]=e.getDevicePixelSize();d.log(1,`${e} resized => ${i}x${s}px`)()},onPositionChange:(e,t)=>{let[i,s]=e.getPosition();d.log(1,`${e} repositioned => ${i},${s}`)()},onVisibilityChange:e=>d.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>d.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:gi(),debugGPUTime:!1,debugShaders:d.get("debug-shaders")||void 0,debugFramebuffers:Boolean(d.get("debug-framebuffers")),debugFactories:Boolean(d.get("debug-factories")),debugWebGL:Boolean(d.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});function pi(r,e){return r!=null?Boolean(r):e!==void 0?e!=="production":!1}function gi(){return pi(d.get("debug"),bi())}function bi(){let r=globalThis.process;if(r?.env)return r.env.NODE_ENV}var yi="set luma.log.level=1 (or higher) to trace rendering",sr="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Ie=class{stats=we;log=d;VERSION="9.3.3";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw d.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),d.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");d.error("This version of luma.gl has already been initialized")()}d.log(1,`${this.VERSION} - ${yi}`)(),globalThis.luma=this}async createDevice(e={}){let t={...Ie.defaultProps,...e},i=this.selectAdapter(t.type,t.adapters);if(!i)throw new Error(sr);return t.waitForPageLoad&&await i.pageLoaded,await i.create(t)}async attachDevice(e,t){let i=this._getTypeFromHandle(e,t.adapters),s=i&&this.selectAdapter(i,t.adapters);if(!s)throw new Error(sr);return await s?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let s of t)if(i.get(s)?.isSupported?.())return s;return null}selectAdapter(e,t=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(t));let s=this._getAdapterMap(t);return i&&s.get(i)||null}enforceWebGL2(e=!0,t=[]){let s=this._getAdapterMap(t).get("webgl");s||d.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Ie.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let i of e)t.set(i.type,i);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?d.warn("WebGL1 is not supported",e)():d.warn("Unknown handle type",e)(),null)}},$e=Ie;u($e,"defaultProps",{...G.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});var nr=new $e;var Ue=class{get pageLoaded(){return _i()}},xi=v()&&typeof document<"u",wi=()=>xi&&document.readyState==="complete",ke=null;function _i(){return ke||(wi()||typeof window>"u"?ke=Promise.resolve():ke=new Promise(r=>window.addEventListener("load",()=>r()))),ke}var Oe=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}};function or(){let r,e;return{promise:new Promise((i,s)=>{r=i,e=s}),resolve:r,reject:e}}function Ge(r,e){if(!r){let t=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,Ge),t}}function Fe(r,e){return Ge(r,e),r}var re=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=or();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...re.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,v()?e.canvas?typeof e.canvas=="string"?this.canvas=Pi(e.canvas):this.canvas=e.canvas:this.canvas=Si(e):this.canvas={width:e.width||1,height:e.height||1},re.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):re.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new Oe({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:t=>this._handleResize(t),onIntersection:t=>this._handleIntersection(t),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let i=this.cssToDeviceRatio(),[s,n]=this.getDrawingBufferSize();return Ti(e,i,s,n,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(s=>s.target===this.canvas);if(!t)return;let i=t.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(f=>f.target===this.canvas);if(!t)return;let i=Fe(t.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let s=this.getDevicePixelSize(),n=t.devicePixelContentBoxSize?.[0]?.inlineSize||i.inlineSize*devicePixelRatio,o=t.devicePixelContentBoxSize?.[0]?.blockSize||i.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,a)),this.devicePixelHeight=Math.max(1,Math.min(o,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:s})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let s=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:s})}}}},R=re;u(R,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});function vi(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}return r||document.body}function Pi(r){let e=document.getElementById(r);if(!R.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function Si(r){let{width:e,height:t}=r,i=document.createElement("canvas");i.id=P("lumagl-auto-created-canvas"),i.width=e||1,i.height=t||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(t)?`${t}px`:"100%",r?.visible||(i.style.visibility="hidden");let s=vi(r?.container||null);return s.insertBefore(i,s.firstChild),i}function Ti(r,e,t,i,s){let n=r,o=ar(n[0],e,t),a=cr(n[1],e,i,s),c=ar(n[0]+1,e,t),f=c===t-1?c:c-1;c=cr(n[1]+1,e,i,s);let h;return s?(c=c===0?c:c+1,h=a,a=c):h=c===i-1?c:c-1,{x:o,y:a,width:Math.max(f-o+1,1),height:Math.max(h-a+1,1)}}function ar(r,e,t){return Math.min(Math.round(r*e),t-1)}function cr(r,e,t,i){return i?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var ie=class extends R{};u(ie,"defaultProps",R.defaultProps);var We=class extends R{};var ze=class extends l{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=ze.normalizeProps(e,t),super(e,t,ze.defaultProps)}static normalizeProps(e,t){return t}},F=ze;u(F,"defaultProps",{...l.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});var Ci={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},w=class extends l{dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlig