@luma.gl/core
Advanced tools
Comparing version 9.0.0-beta.9 to 9.0.0-beta.10
@@ -7,3 +7,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else root['luma'] = factory();})(globalThis, function () { | ||
"use strict";var __exports__=(()=>{var J=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Re=(r,t,e)=>t in r?J(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Me=(r,t)=>{for(var e in t)J(r,e,{get:t[e],enumerable:!0})},Ne=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Le(t))!$e.call(r,n)&&n!==e&&J(r,n,{get:()=>t[n],enumerable:!(o=Ie(t,n))||o.enumerable});return r};var Fe=r=>Ne(J({},"__esModule",{value:!0}),r);var c=(r,t,e)=>(Re(r,typeof t!="symbol"?t+"":t,e),e);var Pr={};Me(Pr,{Buffer:()=>m,CanvasContext:()=>F,CommandBuffer:()=>Y,CommandEncoder:()=>j,ComputePass:()=>W,ComputePipeline:()=>O,Device:()=>x,DeviceFeatures:()=>ut,DeviceLimits:()=>ct,ExternalTexture:()=>D,Framebuffer:()=>k,QuerySet:()=>Q,RenderPass:()=>V,RenderPipeline:()=>G,Resource:()=>u,Sampler:()=>H,Shader:()=>z,StatsManager:()=>M,Texture:()=>h,TextureView:()=>U,TransformFeedback:()=>K,UniformBlock:()=>$,UniformBufferLayout:()=>L,UniformStore:()=>pt,VERSION:()=>it,VertexArray:()=>q,assert:()=>C,cancelAnimationFrame:()=>Ce,cast:()=>be,checkProps:()=>Se,decodeShaderAttributeType:()=>mt,decodeShaderUniformType:()=>dt,decodeTextureFormat:()=>oe,decodeVertexFormat:()=>X,deepEqual:()=>yt,fillArray:()=>me,formatCompilerLog:()=>lt,formatValue:()=>kt,getAttributeInfosFromLayouts:()=>Nt,getDataTypeFromTypedArray:()=>zt,getScratchArray:()=>le,getScratchArrayBuffer:()=>Z,getTypedArrayFromDataType:()=>ge,getVertexFormatFromAttribute:()=>ye,glsl:()=>_r,isNumberArray:()=>y,isObjectEmpty:()=>te,isTypedArray:()=>xt,isUniformValue:()=>Ht,loadFile:()=>Ae,loadImage:()=>ve,loadImageBitmap:()=>Ee,loadScript:()=>_e,log:()=>l,luma:()=>I,makeRandomNumberGenerator:()=>Gt,mergeShaderLayout:()=>ue,random:()=>Pe,requestAnimationFrame:()=>Be,setPathPrefix:()=>Te,splitUniformsAndBindings:()=>xe,stubRemovedMethods:()=>we,uid:()=>S});function bt(r){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,e=r||t;return!!(e&&e.indexOf("Electron")>=0)}function d(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||bt()}var Ue=globalThis.self||globalThis.window||globalThis.global,tt=globalThis.window||globalThis.self||globalThis.global,De=globalThis.document||{},et=globalThis.process||{},ze=globalThis.console,$r=globalThis.navigator||{};var rt="4.0.6",Nr=d();function He(r){try{let t=window[r],e="__storage_test__";return t.setItem(e,e),t.removeItem(e),t}catch{return null}}var ot=class{constructor(t,e,o="sessionStorage"){this.storage=He(o),this.id=t,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let t={};if(this.storage){let e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}};function Wt(r){let t;return r<10?t=`${r.toFixed(2)}ms`:r<100?t=`${r.toFixed(1)}ms`:r<1e3?t=`${r.toFixed(0)}ms`:t=`${(r/1e3).toFixed(2)}s`,t}function jt(r,t=8){let e=Math.max(t-r.length,0);return`${" ".repeat(e)}${r}`}function nt(r,t,e,o=600){let n=r.src.replace(/\(/g,"%28").replace(/\)/g,"%29");r.width>o&&(e=Math.min(e,o/r.width));let s=r.width*e,i=r.height*e,a=["font-size:1px;",`padding:${Math.floor(i/2)}px ${Math.floor(s/2)}px;`,`line-height:${i}px;`,`background:url(${n});`,`background-size:${s}px ${i}px;`,"color:transparent;"].join("");return[`${t} %c+`,a]}var st;(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"})(st||(st={}));var ke=10;function Yt(r){return typeof r!="string"?r:(r=r.toUpperCase(),st[r]||st.WHITE)}function Xt(r,t,e){return!d&&typeof r=="string"&&(t&&(r=`\x1B[${Yt(t)}m${r}\x1B[39m`),e&&(r=`\x1B[${Yt(e)+ke}m${r}\x1B[49m`)),r}function qt(r,t=["constructor"]){let e=Object.getPrototypeOf(r),o=Object.getOwnPropertyNames(e),n=r;for(let s of o){let i=n[s];typeof i=="function"&&(t.find(a=>s===a)||(n[s]=i.bind(r)))}}function v(r,t){if(!r)throw new Error(t||"Assertion failed")}function T(){let r;if(d()&&tt.performance)r=tt?.performance?.now?.();else if("hrtime"in et){let t=et?.hrtime?.();r=t[0]*1e3+t[1]/1e6}else r=Date.now();return r}var _={debug:d()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ge={enabled:!0,level:0};function p(){}var Kt={},Qt={once:!0},w=class{constructor({id:t}={id:""}){this.VERSION=rt,this._startTs=T(),this._deltaTs=T(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new ot(`__probe-${this.id}__`,Ge),this.timeStamp(`${this.id} started`),qt(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((T()-this._startTs).toPrecision(10))}getDelta(){return Number((T()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.setConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){v(t,e)}warn(t){return this._getLogFunction(0,t,_.warn,arguments,Qt)}error(t){return this._getLogFunction(0,t,_.error,arguments)}deprecated(t,e){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${e}\` instead`)}removed(t,e){return this.error(`\`${t}\` has been removed. Use \`${e}\` instead`)}probe(t,e){return this._getLogFunction(t,e,_.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,_.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){return this._getLogFunction(t,e,_.debug||_.info,arguments,Qt)}table(t,e,o){return e?this._getLogFunction(t,e,console.table||p,o&&[o],{tag:je(e)}):p}image({logLevel:t,priority:e,image:o,message:n="",scale:s=1}){return this._shouldLog(t||e)?d()?We({image:o,message:n,scale:s}):Oe({image:o,message:n,scale:s}):p}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||p)}group(t,e,o={collapsed:!1}){let n=Zt({logLevel:t,message:e,opts:o}),{collapsed:s}=o;return n.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(t,e,o={}){return this.group(t,e,Object.assign({},o,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||p)}withGroup(t,e,o){this.group(t,e)();try{o()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=Jt(t)}_getLogFunction(t,e,o,n,s){if(this._shouldLog(t)){s=Zt({logLevel:t,message:e,args:n,opts:s}),o=o||s.method,v(o),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=T();let i=s.tag||s.message;if(s.once&&i)if(!Kt[i])Kt[i]=T();else return p;return e=Ve(this.id,s.message,s),o.bind(console,e,...s.args)}return p}};w.VERSION=rt;function Jt(r){if(!r)return 0;let t;switch(typeof r){case"number":t=r;break;case"object":t=r.logLevel||r.priority||0;break;default:return 0}return v(Number.isFinite(t)&&t>=0),t}function Zt(r){let{logLevel:t,message:e}=r;r.logLevel=Jt(t);let o=r.args?Array.from(r.args):[];for(;o.length&&o.shift()!==e;);switch(typeof t){case"string":case"function":e!==void 0&&o.unshift(e),r.message=t;break;case"object":Object.assign(r,t);break;default:}typeof r.message=="function"&&(r.message=r.message());let n=typeof r.message;return v(n==="string"||n==="object"),Object.assign(r,{args:o},r.opts)}function Ve(r,t,e){if(typeof t=="string"){let o=e.time?jt(Wt(e.total)):"";t=e.time?`${r}: ${o} ${t}`:`${r}: ${t}`,t=Xt(t,e.color,e.background)}return t}function Oe({image:r,message:t="",scale:e=1}){return console.warn("removed"),p}function We({image:r,message:t="",scale:e=1}){if(typeof r=="string"){let n=new Image;return n.onload=()=>{let s=nt(n,t,e);console.log(...s)},n.src=r,p}let o=r.nodeName||"";if(o.toLowerCase()==="img")return console.log(...nt(r,t,e)),p;if(o.toLowerCase()==="canvas"){let n=new Image;return n.onload=()=>console.log(...nt(n,t,e)),n.src=r.toDataURL(),p}return p}function je(r){for(let t in r)for(let e in r[t])return e||"untitled";return"empty"}globalThis.probe={};var io=new w({id:"@probe.gl/log"});var l=new w({id:"luma.gl"});function R(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();r=t[0]*1e3+t[1]/1e6}else r=Date.now();return r}var A=class{constructor(t,e){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=t,this.type=e,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(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=R(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(R()-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 P=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,e="count"){return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let e of Object.values(this.stats))t(e)}getTable(){let t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(e=>this._getOrCreate(e))}_getOrCreate(t){let{name:e,type:o}=t,n=this.stats[e];return n||(t instanceof A?n=t:n=new A(e,o),this.stats[e]=n),n}};var M=class{stats=new Map;getStats(t){return this.get(t)}get(t){return this.stats.has(t)||this.stats.set(t,new P({id:t})),this.stats.get(t)}},B=new M;function Ye(){let r="9.0.0-beta.8",t="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==r)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${r}`);return globalThis.luma||(d()&&l.log(1,`${r} - ${t}`)(),globalThis.luma=globalThis.luma||{VERSION:r,version:r,log:l,stats:B}),r}var it=Ye();function xt(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)?r:null}function y(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number"?r:null:xt(r)}var wt={};function S(r="id"){wt[r]=wt[r]||1;let t=wt[r]++;return`${r}-${t}`}function te(r){let t=!0;for(let e in r){t=!1;break}return t}var u=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(t,e,o){if(!t)throw new Error("no device");this._device=t,this.props=Xe(e,o);let n=this.props.id!=="undefined"?this.props.id:S(this[Symbol.toStringTag]);this.props.id=n,this.id=n,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(t){this._attachedResources.add(t)}detachResource(t){this._attachedResources.delete(t)}destroyAttachedResource(t){this._attachedResources.delete(t)&&t.destroy()}destroyAttachedResources(){for(let t of Object.values(this._attachedResources))t.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let t=this._device.statsManager.getStats("Resource Counts"),e=this[Symbol.toStringTag];t.get(`${e}s Active`).decrementCount()}trackAllocatedMemory(t,e=this[Symbol.toStringTag]){let o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(t),o.get(`${e} Memory`).addCount(t),this.allocatedBytes=t}trackDeallocatedMemory(t=this[Symbol.toStringTag]){let e=this._device.statsManager.getStats("Resource Counts");e.get("GPU Memory").subtractCount(this.allocatedBytes),e.get(`${t} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let t=this._device.statsManager.getStats("Resource Counts"),e=this[Symbol.toStringTag];t.get("Resources Created").incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount()}};c(u,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Xe(r,t){let e={...t};for(let o in r)r[o]!==void 0&&(e[o]=r[o]);return e}var N=class extends u{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(t,e){let o={...e};(e.usage||0)&N.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?o.indexType="uint32":e.data instanceof Uint16Array&&(o.indexType="uint16")),super(t,o,N.defaultProps),this.usage=e.usage||0,this.indexType=o.indexType,this.updateTimestamp=t.incrementTimestamp()}readSyncWebGL(t,e){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(t,e,o){let n=ArrayBuffer.isView(t)?t.buffer:t,s=Math.min(t?t.byteLength:o,N.DEBUG_DATA_MAX_LENGTH);t===null?this.debugData=new ArrayBuffer(s):e===0&&o===t.byteLength?this.debugData=n.slice(0,s):this.debugData=n.slice(e,e+s)}},m=N;c(m,"defaultProps",{...u.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),c(m,"MAP_READ",1),c(m,"MAP_WRITE",2),c(m,"COPY_SRC",4),c(m,"COPY_DST",8),c(m,"INDEX",16),c(m,"VERTEX",32),c(m,"UNIFORM",64),c(m,"STORAGE",128),c(m,"INDIRECT",256),c(m,"QUERY_RESOLVE",512),c(m,"DEBUG_DATA_MAX_LENGTH",32);function at(r){let t=ee[r],e=qe(t),o=r.includes("norm"),n=!o&&!r.startsWith("float"),s=r.startsWith("s");return{dataType:ee[r],byteLength:e,integer:n,signed:s,normalized:o}}function qe(r){return Ke[r]}var ee={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ke={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Qe=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Ze=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function re(r){return Qe.some(t=>r.startsWith(t))}function oe(r){let t=Ze.exec(r);if(t){let[,e,o,n,s,i]=t;if(e){let a=`${n}${o}`,f=at(a);return{format:e,components:e.length,srgb:s==="-srgb",unsized:i==="-unsized",webgl:i==="-webgl",...f}}}return tr(r)}var Je={"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 tr(r){let t=Je[r];if(!t)throw new Error(`Unknown format ${r}`);return{format:t.format||"",components:t.components||t.format?.length||1,byteLength:t.bpp||1,srgb:!1,unsized:!1}}var ct=class{},ut=class{features;disabledFeatures;constructor(t=[],e){this.features=new Set(t),this.disabledFeatures=e||{}}*[Symbol.iterator](){yield*this.features}has(t){return!this.disabledFeatures[t]&&this.features.has(t)}},St=class{get[Symbol.toStringTag](){return"Device"}constructor(t){this.props={...St.defaultProps,...t},this.id=this.props.id||S(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=B;_lumaData={};isTextureFormatCompressed(t){return re(t)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(t){return(t instanceof Promise||typeof t=="string")&&(t={data:t}),this._createTexture(t)}createCommandEncoder(t={}){throw new Error("not implemented")}readPixelsToArrayWebGL(t,e){throw new Error("not implemented")}readPixelsToBufferWebGL(t,e){throw new Error("not implemented")}setParametersWebGL(t){throw new Error("not implemented")}getParametersWebGL(t){throw new Error("not implemented")}withParametersWebGL(t,e){throw new Error("not implemented")}clearWebGL(t){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(t){this.props.onError(t)}_getBufferProps(t){(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e={...t};return(t.usage||0)&m.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?e.indexType="uint32":t.data instanceof Uint16Array?e.indexType="uint16":l.warn("indices buffer content must be of integer type")()),e}},x=St;c(x,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(l.get("debug")),spector:Boolean(l.get("spector")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:t=>l.error(t.message)}),c(x,"VERSION",it);function C(r,t){if(!r)throw new Error(t||"luma.gl: assertion failed.")}var E=new Map,I=class{static registerDevices(t){for(let e of t)C(e.type&&e.isSupported&&e.create),E.set(e.type,e)}static getAvailableDevices(){return Array.from(E).map(t=>t.type)}static getSupportedDevices(){return Array.from(E).filter(t=>t.isSupported()).map(t=>t.type)}static setDefaultDeviceProps(t){Object.assign(x.defaultProps,t)}static async createDevice(t={}){t={...x.defaultProps,...t},t.gl&&(t.type="webgl");let e;switch(t.type){case"webgpu":if(e=E.get("webgpu"),e)return await e.create(t);break;case"webgl":if(e=E.get("webgl"),e)return await e.create(t);break;case"best-available":if(e=E.get("webgpu"),e&&e.isSupported())return await e.create(t);if(e=E.get("webgl"),e&&e.isSupported())return await e.create(t);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}};c(I,"stats",B),c(I,"log",l);var er=d()&&typeof document<"u",ft=()=>er&&document.readyState==="complete",rr={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},F=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ft()}constructor(t){if(this.props={...rr,...t},t=this.props,!d()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(t.canvas)typeof t.canvas=="string"?this.canvas=sr(t.canvas):this.canvas=t.canvas;else{let e=ir(t),o=nr(t?.container||null);o.insertBefore(e,o.firstChild),this.canvas=e,t?.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&&t.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(let o of e)o.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(t){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(t=t===void 0?this.props.useDevicePixels:t,!t||t<=0)?1:t===!0?typeof window<"u"&&window.devicePixelRatio||1:t}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 t=this.getDevicePixelRatio(),e=this.canvas;return e.parentElement?[e.clientWidth*t,e.clientHeight*t]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[t,e]=this.getPixelSize();return t/e}cssToDeviceRatio(){try{let[t]=this.getDrawingBufferSize(),{clientWidth:e}=this._canvasSizeInfo;return e?t/e:1}catch{return 1}}cssToDevicePixels(t,e=!0){let o=this.cssToDeviceRatio(),[n,s]=this.getDrawingBufferSize();return ar(t,o,n,s,e)}setDevicePixelRatio(t,e={}){if(!this.htmlCanvas)return;let o="width"in e?e.width:this.htmlCanvas.clientWidth,n="height"in e?e.height:this.htmlCanvas.clientHeight;(!o||!n)&&(l.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,o=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==o||s.clientHeight!==n||s.devicePixelRatio!==t){let i=t,a=Math.floor(o*i),f=Math.floor(n*i);this.htmlCanvas.width=a,this.htmlCanvas.height=f;let[g,b]=this.getDrawingBufferSize();(g!==a||b!==f)&&(i=Math.min(g/o,b/n),this.htmlCanvas.width=Math.floor(o*i),this.htmlCanvas.height=Math.floor(n*i),l.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=o,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=t}}getDrawingBufferSize(){let t=this.device.gl;if(!t)throw new Error("canvas size");return[t.drawingBufferWidth,t.drawingBufferHeight]}_setAutoCreatedCanvasId(t){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=t)}};c(F,"pageLoaded",or());function or(){return ft()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}function nr(r){if(typeof r=="string"){let t=document.getElementById(r);if(!t&&!ft())throw new Error(`Accessing '${r}' before page was loaded`);if(!t)throw new Error(`${r} is not an HTML element`);return t}else if(r)return r;return document.body}function sr(r){let t=document.getElementById(r);if(!t&&!ft())throw new Error(`Accessing '${r}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}function ir(r){let{width:t,height:e}=r,o=document.createElement("canvas");return o.id="lumagl-auto-created-canvas",o.width=t||1,o.height=e||1,o.style.width=Number.isFinite(t)?`${t}px`:"100%",o.style.height=Number.isFinite(e)?`${e}px`:"100%",o}function ar(r,t,e,o,n){let s=r,i=ne(s[0],t,e),a=se(s[1],t,o,n),f=ne(s[0]+1,t,e),g=f===e-1?f:f-1;f=se(s[1]+1,t,o,n);let b;return n?(f=f===0?f:f+1,b=a,a=f):b=f===o-1?f:f-1,{x:i,y:a,width:Math.max(g-i+1,1),height:Math.max(b-a+1,1)}}function ne(r,t,e){return Math.min(Math.round(r*t),e-1)}function se(r,t,e,o){return o?Math.max(0,e-1-Math.round(r*t)):Math.min(Math.round(r*t),e-1)}var Tt=class extends u{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(t,e,o=Tt.defaultProps){super(t,e,o),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=t.incrementTimestamp()}},h=Tt;c(h,"defaultProps",{...u.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}),c(h,"COPY_SRC",1),c(h,"COPY_DST",2),c(h,"TEXTURE_BINDING",4),c(h,"STORAGE_BINDING",8),c(h,"RENDER_ATTACHMENT",16);var At=class extends u{get[Symbol.toStringTag](){return"TextureView"}constructor(t,e){super(t,e,At.defaultProps)}},U=At;c(U,"defaultProps",{...u.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var Et=class extends u{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(t,e){super(t,e,Et.defaultProps)}},D=Et;c(D,"defaultProps",{...u.defaultProps,source:null,colorSpace:"srgb"});function lt(r,t,e){let o="",n=t.split(/\r?\n/),s=r.slice().sort((i,a)=>i.lineNum-a.lineNum);switch(e?.showSourceCode||"no"){case"all":let i=0;for(let a=1;a<=n.length;a++)for(o+=ae(n[a-1],a,e);s.length>i&&s[i].lineNum===a;){let f=s[i++];o+=ie(f,n,f.lineNum,{...e,inlineSource:!1})}return o;case"issues":case"no":for(let a of r)o+=ie(a,n,a.lineNum,{inlineSource:e?.showSourceCode!=="no"});return o}}function ie(r,t,e,o){if(o?.inlineSource){let n=cr(t,e),s=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^ | ||
"use strict";var __exports__=(()=>{var J=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var $e=Object.prototype.hasOwnProperty;var Re=(r,t,e)=>t in r?J(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var Me=(r,t)=>{for(var e in t)J(r,e,{get:t[e],enumerable:!0})},Ne=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Le(t))!$e.call(r,n)&&n!==e&&J(r,n,{get:()=>t[n],enumerable:!(o=Ie(t,n))||o.enumerable});return r};var Fe=r=>Ne(J({},"__esModule",{value:!0}),r);var c=(r,t,e)=>(Re(r,typeof t!="symbol"?t+"":t,e),e);var Pr={};Me(Pr,{Buffer:()=>m,CanvasContext:()=>F,CommandBuffer:()=>Y,CommandEncoder:()=>j,ComputePass:()=>W,ComputePipeline:()=>O,Device:()=>x,DeviceFeatures:()=>ut,DeviceLimits:()=>ct,ExternalTexture:()=>D,Framebuffer:()=>k,QuerySet:()=>Q,RenderPass:()=>V,RenderPipeline:()=>G,Resource:()=>u,Sampler:()=>H,Shader:()=>z,StatsManager:()=>M,Texture:()=>h,TextureView:()=>U,TransformFeedback:()=>K,UniformBlock:()=>$,UniformBufferLayout:()=>L,UniformStore:()=>pt,VERSION:()=>it,VertexArray:()=>q,assert:()=>C,cancelAnimationFrame:()=>Ce,cast:()=>be,checkProps:()=>Se,decodeShaderAttributeType:()=>mt,decodeShaderUniformType:()=>dt,decodeTextureFormat:()=>oe,decodeVertexFormat:()=>X,deepEqual:()=>yt,fillArray:()=>me,formatCompilerLog:()=>lt,formatValue:()=>kt,getAttributeInfosFromLayouts:()=>Nt,getDataTypeFromTypedArray:()=>zt,getScratchArray:()=>le,getScratchArrayBuffer:()=>Z,getTypedArrayFromDataType:()=>ge,getVertexFormatFromAttribute:()=>ye,glsl:()=>_r,isNumberArray:()=>y,isObjectEmpty:()=>te,isTypedArray:()=>xt,isUniformValue:()=>Ht,loadFile:()=>Ae,loadImage:()=>ve,loadImageBitmap:()=>Ee,loadScript:()=>_e,log:()=>l,luma:()=>I,makeRandomNumberGenerator:()=>Gt,mergeShaderLayout:()=>ue,random:()=>Pe,requestAnimationFrame:()=>Be,setPathPrefix:()=>Te,splitUniformsAndBindings:()=>xe,stubRemovedMethods:()=>we,uid:()=>S});function bt(r){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let t=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,e=r||t;return!!(e&&e.indexOf("Electron")>=0)}function d(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||bt()}var Ue=globalThis.self||globalThis.window||globalThis.global,tt=globalThis.window||globalThis.self||globalThis.global,De=globalThis.document||{},et=globalThis.process||{},ze=globalThis.console,$r=globalThis.navigator||{};var rt="4.0.6",Nr=d();function He(r){try{let t=window[r],e="__storage_test__";return t.setItem(e,e),t.removeItem(e),t}catch{return null}}var ot=class{constructor(t,e,o="sessionStorage"){this.storage=He(o),this.id=t,this.config=e,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let t={};if(this.storage){let e=this.storage.getItem(this.id);t=e?JSON.parse(e):{}}return Object.assign(this.config,t),this}};function Wt(r){let t;return r<10?t=`${r.toFixed(2)}ms`:r<100?t=`${r.toFixed(1)}ms`:r<1e3?t=`${r.toFixed(0)}ms`:t=`${(r/1e3).toFixed(2)}s`,t}function jt(r,t=8){let e=Math.max(t-r.length,0);return`${" ".repeat(e)}${r}`}function nt(r,t,e,o=600){let n=r.src.replace(/\(/g,"%28").replace(/\)/g,"%29");r.width>o&&(e=Math.min(e,o/r.width));let s=r.width*e,i=r.height*e,a=["font-size:1px;",`padding:${Math.floor(i/2)}px ${Math.floor(s/2)}px;`,`line-height:${i}px;`,`background:url(${n});`,`background-size:${s}px ${i}px;`,"color:transparent;"].join("");return[`${t} %c+`,a]}var st;(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"})(st||(st={}));var ke=10;function Yt(r){return typeof r!="string"?r:(r=r.toUpperCase(),st[r]||st.WHITE)}function Xt(r,t,e){return!d&&typeof r=="string"&&(t&&(r=`\x1B[${Yt(t)}m${r}\x1B[39m`),e&&(r=`\x1B[${Yt(e)+ke}m${r}\x1B[49m`)),r}function qt(r,t=["constructor"]){let e=Object.getPrototypeOf(r),o=Object.getOwnPropertyNames(e),n=r;for(let s of o){let i=n[s];typeof i=="function"&&(t.find(a=>s===a)||(n[s]=i.bind(r)))}}function v(r,t){if(!r)throw new Error(t||"Assertion failed")}function T(){let r;if(d()&&tt.performance)r=tt?.performance?.now?.();else if("hrtime"in et){let t=et?.hrtime?.();r=t[0]*1e3+t[1]/1e6}else r=Date.now();return r}var _={debug:d()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Ge={enabled:!0,level:0};function p(){}var Kt={},Qt={once:!0},w=class{constructor({id:t}={id:""}){this.VERSION=rt,this._startTs=T(),this._deltaTs=T(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new ot(`__probe-${this.id}__`,Ge),this.timeStamp(`${this.id} started`),qt(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((T()-this._startTs).toPrecision(10))}getDelta(){return Number((T()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,e){this._storage.setConfiguration({[t]:e})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,e){v(t,e)}warn(t){return this._getLogFunction(0,t,_.warn,arguments,Qt)}error(t){return this._getLogFunction(0,t,_.error,arguments)}deprecated(t,e){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${e}\` instead`)}removed(t,e){return this.error(`\`${t}\` has been removed. Use \`${e}\` instead`)}probe(t,e){return this._getLogFunction(t,e,_.log,arguments,{time:!0,once:!0})}log(t,e){return this._getLogFunction(t,e,_.debug,arguments)}info(t,e){return this._getLogFunction(t,e,console.info,arguments)}once(t,e){return this._getLogFunction(t,e,_.debug||_.info,arguments,Qt)}table(t,e,o){return e?this._getLogFunction(t,e,console.table||p,o&&[o],{tag:je(e)}):p}image({logLevel:t,priority:e,image:o,message:n="",scale:s=1}){return this._shouldLog(t||e)?d()?We({image:o,message:n,scale:s}):Oe({image:o,message:n,scale:s}):p}time(t,e){return this._getLogFunction(t,e,console.time?console.time:console.info)}timeEnd(t,e){return this._getLogFunction(t,e,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,e){return this._getLogFunction(t,e,console.timeStamp||p)}group(t,e,o={collapsed:!1}){let n=Zt({logLevel:t,message:e,opts:o}),{collapsed:s}=o;return n.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(t,e,o={}){return this.group(t,e,Object.assign({},o,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||p)}withGroup(t,e,o){this.group(t,e)();try{o()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=Jt(t)}_getLogFunction(t,e,o,n,s){if(this._shouldLog(t)){s=Zt({logLevel:t,message:e,args:n,opts:s}),o=o||s.method,v(o),s.total=this.getTotal(),s.delta=this.getDelta(),this._deltaTs=T();let i=s.tag||s.message;if(s.once&&i)if(!Kt[i])Kt[i]=T();else return p;return e=Ve(this.id,s.message,s),o.bind(console,e,...s.args)}return p}};w.VERSION=rt;function Jt(r){if(!r)return 0;let t;switch(typeof r){case"number":t=r;break;case"object":t=r.logLevel||r.priority||0;break;default:return 0}return v(Number.isFinite(t)&&t>=0),t}function Zt(r){let{logLevel:t,message:e}=r;r.logLevel=Jt(t);let o=r.args?Array.from(r.args):[];for(;o.length&&o.shift()!==e;);switch(typeof t){case"string":case"function":e!==void 0&&o.unshift(e),r.message=t;break;case"object":Object.assign(r,t);break;default:}typeof r.message=="function"&&(r.message=r.message());let n=typeof r.message;return v(n==="string"||n==="object"),Object.assign(r,{args:o},r.opts)}function Ve(r,t,e){if(typeof t=="string"){let o=e.time?jt(Wt(e.total)):"";t=e.time?`${r}: ${o} ${t}`:`${r}: ${t}`,t=Xt(t,e.color,e.background)}return t}function Oe({image:r,message:t="",scale:e=1}){return console.warn("removed"),p}function We({image:r,message:t="",scale:e=1}){if(typeof r=="string"){let n=new Image;return n.onload=()=>{let s=nt(n,t,e);console.log(...s)},n.src=r,p}let o=r.nodeName||"";if(o.toLowerCase()==="img")return console.log(...nt(r,t,e)),p;if(o.toLowerCase()==="canvas"){let n=new Image;return n.onload=()=>console.log(...nt(n,t,e)),n.src=r.toDataURL(),p}return p}function je(r){for(let t in r)for(let e in r[t])return e||"untitled";return"empty"}globalThis.probe={};var io=new w({id:"@probe.gl/log"});var l=new w({id:"luma.gl"});function R(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();r=t[0]*1e3+t[1]/1e6}else r=Date.now();return r}var A=class{constructor(t,e){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=t,this.type=e,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(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=R(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(R()-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 P=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,e="count"){return this._getOrCreate({name:t,type:e})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let e of Object.values(this.stats))t(e)}getTable(){let t={};return this.forEach(e=>{t[e.name]={time:e.time||0,count:e.count||0,average:e.getAverageTime()||0,hz:e.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(e=>this._getOrCreate(e))}_getOrCreate(t){let{name:e,type:o}=t,n=this.stats[e];return n||(t instanceof A?n=t:n=new A(e,o),this.stats[e]=n),n}};var M=class{stats=new Map;getStats(t){return this.get(t)}get(t){return this.stats.has(t)||this.stats.set(t,new P({id:t})),this.stats.get(t)}},B=new M;function Ye(){let r="9.0.0-beta.9",t="set luma.log.level=1 (or higher) to trace rendering";if(globalThis.luma&&globalThis.luma.VERSION!==r)throw new Error(`luma.gl - multiple VERSIONs detected: ${globalThis.luma.VERSION} vs ${r}`);return globalThis.luma||(d()&&l.log(1,`${r} - ${t}`)(),globalThis.luma=globalThis.luma||{VERSION:r,version:r,log:l,stats:B}),r}var it=Ye();function xt(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)?r:null}function y(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number"?r:null:xt(r)}var wt={};function S(r="id"){wt[r]=wt[r]||1;let t=wt[r]++;return`${r}-${t}`}function te(r){let t=!0;for(let e in r){t=!1;break}return t}var u=class{id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(t,e,o){if(!t)throw new Error("no device");this._device=t,this.props=Xe(e,o);let n=this.props.id!=="undefined"?this.props.id:S(this[Symbol.toStringTag]);this.props.id=n,this.id=n,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(t){this._attachedResources.add(t)}detachResource(t){this._attachedResources.delete(t)}destroyAttachedResource(t){this._attachedResources.delete(t)&&t.destroy()}destroyAttachedResources(){for(let t of Object.values(this._attachedResources))t.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let t=this._device.statsManager.getStats("Resource Counts"),e=this[Symbol.toStringTag];t.get(`${e}s Active`).decrementCount()}trackAllocatedMemory(t,e=this[Symbol.toStringTag]){let o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(t),o.get(`${e} Memory`).addCount(t),this.allocatedBytes=t}trackDeallocatedMemory(t=this[Symbol.toStringTag]){let e=this._device.statsManager.getStats("Resource Counts");e.get("GPU Memory").subtractCount(this.allocatedBytes),e.get(`${t} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let t=this._device.statsManager.getStats("Resource Counts"),e=this[Symbol.toStringTag];t.get("Resources Created").incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount()}};c(u,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function Xe(r,t){let e={...t};for(let o in r)r[o]!==void 0&&(e[o]=r[o]);return e}var N=class extends u{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(t,e){let o={...e};(e.usage||0)&N.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?o.indexType="uint32":e.data instanceof Uint16Array&&(o.indexType="uint16")),super(t,o,N.defaultProps),this.usage=e.usage||0,this.indexType=o.indexType,this.updateTimestamp=t.incrementTimestamp()}readSyncWebGL(t,e){throw new Error("not implemented")}debugData=new ArrayBuffer(0);_setDebugData(t,e,o){let n=ArrayBuffer.isView(t)?t.buffer:t,s=Math.min(t?t.byteLength:o,N.DEBUG_DATA_MAX_LENGTH);t===null?this.debugData=new ArrayBuffer(s):e===0&&o===t.byteLength?this.debugData=n.slice(0,s):this.debugData=n.slice(e,e+s)}},m=N;c(m,"defaultProps",{...u.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1}),c(m,"MAP_READ",1),c(m,"MAP_WRITE",2),c(m,"COPY_SRC",4),c(m,"COPY_DST",8),c(m,"INDEX",16),c(m,"VERTEX",32),c(m,"UNIFORM",64),c(m,"STORAGE",128),c(m,"INDIRECT",256),c(m,"QUERY_RESOLVE",512),c(m,"DEBUG_DATA_MAX_LENGTH",32);function at(r){let t=ee[r],e=qe(t),o=r.includes("norm"),n=!o&&!r.startsWith("float"),s=r.startsWith("s");return{dataType:ee[r],byteLength:e,integer:n,signed:s,normalized:o}}function qe(r){return Ke[r]}var ee={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},Ke={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};var Qe=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Ze=/^(rg?b?a?)([0-9]*)([a-z]*)(-srgb)?(-webgl|-unsized)?$/;function re(r){return Qe.some(t=>r.startsWith(t))}function oe(r){let t=Ze.exec(r);if(t){let[,e,o,n,s,i]=t;if(e){let a=`${n}${o}`,f=at(a);return{format:e,components:e.length,srgb:s==="-srgb",unsized:i==="-unsized",webgl:i==="-webgl",...f}}}return tr(r)}var Je={"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 tr(r){let t=Je[r];if(!t)throw new Error(`Unknown format ${r}`);return{format:t.format||"",components:t.components||t.format?.length||1,byteLength:t.bpp||1,srgb:!1,unsized:!1}}var ct=class{},ut=class{features;disabledFeatures;constructor(t=[],e){this.features=new Set(t),this.disabledFeatures=e||{}}*[Symbol.iterator](){yield*this.features}has(t){return!this.disabledFeatures[t]&&this.features.has(t)}},St=class{get[Symbol.toStringTag](){return"Device"}constructor(t){this.props={...St.defaultProps,...t},this.id=this.props.id||S(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=B;_lumaData={};isTextureFormatCompressed(t){return re(t)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(t){return(t instanceof Promise||typeof t=="string")&&(t={data:t}),this._createTexture(t)}createCommandEncoder(t={}){throw new Error("not implemented")}readPixelsToArrayWebGL(t,e){throw new Error("not implemented")}readPixelsToBufferWebGL(t,e){throw new Error("not implemented")}setParametersWebGL(t){throw new Error("not implemented")}getParametersWebGL(t){throw new Error("not implemented")}withParametersWebGL(t,e){throw new Error("not implemented")}clearWebGL(t){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(t){this.props.onError(t)}_getBufferProps(t){(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e={...t};return(t.usage||0)&m.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?e.indexType="uint32":t.data instanceof Uint16Array?e.indexType="uint16":l.warn("indices buffer content must be of integer type")()),e}},x=St;c(x,"defaultProps",{id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:Boolean(l.get("debug")),spector:Boolean(l.get("spector")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:t=>l.error(t.message)}),c(x,"VERSION",it);function C(r,t){if(!r)throw new Error(t||"luma.gl: assertion failed.")}var E=new Map,I=class{static registerDevices(t){for(let e of t)C(e.type&&e.isSupported&&e.create),E.set(e.type,e)}static getAvailableDevices(){return Array.from(E).map(t=>t.type)}static getSupportedDevices(){return Array.from(E).filter(t=>t.isSupported()).map(t=>t.type)}static setDefaultDeviceProps(t){Object.assign(x.defaultProps,t)}static async createDevice(t={}){t={...x.defaultProps,...t},t.gl&&(t.type="webgl");let e;switch(t.type){case"webgpu":if(e=E.get("webgpu"),e)return await e.create(t);break;case"webgl":if(e=E.get("webgl"),e)return await e.create(t);break;case"best-available":if(e=E.get("webgpu"),e&&e.isSupported())return await e.create(t);if(e=E.get("webgl"),e&&e.isSupported())return await e.create(t);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}};c(I,"stats",B),c(I,"log",l);var er=d()&&typeof document<"u",ft=()=>er&&document.readyState==="complete",rr={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},F=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ft()}constructor(t){if(this.props={...rr,...t},t=this.props,!d()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(t.canvas)typeof t.canvas=="string"?this.canvas=sr(t.canvas):this.canvas=t.canvas;else{let e=ir(t),o=nr(t?.container||null);o.insertBefore(e,o.firstChild),this.canvas=e,t?.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&&t.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(let o of e)o.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(t){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(t=t===void 0?this.props.useDevicePixels:t,!t||t<=0)?1:t===!0?typeof window<"u"&&window.devicePixelRatio||1:t}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 t=this.getDevicePixelRatio(),e=this.canvas;return e.parentElement?[e.clientWidth*t,e.clientHeight*t]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[t,e]=this.getPixelSize();return t/e}cssToDeviceRatio(){try{let[t]=this.getDrawingBufferSize(),{clientWidth:e}=this._canvasSizeInfo;return e?t/e:1}catch{return 1}}cssToDevicePixels(t,e=!0){let o=this.cssToDeviceRatio(),[n,s]=this.getDrawingBufferSize();return ar(t,o,n,s,e)}setDevicePixelRatio(t,e={}){if(!this.htmlCanvas)return;let o="width"in e?e.width:this.htmlCanvas.clientWidth,n="height"in e?e.height:this.htmlCanvas.clientHeight;(!o||!n)&&(l.log(1,"Canvas clientWidth/clientHeight is 0")(),t=1,o=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);let s=this._canvasSizeInfo;if(s.clientWidth!==o||s.clientHeight!==n||s.devicePixelRatio!==t){let i=t,a=Math.floor(o*i),f=Math.floor(n*i);this.htmlCanvas.width=a,this.htmlCanvas.height=f;let[g,b]=this.getDrawingBufferSize();(g!==a||b!==f)&&(i=Math.min(g/o,b/n),this.htmlCanvas.width=Math.floor(o*i),this.htmlCanvas.height=Math.floor(n*i),l.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=o,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=t}}getDrawingBufferSize(){let t=this.device.gl;if(!t)throw new Error("canvas size");return[t.drawingBufferWidth,t.drawingBufferHeight]}_setAutoCreatedCanvasId(t){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=t)}};c(F,"pageLoaded",or());function or(){return ft()||typeof window>"u"?Promise.resolve():new Promise(r=>{window.addEventListener("load",()=>r())})}function nr(r){if(typeof r=="string"){let t=document.getElementById(r);if(!t&&!ft())throw new Error(`Accessing '${r}' before page was loaded`);if(!t)throw new Error(`${r} is not an HTML element`);return t}else if(r)return r;return document.body}function sr(r){let t=document.getElementById(r);if(!t&&!ft())throw new Error(`Accessing '${r}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}function ir(r){let{width:t,height:e}=r,o=document.createElement("canvas");return o.id="lumagl-auto-created-canvas",o.width=t||1,o.height=e||1,o.style.width=Number.isFinite(t)?`${t}px`:"100%",o.style.height=Number.isFinite(e)?`${e}px`:"100%",o}function ar(r,t,e,o,n){let s=r,i=ne(s[0],t,e),a=se(s[1],t,o,n),f=ne(s[0]+1,t,e),g=f===e-1?f:f-1;f=se(s[1]+1,t,o,n);let b;return n?(f=f===0?f:f+1,b=a,a=f):b=f===o-1?f:f-1,{x:i,y:a,width:Math.max(g-i+1,1),height:Math.max(b-a+1,1)}}function ne(r,t,e){return Math.min(Math.round(r*t),e-1)}function se(r,t,e,o){return o?Math.max(0,e-1-Math.round(r*t)):Math.min(Math.round(r*t),e-1)}var Tt=class extends u{get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(t,e,o=Tt.defaultProps){super(t,e,o),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=t.incrementTimestamp()}},h=Tt;c(h,"defaultProps",{...u.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}),c(h,"COPY_SRC",1),c(h,"COPY_DST",2),c(h,"TEXTURE_BINDING",4),c(h,"STORAGE_BINDING",8),c(h,"RENDER_ATTACHMENT",16);var At=class extends u{get[Symbol.toStringTag](){return"TextureView"}constructor(t,e){super(t,e,At.defaultProps)}},U=At;c(U,"defaultProps",{...u.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});var Et=class extends u{get[Symbol.toStringTag](){return"ExternalTexture"}constructor(t,e){super(t,e,Et.defaultProps)}},D=Et;c(D,"defaultProps",{...u.defaultProps,source:null,colorSpace:"srgb"});function lt(r,t,e){let o="",n=t.split(/\r?\n/),s=r.slice().sort((i,a)=>i.lineNum-a.lineNum);switch(e?.showSourceCode||"no"){case"all":let i=0;for(let a=1;a<=n.length;a++)for(o+=ae(n[a-1],a,e);s.length>i&&s[i].lineNum===a;){let f=s[i++];o+=ie(f,n,f.lineNum,{...e,inlineSource:!1})}return o;case"issues":case"no":for(let a of r)o+=ie(a,n,a.lineNum,{inlineSource:e?.showSourceCode!=="no"});return o}}function ie(r,t,e,o){if(o?.inlineSource){let n=cr(t,e),s=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^ | ||
`:"";return` | ||
@@ -10,0 +10,0 @@ ${n}${s}${r.type.toUpperCase()}: ${r.message} |
@@ -14,3 +14,3 @@ // luma.gl | ||
// @ts-expect-error | ||
const VERSION = typeof "9.0.0-beta.8" !== 'undefined' ? "9.0.0-beta.8" : 'running from source'; | ||
const VERSION = typeof "9.0.0-beta.9" !== 'undefined' ? "9.0.0-beta.9" : 'running from source'; | ||
const STARTUP_MESSAGE = 'set luma.log.level=1 (or higher) to trace rendering'; | ||
@@ -17,0 +17,0 @@ // Assign luma.log.level in console to control logging: \ |
{ | ||
"name": "@luma.gl/core", | ||
"version": "9.0.0-beta.9", | ||
"version": "9.0.0-beta.10", | ||
"description": "The luma.gl core Device API", | ||
@@ -49,3 +49,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "6a91ba24a0f78ef190c51e52c31271ea1a5a7a1f" | ||
"gitHead": "1b36500a878e1b365425826750320dde7d6929bb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
940977