@deck.gl/mesh-layers
Advanced tools
Comparing version 9.0.0-alpha.3 to 9.0.0-alpha.4
@@ -7,7 +7,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else root['deck'] = factory();})(globalThis, function () { | ||
"use strict";var __exports__=(()=>{var Gt=Object.create;var de=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var kt=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var Vt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ht=(t,e)=>{for(var r in e)de(t,r,{get:e[r],enumerable:!0})},fe=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jt(e))!$t.call(t,n)&&n!==r&&de(t,n,{get:()=>e[n],enumerable:!(o=Bt(e,n))||o.enumerable});return t},V=(t,e,r)=>(fe(t,e,"default"),r&&fe(r,e,"default")),he=(t,e,r)=>(r=t!=null?Gt(kt(t)):{},fe(e||!t||!t.__esModule?de(r,"default",{value:t,enumerable:!0}):r,t)),zt=t=>fe(de({},"__esModule",{value:!0}),t);var se=Vt((Vr,je)=>{je.exports=globalThis.deck});var ce={};Ht(ce,{SimpleMeshLayer:()=>Te});var D={},ke=he(se());V(D,he(se()));if(!ke.Layer)throw new Error("@deck.gl/core is not found");V(ce,D);var G=he(se());function Se(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function R(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||Se()}var Wt=globalThis.self||globalThis.window||globalThis.global,Q=globalThis.window||globalThis.self||globalThis.global,Xt=globalThis.document||{},X=globalThis.process||{},Kt=globalThis.console,Kr=globalThis.navigator||{};var me=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",Zr=R();function Yt(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var pe=class{constructor(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Yt(o),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function $e(t){let e;return t<10?e="".concat(t.toFixed(2),"ms"):t<100?e="".concat(t.toFixed(1),"ms"):t<1e3?e="".concat(t.toFixed(0),"ms"):e="".concat((t/1e3).toFixed(2),"s"),e}function Ve(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,r=Math.max(e-t.length,0);return"".concat(" ".repeat(r)).concat(t)}function ge(t,e,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,n=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>o&&(r=Math.min(r,o/t.width));let i=t.width*r,s=t.height*r,a=["font-size:1px;","padding:".concat(Math.floor(s/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(s,"px;"),"background:url(".concat(n,");"),"background-size:".concat(i,"px ").concat(s,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}var ye;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(ye||(ye={}));var Jt=10;function He(t){return typeof t!="string"?t:(t=t.toUpperCase(),ye[t]||ye.WHITE)}function ze(t,e,r){if(!R&&typeof t=="string"){if(e){let o=He(e);t="\x1B[".concat(o,"m").concat(t,"\x1B[39m")}if(r){let o=He(r);t="\x1B[".concat(o+Jt,"m").concat(t,"\x1B[49m")}}return t}function We(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],r=Object.getPrototypeOf(t),o=Object.getOwnPropertyNames(r),n=t;for(let i of o){let s=n[i];typeof s=="function"&&(e.find(a=>i===a)||(n[i]=s.bind(t)))}}function ee(t,e){if(!t)throw new Error(e||"Assertion failed")}function K(){let t;if(R()&&Q.performance){var e,r;t=Q===null||Q===void 0||(e=Q.performance)===null||e===void 0||(r=e.now)===null||r===void 0?void 0:r.call(e)}else if("hrtime"in X){var o;let n=X===null||X===void 0||(o=X.hrtime)===null||o===void 0?void 0:o.call(X);t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}var te={debug:R()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Zt={enabled:!0,level:0};function M(){}var Xe={},Ke={once:!0},H=class{constructor(){let{id:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=me,this._startTs=K(),this._deltaTs=K(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new pe("__probe-".concat(this.id,"__"),Zt),this.timeStamp("".concat(this.id," started")),We(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((K()-this._startTs).toPrecision(10))}getDelta(){return Number((K()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){ee(e,r)}warn(e){return this._getLogFunction(0,e,te.warn,arguments,Ke)}error(e){return this._getLogFunction(0,e,te.error,arguments)}deprecated(e,r){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(r,"` instead"))}removed(e,r){return this.error("`".concat(e,"` has been removed. Use `").concat(r,"` instead"))}probe(e,r){return this._getLogFunction(e,r,te.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,te.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,te.debug||te.info,arguments,Ke)}table(e,r,o){return r?this._getLogFunction(e,r,console.table||M,o&&[o],{tag:tr(r)}):M}image(e){let{logLevel:r,priority:o,image:n,message:i="",scale:s=1}=e;return this._shouldLog(r||o)?R()?er({image:n,message:i,scale:s}):Qt({image:n,message:i,scale:s}):M}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||M)}group(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},n=Ye({logLevel:e,message:r,opts:o}),{collapsed:i}=o;return n.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(e,r,Object.assign({},o,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||M)}withGroup(e,r,o){this.group(e,r)();try{o()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Je(e)}_getLogFunction(e,r,o,n,i){if(this._shouldLog(e)){i=Ye({logLevel:e,message:r,args:n,opts:i}),o=o||i.method,ee(o),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=K();let s=i.tag||i.message;if(i.once&&s)if(!Xe[s])Xe[s]=K();else return M;return r=qt(this.id,i.message,i),o.bind(console,r,...i.args)}return M}};H.VERSION=me;function Je(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return ee(Number.isFinite(e)&&e>=0),e}function Ye(t){let{logLevel:e,message:r}=t;t.logLevel=Je(e);let o=t.args?Array.from(t.args):[];for(;o.length&&o.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&o.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let n=typeof t.message;return ee(n==="string"||n==="object"),Object.assign(t,{args:o},t.opts)}function qt(t,e,r){if(typeof e=="string"){let o=r.time?Ve($e(r.total)):"";e=r.time?"".concat(t,": ").concat(o," ").concat(e):"".concat(t,": ").concat(e),e=ze(e,r.color,r.background)}return e}function Qt(t){let{image:e,message:r="",scale:o=1}=t;return console.warn("removed"),M}function er(t){let{image:e,message:r="",scale:o=1}=t;if(typeof e=="string"){let i=new Image;return i.onload=()=>{let s=ge(i,r,o);console.log(...s)},i.src=e,M}let n=e.nodeName||"";if(n.toLowerCase()==="img")return console.log(...ge(e,r,o)),M;if(n.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...ge(i,r,o)),i.src=e.toDataURL(),M}return M}function tr(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var To=new H({id:"@probe.gl/log"});var F=new H({id:"luma.gl"});function Ze(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)?t:null}function Ae(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number"?t:null:Ze(t)}var we={};function j(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";we[t]=we[t]||1;let e=we[t]++;return`${t}-${e}`}var C=class{constructor(e,r,o){if(this.id=void 0,this.props=void 0,this.userData={},this.device=void 0,this._device=void 0,this.destroyed=!1,this.allocatedBytes=0,this._attachedResources=new Set,!e)throw new Error("no device");this._device=e,this.props=rr(r,o);let n=this.props.id!=="undefined"?this.props.id:j(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(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(e),o.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};C.defaultProps={id:"undefined",handle:void 0,userData:void 0};function rr(t,e){let r={...e};for(let o in t)t[o]!==void 0&&(r[o]=t[o]);return r}var qe;qe=Symbol.toStringTag;var p=class extends C{get[qe](){return"Buffer"}constructor(e,r){let o={...r};(r.usage||0)&p.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?o.indexType="uint32":r.data instanceof Uint16Array&&(o.indexType="uint16")),super(e,o,p.defaultProps),this.usage=void 0,this.indexType=void 0,this.byteLength=void 0,this.usage=r.usage||0,this.indexType=o.indexType}write(e,r){throw new Error("not implemented")}readAsync(e,r){throw new Error("not implemented")}getData(){throw new Error("not implemented")}};p.defaultProps={...C.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1};p.MAP_READ=1;p.MAP_WRITE=2;p.COPY_SRC=4;p.COPY_DST=8;p.INDEX=16;p.VERTEX=32;p.UNIFORM=64;p.STORAGE=128;p.INDIRECT=256;p.QUERY_RESOLVE=512;var Qe;Qe=Symbol.toStringTag;var A=class extends C{get[Qe](){return"Texture"}constructor(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:A.defaultProps;super(e,r,o),this.dimension=void 0,this.format=void 0,this.width=void 0,this.height=void 0,this.depth=void 0,this.sampler=void 0,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}};A.defaultProps={...C.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0};A.COPY_SRC=1;A.COPY_DST=2;A.TEXTURE_BINDING=4;A.STORAGE_BINDING=8;A.RENDER_ATTACHMENT=16;var et;et=Symbol.toStringTag;var U=class extends C{get[et](){return"RenderPipeline"}constructor(e,r){super(e,r,U.defaultProps),this.hash="",this.vs=void 0,this.fs=void 0,this.shaderLayout=void 0,this.bufferLayout=void 0,this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}};U.defaultProps={...C.defaultProps,vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}};function tt(t){let[e,r]=nr[t],o=e==="i32"||e==="u32",n=e!=="u32",i=ir[e]*r,s=or(e,r);return{dataType:e,components:r,defaultVertexFormat:s,byteLength:i,integer:o,signed:n}}function or(t,e){let r;switch(t){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?r:`${r}x${e}`}var nr={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},ir={f32:4,f16:2,i32:4,u32:4};function ot(t){let e=rt[t],r=sr(e),o=t.includes("norm"),n=!o&&!t.startsWith("float"),i=t.startsWith("s");return{dataType:rt[t],byteLength:r,integer:n,signed:i,normalized:o}}function sr(t){return ar[t]}var rt={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},ar={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Le(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,o]=t.split("x"),n=r,i=o?parseInt(o):1,s=ot(n),a={type:n,components:i,byteLength:s.byteLength*i,integer:s.integer,signed:s.signed,normalized:s.normalized};return e&&(a.webglOnly=!0),a}function Me(t,e){let r={};for(let o of t.attributes)r[o.name]=ur(t,e,o.name);return r}function ur(t,e,r){let o=lr(t,r),n=cr(e,r);if(!o)return null;let i=tt(o.type),s=n?.vertexFormat||i.defaultVertexFormat,a=Le(s);return{attributeName:n?.attributeName||o.name,bufferName:n?.bufferName||o.name,location:o.location,shaderType:o.type,shaderDataType:i.dataType,shaderComponents:i.components,vertexFormat:s,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:i.integer,stepMode:n?.stepMode||o.stepMode,byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function lr(t,e){let r=t.attributes.find(o=>o.name===e);return r||F.warn(`shader layout attribute "${e}" not present in shader`),r||null}function cr(t,e){fr(t);let r=dr(t,e);return r||(r=hr(t,e),r)?r:(F.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function fr(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&F.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function dr(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function hr(t,e){for(let o of t){var r;let n=o.byteStride;if(typeof o.byteStride!="number")for(let s of o.attributes||[]){let a=Le(s.format);n+=a.byteLength}let i=(r=o.attributes)===null||r===void 0?void 0:r.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:o.name,stepMode:o.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function Y(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}function ae(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!ae(t[o],e[o],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let i of o)if(!e.hasOwnProperty(i)||!ae(t[i],e[i],r-1))return!1;return!0}return!1}var E=t=>`${t}`;function P(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var Ce={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function it(t){let e={};for(let[r,o]of Object.entries(t))e[r]=mr(o);return e}function st(t,e,r){let o={};for(let[n,i]of Object.entries(e))t&&n in t&&!i.private?(i.validate&&P(i.validate(t[n],i),`${r}: invalid ${n}`),o[n]=t[n]):o[n]=i.value;return o}function mr(t){let e=nt(t);if(e!=="object")return{value:t,...Ce[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...Ce[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=nt(t.value),{...t,...Ce[e],type:e}):{type:"object",value:null};throw new Error("props")}function nt(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var at=E`\ | ||
"use strict";var __exports__=(()=>{var jt=Object.create;var me=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var Ht=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var Wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xt=(t,e)=>{for(var r in e)me(t,r,{get:e[r],enumerable:!0})},de=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vt(e))!zt.call(t,n)&&n!==r&&me(t,n,{get:()=>e[n],enumerable:!(o=$t(e,n))||o.enumerable});return t},V=(t,e,r)=>(de(t,e,"default"),r&&de(r,e,"default")),he=(t,e,r)=>(r=t!=null?jt(Ht(t)):{},de(e||!t||!t.__esModule?me(r,"default",{value:t,enumerable:!0}):r,t)),Kt=t=>de(me({},"__esModule",{value:!0}),t);var ae=Wt((Xr,$e)=>{$e.exports=globalThis.deck});var le={};Xt(le,{SimpleMeshLayer:()=>Te});var D={},Ve=he(ae());V(D,he(ae()));if(!Ve.Layer)throw new Error("@deck.gl/core is not found");V(le,D);var U=he(ae());var Ae={};function He(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";Ae[t]=Ae[t]||1;let e=Ae[t]++;return`${t}-${e}`}var Q=class{constructor(e,r,o){if(this.id=void 0,this.props=void 0,this.userData={},this.device=void 0,this._device=void 0,this.destroyed=!1,this.allocatedBytes=0,this._attachedResources=new Set,!e)throw new Error("no device");this._device=e,this.props=Yt(r,o);let n=this.props.id!=="undefined"?this.props.id:He(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(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(e),o.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};Q.defaultProps={id:"undefined",handle:void 0,userData:void 0};function Yt(t,e){let r={...e};for(let o in t)t[o]!==void 0&&(r[o]=t[o]);return r}var ze;ze=Symbol.toStringTag;var A=class extends Q{get[ze](){return"Texture"}constructor(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:A.defaultProps;super(e,r,o),this.dimension=void 0,this.format=void 0,this.width=void 0,this.height=void 0,this.depth=void 0,this.sampler=void 0,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}};A.defaultProps={...Q.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,sampler:{},compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0};A.COPY_SRC=1;A.COPY_DST=2;A.TEXTURE_BINDING=4;A.STORAGE_BINDING=8;A.RENDER_ATTACHMENT=16;function we(t){if(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&Boolean(process.versions.electron))return!0;let e=typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function R(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process.browser)||we()}var Jt=globalThis.self||globalThis.window||globalThis.global,ee=globalThis.window||globalThis.self||globalThis.global,qt=globalThis.document||{},X=globalThis.process||{},Zt=globalThis.console,io=globalThis.navigator||{};var pe=typeof __VERSION__<"u"?__VERSION__:"untranspiled source",uo=R();function Qt(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var ge=class{constructor(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"sessionStorage";this.storage=void 0,this.id=void 0,this.config=void 0,this.storage=Qt(o),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function We(t){let e;return t<10?e="".concat(t.toFixed(2),"ms"):t<100?e="".concat(t.toFixed(1),"ms"):t<1e3?e="".concat(t.toFixed(0),"ms"):e="".concat((t/1e3).toFixed(2),"s"),e}function Xe(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8,r=Math.max(e-t.length,0);return"".concat(" ".repeat(r)).concat(t)}function ye(t,e,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:600,n=t.src.replace(/\(/g,"%28").replace(/\)/g,"%29");t.width>o&&(r=Math.min(r,o/t.width));let i=t.width*r,s=t.height*r,a=["font-size:1px;","padding:".concat(Math.floor(s/2),"px ").concat(Math.floor(i/2),"px;"),"line-height:".concat(s,"px;"),"background:url(".concat(n,");"),"background-size:".concat(i,"px ").concat(s,"px;"),"color:transparent;"].join("");return["".concat(e," %c+"),a]}var xe;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(xe||(xe={}));var er=10;function Ke(t){return typeof t!="string"?t:(t=t.toUpperCase(),xe[t]||xe.WHITE)}function Ye(t,e,r){if(!R&&typeof t=="string"){if(e){let o=Ke(e);t="\x1B[".concat(o,"m").concat(t,"\x1B[39m")}if(r){let o=Ke(r);t="\x1B[".concat(o+er,"m").concat(t,"\x1B[49m")}}return t}function Je(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["constructor"],r=Object.getPrototypeOf(t),o=Object.getOwnPropertyNames(r),n=t;for(let i of o){let s=n[i];typeof s=="function"&&(e.find(a=>i===a)||(n[i]=s.bind(t)))}}function te(t,e){if(!t)throw new Error(e||"Assertion failed")}function K(){let t;if(R()&&ee.performance){var e,r;t=ee===null||ee===void 0||(e=ee.performance)===null||e===void 0||(r=e.now)===null||r===void 0?void 0:r.call(e)}else if("hrtime"in X){var o;let n=X===null||X===void 0||(o=X.hrtime)===null||o===void 0?void 0:o.call(X);t=n[0]*1e3+n[1]/1e6}else t=Date.now();return t}var re={debug:R()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},tr={enabled:!0,level:0};function C(){}var qe={},Ze={once:!0},H=class{constructor(){let{id:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{id:""};this.id=void 0,this.VERSION=pe,this._startTs=K(),this._deltaTs=K(),this._storage=void 0,this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new ge("__probe-".concat(this.id,"__"),tr),this.timeStamp("".concat(this.id," started")),Je(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((K()-this._startTs).toPrecision(10))}getDelta(){return Number((K()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){te(e,r)}warn(e){return this._getLogFunction(0,e,re.warn,arguments,Ze)}error(e){return this._getLogFunction(0,e,re.error,arguments)}deprecated(e,r){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(r,"` instead"))}removed(e,r){return this.error("`".concat(e,"` has been removed. Use `").concat(r,"` instead"))}probe(e,r){return this._getLogFunction(e,r,re.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,re.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,re.debug||re.info,arguments,Ze)}table(e,r,o){return r?this._getLogFunction(e,r,console.table||C,o&&[o],{tag:ir(r)}):C}image(e){let{logLevel:r,priority:o,image:n,message:i="",scale:s=1}=e;return this._shouldLog(r||o)?R()?nr({image:n,message:i,scale:s}):or({image:n,message:i,scale:s}):C}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||C)}group(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{collapsed:!1},n=Qe({logLevel:e,message:r,opts:o}),{collapsed:i}=o;return n.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,r){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.group(e,r,Object.assign({},o,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||C)}withGroup(e,r,o){this.group(e,r)();try{o()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=et(e)}_getLogFunction(e,r,o,n,i){if(this._shouldLog(e)){i=Qe({logLevel:e,message:r,args:n,opts:i}),o=o||i.method,te(o),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=K();let s=i.tag||i.message;if(i.once&&s)if(!qe[s])qe[s]=K();else return C;return r=rr(this.id,i.message,i),o.bind(console,r,...i.args)}return C}};H.VERSION=pe;function et(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return te(Number.isFinite(e)&&e>=0),e}function Qe(t){let{logLevel:e,message:r}=t;t.logLevel=et(e);let o=t.args?Array.from(t.args):[];for(;o.length&&o.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&o.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let n=typeof t.message;return te(n==="string"||n==="object"),Object.assign(t,{args:o},t.opts)}function rr(t,e,r){if(typeof e=="string"){let o=r.time?Xe(We(r.total)):"";e=r.time?"".concat(t,": ").concat(o," ").concat(e):"".concat(t,": ").concat(e),e=Ye(e,r.color,r.background)}return e}function or(t){let{image:e,message:r="",scale:o=1}=t;return console.warn("removed"),C}function nr(t){let{image:e,message:r="",scale:o=1}=t;if(typeof e=="string"){let i=new Image;return i.onload=()=>{let s=ye(i,r,o);console.log(...s)},i.src=e,C}let n=e.nodeName||"";if(n.toLowerCase()==="img")return console.log(...ye(e,r,o)),C;if(n.toLowerCase()==="canvas"){let i=new Image;return i.onload=()=>console.log(...ye(i,r,o)),i.src=e.toDataURL(),C}return C}function ir(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var Do=new H({id:"@probe.gl/log"});var N=new H({id:"luma.gl"});function tt(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)?t:null}function Me(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number"?t:null:tt(t)}var Ce={};function G(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"id";Ce[t]=Ce[t]||1;let e=Ce[t]++;return`${t}-${e}`}var k=class{constructor(e,r,o){if(this.id=void 0,this.props=void 0,this.userData={},this.device=void 0,this._device=void 0,this.destroyed=!1,this.allocatedBytes=0,this._attachedResources=new Set,!e)throw new Error("no device");this._device=e,this.props=sr(r,o);let n=this.props.id!=="undefined"?this.props.id:G(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(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get(`${r}s Active`).decrementCount()}trackAllocatedMemory(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this[Symbol.toStringTag],o=this._device.statsManager.getStats("Resource Counts");o.get("GPU Memory").addCount(e),o.get(`${r} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this[Symbol.toStringTag],r=this._device.statsManager.getStats("Resource Counts");r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),r=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${r}s Created`).incrementCount(),e.get(`${r}s Active`).incrementCount()}};k.defaultProps={id:"undefined",handle:void 0,userData:void 0};function sr(t,e){let r={...e};for(let o in t)t[o]!==void 0&&(r[o]=t[o]);return r}var rt;rt=Symbol.toStringTag;var p=class extends k{get[rt](){return"Buffer"}constructor(e,r){let o={...r};(r.usage||0)&p.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?o.indexType="uint32":r.data instanceof Uint16Array&&(o.indexType="uint16")),super(e,o,p.defaultProps),this.usage=void 0,this.indexType=void 0,this.byteLength=void 0,this.usage=r.usage||0,this.indexType=o.indexType}write(e,r){throw new Error("not implemented")}readAsync(e,r){throw new Error("not implemented")}getData(){throw new Error("not implemented")}};p.defaultProps={...k.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",mappedAtCreation:!1};p.MAP_READ=1;p.MAP_WRITE=2;p.COPY_SRC=4;p.COPY_DST=8;p.INDEX=16;p.VERTEX=32;p.UNIFORM=64;p.STORAGE=128;p.INDIRECT=256;p.QUERY_RESOLVE=512;var ot;ot=Symbol.toStringTag;var F=class extends k{get[ot](){return"RenderPipeline"}constructor(e,r){super(e,r,F.defaultProps),this.hash="",this.vs=void 0,this.fs=void 0,this.shaderLayout=void 0,this.bufferLayout=void 0,this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}};F.defaultProps={...k.defaultProps,vs:null,vsEntryPoint:"",vsConstants:{},fs:null,fsEntryPoint:"",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",parameters:{},vertexCount:0,instanceCount:0,bindings:{},uniforms:{}};function nt(t){let[e,r]=ur[t],o=e==="i32"||e==="u32",n=e!=="u32",i=cr[e]*r,s=ar(e,r);return{dataType:e,components:r,defaultVertexFormat:s,byteLength:i,integer:o,signed:n}}function ar(t,e){let r;switch(t){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e<=2?"float16x2":"float16x4"}return e===1?r:`${r}x${e}`}var ur={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},cr={f32:4,f16:2,i32:4,u32:4};function st(t){let e=it[t],r=fr(e),o=t.includes("norm"),n=!o&&!t.startsWith("float"),i=t.startsWith("s");return{dataType:it[t],byteLength:r,integer:n,signed:i,normalized:o}}function fr(t){return lr[t]}var it={uint8:"uint8",sint8:"sint8",unorm8:"uint8",snorm8:"sint8",uint16:"uint16",sint16:"sint16",unorm16:"uint16",snorm16:"sint16",float16:"float16",float32:"float32",uint32:"uint32",sint32:"sint32"},lr={uint8:1,sint8:1,uint16:2,sint16:2,float16:2,float32:4,uint32:4,sint32:4};function Le(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,o]=t.split("x"),n=r,i=o?parseInt(o):1,s=st(n),a={type:n,components:i,byteLength:s.byteLength*i,integer:s.integer,signed:s.signed,normalized:s.normalized};return e&&(a.webglOnly=!0),a}function Re(t,e){let r={};for(let o of t.attributes)r[o.name]=dr(t,e,o.name);return r}function dr(t,e,r){let o=mr(t,r),n=hr(e,r);if(!o)return null;let i=nt(o.type),s=n?.vertexFormat||i.defaultVertexFormat,a=Le(s);return{attributeName:n?.attributeName||o.name,bufferName:n?.bufferName||o.name,location:o.location,shaderType:o.type,shaderDataType:i.dataType,shaderComponents:i.components,vertexFormat:s,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:i.integer,stepMode:n?.stepMode||o.stepMode,byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function mr(t,e){let r=t.attributes.find(o=>o.name===e);return r||N.warn(`shader layout attribute "${e}" not present in shader`),r||null}function hr(t,e){pr(t);let r=gr(t,e);return r||(r=yr(t,e),r)?r:(N.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function pr(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&N.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function gr(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function yr(t,e){for(let o of t){var r;let n=o.byteStride;if(typeof o.byteStride!="number")for(let s of o.attributes||[]){let a=Le(s.format);n+=a.byteLength}let i=(r=o.attributes)===null||r===void 0?void 0:r.find(s=>s.attribute===e);if(i)return{attributeName:i.attribute,bufferName:o.name,stepMode:o.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:n}}return null}function Y(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}function ue(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!ue(t[o],e[o],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let i of o)if(!e.hasOwnProperty(i)||!ue(t[i],e[i],r-1))return!1;return!0}return!1}var S=t=>`${t}`;function P(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var Pe={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function ut(t){let e={};for(let[r,o]of Object.entries(t))e[r]=xr(o);return e}function ct(t,e,r){let o={};for(let[n,i]of Object.entries(e))t&&n in t&&!i.private?(i.validate&&P(i.validate(t[n],i),`${r}: invalid ${n}`),o[n]=t[n]):o[n]=i.value;return o}function xr(t){let e=at(t);if(e!=="object")return{value:t,...Pe[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...Pe[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=at(t.value),{...t,...Pe[e],type:e}):{type:"object",value:null};throw new Error("props")}function at(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var ft=S`\ | ||
#ifdef MODULE_LOGDEPTH | ||
logdepth_adjustPosition(gl_Position); | ||
#endif | ||
`,ut=E`\ | ||
`,lt=S`\ | ||
#ifdef MODULE_MATERIAL | ||
@@ -33,8 +33,8 @@ gl_FragColor = material_filterColor(gl_FragColor); | ||
#endif | ||
`;var pr={vertex:at,fragment:ut},lt=/void\s+main\s*\([^)]*\)\s*\{\n?/,ct=/}\n?[^{}]*$/,Ie=[],ue="__LUMA_INJECT_DECLARATIONS__";function ft(t){let e={vertex:{},fragment:{}};for(let r in t){let o=t[r],n=gr(r);typeof o=="string"&&(o={order:0,injection:o}),e[n][r]=o}return e}function gr(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function le(t,e,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,n=e==="vertex";for(let i in r){let s=r[i];s.sort((u,l)=>u.order-l.order),Ie.length=s.length;for(let u=0,l=s.length;u<l;++u)Ie[u]=s[u].injection;let a=`${Ie.join(` | ||
`;var vr={vertex:ft,fragment:lt},dt=/void\s+main\s*\([^)]*\)\s*\{\n?/,mt=/}\n?[^{}]*$/,Ie=[],ce="__LUMA_INJECT_DECLARATIONS__";function ht(t){let e={vertex:{},fragment:{}};for(let r in t){let o=t[r],n=br(r);typeof o=="string"&&(o={order:0,injection:o}),e[n][r]=o}return e}function br(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function fe(t,e,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,n=e==="vertex";for(let i in r){let s=r[i];s.sort((u,c)=>u.order-c.order),Ie.length=s.length;for(let u=0,c=s.length;u<c;++u)Ie[u]=s[u].injection;let a=`${Ie.join(` | ||
`)} | ||
`;switch(i){case"vs:#decl":n&&(t=t.replace(ue,a));break;case"vs:#main-start":n&&(t=t.replace(lt,u=>u+a));break;case"vs:#main-end":n&&(t=t.replace(ct,u=>a+u));break;case"fs:#decl":n||(t=t.replace(ue,a));break;case"fs:#main-start":n||(t=t.replace(lt,u=>u+a));break;case"fs:#main-end":n||(t=t.replace(ct,u=>a+u));break;default:t=t.replace(i,u=>u+a)}}return t=t.replace(ue,""),o&&(t=t.replace(/\}\s*$/,i=>i+pr[e])),t}var k=class{static instantiateModules(e){return e.map(r=>{if(r instanceof k)return r;P(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${r}' and use it directly.`),P(r.name,"shader module has no name");let o=new k(r);return o.dependencies=k.instantiateModules(r.dependencies||[]),o})}constructor(e){this.name=void 0,this.vs=void 0,this.fs=void 0,this.getModuleUniforms=void 0,this.dependencies=void 0,this.deprecations=void 0,this.defines=void 0,this.injections=void 0,this.uniforms={},this.uniformTypes={};let{name:r,vs:o,fs:n,dependencies:i=[],uniforms:s={},getUniforms:a,deprecations:u=[],defines:l={},inject:c={}}=e;P(typeof r=="string"),this.name=r,this.vs=o,this.fs=n,this.getModuleUniforms=a,this.dependencies=k.instantiateModules(i),this.deprecations=this._parseDeprecationDefinitions(u),this.defines=l,this.injections=ft(c),s&&(this.uniforms=it(s))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:P(!1)}return`#define MODULE_${this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_")} | ||
`;switch(i){case"vs:#decl":n&&(t=t.replace(ce,a));break;case"vs:#main-start":n&&(t=t.replace(dt,u=>u+a));break;case"vs:#main-end":n&&(t=t.replace(mt,u=>a+u));break;case"fs:#decl":n||(t=t.replace(ce,a));break;case"fs:#main-start":n||(t=t.replace(dt,u=>u+a));break;case"fs:#main-end":n||(t=t.replace(mt,u=>a+u));break;default:t=t.replace(i,u=>u+a)}}return t=t.replace(ce,""),o&&(t=t.replace(/\}\s*$/,i=>i+vr[e])),t}var j=class{static instantiateModules(e){return e.map(r=>{if(r instanceof j)return r;P(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${r}' and use it directly.`),P(r.name,"shader module has no name");let o=new j(r);return o.dependencies=j.instantiateModules(r.dependencies||[]),o})}constructor(e){this.name=void 0,this.vs=void 0,this.fs=void 0,this.getModuleUniforms=void 0,this.dependencies=void 0,this.deprecations=void 0,this.defines=void 0,this.injections=void 0,this.uniforms={},this.uniformTypes={};let{name:r,vs:o,fs:n,dependencies:i=[],uniformPropTypes:s={},getUniforms:a,deprecations:u=[],defines:c={},inject:f={}}=e;P(typeof r=="string"),this.name=r,this.vs=o,this.fs=n,this.getModuleUniforms=a,this.dependencies=j.instantiateModules(i),this.deprecations=this._parseDeprecationDefinitions(u),this.defines=c,this.injections=ht(f),s&&(this.uniforms=ut(s))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:P(!1)}return`#define MODULE_${this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_")} | ||
${r}// END MODULE_${this.name} | ||
`}getUniforms(e,r){return this.getModuleUniforms?this.getModuleUniforms(e,r):st(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,r){this.deprecations.forEach(o=>{var n;(n=o.regex)!==null&&n!==void 0&&n.test(e)&&(o.deprecated?r.deprecated(o.old,o.new)():r.removed(o.old,o.new)())})}_parseDeprecationDefinitions(e){return e.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),e}_defaultGetUniforms(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={},o=this.uniforms;for(let n in o){let i=o[n];n in e&&!i.private?(i.validate&&P(i.validate(e[n],i),`${this.name}: invalid ${n}`),r[n]=e[n]):r[n]=i.value}return r}};function dt(t){let e=k.instantiateModules(t);return yr(e)}function yr(t){let e={},r={};return ht({modules:t,level:0,moduleMap:e,moduleDepth:r}),Object.keys(r).sort((o,n)=>r[n]-r[o]).map(o=>e[o])}function ht(t){let{modules:e,level:r,moduleMap:o,moduleDepth:n}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)o[i.name]=i,(n[i.name]===void 0||n[i.name]<r)&&(n[i.name]=r);for(let i of e)i.dependencies&&ht({modules:i.dependencies,level:r+1,moduleMap:o,moduleDepth:n})}function mt(t){switch(t?.gpu.toLowerCase()){case"apple":return E`\ | ||
`}getUniforms(e,r){return this.getModuleUniforms?this.getModuleUniforms(e,r):ct(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,r){this.deprecations.forEach(o=>{var n;(n=o.regex)!==null&&n!==void 0&&n.test(e)&&(o.deprecated?r.deprecated(o.old,o.new)():r.removed(o.old,o.new)())})}_parseDeprecationDefinitions(e){return e.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),e}_defaultGetUniforms(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r={},o=this.uniforms;for(let n in o){let i=o[n];n in e&&!i.private?(i.validate&&P(i.validate(e[n],i),`${this.name}: invalid ${n}`),r[n]=e[n]):r[n]=i.value}return r}};function pt(t){let e=j.instantiateModules(t);return _r(e)}function _r(t){let e={},r={};return gt({modules:t,level:0,moduleMap:e,moduleDepth:r}),Object.keys(r).sort((o,n)=>r[n]-r[o]).map(o=>e[o])}function gt(t){let{modules:e,level:r,moduleMap:o,moduleDepth:n}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)o[i.name]=i,(n[i.name]===void 0||n[i.name]<r)&&(n[i.name]=r);for(let i of e)i.dependencies&>({modules:i.dependencies,level:r+1,moduleMap:o,moduleDepth:n})}function yt(t){switch(t?.gpu.toLowerCase()){case"apple":return S`\ | ||
#define APPLE_GPU | ||
@@ -46,7 +46,7 @@ // Apple optimizes away the calculation necessary for emulated fp64 | ||
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 | ||
`;case"nvidia":return E`\ | ||
`;case"nvidia":return S`\ | ||
#define NVIDIA_GPU | ||
// Nvidia optimizes away the calculation necessary for emulated fp64 | ||
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 | ||
`;case"intel":return E`\ | ||
`;case"intel":return S`\ | ||
#define INTEL_GPU | ||
@@ -59,5 +59,5 @@ // Intel optimizes away the calculation necessary for emulated fp64 | ||
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 | ||
`;case"amd":return E`\ | ||
`;case"amd":return S`\ | ||
#define AMD_GPU | ||
`;default:return E`\ | ||
`;default:return S`\ | ||
#define DEFAULT_GPU | ||
@@ -70,3 +70,3 @@ // Prevent driver from optimizing away the calculation necessary for emulated fp64 | ||
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 | ||
`}}function pt(t){let e=E`\ | ||
`}}function xt(t){let e=S`\ | ||
#if (__VERSION__ > 120) | ||
@@ -78,3 +78,3 @@ # define FEATURE_GLSL_DERIVATIVES | ||
#endif // __VERSION | ||
`;return!t.features.has("webgl2")&&t.features.has("glsl-frag-depth")&&(e+=E`\ | ||
`;return!t.features.has("webgl2")&&t.features.has("glsl-frag-depth")&&(e+=S`\ | ||
@@ -88,3 +88,3 @@ // FRAG_DEPTH => gl_FragDepth is available | ||
#endif | ||
`),!t.features.has("webgl2")&&t!==null&&t!==void 0&&t.features.has("glsl-derivatives")&&(e+=E`\ | ||
`),!t.features.has("webgl2")&&t!==null&&t!==void 0&&t.features.has("glsl-derivatives")&&(e+=S`\ | ||
@@ -97,3 +97,3 @@ // DERIVATIVES => dxdF, dxdY and fwidth are available | ||
#endif | ||
`),!t.features.has("webgl2")&&t!==null&&t!==void 0&&t.features.has("glsl-frag-data")&&(e+=E`\ | ||
`),!t.features.has("webgl2")&&t!==null&&t!==void 0&&t.features.has("glsl-frag-data")&&(e+=S`\ | ||
@@ -106,3 +106,3 @@ // DRAW_BUFFERS => gl_FragData[] is available | ||
#endif | ||
`),!t.features.has("webgl2")&&t!==null&&t!==void 0&&t.features.has("glsl-texture-lod")&&(e+=E`\ | ||
`),!t.features.has("webgl2")&&t!==null&&t!==void 0&&t.features.has("glsl-texture-lod")&&(e+=S`\ | ||
// TEXTURE_LOD => texture2DLod etc are available | ||
@@ -114,33 +114,33 @@ #ifdef GL_EXT_shader_texture_lod | ||
#endif | ||
`),e}function gt(t,e,r){switch(e){case 300:switch(r){case"vertex":return ve(t,vr);case"fragment":return Tr(t);default:throw new Error(`unknown shader stage ${r}`)}case 100:switch(r){case"vertex":return ve(t,br);case"fragment":return Sr(t);default:throw new Error(`unknown shader stage ${r}`)}default:throw new Error(`unknown GLSL version ${e}`)}}var yt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es | ||
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],vr=[...yt,[re("attribute"),"in $1"],[re("varying"),"out $1"]],xr=[...yt,[re("varying"),"in $1"]],vt=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],br=[...vt,[re("in"),"attribute $1"],[re("out"),"varying $1"]],_r=[...vt,[re("in"),"varying $1"]],Re="gl_FragColor",Pe=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,Er=/void\s+main\s*\([^)]*\)\s*\{\n?/;function ve(t,e){for(let[r,o]of e)t=t.replace(r,o);return t}function Tr(t){t=ve(t,xr);let e=Pe.exec(t);if(e){let r=e[1];t=t.replace(new RegExp(`\\b${Re}\\b`,"g"),r)}else{let r="fragmentColor";t=t.replace(Er,o=>`out vec4 ${r}; | ||
${o}`).replace(new RegExp(`\\b${Re}\\b`,"g"),r)}return t}function Sr(t){t=ve(t,_r);let e=Pe.exec(t);if(e){let r=e[1];t=t.replace(Pe,"").replace(new RegExp(`\\b${r}\\b`,"g"),Re)}return t}function re(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Oe(t,e){let r="";for(let o in t){let n=t[o];if(r+=`void ${n.signature} { | ||
`),e}function vt(t,e,r){switch(e){case 300:switch(r){case"vertex":return ve(t,Sr);case"fragment":return Mr(t);default:throw new Error(`unknown shader stage ${r}`)}case 100:switch(r){case"vertex":return ve(t,Tr);case"fragment":return Cr(t);default:throw new Error(`unknown shader stage ${r}`)}default:throw new Error(`unknown GLSL version ${e}`)}}var bt=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es | ||
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Sr=[...bt,[oe("attribute"),"in $1"],[oe("varying"),"out $1"]],Er=[...bt,[oe("varying"),"in $1"]],_t=[[/^#version[ \t]+300[ \t]+es/,"#version 100"],[/\btexture(2D|2DProj|Cube)Lod\(/g,"texture$1LodEXT("],[/\btexture\(/g,"texture2D("],[/\btextureLod\(/g,"texture2DLodEXT("]],Tr=[..._t,[oe("in"),"attribute $1"],[oe("out"),"varying $1"]],Ar=[..._t,[oe("in"),"varying $1"]],Oe="gl_FragColor",De=/\bout[ \t]+vec4[ \t]+(\w+)[ \t]*;\n?/,wr=/void\s+main\s*\([^)]*\)\s*\{\n?/;function ve(t,e){for(let[r,o]of e)t=t.replace(r,o);return t}function Mr(t){t=ve(t,Er);let e=De.exec(t);if(e){let r=e[1];t=t.replace(new RegExp(`\\b${Oe}\\b`,"g"),r)}else{let r="fragmentColor";t=t.replace(wr,o=>`out vec4 ${r}; | ||
${o}`).replace(new RegExp(`\\b${Oe}\\b`,"g"),r)}return t}function Cr(t){t=ve(t,Ar);let e=De.exec(t);if(e){let r=e[1];t=t.replace(De,"").replace(new RegExp(`\\b${r}\\b`,"g"),Oe)}return t}function oe(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Ne(t,e){let r="";for(let o in t){let n=t[o];if(r+=`void ${n.signature} { | ||
`,n.header&&(r+=` ${n.header}`),e[o]){let i=e[o];i.sort((s,a)=>s.order-a.order);for(let s of i)r+=` ${s.injection} | ||
`}n.footer&&(r+=` ${n.footer}`),r+=`} | ||
`}return r}function Ne(t){let e={vertex:{},fragment:{}};for(let r of t){let o,n;typeof r!="string"?(o=r,n=o.hook):(o={},n=r),n=n.trim();let[i,s]=n.split(":"),a=n.replace(/\(.+/,""),u=Object.assign(o,{signature:s});switch(i){case"vs":e.vertex[a]=u;break;case"fs":e.fragment[a]=u;break;default:throw new Error(i)}}return e}var Et=` | ||
`}return r}function Fe(t){let e={vertex:{},fragment:{}};for(let r of t){let o,n;typeof r!="string"?(o=r,n=o.hook):(o={},n=r),n=n.trim();let[i,s]=n.split(":"),a=n.replace(/\(.+/,""),u=Object.assign(o,{signature:s});switch(i){case"vs":e.vertex[a]=u;break;case"fs":e.fragment[a]=u;break;default:throw new Error(i)}}return e}var At=` | ||
${ue} | ||
${ce} | ||
`,Ar=E`\ | ||
`,Lr=S`\ | ||
precision highp float; | ||
`;function Tt(t,e){let{vs:r,fs:o}=e,n=dt(e.modules||[]);switch(t.shaderLanguage){case"glsl":return{vs:bt(t,{...e,source:r,stage:"vertex",modules:n}),fs:bt(t,{...e,source:o,stage:"fragment",modules:n}),getUniforms:_t(n)};case"wgsl":return{vs:xt(t,{...e,source:r,stage:"vertex",modules:n}),fs:xt(t,{...e,source:o,stage:"fragment",modules:n}),getUniforms:_t(n)}}}function xt(t,e){let{source:r,stage:o,modules:n,defines:i={},hookFunctions:s=[],inject:a={},log:u}=e;P(typeof r=="string","shader source must be a string");let l=r,c={};n.forEach(h=>{Object.assign(c,h.getDefines())}),Object.assign(c,i);let f="",v=Ne(s),x={},_={},I={};for(let h in a){let m=typeof a[h]=="string"?{injection:a[h],order:0}:a[h],T=/^(v|f)s:(#)?([\w-]+)$/.exec(h);if(T){let b=T[2],g=T[3];b?g==="decl"?_[h]=[m]:I[h]=[m]:x[h]=[m]}else I[h]=[m]}for(let h of n){u&&h.checkDeprecations(l,u);let m=h.getModuleSource(o,"wgsl");f+=m;let T=h.injections[o];for(let b in T){let g=/^(v|f)s:#([\w-]+)$/.exec(b);if(g){let w=g[2]==="decl"?_:I;w[b]=w[b]||[],w[b].push(T[b])}else x[b]=x[b]||[],x[b].push(T[b])}}return f+=Et,f=le(f,o,_),f+=Oe(v[o],x),f+=l,f=le(f,o,I),f}function bt(t,e){let r=e.source.includes("->"),{id:o,source:n,stage:i,language:s=r?"wgsl":"glsl",modules:a,defines:u={},hookFunctions:l=[],inject:c={},transpileToGLSL100:f=!1,prologue:v=!r,log:x}=e;P(typeof n=="string","shader source must be a string");let _=n.split(` | ||
`),I=100,h="",m=n;_[0].indexOf("#version ")===0?(I=300,h=_[0],m=_.slice(1).join(` | ||
`)):h=`#version ${I}`;let T=f?100:I,b={};a.forEach(y=>{Object.assign(b,y.getDefines())}),Object.assign(b,u);let g="";switch(s){case"wgsl":break;case"glsl":g=v?`${h} | ||
${wr({id:o,source:n,stage:i})} | ||
`;function wt(t,e){let{vs:r,fs:o}=e,n=pt(e.modules||[]);switch(t.shaderLanguage){case"glsl":return{vs:Et(t,{...e,source:r,stage:"vertex",modules:n}),fs:Et(t,{...e,source:o,stage:"fragment",modules:n}),getUniforms:Tt(n)};case"wgsl":return{vs:St(t,{...e,source:r,stage:"vertex",modules:n}),fs:St(t,{...e,source:o,stage:"fragment",modules:n}),getUniforms:Tt(n)}}}function St(t,e){let{source:r,stage:o,modules:n,defines:i={},hookFunctions:s=[],inject:a={},log:u}=e;P(typeof r=="string","shader source must be a string");let c=r,f={};n.forEach(m=>{Object.assign(f,m.getDefines())}),Object.assign(f,i);let l="",x=Fe(s),v={},_={},L={};for(let m in a){let h=typeof a[m]=="string"?{injection:a[m],order:0}:a[m],E=/^(v|f)s:(#)?([\w-]+)$/.exec(m);if(E){let b=E[2],g=E[3];b?g==="decl"?_[m]=[h]:L[m]=[h]:v[m]=[h]}else L[m]=[h]}for(let m of n){u&&m.checkDeprecations(c,u);let h=m.getModuleSource(o,"wgsl");l+=h;let E=m.injections[o];for(let b in E){let g=/^(v|f)s:#([\w-]+)$/.exec(b);if(g){let w=g[2]==="decl"?_:L;w[b]=w[b]||[],w[b].push(E[b])}else v[b]=v[b]||[],v[b].push(E[b])}}return l+=At,l=fe(l,o,_),l+=Ne(x[o],v),l+=c,l=fe(l,o,L),l}function Et(t,e){let r=e.source.includes("->"),{id:o,source:n,stage:i,language:s=r?"wgsl":"glsl",modules:a,defines:u={},hookFunctions:c=[],inject:f={},transpileToGLSL100:l=!1,prologue:x=!r,log:v}=e;P(typeof n=="string","shader source must be a string");let _=n.split(` | ||
`),L=100,m="",h=n;_[0].indexOf("#version ")===0?(L=300,m=_[0],h=_.slice(1).join(` | ||
`)):m=`#version ${L}`;let E=l?100:L,b={};a.forEach(y=>{Object.assign(b,y.getDefines())}),Object.assign(b,u);let g="";switch(s){case"wgsl":break;case"glsl":g=x?`${m} | ||
${Rr({id:o,source:n,stage:i})} | ||
${`#define SHADER_TYPE_${i.toUpperCase()}`} | ||
${mt(t)} | ||
${pt(t)} | ||
${Lr(b)} | ||
${i==="fragment"?Ar:""} | ||
`:`${h} | ||
`;break}let S=Ne(l),w={},ne={},N={};for(let y in c){let B=typeof c[y]=="string"?{injection:c[y],order:0}:c[y],L=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(L){let d=L[2],q=L[3];d?q==="decl"?ne[y]=[B]:N[y]=[B]:w[y]=[B]}else N[y]=[B]}for(let y of a){x&&y.checkDeprecations(m,x);let B=y.getModuleSource(i);g+=B;let L=y.injections[i];for(let d in L){let q=/^(v|f)s:#([\w-]+)$/.exec(d);if(q){let ie=q[2]==="decl"?ne:N;ie[d]=ie[d]||[],ie[d].push(L[d])}else w[d]=w[d]||[],w[d].push(L[d])}}return g+=Et,g=le(g,i,ne),g+=Oe(S[i],w),g+=m,g=le(g,i,N),g=gt(g,T,i),g.trim()}function _t(t){return function(r){let o={};for(let n of t){let i=n.getUniforms(r,o);Object.assign(o,i)}return o}}function wr(t){let{id:e,source:r,stage:o}=t;return e&&r.indexOf("SHADER_NAME")===-1?` | ||
${yt(t)} | ||
${xt(t)} | ||
${Pr(b)} | ||
${i==="fragment"?Lr:""} | ||
`:`${m} | ||
`;break}let T=Fe(c),w={},ie={},O={};for(let y in f){let B=typeof f[y]=="string"?{injection:f[y],order:0}:f[y],M=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(M){let d=M[2],Z=M[3];d?Z==="decl"?ie[y]=[B]:O[y]=[B]:w[y]=[B]}else O[y]=[B]}for(let y of a){v&&y.checkDeprecations(h,v);let B=y.getModuleSource(i);g+=B;let M=y.injections[i];for(let d in M){let Z=/^(v|f)s:#([\w-]+)$/.exec(d);if(Z){let se=Z[2]==="decl"?ie:O;se[d]=se[d]||[],se[d].push(M[d])}else w[d]=w[d]||[],w[d].push(M[d])}}return g+=At,g=fe(g,i,ie),g+=Ne(T[i],w),g+=h,g=fe(g,i,O),g=vt(g,E,i),g.trim()}function Tt(t){return function(r){let o={};for(let n of t){let i=n.getUniforms(r,o);Object.assign(o,i)}return o}}function Rr(t){let{id:e,source:r,stage:o}=t;return e&&r.indexOf("SHADER_NAME")===-1?` | ||
#define SHADER_NAME ${e}_${o} | ||
`:""}function Lr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=0,r="";for(let o in t){e===0&&(r+=` | ||
`:""}function Pr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=0,r="";for(let o in t){e===0&&(r+=` | ||
// APPLICATION DEFINES | ||
`),e++;let n=t[o];(n||Number.isFinite(n))&&(r+=`#define ${o.toUpperCase()} ${t[o]} | ||
`)}return e===0&&(r+=` | ||
`),r}function At(t,e){if(!e.vs)throw new Error("no vertex shader");let r=St(t,e.vs),o;return e.fs&&(o=St(t,e.fs)),{...e,vs:r,fs:o}}function St(t,e){if(typeof e=="string")return e;switch(t.type){case"webgpu":if(e!=null&&e.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e!=null&&e.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}var O=class{constructor(){this._hookFunctions=[],this._defaultModules=[]}static getDefaultShaderAssembler(){return O.defaultShaderAssembler=O.defaultShaderAssembler||new O,O.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(o=>o.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleShaders(e,r){let o=this._getModuleList(r.modules),n=this._hookFunctions,i=At(e,r);return Tt(e,{...i,modules:o,hookFunctions:n})}_getModuleList(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=new Array(this._defaultModules.length+e.length),o={},n=0;for(let i=0,s=this._defaultModules.length;i<s;++i){let a=this._defaultModules[i],u=a.name;r[n++]=a,o[u]=!0}for(let i=0,s=e.length;i<s;++i){let a=e[i],u=a.name;o[u]||(r[n++]=a,o[u]=!0)}return r.length=n,r}};O.defaultShaderAssembler=void 0;var xe=class{constructor(e){this.id=void 0,this.userData={},this.topology=void 0,this.bufferLayout=[],this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.id=e.id||j("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&Y(this.indices.usage===p.INDEX)}destroy(){var e;this.indices.destroy(),this.attributes.positions.destroy(),this.attributes.normals.destroy(),this.attributes.texCoords.destroy(),(e=this.attributes.colors)===null||e===void 0||e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function wt(t,e){if(e instanceof xe)return e;let r=Mr(t,e),{attributes:o,bufferLayout:n}=Cr(t,e);return new xe({topology:e.topology||"triangle-list",bufferLayout:n,vertexCount:e.vertexCount,indices:r,attributes:o})}function Mr(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:p.INDEX,data:r})}function Cr(t,e){let r=[],o={};for(let[i,s]of Object.entries(e.attributes)){let a=i;switch(i){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break}o[a]=t.createBuffer({data:s.value,id:`${i}-buffer`}),r.push({name:a,format:`float32x${s.size}`})}let n=e._calculateVertexCount(e.attributes,e.indices);return{attributes:o,bufferLayout:r,vertexCount:n}}var z=class{static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new z(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=void 0,this._hashCounter=0,this._hashes={},this._useCounts={},this._pipelineCache={},this.device=e}createRenderPipeline(e){let r={...z.defaultProps,...e},o=this._hashRenderPipeline({...r});if(!this._pipelineCache[o]){let n=this.device.createRenderPipeline({...r,vs:this.device.createShader({stage:"vertex",source:r.vs}),fs:r.fs?this.device.createShader({stage:"fragment",source:r.fs}):null});n.hash=o,this._pipelineCache[o]=n,this._useCounts[o]=0}return this._useCounts[o]++,this._pipelineCache[o]}release(e){let r=e.hash;this._useCounts[r]--,this._useCounts[r]===0&&(this._pipelineCache[r].destroy(),delete this._pipelineCache[r],delete this._useCounts[r])}_createRenderPipeline(e){if(!e.fs)throw new Error("fs");return this.device.createRenderPipeline({...e,vs:this.device.createShader({stage:"vertex",source:e.vs}),fs:e.fs?this.device.createShader({stage:"fragment",source:e.fs}):null})}_hashRenderPipeline(e){let r=this._getHash(e.vs),o=e.fs?this._getHash(e.fs):0,n="-";switch(this.device.info.type){case"webgpu":let i=this._getHash(JSON.stringify(e.parameters)),s=this._getHash(JSON.stringify(e.bufferLayout));return`${r}/${o}V${n}T${e.topology}P${i}BL${s}}`;default:return`${r}/${o}V${n}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};z.defaultProps={...U.defaultProps,vs:void 0,fs:void 0};var W=class{constructor(e,r){this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.pipeline=void 0,this.vertexArray=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this.props={...W.defaultProps,...r},r=this.props,this.id=r.id||j("model"),this.device=e,Object.assign(this.userData,r.userData);let o={type:e.info.type,shaderLanguage:e.info.shadingLanguages[0],gpu:e.info.gpu,features:e.features},{vs:n,fs:i,getUniforms:s}=this.props.shaderAssembler.assembleShaders(o,this.props);if(this.vs=n,this.fs=i,this._getModuleUniforms=s,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&(this._gpuGeometry=this.setGeometry(r.geometry)),this.pipelineFactory=r.pipelineFactory||z.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),r.vertexCount&&this.setVertexCount(r.vertexCount),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),this.setUniforms(this._getModuleUniforms()),Object.seal(this)}destroy(){this.pipelineFactory.release(this.pipeline)}draw(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount})}setGeometry(e){let r=e&&wt(this.device,e);return this.setTopology(r.topology||"triangle-list"),this.bufferLayout=Lt(this.bufferLayout,r.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r),r}_setGeometryAttributes(e){this.vertexCount=e.vertexCount,this.setAttributes(e.attributes),this.setIndexBuffer(e.indices)}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?Lt(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){ae(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setVertexCount(e){this.vertexCount=e}setInstanceCount(e){this.instanceCount=e}setShaderModuleProps(e){let r=this._getModuleUniforms(e),o=Object.keys(r).filter(i=>{let s=r[i];return!Ae(s)&&typeof s!="number"&&typeof s!="boolean"}),n={};for(let i of o)n[i]=r[i],delete r[i];Object.assign(this.uniforms,r),Object.assign(this.bindings,n)}updateModuleSettings(e){this.setShaderModuleProps(e)}setBindings(e){Object.assign(this.bindings,e)}setUniforms(e){this.pipeline.setUniforms(e),Object.assign(this.uniforms,e)}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e)}setAttributes(e){e.indices&&F.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);for(let[o,n]of Object.entries(e)){var r;let i=this.bufferLayout.find(u=>u.name===o);if(!i)continue;let s=i.attributes?(r=i.attributes)===null||r===void 0?void 0:r.map(u=>u.attribute):[i.name],a=!1;for(let u of s){let l=this._attributeInfos[u];l&&(this.vertexArray.setBuffer(l.location,n),a=!0)}a||F.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${o}"`)()}}setConstantAttributes(e){for(let[r,o]of Object.entries(e)){let n=this._attributeInfos[r];n?this.vertexArray.setConstant(n.location,o):F.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){return this._pipelineNeedsUpdate&&(this.pipeline&&F.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),this._pipelineNeedsUpdate=!1,this.pipeline=this.device.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:this.device.createShader({id:"{$this.id}-vertex",stage:"vertex",source:this.vs}),fs:this.fs?this.device.createShader({id:"{$this.id}-fragment",stage:"fragment",source:this.fs}):null}),this._attributeInfos=Me(this.pipeline.shaderLayout,this.bufferLayout)),this.pipeline}};W.defaultProps={...U.defaultProps,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:{},geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},pipelineFactory:void 0,shaderAssembler:O.getDefaultShaderAssembler()};function Lt(t,e){let r=[...t];for(let o of e){let n=r.findIndex(i=>i.name===o.name);n<0?r.push(o):r[n]=o}return r}var J=class{constructor(e){this.id=void 0,this.topology=void 0,this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.userData={};let{attributes:r={},indices:o=null,vertexCount:n=null}=e;this.id=e.id||j("geometry"),this.topology=e.topology,o&&(this.indices=ArrayBuffer.isView(o)?{value:o,size:1}:o),this.attributes={};for(let[i,s]of Object.entries(r)){let a=ArrayBuffer.isView(s)?{value:s}:s;Y(ArrayBuffer.isView(a.value),`${this._print(i)}: must be typed array or object with value as typed array`),(i==="POSITION"||i==="positions")&&!a.size&&(a.size=3),i==="indices"?(Y(!this.indices),this.indices=a):this.attributes[i]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let o=1/0;for(let n of Object.values(e)){let{value:i,size:s,constant:a}=n;!a&&i&&s>=1&&(o=Math.min(o,i.length/s))}return Y(Number.isFinite(o)),o}};var oe=he(se());function Ir(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Rr(t))||e&&t&&typeof t.length=="number"){r&&(t=r);var o=0,n=function(){};return{s:n,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(l){throw l},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. | ||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,s=!1,a;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return i=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!i&&r.return!=null&&r.return()}finally{if(s)throw a}}}}function Rr(t,e){if(t){if(typeof t=="string")return Mt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Mt(t,e)}}function Mt(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}var De=Math.PI/180,be=new Float32Array(16),Ct=new Float32Array(12);function It(t,e,r){var o=e[0]*De,n=e[1]*De,i=e[2]*De,s=Math.sin(i),a=Math.sin(o),u=Math.sin(n),l=Math.cos(i),c=Math.cos(o),f=Math.cos(n),v=r[0],x=r[1],_=r[2];t[0]=v*f*c,t[1]=v*u*c,t[2]=v*-a,t[3]=x*(-u*l+f*a*s),t[4]=x*(f*l+u*a*s),t[5]=x*c*s,t[6]=_*(u*s+f*a*l),t[7]=_*(-f*s+u*a*l),t[8]=_*c*l}function Rt(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var Pt={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update:function(e,r){var o=r.startRow,n=r.endRow,i=this.props,s=i.data,a=i.getOrientation,u=i.getScale,l=i.getTranslation,c=i.getTransformMatrix,f=Array.isArray(c),v=f&&c.length===16,x=Array.isArray(u),_=Array.isArray(a),I=Array.isArray(l),h=v||!f&&Boolean(c(s[0]));h?e.constant=v:e.constant=_&&x&&I;var m=e.value;if(e.constant){var T;if(h)be.set(c),T=Rt(be);else{T=Ct;var b=a,g=u;It(T,b,g),T.set(l,9)}e.value=new Float32Array(T)}else{var S=o*e.size,w=(0,oe.createIterable)(s,o,n),ne=w.iterable,N=w.objectInfo,y=Ir(ne),B;try{for(y.s();!(B=y.n()).done;){var L=B.value;N.index++;var d=void 0;if(h)be.set(v?c:c(L,N)),d=Rt(be);else{d=Ct;var q=_?a:a(L,N),Be=x?u:u(L,N);It(d,q,Be),d.set(I?l:l(L,N),9)}m[S++]=d[0],m[S++]=d[1],m[S++]=d[2],m[S++]=d[3],m[S++]=d[4],m[S++]=d[5],m[S++]=d[6],m[S++]=d[7],m[S++]=d[8],m[S++]=d[9],m[S++]=d[10],m[S++]=d[11]}}catch(ie){y.e(ie)}finally{y.f()}}}};function Ot(t,e){return e===oe.COORDINATE_SYSTEM.CARTESIAN||e===oe.COORDINATE_SYSTEM.METER_OFFSETS||e===oe.COORDINATE_SYSTEM.DEFAULT&&!t.isGeospatial}var Nt=`#version 300 es | ||
`),r}function Ct(t,e){if(!e.vs)throw new Error("no vertex shader");let r=Mt(t,e.vs),o;return e.fs&&(o=Mt(t,e.fs)),{...e,vs:r,fs:o}}function Mt(t,e){if(typeof e=="string")return e;switch(t.type){case"webgpu":if(e!=null&&e.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e!=null&&e.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}var I=class{constructor(){this._hookFunctions=[],this._defaultModules=[]}static getDefaultShaderAssembler(){return I.defaultShaderAssembler=I.defaultShaderAssembler||new I,I.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(o=>o.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleShaders(e,r){let o=this._getModuleList(r.modules),n=this._hookFunctions,i=Ct(e,r);return wt(e,{...i,modules:o,hookFunctions:n})}_getModuleList(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=new Array(this._defaultModules.length+e.length),o={},n=0;for(let i=0,s=this._defaultModules.length;i<s;++i){let a=this._defaultModules[i],u=a.name;r[n++]=a,o[u]=!0}for(let i=0,s=e.length;i<s;++i){let a=e[i],u=a.name;o[u]||(r[n++]=a,o[u]=!0)}return r.length=n,r}};I.defaultShaderAssembler=void 0;var be=class{constructor(e){this.id=void 0,this.userData={},this.topology=void 0,this.bufferLayout=[],this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.id=e.id||G("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&Y(this.indices.usage===p.INDEX)}destroy(){var e;this.indices.destroy(),this.attributes.positions.destroy(),this.attributes.normals.destroy(),this.attributes.texCoords.destroy(),(e=this.attributes.colors)===null||e===void 0||e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function Lt(t,e){if(e instanceof be)return e;let r=Ir(t,e),{attributes:o,bufferLayout:n}=Or(t,e);return new be({topology:e.topology||"triangle-list",bufferLayout:n,vertexCount:e.vertexCount,indices:r,attributes:o})}function Ir(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:p.INDEX,data:r})}function Or(t,e){let r=[],o={};for(let[i,s]of Object.entries(e.attributes)){let a=i;switch(i){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break}o[a]=t.createBuffer({data:s.value,id:`${i}-buffer`}),r.push({name:a,format:`float32x${s.size}`})}let n=e._calculateVertexCount(e.attributes,e.indices);return{attributes:o,bufferLayout:r,vertexCount:n}}var z=class{static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new z(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=void 0,this._hashCounter=0,this._hashes={},this._useCounts={},this._pipelineCache={},this.device=e}createRenderPipeline(e){let r={...z.defaultProps,...e},o=this._hashRenderPipeline({...r});if(!this._pipelineCache[o]){let n=this.device.createRenderPipeline({...r,vs:this.device.createShader({stage:"vertex",source:r.vs}),fs:r.fs?this.device.createShader({stage:"fragment",source:r.fs}):null});n.hash=o,this._pipelineCache[o]=n,this._useCounts[o]=0}return this._useCounts[o]++,this._pipelineCache[o]}release(e){let r=e.hash;this._useCounts[r]--,this._useCounts[r]===0&&(this._pipelineCache[r].destroy(),delete this._pipelineCache[r],delete this._useCounts[r])}_createRenderPipeline(e){if(!e.fs)throw new Error("fs");return this.device.createRenderPipeline({...e,vs:this.device.createShader({stage:"vertex",source:e.vs}),fs:e.fs?this.device.createShader({stage:"fragment",source:e.fs}):null})}_hashRenderPipeline(e){let r=this._getHash(e.vs),o=e.fs?this._getHash(e.fs):0,n="-";switch(this.device.info.type){case"webgpu":let i=this._getHash(JSON.stringify(e.parameters)),s=this._getHash(JSON.stringify(e.bufferLayout));return`${r}/${o}V${n}T${e.topology}P${i}BL${s}}`;default:return`${r}/${o}V${n}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};z.defaultProps={...F.defaultProps,vs:void 0,fs:void 0};var W=class{constructor(e,r){this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.pipeline=void 0,this.vertexArray=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this.props={...W.defaultProps,...r},r=this.props,this.id=r.id||G("model"),this.device=e,Object.assign(this.userData,r.userData);let o={type:e.info.type,shaderLanguage:e.info.shadingLanguages[0],gpu:e.info.gpu,features:e.features},{vs:n,fs:i,getUniforms:s}=this.props.shaderAssembler.assembleShaders(o,this.props);if(this.vs=n,this.fs=i,this._getModuleUniforms=s,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&(this._gpuGeometry=this.setGeometry(r.geometry)),this.pipelineFactory=r.pipelineFactory||z.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),r.vertexCount&&this.setVertexCount(r.vertexCount),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),this.setUniforms(this._getModuleUniforms()),Object.seal(this)}destroy(){this.pipelineFactory.release(this.pipeline)}draw(e){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount})}setGeometry(e){let r=e&&Lt(this.device,e);return this.setTopology(r.topology||"triangle-list"),this.bufferLayout=Rt(this.bufferLayout,r.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r),r}_setGeometryAttributes(e){this.vertexCount=e.vertexCount,this.setAttributes(e.attributes),this.setIndexBuffer(e.indices)}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?Rt(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){ue(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setVertexCount(e){this.vertexCount=e}setInstanceCount(e){this.instanceCount=e}setShaderModuleProps(e){let r=this._getModuleUniforms(e),o=Object.keys(r).filter(i=>{let s=r[i];return!Me(s)&&typeof s!="number"&&typeof s!="boolean"}),n={};for(let i of o)n[i]=r[i],delete r[i];Object.assign(this.uniforms,r),Object.assign(this.bindings,n)}updateModuleSettings(e){this.setShaderModuleProps(e)}setBindings(e){Object.assign(this.bindings,e)}setUniforms(e){this.pipeline.setUniforms(e),Object.assign(this.uniforms,e)}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e)}setAttributes(e){e.indices&&N.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`);for(let[o,n]of Object.entries(e)){var r;let i=this.bufferLayout.find(u=>u.name===o);if(!i)continue;let s=i.attributes?(r=i.attributes)===null||r===void 0?void 0:r.map(u=>u.attribute):[i.name],a=!1;for(let u of s){let c=this._attributeInfos[u];c&&(this.vertexArray.setBuffer(c.location,n),a=!0)}a||N.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${o}"`)()}}setConstantAttributes(e){for(let[r,o]of Object.entries(e)){let n=this._attributeInfos[r];n?this.vertexArray.setConstant(n.location,o):N.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||e}_updatePipeline(){return this._pipelineNeedsUpdate&&(this.pipeline&&N.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),this._pipelineNeedsUpdate=!1,this.pipeline=this.device.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:this.device.createShader({id:"{$this.id}-vertex",stage:"vertex",source:this.vs}),fs:this.fs?this.device.createShader({id:"{$this.id}-fragment",stage:"fragment",source:this.fs}):null}),this._attributeInfos=Re(this.pipeline.shaderLayout,this.bufferLayout)),this.pipeline}};W.defaultProps={...F.defaultProps,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:{},geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},pipelineFactory:void 0,shaderAssembler:I.getDefaultShaderAssembler()};function Rt(t,e){let r=[...t];for(let o of e){let n=r.findIndex(i=>i.name===o.name);n<0?r.push(o):r[n]=o}return r}var J=class{constructor(e){this.id=void 0,this.topology=void 0,this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.userData={};let{attributes:r={},indices:o=null,vertexCount:n=null}=e;this.id=e.id||G("geometry"),this.topology=e.topology,o&&(this.indices=ArrayBuffer.isView(o)?{value:o,size:1}:o),this.attributes={};for(let[i,s]of Object.entries(r)){let a=ArrayBuffer.isView(s)?{value:s}:s;Y(ArrayBuffer.isView(a.value),`${this._print(i)}: must be typed array or object with value as typed array`),(i==="POSITION"||i==="positions")&&!a.size&&(a.size=3),i==="indices"?(Y(!this.indices),this.indices=a):this.attributes[i]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let o=1/0;for(let n of Object.values(e)){let{value:i,size:s,constant:a}=n;!a&&i&&s>=1&&(o=Math.min(o,i.length/s))}return Y(Number.isFinite(o)),o}};var ne=he(ae());function Dr(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Nr(t))||e&&t&&typeof t.length=="number"){r&&(t=r);var o=0,n=function(){};return{s:n,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(c){throw c},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. | ||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,s=!1,a;return{s:function(){r=r.call(t)},n:function(){var c=r.next();return i=c.done,c},e:function(c){s=!0,a=c},f:function(){try{!i&&r.return!=null&&r.return()}finally{if(s)throw a}}}}function Nr(t,e){if(t){if(typeof t=="string")return Pt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Pt(t,e)}}function Pt(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}var Ue=Math.PI/180,_e=new Float32Array(16),It=new Float32Array(12);function Ot(t,e,r){var o=e[0]*Ue,n=e[1]*Ue,i=e[2]*Ue,s=Math.sin(i),a=Math.sin(o),u=Math.sin(n),c=Math.cos(i),f=Math.cos(o),l=Math.cos(n),x=r[0],v=r[1],_=r[2];t[0]=x*l*f,t[1]=x*u*f,t[2]=x*-a,t[3]=v*(-u*c+l*a*s),t[4]=v*(l*c+u*a*s),t[5]=v*f*s,t[6]=_*(u*s+l*a*c),t[7]=_*(-l*s+u*a*c),t[8]=_*f*c}function Dt(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var Nt={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update:function(e,r){var o=r.startRow,n=r.endRow,i=this.props,s=i.data,a=i.getOrientation,u=i.getScale,c=i.getTranslation,f=i.getTransformMatrix,l=Array.isArray(f),x=l&&f.length===16,v=Array.isArray(u),_=Array.isArray(a),L=Array.isArray(c),m=x||!l&&Boolean(f(s[0]));m?e.constant=x:e.constant=_&&v&&L;var h=e.value;if(e.constant){var E;if(m)_e.set(f),E=Dt(_e);else{E=It;var b=a,g=u;Ot(E,b,g),E.set(c,9)}e.value=new Float32Array(E)}else{var T=o*e.size,w=(0,ne.createIterable)(s,o,n),ie=w.iterable,O=w.objectInfo,y=Dr(ie),B;try{for(y.s();!(B=y.n()).done;){var M=B.value;O.index++;var d=void 0;if(m)_e.set(x?f:f(M,O)),d=Dt(_e);else{d=It;var Z=_?a:a(M,O),je=v?u:u(M,O);Ot(d,Z,je),d.set(L?c:c(M,O),9)}h[T++]=d[0],h[T++]=d[1],h[T++]=d[2],h[T++]=d[3],h[T++]=d[4],h[T++]=d[5],h[T++]=d[6],h[T++]=d[7],h[T++]=d[8],h[T++]=d[9],h[T++]=d[10],h[T++]=d[11]}}catch(se){y.e(se)}finally{y.f()}}}};function Ft(t,e){return e===ne.COORDINATE_SYSTEM.CARTESIAN||e===ne.COORDINATE_SYSTEM.METER_OFFSETS||e===ne.COORDINATE_SYSTEM.DEFAULT&&!t.isGeospatial}var Ut=`#version 300 es | ||
#define SHADER_NAME simple-mesh-layer-vs | ||
@@ -199,3 +199,3 @@ uniform float sizeScale; | ||
} | ||
`;var Dt=`#version 300 es | ||
`;var Bt=`#version 300 es | ||
#define SHADER_NAME simple-mesh-layer-fs | ||
@@ -238,4 +238,4 @@ | ||
} | ||
`;function Fe(t){let e=1/0,r=1/0,o=1/0,n=-1/0,i=-1/0,s=-1/0,a=t.POSITION?t.POSITION.value:[],u=a&&a.length;for(let l=0;l<u;l+=3){let c=a[l],f=a[l+1],v=a[l+2];e=c<e?c:e,r=f<r?f:r,o=v<o?v:o,n=c>n?c:n,i=f>i?f:i,s=v>s?v:s}return[[e,r,o],[n,i,s]]}function _e(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_e=function(r){return typeof r}:_e=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_e(t)}function Pr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Z(t,e,r){return typeof Reflect<"u"&&Reflect.get?Z=Reflect.get:Z=function(n,i,s){var a=Or(n,i);if(a){var u=Object.getOwnPropertyDescriptor(a,i);return u.get?u.get.call(s):u.value}},Z(t,e,r||t)}function Or(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&(t=$(t),t!==null););return t}function Nr(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ge(t,e)}function Ge(t,e){return Ge=Object.setPrototypeOf||function(o,n){return o.__proto__=n,o},Ge(t,e)}function Dr(t){var e=Gr();return function(){var o=$(t),n;if(e){var i=$(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return Fr(this,n)}}function Fr(t,e){if(e&&(_e(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ur(t)}function Ur(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Gr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $(t){return $=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},$(t)}function Ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,o)}return r}function Ee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ft(Object(r),!0).forEach(function(o){Br(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ft(Object(r)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}function Br(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ue(t){var e=t.positions||t.POSITION;G.log.assert(e,'no "postions" or "POSITION" attribute in mesh');var r=e.value.length/e.size,o=t.COLOR_0||t.colors;o||(o={size:3,value:new Float32Array(r*3).fill(1)});var n=t.NORMAL||t.normals;n||(n={size:3,value:new Float32Array(r*3).fill(0)});var i=t.TEXCOORD_0||t.texCoords;return i||(i={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:o,normals:n,texCoords:i}}function Ut(t){return t instanceof J?(t.attributes=Ue(t.attributes),t):t.attributes?new J(Ee(Ee({},t),{},{topology:"triangle-list",attributes:Ue(t.attributes)})):new J({topology:"triangle-list",attributes:Ue(t)})}var jr=[0,0,0,255],kr={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:function(e){return e.position}},getColor:{type:"accessor",value:jr},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0}},Te=function(t){Nr(r,t);var e=Dr(r);function r(){var n;Pr(this,r);for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return n=e.call.apply(e,[this].concat(s)),n.state=void 0,n}var o=r.prototype;return o.getShaders=function(){var i=this.context.device.info.type!=="webgl2",s={};return this.context.device.features.has("glsl-derivatives")&&(s.DERIVATIVES_AVAILABLE=1),Z($(r.prototype),"getShaders",this).call(this,{vs:Nt,fs:Dt,modules:[G.project32,G.phongLighting,G.picking],transpileToGLSL100:i,defines:s})},o.getBounds=function(){var i;if(this.props._instanced)return Z($(r.prototype),"getBounds",this).call(this);var s=this.state.positionBounds;if(s)return s;var a=this.props.mesh;if(!a)return null;if(s=(i=a.header)===null||i===void 0?void 0:i.boundingBox,!s){var u=Ut(a),l=u.attributes;l.POSITION=l.POSITION||l.positions,s=Fe(l)}return this.state.positionBounds=s,s},o.initializeState=function(){var i=this.getAttributeManager();i.addInstanced({instancePositions:{transition:!0,type:5130,fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:5121,transition:!0,size:this.props.colorFormat.length,normalized:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:Pt}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})},o.updateState=function(i){Z($(r.prototype),"updateState",this).call(this,i);var s=i.props,a=i.oldProps,u=i.changeFlags;if(s.mesh!==a.mesh||u.extensionsChanged){var l;if(this.state.positionBounds=null,(l=this.state.model)===null||l===void 0||l.destroy(),s.mesh){this.state.model=this.getModel(s.mesh);var c=s.mesh.attributes||s.mesh;this.setState({hasNormals:Boolean(c.NORMAL||c.normals)})}this.getAttributeManager().invalidateAll()}s.texture!==a.texture&&s.texture instanceof A&&this.setTexture(s.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")},o.finalizeState=function(i){Z($(r.prototype),"finalizeState",this).call(this,i),this.state.emptyTexture.delete()},o.draw=function(i){var s=i.uniforms,a=this.state.model;if(a){var u=this.context,l=u.viewport,c=u.renderPass,f=this.props,v=f.sizeScale,x=f.coordinateSystem,_=f._instanced;a.setUniforms(s),a.setUniforms({sizeScale:v,composeModelMatrix:!_||Ot(l,x),flatShading:!this.state.hasNormals}),a.draw(c)}},o.getModel=function(i){var s=new W(this.context.device,Ee(Ee({},this.getShaders()),{},{id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:Ut(i),isInstanced:!0})),a=this.props.texture,u=this.state.emptyTexture;return s.setBindings({sampler:a||u}),s.setUniforms({hasTexture:Boolean(a)}),s},o.setTexture=function(i){var s=this.state,a=s.emptyTexture,u=s.model;u&&(u.setBindings({sampler:i||a}),u.setUniforms({hasTexture:Boolean(i)}))},r}(G.Layer);Te.defaultProps=kr;Te.layerName="SimpleMeshLayer";return zt(ce);})(); | ||
`;function Be(t){let e=1/0,r=1/0,o=1/0,n=-1/0,i=-1/0,s=-1/0,a=t.POSITION?t.POSITION.value:[],u=a&&a.length;for(let c=0;c<u;c+=3){let f=a[c],l=a[c+1],x=a[c+2];e=f<e?f:e,r=l<r?l:r,o=x<o?x:o,n=f>n?f:n,i=l>i?l:i,s=x>s?x:s}return[[e,r,o],[n,i,s]]}function Se(t){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Se=function(r){return typeof r}:Se=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Se(t)}function Fr(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function q(t,e,r){return typeof Reflect<"u"&&Reflect.get?q=Reflect.get:q=function(n,i,s){var a=Ur(n,i);if(a){var u=Object.getOwnPropertyDescriptor(a,i);return u.get?u.get.call(s):u.value}},q(t,e,r||t)}function Ur(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&(t=$(t),t!==null););return t}function Br(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ke(t,e)}function ke(t,e){return ke=Object.setPrototypeOf||function(o,n){return o.__proto__=n,o},ke(t,e)}function Gr(t){var e=$r();return function(){var o=$(t),n;if(e){var i=$(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return kr(this,n)}}function kr(t,e){if(e&&(Se(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jr(t)}function jr(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function $r(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function $(t){return $=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)},$(t)}function Gt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,o)}return r}function Ee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Gt(Object(r),!0).forEach(function(o){Vr(t,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Gt(Object(r)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(r,o))})}return t}function Vr(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ge(t){var e=t.positions||t.POSITION;U.log.assert(e,'no "postions" or "POSITION" attribute in mesh');var r=e.value.length/e.size,o=t.COLOR_0||t.colors;o||(o={size:3,value:new Float32Array(r*3).fill(1)});var n=t.NORMAL||t.normals;n||(n={size:3,value:new Float32Array(r*3).fill(0)});var i=t.TEXCOORD_0||t.texCoords;return i||(i={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:o,normals:n,texCoords:i}}function kt(t){return t instanceof J?(t.attributes=Ge(t.attributes),t):t.attributes?new J(Ee(Ee({},t),{},{topology:"triangle-list",attributes:Ge(t.attributes)})):new J({topology:"triangle-list",attributes:Ge(t)})}var Hr=[0,0,0,255],zr={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:function(e){return e.position}},getColor:{type:"accessor",value:Hr},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0}},Te=function(t){Br(r,t);var e=Gr(r);function r(){var n;Fr(this,r);for(var i=arguments.length,s=new Array(i),a=0;a<i;a++)s[a]=arguments[a];return n=e.call.apply(e,[this].concat(s)),n.state=void 0,n}var o=r.prototype;return o.getShaders=function(){var i=this.context.device.info.type!=="webgl2",s={};return this.context.device.features.has("glsl-derivatives")&&(s.DERIVATIVES_AVAILABLE=1),q($(r.prototype),"getShaders",this).call(this,{vs:Ut,fs:Bt,modules:[U.project32,U.phongLighting,U.picking],transpileToGLSL100:i,defines:s})},o.getBounds=function(){var i;if(this.props._instanced)return q($(r.prototype),"getBounds",this).call(this);var s=this.state.positionBounds;if(s)return s;var a=this.props.mesh;if(!a)return null;if(s=(i=a.header)===null||i===void 0?void 0:i.boundingBox,!s){var u=kt(a),c=u.attributes;c.POSITION=c.POSITION||c.positions,s=Be(c)}return this.state.positionBounds=s,s},o.initializeState=function(){var i=this.getAttributeManager();i.addInstanced({instancePositions:{transition:!0,type:5130,fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:5121,transition:!0,size:this.props.colorFormat.length,normalized:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:Nt}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})},o.updateState=function(i){q($(r.prototype),"updateState",this).call(this,i);var s=i.props,a=i.oldProps,u=i.changeFlags;if(s.mesh!==a.mesh||u.extensionsChanged){var c;if(this.state.positionBounds=null,(c=this.state.model)===null||c===void 0||c.destroy(),s.mesh){this.state.model=this.getModel(s.mesh);var f=s.mesh.attributes||s.mesh;this.setState({hasNormals:Boolean(f.NORMAL||f.normals)})}this.getAttributeManager().invalidateAll()}s.texture!==a.texture&&s.texture instanceof A&&this.setTexture(s.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")},o.finalizeState=function(i){q($(r.prototype),"finalizeState",this).call(this,i),this.state.emptyTexture.delete()},o.draw=function(i){var s=i.uniforms,a=this.state.model;if(a){var u=this.context,c=u.viewport,f=u.renderPass,l=this.props,x=l.sizeScale,v=l.coordinateSystem,_=l._instanced;a.setUniforms(s),a.setUniforms({sizeScale:x,composeModelMatrix:!_||Ft(c,v),flatShading:!this.state.hasNormals}),a.draw(f)}},o.getModel=function(i){var s=new W(this.context.device,Ee(Ee({},this.getShaders()),{},{id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:kt(i),isInstanced:!0})),a=this.props.texture,u=this.state.emptyTexture;return s.setBindings({sampler:a||u}),s.setUniforms({hasTexture:Boolean(a)}),s},o.setTexture=function(i){var s=this.state,a=s.emptyTexture,u=s.model;u&&(u.setBindings({sampler:i||a}),u.setUniforms({hasTexture:Boolean(i)}))},r}(U.Layer);Te.defaultProps=zr;Te.layerName="SimpleMeshLayer";return Kt(le);})(); | ||
return __exports__; | ||
}); |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "9.0.0-alpha.3", | ||
"version": "9.0.0-alpha.4", | ||
"publishConfig": { | ||
@@ -42,3 +42,3 @@ "access": "public" | ||
}, | ||
"gitHead": "51dfb88f9168ccf478d01b28a2c5ada7bd8281c7" | ||
"gitHead": "13ace64fc2cee08c133afc882fc307253489a4e4" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
380194
5711
0
63