@maptalks/gpu 0.116.0 → 0.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @maptalks/gpu v0.116.0
2
+ * @maptalks/gpu v0.117.0
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2025 maptalks.com
5
5
  */
@@ -82,10 +82,10 @@
82
82
 
83
83
  function gltfLoaderExport(e){var t=function(){return "undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0};if(t().maptalks_gltf_loader)return;
84
84
  /*!
85
- * @maptalks/gltf-loader v0.116.0
85
+ * @maptalks/gltf-loader v0.117.0
86
86
  * LICENSE : UNLICENSED
87
87
  * (c) 2016-2025 maptalks.org
88
- */var s="undefined"!=typeof Float32Array?Float32Array:Array;function r(e,t,s){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],f=t[5],u=t[6],h=t[7],c=t[8],l=t[9],d=t[10],m=t[11],g=t[12],p=t[13],b=t[14],_=t[15],y=s[0],x=s[1],w=s[2],T=s[3];return e[0]=y*r+x*o+w*c+T*g,e[1]=y*n+x*f+w*l+T*p,e[2]=y*i+x*u+w*d+T*b,e[3]=y*a+x*h+w*m+T*_,y=s[4],x=s[5],w=s[6],T=s[7],e[4]=y*r+x*o+w*c+T*g,e[5]=y*n+x*f+w*l+T*p,e[6]=y*i+x*u+w*d+T*b,e[7]=y*a+x*h+w*m+T*_,y=s[8],x=s[9],w=s[10],T=s[11],e[8]=y*r+x*o+w*c+T*g,e[9]=y*n+x*f+w*l+T*p,e[10]=y*i+x*u+w*d+T*b,e[11]=y*a+x*h+w*m+T*_,y=s[12],x=s[13],w=s[14],T=s[15],e[12]=y*r+x*o+w*c+T*g,e[13]=y*n+x*f+w*l+T*p,e[14]=y*i+x*u+w*d+T*b,e[15]=y*a+x*h+w*m+T*_,e}function n(){var e=new s(3);return s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function i(e,t,r){var n=new s(3);return n[0]=e,n[1]=t,n[2]=r,n}function a(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function o(e,t,s,r){return e[0]=t,e[1]=s,e[2]=r,e}function f(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e}function u(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function h(e,t,s,r,n){return e[0]=t,e[1]=s,e[2]=r,e[3]=n,e}function c(e,t,s){var r=t[0],n=t[1],i=t[2],a=t[3];return e[0]=s[0]*r+s[4]*n+s[8]*i+s[12]*a,e[1]=s[1]*r+s[5]*n+s[9]*i+s[13]*a,e[2]=s[2]*r+s[6]*n+s[10]*i+s[14]*a,e[3]=s[3]*r+s[7]*n+s[11]*i+s[15]*a,e}function l(){var e=new s(4);return s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),n(),function(){var e;e=new s(4),s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0);}();var d,m=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e};n(),i(1,0,0),i(0,1,0),l(),l(),d=new s(9),s!=Float32Array&&(d[1]=0,d[2]=0,d[3]=0,d[5]=0,d[6]=0,d[7]=0),d[0]=1,d[4]=1,d[8]=1;let g=0;function p(e){return null==e}function b(e){return !p(e)}function _(e){return !p(e)&&("string"==typeof e||null!==e.constructor&&e.constructor===String)}function y(e){for(let t=1;t<arguments.length;t++){const s=arguments[t];for(const t in s)e[t]=s[t];}return e}function x(e){switch(e){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+e)}function w(e){return 0===e.indexOf("data:")&&e.indexOf("base64,")>0}function T(e){const t=function(e){return "undefined"!=typeof self?self.atob(e):window.atob(e)}(e.substring(e.indexOf(",")+1)),s=t.length,r=new Uint8Array(s);for(let e=0;e<s;e++)r[e]=t.charCodeAt(e);return r.buffer}const E=[],O=[],I=[],R=[0,0,0],A=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}([]),q=[1,1,1];function B(e,t,s,r,n,i,a){const o=x(a),f=o.BYTES_PER_ELEMENT;if((0===n||n===r*f)&&i%f==0){const n=new o(t,i,s*r);return e.set(n),e}0===n&&(n=r*f);const u=new Uint8Array(r*f);for(let a=0;a<s;a++){let s=null;const h=new Uint8Array(t,n*a+i,r*f);u.set(h),s=new o(u.buffer,0,r);for(let t=0;t<r;t++)e[a*r+t]=s[t];}return e}const N="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function v(e,t,s){const r=new Uint8Array(e,t,s);return N.decode(r)}const P={get:function(e,t={},s){t||(t={});const r=new AbortController,n=r.signal,i=y({},t);i.signal=n,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),s&&(e=s(e));const a=fetch(e,i).then((e=>{const s=this._parseResponse(e,t.responseType);return s.message?s:s.then((s=>"arraybuffer"===t.responseType?{data:s,cacheControl:e.headers.get("Cache-Control"),expires:e.headers.get("Expires"),contentType:e.headers.get("Content-Type")}:s)).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}))})).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}));return a.xhr=r,a},_parseResponse:(e,t)=>200!==e.status?{status:e.status,statusText:e.statusText,message:`incorrect http request with status code(${e.status}): ${e.statusText}`}:"arraybuffer"===t?e.arrayBuffer():"json"===t?e.json():e.text(),getArrayBuffer:(e,t={},s)=>(t||(t={}),t.responseType="arraybuffer",P.get(e,t,s)),getJSON:function(e,t={},s){return t&&t.jsonp?P.jsonp(e):((t=t||{}).responseType="json",P.get(e,t,s))},jsonp:function(e){const t="_maptalks_jsonp_"+g++;e.match(/\?/)?e+="&callback="+t:e+="?callback="+t;let s=document.createElement("script");return s.type="text/javascript",s.src=e,new Promise((e=>{window[t]=function(r){document.getElementsByTagName("head")[0].removeChild(s),s=null,delete window[t],e(r);},document.getElementsByTagName("head")[0].appendChild(s);}))}};class M{constructor(e,t,s,r,n){this._requestImage=e,this.decoders=t,this._supportedFormats=s,this.images={},this._imgRequests={},this._fetchOptions=r||{},this._urlModifier=n;}requestImageFromBufferURI(e,t,s){if(this.buffers[e.id]){const r=this.buffers[e.id],n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}if(this._imgRequests[e.id])return this._imgRequests[e.id].then((()=>{const r=this.buffers[e.id],n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}));if(w(e.uri)){const r=this.buffers[e.id]=T(e.uri),n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}let r;const n=e.uri.indexOf("blob:")>=0;return r=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this._imgRequests[e.id]=P.getArrayBuffer(r,this._fetchOptions,this._urlModifier).then((r=>{const n=this.buffers[e.id]=r.data,i=this._createDataView(t,n);return this.getImageByBuffer(i,s)}))}getImageByBuffer(e,t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const s=this.decoders;if(s[t.mimeType])return s[t.mimeType](e,{supportedFormats:this._supportedFormats});if("image/crn"===t.mimeType||"image/ktx2"===t.mimeType||"image/cttf"===t.mimeType)throw new Error("missing transcoder for "+t.mimeType,"");return this._getImageInfo(t.id,e)}requestExternalImage(e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const t=0===e.uri.indexOf("data:image/")?e.uri:this.rootPath+"/"+e.uri;return this._imgRequests[e.id]?this._imgRequests[e.id].then((()=>this.images[e.id])):this._imgRequests[e.id]=this._getImageInfo(e.id,t)}_getImageInfo(e,t){return new Promise(((s,r)=>{let n=t;this._urlModifier&&(n=this._urlModifier(t)),this._requestImage(n,this._fetchOptions,((n,i)=>{n?r(n):(URL.revokeObjectURL(t),this.images[e]=i,s(this.images[e]));}));}))}}const S=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],V=[];class L{constructor(e,t,s,r,n){this.rootPath=e,this.gltf=t,this._enableInterleave=!1,this.glbBuffer=s,this.buffers={},this.requests={},this.accessors={},this._compareAccessor(),this._fetchOptions=r,this._urlModifier=n;}_requestData(e,t){const s=this.gltf,r=s.accessors[t];if(void 0===r.bufferView)return this.accessors[r.id]=this._toBufferData(e,t,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const n=s.bufferViews[r.bufferView];return this._requestBufferOfBufferView(n).then((s=>{const{buffer:n,byteOffset:i}=s;return this.accessors[r.id]=this._toBufferData(e,t,n,i)}))}_requestBufferOfBufferView(e){const t=this.gltf.buffers[e.buffer];if(this.buffers[t.id]){const e=this.buffers[t.id];return Promise.resolve({buffer:e,byteOffset:0})}if(this.requests[t.id])return this.requests[t.id].then((()=>{const e=this.buffers[t.id];return Promise.resolve({buffer:e,byteOffset:0})}));if("binary_glTF"!==e.buffer&&"KHR_binary_glTF"!==e.buffer&&t.uri){if(w(t.uri)){const e=this.buffers[t.id]=T(t.uri);return Promise.resolve({buffer:e,byteOffset:0})}let e;const s=t.uri.indexOf("blob:")>=0;return e=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.requests[t.id]=P.getArrayBuffer(e,this._fetchOptions,!s&&this._urlModifier).then((r=>(s&&URL.revokeObjectURL(e),{buffer:this.buffers[t.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_toBufferData(e,t,s,r=0){const n=this.gltf,i=n.accessors[t],a=void 0!==i.bufferView?n.bufferViews[i.bufferView]:{},o=(a.byteOffset||0)+r,f=this._getTypeItemSize(i.type),u=x(i.componentType),h=a.byteStride||0,l={array:void 0,name:e,accessorName:t,byteLength:i.count*f*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:f,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(l.min=i.min),i.max&&(l.max=i.max),s)if(this._enableInterleave)l.byteStride=h,l.byteOffset=o+(i.byteOffset||0),!h||h===f*u.BYTES_PER_ELEMENT||"indices"===e||"input"===e||"output"===e||e.indexOf("morph")>=0?(l.array=this._typedArray(s,i.count,f,o+(i.byteOffset||0),u),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(s,o,a.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const e=new u(i.count*f);if(l.array=B(e,s,i.count,f,h,o+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&f>2){const e=new Float32Array(l.array.length),{decodeMatrix:t}=l.extensions.WEB3D_quantized_attributes;for(let s=0;s<l.array.length;s+=f){V[0]=l.array[s],V[1]=l.array[s+1],V[2]=l.array[s+2],V[3]=1;const r=c(V,V,t);e[s]=r[0],e[s+1]=r[1],e[s+2]=r[2];}l.componentType=5126,l.array=e;}}else l.byteStride=0,l.array=this._typedArray(s,i.count,f,o+(i.byteOffset||0),u),l.byteOffset=l.array.byteOffset;else {l.array=new u(i.count);const e=l.min||l.max;e&&(l.array[0]=e[0],l.array[1]=e[1],l.array[2]=e[2]);}return l}_compareAccessor(){const e=this.gltf.accessors;if(Array.isArray(e))for(let t=0;t<e.length;t++)for(let s=0;s<e.length;s++)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);else for(const t in e)for(const s in e)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);}_typedArray(e,t,s,r,n){return r%n.BYTES_PER_ELEMENT!=0&&(e=e.slice(r,r+t*s*n.BYTES_PER_ELEMENT),r=0),new n(e,r,s*t)}_getTypeItemSize(e){const t=S.indexOf(e);return S[t+1]}requestKHRTechniquesWebgl(e){const{shaders:t}=e,s=t.map((e=>{if(void 0!==e.bufferView){const t=this.gltf.bufferViews[e.bufferView],{byteLength:s}=t;return this._requestBufferOfBufferView(t).then((r=>{const{buffer:n,byteOffset:i}=r,a=v(n,i+(t.byteOffset||0),s);return e.content=a,e}))}if(e.uri){if(w(e.uri)){const t=T(e.uri),s=v(t,0,t.byteLength);return e.content=s,Promise.resolve(e)}{const t=this.rootPath+"/"+e.uri;return P.get(t,this._fetchOptions,this._urlModifier).then((t=>(e.content=t,e)))}}return Promise.resolve(e)}));return Promise.all(s).then((()=>e))}}class D extends M{constructor(e,t,s,r,n,i,a,o){super(r,n,i,a,o),this.rootPath=e,this.gltf=t,this.requests={},this.buffers={},this.glbBuffer=s,this.accessor=new L(e,t,s,a,o);}iterate(e,t){const s=this.gltf[t];if(!s)return;let r=0;for(const t in s)e(t,s[t],r++);}createNode(e){const t={};if(b(e.name)&&(t.name=e.name),b(e.children)&&(t.children=e.children),b(e.jointName)&&(t.jointName=e.jointName),b(e.matrix)&&(t.matrix=e.matrix),b(e.rotation)&&(t.rotation=e.rotation),b(e.scale)&&(t.scale=e.scale),b(e.translation)&&(t.translation=e.translation),b(e.extras)&&(t.extras=e.extras),b(e.meshes)&&(t.mesh=e.meshes[0]),t.translation||t.rotation||t.scale){const e=function(e,t){if(t.matrix)return t.matrix;if(t.translation||t.scale||t.rotation){const s=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}(E,t.translation||R),n=function(e,t){var s=t[0],r=t[1],n=t[2],i=t[3],a=s+s,o=r+r,f=n+n,u=s*a,h=r*a,c=r*o,l=n*a,d=n*o,m=n*f,g=i*a,p=i*o,b=i*f;return e[0]=1-c-m,e[1]=h+b,e[2]=l-p,e[3]=0,e[4]=h-b,e[5]=1-u-m,e[6]=d+g,e[7]=0,e[8]=l+p,e[9]=d-g,e[10]=1-u-c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(O,t.rotation||A),i=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(I,t.scale||q);return r(i,n,i),r(e,s,i)}return function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(e)}([],t);delete t.translation,delete t.rotation,delete t.scale,t.matrix=e;}return t}_loadMaterials(e){const t={};for(const s in e){const r=e[s];let n,i;r.instanceTechnique&&r.instanceTechnique.values?(n=r.instanceTechnique,i=n.values.diffuse):(n=r,i=n.values.tex||n.values.diffuseTex||n.values.diffuse);const a={baseColorTexture:{index:i}};r.name&&(a.name=r.name),r.extensions&&(a.extensions=r.extensions),r.extras&&(a.extras=r.extras),t[s]=a;}return t}_loadImage(e){if(e.bufferView||e.extensions&&(e.extensions.KHR_binary_glTF||e.extensions.binary_glTF)){const t=e.bufferView?e:e.extensions.KHR_binary_glTF||e.extensions.binary_glTF;e.extensions&&(e.mimeType=t.mimeType,e.width=t.width,e.height=t.height);const s=this.gltf.bufferViews[t.bufferView],r=(s.byteOffset||0)+this.glbBuffer.byteOffset,n=s.byteLength,i=this.buffers[t.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,n);return this.getImageByBuffer(i,e)}return this.requestExternalImage(e)}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;const s=this.gltf.images[t.source];return this._loadImage(s).then((e=>{const r=this.gltf.samplers[t.sampler];return {image:{array:e.data,width:e.width,height:e.height,index:t.source,mimeType:s.mimeType,name:s.name,extras:s.extras},sampler:r}}))}getBaseColorTexture(e){const t=this.gltf.materials[e];let s,r;if(t.instanceTechnique&&t.instanceTechnique.values?(s=t.instanceTechnique,r=s.values.diffuse):(s=t,r=s.values.tex||s.values.diffuseTex||s.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const n=this.gltf.textures[r];if(!n)return null;const i=this.gltf.samplers[n.sampler];return {format:n.format||6408,internalFormat:n.internalFormat||6408,type:n.type||5121,sampler:i,source:this.gltf.images[n.source]}}getMaterial(){return null}getAnimations(){return null}}const U=9729;class C extends M{constructor(e,t,s,r,n,i,a,o){super(r,n,i,a,o),this.rootPath=e,this.gltf=t,this.glbBuffer=s,this.buffers={},this.requests={},this.accessor=new L(e,t,s,a,o);}iterate(e,t){const s=this.gltf[t];if(s)for(let t=0;t<s.length;t++)e(t,s[t],t);}createNode(e){const t={};return y(t,e),!b(e.weights)&&this.gltf.meshes&&b(t.mesh)?t.weights=this.gltf.meshes[t.mesh].weights:e.weights&&(t.weights=e.weights),t}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;let s=t.source;if(t.extensions&&t.extensions.EXT_texture_webp?s=t.extensions.EXT_texture_webp.source:t.extensions&&t.extensions.KHR_texture_basisu&&(s=t.extensions.KHR_texture_basisu.source),!b(s))return null;const r=this.gltf.images[s];return this._loadImage(r).then((e=>{if(!e)return null;const s={image:{array:e.data,mipmap:e.mipmap,width:e.width,height:e.height,index:t.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};y(s,t);const n=b(t.sampler)?this.gltf.samplers[t.sampler]:void 0;if(n&&(s.sampler=n,s.sampler.magFilter=n.magFilter||U,s.sampler.minFilter=n.minFilter||9987,s.sampler.wrapS=n.wrapS||10497,s.sampler.wrapT=n.wrapT||10497),"image/ktx2"===s.image.mimeType&&!s.image.mipmap&&s.sampler&&s.sampler.minFilter!==U&&9728!==s.sampler.minFilter){const e=s.sampler.minFilter;s.sampler.minFilter=9984===e||9986===e?9728:U;}return e.format&&(s.format=e.format),s}))}_loadImage(e){if(!b(e.bufferView))return this.requestExternalImage(e);{const t=this.gltf.bufferViews[e.bufferView],s=this.gltf.buffers[t.buffer];if(s.uri)return this.requestImageFromBufferURI(s,t,e);if(this.glbBuffer)return this._requestFromGlbBuffer(t,e)}return null}_requestFromGlbBuffer(e,t){const s=this._createDataView(e,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(s,t)}_createDataView(e,t,s){s=s||0;const r=(e.byteOffset||0)+s,n=e.byteLength;return new Uint8Array(t,r,n)}_transformArrayBufferToBase64(e,t){const s=new Array(e.byteLength);for(let t=0;t<e.byteLength;t++)s[t]=String.fromCharCode(e[t]);s.join("");const r="data:"+(t=t||"image/png")+";base64,"+function(e){return "undefined"!=typeof self?self.btoa(e):window.btoa(e)}(unescape(encodeURIComponent(s)));return r}getAnimations(e){const t=[];return e.forEach((e=>{t.push(this.getSamplers(e.samplers));})),Promise.all(t).then((t=>{for(let s=0;s<t.length;s++)e[s].samplers=t[s];return e}))}getSamplers(e){const t=[];for(let s=0;s<e.length;s++)(b(e[s].input)||b(e[s].output))&&(t.push(this.accessor._requestData("input",e[s].input)),t.push(this.accessor._requestData("output",e[s].output)));return Promise.all(t).then((t=>{for(let s=0;s<t.length/2;s++)e[s].input=t[2*s],e[s].output=t[2*s+1],e[s].interpolation||(e[s].interpolation="LINEAR");return e}))}}const F="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class k{static read(e,t=0,s=0){s||(s=e.byteLength);const r=new DataView(e,t,s),n=r.getUint32(4,!0);if(1===n)return k.readV1(r,t);if(2===n)return k.readV2(e,t);throw new Error("Unsupported glb version : "+n)}static readV1(e,t){const s=e.getUint32(8,!0),r=e.getUint32(12,!0);if(s!==e.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const n=X(e.buffer,20+t,r);return {json:JSON.parse(n),glbBuffer:{byteOffset:20+t+r,buffer:e.buffer,byteLength:s}}}static readV2(e,t){let s,r,n;const i=new DataView(e,t+12);let a=0;for(;a+8<i.byteLength;){const o=i.getUint32(a,!0);a+=4;const f=i.getUint32(a,!0);if(a+=4,1313821514===f)s=X(e,t+12+a,o);else if(5130562===f){n=t+12+a,r=o;break}a+=o;}return {json:JSON.parse(s),glbBuffer:{byteOffset:n,buffer:e,byteLength:r}}}}function X(e,t,s){if(F){const r=new Uint8Array(e,t,s);return F.decode(r)}return function(e){const t=e.length;let s="";for(let r=0;r<t;){let n=e[r++];if(128&n){let s=K[n>>3&7];if(!(64&n)||!s||r+s>t)return null;for(n&=63>>s;s>0;s-=1){const t=e[r++];if(128!=(192&t))return null;n=n<<6|63&t;}}s+=String.fromCharCode(n);}return s}(new Uint8Array(e,t,s))}const K=[1,1,1,1,2,2,3,0],H=[0,0,0],j=[0,0,0,1],z=[1,1,1],W={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},G={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Y={_getTRSW(e,t,s,r,n,i,o,f){const u=b(e)?t.animations:[t.animations[0]],h={};for(let t=0;t<u.length;t++){const c=u[t],l=c.name||t;if(b(e)&&l!==e)continue;const d=c.channelsMap[s];if(d)for(let e=0;e<d.length;e++){const t=d[e];"translation"===t.target.path?(this._getAnimateData(n,c.samplers[t.sampler],r,1),h.translation=a(H,n)):"rotation"===t.target.path?(this._getQuaternion(i,c.samplers[t.sampler],r,1),h.rotation=m(j,i)):"scale"===t.target.path?(this._getAnimateData(o,c.samplers[t.sampler],r,1),h.scale=a(z,o)):"weights"===t.target.path&&f&&(this._getAnimateData(f,c.samplers[t.sampler],r,f.length),h.weights=f);}}return h},_getAnimateData(e,t,s,r){switch(t.interpolation){case"LINEAR":{const n=this._getPreNext(G,t,s,1*r);n&&(e=function(e,t,s,r){for(let n=0;n<e.length;n++)e[n]=t[n]+r*(s[n]-t[n]);return e}(e,n.PREVIOUS,n.NEXT,n.INTERPOLATION));break}case"STEP":{const n=this._getPreNext(G,t,s,1*r);n&&(e=function(e,t){for(let s=0;s<e.length;s++)e[s]=t[s];return e}(e,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this._getPreNext(G,t,s,3*r);n&&(e=this._getCubicSpline(e,n,t.input.array,3*r));break}}return e},_getQuaternion(e,t,s){switch(t.interpolation){case"LINEAR":{const r=this._getPreNext(G,t,s,1);r&&function(e,t,s,r){var n,i,a,o,f,u=t[0],h=t[1],c=t[2],l=t[3],d=s[0],m=s[1],g=s[2],p=s[3];(i=u*d+h*m+c*g+l*p)<0&&(i=-i,d=-d,m=-m,g=-g,p=-p),1-i>1e-6?(n=Math.acos(i),a=Math.sin(n),o=Math.sin((1-r)*n)/a,f=Math.sin(r*n)/a):(o=1-r,f=r),e[0]=o*u+f*d,e[1]=o*h+f*m,e[2]=o*c+f*g,e[3]=o*l+f*p;}(e,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this._getPreNext(G,t,s,1);r&&(e=h(e,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this._getPreNext(G,t,s,3);if(r){for(let e=0;e<r.PREVIOUS.length;e++)r.PREVIOUS[e]=Math.acos(r.PREVIOUS[e]),r.NEXT[e]=Math.acos(r.NEXT[e]);e=this._getCubicSpline(e,r,t.input.array,3);for(let t=0;t<e.length;t++)e[t]=Math.cos(e[t]);}break}}return e},_search(e,t){const s=e.length;let r,n,i,a=0,o=s-1,f=Math.floor((a+o)/2);for(;a<=s-1&&o>=0;){if(a===o)return null;if(e[f]<=t&&t<=e[f+1]){const s=e[f];return r=f,n=f+1,i=(t-s)/(e[f+1]-s),{preIndx:r,nextIndex:n,interpolation:i}}t<e[f]?(o=f,f=Math.floor((a+o)/2)):e[f+1]<t&&(a=f,f=Math.floor((a+o)/2));}return null},_getPreNext(e,t,s,r){const n=t.input.array,i=t.output.array,a=t.output.itemSize;(s<n[0]||s>n[n.length-1])&&(s=Math.max(n[0],Math.min(n[n.length-1],s))),s===n[n.length-1]&&(s=n[0]);const o=this._search(n,s);if(!o||!o.nextIndex)return null;const{preIndx:f,nextIndex:u,interpolation:h}=o;e.PREINDEX=f,e.NEXTINDEX=u,e.INTERPOLATION=h;const c=a*r;return e.PREVIOUS=i.subarray(e.PREINDEX*c,(e.PREINDEX+1)*c),e.NEXT=i.subarray(e.NEXTINDEX*c,(e.NEXTINDEX+1)*c),e},_getCubicSpline(e,t,s,r){const n=t.INTERPOLATION,i=s[t.PREINDEX],a=s[t.NEXTINDEX];for(let s=0;s<3;s++){const o=t.PREVIOUS[r+s],f=(a-i)*t.PREVIOUS[2*r+s],u=t.NEXT[3+s],h=(a-i)*t.NEXT[s],c=(2*Math.pow(n,3)-3*Math.pow(n,2)+1)*o+(Math.pow(n,3)-2*Math.pow(n,2)+n)*f+(2*-Math.pow(n,3)+3*Math.pow(n,2))*u+(Math.pow(n,3)-Math.pow(n,2))*h;e[s]=c;}return e},getAnimationClip(e,t,s,r){const n=e.nodes[t]&&e.nodes[t].weights;return o(H,...W.TRANSLATION),h(j,...W.ROTATION),o(z,...W.SCALE),this._getTRSW(r,e,t,s,H,j,z,n)},getTimeSpan(e){if(!e.animations)return null;if(e.timeSpan)return e.timeSpan;const t=e.animations;return e.timeSpan={},t.forEach(((t,s)=>{let r=-1/0,n=1/0;const i=t.channels;for(let e=0;e<i.length;e++){const s=i[e],a=t.samplers[s.sampler].input.array;a[a.length-1]>r&&(r=a[a.length-1]),a[0]<n&&(n=a[0]);}const a=t.name||s;e.timeSpan[a]={max:r,min:n};})),e.timeSpan},getTimeSpanByName(e,t){const s=this.getTimeSpan(e);return s?b(t)?s[t]:s[Object.keys(s)[0]]:null}};let $=!1;if("undefined"!=typeof OffscreenCanvas){let e;try{e=new OffscreenCanvas(2,2).getContext("2d");}catch(s){}e&&"undefined"!=typeof createImageBitmap&&($=!0);}const J="undefined"==typeof document?null:document.createElement("canvas");function Q(e,t,s){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!J)return void s(new Error("There is no canvas to draw image!"));J.width=r.width,J.height=r.height;const e=J.getContext("2d",{willReadFrequently:!0});e.drawImage(r,0,0,r.width,r.height);const t=e.getImageData(0,0,r.width,r.height),n={width:r.width,height:r.height,data:new Uint8Array(t.data)};s(null,n);},r.onerror=function(e){s(e);},r.src=e;}const Z=[],ee=[],te=30;let se,re;function ne(e,t,s){se||(se=new OffscreenCanvas(2,2),re=se.getContext("2d",{willReadFrequently:!0}));let r=null;if(_(e))this.options.urlModifier&&(e=this.options.urlModifier(e)),Z.push([e,t,s,this]),ie();else {const t=new Blob([e]);r=createImageBitmap(t),r.then(ae.bind(this)).then((e=>{s(null,e);})).catch((e=>{console.warn(e),s(e);}));}}function ie(){if(!Z.length||ee.length>te)return;const e=Z.shift(),[t,s,r,n]=e;ee.push(e),fetch(t,s).then((e=>e.arrayBuffer())).then((e=>{const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)})).then(ae.bind(n)).then((t=>{r.call(n,null,t);const s=ee.indexOf(e);ee.splice(s,1),ie();})).catch((t=>{console.warn(t),r.call(n,t);const s=ee.indexOf(e);ee.splice(s,1),ie();}));}function ae(e){let{width:t,height:s}=e;oe(t)||(t=fe(t)),oe(s)||(s=fe(s));const r=this.options.maxTextureSize;r&&(t=Math.min(r,t),s=Math.min(r,s)),se.width=t,se.height=s,re.drawImage(e,0,0,t,s),e.close();const n=re.getImageData(0,0,t,s);return {width:t,height:s,data:new Uint8Array(n.data)}}function oe(e){return !(e&e-1)&&0!==e}function fe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function ue(e,t){for(const s in e)if(e[s]===t)return s;return t}e.Ajax=P,e.GLTFLoader=class{constructor(e,t,s){if(this.options=s||{},this.options.decoders||(this.options.decoders={}),this._fetchOptions=this.options.fetchOptions||{},t.buffer instanceof ArrayBuffer){const{json:s,glbBuffer:r}=k.read(t.buffer,t.byteOffset,t.byteLength);this._init(e,s,r);}else this._init(e,t);this._accessor=new L(this.rootPath,this.gltf,this.glbBuffer,this._fetchOptions,this.options.urlModifier),this._checkExtensions();}_checkExtensions(){const e=this.gltf.extensionsRequired;if(e){if(e.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(e.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(e.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}_loadExtensions(){const e=this.gltf.extensions;return e&&e.KHR_techniques_webgl?this._accessor.requestKHRTechniquesWebgl(e.KHR_techniques_webgl).then((t=>(e.KHR_techniques_webgl=t,e))):Promise.resolve(e)}_convertKhrTechiqueToTechiques(){if(!Array.isArray(this.gltf.programs))return;const e=this.gltf.materials;for(let t=0;t<e.length;t++)e[t]&&e[t].extensions&&e[t].extensions.KHR_technique_webgl&&(e[t].extensions.KHR_techniques_webgl=e[t].extensions.KHR_technique_webgl,delete e[t].extensions.KHR_technique_webgl);const t=this.gltf.extensions||{},s=this.gltf.techniques;t.KHR_techniques_webgl={programs:this.gltf.programs,shaders:this.gltf.shaders,techniques:s};for(let t=0;t<e.length;t++){const n=(r=e[t])&&r.extensions&&r.extensions.KHR_techniques_webgl;if(n){const{values:e,technique:t}=n,r=s[t];if(!r||!e)continue;const{uniforms:i,parameters:a}=r,o={};for(const t in e){const s=ue(i,t);o[s]=e[t],a[t]&&35678===a[t].type&&(o[s]={index:e[t]});}n.values=o;}}var r;for(let e=0;e<s.length;e++){const t=s[e];if(!t)continue;const{attributes:r,uniforms:n,parameters:i}=t;if(r)for(const e in r){const t=r[e];r[e]=i[t];}if(n)for(const e in n){const t=n[e];n[e]=i[t];}delete t.parameters;}return delete this.gltf.programs,delete this.gltf.shaders,delete this.gltf.techniques,this.gltf.extensions=t,t}load(e){e=e||{},this._convertKhrTechiqueToTechiques();const t=this._loadScene(e),s=this._loadAnimations(),r=this._loadTextures(),n=this._loadExtensions();return Promise.all([t,s,r,n]).then((e=>(e[0].animations=e[1],e[0].textures=e[2],e[0].extensions=e[3],e[0].transferables=this.transferables||[],this.createChannelsMap(e[0]),e[0])))}createChannelsMap(e){const t=e.animations;if(t)for(let e=0;e<t.length;e++){const s=t[e];s.channelsMap={};for(let e=0;e<s.channels.length;e++){const t=s.channels[e];s.channelsMap[t.target.node]||(s.channelsMap[t.target.node]=[]),s.channelsMap[t.target.node].push(t);}}}getExternalResources(){const e=[];if(this.gltf){const{buffers:t,images:s}=this.gltf;for(let s=0;s<t.length;s++)t[s].uri&&t[s].uri.indexOf("data:application/octet-stream;base64")<0&&e.push({type:"buffer",uri:t[s].uri});for(let t=0;t<s.length;t++)s[t].uri&&s[t].uri.indexOf("data:image/")<0&&e.push({type:"image",uri:s[t].uri});}return e}static getAnimationClip(e,t,s,r){return Y.getAnimationClip(e,t,s,r)}static getAnimationTimeSpan(e,t){return Y.getTimeSpanByName(e,t)}static getTypedArrayCtor(e){return x(e)}static readInterleavedArray(e,t,s,r,n,i,a){return B(e,t,s,r,n,i,a)}_init(e,t,s){this.gltf=t,this.glbBuffer=s,this.version=t.asset?+t.asset.version:1,this.rootPath=e,this.buffers={},this.requests={},this.options.requestImage=$?ne.bind(this):this.options.requestImage||Q,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new C(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions,this.options.urlModifier),this.adapter.iterate(((e,t,s)=>{t.id="buffer_"+s;}),"buffers"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s;}),"images"),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s;}),"accessors")):(this.adapter=new D(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions,this.options.urlModifier),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s;}),"accessors"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s;}),"images"));}_parseNodes(e,t){if(e.children&&e.children.length>0){if(!("number"==typeof(s=e.children[0])&&isFinite(s)||_(e.children[0])))return e;const r=e.children.map((e=>{const s=t[e];return s.nodeIndex=e,this._parseNodes(s,t)}));e.children=r;}var s;return e}_loadScene(e){return this._loadNodes(e).then((e=>{const t=this.scenes=[];let s;for(const t in e)e[t]=this._parseNodes(e[t],e),e[t].nodeIndex=Number(t)?Number(t):t;this.adapter.iterate(((r,n,i)=>{const a={};n.name&&(a.name=n.name),n.nodes&&(a.nodes=n.nodes.map((t=>e[t]))),this.gltf.scene===r&&(s=i),t.push(a);}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:s,scenes:t,nodes:e,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const e=this.adapter._loadMaterials(this.gltf.materials);r.materials=e;}return delete this.gltf.buffers,r.json=this.gltf,r}))}_loadNodes(e){return this._loadMeshes(e).then((()=>{const e=this.nodes={};return this.adapter.iterate(((t,s)=>{const r=this.adapter.createNode(s,this.meshes,this.skins);e[t]=r;}),"nodes"),e}))}_loadSkins(){this.skins=[];const e=[];return this.adapter.iterate(((t,s,r)=>{e.push(this._loadSkin(s).then((e=>{e.index=r,this.skins.push(e);})));}),"skins"),e}_loadSkin(e){const t=e.inverseBindMatrices;return this.adapter.accessor._requestData("inverseBindMatrices",t).then((t=>(e.inverseBindMatrices=t,t&&t.buffer&&this.transferables&&this.transferables.indexOf(t.buffer)<0&&this.transferables.push(t.buffer),e)))}_loadAnimations(){const e=this.gltf.animations;return b(e)?this.adapter.getAnimations(e):null}_loadMeshes(e){this.meshes={};let t=[];return this.adapter.iterate(((s,r,n)=>{t.push(this._loadMesh(r,e).then((e=>{e.index=n,this.meshes[s]=e;})));}),"meshes"),t=t.concat(this._loadSkins()),Promise.all(t)}_loadMesh(e,t){const s=e.primitives.map((e=>this._loadPrimitive(e,t))).filter((e=>!!e));return Promise.all(s).then((t=>{const s={};return y(s,e),s.primitives=t,s}))}_loadTextures(){const e=this.gltf.textures;if(!e)return null;const t=[];for(const s in e)t.push(this.adapter._getTexture(s));return Promise.all(t).then((t=>{if(this.transferables)for(let e=0;e<t.length;e++){const s=t[e]&&t[e].image.array;if(s){let e;e=s instanceof ImageBitmap?s:s.buffer,e&&this.transferables.indexOf(e)<0&&this.transferables.push(e);}}if(!Array.isArray(e)){const s={},r=Object.keys(e);for(let e=0;e<t.length;e++)t[e]&&(s[r[e]]=t[e]);return s}return t}))}_loadPrimitive(e,t){let s;const r=[],n=e.extensions;if(b(e.targets))for(let t=0;t<e.targets.length;t++){const s=e.targets[t];for(const e in s){const n=this.adapter.accessor._requestData(`morphTargets_${e}_${t}`,s[e]);n&&r.push(n);}}if(n&&n.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const e=this.options.decoders.draco,{bufferView:i,attributes:a}=n.KHR_draco_mesh_compression,o=this.gltf.bufferViews[i],f=this._accessor._requestBufferOfBufferView(o).then((s=>{const{buffer:r,byteOffset:n}=s;let{byteOffset:i}=o;const f=o.byteLength;i||(i=0);const u=new DataView(r,n+i,f),h={attributes:a,useUniqueIDs:!1,skipAttributeTransform:t.skipAttributeTransform};return e(u,h).then((e=>{const t=Object.values(e.attributes);return e.indices&&t.push(e.indices),t}))}));r.push(f),s=Promise.all(r);}else {const t=e.attributes;for(const e in t){const s=this.adapter.accessor._requestData(e,t[e]);s&&r.push(s);}if(b(e.indices)){const t=this.adapter.accessor._requestData("indices",e.indices);t&&r.push(t);}s=Promise.all(r);}return s.then((t=>{if(n&&n.KHR_draco_mesh_compression){const s=e.targets?e.targets.length:0;t[s]=t[s].concat(t.slice(0,s)),t=t[s];}let s,r;const i={attributes:t.reduce(((e,t)=>{if("indices"===t.name)s=t;else if(t.name.indexOf("morphTargets_")>-1)r=r||{},r[t.name.slice(13)]=t;else {if(!("POSITION"!==t.name||t.min&&t.max)){const e=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0],{itemSize:r,array:n}=t,i=n.length/r;for(let t=0;t<i;t++)for(let i=0;i<r;i++){const a=t*r+i;n[a]<e[i]&&(e[i]=n[a]),n[a]>s[i]&&(s[i]=n[a]);}if(t.quantization){const r=t.quantization,n=r.range/(1<<r.quantizationBits),i=r.minValues;u(e,e,n),f(e,e,i),u(s,s,n),f(s,s,i);}t.min=e,t.max=s;}e[t.name]=t;}return this.transferables&&t.array.buffer&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),e}),{}),material:e.material};return s&&(i.indices=s),r&&(i.morphTargets=r),i.mode=b(e.mode)?e.mode:4,b(e.extras)&&(i.extras=e.extras),i}))}},t().maptalks_gltf_loader=e;}gltfLoaderExport({});
88
+ */var s="undefined"!=typeof Float32Array?Float32Array:Array;function r(e,t,s){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],f=t[5],u=t[6],h=t[7],c=t[8],l=t[9],d=t[10],m=t[11],g=t[12],p=t[13],b=t[14],_=t[15],y=s[0],x=s[1],w=s[2],T=s[3];return e[0]=y*r+x*o+w*c+T*g,e[1]=y*n+x*f+w*l+T*p,e[2]=y*i+x*u+w*d+T*b,e[3]=y*a+x*h+w*m+T*_,y=s[4],x=s[5],w=s[6],T=s[7],e[4]=y*r+x*o+w*c+T*g,e[5]=y*n+x*f+w*l+T*p,e[6]=y*i+x*u+w*d+T*b,e[7]=y*a+x*h+w*m+T*_,y=s[8],x=s[9],w=s[10],T=s[11],e[8]=y*r+x*o+w*c+T*g,e[9]=y*n+x*f+w*l+T*p,e[10]=y*i+x*u+w*d+T*b,e[11]=y*a+x*h+w*m+T*_,y=s[12],x=s[13],w=s[14],T=s[15],e[12]=y*r+x*o+w*c+T*g,e[13]=y*n+x*f+w*l+T*p,e[14]=y*i+x*u+w*d+T*b,e[15]=y*a+x*h+w*m+T*_,e}function n(){var e=new s(3);return s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function i(e,t,r){var n=new s(3);return n[0]=e,n[1]=t,n[2]=r,n}function a(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function o(e,t,s,r){return e[0]=t,e[1]=s,e[2]=r,e}function f(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e}function u(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function h(e,t,s,r,n){return e[0]=t,e[1]=s,e[2]=r,e[3]=n,e}function c(e,t,s){var r=t[0],n=t[1],i=t[2],a=t[3];return e[0]=s[0]*r+s[4]*n+s[8]*i+s[12]*a,e[1]=s[1]*r+s[5]*n+s[9]*i+s[13]*a,e[2]=s[2]*r+s[6]*n+s[10]*i+s[14]*a,e[3]=s[3]*r+s[7]*n+s[11]*i+s[15]*a,e}function l(){var e=new s(4);return s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),n(),function(){var e;e=new s(4),s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0);}();var d,m=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e};n(),i(1,0,0),i(0,1,0),l(),l(),d=new s(9),s!=Float32Array&&(d[1]=0,d[2]=0,d[3]=0,d[5]=0,d[6]=0,d[7]=0),d[0]=1,d[4]=1,d[8]=1;let g=0;function p(e){return null==e}function b(e){return !p(e)}function _(e){return !p(e)&&("string"==typeof e||null!==e.constructor&&e.constructor===String)}function y(e){for(let t=1;t<arguments.length;t++){const s=arguments[t];for(const t in s)e[t]=s[t];}return e}function x(e){switch(e){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+e)}function w(e){return 0===e.indexOf("data:")&&e.indexOf("base64,")>0}function T(e){const t=function(e){return "undefined"!=typeof self?self.atob(e):window.atob(e)}(e.substring(e.indexOf(",")+1)),s=t.length,r=new Uint8Array(s);for(let e=0;e<s;e++)r[e]=t.charCodeAt(e);return r.buffer}const E=[],O=[],I=[],R=[0,0,0],A=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}([]),q=[1,1,1];function B(e,t,s,r,n,i,a){const o=x(a),f=o.BYTES_PER_ELEMENT;if((0===n||n===r*f)&&i%f==0){const n=new o(t,i,s*r);return e.set(n),e}0===n&&(n=r*f);const u=new Uint8Array(r*f);for(let a=0;a<s;a++){let s=null;const h=new Uint8Array(t,n*a+i,r*f);u.set(h),s=new o(u.buffer,0,r);for(let t=0;t<r;t++)e[a*r+t]=s[t];}return e}const N="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function v(e,t,s){const r=new Uint8Array(e,t,s);return N.decode(r)}const P={get:function(e,t={},s){t||(t={});const r=new AbortController,n=r.signal,i=y({},t);i.signal=n,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),s&&(e=s(e));const a=fetch(e,i).then((e=>{const s=this._parseResponse(e,t.responseType);return s.message?s:s.then((s=>"arraybuffer"===t.responseType?{data:s,cacheControl:e.headers.get("Cache-Control"),expires:e.headers.get("Expires"),contentType:e.headers.get("Content-Type")}:s)).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}))})).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}));return a.xhr=r,a},_parseResponse:(e,t)=>200!==e.status?{status:e.status,statusText:e.statusText,message:`incorrect http request with status code(${e.status}): ${e.statusText}`}:"arraybuffer"===t?e.arrayBuffer():"json"===t?e.json():e.text(),getArrayBuffer:(e,t={},s)=>(t||(t={}),t.responseType="arraybuffer",P.get(e,t,s)),getJSON:function(e,t={},s){return t&&t.jsonp?P.jsonp(e):((t=t||{}).responseType="json",P.get(e,t,s))},jsonp:function(e){const t="_maptalks_jsonp_"+g++;e.match(/\?/)?e+="&callback="+t:e+="?callback="+t;let s=document.createElement("script");return s.type="text/javascript",s.src=e,new Promise((e=>{window[t]=function(r){document.getElementsByTagName("head")[0].removeChild(s),s=null,delete window[t],e(r);},document.getElementsByTagName("head")[0].appendChild(s);}))}};class M{constructor(e,t,s,r,n){this._requestImage=e,this.decoders=t,this._supportedFormats=s,this.images={},this._imgRequests={},this._fetchOptions=r||{},this._urlModifier=n;}requestImageFromBufferURI(e,t,s){if(this.buffers[e.id]){const r=this.buffers[e.id],n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}if(this._imgRequests[e.id])return this._imgRequests[e.id].then((()=>{const r=this.buffers[e.id],n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}));if(w(e.uri)){const r=this.buffers[e.id]=T(e.uri),n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}let r;const n=e.uri.indexOf("blob:")>=0;return r=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this._imgRequests[e.id]=P.getArrayBuffer(r,this._fetchOptions,this._urlModifier).then((r=>{const n=this.buffers[e.id]=r.data,i=this._createDataView(t,n);return this.getImageByBuffer(i,s)}))}getImageByBuffer(e,t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const s=this.decoders;if(s[t.mimeType])return s[t.mimeType](e,{supportedFormats:this._supportedFormats});if("image/crn"===t.mimeType||"image/ktx2"===t.mimeType||"image/cttf"===t.mimeType)throw new Error("missing transcoder for "+t.mimeType,"");return this._getImageInfo(t.id,e)}requestExternalImage(e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const t=0===e.uri.indexOf("data:image/")?e.uri:this.rootPath+"/"+e.uri;return this._imgRequests[e.id]?this._imgRequests[e.id].then((()=>this.images[e.id])):this._imgRequests[e.id]=this._getImageInfo(e.id,t)}_getImageInfo(e,t){return new Promise(((s,r)=>{let n=t;this._urlModifier&&(n=this._urlModifier(t)),this._requestImage(n,this._fetchOptions,((n,i)=>{n?r(n):(URL.revokeObjectURL(t),this.images[e]=i,s(this.images[e]));}));}))}}const S=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],V=[];class L{constructor(e,t,s,r,n){this.rootPath=e,this.gltf=t,this._enableInterleave=!1,this.glbBuffer=s,this.buffers={},this.requests={},this.accessors={},this._compareAccessor(),this._fetchOptions=r,this._urlModifier=n;}_requestData(e,t){const s=this.gltf,r=s.accessors[t];if(void 0===r.bufferView)return this.accessors[r.id]=this._toBufferData(e,t,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const n=s.bufferViews[r.bufferView];return this._requestBufferOfBufferView(n).then((s=>{const{buffer:n,byteOffset:i}=s;return this.accessors[r.id]=this._toBufferData(e,t,n,i)}))}_requestBufferOfBufferView(e){const t=this.gltf.buffers[e.buffer];if(this.buffers[t.id]){const e=this.buffers[t.id];return Promise.resolve({buffer:e,byteOffset:0})}if(this.requests[t.id])return this.requests[t.id].then((()=>{const e=this.buffers[t.id];return Promise.resolve({buffer:e,byteOffset:0})}));if("binary_glTF"!==e.buffer&&"KHR_binary_glTF"!==e.buffer&&t.uri){if(w(t.uri)){const e=this.buffers[t.id]=T(t.uri);return Promise.resolve({buffer:e,byteOffset:0})}let e;const s=t.uri.indexOf("blob:")>=0;return e=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.requests[t.id]=P.getArrayBuffer(e,this._fetchOptions,!s&&this._urlModifier).then((r=>(s&&URL.revokeObjectURL(e),{buffer:this.buffers[t.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_toBufferData(e,t,s,r=0){const n=this.gltf,i=n.accessors[t],a=void 0!==i.bufferView?n.bufferViews[i.bufferView]:{},o=(a.byteOffset||0)+r,f=this._getTypeItemSize(i.type),u=x(i.componentType),h=a.byteStride||0,l={array:void 0,name:e,accessorName:t,byteLength:i.count*f*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:f,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(l.min=i.min),i.max&&(l.max=i.max),s)if(this._enableInterleave)l.byteStride=h,l.byteOffset=o+(i.byteOffset||0),!h||h===f*u.BYTES_PER_ELEMENT||"indices"===e||"input"===e||"output"===e||e.indexOf("morph")>=0?(l.array=this._typedArray(s,i.count,f,o+(i.byteOffset||0),u),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(s,o,a.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const e=new u(i.count*f);if(l.array=B(e,s,i.count,f,h,o+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&f>2){const e=new Float32Array(l.array.length),{decodeMatrix:t}=l.extensions.WEB3D_quantized_attributes;for(let s=0;s<l.array.length;s+=f){V[0]=l.array[s],V[1]=l.array[s+1],V[2]=l.array[s+2],V[3]=1;const r=c(V,V,t);e[s]=r[0],e[s+1]=r[1],e[s+2]=r[2];}l.componentType=5126,l.array=e;}}else l.byteStride=0,l.array=this._typedArray(s,i.count,f,o+(i.byteOffset||0),u),l.byteOffset=l.array.byteOffset;else {l.array=new u(i.count);const e=l.min||l.max;e&&(l.array[0]=e[0],l.array[1]=e[1],l.array[2]=e[2]);}return l}_compareAccessor(){const e=this.gltf.accessors;if(Array.isArray(e))for(let t=0;t<e.length;t++)for(let s=0;s<e.length;s++)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);else for(const t in e)for(const s in e)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);}_typedArray(e,t,s,r,n){return r%n.BYTES_PER_ELEMENT!=0&&(e=e.slice(r,r+t*s*n.BYTES_PER_ELEMENT),r=0),new n(e,r,s*t)}_getTypeItemSize(e){const t=S.indexOf(e);return S[t+1]}requestKHRTechniquesWebgl(e){const{shaders:t}=e,s=t.map((e=>{if(void 0!==e.bufferView){const t=this.gltf.bufferViews[e.bufferView],{byteLength:s}=t;return this._requestBufferOfBufferView(t).then((r=>{const{buffer:n,byteOffset:i}=r,a=v(n,i+(t.byteOffset||0),s);return e.content=a,e}))}if(e.uri){if(w(e.uri)){const t=T(e.uri),s=v(t,0,t.byteLength);return e.content=s,Promise.resolve(e)}{const t=this.rootPath+"/"+e.uri;return P.get(t,this._fetchOptions,this._urlModifier).then((t=>(e.content=t,e)))}}return Promise.resolve(e)}));return Promise.all(s).then((()=>e))}}class D extends M{constructor(e,t,s,r,n,i,a,o){super(r,n,i,a,o),this.rootPath=e,this.gltf=t,this.requests={},this.buffers={},this.glbBuffer=s,this.accessor=new L(e,t,s,a,o);}iterate(e,t){const s=this.gltf[t];if(!s)return;let r=0;for(const t in s)e(t,s[t],r++);}createNode(e){const t={};if(b(e.name)&&(t.name=e.name),b(e.children)&&(t.children=e.children),b(e.jointName)&&(t.jointName=e.jointName),b(e.matrix)&&(t.matrix=e.matrix),b(e.rotation)&&(t.rotation=e.rotation),b(e.scale)&&(t.scale=e.scale),b(e.translation)&&(t.translation=e.translation),b(e.extras)&&(t.extras=e.extras),b(e.meshes)&&(t.mesh=e.meshes[0]),t.translation||t.rotation||t.scale){const e=function(e,t){if(t.matrix)return t.matrix;if(t.translation||t.scale||t.rotation){const s=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}(E,t.translation||R),n=function(e,t){var s=t[0],r=t[1],n=t[2],i=t[3],a=s+s,o=r+r,f=n+n,u=s*a,h=r*a,c=r*o,l=n*a,d=n*o,m=n*f,g=i*a,p=i*o,b=i*f;return e[0]=1-c-m,e[1]=h+b,e[2]=l-p,e[3]=0,e[4]=h-b,e[5]=1-u-m,e[6]=d+g,e[7]=0,e[8]=l+p,e[9]=d-g,e[10]=1-u-c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(O,t.rotation||A),i=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(I,t.scale||q);return r(i,n,i),r(e,s,i)}return function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(e)}([],t);delete t.translation,delete t.rotation,delete t.scale,t.matrix=e;}return t}_loadMaterials(e){const t={};for(const s in e){const r=e[s];let n,i;r.instanceTechnique&&r.instanceTechnique.values?(n=r.instanceTechnique,i=n.values.diffuse):(n=r,i=n.values.tex||n.values.diffuseTex||n.values.diffuse);const a={baseColorTexture:{index:i}};r.name&&(a.name=r.name),r.extensions&&(a.extensions=r.extensions),r.extras&&(a.extras=r.extras),t[s]=a;}return t}_loadImage(e){if(e.bufferView||e.extensions&&(e.extensions.KHR_binary_glTF||e.extensions.binary_glTF)){const t=e.bufferView?e:e.extensions.KHR_binary_glTF||e.extensions.binary_glTF;e.extensions&&(e.mimeType=t.mimeType,e.width=t.width,e.height=t.height);const s=this.gltf.bufferViews[t.bufferView],r=(s.byteOffset||0)+this.glbBuffer.byteOffset,n=s.byteLength,i=this.buffers[t.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,n);return this.getImageByBuffer(i,e)}return this.requestExternalImage(e)}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;const s=this.gltf.images[t.source];return this._loadImage(s).then((e=>{const r=this.gltf.samplers[t.sampler];return {image:{array:e.data,width:e.width,height:e.height,index:t.source,mimeType:s.mimeType,name:s.name,extras:s.extras},sampler:r}}))}getBaseColorTexture(e){const t=this.gltf.materials[e];let s,r;if(t.instanceTechnique&&t.instanceTechnique.values?(s=t.instanceTechnique,r=s.values.diffuse):(s=t,r=s.values.tex||s.values.diffuseTex||s.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const n=this.gltf.textures[r];if(!n)return null;const i=this.gltf.samplers[n.sampler];return {format:n.format||6408,internalFormat:n.internalFormat||6408,type:n.type||5121,sampler:i,source:this.gltf.images[n.source]}}getMaterial(){return null}getAnimations(){return null}}const U=9729;class C extends M{constructor(e,t,s,r,n,i,a,o){super(r,n,i,a,o),this.rootPath=e,this.gltf=t,this.glbBuffer=s,this.buffers={},this.requests={},this.accessor=new L(e,t,s,a,o);}iterate(e,t){const s=this.gltf[t];if(s)for(let t=0;t<s.length;t++)e(t,s[t],t);}createNode(e){const t={};return y(t,e),!b(e.weights)&&this.gltf.meshes&&b(t.mesh)?t.weights=this.gltf.meshes[t.mesh].weights:e.weights&&(t.weights=e.weights),t}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;let s=t.source;if(t.extensions&&t.extensions.EXT_texture_webp?s=t.extensions.EXT_texture_webp.source:t.extensions&&t.extensions.KHR_texture_basisu&&(s=t.extensions.KHR_texture_basisu.source),!b(s))return null;const r=this.gltf.images[s];return this._loadImage(r).then((e=>{if(!e)return null;const s={image:{array:e.data,mipmap:e.mipmap,width:e.width,height:e.height,index:t.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};y(s,t);const n=b(t.sampler)?this.gltf.samplers[t.sampler]:void 0;if(n&&(s.sampler=n,s.sampler.magFilter=n.magFilter||U,s.sampler.minFilter=n.minFilter||9987,s.sampler.wrapS=n.wrapS||10497,s.sampler.wrapT=n.wrapT||10497),"image/ktx2"===s.image.mimeType&&!s.image.mipmap&&s.sampler&&s.sampler.minFilter!==U&&9728!==s.sampler.minFilter){const e=s.sampler.minFilter;s.sampler.minFilter=9984===e||9986===e?9728:U;}if(e.format&&(s.format=e.format),6407===s.format){const e=s.image.array&&s.image.array.length;e&&e===s.image.width*s.image.height*4&&(s.format=6408);}return s}))}_loadImage(e){if(!b(e.bufferView))return this.requestExternalImage(e);{const t=this.gltf.bufferViews[e.bufferView],s=this.gltf.buffers[t.buffer];if(s.uri)return this.requestImageFromBufferURI(s,t,e);if(this.glbBuffer)return this._requestFromGlbBuffer(t,e)}return null}_requestFromGlbBuffer(e,t){const s=this._createDataView(e,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(s,t)}_createDataView(e,t,s){s=s||0;const r=(e.byteOffset||0)+s,n=e.byteLength;return new Uint8Array(t,r,n)}_transformArrayBufferToBase64(e,t){const s=new Array(e.byteLength);for(let t=0;t<e.byteLength;t++)s[t]=String.fromCharCode(e[t]);s.join("");const r="data:"+(t=t||"image/png")+";base64,"+function(e){return "undefined"!=typeof self?self.btoa(e):window.btoa(e)}(unescape(encodeURIComponent(s)));return r}getAnimations(e){const t=[];return e.forEach((e=>{t.push(this.getSamplers(e.samplers));})),Promise.all(t).then((t=>{for(let s=0;s<t.length;s++)e[s].samplers=t[s];return e}))}getSamplers(e){const t=[];for(let s=0;s<e.length;s++)(b(e[s].input)||b(e[s].output))&&(t.push(this.accessor._requestData("input",e[s].input)),t.push(this.accessor._requestData("output",e[s].output)));return Promise.all(t).then((t=>{for(let s=0;s<t.length/2;s++)e[s].input=t[2*s],e[s].output=t[2*s+1],e[s].interpolation||(e[s].interpolation="LINEAR");return e}))}}const F="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class k{static read(e,t=0,s=0){s||(s=e.byteLength);const r=new DataView(e,t,s),n=r.getUint32(4,!0);if(1===n)return k.readV1(r,t);if(2===n)return k.readV2(e,t);throw new Error("Unsupported glb version : "+n)}static readV1(e,t){const s=e.getUint32(8,!0),r=e.getUint32(12,!0);if(s!==e.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const n=X(e.buffer,20+t,r);return {json:JSON.parse(n),glbBuffer:{byteOffset:20+t+r,buffer:e.buffer,byteLength:s}}}static readV2(e,t){let s,r,n;const i=new DataView(e,t+12);let a=0;for(;a+8<i.byteLength;){const o=i.getUint32(a,!0);a+=4;const f=i.getUint32(a,!0);if(a+=4,1313821514===f)s=X(e,t+12+a,o);else if(5130562===f){n=t+12+a,r=o;break}a+=o;}return {json:JSON.parse(s),glbBuffer:{byteOffset:n,buffer:e,byteLength:r}}}}function X(e,t,s){if(F){const r=new Uint8Array(e,t,s);return F.decode(r)}return function(e){const t=e.length;let s="";for(let r=0;r<t;){let n=e[r++];if(128&n){let s=K[n>>3&7];if(!(64&n)||!s||r+s>t)return null;for(n&=63>>s;s>0;s-=1){const t=e[r++];if(128!=(192&t))return null;n=n<<6|63&t;}}s+=String.fromCharCode(n);}return s}(new Uint8Array(e,t,s))}const K=[1,1,1,1,2,2,3,0],H=[0,0,0],j=[0,0,0,1],z=[1,1,1],W={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},G={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Y={_getTRSW(e,t,s,r,n,i,o,f){const u=b(e)?t.animations:[t.animations[0]],h={};for(let t=0;t<u.length;t++){const c=u[t],l=c.name||t;if(b(e)&&l!==e)continue;const d=c.channelsMap[s];if(d)for(let e=0;e<d.length;e++){const t=d[e];"translation"===t.target.path?(this._getAnimateData(n,c.samplers[t.sampler],r,1),h.translation=a(H,n)):"rotation"===t.target.path?(this._getQuaternion(i,c.samplers[t.sampler],r,1),h.rotation=m(j,i)):"scale"===t.target.path?(this._getAnimateData(o,c.samplers[t.sampler],r,1),h.scale=a(z,o)):"weights"===t.target.path&&f&&(this._getAnimateData(f,c.samplers[t.sampler],r,f.length),h.weights=f);}}return h},_getAnimateData(e,t,s,r){switch(t.interpolation){case"LINEAR":{const n=this._getPreNext(G,t,s,1*r);n&&(e=function(e,t,s,r){for(let n=0;n<e.length;n++)e[n]=t[n]+r*(s[n]-t[n]);return e}(e,n.PREVIOUS,n.NEXT,n.INTERPOLATION));break}case"STEP":{const n=this._getPreNext(G,t,s,1*r);n&&(e=function(e,t){for(let s=0;s<e.length;s++)e[s]=t[s];return e}(e,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this._getPreNext(G,t,s,3*r);n&&(e=this._getCubicSpline(e,n,t.input.array,3*r));break}}return e},_getQuaternion(e,t,s){switch(t.interpolation){case"LINEAR":{const r=this._getPreNext(G,t,s,1);r&&function(e,t,s,r){var n,i,a,o,f,u=t[0],h=t[1],c=t[2],l=t[3],d=s[0],m=s[1],g=s[2],p=s[3];(i=u*d+h*m+c*g+l*p)<0&&(i=-i,d=-d,m=-m,g=-g,p=-p),1-i>1e-6?(n=Math.acos(i),a=Math.sin(n),o=Math.sin((1-r)*n)/a,f=Math.sin(r*n)/a):(o=1-r,f=r),e[0]=o*u+f*d,e[1]=o*h+f*m,e[2]=o*c+f*g,e[3]=o*l+f*p;}(e,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this._getPreNext(G,t,s,1);r&&(e=h(e,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this._getPreNext(G,t,s,3);if(r){for(let e=0;e<r.PREVIOUS.length;e++)r.PREVIOUS[e]=Math.acos(r.PREVIOUS[e]),r.NEXT[e]=Math.acos(r.NEXT[e]);e=this._getCubicSpline(e,r,t.input.array,3);for(let t=0;t<e.length;t++)e[t]=Math.cos(e[t]);}break}}return e},_search(e,t){const s=e.length;let r,n,i,a=0,o=s-1,f=Math.floor((a+o)/2);for(;a<=s-1&&o>=0;){if(a===o)return null;if(e[f]<=t&&t<=e[f+1]){const s=e[f];return r=f,n=f+1,i=(t-s)/(e[f+1]-s),{preIndx:r,nextIndex:n,interpolation:i}}t<e[f]?(o=f,f=Math.floor((a+o)/2)):e[f+1]<t&&(a=f,f=Math.floor((a+o)/2));}return null},_getPreNext(e,t,s,r){const n=t.input.array,i=t.output.array,a=t.output.itemSize;(s<n[0]||s>n[n.length-1])&&(s=Math.max(n[0],Math.min(n[n.length-1],s))),s===n[n.length-1]&&(s=n[0]);const o=this._search(n,s);if(!o||!o.nextIndex)return null;const{preIndx:f,nextIndex:u,interpolation:h}=o;e.PREINDEX=f,e.NEXTINDEX=u,e.INTERPOLATION=h;const c=a*r;return e.PREVIOUS=i.subarray(e.PREINDEX*c,(e.PREINDEX+1)*c),e.NEXT=i.subarray(e.NEXTINDEX*c,(e.NEXTINDEX+1)*c),e},_getCubicSpline(e,t,s,r){const n=t.INTERPOLATION,i=s[t.PREINDEX],a=s[t.NEXTINDEX];for(let s=0;s<3;s++){const o=t.PREVIOUS[r+s],f=(a-i)*t.PREVIOUS[2*r+s],u=t.NEXT[3+s],h=(a-i)*t.NEXT[s],c=(2*Math.pow(n,3)-3*Math.pow(n,2)+1)*o+(Math.pow(n,3)-2*Math.pow(n,2)+n)*f+(2*-Math.pow(n,3)+3*Math.pow(n,2))*u+(Math.pow(n,3)-Math.pow(n,2))*h;e[s]=c;}return e},getAnimationClip(e,t,s,r){const n=e.nodes[t]&&e.nodes[t].weights;return o(H,...W.TRANSLATION),h(j,...W.ROTATION),o(z,...W.SCALE),this._getTRSW(r,e,t,s,H,j,z,n)},getTimeSpan(e){if(!e.animations)return null;if(e.timeSpan)return e.timeSpan;const t=e.animations;return e.timeSpan={},t.forEach(((t,s)=>{let r=-1/0,n=1/0;const i=t.channels;for(let e=0;e<i.length;e++){const s=i[e],a=t.samplers[s.sampler].input.array;a[a.length-1]>r&&(r=a[a.length-1]),a[0]<n&&(n=a[0]);}const a=t.name||s;e.timeSpan[a]={max:r,min:n};})),e.timeSpan},getTimeSpanByName(e,t){const s=this.getTimeSpan(e);return s?b(t)?s[t]:s[Object.keys(s)[0]]:null}};let $=!1;if("undefined"!=typeof OffscreenCanvas){let e;try{e=new OffscreenCanvas(2,2).getContext("2d");}catch(s){}e&&"undefined"!=typeof createImageBitmap&&($=!0);}const J="undefined"==typeof document?null:document.createElement("canvas");function Q(e,t,s){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!J)return void s(new Error("There is no canvas to draw image!"));J.width=r.width,J.height=r.height;const e=J.getContext("2d",{willReadFrequently:!0});e.drawImage(r,0,0,r.width,r.height);const t=e.getImageData(0,0,r.width,r.height),n={width:r.width,height:r.height,data:new Uint8Array(t.data)};s(null,n);},r.onerror=function(e){s(e);},r.src=e;}const Z=[],ee=[],te=30;let se,re;function ne(e,t,s){se||(se=new OffscreenCanvas(2,2),re=se.getContext("2d",{willReadFrequently:!0}));let r=null;if(_(e))this.options.urlModifier&&(e=this.options.urlModifier(e)),Z.push([e,t,s,this]),ie();else {const t=new Blob([e]);r=createImageBitmap(t),r.then(ae.bind(this)).then((e=>{s(null,e);})).catch((e=>{console.warn(e),s(e);}));}}function ie(){if(!Z.length||ee.length>te)return;const e=Z.shift(),[t,s,r,n]=e;ee.push(e),fetch(t,s).then((e=>e.arrayBuffer())).then((e=>{const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)})).then(ae.bind(n)).then((t=>{r.call(n,null,t);const s=ee.indexOf(e);ee.splice(s,1),ie();})).catch((t=>{console.warn(t),r.call(n,t);const s=ee.indexOf(e);ee.splice(s,1),ie();}));}function ae(e){let{width:t,height:s}=e;oe(t)||(t=fe(t)),oe(s)||(s=fe(s));const r=this.options.maxTextureSize;r&&(t=Math.min(r,t),s=Math.min(r,s)),se.width=t,se.height=s,re.drawImage(e,0,0,t,s),e.close();const n=re.getImageData(0,0,t,s);return {width:t,height:s,data:new Uint8Array(n.data)}}function oe(e){return !(e&e-1)&&0!==e}function fe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function ue(e,t){for(const s in e)if(e[s]===t)return s;return t}e.Ajax=P,e.GLTFLoader=class{constructor(e,t,s){if(this.options=s||{},this.options.decoders||(this.options.decoders={}),this._fetchOptions=this.options.fetchOptions||{},t.buffer instanceof ArrayBuffer){const{json:s,glbBuffer:r}=k.read(t.buffer,t.byteOffset,t.byteLength);this._init(e,s,r);}else this._init(e,t);this._accessor=new L(this.rootPath,this.gltf,this.glbBuffer,this._fetchOptions,this.options.urlModifier),this._checkExtensions();}_checkExtensions(){const e=this.gltf.extensionsRequired;if(e){if(e.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(e.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(e.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}_loadExtensions(){const e=this.gltf.extensions;return e&&e.KHR_techniques_webgl?this._accessor.requestKHRTechniquesWebgl(e.KHR_techniques_webgl).then((t=>(e.KHR_techniques_webgl=t,e))):Promise.resolve(e)}_convertKhrTechiqueToTechiques(){if(!Array.isArray(this.gltf.programs))return;const e=this.gltf.materials;for(let t=0;t<e.length;t++)e[t]&&e[t].extensions&&e[t].extensions.KHR_technique_webgl&&(e[t].extensions.KHR_techniques_webgl=e[t].extensions.KHR_technique_webgl,delete e[t].extensions.KHR_technique_webgl);const t=this.gltf.extensions||{},s=this.gltf.techniques;t.KHR_techniques_webgl={programs:this.gltf.programs,shaders:this.gltf.shaders,techniques:s};for(let t=0;t<e.length;t++){const n=(r=e[t])&&r.extensions&&r.extensions.KHR_techniques_webgl;if(n){const{values:e,technique:t}=n,r=s[t];if(!r||!e)continue;const{uniforms:i,parameters:a}=r,o={};for(const t in e){const s=ue(i,t);o[s]=e[t],a[t]&&35678===a[t].type&&(o[s]={index:e[t]});}n.values=o;}}var r;for(let e=0;e<s.length;e++){const t=s[e];if(!t)continue;const{attributes:r,uniforms:n,parameters:i}=t;if(r)for(const e in r){const t=r[e];r[e]=i[t];}if(n)for(const e in n){const t=n[e];n[e]=i[t];}delete t.parameters;}return delete this.gltf.programs,delete this.gltf.shaders,delete this.gltf.techniques,this.gltf.extensions=t,t}load(e){e=e||{},this._convertKhrTechiqueToTechiques();const t=this._loadScene(e),s=this._loadAnimations(),r=this._loadTextures(),n=this._loadExtensions();return Promise.all([t,s,r,n]).then((e=>(e[0].animations=e[1],e[0].textures=e[2],e[0].extensions=e[3],e[0].transferables=this.transferables||[],this.createChannelsMap(e[0]),e[0])))}createChannelsMap(e){const t=e.animations;if(t)for(let e=0;e<t.length;e++){const s=t[e];s.channelsMap={};for(let e=0;e<s.channels.length;e++){const t=s.channels[e];s.channelsMap[t.target.node]||(s.channelsMap[t.target.node]=[]),s.channelsMap[t.target.node].push(t);}}}getExternalResources(){const e=[];if(this.gltf){const{buffers:t,images:s}=this.gltf;for(let s=0;s<t.length;s++)t[s].uri&&t[s].uri.indexOf("data:application/octet-stream;base64")<0&&e.push({type:"buffer",uri:t[s].uri});for(let t=0;t<s.length;t++)s[t].uri&&s[t].uri.indexOf("data:image/")<0&&e.push({type:"image",uri:s[t].uri});}return e}static getAnimationClip(e,t,s,r){return Y.getAnimationClip(e,t,s,r)}static getAnimationTimeSpan(e,t){return Y.getTimeSpanByName(e,t)}static getTypedArrayCtor(e){return x(e)}static readInterleavedArray(e,t,s,r,n,i,a){return B(e,t,s,r,n,i,a)}_init(e,t,s){this.gltf=t,this.glbBuffer=s,this.version=t.asset?+t.asset.version:1,this.rootPath=e,this.buffers={},this.requests={},this.options.requestImage=$?ne.bind(this):this.options.requestImage||Q,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new C(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions,this.options.urlModifier),this.adapter.iterate(((e,t,s)=>{t.id="buffer_"+s;}),"buffers"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s;}),"images"),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s;}),"accessors")):(this.adapter=new D(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions,this.options.urlModifier),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s;}),"accessors"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s;}),"images"));}_parseNodes(e,t){if(e.children&&e.children.length>0){if(!("number"==typeof(s=e.children[0])&&isFinite(s)||_(e.children[0])))return e;const r=e.children.map((e=>{const s=t[e];return s.nodeIndex=e,this._parseNodes(s,t)}));e.children=r;}var s;return e}_loadScene(e){return this._loadNodes(e).then((e=>{const t=this.scenes=[];let s;for(const t in e)e[t]=this._parseNodes(e[t],e),e[t].nodeIndex=Number(t)?Number(t):t;this.adapter.iterate(((r,n,i)=>{const a={};n.name&&(a.name=n.name),n.nodes&&(a.nodes=n.nodes.map((t=>e[t]))),this.gltf.scene===r&&(s=i),t.push(a);}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:s,scenes:t,nodes:e,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const e=this.adapter._loadMaterials(this.gltf.materials);r.materials=e;}return delete this.gltf.buffers,r.json=this.gltf,r}))}_loadNodes(e){return this._loadMeshes(e).then((()=>{const e=this.nodes={};return this.adapter.iterate(((t,s)=>{const r=this.adapter.createNode(s,this.meshes,this.skins);e[t]=r;}),"nodes"),e}))}_loadSkins(){this.skins=[];const e=[];return this.adapter.iterate(((t,s,r)=>{e.push(this._loadSkin(s).then((e=>{e.index=r,this.skins.push(e);})));}),"skins"),e}_loadSkin(e){const t=e.inverseBindMatrices;return this.adapter.accessor._requestData("inverseBindMatrices",t).then((t=>(e.inverseBindMatrices=t,t&&t.buffer&&this.transferables&&this.transferables.indexOf(t.buffer)<0&&this.transferables.push(t.buffer),e)))}_loadAnimations(){const e=this.gltf.animations;return b(e)?this.adapter.getAnimations(e):null}_loadMeshes(e){this.meshes={};let t=[];return this.adapter.iterate(((s,r,n)=>{t.push(this._loadMesh(r,e).then((e=>{e.index=n,this.meshes[s]=e;})));}),"meshes"),t=t.concat(this._loadSkins()),Promise.all(t)}_loadMesh(e,t){const s=e.primitives.map((e=>this._loadPrimitive(e,t))).filter((e=>!!e));return Promise.all(s).then((t=>{const s={};return y(s,e),s.primitives=t,s}))}_loadTextures(){const e=this.gltf.textures;if(!e)return null;const t=[];for(const s in e)t.push(this.adapter._getTexture(s));return Promise.all(t).then((t=>{if(this.transferables)for(let e=0;e<t.length;e++){const s=t[e]&&t[e].image.array;if(s){let e;e=s instanceof ImageBitmap?s:s.buffer,e&&this.transferables.indexOf(e)<0&&this.transferables.push(e);}}if(!Array.isArray(e)){const s={},r=Object.keys(e);for(let e=0;e<t.length;e++)t[e]&&(s[r[e]]=t[e]);return s}return t}))}_loadPrimitive(e,t){let s;const r=[],n=e.extensions;if(b(e.targets))for(let t=0;t<e.targets.length;t++){const s=e.targets[t];for(const e in s){const n=this.adapter.accessor._requestData(`morphTargets_${e}_${t}`,s[e]);n&&r.push(n);}}if(n&&n.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const e=this.options.decoders.draco,{bufferView:i,attributes:a}=n.KHR_draco_mesh_compression,o=this.gltf.bufferViews[i],f=this._accessor._requestBufferOfBufferView(o).then((s=>{const{buffer:r,byteOffset:n}=s;let{byteOffset:i}=o;const f=o.byteLength;i||(i=0);const u=new DataView(r,n+i,f),h={attributes:a,useUniqueIDs:!1,skipAttributeTransform:t.skipAttributeTransform};return e(u,h).then((e=>{const t=Object.values(e.attributes);return e.indices&&t.push(e.indices),t}))}));r.push(f),s=Promise.all(r);}else {const t=e.attributes;for(const e in t){const s=this.adapter.accessor._requestData(e,t[e]);s&&r.push(s);}if(b(e.indices)){const t=this.adapter.accessor._requestData("indices",e.indices);t&&r.push(t);}s=Promise.all(r);}return s.then((t=>{if(n&&n.KHR_draco_mesh_compression){const s=e.targets?e.targets.length:0;t[s]=t[s].concat(t.slice(0,s)),t=t[s];}let s,r;const i={attributes:t.reduce(((e,t)=>{if("indices"===t.name)s=t;else if(t.name.indexOf("morphTargets_")>-1)r=r||{},r[t.name.slice(13)]=t;else {if(!("POSITION"!==t.name||t.min&&t.max)){const e=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0],{itemSize:r,array:n}=t,i=n.length/r;for(let t=0;t<i;t++)for(let i=0;i<r;i++){const a=t*r+i;n[a]<e[i]&&(e[i]=n[a]),n[a]>s[i]&&(s[i]=n[a]);}if(t.quantization){const r=t.quantization,n=r.range/(1<<r.quantizationBits),i=r.minValues;u(e,e,n),f(e,e,i),u(s,s,n),f(s,s,i);}t.min=e,t.max=s;}e[t.name]=t;}return this.transferables&&t.array.buffer&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),e}),{}),material:e.material};return s&&(i.indices=s),r&&(i.morphTargets=r),i.mode=b(e.mode)?e.mode:4,b(e.extras)&&(i.extras=e.extras),i}))}},t().maptalks_gltf_loader=e;}gltfLoaderExport({});
89
89
 
90
90
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
91
91
 
@@ -19145,7 +19145,7 @@
19145
19145
  function buildTangents(positions, normals, uvs, indices, out) {
19146
19146
  const nVertices = positions.length / 3;
19147
19147
 
19148
- const tangents = new Array(4 * nVertices);
19148
+ const tangents = out || new Array(4 * nVertices);
19149
19149
 
19150
19150
  const tan1 = [], tan2 = [];
19151
19151
 
@@ -19343,7 +19343,7 @@
19343
19343
  var t = /*@__PURE__*/getDefaultExportFromCjs(fastDeepEqual);
19344
19344
 
19345
19345
  /*!
19346
- * @maptalks/fusiongl v0.116.0
19346
+ * @maptalks/fusiongl v0.117.0
19347
19347
  * LICENSE : UNLICENSED
19348
19348
  * (c) 2016-2025 maptalks.com
19349
19349
  */
@@ -19404,11 +19404,7 @@
19404
19404
  return Array.isArray(e) && Array || e instanceof Uint8Array && Uint8Array || e instanceof Int8Array && Int8Array || e instanceof Uint16Array && Uint16Array || e instanceof Int16Array && Int16Array || e instanceof Uint32Array && Uint32Array || e instanceof Int32Array && Int32Array || e instanceof Uint8ClampedArray && Uint8ClampedArray || e instanceof Float32Array && Float32Array || e instanceof Float64Array && Float64Array;
19405
19405
  }
19406
19406
 
19407
- function N(e) {
19408
- return (e = Math.abs(e)) < 128 ? Int8Array : e < 32768 ? Int16Array : Float32Array;
19409
- }
19410
-
19411
- function D(e, t, n) {
19407
+ function N(e, t, n) {
19412
19408
  return Math.min(n, Math.max(t, e));
19413
19409
  }
19414
19410
 
@@ -19416,11 +19412,11 @@
19416
19412
  return !globalThis.MAPTALKS_DISABLE_VAO && (!e.wgpu && (e && e.hasExtension && e.hasExtension("oes_vertex_array_object")));
19417
19413
  }
19418
19414
 
19419
- function U(e, t) {
19415
+ function D(e, t) {
19420
19416
  return Object.prototype.hasOwnProperty.call(e, t);
19421
19417
  }
19422
19418
 
19423
- function B(e) {
19419
+ function U(e) {
19424
19420
  if (e.data) {
19425
19421
  if (e.data.BYTES_PER_ELEMENT) return e.data.length * e.data.BYTES_PER_ELEMENT;
19426
19422
  if (e.data.length) return 4 * e.data.length;
@@ -19435,11 +19431,11 @@
19435
19431
  return 0;
19436
19432
  }
19437
19433
 
19438
- function z(e) {
19439
- return e.width * e.height * V(e.format) * G(e.type) * ("textureCube" === e._reglType ? 6 : 1);
19434
+ function B(e) {
19435
+ return e.width * e.height * V(e.format) * z(e.type) * ("textureCube" === e._reglType ? 6 : 1);
19440
19436
  }
19441
19437
 
19442
- function G(e) {
19438
+ function z(e) {
19443
19439
  return "uint8" === e ? 1 : "uint16" === e || "float16" === e || "half float" === e ? 2 : "uint32" === e || "float" === e || "float32" === e ? 4 : 0;
19444
19440
  }
19445
19441
 
@@ -19447,17 +19443,17 @@
19447
19443
  return "depth" === e || "alpha" === e || "luminance" === e ? 1 : "luminance alpha" === e || "depth stencil" === e ? 2 : "srgba" === e || "rgb5 a1" === e || "rgba" === e.substring(0, 4) ? 4 : "srgb" === e || "rgb" === e.substring(0, 3) ? 3 : 1;
19448
19444
  }
19449
19445
 
19450
- function j(e) {
19446
+ function G(e) {
19451
19447
  if (!e.componentType) return !1;
19452
19448
  const t = A().GLTFLoader.getTypedArrayCtor(e.componentType);
19453
19449
  return e.byteStride > 0 && e.byteStride !== e.itemSize * t.BYTES_PER_ELEMENT;
19454
19450
  }
19455
19451
 
19456
- function W(e) {
19457
- return e && (e.stride > 0 || j(e));
19452
+ function j(e) {
19453
+ return e && (e.stride > 0 || G(e));
19458
19454
  }
19459
19455
 
19460
- function q(e) {
19456
+ function W(e) {
19461
19457
  const t = e.getExtension && e, n = !t && e, r = "WEBGL_compressed_texture_", i = "texture-compression-", o = {
19462
19458
  "etc": t ? !!t.getExtension(r + "etc") : !!n.features.has(i + "etc2"),
19463
19459
  "etc1": t ? !!t.getExtension(r + "etc1") : !!n.features.has(i + "etc2"),
@@ -19470,7 +19466,7 @@
19470
19466
  o[r + "astc"] = o.astc, o[r + "bc7"] = o.bc7, o;
19471
19467
  }
19472
19468
 
19473
- function X(e) {
19469
+ function q(e) {
19474
19470
  let t = 0;
19475
19471
  const n = e && e.length || 0;
19476
19472
  if (!n) return t;
@@ -19479,18 +19475,18 @@
19479
19475
  return t;
19480
19476
  }
19481
19477
 
19482
- function $(e) {
19478
+ function X(e) {
19483
19479
  return !(e & e - 1) && 0 !== e;
19484
19480
  }
19485
19481
 
19486
- function K(e) {
19482
+ function $(e) {
19487
19483
  return Math.pow(2, Math.floor(Math.log(e) / Math.LN2));
19488
19484
  }
19489
19485
 
19490
- function Y(e, t, n) {
19491
- if (H(e)) return $(t) && $(n) ? e : function(e, t, n) {
19486
+ function K(e, t, n) {
19487
+ if (H(e)) return X(t) && X(n) ? e : function(e, t, n) {
19492
19488
  let r = t, i = n;
19493
- $(t) || (r = K(t)), $(n) || (i = K(n));
19489
+ X(t) || (r = $(t)), X(n) || (i = $(n));
19494
19490
  const o = new ImageData(new Uint8ClampedArray(e), t, n), s = document.createElement("canvas");
19495
19491
  s.width = t, s.height = n, s.getContext("2d").putImageData(o, 0, 0);
19496
19492
  const a = document.createElement("canvas");
@@ -19501,8 +19497,8 @@
19501
19497
  document.body.appendChild(l)), l.width = r, l.height = i, l.getContext("2d").drawImage(a, 0, 0),
19502
19498
  a;
19503
19499
  }(e, t, n);
19504
- if ($(e.width) && $(e.height)) return e;
19505
- t = e.width, n = e.height, $(t) || (t = K(t)), $(n) || (n = K(n));
19500
+ if (X(e.width) && X(e.height)) return e;
19501
+ t = e.width, n = e.height, X(t) || (t = $(t)), X(n) || (n = $(n));
19506
19502
  const r = document.createElement("canvas");
19507
19503
  r.width = t, r.height = n, r.getContext("2d").drawImage(e, 0, 0, t, n);
19508
19504
  const i = e.src, o = i.lastIndexOf("/") + 1, s = i.substring(o);
@@ -19510,33 +19506,35 @@
19510
19506
  r;
19511
19507
  }
19512
19508
 
19513
- function Z(e) {
19509
+ function Y(e) {
19514
19510
  return !!e.wgpu || (!e._gl || e._gl instanceof WebGL2RenderingContext);
19515
19511
  }
19516
19512
 
19517
- var J = Object.freeze({
19513
+ var Z = Object.freeze({
19518
19514
  __proto__: null,
19519
- clamp: D,
19515
+ clamp: N,
19520
19516
  defined: O,
19521
19517
  extend: E,
19522
19518
  extendWithoutNil: P,
19523
19519
  getArrayCtor: L,
19524
- getBufferSize: B,
19525
- getPosArrayType: N,
19526
- getSupportedFormats: q,
19527
- getTexMemorySize: z,
19528
- getTextureByteWidth: G,
19520
+ getBufferSize: U,
19521
+ getPosArrayType: function(e) {
19522
+ return (e = Math.abs(e)) < 128 ? Int8Array : e < 32768 ? Int16Array : Float32Array;
19523
+ },
19524
+ getSupportedFormats: W,
19525
+ getTexMemorySize: B,
19526
+ getTextureByteWidth: z,
19529
19527
  getTextureChannels: V,
19530
- hasOwn: U,
19531
- hashCode: X,
19528
+ hasOwn: D,
19529
+ hashCode: q,
19532
19530
  interpolate: R,
19533
19531
  isArray: H,
19534
19532
  isFunction: k,
19535
- isInStride: j,
19536
- isInterleaved: W,
19533
+ isInStride: G,
19534
+ isInterleaved: j,
19537
19535
  isNil: C,
19538
19536
  isNumber: I,
19539
- isPowerOfTwo: $,
19537
+ isPowerOfTwo: X,
19540
19538
  isString: M,
19541
19539
  isSupportVAO: F,
19542
19540
  isTextureDestroyed: function(e) {
@@ -19555,15 +19553,15 @@
19555
19553
  for (let r = 0, i = t.length; r < i; r++) e[r] = t[r] / n;
19556
19554
  return e;
19557
19555
  },
19558
- resizeToPowerOfTwo: Y,
19556
+ resizeToPowerOfTwo: K,
19559
19557
  set: function(e, t) {
19560
19558
  for (let n = 0; n < e.length; n++) e[n] = t[n];
19561
19559
  return e;
19562
19560
  },
19563
- supportNPOT: Z
19561
+ supportNPOT: Y
19564
19562
  });
19565
19563
 
19566
- function Q(e) {
19564
+ function J(e) {
19567
19565
  return class extends e {
19568
19566
  on(e, t) {
19569
19567
  return this._events || (this._events = {
@@ -19594,25 +19592,25 @@
19594
19592
  };
19595
19593
  }
19596
19594
 
19597
- const ee = "__reshader_disposed", te = "not implemented";
19595
+ const Q = "__reshader_disposed", ee = "not implemented";
19598
19596
 
19599
- var ne = Object.freeze({
19597
+ var te = Object.freeze({
19600
19598
  __proto__: null,
19601
- ERROR_NOT_IMPLEMENTED: te,
19602
- KEY_DISPOSED: ee,
19599
+ ERROR_NOT_IMPLEMENTED: ee,
19600
+ KEY_DISPOSED: Q,
19603
19601
  WEBGL_EXTENSIONS: [ "ANGLE_instanced_arrays", "OES_element_index_uint", "OES_standard_derivatives" ],
19604
19602
  WEBGL_OPTIONAL_EXTENSIONS: [ "OES_vertex_array_object", "OES_texture_half_float", "OES_texture_half_float_linear", "OES_texture_float", "OES_texture_float_linear", "WEBGL_depth_texture", "EXT_shader_texture_lod", "EXT_texture_filter_anisotropic" ]
19605
19603
  });
19606
19604
 
19607
- const re = "_reshader_refCount";
19605
+ const ne = "_reshader_refCount";
19608
19606
 
19609
- let ie = class {};
19607
+ let re = class {};
19610
19608
 
19611
- class oe extends(Q(ie)){
19609
+ class ie extends(J(re)){
19612
19610
  constructor(e, t) {
19613
19611
  if (super(), k(e)) {
19614
19612
  this._texture = e, e = this.config = {};
19615
- for (const t in this._texture) U(this._texture, t) && (k(this._texture[t]) || (e[t] = this._texture[t]));
19613
+ for (const t in this._texture) D(this._texture, t) && (k(this._texture[t]) || (e[t] = this._texture[t]));
19616
19614
  } else if (this.config = e || {}, this.resLoader = t, (e.url || e.promise) && !e.data) {
19617
19615
  this._loading = !0;
19618
19616
  const n = this;
@@ -19654,16 +19652,16 @@
19654
19652
  getMemorySize() {
19655
19653
  if (!this.config) return 0;
19656
19654
  const {width: e, height: t, type: n, format: r} = this.config;
19657
- return e * t * G(n || "uint8") * V(r || "rgba");
19655
+ return e * t * z(n || "uint8") * V(r || "rgba");
19658
19656
  }
19659
19657
  _update() {
19660
- throw new Error(te);
19658
+ throw new Error(ee);
19661
19659
  }
19662
19660
  dispose() {
19663
19661
  this.config && this.config.url && (URL.revokeObjectURL(this.config.url), this.resLoader.disposeRes(this.config.url)),
19664
19662
  this.config && this.config.data instanceof ImageBitmap && (this.config.data.close(),
19665
- this.config.data = []), this._texture && !this._texture[ee] && (this._texture[re] && this._texture[re]--,
19666
- this._texture[re] || (this._texture.destroy(), this._texture[ee] = !0, delete this._texture)),
19663
+ this.config.data = []), this._texture && !this._texture[Q] && (this._texture[ne] && this._texture[ne]--,
19664
+ this._texture[ne] || (this._texture.destroy(), this._texture[Q] = !0, delete this._texture)),
19667
19665
  delete this.resLoader, delete this._regl;
19668
19666
  const e = this.config && this.config.url;
19669
19667
  delete this.config, e && this.fire("disposed", {
@@ -19673,9 +19671,9 @@
19673
19671
  }
19674
19672
  }
19675
19673
 
19676
- const se = identity$2([]), ae = identity$2([]);
19674
+ const oe = identity$2([]), se = identity$2([]);
19677
19675
 
19678
- class le {
19676
+ class ae {
19679
19677
  constructor(e, t) {
19680
19678
  this.min = e || [ 1 / 0, 1 / 0, 1 / 0 ], this.max = t || [ -1 / 0, -1 / 0, -1 / 0 ],
19681
19679
  this.updateVertex();
@@ -19725,7 +19723,7 @@
19725
19723
  this.vertex;
19726
19724
  }
19727
19725
  copy(e) {
19728
- return e ? le.copy(e, this) : new le(this.min.slice(), this.max.slice());
19726
+ return e ? ae.copy(e, this) : new ae(this.min.slice(), this.max.slice());
19729
19727
  }
19730
19728
  equals(e) {
19731
19729
  if (!equals$4(this.min, e.min) || !equals$4(this.max, e.max)) return !1;
@@ -19734,33 +19732,33 @@
19734
19732
  return !0;
19735
19733
  }
19736
19734
  transform(e, t) {
19737
- if (e = e || ae, (t = t || ae)[1] || t[2] || t[4] || t[6] || t[8] || t[9]) {
19738
- const n = this.vertex, r = multiply$5(se, t, e);
19735
+ if (e = e || se, (t = t || se)[1] || t[2] || t[4] || t[6] || t[8] || t[9]) {
19736
+ const n = this.vertex, r = multiply$5(oe, t, e);
19739
19737
  for (let e = 0; e < n.length; e++) transformMat4$2(this.vertex[e], this.vertex[e], r);
19740
19738
  const i = this.vertex.map((e => e[0])), o = this.vertex.map((e => e[1])), s = this.vertex.map((e => e[2])), a = Math.min(...i), l = Math.max(...i), u = Math.min(...o), f = Math.max(...o), d = Math.min(...s), m = Math.max(...s);
19741
19739
  set$5(this.min, a, u, d), set$5(this.max, l, f, m);
19742
19740
  } else {
19743
- const n = multiply$5(se, t, e);
19741
+ const n = multiply$5(oe, t, e);
19744
19742
  transformMat4$2(this.min, this.min, n), transformMat4$2(this.max, this.max, n);
19745
19743
  }
19746
19744
  return this;
19747
19745
  }
19748
19746
  }
19749
19747
 
19750
- function ce(e, t, n = 2) {
19748
+ function le(e, t, n = 2) {
19751
19749
  const r = t && t.length, i = r ? t[0] * n : e.length;
19752
- let o = he(e, 0, i, n, !0);
19750
+ let o = ce(e, 0, i, n, !0);
19753
19751
  const s = [];
19754
19752
  if (!o || o.next === o.prev) return s;
19755
19753
  let a, l, c;
19756
19754
  if (r && (o = function(e, t, n, r) {
19757
19755
  const i = [];
19758
19756
  for (let n = 0, o = t.length; n < o; n++) {
19759
- const s = he(e, t[n] * r, n < o - 1 ? t[n + 1] * r : e.length, r, !1);
19760
- s === s.next && (s.steiner = !0), i.push(ye(s));
19757
+ const s = ce(e, t[n] * r, n < o - 1 ? t[n + 1] * r : e.length, r, !1);
19758
+ s === s.next && (s.steiner = !0), i.push(be(s));
19761
19759
  }
19762
- i.sort(_e);
19763
- for (let e = 0; e < i.length; e++) n = ve(i[e], n);
19760
+ i.sort(pe);
19761
+ for (let e = 0; e < i.length; e++) n = _e(i[e], n);
19764
19762
  return n;
19765
19763
  }(e, t, o, n)), e.length > 80 * n) {
19766
19764
  a = 1 / 0, l = 1 / 0;
@@ -19771,39 +19769,39 @@
19771
19769
  }
19772
19770
  c = Math.max(t - a, r - l), c = 0 !== c ? 32767 / c : 0;
19773
19771
  }
19774
- return fe(o, s, n, a, l, c, 0), s;
19772
+ return ue(o, s, n, a, l, c, 0), s;
19775
19773
  }
19776
19774
 
19777
- function he(e, t, n, r, i) {
19775
+ function ce(e, t, n, r, i) {
19778
19776
  let o;
19779
19777
  if (i === function(e, t, n, r) {
19780
19778
  let i = 0;
19781
19779
  for (let o = t, s = n - r; o < n; o += r) i += (e[s] - e[o]) * (e[o + 1] + e[s + 1]),
19782
19780
  s = o;
19783
19781
  return i;
19784
- }(e, t, n, r) > 0) for (let i = t; i < n; i += r) o = Ie(i / r | 0, e[i], e[i + 1], o); else for (let i = n - r; i >= t; i -= r) o = Ie(i / r | 0, e[i], e[i + 1], o);
19785
- return o && Me(o, o.next) && (Re(o), o = o.next), o;
19782
+ }(e, t, n, r) > 0) for (let i = t; i < n; i += r) o = Pe(i / r | 0, e[i], e[i + 1], o); else for (let i = n - r; i >= t; i -= r) o = Pe(i / r | 0, e[i], e[i + 1], o);
19783
+ return o && Ae(o, o.next) && (Ie(o), o = o.next), o;
19786
19784
  }
19787
19785
 
19788
- function ue(e, t) {
19786
+ function he(e, t) {
19789
19787
  if (!e) return e;
19790
19788
  t || (t = e);
19791
19789
  let n, r = e;
19792
19790
  do {
19793
- if (n = !1, r.steiner || !Me(r, r.next) && 0 !== Ae(r.prev, r, r.next)) r = r.next; else {
19794
- if (Re(r), r = t = r.prev, r === r.next) break;
19791
+ if (n = !1, r.steiner || !Ae(r, r.next) && 0 !== we(r.prev, r, r.next)) r = r.next; else {
19792
+ if (Ie(r), r = t = r.prev, r === r.next) break;
19795
19793
  n = !0;
19796
19794
  }
19797
19795
  } while (n || r !== t);
19798
19796
  return t;
19799
19797
  }
19800
19798
 
19801
- function fe(e, t, n, r, i, o, s) {
19799
+ function ue(e, t, n, r, i, o, s) {
19802
19800
  if (!e) return;
19803
19801
  !s && o && function(e, t, n, r) {
19804
19802
  let i = e;
19805
19803
  do {
19806
- 0 === i.z && (i.z = be(i.x, i.y, t, n, r)), i.prevZ = i.prev, i.nextZ = i.next,
19804
+ 0 === i.z && (i.z = xe(i.x, i.y, t, n, r)), i.prevZ = i.prev, i.nextZ = i.next,
19807
19805
  i = i.next;
19808
19806
  } while (i !== e);
19809
19807
  i.prevZ.nextZ = null, i.prevZ = null, function(e) {
@@ -19829,64 +19827,64 @@
19829
19827
  let a = e;
19830
19828
  for (;e.prev !== e.next; ) {
19831
19829
  const l = e.prev, c = e.next;
19832
- if (o ? me(e, r, i, o) : de(e)) t.push(l.i, e.i, c.i), Re(e), e = c.next, a = c.next; else if ((e = c) === a) {
19833
- s ? 1 === s ? fe(e = ge(ue(e), t), t, n, r, i, o, 2) : 2 === s && pe(e, t, n, r, i, o) : fe(ue(e), t, n, r, i, o, 1);
19830
+ if (o ? de(e, r, i, o) : fe(e)) t.push(l.i, e.i, c.i), Ie(e), e = c.next, a = c.next; else if ((e = c) === a) {
19831
+ s ? 1 === s ? ue(e = me(he(e), t), t, n, r, i, o, 2) : 2 === s && ge(e, t, n, r, i, o) : ue(he(e), t, n, r, i, o, 1);
19834
19832
  break;
19835
19833
  }
19836
19834
  }
19837
19835
  }
19838
19836
 
19839
- function de(e) {
19837
+ function fe(e) {
19840
19838
  const t = e.prev, n = e, r = e.next;
19841
- if (Ae(t, n, r) >= 0) return !1;
19839
+ if (we(t, n, r) >= 0) return !1;
19842
19840
  const i = t.x, o = n.x, s = r.x, a = t.y, l = n.y, c = r.y, h = Math.min(i, o, s), u = Math.min(a, l, c), f = Math.max(i, o, s), d = Math.max(a, l, c);
19843
19841
  let m = r.next;
19844
19842
  for (;m !== t; ) {
19845
- if (m.x >= h && m.x <= f && m.y >= u && m.y <= d && Te(i, a, o, l, s, c, m.x, m.y) && Ae(m.prev, m, m.next) >= 0) return !1;
19843
+ if (m.x >= h && m.x <= f && m.y >= u && m.y <= d && Se(i, a, o, l, s, c, m.x, m.y) && we(m.prev, m, m.next) >= 0) return !1;
19846
19844
  m = m.next;
19847
19845
  }
19848
19846
  return !0;
19849
19847
  }
19850
19848
 
19851
- function me(e, t, n, r) {
19849
+ function de(e, t, n, r) {
19852
19850
  const i = e.prev, o = e, s = e.next;
19853
- if (Ae(i, o, s) >= 0) return !1;
19854
- const a = i.x, l = o.x, c = s.x, h = i.y, u = o.y, f = s.y, d = Math.min(a, l, c), m = Math.min(h, u, f), g = Math.max(a, l, c), p = Math.max(h, u, f), _ = be(d, m, t, n, r), v = be(g, p, t, n, r);
19851
+ if (we(i, o, s) >= 0) return !1;
19852
+ const a = i.x, l = o.x, c = s.x, h = i.y, u = o.y, f = s.y, d = Math.min(a, l, c), m = Math.min(h, u, f), g = Math.max(a, l, c), p = Math.max(h, u, f), _ = xe(d, m, t, n, r), v = xe(g, p, t, n, r);
19855
19853
  let x = e.prevZ, b = e.nextZ;
19856
19854
  for (;x && x.z >= _ && b && b.z <= v; ) {
19857
- if (x.x >= d && x.x <= g && x.y >= m && x.y <= p && x !== i && x !== s && Te(a, h, l, u, c, f, x.x, x.y) && Ae(x.prev, x, x.next) >= 0) return !1;
19858
- if (x = x.prevZ, b.x >= d && b.x <= g && b.y >= m && b.y <= p && b !== i && b !== s && Te(a, h, l, u, c, f, b.x, b.y) && Ae(b.prev, b, b.next) >= 0) return !1;
19855
+ if (x.x >= d && x.x <= g && x.y >= m && x.y <= p && x !== i && x !== s && Se(a, h, l, u, c, f, x.x, x.y) && we(x.prev, x, x.next) >= 0) return !1;
19856
+ if (x = x.prevZ, b.x >= d && b.x <= g && b.y >= m && b.y <= p && b !== i && b !== s && Se(a, h, l, u, c, f, b.x, b.y) && we(b.prev, b, b.next) >= 0) return !1;
19859
19857
  b = b.nextZ;
19860
19858
  }
19861
19859
  for (;x && x.z >= _; ) {
19862
- if (x.x >= d && x.x <= g && x.y >= m && x.y <= p && x !== i && x !== s && Te(a, h, l, u, c, f, x.x, x.y) && Ae(x.prev, x, x.next) >= 0) return !1;
19860
+ if (x.x >= d && x.x <= g && x.y >= m && x.y <= p && x !== i && x !== s && Se(a, h, l, u, c, f, x.x, x.y) && we(x.prev, x, x.next) >= 0) return !1;
19863
19861
  x = x.prevZ;
19864
19862
  }
19865
19863
  for (;b && b.z <= v; ) {
19866
- if (b.x >= d && b.x <= g && b.y >= m && b.y <= p && b !== i && b !== s && Te(a, h, l, u, c, f, b.x, b.y) && Ae(b.prev, b, b.next) >= 0) return !1;
19864
+ if (b.x >= d && b.x <= g && b.y >= m && b.y <= p && b !== i && b !== s && Se(a, h, l, u, c, f, b.x, b.y) && we(b.prev, b, b.next) >= 0) return !1;
19867
19865
  b = b.nextZ;
19868
19866
  }
19869
19867
  return !0;
19870
19868
  }
19871
19869
 
19872
- function ge(e, t) {
19870
+ function me(e, t) {
19873
19871
  let n = e;
19874
19872
  do {
19875
19873
  const r = n.prev, i = n.next.next;
19876
- !Me(r, i) && Ce(r, n, n.next, i) && Ee(r, i) && Ee(i, r) && (t.push(r.i, n.i, i.i),
19877
- Re(n), Re(n.next), n = e = i), n = n.next;
19874
+ !Ae(r, i) && Me(r, n, n.next, i) && ke(r, i) && ke(i, r) && (t.push(r.i, n.i, i.i),
19875
+ Ie(n), Ie(n.next), n = e = i), n = n.next;
19878
19876
  } while (n !== e);
19879
- return ue(n);
19877
+ return he(n);
19880
19878
  }
19881
19879
 
19882
- function pe(e, t, n, r, i, o) {
19880
+ function ge(e, t, n, r, i, o) {
19883
19881
  let s = e;
19884
19882
  do {
19885
19883
  let e = s.next.next;
19886
19884
  for (;e !== s.prev; ) {
19887
- if (s.i !== e.i && we(s, e)) {
19888
- let a = Pe(s, e);
19889
- return s = ue(s, s.next), a = ue(a, a.next), fe(s, t, n, r, i, o, 0), void fe(a, t, n, r, i, o, 0);
19885
+ if (s.i !== e.i && Te(s, e)) {
19886
+ let a = Ee(s, e);
19887
+ return s = he(s, s.next), a = he(a, a.next), ue(s, t, n, r, i, o, 0), void ue(a, t, n, r, i, o, 0);
19890
19888
  }
19891
19889
  e = e.next;
19892
19890
  }
@@ -19894,7 +19892,7 @@
19894
19892
  } while (s !== e);
19895
19893
  }
19896
19894
 
19897
- function _e(e, t) {
19895
+ function pe(e, t) {
19898
19896
  let n = e.x - t.x;
19899
19897
  if (0 === n && (n = e.y - t.y, 0 === n)) {
19900
19898
  n = (e.next.y - e.y) / (e.next.x - e.x) - (t.next.y - t.y) / (t.next.x - t.x);
@@ -19902,14 +19900,14 @@
19902
19900
  return n;
19903
19901
  }
19904
19902
 
19905
- function ve(e, t) {
19903
+ function _e(e, t) {
19906
19904
  const n = function(e, t) {
19907
19905
  let n = t;
19908
19906
  const r = e.x, i = e.y;
19909
19907
  let o, s = -1 / 0;
19910
- if (Me(e, n)) return n;
19908
+ if (Ae(e, n)) return n;
19911
19909
  do {
19912
- if (Me(e, n.next)) return n.next;
19910
+ if (Ae(e, n.next)) return n.next;
19913
19911
  if (i <= n.y && i >= n.next.y && n.next.y !== n.y) {
19914
19912
  const e = n.x + (i - n.y) * (n.next.x - n.x) / (n.next.y - n.y);
19915
19913
  if (e <= r && e > s && (s = e, o = n.x < n.next.x ? n : n.next, e === r)) return o;
@@ -19921,9 +19919,9 @@
19921
19919
  let h = 1 / 0;
19922
19920
  n = o;
19923
19921
  do {
19924
- if (r >= n.x && n.x >= l && r !== n.x && Se(i < c ? r : s, i, l, c, i < c ? s : r, i, n.x, n.y)) {
19922
+ if (r >= n.x && n.x >= l && r !== n.x && ye(i < c ? r : s, i, l, c, i < c ? s : r, i, n.x, n.y)) {
19925
19923
  const t = Math.abs(i - n.y) / (r - n.x);
19926
- Ee(n, e) && (t < h || t === h && (n.x > o.x || n.x === o.x && xe(o, n))) && (o = n,
19924
+ ke(n, e) && (t < h || t === h && (n.x > o.x || n.x === o.x && ve(o, n))) && (o = n,
19927
19925
  h = t);
19928
19926
  }
19929
19927
  n = n.next;
@@ -19931,19 +19929,19 @@
19931
19929
  return o;
19932
19930
  }(e, t);
19933
19931
  if (!n) return t;
19934
- const r = Pe(n, e);
19935
- return ue(r, r.next), ue(n, n.next);
19932
+ const r = Ee(n, e);
19933
+ return he(r, r.next), he(n, n.next);
19936
19934
  }
19937
19935
 
19938
- function xe(e, t) {
19939
- return Ae(e.prev, e, t.prev) < 0 && Ae(t.next, e, e.next) < 0;
19936
+ function ve(e, t) {
19937
+ return we(e.prev, e, t.prev) < 0 && we(t.next, e, e.next) < 0;
19940
19938
  }
19941
19939
 
19942
- function be(e, t, n, r, i) {
19940
+ function xe(e, t, n, r, i) {
19943
19941
  return (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e = (e - n) * i | 0) | e << 8)) | e << 4)) | e << 2)) | e << 1)) | (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t = (t - r) * i | 0) | t << 8)) | t << 4)) | t << 2)) | t << 1)) << 1;
19944
19942
  }
19945
19943
 
19946
- function ye(e) {
19944
+ function be(e) {
19947
19945
  let t = e, n = e;
19948
19946
  do {
19949
19947
  (t.x < n.x || t.x === n.x && t.y < n.y) && (n = t), t = t.next;
@@ -19951,23 +19949,23 @@
19951
19949
  return n;
19952
19950
  }
19953
19951
 
19954
- function Se(e, t, n, r, i, o, s, a) {
19952
+ function ye(e, t, n, r, i, o, s, a) {
19955
19953
  return (i - s) * (t - a) >= (e - s) * (o - a) && (e - s) * (r - a) >= (n - s) * (t - a) && (n - s) * (o - a) >= (i - s) * (r - a);
19956
19954
  }
19957
19955
 
19958
- function Te(e, t, n, r, i, o, s, a) {
19959
- return !(e === s && t === a) && Se(e, t, n, r, i, o, s, a);
19956
+ function Se(e, t, n, r, i, o, s, a) {
19957
+ return !(e === s && t === a) && ye(e, t, n, r, i, o, s, a);
19960
19958
  }
19961
19959
 
19962
- function we(e, t) {
19960
+ function Te(e, t) {
19963
19961
  return e.next.i !== t.i && e.prev.i !== t.i && !function(e, t) {
19964
19962
  let n = e;
19965
19963
  do {
19966
- if (n.i !== e.i && n.next.i !== e.i && n.i !== t.i && n.next.i !== t.i && Ce(n, n.next, e, t)) return !0;
19964
+ if (n.i !== e.i && n.next.i !== e.i && n.i !== t.i && n.next.i !== t.i && Me(n, n.next, e, t)) return !0;
19967
19965
  n = n.next;
19968
19966
  } while (n !== e);
19969
19967
  return !1;
19970
- }(e, t) && (Ee(e, t) && Ee(t, e) && function(e, t) {
19968
+ }(e, t) && (ke(e, t) && ke(t, e) && function(e, t) {
19971
19969
  let n = e, r = !1;
19972
19970
  const i = (e.x + t.x) / 2, o = (e.y + t.y) / 2;
19973
19971
  do {
@@ -19975,52 +19973,52 @@
19975
19973
  n = n.next;
19976
19974
  } while (n !== e);
19977
19975
  return r;
19978
- }(e, t) && (Ae(e.prev, e, t.prev) || Ae(e, t.prev, t)) || Me(e, t) && Ae(e.prev, e, e.next) > 0 && Ae(t.prev, t, t.next) > 0);
19976
+ }(e, t) && (we(e.prev, e, t.prev) || we(e, t.prev, t)) || Ae(e, t) && we(e.prev, e, e.next) > 0 && we(t.prev, t, t.next) > 0);
19979
19977
  }
19980
19978
 
19981
- function Ae(e, t, n) {
19979
+ function we(e, t, n) {
19982
19980
  return (t.y - e.y) * (n.x - t.x) - (t.x - e.x) * (n.y - t.y);
19983
19981
  }
19984
19982
 
19985
- function Me(e, t) {
19983
+ function Ae(e, t) {
19986
19984
  return e.x === t.x && e.y === t.y;
19987
19985
  }
19988
19986
 
19989
- function Ce(e, t, n, r) {
19990
- const i = ke(Ae(e, t, n)), o = ke(Ae(e, t, r)), s = ke(Ae(n, r, e)), a = ke(Ae(n, r, t));
19991
- return i !== o && s !== a || (!(0 !== i || !Oe(e, n, t)) || (!(0 !== o || !Oe(e, r, t)) || (!(0 !== s || !Oe(n, e, r)) || !(0 !== a || !Oe(n, t, r)))));
19987
+ function Me(e, t, n, r) {
19988
+ const i = Oe(we(e, t, n)), o = Oe(we(e, t, r)), s = Oe(we(n, r, e)), a = Oe(we(n, r, t));
19989
+ return i !== o && s !== a || (!(0 !== i || !Ce(e, n, t)) || (!(0 !== o || !Ce(e, r, t)) || (!(0 !== s || !Ce(n, e, r)) || !(0 !== a || !Ce(n, t, r)))));
19992
19990
  }
19993
19991
 
19994
- function Oe(e, t, n) {
19992
+ function Ce(e, t, n) {
19995
19993
  return t.x <= Math.max(e.x, n.x) && t.x >= Math.min(e.x, n.x) && t.y <= Math.max(e.y, n.y) && t.y >= Math.min(e.y, n.y);
19996
19994
  }
19997
19995
 
19998
- function ke(e) {
19996
+ function Oe(e) {
19999
19997
  return e > 0 ? 1 : e < 0 ? -1 : 0;
20000
19998
  }
20001
19999
 
20002
- function Ee(e, t) {
20003
- return Ae(e.prev, e, e.next) < 0 ? Ae(e, t, e.next) >= 0 && Ae(e, e.prev, t) >= 0 : Ae(e, t, e.prev) < 0 || Ae(e, e.next, t) < 0;
20000
+ function ke(e, t) {
20001
+ return we(e.prev, e, e.next) < 0 ? we(e, t, e.next) >= 0 && we(e, e.prev, t) >= 0 : we(e, t, e.prev) < 0 || we(e, e.next, t) < 0;
20004
20002
  }
20005
20003
 
20006
- function Pe(e, t) {
20007
- const n = He(e.i, e.x, e.y), r = He(t.i, t.x, t.y), i = e.next, o = t.prev;
20004
+ function Ee(e, t) {
20005
+ const n = Re(e.i, e.x, e.y), r = Re(t.i, t.x, t.y), i = e.next, o = t.prev;
20008
20006
  return e.next = t, t.prev = e, n.next = i, i.prev = n, r.next = n, n.prev = r, o.next = r,
20009
20007
  r.prev = o, r;
20010
20008
  }
20011
20009
 
20012
- function Ie(e, t, n, r) {
20013
- const i = He(e, t, n);
20010
+ function Pe(e, t, n, r) {
20011
+ const i = Re(e, t, n);
20014
20012
  return r ? (i.next = r.next, i.prev = r, r.next.prev = i, r.next = i) : (i.prev = i,
20015
20013
  i.next = i), i;
20016
20014
  }
20017
20015
 
20018
- function Re(e) {
20016
+ function Ie(e) {
20019
20017
  e.next.prev = e.prev, e.prev.next = e.next, e.prevZ && (e.prevZ.nextZ = e.nextZ),
20020
20018
  e.nextZ && (e.nextZ.prevZ = e.prevZ);
20021
20019
  }
20022
20020
 
20023
- function He(e, t, n) {
20021
+ function Re(e, t, n) {
20024
20022
  return {
20025
20023
  i: e,
20026
20024
  x: t,
@@ -20034,7 +20032,7 @@
20034
20032
  };
20035
20033
  }
20036
20034
 
20037
- function Le(e) {
20035
+ function He(e) {
20038
20036
  const t = [], n = [], r = e[0][0].length;
20039
20037
  let i = 0, o = 0;
20040
20038
  for (const s of e) {
@@ -20048,13 +20046,13 @@
20048
20046
  };
20049
20047
  }
20050
20048
 
20051
- function Ne(e) {
20049
+ function Le(e) {
20052
20050
  let t;
20053
20051
  return Array.isArray(e) || e instanceof Float32Array ? t = "float32" : e instanceof Uint32Array ? t = "uint32" : e instanceof Int32Array ? t = "sint32" : e instanceof Uint16Array ? t = "uint16" : e instanceof Int16Array ? t = "sint16" : e instanceof Uint8Array ? t = "uint8" : e instanceof Int8Array && (t = "sint8"),
20054
20052
  t;
20055
20053
  }
20056
20054
 
20057
- const De = {
20055
+ const Ne = {
20058
20056
  5120: {
20059
20057
  name: "sint8",
20060
20058
  bytes: 1
@@ -20086,11 +20084,11 @@
20086
20084
  };
20087
20085
 
20088
20086
  function Fe(e, t) {
20089
- const n = De[e].name;
20087
+ const n = Ne[e].name;
20090
20088
  return t > 1 ? n + "x" + t : n;
20091
20089
  }
20092
20090
 
20093
- const Ue = {
20091
+ const De = {
20094
20092
  mat2x3f: {
20095
20093
  pad: [ 3, 1 ]
20096
20094
  },
@@ -20117,11 +20115,11 @@
20117
20115
  }
20118
20116
  };
20119
20117
 
20120
- function Be(e, t) {
20118
+ function Ue(e, t) {
20121
20119
  return 0 === t ? e : Math.ceil(e / t) * t;
20122
20120
  }
20123
20121
 
20124
- const ze = [], Ge = {
20122
+ const Be = [], ze = {
20125
20123
  5120: "int8",
20126
20124
  5122: "int16",
20127
20125
  5124: "int32",
@@ -20137,7 +20135,7 @@
20137
20135
  5123: 2,
20138
20136
  5125: 4,
20139
20137
  5126: 4
20140
- }, je = {
20138
+ }, Ge = {
20141
20139
  "positionSize": 3,
20142
20140
  "primitive": "triangles",
20143
20141
  "positionAttribute": "aPosition",
@@ -20150,11 +20148,11 @@
20150
20148
  "textureCoordMatrixAttribute": "aTextureCoordMatrix"
20151
20149
  };
20152
20150
 
20153
- let We = 1;
20151
+ let je = 1;
20154
20152
 
20155
- const qe = "_reshader_refCount";
20153
+ const We = "_reshader_refCount";
20156
20154
 
20157
- class Xe {
20155
+ class qe {
20158
20156
  static createElementBuffer(e, t) {
20159
20157
  if (e.wgpu) {
20160
20158
  if (Array.isArray(t)) {
@@ -20170,18 +20168,31 @@
20170
20168
  static padGPUBufferAlignment(e, t) {
20171
20169
  const n = e.byteLength / t;
20172
20170
  if (n % 4 == 0) return e;
20173
- const r = e.constructor, i = e.length / t, o = tt(i, n / i), s = new r(o * t);
20174
- for (let n = 0; n < t; n++) for (let t = 0; t < i; t++) s[n * o + t] = e[n * i + t];
20175
- return s;
20171
+ const r = e.constructor, i = e.length / t;
20172
+ if (3 === i) {
20173
+ const o = tt(i, n / i), s = new r(o * t);
20174
+ for (let n = 0; n < t; n++) for (let t = 0; t < i; t++) s[n * o + t] = e[n * i + t];
20175
+ return s;
20176
+ }
20177
+ {
20178
+ const n = function(e, t) {
20179
+ if (e === Uint8Array || e === Uint8ClampedArray) return 1 === t ? Uint32Array : Uint16Array;
20180
+ if (e === Int8Array) return 1 === t ? Int32Array : Int16Array;
20181
+ if (e === Uint16Array) return Uint32Array;
20182
+ if (e === Int16Array) return Int32Array;
20183
+ throw new Error("sth unexpected in getPadArrayCtor");
20184
+ }(r, i), o = new n(i * t);
20185
+ return o.set(e), o;
20186
+ }
20176
20187
  }
20177
20188
  constructor(e, t, n, r) {
20178
- this._version = 0, this.data = e, this.elements = t, this.desc = E({}, je, r), this.semantic = function(e) {
20189
+ this._version = 0, this.data = e, this.elements = t, this.desc = E({}, Ge, r), this.semantic = function(e) {
20179
20190
  const t = {};
20180
- for (const n in je) n.endsWith("Attribute") && (t[e[n]] = je[n]);
20191
+ for (const n in Ge) n.endsWith("Attribute") && (t[e[n]] = Ge[n]);
20181
20192
  return t;
20182
20193
  }(this.desc);
20183
20194
  const i = this._getPosAttribute();
20184
- this.data[this.desc.positionAttribute] = i, n || (this.elements ? n = $e(this.elements) : i && i.length ? n = i.length / this.desc.positionSize : i && i.interleavedArray ? n = i.interleavedArray.length / this.desc.positionSize : i && i.array && (n = i.array.length / this.desc.positionSize)),
20195
+ this.data[this.desc.positionAttribute] = i, n || (this.elements ? n = Xe(this.elements) : i && i.length ? n = i.length / this.desc.positionSize : i && i.interleavedArray ? n = i.interleavedArray.length / this.desc.positionSize : i && i.array && (n = i.array.length / this.desc.positionSize)),
20185
20196
  this.count = n, this.elements || (this.elements = n), this._isIndexed = !I(this.elements),
20186
20197
  this.properties = {}, this._buffers = {}, this._vao = {}, this.getVertexCount(),
20187
20198
  this._prepareData(!0), this.updateBoundingBox();
@@ -20202,14 +20213,14 @@
20202
20213
  const r = this.data[n];
20203
20214
  if (r) if (r.buffer && r.buffer.destroy) {
20204
20215
  const t = r.buffer;
20205
- t[qe] || (t[qe] = 0), e && t[qe]++;
20206
- } else if (r && r.array) if (j(r)) {
20216
+ t[We] || (t[We] = 0), e && t[We]++;
20217
+ } else if (r && r.array) if (G(r)) {
20207
20218
  let e = r.array.buffer.__id;
20208
- e || (e = r.array.buffer.__id = We++), this.data[n] = {
20219
+ e || (e = r.array.buffer.__id = je++), this.data[n] = {
20209
20220
  buffer: e,
20210
20221
  offset: r.byteOffset,
20211
20222
  stride: r.byteStride,
20212
- type: Ge[r.componentType],
20223
+ type: ze[r.componentType],
20213
20224
  size: r.itemSize,
20214
20225
  count: r.count,
20215
20226
  componentType: r.componentType
@@ -20245,7 +20256,7 @@
20245
20256
  if (s && s.destroy) void 0 !== n[r].stride ? o.push(n[r]) : o.push(s); else {
20246
20257
  const e = n[r];
20247
20258
  if (!e) {
20248
- this.desc.fillEmptyDataInMissingAttribute ? o.push(new Uint8Array(4 * i)) : o.push(ze);
20259
+ this.desc.fillEmptyDataInMissingAttribute ? o.push(new Uint8Array(4 * i)) : o.push(Be);
20249
20260
  continue;
20250
20261
  }
20251
20262
  const t = (e.data && H(e.data) ? e.data.length : e.length) / i;
@@ -20283,19 +20294,19 @@
20283
20294
  }
20284
20295
  generateBuffers(e) {
20285
20296
  const t = !!e.wgpu, n = this._buffers;
20286
- for (const t in n) n[t].buffer || (n[t].buffer = Xe.createBuffer(e, n[t].data, t)),
20297
+ for (const t in n) n[t].buffer || (n[t].buffer = qe.createBuffer(e, n[t].data, t)),
20287
20298
  delete n[t].data;
20288
20299
  const r = this.desc.positionAttribute, i = this.desc.altitudeAttribute, o = this.data, s = this._vertexCount, a = {};
20289
20300
  for (const l in o) if (o[l]) {
20290
- if (Array.isArray(o[l]) ? o[l] = new Float32Array(o[l]) : t && H(o[l]) && (o[l] = Xe.padGPUBufferAlignment(o[l], s)),
20291
- void 0 === o[l].buffer || o[l].buffer instanceof ArrayBuffer) {
20292
- const t = (o[l].data ? o[l].data : o[l]).length / s, n = o[l].data ? o[l] : {
20293
- data: o[l]
20294
- };
20295
- n.dimension = t;
20296
- const c = Xe.createBuffer(e, n, l);
20297
- c[qe] = 1, a[l] = {
20298
- buffer: c
20301
+ if (Array.isArray(o[l]) && (o[l] = new Float32Array(o[l])), void 0 === o[l].buffer || o[l].buffer instanceof ArrayBuffer) {
20302
+ const n = o[l].data ? o[l].data : o[l], c = n.length / s;
20303
+ let h = n;
20304
+ t && (h = qe.padGPUBufferAlignment(n, s));
20305
+ const u = o[l].data ? o[l] : {};
20306
+ u.data = h, u.dimension = c;
20307
+ const f = qe.createBuffer(e, u, l);
20308
+ f[We] = 1, a[l] = {
20309
+ buffer: f
20299
20310
  }, l !== r && l !== i || (a[l].array = o[l]);
20300
20311
  } else o[l].buffer.destroy ? a[l] = o[l] : n[o[l].buffer] && (a[l] = E({}, o[l]),
20301
20312
  a[l].buffer = n[o[l].buffer].buffer);
@@ -20305,13 +20316,15 @@
20305
20316
  if (this.getPrimitive(), this.elements, this.getElementsType(this.elements), !this.desc.static && !this.elements.destroy) {
20306
20317
  const e = this.elements;
20307
20318
  let t;
20308
- t = Array.isArray(this.elements) ? et(this.elements) : this.elements.constructor,
20309
- this.indices = new t(e.length);
20310
- for (let t = 0; t < e.length; t++) this.indices[t] = e[t];
20319
+ if (t = Array.isArray(this.elements) ? et(this.elements) : this.elements.constructor,
20320
+ e instanceof t) this.indices = new t(e); else {
20321
+ this.indices = new t(e.length);
20322
+ for (let t = 0; t < e.length; t++) this.indices[t] = e[t];
20323
+ }
20311
20324
  }
20312
- this.elements = this.elements.destroy ? this.elements : Xe.createElementBuffer(e, this.elements);
20325
+ this.elements = this.elements.destroy ? this.elements : qe.createElementBuffer(e, this.elements);
20313
20326
  const t = this.elements;
20314
- t[qe] || (t[qe] = 0), t[qe]++;
20327
+ t[We] || (t[We] = 0), t[We]++;
20315
20328
  }
20316
20329
  }
20317
20330
  getVertexCount() {
@@ -20339,34 +20352,35 @@
20339
20352
  let r;
20340
20353
  return this._incrVersion(), this.data[e] = t, n.buffer && n.buffer.destroy && (r = n),
20341
20354
  e === this.desc.positionAttribute && this.updateBoundingBox(), this.getVertexCount(),
20342
- r && (r.buffer.mapState ? r.buffer = this._updateGPUBuffer(r.buffer, t) : r.buffer(t),
20355
+ r && (r.buffer.mapState ? (t = qe.padGPUBufferAlignment(t, this._vertexCount), r.buffer = this._updateGPUBuffer(r.buffer, t, 0, t.buffer.byteLength)) : r.buffer(t),
20343
20356
  this.data[e] = r), this._prepareData(!1), this.desc.positionAttribute === e && (this._posDirty = !0),
20344
20357
  delete this._reglData, this;
20345
20358
  }
20346
- _updateGPUBuffer(e, t) {
20359
+ _updateGPUBuffer(e, t, n, r) {
20347
20360
  Array.isArray(t) && (t = new Float32Array(t));
20348
- const n = e.device;
20361
+ const i = e.device;
20349
20362
  if (t.buffer.byteLength > e.size) {
20350
- const r = Qe(n, t, e.usage, e.label);
20351
- return delete e.device, e.destroy(), r;
20363
+ const n = Qe(i, t, e.usage, e.label);
20364
+ return delete e.device, e.destroy(), n;
20352
20365
  }
20353
- return n.wgpu.queue.writeBuffer(e, 0, t.buffer, 0, t.buffer.byteLength), e;
20366
+ return i.wgpu.queue.writeBuffer(e, 0, t.buffer, n, r), e;
20354
20367
  }
20355
20368
  updateSubData(e, t, n) {
20356
20369
  const r = this.data[e];
20357
20370
  if (!r) return this;
20358
20371
  let i;
20359
20372
  if (this._incrVersion(), r.buffer && r.buffer.destroy && (i = r), e === this.desc.positionAttribute && this._updateSubBoundingBox(t),
20360
- i) {
20373
+ i) if (i.buffer.mapState) {
20374
+ t = qe.padGPUBufferAlignment(t, this._vertexCount);
20375
+ const e = i.buffer.bytesPerElement;
20376
+ if (t.BYTES_PER_ELEMENT !== e) {
20377
+ t = new ($e(t, e))(t);
20378
+ }
20379
+ i.buffer = this._updateGPUBuffer(i.buffer, t, n * e, t.buffer.byteLength);
20380
+ } else {
20361
20381
  const e = Ve[i.buffer._buffer.dtype];
20362
20382
  if (t.BYTES_PER_ELEMENT !== e) {
20363
- const n = function(e, t) {
20364
- if (e instanceof Uint8Array || e instanceof Uint16Array || e instanceof Uint32Array || e instanceof Uint8ClampedArray) return 1 === t ? Uint8Array : 2 === t ? Uint16Array : Uint32Array;
20365
- if (e instanceof Int8Array || e instanceof Int16Array || e instanceof Int32Array) return 1 === t ? Int8Array : 2 === t ? Int16Array : Int32Array;
20366
- if (e instanceof Float32Array || e instanceof Float64Array) return 4 === t ? Float32Array : Float64Array;
20367
- return null;
20368
- }(t, e);
20369
- t = new n(t);
20383
+ t = new ($e(t, e))(t);
20370
20384
  }
20371
20385
  i.buffer.subdata(t, n * e);
20372
20386
  } else {
@@ -20386,11 +20400,11 @@
20386
20400
  if (!e) throw new Error("elements data is invalid");
20387
20401
  this._incrVersion();
20388
20402
  const n = this.elements;
20389
- if (this.count = void 0 === t ? $e(e) : t, e && e.destroy) this.elements = e; else if (n.destroy) if (n.mapState) {
20403
+ if (this.count = void 0 === t ? Xe(e) : t, e && e.destroy) this.elements = e; else if (n.destroy) if (n.mapState) {
20390
20404
  if (Array.isArray(e)) {
20391
20405
  e = new (et(e))(e);
20392
20406
  }
20393
- this.elements = this._updateGPUBuffer(n, e);
20407
+ this.elements = this._updateGPUBuffer(n, e, 0, e.buffer.byteLength);
20394
20408
  } else this.elements = n(e); else this.elements = e;
20395
20409
  return this._markVAODirty(!0), this._isIndexed = !I(e), this;
20396
20410
  }
@@ -20398,8 +20412,8 @@
20398
20412
  return this._isIndexed;
20399
20413
  }
20400
20414
  deleteElements() {
20401
- return this.elements && 0 !== this.elements.length ? (this._incrVersion(), this.elements && this.elements.destroy && !this.elements[ee] && (this.elements.destroy(),
20402
- this.elements[ee] = 1), this.elements = [], this._markVAODirty(!0), this) : this;
20415
+ return this.elements && 0 !== this.elements.length ? (this._incrVersion(), this.elements && this.elements.destroy && !this.elements[Q] && (this.elements.destroy(),
20416
+ this.elements[Q] = 1), this.elements = [], this._markVAODirty(!0), this) : this;
20403
20417
  }
20404
20418
  _markVAODirty(e) {
20405
20419
  if (this._vao) {
@@ -20421,13 +20435,13 @@
20421
20435
  }
20422
20436
  dispose() {
20423
20437
  if (this._deleteVAO(), this._forEachBuffer((e => {
20424
- if (!e[ee]) {
20425
- let t = e[qe];
20426
- t && t--, t <= 0 ? (e[ee] = !0, e.destroy()) : e[qe] = t;
20438
+ if (!e[Q]) {
20439
+ let t = e[We];
20440
+ t && t--, t <= 0 ? (e[Q] = !0, e.destroy()) : e[We] = t;
20427
20441
  }
20428
20442
  })), this.properties) {
20429
20443
  const e = this.properties.oldElementsBeforeHighlight;
20430
- e && !e[ee] && e.destroy && (e.destroy(), e[ee] = !0), delete this.properties.oldElementsBeforeHighlight,
20444
+ e && !e[Q] && e.destroy && (e.destroy(), e[Q] = !0), delete this.properties.oldElementsBeforeHighlight,
20431
20445
  delete this.properties.hasInvisible;
20432
20446
  }
20433
20447
  this.data = {}, this._buffers = {}, delete this._reglData, this.count = 0, this.elements = [],
@@ -20442,10 +20456,10 @@
20442
20456
  }
20443
20457
  updateBoundingBox() {
20444
20458
  let e = this.boundingBox;
20445
- e || (e = this.boundingBox = new le);
20459
+ e || (e = this.boundingBox = new ae);
20446
20460
  const t = this.desc.positionAttribute;
20447
20461
  let n, r, i = this.data[t];
20448
- if (H(i) || (i.data ? i = i.data : W(i) ? i = this._getAttributeData(this.desc.positionAttribute) : i.array && (n = i.min,
20462
+ if (H(i) || (i.data ? i = i.data : j(i) ? i = this._getAttributeData(this.desc.positionAttribute) : i.array && (n = i.min,
20449
20463
  r = i.max, i = i.array)), i && i.length) {
20450
20464
  const t = e.min, o = e.max;
20451
20465
  if (n && r) set$5(t, ...n), set$5(o, ...r); else {
@@ -20471,7 +20485,7 @@
20471
20485
  }
20472
20486
  _getAttributeData(e) {
20473
20487
  const t = A(), n = this.data[e] && this.data[e].array ? this.data[e].array : this.data[e], r = n.buffer;
20474
- if (W(n)) {
20488
+ if (j(n)) {
20475
20489
  const i = this._buffers[r] ? this._buffers[r].data : n.array, {count: o, size: s, stride: a, offset: l, componentType: c} = n, h = t.GLTFLoader.getTypedArrayCtor(c);
20476
20490
  if ((0 === a || a === s * h.BYTES_PER_ELEMENT) && l % h.BYTES_PER_ELEMENT == 0) return new h(i, l, o * s);
20477
20491
  if (e === this.desc.positionAttribute) return !this._tempPosArray || this._tempPosArray && this._tempPosArray.length < s * o ? (this._tempPosArray = new h(s * o),
@@ -20484,13 +20498,16 @@
20484
20498
  }
20485
20499
  return n;
20486
20500
  }
20487
- createTangent(e = "aTangent") {
20501
+ createTangent(e = "aTangent", t) {
20488
20502
  this._incrVersion();
20489
- const {normalAttribute: t, positionAttribute: n, uv0Attribute: r} = this.desc, i = this._getAttributeData(t), o = this._getAttributeData(n), s = buildTangents(o, i, this.data[r], this.elements), a = this.data[e] = new Float32Array(s.length), l = [ 0, 0, 0, 0 ], c = [ 0, 0, 0 ], f = [ 0, 0, 0, 0 ];
20490
- for (let e = 0; e < s.length; e += 4) {
20503
+ const {normalAttribute: n, positionAttribute: r, uv0Attribute: i} = this.desc, o = this._getAttributeData(n), s = this._getAttributeData(r);
20504
+ let a;
20505
+ a = t && t.length ? t : buildTangents(s, o, this.data[i], this.elements);
20506
+ const l = this.data[e] = new Float32Array(a.length), c = [ 0, 0, 0, 0 ], f = [ 0, 0, 0 ], d = [ 0, 0, 0, 0 ];
20507
+ for (let e = 0; e < a.length; e += 4) {
20491
20508
  const t = e / 4 * 3;
20492
- set$5(c, i[t], i[t + 1], i[t + 2]), set$4(l, s[e], s[e + 1], s[e + 2], s[e + 3]),
20493
- packTangentFrame(f, c, l), copy$4(a.subarray(e, e + 4), f);
20509
+ set$5(f, o[t], o[t + 1], o[t + 2]), set$4(c, a[e], a[e + 1], a[e + 2], a[e + 3]),
20510
+ packTangentFrame(d, f, c), copy$4(l.subarray(e, e + 4), d);
20494
20511
  }
20495
20512
  delete this._reglData;
20496
20513
  }
@@ -20537,7 +20554,7 @@
20537
20554
  }
20538
20555
  getMemorySize() {
20539
20556
  let e = 0;
20540
- for (const t in this.data) U(this.data, t) && (e += B(this.data[t]));
20557
+ for (const t in this.data) D(this.data, t) && (e += U(this.data[t]));
20541
20558
  if (this.elements) {
20542
20559
  const t = this.elements;
20543
20560
  t.destroy ? t._elements ? e += t._elements.buffer.byteLength : e += t.size : t.BYTES_PER_ELEMENT ? e += t.length * t.BYTES_PER_ELEMENT : t.length && (e += 4 * t.length);
@@ -20546,8 +20563,8 @@
20546
20563
  }
20547
20564
  _forEachBuffer(e) {
20548
20565
  this.elements && this.elements.destroy && e(this.elements);
20549
- for (const t in this.data) U(this.data, t) && this.data[t] && this.data[t].buffer && this.data[t].buffer.destroy && e(this.data[t].buffer);
20550
- for (const t in this._buffers) U(this._buffers, t) && this._buffers[t] && this._buffers[t].buffer && this._buffers[t].buffer.destroy && e(this._buffers[t].buffer);
20566
+ for (const t in this.data) D(this.data, t) && this.data[t] && this.data[t].buffer && this.data[t].buffer.destroy && e(this.data[t].buffer);
20567
+ for (const t in this._buffers) D(this._buffers, t) && this._buffers[t] && this._buffers[t].buffer && this._buffers[t].buffer.destroy && e(this._buffers[t].buffer);
20551
20568
  }
20552
20569
  getElementsType(e) {
20553
20570
  return e instanceof Uint8Array ? "uint8" : e instanceof Uint16Array ? "uint16" : e instanceof Uint32Array ? "uint32" : void 0;
@@ -20604,7 +20621,7 @@
20604
20621
  }
20605
20622
  }
20606
20623
 
20607
- function $e(e) {
20624
+ function Xe(e) {
20608
20625
  if (I(e)) return e;
20609
20626
  if (void 0 !== e.count) return e.count;
20610
20627
  if (e.destroy) return e._elements ? e._elements.vertCount : e.itemCount;
@@ -20613,6 +20630,10 @@
20613
20630
  throw new Error("invalid elements length");
20614
20631
  }
20615
20632
 
20633
+ function $e(e, t) {
20634
+ return e instanceof Uint8Array || e instanceof Uint16Array || e instanceof Uint32Array || e instanceof Uint8ClampedArray ? 1 === t ? Uint8Array : 2 === t ? Uint16Array : Uint32Array : e instanceof Int8Array || e instanceof Int16Array || e instanceof Int32Array ? 1 === t ? Int8Array : 2 === t ? Int16Array : Int32Array : e instanceof Float32Array || e instanceof Float64Array ? 4 === t ? Float32Array : Float64Array : null;
20635
+ }
20636
+
20616
20637
  function Ke(e, t) {
20617
20638
  const n = e.data || e.array || e;
20618
20639
  let r = t.itemSize;
@@ -20632,7 +20653,7 @@
20632
20653
  if (H(n)) {
20633
20654
  let o, s;
20634
20655
  return e.componentType ? (o = Fe(e.componentType, e.itemSize), i = e.componentType,
20635
- s = De[i].bytes) : (o = Ze(n, r), s = Ye(n)), r = tt(r, s), {
20656
+ s = Ne[i].bytes) : (o = Ze(n, r), s = Ye(n)), r = tt(r, s), {
20636
20657
  arrayStride: r * s,
20637
20658
  attributes: [ {
20638
20659
  shaderLocation: t.location,
@@ -20658,7 +20679,7 @@
20658
20679
  function Ze(e, t) {
20659
20680
  const n = Je(e);
20660
20681
  let r;
20661
- return r = n.destroy ? n.itemType : Ne(n), t > 1 ? r + "x" + t : r;
20682
+ return r = n.destroy ? n.itemType : Le(n), t > 1 ? r + "x" + t : r;
20662
20683
  }
20663
20684
 
20664
20685
  function Je(e) {
@@ -20666,15 +20687,15 @@
20666
20687
  }
20667
20688
 
20668
20689
  function Qe(e, t, n, r) {
20669
- t = t.data || t, Array.isArray(t[0]) && (t = Le(t)), Array.isArray(t) && (t = new Float32Array(t));
20670
- const i = t.constructor, o = Be(t.byteLength, 4), s = e.wgpu.createBuffer({
20690
+ t = t.data || t, Array.isArray(t[0]) && (t = He(t)), Array.isArray(t) && (t = new Float32Array(t));
20691
+ const i = t.constructor, o = Ue(t.byteLength, 4), s = e.wgpu.createBuffer({
20671
20692
  label: r,
20672
20693
  size: o,
20673
20694
  usage: n,
20674
20695
  mappedAtCreation: !0
20675
20696
  });
20676
20697
  return s.device = e, new i(s.getMappedRange()).set(t), s.unmap(), s.itemCount = t.length,
20677
- s.itemType = Ne(t), s.bytesPerElement = Ye(t), s;
20698
+ s.itemType = Le(t), s.bytesPerElement = Ye(t), s;
20678
20699
  }
20679
20700
 
20680
20701
  function et(e) {
@@ -20809,7 +20830,7 @@
20809
20830
 
20810
20831
  const bt = [ 0, 0, 0 ], yt = [ 0, 0, 0 ], St = [ 0, 0, 0 ], Tt = [], wt = [], At = [], Mt = [ "a", "b", "c" ];
20811
20832
 
20812
- class Ct extends Xe {
20833
+ class Ct extends qe {
20813
20834
  constructor(e, t, n, r) {
20814
20835
  super(e, t, n, {
20815
20836
  primitive: rt(1),
@@ -20871,7 +20892,7 @@
20871
20892
 
20872
20893
  class Et {}
20873
20894
 
20874
- class Pt extends(Q(Et)){
20895
+ class Pt extends(J(Et)){
20875
20896
  constructor(e = {}, t) {
20876
20897
  super(), this._version = 0, this._propVerion = 0, this.uniforms = P({}, t || {}, e);
20877
20898
  for (const t in e) {
@@ -20921,7 +20942,7 @@
20921
20942
  getMemorySize() {
20922
20943
  const e = this.uniforms;
20923
20944
  let t = 0;
20924
- for (const n in e) this.isTexture(n) ? t += e[n].getMemorySize() : this.uniforms[n] && this.uniforms[n].destroy && (t += z(this.uniforms[n]));
20945
+ for (const n in e) this.isTexture(n) ? t += e[n].getMemorySize() : this.uniforms[n] && this.uniforms[n].destroy && (t += B(this.uniforms[n]));
20925
20946
  return t;
20926
20947
  }
20927
20948
  isReady() {
@@ -20972,12 +20993,12 @@
20972
20993
  return !!(this.uniforms && this.uniforms.jointTexture && this.uniforms.skinAnimation);
20973
20994
  }
20974
20995
  isTexture(e) {
20975
- return this.uniforms[e] instanceof oe;
20996
+ return this.uniforms[e] instanceof ie;
20976
20997
  }
20977
20998
  dispose() {
20978
20999
  for (const e in this.uniforms) {
20979
21000
  const t = this.uniforms[e];
20980
- t && (t.dispose ? t.dispose() : t.destroy && !t[ee] && (t.destroy(), t[ee] = !0));
21001
+ t && (t.dispose ? t.dispose() : t.destroy && !t[Q] && (t.destroy(), t[Q] = !0));
20981
21002
  }
20982
21003
  delete this.uniforms, delete this._reglUniforms, delete this._bindedOnTextureComplete,
20983
21004
  this._disposed = !0;
@@ -21000,7 +21021,7 @@
21000
21021
  }
21001
21022
  _genUniformKeys() {
21002
21023
  const e = [];
21003
- for (const t in this.uniforms) U(this.uniforms, t) && !C(this.uniforms[t]) && e.push(t);
21024
+ for (const t in this.uniforms) D(this.uniforms, t) && !C(this.uniforms[t]) && e.push(t);
21004
21025
  this._uniformKeys = e.join();
21005
21026
  }
21006
21027
  _incrVersion() {
@@ -21095,7 +21116,7 @@
21095
21116
  "occlusionTexture": null
21096
21117
  };
21097
21118
 
21098
- function Dt(e) {
21119
+ function Ft(e) {
21099
21120
  return class extends e {
21100
21121
  constructor(...e) {
21101
21122
  let t = e[0];
@@ -21110,7 +21131,7 @@
21110
21131
  };
21111
21132
  }
21112
21133
 
21113
- class Ft extends(Dt(Ht)){}
21134
+ class Dt extends(Ft(Ht)){}
21114
21135
 
21115
21136
  class Ut {
21116
21137
  constructor() {
@@ -21137,7 +21158,7 @@
21137
21158
  if (e) {
21138
21159
  t(zt.instance);
21139
21160
  for (const n of e) n instanceof Array ? this.searchBlock(n, t) : n.search(t);
21140
- t(Gt.instance);
21161
+ t(Vt.instance);
21141
21162
  }
21142
21163
  }
21143
21164
  }
@@ -21146,17 +21167,17 @@
21146
21167
 
21147
21168
  zt.instance = new zt;
21148
21169
 
21149
- class Gt extends Bt {}
21170
+ class Vt extends Bt {}
21150
21171
 
21151
- Gt.instance = new Gt;
21172
+ Vt.instance = new Vt;
21152
21173
 
21153
- class Vt extends Bt {
21174
+ class Gt extends Bt {
21154
21175
  constructor() {
21155
21176
  super();
21156
21177
  }
21157
21178
  }
21158
21179
 
21159
- let jt = class extends Vt {
21180
+ let jt = class extends Gt {
21160
21181
  constructor(e, t, n, r, i, o) {
21161
21182
  super(), this.calls = new Set, this.name = e, this.args = t, this.returnType = n,
21162
21183
  this.body = r, this.startLine = i, this.endLine = o;
@@ -21169,7 +21190,7 @@
21169
21190
  }
21170
21191
  };
21171
21192
 
21172
- class Wt extends Vt {
21193
+ class Wt extends Gt {
21173
21194
  constructor(e) {
21174
21195
  super(), this.expression = e;
21175
21196
  }
@@ -21181,7 +21202,7 @@
21181
21202
  }
21182
21203
  }
21183
21204
 
21184
- class qt extends Vt {
21205
+ class qt extends Gt {
21185
21206
  constructor(e, t) {
21186
21207
  super(), this.condition = e, this.body = t;
21187
21208
  }
@@ -21193,7 +21214,7 @@
21193
21214
  }
21194
21215
  }
21195
21216
 
21196
- class Xt extends Vt {
21217
+ class Xt extends Gt {
21197
21218
  constructor(e) {
21198
21219
  super(), this.body = e;
21199
21220
  }
@@ -21205,7 +21226,7 @@
21205
21226
  }
21206
21227
  }
21207
21228
 
21208
- class $t extends Vt {
21229
+ class $t extends Gt {
21209
21230
  constructor(e, t, n, r) {
21210
21231
  super(), this.init = e, this.condition = t, this.increment = n, this.body = r;
21211
21232
  }
@@ -21219,7 +21240,7 @@
21219
21240
  }
21220
21241
  }
21221
21242
 
21222
- class Kt extends Vt {
21243
+ class Kt extends Gt {
21223
21244
  constructor(e, t, n, r, i) {
21224
21245
  super(), this.name = e, this.type = t, this.storage = n, this.access = r, this.value = i;
21225
21246
  }
@@ -21232,7 +21253,7 @@
21232
21253
  }
21233
21254
  }
21234
21255
 
21235
- class Yt extends Vt {
21256
+ class Yt extends Gt {
21236
21257
  constructor(e, t, n) {
21237
21258
  super(), this.name = e, this.type = t, this.value = n;
21238
21259
  }
@@ -21245,7 +21266,7 @@
21245
21266
  }
21246
21267
  }
21247
21268
 
21248
- class Zt extends Vt {
21269
+ class Zt extends Gt {
21249
21270
  constructor(e, t, n, r, i) {
21250
21271
  super(), this.name = e, this.type = t, this.storage = n, this.access = r, this.value = i;
21251
21272
  }
@@ -21258,7 +21279,7 @@
21258
21279
  }
21259
21280
  }
21260
21281
 
21261
- class Jt extends Vt {
21282
+ class Jt extends Gt {
21262
21283
  constructor(e, t, n, r, i) {
21263
21284
  super(), this.name = e, this.type = t, this.storage = n, this.access = r, this.value = i;
21264
21285
  }
@@ -21286,7 +21307,7 @@
21286
21307
  };
21287
21308
  }(Qt || (Qt = {}));
21288
21309
 
21289
- class on extends Vt {
21310
+ class on extends Gt {
21290
21311
  constructor(e, t) {
21291
21312
  super(), this.operator = e, this.variable = t;
21292
21313
  }
@@ -21310,7 +21331,7 @@
21310
21331
  };
21311
21332
  }(en || (en = {}));
21312
21333
 
21313
- class sn extends Vt {
21334
+ class sn extends Gt {
21314
21335
  constructor(e, t, n) {
21315
21336
  super(), this.operator = e, this.variable = t, this.value = n;
21316
21337
  }
@@ -21322,7 +21343,7 @@
21322
21343
  }
21323
21344
  }
21324
21345
 
21325
- class an extends Vt {
21346
+ class an extends Gt {
21326
21347
  constructor(e, t) {
21327
21348
  super(), this.name = e, this.args = t;
21328
21349
  }
@@ -21335,7 +21356,7 @@
21335
21356
  }
21336
21357
  }
21337
21358
 
21338
- class ln extends Vt {
21359
+ class ln extends Gt {
21339
21360
  constructor(e, t) {
21340
21361
  super(), this.body = e, this.continuing = t;
21341
21362
  }
@@ -21344,7 +21365,7 @@
21344
21365
  }
21345
21366
  }
21346
21367
 
21347
- class cn extends Vt {
21368
+ class cn extends Gt {
21348
21369
  constructor(e, t) {
21349
21370
  super(), this.condition = e, this.body = t;
21350
21371
  }
@@ -21353,7 +21374,7 @@
21353
21374
  }
21354
21375
  }
21355
21376
 
21356
- class hn extends Vt {
21377
+ class hn extends Gt {
21357
21378
  constructor(e, t, n, r) {
21358
21379
  super(), this.condition = e, this.body = t, this.elseif = n, this.else = r;
21359
21380
  }
@@ -21366,7 +21387,7 @@
21366
21387
  }
21367
21388
  }
21368
21389
 
21369
- class un extends Vt {
21390
+ class un extends Gt {
21370
21391
  constructor(e) {
21371
21392
  super(), this.value = e;
21372
21393
  }
@@ -21379,7 +21400,7 @@
21379
21400
  }
21380
21401
  }
21381
21402
 
21382
- class fn extends Vt {
21403
+ class fn extends Gt {
21383
21404
  constructor(e) {
21384
21405
  super(), this.name = e;
21385
21406
  }
@@ -21388,7 +21409,7 @@
21388
21409
  }
21389
21410
  }
21390
21411
 
21391
- class dn extends Vt {
21412
+ class dn extends Gt {
21392
21413
  constructor(e) {
21393
21414
  super(), this.extensions = e;
21394
21415
  }
@@ -21397,7 +21418,7 @@
21397
21418
  }
21398
21419
  }
21399
21420
 
21400
- class mn extends Vt {
21421
+ class mn extends Gt {
21401
21422
  constructor(e, t) {
21402
21423
  super(), this.severity = e, this.rule = t;
21403
21424
  }
@@ -21406,7 +21427,7 @@
21406
21427
  }
21407
21428
  }
21408
21429
 
21409
- class gn extends Vt {
21430
+ class gn extends Gt {
21410
21431
  constructor(e, t) {
21411
21432
  super(), this.name = e, this.type = t;
21412
21433
  }
@@ -21415,7 +21436,7 @@
21415
21436
  }
21416
21437
  }
21417
21438
 
21418
- class pn extends Vt {
21439
+ class pn extends Gt {
21419
21440
  constructor() {
21420
21441
  super();
21421
21442
  }
@@ -21424,7 +21445,7 @@
21424
21445
  }
21425
21446
  }
21426
21447
 
21427
- class _n extends Vt {
21448
+ class _n extends Gt {
21428
21449
  constructor() {
21429
21450
  super();
21430
21451
  }
@@ -21433,7 +21454,7 @@
21433
21454
  }
21434
21455
  }
21435
21456
 
21436
- class vn extends Vt {
21457
+ class vn extends Gt {
21437
21458
  constructor() {
21438
21459
  super();
21439
21460
  }
@@ -21442,7 +21463,7 @@
21442
21463
  }
21443
21464
  }
21444
21465
 
21445
- class xn extends Vt {
21466
+ class xn extends Gt {
21446
21467
  constructor(e) {
21447
21468
  super(), this.name = e;
21448
21469
  }
@@ -21804,7 +21825,7 @@
21804
21825
  }
21805
21826
  }
21806
21827
 
21807
- class Dn extends Ln {
21828
+ class Fn extends Ln {
21808
21829
  constructor(e, t, n) {
21809
21830
  super(), this.operator = e, this.left = t, this.right = n;
21810
21831
  }
@@ -21861,13 +21882,13 @@
21861
21882
  }
21862
21883
  }
21863
21884
 
21864
- class Fn extends Bt {
21885
+ class Dn extends Bt {
21865
21886
  constructor() {
21866
21887
  super();
21867
21888
  }
21868
21889
  }
21869
21890
 
21870
- class Un extends Fn {
21891
+ class Un extends Dn {
21871
21892
  constructor(e, t) {
21872
21893
  super(), this.selector = e, this.body = t;
21873
21894
  }
@@ -21879,7 +21900,7 @@
21879
21900
  }
21880
21901
  }
21881
21902
 
21882
- class Bn extends Fn {
21903
+ class Bn extends Dn {
21883
21904
  constructor(e) {
21884
21905
  super(), this.body = e;
21885
21906
  }
@@ -21900,7 +21921,7 @@
21900
21921
  }
21901
21922
  }
21902
21923
 
21903
- class Gn extends Bt {
21924
+ class Vn extends Bt {
21904
21925
  constructor(e, t) {
21905
21926
  super(), this.condition = e, this.body = t;
21906
21927
  }
@@ -21912,7 +21933,7 @@
21912
21933
  }
21913
21934
  }
21914
21935
 
21915
- class Vn extends Bt {
21936
+ class Gn extends Bt {
21916
21937
  constructor(e, t, n) {
21917
21938
  super(), this.name = e, this.type = t, this.attributes = n;
21918
21939
  }
@@ -22671,7 +22692,7 @@
22671
22692
  }
22672
22693
  _elseif_statement(e = []) {
22673
22694
  const t = this._optional_paren_expression(), n = this._compound_statement();
22674
- return e.push(new Gn(t, n)), this._match_elseif() && (this._check(qn.tokens.attr) && this._attribute(),
22695
+ return e.push(new Vn(t, n)), this._match_elseif() && (this._check(qn.tokens.attr) && this._attribute(),
22675
22696
  this._elseif_statement(e)), e;
22676
22697
  }
22677
22698
  _return_statement() {
@@ -22681,51 +22702,51 @@
22681
22702
  }
22682
22703
  _short_circuit_or_expression() {
22683
22704
  let e = this._short_circuit_and_expr();
22684
- for (;this._match(qn.tokens.or_or); ) e = new Dn(this._previous().toString(), e, this._short_circuit_and_expr());
22705
+ for (;this._match(qn.tokens.or_or); ) e = new Fn(this._previous().toString(), e, this._short_circuit_and_expr());
22685
22706
  return e;
22686
22707
  }
22687
22708
  _short_circuit_and_expr() {
22688
22709
  let e = this._inclusive_or_expression();
22689
- for (;this._match(qn.tokens.and_and); ) e = new Dn(this._previous().toString(), e, this._inclusive_or_expression());
22710
+ for (;this._match(qn.tokens.and_and); ) e = new Fn(this._previous().toString(), e, this._inclusive_or_expression());
22690
22711
  return e;
22691
22712
  }
22692
22713
  _inclusive_or_expression() {
22693
22714
  let e = this._exclusive_or_expression();
22694
- for (;this._match(qn.tokens.or); ) e = new Dn(this._previous().toString(), e, this._exclusive_or_expression());
22715
+ for (;this._match(qn.tokens.or); ) e = new Fn(this._previous().toString(), e, this._exclusive_or_expression());
22695
22716
  return e;
22696
22717
  }
22697
22718
  _exclusive_or_expression() {
22698
22719
  let e = this._and_expression();
22699
- for (;this._match(qn.tokens.xor); ) e = new Dn(this._previous().toString(), e, this._and_expression());
22720
+ for (;this._match(qn.tokens.xor); ) e = new Fn(this._previous().toString(), e, this._and_expression());
22700
22721
  return e;
22701
22722
  }
22702
22723
  _and_expression() {
22703
22724
  let e = this._equality_expression();
22704
- for (;this._match(qn.tokens.and); ) e = new Dn(this._previous().toString(), e, this._equality_expression());
22725
+ for (;this._match(qn.tokens.and); ) e = new Fn(this._previous().toString(), e, this._equality_expression());
22705
22726
  return e;
22706
22727
  }
22707
22728
  _equality_expression() {
22708
22729
  const e = this._relational_expression();
22709
- return this._match([ qn.tokens.equal_equal, qn.tokens.not_equal ]) ? new Dn(this._previous().toString(), e, this._relational_expression()) : e;
22730
+ return this._match([ qn.tokens.equal_equal, qn.tokens.not_equal ]) ? new Fn(this._previous().toString(), e, this._relational_expression()) : e;
22710
22731
  }
22711
22732
  _relational_expression() {
22712
22733
  let e = this._shift_expression();
22713
- for (;this._match([ qn.tokens.less_than, qn.tokens.greater_than, qn.tokens.less_than_equal, qn.tokens.greater_than_equal ]); ) e = new Dn(this._previous().toString(), e, this._shift_expression());
22734
+ for (;this._match([ qn.tokens.less_than, qn.tokens.greater_than, qn.tokens.less_than_equal, qn.tokens.greater_than_equal ]); ) e = new Fn(this._previous().toString(), e, this._shift_expression());
22714
22735
  return e;
22715
22736
  }
22716
22737
  _shift_expression() {
22717
22738
  let e = this._additive_expression();
22718
- for (;this._match([ qn.tokens.shift_left, qn.tokens.shift_right ]); ) e = new Dn(this._previous().toString(), e, this._additive_expression());
22739
+ for (;this._match([ qn.tokens.shift_left, qn.tokens.shift_right ]); ) e = new Fn(this._previous().toString(), e, this._additive_expression());
22719
22740
  return e;
22720
22741
  }
22721
22742
  _additive_expression() {
22722
22743
  let e = this._multiplicative_expression();
22723
- for (;this._match([ qn.tokens.plus, qn.tokens.minus ]); ) e = new Dn(this._previous().toString(), e, this._multiplicative_expression());
22744
+ for (;this._match([ qn.tokens.plus, qn.tokens.minus ]); ) e = new Fn(this._previous().toString(), e, this._multiplicative_expression());
22724
22745
  return e;
22725
22746
  }
22726
22747
  _multiplicative_expression() {
22727
22748
  let e = this._unary_expression();
22728
- for (;this._match([ qn.tokens.star, qn.tokens.forward_slash, qn.tokens.modulo ]); ) e = new Dn(this._previous().toString(), e, this._unary_expression());
22749
+ for (;this._match([ qn.tokens.star, qn.tokens.forward_slash, qn.tokens.modulo ]); ) e = new Fn(this._previous().toString(), e, this._unary_expression());
22729
22750
  return e;
22730
22751
  }
22731
22752
  _unary_expression() {
@@ -22812,7 +22833,7 @@
22812
22833
  this._consume(qn.tokens.colon, "Expected ':' for struct member type.");
22813
22834
  const r = this._attribute(), i = this._type_decl();
22814
22835
  null != i && (i.attributes = r), this._check(qn.tokens.brace_right) ? this._match(qn.tokens.comma) : this._consume(qn.tokens.comma, "Expected ',' for struct member."),
22815
- n.push(new Vn(t, i, e));
22836
+ n.push(new Gn(t, i, e));
22816
22837
  }
22817
22838
  this._consume(qn.tokens.brace_right, "Expected '}' after struct body.");
22818
22839
  const r = this._currentLine, i = new bn(t, n, e, r);
@@ -23259,7 +23280,7 @@
23259
23280
  _findResources(e, t) {
23260
23281
  const n = [], r = this, i = [];
23261
23282
  return e.search((o => {
23262
- if (o instanceof zt) i.push({}); else if (o instanceof Gt) i.pop(); else if (o instanceof Kt) {
23283
+ if (o instanceof zt) i.push({}); else if (o instanceof Vt) i.pop(); else if (o instanceof Kt) {
23263
23284
  const e = o;
23264
23285
  t && null !== e.type && this._markStructsFromAST(e.type), i.length > 0 && (i[i.length - 1][e.name] = e);
23265
23286
  } else if (o instanceof Cn) {
@@ -23582,11 +23603,11 @@
23582
23603
  const i = s + n.offset, o = n.size;
23583
23604
  this._fillValue(n.type, a, i, o, r);
23584
23605
  }
23585
- s += Be(i.size, o);
23606
+ s += Ue(i.size, o);
23586
23607
  } else if (i.resourceType === rn.Uniform) {
23587
23608
  t.addItem(l, s);
23588
23609
  const n = e[i.name], r = k(i.size) ? i.size() : i.size;
23589
- this._fillValue(i.type, a, s, r, n), s += Be(r, o);
23610
+ this._fillValue(i.type, a, s, r, n), s += Ue(r, o);
23590
23611
  }
23591
23612
  }
23592
23613
  }
@@ -23594,7 +23615,7 @@
23594
23615
  const o = new Float32Array(t, n, r / 4);
23595
23616
  if (H(i)) {
23596
23617
  const t = function(e) {
23597
- return Ue[e.name];
23618
+ return De[e.name];
23598
23619
  }(e);
23599
23620
  if (!t) return void o.set(i);
23600
23621
  for (let e = 0; e < i.length; e++) {
@@ -23758,7 +23779,7 @@
23758
23779
  if (this._dirtyUniforms || this._dirtyGeometry || this._material && this._materialVer !== this._material.version) {
23759
23780
  this._uniformDescriptors = new Set, this._realUniforms = {}, this._prepareUniformsForDraco();
23760
23781
  const t = this.uniforms;
23761
- for (const e in this.uniforms) if (U(this.uniforms, e)) {
23782
+ for (const e in this.uniforms) if (D(this.uniforms, e)) {
23762
23783
  Object.getOwnPropertyDescriptor(t, e).get ? (this._uniformDescriptors.add(e), Object.defineProperty(this._realUniforms, e, {
23763
23784
  enumerable: !0,
23764
23785
  configurable: !0,
@@ -23769,7 +23790,7 @@
23769
23790
  }
23770
23791
  if (this._material) {
23771
23792
  const t = this._material.getUniforms(e);
23772
- for (const e in t) if (U(t, e) && !U(this._realUniforms, e)) {
23793
+ for (const e in t) if (D(t, e) && !D(this._realUniforms, e)) {
23773
23794
  Object.getOwnPropertyDescriptor(t, e).get ? (this._uniformDescriptors.add(e), Object.defineProperty(this._realUniforms, e, {
23774
23795
  enumerable: !0,
23775
23796
  configurable: !0,
@@ -23785,7 +23806,7 @@
23785
23806
  if (this._dirtyProps) for (const e of this._dirtyProps) this._realUniforms[e] = this.uniforms[e];
23786
23807
  if (this._material && this._material.propVersion !== this._materialPropVer) {
23787
23808
  const t = this._material.getUniforms(e);
23788
- for (const e in t) if (U(t, e) && !this._uniformDescriptors.has(e)) {
23809
+ for (const e in t) if (D(t, e) && !this._uniformDescriptors.has(e)) {
23789
23810
  Object.getOwnPropertyDescriptor(t, e).get || this._realUniforms[e] === t[e] || (this._realUniforms[e] = t[e]);
23790
23811
  }
23791
23812
  this._materialPropVer = this._material.propVersion;
@@ -23836,12 +23857,12 @@
23836
23857
  }
23837
23858
  updateBoundingBox() {
23838
23859
  const e = this._geometry.boundingBox;
23839
- this._bbox || (this._bbox = new le), this._bboxArr || (this._bboxArr = [ [ 0, 0, 0 ], [ 0, 0, 0 ] ]),
23840
- this._geoBox || (this._geoBox = new le), le.copy(this._bbox, e), this._bbox.updateVertex(),
23860
+ this._bbox || (this._bbox = new ae), this._bboxArr || (this._bboxArr = [ [ 0, 0, 0 ], [ 0, 0, 0 ] ]),
23861
+ this._geoBox || (this._geoBox = new ae), ae.copy(this._bbox, e), this._bbox.updateVertex(),
23841
23862
  "InstancedMesh" === this.constructor.name ? (this._bbox.transform(this.localTransform, this.positionMatrix),
23842
23863
  this._currentTransform = multiply$5(this._currentTransform || new Array(16), this.positionMatrix, this.localTransform)) : (this._bbox.transform(this.positionMatrix, this.localTransform),
23843
23864
  this._currentTransform = multiply$5(this._currentTransform || new Array(16), this.localTransform, this.positionMatrix)),
23844
- le.copy(this._geoBox, e), copy$5(this._bboxArr[0], this._bbox.min), copy$5(this._bboxArr[1], this._bbox.max);
23865
+ ae.copy(this._geoBox, e), copy$5(this._bboxArr[0], this._bbox.min), copy$5(this._bboxArr[1], this._bbox.max);
23845
23866
  }
23846
23867
  _createDefinesKey(e) {
23847
23868
  const t = [];
@@ -23894,7 +23915,7 @@
23894
23915
  }
23895
23916
  _getInstanceMemorySize() {
23896
23917
  let e = 0;
23897
- for (const t in this.instancedData) U(this.instancedData, t) && (e += B(this.instancedData[t]));
23918
+ for (const t in this.instancedData) D(this.instancedData, t) && (e += U(this.instancedData[t]));
23898
23919
  return e;
23899
23920
  }
23900
23921
  _checkInstancedProp() {
@@ -23941,7 +23962,7 @@
23941
23962
  const t = !!e && e.wgpu, n = this.instancedData, r = this.instanceCount, i = {};
23942
23963
  for (const o in n) {
23943
23964
  if (!n[o]) continue;
23944
- Array.isArray(n[o]) ? n[o] = new Float32Array(n[o]) : t && H(n[o]) && (n[o] = Xe.padGPUBufferAlignment(n[o], r));
23965
+ Array.isArray(n[o]) ? n[o] = new Float32Array(n[o]) : t && H(n[o]) && (n[o] = qe.padGPUBufferAlignment(n[o], r));
23945
23966
  const s = n[o];
23946
23967
  if (void 0 !== s.buffer && s.buffer.destroy) i[o] = s, i[o].divisor && (i[o].divisor = 1); else if (n[o].destroy) i[o] = {
23947
23968
  buffer: n[o],
@@ -23952,7 +23973,7 @@
23952
23973
  dimension: n[o].length / this._instanceCount
23953
23974
  };
23954
23975
  i[o] = {
23955
- buffer: Xe.createBuffer(e, t, o),
23976
+ buffer: qe.createBuffer(e, t, o),
23956
23977
  divisor: 1
23957
23978
  };
23958
23979
  }
@@ -23969,7 +23990,7 @@
23969
23990
  if (e) for (const t in e) {
23970
23991
  if (!e[t]) continue;
23971
23992
  const n = e[t].destroy ? e[t] : e[t].buffer;
23972
- n.destroy && !n[ee] && (n[ee] = 1, n.destroy());
23993
+ n.destroy && !n[Q] && (n[Q] = 1, n.destroy());
23973
23994
  }
23974
23995
  this.instancedData = {};
23975
23996
  for (const e in this._vao) this._vao[e].vao.destroy();
@@ -24011,6 +24032,9 @@
24011
24032
  clear(e) {
24012
24033
  this.device.clear(e);
24013
24034
  }
24035
+ isWebGPU() {
24036
+ return !!this.device.wgpu;
24037
+ }
24014
24038
  }
24015
24039
 
24016
24040
  const xr = {
@@ -24128,7 +24152,7 @@
24128
24152
  }
24129
24153
  }
24130
24154
 
24131
- class yr extends(Q(br)){}
24155
+ class yr extends(J(br)){}
24132
24156
 
24133
24157
  const Sr = [ 0, 0, 0 ], Tr = [ 0, 0, 0 ];
24134
24158
 
@@ -24317,10 +24341,10 @@
24317
24341
  };
24318
24342
  }
24319
24343
 
24320
- const Dr = {
24344
+ const Fr = {
24321
24345
  toHalfFloat: function(e) {
24322
24346
  Math.abs(e) > 65504 && console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),
24323
- e = D(e, -65504, 65504), Lr.floatView[0] = e;
24347
+ e = N(e, -65504, 65504), Lr.floatView[0] = e;
24324
24348
  const t = Lr.uint32View[0], n = t >> 23 & 511;
24325
24349
  return Lr.baseTable[n] + ((8388607 & t) >> Lr.shiftTable[n]);
24326
24350
  },
@@ -24329,18 +24353,18 @@
24329
24353
  return Lr.uint32View[0] = Lr.mantissaTable[Lr.offsetTable[t] + (1023 & e)] + Lr.exponentTable[t],
24330
24354
  Lr.floatView[0];
24331
24355
  }
24332
- }, Fr = 9728, Ur = 9729, Br = 9987;
24356
+ }, Dr = 9728, Ur = 9729, Br = 9987;
24333
24357
 
24334
24358
  var zr = Object.freeze({
24335
24359
  __proto__: null,
24336
24360
  GL_LINEAR: Ur,
24337
24361
  GL_LINEAR_MIPMAP_LINEAR: Br,
24338
- GL_NEAREST: Fr,
24362
+ GL_NEAREST: Dr,
24339
24363
  MAG_FILTER: 10240,
24340
24364
  MIN_FILTER: 10241
24341
24365
  });
24342
24366
 
24343
- class Gr extends oe {
24367
+ class Vr extends ie {
24344
24368
  constructor() {
24345
24369
  super(...arguments), this._version = 0;
24346
24370
  }
@@ -24357,7 +24381,7 @@
24357
24381
  if (!(e = Hr(e.data, 0))) throw new Error("Invalid hdr data" + (t.url ? ":" + t.url : ""));
24358
24382
  {
24359
24383
  const n = new Uint16Array(e.pixels.length);
24360
- for (let t = 0; t < e.pixels.length; t++) n[t] = Math.min(Dr.toHalfFloat(e.pixels[t]), 65504);
24384
+ for (let t = 0; t < e.pixels.length; t++) n[t] = Math.min(Fr.toHalfFloat(e.pixels[t]), 65504);
24361
24385
  t.data = n, t.type = "float16", t.colorSpace = "browser", t.min = "linear", t.mag = "linear";
24362
24386
  }
24363
24387
  } else t.data = e;
@@ -24371,7 +24395,7 @@
24371
24395
  this.dirty = !!this._texture;
24372
24396
  }
24373
24397
  _update() {
24374
- this._texture && !this._texture[ee] && (this._version++, k(this._texture) ? this._texture(this.config) : this._texture.update(this.config)),
24398
+ this._texture && !this._texture[Q] && (this._version++, k(this._texture) ? this._texture(this.config) : this._texture.update(this.config)),
24375
24399
  this.dirty = !1;
24376
24400
  }
24377
24401
  setMinFilter(e) {
@@ -24385,28 +24409,28 @@
24385
24409
  createREGLTexture(e) {
24386
24410
  if (this._regl = e, this._checkNPOT(e), H(this.config.data) || H(this.config.mipmap)) {
24387
24411
  const t = vt(e, this.config);
24388
- return t[re] || (t[re] = 0), t[re]++, t;
24412
+ return t[ne] || (t[ne] = 0), t[ne]++, t;
24389
24413
  }
24390
24414
  return e.texture(this.config);
24391
24415
  }
24392
24416
  _checkNPOT(e) {
24393
24417
  const t = this.config;
24394
- t.data && this._needPowerOf2(e) && (t.data instanceof Image ? (t.data = Y(t.data),
24395
- t.width = t.data.width, t.height = t.data.height) : t.hdr || !H(t.data) || $(t.width) && $(t.height) || (t.data = Y(t.data, t.width, t.height),
24418
+ t.data && this._needPowerOf2(e) && (t.data instanceof Image ? (t.data = K(t.data),
24419
+ t.width = t.data.width, t.height = t.data.height) : t.hdr || !H(t.data) || X(t.width) && X(t.height) || (t.data = K(t.data, t.width, t.height),
24396
24420
  t.width = t.data.width, t.height = t.data.height));
24397
24421
  }
24398
24422
  _needPowerOf2(e) {
24399
- if (Z(e)) return !1;
24423
+ if (Y(e)) return !1;
24400
24424
  const t = this.config;
24401
24425
  return t.wrap && "clamp" !== t.wrap || t.wrapS && "clamp" !== t.wrapS || t.wrapT && "clamp" !== t.wrapT || t.min && "nearest" !== t.min && "linear" !== t.min;
24402
24426
  }
24403
24427
  }
24404
24428
 
24405
- class Vr extends Xe {
24429
+ class Gr extends qe {
24406
24430
  constructor(e) {
24407
- super({
24408
- aPosition: new (N(e = e || 0))([ -1, -1, e, 1, -1, e, -1, 1, e, 1, 1, e ]),
24409
- aNormal: new Int8Array([ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ])
24431
+ e = e || 0, super({
24432
+ aPosition: new Float32Array([ -1, -1, e, 1, -1, e, -1, 1, e, 1, 1, e ]),
24433
+ aNormal: new Float32Array([ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 ])
24410
24434
  }, new Uint16Array([ 0, 1, 3, 3, 2, 0 ]));
24411
24435
  }
24412
24436
  }
@@ -24655,7 +24679,7 @@
24655
24679
  },
24656
24680
  compute_texcoord: {
24657
24681
  defines: [ "HAS_MAP" ],
24658
- frag: "\n#ifdef HAS_KHR_TEXTURE_TRANSFORM\n struct TextureTransformUniforms {\n offset: vec2f,\n rotation: f32,\n scale: vec2f,\n };\n\n @group(0) @binding($b) var<uniform> textureTransformUniforms: TextureTransformUniforms;\n\n fn khr_tex_transformTexCoord(texCoords: vec2f, offset: vec2f, rotation: f32, scale: vec2f) -> vec2f {\n rotation = -rotation;\n let transform = mat3x3f(\n cos(rotation) * scale.x, sin(rotation) * scale.x, 0.0,\n -sin(rotation) * scale.y, cos(rotation) * scale.y, 0.0,\n offset.x, offset.y, 1.0\n );\n let transformedTexCoords = (transform * vec3f(fract(texCoords), 1.0)).xy;\n return transformedTexCoords;\n }\n#endif\n\nfn computeTexCoord(vertexOutput: VertexOutput) -> vec2f {\n let texCoord = vertexOutput.vTexCoord;\n #ifdef HAS_I3S_UVREGION\n let atlasScale = vertexOutput.vUvRegion.zw - vertexOutput.vUvRegion.xy;\n let uvAtlas = fract(texCoord) * atlasScale + vertexOutput.vUvRegion.xy;\n return uvAtlas;\n #elif HAS_KHR_TEXTURE_TRANSFORM\n let uniforms = textureTransformUniforms;\n return khr_tex_transformTexCoord(texCoord, uniforms.offset, uniforms.rotation, uniforms.scale);\n #else\n return texCoord;\n #endif\n}\n"
24682
+ frag: "\n#ifdef HAS_KHR_TEXTURE_TRANSFORM\n struct TextureTransformUniforms {\n offset: vec2f,\n rotation: f32,\n scale: vec2f,\n };\n\n @group(0) @binding($b) var<uniform> textureTransformUniforms: TextureTransformUniforms;\n\n fn khr_tex_transformTexCoord(texCoords: vec2f, offset: vec2f, rotation: f32, scale: vec2f) -> vec2f {\n rotation = -rotation;\n let transform = mat3x3f(\n cos(rotation) * scale.x, sin(rotation) * scale.x, 0.0,\n -sin(rotation) * scale.y, cos(rotation) * scale.y, 0.0,\n offset.x, offset.y, 1.0\n );\n let transformedTexCoords = (transform * vec3f(fract(texCoords), 1.0)).xy;\n return transformedTexCoords;\n }\n#endif\n\nfn computeTexCoord(texCoord: vec2f, vertexOutput: VertexOutput) -> vec2f {\n #ifdef HAS_I3S_UVREGION\n let atlasScale = vertexOutput.vUvRegion.zw - vertexOutput.vUvRegion.xy;\n let uvAtlas = fract(texCoord) * atlasScale + vertexOutput.vUvRegion.xy;\n return uvAtlas;\n #elif HAS_KHR_TEXTURE_TRANSFORM\n let uniforms = textureTransformUniforms;\n return khr_tex_transformTexCoord(texCoord, uniforms.offset, uniforms.rotation, uniforms.scale);\n #else\n return texCoord;\n #endif\n}\n"
24659
24683
  },
24660
24684
  fbo_picking: {
24661
24685
  vert: "\n//--------------------------\n// Picking\n//\n// #define ENABLE_PICKING 整型 是否开启PICKING\n//\n// uniform int batchId geometry的批次id\n//\n//\n// fn fbo_picking_setData(viewPosZ: f32, visible: bool)\n// 设置picking数据,必须在设置gl_Position后调用\n//\n// 示例:\n// fbo_picking_setData(output.position.w, true);\n//--------------------------\n\n#ifdef ENABLE_PICKING\n#if HAS_PICKING_ID == 2\n struct PickingUniforms {\n uPickingId: f32,\n }\n @group(0) @binding($b) var<uniform> pickingUniforms: PickingUniforms;\n#endif\n#endif\n\nfn fbo_picking_setData(input: VertexInput, output: ptr<function, VertexOutput>, viewPosZ: f32, visible: bool) {\n #ifdef ENABLE_PICKING\n #if HAS_PICKING_ID == 1\n output.vPickingId = input.aPickingId;\n #elif HAS_PICKING_ID == 2\n output.vPickingId = pickingUniforms.uPickingId;\n #endif\n output.vFbo_picking_viewZ = viewPosZ;\n output.vFbo_picking_visible = select(0.0, 1.0, visible);\n #endif\n output.vFbo_picking_fragDepth = viewPosZ + 1.0;\n}\n",
@@ -24712,7 +24736,7 @@
24712
24736
  frag: "\n#ifdef HAS_TERRAIN_NORMAL\nstruct TerrainNormalUniforms {\n terrainHeightMapResolution: vec2f,\n terrainResolution: vec2f,\n terrainHeightScale: f32,\n terrainTileResolution: f32,\n terrainUnpackFactors: vec4f\n};\n\n@group(0) @binding($b) var<uniform> terrainNormalUniforms: TerrainNormalUniforms;\n@group(0) @binding($b) var terrainHeightTexture: texture_2d<f32>;\n@group(0) @binding($b) var terrainHeightSampler: sampler;\n\nfn getHeight(uv: vec2f) -> f32 {\n let color = textureSample(terrainHeightTexture, terrainHeightSampler, uv) * 255.0;\n let colorWithAlpha = vec4f(color.rgb, -1.0);\n return dot(colorWithAlpha, terrainNormalUniforms.terrainUnpackFactors) / 4.0;\n}\n\nfn convertTerrainHeightToNormalMap(uv: vec2f) -> vec3f {\n let flippedUV = vec2f(uv.x, 1.0 - uv.y);\n let epsilon = 1.0 / terrainNormalUniforms.terrainHeightMapResolution;\n\n let a = getHeight(flippedUV + vec2f(-epsilon.x, -epsilon.y));\n let b = getHeight(flippedUV + vec2f(0.0, -epsilon.y));\n let c = getHeight(flippedUV + vec2f(epsilon.x, -epsilon.y));\n let d = getHeight(flippedUV + vec2f(-epsilon.x, 0.0));\n let e = getHeight(flippedUV + vec2f(epsilon.x, 0.0));\n let f = getHeight(flippedUV + vec2f(-epsilon.x, epsilon.y));\n let g = getHeight(flippedUV + vec2f(0.0, epsilon.y));\n let h = getHeight(flippedUV + vec2f(epsilon.x, epsilon.y));\n\n let dxy = vec2f(\n (c + e + e + h) - (a + d + d + f),\n (f + g + g + h) - (a + b + b + c)\n );\n return normalize(vec3f(dxy / epsilon, terrainNormalUniforms.terrainResolution.x));\n}\n#endif\n"
24713
24737
  },
24714
24738
  mesh_picking: {
24715
- vert: "\n#include <fbo_picking_vert>\n#include <get_output>\n\nstruct VertexInput {\n @location($i) aPosition: vec3f,\n}\n\nstruct Uniforms {\n projViewModelMatrix: mat4x4f,\n modelMatrix: mat4x4f,\n positionMatrix: mat4x4f,\n}\n\n@group(0) @binding($b) var<uniform> uniforms: Uniforms;\n\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n // 其他varying变量可以在这里添加\n}\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n\n let localPositionMatrix = getPositionMatrix(input, &output, uniforms.modelMatrix);\n let localPosition = getPosition(vec3f(input.aPosition.xyz), input);\n\n output.position = uniforms.projViewModelMatrix * localPositionMatrix * localPosition;\n // 传入Position的depth值\n fbo_picking_setData(input, &output, output.position.w, true);\n\n return output;\n}\n"
24739
+ vert: "\n#include <fbo_picking_vert>\n#include <get_output>\n\nstruct VertexInput {\n #ifdef POSITION_IS_INT\n @location($i) aPosition: vec4i,\n #else\n @location($i) aPosition: vec3f,\n #endif\n}\n\nstruct Uniforms {\n projViewModelMatrix: mat4x4f,\n modelMatrix: mat4x4f,\n positionMatrix: mat4x4f,\n}\n\n@group(0) @binding($b) var<uniform> uniforms: Uniforms;\n\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n // 其他varying变量可以在这里添加\n}\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n\n let localPositionMatrix = getPositionMatrix(input, &output, uniforms.modelMatrix);\n let localPosition = getPosition(vec3f(input.aPosition.xyz), input);\n\n output.position = uniforms.projViewModelMatrix * localPositionMatrix * localPosition;\n // 传入Position的depth值\n fbo_picking_setData(input, &output, output.position.w, true);\n\n return output;\n}\n"
24716
24740
  }
24717
24741
  };
24718
24742
 
@@ -25052,7 +25076,7 @@
25052
25076
  let n;
25053
25077
  this.texture && (this.texture.destroy(), this._clearBindGroups());
25054
25078
  {
25055
- let r = e.width, i = e.height;
25079
+ let r = k(e.width) ? e.width() : e.width, i = k(e.height) ? e.height() : e.height;
25056
25080
  if (void 0 === r || void 0 === i) {
25057
25081
  const t = e.data;
25058
25082
  if (H(e.data)) {
@@ -25216,10 +25240,10 @@
25216
25240
  const t = n[e];
25217
25241
  if (t) if (t.isGlobal) {
25218
25242
  let e = this._shaderUniforms.index;
25219
- this._shaderUniforms[e++] = t, this._shaderUniforms.index = e, this._shaderUniforms.totalSize += Be(t.size, this.alignment);
25243
+ this._shaderUniforms[e++] = t, this._shaderUniforms.index = e, this._shaderUniforms.totalSize += Ue(t.size, this.alignment);
25220
25244
  } else {
25221
25245
  let e = this._meshUniforms.index;
25222
- this._meshUniforms[e++] = t, this._meshUniforms.index = e, this._meshUniforms.totalSize += Be(t.size, this.alignment);
25246
+ this._meshUniforms[e++] = t, this._meshUniforms.index = e, this._meshUniforms.totalSize += Ue(t.size, this.alignment);
25223
25247
  }
25224
25248
  }
25225
25249
  }
@@ -25247,7 +25271,7 @@
25247
25271
  } else if (s.resourceType === rn.Texture) {
25248
25272
  const r = n && n[h] || t.getUniform(h) || t.material && t.material.getUniform(h);
25249
25273
  let i = r;
25250
- if (i instanceof oe && (i = r.getREGLTexture(e)), i instanceof gi && (i = i.colorTexture),
25274
+ if (i instanceof ie && (i = r.getREGLTexture(e)), i instanceof gi && (i = i.colorTexture),
25251
25275
  !i) continue;
25252
25276
  c.push(i), l.push({
25253
25277
  binding: s.binding,
@@ -25259,7 +25283,7 @@
25259
25283
  binding: s.binding,
25260
25284
  resource: {
25261
25285
  buffer: e.gpuBuffer,
25262
- size: Be(s.size, this.alignment)
25286
+ size: Ue(s.size, this.alignment)
25263
25287
  }
25264
25288
  });
25265
25289
  }
@@ -25454,7 +25478,7 @@
25454
25478
  const f = c.getBindGroups();
25455
25479
  let d = [];
25456
25480
  u && (d = u.getBindGroups());
25457
- const m = this._createBindGroupLayout(f, d, n, this.uniformValues), g = this._createPipeline(r, o, h, s, m, n, e, t), p = this._createBindGroupMapping(f, d, n), _ = r.wgpu.limits.minUniformBufferOffsetAlignment;
25481
+ const m = this._createCommandBindGroupLayout(f, d, n, this.uniformValues), g = this._createCommandPipeline(r, o, h, s, m, n, e, t), p = this._createBindGroupMapping(f, d, n), _ = r.wgpu.limits.minUniformBufferOffsetAlignment;
25458
25482
  return {
25459
25483
  uid: -1,
25460
25484
  layout: m,
@@ -25472,7 +25496,7 @@
25472
25496
  } ];
25473
25497
  return e.key = e.map((e => e.name)).join(), e;
25474
25498
  }
25475
- _createBindGroupLayout(e, t, n, r) {
25499
+ _createCommandBindGroupLayout(e, t, n, r) {
25476
25500
  const i = [];
25477
25501
  for (let t = 0; t < e.length; t++) {
25478
25502
  const o = e[t];
@@ -25509,14 +25533,16 @@
25509
25533
  }
25510
25534
  if (n.resourceType === rn.Texture) {
25511
25535
  const o = n.name, s = i[o] || r.material && r.material.get(o);
25512
- let a;
25513
- s && (s instanceof Gr ? a = s.config.type : s instanceof mi && (a = s.gpuFormat.format));
25514
- let l = "float";
25515
- return a && a.startsWith("depth") && (l = "depth"), {
25536
+ let a, l = !1;
25537
+ s && (s instanceof Vr ? a = s.config.type : s instanceof mi && (a = s.gpuFormat.format),
25538
+ l = !!(s.config && s.config.sampleCount > 1));
25539
+ let c = l ? "unfilterable-float" : "float";
25540
+ return a && a.startsWith("depth") && (c = "depth"), {
25516
25541
  binding: e,
25517
25542
  visibility: t,
25518
25543
  texture: {
25519
- sampleType: l
25544
+ multisampled: l,
25545
+ sampleType: c
25520
25546
  }
25521
25547
  };
25522
25548
  }
@@ -25578,7 +25604,7 @@
25578
25604
  e.groups = e.groups || [], e.groups[s] = e.groups[s] || [], o.isGlobal = c, o.index = e.groups[s][a] = o;
25579
25605
  }
25580
25606
  }
25581
- _createPipeline(e, t, n, r, i, o, s, a) {
25607
+ _createCommandPipeline(e, t, n, r, i, o, s, a) {
25582
25608
  const l = e.wgpu, c = l.createShaderModule({
25583
25609
  label: this.name + "-vertmodule",
25584
25610
  code: t
@@ -25715,7 +25741,7 @@
25715
25741
  }
25716
25742
  }
25717
25743
 
25718
- const Di = "function", Fi = "array";
25744
+ const Fi = "function", Di = "array";
25719
25745
 
25720
25746
  let Ui = 0;
25721
25747
 
@@ -25734,14 +25760,14 @@
25734
25760
  for (let e = 0, t = i.length; e < t; e++) {
25735
25761
  const t = i[e];
25736
25762
  if (M(t)) if (t.indexOf("[") > 0) {
25737
- const {name: e, len: n} = Gi(t);
25763
+ const {name: e, len: n} = Vi(t);
25738
25764
  this.contextDesc[e] = {
25739
25765
  name: e,
25740
25766
  type: "array",
25741
25767
  length: n
25742
25768
  };
25743
25769
  } else this.contextDesc[t] = null; else if (t.name.indexOf("[") > 0) {
25744
- const {name: e, len: n} = Gi(t.name);
25770
+ const {name: e, len: n} = Vi(t.name);
25745
25771
  this.contextDesc[e] = {
25746
25772
  name: e,
25747
25773
  type: "array",
@@ -25803,11 +25829,11 @@
25803
25829
  }
25804
25830
  _insertDefines(e, t) {
25805
25831
  const n = [];
25806
- for (const e in t) U(t, e) && !k(t[e]) && n.push(`#define ${e} ${t[e]}\n`);
25832
+ for (const e in t) D(t, e) && !k(t[e]) && n.push(`#define ${e} ${t[e]}\n`);
25807
25833
  return n.join("") + e;
25808
25834
  }
25809
25835
  createMeshCommand(e, t, n = {}, r) {
25810
- const i = t.getDefines(), o = t.getElements(), s = t instanceof pr, a = t.disableVAO, l = F(e) && !a, c = E({}, this.shaderDefines || {}, i || {}), h = this._insertDefines(this.vert, c), u = this.getVersion(e, h) + h, f = this._insertDefines(this.frag, c), d = this.getVersion(e, f) + f, m = X(u) + "_" + X(d), {activeAttributes: g, activeUniforms: p} = this.getActiveVars(e, u, d, m), _ = {};
25836
+ const i = t.getDefines(), o = t.getElements(), s = t instanceof pr, a = t.disableVAO, l = F(e) && !a, c = E({}, this.shaderDefines || {}, i || {}), h = this._insertDefines(this.vert, c), u = this.getVersion(e, h) + h, f = this._insertDefines(this.frag, c), d = this.getVersion(e, f) + f, m = q(u) + "_" + q(d), {activeAttributes: g, activeUniforms: p} = this.getActiveVars(e, u, d, m), _ = {};
25811
25837
  g.forEach(((t, n) => {
25812
25838
  const r = t.name;
25813
25839
  _[r] = l ? n : e.prop(r);
@@ -25817,7 +25843,7 @@
25817
25843
  v[t] = e.prop(t);
25818
25844
  }));
25819
25845
  const x = this.contextDesc;
25820
- for (const t in x) if (x[t] && x[t].type === Di) v[t] = x[t].fn; else if (x[t] && x[t].type === Fi) {
25846
+ for (const t in x) if (x[t] && x[t].type === Fi) v[t] = x[t].fn; else if (x[t] && x[t].type === Di) {
25821
25847
  const n = x[t].name, r = x[t].length;
25822
25848
  for (let t = 0; t < r; t++) {
25823
25849
  const r = `${n}[${t}]`;
@@ -25840,7 +25866,7 @@
25840
25866
  dispose() {
25841
25867
  for (const e in this.commands) {
25842
25868
  const t = this.commands[e];
25843
- t && (t.destroy && !t[ee] && (t[ee] = !0, t.destroy()));
25869
+ t && (t.destroy && !t[Q] && (t[Q] = !0, t.destroy()));
25844
25870
  }
25845
25871
  this.commands = {}, delete this.vert, delete this.frag;
25846
25872
  }
@@ -25871,7 +25897,7 @@
25871
25897
  }
25872
25898
  }
25873
25899
 
25874
- function Gi(e) {
25900
+ function Vi(e) {
25875
25901
  const t = e.indexOf("["), n = e.indexOf("]");
25876
25902
  return {
25877
25903
  name: e.substring(0, t),
@@ -25879,7 +25905,7 @@
25879
25905
  };
25880
25906
  }
25881
25907
 
25882
- const Vi = new ui;
25908
+ const Gi = new ui;
25883
25909
 
25884
25910
  class ji extends zi {
25885
25911
  getShaderCommandKey(e, t, n) {
@@ -25889,14 +25915,14 @@
25889
25915
  const {funcs: t, key: r, commandKey: i} = e;
25890
25916
  if (!t.length) return i;
25891
25917
  const o = t.map((e => e(null, n)));
25892
- if (Vi.generateValuesKey(o) === r) return i;
25918
+ if (Gi.generateValuesKey(o) === r) return i;
25893
25919
  }
25894
25920
  const r = this._gpuFramebuffer, i = this.extraCommandProps;
25895
- Vi.readFromREGLCommand(i, t, n, r);
25896
- const o = Vi.getSignatureKey();
25921
+ Gi.readFromREGLCommand(i, t, n, r);
25922
+ const o = Gi.getSignatureKey();
25897
25923
  return t.setShaderFnValues(this.uid, {
25898
- funcs: Vi.functionProps.map((e => e.func)),
25899
- key: Vi.getFnValuesKey(),
25924
+ funcs: Gi.functionProps.map((e => e.func)),
25925
+ key: Gi.getFnValuesKey(),
25900
25926
  commandKey: o
25901
25927
  }), o;
25902
25928
  }
@@ -26043,11 +26069,12 @@
26043
26069
 
26044
26070
  var qi = "#if __VERSION__ == 300\n#define attribute in\n#define varying out\n#endif\nattribute vec2 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_Position = vec4(aPosition, 0., 1.);\n vTexCoord = aTexCoord;\n}";
26045
26071
 
26046
- const Xi = new Int8Array([ -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1 ]), $i = new Uint8Array([ 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0 ]);
26072
+ const Xi = new Float32Array([ -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1 ]), $i = new Float32Array([ 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0 ]);
26047
26073
 
26048
26074
  class Ki extends Wi {
26049
26075
  constructor(e) {
26050
- e.vert = e.vert || qi, e.extraCommandProps = e.extraCommandProps || {}, e.extraCommandProps.depth || (e.extraCommandProps.depth = {
26076
+ e.vert = e.vert || qi, e.wgslVert = e.wgslVert || "struct VertexOutput {\n @builtin(position) position : vec4f,\n @location($o) vTexCoord: vec2f\n}\n@vertex\nfn main(\n @location($i) aPosition: vec2f,\n @location($i) aTexCoord: vec2f\n) -> VertexOutput {\n var output: VertexOutput;\n output.position = vec4f(aPosition, 0., 1.);\n output.vTexCoord = aTexCoord;\n return output;\n}",
26077
+ e.extraCommandProps = e.extraCommandProps || {}, e.extraCommandProps.depth || (e.extraCommandProps.depth = {
26051
26078
  enable: !1,
26052
26079
  mask: !1
26053
26080
  }), e.extraCommandProps.stencil || (e.extraCommandProps.stencil = {
@@ -26063,7 +26090,7 @@
26063
26090
  this.commands[t + "_quad"];
26064
26091
  }
26065
26092
  _createQuadMesh(e) {
26066
- const t = new Xe({
26093
+ const t = new qe({
26067
26094
  aPosition: Xi,
26068
26095
  aTexCoord: $i
26069
26096
  }, null, Xi.length / 2, {
@@ -26084,8 +26111,9 @@
26084
26111
  class Yi extends Ki {
26085
26112
  constructor() {
26086
26113
  super({
26087
- vert: qi,
26114
+ name: "fxaa",
26088
26115
  frag: "#define SHADER_NAME FXAA\nprecision mediump float;\nvarying vec2 vTexCoord;\nuniform float enableFXAA;\nuniform float enableToneMapping;\nuniform float enableSharpen;\nuniform vec2 resolution;\nuniform sampler2D textureSource;\n#ifdef HAS_NOAA_TEX\nuniform sampler2D noAaTextureSource;\n#endif\n#ifdef HAS_POINT_TEX\nuniform sampler2D pointTextureSource;\n#endif\n#ifdef HAS_TAA_TEX\nuniform sampler2D taaTextureSource;\n#ifdef HAS_FXAA_TEX\nuniform sampler2D fxaaTextureSource;\n#endif\n#endif\nuniform float pixelRatio;\nuniform float sharpFactor;\n#ifdef HAS_OUTLINE_TEX\nuniform sampler2D textureOutline;\nuniform float enableOutline;\nuniform float highlightFactor;\nuniform float outlineFactor;\nuniform float outlineWidth;\nuniform vec3 outlineColor;\n#endif\nvec2 c;\nvec4 d(vec2 e) {\n \n#ifdef HAS_TAA_TEX\nvec4 f = texture2D(textureSource, e);\n vec4 taa = texture2D(taaTextureSource, e);\n#ifdef HAS_FXAA_TEX\nvec4 h = texture2D(fxaaTextureSource, e);\n#else\nvec4 h = vec4(.0);\n#endif\nvec4 i = taa + f * (1. - taa.a);\n return h + i * (1. - h.a);\n#else\nreturn texture2D(textureSource, e);\n#endif\n}\nvec3 j(const in vec3 k, const float l) {\n vec2 m = pixelRatio / resolution.xy;\n float n = .0;\n vec4 o = texture2D(textureSource, c + m * vec2(-1., -1.));\n o.rgb = mix(vec3(.0), o.rgb, sign(o.a));\n n += mix(.0, 1., sign(o.a));\n vec4 u = texture2D(textureSource, c + m * vec2(1.));\n u.rgb = mix(vec3(.0), u.rgb, sign(u.a));\n n += mix(.0, 1., sign(u.a));\n vec4 v = texture2D(textureSource, c + m * vec2(1., -1.));\n v.rgb = mix(vec3(.0), v.rgb, sign(v.a));\n n += mix(.0, 1., sign(v.a));\n vec4 A = texture2D(textureSource, c + m * vec2(-1., 1.));\n A.rgb = mix(vec3(.0), A.rgb, sign(A.a));\n n += mix(.0, 1., sign(A.a));\n return k + l * (n * k - o.rgb - v.rgb - A.rgb - u.rgb);\n}\nvec4 B(const in vec4 k) {\n return vec4(j(k.rgb, sharpFactor), k.a);\n}\nvec3 C(const vec3 x) {\n const float a = 2.51;\n const float b = .03;\n const float D = 2.43;\n const float E = .59;\n const float F = .14;\n return (x * (a * x + b)) / (x * (D * x + E) + F);\n}\nvec3 G(vec3 k) {\n k = k / (k + vec3(1.));\n return k = pow(k, vec3(1. / 2.2));\n}\n#ifdef HAS_OUTLINE_TEX\nvec4 H() {\n float I = 2.;\n float J = 1.;\n float K = pixelRatio / resolution[0] * outlineWidth;\n float L = pixelRatio / resolution[1] * outlineWidth;\n vec4 M = (texture2D(textureOutline, c + vec2(K, L)));\n vec4 N = (texture2D(textureOutline, c + vec2(K, .0)));\n vec4 O = (texture2D(textureOutline, c + vec2(K, -L)));\n vec4 P = (texture2D(textureOutline, c + vec2(.0, -L)));\n vec4 Q = (texture2D(textureOutline, c + vec2(-K, -L)));\n vec4 R = (texture2D(textureOutline, c + vec2(-K, .0)));\n vec4 S = (texture2D(textureOutline, c + vec2(-K, L)));\n vec4 T = (texture2D(textureOutline, c + vec2(.0, L)));\n vec4 U = -I * R + I * N + -J * S + J * M + -J * Q + J * O;\n vec4 V = -I * P + I * T + -J * Q + J * S + -J * O + J * M;\n float W = sqrt(dot(V, V) + dot(U, U));\n bool X = W < 1. / 65025.;\n vec3 Y = (texture2D(textureOutline, c)).r * outlineColor;\n if(Y == vec3(.0) || (highlightFactor == .0 && X)) {\n return vec4(.0);\n }\n float Z = X ? highlightFactor : min(1., sqrt(W) * outlineFactor);\n return Z * vec4(Y, 1.);\n}\nvec4 ba(const in vec4 k) {\n vec4 H = H();\n return H + vec4(k) * (1. - H.a);\n}\n#endif\nvoid main() {\n c = vTexCoord;\n vec4 k;\n if(enableFXAA == 1.) {\n \n } else {\n k = d(vTexCoord);\n }\n if(enableSharpen == 1.) {\n k = B(k);\n }\n#if defined(HAS_NOAA_TEX) || defined(HAS_POINT_TEX)\nvec4 bb = vec4(.0);\n vec4 bc = vec4(.0);\n#ifdef HAS_POINT_TEX\nbb = texture2D(pointTextureSource, vTexCoord);\n#endif\n#ifdef HAS_NOAA_TEX\nbc = texture2D(noAaTextureSource, vTexCoord);\n#endif\nvec4 bd = bb + bc * (1. - bb.a);\n k = bd + k * (1. - bd.a);\n#endif\nif(enableToneMapping == 1.) {\n k.rgb = G(k.rgb);\n }\n#ifdef HAS_OUTLINE_TEX\nk = ba(k);\n#endif\ngl_FragColor = k;\n}",
26116
+ wgslFrag: "struct VertexOutput {\n @location($o) vTexCoord: vec2f\n}\nstruct FxaaUniforms {\n enableFXAA: f32,\n enableToneMapping: f32,\n enableSharpen: f32,\n resolution: vec2f,\n pixelRatio: f32,\n sharpFactor: f32,\n #ifdef HAS_OUTLINE_TEX\n enableOutline: f32,\n highlightFactor: f32,\n outlineFactor: f32,\n outlineWidth: f32,\n outlineColor: vec3f,\n #endif\n};\n@binding($b) @group(0) var<uniform> uniforms: FxaaUniforms;\n#ifdef HAS_MULTISAMPLED\n@binding($b) @group(0) var textureSource: texture_multisampled_2d<f32>;\n#else\n@binding($b) @group(0) var textureSource: texture_2d<f32>;\n#endif\n@binding($b) @group(0) var textureSourceSampler: sampler;\n#ifdef HAS_OUTLINE_TEX\n#ifdef HAS_MULTISAMPLED\n@binding($b) @group(0) var textureOutline: texture_multisampled_2d<f32>;\n#else\n@binding($b) @group(0) var textureOutline: texture_2d<f32>;\n#endif\n@binding($b) @group(0) var textureOutlineSampler: sampler;\n#endif\nvar<private> gTexCoord: vec2f;\nfn fetchSourceTexel(uv: vec2f) -> vec4f {\n let flipUV = vec2f(uv.x, 1.0 - uv.y);\n#ifdef HAS_MULTISAMPLED\n return textureLoad(textureSource, vec2i(flipUV * vec2f(uniforms.resolution)), 0);\n#else\n return textureSample(textureSource, textureSourceSampler, flipUV);\n#endif\n}\n#ifdef HAS_OUTLINE_TEX\n fn fetchOutlineTexel(uv: vec2f) -> vec4f {\n let flipUV = vec2f(uv.x, 1.0 - uv.y);\n #ifdef HAS_MULTISAMPLED\n return textureLoad(textureOutline, vec2i(flipUV * vec2f(uniforms.resolution)), 0);\n #else\n return textureSample(textureOutline, textureOutlineSampler, flipUV);\n #endif\n }\n#endif\nfn readFXAATexture(uv: vec2f) -> vec4f {\n return fetchSourceTexel(uv);\n}\nfn sharpColorFactor(color: vec3f, sharp: f32) -> vec3f {\n let off = uniforms.pixelRatio / uniforms.resolution;\n var count: f32 = 0.0;\n let rgbNW = fetchSourceTexel(gTexCoord + off * vec2f(-1.0, -1.0));\n let rgbNW_rgb = select(vec3f(0.0), rgbNW.rgb, rgbNW.a > 0.0);\n count += select(0.0, 1.0, rgbNW.a > 0.0);\n let rgbSE = fetchSourceTexel(gTexCoord + off * vec2f(1.0, 1.0));\n let rgbSE_rgb = select(vec3f(0.0), rgbSE.rgb, rgbSE.a > 0.0);\n count += select(0.0, 1.0, rgbSE.a > 0.0);\n let rgbNE = fetchSourceTexel(gTexCoord + off * vec2f(1.0, -1.0));\n let rgbNE_rgb = select(vec3f(0.0), rgbNE.rgb, rgbNE.a > 0.0);\n count += select(0.0, 1.0, rgbNE.a > 0.0);\n let rgbSW = fetchSourceTexel(gTexCoord + off * vec2f(-1.0, 1.0));\n let rgbSW_rgb = select(vec3f(0.0), rgbSW.rgb, rgbSW.a > 0.0);\n count += select(0.0, 1.0, rgbSW.a > 0.0);\n return color + sharp * (count * color - rgbNW_rgb - rgbNE_rgb - rgbSW_rgb - rgbSE_rgb);\n}\nfn sharpen(color: vec4f) -> vec4f {\n return vec4f(sharpColorFactor(color.rgb, uniforms.sharpFactor), color.a);\n}\nfn HDR_ACES(x: vec3f) -> vec3f {\n let a: f32 = 2.51;\n let b: f32 = 0.03;\n let c: f32 = 2.43;\n let d: f32 = 0.59;\n let e: f32 = 0.14;\n return (x * (a * x + b)) / (x * (c * x + d) + e);\n}\nfn tonemap(color: vec3f) -> vec3f {\n var result = color / (color + vec3f(1.0));\n result = pow(result, vec3f(1.0 / 2.2));\n return result;\n}\n#ifdef HAS_OUTLINE_TEX\nfn outline() -> vec4f {\n let offsetx = uniforms.pixelRatio / uniforms.resolution.x * uniforms.outlineWidth;\n let offsety = uniforms.pixelRatio / uniforms.resolution.y * uniforms.outlineWidth;\n let fac0: f32 = 2.0;\n let fac1: f32 = 1.0;\n let texel0 = fetchOutlineTexel(gTexCoord + vec2f(offsetx, offsety));\n let texel1 = fetchOutlineTexel(gTexCoord + vec2f(offsetx, 0.0));\n let texel2 = fetchOutlineTexel(gTexCoord + vec2f(offsetx, -offsety));\n let texel3 = fetchOutlineTexel(gTexCoord + vec2f(0.0, -offsety));\n let texel4 = fetchOutlineTexel(gTexCoord + vec2f(-offsetx, -offsety));\n let texel5 = fetchOutlineTexel(gTexCoord + vec2f(-offsetx, 0.0));\n let texel6 = fetchOutlineTexel(gTexCoord + vec2f(-offsetx, offsety));\n let texel7 = fetchOutlineTexel(gTexCoord + vec2f(0.0, offsety));\n let rowx = -fac0 * texel5 + fac0 * texel1 + -fac1 * texel6 + fac1 * texel0 + -fac1 * texel4 + fac1 * texel2;\n let rowy = -fac0 * texel3 + fac0 * texel7 + -fac1 * texel4 + fac1 * texel6 + -fac1 * texel2 + fac1 * texel0;\n let magSqr = sqrt(dot(rowy, rowy) + dot(rowx, rowx));\n let infMag = magSqr < 1.0 / 65025.0;\n let texelCenter = fetchOutlineTexel(gTexCoord).r * uniforms.outlineColor;\n if (all(texelCenter == vec3f(0.0)) || (uniforms.highlightFactor == 0.0 && infMag)) {\n return vec4f(0.0);\n }\n let finalFactor = select(min(1.0, sqrt(magSqr) * uniforms.outlineFactor), uniforms.highlightFactor, infMag);\n return finalFactor * vec4f(texelCenter, 1.0);\n}\nfn composeOutline(color: vec4f) -> vec4f {\n let outlineColor = outline();\n return outlineColor + color * (1.0 - outlineColor.a);\n}\n#endif\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n gTexCoord = vertexOutput.vTexCoord;\n var color: vec4f;\n if (uniforms.enableFXAA == 1.0) {\n color = readFXAATexture(vertexOutput.vTexCoord);\n } else {\n color = readFXAATexture(vertexOutput.vTexCoord);\n }\n if (uniforms.enableSharpen == 1.0) {\n color = sharpen(color);\n }\n if (uniforms.enableToneMapping == 1.0) {\n color = vec4(tonemap(color.rgb), color.a);\n }\n #ifdef HAS_OUTLINE_TEX\n if (uniforms.enableOutline == 1.0) {\n color = composeOutline(color);\n }\n #endif\n return color;\n}",
26089
26117
  extraCommandProps: {
26090
26118
  viewport: {
26091
26119
  x: 0,
@@ -26609,7 +26637,7 @@
26609
26637
  return this._skyboxMesh || this._createSkyboxMesh(e), super.draw(e, this._skyboxMesh);
26610
26638
  }
26611
26639
  _createSkyboxMesh(e) {
26612
- const t = new Xe({
26640
+ const t = new qe({
26613
26641
  aPosition: new Int8Array(ho)
26614
26642
  }, null, ho.length / 3);
26615
26643
  t.generateBuffers(e), this._skyboxMesh = [ new gr(t) ], this._meshDefines && (this._skyboxMesh[0].setDefines(this._meshDefines),
@@ -26657,7 +26685,6 @@
26657
26685
  class go extends Ki {
26658
26686
  constructor() {
26659
26687
  super({
26660
- vert: qi,
26661
26688
  frag: "precision highp float;\nuniform sampler2D texture;\nuniform vec2 size;\nuniform float enableSharpen;\nuniform float sharpFactor;\nuniform float pixelRatio;\nvec2 c;\nvec3 d(const in vec3 e, const float f) {\n vec2 h = pixelRatio / size.xy;\n float i = .0;\n vec4 j = texture2D(texture, c + h * vec2(-1., -1.));\n j.rgb = mix(vec3(.0), j.rgb, sign(j.a));\n i += mix(.0, 1., sign(j.a));\n vec4 k = texture2D(texture, c + h * vec2(1.));\n k.rgb = mix(vec3(.0), k.rgb, sign(k.a));\n i += mix(.0, 1., sign(k.a));\n vec4 l = texture2D(texture, c + h * vec2(1., -1.));\n l.rgb = mix(vec3(.0), l.rgb, sign(l.a));\n i += mix(.0, 1., sign(l.a));\n vec4 m = texture2D(texture, c + h * vec2(-1., 1.));\n m.rgb = mix(vec3(.0), m.rgb, sign(m.a));\n i += mix(.0, 1., sign(m.a));\n return e + f * (i * e - j.rgb - l.rgb - m.rgb - k.rgb);\n}\nvoid main() {\n c = gl_FragCoord.xy / size;\n vec4 e = texture2D(texture, c);\n if(enableSharpen == 1.) {\n e.rgb = d(e.rgb, sharpFactor);\n }\n gl_FragColor = e;\n}",
26662
26689
  extraCommandProps: {
26663
26690
  viewport: {
@@ -26799,7 +26826,7 @@
26799
26826
  this._fixZoom = e.getZoom();
26800
26827
  const t = 800 * Math.pow(2, 16.685648411389433 - this._fixZoom), n = [ -t, 0, -t, t, 0, -t, -t, 0, t, t, 0, t ], r = {};
26801
26828
  r.POSITION = n, r.NORMAL = [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ], r.TEXCOORD_0 = [ 0, 0, 1, 0, 0, 1, 1, 1 ];
26802
- const i = new Xe(r, [ 3, 1, 0, 0, 2, 3 ], 0, {
26829
+ const i = new qe(r, [ 3, 1, 0, 0, 2, 3 ], 0, {
26803
26830
  positionAttribute: "POSITION",
26804
26831
  normalAttribute: "NORMAL",
26805
26832
  uv0Attribute: "TEXCOORD_0"
@@ -26988,7 +27015,7 @@
26988
27015
  type: "float"
26989
27016
  };
26990
27017
 
26991
- class Do {
27018
+ class Fo {
26992
27019
  constructor(e, t, n) {
26993
27020
  this._regl = e, this.joints = t, this.inverseBindMatrices = [], this.jointMatrices = [],
26994
27021
  this.jointData = new Float32Array(16 * t.length);
@@ -27008,9 +27035,9 @@
27008
27035
  }
27009
27036
  }
27010
27037
 
27011
- const Fo = [ 0, 0, 0 ], Uo = [ 0, 0, 0, 1 ], Bo = [ 1, 1, 1 ], zo = [];
27038
+ const Do = [ 0, 0, 0 ], Uo = [ 0, 0, 0, 1 ], Bo = [ 1, 1, 1 ], zo = [];
27012
27039
 
27013
- class Go {
27040
+ class Vo {
27014
27041
  constructor(e = [ 0, 0, 0 ], t = [ 0, 0, 0, 1 ], n = [ 1, 1, 1 ]) {
27015
27042
  this.translation = e, this.rotation = t, this.scale = n;
27016
27043
  }
@@ -27021,12 +27048,12 @@
27021
27048
  getTranslation$1(this.translation, e), getRotation(this.rotation, e), getScaling(this.scale, e);
27022
27049
  }
27023
27050
  update(e) {
27024
- e && (e.translation && !equals$4(e.translation, Fo) && copy$5(this.translation, e.translation),
27051
+ e && (e.translation && !equals$4(e.translation, Do) && copy$5(this.translation, e.translation),
27025
27052
  e.rotation && !equals$2(e.rotation, Uo) && copy$3(this.rotation, e.rotation), e.scale && !equals$4(e.scale, Bo) && copy$5(this.scale, e.scale));
27026
27053
  }
27027
27054
  }
27028
27055
 
27029
- class Vo {
27056
+ class Go {
27030
27057
  constructor(e) {
27031
27058
  this._init(e);
27032
27059
  }
@@ -27094,7 +27121,7 @@
27094
27121
  this._skinMap = {};
27095
27122
  for (let t = 0; t < e.length; t++) {
27096
27123
  const n = e[t];
27097
- n.joints = n.joints.map((e => this.gltf.nodes[e])), this._skinMap[t] = new Do(this.regl, n.joints, n.inverseBindMatrices.array),
27124
+ n.joints = n.joints.map((e => this.gltf.nodes[e])), this._skinMap[t] = new Fo(this.regl, n.joints, n.inverseBindMatrices.array),
27098
27125
  delete n.inverseBindMatrices;
27099
27126
  }
27100
27127
  }
@@ -27129,12 +27156,12 @@
27129
27156
  e.geometry.dispose();
27130
27157
  for (const t in e.materialInfo) {
27131
27158
  const n = e.materialInfo[t];
27132
- n && n.destroy && !n[ee] && n.destroy();
27159
+ n && n.destroy && !n[Q] && n.destroy();
27133
27160
  }
27134
27161
  }));
27135
27162
  for (const e in this._textureMap) {
27136
27163
  const t = this._textureMap[e];
27137
- t && t.destroy && !t[ee] && t.destroy();
27164
+ t && t.destroy && !t[Q] && t.destroy();
27138
27165
  }
27139
27166
  delete this.gltf;
27140
27167
  }
@@ -27210,7 +27237,7 @@
27210
27237
  _parserNode(e, t, n) {
27211
27238
  if (e.isParsed) return;
27212
27239
  e.nodeMatrix = e.nodeMatrix || identity$2([]), e.localMatrix = e.localMatrix || identity$2([]),
27213
- e.matrix ? (e.trs = new Go, e.trs.decompose(e.matrix)) : e.trs = new Go(e.translation, e.rotation, e.scale),
27240
+ e.matrix ? (e.trs = new Vo, e.trs.decompose(e.matrix)) : e.trs = new Vo(e.translation, e.rotation, e.scale),
27214
27241
  e.localMatrix = e.trs.getMatrix(), n ? multiply$5(e.nodeMatrix, n, e.matrix || e.localMatrix) : copy$6(e.nodeMatrix, e.matrix || e.localMatrix);
27215
27242
  const r = e.nodeMatrix;
27216
27243
  if (e.children) for (let n = 0; n < e.children.length; n++) {
@@ -27220,7 +27247,7 @@
27220
27247
  if (O(e.skin)) {
27221
27248
  this._isAnimation = !0;
27222
27249
  const t = e.skin;
27223
- e.trs = new Go, e.skin = this._skinMap[t];
27250
+ e.trs = new Vo, e.skin = this._skinMap[t];
27224
27251
  }
27225
27252
  if (O(e.mesh)) {
27226
27253
  const n = e.mesh;
@@ -27242,7 +27269,7 @@
27242
27269
  dimension: r[e].itemSize
27243
27270
  }));
27244
27271
  if (e.morphTargets) {
27245
- const e = W(o.POSITION) ? o.POSITION.itemSize * o.POSITION.count : o.POSITION.array.length;
27272
+ const e = j(o.POSITION) ? o.POSITION.itemSize * o.POSITION.count : o.POSITION.array.length;
27246
27273
  for (let t = 0; t < 8; t++) o[`POSITION${t}`] || (o[`POSITION${t}`] = new Float32Array(e).fill(0));
27247
27274
  for (let e = 0; e < 4; e++) {
27248
27275
  const t = o.NORMAL.array ? o.NORMAL.array.length : o.NORMAL.length;
@@ -27251,7 +27278,7 @@
27251
27278
  }
27252
27279
  let s = e.indices;
27253
27280
  s && void 0 === s.bufferView && s.array && (s = s.array);
27254
- const a = new Xe(o, s, 0, {
27281
+ const a = new qe(o, s, 0, {
27255
27282
  primitive: I(e.mode) ? rt(e.mode) : e.mode,
27256
27283
  positionAttribute: "POSITION",
27257
27284
  normalAttribute: "NORMAL",
@@ -27281,7 +27308,7 @@
27281
27308
  numJoints: e.skin.joints.length,
27282
27309
  jointTexture: e.skin.jointTexture
27283
27310
  });
27284
- const l = new Vo(a);
27311
+ const l = new Go(a);
27285
27312
  t.push(l);
27286
27313
  }));
27287
27314
  }
@@ -27329,7 +27356,7 @@
27329
27356
  _toTexture(e) {
27330
27357
  if (!e) return this._emptyTexture;
27331
27358
  const t = e.image.array, n = e.sampler || {}, r = e.image.width, i = e.image.height;
27332
- return new Gr({
27359
+ return new Vr({
27333
27360
  width: r,
27334
27361
  height: i,
27335
27362
  data: t,
@@ -27754,7 +27781,7 @@
27754
27781
  let r = t;
27755
27782
  if (o) {
27756
27783
  r = new Uint16Array(t.length);
27757
- for (let e = 0; e < t.length; e++) r[e] = Math.min(Dr.toHalfFloat(t[e]), 65504);
27784
+ for (let e = 0; e < t.length; e++) r[e] = Math.min(Fr.toHalfFloat(t[e]), 65504);
27758
27785
  }
27759
27786
  d[n] || (d[n] = {
27760
27787
  mipmap: []
@@ -27861,7 +27888,7 @@
27861
27888
  const t = e.read();
27862
27889
  if (r) {
27863
27890
  const e = new Uint16Array(t.length);
27864
- for (let n = 0; n < t.length; n++) e[n] = Math.min(Dr.toHalfFloat(t[n]), 65504);
27891
+ for (let n = 0; n < t.length; n++) e[n] = Math.min(Fr.toHalfFloat(t[n]), 65504);
27865
27892
  a.push(e);
27866
27893
  } else a.push(t);
27867
27894
  })), s.destroy(), c.destroy(), a;
@@ -28052,18 +28079,18 @@
28052
28079
  }
28053
28080
  }
28054
28081
 
28055
- class Hs extends(Dt(Rs)){}
28082
+ class Hs extends(Ft(Rs)){}
28056
28083
 
28057
28084
  function Ls(e, t, n) {
28058
28085
  if (n.ambientUpdate) {
28059
28086
  const {iblTexes: r} = e, i = n.target;
28060
- r ? (Fs(r), e.iblTexes = Ds(t, i)) : e.iblTexes = Ds(t, i), i.getRenderer().setToRedraw();
28087
+ r ? (Ds(r), e.iblTexes = Fs(t, i)) : e.iblTexes = Fs(t, i), i.getRenderer().setToRedraw();
28061
28088
  }
28062
28089
  }
28063
28090
 
28064
28091
  const Ns = [ 0, 0 ];
28065
28092
 
28066
- function Ds(e, t) {
28093
+ function Fs(e, t) {
28067
28094
  const n = t.getLightManager(), r = n && n.getAmbientResource();
28068
28095
  if (!r) return null;
28069
28096
  const i = r.isHDR;
@@ -28090,14 +28117,14 @@
28090
28117
  };
28091
28118
  }
28092
28119
 
28093
- function Fs(e) {
28120
+ function Ds(e) {
28094
28121
  for (const t in e) e[t] && e[t].destroy && e[t].destroy(), delete e[t];
28095
28122
  }
28096
28123
 
28097
28124
  var Us = Object.freeze({
28098
28125
  __proto__: null,
28099
- createIBLTextures: Ds,
28100
- disposeIBLTextures: Fs,
28126
+ createIBLTextures: Fs,
28127
+ disposeIBLTextures: Ds,
28101
28128
  getIBLResOnCanvas: function(e) {
28102
28129
  const {dfgLUT: t, iblTexes: n} = e;
28103
28130
  return {
@@ -28145,7 +28172,7 @@
28145
28172
  }
28146
28173
  e.dfgLUT.mtkRefCount++;
28147
28174
  const r = n.getLightManager();
28148
- return r && r.getAmbientResource() ? (e.iblTexes || (e.iblTexes = Ds(t, n)), {
28175
+ return r && r.getAmbientResource() ? (e.iblTexes || (e.iblTexes = Fs(t, n)), {
28149
28176
  dfgLUT: e.dfgLUT,
28150
28177
  iblTexes: e.iblTexes
28151
28178
  }) : {
@@ -28162,7 +28189,7 @@
28162
28189
  }
28163
28190
  e.dfgLUT.destroy(), delete e.dfgLUT;
28164
28191
  }
28165
- e.iblTexes && n && (Fs(e.iblTexes), delete e.iblTexes);
28192
+ e.iblTexes && n && (Ds(e.iblTexes), delete e.iblTexes);
28166
28193
  }
28167
28194
  });
28168
28195
 
@@ -28203,7 +28230,7 @@
28203
28230
  }
28204
28231
  }
28205
28232
 
28206
- let Gs = null, Vs = null;
28233
+ let Vs = null, Gs = null;
28207
28234
 
28208
28235
  class js {
28209
28236
  constructor(e, {width: t, height: n, blurOffset: r, defines: i}) {
@@ -28224,9 +28251,9 @@
28224
28251
  this.height = t, this;
28225
28252
  }
28226
28253
  _renderShadow(e, t, n, r, i) {
28227
- const o = this.renderer, s = Gs(t);
28254
+ const o = this.renderer, s = Vs(t);
28228
28255
  if (r) for (let e = 4; e < 8; e++) s[e] = r[e - 4];
28229
- const a = Vs(i, s, n);
28256
+ const a = Gs(i, s, n);
28230
28257
  return o.clear({
28231
28258
  color: [ 1, 0, 0, 1 ],
28232
28259
  depth: 1,
@@ -28276,7 +28303,7 @@
28276
28303
  }
28277
28304
  }
28278
28305
 
28279
- Gs = function() {
28306
+ Vs = function() {
28280
28307
  const e = [ [ -1, -1, -1, 1 ], [ 1, -1, -1, 1 ], [ 1, 1, -1, 1 ], [ -1, 1, -1, 1 ], [ -1, -1, 1, 1 ], [ 1, -1, 1, 1 ], [ 1, 1, 1, 1 ], [ -1, 1, 1, 1 ] ], t = new Array(16);
28281
28308
  return function(n) {
28282
28309
  invert$2(t, n);
@@ -28287,7 +28314,7 @@
28287
28314
  }
28288
28315
  return r;
28289
28316
  };
28290
- }(), Vs = function() {
28317
+ }(), Gs = function() {
28291
28318
  let e = new Array(4);
28292
28319
  const t = new Array(3), n = [ 0, 0, 0, 0 ], r = [ 0, 1, 0 ], i = new Array(3);
28293
28320
  let o = new Array(16), s = new Array(16);
@@ -28352,7 +28379,7 @@
28352
28379
 
28353
28380
  let Ks, Ys;
28354
28381
 
28355
- const Zs = [ 1, 1 ], Js = "\n vec3 unpack(highp float f) {\n highp vec3 color;\n color.b = floor(f / 65536.0);\n color.g = floor((f - color.b * 65536.0) / 256.0);\n color.r = f - floor(color.b * 65536.0) - floor(color.g * 256.0);\n // now we have a vec3 with the 3 components in range [0..255]. Let's normalize it!\n return color / 255.0;\n }\n", Qs = "\nfn unpack(f: f32) -> vec3f {\n var color: vec3f;\n color.b = floor(f / 65536.0);\n color.g = floor((f - color.b * 65536.0) / 256.0);\n color.r = f - floor(color.b * 65536.0) - floor(color.g * 256.0);\n return color / 255.0;\n}\n", ea = `\n precision highp float;\n\n varying float vPickingId;\n varying float vFbo_picking_visible;\n\n uniform float fbo_picking_meshId;\n\n ${Js}\n\n void main() {\n if (vFbo_picking_visible == 0.0) {\n discard;\n return;\n }\n gl_FragColor = vec4(unpack(vPickingId), fbo_picking_meshId / 255.0);\n }\n`, ta = `\n ${Qs} // Assuming unpack function is defined in this include\n\n struct PickingUniforms {\n fbo_picking_meshId: f32,\n };\n\n @group(0) @binding($b) var<uniform> pickingUniforms: PickingUniforms;\n\n struct VertexOutput {\n @location($i) vPickingId: f32,\n @location($i) vFbo_picking_visible: f32,\n };\n\n @fragment\n fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n if (vertexOutput.vFbo_picking_visible == 0.0) {\n discard;\n }\n\n let rgb = unpack(vertexOutput.vPickingId);\n let alpha = pickingUniforms.fbo_picking_meshId / 255.0;\n return vec4f(rgb, alpha);\n // return vec4f(1.0, 0.0, 0.0, 1.0);\n }\n`, na = `\n precision highp float;\n\n uniform int fbo_picking_meshId;\n varying float vFbo_picking_visible;\n\n ${Js}\n\n void main() {\n if (vFbo_picking_visible == 0.0) {\n discard;\n return;\n }\n gl_FragColor = vec4(unpack(float(fbo_picking_meshId)), 1.0);\n // gl_FragColor = vec4(unpack(float(35)), 1.0);\n }\n`, ra = `\n ${Qs}\n\n struct PickingUniforms {\n fbo_picking_meshId: f32,\n };\n\n @group(0) @binding(0) var<uniform> pickingUniforms: PickingUniforms;\n\n struct VertexOutput {\n @location($i) vFbo_picking_visible: f32,\n };\n\n @fragment\n fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n if (vertexOutput.vFbo_picking_visible == 0.0) {\n discard;\n }\n\n let meshIdFloat = pickingUniforms.fbo_picking_meshId;\n let rgb = unpack(meshIdFloat);\n\n return vec4f(rgb, 1.0);\n }\n`, ia = `\n precision highp float;\n\n varying float vPickingId;\n varying float vFbo_picking_visible;\n\n ${Js}\n\n void main() {\n if (vFbo_picking_visible == 0.0) {\n discard;\n return;\n }\n gl_FragColor = vec4(unpack(vPickingId), 1.0);\n }\n`, oa = `\n ${Qs}\n\n struct VertexOutput {\n @location($i) vPickingId: f32,\n @location($i) vFbo_picking_visible: f32,\n };\n\n @fragment\n fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n if (vertexOutput.vFbo_picking_visible == 0.0) {\n discard;\n }\n let rgb = unpack(vertexOutput.vPickingId);\n return vec4f(rgb, 1.0);\n }\n`;
28382
+ const Zs = [ 1, 1 ], Js = "\n vec3 unpack(highp float f) {\n highp vec3 color;\n color.b = floor(f / 65536.0);\n color.g = floor((f - color.b * 65536.0) / 256.0);\n color.r = f - floor(color.b * 65536.0) - floor(color.g * 256.0);\n // now we have a vec3 with the 3 components in range [0..255]. Let's normalize it!\n return color / 255.0;\n }\n", Qs = "\nfn unpack(f: f32) -> vec3f {\n var color: vec3f;\n color.b = floor(f / 65536.0);\n color.g = floor((f - color.b * 65536.0) / 256.0);\n color.r = f - floor(color.b * 65536.0) - floor(color.g * 256.0);\n return color / 255.0;\n}\n", ea = `\n precision highp float;\n\n varying float vPickingId;\n varying float vFbo_picking_visible;\n\n uniform float fbo_picking_meshId;\n\n ${Js}\n\n void main() {\n if (vFbo_picking_visible == 0.0) {\n discard;\n return;\n }\n gl_FragColor = vec4(unpack(vPickingId), fbo_picking_meshId / 255.0);\n }\n`, ta = `\n ${Qs} // Assuming unpack function is defined in this include\n\n struct PickingUniforms {\n fbo_picking_meshId: f32,\n };\n\n @group(0) @binding($b) var<uniform> pickingUniforms: PickingUniforms;\n\n struct VertexOutput {\n @location($i) vFbo_picking_visible: f32,\n @location($i) vPickingId: f32,\n };\n\n @fragment\n fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n if (vertexOutput.vFbo_picking_visible == 0.0) {\n discard;\n }\n\n let rgb = unpack(vertexOutput.vPickingId);\n let alpha = pickingUniforms.fbo_picking_meshId / 255.0;\n return vec4f(rgb, alpha);\n // return vec4f(1.0, 0.0, 0.0, 1.0);\n }\n`, na = `\n precision highp float;\n\n uniform int fbo_picking_meshId;\n varying float vFbo_picking_visible;\n\n ${Js}\n\n void main() {\n if (vFbo_picking_visible == 0.0) {\n discard;\n return;\n }\n gl_FragColor = vec4(unpack(float(fbo_picking_meshId)), 1.0);\n // gl_FragColor = vec4(unpack(float(35)), 1.0);\n }\n`, ra = `\n ${Qs}\n\n struct PickingUniforms {\n fbo_picking_meshId: f32,\n };\n\n @group(0) @binding(0) var<uniform> pickingUniforms: PickingUniforms;\n\n struct VertexOutput {\n @location($i) vFbo_picking_visible: f32,\n };\n\n @fragment\n fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n if (vertexOutput.vFbo_picking_visible == 0.0) {\n discard;\n }\n\n let meshIdFloat = pickingUniforms.fbo_picking_meshId;\n let rgb = unpack(meshIdFloat);\n\n return vec4f(rgb, 1.0);\n }\n`, ia = `\n precision highp float;\n\n varying float vFbo_picking_visible;\n varying float vPickingId;\n\n ${Js}\n\n void main() {\n if (vFbo_picking_visible == 0.0) {\n discard;\n return;\n }\n gl_FragColor = vec4(unpack(vPickingId), 1.0);\n }\n`, oa = `\n ${Qs}\n\n struct VertexOutput {\n @location($i) vFbo_picking_visible: f32,\n @location($i) vPickingId: f32,\n };\n\n @fragment\n fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n if (vertexOutput.vFbo_picking_visible == 0.0) {\n discard;\n }\n let rgb = unpack(vertexOutput.vPickingId);\n return vec4f(rgb, 1.0);\n }\n`;
28356
28383
 
28357
28384
  function sa(e, t, n) {
28358
28385
  const r = t[0], i = t[1], o = t[2], s = 1 / (n[3] * r + n[7] * i + n[11] * o + n[15]);
@@ -28439,7 +28466,7 @@
28439
28466
  }
28440
28467
  alloc(e, t) {
28441
28468
  if (this.activeBuffer) {
28442
- const e = Be(this.activeBuffer.size, this.bufferAlignment);
28469
+ const e = Ue(this.activeBuffer.size, this.bufferAlignment);
28443
28470
  this.bufferSize - e < t && this.scheduleSubmit();
28444
28471
  }
28445
28472
  this.activeBuffer || (this.activeBuffer = this.poolBuffers.pop(), this.activeBuffer || (this.activeBuffer = {
@@ -28448,7 +28475,7 @@
28448
28475
  offset: 0,
28449
28476
  size: 0
28450
28477
  }), this.activeBuffer.offset = 0, this.activeBuffer.size = 0);
28451
- const n = this.activeBuffer, r = Be(n.size, this.bufferAlignment);
28478
+ const n = this.activeBuffer, r = Ue(n.size, this.bufferAlignment);
28452
28479
  e.gpuBuffer = n.gpuBuffer, e.offset = r, e.storage = n.storage, n.size = r + t;
28453
28480
  }
28454
28481
  createBuffer(e, t) {
@@ -28489,7 +28516,7 @@
28489
28516
  this.dynamicBufferPool = new da(e, 1048576, i.minUniformBufferOffsetAlignment);
28490
28517
  }
28491
28518
  hasExtension(e) {
28492
- return this._supportedFormats || (this._supportedFormats = q(this.wgpu)), this._supportedFormats[e],
28519
+ return this._supportedFormats || (this._supportedFormats = W(this.wgpu)), this._supportedFormats[e],
28493
28520
  !0;
28494
28521
  }
28495
28522
  getCommandEncoder() {
@@ -28527,7 +28554,7 @@
28527
28554
  this.commandBuffers.length = 0);
28528
28555
  }
28529
28556
  buffer(e) {
28530
- return Xe.createBuffer(this, e, e.name);
28557
+ return qe.createBuffer(this, e, e.name);
28531
28558
  }
28532
28559
  framebuffer(e, t) {
28533
28560
  let n;
@@ -28575,7 +28602,7 @@
28575
28602
  const n = e.getContext("webgpu");
28576
28603
  return n.configure({
28577
28604
  device: s,
28578
- format: "bgra8unorm",
28605
+ format: "rgba8unorm",
28579
28606
  usage: GPUTextureUsage.COPY_DST,
28580
28607
  alphaMode: c[t]
28581
28608
  }), n.getCurrentTexture();
@@ -28600,7 +28627,8 @@
28600
28627
  })), l;
28601
28628
  }
28602
28629
  destroy() {
28603
- this._defaultFramebuffer && (this._defaultFramebuffer.destroy(), delete this._defaultFramebuffer);
28630
+ this._defaultFramebuffer && (this._defaultFramebuffer.destroy(), delete this._defaultFramebuffer),
28631
+ this.dynamicBufferPool && (this.dynamicBufferPool.destroy(), delete this.dynamicBufferPool);
28604
28632
  for (const e in this._readTargets) {
28605
28633
  const t = this._readTargets[e];
28606
28634
  t && t.destroy();
@@ -28649,8 +28677,8 @@
28649
28677
  name: "standard",
28650
28678
  vert: e.vert || "#include <gl2_vert>\n#define SHADER_NAME PBR\nattribute vec3 aPosition;\n#if defined(HAS_MAP) || defined(HAS_TERRAIN_FLAT_MASK)\nattribute vec2 aTexCoord;\n#include <common_pack_float>\n#endif\n#if defined(HAS_MAP)\nuniform vec2 uvOrigin;\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\nuniform float uvRotation;\n#ifdef HAS_I3S_UVREGION\nattribute vec4 uvRegion;\nvarying vec4 vUvRegion;\n#endif\n#if defined(HAS_AO_MAP)\nattribute vec2 aTexCoord1;\nvarying vec2 vTexCoord1;\n#endif\n#endif\nvec3 c;\nvec3 d;\nvec4 e;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\nuniform mediump vec3 cameraPosition;\nuniform mat3 modelNormalMatrix;\n#ifdef HAS_SSR\nuniform mat3 modelViewNormalMatrix;\nvarying vec3 vViewNormal;\n#ifdef HAS_TANGENT\nvarying vec4 vViewTangent;\n#endif\n#endif\nvarying vec3 vModelNormal;\nvarying vec4 vViewVertex;\n#if defined(HAS_TANGENT)\nvarying vec4 vModelTangent;\nvarying vec3 vModelBiTangent;\n#endif\nvarying vec3 vModelVertex;\n#if defined(HAS_MAP)\nvarying vec2 vTexCoord;\n#endif\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\n#ifdef HAS_OPACITY\nattribute float aOpacity;\n#endif\nvarying float vOpacity;\n#include <highlight_vert>\n#if defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nattribute vec3 aColor0;\nvarying vec3 vColor0;\n#else\nattribute vec4 aColor0;\nvarying vec4 vColor0;\n#endif\n#endif\n#include <line_extrusion_vert>\n#include <get_output>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#include <heatmap_render_vert>\n#include <vertex_color_vert>\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nvarying vec3 vTangentViewPos;\nvarying vec3 vTangentFragPos;\n#if __VERSION__ == 100\nmat3 f(in mat3 h) {\n vec3 i = h[0];\n vec3 j = h[1];\n vec3 k = h[2];\n return mat3(vec3(i.x, j.x, k.x), vec3(i.y, j.y, k.y), vec3(i.z, j.z, k.z));\n}\n#else\nmat3 f(in mat3 h) {\n return transpose(h);\n}\n#endif\n#endif\nvoid l(const highp vec4 q, out highp vec3 m) {\n m = vec3(.0, .0, 1.) + vec3(2., -2., -2.) * q.x * q.zwx + vec3(2., 2., -2.) * q.y * q.wzy;\n}\nvoid l(const highp vec4 q, out highp vec3 m, out highp vec3 t) {\n l(q, m);\n t = vec3(1., .0, .0) + vec3(-2., 2., -2.) * q.y * q.yxw + vec3(-2., 2., 2.) * q.z * q.zwx;\n}\nconst float o = .5;\nvec2 u(vec2 v, float A) {\n return vec2(cos(A) * (v.x - o) + sin(A) * (v.y - o) + o, cos(A) * (v.y - o) - sin(A) * (v.x - o) + o);\n}\n#if defined(HAS_MAP)\nvec2 B(vec2 v) {\n vec2 C = decode_getTexcoord(v);\n#ifdef HAS_RANDOM_TEX\nvec2 D = uvOrigin;\n vec2 E = C * uvScale + uvOffset;\n return mod(D, 1.) + E;\n#else\nvec2 D = uvOrigin;\n vec2 E = C * uvScale;\n if(uvRotation != .0) {\n D = u(D, uvRotation);\n E = u(E, uvRotation);\n }\n return mod(D, 1.) + E + uvOffset;\n#endif\n}\n#endif\n#ifdef PICKING_MODE\n#include <fbo_picking_vert>\n#endif\n#include <excavate_vert>\nvoid main() {\n mat4 F = getPositionMatrix();\n#ifdef IS_LINE_EXTRUSION\nvec3 G = getLineExtrudePosition(aPosition);\n vec4 H = getPosition(G);\n#else\nvec4 H = getPosition(aPosition);\n#endif\nvModelVertex = (modelMatrix * H).xyz;\n vec4 I = F * H;\n vec4 J = modelViewMatrix * I;\n vViewVertex = J;\n#ifdef HAS_MASK_EXTENT\ngl_Position = projMatrix * getMaskPosition(I, modelMatrix);\n#else\ngl_Position = projMatrix * J;\n#endif\n#ifdef PICKING_MODE\nfloat K = 1.;\n#if defined(HAS_COLOR)\nK *= aColor.a;\n#endif\n#if defined(HAS_COLOR0) && COLOR0_SIZE == 4\nK *= aColor0.a;\n#endif\nfbo_picking_setData(gl_Position.w, K != .0);\n#else\n#if defined(HAS_MAP)\nvTexCoord = B(aTexCoord);\n#ifdef HAS_AO_MAP\nvTexCoord1 = B(aTexCoord1);\n#endif\n#ifdef HAS_I3S_UVREGION\nvUvRegion = uvRegion / 65535.;\n#endif\n#endif\n#if defined(HAS_TANGENT) || defined(HAS_NORMAL)\nmat3 L = mat3(F);\n mat3 M = modelNormalMatrix * L;\n#if defined(HAS_TANGENT)\nvec3 t;\n l(aTangent, d, t);\n vModelTangent = vec4(M * t, aTangent.w);\n#else\nd = decode_getNormal(aNormal);\n#endif\nvec3 N = d;\n vModelNormal = M * N;\n#else\nd = vec3(.0);\n vModelNormal = vec3(.0);\n#endif\n#if defined(HAS_TANGENT)\nvModelBiTangent = cross(vModelNormal, vModelTangent.xyz) * sign(aTangent.w);\n#endif\n#ifdef HAS_SSR\nmat3 O = modelViewNormalMatrix * L;\n vViewNormal = O * d;\n#if defined(HAS_TANGENT)\nvec4 P = vec4(t, aTangent.w);\n vViewTangent = vec4(O * P.xyz, P.w);\n#endif\n#endif\n#if defined(HAS_COLOR)\nvColor = aColor / 255.;\n#endif\n#ifdef HAS_OPACITY\nvOpacity = aOpacity / 255.;\n#else\nvOpacity = 1.;\n#endif\nhighlight_setVarying();\n#if defined(HAS_COLOR0)\nvColor0 = aColor0 / 255.;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(I);\n#endif\n#ifdef HAS_HEATMAP\nheatmap_compute(projMatrix * modelViewMatrix * F, H);\n#endif\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nmat3 Q = f(mat3(vModelTangent.xyz, vModelBiTangent, vModelNormal));\n vTangentViewPos = Q * cameraPosition;\n vTangentFragPos = Q * vModelVertex;\n#endif\n#ifdef HAS_VERTEX_COLOR\nvertexColor_update();\n#endif\n#ifdef HAS_EXCAVATE_ANALYSIS\nvCoordinateTexcoord = getCoordinateTexcoord(I);\n vExcavateHeight = getWorldHeight(I);\n#endif\n#endif\n}",
28651
28679
  frag: e.frag || "#define PI 3.141593\n#define RECIPROCAL_PI 1.0\n#if __VERSION__ == 100\n#if defined(GL_EXT_shader_texture_lod)\n#extension GL_EXT_shader_texture_lod : enable\n#define textureCubeLod(tex, uv, lod) textureCubeLodEXT(tex, uv, lod)\n#else\n#define textureCubeLod(tex, uv, lod) textureCube(tex, uv, lod)\n#endif\n#if defined(GL_OES_standard_derivatives)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#else\n#define textureCubeLod(tex, uv, lod) textureLod(tex, uv, lod)\n#endif\n#define saturate(x) clamp(x, 0.0, 1.0)\nprecision mediump float;\n#include <gl2_frag>\n#include <hsv_frag>\n#include <srgb_frag>\nuniform vec3 hsv;\nuniform float contrast;\nstruct MaterialUniforms {\n vec2 roughnessMetalness;\n vec3 albedo;\n float alpha;\n vec3 normal;\n vec3 emit;\n float ao;\n vec3 specularColor;\n float glossiness;\n vec4 skinColor;\n} c;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\nuniform vec3 cameraPosition;\nuniform float alphaTest;\n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nuniform vec4 diffuseFactor;\nuniform vec3 specularFactor;\nuniform float glossinessFactor;\n#if defined(HAS_DIFFUSE_MAP)\nuniform sampler2D diffuseTexture;\n#endif\n#if defined(HAS_SPECULARGLOSSINESS_MAP)\nuniform sampler2D specularGlossinessTexture;\n#endif\n#endif\nuniform vec3 emissiveFactor;\nuniform vec4 baseColorFactor;\nuniform float baseColorIntensity;\nuniform float emitColorFactor;\nuniform float occlusionFactor;\nuniform float environmentExposure;\nuniform float roughnessFactor;\nuniform float metallicFactor;\nuniform float normalMapFactor;\nuniform float specularF0;\nuniform int emitMultiplicative;\nuniform int normalMapFlipY;\nuniform int outputSRGB;\nuniform mat3 environmentTransform;\n#if defined(HAS_ALBEDO_MAP)\nuniform sampler2D baseColorTexture;\n#endif\n#if defined(HAS_METALLICROUGHNESS_MAP)\nuniform sampler2D metallicRoughnessTexture;\n#endif\n#if defined(HAS_EMISSIVE_MAP)\nuniform sampler2D emissiveTexture;\n#endif\n#if defined(HAS_AO_MAP)\nuniform sampler2D occlusionTexture;\nvarying vec2 vTexCoord1;\n#endif\n#if defined(HAS_NORMAL_MAP) && defined(HAS_TANGENT)\nuniform sampler2D normalTexture;\n#endif\n#if defined(HAS_SKIN_MAP)\nuniform sampler2D skinTexture;\n#endif\n#if defined(ALPHA_MODE) && ALPHA_MODE == 1\nuniform float alphaCutoff;\n#endif\n#ifdef HAS_RANDOM_TEX\nuniform highp vec2 uvOrigin;\nuniform sampler2D noiseTexture;\n#endif\nuniform sampler2D brdfLUT;\n#if defined(HAS_IBL_LIGHTING)\nuniform vec3 hdrHSV;\nuniform samplerCube prefilterMap;\nuniform vec3 diffuseSPH[9];\nuniform vec2 prefilterMiplevel;\nuniform vec2 prefilterSize;\n#else\nuniform vec3 ambientColor;\n#endif\nuniform vec2 cameraNearFar;\nuniform vec3 light0_viewDirection;\nuniform vec4 light0_diffuse;\n#ifdef HAS_SSR\nvarying vec3 vViewNormal;\n#if defined(HAS_TANGENT)\nvarying vec4 vViewTangent;\n#endif\n#endif\nvarying vec3 vModelVertex;\nvarying vec4 vViewVertex;\n#if defined(HAS_MAP)\n#include <compute_texcoord_frag>\n#endif\nvarying vec3 vModelNormal;\n#if defined(HAS_TANGENT)\nvarying vec4 vModelTangent;\nvarying vec3 vModelBiTangent;\n#endif\n#if defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nvarying vec3 vColor0;\n#else\nvarying vec4 vColor0;\n#endif\n#endif\n#if defined(HAS_COLOR)\nvarying vec4 vColor;\n#elif defined(IS_LINE_EXTRUSION)\nuniform vec4 lineColor;\n#else\nuniform vec4 polygonFill;\n#endif\n#ifdef HAS_LAYER_OPACITY\nuniform float layerOpacity;\n#endif\nvarying float vOpacity;\n#ifdef HAS_INSTANCE_COLOR\nvarying vec4 vInstanceColor;\n#endif\n#ifdef IS_LINE_EXTRUSION\nuniform float lineOpacity;\n#else\nuniform float polygonOpacity;\n#endif\n#ifdef HAS_PATTERN\nuniform sampler2D linePatternFile;\nuniform vec2 atlasSize;\nuniform float flipY;\nuniform float currentTime;\nuniform float animSpeedScale;\n#ifdef HAS_PATTERN_ANIM\nvarying float vLinePatternAnimSpeed;\n#else\nuniform float linePatternAnimSpeed;\n#endif\n#ifdef HAS_PATTERN_GAP\nvarying float vLinePatternGap;\n#else\nuniform float linePatternGap;\n#endif\nuniform vec4 linePatternGapColor;\nuniform vec2 uvScale;\nvarying float vPatternHeight;\nvarying float vLinesofar;\nvarying vec4 vTexInfo;\nvarying float vNormalY;\nvec2 d(vec2 e) {\n vec2 f = mod(e, 1.);\n vec2 h = vTexInfo.xy;\n vec2 i = vTexInfo.zw;\n return (h + f * i) / atlasSize;\n}\n#endif\n#include <heatmap_render_frag>\n#include <snow_frag>\n#include <mask_frag>\n#include <terrain_normal_frag>\n#include <vertex_color_frag>\n#include <excavate_frag>\n#ifdef HAS_RANDOM_TEX\nconst float j = .5;\nvec2 k(vec2 f, float l) {\n return vec2(cos(l) * (f.x - j) + sin(l) * (f.y - j) + j, cos(l) * (f.y - j) - sin(l) * (f.x - j) + j);\n}\nfloat m(vec3 n) {\n return n.x + n.y + n.z;\n}\n#endif\nvec4 o(sampler2D u, in vec2 f) {\n \n#ifdef HAS_RANDOM_TEX\nhighp vec2 A = uvOrigin;\n highp vec2 B = f + A - mod(A, 1.);\n float C = texture2D(noiseTexture, .005 * B).x;\n vec2 D = dFdx(B);\n vec2 E = dFdx(B);\n float F = C * 8.;\n float G = fract(F);\n#if 1\nfloat H = floor(F);\n float I = H + 1.;\n#else\nfloat H = floor(F + .5);\n float I = floor(F);\n G = min(G, 1. - G) * 2.;\n#endif\nvec2 J = sin(vec2(3., 7.) * H);\n vec2 K = sin(vec2(3., 7.) * I);\n float L = .5;\n vec4 M = texture2DGradEXT(u, f + L * J, D, E);\n vec4 N = texture2DGradEXT(u, f + L * K, D, E);\n return mix(M, N, smoothstep(.2, .8, G - .1 * m(M.xyz - N.xyz)));\n#else\nreturn texture2D(u, f);\n#endif\n}\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nuniform sampler2D bumpTexture;\nuniform float bumpScale;\nuniform float bumpMaxLayers;\nuniform float bumpMinLayers;\nvec2 O(vec2 f, vec3 P) {\n float Q = mix(bumpMaxLayers, bumpMinLayers, abs(dot(vec3(.0, .0, 1.), P)));\n float R = 1. / Q;\n float S = .0;\n vec2 T = P.xy * bumpScale / (P.z * Q);\n vec2 U = f;\n float V = o(bumpTexture, U).r;\n for(int W = 0; W < 30; W++) {\n S += R;\n U -= T;\n V = o(bumpTexture, U).r;\n if(V < S) {\n break;\n }\n }\n vec2 X = U + T;\n float Y = V - S;\n float Z = o(bumpTexture, X).r - S + R;\n return mix(U, X, Y / (Y - Z));\n}\nvarying vec3 vTangentViewPos;\nvarying vec3 vTangentFragPos;\n#endif\n#define SHADER_NAME PBR\nvec3 ba() {\n return c.albedo;\n}\nfloat bb() {\n return c.alpha;\n}\nfloat bc() {\n return c.roughnessMetalness.y;\n}\nfloat bd() {\n \n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nreturn 1. - c.glossiness;\n#else\nreturn c.roughnessMetalness.x;\n#endif\n}\nvec3 be() {\n return c.emit;\n}\nvec4 bf() {\n return c.skinColor;\n}\nvec3 bg() {\n return c.normal;\n}\nfloat bh() {\n return c.ao;\n}\nfloat bi(const in vec4 bj) {\n return bj.r + bj.g / 255.;\n}\nvec3 bk(const in float bl, in vec3 bm, const in vec3 t, const in vec3 b, in vec3 bn) {\n bm.xy = bl * bm.xy;\n mat3 bo = mat3(t, b, bn);\n return normalize(bo * bm);\n}\nfloat bp(const float bq, const vec3 bm, const vec3 br) {\n float bs = clamp(dot(bm, br), 0., 1.);\n float a = bq * bq;\n float bt = a * a;\n float bu = (bs * bt - bs) * bs + 1.;\n return bt / (PI * bu * bu);\n}\nvec3 bv(const vec3 bw, const float bx, const in vec3 by, const in vec3 br) {\n float bz = clamp(dot(by, br), 0., 1.);\n bz = pow(1. - bz, 5.);\n return bx * bz + (1. - bz) * bw;\n}\nfloat bA(const in vec3 bm, const in vec3 bB, const in float bq, const float bC) {\n float bD = clamp(dot(bm, bB), 0., 1.);\n float a = bq * bq;\n float bE = bD * (bC * (1. - a) + a);\n float bF = bC * (bD * (1. - a) + a);\n return .5 / (bF + bE);\n}\nvec3 bG(const float bq, const vec3 bm, const vec3 bB, const vec3 by, const vec3 bH, const float bC, const float bx) {\n vec3 br = normalize(bB + by);\n float bI = bp(bq, bm, br);\n float bJ = bA(bm, bB, bq, bC);\n vec3 bK = bv(bH, bx, by, br);\n return (bI * bJ * PI) * bK;\n}\nvec3 bL(const in vec3 bM) {\n return RECIPROCAL_PI * bM;\n}\nvoid bN(const in vec3 bm, const in vec3 bB, const in float bC, const in float bq, const in vec3 bO, const in vec3 bH, const in vec3 bP, const in vec3 by, const in float bx, out vec3 bQ, out vec3 bR) {\n if(bC <= .0) {\n bR = bQ = vec3(.0);\n return;\n }\n vec3 a = bC * bP;\n vec3 bS = bG(bq, bm, bB, by, bH, bC, bx);\n bR = a * bS;\n bQ = a * bL(bO);\n}\n#if defined(HAS_IBL_LIGHTING)\nvec3 bT(const in vec3 bm) {\n vec3 bn = environmentTransform * bm;\n float x = bn.x;\n float y = bn.y;\n float z = bn.z;\n vec3 bU = (diffuseSPH[0] + diffuseSPH[1] * x + diffuseSPH[2] * y + diffuseSPH[3] * z + diffuseSPH[4] * z * x + diffuseSPH[5] * y * z + diffuseSPH[6] * y * x + diffuseSPH[7] * (3. * z * z - 1.) + diffuseSPH[8] * (x * x - y * y));\n if(length(hdrHSV) > .0) {\n bU = hsv_apply(bU, hdrHSV);\n }\n return max(bU, vec3(.0));\n}\nvec3 bV(const in float bq, const in vec3 bW) {\n vec3 bX = bW;\n float bY = prefilterMiplevel.x;\n float bZ = min(bY, bq * prefilterMiplevel.y);\n vec3 ca = textureCubeLod(prefilterMap, bX, bZ).rgb;\n if(length(hdrHSV) > .0) {\n return hsv_apply(ca, hdrHSV);\n } else {\n return ca;\n }\n}\nvec3 cb(const in vec3 cc, const in vec3 bB, const in float bq, const in vec3 cd, const in vec3 bO) {\n float ce = 1. - bq;\n vec3 bW = mix(cc, reflect(-bB, cc), ce * (sqrt(ce) + bq));\n float bl = clamp(1. + dot(bW, cd), .0, 1.);\n vec3 cf = bV(bq, environmentTransform * bW) * bl * bl;\n return cf;\n}\n#else\nvec3 cb(const in vec3 bm, const in vec3 cg, const in float bq, const in vec3 cd, const in vec3 bO) {\n return ambientColor * bL(bO);\n}\n#endif\nvec3 ch(const in vec3 ci, const in float bq, const in float bD, const in float bx) {\n vec4 rgba = texture2D(brdfLUT, vec2(bD, bq)) * vec4(255., 65280.0, 255., 65280.0);\n float b = (rgba[3] + rgba[2]);\n float a = (rgba[1] + rgba[0]);\n return (ci * a + b * bx) / 65535.;\n}\nvec3 cj(const in vec3 bm, const in vec3 cg, const in float bD, const in float bq, const in vec3 bH, const in vec3 cd, const in float bx, const in vec3 bO) {\n return cb(bm, cg, bq, cd, bO) * ch(bH, bq, bD, bx);\n}\nfloat ck(const in float cl, const in float bD) {\n float bu = bD + cl;\n return clamp(bu * bu - 1. + cl, .0, 1.);\n}\nvoid cm() {\n \n#ifdef HAS_MAP\nvec2 f = computeTexCoord(vTexCoord);\n#endif\n#ifdef HAS_UV_FLIP\nf.y = 1. - f.y;\n#endif\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nf = O(f, normalize(vTangentViewPos - vTangentFragPos));\n#endif\nc.albedo = baseColorIntensity * baseColorFactor.rgb;\n c.alpha = baseColorFactor.a * vOpacity;\n#if defined(HAS_PATTERN)\nfloat cn = vLinesofar;\n vec2 i = vTexInfo.zw;\n#ifdef HAS_PATTERN_GAP\nfloat co = vLinePatternGap;\n#else\nfloat co = linePatternGap;\n#endif\n#ifdef HAS_PATTERN_ANIM\nfloat cp = vLinePatternAnimSpeed;\n#else\nfloat cp = linePatternAnimSpeed;\n#endif\nfloat cq = ceil(i.x * vPatternHeight / i.y);\n float cr = cq * (1. + co);\n cp /= animSpeedScale;\n cn += mod(currentTime * -cp * .2, cr);\n float cs = mod(cn / cr, 1.);\n float ct = mod(flipY * vNormalY, 1.);\n vec2 f = d(vec2(cs * (1. + co) * uvScale[0], ct * uvScale[1]));\n vec4 cu = texture2D(linePatternFile, f);\n float cv = clamp(sign(1. / (1. + co) - cs) + .000001, .0, 1.);\n cu = mix(linePatternGapColor, cu, cv);\n#ifdef IS_SQUARE_TUBE\nfloat n = clamp(sign(abs(vNormalY) - .999999), .0, 1.);\n cu = mix(cu, vec4(1.), n);\n#endif\nc.albedo *= cu.rgb;\n c.alpha *= cu.a;\n#endif\n#if defined(HAS_ALBEDO_MAP)\nvec4 cw = o(baseColorTexture, f);\n c.albedo *= sRGBToLinear(cw.rgb);\n c.alpha *= cw.a;\n#endif\n#if defined(HAS_SKIN_MAP)\nvec4 cx = o(skinTexture, f);\n c.skinColor = cx;\n#endif\n#if defined(HAS_COLOR0)\nc.albedo *= vColor0.rgb;\n#if COLOR0_SIZE == 4\nc.alpha *= vColor0.a;\n#endif\n#endif\n#if defined(HAS_COLOR)\nc.albedo *= vColor.rgb;\n c.alpha *= vColor.a;\n#elif defined(IS_LINE_EXTRUSION)\nc.albedo *= lineColor.rgb;\n c.alpha *= lineColor.a;\n#else\nc.albedo *= polygonFill.rgb;\n c.alpha *= polygonFill.a;\n#endif\n#if defined(HAS_INSTANCE_COLOR)\nc.albedo *= vInstanceColor.rgb;\n c.alpha *= vInstanceColor.a;\n#endif\n#if defined(HAS_METALLICROUGHNESS_MAP)\nc.roughnessMetalness = o(metallicRoughnessTexture, f).gb * vec2(roughnessFactor, metallicFactor);\n#else\nc.roughnessMetalness = vec2(roughnessFactor, metallicFactor);\n#endif\nc.emit = emissiveFactor;\n#if defined(HAS_EMISSIVE_MAP)\nif(emitMultiplicative == 1) {\n c.emit *= sRGBToLinear(o(emissiveTexture, f).rgb);\n } else {\n c.emit += sRGBToLinear(o(emissiveTexture, f).rgb);\n }\n#endif\nc.emit *= emitColorFactor;\n#if defined(HAS_AO_MAP)\nvec2 cy = computeTexCoord(vTexCoord1);\n c.ao = o(occlusionTexture, cy).r;\n#else\nc.ao = 1.;\n#endif\nc.ao *= occlusionFactor;\n#if defined(HAS_NORMAL_MAP) && defined(HAS_TANGENT)\nvec3 cz = o(normalTexture, f).xyz * 2. - 1.;\n cz.y = normalMapFlipY == 1 ? -cz.y : cz.y;\n c.normal = cz;\n#else\nc.normal = normalize(vModelNormal);\n#endif\n#if defined(HAS_TERRAIN_NORMAL) && defined(HAS_TANGENT)\nvec3 cz = convertTerrainHeightToNormalMap(f);\n cz.y = normalMapFlipY == 1 ? -cz.y : cz.y;\n c.normal = cz;\n#endif\n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nc.albedo *= diffuseFactor.rgb;\n c.alpha *= diffuseFactor.a;\n#if defined(HAS_DIFFUSE_MAP)\nvec4 cA = o(diffuseTexture, f);\n c.albedo *= sRGBToLinear(cA.rgb);\n c.alpha *= cA.a;\n#endif\nc.specularColor = specularFactor;\n c.glossiness = glossinessFactor;\n#if defined(HAS_SPECULARGLOSSINESS_MAP)\nvec4 cB = o(specularGlossinessTexture, f);\n c.specularColor *= sRGBToLinear(cB.rgb);\n c.glossiness *= cB.a;\n#endif\n#endif\n}\nvec3 cC(const vec3 x) {\n const float a = 2.51;\n const float b = .03;\n const float cD = 2.43;\n const float bu = .59;\n const float cE = .14;\n return (x * (a * x + b)) / (x * (cD * x + bu) + cE);\n}\nvec3 cF(vec3 cG) {\n cG = cC(cG);\n return cG = pow(cG, vec3(1. / 2.2));\n}\nuniform float specularAAVariance;\nuniform float specularAAThreshold;\nfloat cH(float bq, const vec3 cI) {\n \n#if defined(GL_OES_standard_derivatives) || __VERSION__ == 300\nvec3 cJ = dFdx(cI);\n vec3 cK = dFdy(cI);\n float cL = specularAAVariance * (dot(cJ, cJ) + dot(cK, cK));\n float cM = min(2. * cL, specularAAThreshold);\n float cN = saturate(bq * bq + cM);\n return sqrt(cN);\n#else\nreturn bq;\n#endif\n}\n#ifdef HAS_SSR\nuniform sampler2D TextureDepth;\nuniform highp vec2 outSize;\nuniform float ssrFactor;\nuniform float ssrQuality;\nuniform sampler2D TextureReflected;\nuniform highp mat4 projMatrix;\nuniform mat4 invProjMatrix;\nuniform vec4 outputFovInfo[2];\nuniform mat4 reprojViewProjMatrix;\nvec3 cO(const in mat4 cP, const in vec3 cQ) {\n vec4 cR = cP * vec4(cQ, 1.);\n return vec3(.5 + .5 * cR.xy / cR.w, cR.w);\n}\nvec3 cS(const in float cT, const in vec2 f) {\n return texture2D(TextureReflected, f).rgb;\n}\nfloat cU(float cV) {\n highp mat4 cP = projMatrix;\n highp float z = cV * 2. - 1.;\n return -cP[3].z / (z + cP[2].z);\n}\nfloat cW(const vec2 f) {\n float cV = bi(texture2D(TextureDepth, f));\n return cV;\n}\nfloat cX(const in vec2 cY, const in float cZ) {\n vec3 da = vec3(.06711056, .00583715, 52.9829189);\n return fract(da.z * fract(dot(cY.xy + cZ * vec2(47., 17.) * .695, da.xy))) * .5;\n}\nvec3 db(const in float cZ, const in vec3 dc, const in vec3 dd, const in vec3 de, const in vec3 cg, const in float df) {\n vec2 dg;\n dg.x = cX(gl_FragCoord.yx, cZ);\n dg.y = fract(dg.x * 52.9829189);\n dg.y = mix(dg.y, 1., .7);\n float dh = 2. * 3.14159 * dg.x;\n float di = pow(max(dg.y, .000001), df / (2. - df));\n float dj = sqrt(1. - di * di);\n vec3 dk = vec3(dj * cos(dh), dj * sin(dh), di);\n dk = dk.x * dc + dk.y * dd + dk.z * de;\n return normalize((2. * dot(cg, dk)) * dk - cg);\n}\nfloat dl(const in float cZ) {\n return (cX(gl_FragCoord.xy, cZ) - .5);\n}\nvec3 dm(const in vec3 dn, const in float dp, const in vec3 dq) {\n vec3 dr = cO(projMatrix, vViewVertex.xyz + dq * dp);\n dr.z = 1. / dr.z;\n dr -= dn;\n float ds = min(1., .99 * (1. - dn.x) / max(1e-5, dr.x));\n float dt = min(1., .99 * (1. - dn.y) / max(1e-5, dr.y));\n float dw = min(1., .99 * dn.x / max(1e-5, -dr.x));\n float dx = min(1., .99 * dn.y / max(1e-5, -dr.y));\n return dr * min(ds, dt) * min(dw, dx);\n}\nfloat dy(const in vec3 dn, const in vec3 dr, inout float dz, inout float dA) {\n float dB = (dA + dz) * .5;\n vec3 dC = dn + dr * dB;\n float z = cW(dC.xy);\n float cV = cU(z);\n float dD = -1. / dC.z;\n dz = cV > dD ? dz : dB;\n dA = cV > dD ? dB : dA;\n return dB;\n}\nvec4 dE(const in vec3 dn, const in float dp, in float dF, const in vec3 dq, const in float bq, const in float cZ) {\n int dG = 20;\n float dH = 1. / float(dG);\n dF *= dH;\n vec3 dr = dm(dn, dp, dq);\n float dI = dH;\n vec3 dJ = vec3(.0, dI, 1.);\n vec3 dC;\n float z, cV, dD, dK, dL, dM;\n bool dN;\n float dO = 1.;\n float dB;\n for(int W = 0; W < dG; W++) {\n dC = dn + dr * dJ.y;\n z = cW(dC.xy);\n cV = cU(z);\n dD = -1. / dC.z;\n float dP = clamp(sign(.999 - z), .0, 1.);\n dK = dP * (dD - cV);\n dK *= clamp(sign(abs(dK) - dp * dH * dH), .0, 1.);\n dN = abs(dK + dF) < dF;\n dL = clamp(dJ.x / (dJ.x - dK), .0, 1.);\n dM = dN ? dJ.y + dL * dH - dH : 1.;\n dJ.z = min(dJ.z, dM);\n dJ.x = dK;\n if(dN) {\n float dz = dJ.y - dH;\n float dA = dJ.y;\n dB = dy(dn, dr, dz, dA);\n dB = dy(dn, dr, dz, dA);\n dB = dy(dn, dr, dz, dA);\n dO = dB;\n break;\n }\n dJ.y += dH;\n }\n return vec4(dn + dr * dO, 1. - dO);\n}\nvec4 dQ(in vec4 dR, const in float dS, const in vec3 dT, const in vec3 dU, const in float bq) {\n vec4 dV = mix(outputFovInfo[0], outputFovInfo[1], dR.x);\n dR.xyz = vec3(mix(dV.xy, dV.zw, dR.y), 1.) * -1. / dR.z;\n dR.xyz = (reprojViewProjMatrix * vec4(dR.xyz, 1.)).xyw;\n dR.xy /= dR.z;\n float dW = clamp(6. - 6. * max(abs(dR.x), abs(dR.y)), .0, 1.);\n dR.xy = .5 + .5 * dR.xy;\n vec3 dX = dU * cS(bq * (1. - dR.w), dR.xy);\n return vec4(mix(dT, dX, dS * dW), 1.);\n}\nvec3 ssr(const in vec3 dT, const in vec3 dU, const in float bq, const in vec3 bm, const in vec3 cg) {\n float dY = .0;\n vec4 bU = vec4(.0);\n float df = bq * bq;\n df = df * df;\n vec3 dZ = abs(bm.z) < .999 ? vec3(.0, .0, 1.) : vec3(1., .0, .0);\n vec3 dc = normalize(cross(dZ, bm));\n vec3 dd = cross(bm, dc);\n float dS = ssrFactor * clamp(-4. * dot(cg, bm) + 3.8, .0, 1.);\n dS *= clamp(4.7 - bq * 5., .0, 1.);\n vec3 dn = cO(projMatrix, vViewVertex.xyz);\n dn.z = 1. / dn.z;\n vec3 dq = db(dY, dc, dd, bm, cg, df);\n float dp = mix(cameraNearFar.y + vViewVertex.z, -vViewVertex.z - cameraNearFar.x, dq.z * .5 + .5);\n float dF = .5 * dp;\n vec4 dR;\n if(dot(dq, bm) > .001 && dS > .0) {\n dR = dE(dn, dp, dF, dq, bq, dY);\n if(dR.w > .0)\n bU += dQ(dR, dS, dT, dU, bq);\n \n }\n return bU.w > .0 ? bU.rgb / bU.w : dT;\n}\n#endif\n#include <highlight_frag>\nvec4 ea(in vec4 eb) {\n return vec4(mix(pow(eb.rgb, vec3(.41666)) * 1.055 - vec3(.055), eb.rgb * 12.92, vec3(lessThanEqual(eb.rgb, vec3(.0031308)))), eb.a);\n}\nvec4 ec(vec4 eb) {\n return (ea(eb));\n}\nvoid main() {\n cm();\n vec3 cg = normalize(cameraPosition - vModelVertex.xyz);\n#if defined(HAS_DOUBLE_SIDE)\nvec3 cd = gl_FrontFacing ? normalize(vModelNormal) : -normalize(vModelNormal);\n#else\nvec3 cd = normalize(vModelNormal);\n#endif\n#if defined(HAS_TANGENT)\nvec4 ed;\n ed = vModelTangent;\n#if defined(HAS_DOUBLE_SIDE)\ned.xyz = gl_FrontFacing ? normalize(ed.xyz) : -normalize(ed.xyz);\n#else\ned.xyz = normalize(ed.xyz);\n#endif\nvec3 ee = normalize(vModelBiTangent);\n#endif\nfloat bw = .08 * specularF0;\n float ef = bc();\n vec3 bO = ba();\n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nvec3 eg = c.specularColor;\n#else\nvec3 eg = mix(vec3(bw), bO, ef);\n#endif\nbO *= 1. - ef;\n float eh = clamp(50.0 * eg.g, .0, 1.);\n float ei = bd();\n if(specularAAVariance > .0) {\n ei = cH(ei, cd);\n }\n vec3 ej = be();\n vec3 ek = bg();\n vec3 el = vec3(ek);\n#if defined(HAS_TANGENT) && (defined(HAS_NORMAL_MAP) || defined(HAS_TERRAIN_NORMAL))\nel = bk(normalMapFactor, el, ed.xyz, ee, cd);\n#endif\nvec3 cA = vec3(.0);\n vec3 bH = vec3(.0);\n#if defined(HAS_IBL_LIGHTING)\ncA = bO * bT(el) * .5;\n#else\ncA = bO * ambientColor;\n#endif\nfloat bD = dot(el, cg);\n bH = cj(el, cg, bD, ei, eg, cd, eh, bO);\n float em;\n float en = 1.;\n float eo = bh();\n cA *= environmentExposure * eo;\n#ifdef HAS_IBL_LIGHTING\nen = ck(eo, bD);\n#endif\n#ifdef HAS_SSR\nvec3 ep = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\n vec3 eq = ep;\n#if defined(HAS_TANGENT) && (defined(HAS_NORMAL_MAP) || defined(HAS_TERRAIN_NORMAL))\nvec4 er;\n er = vViewTangent;\n er = gl_FrontFacing ? er : -er;\n er.xyz = normalize(er.xyz);\n vec3 es = normalize(cross(ep, er.xyz)) * er.w;\n eq = bk(normalMapFactor, ek, er.xyz, es, ep);\n#endif\nbH = ssr(bH, eg * en, ei, eq, -normalize(vViewVertex.xyz));\n#endif\nbH *= environmentExposure * en;\n vec3 et, eu;\n vec3 ev = vModelNormal;\n vec3 ew = -light0_viewDirection;\n float ex = saturate(dot(ew, el));\n bN(el, cg, ex, max(.045, ei), bO, eg, light0_diffuse.rgb, ew, eh, eu, et);\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat ey = shadow_computeShadow();\n eu = shadow_blend(eu, ey).rgb;\n et = shadow_blend(et, ey).rgb;\n#endif\ncA += eu;\n bH += et;\n cA += ej;\n vec3 ez = bH + cA;\n if(outputSRGB == 1)\n ez = linearTosRGB(ez);\n \n#ifdef HAS_SKIN_MAP\nvec4 eA = bf();\n ez.rgb = ez.rgb * (1. - eA.a) + eA.rgb * eA.a;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nez.rgb = shadow_blend(ez.rgb, ey).rgb;\n#endif\n#endif\nfloat eB = bb();\n if(eB < alphaTest) {\n discard;\n }\n#if defined(ALPHA_MODE)\n#if ALPHA_MODE == 1\nif(eB < alphaCutoff) {\n discard;\n } else {\n eB = 1.;\n }\n#else\neB = 1.;\n#endif\n#endif\n#if defined(IS_LINE_EXTRUSION)\neB *= lineOpacity;\n#else\neB *= polygonOpacity;\n#endif\nglFragColor = vec4(ez * eB, eB);\n#ifdef HAS_VERTEX_COLOR\nglFragColor *= vertexColor_get();\n#endif\n#ifdef HAS_EXCAVATE_ANALYSIS\nglFragColor = excavateColor(glFragColor);\n#endif\n#ifdef HAS_HEATMAP\nglFragColor = heatmap_getColor(glFragColor);\n#endif\n#ifdef HAS_SNOW\nglFragColor.rgb = snow(glFragColor, bg(), 1.);\n#endif\nif(contrast != 1.) {\n glFragColor = contrastMatrix(contrast) * glFragColor;\n }\n if(length(hsv) > .0) {\n glFragColor = hsv_apply(glFragColor, hsv);\n }\n#ifdef OUTPUT_NORMAL\nglFragColor = vec4(cd, 1.);\n#endif\nglFragColor = highlight_blendColor(glFragColor);\n#ifdef HAS_LAYER_OPACITY\nglFragColor *= layerOpacity;\n#endif\n#ifdef HAS_MASK_EXTENT\nglFragColor = setMask(glFragColor);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",
28652
- wgslVert: e.wgslVert || "#include <highlight_vert>\n#include <line_extrusion_vert>\n#include <get_output>\n#include <vsm_shadow_vert>\n#include <vertex_color_vert>\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <excavate_vert>\n#include <common_pack_float>\nstruct VertexInput {\n #ifdef POSITION_IS_INT\n @location($i) aPosition: vec4i,\n #else\n @location($i) aPosition: vec3f,\n #endif\n #if HAS_MAP || HAS_TERRAIN_FLAT_MASK\n @location($i) aTexCoord: vec2f,\n #endif\n #if HAS_MAP\n #ifdef HAS_I3S_UVREGION\n @location($i) uvRegion: vec4f,\n #endif\n #if HAS_AO_MAP\n @location($i) aTexCoord1: vec2f,\n #endif\n #endif\n #if HAS_COLOR\n @location($i) aColor: vec4u,\n #endif\n #ifdef HAS_OPACITY\n @location($i) aOpacity: f32,\n #endif\n #if HAS_COLOR0\n #if COLOR0_SIZE == 3\n @location($i) aColor0: vec3u,\n #else\n @location($i) aColor0: vec4u,\n #endif\n #endif\n #if HAS_TANGENT || HAS_NORMAL\n #ifdef NORMAL_IS_INT\n @location($i) aNormal: vec4i,\n #else\n @location($i) aNormal: vec3f,\n #endif\n #if HAS_TANGENT\n @location($i) aTangent: vec4f,\n #endif\n #endif\n}\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n #ifdef HAS_SSR\n @location($o) vViewNormal: vec3f,\n #ifdef HAS_TANGENT\n @location($o) vViewTangent: vec4f,\n #endif\n #endif\n @location($o) vModelNormal: vec3f,\n @location($o) vViewVertex: vec4f,\n #if HAS_TANGENT\n @location($o) vModelTangent: vec4f,\n @location($o) vModelBiTangent: vec3f,\n #endif\n @location($o) vModelVertex: vec3f,\n #if HAS_MAP\n @location($o) vTexCoord: vec2f,\n #ifdef HAS_AO_MAP\n @location($o) vTexCoord1: vec2f,\n #endif\n #ifdef HAS_I3S_UVREGION\n @location($o) vUvRegion: vec4f,\n #endif\n #endif\n #if HAS_COLOR\n @location($o) vColor: vec4f,\n #endif\n @location($o) vOpacity: f32,\n #if HAS_COLOR0\n @location($o) vColor0: vec4f,\n #endif\n #if HAS_BUMP_MAP && HAS_TANGENT\n @location($o) vTangentViewPos: vec3f,\n @location($o) vTangentFragPos: vec3f,\n #endif\n}\nstruct ShaderUniforms {\n cameraPosition: vec3f,\n projMatrix: mat4x4f,\n}\nstruct Uniforms {\n uvOrigin: vec2f,\n uvScale: vec2f,\n uvOffset: vec2f,\n uvRotation: f32,\n modelMatrix: mat4x4f,\n modelViewMatrix: mat4x4f,\n positionMatrix: mat4x4f,\n modelNormalMatrix: mat3x3f,\n #ifdef HAS_SSR\n modelViewNormalMatrix: mat3x3f,\n #endif\n};\n@group(0) @binding($b) var<uniform> uniforms: Uniforms;\n@group(0) @binding($b) var<uniform> shaderUniforms: ShaderUniforms;\nvar<private> Vertex: vec3f;\nvar<private> Normal: vec3f;\nvar<private> Tangent: vec4f;\nconst mid = 0.5;\nfn toTangentFrame(q: vec4f) -> vec3f {\n return vec3f(0.0, 0.0, 1.0) +\n vec3f(2.0, -2.0, -2.0) * q.x * q.zwx +\n vec3f(2.0, 2.0, -2.0) * q.y * q.wzy;\n}\nstruct TangentFrame {\n n: vec3f,\n t: vec3f\n}\nfn toTangentFrameWithTangent(q: vec4f) -> TangentFrame {\n var out: TangentFrame;\n out.n = toTangentFrame(q);\n out.t = vec3f(1.0, 0.0, 0.0) +\n vec3f(-2.0, 2.0, -2.0) * q.y * q.yxw +\n vec3f(-2.0, 2.0, 2.0) * q.z * q.zwx;\n return out;\n}\nfn rotateUV(uv: vec2f, rotation: f32) -> vec2f {\n return vec2f(\n cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,\n cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid\n );\n}\n#if HAS_MAP\nfn transformTexcoord(uv: vec2f) -> vec2f {\n let decodedTexCoord = decode_getTexcoord(uv);\n #ifdef HAS_RANDOM_TEX\n let origin = uniforms.uvOrigin;\n let texCoord = decodedTexCoord * uniforms.uvScale + uniforms.uvOffset;\n return (origin % 1.0) + texCoord;\n #else\n let origin = uniforms.uvOrigin;\n let texCoord = decodedTexCoord * uniforms.uvScale;\n if (uniforms.uvRotation != 0.0) {\n origin = rotateUV(origin, uniforms.uvRotation);\n texCoord = rotateUV(texCoord, uniforms.uvRotation);\n }\n return (origin % 1.0) + texCoord + uniforms.uvOffset;\n #endif\n}\n#endif\nfn transposeMat3(inMat: mat3x3f) -> mat3x3f {\n let i0 = inMat[0];\n let i1 = inMat[1];\n let i2 = inMat[2];\n return mat3x3f(\n vec3f(i0.x, i1.x, i2.x),\n vec3f(i0.y, i1.y, i2.y),\n vec3f(i0.z, i1.z, i2.z)\n );\n}\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let localPositionMatrix = getPositionMatrix(input, &output, uniforms.positionMatrix);\n #ifdef IS_LINE_EXTRUSION\n let linePosition = getLineExtrudePosition(vec3f(input.aPosition.xyz), input);\n let localVertex = getPosition(linePosition, input);\n #else\n let localVertex = getPosition(vec3f(input.aPosition.xyz), input);\n #endif\n output.vModelVertex = (uniforms.modelMatrix * localVertex).xyz;\n let position = localPositionMatrix * localVertex;\n let viewVertex = uniforms.modelViewMatrix * position;\n output.vViewVertex = viewVertex;\n #ifdef HAS_MASK_EXTENT\n output.position = shaderUniforms.projMatrix * getMaskPosition(position, uniforms.modelMatrix);\n #else\n output.position = shaderUniforms.projMatrix * viewVertex;\n #endif\n #ifdef PICKING_MODE\n var alpha = 1.0;\n #if HAS_COLOR\n alpha *= f32(input.aColor.a);\n #endif\n #if HAS_COLOR0 && COLOR0_SIZE == 4\n alpha *= f32(input.aColor0.a);\n #endif\n fbo_picking_setData(vertex, &output, output.position.w, alpha != 0.0);\n #else\n #if HAS_MAP\n output.vTexCoord = transformTexcoord(input.aTexCoord);\n #ifdef HAS_AO_MAP\n output.vTexCoord1 = transformTexcoord(input.aTexCoord1);\n #endif\n #ifdef HAS_I3S_UVREGION\n output.vUvRegion = input.uvRegion / 65535.0;\n #endif\n #endif\n #if HAS_TANGENT || HAS_NORMAL\n let positionNormalMatrix = mat3x3f(\n localPositionMatrix[0].xyz,\n localPositionMatrix[1].xyz,\n localPositionMatrix[2].xyz\n );\n let normalMatrix = uniforms.modelNormalMatrix * positionNormalMatrix;\n #if HAS_TANGENT\n let tangentFrame = toTangentFrameWithTangent(input.aTangent);\n Normal = tangentFrame.n;\n let t = tangentFrame.t;\n output.vModelTangent = vec4f(normalMatrix * t, input.aTangent.w);\n #else\n Normal = decode_getNormal(vec3f(input.aNormal.xyz));\n #endif\n let localNormal = Normal;\n output.vModelNormal = normalMatrix * localNormal;\n #else\n Normal = vec3f(0);\n output.vModelNormal = vec3f(0);\n #endif\n #if HAS_TANGENT\n output.vModelBiTangent = cross(output.vModelNormal, output.vModelTangent.xyz) * sign(input.aTangent.w);\n #endif\n #ifdef HAS_SSR\n let ssrNormalMatrix = uniforms.modelViewNormalMatrix * positionNormalMatrix;\n output.vViewNormal = ssrNormalMatrix * Normal;\n #if HAS_TANGENT\n let localTangent = vec4f(t, input.aTangent.w);\n output.vViewTangent = vec4f(ssrNormalMatrix * localTangent.xyz, localTangent.w);\n #endif\n #endif\n #if HAS_COLOR\n output.vColor = vec4f(input.aColor) / 255.0;\n #endif\n #ifdef HAS_OPACITY\n output.vOpacity = input.aOpacity / 255.0;\n #else\n output.vOpacity = 1.0;\n #endif\n #if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n highlight_setVarying(input, &output);\n #endif\n #if HAS_COLOR0\n #if COLOR0_SIZE == 3\n output.vColor0 = vec4f(vec3f(input.aColor0), 255.0) / 255.0;\n #else\n output.vColor0 = vec4f(input.aColor0) / 255.0;\n #endif\n #endif\n #if HAS_SHADOWING && !HAS_BLOOM\n shadow_computeShadowPars(position);\n #endif\n #if HAS_BUMP_MAP && HAS_TANGENT\n let TBN = transposeMat3(mat3x3f(output.vModelTangent.xyz, output.vModelBiTangent, output.vModelNormal));\n output.vTangentViewPos = TBN * shaderUniforms.cameraPosition;\n output.vTangentFragPos = TBN * output.vModelVertex;\n #endif\n #ifdef HAS_VERTEX_COLOR\n vertexColor_update(input, &output);\n #endif\n #ifdef HAS_EXCAVATE_ANALYSIS\n output.vCoordinateTexcoord = getCoordinateTexcoord(position, uniforms.modelMatrix);\n output.vExcavateHeight = getWorldHeight(position, uniforms.modelMatrix);\n #endif\n #endif\n return output;\n}",
28653
- wgslFrag: e.wgslFrag || "#include <hsv_frag>\n#include <srgb_frag>\n#include <highlight_frag>\n#include <snow_frag>\n#include <mask_frag>\n#include <terrain_normal_frag>\n#include <vertex_color_frag>\n#include <excavate_frag>\n#define PI 3.141593\n#define RECIPROCAL_PI 0.3183099\nstruct MaterialUniforms {\n roughnessMetalness: vec2f,\n albedo: vec3f,\n alpha: f32,\n normal: vec3f,\n emit: vec3f,\n ao: f32,\n specularColor: vec3f,\n glossiness: f32,\n skinColor: vec4f\n};\nvar<private> materialUniforms: MaterialUniforms;\nstruct SceneUniforms {\n alphaTest: f32,\n emissiveFactor: vec3f,\n baseColorFactor: vec4f,\n baseColorIntensity: f32,\n emitColorFactor: f32,\n occlusionFactor: f32,\n roughnessFactor: f32,\n metallicFactor: f32,\n normalMapFactor: f32,\n specularF0: f32,\n emitMultiplicative: f32,\n normalMapFlipY: f32,\n outputSRGB: f32,\n contrast: f32,\n hsv: vec3f,\n specularAAVariance: f32,\n specularAAThreshold: f32,\n #if HAS_SSR\n invProjMatrix: mat4x4f,\n outputFovInfo: array<vec4f, 2>,\n reprojViewProjMatrix: mat4x4f,\n #endif\n #ifndef HAS_COLOR\n #ifdef IS_LINE_EXTRUSION\n lineColor: vec4f,\n #else\n polygonFill: vec4f\n #endif\n #endif\n};\nstruct ShaderUniforms {\n #if HAS_IBL_LIGHTING\n hdrHSV: vec3f,\n diffuseSPH: vec3f,\n prefilterMiplevel: vec2f,\n prefilterSize: vec2f,\n #else\n ambientColor: vec3f,\n #endif\n cameraPosition: vec3f,\n cameraNearFar: vec2f,\n environmentExposure: f32,\n environmentTransform: mat3x3f,\n light0_viewDirection: vec3f,\n light0_diffuse: vec4f,\n #if HAS_LAYER_OPACITY\n layerOpacity: f32,\n #endif\n #if HAS_SSR\n outSize: vec2f,\n ssrFactor: f32,\n ssrQuality: f32,\n projMatrix: mat4x4f,\n #endif\n}\n@group(0) @binding($b) var<uniform> uniforms: SceneUniforms;\n@group(0) @binding($b) var<uniform> shaderUniforms: ShaderUniforms;\n#if HAS_ALBEDO_MAP\n @group(0) @binding($b) var baseColorTexture: texture_2d<f32>;\n @group(0) @binding($b) var baseColorSampler: sampler;\n#endif\n#if HAS_METALLICROUGHNESS_MAP\n @group(0) @binding($b) var metallicRoughnessTexture: texture_2d<f32>;\n @group(0) @binding($b) var metallicRoughnessSampler: sampler;\n#endif\n#if HAS_EMISSIVE_MAP\n @group(0) @binding($b) var emissiveTexture: texture_2d<f32>;\n @group(0) @binding($b) var emissiveSampler: sampler;\n#endif\n#if HAS_AO_MAP\n @group(0) @binding($b) var occlusionTexture: texture_2d<f32>;\n @group(0) @binding($b) var occlusionSampler: sampler;\n#endif\n#if HAS_NORMAL_MAP && HAS_TANGENT\n @group(0) @binding($b) var normalTexture: texture_2d<f32>;\n @group(0) @binding($b) var normalSampler: sampler;\n#endif\n#if HAS_SKIN_MAP\n @group(0) @binding($b) var skinTexture: texture_2d<f32>;\n @group(0) @binding($b) var skinSampler: sampler;\n#endif\n#if HAS_RANDOM_TEX\n @group(0) @binding($b) var noiseTexture: texture_2d<f32>;\n @group(0) @binding($b) var noiseSampler: sampler;\n#endif\n@group(0) @binding($b) var brdfLUT: texture_2d<f32>;\n@group(0) @binding($b) var brdfLUTSampler: sampler;\n#if HAS_IBL_LIGHTING\n @group(0) @binding($b) var prefilterMap: texture_cube<f32>;\n @group(0) @binding($b) var prefilterSampler: sampler;\n#endif\n#if HAS_SSR\n @group(0) @binding($b) var TextureDepth: texture_2d<f32>;\n @group(0) @binding($b) var TextureDepthSampler: sampler;\n @group(0) @binding($b) var TextureReflected: texture_2d<f32>;\n @group(0) @binding($b) var TextureReflectedSampler: sampler;\n#endif\n#if HAS_BUMP_MAP && HAS_TANGENT\n @group(0) @binding($b) var bumpTexture: texture_2d<f32>;\n @group(0) @binding($b) var bumpSampler: sampler;\n#endif\n#if HAS_PATTERN\n @group(0) @binding($b) var linePatternFile: texture_2d<f32>;\n @group(0) @binding($b) var linePatternSampler: sampler;\n#endif\nstruct VertexOutput {\n #ifdef HAS_SSR\n @location($i) vViewNormal: vec3f,\n #ifdef HAS_TANGENT\n @location($i) vViewTangent: vec4f,\n #endif\n #endif\n @location($i) vModelNormal: vec3f,\n @location($i) vViewVertex: vec4f,\n #if HAS_TANGENT\n @location($i) vModelTangent: vec4f,\n @location($i) vModelBiTangent: vec3f,\n #endif\n @location($i) vModelVertex: vec3f,\n #if HAS_MAP\n @location($i) vTexCoord: vec2f,\n #ifdef HAS_AO_MAP\n @location($i) vTexCoord1: vec2f,\n #endif\n #ifdef HAS_I3S_UVREGION\n @location($i) vUvRegion: vec4f,\n #endif\n #endif\n #if HAS_COLOR\n @location($i) vColor: vec4f,\n #endif\n @location($i) vOpacity: f32,\n #if HAS_COLOR0\n @location($i) vColor0: vec4f,\n #endif\n #if HAS_BUMP_MAP && HAS_TANGENT\n @location($i) vTangentViewPos: vec3f,\n @location($i) vTangentFragPos: vec3f,\n #endif\n};\nfn getMaterialAlbedo() -> vec3f {\n return materialUniforms.albedo;\n}\nfn getMaterialAlpha() -> f32 {\n return materialUniforms.alpha;\n}\nfn getMaterialMetalness() -> f32 {\n return materialUniforms.roughnessMetalness.y;\n}\nfn getMaterialRoughness() -> f32 {\n #if SHADING_MODEL_SPECULAR_GLOSSINESS\n return 1.0 - materialUniforms.glossiness;\n #else\n return materialUniforms.roughnessMetalness.x;\n #endif\n}\nfn getMaterialEmitColor() -> vec3f {\n return materialUniforms.emit;\n}\nfn getMaterialSkinColor() -> vec4f {\n return materialUniforms.skinColor;\n}\nfn getMaterialNormalMap() -> vec3f {\n return materialUniforms.normal;\n}\nfn getMaterialOcclusion() -> f32 {\n return materialUniforms.ao;\n}\nfn decodeDepth(pack: vec4f) -> f32 {\n return pack.r + pack.g / 255.0;\n}\nfn transformNormal(factor: f32, normalToTransform: vec3f, t: vec3f, b: vec3f, n: vec3f) -> vec3f {\n let normal = vec3f(normalToTransform.xy * factor, normalToTransform.z);\n let tbn = mat3x3f(t, b, n);\n return normalize(tbn * normal);\n}\nfn D_GGX(roughness: f32, normal: vec3f, H: vec3f) -> f32 {\n let NoH = clamp(dot(normal, H), 0.0, 1.0);\n let a = roughness * roughness;\n let a2 = a * a;\n let d = (NoH * a2 - NoH) * NoH + 1.0;\n return a2 / ( PI * d * d);\n}\nfn F_Schlick(f0: vec3f, f90: f32, L: vec3f, H: vec3f) -> vec3f {\n var VoH = clamp(dot(L, H), 0.0, 1.0);\n VoH = pow(1.0 - VoH, 5.0);\n return f90 * VoH + (1.0 - VoH) * f0;\n}\nfn V_SmithGGXCorrelated(normal: vec3f, V: vec3f, roughness: f32, NoL: f32) -> f32 {\n let NoV = clamp(dot(normal, V), 0.0, 1.0);\n let a = roughness * roughness;\n let GGXL = NoV * (NoL * (1.0 - a) + a);\n let GGXV = NoL * (NoV * (1.0 - a) + a);\n return 0.5 / (GGXV + GGXL);\n}\nfn computeSpecularBRDF(roughness: f32, normal: vec3f, V: vec3f, L: vec3f, specular: vec3f, NoL: f32, f90: f32) -> vec3f {\n let H = normalize(V + L);\n let D = D_GGX(roughness, normal, H);\n let V_S = V_SmithGGXCorrelated(normal, V, roughness, NoL);\n let F = F_Schlick(specular, f90, L, H);\n return (D * V_S * PI) * F;\n}\nfn BRDF_Lambert(diffuseColor: vec3f) -> vec3f {\n return RECIPROCAL_PI * diffuseColor;\n}\nstruct LambertLight {\n diffuse: vec3f,\n specular: vec3f\n}\nfn computeLambert(\n normal: vec3f,\n V: vec3f,\n NoL: f32,\n roughness: f32,\n materialDiffuse: vec3f,\n specular: vec3f,\n lightColor: vec3f,\n L: vec3f,\n f90: f32\n) -> LambertLight {\n var lambert: LambertLight;\n if (NoL <= 0.0) {\n lambert.diffuse = vec3f(0.0);\n lambert.specular = vec3f(0.0);\n return lambert;\n }\n let a = NoL * lightColor;\n let brdf = computeSpecularBRDF(roughness, normal, V, L, specular, NoL, f90);\n lambert.specular = a * brdf;\n lambert.diffuse = a * BRDF_Lambert(materialDiffuse);\n return lambert;\n}\n#if HAS_IBL_LIGHTING\n fn computeDiffuseSPH(normal: vec3f) -> vec3f {\n let n = uniforms.environmentTransform * normal;\n let diffuseSPH = shaderUniforms.diffuseSPH;\n let x = n.x;\n let y = n.y;\n let z = n.z;\n let result = (\n diffuseSPH[0] +\n diffuseSPH[1] * x +\n diffuseSPH[2] * y +\n diffuseSPH[3] * z +\n diffuseSPH[4] * z * x +\n diffuseSPH[5] * y * z +\n diffuseSPH[6] * y * x +\n diffuseSPH[7] * (3.0 * z * z - 1.0) +\n diffuseSPH[8] * (x*x - y*y)\n );\n if (length(shaderUniforms.hdrHSV) > 0.0) {\n return hsv_apply3(result, shaderUniforms.hdrHSV);\n }\n return max(result, vec3f(0.0));\n }\n fn fetchEnvMap(roughness: f32, R: vec3f) -> vec3f {\n let dir = R;\n let maxLevels = shaderUniforms.prefilterMiplevel.x;\n let lod = min(maxLevels, roughness * shaderUniforms.prefilterMiplevel.y);\n var envLight = textureSampleLevel(prefilterMap, prefilterSampler, dir, lod).rgb;\n if (length(shaderUniforms.hdrHSV) > 0.0) {\n envLight = hsv_apply3(envLight, shaderUniforms.hdrHSV);\n }\n return envLight;\n }\n fn getIBLEnvMap(N: vec3f, V: vec3f, roughness: f32, frontNormal: vec3f, materialDiffuse: vec3f) -> vec3f {\n let smoothness = 1.0 - roughness;\n let R = mix(N, reflect(-V, N), smoothness * (sqrt(smoothness) + roughness));\n let factor = clamp(1.0 + dot(R, frontNormal), 0.0, 1.0);\n let prefilteredEnvColor = fetchEnvMap(roughness, uniforms.environmentTransform * R) * factor * factor;\n return prefilteredEnvColor;\n }\n#else\n fn getIBLEnvMap(normal: vec3f, eyeVector: vec3f, roughness: f32, frontNormal: vec3f, materialDiffuse: vec3f) -> vec3f {\n return shaderUniforms.ambientColor * BRDF_Lambert(materialDiffuse);\n }\n#endif\nfn computeBRDF(spec: vec3f, roughness: f32, NoV: f32, f90: f32) -> vec3f {\n let rgba = textureSample(brdfLUT, brdfLUTSampler, vec2f(NoV, roughness)) * vec4f(255.0, 65280.0, 255.0, 65280.0);\n let b = (rgba[3] + rgba[2]);\n let a = (rgba[1] + rgba[0]);\n return (spec * a + b * f90) / 65535.0;\n}\nfn computeIBLSpecular(\n normal: vec3f,\n eyeVector: vec3f,\n NoV: f32,\n roughness: f32,\n specular: vec3f,\n frontNormal: vec3f,\n f90: f32,\n materialDiffuse: vec3f\n) -> vec3f {\n return getIBLEnvMap(normal, eyeVector, roughness, frontNormal, materialDiffuse) * computeBRDF(specular, roughness, NoV, f90);\n}\nfn computeSpecularAO(ao: f32, NoV: f32) -> f32 {\n let d = NoV + ao;\n return clamp((d * d) - 1.0 + ao, 0.0, 1.0);\n}\nfn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {\n var materialUniforms: MaterialUniforms;\n#ifdef HAS_MAP\n var uv = computeTexCoord(vertexOutput.vTexCoord);\n#endif\n#ifdef HAS_UV_FLIP\n uv.y = 1.0 - uv.y;\n#endif\n#if HAS_BUMP_MAP && HAS_TANGENT\n uv = bumpUV(uv, normalize(vertexOutput.vTangentViewPos - vertexOutput.vTangentFragPos));\n#endif\n materialUniforms.albedo = uniforms.baseColorIntensity * uniforms.baseColorFactor.rgb;\n materialUniforms.alpha = uniforms.baseColorFactor.a * vertexOutput.vOpacity;\n#if HAS_PATTERN\n var linesofar = vertexOutput.vLinesofar;\n let uvSize = vertexOutput.vTexInfo.zw;\n#ifdef HAS_PATTERN_GAP\n let myGap = vertexOutput.vLinePatternGap;\n#else\n let myGap = uniforms.linePatternGap;\n#endif\n#ifdef HAS_PATTERN_ANIM\n let myAnimSpeed = vertexOutput.vLinePatternAnimSpeed;\n#else\n let myAnimSpeed = uniforms.linePatternAnimSpeed;\n#endif\n let patternWidth = ceil(uvSize.x * vertexOutput.vPatternHeight / uvSize.y);\n let plusGapWidth = patternWidth * (1.0 + myGap);\n let animSpeed = myAnimSpeed / uniforms.animSpeedScale;\n linesofar += (uniforms.currentTime * -animSpeed * 0.2) % plusGapWidth;\n let patternx = (linesofar / plusGapWidth) % 1.0;\n let patterny = (uniforms.flipY * vertexOutput.vNormalY) % 1.0;\n uv = computeUV(vec2(patternx * (1.0 + myGap) * uniforms.uvScale[0], patterny * uniforms.uvScale[1]));\n let patternColor = textureSample(linePatternFile, linePatternFileSampler, uv);\n let inGap = clamp(sign(1.0 / (1.0 + myGap) - patternx) + 0.000001, 0.0, 1.0);\n let patternColor = mix(uniforms.linePatternGapColor, patternColor, inGap);\n#ifdef IS_SQUARE_TUBE\n let v = clamp(sign(abs(vertexOutput.vNormalY) - 0.999999), 0.0, 1.0);\n let patternColor = mix(patternColor, vec4(1.0), v);\n#endif\n materialUniforms.albedo *= patternColor.rgb;\n materialUniforms.alpha *= patternColor.a;\n#endif\n#if HAS_ALBEDO_MAP\n let baseColor = textureSample(baseColorTexture, baseColorTextureSampler, uv);\n materialUniforms.albedo *= sRGBToLinear(baseColor.rgb);\n materialUniforms.alpha *= baseColor.a;\n#endif\n#if HAS_SKIN_MAP\n let skinColorValue = textureSample(skinTexture, skinTextureSampler, uv);\n materialUniforms.skinColor = skinColorValue;\n#endif\n#if HAS_COLOR0\n materialUniforms.albedo *= vertexOutput.vColor0.rgb;\n#if COLOR0_SIZE == 4\n materialUniforms.alpha *= vertexOutput.vColor0.a;\n#endif\n#endif\n#if HAS_COLOR\n materialUniforms.albedo *= vertexOutput.vColor.rgb;\n materialUniforms.alpha *= vertexOutput.vColor.a;\n#elif IS_LINE_EXTRUSION\n materialUniforms.albedo *= uniforms.lineColor.rgb;\n materialUniforms.alpha *= uniforms.lineColor.a;\n#else\n materialUniforms.albedo *= uniforms.polygonFill.rgb;\n materialUniforms.alpha *= uniforms.polygonFill.a;\n#endif\n#if HAS_INSTANCE_COLOR\n materialUniforms.albedo *= vertexOutput.vInstanceColor.rgb;\n materialUniforms.alpha *= vertexOutput.vInstanceColor.a;\n#endif\n#if HAS_METALLICROUGHNESS_MAP\n let mrSample = textureSample(metallicRoughnessTexture, metallicRoughnessTextureSampler, uv).gb;\n materialUniforms.roughnessMetalness = mrSample * vec2(uniforms.roughnessFactor, uniforms.metallicFactor);\n#else\n materialUniforms.roughnessMetalness = vec2(uniforms.roughnessFactor, uniforms.metallicFactor);\n#endif\n materialUniforms.emit = uniforms.emissiveFactor;\n#if HAS_EMISSIVE_MAP\n if (uniforms.emitMultiplicative == 1.0) {\n materialUniforms.emit *= sRGBToLinear(textureSample(emissiveTexture, emissiveTextureSampler, uv).rgb);\n } else {\n materialUniforms.emit += sRGBToLinear(textureSample(emissiveTexture, emissiveTextureSampler, uv).rgb);\n }\n#endif\n materialUniforms.emit *= uniforms.emitColorFactor;\n#if HAS_AO_MAP\n let aoTexCoord = computeTexCoord(vertexOutput.vTexCoord1);\n materialUniforms.ao = textureSample(occlusionTexture, occlusionTextureSampler, aoTexCoord).r;\n#else\n materialUniforms.ao = 1.0;\n#endif\n materialUniforms.ao *= uniforms.occlusionFactor;\n#if HAS_NORMAL_MAP && HAS_TANGENT\n var nmap = textureSample(normalTexture, normalTextureSampler, uv).xyz * 2.0 - 1.0;\n nmap.y = select(nmap.y, -namp.y, uniforms.normalMapFlipY == 1.0);\n materialUniforms.normal = nmap;\n#else\n materialUniforms.normal = normalize(vertexOutput.vModelNormal);\n#endif\n#if HAS_TERRAIN_NORMAL && HAS_TANGENT\n var nmap = convertTerrainHeightToNormalMap(uv);\n nmap.y = select(nmap.y, -namp.y, uniforms.normalMapFlipY == 1.0);\n materialUniforms.normal = nmap;\n#endif\n#if SHADING_MODEL_SPECULAR_GLOSSINESS\n materialUniforms.albedo *= uniforms.diffuseFactor.rgb;\n materialUniforms.alpha *= uniforms.diffuseFactor.a;\n#if HAS_DIFFUSE_MAP\n let diffuse = textureSample(diffuseTexture, diffuseTextureSampler, uv);\n materialUniforms.albedo *= sRGBToLinear(diffuse.rgb);\n materialUniforms.alpha *= diffuse.a;\n#endif\n materialUniforms.specularColor = uniforms.specularFactor;\n materialUniforms.glossiness = uniforms.glossinessFactor;\n#if HAS_SPECULARGLOSSINESS_MAP\n let specularGlossiness = textureSample(specularGlossinessTexture, specularGlossinessTextureSampler, uv);\n materialUniforms.specularColor *= sRGBToLinear(specularGlossiness.rgb);\n materialUniforms.glossiness *= specularGlossiness.a;\n#endif\n#endif\n return materialUniforms;\n}\nfn HDR_ACES(x: vec3f) -> vec3f {\n const a = 2.51;\n const b = 0.03;\n const c = 2.43;\n const d = 0.59;\n const e = 0.14;\n return (x * (a * x + b)) / (x * (c * x + d) + e);\n}\nfn tonemap(color: vec3f) -> vec3f {\n let tonemapped = HDR_ACES(color);\n return pow(tonemapped, vec3f(1.0/2.2));\n}\nfn normalFiltering(roughness: f32, worldNormal: vec3f) -> f32 {\n let du = dpdx(worldNormal);\n let dv = dpdy(worldNormal);\n let variance = uniforms.specularAAVariance * (dot(du, du) + dot(dv, dv));\n let kernelRoughness = min(2.0 * variance, uniforms.specularAAThreshold);\n let squareRoughness = saturate(roughness * roughness + kernelRoughness);\n return sqrt(squareRoughness);\n}\n#if HAS_SSR\n fn ssrViewToScreen(projection: mat4x4f, viewVertex: vec3f) -> vec3f {\n let projected = projection * vec4f(viewVertex, 1.0);\n return vec3f(0.5 + 0.5 * projected.xy / projected.w, projected.w);\n }\n fn fetchColorLod(level: f32, uv: vec2f) -> vec3f {\n return textureSampleLevel(TextureReflected, TextureReflectedSampler, uv, level).rgb;\n }\n fn linearizeDepth(depth: f32) -> f32 {\n let projection = uniforms.projMatrix;\n let z = depth * 2.0 - 1.0; return -projection[3].z / (z + projection[2].z);\n }\n fn fetchDepth(uv: vec2f) -> f32 {\n let depth = decodeDepth(textureSample(TextureDepth, TextureDepthSampler, uv));\n return depth;\n }\n fn interleavedGradientNoise(fragCoord: vec2f, frameMod: f32) -> f32 {\n let magic = vec3f(0.06711056, 0.00583715, 52.9829189);\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2f(47.0, 17.0) * 0.695, magic.xy))) * 0.5;\n }\n fn importanceSampling(\n frameMod: f32,\n tangentX: vec3f,\n tangentY: vec3f,\n tangentZ: vec3f,\n eyeVector: vec3f,\n rough4: f32\n ) -> vec3f {\n var E: vec2f;\n E.x = interleavedGradientNoise(fragCoord.yx, frameMod);\n E.y = fract(E.x * 52.9829189);\n E.y = mix(E.y, 1.0, 0.7);\n let phi = 2.0 * 3.14159 * E.x;\n let cosTheta = pow(max(E.y, 0.000001), rough4 / (2.0 - rough4));\n let sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n var h = vec3f(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);\n h = h.x * tangentX + h.y * tangentY + h.z * tangentZ;\n return normalize((2.0 * dot(eyeVector, h)) * h - eyeVector);\n }\n fn getStepOffset(frameMod: f32) -> f32 {\n return (interleavedGradientNoise(fragCoord.xy, frameMod) - 0.5);\n }\n fn computeRayDirUV(rayOriginUV: vec3f, rayLen: f32, rayDirView: vec3f) -> vec3f {\n let rayDirUV = ssrViewToScreen(uniforms.projMatrix, vViewVertex.xyz + rayDirView * rayLen);\n rayDirUV.z = 1.0 / rayDirUV.z;\n rayDirUV -= rayOriginUV;\n let scaleMaxX = min(1.0, 0.99 * (1.0 - rayOriginUV.x) / max(1e-5, rayDirUV.x));\n let scaleMaxY = min(1.0, 0.99 * (1.0 - rayOriginUV.y) / max(1e-5, rayDirUV.y));\n let scaleMinX = min(1.0, 0.99 * rayOriginUV.x / max(1e-5, -rayDirUV.x));\n let scaleMinY = min(1.0, 0.99 * rayOriginUV.y / max(1e-5, -rayDirUV.y));\n return rayDirUV * min(scaleMaxX, scaleMaxY) * min(scaleMinX, scaleMinY);\n }\n fn binarySearch(rayOriginUV: vec3f, rayDirUV: vec3f, startSteps: ptr<function, f32>, endSteps: ptr<function, f32>) -> f32 {\n let steps = (*startSteps + *endSteps) * 0.5;\n let sampleUV = rayOriginUV + rayDirUV * steps;\n let z = fetchDepth(sampleUV.xy);\n let depth = linearizeDepth(z);\n let sampleDepth = -1.0 / sampleUV.z;\n *startSteps = select(steps, *startSteps, depth > sampleDepth);\n *endSteps = select(*endSteps, steps, depth > sampleDepth);\n return steps;\n }\n fn rayTrace(\n rayOriginUV: vec3f,\n rayLen: f32,\n depthTolerance: f32,\n rayDirView: vec3f,\n roughness: f32,\n frameMod: f32\n ) -> vec4f {\n let checkSteps = 20;\n let invNumSteps = 1.0 / f32(checkSteps);\n depthTolerance *= invNumSteps;\n let rayDirUV = computeRayDirUV(rayOriginUV, rayLen, rayDirView);\n let sampleTime = invNumSteps;\n var diffSampleW = vec3f(0.0, sampleTime, 1.0);\n var sampleUV: vec3f;\n var hit = false;\n var hitDepth = 1.0;\n var steps: f32;\n for (var i = 0; i < checkSteps; i++) {\n sampleUV = rayOriginUV + rayDirUV * diffSampleW.y;\n let z = fetchDepth(sampleUV.xy);\n let depth = linearizeDepth(z);\n let sampleDepth = -1.0 / sampleUV.z;\n let validDepth = clamp(sign(0.999 - z), 0.0, 1.0);\n var depthDiff = validDepth * (sampleDepth - depth);\n depthDiff *= clamp(sign(abs(depthDiff) - rayLen * invNumSteps * invNumSteps), 0.0, 1.0);\n hit = abs(depthDiff + depthTolerance) < depthTolerance;\n let timeLerp = clamp(diffSampleW.x / (diffSampleW.x - depthDiff), 0.0, 1.0);\n let hitTime = select(1.0, (diffSampleW.y + timeLerp * invNumSteps - invNumSteps), hit);\n diffSampleW.z = min(diffSampleW.z, hitTime);\n diffSampleW.x = depthDiff;\n if (hit) {\n var startSteps = diffSampleW.y - invNumSteps;\n var endSteps = diffSampleW.y;\n steps = binarySearch(rayOriginUV, rayDirUV, &startSteps, &endSteps);\n steps = binarySearch(rayOriginUV, rayDirUV, &startSteps, &endSteps);\n steps = binarySearch(rayOriginUV, rayDirUV, &startSteps, &endSteps);\n hitDepth = steps;\n break;\n }\n diffSampleW.y += invNumSteps;\n }\n return vec4f(rayOriginUV + rayDirUV * hitDepth, 1.0 - hitDepth);\n }\n fn fetchColorInRay(\n resRay: vec4f,\n maskSsr: f32,\n specularEnvironment: vec3f,\n specularColor: vec3f,\n roughness: f32\n ) -> vec4f {\n let AB = mix(uniforms.outputFovInfo[0], uniforms.outputFovInfo[1], resRay.x);\n resRay.xyz = vec3f(mix(AB.xy, AB.zw, resRay.y), 1.0) * -1.0 / resRay.z;\n resRay.xyz = (uniforms.reprojViewProjMatrix * vec4f(resRay.xyz, 1.0)).xyw;\n resRay.xy /= resRay.z;\n let maskEdge = clamp(6.0 - 6.0 * max(abs(resRay.x), abs(resRay.y)), 0.0, 1.0);\n resRay.xy = 0.5 + 0.5 * resRay.xy;\n let fetchColor = specularColor * fetchColorLod(roughness * (1.0 - resRay.w), resRay.xy);\n return vec4f(mix(specularEnvironment, fetchColor, maskSsr * maskEdge), 1.0);\n }\n fn ssr(\n specularEnvironment: vec3f,\n specularColor: vec3f,\n roughness: f32,\n normal: vec3f,\n eyeVector: vec3f\n ) -> vec3f {\n let taaSS = 0.0;\n var result = vec4f(0.0);\n var rough4 = roughness * roughness;\n rough4 = rough4 * rough4;\n let upVector = select(vec3f(1.0, 0.0, 0.0), vec3f(0.0, 0.0, 1.0), abs(normal.z) < 0.999);\n let tangentX = normalize(cross(upVector, normal));\n let tangentY = cross(normal, tangentX);\n var maskSsr = shaderUniforms.ssrFactor * clamp(-4.0 * dot(eyeVector, normal) + 3.8, 0.0, 1.0);\n maskSsr *= clamp(4.7 - roughness * 5.0, 0.0, 1.0);\n let rayOriginUV = ssrViewToScreen(shaderUniforms.projMatrix, vViewVertex.xyz);\n rayOriginUV.z = 1.0 / rayOriginUV.z;\n let rayDirView = importanceSampling(taaSS, tangentX, tangentY, normal, eyeVector, rough4);\n let rayLen = mix(shaderUniforms.cameraNearFar.y + vViewVertex.z, -vViewVertex.z - shaderUniforms.cameraNearFar.x, rayDirView.z * 0.5 + 0.5);\n let depthTolerance = 0.5 * rayLen;\n var resRay: vec4f;\n if (dot(rayDirView, normal) > 0.001 && maskSsr > 0.0) {\n resRay = rayTrace(rayOriginUV, rayLen, depthTolerance, rayDirView, roughness, taaSS);\n if (resRay.w > 0.0) {\n result += fetchColorInRay(resRay, maskSsr, specularEnvironment, specularColor, roughness);\n }\n }\n return select(specularEnvironment, result.rgb / result.w, result.w > 0.0);\n }\n#endif\nfn sRGBTransferOETF(value: vec4f) -> vec4f {\n let isLow: vec3<bool> = value.rgb <= vec3f(0.0031308);\n let highPart: vec3f = pow(value.rgb, vec3f(0.41666)) * 1.055 - vec3f(0.055);\n let lowPart: vec3f = value.rgb * 12.92;\n let rgb: vec3f = select(highPart, lowPart, isLow);\n return vec4f(rgb, value.a);\n}\nfn linearToOutputTexel(value: vec4f) -> vec4f {\n return sRGBTransferOETF(value);\n}\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n materialUniforms = initMaterial(vertexOutput);\n var glFragColor: vec4f;\n let eyeVector = normalize(shaderUniforms.cameraPosition - vertexOutput.vModelVertex);\n #if HAS_DOUBLE_SIDE\n let frontNormal = select(-normalize(vertexOutput.vModelNormal), normalize(vertexOutput.vModelNormal), gl_FrontFacing);\n #else\n let frontNormal = normalize(vertexOutput.vModelNormal);\n #endif\n let f0 = 0.08 * uniforms.specularF0;\n let metal = getMaterialMetalness();\n var materialDiffuse = getMaterialAlbedo();\n #if SHADING_MODEL_SPECULAR_GLOSSINESS\n let materialSpecular = materialUniforms.specularColor;\n #else\n let materialSpecular = mix(vec3f(f0), materialDiffuse, metal);\n #endif\n materialDiffuse *= 1.0 - metal;\n let materialF90 = clamp(50.0 * materialSpecular.g, 0.0, 1.0);\n var materialRoughness = getMaterialRoughness();\n if (uniforms.specularAAVariance > 0.0) {\n materialRoughness = normalFiltering(materialRoughness, frontNormal);\n }\n let materialEmit = getMaterialEmitColor();\n var materialNormal = getMaterialNormalMap();\n #if HAS_TANGENT\n #if HAS_NORMAL_MAP || HAS_TERRAIN_NORMAL\n materialNormal = transformNormal(uniforms.normalMapFactor, materialNormal, vertexOutput.vModelTangent.xyz, vertexOutput.vModelBiTangent, frontNormal);\n #endif\n #endif\n var diffuse = vec3f(0.0);\n var specular = vec3f(0.0);\n #if HAS_IBL_LIGHTING\n diffuse = materialDiffuse * computeDiffuseSPH(materialNormal) * 0.5;\n #else\n diffuse = materialDiffuse * shaderUniforms.ambientColor;\n #endif\n let NoV = dot(materialNormal, eyeVector);\n specular = computeIBLSpecular(materialNormal, eyeVector, NoV, materialRoughness, materialSpecular, frontNormal, materialF90, materialDiffuse);\n var specularAO = 1.0;\n let materialAO = getMaterialOcclusion();\n diffuse *= shaderUniforms.environmentExposure * materialAO;\n #if HAS_IBL_LIGHTING\n specularAO = computeSpecularAO(materialAO, NoV);\n #endif\n #if HAS_SSR\n var ssrfrontNormal = normalize(select(-vertexOutput.vViewNormal, vertexOutput.vViewNormal, gl_FrontFacing));\n var viewNormal = ssrfrontNormal;\n #if HAS_TANGENT\n #if HAS_NORMAL_MAP || HAS_TERRAIN_NORMAL\n var ssrTangent = select(-vertexOutput.vViewTangent, vertexOutput.vViewTangent, gl_FrontFacing);\n ssrTangent.xyz = normalize(ssrTangent.xyz);\n let ssrBinormal = normalize(cross(ssrfrontNormal, ssrTangent.xyz)) * ssrTangent.w;\n viewNormal = transformNormal(uniforms.normalMapFactor, materialNormal, ssrTangent.xyz, ssrBinormal, ssrfrontNormal);\n #endif\n #endif\n specular = ssr(specular, materialSpecular * specularAO, materialRoughness, viewNormal, -normalize(vertexOutput.vViewVertex.xyz));\n #endif\n specular *= shaderUniforms.environmentExposure * specularAO;\n let modelNormal = vertexOutput.vModelNormal;\n let lightDir = -shaderUniforms.light0_viewDirection;\n let dotNL = saturate(dot(lightDir, materialNormal));\n let lambertResult = computeLambert(materialNormal, eyeVector, dotNL, max(0.045, materialRoughness), materialDiffuse, materialSpecular, shaderUniforms.light0_diffuse.rgb, lightDir, materialF90);\n var ambientDiffuse = lambertResult.diffuse;\n var ambientSpecular = lambertResult.specular;\n #if HAS_SHADOWING && !HAS_BLOOM\n let shadowCoeff = shadow_computeShadow();\n ambientDiffuse = shadow_blend(ambientDiffuse, shadowCoeff).rgb;\n ambientSpecular = shadow_blend(ambientSpecular, shadowCoeff).rgb;\n #endif\n diffuse += ambientDiffuse;\n specular += ambientSpecular;\n diffuse += materialEmit;\n var frag = specular + diffuse;\n if (uniforms.outputSRGB == 1.0) {\n frag = linearTosRGB(frag);\n }\n #if HAS_SKIN_MAP\n let skinColor = getMaterialSkinColor();\n frag.rgb = frag.rgb * (1.0 - skinColor.a) + skinColor.rgb * skinColor.a;\n #if HAS_SHADOWING && !HAS_BLOOM\n frag.rgb = shadow_blend(frag.rgb, shadowCoeff).rgb;\n #endif\n #endif\n var alpha = getMaterialAlpha();\n if (alpha < uniforms.alphaTest) {\n discard;\n }\n #if ALPHA_MODE\n #if ALPHA_MODE == 1\n if (alpha < uniforms.alphaCutoff) {\n discard;\n } else {\n alpha = 1.0;\n }\n #else\n alpha = 1.0;\n #endif\n #endif\n glFragColor = vec4f(frag * alpha, alpha);\n #ifdef HAS_VERTEX_COLOR\n glFragColor *= vertexColor_get(vertexOutput);\n #endif\n #ifdef HAS_EXCAVATE_ANALYSIS\n glFragColor = excavateColor(glFragColor);\n #endif\n #ifdef HAS_SNOW\n glFragColor.rgb = snow(glFragColor, getMaterialNormalMap(), 1.0);\n #endif\n if (uniforms.contrast != 1.0) {\n glFragColor = contrastMatrix(uniforms.contrast) * glFragColor;\n }\n if (length(uniforms.hsv) > 0.0) {\n glFragColor = hsv_apply4(glFragColor, uniforms.hsv);\n }\n #ifdef OUTPUT_NORMAL\n glFragColor = vec4f(frontNormal, 1.0);\n #endif\n #if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n glFragColor = highlight_blendColor(glFragColor, vertexOutput);\n #endif\n #ifdef HAS_LAYER_OPACITY\n glFragColor *= shaderUniforms.layerOpacity;\n #endif\n #ifdef HAS_MASK_EXTENT\n glFragColor = setMask(glFragColor);\n #endif\n return glFragColor;\n}",
28680
+ wgslVert: e.wgslVert || "#include <highlight_vert>\n#include <line_extrusion_vert>\n#include <get_output>\n#include <vsm_shadow_vert>\n#include <vertex_color_vert>\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <excavate_vert>\n#include <common_pack_float>\nstruct VertexInput {\n #ifdef POSITION_IS_INT\n @location($i) aPosition: vec4i,\n #else\n @location($i) aPosition: vec3f,\n #endif\n #if HAS_MAP || HAS_TERRAIN_FLAT_MASK\n @location($i) aTexCoord: vec2f,\n #endif\n #if HAS_MAP\n #ifdef HAS_I3S_UVREGION\n @location($i) uvRegion: vec4f,\n #endif\n #if HAS_AO_MAP\n @location($i) aTexCoord1: vec2f,\n #endif\n #endif\n #if HAS_COLOR\n @location($i) aColor: vec4u,\n #endif\n #ifdef HAS_OPACITY\n @location($i) aOpacity: u32,\n #endif\n #if HAS_COLOR0\n #if COLOR0_SIZE == 3\n @location($i) aColor0: vec3u,\n #else\n @location($i) aColor0: vec4u,\n #endif\n #endif\n #if HAS_TANGENT || HAS_NORMAL\n #ifdef NORMAL_IS_INT\n @location($i) aNormal: vec4i,\n #else\n @location($i) aNormal: vec3f,\n #endif\n #if HAS_TANGENT\n @location($i) aTangent: vec4f,\n #endif\n #endif\n}\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n #ifdef HAS_SSR\n @location($o) vViewNormal: vec3f,\n #ifdef HAS_TANGENT\n @location($o) vViewTangent: vec4f,\n #endif\n #endif\n @location($o) vModelNormal: vec3f,\n @location($o) vViewVertex: vec4f,\n #if HAS_TANGENT\n @location($o) vModelTangent: vec4f,\n @location($o) vModelBiTangent: vec3f,\n #endif\n @location($o) vModelVertex: vec3f,\n #if HAS_MAP\n @location($o) vTexCoord: vec2f,\n #ifdef HAS_AO_MAP\n @location($o) vTexCoord1: vec2f,\n #endif\n #ifdef HAS_I3S_UVREGION\n @location($o) vUvRegion: vec4f,\n #endif\n #endif\n #if HAS_COLOR\n @location($o) vColor: vec4f,\n #endif\n @location($o) vOpacity: f32,\n #if HAS_COLOR0\n @location($o) vColor0: vec4f,\n #endif\n #if HAS_BUMP_MAP && HAS_TANGENT\n @location($o) vTangentViewPos: vec3f,\n @location($o) vTangentFragPos: vec3f,\n #endif\n}\nstruct ShaderUniforms {\n cameraPosition: vec3f,\n projMatrix: mat4x4f,\n}\nstruct Uniforms {\n uvOrigin: vec2f,\n uvScale: vec2f,\n uvOffset: vec2f,\n uvRotation: f32,\n modelMatrix: mat4x4f,\n modelViewMatrix: mat4x4f,\n positionMatrix: mat4x4f,\n modelNormalMatrix: mat3x3f,\n #ifdef HAS_SSR\n modelViewNormalMatrix: mat3x3f,\n #endif\n};\n@group(0) @binding($b) var<uniform> uniforms: Uniforms;\n@group(0) @binding($b) var<uniform> shaderUniforms: ShaderUniforms;\nvar<private> Vertex: vec3f;\nvar<private> Normal: vec3f;\nvar<private> Tangent: vec4f;\nconst mid = 0.5;\nfn toTangentFrame(q: vec4f) -> vec3f {\n return vec3f(0.0, 0.0, 1.0) +\n vec3f(2.0, -2.0, -2.0) * q.x * q.zwx +\n vec3f(2.0, 2.0, -2.0) * q.y * q.wzy;\n}\nstruct TangentFrame {\n n: vec3f,\n t: vec3f\n}\nfn toTangentFrameWithTangent(q: vec4f) -> TangentFrame {\n var out: TangentFrame;\n out.n = toTangentFrame(q);\n out.t = vec3f(1.0, 0.0, 0.0) +\n vec3f(-2.0, 2.0, -2.0) * q.y * q.yxw +\n vec3f(-2.0, 2.0, 2.0) * q.z * q.zwx;\n return out;\n}\nfn rotateUV(uv: vec2f, rotation: f32) -> vec2f {\n return vec2f(\n cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,\n cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid\n );\n}\n#if HAS_MAP\nfn transformTexcoord(uv: vec2f) -> vec2f {\n let decodedTexCoord = decode_getTexcoord(uv);\n #ifdef HAS_RANDOM_TEX\n let origin = uniforms.uvOrigin;\n let texCoord = decodedTexCoord * uniforms.uvScale + uniforms.uvOffset;\n return (origin % 1.0) + texCoord;\n #else\n var origin = uniforms.uvOrigin;\n var texCoord = decodedTexCoord * uniforms.uvScale;\n if (uniforms.uvRotation != 0.0) {\n origin = rotateUV(origin, uniforms.uvRotation);\n texCoord = rotateUV(texCoord, uniforms.uvRotation);\n }\n return (origin % 1.0) + texCoord + uniforms.uvOffset;\n #endif\n}\n#endif\nfn transposeMat3(inMat: mat3x3f) -> mat3x3f {\n let i0 = inMat[0];\n let i1 = inMat[1];\n let i2 = inMat[2];\n return mat3x3f(\n vec3f(i0.x, i1.x, i2.x),\n vec3f(i0.y, i1.y, i2.y),\n vec3f(i0.z, i1.z, i2.z)\n );\n}\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let localPositionMatrix = getPositionMatrix(input, &output, uniforms.positionMatrix);\n #ifdef IS_LINE_EXTRUSION\n let linePosition = getLineExtrudePosition(vec3f(input.aPosition.xyz), input);\n let localVertex = getPosition(linePosition, input);\n #else\n let localVertex = getPosition(vec3f(input.aPosition.xyz), input);\n #endif\n output.vModelVertex = (uniforms.modelMatrix * localVertex).xyz;\n let position = localPositionMatrix * localVertex;\n let viewVertex = uniforms.modelViewMatrix * position;\n output.vViewVertex = viewVertex;\n #ifdef HAS_MASK_EXTENT\n output.position = shaderUniforms.projMatrix * getMaskPosition(position, uniforms.modelMatrix);\n #else\n output.position = shaderUniforms.projMatrix * viewVertex;\n #endif\n #ifdef PICKING_MODE\n var alpha = 1.0;\n #if HAS_COLOR\n alpha *= f32(input.aColor.a);\n #endif\n #if HAS_COLOR0 && COLOR0_SIZE == 4\n alpha *= f32(input.aColor0.a);\n #endif\n fbo_picking_setData(vertex, &output, output.position.w, alpha != 0.0);\n #else\n #if HAS_MAP\n output.vTexCoord = transformTexcoord(input.aTexCoord);\n #ifdef HAS_AO_MAP\n output.vTexCoord1 = transformTexcoord(input.aTexCoord1);\n #endif\n #ifdef HAS_I3S_UVREGION\n output.vUvRegion = input.uvRegion / 65535.0;\n #endif\n #endif\n #if HAS_TANGENT || HAS_NORMAL\n let positionNormalMatrix = mat3x3f(\n localPositionMatrix[0].xyz,\n localPositionMatrix[1].xyz,\n localPositionMatrix[2].xyz\n );\n let normalMatrix = uniforms.modelNormalMatrix * positionNormalMatrix;\n #if HAS_TANGENT\n let tangentFrame = toTangentFrameWithTangent(input.aTangent);\n Normal = tangentFrame.n;\n let t = tangentFrame.t;\n output.vModelTangent = vec4f(normalMatrix * t, input.aTangent.w);\n #else\n Normal = decode_getNormal(vec3f(input.aNormal.xyz));\n #endif\n let localNormal = Normal;\n output.vModelNormal = normalMatrix * localNormal;\n #else\n Normal = vec3f(0);\n output.vModelNormal = vec3f(0);\n #endif\n #if HAS_TANGENT\n output.vModelBiTangent = cross(output.vModelNormal, output.vModelTangent.xyz) * sign(input.aTangent.w);\n #endif\n #ifdef HAS_SSR\n let ssrNormalMatrix = uniforms.modelViewNormalMatrix * positionNormalMatrix;\n output.vViewNormal = ssrNormalMatrix * Normal;\n #if HAS_TANGENT\n let localTangent = vec4f(t, input.aTangent.w);\n output.vViewTangent = vec4f(ssrNormalMatrix * localTangent.xyz, localTangent.w);\n #endif\n #endif\n #if HAS_COLOR\n output.vColor = vec4f(input.aColor) / 255.0;\n #endif\n #ifdef HAS_OPACITY\n output.vOpacity = f32(input.aOpacity) / 255.0;\n #else\n output.vOpacity = 1.0;\n #endif\n #if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n highlight_setVarying(input, &output);\n #endif\n #if HAS_COLOR0\n #if COLOR0_SIZE == 3\n output.vColor0 = vec4f(vec3f(input.aColor0), 255.0) / 255.0;\n #else\n output.vColor0 = vec4f(input.aColor0) / 255.0;\n #endif\n #endif\n #if HAS_SHADOWING && !HAS_BLOOM\n shadow_computeShadowPars(position);\n #endif\n #if HAS_BUMP_MAP && HAS_TANGENT\n let TBN = transposeMat3(mat3x3f(output.vModelTangent.xyz, output.vModelBiTangent, output.vModelNormal));\n output.vTangentViewPos = TBN * shaderUniforms.cameraPosition;\n output.vTangentFragPos = TBN * output.vModelVertex;\n #endif\n #ifdef HAS_VERTEX_COLOR\n vertexColor_update(input, &output);\n #endif\n #ifdef HAS_EXCAVATE_ANALYSIS\n output.vCoordinateTexcoord = getCoordinateTexcoord(position, uniforms.modelMatrix);\n output.vExcavateHeight = getWorldHeight(position, uniforms.modelMatrix);\n #endif\n #endif\n return output;\n}",
28681
+ wgslFrag: e.wgslFrag || "#include <hsv_frag>\n#include <srgb_frag>\n#include <highlight_frag>\n#include <snow_frag>\n#include <mask_frag>\n#include <terrain_normal_frag>\n#include <vertex_color_frag>\n#include <excavate_frag>\n#include <compute_texcoord_frag>\n#define PI 3.141593\n#define RECIPROCAL_PI 0.3183099\nstruct MaterialUniforms {\n roughnessMetalness: vec2f,\n albedo: vec3f,\n alpha: f32,\n normal: vec3f,\n emit: vec3f,\n ao: f32,\n specularColor: vec3f,\n glossiness: f32,\n skinColor: vec4f\n};\nvar<private> materialUniforms: MaterialUniforms;\nstruct SceneUniforms {\n alphaTest: f32,\n emissiveFactor: vec3f,\n baseColorFactor: vec4f,\n baseColorIntensity: f32,\n emitColorFactor: f32,\n occlusionFactor: f32,\n roughnessFactor: f32,\n metallicFactor: f32,\n normalMapFactor: f32,\n specularF0: f32,\n emitMultiplicative: f32,\n normalMapFlipY: f32,\n outputSRGB: f32,\n contrast: f32,\n hsv: vec3f,\n specularAAVariance: f32,\n specularAAThreshold: f32,\n #if HAS_SSR\n invProjMatrix: mat4x4f,\n outputFovInfo: array<vec4f, 2>,\n reprojViewProjMatrix: mat4x4f,\n #endif\n #ifndef HAS_COLOR\n #ifdef IS_LINE_EXTRUSION\n lineColor: vec4f,\n #else\n polygonFill: vec4f\n #endif\n #endif\n};\nstruct ShaderUniforms {\n #if HAS_IBL_LIGHTING\n hdrHSV: vec3f,\n diffuseSPH: vec3f,\n prefilterMiplevel: vec2f,\n prefilterSize: vec2f,\n #else\n ambientColor: vec3f,\n #endif\n cameraPosition: vec3f,\n cameraNearFar: vec2f,\n environmentExposure: f32,\n environmentTransform: mat3x3f,\n light0_viewDirection: vec3f,\n light0_diffuse: vec4f,\n #if HAS_LAYER_OPACITY\n layerOpacity: f32,\n #endif\n #if HAS_SSR\n outSize: vec2f,\n ssrFactor: f32,\n ssrQuality: f32,\n projMatrix: mat4x4f,\n #endif\n}\n@group(0) @binding($b) var<uniform> uniforms: SceneUniforms;\n@group(0) @binding($b) var<uniform> shaderUniforms: ShaderUniforms;\n#if HAS_ALBEDO_MAP\n @group(0) @binding($b) var baseColorTexture: texture_2d<f32>;\n @group(0) @binding($b) var baseColorTextureSampler: sampler;\n#endif\n#if HAS_METALLICROUGHNESS_MAP\n @group(0) @binding($b) var metallicRoughnessTexture: texture_2d<f32>;\n @group(0) @binding($b) var metallicRoughnessTextureSampler: sampler;\n#endif\n#if HAS_EMISSIVE_MAP\n @group(0) @binding($b) var emissiveTexture: texture_2d<f32>;\n @group(0) @binding($b) var emissiveTextureSampler: sampler;\n#endif\n#if HAS_AO_MAP\n @group(0) @binding($b) var occlusionTexture: texture_2d<f32>;\n @group(0) @binding($b) var occlusionTextureSampler: sampler;\n#endif\n#if HAS_NORMAL_MAP && HAS_TANGENT\n @group(0) @binding($b) var normalTexture: texture_2d<f32>;\n @group(0) @binding($b) var normalTextureSampler: sampler;\n#endif\n#if HAS_SKIN_MAP\n @group(0) @binding($b) var skinTexture: texture_2d<f32>;\n @group(0) @binding($b) var skinTextureSampler: sampler;\n#endif\n#if HAS_RANDOM_TEX\n @group(0) @binding($b) var noiseTexture: texture_2d<f32>;\n @group(0) @binding($b) var noiseTextureSampler: sampler;\n#endif\n@group(0) @binding($b) var brdfLUT: texture_2d<f32>;\n@group(0) @binding($b) var brdfLUTSampler: sampler;\n#if HAS_IBL_LIGHTING\n @group(0) @binding($b) var prefilterMap: texture_cube<f32>;\n @group(0) @binding($b) var prefilterSampler: sampler;\n#endif\n#if HAS_SSR\n @group(0) @binding($b) var TextureDepth: texture_2d<f32>;\n @group(0) @binding($b) var TextureDepthSampler: sampler;\n @group(0) @binding($b) var TextureReflected: texture_2d<f32>;\n @group(0) @binding($b) var TextureReflectedSampler: sampler;\n#endif\n#if HAS_BUMP_MAP && HAS_TANGENT\n @group(0) @binding($b) var bumpTexture: texture_2d<f32>;\n @group(0) @binding($b) var bumpSampler: sampler;\n#endif\n#if HAS_PATTERN\n @group(0) @binding($b) var linePatternFile: texture_2d<f32>;\n @group(0) @binding($b) var linePatternFileSampler: sampler;\n#endif\nstruct VertexOutput {\n #ifdef HAS_SSR\n @location($i) vViewNormal: vec3f,\n #ifdef HAS_TANGENT\n @location($i) vViewTangent: vec4f,\n #endif\n #endif\n @location($i) vModelNormal: vec3f,\n @location($i) vViewVertex: vec4f,\n #if HAS_TANGENT\n @location($i) vModelTangent: vec4f,\n @location($i) vModelBiTangent: vec3f,\n #endif\n @location($i) vModelVertex: vec3f,\n #if HAS_MAP\n @location($i) vTexCoord: vec2f,\n #ifdef HAS_AO_MAP\n @location($i) vTexCoord1: vec2f,\n #endif\n #ifdef HAS_I3S_UVREGION\n @location($i) vUvRegion: vec4f,\n #endif\n #endif\n #if HAS_COLOR\n @location($i) vColor: vec4f,\n #endif\n @location($i) vOpacity: f32,\n #if HAS_COLOR0\n @location($i) vColor0: vec4f,\n #endif\n #if HAS_BUMP_MAP && HAS_TANGENT\n @location($i) vTangentViewPos: vec3f,\n @location($i) vTangentFragPos: vec3f,\n #endif\n};\nfn getMaterialAlbedo() -> vec3f {\n return materialUniforms.albedo;\n}\nfn getMaterialAlpha() -> f32 {\n return materialUniforms.alpha;\n}\nfn getMaterialMetalness() -> f32 {\n return materialUniforms.roughnessMetalness.y;\n}\nfn getMaterialRoughness() -> f32 {\n #if SHADING_MODEL_SPECULAR_GLOSSINESS\n return 1.0 - materialUniforms.glossiness;\n #else\n return materialUniforms.roughnessMetalness.x;\n #endif\n}\nfn getMaterialEmitColor() -> vec3f {\n return materialUniforms.emit;\n}\nfn getMaterialSkinColor() -> vec4f {\n return materialUniforms.skinColor;\n}\nfn getMaterialNormalMap() -> vec3f {\n return materialUniforms.normal;\n}\nfn getMaterialOcclusion() -> f32 {\n return materialUniforms.ao;\n}\nfn decodeDepth(pack: vec4f) -> f32 {\n return pack.r + pack.g / 255.0;\n}\nfn transformNormal(factor: f32, normalToTransform: vec3f, t: vec3f, b: vec3f, n: vec3f) -> vec3f {\n let normal = vec3f(normalToTransform.xy * factor, normalToTransform.z);\n let tbn = mat3x3f(t, b, n);\n return normalize(tbn * normal);\n}\nfn D_GGX(roughness: f32, normal: vec3f, H: vec3f) -> f32 {\n let NoH = clamp(dot(normal, H), 0.0, 1.0);\n let a = roughness * roughness;\n let a2 = a * a;\n let d = (NoH * a2 - NoH) * NoH + 1.0;\n return a2 / ( PI * d * d);\n}\nfn F_Schlick(f0: vec3f, f90: f32, L: vec3f, H: vec3f) -> vec3f {\n var VoH = clamp(dot(L, H), 0.0, 1.0);\n VoH = pow(1.0 - VoH, 5.0);\n return f90 * VoH + (1.0 - VoH) * f0;\n}\nfn V_SmithGGXCorrelated(normal: vec3f, V: vec3f, roughness: f32, NoL: f32) -> f32 {\n let NoV = clamp(dot(normal, V), 0.0, 1.0);\n let a = roughness * roughness;\n let GGXL = NoV * (NoL * (1.0 - a) + a);\n let GGXV = NoL * (NoV * (1.0 - a) + a);\n return 0.5 / (GGXV + GGXL);\n}\nfn computeSpecularBRDF(roughness: f32, normal: vec3f, V: vec3f, L: vec3f, specular: vec3f, NoL: f32, f90: f32) -> vec3f {\n let H = normalize(V + L);\n let D = D_GGX(roughness, normal, H);\n let V_S = V_SmithGGXCorrelated(normal, V, roughness, NoL);\n let F = F_Schlick(specular, f90, L, H);\n return (D * V_S * PI) * F;\n}\nfn BRDF_Lambert(diffuseColor: vec3f) -> vec3f {\n return RECIPROCAL_PI * diffuseColor;\n}\nstruct LambertLight {\n diffuse: vec3f,\n specular: vec3f\n}\nfn computeLambert(\n normal: vec3f,\n V: vec3f,\n NoL: f32,\n roughness: f32,\n materialDiffuse: vec3f,\n specular: vec3f,\n lightColor: vec3f,\n L: vec3f,\n f90: f32\n) -> LambertLight {\n var lambert: LambertLight;\n if (NoL <= 0.0) {\n lambert.diffuse = vec3f(0.0);\n lambert.specular = vec3f(0.0);\n return lambert;\n }\n let a = NoL * lightColor;\n let brdf = computeSpecularBRDF(roughness, normal, V, L, specular, NoL, f90);\n lambert.specular = a * brdf;\n lambert.diffuse = a * BRDF_Lambert(materialDiffuse);\n return lambert;\n}\n#if HAS_IBL_LIGHTING\n fn computeDiffuseSPH(normal: vec3f) -> vec3f {\n let n = uniforms.environmentTransform * normal;\n let diffuseSPH = shaderUniforms.diffuseSPH;\n let x = n.x;\n let y = n.y;\n let z = n.z;\n let result = (\n diffuseSPH[0] +\n diffuseSPH[1] * x +\n diffuseSPH[2] * y +\n diffuseSPH[3] * z +\n diffuseSPH[4] * z * x +\n diffuseSPH[5] * y * z +\n diffuseSPH[6] * y * x +\n diffuseSPH[7] * (3.0 * z * z - 1.0) +\n diffuseSPH[8] * (x*x - y*y)\n );\n if (length(shaderUniforms.hdrHSV) > 0.0) {\n return hsv_apply3(result, shaderUniforms.hdrHSV);\n }\n return max(result, vec3f(0.0));\n }\n fn fetchEnvMap(roughness: f32, R: vec3f) -> vec3f {\n let dir = R;\n let maxLevels = shaderUniforms.prefilterMiplevel.x;\n let lod = min(maxLevels, roughness * shaderUniforms.prefilterMiplevel.y);\n var envLight = textureSampleLevel(prefilterMap, prefilterSampler, dir, lod).rgb;\n if (length(shaderUniforms.hdrHSV) > 0.0) {\n envLight = hsv_apply3(envLight, shaderUniforms.hdrHSV);\n }\n return envLight;\n }\n fn getIBLEnvMap(N: vec3f, V: vec3f, roughness: f32, frontNormal: vec3f, materialDiffuse: vec3f) -> vec3f {\n let smoothness = 1.0 - roughness;\n let R = mix(N, reflect(-V, N), smoothness * (sqrt(smoothness) + roughness));\n let factor = clamp(1.0 + dot(R, frontNormal), 0.0, 1.0);\n let prefilteredEnvColor = fetchEnvMap(roughness, uniforms.environmentTransform * R) * factor * factor;\n return prefilteredEnvColor;\n }\n#else\n fn getIBLEnvMap(normal: vec3f, eyeVector: vec3f, roughness: f32, frontNormal: vec3f, materialDiffuse: vec3f) -> vec3f {\n return shaderUniforms.ambientColor * BRDF_Lambert(materialDiffuse);\n }\n#endif\nfn computeBRDF(spec: vec3f, roughness: f32, NoV: f32, f90: f32) -> vec3f {\n let rgba = textureSample(brdfLUT, brdfLUTSampler, vec2f(NoV, roughness)) * vec4f(255.0, 65280.0, 255.0, 65280.0);\n let b = (rgba[3] + rgba[2]);\n let a = (rgba[1] + rgba[0]);\n return (spec * a + b * f90) / 65535.0;\n}\nfn computeIBLSpecular(\n normal: vec3f,\n eyeVector: vec3f,\n NoV: f32,\n roughness: f32,\n specular: vec3f,\n frontNormal: vec3f,\n f90: f32,\n materialDiffuse: vec3f\n) -> vec3f {\n return getIBLEnvMap(normal, eyeVector, roughness, frontNormal, materialDiffuse) * computeBRDF(specular, roughness, NoV, f90);\n}\nfn computeSpecularAO(ao: f32, NoV: f32) -> f32 {\n let d = NoV + ao;\n return clamp((d * d) - 1.0 + ao, 0.0, 1.0);\n}\nfn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {\n var materialUniforms: MaterialUniforms;\n#ifdef HAS_MAP\n var uv = computeTexCoord(vertexOutput.vTexCoord, vertexOutput);\n#endif\n#ifdef HAS_UV_FLIP\n uv.y = 1.0 - uv.y;\n#endif\n#if HAS_BUMP_MAP && HAS_TANGENT\n uv = bumpUV(uv, normalize(vertexOutput.vTangentViewPos - vertexOutput.vTangentFragPos));\n#endif\n materialUniforms.albedo = uniforms.baseColorIntensity * uniforms.baseColorFactor.rgb;\n materialUniforms.alpha = uniforms.baseColorFactor.a * vertexOutput.vOpacity;\n#if HAS_PATTERN\n var linesofar = vertexOutput.vLinesofar;\n let uvSize = vertexOutput.vTexInfo.zw;\n#ifdef HAS_PATTERN_GAP\n let myGap = vertexOutput.vLinePatternGap;\n#else\n let myGap = uniforms.linePatternGap;\n#endif\n#ifdef HAS_PATTERN_ANIM\n let myAnimSpeed = vertexOutput.vLinePatternAnimSpeed;\n#else\n let myAnimSpeed = uniforms.linePatternAnimSpeed;\n#endif\n let patternWidth = ceil(uvSize.x * vertexOutput.vPatternHeight / uvSize.y);\n let plusGapWidth = patternWidth * (1.0 + myGap);\n let animSpeed = myAnimSpeed / uniforms.animSpeedScale;\n linesofar += (uniforms.currentTime * -animSpeed * 0.2) % plusGapWidth;\n let patternx = (linesofar / plusGapWidth) % 1.0;\n let patterny = (uniforms.flipY * vertexOutput.vNormalY) % 1.0;\n uv = computeUV(vec2(patternx * (1.0 + myGap) * uniforms.uvScale[0], patterny * uniforms.uvScale[1]));\n let patternColor = textureSample(linePatternFile, linePatternFileSampler, uv);\n let inGap = clamp(sign(1.0 / (1.0 + myGap) - patternx) + 0.000001, 0.0, 1.0);\n let patternColor = mix(uniforms.linePatternGapColor, patternColor, inGap);\n#ifdef IS_SQUARE_TUBE\n let v = clamp(sign(abs(vertexOutput.vNormalY) - 0.999999), 0.0, 1.0);\n let patternColor = mix(patternColor, vec4(1.0), v);\n#endif\n materialUniforms.albedo *= patternColor.rgb;\n materialUniforms.alpha *= patternColor.a;\n#endif\n#if HAS_ALBEDO_MAP\n let baseColor = textureSample(baseColorTexture, baseColorTextureSampler, uv);\n materialUniforms.albedo *= sRGBToLinear(baseColor.rgb);\n materialUniforms.alpha *= baseColor.a;\n#endif\n#if HAS_SKIN_MAP\n let skinColorValue = textureSample(skinTexture, skinTextureSampler, uv);\n materialUniforms.skinColor = skinColorValue;\n#endif\n#if HAS_COLOR0\n materialUniforms.albedo *= vertexOutput.vColor0.rgb;\n#if COLOR0_SIZE == 4\n materialUniforms.alpha *= vertexOutput.vColor0.a;\n#endif\n#endif\n#if HAS_COLOR\n materialUniforms.albedo *= vertexOutput.vColor.rgb;\n materialUniforms.alpha *= vertexOutput.vColor.a;\n#elif IS_LINE_EXTRUSION\n materialUniforms.albedo *= uniforms.lineColor.rgb;\n materialUniforms.alpha *= uniforms.lineColor.a;\n#else\n materialUniforms.albedo *= uniforms.polygonFill.rgb;\n materialUniforms.alpha *= uniforms.polygonFill.a;\n#endif\n#if HAS_INSTANCE_COLOR\n materialUniforms.albedo *= vertexOutput.vInstanceColor.rgb;\n materialUniforms.alpha *= vertexOutput.vInstanceColor.a;\n#endif\n#if HAS_METALLICROUGHNESS_MAP\n let mrSample = textureSample(metallicRoughnessTexture, metallicRoughnessTextureSampler, uv).gb;\n materialUniforms.roughnessMetalness = mrSample * vec2(uniforms.roughnessFactor, uniforms.metallicFactor);\n#else\n materialUniforms.roughnessMetalness = vec2(uniforms.roughnessFactor, uniforms.metallicFactor);\n#endif\n materialUniforms.emit = uniforms.emissiveFactor;\n#if HAS_EMISSIVE_MAP\n if (uniforms.emitMultiplicative == 1.0) {\n materialUniforms.emit *= sRGBToLinear(textureSample(emissiveTexture, emissiveTextureSampler, uv).rgb);\n } else {\n materialUniforms.emit += sRGBToLinear(textureSample(emissiveTexture, emissiveTextureSampler, uv).rgb);\n }\n#endif\n materialUniforms.emit *= uniforms.emitColorFactor;\n#if HAS_AO_MAP\n let aoTexCoord = computeTexCoord(vertexOutput.vTexCoord1, vertexOutput);\n materialUniforms.ao = textureSample(occlusionTexture, occlusionTextureSampler, aoTexCoord).r;\n#else\n materialUniforms.ao = 1.0;\n#endif\n materialUniforms.ao *= uniforms.occlusionFactor;\n#if HAS_NORMAL_MAP && HAS_TANGENT\n var nmap = textureSample(normalTexture, normalTextureSampler, uv).xyz * 2.0 - 1.0;\n nmap.y = select(nmap.y, -namp.y, uniforms.normalMapFlipY == 1.0);\n materialUniforms.normal = nmap;\n#else\n materialUniforms.normal = normalize(vertexOutput.vModelNormal);\n#endif\n#if HAS_TERRAIN_NORMAL && HAS_TANGENT\n var nmap = convertTerrainHeightToNormalMap(uv);\n nmap.y = select(nmap.y, -namp.y, uniforms.normalMapFlipY == 1.0);\n materialUniforms.normal = nmap;\n#endif\n#if SHADING_MODEL_SPECULAR_GLOSSINESS\n materialUniforms.albedo *= uniforms.diffuseFactor.rgb;\n materialUniforms.alpha *= uniforms.diffuseFactor.a;\n#if HAS_DIFFUSE_MAP\n let diffuse = textureSample(diffuseTexture, diffuseTextureSampler, uv);\n materialUniforms.albedo *= sRGBToLinear(diffuse.rgb);\n materialUniforms.alpha *= diffuse.a;\n#endif\n materialUniforms.specularColor = uniforms.specularFactor;\n materialUniforms.glossiness = uniforms.glossinessFactor;\n#if HAS_SPECULARGLOSSINESS_MAP\n let specularGlossiness = textureSample(specularGlossinessTexture, specularGlossinessTextureSampler, uv);\n materialUniforms.specularColor *= sRGBToLinear(specularGlossiness.rgb);\n materialUniforms.glossiness *= specularGlossiness.a;\n#endif\n#endif\n return materialUniforms;\n}\nfn HDR_ACES(x: vec3f) -> vec3f {\n const a = 2.51;\n const b = 0.03;\n const c = 2.43;\n const d = 0.59;\n const e = 0.14;\n return (x * (a * x + b)) / (x * (c * x + d) + e);\n}\nfn tonemap(color: vec3f) -> vec3f {\n let tonemapped = HDR_ACES(color);\n return pow(tonemapped, vec3f(1.0/2.2));\n}\nfn normalFiltering(roughness: f32, worldNormal: vec3f) -> f32 {\n let du = dpdx(worldNormal);\n let dv = dpdy(worldNormal);\n let variance = uniforms.specularAAVariance * (dot(du, du) + dot(dv, dv));\n let kernelRoughness = min(2.0 * variance, uniforms.specularAAThreshold);\n let squareRoughness = saturate(roughness * roughness + kernelRoughness);\n return sqrt(squareRoughness);\n}\n#if HAS_SSR\n fn ssrViewToScreen(projection: mat4x4f, viewVertex: vec3f) -> vec3f {\n let projected = projection * vec4f(viewVertex, 1.0);\n return vec3f(0.5 + 0.5 * projected.xy / projected.w, projected.w);\n }\n fn fetchColorLod(level: f32, uv: vec2f) -> vec3f {\n return textureSampleLevel(TextureReflected, TextureReflectedSampler, uv, level).rgb;\n }\n fn linearizeDepth(depth: f32) -> f32 {\n let projection = uniforms.projMatrix;\n let z = depth * 2.0 - 1.0; return -projection[3].z / (z + projection[2].z);\n }\n fn fetchDepth(uv: vec2f) -> f32 {\n let depth = decodeDepth(textureSample(TextureDepth, TextureDepthSampler, uv));\n return depth;\n }\n fn interleavedGradientNoise(fragCoord: vec2f, frameMod: f32) -> f32 {\n let magic = vec3f(0.06711056, 0.00583715, 52.9829189);\n return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2f(47.0, 17.0) * 0.695, magic.xy))) * 0.5;\n }\n fn importanceSampling(\n frameMod: f32,\n tangentX: vec3f,\n tangentY: vec3f,\n tangentZ: vec3f,\n eyeVector: vec3f,\n rough4: f32\n ) -> vec3f {\n var E: vec2f;\n E.x = interleavedGradientNoise(fragCoord.yx, frameMod);\n E.y = fract(E.x * 52.9829189);\n E.y = mix(E.y, 1.0, 0.7);\n let phi = 2.0 * 3.14159 * E.x;\n let cosTheta = pow(max(E.y, 0.000001), rough4 / (2.0 - rough4));\n let sinTheta = sqrt(1.0 - cosTheta * cosTheta);\n var h = vec3f(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);\n h = h.x * tangentX + h.y * tangentY + h.z * tangentZ;\n return normalize((2.0 * dot(eyeVector, h)) * h - eyeVector);\n }\n fn getStepOffset(frameMod: f32) -> f32 {\n return (interleavedGradientNoise(fragCoord.xy, frameMod) - 0.5);\n }\n fn computeRayDirUV(rayOriginUV: vec3f, rayLen: f32, rayDirView: vec3f) -> vec3f {\n let rayDirUV = ssrViewToScreen(uniforms.projMatrix, vViewVertex.xyz + rayDirView * rayLen);\n rayDirUV.z = 1.0 / rayDirUV.z;\n rayDirUV -= rayOriginUV;\n let scaleMaxX = min(1.0, 0.99 * (1.0 - rayOriginUV.x) / max(1e-5, rayDirUV.x));\n let scaleMaxY = min(1.0, 0.99 * (1.0 - rayOriginUV.y) / max(1e-5, rayDirUV.y));\n let scaleMinX = min(1.0, 0.99 * rayOriginUV.x / max(1e-5, -rayDirUV.x));\n let scaleMinY = min(1.0, 0.99 * rayOriginUV.y / max(1e-5, -rayDirUV.y));\n return rayDirUV * min(scaleMaxX, scaleMaxY) * min(scaleMinX, scaleMinY);\n }\n fn binarySearch(rayOriginUV: vec3f, rayDirUV: vec3f, startSteps: ptr<function, f32>, endSteps: ptr<function, f32>) -> f32 {\n let steps = (*startSteps + *endSteps) * 0.5;\n let sampleUV = rayOriginUV + rayDirUV * steps;\n let z = fetchDepth(sampleUV.xy);\n let depth = linearizeDepth(z);\n let sampleDepth = -1.0 / sampleUV.z;\n *startSteps = select(steps, *startSteps, depth > sampleDepth);\n *endSteps = select(*endSteps, steps, depth > sampleDepth);\n return steps;\n }\n fn rayTrace(\n rayOriginUV: vec3f,\n rayLen: f32,\n depthTolerance: f32,\n rayDirView: vec3f,\n roughness: f32,\n frameMod: f32\n ) -> vec4f {\n let checkSteps = 20;\n let invNumSteps = 1.0 / f32(checkSteps);\n depthTolerance *= invNumSteps;\n let rayDirUV = computeRayDirUV(rayOriginUV, rayLen, rayDirView);\n let sampleTime = invNumSteps;\n var diffSampleW = vec3f(0.0, sampleTime, 1.0);\n var sampleUV: vec3f;\n var hit = false;\n var hitDepth = 1.0;\n var steps: f32;\n for (var i = 0; i < checkSteps; i++) {\n sampleUV = rayOriginUV + rayDirUV * diffSampleW.y;\n let z = fetchDepth(sampleUV.xy);\n let depth = linearizeDepth(z);\n let sampleDepth = -1.0 / sampleUV.z;\n let validDepth = clamp(sign(0.999 - z), 0.0, 1.0);\n var depthDiff = validDepth * (sampleDepth - depth);\n depthDiff *= clamp(sign(abs(depthDiff) - rayLen * invNumSteps * invNumSteps), 0.0, 1.0);\n hit = abs(depthDiff + depthTolerance) < depthTolerance;\n let timeLerp = clamp(diffSampleW.x / (diffSampleW.x - depthDiff), 0.0, 1.0);\n let hitTime = select(1.0, (diffSampleW.y + timeLerp * invNumSteps - invNumSteps), hit);\n diffSampleW.z = min(diffSampleW.z, hitTime);\n diffSampleW.x = depthDiff;\n if (hit) {\n var startSteps = diffSampleW.y - invNumSteps;\n var endSteps = diffSampleW.y;\n steps = binarySearch(rayOriginUV, rayDirUV, &startSteps, &endSteps);\n steps = binarySearch(rayOriginUV, rayDirUV, &startSteps, &endSteps);\n steps = binarySearch(rayOriginUV, rayDirUV, &startSteps, &endSteps);\n hitDepth = steps;\n break;\n }\n diffSampleW.y += invNumSteps;\n }\n return vec4f(rayOriginUV + rayDirUV * hitDepth, 1.0 - hitDepth);\n }\n fn fetchColorInRay(\n resRay: vec4f,\n maskSsr: f32,\n specularEnvironment: vec3f,\n specularColor: vec3f,\n roughness: f32\n ) -> vec4f {\n let AB = mix(uniforms.outputFovInfo[0], uniforms.outputFovInfo[1], resRay.x);\n resRay.xyz = vec3f(mix(AB.xy, AB.zw, resRay.y), 1.0) * -1.0 / resRay.z;\n resRay.xyz = (uniforms.reprojViewProjMatrix * vec4f(resRay.xyz, 1.0)).xyw;\n resRay.xy /= resRay.z;\n let maskEdge = clamp(6.0 - 6.0 * max(abs(resRay.x), abs(resRay.y)), 0.0, 1.0);\n resRay.xy = 0.5 + 0.5 * resRay.xy;\n let fetchColor = specularColor * fetchColorLod(roughness * (1.0 - resRay.w), resRay.xy);\n return vec4f(mix(specularEnvironment, fetchColor, maskSsr * maskEdge), 1.0);\n }\n fn ssr(\n specularEnvironment: vec3f,\n specularColor: vec3f,\n roughness: f32,\n normal: vec3f,\n eyeVector: vec3f\n ) -> vec3f {\n let taaSS = 0.0;\n var result = vec4f(0.0);\n var rough4 = roughness * roughness;\n rough4 = rough4 * rough4;\n let upVector = select(vec3f(1.0, 0.0, 0.0), vec3f(0.0, 0.0, 1.0), abs(normal.z) < 0.999);\n let tangentX = normalize(cross(upVector, normal));\n let tangentY = cross(normal, tangentX);\n var maskSsr = shaderUniforms.ssrFactor * clamp(-4.0 * dot(eyeVector, normal) + 3.8, 0.0, 1.0);\n maskSsr *= clamp(4.7 - roughness * 5.0, 0.0, 1.0);\n let rayOriginUV = ssrViewToScreen(shaderUniforms.projMatrix, vViewVertex.xyz);\n rayOriginUV.z = 1.0 / rayOriginUV.z;\n let rayDirView = importanceSampling(taaSS, tangentX, tangentY, normal, eyeVector, rough4);\n let rayLen = mix(shaderUniforms.cameraNearFar.y + vViewVertex.z, -vViewVertex.z - shaderUniforms.cameraNearFar.x, rayDirView.z * 0.5 + 0.5);\n let depthTolerance = 0.5 * rayLen;\n var resRay: vec4f;\n if (dot(rayDirView, normal) > 0.001 && maskSsr > 0.0) {\n resRay = rayTrace(rayOriginUV, rayLen, depthTolerance, rayDirView, roughness, taaSS);\n if (resRay.w > 0.0) {\n result += fetchColorInRay(resRay, maskSsr, specularEnvironment, specularColor, roughness);\n }\n }\n return select(specularEnvironment, result.rgb / result.w, result.w > 0.0);\n }\n#endif\nfn sRGBTransferOETF(value: vec4f) -> vec4f {\n let isLow: vec3<bool> = value.rgb <= vec3f(0.0031308);\n let highPart: vec3f = pow(value.rgb, vec3f(0.41666)) * 1.055 - vec3f(0.055);\n let lowPart: vec3f = value.rgb * 12.92;\n let rgb: vec3f = select(highPart, lowPart, isLow);\n return vec4f(rgb, value.a);\n}\nfn linearToOutputTexel(value: vec4f) -> vec4f {\n return sRGBTransferOETF(value);\n}\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n materialUniforms = initMaterial(vertexOutput);\n var glFragColor: vec4f;\n let eyeVector = normalize(shaderUniforms.cameraPosition - vertexOutput.vModelVertex);\n #if HAS_DOUBLE_SIDE\n let frontNormal = select(-normalize(vertexOutput.vModelNormal), normalize(vertexOutput.vModelNormal), gl_FrontFacing);\n #else\n let frontNormal = normalize(vertexOutput.vModelNormal);\n #endif\n let f0 = 0.08 * uniforms.specularF0;\n let metal = getMaterialMetalness();\n var materialDiffuse = getMaterialAlbedo();\n #if SHADING_MODEL_SPECULAR_GLOSSINESS\n let materialSpecular = materialUniforms.specularColor;\n #else\n let materialSpecular = mix(vec3f(f0), materialDiffuse, metal);\n #endif\n materialDiffuse *= 1.0 - metal;\n let materialF90 = clamp(50.0 * materialSpecular.g, 0.0, 1.0);\n var materialRoughness = getMaterialRoughness();\n if (uniforms.specularAAVariance > 0.0) {\n materialRoughness = normalFiltering(materialRoughness, frontNormal);\n }\n let materialEmit = getMaterialEmitColor();\n var materialNormal = getMaterialNormalMap();\n #if HAS_TANGENT\n #if HAS_NORMAL_MAP || HAS_TERRAIN_NORMAL\n materialNormal = transformNormal(uniforms.normalMapFactor, materialNormal, vertexOutput.vModelTangent.xyz, vertexOutput.vModelBiTangent, frontNormal);\n #endif\n #endif\n var diffuse = vec3f(0.0);\n var specular = vec3f(0.0);\n #if HAS_IBL_LIGHTING\n diffuse = materialDiffuse * computeDiffuseSPH(materialNormal) * 0.5;\n #else\n diffuse = materialDiffuse * shaderUniforms.ambientColor;\n #endif\n let NoV = dot(materialNormal, eyeVector);\n specular = computeIBLSpecular(materialNormal, eyeVector, NoV, materialRoughness, materialSpecular, frontNormal, materialF90, materialDiffuse);\n var specularAO = 1.0;\n let materialAO = getMaterialOcclusion();\n diffuse *= shaderUniforms.environmentExposure * materialAO;\n #if HAS_IBL_LIGHTING\n specularAO = computeSpecularAO(materialAO, NoV);\n #endif\n #if HAS_SSR\n var ssrfrontNormal = normalize(select(-vertexOutput.vViewNormal, vertexOutput.vViewNormal, gl_FrontFacing));\n var viewNormal = ssrfrontNormal;\n #if HAS_TANGENT\n #if HAS_NORMAL_MAP || HAS_TERRAIN_NORMAL\n var ssrTangent = select(-vertexOutput.vViewTangent, vertexOutput.vViewTangent, gl_FrontFacing);\n ssrTangent.xyz = normalize(ssrTangent.xyz);\n let ssrBinormal = normalize(cross(ssrfrontNormal, ssrTangent.xyz)) * ssrTangent.w;\n viewNormal = transformNormal(uniforms.normalMapFactor, materialNormal, ssrTangent.xyz, ssrBinormal, ssrfrontNormal);\n #endif\n #endif\n specular = ssr(specular, materialSpecular * specularAO, materialRoughness, viewNormal, -normalize(vertexOutput.vViewVertex.xyz));\n #endif\n specular *= shaderUniforms.environmentExposure * specularAO;\n let modelNormal = vertexOutput.vModelNormal;\n let lightDir = -shaderUniforms.light0_viewDirection;\n let dotNL = saturate(dot(lightDir, materialNormal));\n let lambertResult = computeLambert(materialNormal, eyeVector, dotNL, max(0.045, materialRoughness), materialDiffuse, materialSpecular, shaderUniforms.light0_diffuse.rgb, lightDir, materialF90);\n var ambientDiffuse = lambertResult.diffuse;\n var ambientSpecular = lambertResult.specular;\n #if HAS_SHADOWING && !HAS_BLOOM\n let shadowCoeff = shadow_computeShadow();\n ambientDiffuse = shadow_blend(ambientDiffuse, shadowCoeff).rgb;\n ambientSpecular = shadow_blend(ambientSpecular, shadowCoeff).rgb;\n #endif\n diffuse += ambientDiffuse;\n specular += ambientSpecular;\n diffuse += materialEmit;\n var frag = specular + diffuse;\n if (uniforms.outputSRGB == 1.0) {\n frag = linearTosRGB(frag);\n }\n #if HAS_SKIN_MAP\n let skinColor = getMaterialSkinColor();\n frag.rgb = frag.rgb * (1.0 - skinColor.a) + skinColor.rgb * skinColor.a;\n #if HAS_SHADOWING && !HAS_BLOOM\n frag.rgb = shadow_blend(frag.rgb, shadowCoeff).rgb;\n #endif\n #endif\n var alpha = getMaterialAlpha();\n if (alpha < uniforms.alphaTest) {\n discard;\n }\n #if ALPHA_MODE\n #if ALPHA_MODE == 1\n if (alpha < uniforms.alphaCutoff) {\n discard;\n } else {\n alpha = 1.0;\n }\n #else\n alpha = 1.0;\n #endif\n #endif\n glFragColor = vec4f(frag * alpha, alpha);\n #ifdef HAS_VERTEX_COLOR\n glFragColor *= vertexColor_get(vertexOutput);\n #endif\n #ifdef HAS_EXCAVATE_ANALYSIS\n glFragColor = excavateColor(glFragColor);\n #endif\n #ifdef HAS_SNOW\n glFragColor.rgb = snow(glFragColor, getMaterialNormalMap(), 1.0);\n #endif\n if (uniforms.contrast != 1.0) {\n glFragColor = contrastMatrix(uniforms.contrast) * glFragColor;\n }\n if (length(uniforms.hsv) > 0.0) {\n glFragColor = hsv_apply4(glFragColor, uniforms.hsv);\n }\n #ifdef OUTPUT_NORMAL\n glFragColor = vec4f(frontNormal, 1.0);\n #endif\n #if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n glFragColor = highlight_blendColor(glFragColor, vertexOutput);\n #endif\n #ifdef HAS_LAYER_OPACITY\n glFragColor *= shaderUniforms.layerOpacity;\n #endif\n #ifdef HAS_MASK_EXTENT\n glFragColor = setMask(glFragColor);\n #endif\n return glFragColor;\n}",
28654
28682
  uniforms: h,
28655
28683
  extraCommandProps: t,
28656
28684
  defines: r
@@ -28680,15 +28708,15 @@
28680
28708
  }
28681
28709
  },
28682
28710
  PBRUtils: Us
28683
- }, va = ce;
28711
+ }, va = le;
28684
28712
 
28685
- va.flatten = Le;
28713
+ va.flatten = He;
28686
28714
 
28687
28715
  var xa = Object.freeze({
28688
28716
  __proto__: null,
28689
- AbstractTexture: oe,
28717
+ AbstractTexture: ie,
28690
28718
  BloomPass: so,
28691
- BoundingBox: le,
28719
+ BoundingBox: ae,
28692
28720
  BoxBlurShader: class extends Ki {
28693
28721
  constructor({blurOffset: e}) {
28694
28722
  super({
@@ -28712,7 +28740,7 @@
28712
28740
  return this.commands[n] || (this.commands[n] = this.createMeshCommand(e, t)), this.commands[n];
28713
28741
  }
28714
28742
  },
28715
- Constants: ne,
28743
+ Constants: te,
28716
28744
  CopyShader: go,
28717
28745
  EdgeGeometry: Ct,
28718
28746
  EdgeShader: class extends Wi {
@@ -29096,7 +29124,7 @@
29096
29124
  this.resourceMap[e])));
29097
29125
  }
29098
29126
  },
29099
- Geometry: Xe,
29127
+ Geometry: qe,
29100
29128
  GraphicsDevice: ga,
29101
29129
  GraphicsFramebuffer: gi,
29102
29130
  GraphicsTexture: mi,
@@ -29125,7 +29153,7 @@
29125
29153
  if (e && e.indexOf("precision") < 0) return "precision mediump float;\n" + e;
29126
29154
  return e;
29127
29155
  }(u.content);
29128
- const f = X(h.content) + "-" + X(u.content);
29156
+ const f = q(h.content) + "-" + q(u.content);
29129
29157
  this._khrShaders[f] || (this._khrShaders[f] = this._createTechniqueShader(f, i, s, this._commandProps, r));
29130
29158
  const {attributeSemantics: d} = this._khrShaders[f], m = this._createGeometry(e, d, n, f), g = E({}, a);
29131
29159
  for (const e in a) if (l.uniforms[e] && 35678 === l.uniforms[e].type) {
@@ -29157,7 +29185,7 @@
29157
29185
  buffer: n
29158
29186
  }, i[e].quantization && (s[r].quantization = i[e].quantization), r === t.POSITION && (s[r].array = i[e].array);
29159
29187
  }
29160
- const a = new Xe(s, e.indices.array ? e.indices.array : e.indices, 0, {
29188
+ const a = new qe(s, e.indices.array ? e.indices.array : e.indices, 0, {
29161
29189
  positionAttribute: t.POSITION,
29162
29190
  normalAttribute: t.NORMAL,
29163
29191
  uv0Attribute: t.TEXCOORD_0,
@@ -29183,7 +29211,7 @@
29183
29211
  t.height = n.height;
29184
29212
  const r = e.sampler || e.texture.sampler;
29185
29213
  return r && (r.magFilter && (t.mag = ht(r.magFilter)), r.minFilter && (t.min = ft(r.minFilter)),
29186
- r.wrapS && (t.wrapS = mt(r.wrapS)), r.wrapT && (t.wrapT = mt(r.wrapT))), new Gr(t, this._resLoader);
29214
+ r.wrapS && (t.wrapS = mt(r.wrapS)), r.wrapT && (t.wrapT = mt(r.wrapT))), new Vr(t, this._resLoader);
29187
29215
  }
29188
29216
  _createTechniqueShader(e, t, n, r, i) {
29189
29217
  const {techniques: o, programs: s, shaders: a} = t, l = o[n], c = s[l.program], h = a[c.vertexShader].content, u = a[c.fragmentShader].content, f = {};
@@ -29262,8 +29290,8 @@
29262
29290
  t;
29263
29291
  }
29264
29292
  },
29265
- PhongSpecularGlossinessMaterial: Ft,
29266
- Plane: Vr,
29293
+ PhongSpecularGlossinessMaterial: Dt,
29294
+ Plane: Gr,
29267
29295
  PointLineShader: class extends Wi {
29268
29296
  constructor(e = {}) {
29269
29297
  const t = [];
@@ -29341,8 +29369,8 @@
29341
29369
  }), this.version = 300;
29342
29370
  }
29343
29371
  },
29344
- Texture2D: Gr,
29345
- Util: J,
29372
+ Texture2D: Vr,
29373
+ Util: Z,
29346
29374
  WGSLParseDefines: Mi,
29347
29375
  WaterShader: class extends Wi {
29348
29376
  constructor(e = {}) {
@@ -29670,9 +29698,9 @@
29670
29698
  return Pa[e.slice(0, 3)];
29671
29699
  };
29672
29700
 
29673
- var Na = ya.exports, Da = {
29701
+ var Na = ya.exports, Fa = {
29674
29702
  exports: {}
29675
- }, Fa = {
29703
+ }, Da = {
29676
29704
  "aliceblue": [ 240, 248, 255 ],
29677
29705
  "antiquewhite": [ 250, 235, 215 ],
29678
29706
  "aqua": [ 0, 255, 255 ],
@@ -29823,9 +29851,9 @@
29823
29851
  "yellowgreen": [ 154, 205, 50 ]
29824
29852
  }, Ua = {};
29825
29853
 
29826
- for (var Ba in Fa) Fa.hasOwnProperty(Ba) && (Ua[Fa[Ba]] = Ba);
29854
+ for (var Ba in Da) Da.hasOwnProperty(Ba) && (Ua[Da[Ba]] = Ba);
29827
29855
 
29828
- var za = Da.exports = {
29856
+ var za = Fa.exports = {
29829
29857
  rgb: {
29830
29858
  channels: 3,
29831
29859
  labels: "rgb"
@@ -29888,14 +29916,14 @@
29888
29916
  }
29889
29917
  };
29890
29918
 
29891
- for (var Ga in za) if (za.hasOwnProperty(Ga)) {
29892
- if (!("channels" in za[Ga])) throw new Error("missing channels property: " + Ga);
29893
- if (!("labels" in za[Ga])) throw new Error("missing channel labels property: " + Ga);
29894
- if (za[Ga].labels.length !== za[Ga].channels) throw new Error("channel and label counts mismatch: " + Ga);
29895
- var Va = za[Ga].channels, ja = za[Ga].labels;
29896
- delete za[Ga].channels, delete za[Ga].labels, Object.defineProperty(za[Ga], "channels", {
29897
- value: Va
29898
- }), Object.defineProperty(za[Ga], "labels", {
29919
+ for (var Va in za) if (za.hasOwnProperty(Va)) {
29920
+ if (!("channels" in za[Va])) throw new Error("missing channels property: " + Va);
29921
+ if (!("labels" in za[Va])) throw new Error("missing channel labels property: " + Va);
29922
+ if (za[Va].labels.length !== za[Va].channels) throw new Error("channel and label counts mismatch: " + Va);
29923
+ var Ga = za[Va].channels, ja = za[Va].labels;
29924
+ delete za[Va].channels, delete za[Va].labels, Object.defineProperty(za[Va], "channels", {
29925
+ value: Ga
29926
+ }), Object.defineProperty(za[Va], "labels", {
29899
29927
  value: ja
29900
29928
  });
29901
29929
  }
@@ -29920,13 +29948,13 @@
29920
29948
  var t = Ua[e];
29921
29949
  if (t) return t;
29922
29950
  var n, r, i, o = 1 / 0;
29923
- for (var s in Fa) if (Fa.hasOwnProperty(s)) {
29924
- var a = Fa[s], l = (r = e, i = a, Math.pow(r[0] - i[0], 2) + Math.pow(r[1] - i[1], 2) + Math.pow(r[2] - i[2], 2));
29951
+ for (var s in Da) if (Da.hasOwnProperty(s)) {
29952
+ var a = Da[s], l = (r = e, i = a, Math.pow(r[0] - i[0], 2) + Math.pow(r[1] - i[1], 2) + Math.pow(r[2] - i[2], 2));
29925
29953
  l < o && (o = l, n = s);
29926
29954
  }
29927
29955
  return n;
29928
29956
  }, za.keyword.rgb = function(e) {
29929
- return Fa[e];
29957
+ return Da[e];
29930
29958
  }, za.rgb.xyz = function(e) {
29931
29959
  var t = e[0] / 255, n = e[1] / 255, r = e[2] / 255;
29932
29960
  return [ 100 * (.4124 * (t = t > .04045 ? Math.pow((t + .055) / 1.055, 2.4) : t / 12.92) + .3576 * (n = n > .04045 ? Math.pow((n + .055) / 1.055, 2.4) : n / 12.92) + .1805 * (r = r > .04045 ? Math.pow((r + .055) / 1.055, 2.4) : r / 12.92)), 100 * (.2126 * t + .7152 * n + .0722 * r), 100 * (.0193 * t + .1192 * n + .9505 * r) ];
@@ -30132,7 +30160,7 @@
30132
30160
  return [ (e[0] + e[1] + e[2]) / 3 / 255 * 100 ];
30133
30161
  };
30134
30162
 
30135
- var Wa = Da.exports, qa = Wa;
30163
+ var Wa = Fa.exports, qa = Wa;
30136
30164
 
30137
30165
  function Xa(e) {
30138
30166
  var t = function() {
@@ -30604,7 +30632,7 @@
30604
30632
  return !1;
30605
30633
  }
30606
30634
  _createGround() {
30607
- const e = new Vr;
30635
+ const e = new Gr;
30608
30636
  e.generateBuffers(this.renderer.device), this._ground = new gr(e), this._groundScene = new Cr([ this._ground ]);
30609
30637
  }
30610
30638
  _transformGround() {
@@ -30620,7 +30648,7 @@
30620
30648
  return r ? o.y : o.x;
30621
30649
  }
30622
30650
 
30623
- const {getIBLResOnCanvas: Ll, logoutIBLResOnCanvas: Nl, getPBRUniforms: Dl, loginIBLResOnCanvas: Fl} = _a.PBRUtils, Ul = [ 0, 0 ], Bl = [ 1, 1 ], zl = [], Gl = [], Vl = [], jl = [], Wl = [];
30651
+ const {getIBLResOnCanvas: Ll, logoutIBLResOnCanvas: Nl, getPBRUniforms: Fl, loginIBLResOnCanvas: Dl} = _a.PBRUtils, Ul = [ 0, 0 ], Bl = [ 1, 1 ], zl = [], Vl = [], Gl = [], jl = [], Wl = [];
30624
30652
 
30625
30653
  class ql {
30626
30654
  static getGroundTransform(e, t) {
@@ -30631,7 +30659,7 @@
30631
30659
  this._bindOnMaterialComplete = (...e) => this._onMaterialComplete.call(this, ...e),
30632
30660
  this._init();
30633
30661
  const n = this.getMap().getRenderer().canvas;
30634
- Fl(n, e, this.getMap());
30662
+ Dl(n, e, this.getMap());
30635
30663
  }
30636
30664
  needToRedraw() {
30637
30665
  const e = this._getUVOffsetAnim();
@@ -30716,7 +30744,7 @@
30716
30744
  let t;
30717
30745
  if ("lit" === this._layer.getGroundConfig().renderPlugin.type) {
30718
30746
  const n = this.getMap().getRenderer().canvas, {iblTexes: r, dfgLUT: i} = Ll(n);
30719
- t = Dl(this.getMap(), r, i, e && e.ssr, e && e.jitter);
30747
+ t = Fl(this.getMap(), r, i, e && e.ssr, e && e.jitter);
30720
30748
  } else {
30721
30749
  t = {
30722
30750
  projViewMatrix: this.getMap().projViewMatrix
@@ -30742,10 +30770,10 @@
30742
30770
  }
30743
30771
  }), this._fillShader = new Wi({
30744
30772
  name: "ground-fill",
30745
- vert: "attribute vec3 aPosition;\nuniform mat4 projViewModelMatrix;\nuniform mat4 modelMatrix;\n#ifdef HAS_PATTERN\nattribute vec2 aTexCoord;\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\nvarying vec2 vTexCoord;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\nvoid main() {\n \n#ifdef HAS_PATTERN\nvTexCoord = aTexCoord * uvScale + uvOffset;\n#endif\nvec3 c = vec3(aPosition);\n gl_Position = projViewModelMatrix * vec4(c, 1.);\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(vec4(c, 1.));\n#endif\n}",
30746
- frag: "precision mediump float;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#ifdef HAS_PATTERN\nuniform sampler2D polygonPatternFile;\nvarying vec2 vTexCoord;\n#endif\nuniform vec4 polygonFill;\nuniform float polygonOpacity;\nvoid main() {\n \n#ifdef HAS_PATTERN\nvec4 c = texture2D(polygonPatternFile, vTexCoord);\n#else\nvec4 c = polygonFill;\n#endif\ngl_FragColor = c * polygonOpacity;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat d = shadow_computeShadow();\n gl_FragColor.rgb = shadow_blend(gl_FragColor.rgb, d);\n#endif\n}",
30747
- wgslFrag: null,
30748
- wgslVert: null,
30773
+ vert: "#define SHADER_NAME BACK_FILL\nattribute vec3 aPosition;\nuniform mat4 projViewModelMatrix;\nuniform mat4 modelMatrix;\n#ifdef HAS_PATTERN\nattribute vec2 aTexCoord;\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\nvarying vec2 vTexCoord;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\nvoid main() {\n \n#ifdef HAS_PATTERN\nvTexCoord = aTexCoord * uvScale + uvOffset;\n#endif\nvec3 c = vec3(aPosition);\n gl_Position = projViewModelMatrix * vec4(c, 1.);\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(vec4(c, 1.));\n#endif\n}",
30774
+ frag: "#define SHADER_NAME BACK_FILL\nprecision mediump float;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#ifdef HAS_PATTERN\nuniform sampler2D polygonPatternFile;\nvarying vec2 vTexCoord;\n#endif\nuniform vec4 polygonFill;\nuniform float polygonOpacity;\nvoid main() {\n \n#ifdef HAS_PATTERN\nvec4 c = texture2D(polygonPatternFile, vTexCoord);\n#else\nvec4 c = polygonFill;\n#endif\ngl_FragColor = c * polygonOpacity;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat d = shadow_computeShadow();\n gl_FragColor.rgb = shadow_blend(gl_FragColor.rgb, d);\n#endif\n}",
30775
+ wgslVert: "#include <vsm_shadow_vert>\nstruct VertexInput {\n @location($i) aPosition: vec3f,\n#ifdef HAS_PATTERN\n @location($i) aTexCoord: vec2f,\n#endif\n};\nstruct VertexOutput {\n @builtin(position) Position: vec4f,\n#ifdef HAS_PATTERN\n @location($o) vTexCoord: vec2f,\n#endif\n};\nstruct BackFillUniforms {\n projViewModelMatrix: mat4x4f,\n modelMatrix: mat4x4f,\n#ifdef HAS_PATTERN\n uvScale: vec2f,\n uvOffset: vec2f,\n#endif\n};\n@group(0) @binding($b) var<uniform> uniforms: BackFillUniforms;\n@vertex\nfn main(vertexInput: VertexInput) -> VertexOutput {\n var vertexOutput: VertexOutput;\n#ifdef HAS_PATTERN\n vertexOutput.vTexCoord = vertexInput.aTexCoord * uniforms.uvScale + uniforms.uvOffset;\n#endif\n let position = vec3f(vertexInput.aPosition);\n vertexOutput.Position = uniforms.projViewModelMatrix * vec4f(position, 1.0);\n#if HAS_SHADOWING && !HAS_BLOOM\n shadow_computeShadowPars(uniforms.modelMatrix * vec4f(position, 1.0));\n#endif\n return vertexOutput;\n}",
30776
+ wgslFrag: "#if HAS_SHADOWING && !HAS_BLOOM\n #include <vsm_shadow_frag>\n#endif\nstruct VertexOutput {\n @builtin(position) Position: vec4f,\n#ifdef HAS_PATTERN\n @location($i) vTexCoord: vec2f,\n#endif\n};\nstruct BackFillUniforms {\n polygonFill: vec4f,\n polygonOpacity: f32,\n};\n@group(0) @binding($b) var<uniform> uniforms: BackFillUniforms;\n#ifdef HAS_PATTERN\n@group(0) @binding($b) var polygonPatternFile: texture_2d<f32>;\n@group(0) @binding($b) var polygonPatternFileSampler: sampler;\n#endif\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n#ifdef HAS_PATTERN\n let color = textureSample(polygonPatternFile, polygonPatternFileSampler, vertexOutput.vTexCoord);\n#else\n let color = uniforms.polygonFill;\n#endif\n var fragColor: vec4f = color * uniforms.polygonOpacity;\n#if HAS_SHADOWING && !HAS_BLOOM\n let shadowCoeff = shadow_computeShadow();\n fragColor = vec4(shadow_blend(fragColor.rgb, shadowCoeff), fragColor.a);\n#endif\n return fragColor;\n}",
30749
30777
  uniforms: t,
30750
30778
  extraCommandProps: e,
30751
30779
  defines: {}
@@ -30802,8 +30830,8 @@
30802
30830
  return !!(e && e.getAmbientResource());
30803
30831
  }
30804
30832
  _createGround() {
30805
- const e = new Vr;
30806
- e.data.aTexCoord = new Uint8Array([ 0, 0, 1, 0, 0, 1, 1, 1 ]), e.createTangent(),
30833
+ const e = new Gr;
30834
+ e.data.aTexCoord = new Float32Array([ 0, 0, 1, 0, 0, 1, 1, 1 ]), e.createTangent(),
30807
30835
  e.generateBuffers(this.renderer.device), this._ground = new gr(e, null, {
30808
30836
  castShadow: !1
30809
30837
  });
@@ -30834,8 +30862,8 @@
30834
30862
  return Rl[0] = p / a[0], Rl[1] = _ / a[1], Rl[2] = v, Rl[3] = x, Rl[4] = m, Rl;
30835
30863
  }(e, a, l, u, p, _, c, g, f, m, v), w = 2 * r.getWidth() / x, A = 2 * r.getHeight() / b;
30836
30864
  if (!this.material) return this._ground.setUniform("uvScale", set$1(zl, w, A)),
30837
- void this._ground.setUniform("uvOffset", set$1(Gl, y % 1 + T[0], S % 1 + T[1]));
30838
- this._ground.setUniform("uvScale", set$1(Wl, w, A)), this._ground.setUniform("uvOffset", set$1(Vl, y % 1 + T[0], S % 1 + T[1])),
30865
+ void this._ground.setUniform("uvOffset", set$1(Vl, y % 1 + T[0], S % 1 + T[1]));
30866
+ this._ground.setUniform("uvScale", set$1(Wl, w, A)), this._ground.setUniform("uvOffset", set$1(Gl, y % 1 + T[0], S % 1 + T[1])),
30839
30867
  this._ground.setUniform("uvOrigin", set$1(jl, y - y % 1, S - S % 1)), this._ground.setUniform("uvRotation", 0);
30840
30868
  }
30841
30869
  _getGroundDefines(e) {
@@ -30862,7 +30890,7 @@
30862
30890
  url: i,
30863
30891
  wrap: "repeat"
30864
30892
  } : i, i.flipY = !0, i.min = "linear mipmap linear", i.mag = "linear", i.flipY = !0,
30865
- t[r] = new Gr(i, this._loader), n = !0;
30893
+ t[r] = new Vr(i, this._loader), n = !0;
30866
30894
  } else t[r] = e[r];
30867
30895
  this.material ? (this._loadingMaterial = new _a.StandardMaterial(t), this._loadingMaterial.isReady() ? this._onMaterialComplete() : this._loadingMaterial.once("complete", this._bindOnMaterialComplete)) : (this.material = new _a.StandardMaterial(t),
30868
30896
  this.material.once("complete", this._bindOnMaterialComplete, this)), n || this._onMaterialComplete();
@@ -30872,7 +30900,7 @@
30872
30900
  delete this._loadingMaterial), this.setToRedraw();
30873
30901
  }
30874
30902
  _createPatternTexture(e) {
30875
- e = Y(e);
30903
+ e = K(e);
30876
30904
  const t = this._regl, n = {
30877
30905
  width: e.width,
30878
30906
  height: e.height,
@@ -31039,7 +31067,7 @@
31039
31067
  }
31040
31068
  const h = {};
31041
31069
  h.POSITION = s, h.NORMAL = a, h.TEXCOORD_0 = l;
31042
- const u = new Xe(h, c, 0, {
31070
+ const u = new qe(h, c, 0, {
31043
31071
  primitive: "triangles",
31044
31072
  positionAttribute: "POSITION",
31045
31073
  normalAttribute: "NORMAL",
@@ -31221,7 +31249,7 @@
31221
31249
  this._fixZoom = e.getZoom();
31222
31250
  const t = 16e3 * Math.pow(2, 16.685648411389433 - this._fixZoom), n = [ -t, 0, -t, t, 0, -t, -t, 0, t, t, 0, t ], r = {};
31223
31251
  r.POSITION = n, r.NORMAL = [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ], r.TEXCOORD_0 = [ 0, 0, 1, 0, 0, 1, 1, 1 ];
31224
- const i = new Xe(r, [ 3, 1, 0, 0, 2, 3 ], 0, {
31252
+ const i = new qe(r, [ 3, 1, 0, 0, 2, 3 ], 0, {
31225
31253
  positionAttribute: "POSITION",
31226
31254
  normalAttribute: "NORMAL",
31227
31255
  uv0Attribute: "TEXCOORD_0"
@@ -31471,8 +31499,9 @@
31471
31499
  fxaa(e, t, n, r, i, o, s, a, l, c, h, u) {
31472
31500
  !e || e.width === t.fbo && e.height === t.height || e.resize(t.width, t.height);
31473
31501
  const f = {};
31474
- a ? f.HAS_OUTLINE_TEX = 1 : delete f.HAS_OUTLINE_TEX, this._fxaaShader.setDefines(f),
31475
- this._renderer.render(this._fxaaShader, {
31502
+ a ? f.HAS_OUTLINE_TEX = 1 : delete f.HAS_OUTLINE_TEX;
31503
+ !0 === this._layer.options.antialias ? f.HAS_MULTISAMPLED = 1 : delete f.HAS_MULTISAMPLED,
31504
+ this._fxaaShader.setDefines(f), this._renderer.render(this._fxaaShader, {
31476
31505
  textureSource: t,
31477
31506
  resolution: set$1(bc, t.width, t.height),
31478
31507
  enableFXAA: n,
@@ -31788,9 +31817,9 @@
31788
31817
  this.device = this.regl;
31789
31818
  }
31790
31819
  };
31791
- }, {LayerAbstractRenderer: Lc} = e__namespace.renderer, Nc = [ 0, 0, 0, 0 ], Dc = [ 1, 1, -1 ], Fc = [ 0, 0 ], Uc = e => !e.bloom && !e.ssr, Bc = e => !e.bloom, zc = e => !e.ssr;
31820
+ }, {LayerAbstractRenderer: Lc} = e__namespace.renderer, Nc = [ 0, 0, 0, 0 ], Fc = [ 1, 1, -1 ], Dc = [ 0, 0 ], Uc = e => !e.bloom && !e.ssr, Bc = e => !e.bloom, zc = e => !e.ssr;
31792
31821
 
31793
- class Gc extends(Hc(Lc)){
31822
+ class Vc extends(Hc(Lc)){
31794
31823
  setToRedraw() {
31795
31824
  this.setRetireFrames(), super.setToRedraw();
31796
31825
  }
@@ -31811,7 +31840,7 @@
31811
31840
  this._postProcess());
31812
31841
  }
31813
31842
  prepareCanvas() {
31814
- super.prepareCanvas(), this.forEachRenderer((e => {
31843
+ super.prepareCanvas(), this.resizeCanvas(), this.forEachRenderer((e => {
31815
31844
  e.prepareCanvas();
31816
31845
  }));
31817
31846
  }
@@ -31824,14 +31853,14 @@
31824
31853
  const n = this.hasRenderTarget(), r = this._getDrawContext(t);
31825
31854
  if (n && (this._drawContext.renderTarget = this._getFramebufferTarget()), this._envPainter.paint(r),
31826
31855
  this.drawGround(!0), !n) return void this._renderInMode("default", null, e, t, !0);
31827
- const i = this.reglGL, o = this.layer._getSceneConfig(), s = o && o.postProcess, a = this.isSSROn();
31828
- r.jitter = Fc;
31829
- const l = this.layer.getGroundConfig();
31830
- r.hasSSRGround = !!(a && l && l.enable && l.symbol && l.symbol.ssr), i.resetDrawCalls(),
31831
- this._renderInMode("default", this._targetFBO, e, t, !0), a && this._postProcessor.drawSSR(this._blitDepthTex(), this._targetFBO);
31832
- s.bloom && s.bloom.enable && (this._bloomPainted = this._postProcessor.drawBloom(this._depthTex)),
31833
- 2 === a && this._postProcessor.drawSSR(this._blitDepthTex(), this._targetFBO, !0),
31834
- i.resetDrawCalls(), this._weatherPainter.renderScene(r), this._pointDrawCount = i.getDrawCalls();
31856
+ const i = this.layer._getSceneConfig(), o = i && i.postProcess, s = this.isSSROn();
31857
+ r.jitter = Dc;
31858
+ const a = this.layer.getGroundConfig();
31859
+ r.hasSSRGround = !!(s && a && a.enable && a.symbol && a.symbol.ssr), this._renderInMode("default", this._targetFBO, e, t, !0),
31860
+ s && this._postProcessor.drawSSR(this._blitDepthTex(), this._targetFBO);
31861
+ o.bloom && o.bloom.enable && (this._bloomPainted = this._postProcessor.drawBloom(this._depthTex)),
31862
+ 2 === s && this._postProcessor.drawSSR(this._blitDepthTex(), this._targetFBO, !0),
31863
+ this._weatherPainter.renderScene(r);
31835
31864
  }
31836
31865
  _renderInMode(e, t, n, r, i) {
31837
31866
  this._renderMode = e;
@@ -31843,10 +31872,10 @@
31843
31872
  }
31844
31873
  _getDrawContext(e) {
31845
31874
  let t = e[0];
31846
- return Vc(t) || (t = e[1]), t !== this._contextFrameTime && (this.forEachRenderer(((e, t) => {
31875
+ return Gc(t) || (t = e[1]), t !== this._contextFrameTime && (this.forEachRenderer(((e, t) => {
31847
31876
  t.isVisible() && e.needRetireFrames && e.needRetireFrames() && this.setRetireFrames();
31848
31877
  })), this._drawContext = this._prepareDrawContext(t), this._contextFrameTime = t,
31849
- this._frameEvent = Vc(e[0]) ? null : e[0]), this._drawContext;
31878
+ this._frameEvent = Gc(e[0]) ? null : e[0]), this._drawContext;
31850
31879
  }
31851
31880
  _renderOutlines() {
31852
31881
  if (!this.isEnableOutline()) return;
@@ -31859,16 +31888,16 @@
31859
31888
  const {width: e, height: t} = this.canvas;
31860
31889
  let n = this._outlineFBO;
31861
31890
  if (n) e === n.width && t === n.height || n.resize(e, t); else {
31862
- const r = this.regl.texture({
31891
+ const r = this.device && this.device.wgpu ? "rgba" : "rgba4", i = this.layer.options.antialias ? 4 : 1, o = this.regl.texture({
31863
31892
  width: e,
31864
31893
  height: t,
31865
- format: "rgba4",
31866
- sampleCount: 4
31894
+ format: r,
31895
+ sampleCount: i
31867
31896
  });
31868
31897
  n = this._outlineFBO = this.regl.framebuffer({
31869
31898
  width: e,
31870
31899
  height: t,
31871
- colors: [ r ],
31900
+ colors: [ o ],
31872
31901
  depth: !1,
31873
31902
  stencil: !1
31874
31903
  });
@@ -32011,7 +32040,7 @@
32011
32040
  super.clearContext(), this._clearFramebuffers();
32012
32041
  }
32013
32042
  _clearFramebuffers() {
32014
- const e = this.regl;
32043
+ const e = this.device;
32015
32044
  this._targetFBO && e.clear({
32016
32045
  color: Nc,
32017
32046
  depth: 1,
@@ -32097,7 +32126,7 @@
32097
32126
  if (!t || !t.enable) return !1;
32098
32127
  if (!this._groundPainter) return !1;
32099
32128
  const n = this.getFrameContext(), r = n.jitter;
32100
- n.jitter = Fc;
32129
+ n.jitter = Dc;
32101
32130
  const i = this.layer.getPolygonOffsetCount();
32102
32131
  let o;
32103
32132
  n.offsetFactor = i + 1, n.offsetUnits = i + 1, e && (o = n.sceneFilter, delete n.sceneFilter);
@@ -32159,7 +32188,7 @@
32159
32188
  };
32160
32189
  let t = !1;
32161
32190
  if (e.options.lights) {
32162
- const n = e.getLightManager().getDirectionalLight().direction || Dc;
32191
+ const n = e.getLightManager().getDirectionalLight().direction || Fc;
32163
32192
  this._renderedView.lightDirection = copy$5([], n), t = !0;
32164
32193
  }
32165
32194
  return {
@@ -32170,7 +32199,7 @@
32170
32199
  const t = e.getResolution() / this._renderedView.res, n = e.coordToContainerPoint(this._renderedView.center), r = this.layer.options.viewMoveThreshold, i = n._sub(e.width / 2, e.height / 2).mag() > r || t < .95 || t > 1.05;
32171
32200
  let o = !1;
32172
32201
  if (e.options.lights) {
32173
- const t = e.getLightManager().getDirectionalLight().direction || Dc;
32202
+ const t = e.getLightManager().getDirectionalLight().direction || Fc;
32174
32203
  o = !equals$4(this._renderedView.lightDirection, t), o && (this._renderedView.lightDirection = copy$5([], t));
32175
32204
  }
32176
32205
  return i && (this._renderedView.center = e.getCenter(), this._renderedView.bearing = e.getBearing(),
@@ -32246,7 +32275,7 @@
32246
32275
  n[e].needUpdateShadow = !1), n[e].hasFunctionUniform && (n[e].hasFunctionUniform("minAltitude") || n[e].setFunctionUniform("minAltitude", (() => t && t.options.altitude || 0)),
32247
32276
  r.push(n[e])));
32248
32277
  })), this._shadowScene || (this._shadowScene = new Cr), this._shadowScene.setMeshes(r);
32249
- const o = this.getMap(), s = n.shadow, a = o.getLightManager(), l = a && a.getDirectionalLight().direction || Dc, c = !n.ground || !n.ground.enable;
32278
+ const o = this.getMap(), s = n.shadow, a = o.getLightManager(), l = a && a.getDirectionalLight().direction || Fc, c = !n.ground || !n.ground.enable;
32250
32279
  return this._shadowProcess.render(c, o.projMatrix, o.viewMatrix, s.color, s.opacity, l, this._shadowScene, this._jitter, t, i);
32251
32280
  }
32252
32281
  _renderWeather(e) {
@@ -32283,7 +32312,7 @@
32283
32312
  _getFramebufferTarget() {
32284
32313
  const e = this.layer._getSceneConfig(), t = e && e.postProcess;
32285
32314
  if (!this._targetFBO) {
32286
- const e = this.regl;
32315
+ const e = this.device;
32287
32316
  let n = this._depthTex;
32288
32317
  (!n || !n._texture || n._texture.refCount <= 0) && (n = null);
32289
32318
  const r = this.createFBOInfo(t, n);
@@ -32296,28 +32325,28 @@
32296
32325
  }
32297
32326
  _createSimpleFBOInfo(e, t, n) {
32298
32327
  t = t || this.canvas.width, n = n || this.canvas.height;
32299
- const r = this.device, i = this._isUseMultiSample();
32300
- let o;
32301
- if (!e && i) o = r.renderbuffer({
32328
+ const r = this.device, i = this._isUseMultiSample(), o = this.layer.options.antialias;
32329
+ let s;
32330
+ if (!e && i) s = r.renderbuffer({
32302
32331
  width: t,
32303
32332
  height: n,
32304
32333
  samples: this.layer.options.multiSamples,
32305
32334
  format: "rgba8"
32306
32335
  }); else {
32307
- const e = "uint8";
32308
- o = r.texture({
32336
+ const e = o ? 4 : 1, i = "uint8";
32337
+ s = r.texture({
32309
32338
  min: "nearest",
32310
32339
  mag: "nearest",
32311
- type: e,
32340
+ type: i,
32312
32341
  width: t,
32313
32342
  height: n,
32314
- sampleCount: 4
32343
+ sampleCount: e
32315
32344
  });
32316
32345
  }
32317
32346
  return {
32318
32347
  width: t,
32319
32348
  height: n,
32320
- colors: [ o ],
32349
+ colors: [ s ],
32321
32350
  colorFormat: i ? "rgba8" : "rgba"
32322
32351
  };
32323
32352
  }
@@ -32334,16 +32363,17 @@
32334
32363
  });
32335
32364
  o.depthStencil = e;
32336
32365
  } else if (a) {
32337
- const e = t || i.texture({
32366
+ const e = this.layer.options.antialias ? 4 : 1, s = t || i.texture({
32338
32367
  min: "nearest",
32339
32368
  mag: "nearest",
32340
32369
  mipmap: !1,
32341
32370
  type: "depth stencil",
32342
32371
  width: n,
32343
32372
  height: r,
32344
- format: "depth stencil"
32373
+ format: "depth stencil",
32374
+ sampleCount: e
32345
32375
  });
32346
- o.depthStencil = e;
32376
+ o.depthStencil = s;
32347
32377
  } else {
32348
32378
  const e = t || i.renderbuffer({
32349
32379
  width: n,
@@ -32404,7 +32434,7 @@
32404
32434
  }
32405
32435
  }
32406
32436
 
32407
- function Vc(e) {
32437
+ function Gc(e) {
32408
32438
  return "number" == typeof e && !isNaN(e);
32409
32439
  }
32410
32440
 
@@ -32785,7 +32815,7 @@
32785
32815
  const {positions: o, texcoords: s, triangles: a, empty: l} = n;
32786
32816
  if (i && i.geometry !== this._emptyTerrainGeometry) i.geometry.updateData("aPosition", o),
32787
32817
  i.geometry.updateData("aTexCoord", s), i.geometry.setElements(a), i.geometry.generateBuffers(this.graphics); else {
32788
- const e = l ? this._emptyTerrainGeometry : new Xe({
32818
+ const e = l ? this._emptyTerrainGeometry : new qe({
32789
32819
  aPosition: o,
32790
32820
  aTexCoord: s
32791
32821
  }, a, 0);
@@ -32946,7 +32976,7 @@
32946
32976
  }
32947
32977
  _createEmptyTerrainGeo() {
32948
32978
  const e = sh, {positions: t, texcoords: n, triangles: r} = e;
32949
- this._emptyTerrainGeometry = new Xe({
32979
+ this._emptyTerrainGeometry = new qe({
32950
32980
  aPosition: t,
32951
32981
  aTexCoord: n
32952
32982
  }, r, 0), this._emptyTerrainGeometry.generateBuffers(this.graphics);
@@ -32987,31 +33017,32 @@
32987
33017
  ph(e, this.getMap());
32988
33018
  }
32989
33019
  createTerrainMesh(e, t) {
32990
- const {mesh: n, image: r} = t, {positions: i, texcoords: o, triangles: s, leftSkirtIndex: a, rightSkirtIndex: l, bottomSkirtIndex: c, numVerticesWithoutSkirts: h} = n, u = new Int8Array(i.length);
32991
- for (let e = 2; e < u.length; e += 3) e < 3 * h ? u[e] = 1 : e < a / 2 * 3 ? u[e - 2] = -1 : e < l / 2 * 3 ? u[e - 2] = 1 : u[e - 1] = e < c / 2 * 3 ? -1 : 1;
32992
- const f = new Xe({
33020
+ const {mesh: n, image: r} = t, {positions: i, texcoords: o, triangles: s, leftSkirtIndex: a, rightSkirtIndex: l, bottomSkirtIndex: c, numVerticesWithoutSkirts: h, tangents: u} = n, f = new Int8Array(i.length);
33021
+ for (let e = 2; e < f.length; e += 3) e < 3 * h ? f[e] = 1 : e < a / 2 * 3 ? f[e - 2] = -1 : e < l / 2 * 3 ? f[e - 2] = 1 : f[e - 1] = e < c / 2 * 3 ? -1 : 1;
33022
+ const d = new qe({
32993
33023
  aPosition: i,
32994
33024
  aTexCoord: o,
32995
- aNormal: u
33025
+ aNormal: f
32996
33026
  }, s, 0);
32997
- let d;
32998
- f.createTangent(), delete f.data.aNormal, f.generateBuffers(this.graphics), d = r ? this.graphics.texture({
33027
+ let m;
33028
+ d.createTangent("aTangent", u), delete d.data.aNormal, d.generateBuffers(this.graphics),
33029
+ m = r ? this.graphics.texture({
32999
33030
  width: r.width,
33000
33031
  height: r.height,
33001
33032
  data: r,
33002
33033
  min: "linear",
33003
33034
  mag: "linear"
33004
33035
  }) : this.getEmptyTexture();
33005
- const m = this.getEmptyTexture(), g = fl({}, _h, this.layer.options.material || {});
33006
- g.skinTexture = m, g.terrainHeightTexture = d;
33007
- const p = new _a.StandardMaterial(g), _ = new gr(f, p);
33008
- if (_.properties.matVer = this._matVer, !_.uniforms.flatMask) {
33036
+ const g = this.getEmptyTexture(), p = fl({}, _h, this.layer.options.material || {});
33037
+ p.skinTexture = g, p.terrainHeightTexture = m;
33038
+ const _ = new _a.StandardMaterial(p), v = new gr(d, _);
33039
+ if (v.properties.matVer = this._matVer, !v.uniforms.flatMask) {
33009
33040
  const e = this.getEmptyTexture();
33010
- _.setUniform("flatMask", e);
33041
+ v.setUniform("flatMask", e);
33011
33042
  }
33012
- const v = _.defines;
33013
- return v.HAS_UV_FLIP = 1, v.HAS_TERRAIN_NORMAL = 1, v.HAS_MAP = 1, v.HAS_LAYER_OPACITY = 1,
33014
- v.HAS_TERRAIN_FLAT_MASK = 1, _.defines = v, this.prepareMesh(_, e, t), _;
33043
+ const x = v.defines;
33044
+ return x.HAS_UV_FLIP = 1, x.HAS_TERRAIN_NORMAL = 1, x.HAS_MAP = 1, x.HAS_LAYER_OPACITY = 1,
33045
+ x.HAS_TERRAIN_FLAT_MASK = 1, v.defines = x, this.prepareMesh(v, e, t), v;
33015
33046
  }
33016
33047
  addTerrainImage(e, t) {
33017
33048
  const n = t.terrainMesh;
@@ -33910,7 +33941,7 @@
33910
33941
  }
33911
33942
  });
33912
33943
  const t = new Int16Array([ -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1 ]);
33913
- this._skinGeometry = this._skinGeometry || new Xe({
33944
+ this._skinGeometry = this._skinGeometry || new qe({
33914
33945
  aPosition: t
33915
33946
  }, 0, 6, {
33916
33947
  positionSize: 2
@@ -33949,7 +33980,7 @@
33949
33980
  return e + "-" + t;
33950
33981
  }
33951
33982
 
33952
- const Dh = {
33983
+ const Fh = {
33953
33984
  "clip-inside": .1,
33954
33985
  "clip-outside": .2,
33955
33986
  "flat-inside": .3,
@@ -33957,10 +33988,10 @@
33957
33988
  "color": .5,
33958
33989
  "texture": .6,
33959
33990
  "elevate": .7
33960
- }, Fh = [], Uh = [ 1, 1, 1 ], Bh = {
33991
+ }, Dh = [], Uh = [ 1, 1, 1 ], Bh = {
33961
33992
  polygonFill: [ 255, 0, 0 ],
33962
33993
  polygonOpacity: .8
33963
- }, zh = new e$2.Coordinate(0, 0), Gh = new e$2.Coordinate(0, 0), Vh = [], jh = new e$2.Coordinate(0, 0), Wh = new e$2.Point(0, 0), qh = new e$2.Point(0, 0), Xh = new e$2.Point(0, 0);
33994
+ }, zh = new e$2.Coordinate(0, 0), Vh = new e$2.Coordinate(0, 0), Gh = [], jh = new e$2.Coordinate(0, 0), Wh = new e$2.Point(0, 0), qh = new e$2.Point(0, 0), Xh = new e$2.Point(0, 0);
33964
33995
 
33965
33996
  class $h extends e$2.Polygon {
33966
33997
  getMode() {
@@ -33980,17 +34011,17 @@
33980
34011
  if (t && (delete t._maskProjViewMatrix, delete t._maskExtentInWorld), !this._mesh) return this;
33981
34012
  const n = this.getMode(), r = this.toGeoJSON();
33982
34013
  r.geometry.coordinates[0].reverse();
33983
- const i = ce.flatten(r.geometry.coordinates), {positions: o, uvs: s, triangles: a} = "texture" === n ? this._createBilinearPOSITON(i) : this._createPOSITION(i), l = this._mesh.geometry;
34014
+ const i = le.flatten(r.geometry.coordinates), {positions: o, uvs: s, triangles: a} = "texture" === n ? this._createBilinearPOSITON(i) : this._createPOSITION(i), l = this._mesh.geometry;
33984
34015
  if (l.updateData("POSITION", o), l.updateData("TEXCOORD", s), l.setElements(a),
33985
34016
  this._setLocalTransform(this._mesh), this._copyMesh) {
33986
- const e = this._createPOSITION(ce.flatten(r.geometry.coordinates), !0).positions;
34017
+ const e = this._createPOSITION(le.flatten(r.geometry.coordinates), !0).positions;
33987
34018
  this._copyMesh.geometry.updateData("POSITION", e), this._setLocalTransform(this._copyMesh);
33988
34019
  }
33989
34020
  }
33990
34021
  _createGeometry(e) {
33991
34022
  const t = this.getMode(), n = this.toGeoJSON();
33992
34023
  n.geometry.coordinates[0].reverse();
33993
- const r = ce.flatten(n.geometry.coordinates), {positions: i, uvs: o, triangles: s} = "texture" === t ? this._createBilinearPOSITON(r) : this._createPOSITION(r), a = this._createPOSITION(ce.flatten(n.geometry.coordinates), !0).positions, l = new Xe({
34024
+ const r = le.flatten(n.geometry.coordinates), {positions: i, uvs: o, triangles: s} = "texture" === t ? this._createBilinearPOSITON(r) : this._createPOSITION(r), a = this._createPOSITION(le.flatten(n.geometry.coordinates), !0).positions, l = new qe({
33994
34025
  POSITION: i,
33995
34026
  TEXCOORD: o
33996
34027
  }, s, 0, {
@@ -33998,7 +34029,7 @@
33998
34029
  uv0Attribute: "TEXCOORD"
33999
34030
  });
34000
34031
  l.generateBuffers(e);
34001
- const c = new Xe({
34032
+ const c = new qe({
34002
34033
  POSITION: a,
34003
34034
  TEXCOORD: o
34004
34035
  }, s, 0, {
@@ -34023,7 +34054,7 @@
34023
34054
  return {
34024
34055
  positions: o,
34025
34056
  uvs: this._createTexcoords(e.vertices, r),
34026
- triangles: ce(o, e.holes, 3)
34057
+ triangles: le(o, e.holes, 3)
34027
34058
  };
34028
34059
  }
34029
34060
  _createTexcoords(e, t) {
@@ -34075,7 +34106,7 @@
34075
34106
  this._dispose(), delete this._mesh, this.maskGeoJSON && (this.maskGeoJSON = null);
34076
34107
  }
34077
34108
  _getMaskMode() {
34078
- return Dh[this._mode];
34109
+ return Fh[this._mode];
34079
34110
  }
34080
34111
  _getMaskColor() {
34081
34112
  const e = this.getSymbol(), {polygonFill: t, polygonOpacity: n} = e || Bh, r = yl([], t);
@@ -34087,7 +34118,7 @@
34087
34118
  return t.altitudeToPoint(e, n);
34088
34119
  }
34089
34120
  _setLocalTransform(e) {
34090
- const t = Tl(this.getMap(), this.getCenter()), n = fromRotationTranslationScale(e.localTransform, identity$1(Fh), t, Uh);
34121
+ const t = Tl(this.getMap(), this.getCenter()), n = fromRotationTranslationScale(e.localTransform, identity$1(Dh), t, Uh);
34091
34122
  e.localTransform = n;
34092
34123
  }
34093
34124
  _dispose() {
@@ -34109,9 +34140,9 @@
34109
34140
  for (let n = 0; n < e.length; n++) {
34110
34141
  zh.x = e[n].x, zh.y = e[n].y;
34111
34142
  const i = n + 1 >= e.length ? 0 : n + 1;
34112
- Gh.x = e[i].x, Gh.y = e[i].y, jh.x = t[0], jh.y = t[1], Vh[0] = jh, Vh[1] = zh,
34113
- Vh[2] = Gh;
34114
- r += this._calArea(Vh);
34143
+ Vh.x = e[i].x, Vh.y = e[i].y, jh.x = t[0], jh.y = t[1], Gh[0] = jh, Gh[1] = zh,
34144
+ Gh[2] = Vh;
34145
+ r += this._calArea(Gh);
34115
34146
  }
34116
34147
  return !(Math.abs(r - n) > 1e-8);
34117
34148
  }
@@ -34558,17 +34589,20 @@
34558
34589
  return o;
34559
34590
  }
34560
34591
  _testMesh(e, t, n, r, i, o, s, a, l) {
34561
- const c = [];
34562
- for (let u = 0; u < o.length && !(u > e.properties.skirtOffset); u += 3) {
34563
- const e = o[u], f = o[u + 1], d = o[u + 2], m = set$5(Mu, r[e * s], r[e * s + 1], r[e * s + 2]), g = this._toWorldPosition(vu, n, m, i[e] / 100, a), p = set$5(Cu, r[f * s], r[f * s + 1], r[f * s + 2]), _ = this._toWorldPosition(xu, n, p, i[f] / 100, a), v = set$5(Ou, r[d * s], r[d * s + 1], r[d * s + 2]), x = this._toWorldPosition(bu, n, v, i[d] / 100, a), b = set$5(_u, g, _, x), y = sub$3(Tu, g, _), S = sub$3(wu, g, x), T = this._testIntersection(ku, b, t);
34564
- if (T) {
34565
- const t = n.pointAtResToAltitude(T[2], n.getGLRes());
34566
- yu.x = T[0], yu.y = T[1];
34567
- const r = n.pointAtResToCoordinate(yu, n.getGLRes());
34592
+ const c = [], u = n.getGLRes();
34593
+ for (let f = 0; f < o.length && !(f > e.properties.skirtOffset); f += 3) {
34594
+ const e = o[f], d = o[f + 1], m = o[f + 2], g = e * s, p = d * s, _ = m * s;
34595
+ Mu[0] = r[g], Mu[1] = r[g + 1], Mu[2] = r[g + 2], Cu[0] = r[p], Cu[1] = r[p + 1],
34596
+ Cu[2] = r[p + 2], Ou[0] = r[_], Ou[1] = r[_ + 1], Ou[2] = r[_ + 2];
34597
+ const v = this._toWorldPosition(vu, n, Mu, i[e] / 100, a), x = this._toWorldPosition(xu, n, Cu, i[d] / 100, a), b = this._toWorldPosition(bu, n, Ou, i[m] / 100, a), y = set$5(_u, v, x, b), S = sub$3(Tu, v, x), T = sub$3(wu, v, b), w = this._testIntersection(ku, y, t);
34598
+ if (w) {
34599
+ const t = n.pointAtResToAltitude(w[2], u);
34600
+ yu.x = w[0], yu.y = w[1];
34601
+ const r = n.pointAtResToCoordinate(yu, u);
34568
34602
  if (r.z = t, c.push({
34569
34603
  coordinate: r,
34570
- indices: [ e, f, d ],
34571
- normal: cross$3([], y, S)
34604
+ indices: [ e, d, m ],
34605
+ normal: cross$3([], S, T)
34572
34606
  }), 0 !== l && c.length >= l) break;
34573
34607
  }
34574
34608
  }
@@ -34597,7 +34631,7 @@
34597
34631
  return [ i.x, i.y, o ];
34598
34632
  }
34599
34633
 
34600
- const Hu = () => {}, Lu = new e__namespace.Coordinate(0, 0), Nu = [ 0, 0, 0 ], Du = [ 0, 0, 0 ], Fu = [ 0, 0, 0 ];
34634
+ const Hu = () => {}, Lu = new e__namespace.Coordinate(0, 0), Nu = [ 0, 0, 0 ], Fu = [ 0, 0, 0 ], Du = [ 0, 0, 0 ];
34601
34635
 
34602
34636
  class Uu extends e__namespace.Layer {
34603
34637
  static fromJSON(t) {
@@ -34850,8 +34884,8 @@
34850
34884
  }
34851
34885
  _queryRayCast(t, n) {
34852
34886
  const r = this.getMap(), i = r.getGLRes();
34853
- r.getContainerPointRay(Du, Fu, t);
34854
- const o = new Pu(Du, Fu, !1).test(n, r, {
34887
+ r.getContainerPointRay(Fu, Du, t);
34888
+ const o = new Pu(Fu, Du, !1).test(n, r, {
34855
34889
  count: 1
34856
34890
  }), s = [];
34857
34891
  o.forEach((e => {
@@ -34859,8 +34893,8 @@
34859
34893
  s.push(e.coordinate);
34860
34894
  }));
34861
34895
  }));
34862
- const a = r.pointAtResToCoordinate(new e__namespace.Point(Du[0], Du[1]), i, Lu);
34863
- this._meterToGLPoint || (this._meterToGLPoint = r.altitudeToPoint(1, i)), a.z = Du[2] / this._meterToGLPoint;
34896
+ const a = r.pointAtResToCoordinate(new e__namespace.Point(Fu[0], Fu[1]), i, Lu);
34897
+ this._meterToGLPoint || (this._meterToGLPoint = r.altitudeToPoint(1, i)), a.z = Fu[2] / this._meterToGLPoint;
34864
34898
  const l = set$5(Nu, a.x, a.y, a.z);
34865
34899
  return s.sort(((e, t) => dist$2(e.toArray(), l) - dist$2(t.toArray(), l))), s[0];
34866
34900
  }
@@ -34941,13 +34975,13 @@
34941
34975
  return 0 === n ? e.__group_gl_order - t.__group_gl_order : n;
34942
34976
  }
34943
34977
 
34944
- var Gu;
34978
+ var Vu;
34945
34979
 
34946
- let Vu;
34980
+ let Gu;
34947
34981
 
34948
34982
  function ju(e, t) {
34949
34983
  const {cubePixels: n, width: r, height: i} = e, o = n.map((e => e.buffer));
34950
- (Vu || (Vu = new e$2.worker.Actor("maplight")), Vu).send({
34984
+ (Gu || (Gu = new e$2.worker.Actor("maplight")), Gu).send({
34951
34985
  cubePixels: o,
34952
34986
  width: r,
34953
34987
  height: i
@@ -34970,10 +35004,10 @@
34970
35004
  geometryEvents: !0,
34971
35005
  multiSamples: 4,
34972
35006
  forceRedrawPerFrame: !1
34973
- }), Uu.registerJSONType("GroupGLLayer"), Uu.registerRenderer("gl", Gc), Uu.registerRenderer("gpu", Gc),
35007
+ }), Uu.registerJSONType("GroupGLLayer"), Uu.registerRenderer("gl", Vc), Uu.registerRenderer("gpu", Vc),
34974
35008
  Uu.registerRenderer("canvas", null), function(e) {
34975
35009
  e[e.AMBIENT = 0] = "AMBIENT", e[e.REALISTIC = 1] = "REALISTIC";
34976
- }(Gu || (Gu = {}));
35010
+ }(Vu || (Vu = {}));
34977
35011
 
34978
35012
  class Wu {
34979
35013
  constructor(e) {
@@ -35052,7 +35086,7 @@
35052
35086
  hdr: !0,
35053
35087
  flipY: !0
35054
35088
  };
35055
- this._loader.setURLModifier(l), this._hdr = new Gr(t, this._loader), this._hdr.once("complete", (() => {
35089
+ this._loader.setURLModifier(l), this._hdr = new Vr(t, this._loader), this._hdr.once("complete", (() => {
35056
35090
  this._onHDRLoaded();
35057
35091
  })), this._hdr.once("error", (() => {
35058
35092
  this._onHDRError();
@@ -35227,13 +35261,13 @@
35227
35261
 
35228
35262
  class tf extends e$2.renderer.MapAbstractRenderer {
35229
35263
  clearCanvas() {
35230
- this.regl && this.regl.clear({
35264
+ this.device && this.device.clear({
35231
35265
  color: [ 0, 0, 0, 0 ]
35232
35266
  });
35233
35267
  }
35234
35268
  clearLayerCanvasContext(e) {
35235
- if (!this.regl) return;
35236
- this.regl.clear({
35269
+ if (!this.device) return;
35270
+ this.device.clear({
35237
35271
  depth: 1,
35238
35272
  stencil: 0
35239
35273
  });
@@ -35295,28 +35329,11 @@
35295
35329
 
35296
35330
  e$2.Map.registerRenderer("gl", tf), "function" == typeof SuppressedError && SuppressedError;
35297
35331
 
35298
- class sf extends e$2.renderer.MapAbstractRenderer {
35332
+ class sf extends tf {
35299
35333
  drawLayers(e, t) {
35300
35334
  const n = super.drawLayers(e, t);
35301
35335
  return n && this.device.submit(), n;
35302
35336
  }
35303
- clearCanvas() {
35304
- this.device && this.device.clear({
35305
- color: [ 0, 0, 0, 0 ]
35306
- });
35307
- }
35308
- clearLayerCanvasContext(e) {
35309
- this.device && this.device.clear({
35310
- depth: 1,
35311
- stencil: 0
35312
- });
35313
- }
35314
- isWebGL() {
35315
- return !1;
35316
- }
35317
- isWebGPU() {
35318
- return !0;
35319
- }
35320
35337
  createContext() {
35321
35338
  return function() {
35322
35339
  return nf(this, void 0, void 0, (function*() {
@@ -35345,6 +35362,12 @@
35345
35362
  };
35346
35363
  }));
35347
35364
  }
35365
+ isWebGL() {
35366
+ return !1;
35367
+ }
35368
+ isWebGPU() {
35369
+ return !0;
35370
+ }
35348
35371
  }
35349
35372
 
35350
35373
  e$2.Map.registerRenderer("gpu", sf);
@@ -35442,7 +35465,7 @@
35442
35465
  const e = copy$6(x.localTransform, t.localTransform), n = copy$6(x.positionMatrix, t.positionMatrix);
35443
35466
  x.setLocalTransform(e), x.setPositionMatrix(n), t.properties.hlBloomMesh.geometry.setElements(g);
35444
35467
  } else {
35445
- const n = new Xe(_.data, g, 0, _.desc);
35468
+ const n = new qe(_.data, g, 0, _.desc);
35446
35469
  n.generateBuffers(e);
35447
35470
  const r = t.material;
35448
35471
  x = new gr(n, r, t.config);
@@ -35513,7 +35536,7 @@
35513
35536
  premultiplyAlpha: !0
35514
35537
  };
35515
35538
  let d = this.getTexture();
35516
- d ? d.setConfig(f) : d = new Gr(f), o = fl(o || {}, {
35539
+ d ? d.setConfig(f) : d = new Vr(f), o = fl(o || {}, {
35517
35540
  opacity: 1,
35518
35541
  debugLine: 0,
35519
35542
  alphaTest: 0,
@@ -35521,7 +35544,7 @@
35521
35544
  baseColorTexture: d
35522
35545
  });
35523
35546
  const m = new Pt(o), g = new gr(e, m);
35524
- g.properties.minFilter = Fr;
35547
+ g.properties.minFilter = Dr;
35525
35548
  const p = identity$2([]);
35526
35549
  return translate$1(p, p, [ h || 0, u || 0, 0 ]), scale$8(p, p, [ i * s, i * a, 1 ]),
35527
35550
  g.localTransform = p, g;
@@ -35531,14 +35554,14 @@
35531
35554
  const r = function(e) {
35532
35555
  const t = e.getZoom(), n = e.isMoving() && e.getRenderer().isViewChanged();
35533
35556
  let r;
35534
- r = n ? Br : e.getBearing() || e.getPitch() || !Number.isInteger(t) ? Ur : Fr;
35557
+ r = n ? Br : e.getBearing() || e.getPitch() || !Number.isInteger(t) ? Ur : Dr;
35535
35558
  return r;
35536
35559
  }(t);
35537
35560
  if (e.properties.minFilter !== r) {
35538
35561
  e.material.get("baseColorTexture").setMinFilter(r), e.properties.minFilter = r;
35539
35562
  }
35540
35563
  const i = t.getDevicePixelRatio(), o = t.getResolution() !== n;
35541
- let s = Fr;
35564
+ let s = Dr;
35542
35565
  if ((1 !== i || o) && (s = Ur), e.properties.magFilter !== s) {
35543
35566
  e.material.get("baseColorTexture").setMagFilter(s), e.properties.magFilter = s;
35544
35567
  }
@@ -35559,7 +35582,7 @@
35559
35582
  if (!this._tileGeometry) {
35560
35583
  this._shader = new Qi({
35561
35584
  extraCommandProps: this._getCommandProps()
35562
- }), this._tileGeometry = new Xe({
35585
+ }), this._tileGeometry = new qe({
35563
35586
  aPosition: yf,
35564
35587
  aTexCoord: Sf
35565
35588
  }, 4, 0, {
@@ -35630,7 +35653,7 @@
35630
35653
  height: o.height
35631
35654
  };
35632
35655
  let c = this.getTexture();
35633
- c ? c.setConfig(l) : c = new Gr(l);
35656
+ c ? c.setConfig(l) : c = new Vr(l);
35634
35657
  const {device: h, regl: u} = this.context;
35635
35658
  return c.getREGLTexture(h || u), c;
35636
35659
  }
@@ -35803,7 +35826,7 @@
35803
35826
  initContext() {
35804
35827
  this._shader = new Qi({
35805
35828
  extraCommandProps: this._getCommandProps()
35806
- }), this._imageGeometry = new Xe({
35829
+ }), this._imageGeometry = new qe({
35807
35830
  aPosition: kf,
35808
35831
  aTexCoord: Ef
35809
35832
  }, 4, 0, {
@@ -35906,7 +35929,7 @@
35906
35929
  this._createColorRamp(), this._createShader(), this._createHeatmapTex(), this._createGround();
35907
35930
  }
35908
35931
  _createGround() {
35909
- const e = new Vr;
35932
+ const e = new Gr;
35910
35933
  e.generateBuffers(this.renderer.device), this._ground = new gr(e), this._groundScene = new Cr([ this._ground ]);
35911
35934
  }
35912
35935
  _transformGround() {
@@ -36010,7 +36033,7 @@
36010
36033
  }
36011
36034
  }
36012
36035
 
36013
- class Df extends $h {
36036
+ class Ff extends $h {
36014
36037
  constructor(e, t) {
36015
36038
  super(e, t);
36016
36039
  }
@@ -36039,13 +36062,13 @@
36039
36062
  }
36040
36063
  }
36041
36064
 
36042
- let Ff = class extends Df {
36065
+ let Df = class extends Ff {
36043
36066
  constructor(e, t) {
36044
36067
  super(e, t), this._mode = "flat-inside";
36045
36068
  }
36046
36069
  };
36047
36070
 
36048
- class Uf extends Df {
36071
+ class Uf extends Ff {
36049
36072
  constructor(e, t) {
36050
36073
  super(e, t), this._mode = "flat-outside";
36051
36074
  }
@@ -36146,7 +36169,7 @@
36146
36169
  }
36147
36170
  }
36148
36171
 
36149
- class Gf extends $h {
36172
+ class Vf extends $h {
36150
36173
  constructor(e, t) {
36151
36174
  super(e, t), this._mode = "texture";
36152
36175
  }
@@ -36192,7 +36215,7 @@
36192
36215
  }
36193
36216
  }
36194
36217
 
36195
- class Vf extends Df {
36218
+ class Gf extends Ff {
36196
36219
  constructor(e, t) {
36197
36220
  super(e, t), this.setElevation(t.elevation), this._mode = "elevate";
36198
36221
  }
@@ -36540,12 +36563,20 @@
36540
36563
 
36541
36564
  const e = "${"; const code = `function(t){
36542
36565
  /*!
36543
- * @maptalks/gltf-loader v0.116.0
36566
+ * @maptalks/gltf-loader v0.117.0
36544
36567
  * LICENSE : UNLICENSED
36545
36568
  * (c) 2016-2025 maptalks.org
36546
36569
  */
36547
36570
  var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t=new n(3);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function s(t,e,r){var i=new n(3);return i[0]=t,i[1]=e,i[2]=r,i}function a(){var t=new n(4);return n!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),i(),e=new n(4),n!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),i(),s(1,0,0),s(0,1,0),a(),a(),r=new n(9),n!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1;let o=0;!function(t){t[0]=0,t[1]=0,t[2]=0,t[3]=1}([]),"undefined"!=typeof TextDecoder&&new TextDecoder("utf-8");const h={get:function(t,e={},r){e||(e={});const n=new AbortController,i=n.signal,s=function(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}({},e);s.signal=i,s.method||(s.method="GET"),s.referrerPolicy=s.referrerPolicy||"origin","undefined"==typeof window||s.referrer||(s.referrer=window.location.href),r&&(t=r(t));const a=fetch(t,s).then((t=>{const r=this._parseResponse(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}))})).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}));return a.xhr=n,a},_parseResponse:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${e}t.status}): ${e}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},r)=>(e||(e={}),e.responseType="arraybuffer",h.get(t,e,r)),getJSON:function(t,e={},r){return e&&e.jsonp?h.jsonp(t):((e=e||{}).responseType="json",h.get(t,e,r))},jsonp:function(t){const e="_maptalks_jsonp_"+o++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))}};if("undefined"!=typeof TextDecoder&&new TextDecoder("utf-8"),"undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(n){}}"undefined"!=typeof document&&document.createElement("canvas"),
36548
- /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */function(){function t(t){throw t}var e=void 0,r=!0,n=this;function i(t,r){var i,s=t.split("."),a=n;!(s[0]in a)&&a.execScript&&a.execScript("var "+s[0]);for(;s.length&&(i=s.shift());)s.length||r===e?a=a[i]?a[i]:a[i]={}:a[i]=r}var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;function a(e,r){this.index="number"==typeof r?r:0,this.i=0,this.buffer=e instanceof(s?Uint8Array:Array)?e:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}a.prototype.f=function(){var t,e=this.buffer,r=e.length,n=new(s?Uint8Array:Array)(r<<1);if(s)n.set(e);else for(t=0;t<r;++t)n[t]=e[t];return this.buffer=n},a.prototype.d=function(t,e,r){var n,i=this.buffer,s=this.index,a=this.i,o=i[s];if(r&&1<e&&(t=8<e?(u[255&t]<<24|u[t>>>8&255]<<16|u[t>>>16&255]<<8|u[t>>>24&255])>>32-e:u[t]>>8-e),8>e+a)o=o<<e|t,a+=e;else for(n=0;n<e;++n)o=o<<1|t>>e-n-1&1,8==++a&&(a=0,i[s++]=u[o],o=0,s===i.length&&(i=this.f()));i[s]=o,this.buffer=i,this.i=a,this.index=s},a.prototype.finish=function(){var t,e=this.buffer,r=this.index;return 0<this.i&&(e[r]<<=8-this.i,e[r]=u[e[r]],r++),s?t=e.subarray(0,r):(e.length=r,t=e),t};var o,h=new(s?Uint8Array:Array)(256);for(o=0;256>o;++o){for(var c=l=o,f=7,l=l>>>1;l;l>>>=1)c<<=1,c|=1&l,--f;h[o]=(c<<f&255)>>>0}var u=h;function g(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function d(t){var e,r,n,i,a,o,h,c,f,l,u=t.length,g=0,d=Number.POSITIVE_INFINITY;for(c=0;c<u;++c)t[c]>g&&(g=t[c]),t[c]<d&&(d=t[c]);for(e=1<<g,r=new(s?Uint32Array:Array)(e),n=1,i=0,a=2;n<=g;){for(c=0;c<u;++c)if(t[c]===n){for(o=0,h=i,f=0;f<n;++f)o=o<<1|1&h,h>>=1;for(l=n<<16|c,f=o;f<e;f+=a)r[f]=l;++i}++n,i<<=1,a<<=1}return[r,g,d]}function p(t,e){this.h=m,this.w=0,this.input=s&&t instanceof Array?new Uint8Array(t):t,this.b=0,e&&(e.lazy&&(this.w=e.lazy),"number"==typeof e.compressionType&&(this.h=e.compressionType),e.outputBuffer&&(this.a=s&&e.outputBuffer instanceof Array?new Uint8Array(e.outputBuffer):e.outputBuffer),"number"==typeof e.outputIndex&&(this.b=e.outputIndex)),this.a||(this.a=new(s?Uint8Array:Array)(32768))}g.prototype.getParent=function(t){return 2*((t-2)/4|0)},g.prototype.push=function(t,e){var r,n,i,s=this.buffer;for(r=this.length,s[this.length++]=e,s[this.length++]=t;0<r&&(n=this.getParent(r),s[r]>s[n]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return this.length},g.prototype.pop=function(){var t,e,r,n,i,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],i=0;!((n=2*i+2)>=this.length)&&(n+2<this.length&&s[n+2]>s[n]&&(n+=2),s[n]>s[i]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return{index:t,value:e,length:this.length}};var y,m=2,b={NONE:0,r:1,k:m,N:3},w=[];for(y=0;288>y;y++)switch(r){case 143>=y:w.push([y+48,8]);break;case 255>=y:w.push([y-144+400,9]);break;case 279>=y:w.push([y-256+0,7]);break;case 287>=y:w.push([y-280+192,8]);break;default:t("invalid literal: "+y)}function A(t,e){this.length=t,this.G=e}p.prototype.j=function(){var n,i,o,h,c=this.input;switch(this.h){case 0:for(o=0,h=c.length;o<h;){var f,l,u,g=i=s?c.subarray(o,o+65535):c.slice(o,o+65535),d=(o+=i.length)===h,p=e,y=e,b=this.a,A=this.b;if(s){for(b=new Uint8Array(this.a.buffer);b.length<=A+g.length+5;)b=new Uint8Array(b.length<<1);b.set(this.a)}if(f=d?1:0,b[A++]=0|f,u=65536+~(l=g.length)&65535,b[A++]=255&l,b[A++]=l>>>8&255,b[A++]=255&u,b[A++]=u>>>8&255,s)b.set(g,A),A+=g.length,b=b.subarray(0,A);else{for(p=0,y=g.length;p<y;++p)b[A++]=g[p];b.length=A}this.b=A,this.a=b}break;case 1:var v=new a(s?new Uint8Array(this.a.buffer):this.a,this.b);v.d(1,1,r),v.d(1,2,r);var k,x,M,I=E(this,c);for(k=0,x=I.length;k<x;k++)if(M=I[k],a.prototype.d.apply(v,w[M]),256<M)v.d(I[++k],I[++k],r),v.d(I[++k],5),v.d(I[++k],I[++k],r);else if(256===M)break;this.a=v.finish(),this.b=this.a.length;break;case m:var S,D,B,z,F,_,C,N,O,R,P,j,q,L,H,Y=new a(s?new Uint8Array(this.a.buffer):this.a,this.b),W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=Array(19);for(S=m,Y.d(1,1,r),Y.d(S,2,r),D=E(this,c),C=U(_=T(this.L,15)),O=U(N=T(this.K,7)),B=286;257<B&&0===_[B-1];B--);for(z=30;1<z&&0===N[z-1];z--);var Z,G,$,J,K,X,Q=B,tt=z,et=new(s?Uint32Array:Array)(Q+tt),rt=new(s?Uint32Array:Array)(316),nt=new(s?Uint8Array:Array)(19);for(Z=G=0;Z<Q;Z++)et[G++]=_[Z];for(Z=0;Z<tt;Z++)et[G++]=N[Z];if(!s)for(Z=0,J=nt.length;Z<J;++Z)nt[Z]=0;for(Z=K=0,J=et.length;Z<J;Z+=G){for(G=1;Z+G<J&&et[Z+G]===et[Z];++G);if($=G,0===et[Z])if(3>$)for(;0<$--;)rt[K++]=0,nt[0]++;else for(;0<$;)(X=138>$?$:138)>$-3&&X<$&&(X=$-3),10>=X?(rt[K++]=17,rt[K++]=X-3,nt[17]++):(rt[K++]=18,rt[K++]=X-11,nt[18]++),$-=X;else if(rt[K++]=et[Z],nt[et[Z]]++,3>--$)for(;0<$--;)rt[K++]=et[Z],nt[et[Z]]++;else for(;0<$;)(X=6>$?$:6)>$-3&&X<$&&(X=$-3),rt[K++]=16,rt[K++]=X-3,nt[16]++,$-=X}for(n=s?rt.subarray(0,K):rt.slice(0,K),R=T(nt,7),L=0;19>L;L++)V[L]=R[W[L]];for(F=19;4<F&&0===V[F-1];F--);for(P=U(R),Y.d(B-257,5,r),Y.d(z-1,5,r),Y.d(F-4,4,r),L=0;L<F;L++)Y.d(V[L],3,r);for(L=0,H=n.length;L<H;L++)if(j=n[L],Y.d(P[j],R[j],r),16<=j){switch(L++,j){case 16:q=2;break;case 17:q=3;break;case 18:q=7;break;default:t("invalid code: "+j)}Y.d(n[L],q,r)}var it,st,at,ot,ht,ct,ft,lt,ut=[C,_],gt=[O,N];for(ht=ut[0],ct=ut[1],ft=gt[0],lt=gt[1],it=0,st=D.length;it<st;++it)if(at=D[it],Y.d(ht[at],ct[at],r),256<at)Y.d(D[++it],D[++it],r),ot=D[++it],Y.d(ft[ot],lt[ot],r),Y.d(D[++it],D[++it],r);else if(256===at)break;this.a=Y.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var v=function(){function e(e){switch(r){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}var n,i,s=[];for(n=3;258>=n;n++)i=e(n),s[n]=i[2]<<24|i[1]<<16|i[0];return s}(),k=s?new Uint32Array(v):v;function E(n,i){function a(e,n){var i,s,a,o,h=e.G,c=[],f=0;switch(i=k[e.length],c[f++]=65535&i,c[f++]=i>>16&255,c[f++]=i>>24,r){case 1===h:s=[0,h-1,0];break;case 2===h:s=[1,h-2,0];break;case 3===h:s=[2,h-3,0];break;case 4===h:s=[3,h-4,0];break;case 6>=h:s=[4,h-5,1];break;case 8>=h:s=[5,h-7,1];break;case 12>=h:s=[6,h-9,2];break;case 16>=h:s=[7,h-13,2];break;case 24>=h:s=[8,h-17,3];break;case 32>=h:s=[9,h-25,3];break;case 48>=h:s=[10,h-33,4];break;case 64>=h:s=[11,h-49,4];break;case 96>=h:s=[12,h-65,5];break;case 128>=h:s=[13,h-97,5];break;case 192>=h:s=[14,h-129,6];break;case 256>=h:s=[15,h-193,6];break;case 384>=h:s=[16,h-257,7];break;case 512>=h:s=[17,h-385,7];break;case 768>=h:s=[18,h-513,8];break;case 1024>=h:s=[19,h-769,8];break;case 1536>=h:s=[20,h-1025,9];break;case 2048>=h:s=[21,h-1537,9];break;case 3072>=h:s=[22,h-2049,10];break;case 4096>=h:s=[23,h-3073,10];break;case 6144>=h:s=[24,h-4097,11];break;case 8192>=h:s=[25,h-6145,11];break;case 12288>=h:s=[26,h-8193,12];break;case 16384>=h:s=[27,h-12289,12];break;case 24576>=h:s=[28,h-16385,13];break;case 32768>=h:s=[29,h-24577,13];break;default:t("invalid distance")}for(i=s,c[f++]=i[0],c[f++]=i[1],c[f++]=i[2],a=0,o=c.length;a<o;++a)m[b++]=c[a];A[c[0]]++,v[c[3]]++,w=e.length+n-1,d=null}var o,h,c,f,l,u,g,d,p,y={},m=s?new Uint16Array(2*i.length):[],b=0,w=0,A=new(s?Uint32Array:Array)(286),v=new(s?Uint32Array:Array)(30),E=n.w;if(!s){for(c=0;285>=c;)A[c++]=0;for(c=0;29>=c;)v[c++]=0}for(A[256]=1,o=0,h=i.length;o<h;++o){for(c=l=0,f=3;c<f&&o+c!==h;++c)l=l<<8|i[o+c];if(y[l]===e&&(y[l]=[]),u=y[l],!(0<w--)){for(;0<u.length&&32768<o-u[0];)u.shift();if(o+3>=h){for(d&&a(d,-1),c=0,f=h-o;c<f;++c)p=i[o+c],m[b++]=p,++A[p];break}0<u.length?(g=x(i,o,u),d?d.length<g.length?(p=i[o-1],m[b++]=p,++A[p],a(g,0)):a(d,-1):g.length<E?d=g:a(g,0)):d?a(d,-1):(p=i[o],m[b++]=p,++A[p])}u.push(o)}return m[b++]=256,A[256]++,n.L=A,n.K=v,s?m.subarray(0,b):m}function x(t,e,r){var n,i,s,a,o,h,c=0,f=t.length;a=0,h=r.length;t:for(;a<h;a++){if(n=r[h-a-1],s=3,3<c){for(o=c;3<o;o--)if(t[n+o-1]!==t[e+o-1])continue t;s=c}for(;258>s&&e+s<f&&t[n+s]===t[e+s];)++s;if(s>c&&(i=n,c=s),258===s)break}return new A(c,e-i)}function T(t,e){var r,n,i,a,o,h=t.length,c=new g(572),f=new(s?Uint8Array:Array)(h);if(!s)for(a=0;a<h;a++)f[a]=0;for(a=0;a<h;++a)0<t[a]&&c.push(a,t[a]);if(r=Array(c.length/2),n=new(s?Uint32Array:Array)(c.length/2),1===r.length)return f[c.pop().index]=1,f;for(a=0,o=c.length/2;a<o;++a)r[a]=c.pop(),n[a]=r[a].value;for(i=function(t,e,r){function n(t){var r=d[t][p[t]];r===e?(n(t+1),n(t+1)):--u[r],++p[t]}var i,a,o,h,c,f=new(s?Uint16Array:Array)(r),l=new(s?Uint8Array:Array)(r),u=new(s?Uint8Array:Array)(e),g=Array(r),d=Array(r),p=Array(r),y=(1<<r)-e,m=1<<r-1;for(f[r-1]=e,a=0;a<r;++a)y<m?l[a]=0:(l[a]=1,y-=m),y<<=1,f[r-2-a]=(f[r-1-a]/2|0)+e;for(f[0]=l[0],g[0]=Array(f[0]),d[0]=Array(f[0]),a=1;a<r;++a)f[a]>2*f[a-1]+l[a]&&(f[a]=2*f[a-1]+l[a]),g[a]=Array(f[a]),d[a]=Array(f[a]);for(i=0;i<e;++i)u[i]=r;for(o=0;o<f[r-1];++o)g[r-1][o]=t[o],d[r-1][o]=o;for(i=0;i<r;++i)p[i]=0;for(1===l[r-1]&&(--u[0],++p[r-1]),a=r-2;0<=a;--a){for(h=i=0,c=p[a+1],o=0;o<f[a];o++)(h=g[a+1][c]+g[a+1][c+1])>t[i]?(g[a][o]=h,d[a][o]=e,c+=2):(g[a][o]=t[i],d[a][o]=i,++i);p[a]=0,1===l[a]&&n(a)}return u}(n,n.length,e),a=0,o=r.length;a<o;++a)f[r[a].index]=i[a];return f}function U(t){var e,r,n,i,a=new(s?Uint16Array:Array)(t.length),o=[],h=[],c=0;for(e=0,r=t.length;e<r;e++)o[t[e]]=1+(0|o[t[e]]);for(e=1,r=16;e<=r;e++)h[e]=c,c+=0|o[e],c<<=1;for(e=0,r=t.length;e<r;e++)for(c=h[t[e]],h[t[e]]+=1,n=a[e]=0,i=t[e];n<i;n++)a[e]=a[e]<<1|1&c,c>>>=1;return a}function M(e,r){switch(this.l=[],this.m=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(e):e,this.s=!1,this.n=S,this.B=!1,!r&&(r={})||(r.index&&(this.c=r.index),r.bufferSize&&(this.m=r.bufferSize),r.bufferType&&(this.n=r.bufferType),r.resize&&(this.B=r.resize)),this.n){case I:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.m+258);break;case S:this.b=0,this.a=new(s?Uint8Array:Array)(this.m),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}var I=0,S=1,D={D:I,C:S};M.prototype.p=function(){for(;!this.s;){var n=$(this,3);switch(1&n&&(this.s=r),n>>>=1){case 0:var i=this.input,a=this.c,o=this.a,h=this.b,c=i.length,f=e,l=o.length,u=e;switch(this.e=this.g=0,a+1>=c&&t(Error("invalid uncompressed block header: LEN")),f=i[a++]|i[a++]<<8,a+1>=c&&t(Error("invalid uncompressed block header: NLEN")),f===~(i[a++]|i[a++]<<8)&&t(Error("invalid uncompressed block header: length verify")),a+f>i.length&&t(Error("input buffer is broken")),this.n){case I:for(;h+f>o.length;){if(f-=u=l-h,s)o.set(i.subarray(a,a+u),h),h+=u,a+=u;else for(;u--;)o[h++]=i[a++];this.b=h,o=this.f(),h=this.b}break;case S:for(;h+f>o.length;)o=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)o.set(i.subarray(a,a+f),h),h+=f,a+=f;else for(;f--;)o[h++]=i[a++];this.c=a,this.b=h,this.a=o;break;case 1:this.o(V,G);break;case 2:var g,p,y,m,b=$(this,5)+257,w=$(this,5)+1,A=$(this,4)+4,v=new(s?Uint8Array:Array)(_.length),k=e,E=e,x=e,T=e,U=e;for(U=0;U<A;++U)v[_[U]]=$(this,3);if(!s)for(U=A,A=v.length;U<A;++U)v[_[U]]=0;for(g=d(v),k=new(s?Uint8Array:Array)(b+w),U=0,m=b+w;U<m;)switch(E=J(this,g),E){case 16:for(T=3+$(this,2);T--;)k[U++]=x;break;case 17:for(T=3+$(this,3);T--;)k[U++]=0;x=0;break;case 18:for(T=11+$(this,7);T--;)k[U++]=0;x=0;break;default:x=k[U++]=E}p=d(s?k.subarray(0,b):k.slice(0,b)),y=d(s?k.subarray(b):k.slice(b)),this.o(p,y);break;default:t(Error("unknown BTYPE: "+n))}}return this.t()};var B,z,F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],_=s?new Uint16Array(F):F,C=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],N=s?new Uint16Array(C):C,O=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],R=s?new Uint8Array(O):O,P=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],j=s?new Uint16Array(P):P,q=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],L=s?new Uint8Array(q):q,H=new(s?Uint8Array:Array)(288);for(B=0,z=H.length;B<z;++B)H[B]=143>=B?8:255>=B?9:279>=B?7:8;var Y,W,V=d(H),Z=new(s?Uint8Array:Array)(30);for(Y=0,W=Z.length;Y<W;++Y)Z[Y]=5;var G=d(Z);function $(e,r){for(var n,i=e.g,s=e.e,a=e.input,o=e.c,h=a.length;s<r;)o>=h&&t(Error("input buffer is broken")),i|=a[o++]<<s,s+=8;return n=i&(1<<r)-1,e.g=i>>>r,e.e=s-r,e.c=o,n}function J(e,r){for(var n,i,s=e.g,a=e.e,o=e.input,h=e.c,c=o.length,f=r[0],l=r[1];a<l&&!(h>=c);)s|=o[h++]<<a,a+=8;return(i=(n=f[s&(1<<l)-1])>>>16)>a&&t(Error("invalid code length: "+i)),e.g=s>>i,e.e=a-i,e.c=h,65535&n}function K(t){if("string"==typeof t){var e,r,n=t.split("");for(e=0,r=n.length;e<r;e++)n[e]=(255&n[e].charCodeAt(0))>>>0;t=n}for(var i,s=1,a=0,o=t.length,h=0;0<o;){o-=i=1024<o?1024:o;do{a+=s+=t[h++]}while(--i);s%=65521,a%=65521}return(a<<16|s)>>>0}function X(e,r){var n,i;if(this.input=e,this.c=0,!r&&(r={})||(r.index&&(this.c=r.index),r.verify&&(this.M=r.verify)),n=e[this.c++],i=e[this.c++],(15&n)===Q)this.method=Q;else t(Error("unsupported compression method"));0!=((n<<8)+i)%31&&t(Error("invalid fcheck flag:"+((n<<8)+i)%31)),32&i&&t(Error("fdict flag is not supported")),this.A=new M(e,{index:this.c,bufferSize:r.bufferSize,bufferType:r.bufferType,resize:r.resize})}M.prototype.o=function(t,e){var r=this.a,n=this.b;this.u=t;for(var i,s,a,o,h=r.length-258;256!==(i=J(this,t));)if(256>i)n>=h&&(this.b=n,r=this.f(),n=this.b),r[n++]=i;else for(o=N[s=i-257],0<R[s]&&(o+=$(this,R[s])),i=J(this,e),a=j[i],0<L[i]&&(a+=$(this,L[i])),n>=h&&(this.b=n,r=this.f(),n=this.b);o--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},M.prototype.I=function(t,e){var r=this.a,n=this.b;this.u=t;for(var i,s,a,o,h=r.length;256!==(i=J(this,t));)if(256>i)n>=h&&(h=(r=this.f()).length),r[n++]=i;else for(o=N[s=i-257],0<R[s]&&(o+=$(this,R[s])),i=J(this,e),a=j[i],0<L[i]&&(a+=$(this,L[i])),n+o>h&&(h=(r=this.f()).length);o--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},M.prototype.f=function(){var t,e,r=new(s?Uint8Array:Array)(this.b-32768),n=this.b-32768,i=this.a;if(s)r.set(i.subarray(32768,r.length));else for(t=0,e=r.length;t<e;++t)r[t]=i[t+32768];if(this.l.push(r),this.q+=r.length,s)i.set(i.subarray(n,n+32768));else for(t=0;32768>t;++t)i[t]=i[n+t];return this.b=32768,i},M.prototype.J=function(t){var e,r,n,i=this.input.length/this.c+1|0,a=this.input,o=this.a;return t&&("number"==typeof t.v&&(i=t.v),"number"==typeof t.F&&(i+=t.F)),2>i?r=(n=(a.length-this.c)/this.u[2]/2*258|0)<o.length?o.length+n:o.length<<1:r=o.length*i,s?(e=new Uint8Array(r)).set(o):e=o,this.a=e},M.prototype.t=function(){var t,e,r,n,i,a=0,o=this.a,h=this.l,c=new(s?Uint8Array:Array)(this.q+(this.b-32768));if(0===h.length)return s?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(e=0,r=h.length;e<r;++e)for(n=0,i=(t=h[e]).length;n<i;++n)c[a++]=t[n];for(e=32768,r=this.b;e<r;++e)c[a++]=o[e];return this.l=[],this.buffer=c},M.prototype.H=function(){var t,e=this.b;return s?this.B?(t=new Uint8Array(e)).set(this.a.subarray(0,e)):t=this.a.subarray(0,e):(this.a.length>e&&(this.a.length=e),t=this.a),this.buffer=t},X.prototype.p=function(){var e,r=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&((r[this.c++]<<24|r[this.c++]<<16|r[this.c++]<<8|r[this.c++])>>>0!==K(e)&&t(Error("invalid adler-32 checksum"))),e};var Q=8;function tt(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=et.k;var r,n={};for(r in!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType),e)n[r]=e[r];n.outputBuffer=this.a,this.z=new p(this.input,n)}var et=b;function rt(t,e){var r,n,s,a;if(Object.keys)r=Object.keys(e);else for(n in r=[],s=0,e)r[s++]=n;for(s=0,a=r.length;s<a;++s)i(t+"."+(n=r[s]),e[n])}tt.prototype.j=function(){var e,r,n,i,a,o,h,c=0;if(h=this.a,(e=Q)===Q)r=Math.LOG2E*Math.log(32768)-8;else t(Error("invalid compression method"));if(n=r<<4|e,h[c++]=n,e===Q)switch(this.h){case et.NONE:a=0;break;case et.r:a=1;break;case et.k:a=2;break;default:t(Error("unsupported compression type"))}else t(Error("invalid compression method"));return i=a<<6,h[c++]=i|31-(256*n+i)%31,o=K(this.input),this.z.b=c,c=(h=this.z.j()).length,s&&((h=new Uint8Array(h.buffer)).length<=c+4&&(this.a=new Uint8Array(h.length+4),this.a.set(h),h=this.a),h=h.subarray(0,c+4)),h[c++]=o>>24&255,h[c++]=o>>16&255,h[c++]=o>>8&255,h[c++]=255&o,h},i("Zlib.Inflate",X),i("Zlib.Inflate.prototype.decompress",X.prototype.p),rt("Zlib.Inflate.BufferType",{ADAPTIVE:D.C,BLOCK:D.D}),i("Zlib.Deflate",tt),i("Zlib.Deflate.compress",(function(t,e){return new tt(t,e).j()})),i("Zlib.Deflate.prototype.compress",tt.prototype.j),rt("Zlib.Deflate.CompressionType",{NONE:et.NONE,FIXED:et.r,DYNAMIC:et.k})}.call(self);var c="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var f,l=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t};function u(t,e,r){return t[0]=e,t[1]=r,t}f=new c(3),c!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0),function(){var t=function(){var t=new c(2);return c!=Float32Array&&(t[0]=0,t[1]=0),t}()}();class g{constructor(t=257){this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(\`Expected grid size to be 2^n+1, got ${e}t}.\`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let r=t+2,n=0,i=0,s=0,a=0,o=0,h=0;for(1&r?s=a=o=e:n=i=h=e;(r>>=1)>1;){const t=n+s>>1,e=i+a>>1;1&r?(s=n,a=i,n=o,i=h):(n=s,i=a,s=o,a=h),o=t,h=e}const c=4*t;this.coords[c+0]=n,this.coords[c+1]=i,this.coords[c+2]=s,this.coords[c+3]=a}}createTile(t){return new d(t,this)}}class d{constructor(t,e){const r=e.gridSize;if(t.length!==r*r)throw new Error(\`Expected terrain data of length ${e}r*r} (${e}r} x ${e}r}), got ${e}t.length}.\`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:r,gridSize:n}=this.martini,{terrain:i,errors:s}=this;for(let a=t-1;a>=0;a--){const t=4*a,o=r[t+0],h=r[t+1],c=r[t+2],f=r[t+3],l=o+c>>1,u=h+f>>1,g=l+u-h,d=u+o-l,p=(i[h*n+o]+i[f*n+c])/2,y=u*n+l,m=Math.abs(p-i[y]);if(s[y]=Math.max(s[y],m),a<e){const t=(h+d>>1)*n+(o+g>>1),e=(f+d>>1)*n+(c+g>>1);s[y]=Math.max(s[y],s[t],s[e])}}}getMesh(t=0){const{gridSize:e,indices:r}=this.martini,{errors:n}=this;let i=0,s=0;const a=e-1;function o(a,h,c,f,l,u){const g=a+c>>1,d=h+f>>1;Math.abs(a-l)+Math.abs(h-u)>1&&n[d*e+g]>t?(o(l,u,a,h,g,d),o(c,f,l,u,g,d)):(r[h*e+a]=r[h*e+a]||++i,r[f*e+c]=r[f*e+c]||++i,r[u*e+l]=r[u*e+l]||++i,s++)}r.fill(0),o(0,0,a,a,a,0),o(a,a,0,0,0,a);const h=new Uint16Array(2*i),c=new Uint32Array(3*s);let f=0;function l(i,s,a,o,u,g){const d=i+a>>1,p=s+o>>1;if(Math.abs(i-u)+Math.abs(s-g)>1&&n[p*e+d]>t)l(u,g,i,s,d,p),l(a,o,u,g,d,p);else{const t=r[s*e+i]-1,n=r[o*e+a]-1,l=r[g*e+u]-1;h[2*t]=i,h[2*t+1]=s,h[2*n]=a,h[2*n+1]=o,h[2*l]=u,h[2*l+1]=g,c[f++]=t,c[f++]=n,c[f++]=l}}return l(0,0,a,a,a,0),l(a,a,0,0,0,a),{vertices:h,triangles:c}}getMeshWithSkirts(t=0,e){const{gridSize:r,indices:n}=this.martini,{errors:i}=this;let s=0,a=0;const o=r-1;let h,c,f=0;const l=[],u=[],g=[],d=[];function p(e,y,m,b,w,A){const v=e+m>>1,k=y+b>>1;Math.abs(e-w)+Math.abs(y-A)>1&&i[k*r+v]>t?(p(w,A,e,y,v,k),p(m,b,w,A,v,k)):(h=y*r+e,c=b*r+m,f=A*r+w,0===n[h]&&(0===e?l.push(s):e===o&&u.push(s),0===y?g.push(s):y===o&&d.push(s),n[h]=++s),0===n[c]&&(0===m?l.push(s):m===o&&u.push(s),0===b?g.push(s):b===o&&d.push(s),n[c]=++s),0===n[f]&&(0===w?l.push(s):w===o&&u.push(s),0===A?g.push(s):A===o&&d.push(s),n[f]=++s),a++)}let y;n.fill(0),p(0,0,o,o,o,0),p(o,o,0,0,0,o),y=e?2*(s+3*l.length-2+3*u.length-2+3*g.length-2+3*d.length-2):2*(s+l.length+u.length+g.length+d.length);const m=3*(a+2*(l.length-1)+2*(u.length-1)+2*(g.length-1)+2*(d.length-1)),b=new Uint16Array(y),w=new Uint32Array(m);let A=0;function v(e,s,a,o,h,c){const f=e+a>>1,l=s+o>>1;if(Math.abs(e-h)+Math.abs(s-c)>1&&i[l*r+f]>t)v(h,c,e,s,f,l),v(a,o,h,c,f,l);else{const t=n[s*r+e]-1,i=n[o*r+a]-1,f=n[c*r+h]-1;b[2*t]=e,b[2*t+1]=s,b[2*i]=a,b[2*i+1]=o,b[2*f]=h,b[2*f+1]=c,w[A++]=t,w[A++]=i,w[A++]=f}}v(0,0,o,o,o,0),v(o,o,0,0,0,o),l.sort(((t,e)=>b[2*t+1]-b[2*e+1])),u.sort(((t,e)=>b[2*e+1]-b[2*t+1])),g.sort(((t,e)=>b[2*e]-b[2*t])),d.sort(((t,e)=>b[2*t]-b[2*e]));let k,E,x,T,U=2*s,M=0;function I(t){M=t.length;for(let r=0;r<M-1;r++)k=t[r],E=t[r+1],x=U/2,T=(U+(e?6:2))/2,b[U++]=2*k,b[U++]=2*k+1,e&&(b[U++]=2*k,b[U++]=2*k+1,b[U++]=2*E,b[U++]=2*E+1),e?(w[A++]=x+1,w[A++]=x,w[A++]=x+2,w[A++]=x,w[A++]=T,w[A++]=x+2):(w[A++]=k,w[A++]=x,w[A++]=E,w[A++]=x,w[A++]=T,w[A++]=E);b[U++]=2*t[M-1],b[U++]=2*t[M-1]+1}I(l);const S=U;I(u);const D=U;I(g);const B=U;I(d);return{vertices:b,triangles:w,numVerticesWithoutSkirts:s,numTrianglesWithoutSkirts:a,leftSkirtIndex:S,rightSkirtIndex:D,bottomSkirtIndex:B,topSkirtIndex:U}}}const p={};let y;const m={width:100,height:10};let b,w=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),w=!0}catch(t){w=!1}function A(){if(!y){const{width:t,height:e}=m;w?y=new OffscreenCanvas(t,e):(y=document.createElement("canvas"),y.width=t,y.height=e)}return y}class v{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let r=1/0,n=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];r=Math.min(i,r),n=Math.max(i,n)}this.min=r,this.max=n,this.valueOffset=this.max-this.min,this.options=Object.assign({},m,e),this._initImgData()}getImageData(){return this.imgData}_initImgData(){const t=A(),{width:e,height:r}=this.options;t.width=e,t.height=r;const n=t.getContext("2d");n.clearRect(0,0,t.width,t.height);const i=n.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:a}=this;for(let t=0,e=s.length;t<e;t++){const[e,r]=s[t],n=(e-this.min)/a;i.addColorStop(n,r)}n.fillStyle=i,n.fillRect(0,0,t.width,t.height),this.imgData=n.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let r=Math.round(e*this.imgData.width);r=Math.min(r,this.imgData.width-1);const n=4*r;return[this.imgData.data[n],this.imgData.data[n+1],this.imgData.data[n+2],this.imgData.data[n+3]]}}let k=null,E=null;const x=[0,0,0],T=[256,256];function U(){try{k||(k=new OffscreenCanvas(1,1))}catch(t){console.error(t)}}const M={},I={},S={width:64,height:64,elementsPerHeight:3,heightOffset:-1e3,exaggeration:1,heightScale:.001,elementMultiplier:256,stride:4,skirtHeight:.002,skirtOffset:.01},D={cesium_request_token:{Accept:"application/json,*/*;q=0.01","Accept-Encoding":"gzip, deflate, br"},tianditu:{"Accept-Encoding":"gzip, deflate, br"},cesium:{"Accept-Encoding":"gzip, deflate, br",Accept:"application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01"},mapbox:{Accept:"image/webp,*/*"}};D["cesium-ion"]=D.cesium;const B=32767;let z=null,F=null;function _(t,e){const r=function(t){if(t.length<1e3)return null;const e=new Zlib.Inflate(t);return e?e.decompress():null}(new Uint8Array(t));if(!r)throw new Error((n=new Uint8Array(t),C.decode(n)));var n;const i=function(t){const e=t,r=S.width,n=S.height,i=new Uint8Array(r*n*S.stride);let s,a,o,h,c;for(let t=0;t<n;t++)for(let f=0;f<r;f++){h=parseInt(149*t/(n-1)),c=parseInt(149*f/(r-1)),a=2*(150*h+c),s=e[a]+256*e[a+1],(s>1e4||s<-2e3)&&(s=0),o=4*(t*r+f);const l=(s+1e3)/S.heightScale,u=S.elementMultiplier;i[o]=l/(u*u),i[o+1]=(l-i[o]*u*u)/u,i[o+2]=l-i[o]*u*u-i[o+1]*u,i[o+3]=255}return i}(r),s=function(t,e){const r=e,n=e,i=r+1,s=n+1,a=S.elementsPerHeight,o=S.heightOffset,h=S.heightScale,c=S.elementMultiplier,f=S.skirtHeight,l=new Float32Array(i*s);let u=0,g=1/0,d=-1/0;for(let e=0;e<i;e++){const i=e>=n?n-1:e;for(let e=0;e<s;e++){let n=0;const s=i*(4*r)+4*(e>=r?r-1:e);for(let e=0;e<a;e++)n=n*c+t[s+e];n=1*(n*h+o),n-=f,l[u]=n,n<g&&(g=n),n>d&&(d=n),u++}}return{data:l,min:g,max:d}}(i,e-1);return s.width=s.height=e,s}const C=new TextDecoder("utf-8");function N(t){return t>>1^-(1&t)}const O=[];function R(t){let e=0;const r=3*Float64Array.BYTES_PER_ELEMENT,n=3*Uint16Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT;const s=new DataView(t);e+=r;const a=s.getFloat32(e,!0);e+=Float32Array.BYTES_PER_ELEMENT;const o=s.getFloat32(e,!0);e+=Float32Array.BYTES_PER_ELEMENT,e+=r;const h=s.getFloat64(e,!0);e+=Float64Array.BYTES_PER_ELEMENT,e+=r;const c=s.getUint32(e,!0);e+=Uint32Array.BYTES_PER_ELEMENT;const f=new Uint16Array(t,e,3*c);e+=c*n,c>65536&&(i=Uint32Array.BYTES_PER_ELEMENT);!function(t,e,r){const n=t.length;let i=0,s=0,a=0;for(let o=0;o<n;++o)i+=N(t[o]),s+=N(e[o]),t[o]=i,e[o]=s,r&&(a+=N(r[o]),r[o]=a)}(f.subarray(0,c),f.subarray(c,2*c),f.subarray(2*c,3*c)),e%i!=0&&(e+=i-e%i);const l=s.getUint32(e,!0);e+=Uint32Array.BYTES_PER_ELEMENT;const u=c>65536?new Uint32Array(t,e,3*l):new Uint16Array(t,e,3*l);let g=0;const d=u.length;for(let t=0;t<d;++t){const e=u[t];u[t]=g-e,0===e&&++g}const p={minimumHeight:a,maximumHeight:o,quantizedVertices:f,indices:u}.quantizedVertices,y=p.length/3,m=p.subarray(0,y),b=p.subarray(y,2*y),w=p.subarray(2*y,3*y),A=O;for(let t=0;t<y;++t){const e=m[t],r=b[t],n=e/B,i=r/B,s=(v=a,k=o,(1-(E=w[t]/B))*v+E*k);A[3*t]=n,A[3*t+1]=1-i,A[3*t+2]=s}var v,k,E;return{positions:A,radius:h,min:a,max:o,indices:u}}const P=[],j=[],q=[],L=[],H=[];class Y{constructor(t,e,r,n,i){this.p0=[],this.p1=[],this.p2=[],this.normal=[],this.min=[],this.max=[],this.set(t,e,r,n,i)}set(t,e,r,n,i){this.radius=i;let s=3*e,a=3*e+1,o=3*e+2;this.p0[0]=t[s]*i,this.p0[1]=t[a]*i,this.p0[2]=t[o],s=3*r,a=3*r+1,o=3*r+2,this.p1[0]=t[s]*i,this.p1[1]=t[a]*i,this.p1[2]=t[o],s=3*n,a=3*n+1,o=3*n+2,this.p2[0]=t[s]*i,this.p2[1]=t[a]*i,this.p2[2]=t[o],this.min[0]=Math.min(this.p0[0],this.p1[0],this.p2[0]),this.min[1]=Math.min(this.p0[1],this.p1[1],this.p2[1]),this.max[0]=Math.max(this.p0[0],this.p1[0],this.p2[0]),this.max[1]=Math.max(this.p0[1],this.p1[1],this.p2[1]);const h=l(P,this.p1,this.p0),c=l(j,this.p2,this.p1);this.normal=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}(this.normal,function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],h=r[2];return t[0]=i*h-s*o,t[1]=s*a-n*h,t[2]=n*o-i*a,t}(this.normal,h,c))}contains(t,e){if(t<this.min[0]||t>this.max[0]||e<this.min[1]||e>this.max[1])return!1;u(q,this.p0[0],this.p0[1]),u(L,this.p1[0],this.p1[1]),u(H,this.p2[0],this.p2[1]);const r=G(q[0],q[1],L[0],L[1],H[0],H[1]);return G(t,e,q[0],q[1],H[0],H[1])+G(t,e,q[0],q[1],L[0],L[1])+G(t,e,L[0],L[1],H[0],H[1])-r<=1e-4}getHeight(t,e){const r=this.normal;return this.p0[2]-((t-this.p0[0])*r[0]+(e-this.p0[1])*r[1])/r[2]}}let W=null;function V(t,e,r){if(W&&W.contains(e,r))return W.getHeight(e,r);for(let n=0;n<t.length;n++)if(t[n].contains(e,r))return W=t[n],t[n].getHeight(e,r);return 0}const Z=[];function G(t,e,r,n,i,s){return.5*Math.abs(t*n+r*s+i*e-t*s-r*e-i*n)}function $(t,e,r,n,i,s){"cesium-ion"===r&&(e.Authorization="Bearer "+z),function(t,e,r){const n={method:"GET",referrer:r,headers:e},i=h.getArrayBuffer(t,n),s=i.xhr;return I[t]=s,i.then((e=>(delete I[t],e)))}(t,e,origin).then((t=>{if(!t||t.message)s(t?{empty:!0,originalError:t}:{error:{canceled:!0}});else{const e=t.data;let a=null;if("tianditu"===r){const t=_(e,n);K(i,t,n,null,!0,s)}else if("cesium-ion"===r||"cesium"===r){a=R(e);const t=function(t,e){const{positions:r,min:n,max:i,indices:s,radius:a}=t,o=[];let h=0;for(let t=0;t<s.length;t+=3){let e=Z[h];e?e.set(r,s[t],s[t+1],s[t+2],2*a):e=Z[h]=new Y(r,s[t],s[t+1],s[t+2],2*a),h++,o.push(e)}const c=new Float32Array(e*e);h=0;for(let t=0;t<e;t++)for(let r=0;r<e;r++)c[h++]=V(o,r/e*a*2,t/e*a*2);return{data:c,min:n,max:i,width:e,height:e}}(a,n);K(i,t,n,null,!0,s)}else"mapbox"===r&&(a=function(t){const e=new self.Blob([new Uint8Array(t)]);return self.createImageBitmap(e)}(e),a.then((t=>{const e=Q(X(t),n);K(i,e,n,t,!0,s)})))}})).catch((e=>{delete I[t],s({empty:!0,originalError:e})}))}function J(t,e){const r=Math.floor(10*(t+1e4)),n=r>>16,i=r>>8&255,s=255&r;return e?(e[0]=n,e[1]=i,e[2]=s,e):[n,i,s]}function K(t,e,r,n,i,s){const a=function(t,e,r){let n=p[r];n||(n=p[r]=new g(r));const i=n.createTile(e).getMeshWithSkirts(t,!0),{triangles:s,vertices:a,leftSkirtIndex:o,rightSkirtIndex:h,bottomSkirtIndex:c,topSkirtIndex:f}=i;let{numVerticesWithoutSkirts:l,numTrianglesWithoutSkirts:u}=i;l||(l=a.length/2,u=s.length/3);const d=a.length/2,y=new Float32Array(3*d),m=new Float32Array(2*d);let b=1/0,w=-1/0;const A=r-1;for(let t=0;t<d;t++){const n=a[2*t],i=a[2*t+1];if(t>=l){const e=n/2*3;let r,i=.001;(t-(t<o/2?l:t<h/2?o/2:t<c/2?h/2:c/2))%3==0?(r=Math.min(0,b),i=0):r=y[e+2],y[3*t]=y[e],y[3*t+1]=y[e+1],y[3*t+2]=r,m[2*t]=y[e]/A+i,m[2*t+1]=-y[e+1]/A+i}else{const s=e[i*r+n];y[3*t]=1*n,y[3*t+1]=1*-i,y[3*t+2]=s,m[2*t]=n/A,m[2*t+1]=i/A,s<b&&(b=s),s>w&&(w=s)}}return{positions:y,texcoords:m,triangles:s,leftSkirtIndex:o,rightSkirtIndex:h,bottomSkirtIndex:c,topSkirtIndex:f,numTrianglesWithoutSkirts:u,numVerticesWithoutSkirts:l,minHeight:Math.min(0,b),maxHeight:w,terrainWidth:r}}(t/6,e.data,r),o=[a.positions.buffer,a.texcoords.buffer,a.triangles.buffer];n||(n=function(t){if(U(),!k)return;const{width:e,height:r,data:n}=t;if(e&&r&&n)try{let t=k.getContext("2d",{willReadFrequently:!0});const i=t.createImageData(e,r);for(let t=0,e=n.length;t<e;t++){const e=n[t],[r,s,a]=J(e,x),o=4*t;i.data[o]=r,i.data[o+1]=s,i.data[o+2]=a,i.data[o+3]=255}return k.width=e,k.height=r,t=k.getContext("2d",{willReadFrequently:!0}),tt(t),t.putImageData(i,0,0),k.transferToImageBitmap()}catch(t){console.log(t)}}(e)),n&&o.push(n);const h={mesh:a};h.image=n,h.data=e,o.push(e.data.buffer),s(h,o)}function X(t){const{width:e,height:r}=t;return k||(k=new OffscreenCanvas(1,1),E=k.getContext("2d",{willReadFrequently:!0})),k.width=e,k.height=r,E.drawImage(t,0,0,e,r),E.getImageData(0,0,e,r)}function Q(t,e){const{data:r,width:n}=t;let i=1/0,s=-1/0;const a=new Float32Array(e*e),o=Math.round(n/e);for(let t=0;t<e;t++)for(let h=0;h<e;h++){const c=t+h*e;let f=0,l=0;const u=t,g=h;for(let t=0;t<o;t++)for(let e=0;e<o;e++){let i=u*o+t,s=g*o+e;s>n-1&&(s=n-1),i>n-1&&(i=n-1);const a=i+s*n,h=r[4*a],c=r[4*a+1],d=r[4*a+2];0===r[4*a+3]?l+=1:f+=.1*(256*h*256+256*c+d)-1e4}f/=o*o-l||1,f>s&&(s=f),f<i&&(i=f),a[c]=f}return{data:a,width:e,height:e,min:i,max:s}}function tt(t){const e=t.canvas,{width:r,height:n}=e;t.clearRect(0,0,r,n)}function et(t,e,r){if(!e||!Array.isArray(e)||e.length<2)return;if(!t||!t.image)return null;let{width:n,height:i}=t.image;(r=r||T)[0]===n&&r[1]===i||(n=r[0],i=r[1]),[n,i]=T;try{if(U(),!k)return;const r=k;r.width=n,r.height=i;const s=r.getContext("2d",{willReadFrequently:!0});tt(s),s.drawImage(t.image,0,0,n,i);const a=s.getImageData(0,0,n,i);!function(t,e){const r=JSON.stringify(e);M[r]||(M[r]=new v(e));const n=M[r],i=t.data;for(let t=0,e=i.length;t<e;t+=4){const e=i[t],r=i[t+1],s=i[t+2];let a=0;0!==i[t+3]&&(a=.1*(256*e*256+256*r+s)-1e4,a=Math.max(a,0));const[o,h,c]=n.getColor(a);i[t]=o,i[t+1]=h,i[t+2]=c,i[t+3]=255}}(a,e),s.putImageData(a,0,0);const o=r.transferToImageBitmap();s.save(),s.scale(1,-1),s.drawImage(o,0,-i,n,i),s.restore();const h=r.transferToImageBitmap();return o.close(),h}catch(t){console.error(t)}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;if("addLayer"===r.command||"removeLayer"===r.command)b=t.workerId,self.postMessage({type:"<response>",actorId:r.actorId,workerId:b,params:"ok",callback:t.callback});else if("fetchTerrain"===r.command){const t=(r.params||{}).colors,n=(r.params||{}).tileSize;!function(t,e){const{url:r,origin:n,type:i,accessToken:s,terrainWidth:a,error:o,tileImage:h}=t;if(h&&h.close){const t=Q(X(h),a);return void K(o,t,a,h,0,e)}const c=t.headers||D[i];if("tianditu"===i)$(r,c,i,a,o,e);else if("cesium-ion"===i){const h=t.cesiumIonTokenURL+s;z?$(r,c,i,a,o,e):(F||(F=fetch(h,{responseType:"json",method:"GET",referrer:n,headers:{Accept:"application/json,*/*;q=0.01","Accept-Encoding":"gzip, deflate, br"}}).then((t=>t.json())).then((t=>{z=t.accessToken,F=null}))),F.then((()=>{$(r,c,i,a,o,e)})))}else("cesium"===i||"mapbox"===i)&&$(r,c,i,a,o,e)}(r.params,((r,i)=>{const s=et(r,t,n);s&&(r.colorsTexture=s,(i=i||[]).push(s)),e(r.error,r,i)}))}else"abortTerrain"===r.command&&(n=r.params.url,I[n]&&(I[n].abort(),delete I[n]));var n}}`;
36571
+ /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */function(){function t(t){throw t}var e=void 0,r=!0,n=this;function i(t,r){var i,s=t.split("."),a=n;!(s[0]in a)&&a.execScript&&a.execScript("var "+s[0]);for(;s.length&&(i=s.shift());)s.length||r===e?a=a[i]?a[i]:a[i]={}:a[i]=r}var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;function a(e,r){this.index="number"==typeof r?r:0,this.i=0,this.buffer=e instanceof(s?Uint8Array:Array)?e:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}a.prototype.f=function(){var t,e=this.buffer,r=e.length,n=new(s?Uint8Array:Array)(r<<1);if(s)n.set(e);else for(t=0;t<r;++t)n[t]=e[t];return this.buffer=n},a.prototype.d=function(t,e,r){var n,i=this.buffer,s=this.index,a=this.i,o=i[s];if(r&&1<e&&(t=8<e?(u[255&t]<<24|u[t>>>8&255]<<16|u[t>>>16&255]<<8|u[t>>>24&255])>>32-e:u[t]>>8-e),8>e+a)o=o<<e|t,a+=e;else for(n=0;n<e;++n)o=o<<1|t>>e-n-1&1,8==++a&&(a=0,i[s++]=u[o],o=0,s===i.length&&(i=this.f()));i[s]=o,this.buffer=i,this.i=a,this.index=s},a.prototype.finish=function(){var t,e=this.buffer,r=this.index;return 0<this.i&&(e[r]<<=8-this.i,e[r]=u[e[r]],r++),s?t=e.subarray(0,r):(e.length=r,t=e),t};var o,h=new(s?Uint8Array:Array)(256);for(o=0;256>o;++o){for(var c=l=o,f=7,l=l>>>1;l;l>>>=1)c<<=1,c|=1&l,--f;h[o]=(c<<f&255)>>>0}var u=h;function g(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function d(t){var e,r,n,i,a,o,h,c,f,l,u=t.length,g=0,d=Number.POSITIVE_INFINITY;for(c=0;c<u;++c)t[c]>g&&(g=t[c]),t[c]<d&&(d=t[c]);for(e=1<<g,r=new(s?Uint32Array:Array)(e),n=1,i=0,a=2;n<=g;){for(c=0;c<u;++c)if(t[c]===n){for(o=0,h=i,f=0;f<n;++f)o=o<<1|1&h,h>>=1;for(l=n<<16|c,f=o;f<e;f+=a)r[f]=l;++i}++n,i<<=1,a<<=1}return[r,g,d]}function p(t,e){this.h=m,this.w=0,this.input=s&&t instanceof Array?new Uint8Array(t):t,this.b=0,e&&(e.lazy&&(this.w=e.lazy),"number"==typeof e.compressionType&&(this.h=e.compressionType),e.outputBuffer&&(this.a=s&&e.outputBuffer instanceof Array?new Uint8Array(e.outputBuffer):e.outputBuffer),"number"==typeof e.outputIndex&&(this.b=e.outputIndex)),this.a||(this.a=new(s?Uint8Array:Array)(32768))}g.prototype.getParent=function(t){return 2*((t-2)/4|0)},g.prototype.push=function(t,e){var r,n,i,s=this.buffer;for(r=this.length,s[this.length++]=e,s[this.length++]=t;0<r&&(n=this.getParent(r),s[r]>s[n]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return this.length},g.prototype.pop=function(){var t,e,r,n,i,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],i=0;!((n=2*i+2)>=this.length)&&(n+2<this.length&&s[n+2]>s[n]&&(n+=2),s[n]>s[i]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return{index:t,value:e,length:this.length}};var y,m=2,b={NONE:0,r:1,k:m,N:3},w=[];for(y=0;288>y;y++)switch(r){case 143>=y:w.push([y+48,8]);break;case 255>=y:w.push([y-144+400,9]);break;case 279>=y:w.push([y-256+0,7]);break;case 287>=y:w.push([y-280+192,8]);break;default:t("invalid literal: "+y)}function A(t,e){this.length=t,this.G=e}p.prototype.j=function(){var n,i,o,h,c=this.input;switch(this.h){case 0:for(o=0,h=c.length;o<h;){var f,l,u,g=i=s?c.subarray(o,o+65535):c.slice(o,o+65535),d=(o+=i.length)===h,p=e,y=e,b=this.a,A=this.b;if(s){for(b=new Uint8Array(this.a.buffer);b.length<=A+g.length+5;)b=new Uint8Array(b.length<<1);b.set(this.a)}if(f=d?1:0,b[A++]=0|f,u=65536+~(l=g.length)&65535,b[A++]=255&l,b[A++]=l>>>8&255,b[A++]=255&u,b[A++]=u>>>8&255,s)b.set(g,A),A+=g.length,b=b.subarray(0,A);else{for(p=0,y=g.length;p<y;++p)b[A++]=g[p];b.length=A}this.b=A,this.a=b}break;case 1:var v=new a(s?new Uint8Array(this.a.buffer):this.a,this.b);v.d(1,1,r),v.d(1,2,r);var k,x,M,I=E(this,c);for(k=0,x=I.length;k<x;k++)if(M=I[k],a.prototype.d.apply(v,w[M]),256<M)v.d(I[++k],I[++k],r),v.d(I[++k],5),v.d(I[++k],I[++k],r);else if(256===M)break;this.a=v.finish(),this.b=this.a.length;break;case m:var S,D,F,B,z,N,_,C,O,R,P,j,q,L,H,Y=new a(s?new Uint8Array(this.a.buffer):this.a,this.b),W=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=Array(19);for(S=m,Y.d(1,1,r),Y.d(S,2,r),D=E(this,c),_=U(N=T(this.L,15)),O=U(C=T(this.K,7)),F=286;257<F&&0===N[F-1];F--);for(B=30;1<B&&0===C[B-1];B--);var Z,G,$,J,K,X,Q=F,tt=B,et=new(s?Uint32Array:Array)(Q+tt),rt=new(s?Uint32Array:Array)(316),nt=new(s?Uint8Array:Array)(19);for(Z=G=0;Z<Q;Z++)et[G++]=N[Z];for(Z=0;Z<tt;Z++)et[G++]=C[Z];if(!s)for(Z=0,J=nt.length;Z<J;++Z)nt[Z]=0;for(Z=K=0,J=et.length;Z<J;Z+=G){for(G=1;Z+G<J&&et[Z+G]===et[Z];++G);if($=G,0===et[Z])if(3>$)for(;0<$--;)rt[K++]=0,nt[0]++;else for(;0<$;)(X=138>$?$:138)>$-3&&X<$&&(X=$-3),10>=X?(rt[K++]=17,rt[K++]=X-3,nt[17]++):(rt[K++]=18,rt[K++]=X-11,nt[18]++),$-=X;else if(rt[K++]=et[Z],nt[et[Z]]++,3>--$)for(;0<$--;)rt[K++]=et[Z],nt[et[Z]]++;else for(;0<$;)(X=6>$?$:6)>$-3&&X<$&&(X=$-3),rt[K++]=16,rt[K++]=X-3,nt[16]++,$-=X}for(n=s?rt.subarray(0,K):rt.slice(0,K),R=T(nt,7),L=0;19>L;L++)V[L]=R[W[L]];for(z=19;4<z&&0===V[z-1];z--);for(P=U(R),Y.d(F-257,5,r),Y.d(B-1,5,r),Y.d(z-4,4,r),L=0;L<z;L++)Y.d(V[L],3,r);for(L=0,H=n.length;L<H;L++)if(j=n[L],Y.d(P[j],R[j],r),16<=j){switch(L++,j){case 16:q=2;break;case 17:q=3;break;case 18:q=7;break;default:t("invalid code: "+j)}Y.d(n[L],q,r)}var it,st,at,ot,ht,ct,ft,lt,ut=[_,N],gt=[O,C];for(ht=ut[0],ct=ut[1],ft=gt[0],lt=gt[1],it=0,st=D.length;it<st;++it)if(at=D[it],Y.d(ht[at],ct[at],r),256<at)Y.d(D[++it],D[++it],r),ot=D[++it],Y.d(ft[ot],lt[ot],r),Y.d(D[++it],D[++it],r);else if(256===at)break;this.a=Y.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var v=function(){function e(e){switch(r){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}var n,i,s=[];for(n=3;258>=n;n++)i=e(n),s[n]=i[2]<<24|i[1]<<16|i[0];return s}(),k=s?new Uint32Array(v):v;function E(n,i){function a(e,n){var i,s,a,o,h=e.G,c=[],f=0;switch(i=k[e.length],c[f++]=65535&i,c[f++]=i>>16&255,c[f++]=i>>24,r){case 1===h:s=[0,h-1,0];break;case 2===h:s=[1,h-2,0];break;case 3===h:s=[2,h-3,0];break;case 4===h:s=[3,h-4,0];break;case 6>=h:s=[4,h-5,1];break;case 8>=h:s=[5,h-7,1];break;case 12>=h:s=[6,h-9,2];break;case 16>=h:s=[7,h-13,2];break;case 24>=h:s=[8,h-17,3];break;case 32>=h:s=[9,h-25,3];break;case 48>=h:s=[10,h-33,4];break;case 64>=h:s=[11,h-49,4];break;case 96>=h:s=[12,h-65,5];break;case 128>=h:s=[13,h-97,5];break;case 192>=h:s=[14,h-129,6];break;case 256>=h:s=[15,h-193,6];break;case 384>=h:s=[16,h-257,7];break;case 512>=h:s=[17,h-385,7];break;case 768>=h:s=[18,h-513,8];break;case 1024>=h:s=[19,h-769,8];break;case 1536>=h:s=[20,h-1025,9];break;case 2048>=h:s=[21,h-1537,9];break;case 3072>=h:s=[22,h-2049,10];break;case 4096>=h:s=[23,h-3073,10];break;case 6144>=h:s=[24,h-4097,11];break;case 8192>=h:s=[25,h-6145,11];break;case 12288>=h:s=[26,h-8193,12];break;case 16384>=h:s=[27,h-12289,12];break;case 24576>=h:s=[28,h-16385,13];break;case 32768>=h:s=[29,h-24577,13];break;default:t("invalid distance")}for(i=s,c[f++]=i[0],c[f++]=i[1],c[f++]=i[2],a=0,o=c.length;a<o;++a)m[b++]=c[a];A[c[0]]++,v[c[3]]++,w=e.length+n-1,d=null}var o,h,c,f,l,u,g,d,p,y={},m=s?new Uint16Array(2*i.length):[],b=0,w=0,A=new(s?Uint32Array:Array)(286),v=new(s?Uint32Array:Array)(30),E=n.w;if(!s){for(c=0;285>=c;)A[c++]=0;for(c=0;29>=c;)v[c++]=0}for(A[256]=1,o=0,h=i.length;o<h;++o){for(c=l=0,f=3;c<f&&o+c!==h;++c)l=l<<8|i[o+c];if(y[l]===e&&(y[l]=[]),u=y[l],!(0<w--)){for(;0<u.length&&32768<o-u[0];)u.shift();if(o+3>=h){for(d&&a(d,-1),c=0,f=h-o;c<f;++c)p=i[o+c],m[b++]=p,++A[p];break}0<u.length?(g=x(i,o,u),d?d.length<g.length?(p=i[o-1],m[b++]=p,++A[p],a(g,0)):a(d,-1):g.length<E?d=g:a(g,0)):d?a(d,-1):(p=i[o],m[b++]=p,++A[p])}u.push(o)}return m[b++]=256,A[256]++,n.L=A,n.K=v,s?m.subarray(0,b):m}function x(t,e,r){var n,i,s,a,o,h,c=0,f=t.length;a=0,h=r.length;t:for(;a<h;a++){if(n=r[h-a-1],s=3,3<c){for(o=c;3<o;o--)if(t[n+o-1]!==t[e+o-1])continue t;s=c}for(;258>s&&e+s<f&&t[n+s]===t[e+s];)++s;if(s>c&&(i=n,c=s),258===s)break}return new A(c,e-i)}function T(t,e){var r,n,i,a,o,h=t.length,c=new g(572),f=new(s?Uint8Array:Array)(h);if(!s)for(a=0;a<h;a++)f[a]=0;for(a=0;a<h;++a)0<t[a]&&c.push(a,t[a]);if(r=Array(c.length/2),n=new(s?Uint32Array:Array)(c.length/2),1===r.length)return f[c.pop().index]=1,f;for(a=0,o=c.length/2;a<o;++a)r[a]=c.pop(),n[a]=r[a].value;for(i=function(t,e,r){function n(t){var r=d[t][p[t]];r===e?(n(t+1),n(t+1)):--u[r],++p[t]}var i,a,o,h,c,f=new(s?Uint16Array:Array)(r),l=new(s?Uint8Array:Array)(r),u=new(s?Uint8Array:Array)(e),g=Array(r),d=Array(r),p=Array(r),y=(1<<r)-e,m=1<<r-1;for(f[r-1]=e,a=0;a<r;++a)y<m?l[a]=0:(l[a]=1,y-=m),y<<=1,f[r-2-a]=(f[r-1-a]/2|0)+e;for(f[0]=l[0],g[0]=Array(f[0]),d[0]=Array(f[0]),a=1;a<r;++a)f[a]>2*f[a-1]+l[a]&&(f[a]=2*f[a-1]+l[a]),g[a]=Array(f[a]),d[a]=Array(f[a]);for(i=0;i<e;++i)u[i]=r;for(o=0;o<f[r-1];++o)g[r-1][o]=t[o],d[r-1][o]=o;for(i=0;i<r;++i)p[i]=0;for(1===l[r-1]&&(--u[0],++p[r-1]),a=r-2;0<=a;--a){for(h=i=0,c=p[a+1],o=0;o<f[a];o++)(h=g[a+1][c]+g[a+1][c+1])>t[i]?(g[a][o]=h,d[a][o]=e,c+=2):(g[a][o]=t[i],d[a][o]=i,++i);p[a]=0,1===l[a]&&n(a)}return u}(n,n.length,e),a=0,o=r.length;a<o;++a)f[r[a].index]=i[a];return f}function U(t){var e,r,n,i,a=new(s?Uint16Array:Array)(t.length),o=[],h=[],c=0;for(e=0,r=t.length;e<r;e++)o[t[e]]=1+(0|o[t[e]]);for(e=1,r=16;e<=r;e++)h[e]=c,c+=0|o[e],c<<=1;for(e=0,r=t.length;e<r;e++)for(c=h[t[e]],h[t[e]]+=1,n=a[e]=0,i=t[e];n<i;n++)a[e]=a[e]<<1|1&c,c>>>=1;return a}function M(e,r){switch(this.l=[],this.m=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(e):e,this.s=!1,this.n=S,this.B=!1,!r&&(r={})||(r.index&&(this.c=r.index),r.bufferSize&&(this.m=r.bufferSize),r.bufferType&&(this.n=r.bufferType),r.resize&&(this.B=r.resize)),this.n){case I:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.m+258);break;case S:this.b=0,this.a=new(s?Uint8Array:Array)(this.m),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}var I=0,S=1,D={D:I,C:S};M.prototype.p=function(){for(;!this.s;){var n=$(this,3);switch(1&n&&(this.s=r),n>>>=1){case 0:var i=this.input,a=this.c,o=this.a,h=this.b,c=i.length,f=e,l=o.length,u=e;switch(this.e=this.g=0,a+1>=c&&t(Error("invalid uncompressed block header: LEN")),f=i[a++]|i[a++]<<8,a+1>=c&&t(Error("invalid uncompressed block header: NLEN")),f===~(i[a++]|i[a++]<<8)&&t(Error("invalid uncompressed block header: length verify")),a+f>i.length&&t(Error("input buffer is broken")),this.n){case I:for(;h+f>o.length;){if(f-=u=l-h,s)o.set(i.subarray(a,a+u),h),h+=u,a+=u;else for(;u--;)o[h++]=i[a++];this.b=h,o=this.f(),h=this.b}break;case S:for(;h+f>o.length;)o=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)o.set(i.subarray(a,a+f),h),h+=f,a+=f;else for(;f--;)o[h++]=i[a++];this.c=a,this.b=h,this.a=o;break;case 1:this.o(V,G);break;case 2:var g,p,y,m,b=$(this,5)+257,w=$(this,5)+1,A=$(this,4)+4,v=new(s?Uint8Array:Array)(N.length),k=e,E=e,x=e,T=e,U=e;for(U=0;U<A;++U)v[N[U]]=$(this,3);if(!s)for(U=A,A=v.length;U<A;++U)v[N[U]]=0;for(g=d(v),k=new(s?Uint8Array:Array)(b+w),U=0,m=b+w;U<m;)switch(E=J(this,g),E){case 16:for(T=3+$(this,2);T--;)k[U++]=x;break;case 17:for(T=3+$(this,3);T--;)k[U++]=0;x=0;break;case 18:for(T=11+$(this,7);T--;)k[U++]=0;x=0;break;default:x=k[U++]=E}p=d(s?k.subarray(0,b):k.slice(0,b)),y=d(s?k.subarray(b):k.slice(b)),this.o(p,y);break;default:t(Error("unknown BTYPE: "+n))}}return this.t()};var F,B,z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=s?new Uint16Array(z):z,_=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],C=s?new Uint16Array(_):_,O=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],R=s?new Uint8Array(O):O,P=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],j=s?new Uint16Array(P):P,q=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],L=s?new Uint8Array(q):q,H=new(s?Uint8Array:Array)(288);for(F=0,B=H.length;F<B;++F)H[F]=143>=F?8:255>=F?9:279>=F?7:8;var Y,W,V=d(H),Z=new(s?Uint8Array:Array)(30);for(Y=0,W=Z.length;Y<W;++Y)Z[Y]=5;var G=d(Z);function $(e,r){for(var n,i=e.g,s=e.e,a=e.input,o=e.c,h=a.length;s<r;)o>=h&&t(Error("input buffer is broken")),i|=a[o++]<<s,s+=8;return n=i&(1<<r)-1,e.g=i>>>r,e.e=s-r,e.c=o,n}function J(e,r){for(var n,i,s=e.g,a=e.e,o=e.input,h=e.c,c=o.length,f=r[0],l=r[1];a<l&&!(h>=c);)s|=o[h++]<<a,a+=8;return(i=(n=f[s&(1<<l)-1])>>>16)>a&&t(Error("invalid code length: "+i)),e.g=s>>i,e.e=a-i,e.c=h,65535&n}function K(t){if("string"==typeof t){var e,r,n=t.split("");for(e=0,r=n.length;e<r;e++)n[e]=(255&n[e].charCodeAt(0))>>>0;t=n}for(var i,s=1,a=0,o=t.length,h=0;0<o;){o-=i=1024<o?1024:o;do{a+=s+=t[h++]}while(--i);s%=65521,a%=65521}return(a<<16|s)>>>0}function X(e,r){var n,i;if(this.input=e,this.c=0,!r&&(r={})||(r.index&&(this.c=r.index),r.verify&&(this.M=r.verify)),n=e[this.c++],i=e[this.c++],(15&n)===Q)this.method=Q;else t(Error("unsupported compression method"));0!=((n<<8)+i)%31&&t(Error("invalid fcheck flag:"+((n<<8)+i)%31)),32&i&&t(Error("fdict flag is not supported")),this.A=new M(e,{index:this.c,bufferSize:r.bufferSize,bufferType:r.bufferType,resize:r.resize})}M.prototype.o=function(t,e){var r=this.a,n=this.b;this.u=t;for(var i,s,a,o,h=r.length-258;256!==(i=J(this,t));)if(256>i)n>=h&&(this.b=n,r=this.f(),n=this.b),r[n++]=i;else for(o=C[s=i-257],0<R[s]&&(o+=$(this,R[s])),i=J(this,e),a=j[i],0<L[i]&&(a+=$(this,L[i])),n>=h&&(this.b=n,r=this.f(),n=this.b);o--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},M.prototype.I=function(t,e){var r=this.a,n=this.b;this.u=t;for(var i,s,a,o,h=r.length;256!==(i=J(this,t));)if(256>i)n>=h&&(h=(r=this.f()).length),r[n++]=i;else for(o=C[s=i-257],0<R[s]&&(o+=$(this,R[s])),i=J(this,e),a=j[i],0<L[i]&&(a+=$(this,L[i])),n+o>h&&(h=(r=this.f()).length);o--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},M.prototype.f=function(){var t,e,r=new(s?Uint8Array:Array)(this.b-32768),n=this.b-32768,i=this.a;if(s)r.set(i.subarray(32768,r.length));else for(t=0,e=r.length;t<e;++t)r[t]=i[t+32768];if(this.l.push(r),this.q+=r.length,s)i.set(i.subarray(n,n+32768));else for(t=0;32768>t;++t)i[t]=i[n+t];return this.b=32768,i},M.prototype.J=function(t){var e,r,n,i=this.input.length/this.c+1|0,a=this.input,o=this.a;return t&&("number"==typeof t.v&&(i=t.v),"number"==typeof t.F&&(i+=t.F)),2>i?r=(n=(a.length-this.c)/this.u[2]/2*258|0)<o.length?o.length+n:o.length<<1:r=o.length*i,s?(e=new Uint8Array(r)).set(o):e=o,this.a=e},M.prototype.t=function(){var t,e,r,n,i,a=0,o=this.a,h=this.l,c=new(s?Uint8Array:Array)(this.q+(this.b-32768));if(0===h.length)return s?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(e=0,r=h.length;e<r;++e)for(n=0,i=(t=h[e]).length;n<i;++n)c[a++]=t[n];for(e=32768,r=this.b;e<r;++e)c[a++]=o[e];return this.l=[],this.buffer=c},M.prototype.H=function(){var t,e=this.b;return s?this.B?(t=new Uint8Array(e)).set(this.a.subarray(0,e)):t=this.a.subarray(0,e):(this.a.length>e&&(this.a.length=e),t=this.a),this.buffer=t},X.prototype.p=function(){var e,r=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&((r[this.c++]<<24|r[this.c++]<<16|r[this.c++]<<8|r[this.c++])>>>0!==K(e)&&t(Error("invalid adler-32 checksum"))),e};var Q=8;function tt(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=et.k;var r,n={};for(r in!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType),e)n[r]=e[r];n.outputBuffer=this.a,this.z=new p(this.input,n)}var et=b;function rt(t,e){var r,n,s,a;if(Object.keys)r=Object.keys(e);else for(n in r=[],s=0,e)r[s++]=n;for(s=0,a=r.length;s<a;++s)i(t+"."+(n=r[s]),e[n])}tt.prototype.j=function(){var e,r,n,i,a,o,h,c=0;if(h=this.a,(e=Q)===Q)r=Math.LOG2E*Math.log(32768)-8;else t(Error("invalid compression method"));if(n=r<<4|e,h[c++]=n,e===Q)switch(this.h){case et.NONE:a=0;break;case et.r:a=1;break;case et.k:a=2;break;default:t(Error("unsupported compression type"))}else t(Error("invalid compression method"));return i=a<<6,h[c++]=i|31-(256*n+i)%31,o=K(this.input),this.z.b=c,c=(h=this.z.j()).length,s&&((h=new Uint8Array(h.buffer)).length<=c+4&&(this.a=new Uint8Array(h.length+4),this.a.set(h),h=this.a),h=h.subarray(0,c+4)),h[c++]=o>>24&255,h[c++]=o>>16&255,h[c++]=o>>8&255,h[c++]=255&o,h},i("Zlib.Inflate",X),i("Zlib.Inflate.prototype.decompress",X.prototype.p),rt("Zlib.Inflate.BufferType",{ADAPTIVE:D.C,BLOCK:D.D}),i("Zlib.Deflate",tt),i("Zlib.Deflate.compress",(function(t,e){return new tt(t,e).j()})),i("Zlib.Deflate.prototype.compress",tt.prototype.j),rt("Zlib.Deflate.CompressionType",{NONE:et.NONE,FIXED:et.r,DYNAMIC:et.k})}.call(self);var c="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var f,l=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t};function u(t,e,r){return t[0]=e,t[1]=r,t}f=new c(3),c!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0),function(){var t=function(){var t=new c(2);return c!=Float32Array&&(t[0]=0,t[1]=0),t}()}();class g{constructor(t=257){this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(\`Expected grid size to be 2^n+1, got ${e}t}.\`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let r=t+2,n=0,i=0,s=0,a=0,o=0,h=0;for(1&r?s=a=o=e:n=i=h=e;(r>>=1)>1;){const t=n+s>>1,e=i+a>>1;1&r?(s=n,a=i,n=o,i=h):(n=s,i=a,s=o,a=h),o=t,h=e}const c=4*t;this.coords[c+0]=n,this.coords[c+1]=i,this.coords[c+2]=s,this.coords[c+3]=a}}createTile(t){return new d(t,this)}}class d{constructor(t,e){const r=e.gridSize;if(t.length!==r*r)throw new Error(\`Expected terrain data of length ${e}r*r} (${e}r} x ${e}r}), got ${e}t.length}.\`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:r,gridSize:n}=this.martini,{terrain:i,errors:s}=this;for(let a=t-1;a>=0;a--){const t=4*a,o=r[t+0],h=r[t+1],c=r[t+2],f=r[t+3],l=o+c>>1,u=h+f>>1,g=l+u-h,d=u+o-l,p=(i[h*n+o]+i[f*n+c])/2,y=u*n+l,m=Math.abs(p-i[y]);if(s[y]=Math.max(s[y],m),a<e){const t=(h+d>>1)*n+(o+g>>1),e=(f+d>>1)*n+(c+g>>1);s[y]=Math.max(s[y],s[t],s[e])}}}getMesh(t=0){const{gridSize:e,indices:r}=this.martini,{errors:n}=this;let i=0,s=0;const a=e-1;function o(a,h,c,f,l,u){const g=a+c>>1,d=h+f>>1;Math.abs(a-l)+Math.abs(h-u)>1&&n[d*e+g]>t?(o(l,u,a,h,g,d),o(c,f,l,u,g,d)):(r[h*e+a]=r[h*e+a]||++i,r[f*e+c]=r[f*e+c]||++i,r[u*e+l]=r[u*e+l]||++i,s++)}r.fill(0),o(0,0,a,a,a,0),o(a,a,0,0,0,a);const h=new Uint16Array(2*i),c=new Uint32Array(3*s);let f=0;function l(i,s,a,o,u,g){const d=i+a>>1,p=s+o>>1;if(Math.abs(i-u)+Math.abs(s-g)>1&&n[p*e+d]>t)l(u,g,i,s,d,p),l(a,o,u,g,d,p);else{const t=r[s*e+i]-1,n=r[o*e+a]-1,l=r[g*e+u]-1;h[2*t]=i,h[2*t+1]=s,h[2*n]=a,h[2*n+1]=o,h[2*l]=u,h[2*l+1]=g,c[f++]=t,c[f++]=n,c[f++]=l}}return l(0,0,a,a,a,0),l(a,a,0,0,0,a),{vertices:h,triangles:c}}getMeshWithSkirts(t=0,e){const{gridSize:r,indices:n}=this.martini,{errors:i}=this;let s=0,a=0;const o=r-1;let h,c,f=0;const l=[],u=[],g=[],d=[];function p(e,y,m,b,w,A){const v=e+m>>1,k=y+b>>1;Math.abs(e-w)+Math.abs(y-A)>1&&i[k*r+v]>t?(p(w,A,e,y,v,k),p(m,b,w,A,v,k)):(h=y*r+e,c=b*r+m,f=A*r+w,0===n[h]&&(0===e?l.push(s):e===o&&u.push(s),0===y?g.push(s):y===o&&d.push(s),n[h]=++s),0===n[c]&&(0===m?l.push(s):m===o&&u.push(s),0===b?g.push(s):b===o&&d.push(s),n[c]=++s),0===n[f]&&(0===w?l.push(s):w===o&&u.push(s),0===A?g.push(s):A===o&&d.push(s),n[f]=++s),a++)}let y;n.fill(0),p(0,0,o,o,o,0),p(o,o,0,0,0,o),y=e?2*(s+3*l.length-2+3*u.length-2+3*g.length-2+3*d.length-2):2*(s+l.length+u.length+g.length+d.length);const m=3*(a+2*(l.length-1)+2*(u.length-1)+2*(g.length-1)+2*(d.length-1)),b=new Uint16Array(y),w=new Uint32Array(m);let A=0;function v(e,s,a,o,h,c){const f=e+a>>1,l=s+o>>1;if(Math.abs(e-h)+Math.abs(s-c)>1&&i[l*r+f]>t)v(h,c,e,s,f,l),v(a,o,h,c,f,l);else{const t=n[s*r+e]-1,i=n[o*r+a]-1,f=n[c*r+h]-1;b[2*t]=e,b[2*t+1]=s,b[2*i]=a,b[2*i+1]=o,b[2*f]=h,b[2*f+1]=c,w[A++]=t,w[A++]=i,w[A++]=f}}v(0,0,o,o,o,0),v(o,o,0,0,0,o),l.sort(((t,e)=>b[2*t+1]-b[2*e+1])),u.sort(((t,e)=>b[2*e+1]-b[2*t+1])),g.sort(((t,e)=>b[2*e]-b[2*t])),d.sort(((t,e)=>b[2*t]-b[2*e]));let k,E,x,T,U=2*s,M=0;function I(t){M=t.length;for(let r=0;r<M-1;r++)k=t[r],E=t[r+1],x=U/2,T=(U+(e?6:2))/2,b[U++]=2*k,b[U++]=2*k+1,e&&(b[U++]=2*k,b[U++]=2*k+1,b[U++]=2*E,b[U++]=2*E+1),e?(w[A++]=x+1,w[A++]=x,w[A++]=x+2,w[A++]=x,w[A++]=T,w[A++]=x+2):(w[A++]=k,w[A++]=x,w[A++]=E,w[A++]=x,w[A++]=T,w[A++]=E);b[U++]=2*t[M-1],b[U++]=2*t[M-1]+1}I(l);const S=U;I(u);const D=U;I(g);const F=U;I(d);return{vertices:b,triangles:w,numVerticesWithoutSkirts:s,numTrianglesWithoutSkirts:a,leftSkirtIndex:S,rightSkirtIndex:D,bottomSkirtIndex:F,topSkirtIndex:U}}}const p={};let y;const m={width:100,height:10};let b=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),b=!0}catch(t){b=!1}function w(){if(!y){const{width:t,height:e}=m;b?y=new OffscreenCanvas(t,e):(y=document.createElement("canvas"),y.width=t,y.height=e)}return y}class A{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let r=1/0,n=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];r=Math.min(i,r),n=Math.max(i,n)}this.min=r,this.max=n,this.valueOffset=this.max-this.min,this.options=Object.assign({},m,e),this._initImgData()}getImageData(){return this.imgData}_initImgData(){const t=w(),{width:e,height:r}=this.options;t.width=e,t.height=r;const n=t.getContext("2d");n.clearRect(0,0,t.width,t.height);const i=n.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:a}=this;for(let t=0,e=s.length;t<e;t++){const[e,r]=s[t],n=(e-this.min)/a;i.addColorStop(n,r)}n.fillStyle=i,n.fillRect(0,0,t.width,t.height),this.imgData=n.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let r=Math.round(e*this.imgData.width);r=Math.min(r,this.imgData.width-1);const n=4*r;return[this.imgData.data[n],this.imgData.data[n+1],this.imgData.data[n+2],this.imgData.data[n+3]]}}var v="undefined"!=typeof Float32Array?Float32Array:Array;function k(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function E(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function x(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function T(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}var U=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t};
36572
+ /*!
36573
+ * Contains code from THREE.JS
36574
+ * https://github.com/mrdoob/three.js/
36575
+ * License MIT
36576
+ *
36577
+ * Generate tangents per vertex.
36578
+ */
36579
+ function M(t,e,r,n,i){const s=t.length/3,a=new Array(4*s),o=[],h=[];for(let t=0;t<s;t++)o[t]=[0,0,0],h[t]=[0,0,0];const c=[0,0,0],f=[0,0,0],l=[0,0,0],u=[0,0],g=[0,0],d=[0,0],p=[0,0,0],y=[0,0,0];function m(e,n,i){I(c,t,3*e),I(f,t,3*n),I(l,t,3*i),S(u,r,2*e),S(g,r,2*n),S(d,r,2*i);const s=f[0]-c[0],a=l[0]-c[0],m=f[1]-c[1],b=l[1]-c[1],w=f[2]-c[2],A=l[2]-c[2],v=g[0]-u[0],k=d[0]-u[0],T=g[1]-u[1],U=d[1]-u[1],M=1/(v*U-k*T);E(p,(U*s-T*a)*M,(U*m-T*b)*M,(U*w-T*A)*M),E(y,(v*a-k*s)*M,(v*b-k*m)*M,(v*A-k*w)*M),x(o[e],o[e],p),x(o[n],o[n],p),x(o[i],o[i],p),x(h[e],h[e],y),x(h[n],h[n],y),x(h[i],h[i],y)}for(let t=0,e=n.length;t<e;t+=3)m(n[t+0],n[t+1],n[t+2]);const b=[],w=[],A=[],v=[];let M,D,F;function B(t){I(A,e,3*t),k(v,A),D=o[t],k(b,D),U(b,b,function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}(A,A,T(A,D))),function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s)}(b,b),function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],h=r[2];t[0]=i*h-s*o,t[1]=s*a-n*h,t[2]=n*o-i*a}(w,v,D),F=T(w,h[t]),M=F<0?-1:1,a[4*t]=b[0],a[4*t+1]=b[1],a[4*t+2]=b[2],a[4*t+3]=M}for(let t=0,e=n.length;t<e;t+=3)B(n[t+0]),B(n[t+1]),B(n[t+2]);return a}function I(t,e,r){return t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2],t}function S(t,e,r){return t[0]=e[r],t[1]=e[r+1],t}function D(t){return"number"==typeof t&&!isNaN(t)}let F;!function(){var t=function(){var t=new v(3);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();let B=null,z=null;const N=[0,0,0],_=[256,256];function C(){try{B||(B=new OffscreenCanvas(1,1))}catch(t){console.error(t)}}const O={},R={},P={width:64,height:64,elementsPerHeight:3,heightOffset:-1e3,exaggeration:1,heightScale:.001,elementMultiplier:256,stride:4,skirtHeight:.002,skirtOffset:.01},j={cesium_request_token:{Accept:"application/json,*/*;q=0.01","Accept-Encoding":"gzip, deflate, br"},tianditu:{"Accept-Encoding":"gzip, deflate, br"},cesium:{"Accept-Encoding":"gzip, deflate, br",Accept:"application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01"},mapbox:{Accept:"image/webp,*/*"}};j["cesium-ion"]=j.cesium;const q=32767;let L=null,H=null;function Y(t,e){const r=function(t){if(t.length<1e3)return null;const e=new Zlib.Inflate(t);return e?e.decompress():null}(new Uint8Array(t));if(!r)throw new Error((n=new Uint8Array(t),W.decode(n)));var n;const i=function(t){const e=t,r=P.width,n=P.height,i=new Uint8Array(r*n*P.stride);let s,a,o,h,c;for(let t=0;t<n;t++)for(let f=0;f<r;f++){h=parseInt(149*t/(n-1)),c=parseInt(149*f/(r-1)),a=2*(150*h+c),s=e[a]+256*e[a+1],(s>1e4||s<-2e3)&&(s=0),o=4*(t*r+f);const l=(s+1e3)/P.heightScale,u=P.elementMultiplier;i[o]=l/(u*u),i[o+1]=(l-i[o]*u*u)/u,i[o+2]=l-i[o]*u*u-i[o+1]*u,i[o+3]=255}return i}(r),s=function(t,e){const r=e,n=e,i=r+1,s=n+1,a=P.elementsPerHeight,o=P.heightOffset,h=P.heightScale,c=P.elementMultiplier,f=P.skirtHeight,l=new Float32Array(i*s);let u=0,g=1/0,d=-1/0;for(let e=0;e<i;e++){const i=e>=n?n-1:e;for(let e=0;e<s;e++){let n=0;const s=i*(4*r)+4*(e>=r?r-1:e);for(let e=0;e<a;e++)n=n*c+t[s+e];n=1*(n*h+o),n-=f,l[u]=n,n<g&&(g=n),n>d&&(d=n),u++}}return{data:l,min:g,max:d}}(i,e-1);return s.width=s.height=e,s}const W=new TextDecoder("utf-8");function V(t){return t>>1^-(1&t)}const Z=[];function G(t){let e=0;const r=3*Float64Array.BYTES_PER_ELEMENT,n=3*Uint16Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT;const s=new DataView(t);e+=r;const a=s.getFloat32(e,!0);e+=Float32Array.BYTES_PER_ELEMENT;const o=s.getFloat32(e,!0);e+=Float32Array.BYTES_PER_ELEMENT,e+=r;const h=s.getFloat64(e,!0);e+=Float64Array.BYTES_PER_ELEMENT,e+=r;const c=s.getUint32(e,!0);e+=Uint32Array.BYTES_PER_ELEMENT;const f=new Uint16Array(t,e,3*c);e+=c*n,c>65536&&(i=Uint32Array.BYTES_PER_ELEMENT);!function(t,e,r){const n=t.length;let i=0,s=0,a=0;for(let o=0;o<n;++o)i+=V(t[o]),s+=V(e[o]),t[o]=i,e[o]=s,r&&(a+=V(r[o]),r[o]=a)}(f.subarray(0,c),f.subarray(c,2*c),f.subarray(2*c,3*c)),e%i!=0&&(e+=i-e%i);const l=s.getUint32(e,!0);e+=Uint32Array.BYTES_PER_ELEMENT;const u=c>65536?new Uint32Array(t,e,3*l):new Uint16Array(t,e,3*l);let g=0;const d=u.length;for(let t=0;t<d;++t){const e=u[t];u[t]=g-e,0===e&&++g}const p={minimumHeight:a,maximumHeight:o,quantizedVertices:f,indices:u}.quantizedVertices,y=p.length/3,m=p.subarray(0,y),b=p.subarray(y,2*y),w=p.subarray(2*y,3*y),A=Z;for(let t=0;t<y;++t){const e=m[t],r=b[t],n=e/q,i=r/q,s=(v=a,k=o,(1-(E=w[t]/q))*v+E*k);A[3*t]=n,A[3*t+1]=1-i,A[3*t+2]=s}var v,k,E;return{positions:A,radius:h,min:a,max:o,indices:u}}const $=[],J=[],K=[],X=[],Q=[];class tt{constructor(t,e,r,n,i){this.p0=[],this.p1=[],this.p2=[],this.normal=[],this.min=[],this.max=[],this.set(t,e,r,n,i)}set(t,e,r,n,i){this.radius=i;let s=3*e,a=3*e+1,o=3*e+2;this.p0[0]=t[s]*i,this.p0[1]=t[a]*i,this.p0[2]=t[o],s=3*r,a=3*r+1,o=3*r+2,this.p1[0]=t[s]*i,this.p1[1]=t[a]*i,this.p1[2]=t[o],s=3*n,a=3*n+1,o=3*n+2,this.p2[0]=t[s]*i,this.p2[1]=t[a]*i,this.p2[2]=t[o],this.min[0]=Math.min(this.p0[0],this.p1[0],this.p2[0]),this.min[1]=Math.min(this.p0[1],this.p1[1],this.p2[1]),this.max[0]=Math.max(this.p0[0],this.p1[0],this.p2[0]),this.max[1]=Math.max(this.p0[1],this.p1[1],this.p2[1]);const h=l($,this.p1,this.p0),c=l(J,this.p2,this.p1);this.normal=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}(this.normal,function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],h=r[2];return t[0]=i*h-s*o,t[1]=s*a-n*h,t[2]=n*o-i*a,t}(this.normal,h,c))}contains(t,e){if(t<this.min[0]||t>this.max[0]||e<this.min[1]||e>this.max[1])return!1;u(K,this.p0[0],this.p0[1]),u(X,this.p1[0],this.p1[1]),u(Q,this.p2[0],this.p2[1]);const r=it(K[0],K[1],X[0],X[1],Q[0],Q[1]);return it(t,e,K[0],K[1],Q[0],Q[1])+it(t,e,K[0],K[1],X[0],X[1])+it(t,e,X[0],X[1],Q[0],Q[1])-r<=1e-4}getHeight(t,e){const r=this.normal;return this.p0[2]-((t-this.p0[0])*r[0]+(e-this.p0[1])*r[1])/r[2]}}let et=null;function rt(t,e,r){if(et&&et.contains(e,r))return et.getHeight(e,r);for(let n=0;n<t.length;n++)if(t[n].contains(e,r))return et=t[n],t[n].getHeight(e,r);return 0}const nt=[];function it(t,e,r,n,i,s){return.5*Math.abs(t*n+r*s+i*e-t*s-r*e-i*n)}function st(t,e,r,n,i,s){"cesium-ion"===r&&(e.Authorization="Bearer "+L),function(t,e,r){const n={method:"GET",referrer:r,headers:e},i=h.getArrayBuffer(t,n),s=i.xhr;return R[t]=s,i.then((e=>(delete R[t],e)))}(t,e,origin).then((t=>{if(!t||t.message)s(t?{empty:!0,originalError:t}:{error:{canceled:!0}});else{const e=t.data;let a=null;if("tianditu"===r){const t=Y(e,n);ot(i,t,n,null,!0,s)}else if("cesium-ion"===r||"cesium"===r){a=G(e);const t=function(t,e){const{positions:r,min:n,max:i,indices:s,radius:a}=t,o=[];let h=0;for(let t=0;t<s.length;t+=3){let e=nt[h];e?e.set(r,s[t],s[t+1],s[t+2],2*a):e=nt[h]=new tt(r,s[t],s[t+1],s[t+2],2*a),h++,o.push(e)}const c=new Float32Array(e*e);h=0;for(let t=0;t<e;t++)for(let r=0;r<e;r++)c[h++]=rt(o,r/e*a*2,t/e*a*2);return{data:c,min:n,max:i,width:e,height:e}}(a,n);ot(i,t,n,null,!0,s)}else"mapbox"===r&&(a=function(t){const e=new self.Blob([new Uint8Array(t)]);return self.createImageBitmap(e)}(e),a.then((t=>{const e=ct(ht(t),n);ot(i,e,n,t,!0,s)})))}})).catch((e=>{delete R[t],s({empty:!0,originalError:e})}))}function at(t,e){const r=Math.floor(10*(t+1e4)),n=r>>16,i=r>>8&255,s=255&r;return e?(e[0]=n,e[1]=i,e[2]=s,e):[n,i,s]}function ot(t,e,r,n,i,s){const a=function(t,e,r){let n=p[r];n||(n=p[r]=new g(r));const i=n.createTile(e).getMeshWithSkirts(t,!0),{triangles:s,vertices:a,leftSkirtIndex:o,rightSkirtIndex:h,bottomSkirtIndex:c,topSkirtIndex:f}=i;let{numVerticesWithoutSkirts:l,numTrianglesWithoutSkirts:u}=i;l||(l=a.length/2,u=s.length/3);const d=a.length/2,y=new Float32Array(3*d),m=new Float32Array(2*d);let b=1/0,w=-1/0;const A=r-1;for(let t=0;t<d;t++){const n=a[2*t],i=a[2*t+1];if(t>=l){const e=n/2*3;let r,i=.001;(t-(t<o/2?l:t<h/2?o/2:t<c/2?h/2:c/2))%3==0?(r=Math.min(0,b),i=0):r=y[e+2],y[3*t]=y[e],y[3*t+1]=y[e+1],y[3*t+2]=r,m[2*t]=y[e]/A+i,m[2*t+1]=-y[e+1]/A+i}else{const s=e[i*r+n];y[3*t]=1*n,y[3*t+1]=1*-i,y[3*t+2]=s,m[2*t]=n/A,m[2*t+1]=i/A,s<b&&(b=s),s>w&&(w=s)}}return{positions:y,texcoords:m,triangles:s,leftSkirtIndex:o,rightSkirtIndex:h,bottomSkirtIndex:c,topSkirtIndex:f,numTrianglesWithoutSkirts:u,numVerticesWithoutSkirts:l,minHeight:Math.min(0,b),maxHeight:w,terrainWidth:r}}(t/6,e.data,r),o=[a.positions.buffer,a.texcoords.buffer,a.triangles.buffer];n||(n=function(t){if(C(),!B)return;const{width:e,height:r,data:n}=t;if(e&&r&&n)try{let t=B.getContext("2d",{willReadFrequently:!0});const i=t.createImageData(e,r);for(let t=0,e=n.length;t<e;t++){const e=n[t],[r,s,a]=at(e,N),o=4*t;i.data[o]=r,i.data[o+1]=s,i.data[o+2]=a,i.data[o+3]=255}return B.width=e,B.height=r,t=B.getContext("2d",{willReadFrequently:!0}),ft(t),t.putImageData(i,0,0),B.transferToImageBitmap()}catch(t){console.log(t)}}(e)),n&&o.push(n);const h={mesh:a};h.image=n,h.data=e,o.push(e.data.buffer),s(h,o)}function ht(t){const{width:e,height:r}=t;return B||(B=new OffscreenCanvas(1,1),z=B.getContext("2d",{willReadFrequently:!0})),B.width=e,B.height=r,z.drawImage(t,0,0,e,r),z.getImageData(0,0,e,r)}function ct(t,e){const{data:r,width:n}=t;let i=1/0,s=-1/0;const a=new Float32Array(e*e),o=Math.round(n/e);for(let t=0;t<e;t++)for(let h=0;h<e;h++){const c=t+h*e;let f=0,l=0;const u=t,g=h;for(let t=0;t<o;t++)for(let e=0;e<o;e++){let i=u*o+t,s=g*o+e;s>n-1&&(s=n-1),i>n-1&&(i=n-1);const a=i+s*n,h=r[4*a],c=r[4*a+1],d=r[4*a+2];0===r[4*a+3]?l+=1:f+=.1*(256*h*256+256*c+d)-1e4}f/=o*o-l||1,f>s&&(s=f),f<i&&(i=f),a[c]=f}return{data:a,width:e,height:e,min:i,max:s}}function ft(t){const e=t.canvas,{width:r,height:n}=e;t.clearRect(0,0,r,n)}function lt(t,e,r){if(!e||!Array.isArray(e)||e.length<2)return;if(!t||!t.image)return null;let{width:n,height:i}=t.image;(r=r||_)[0]===n&&r[1]===i||(n=r[0],i=r[1]),[n,i]=_;try{if(C(),!B)return;const r=B;r.width=n,r.height=i;const s=r.getContext("2d",{willReadFrequently:!0});ft(s),s.drawImage(t.image,0,0,n,i);const a=s.getImageData(0,0,n,i);!function(t,e){const r=JSON.stringify(e);O[r]||(O[r]=new A(e));const n=O[r],i=t.data;for(let t=0,e=i.length;t<e;t+=4){const e=i[t],r=i[t+1],s=i[t+2];let a=0;0!==i[t+3]&&(a=.1*(256*e*256+256*r+s)-1e4,a=Math.max(a,0));const[o,h,c]=n.getColor(a);i[t]=o,i[t+1]=h,i[t+2]=c,i[t+3]=255}}(a,e),s.putImageData(a,0,0);const o=r.transferToImageBitmap();s.save(),s.scale(1,-1),s.drawImage(o,0,-i,n,i),s.restore();const h=r.transferToImageBitmap();return o.close(),h}catch(t){console.error(t)}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;if("addLayer"===r.command||"removeLayer"===r.command)F=t.workerId,self.postMessage({type:"<response>",actorId:r.actorId,workerId:F,params:"ok",callback:t.callback});else if("fetchTerrain"===r.command){const t=(r.params||{}).colors,n=(r.params||{}).tileSize;!function(t,e){const{url:r,origin:n,type:i,accessToken:s,terrainWidth:a,error:o,tileImage:h}=t;if(h&&h.close){const t=ct(ht(h),a);return void ot(o,t,a,h,0,e)}const c=t.headers||j[i];if("tianditu"===i)st(r,c,i,a,o,e);else if("cesium-ion"===i){const h=t.cesiumIonTokenURL+s;L?st(r,c,i,a,o,e):(H||(H=fetch(h,{responseType:"json",method:"GET",referrer:n,headers:{Accept:"application/json,*/*;q=0.01","Accept-Encoding":"gzip, deflate, br"}}).then((t=>t.json())).then((t=>{L=t.accessToken,H=null}))),H.then((()=>{st(r,c,i,a,o,e)})))}else("cesium"===i||"mapbox"===i)&&st(r,c,i,a,o,e)}(r.params,((r,i)=>{i=i||[];const s=lt(r,t,n);s&&(r.colorsTexture=s,i.push(s));const a=function(t){if(!t)return;const{positions:e,texcoords:r,triangles:n,leftSkirtIndex:i,rightSkirtIndex:s,bottomSkirtIndex:a,numVerticesWithoutSkirts:o}=t;if(!e||!r||!n)return;if(!(D(i)&&D(s)&&D(a)&&D(o)))return;const h=new Int8Array(e.length);for(let t=2;t<h.length;t+=3)t<3*o?h[t]=1:t<i/2*3?h[t-2]=-1:t<s/2*3?h[t-2]=1:h[t-1]=t<a/2*3?-1:1;const c=M(e,h,r,n);return new Float32Array(c)}(r.mesh);a&&r.mesh&&(r.mesh.tangents=a,i.push(a.buffer)),e(r.error,r,i)}))}else"abortTerrain"===r.command&&(n=r.params.url,R[n]&&(R[n].abort(),delete R[n]));var n}}`;
36549
36580
 
36550
36581
  // transcoders必须要在reshader.gl之前import,否则reshader.gl无法识别到GLTFLoader
36551
36582
  registerGLTFLoaderBundle(gltfLoaderExport);
@@ -36560,8 +36591,8 @@ var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t
36560
36591
  exports.ColorMask = Bf;
36561
36592
  exports.ContextUtil = ch;
36562
36593
  exports.Distance3DTool = Jf;
36563
- exports.ElevateMask = Vf;
36564
- exports.FlatInsideMask = Ff;
36594
+ exports.ElevateMask = Gf;
36595
+ exports.FlatInsideMask = Df;
36565
36596
  exports.FlatOutsideMask = Uf;
36566
36597
  exports.GLContext = WebGL2RenderingContext$1;
36567
36598
  exports.GroundPainter = ql;
@@ -36569,7 +36600,7 @@ var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t
36569
36600
  exports.HeatmapProcess = Rf;
36570
36601
  exports.Height3DTool = td;
36571
36602
  exports.HighlightUtil = df;
36572
- exports.ImageMask = Gf;
36603
+ exports.ImageMask = Vf;
36573
36604
  exports.MapGLRenderer = tf;
36574
36605
  exports.MapGPURenderer = sf;
36575
36606
  exports.MaskLayerMixin = au;
@@ -36579,7 +36610,7 @@ var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t
36579
36610
  exports.VideoMask = zf;
36580
36611
  exports.color = cl;
36581
36612
  exports.createREGL = S;
36582
- exports.earcut = ce;
36613
+ exports.earcut = le;
36583
36614
  exports.mat2 = p;
36584
36615
  exports.mat2d = _;
36585
36616
  exports.mat3 = f;
@@ -36592,7 +36623,7 @@ var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t
36592
36623
  exports.vec3 = h$1;
36593
36624
  exports.vec4 = u$1;
36594
36625
 
36595
- typeof console !== 'undefined' && console.log('@maptalks/gpu v0.116.0');
36626
+ typeof console !== 'undefined' && console.log('@maptalks/gpu v0.117.0');
36596
36627
 
36597
36628
  }));
36598
36629
  //# sourceMappingURL=maptalksgpu.js.map