@maptalks/gpu 0.120.0 → 0.122.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.120.0
2
+ * @maptalks/gpu v0.122.0
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2026 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.120.0
85
+ * @maptalks/gltf-loader v0.122.0
86
86
  * LICENSE : UNLICENSED
87
87
  * (c) 2016-2026 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;}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({});
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}([]),v=[1,1,1];function q(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 B="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function P(e,t,s){const r=new Uint8Array(e,t,s);return B.decode(r)}const N={get:function(e,t={},s){t||(t={}),t=y({},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",N.get(e,t,s)),getJSON:function(e,t={},s){return t&&t.jsonp?N.jsonp(e):((t=t||{}).responseType="json",N.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]=N.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]=N.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=q(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=P(n,i+(t.byteOffset||0),s);return e.content=a,e}))}if(e.uri){if(w(e.uri)){const t=T(e.uri),s=P(t,0,t.byteLength);return e.content=s,Promise.resolve(e)}{const t=this.rootPath+"/"+e.uri;return N.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||v);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],j=[0,0,0],H=[0,0,0,1],z=[1,1,1],G={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},W={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(j,n)):"rotation"===t.target.path?(this._getQuaternion(i,c.samplers[t.sampler],r,1),h.rotation=m(H,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(W,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(W,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(W,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(W,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(W,t,s,1);r&&(e=h(e,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this._getPreNext(W,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(j,...G.TRANSLATION),h(H,...G.ROTATION),o(z,...G.SCALE),this._getTRSW(r,e,t,s,j,H,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}},J="EXT_mesh_gpu_instancing",$="EXT_structural_metadata";let Q=!1;if("undefined"!=typeof OffscreenCanvas){let e;try{e=new OffscreenCanvas(2,2).getContext("2d");}catch(s){}e&&"undefined"!=typeof createImageBitmap&&(Q=!0);}const Z="undefined"==typeof document?null:document.createElement("canvas");function ee(e,t,s){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Z)return void s(new Error("There is no canvas to draw image!"));Z.width=r.width,Z.height=r.height;const e=Z.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 te=[],se=[],re=30;let ne,ie;function ae(e,t,s){ne||(ne=new OffscreenCanvas(2,2),ie=ne.getContext("2d",{willReadFrequently:!0}));let r=null;if(_(e))this.options.urlModifier&&(e=this.options.urlModifier(e)),te.push([e,t,s,this]),oe();else {const t=new Blob([e]);r=createImageBitmap(t),r.then(fe.bind(this)).then((e=>{s(null,e);})).catch((e=>{console.warn(e),s(e);}));}}function oe(){if(!te.length||se.length>re)return;const e=te.shift(),[t,s,r,n]=e;se.push(e),fetch(t,s).then((e=>e.arrayBuffer())).then((e=>{const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)})).then(fe.bind(n)).then((t=>{r.call(n,null,t);const s=se.indexOf(e);se.splice(s,1),oe();})).catch((t=>{console.warn(t),r.call(n,t);const s=se.indexOf(e);se.splice(s,1),oe();}));}function fe(e){let{width:t,height:s}=e;ue(t)||(t=he(t)),ue(s)||(s=he(s));const r=this.options.maxTextureSize;r&&(t=Math.min(r,t),s=Math.min(r,s)),ne.width=t,ne.height=s,ie.drawImage(e,0,0,t,s),e.close();const n=ie.getImageData(0,0,t,s);return {width:t,height:s,data:new Uint8Array(n.data)}}function ue(e){return !(e&e-1)&&0!==e}function he(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function ce(e,t){for(const s in e)if(e[s]===t)return s;return t}e.Ajax=N,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=ce(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(),i=this._loadStructuralMetadata();return Promise.all([t,s,r,n,i]).then((e=>(e[0].animations=e[1],e[0].textures=e[2],e[0].extensions=e[3],e[0].transferables=this.transferables||[],e[0].structuralMetadata=e[4],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 q(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=Q?ae.bind(this):this.options.requestImage||ee,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={},t=[];return this.adapter.iterate(((s,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);e[s]=n;const i=function(e){return e?.extensions?.[J]}(r);if(i){const e=this._loadGpuInstancingData(i).then((e=>{n.extensions||(n.extensions={}),n.extensions[J]=e;}));t.push(e);}}),"nodes"),Promise.all(t).then((()=>e))}))}_loadGpuInstancingData(e){const t=function(e){return e?.attributes?Object.entries(e.attributes).map((([e,t])=>({name:e,accessorIndex:t}))):[]}(e);if(0===t.length)return Promise.resolve({attributes:{}});const s=t.map((({name:e,accessorIndex:t})=>this.adapter.accessor._requestData(e,t).then((t=>(t&&t.array&&t.array.buffer&&this.transferables&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),{name:e,data:t})))));return Promise.all(s).then((e=>{const t={};return e.forEach((({name:e,data:s})=>{t[e]=s;})),{attributes:t}}))}_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),e.extensions&&(i.extensions=e.extensions),i}))}_loadStructuralMetadata(){const e=this.gltf.extensionsUsed||[],t=e.includes("EXT_mesh_features"),s=e.includes($);if(!t&&!s)return Promise.resolve();const r=[];if(s){const e=this.gltf.extensions?.[$];e?.propertyTables&&r.push(this._loadPropertyTableBuffers(e.propertyTables));}return Promise.all(r).then((e=>{const t=e[0]||[];if(s)return async function(e,t,s,r,n){const i=e?.extensions?.[$];if(!i)return null;if(i.schemaUri){let e=i.schemaUri;return e.includes("://")||e.startsWith("blob:")||(e=s+e),{schema:await N.getJSON(e,r,n),propertyTables:i.propertyTables||[],buffers:t}}return {schema:i.schema,propertyTables:i.propertyTables||[],buffers:t}}(this.gltf,t,this.rootPath,this._fetchOptions,this.options.urlModifier).then((e=>(e&&t.forEach((e=>{e&&this.transferables.indexOf(e)<0&&this.transferables.push(e);})),e)))}))}_loadPropertyTableBuffers(e){const t=this.gltf.bufferViews||[],s=function(e){const t=new Set;if(!e)return t;for(const s of e){const e=s.properties;if(e)for(const s of Object.values(e))void 0!==s.values&&t.add(s.values),void 0!==s.arrayOffsets&&t.add(s.arrayOffsets),void 0!==s.stringOffsets&&t.add(s.stringOffsets);}return t}(e),r=new Array(t.length).fill(null),n=[];return s.forEach((e=>{const s=t[e];if(!s)return;const i=this._accessor._requestBufferOfBufferView(s).then((t=>{const{buffer:n,byteOffset:i}=t,a=(s.byteOffset||0)+i;r[e]=n.slice(a,a+s.byteLength);}));n.push(i);})),Promise.all(n).then((()=>r))}},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
 
@@ -8922,7 +8922,7 @@
8922
8922
  var t = /*@__PURE__*/getDefaultExportFromCjs(fastDeepEqual);
8923
8923
 
8924
8924
  /*!
8925
- * @maptalks/fusiongl v0.120.0
8925
+ * @maptalks/fusiongl v0.122.0
8926
8926
  * LICENSE : UNLICENSED
8927
8927
  * (c) 2016-2026 maptalks.com
8928
8928
  */
@@ -8955,11 +8955,11 @@
8955
8955
  return !C(e) && ("function" == typeof e || null !== e.constructor && e.constructor === Function);
8956
8956
  }
8957
8957
 
8958
- function I(e, ...t) {
8958
+ function E(e, ...t) {
8959
8959
  return Object.assign(e, ...t), e;
8960
8960
  }
8961
8961
 
8962
- function E(e, ...t) {
8962
+ function I(e, ...t) {
8963
8963
  for (let n = 0; n < t.length; n++) {
8964
8964
  const r = t[n];
8965
8965
  for (const t in r) void 0 !== r[t] && null !== r[t] && (e[t] = r[t]);
@@ -8987,13 +8987,13 @@
8987
8987
  return Math.min(n, Math.max(t, e));
8988
8988
  }
8989
8989
 
8990
- function N(e) {
8990
+ function F(e) {
8991
8991
  return void 0 === e.supportVAO && (e.supportVAO = function(e) {
8992
8992
  return !globalThis.MAPTALKS_DISABLE_VAO && !e.wgpu && e && e.hasExtension && e.hasExtension("oes_vertex_array_object");
8993
8993
  }(e)), e.supportVAO;
8994
8994
  }
8995
8995
 
8996
- function F(e, t) {
8996
+ function N(e, t) {
8997
8997
  return Object.prototype.hasOwnProperty.call(e, t);
8998
8998
  }
8999
8999
 
@@ -9013,14 +9013,14 @@
9013
9013
  }
9014
9014
 
9015
9015
  function U(e) {
9016
- return e.width * e.height * z(e.format) * G(e.type) * ("textureCube" === e._reglType ? 6 : 1);
9016
+ return e.width * e.height * G(e.format) * z(e.type) * ("textureCube" === e._reglType ? 6 : 1);
9017
9017
  }
9018
9018
 
9019
- function G(e) {
9019
+ function z(e) {
9020
9020
  return "uint8" === e ? 1 : "uint16" === e || "float16" === e || "half float" === e ? 2 : "uint32" === e || "float" === e || "float32" === e ? 4 : 0;
9021
9021
  }
9022
9022
 
9023
- function z(e) {
9023
+ function G(e) {
9024
9024
  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;
9025
9025
  }
9026
9026
 
@@ -9092,15 +9092,15 @@
9092
9092
  }
9093
9093
 
9094
9094
  function Z(e) {
9095
- return e && !(e instanceof GPUBuffer) && (e.dispose || e.destroy);
9095
+ return e && !e.mapAsync && (e.dispose || e.destroy);
9096
9096
  }
9097
9097
 
9098
9098
  var J = Object.freeze({
9099
9099
  __proto__: null,
9100
9100
  clamp: D,
9101
9101
  defined: O,
9102
- extend: I,
9103
- extendWithoutNil: E,
9102
+ extend: E,
9103
+ extendWithoutNil: I,
9104
9104
  getArrayCtor: H,
9105
9105
  getBufferSize: B,
9106
9106
  getPosArrayType: function(e) {
@@ -9108,9 +9108,9 @@
9108
9108
  },
9109
9109
  getSupportedFormats: W,
9110
9110
  getTexMemorySize: U,
9111
- getTextureByteWidth: G,
9112
- getTextureChannels: z,
9113
- hasOwn: F,
9111
+ getTextureByteWidth: z,
9112
+ getTextureChannels: G,
9113
+ hasOwn: N,
9114
9114
  hashCode: q,
9115
9115
  interpolate: R,
9116
9116
  isArray: L,
@@ -9121,7 +9121,7 @@
9121
9121
  isNumber: P,
9122
9122
  isPowerOfTwo: $,
9123
9123
  isString: A,
9124
- isSupportVAO: N,
9124
+ isSupportVAO: F,
9125
9125
  isTextureDestroyed: function(e) {
9126
9126
  return e.device ? !e.texture : !e._texture || !e._texture.texture;
9127
9127
  },
@@ -9196,7 +9196,7 @@
9196
9196
  constructor(e, t) {
9197
9197
  if (super(), k(e)) {
9198
9198
  this._texture = e, e = this.config = {};
9199
- for (const t in this._texture) F(this._texture, t) && (k(this._texture[t]) || (e[t] = this._texture[t]));
9199
+ for (const t in this._texture) N(this._texture, t) && (k(this._texture[t]) || (e[t] = this._texture[t]));
9200
9200
  } else if (this.config = e || {}, this.resLoader = t, (e.url || e.promise) && !e.data) {
9201
9201
  this._loading = !0;
9202
9202
  const n = this;
@@ -9238,7 +9238,7 @@
9238
9238
  getMemorySize() {
9239
9239
  if (!this.config) return 0;
9240
9240
  const {width: e, height: t, type: n, format: r} = this.config;
9241
- return e * t * G(n || "uint8") * z(r || "rgba");
9241
+ return e * t * z(n || "uint8") * G(r || "rgba");
9242
9242
  }
9243
9243
  _update() {
9244
9244
  throw new Error(te);
@@ -9457,7 +9457,7 @@
9457
9457
  let n = e;
9458
9458
  do {
9459
9459
  const r = n.prev, i = n.next.next;
9460
- !Ae(r, i) && Ce(r, n, n.next, i) && Ie(r, i) && Ie(i, r) && (t.push(r.i, n.i, i.i),
9460
+ !Ae(r, i) && Ce(r, n, n.next, i) && Ee(r, i) && Ee(i, r) && (t.push(r.i, n.i, i.i),
9461
9461
  Re(n), Re(n.next), n = e = i), n = n.next;
9462
9462
  } while (n !== e);
9463
9463
  return fe(n);
@@ -9469,7 +9469,7 @@
9469
9469
  let e = s.next.next;
9470
9470
  for (;e !== s.prev; ) {
9471
9471
  if (s.i !== e.i && we(s, e)) {
9472
- let a = Ee(s, e);
9472
+ let a = Ie(s, e);
9473
9473
  return s = fe(s, s.next), a = fe(a, a.next), he(s, t, n, r, i, o, 0), void he(a, t, n, r, i, o, 0);
9474
9474
  }
9475
9475
  e = e.next;
@@ -9507,7 +9507,7 @@
9507
9507
  do {
9508
9508
  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)) {
9509
9509
  const t = Math.abs(i - n.y) / (r - n.x);
9510
- Ie(n, e) && (t < u || t === u && (n.x > o.x || n.x === o.x && xe(o, n))) && (o = n,
9510
+ Ee(n, e) && (t < u || t === u && (n.x > o.x || n.x === o.x && xe(o, n))) && (o = n,
9511
9511
  u = t);
9512
9512
  }
9513
9513
  n = n.next;
@@ -9515,7 +9515,7 @@
9515
9515
  return o;
9516
9516
  }(e, t);
9517
9517
  if (!n) return t;
9518
- const r = Ee(n, e);
9518
+ const r = Ie(n, e);
9519
9519
  return fe(r, r.next), fe(n, n.next);
9520
9520
  }
9521
9521
 
@@ -9551,7 +9551,7 @@
9551
9551
  n = n.next;
9552
9552
  } while (n !== e);
9553
9553
  return !1;
9554
- }(e, t) && (Ie(e, t) && Ie(t, e) && function(e, t) {
9554
+ }(e, t) && (Ee(e, t) && Ee(t, e) && function(e, t) {
9555
9555
  let n = e, r = !1;
9556
9556
  const i = (e.x + t.x) / 2, o = (e.y + t.y) / 2;
9557
9557
  do {
@@ -9583,11 +9583,11 @@
9583
9583
  return e > 0 ? 1 : e < 0 ? -1 : 0;
9584
9584
  }
9585
9585
 
9586
- function Ie(e, t) {
9586
+ function Ee(e, t) {
9587
9587
  return Me(e.prev, e, e.next) < 0 ? Me(e, t, e.next) >= 0 && Me(e, e.prev, t) >= 0 : Me(e, t, e.prev) < 0 || Me(e, e.next, t) < 0;
9588
9588
  }
9589
9589
 
9590
- function Ee(e, t) {
9590
+ function Ie(e, t) {
9591
9591
  const n = Le(e.i, e.x, e.y), r = Le(t.i, t.x, t.y), i = e.next, o = t.prev;
9592
9592
  return e.next = t, t.prev = e, n.next = i, i.prev = n, r.next = n, n.prev = r, o.next = r,
9593
9593
  r.prev = o, r;
@@ -9638,7 +9638,7 @@
9638
9638
  t;
9639
9639
  }
9640
9640
 
9641
- const Ne = {
9641
+ const Fe = {
9642
9642
  5120: {
9643
9643
  name: "sint8",
9644
9644
  bytes: 1
@@ -9669,8 +9669,8 @@
9669
9669
  }
9670
9670
  };
9671
9671
 
9672
- function Fe(e, t) {
9673
- const n = Ne[e].name;
9672
+ function Ne(e, t) {
9673
+ const n = Fe[e].name;
9674
9674
  return t > 1 ? n + "x" + t : n;
9675
9675
  }
9676
9676
 
@@ -9705,7 +9705,7 @@
9705
9705
  return 0 === t ? e : Math.ceil(e / t) * t;
9706
9706
  }
9707
9707
 
9708
- const Ge = [], ze = {
9708
+ const ze = [], Ge = {
9709
9709
  5120: "int8",
9710
9710
  5122: "int16",
9711
9711
  5124: "int32",
@@ -9760,29 +9760,32 @@
9760
9760
  static createBuffer(e, t, n) {
9761
9761
  return e.wgpu ? rt(e, t, GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST, n) : e.buffer(t);
9762
9762
  }
9763
- static padGPUBufferAlignment(e, t) {
9763
+ static padGPUBufferAlignment(e, t, n = !1) {
9764
9764
  if (0 === t) return e;
9765
- const n = e.byteLength / t;
9766
- if (n % 4 == 0) return e;
9767
- const r = e.constructor, i = e.length / t;
9768
- if (3 === i) {
9769
- const o = ot(i, n / i), s = Ke(r, o * t);
9770
- for (let n = 0; n < t; n++) for (let t = 0; t < i; t++) s[n * o + t] = e[n * i + t];
9771
- return s;
9765
+ const r = e.byteLength / t;
9766
+ if (r % 4 == 0) return e;
9767
+ const i = e.constructor, o = e.length / t;
9768
+ if (3 === o) {
9769
+ const s = ot(o, r / o);
9770
+ let a;
9771
+ a = n ? Ke(i, s * t) : new i(s * t);
9772
+ for (let n = 0; n < t; n++) for (let t = 0; t < o; t++) a[n * s + t] = e[n * o + t];
9773
+ return a;
9772
9774
  }
9773
9775
  {
9774
- const n = function(e, t) {
9776
+ const r = function(e, t) {
9775
9777
  if (e === Uint8Array || e === Uint8ClampedArray) return 1 === t ? Uint32Array : Uint16Array;
9776
9778
  if (e === Int8Array) return 1 === t ? Int32Array : Int16Array;
9777
9779
  if (e === Uint16Array) return Uint32Array;
9778
9780
  if (e === Int16Array) return Int32Array;
9779
9781
  throw new Error("sth unexpected in getPadArrayCtor");
9780
- }(r, i), o = Ke(n, i * t);
9781
- return o.set(e), o;
9782
+ }(i, o);
9783
+ let s;
9784
+ return s = n ? Ke(r, o * t) : new r(o * t), s.set(e), s;
9782
9785
  }
9783
9786
  }
9784
9787
  constructor(e, t, n, r) {
9785
- this._version = 0, this.data = e, this.elements = t, this.desc = I({}, je, r), this.semantic = function(e) {
9788
+ this._version = 0, this.data = e, this.elements = t, this.desc = E({}, je, r), this.semantic = function(e) {
9786
9789
  const t = {};
9787
9790
  for (const n in je) n.endsWith("Attribute") && (t[e[n]] = je[n]);
9788
9791
  return t;
@@ -9816,7 +9819,7 @@
9816
9819
  buffer: e,
9817
9820
  offset: r.byteOffset,
9818
9821
  stride: r.byteStride,
9819
- type: ze[r.componentType],
9822
+ type: Ge[r.componentType],
9820
9823
  size: r.itemSize,
9821
9824
  count: r.count,
9822
9825
  componentType: r.componentType
@@ -9836,14 +9839,14 @@
9836
9839
  const t = e.key, n = !this._reglData || !this._reglData[t];
9837
9840
  if (this._reglData || (this._reglData = {}), n) {
9838
9841
  const e = this._reglData[t] = {}, n = this.data, {positionAttribute: r, normalAttribute: i, uv0Attribute: o, uv1Attribute: s, tangentAttribute: a, color0Attribute: l, pickingIdAttribute: c, textureCoordMatrixAttribute: u} = this.desc;
9839
- I(e, this.data), e.aPosition = n[r], n[i] && (e.aNormal = n[i]), n[o] && (e.aTexCoord = n[o]),
9842
+ E(e, this.data), e.aPosition = n[r], n[i] && (e.aNormal = n[i]), n[o] && (e.aTexCoord = n[o]),
9840
9843
  n[s] && (e.aTexCoord1 = n[s]), n[a] && (e.aTangent = n[a]), n[l] && (e.aColor0 = n[l]),
9841
9844
  n[c] && (e.aPickingId = n[c]), n[u] && (e.aTextureCoordMatrix = n[u]);
9842
9845
  }
9843
9846
  return this._reglData[t];
9844
9847
  }
9845
9848
  getREGLData(e, t, n) {
9846
- if (this.getAttrData(t), N(e) && !n) {
9849
+ if (this.getAttrData(t), F(e) && !n) {
9847
9850
  const n = !this._reglData || !this._reglData[t.key], r = t && t.key || "default";
9848
9851
  if (!this._vao[r] || n || this._vao[r].dirty) {
9849
9852
  const n = this._reglData[t.key], i = this._vertexCount, o = [];
@@ -9852,7 +9855,7 @@
9852
9855
  if (s && s.destroy) void 0 !== n[r].stride ? o.push(n[r]) : o.push(s); else {
9853
9856
  const e = n[r];
9854
9857
  if (!e) {
9855
- this.desc.fillEmptyDataInMissingAttribute ? o.push(new Uint8Array(4 * i)) : o.push(Ge);
9858
+ this.desc.fillEmptyDataInMissingAttribute ? o.push(new Uint8Array(4 * i)) : o.push(ze);
9856
9859
  continue;
9857
9860
  }
9858
9861
  const t = (e.data && L(e.data) ? e.data.length : e.length) / i;
@@ -9896,16 +9899,18 @@
9896
9899
  const r = this.desc.positionAttribute, i = this.desc.altitudeAttribute, o = this.data, s = this._vertexCount, a = {};
9897
9900
  for (const l in o) if (o[l]) {
9898
9901
  if (Array.isArray(o[l]) && (o[l] = new Float32Array(o[l])), void 0 === o[l].buffer || o[l].buffer instanceof ArrayBuffer) {
9899
- const n = o[l].data ? o[l].data : o[l], c = n.length / s;
9902
+ let n = o[l].data ? o[l].data : o[l];
9903
+ const c = Math.floor(n.length / s);
9904
+ c * s !== n.length && (n = n.slice(0, s * c), o[l].data ? o[l].data = n : o[l] = n);
9900
9905
  let u = n;
9901
- t && (u = Ye.padGPUBufferAlignment(n, s));
9906
+ t && (u = Ye.padGPUBufferAlignment(n, s, !0));
9902
9907
  const f = o[l].data ? o[l] : {};
9903
9908
  f.data = u, f.dimension = c;
9904
9909
  const h = Ye.createBuffer(e, f, l);
9905
9910
  h[$e] = 1, a[l] = {
9906
9911
  buffer: h
9907
9912
  }, l !== r && l !== i || (a[l].array = o[l]);
9908
- } else o[l].buffer.destroy ? a[l] = o[l] : n[o[l].buffer] && (a[l] = I({}, o[l]),
9913
+ } else o[l].buffer.destroy ? a[l] = o[l] : n[o[l].buffer] && (a[l] = E({}, o[l]),
9909
9914
  a[l].buffer = n[o[l].buffer].buffer);
9910
9915
  (this.desc.static || l !== r) && delete o[l].array;
9911
9916
  }
@@ -9952,7 +9957,7 @@
9952
9957
  let r;
9953
9958
  this._incrVersion(), this.data[e] = t, n.buffer && n.buffer.destroy && (r = n);
9954
9959
  const i = e === this.desc.positionAttribute;
9955
- return i && this.updateBoundingBox(), this.getVertexCount(), r && (r.buffer.mapState ? (t = Ye.padGPUBufferAlignment(t, this._vertexCount),
9960
+ return i && this.updateBoundingBox(), this.getVertexCount(), r && (r.buffer.mapState ? (t = Ye.padGPUBufferAlignment(t, this._vertexCount, !0),
9956
9961
  r.buffer = this._updateGPUBuffer(r.buffer, t, 0, t.buffer.byteLength)) : r.buffer(t),
9957
9962
  this.data[e] = r, i && (this.data[e].array = t)), this._prepareData(!1), i && (this._posDirty = !0),
9958
9963
  delete this._reglData, this;
@@ -9973,7 +9978,7 @@
9973
9978
  if (this._incrVersion(), r.buffer && r.buffer.destroy && (i = r), e === this.desc.positionAttribute && this._updateSubBoundingBox(t),
9974
9979
  i) if (i.buffer.mapState) {
9975
9980
  const e = i.buffer.itemCount / this._vertexCount, r = t.length / e;
9976
- t = Ye.padGPUBufferAlignment(t, r);
9981
+ t = Ye.padGPUBufferAlignment(t, r, !0);
9977
9982
  const o = i.buffer.bytesPerElement;
9978
9983
  if (t.BYTES_PER_ELEMENT !== o) {
9979
9984
  t = new (Je(t, o))(t);
@@ -10158,7 +10163,7 @@
10158
10163
  }
10159
10164
  getMemorySize() {
10160
10165
  let e = 0;
10161
- for (const t in this.data) F(this.data, t) && (e += B(this.data[t]));
10166
+ for (const t in this.data) N(this.data, t) && (e += B(this.data[t]));
10162
10167
  if (this.elements) {
10163
10168
  const t = this.elements;
10164
10169
  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);
@@ -10167,8 +10172,8 @@
10167
10172
  }
10168
10173
  _forEachBuffer(e) {
10169
10174
  this.elements && this.elements.destroy && e(this.elements);
10170
- for (const t in this.data) F(this.data, t) && this.data[t] && this.data[t].buffer && this.data[t].buffer.destroy && e(this.data[t].buffer);
10171
- for (const t in this._buffers) F(this._buffers, t) && this._buffers[t] && this._buffers[t].buffer && this._buffers[t].buffer.destroy && e(this._buffers[t].buffer);
10175
+ for (const t in this.data) N(this.data, t) && this.data[t] && this.data[t].buffer && this.data[t].buffer.destroy && e(this.data[t].buffer);
10176
+ for (const t in this._buffers) N(this._buffers, t) && this._buffers[t] && this._buffers[t].buffer && this._buffers[t].buffer.destroy && e(this._buffers[t].buffer);
10172
10177
  }
10173
10178
  getElementsType(e) {
10174
10179
  return e instanceof Uint8Array ? "uint8" : e instanceof Uint16Array ? "uint16" : e instanceof Uint32Array ? "uint32" : void 0;
@@ -10202,7 +10207,7 @@
10202
10207
  if (!l) continue;
10203
10208
  const c = a.accessorName, u = a.byteStride;
10204
10209
  if (u && c) {
10205
- const e = Fe(a.componentType, a.itemSize);
10210
+ const e = Ne(a.componentType, a.itemSize);
10206
10211
  let t = i[c];
10207
10212
  t ? t.attributes.push({
10208
10213
  shaderLocation: l.location,
@@ -10256,8 +10261,8 @@
10256
10261
  }
10257
10262
  if (L(n)) {
10258
10263
  let o, s;
10259
- return e.componentType ? (o = Fe(e.componentType, e.itemSize), i = e.componentType,
10260
- s = Ne[i].bytes) : (o = tt(n, r), s = et(n)), r = ot(r, s), {
10264
+ return e.componentType ? (o = Ne(e.componentType, e.itemSize), i = e.componentType,
10265
+ s = Fe[i].bytes) : (o = tt(n, r), s = et(n)), r = ot(r, s), {
10261
10266
  arrayStride: r * s,
10262
10267
  attributes: [ {
10263
10268
  shaderLocation: t.location,
@@ -10287,7 +10292,7 @@
10287
10292
  }
10288
10293
 
10289
10294
  function nt(e) {
10290
- return e.data || e.buffer.destroy && e.buffer || e;
10295
+ return e.data || e.buffer && e.buffer.destroy && e.buffer || e;
10291
10296
  }
10292
10297
 
10293
10298
  function rt(e, t, n, r) {
@@ -10405,7 +10410,7 @@
10405
10410
  let s = i[xt][o];
10406
10411
  if (!s) {
10407
10412
  const t = {};
10408
- n && I(t, n), t.data = r, t.type || (t.type = ut(r)), s = e.buffer(t), i[xt][o] = s;
10413
+ n && E(t, n), t.data = r, t.type || (t.type = ut(r)), s = e.buffer(t), i[xt][o] = s;
10409
10414
  }
10410
10415
  return s;
10411
10416
  }
@@ -10432,9 +10437,9 @@
10432
10437
  getUniqueTexture: St
10433
10438
  });
10434
10439
 
10435
- const wt = [ 0, 0, 0 ], Mt = [ 0, 0, 0 ], At = [ 0, 0, 0 ], Ct = [], Ot = [], kt = [], It = [ "a", "b", "c" ];
10440
+ const wt = [ 0, 0, 0 ], Mt = [ 0, 0, 0 ], At = [ 0, 0, 0 ], Ct = [], Ot = [], kt = [], Et = [ "a", "b", "c" ];
10436
10441
 
10437
- class Et extends Ye {
10442
+ class It extends Ye {
10438
10443
  constructor(e, t, n, r) {
10439
10444
  super(e, t, n, {
10440
10445
  primitive: at(1),
@@ -10461,7 +10466,7 @@
10461
10466
  return this.elements = this._createElements(c), c;
10462
10467
  }
10463
10468
  _calEdgeData(e, t, n, r, i, o, s, a) {
10464
- const l = (e + 1) % 3, c = i[e], f = i[l], h = n[It[e]], d = n[It[l]], m = `${c}_${f}`, p = `${f}_${c}`;
10469
+ const l = (e + 1) % 3, c = i[e], f = i[l], h = n[Et[e]], d = n[Et[l]], m = `${c}_${f}`, p = `${f}_${c}`;
10465
10470
  if (p in r && r[p]) {
10466
10471
  dot$5(s, r[p].normal) <= o && (a.push(h[0], h[1], h[2]), a.push(d[0], d[1], d[2])),
10467
10472
  r[p] = null;
@@ -10498,7 +10503,7 @@
10498
10503
 
10499
10504
  class Ht extends(Q(Lt)){
10500
10505
  constructor(e = {}, t) {
10501
- super(), this._version = 0, this._propVerion = 0, this._texVersion = 0, this.uniforms = E({}, t || {}, e);
10506
+ super(), this._version = 0, this._propVerion = 0, this._texVersion = 0, this.uniforms = I({}, t || {}, e);
10502
10507
  for (const t in e) {
10503
10508
  const n = Object.getOwnPropertyDescriptor(e, t).get;
10504
10509
  n && Object.defineProperty(this.uniforms, t, {
@@ -10628,7 +10633,7 @@
10628
10633
  }
10629
10634
  _genUniformKeys() {
10630
10635
  const e = [];
10631
- for (const t in this.uniforms) F(this.uniforms, t) && !C(this.uniforms[t]) && e.push(t);
10636
+ for (const t in this.uniforms) N(this.uniforms, t) && !C(this.uniforms[t]) && e.push(t);
10632
10637
  this._uniformKeys = e.join();
10633
10638
  }
10634
10639
  _incrVersion() {
@@ -10657,7 +10662,7 @@
10657
10662
  "noiseEnable": !1
10658
10663
  };
10659
10664
 
10660
- const Nt = {
10665
+ const Ft = {
10661
10666
  "baseColorFactor": [ 1, 1, 1, 1 ],
10662
10667
  "materialShininess": 32,
10663
10668
  "environmentExposure": 1,
@@ -10674,14 +10679,14 @@
10674
10679
  "alphaTest": 0
10675
10680
  };
10676
10681
 
10677
- class Ft extends Ht {
10682
+ class Nt extends Ht {
10678
10683
  constructor(e) {
10679
- super(e, Nt);
10684
+ super(e, Ft);
10680
10685
  }
10681
10686
  static convertFrom(e) {
10682
10687
  const t = {};
10683
- for (const n in Nt) t[n] = e.get(n);
10684
- return new Ft(t);
10688
+ for (const n in Ft) t[n] = e.get(n);
10689
+ return new Nt(t);
10685
10690
  }
10686
10691
  appendDefines(e, t) {
10687
10692
  super.appendDefines(e, t);
@@ -10726,11 +10731,11 @@
10726
10731
  "occlusionTexture": null
10727
10732
  };
10728
10733
 
10729
- function Gt(e) {
10734
+ function zt(e) {
10730
10735
  return class extends e {
10731
10736
  constructor(...e) {
10732
10737
  let t = e[0];
10733
- t = I({}, Ut, t || {}), super(t, e);
10738
+ t = E({}, Ut, t || {}), super(t, e);
10734
10739
  }
10735
10740
  appendDefines(e, t) {
10736
10741
  if (super.appendDefines(e, t), e.SHADING_MODEL_SPECULAR_GLOSSINESS = 1, !t.data[t.desc.uv0Attribute]) return e;
@@ -10741,7 +10746,7 @@
10741
10746
  };
10742
10747
  }
10743
10748
 
10744
- class zt extends(Gt(Ft)){}
10749
+ class Gt extends(zt(Nt)){}
10745
10750
 
10746
10751
  class Vt {
10747
10752
  constructor() {
@@ -11149,7 +11154,7 @@
11149
11154
  }
11150
11155
  }
11151
11156
 
11152
- class In extends kn {
11157
+ class En extends kn {
11153
11158
  constructor(e) {
11154
11159
  super(), this.value = e;
11155
11160
  }
@@ -11164,7 +11169,7 @@
11164
11169
  }
11165
11170
  }
11166
11171
 
11167
- class En extends kn {
11172
+ class In extends kn {
11168
11173
  constructor(e, t) {
11169
11174
  super(), this.type = e, this.args = t;
11170
11175
  }
@@ -11337,7 +11342,7 @@
11337
11342
  }
11338
11343
  evaluate(e) {
11339
11344
  var t, n;
11340
- if (this.initializer instanceof En) {
11345
+ if (this.initializer instanceof In) {
11341
11346
  const r = null === (t = this.postfix) || void 0 === t ? void 0 : t.evaluateString(e), i = null === (n = this.initializer.type) || void 0 === n ? void 0 : n.name, o = e.structs.get(i), s = null == o ? void 0 : o.getMemberIndex(r);
11342
11347
  if (void 0 !== s && -1 != s) {
11343
11348
  return this.initializer.args[s].evaluate(e);
@@ -11375,7 +11380,7 @@
11375
11380
  }
11376
11381
  }
11377
11382
 
11378
- class Nn extends kn {
11383
+ class Fn extends kn {
11379
11384
  constructor(e) {
11380
11385
  super(), this.contents = e;
11381
11386
  }
@@ -11390,7 +11395,7 @@
11390
11395
  }
11391
11396
  }
11392
11397
 
11393
- class Fn extends kn {
11398
+ class Nn extends kn {
11394
11399
  constructor(e) {
11395
11400
  super(), this.index = e;
11396
11401
  }
@@ -11435,7 +11440,7 @@
11435
11440
  }
11436
11441
  }
11437
11442
 
11438
- class Gn extends Bn {
11443
+ class zn extends Bn {
11439
11444
  constructor(e, t, n) {
11440
11445
  super(), this.operator = e, this.left = t, this.right = n;
11441
11446
  }
@@ -11492,13 +11497,13 @@
11492
11497
  }
11493
11498
  }
11494
11499
 
11495
- class zn extends jt {
11500
+ class Gn extends jt {
11496
11501
  constructor() {
11497
11502
  super();
11498
11503
  }
11499
11504
  }
11500
11505
 
11501
- class Vn extends zn {
11506
+ class Vn extends Gn {
11502
11507
  constructor(e, t) {
11503
11508
  super(), this.selector = e, this.body = t;
11504
11509
  }
@@ -11510,7 +11515,7 @@
11510
11515
  }
11511
11516
  }
11512
11517
 
11513
- class jn extends zn {
11518
+ class jn extends Gn {
11514
11519
  constructor(e) {
11515
11520
  super(), this.body = e;
11516
11521
  }
@@ -12312,51 +12317,51 @@
12312
12317
  }
12313
12318
  _short_circuit_or_expression() {
12314
12319
  let e = this._short_circuit_and_expr();
12315
- for (;this._match(Yn.tokens.or_or); ) e = new Gn(this._previous().toString(), e, this._short_circuit_and_expr());
12320
+ for (;this._match(Yn.tokens.or_or); ) e = new zn(this._previous().toString(), e, this._short_circuit_and_expr());
12316
12321
  return e;
12317
12322
  }
12318
12323
  _short_circuit_and_expr() {
12319
12324
  let e = this._inclusive_or_expression();
12320
- for (;this._match(Yn.tokens.and_and); ) e = new Gn(this._previous().toString(), e, this._inclusive_or_expression());
12325
+ for (;this._match(Yn.tokens.and_and); ) e = new zn(this._previous().toString(), e, this._inclusive_or_expression());
12321
12326
  return e;
12322
12327
  }
12323
12328
  _inclusive_or_expression() {
12324
12329
  let e = this._exclusive_or_expression();
12325
- for (;this._match(Yn.tokens.or); ) e = new Gn(this._previous().toString(), e, this._exclusive_or_expression());
12330
+ for (;this._match(Yn.tokens.or); ) e = new zn(this._previous().toString(), e, this._exclusive_or_expression());
12326
12331
  return e;
12327
12332
  }
12328
12333
  _exclusive_or_expression() {
12329
12334
  let e = this._and_expression();
12330
- for (;this._match(Yn.tokens.xor); ) e = new Gn(this._previous().toString(), e, this._and_expression());
12335
+ for (;this._match(Yn.tokens.xor); ) e = new zn(this._previous().toString(), e, this._and_expression());
12331
12336
  return e;
12332
12337
  }
12333
12338
  _and_expression() {
12334
12339
  let e = this._equality_expression();
12335
- for (;this._match(Yn.tokens.and); ) e = new Gn(this._previous().toString(), e, this._equality_expression());
12340
+ for (;this._match(Yn.tokens.and); ) e = new zn(this._previous().toString(), e, this._equality_expression());
12336
12341
  return e;
12337
12342
  }
12338
12343
  _equality_expression() {
12339
12344
  const e = this._relational_expression();
12340
- return this._match([ Yn.tokens.equal_equal, Yn.tokens.not_equal ]) ? new Gn(this._previous().toString(), e, this._relational_expression()) : e;
12345
+ return this._match([ Yn.tokens.equal_equal, Yn.tokens.not_equal ]) ? new zn(this._previous().toString(), e, this._relational_expression()) : e;
12341
12346
  }
12342
12347
  _relational_expression() {
12343
12348
  let e = this._shift_expression();
12344
- for (;this._match([ Yn.tokens.less_than, Yn.tokens.greater_than, Yn.tokens.less_than_equal, Yn.tokens.greater_than_equal ]); ) e = new Gn(this._previous().toString(), e, this._shift_expression());
12349
+ for (;this._match([ Yn.tokens.less_than, Yn.tokens.greater_than, Yn.tokens.less_than_equal, Yn.tokens.greater_than_equal ]); ) e = new zn(this._previous().toString(), e, this._shift_expression());
12345
12350
  return e;
12346
12351
  }
12347
12352
  _shift_expression() {
12348
12353
  let e = this._additive_expression();
12349
- for (;this._match([ Yn.tokens.shift_left, Yn.tokens.shift_right ]); ) e = new Gn(this._previous().toString(), e, this._additive_expression());
12354
+ for (;this._match([ Yn.tokens.shift_left, Yn.tokens.shift_right ]); ) e = new zn(this._previous().toString(), e, this._additive_expression());
12350
12355
  return e;
12351
12356
  }
12352
12357
  _additive_expression() {
12353
12358
  let e = this._multiplicative_expression();
12354
- for (;this._match([ Yn.tokens.plus, Yn.tokens.minus ]); ) e = new Gn(this._previous().toString(), e, this._multiplicative_expression());
12359
+ for (;this._match([ Yn.tokens.plus, Yn.tokens.minus ]); ) e = new zn(this._previous().toString(), e, this._multiplicative_expression());
12355
12360
  return e;
12356
12361
  }
12357
12362
  _multiplicative_expression() {
12358
12363
  let e = this._unary_expression();
12359
- for (;this._match([ Yn.tokens.star, Yn.tokens.forward_slash, Yn.tokens.modulo ]); ) e = new Gn(this._previous().toString(), e, this._unary_expression());
12364
+ for (;this._match([ Yn.tokens.star, Yn.tokens.forward_slash, Yn.tokens.modulo ]); ) e = new zn(this._previous().toString(), e, this._unary_expression());
12360
12365
  return e;
12361
12366
  }
12362
12367
  _unary_expression() {
@@ -12370,11 +12375,11 @@
12370
12375
  if (this._match(Yn.tokens.bracket_left)) {
12371
12376
  const e = this._short_circuit_or_expression();
12372
12377
  this._consume(Yn.tokens.bracket_right, "Expected ']'.");
12373
- const t = new Fn(e), n = this._postfix_expression();
12378
+ const t = new Nn(e), n = this._postfix_expression();
12374
12379
  return n && (t.postfix = n), t;
12375
12380
  }
12376
12381
  if (this._match(Yn.tokens.period)) {
12377
- const e = this._consume(Yn.tokens.ident, "Expected member name."), t = this._postfix_expression(), n = new In(e.lexeme);
12382
+ const e = this._consume(Yn.tokens.ident, "Expected member name."), t = this._postfix_expression(), n = new En(e.lexeme);
12378
12383
  return t && (n.postfix = t), n;
12379
12384
  }
12380
12385
  return null;
@@ -12393,7 +12398,7 @@
12393
12398
  const e = this._previous().toString();
12394
12399
  if (this._check(Yn.tokens.paren_left)) {
12395
12400
  const t = this._argument_expression_list(), n = this._getStruct(e);
12396
- return null != n ? new En(n, t) : new Pn(e, t);
12401
+ return null != n ? new In(n, t) : new Pn(e, t);
12397
12402
  }
12398
12403
  if (this._context.constants.has(e)) {
12399
12404
  const t = this._context.constants.get(e);
@@ -12411,7 +12416,7 @@
12411
12416
  return new Dn(e, t);
12412
12417
  }
12413
12418
  const e = this._type_decl(), t = this._argument_expression_list();
12414
- return new En(e, t);
12419
+ return new In(e, t);
12415
12420
  }
12416
12421
  _argument_expression_list() {
12417
12422
  if (!this._match(Yn.tokens.paren_left)) return null;
@@ -12426,12 +12431,12 @@
12426
12431
  _optional_paren_expression() {
12427
12432
  this._match(Yn.tokens.paren_left);
12428
12433
  const e = this._short_circuit_or_expression();
12429
- return this._match(Yn.tokens.paren_right), new Nn([ e ]);
12434
+ return this._match(Yn.tokens.paren_right), new Fn([ e ]);
12430
12435
  }
12431
12436
  _paren_expression() {
12432
12437
  this._consume(Yn.tokens.paren_left, "Expected '('.");
12433
12438
  const e = this._short_circuit_or_expression();
12434
- return this._consume(Yn.tokens.paren_right, "Expected ')'."), new Nn([ e ]);
12439
+ return this._consume(Yn.tokens.paren_right, "Expected ')'."), new Fn([ e ]);
12435
12440
  }
12436
12441
  _struct_decl() {
12437
12442
  if (!this._match(Yn.keywords.struct)) return null;
@@ -12470,7 +12475,7 @@
12470
12475
  let n = null;
12471
12476
  if (this._match(Yn.tokens.equal)) {
12472
12477
  const e = this._short_circuit_or_expression();
12473
- if (e instanceof En) n = e; else if (e instanceof Ln && e.initializer instanceof En) n = e.initializer; else try {
12478
+ if (e instanceof In) n = e; else if (e instanceof Ln && e.initializer instanceof In) n = e.initializer; else try {
12474
12479
  const t = e.evaluate(this._context);
12475
12480
  n = new Hn(t);
12476
12481
  } catch (t) {
@@ -12893,7 +12898,7 @@
12893
12898
  if (o instanceof Wt) i.push({}); else if (o instanceof qt) i.pop(); else if (o instanceof Qt) {
12894
12899
  const e = o;
12895
12900
  t && null !== e.type && this._markStructsFromAST(e.type), i.length > 0 && (i[i.length - 1][e.name] = e);
12896
- } else if (o instanceof En) {
12901
+ } else if (o instanceof In) {
12897
12902
  const e = o;
12898
12903
  t && null !== e.type && this._markStructsFromAST(e.type);
12899
12904
  } else if (o instanceof tn) {
@@ -13343,7 +13348,7 @@
13343
13348
  }
13344
13349
  getDefines() {
13345
13350
  const e = {};
13346
- return I(e, this._getDefines()), this._material && this._geometry && this._material.appendDefines(e, this._geometry),
13351
+ return E(e, this._getDefines()), this._material && this._geometry && this._material.appendDefines(e, this._geometry),
13347
13352
  e;
13348
13353
  }
13349
13354
  _getDefines() {
@@ -13366,7 +13371,7 @@
13366
13371
  return this._material && this._material.hasSkinAnimation();
13367
13372
  }
13368
13373
  _getDefinesKey() {
13369
- return this._bakDefines = I({}, this._defines), this.dirtyDefines = !1, this._createDefinesKey(this.getDefines());
13374
+ return this._bakDefines = E({}, this._defines), this.dirtyDefines = !1, this._createDefinesKey(this.getDefines());
13370
13375
  }
13371
13376
  getCommandKey(e) {
13372
13377
  if (!this._commandKey || this.dirtyDefines || this._material && this._materialKeys !== this._material.getUniformKeys()) {
@@ -13387,13 +13392,13 @@
13387
13392
  return this._geometry.getREGLData(e, t, this.disableVAO);
13388
13393
  }
13389
13394
  appendGeoAttributes(e, t, n) {
13390
- I(e, this._getGeometryAttributes(t, n)), N(t) && !this.disableVAO || (e.elements = this._geometry.getElements());
13395
+ E(e, this._getGeometryAttributes(t, n)), F(t) && !this.disableVAO || (e.elements = this._geometry.getElements());
13391
13396
  }
13392
13397
  getUniforms(e) {
13393
13398
  if (this._dirtyUniforms || this._dirtyGeometry || this._material && this._materialVer !== this._material.version) {
13394
13399
  this._uniformDescriptors = new Set, this._realUniforms = {}, this._prepareUniformsForDraco();
13395
13400
  const t = this.uniforms;
13396
- for (const e in this.uniforms) if (F(this.uniforms, e)) {
13401
+ for (const e in this.uniforms) if (N(this.uniforms, e)) {
13397
13402
  Object.getOwnPropertyDescriptor(t, e).get ? (this._uniformDescriptors.add(e), Object.defineProperty(this._realUniforms, e, {
13398
13403
  enumerable: !0,
13399
13404
  configurable: !0,
@@ -13404,7 +13409,7 @@
13404
13409
  }
13405
13410
  if (this._material) {
13406
13411
  const t = this._material.getUniforms(e);
13407
- for (const e in t) if (F(t, e) && !F(this._realUniforms, e)) {
13412
+ for (const e in t) if (N(t, e) && !N(this._realUniforms, e)) {
13408
13413
  Object.getOwnPropertyDescriptor(t, e).get ? (this._uniformDescriptors.add(e), Object.defineProperty(this._realUniforms, e, {
13409
13414
  enumerable: !0,
13410
13415
  configurable: !0,
@@ -13420,7 +13425,7 @@
13420
13425
  if (this._dirtyProps) for (const e of this._dirtyProps) this._realUniforms[e] = this.uniforms[e];
13421
13426
  if (this._material && this._material.propVersion !== this._materialPropVer) {
13422
13427
  const t = this._material.getUniforms(e);
13423
- for (const e in t) if (F(t, e) && !this._uniformDescriptors.has(e)) {
13428
+ for (const e in t) if (N(t, e) && !this._uniformDescriptors.has(e)) {
13424
13429
  Object.getOwnPropertyDescriptor(t, e).get || this._realUniforms[e] === t[e] || (this._realUniforms[e] = t[e]);
13425
13430
  }
13426
13431
  this._materialPropVer = this._material.propVersion;
@@ -13529,7 +13534,7 @@
13529
13534
  }
13530
13535
  _getInstanceMemorySize() {
13531
13536
  let e = 0;
13532
- for (const t in this.instancedData) F(this.instancedData, t) && (e += B(this.instancedData[t]));
13537
+ for (const t in this.instancedData) N(this.instancedData, t) && (e += B(this.instancedData[t]));
13533
13538
  return e;
13534
13539
  }
13535
13540
  _checkInstancedProp() {
@@ -13537,7 +13542,7 @@
13537
13542
  }
13538
13543
  appendGeoAttributes(e, t, n) {
13539
13544
  const r = this.geometry.getAttrData(n);
13540
- if (N(t)) {
13545
+ if (F(t)) {
13541
13546
  const i = n.key;
13542
13547
  if (!this._vao[i] || this._vao[i].dirty) {
13543
13548
  const e = n.map((e => e.name)), o = [];
@@ -13553,8 +13558,8 @@
13553
13558
  vao: t.vao(s)
13554
13559
  }, delete this._vao[i].dirty;
13555
13560
  }
13556
- I(e, this._vao[i]);
13557
- } else I(e, r);
13561
+ E(e, this._vao[i]);
13562
+ } else E(e, r);
13558
13563
  }
13559
13564
  getDefines() {
13560
13565
  const e = super.getDefines();
@@ -13576,7 +13581,7 @@
13576
13581
  const t = !!e && e.wgpu, n = this.instancedData, r = this.instanceCount, i = {};
13577
13582
  for (const o in n) {
13578
13583
  if (!n[o]) continue;
13579
- Array.isArray(n[o]) ? n[o] = new Float32Array(n[o]) : t && L(n[o]) && (n[o] = Ye.padGPUBufferAlignment(n[o], r));
13584
+ Array.isArray(n[o]) ? n[o] = new Float32Array(n[o]) : t && L(n[o]) && (n[o] = Ye.padGPUBufferAlignment(n[o], r, !0));
13580
13585
  const s = n[o];
13581
13586
  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] = {
13582
13587
  buffer: n[o],
@@ -13596,7 +13601,7 @@
13596
13601
  }
13597
13602
  getRenderProps(e) {
13598
13603
  const t = super.getRenderProps(e);
13599
- return N(e) || I(t, this.instancedData), t.elements = this.geometry.getElements(),
13604
+ return F(e) || E(t, this.instancedData), t.elements = this.geometry.getElements(),
13600
13605
  t.instances = this._instanceCount, t;
13601
13606
  }
13602
13607
  disposeInstancedData() {
@@ -13772,12 +13777,12 @@
13772
13777
 
13773
13778
  let Or, kr = 0;
13774
13779
 
13775
- function Ir(e, t) {
13780
+ function Er(e, t) {
13776
13781
  return transformMat4$2(Ar, e.geometry.boundingBox.getCenter(), e.localTransform),
13777
13782
  transformMat4$2(Cr, t.geometry.boundingBox.getCenter(), t.localTransform), dist$2(Cr, Or) - dist$2(Ar, Or);
13778
13783
  }
13779
13784
 
13780
- class Er {
13785
+ class Ir {
13781
13786
  constructor(e) {
13782
13787
  this._id = kr++, this.sortedMeshes = {}, this.setMeshes(e), this.dirty();
13783
13788
  }
@@ -13835,7 +13840,7 @@
13835
13840
  n = this.sortedMeshes.transparents = [];
13836
13841
  for (let r = 0, i = t.length; r < i; r++) t[r].transparent ? n.push(t[r]) : e.push(t[r]);
13837
13842
  }
13838
- e && n.length > 1 && (Or = e, n.sort(Ir)), this._dirty = !1;
13843
+ e && n.length > 1 && (Or = e, n.sort(Er)), this._dirty = !1;
13839
13844
  }
13840
13845
  getSortedMeshes() {
13841
13846
  return this._dirty && this.sortMeshes(), this.sortedMeshes || {};
@@ -13864,7 +13869,7 @@
13864
13869
  return n;
13865
13870
  }
13866
13871
 
13867
- function Nr(e, t, n, r) {
13872
+ function Fr(e, t, n, r) {
13868
13873
  if (r < Rr | r > Lr) return Dr(e, t, n, r);
13869
13874
  let i = t[n++];
13870
13875
  if (2 !== i) return Dr(e, t, n - 1, r);
@@ -13880,7 +13885,7 @@
13880
13885
  return n;
13881
13886
  }
13882
13887
 
13883
- function Fr(e, t = 0) {
13888
+ function Nr(e, t = 0) {
13884
13889
  const n = new Uint8Array(e), r = n.length;
13885
13890
  if ("#?" !== function(e, t, n) {
13886
13891
  let r = "";
@@ -13907,7 +13912,7 @@
13907
13912
  const f = new Float32Array(l * a * 4);
13908
13913
  let h = 0;
13909
13914
  for (let e = 0; e < a; e++) {
13910
- if (c = Nr(u, n, c, l), !c) return null;
13915
+ if (c = Fr(u, n, c, l), !c) return null;
13911
13916
  for (let e = 0; e < l; e++) Hr(u[e], f, h, t), h += 4;
13912
13917
  }
13913
13918
  return {
@@ -13952,7 +13957,7 @@
13952
13957
  };
13953
13958
  }
13954
13959
 
13955
- const Gr = {
13960
+ const zr = {
13956
13961
  toHalfFloat: function(e) {
13957
13962
  Math.abs(e) > 65504 && console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),
13958
13963
  e = D(e, -65504, 65504), Br.floatView[0] = e;
@@ -13964,13 +13969,13 @@
13964
13969
  return Br.uint32View[0] = Br.mantissaTable[Br.offsetTable[t] + (1023 & e)] + Br.exponentTable[t],
13965
13970
  Br.floatView[0];
13966
13971
  }
13967
- }, zr = 9728, Vr = 9729, jr = 9987;
13972
+ }, Gr = 9728, Vr = 9729, jr = 9987;
13968
13973
 
13969
13974
  var Wr = Object.freeze({
13970
13975
  __proto__: null,
13971
13976
  GL_LINEAR: Vr,
13972
13977
  GL_LINEAR_MIPMAP_LINEAR: jr,
13973
- GL_NEAREST: zr,
13978
+ GL_NEAREST: Gr,
13974
13979
  MAG_FILTER: 10240,
13975
13980
  MIN_FILTER: 10241
13976
13981
  });
@@ -13989,10 +13994,10 @@
13989
13994
  const t = this.config;
13990
13995
  if (t) {
13991
13996
  if (t.hdr) {
13992
- if (!(e = Fr(e.data, 0))) throw new Error("Invalid hdr data" + (t.url ? ":" + t.url : ""));
13997
+ if (!(e = Nr(e.data, 0))) throw new Error("Invalid hdr data" + (t.url ? ":" + t.url : ""));
13993
13998
  {
13994
13999
  const n = new Uint16Array(e.pixels.length);
13995
- for (let t = 0; t < e.pixels.length; t++) n[t] = Math.min(Gr.toHalfFloat(e.pixels[t]), 65504);
14000
+ for (let t = 0; t < e.pixels.length; t++) n[t] = Math.min(zr.toHalfFloat(e.pixels[t]), 65504);
13996
14001
  t.data = n, t.type = "float16", t.colorSpace = "browser", t.min = "linear", t.mag = "linear";
13997
14002
  }
13998
14003
  } else t.data = e;
@@ -14550,7 +14555,7 @@
14550
14555
  })) : u = t.factor);
14551
14556
  } else c = 0, u = 0;
14552
14557
  this.depthBias = c, this.depthBiasSlopeScale = u;
14553
- let f = "always", h = !1;
14558
+ let f = "less", h = !0;
14554
14559
  const d = e.depth;
14555
14560
  if (a && d && _i(d.enable, n)) {
14556
14561
  if (d.func) {
@@ -14674,7 +14679,7 @@
14674
14679
  class bi {
14675
14680
  constructor(e, t) {
14676
14681
  this.version = 0, this.device = e, this.config = t, this.gpuFormat = pi(t.format, t.type),
14677
- this._updateTexture();
14682
+ this.dirty = !1, this._updateTexture();
14678
14683
  }
14679
14684
  get width() {
14680
14685
  return this.texture && this.texture.width || this.config && this.config.width;
@@ -14689,38 +14694,52 @@
14689
14694
  this.texture && this.version++;
14690
14695
  }
14691
14696
  resize(e, t) {
14692
- this.texture && this.texture.width === e && this.texture.height === t || (this.config.width = e,
14693
- this.config.height = t, this._updateTexture());
14697
+ this.texture && this.texture.width === e && this.texture.height === t || (this.dirty = !0,
14698
+ this.config.width = e, this.config.height = t, this._updateTexture());
14694
14699
  }
14695
14700
  update(e) {
14696
- I(this.config, e), this.gpuFormat = pi(this.config.format, this.config.type), this._updateTexture();
14701
+ this.texture && (this.dirty = this._isDirty(e));
14702
+ const {width: t, height: n} = this._getSize(e);
14703
+ E(this.config, e), this.config.width = t, this.config.height = n, this.gpuFormat = pi(this.config.format, this.config.type),
14704
+ this._updateTexture();
14697
14705
  }
14698
14706
  _updateTexture() {
14699
- const e = this.config, t = this.device.wgpu;
14700
- let n;
14701
- this.texture && (this.version++, this.device.addToDestroyList(this.texture));
14707
+ const e = this.config, {width: t, height: n} = this._getSize(e), r = this.device.wgpu;
14708
+ this.dirty && (this.version++, this.device.addToDestroyList(this.texture), this.texture = null,
14709
+ this.dirty = !1);
14710
+ let i = this.texture;
14702
14711
  {
14703
- let r = k(e.width) ? e.width() : e.width, i = k(e.height) ? e.height() : e.height;
14704
- if (void 0 === r || void 0 === i) {
14705
- const t = e.data;
14706
- if (t) if (L(e.data)) {
14707
- const t = e.data.length;
14708
- r = Math.sqrt(t / 4), i = r;
14709
- } else r = t.width, i = t.height; else r = i = 1;
14710
- }
14711
14712
  const o = this.gpuFormat.format, s = "depth24plus" === o || "depth24plus-stencil8" === o ? GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.RENDER_ATTACHMENT : GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT, a = {
14712
- size: [ r, i, this.arrayLayers ],
14713
+ size: [ t, n, this.arrayLayers ],
14713
14714
  format: o,
14714
14715
  usage: s,
14715
14716
  mipLevelCount: this.getMipLevelCount()
14716
14717
  };
14717
- e.sampleCount && (a.sampleCount = e.sampleCount), n = t.createTexture(a), this.fillData(n, r, i);
14718
+ e.sampleCount && (a.sampleCount = e.sampleCount), i = i || r.createTexture(a), this.fillData(i, t, n);
14718
14719
  }
14719
- this.texture = n;
14720
+ this.texture = i;
14720
14721
  }
14721
- getMipLevelCount() {
14722
- const e = this.config.data;
14723
- return e && e.mipmap ? e.mipmap.length : 1;
14722
+ _isDirty(e) {
14723
+ if (!this.texture) return !1;
14724
+ const {width: t, height: n} = this._getSize(e);
14725
+ return t !== this.texture.width || (n !== this.texture.height || (!(!e.format || e.format === this.config.format) || (!(!e.type || e.type === this.config.type) || this.getMipLevelCount(e.data) !== this.getMipLevelCount())));
14726
+ }
14727
+ _getSize(e) {
14728
+ let t = k(e.width) ? e.width() : e.width, n = k(e.height) ? e.height() : e.height;
14729
+ if (void 0 === t || void 0 === n) {
14730
+ const r = e.data;
14731
+ if (r) if (L(e.data)) {
14732
+ const r = e.data.length;
14733
+ t = Math.sqrt(r / 4), n = t;
14734
+ } else t = r.videoWidth || r.width, n = r.videoHeight || r.height; else t = n = 1;
14735
+ }
14736
+ return {
14737
+ width: t,
14738
+ height: n
14739
+ };
14740
+ }
14741
+ getMipLevelCount(e) {
14742
+ return (e = e || this.config.data) && e.mipmap ? e.mipmap.length : 1;
14724
14743
  }
14725
14744
  fillData(e, t, n) {
14726
14745
  const r = this.config, i = [ 0, 0, 0 ];
@@ -14818,6 +14837,13 @@
14818
14837
  t && t.view && this.depthTexture && (t.view = this.depthTexture.getView());
14819
14838
  }
14820
14839
  }
14840
+ getCommandKey() {
14841
+ if (this._cmdKey) return this._cmdKey;
14842
+ const e = this.colorTexture, t = this.depthTexture;
14843
+ let n = "";
14844
+ return e && (n += `${e.gpuFormat.format}-${e.config.sampleCount};`), t && (n += `${t.gpuFormat.format};`),
14845
+ this._cmdKey = n, n;
14846
+ }
14821
14847
  _update() {
14822
14848
  let e = this.options.colors && this.options.colors[0] || this.options.color;
14823
14849
  const t = this.options.colorFormat, n = this.options.colorType;
@@ -15010,20 +15036,20 @@
15010
15036
  if (!e) return;
15011
15037
  const r = e.matchAll(Mi), i = {};
15012
15038
  for (const e of r) i[e[1]] = e[2];
15013
- let o = Ii(e = e.replace(/#define.*$/gm, ""), i);
15039
+ let o = Ei(e = e.replace(/#define.*$/gm, ""), i);
15014
15040
  const s = null === (n = o.match(Ci)) || void 0 === n ? void 0 : n.filter((e => !!isNaN(e) && "" != e)).map((e => {
15015
15041
  const t = e.indexOf(" ");
15016
15042
  return e.substring(t).trim();
15017
15043
  })), {normalizeDefines: a, constValues: l} = function(e, t) {
15018
15044
  var n;
15019
- const r = new Set, i = null === (n = null == e ? void 0 : e.map) || void 0 === n ? void 0 : n.call(e, (e => Ei(e, t, r))), o = {};
15045
+ const r = new Set, i = null === (n = null == e ? void 0 : e.map) || void 0 === n ? void 0 : n.call(e, (e => Ii(e, t, r))), o = {};
15020
15046
  for (const e in t) r.has(e) || (o[e] = t[e]);
15021
15047
  return {
15022
15048
  normalizeDefines: i,
15023
15049
  constValues: o
15024
15050
  };
15025
15051
  }(s, t);
15026
- o = Ii(o, l);
15052
+ o = Ei(o, l);
15027
15053
  const c = function(e, t) {
15028
15054
  let n = e;
15029
15055
  const r = (null == t ? void 0 : t.map((e => {
@@ -15099,7 +15125,7 @@
15099
15125
  }
15100
15126
  }
15101
15127
 
15102
- function Ii(e, t) {
15128
+ function Ei(e, t) {
15103
15129
  var n;
15104
15130
  if (!t) return e;
15105
15131
  let r = e;
@@ -15110,7 +15136,7 @@
15110
15136
  })), r;
15111
15137
  }
15112
15138
 
15113
- function Ei(e, t, n) {
15139
+ function Ii(e, t, n) {
15114
15140
  if ((null == e ? void 0 : e.includes("&&")) || (null == e ? void 0 : e.includes("||"))) {
15115
15141
  if (e.includes("&&")) {
15116
15142
  const r = e.split("&&").map((e => e.trim()));
@@ -15147,7 +15173,7 @@
15147
15173
  var Ri = Object.freeze({
15148
15174
  __proto__: null,
15149
15175
  WGSLParseDefines: Oi,
15150
- getDefineConditionValue: Ei
15176
+ getDefineConditionValue: Ii
15151
15177
  });
15152
15178
 
15153
15179
  const Li = /struct\s+VertexOutput\s*\{[\s\S]*?\}/;
@@ -15170,10 +15196,10 @@
15170
15196
  } catch (e) {
15171
15197
  throw e.message = this.name + "(frag):" + e.message, console.error(e), e;
15172
15198
  }
15173
- o = Gi(o), s && (s = Gi(s));
15174
- const {source: a, index: l} = zi(o, 0);
15199
+ o = zi(o), s && (s = zi(s));
15200
+ const {source: a, index: l} = Gi(o, 0);
15175
15201
  if (o = a, s) {
15176
- const {source: e} = zi(s, l);
15202
+ const {source: e} = Gi(s, l);
15177
15203
  s = e;
15178
15204
  const t = o.match(Li);
15179
15205
  if (t) {
@@ -15243,7 +15269,7 @@
15243
15269
  i.push(s);
15244
15270
  }
15245
15271
  }
15246
- return i.sort(Fi), this.device.wgpu.createBindGroupLayout({
15272
+ return i.sort(Ni), this.device.wgpu.createBindGroupLayout({
15247
15273
  label: this.name + "-bindgrouplayout",
15248
15274
  entries: i
15249
15275
  });
@@ -15303,7 +15329,7 @@
15303
15329
  n && (a.add(t), i[t] = {
15304
15330
  geoAttrName: e,
15305
15331
  location: n.location,
15306
- itemSize: Ni(n.type)
15332
+ itemSize: Fi(n.type)
15307
15333
  });
15308
15334
  }
15309
15335
  for (const e in r) if (!a.has(e)) {
@@ -15311,7 +15337,7 @@
15311
15337
  i[e] = {
15312
15338
  geoAttrName: e,
15313
15339
  location: t.location,
15314
- itemSize: Ni(t.type)
15340
+ itemSize: Fi(t.type)
15315
15341
  };
15316
15342
  }
15317
15343
  if (t instanceof br) {
@@ -15319,7 +15345,7 @@
15319
15345
  for (const t in e) r[t] && (i[t] = {
15320
15346
  geoAttrName: t,
15321
15347
  location: r[t].location,
15322
- itemSize: Ni(r[t].type)
15348
+ itemSize: Fi(r[t].type)
15323
15349
  });
15324
15350
  }
15325
15351
  return i;
@@ -15376,7 +15402,8 @@
15376
15402
  },
15377
15403
  primitive: {
15378
15404
  topology: s.topology,
15379
- cullMode: s.cullMode
15405
+ cullMode: s.cullMode,
15406
+ frontFace: s.frontFace
15380
15407
  }
15381
15408
  }, m = a && a.colorTexture && a.colorTexture.config.sampleCount;
15382
15409
  m && (d.multisample = {
@@ -15428,11 +15455,11 @@
15428
15455
  return "modelMatrix" === t || "positionMatrix" === t || "projViewModelMatrix" === t || "modelViewMatrix" === t || "modelNormalMatrix" === t || "polygonFill" === t || "polygonOpacity" === t || "lineColor" === t || "lineOpacity" === t || (n[t] && !n[t].global || e.hasUniform(t) || e.material && e.material.hasUniform(t));
15429
15456
  }
15430
15457
 
15431
- function Ni(e) {
15458
+ function Fi(e) {
15432
15459
  return e.name.startsWith("vec") ? parseInt(e.name[3]) : 1;
15433
15460
  }
15434
15461
 
15435
- function Fi(e, t) {
15462
+ function Ni(e, t) {
15436
15463
  return e.binding - t.binding;
15437
15464
  }
15438
15465
 
@@ -15440,14 +15467,14 @@
15440
15467
 
15441
15468
  const Ui = () => "" + Bi++;
15442
15469
 
15443
- function Gi(e) {
15470
+ function zi(e) {
15444
15471
  Bi = 0;
15445
15472
  const t = e.replaceAll("$i", Ui);
15446
15473
  Bi = 0;
15447
15474
  return t.replaceAll("$o", Ui);
15448
15475
  }
15449
15476
 
15450
- function zi(e, t) {
15477
+ function Gi(e, t) {
15451
15478
  return Bi = t, {
15452
15479
  source: e.replaceAll("$b", Ui),
15453
15480
  index: Bi
@@ -15501,7 +15528,7 @@
15501
15528
  enumerable: !0,
15502
15529
  configurable: !1,
15503
15530
  get: () => l
15504
- }), this.setDefines(o && I({}, o) || {}), i = this.uniforms = (i || []).slice(),
15531
+ }), this.setDefines(o && E({}, o) || {}), i = this.uniforms = (i || []).slice(),
15505
15532
  this.contextDesc = {};
15506
15533
  for (let e = 0, t = i.length; e < t; e++) {
15507
15534
  const t = i[e];
@@ -15522,7 +15549,7 @@
15522
15549
  };
15523
15550
  } else this.contextDesc[t.name] = t;
15524
15551
  }
15525
- this.extraCommandProps = s && I({}, s) || {}, this.commands = {}, this._compileSource();
15552
+ this.extraCommandProps = s && E({}, s) || {}, this.commands = {}, this._compileSource();
15526
15553
  }
15527
15554
  set shaderDefines(e) {
15528
15555
  this._shaderDefines = e, this.dkey = Object.keys(this._shaderDefines).join();
@@ -15575,11 +15602,11 @@
15575
15602
  }
15576
15603
  _insertDefines(e, t) {
15577
15604
  const n = [];
15578
- for (const e in t) F(t, e) && !k(t[e]) && n.push(`#define ${e} ${t[e]}\n`);
15605
+ for (const e in t) N(t, e) && !k(t[e]) && n.push(`#define ${e} ${t[e]}\n`);
15579
15606
  return n.join("") + e;
15580
15607
  }
15581
15608
  createMeshCommand(e, t, n = {}, r) {
15582
- const i = t.getDefines(), o = t.getElements(), s = t instanceof br, a = t.disableVAO, l = N(e) && !a, c = I({}, this.shaderDefines || {}, i || {}), u = this._insertDefines(this.vert, c), f = this.getVersion(e, u) + u, h = this._insertDefines(this.frag, c), d = this.getVersion(e, h) + h, m = q(f) + "_" + q(d), {activeAttributes: p, activeUniforms: g} = this.getActiveVars(e, f, d, m), _ = {};
15609
+ const i = t.getDefines(), o = t.getElements(), s = t instanceof br, a = t.disableVAO, l = F(e) && !a, c = E({}, this.shaderDefines || {}, i || {}), u = this._insertDefines(this.vert, c), f = this.getVersion(e, u) + u, h = this._insertDefines(this.frag, c), d = this.getVersion(e, h) + h, m = q(f) + "_" + q(d), {activeAttributes: p, activeUniforms: g} = this.getActiveVars(e, f, d, m), _ = {};
15583
15610
  p.forEach(((t, n) => {
15584
15611
  const r = t.name;
15585
15612
  _[r] = l ? n : e.prop(r);
@@ -15605,7 +15632,7 @@
15605
15632
  l && (b.vao = e.prop("vao")), l && !s || !o || P(o) || (b.elements = e.prop("elements")),
15606
15633
  b.count = e.prop("count"), b.offset = e.prop("offset"), b.primitive = e.prop("primitive"),
15607
15634
  b.framebuffer = e.prop("framebuffer"), s && (b.instances = e.prop("instances")),
15608
- I(b, this.extraCommandProps, n);
15635
+ E(b, this.extraCommandProps, n);
15609
15636
  const y = e(b);
15610
15637
  return p.key = p.map((e => e.name)).join(), y.activeAttributes = p, y;
15611
15638
  }
@@ -15656,27 +15683,29 @@
15656
15683
  class Ji extends Ki {
15657
15684
  getShaderCommandKey(e, t, n) {
15658
15685
  if (e && e.wgpu) {
15659
- const e = t.getShaderFnValues(this.uid);
15660
- if (e) {
15661
- const {funcs: t, key: r, commandKey: i} = e;
15662
- if (!t.length) return i;
15663
- const o = t.map((e => e(null, n)));
15664
- if (Zi.generateValuesKey(o) === r) return i;
15686
+ let e = "";
15687
+ this._gpuFramebuffer && (e = `-${this._gpuFramebuffer.getCommandKey()}`);
15688
+ const r = t.getShaderFnValues(this.uid);
15689
+ if (r) {
15690
+ const {funcs: t, key: i, commandKey: o} = r;
15691
+ if (!t.length) return o + e;
15692
+ const s = t.map((e => e(null, n)));
15693
+ if (Zi.generateValuesKey(s) === i) return o + e;
15665
15694
  }
15666
- const r = this._gpuFramebuffer, i = this.extraCommandProps;
15667
- Zi.readFromREGLCommand(i, t, n, r);
15668
- const o = Zi.getSignatureKey();
15695
+ const i = this._gpuFramebuffer, o = this.extraCommandProps;
15696
+ Zi.readFromREGLCommand(o, t, n, i);
15697
+ const s = Zi.getSignatureKey();
15669
15698
  return t.setShaderFnValues(this.uid, {
15670
15699
  funcs: Zi.functionProps.map((e => e.func)),
15671
15700
  key: Zi.getFnValuesKey(),
15672
- commandKey: o
15673
- }), o;
15701
+ commandKey: s
15702
+ }), s + e;
15674
15703
  }
15675
15704
  return super.getShaderCommandKey(e, t, n);
15676
15705
  }
15677
15706
  createMeshCommand(e, t, n, r) {
15678
15707
  if (e && e.wgpu) {
15679
- const i = this.context, o = this._gpuFramebuffer, s = I({}, this.shaderDefines || {}, t.getDefines()), {vert: a, frag: l} = this._compileWGSLSource(s), c = new Hi(this.name, e, a, l, t, this.contextDesc, s, i), u = new gi, f = I({}, this.extraCommandProps || {}, n || {});
15708
+ const i = this.context, o = this._gpuFramebuffer, s = E({}, this.shaderDefines || {}, t.getDefines()), {vert: a, frag: l} = this._compileWGSLSource(s), c = new Hi(this.name, e, a, l, t, this.contextDesc, s, i), u = new gi, f = E({}, this.extraCommandProps || {}, n || {});
15680
15709
  u.readFromREGLCommand(f, t, r, o);
15681
15710
  const h = c.build(u, o);
15682
15711
  return h.uid = this.uid + "-" + this.commandId++, h;
@@ -15841,10 +15870,9 @@
15841
15870
  draw(e) {
15842
15871
  return this._quadMesh || this._createQuadMesh(e), super.draw(e, this._quadMesh);
15843
15872
  }
15844
- getMeshCommand(e) {
15845
- const t = this.dkey || "";
15846
- return this.commands[t + "_quad"] || (this.commands[t + "_quad"] = this.createMeshCommand(e, this._quadMesh[0])),
15847
- this.commands[t + "_quad"];
15873
+ getMeshCommand(e, t, n) {
15874
+ const r = (this.dkey || "") + this.getShaderCommandKey(e, t, n) + "_quad";
15875
+ return this.commands[r] || (this.commands[r] = this.createMeshCommand(e, t)), this.commands[r];
15848
15876
  }
15849
15877
  _createQuadMesh(e) {
15850
15878
  const t = new Ye({
@@ -15881,10 +15909,6 @@
15881
15909
  }
15882
15910
  });
15883
15911
  }
15884
- getMeshCommand(e, t) {
15885
- const n = (this.dkey || "") + "_fxaa";
15886
- return this.commands[n] || (this.commands[n] = this.createMeshCommand(e, t)), this.commands[n];
15887
- }
15888
15912
  }
15889
15913
 
15890
15914
  var so = "#include <gl2_vert>\nattribute vec2 aPosition;\nattribute vec2 aTexCoord;\nuniform mat4 projViewModelMatrix;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_Position = projViewModelMatrix * vec4(aPosition, 0., 1.);\n vTexCoord = aTexCoord;\n}", ao = "precision mediump float;\n#include <gl2_frag>\nuniform sampler2D baseColorTexture;\nuniform float opacity;\nuniform vec4 baseColor;\nuniform float alphaTest;\n#ifdef HAS_DEBUG\nuniform sampler2D debugTexture;\n#endif\nvarying vec2 vTexCoord;\nvoid main() {\n glFragColor = texture2D(baseColorTexture, vTexCoord);\n glFragColor *= baseColor;\n#ifdef HAS_DEBUG\nvec4 c = texture2D(debugTexture, vTexCoord);\n glFragColor = vec4(c.rgb + glFragColor.rgb * (1. - c.a), c.a + glFragColor.a * (1. - c.a));\n#endif\nif(glFragColor.a < alphaTest) {\n discard;\n }\n glFragColor *= opacity;\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}";
@@ -16375,7 +16399,7 @@
16375
16399
  return multiply$5(n, t.projViewMatrix, t.modelMatrix);
16376
16400
  }
16377
16401
  } ],
16378
- extraCommandProps: I({}, t, {
16402
+ extraCommandProps: E({}, t, {
16379
16403
  blend: {
16380
16404
  enable: !0,
16381
16405
  func: {
@@ -16394,8 +16418,11 @@
16394
16418
  class So extends Qi {
16395
16419
  constructor() {
16396
16420
  super({
16421
+ name: "skybox",
16397
16422
  vert: "#include <gl2_vert>\nattribute vec3 aPosition;\nuniform mat4 projMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 transformMatrix;\nvarying vec3 vWorldPos;\nvoid main() {\n vWorldPos = aPosition;\n mat4 c = mat4(mat3(viewMatrix) * transformMatrix);\n vec4 d = projMatrix * c * vec4(vWorldPos, 1.);\n gl_Position = d.xyww;\n}",
16398
16423
  frag: yo,
16424
+ wgslVert: "struct Uniforms {\n projMatrix: mat4x4f,\n viewMatrix: mat4x4f,\n transformMatrix: mat3x3f,\n};\n@group(0) @binding($b) var<uniform> uniforms: Uniforms;\nstruct VertexInput {\n @location($i) aPosition: vec3f,\n};\nstruct VertexOutput {\n @builtin(position) position: vec4f,\n @location($o) vWorldPos: vec3f,\n};\n@vertex\nfn main(vertexInput: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n output.vWorldPos = vertexInput.aPosition;\n let viewMatrix = uniforms.viewMatrix;\n let m3 = mat3x3f(viewMatrix[0].xyz, viewMatrix[1].xyz, viewMatrix[2].xyz) * uniforms.transformMatrix;\n let rotViewMatrix: mat4x4f = mat4x4f(\n vec4<f32>(m3[0], 0.0),\n vec4<f32>(m3[1], 0.0),\n vec4<f32>(m3[2], 0.0),\n vec4<f32>(0.0, 0.0, 0.0, 1.0)\n );\n let clipPos: vec4f = uniforms.projMatrix * rotViewMatrix * vec4f(output.vWorldPos, 1.0);\n output.position = vec4f(clipPos.xy, clipPos.w, clipPos.w);\n return output;\n}",
16425
+ wgslFrag: "#include <hsv_frag>\nstruct SkyboxUniforms {\n hsv: vec3f,\n #ifdef USE_AMBIENT\n diffuseSPH: array<vec3f, 9>,\n #else\n bias: f32,\n size: f32,\n #endif\n environmentExposure: f32,\n backgroundIntensity: f32,\n};\n@group(0) @binding($b) var<uniform> uniforms: SkyboxUniforms;\n#ifndef USE_AMBIENT\n @group(0) @binding($b) var cubeMap: texture_cube<f32>;\n @group(0) @binding($b) var cubeMapSampler: sampler;\n#endif\nfn textureCubeFixed(tex: texture_cube<f32>, texSampler: sampler, R: vec3f, size: f32, bias: f32) -> vec4f {\n var dir: vec3f = R;\n return textureSampleLevel(tex, texSampler, dir, bias);\n}\nfn computeDiffuseSPH(normal: vec3f, diffuseSPH: array<vec3f, 9>) -> vec3f {\n let x: f32 = normal.x;\n let y: f32 = normal.y;\n let z: f32 = normal.z;\n var result: vec3f = (\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 return max(result, vec3f(0.0));\n}\nfn pseudoRandom(fragCoord: vec2f) -> f32 {\n var p3: vec3f = fract(vec3f(fragCoord.x, fragCoord.y, fragCoord.x) * 0.1031);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n}\n#if TONE_MAPPING\n const toneMappingExposure: f32 = 1.0;\n fn RRTAndODTFit(v: vec3f) -> vec3f {\n let a: vec3f = v * (v + 0.0245786) - 0.000090537;\n let b: vec3f = v * (0.983729 * v + 0.4329510) + 0.238081;\n return a / b;\n }\n fn ACESFilmicToneMapping(color: vec3f) -> vec3f {\n const ACESInputMat: mat3x3f = mat3x3f(\n vec3f(0.59719, 0.07600, 0.02840),\n vec3f(0.35458, 0.90834, 0.13383),\n vec3f(0.04823, 0.01566, 0.83777)\n );\n const ACESOutputMat: mat3x3f = mat3x3f(\n vec3f(1.60475, -0.10208, -0.00327),\n vec3f(-0.53108, 1.10813, -0.07276),\n vec3f(-0.07367, -0.00605, 1.07602)\n );\n var adjustedColor: vec3f = color * toneMappingExposure / 0.6;\n adjustedColor = ACESInputMat * adjustedColor;\n adjustedColor = RRTAndODTFit(adjustedColor);\n adjustedColor = ACESOutputMat * adjustedColor;\n return clamp(adjustedColor, 0, 1);\n }\n fn toneMapping(color: vec3f) -> vec3f {\n return ACESFilmicToneMapping(color);\n }\n fn sRGBTransferOETF(value: vec4f) -> vec4f {\n var result: vec3f;\n let threshold: vec3f = vec3f(0.0031308);\n for (var i: i32 = 0; i < 3; i++) {\n if (value[i] <= threshold[i]) {\n result[i] = value[i] * 12.92;\n } else {\n result[i] = pow(value[i], 0.41666) * 1.055 - 0.055;\n }\n }\n return vec4f(result, value.a);\n }\n fn linearToOutputTexel(value: vec4f) -> vec4f {\n return sRGBTransferOETF(value);\n }\n#endif\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n var envColor: vec4f;\n #ifdef USE_AMBIENT\n var normal: vec3f = normalize(\n vertexOutput.vWorldPos +\n mix(-0.5/255.0, 0.5/255.0, pseudoRandom(vertexOutput.fragCoord.xy)) * 2.0\n );\n envColor = vec4f(computeDiffuseSPH(normal, uniforms.diffuseSPH), 1.0);\n #else\n envColor = textureCubeFixed(\n cubeMap,\n cubeMapSampler,\n vertexOutput.vWorldPos,\n uniforms.size,\n uniforms.bias\n );\n #endif\n var rgb = envColor.rgb;\n rgb *= uniforms.environmentExposure;\n rgb *= uniforms.backgroundIntensity;\n if (length(uniforms.hsv) > 0.0) {\n rgb = hsv_apply3(clamp(rgb, vec3f(0.0), vec3f(1.0)), uniforms.hsv);\n }\n #if TONE_MAPPING\n rgb = toneMapping(rgb);\n let fragColor = linearToOutputTexel(vec4f(rgb, envColor.a));\n #else\n let fragColor = vec4f(rgb, envColor.a);\n #endif\n return fragColor;\n}",
16399
16426
  extraCommandProps: {
16400
16427
  depth: {
16401
16428
  enable: !0,
@@ -16421,7 +16448,7 @@
16421
16448
  }
16422
16449
  _createSkyboxMesh(e) {
16423
16450
  const t = new Ye({
16424
- aPosition: new Int8Array(bo)
16451
+ aPosition: new Float32Array(bo)
16425
16452
  }, null, bo.length / 3);
16426
16453
  t.generateBuffers(e), this._skyboxMesh = [ new xr(t) ], this._meshDefines && (this._skyboxMesh[0].setDefines(this._meshDefines),
16427
16454
  delete this._meshDefines);
@@ -16448,7 +16475,7 @@
16448
16475
  },
16449
16476
  viewport: e
16450
16477
  };
16451
- t && t.extraCommandProps && I(n, t.extraCommandProps);
16478
+ t && t.extraCommandProps && E(n, t.extraCommandProps);
16452
16479
  const r = [];
16453
16480
  super({
16454
16481
  vert: "#define SHADER_NAME HEATMAP_DISPLAY\nuniform mat4 projViewModelMatrix;\nattribute vec3 aPosition;\nvoid main() {\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.);\n}",
@@ -16528,7 +16555,7 @@
16528
16555
  }
16529
16556
  });
16530
16557
  const e = this._layer.getRenderer().createFBOInfo();
16531
- this._fbo = this._regl.framebuffer(e), this._scene = new Er, this.renderer = new Sr(this._regl);
16558
+ this._fbo = this._regl.framebuffer(e), this._scene = new Ir, this.renderer = new Sr(this._regl);
16532
16559
  }
16533
16560
  render(e, t) {
16534
16561
  this._resize(), this.renderer.clear({
@@ -16554,7 +16581,7 @@
16554
16581
  }
16555
16582
  }
16556
16583
 
16557
- class Io extends io {
16584
+ class Eo extends io {
16558
16585
  constructor() {
16559
16586
  super({
16560
16587
  vert: eo,
@@ -16571,9 +16598,9 @@
16571
16598
  }
16572
16599
  }
16573
16600
 
16574
- const Eo = [], Po = [ .03, .03, .03 ], Ro = [], Lo = [], Ho = [], Do = fromRotationTranslation$1([], fromEuler([], 90, 0, 0), [ 0, 0, 0 ]);
16601
+ const Io = [], Po = [ .03, .03, .03 ], Ro = [], Lo = [], Ho = [], Do = fromRotationTranslation$1([], fromEuler([], 90, 0, 0), [ 0, 0, 0 ]);
16575
16602
 
16576
- class No {
16603
+ class Fo {
16577
16604
  constructor(e, t) {
16578
16605
  this._regl = e, this._viewport = t, this._init();
16579
16606
  }
@@ -16585,7 +16612,7 @@
16585
16612
  name: "modelViewMatrix",
16586
16613
  type: "function",
16587
16614
  fn: function(e, t) {
16588
- return multiply$5(Eo, t.viewMatrix, t.modelMatrix);
16615
+ return multiply$5(Io, t.viewMatrix, t.modelMatrix);
16589
16616
  }
16590
16617
  } ],
16591
16618
  extraCommandProps: {
@@ -16600,7 +16627,7 @@
16600
16627
  min: "linear"
16601
16628
  }),
16602
16629
  depth: !0
16603
- }), this._scene = new Er, this.renderer = new Sr(this._regl);
16630
+ }), this._scene = new Ir, this.renderer = new Sr(this._regl);
16604
16631
  }
16605
16632
  _transformRipples(e) {
16606
16633
  const t = e.coordinateToPointAtRes(e.getCenter(), e.getGLRes()), n = e.getGLScale() / e.getGLScale(this._fixZoom), r = set$5(Lo, n, n, n), i = multiply$4(r, Po, r), o = identity$2(Ho);
@@ -16645,7 +16672,7 @@
16645
16672
  }
16646
16673
  }
16647
16674
 
16648
- var Fo = "attribute vec3 aPosition;\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\n#ifdef HAS_TEXTURE\nattribute vec2 aTexCoord;\nvarying vec2 uv;\nvarying vec4 vPos;\n#endif\n#include <get_output>\nvoid main() {\n mat4 c = getPositionMatrix();\n vec4 d = c * getPosition(aPosition);\n gl_Position = projViewModelMatrix * d;\n#ifdef HAS_TEXTURE\nuv = aTexCoord;\n vPos = getPosition(aPosition);\n#endif\n}";
16675
+ var No = "attribute vec3 aPosition;\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\n#ifdef HAS_TEXTURE\nattribute vec2 aTexCoord;\nvarying vec2 uv;\nvarying vec4 vPos;\n#endif\n#include <get_output>\nvoid main() {\n mat4 c = getPositionMatrix();\n vec4 d = c * getPosition(aPosition);\n gl_Position = projViewModelMatrix * d;\n#ifdef HAS_TEXTURE\nuv = aTexCoord;\n vPos = getPosition(aPosition);\n#endif\n}";
16649
16676
 
16650
16677
  const Bo = [ 0, 0, 0, 1 ];
16651
16678
 
@@ -16679,7 +16706,7 @@
16679
16706
  fn: (e, t) => multiply$5([], t.projViewMatrix, t.modelMatrix)
16680
16707
  } ];
16681
16708
  this._maskColorShader = new Qi({
16682
- vert: Fo,
16709
+ vert: No,
16683
16710
  frag: "#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 maskColor;\n#ifdef HAS_TEXTURE\nuniform sampler2D maskTexture;\nvarying vec2 uv;\nuniform vec3 mask_position0;\nuniform vec3 mask_position1;\nuniform vec3 mask_position2;\nuniform vec3 mask_position3;\nvarying vec4 vPos;\nvec2 c(vec2 d, vec2 a, vec2 b, vec2 e, vec2 f) {\n vec2 h = vec2(.5);\n for(int i = 0; i < 10; i++) {\n float j = h.x;\n float k = h.y;\n vec2 l = (1. - j) * (1. - k) * a + j * (1. - k) * b + j * k * e + (1. - j) * k * f;\n vec2 m = d - l;\n if(length(m) < .001)\n break;\n vec2 n = -(1. - k) * a + (1. - k) * b + k * e - k * f;\n vec2 o = -(1. - j) * a - j * b + j * e + (1. - j) * f;\n float A = n.x * o.y - n.y * o.x;\n if(abs(A) > .0001) {\n vec2 B = vec2((m.x * o.y - m.y * o.x) / A, (m.y * n.x - m.x * n.y) / A);\n h += B;\n }\n h = clamp(h, .0, 1.);\n }\n return h;\n}\n#endif\nvoid main() {\n \n#ifdef HAS_TEXTURE\nvec2 d = vPos.xy;\n vec2 C = c(d, mask_position0.xy, mask_position1.xy, mask_position2.xy, mask_position3.xy);\n gl_FragColor = texture2D(maskTexture, C);\n gl_FragColor.a *= maskColor.a;\n#else\nif(maskColor.a == .0) {\n discard;\n }\n gl_FragColor = maskColor;\n#endif\n}",
16684
16711
  uniforms: e,
16685
16712
  extraCommandProps: {
@@ -16690,13 +16717,13 @@
16690
16717
  }
16691
16718
  }
16692
16719
  }), this._maskModeShader = new Qi({
16693
- vert: Fo,
16720
+ vert: No,
16694
16721
  frag: "#ifdef GL_ES\nprecision highp float;\n#endif\nuniform float maskMode;\n#ifdef HAS_MASK_FLAT\nuniform float flatHeight;\n#endif\n#ifdef HAS_MASK_COLOR\nuniform vec2 heightRange;\n#endif\nvoid main() {\n \n#if defined(HAS_MASK_FLAT)\ngl_FragColor = vec4(maskMode, flatHeight, .0, 1.);\n#elif defined(HAS_MASK_COLOR)\ngl_FragColor = vec4(maskMode, .0, heightRange.x, heightRange.y);\n#else\ngl_FragColor = vec4(maskMode, .0, .0, .0);\n#endif\n}",
16695
16722
  uniforms: e,
16696
16723
  extraCommandProps: {
16697
16724
  viewport: this._viewport
16698
16725
  }
16699
- }), this._scene = new Er;
16726
+ }), this._scene = new Ir;
16700
16727
  }
16701
16728
  render(e, t) {
16702
16729
  this._resize(), this.renderer.clear({
@@ -16730,7 +16757,7 @@
16730
16757
  }
16731
16758
  }
16732
16759
 
16733
- const Go = "\n#ifdef GL_ES\n precision highp float;\n#endif\nuniform mat3 ring;\n\nuniform float effectTime;\nvarying vec4 vWorldPosition;\n\nvec3 hsb2rgb(in vec3 c) {\n vec3 rgb = clamp(abs(mod(c.x * 6.0 + vec3(0.0,4.0,2.0), 6.0)-3.0)-1.0, 0.0, 1.0 );\n rgb = rgb*rgb*(3.0-2.0*rgb);\n return c.z * mix( vec3(1.0), rgb, c.y);\n}\n\nvec4 glowring(vec4 worldPos, vec2 center, float radius, float speed, vec3 effectColor, float direction, float height) {\n vec2 dir = vec2(worldPos.xy) - center;\n float len = length(dir);\n if (len > radius) {\n return vec4(0.0);\n } else {\n vec2 uv = vec2(0.0);\n if (direction == 0.0) {\n vec2 lefttop = vec2(center.x - radius, center.y + radius);\n vec2 rightbottom = vec2(center.x + radius, center.y - radius);\n uv = vec2(abs(worldPos.x - lefttop.x) / (2.0 * radius), abs(worldPos.y - rightbottom.y) / (2.0 * radius));\n uv.x -= 0.5;\n uv.y -= 0.5;\n } else {\n if (worldPos.z < 0.1) {\n return vec4(0.0);\n }\n uv = vec2(0.0, worldPos.z / height);\n }\n float itime = (effectTime / 2.0) * speed;\n float r = length(uv) * 3.0;\n vec3 color = hsb2rgb(effectColor);\n\n float a = pow(r, 2.0);\n float b = sin(r * 0.8 - 1.6);\n float c = sin(r - 0.010);\n float s = sin(a - itime * 3.0 + b) * c;\n float t = abs(1.0 / (s * 10.8)) - 0.01;\n color *= t;\n vec4 newColor = vec4(color, t);\n return newColor;\n }\n}\n\nvoid main() {\n vec4 color = vec4(0.0);\n gl_FragColor = color;\n}\n", zo = [];
16760
+ const zo = "\n#ifdef GL_ES\n precision highp float;\n#endif\nuniform mat3 ring;\n\nuniform float effectTime;\nvarying vec4 vWorldPosition;\n\nvec3 hsb2rgb(in vec3 c) {\n vec3 rgb = clamp(abs(mod(c.x * 6.0 + vec3(0.0,4.0,2.0), 6.0)-3.0)-1.0, 0.0, 1.0 );\n rgb = rgb*rgb*(3.0-2.0*rgb);\n return c.z * mix( vec3(1.0), rgb, c.y);\n}\n\nvec4 glowring(vec4 worldPos, vec2 center, float radius, float speed, vec3 effectColor, float direction, float height) {\n vec2 dir = vec2(worldPos.xy) - center;\n float len = length(dir);\n if (len > radius) {\n return vec4(0.0);\n } else {\n vec2 uv = vec2(0.0);\n if (direction == 0.0) {\n vec2 lefttop = vec2(center.x - radius, center.y + radius);\n vec2 rightbottom = vec2(center.x + radius, center.y - radius);\n uv = vec2(abs(worldPos.x - lefttop.x) / (2.0 * radius), abs(worldPos.y - rightbottom.y) / (2.0 * radius));\n uv.x -= 0.5;\n uv.y -= 0.5;\n } else {\n if (worldPos.z < 0.1) {\n return vec4(0.0);\n }\n uv = vec2(0.0, worldPos.z / height);\n }\n float itime = (effectTime / 2.0) * speed;\n float r = length(uv) * 3.0;\n vec3 color = hsb2rgb(effectColor);\n\n float a = pow(r, 2.0);\n float b = sin(r * 0.8 - 1.6);\n float c = sin(r - 0.010);\n float s = sin(a - itime * 3.0 + b) * c;\n float t = abs(1.0 / (s * 10.8)) - 0.01;\n color *= t;\n vec4 newColor = vec4(color, t);\n return newColor;\n }\n}\n\nvoid main() {\n vec4 color = vec4(0.0);\n gl_FragColor = color;\n}\n", Go = [];
16734
16761
 
16735
16762
  class Vo {
16736
16763
  constructor(e, t, n) {
@@ -16738,7 +16765,7 @@
16738
16765
  }
16739
16766
  _init() {
16740
16767
  const e = this._layer.getRenderer().createFBOInfo();
16741
- this._fbo = this._regl.framebuffer(e), this._scene = new Er, this.renderer = new Sr(this._regl);
16768
+ this._fbo = this._regl.framebuffer(e), this._scene = new Ir, this.renderer = new Sr(this._regl);
16742
16769
  }
16743
16770
  render(e, t) {
16744
16771
  this._resize(), this.renderer.clear({
@@ -16757,7 +16784,7 @@
16757
16784
  name: "modelViewMatrix",
16758
16785
  type: "function",
16759
16786
  fn: function(e, t) {
16760
- return multiply$5(zo, t.viewMatrix, t.modelMatrix);
16787
+ return multiply$5(Go, t.viewMatrix, t.modelMatrix);
16761
16788
  }
16762
16789
  } ],
16763
16790
  extraCommandProps: {
@@ -16777,7 +16804,7 @@
16777
16804
  _createFragSource(e) {
16778
16805
  let t = "";
16779
16806
  for (let n = 0; n < e.length; n++) t += `uniform mat3 ring${n};\n`;
16780
- t = Go.replace("uniform mat3 ring;", t);
16807
+ t = zo.replace("uniform mat3 ring;", t);
16781
16808
  let n = "";
16782
16809
  for (let t = 0; t < e.length; t++) n += `\n vec2 center${t} = vec2(ring${t}[0][0], ring${t}[0][1]);\n float radius${t} = ring${t}[0][2];\n float speed${t} = ring${t}[1][0];\n vec3 color${t} = vec3(ring${t}[1][1], ring${t}[1][2], ring${t}[2][0]);\n float direction${t} = ring${t}[2][1];\n float height${t} = ring${t}[2][2];\n vec4 ringColor${t} = glowring(vWorldPosition, center${t}, radius${t}, speed${t}, color${t}, direction${t}, height${t});\n color += ringColor${t};\n `;
16783
16810
  return n += "gl_FragColor = color;", t = t.replace("gl_FragColor = color;", n),
@@ -16862,7 +16889,7 @@
16862
16889
  const t = e._getAttributeData(n);
16863
16890
  n !== e.desc.positionAttribute ? r[n] = t : r[n] = t.slice();
16864
16891
  }
16865
- const i = void 0 !== n.length ? n.slice() : n, o = JSON.parse(JSON.stringify(e.desc)), s = new Et(r, i, 0, o);
16892
+ const i = void 0 !== n.length ? n.slice() : n, o = JSON.parse(JSON.stringify(e.desc)), s = new It(r, i, 0, o);
16866
16893
  return s.properties = e.properties, s;
16867
16894
  }
16868
16895
  }
@@ -17050,7 +17077,7 @@
17050
17077
  }
17051
17078
  n && r.TEXCOORD_0 && !r.TEXCOORD_0 && (r.TEXCOORD_1 = r.TEXCOORD_0);
17052
17079
  const o = {};
17053
- for (const e in r) o[e] = I({}, r[e]), t && (o[e].buffer = yt(t, r[e], {
17080
+ for (const e in r) o[e] = E({}, r[e]), t && (o[e].buffer = yt(t, r[e], {
17054
17081
  dimension: r[e].itemSize
17055
17082
  }));
17056
17083
  if (e.morphTargets) {
@@ -17393,18 +17420,21 @@
17393
17420
  const xs = function() {
17394
17421
  const e = [ 0, 0, 0 ], t = 90 * Math.PI / 180, n = [ 0, 0, 0, 0 ], r = new Array(16);
17395
17422
  return function(i, o, s, a, l, u) {
17396
- const f = [ lookAt([], e, [ 1, 0, 0 ], u && u[0] || [ 0, -1, 0 ]), lookAt([], e, [ -1, 0, 0 ], u && u[1] || [ 0, -1, 0 ]), lookAt([], e, [ 0, 1, 0 ], u && u[2] || [ 0, 0, 1 ]), lookAt([], e, [ 0, -1, 0 ], u && u[3] || [ 0, 0, -1 ]), lookAt([], e, [ 0, 0, 1 ], u && u[4] || [ 0, -1, 0 ]), lookAt([], e, [ 0, 0, -1 ], u && u[5] || [ 0, -1, 0 ]) ], h = {
17423
+ const f = [ lookAt([], e, [ 1, 0, 0 ], u && u[0] || [ 0, -1, 0 ]), lookAt([], e, [ -1, 0, 0 ], u && u[1] || [ 0, -1, 0 ]), lookAt([], e, [ 0, 1, 0 ], u && u[2] || [ 0, 0, 1 ]), lookAt([], e, [ 0, -1, 0 ], u && u[3] || [ 0, 0, -1 ]), lookAt([], e, [ 0, 0, 1 ], u && u[4] || [ 0, -1, 0 ]), lookAt([], e, [ 0, 0, -1 ], u && u[5] || [ 0, -1, 0 ]) ];
17424
+ let h;
17425
+ h = !!i.wgpu ? perspectiveZO(r, t, 1, .5, 1.1) : perspective(r, t, 1, .5, 1.1);
17426
+ const d = {
17397
17427
  context: {
17398
17428
  viewMatrix: function(e, t, n) {
17399
17429
  return f[n];
17400
17430
  },
17401
- projMatrix: perspective(r, t, 1, .5, 1.1)
17431
+ projMatrix: h
17402
17432
  }
17403
17433
  };
17404
- o && (o.faces ? h.framebuffer = function(e, t, n) {
17434
+ o && (o.faces ? d.framebuffer = function(e, t, n) {
17405
17435
  return o.faces[n];
17406
- } : h.framebuffer = o);
17407
- return i(h)(6, ((e, t, r) => {
17436
+ } : d.framebuffer = o);
17437
+ return i(d)(6, ((e, t, r) => {
17408
17438
  const c = {
17409
17439
  color: n,
17410
17440
  depth: 1
@@ -17439,9 +17469,9 @@
17439
17469
  nz: [ 0, 1, 2, 1, -1, 1 ]
17440
17470
  }, ks = [ "px", "nx", "py", "ny", "pz", "nz" ];
17441
17471
 
17442
- let Is;
17472
+ let Es;
17443
17473
 
17444
- const Es = Kr.compile(yo);
17474
+ const Is = Kr.compile(yo);
17445
17475
 
17446
17476
  function Ps(e, t = {}, n) {
17447
17477
  e = Ds(e);
@@ -17454,7 +17484,7 @@
17454
17484
  });
17455
17485
  l = function(e, t, n) {
17456
17486
  const r = e({
17457
- frag: Es,
17487
+ frag: Is,
17458
17488
  vert: ys,
17459
17489
  attributes: {
17460
17490
  "aPosition": bs.vertices
@@ -17516,7 +17546,7 @@
17516
17546
  const {prefilterMap: f, prefilterMipmap: h} = function(e, t, n, r, i, o) {
17517
17547
  const s = function(e, t, n, r, i, o) {
17518
17548
  r = r || 1024, i = i || 256;
17519
- const s = Fs(r, i), a = e.texture({
17549
+ const s = Ns(r, i), a = e.texture({
17520
17550
  data: s,
17521
17551
  width: i,
17522
17552
  height: r,
@@ -17566,7 +17596,7 @@
17566
17596
  let r = t;
17567
17597
  if (o) {
17568
17598
  r = new Uint16Array(t.length);
17569
- for (let e = 0; e < t.length; e++) r[e] = Math.min(Gr.toHalfFloat(t[e]), 65504);
17599
+ for (let e = 0; e < t.length; e++) r[e] = Math.min(zr.toHalfFloat(t[e]), 65504);
17570
17600
  }
17571
17601
  d[n] || (d[n] = {
17572
17602
  mipmap: []
@@ -17674,7 +17704,7 @@
17674
17704
  const t = e.read();
17675
17705
  if (r) {
17676
17706
  const e = new Uint16Array(t.length);
17677
- for (let n = 0; n < t.length; n++) e[n] = Math.min(Gr.toHalfFloat(t[n]), 65504);
17707
+ for (let n = 0; n < t.length; n++) e[n] = Math.min(zr.toHalfFloat(t[n]), 65504);
17678
17708
  a.push(e);
17679
17709
  } else a.push(t);
17680
17710
  })), s.destroy(), c.destroy(), a;
@@ -17684,9 +17714,9 @@
17684
17714
 
17685
17715
  function Ds(e) {
17686
17716
  return e.vao && e || function() {
17687
- if (!Is) {
17717
+ if (!Es) {
17688
17718
  const e = document.createElement("canvas").getContext("webgl");
17689
- Is = S({
17719
+ Es = S({
17690
17720
  optionalExtensions: [ "OES_texture_half_float", "OES_texture_half_float_linear", "OES_texture_float", "OES_texture_float_linear" ],
17691
17721
  attributes: {
17692
17722
  alpha: !0,
@@ -17695,18 +17725,18 @@
17695
17725
  preserveDrawingBuffer: !0
17696
17726
  },
17697
17727
  gl: e
17698
- }), Is.on("lost", (() => {
17699
- Is.destroy(), Is = null;
17728
+ }), Es.on("lost", (() => {
17729
+ Es.destroy(), Es = null;
17700
17730
  }));
17701
17731
  }
17702
- return Is;
17732
+ return Es;
17703
17733
  }();
17704
17734
  }
17705
17735
 
17706
- function Ns(e, t, n, r) {
17736
+ function Fs(e, t, n, r) {
17707
17737
  const i = Ds(e);
17708
17738
  t = t || 256;
17709
- const o = Fs(n = n || 1024, r = r || 256), s = i.texture({
17739
+ const o = Ns(n = n || 1024, r = r || 256), s = i.texture({
17710
17740
  data: o,
17711
17741
  width: r,
17712
17742
  height: n,
@@ -17761,7 +17791,7 @@
17761
17791
  return u.destroy(), a.destroy(), l.destroy(), s.destroy(), c;
17762
17792
  }
17763
17793
 
17764
- function Fs(e, t) {
17794
+ function Ns(e, t) {
17765
17795
  const n = new Float32Array(e * t * 4);
17766
17796
  for (let r = 0; r < e; r++) {
17767
17797
  const {x: i, y: o} = Bs(r, e);
@@ -17787,7 +17817,7 @@
17787
17817
  return e._gl instanceof WebGL2RenderingContext || e.hasExtension("OES_texture_half_float");
17788
17818
  }
17789
17819
 
17790
- var Gs = Object.freeze({
17820
+ var zs = Object.freeze({
17791
17821
  __proto__: null,
17792
17822
  createIBLMaps: function(e, t = {}) {
17793
17823
  return Ps(e, t);
@@ -17799,11 +17829,11 @@
17799
17829
  }));
17800
17830
  }));
17801
17831
  },
17802
- generateDFGLUT: Ns,
17832
+ generateDFGLUT: Fs,
17803
17833
  supportFloat16: Us
17804
17834
  });
17805
17835
 
17806
- const zs = {
17836
+ const Gs = {
17807
17837
  "uvScale": [ 1, 1 ],
17808
17838
  "uvOffset": [ 0, 0 ],
17809
17839
  "uvRotation": 0,
@@ -17841,7 +17871,7 @@
17841
17871
 
17842
17872
  class Vs extends Ht {
17843
17873
  constructor(e) {
17844
- const t = I({}, zs);
17874
+ const t = E({}, Gs);
17845
17875
  (e.metallicRoughnessTexture || e.metallicRoughnessTexture) && (t.roughnessFactor = 1,
17846
17876
  t.metallicFactor = 1), super(e, t);
17847
17877
  }
@@ -17865,7 +17895,7 @@
17865
17895
  }
17866
17896
  }
17867
17897
 
17868
- class js extends(Gt(Vs)){}
17898
+ class js extends(zt(Vs)){}
17869
17899
 
17870
17900
  function Ws(e, t, n) {
17871
17901
  if (n.ambientUpdate) {
@@ -17937,7 +17967,7 @@
17937
17967
  return s.environmentExposure = P(i.exposure) ? i.exposure : 1, s.environmentOrientation = i.orientation || 0,
17938
17968
  s.light0_diffuse = [ ...o.color || [ 1, 1, 1 ], 1 ], s.light0_viewDirection = o.direction || [ 1, 1, -1 ],
17939
17969
  s;
17940
- }(e, t), u = I({
17970
+ }(e, t), u = E({
17941
17971
  viewMatrix: o,
17942
17972
  projMatrix: s,
17943
17973
  projViewMatrix: e.projViewMatrix,
@@ -17945,14 +17975,14 @@
17945
17975
  outSize: [ l.width, l.height ],
17946
17976
  cameraNearFar: [ e.cameraNear, e.cameraFar ]
17947
17977
  }, c);
17948
- return u.brdfLUT = n, r && r.renderUniforms && I(u, r.renderUniforms), u.halton = i || qs,
17978
+ return u.brdfLUT = n, r && r.renderUniforms && E(u, r.renderUniforms), u.halton = i || qs,
17949
17979
  u;
17950
17980
  },
17951
17981
  isSupported: function(e) {
17952
17982
  return !!e.wgpu || e.hasExtension("EXT_shader_texture_lod");
17953
17983
  },
17954
17984
  loginIBLResOnCanvas: function(e, t, n) {
17955
- if (!e.dfgLUT && (e.dfgLUT = Ns(t), e.dfgLUT.mtkRefCount = 0, n)) {
17985
+ if (!e.dfgLUT && (e.dfgLUT = Fs(t), e.dfgLUT.mtkRefCount = 0, n)) {
17956
17986
  const r = (...n) => Ws.call(this, e, t, ...n);
17957
17987
  n.on("updatelights", r), e._iblResListener = r;
17958
17988
  }
@@ -18400,6 +18430,7 @@
18400
18430
  }) : n = e, new Si(this, n);
18401
18431
  }
18402
18432
  texture(e, t) {
18433
+ void 0 === e && (e = 1);
18403
18434
  let n = e;
18404
18435
  return P(e) && (n = {
18405
18436
  width: e,
@@ -18487,7 +18518,7 @@
18487
18518
  t.setPipeline(n), t.draw(3), t.end(), this.submit();
18488
18519
  }
18489
18520
  _getClearPipeline(e) {
18490
- const t = e === this.getDefaultFramebuffer(), n = e.colorTexture && e.colorTexture.config.sampleCount || 1, r = t || !!e.depthTexture;
18521
+ const t = e === this.getDefaultFramebuffer(), n = e.colorTexture && e.colorTexture.config.sampleCount || 1, r = t || e.depthTexture && e.depthTexture.gpuFormat.format;
18491
18522
  let i;
18492
18523
  i = e.colorTexture ? e.colorTexture.gpuFormat.format : navigator.gpu.getPreferredCanvasFormat(),
18493
18524
  this._clearPipelines = this._clearPipelines || {};
@@ -18511,7 +18542,7 @@
18511
18542
  r && (l.depthStencil = {
18512
18543
  depthWriteEnabled: !1,
18513
18544
  depthCompare: "always",
18514
- format: "depth24plus-stencil8"
18545
+ format: !0 === r ? "depth24plus-stencil8" : r
18515
18546
  }), n > 1 && (l.multisample = {
18516
18547
  count: n
18517
18548
  });
@@ -18521,16 +18552,16 @@
18521
18552
  }
18522
18553
 
18523
18554
  const Ca = {
18524
- parseHDR: Fr
18555
+ parseHDR: Nr
18525
18556
  }, Oa = {
18526
- PBRHelper: Gs,
18557
+ PBRHelper: zs,
18527
18558
  StandardMaterial: Vs,
18528
18559
  StandardSpecularGlossinessMaterial: js,
18529
18560
  StandardShader: class extends Qi {
18530
18561
  constructor(e = {}) {
18531
18562
  let t = e.extraCommandProps || {};
18532
18563
  const n = e.uniforms;
18533
- t = I({}, t);
18564
+ t = E({}, t);
18534
18565
  const r = e.defines || {}, i = [], o = [], s = [], a = [], l = [], u = [ {
18535
18566
  name: "modelNormalMatrix",
18536
18567
  type: "function",
@@ -18559,8 +18590,8 @@
18559
18590
  const f = {
18560
18591
  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}",
18561
18592
  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}",
18562
- 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\n @location($i) aTangent: vec4f,\n #elif HAS_NORMAL\n #ifdef NORMAL_IS_INT\n @location($i) aNormal: vec4i,\n #else\n @location($i) aNormal: vec3f,\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, &output);\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}",
18563
- 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#if HAS_SHADOWING && !HAS_BLOOM\n #include <vsm_shadow_frag>\n#endif\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 #ifdef HAS_PATTERN\n #ifndef HAS_PATTERN_ANIM\n linePatternAnimSpeed: f32,\n #endif\n #ifndef HAS_PATTERN_GAP\n linePatternGap: f32,\n #endif\n linePatternGapColor: vec4f,\n flipY: f32,\n animSpeedScale: f32,\n uvScale: vec2f,\n atlasSize: vec2f,\n #endif\n};\nstruct ShaderUniforms {\n #if HAS_IBL_LIGHTING\n hdrHSV: vec3f,\n diffuseSPH: array<vec3f, 9>,\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 #ifdef HAS_PATTERN\n currentTime: f32,\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 prefilterMapSampler: 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\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 = shaderUniforms.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, prefilterMapSampler, 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, shaderUniforms.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}\n#ifdef HAS_PATTERN\n fn computeUV(input: VertexOutput, texCoord: vec2f) -> vec2f {\n let uv = texCoord % 1.0;\n let uvStart = vec2f(input.vTexInfo.xy);\n let uvSize = vec2f(input.vTexInfo.zw);\n return (uvStart + uv * uvSize) / uniforms.atlasSize;\n }\n#endif\nfn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {\n var materialUniforms: MaterialUniforms;\n var uv: vec2f;\n#ifdef HAS_MAP\n 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 += (shaderUniforms.currentTime * -animSpeed * 0.2) % plusGapWidth;\n let patternx = (linesofar / plusGapWidth) % 1.0;\n let patterny = (uniforms.flipY * vertexOutput.vNormalY) % 1.0;\n let texCoord = vec2f(patternx * (1.0 + myGap) * uniforms.uvScale[0], patterny * uniforms.uvScale[1]);\n uv = computeUV(vertexOutput, texCoord);\n var patternColor = textureSample(linePatternFile, linePatternFileSampler, uv);\n let inGap = clamp(sign(1.0 / (1.0 + myGap) - patternx) + 0.000001, 0.0, 1.0);\n 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 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, -nmap.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, -nmap.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(vertexOutput);\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 = frag.rgb * (1.0 - skinColor.a) + skinColor.rgb * skinColor.a;\n #if HAS_SHADOWING && !HAS_BLOOM\n frag = shadow_blend(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}",
18593
+ 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\n @location($i) aTangent: vec4f,\n #elif HAS_NORMAL\n #ifdef NORMAL_IS_INT\n @location($i) aNormal: vec4i,\n #else\n @location($i) aNormal: vec3f,\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(input, &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, &output);\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}",
18594
+ 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#if HAS_SHADOWING && !HAS_BLOOM\n #include <vsm_shadow_frag>\n#endif\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 #ifdef MESH_ENV_EXPO\n environmentExposure: f32,\n #endif\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 #ifdef HAS_PATTERN\n #ifndef HAS_PATTERN_ANIM\n linePatternAnimSpeed: f32,\n #endif\n #ifndef HAS_PATTERN_GAP\n linePatternGap: f32,\n #endif\n linePatternGapColor: vec4f,\n flipY: f32,\n animSpeedScale: f32,\n uvScale: vec2f,\n atlasSize: vec2f,\n #endif\n};\nstruct ShaderUniforms {\n #if HAS_IBL_LIGHTING\n hdrHSV: vec3f,\n diffuseSPH: array<vec3f, 9>,\n prefilterMiplevel: vec2f,\n prefilterSize: vec2f,\n #else\n ambientColor: vec3f,\n #endif\n cameraPosition: vec3f,\n cameraNearFar: vec2f,\n #ifndef MESH_ENV_EXPO\n environmentExposure: f32,\n #endif\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 #ifdef HAS_PATTERN\n currentTime: f32,\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 prefilterMapSampler: 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\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 = shaderUniforms.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, prefilterMapSampler, 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, shaderUniforms.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}\n#ifdef HAS_PATTERN\n fn computeUV(input: VertexOutput, texCoord: vec2f) -> vec2f {\n let uv = texCoord % 1.0;\n let uvStart = vec2f(input.vTexInfo.xy);\n let uvSize = vec2f(input.vTexInfo.zw);\n return (uvStart + uv * uvSize) / uniforms.atlasSize;\n }\n#endif\nfn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {\n var materialUniforms: MaterialUniforms;\n var uv: vec2f;\n#ifdef HAS_MAP\n 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 += (shaderUniforms.currentTime * -animSpeed * 0.2) % plusGapWidth;\n let patternx = (linesofar / plusGapWidth) % 1.0;\n let patterny = (uniforms.flipY * vertexOutput.vNormalY) % 1.0;\n let texCoord = vec2f(patternx * (1.0 + myGap) * uniforms.uvScale[0], patterny * uniforms.uvScale[1]);\n uv = computeUV(vertexOutput, texCoord);\n var patternColor = textureSample(linePatternFile, linePatternFileSampler, uv);\n let inGap = clamp(sign(1.0 / (1.0 + myGap) - patternx) + 0.000001, 0.0, 1.0);\n 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 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, -nmap.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, -nmap.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 #ifdef MESH_ENV_EXPO\n let environmentExposure = materialUniforms.environmentExposure;\n #else\n let environmentExposure = shaderUniforms.environmentExposure;\n #endif\n var specularAO = 1.0;\n let materialAO = getMaterialOcclusion();\n diffuse *= 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 *= 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(vertexOutput);\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 = frag.rgb * (1.0 - skinColor.a) + skinColor.rgb * skinColor.a;\n #if HAS_SHADOWING && !HAS_BLOOM\n frag = shadow_blend(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}",
18564
18595
  uniforms: u,
18565
18596
  extraCommandProps: t,
18566
18597
  defines: r
@@ -18595,7 +18626,7 @@
18595
18626
 
18596
18627
  ka.flatten = He;
18597
18628
 
18598
- var Ia = Object.freeze({
18629
+ var Ea = Object.freeze({
18599
18630
  __proto__: null,
18600
18631
  AbstractTexture: oe,
18601
18632
  BloomPass: go,
@@ -18625,7 +18656,7 @@
18625
18656
  },
18626
18657
  Constants: ne,
18627
18658
  CopyShader: wo,
18628
- EdgeGeometry: Et,
18659
+ EdgeGeometry: It,
18629
18660
  EdgeShader: class extends Qi {
18630
18661
  constructor(e = {}) {
18631
18662
  const t = [], n = e.uniforms, r = [ {
@@ -18648,7 +18679,7 @@
18648
18679
  FBORayPicking: class {
18649
18680
  constructor(e, {name: t, vert: n, wgslVert: r, uniforms: i, defines: o, extraCommandProps: s, enableStencil: a}, l, c) {
18650
18681
  this._renderer = e, this._fbo = l, this._map = c, this._clearFbo(l), this._name = t || "fboraypicking",
18651
- this._vert = n, this._wgslVert = r, this._uniforms = i, this._defines = o, this._extraCommandProps = I({}, s),
18682
+ this._vert = n, this._wgslVert = r, this._uniforms = i, this._defines = o, this._extraCommandProps = E({}, s),
18652
18683
  delete this._extraCommandProps.blend, a ? this._extraCommandProps.stencil = {
18653
18684
  enable: a,
18654
18685
  mask: 255,
@@ -18715,7 +18746,7 @@
18715
18746
  uniforms: e,
18716
18747
  defines: o,
18717
18748
  extraCommandProps: i
18718
- }), this._scene = new Er, this._scene1 = new Er;
18749
+ }), this._scene = new Ir, this._scene1 = new Ir;
18719
18750
  }
18720
18751
  filter() {
18721
18752
  return !0;
@@ -18959,7 +18990,7 @@
18959
18990
  }
18960
18991
  },
18961
18992
  FogPass: ko,
18962
- FogShader: Io,
18993
+ FogShader: Eo,
18963
18994
  FxaaShader: oo,
18964
18995
  GLTFHelper: fs,
18965
18996
  GLTFManager: class {
@@ -19053,7 +19084,7 @@
19053
19084
  }(f.content);
19054
19085
  const h = q(u.content) + "-" + q(f.content);
19055
19086
  this._khrShaders[h] || (this._khrShaders[h] = this._createTechniqueShader(h, i, s, this._commandProps, r));
19056
- const {attributeSemantics: d} = this._khrShaders[h], m = this._createGeometry(e, d, n, h), p = I({}, a);
19087
+ const {attributeSemantics: d} = this._khrShaders[h], m = this._createGeometry(e, d, n, h), p = E({}, a);
19057
19088
  for (const e in a) if (l.uniforms[e] && 35678 === l.uniforms[e].type) {
19058
19089
  const n = a[e].index, r = t.textures[n];
19059
19090
  p[e] = this._getTexture(r);
@@ -19155,7 +19186,7 @@
19155
19186
  Material: Ht,
19156
19187
  Mesh: xr,
19157
19188
  MeshShader: Qi,
19158
- PhongMaterial: Ft,
19189
+ PhongMaterial: Nt,
19159
19190
  PhongShader: class extends Qi {
19160
19191
  constructor(e = {}) {
19161
19192
  const t = [], n = [], r = e.uniforms, i = [ {
@@ -19175,8 +19206,8 @@
19175
19206
  name: "phong",
19176
19207
  vert: e.vert || "#include <gl2_vert>\nattribute vec3 aPosition;\n#include <line_extrusion_vert>\n#ifdef HAS_MAP\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\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\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\nvarying vec4 vColor;\n#elif defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nattribute vec3 aColor0;\n#else\nattribute vec4 aColor0;\n#endif\nvarying vec4 vColor;\n#endif\nvarying vec3 vFragPos;\nvarying vec3 vNormal;\nuniform mat4 projMatrix;\nuniform mat3 modelNormalMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 positionMatrix;\nuniform vec2 halton;\nuniform vec2 outSize;\nuniform mat4 projViewMatrix;\n#include <highlight_vert>\n#include <get_output>\n#include <heatmap_render_vert>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\nattribute float aExtrusionOpacity;\nvarying float vExtrusionOpacity;\n#endif\n#if defined(HAS_TANGENT)\nvarying vec4 vTangent;\n#endif\nvoid c(const highp vec4 q, out highp vec3 d) {\n d = vec3(.0, .0, 1.) + vec3(2., -2., -2.) * q.x * q.zwx + vec3(2., 2., -2.) * q.y * q.wzy;\n}\nvoid c(const highp vec4 q, out highp vec3 d, out highp vec3 t) {\n c(q, d);\n t = vec3(1., .0, .0) + vec3(-2., 2., -2.) * q.y * q.yxw + vec3(-2., 2., 2.) * q.z * q.zwx;\n}\n#include <vertex_color_vert>\nvoid main() {\n \n#ifdef IS_LINE_EXTRUSION\nvec4 e = getPosition(getLineExtrudePosition(aPosition));\n#else\nvec4 e = getPosition(aPosition);\n#endif\nmat4 f = getPositionMatrix();\n vFragPos = vec3(modelMatrix * f * e);\n#if defined(HAS_NORMAL) || defined(HAS_TANGENT)\nmat3 h = modelNormalMatrix * mat3(f);\n vec3 i;\n#if defined(HAS_TANGENT)\nvec3 t;\n c(aTangent, i, t);\n vTangent = vec4(h * t, aTangent.w);\n#else\ni = decode_getNormal(aNormal);\n#endif\nvec3 j = appendMorphNormal(i);\n vNormal = normalize(h * j);\n#else\nvNormal = vec3(.0);\n#endif\nmat4 k = projMatrix;\n k[2].xy += halton.xy / outSize.xy;\n#ifdef HAS_MASK_EXTENT\ngl_Position = k * getMaskPosition(f * e, modelMatrix);\n#else\ngl_Position = k * modelViewMatrix * f * e;\n#endif\n#ifdef HAS_MAP\nvec2 l = decode_getTexcoord(aTexCoord);\n vTexCoord = l * uvScale + uvOffset;\n#endif\n#ifdef HAS_AO_MAP\nvec2 m = decode_getTexcoord(aTexCoord1);\n vTexCoord1 = m * uvScale + uvOffset;\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\nvExtrusionOpacity = aExtrusionOpacity;\n#endif\n#if defined(HAS_COLOR)\nvColor = aColor / 255.;\n#elif defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nvColor = vec4(aColor0 / 255., 1.);\n#else\nvColor = aColor0 / 255.;\n#endif\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(f * e);\n#endif\n#ifdef HAS_HEATMAP\nheatmap_compute(projMatrix * modelViewMatrix * f, e);\n#endif\n#ifdef HAS_I3S_UVREGION\nvUvRegion = uvRegion / 65535.;\n#endif\nhighlight_setVarying();\n#ifdef HAS_VERTEX_COLOR\nvertexColor_update();\n#endif\n}",
19177
19208
  frag: e.frag || "precision mediump float;\n#include <gl2_frag>\nuniform vec4 baseColorFactor;\nuniform float materialShininess;\nuniform float environmentExposure;\nuniform float specularStrength;\nuniform vec3 light0_viewDirection;\nuniform vec3 ambientColor;\nuniform vec4 light0_diffuse;\nuniform vec3 lightSpecular;\nuniform vec3 cameraPosition;\nuniform float alphaTest;\n#ifdef HAS_TOON\nuniform float toons;\nuniform float specularToons;\n#endif\n#ifdef HAS_TANGENT\nvarying vec4 vTangent;\n#endif\n#ifdef HAS_MAP\n#include <compute_texcoord_frag>\n#endif\nvarying vec3 vNormal;\nvarying vec3 vFragPos;\n#ifdef HAS_INSTANCE_COLOR\nvarying vec4 vInstanceColor;\n#endif\n#ifdef HAS_BASECOLOR_MAP\nuniform sampler2D baseColorTexture;\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\nuniform vec2 extrusionOpacityRange;\nvarying float vExtrusionOpacity;\n#endif\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\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\n#ifdef IS_LINE_EXTRUSION\nuniform float lineOpacity;\n#else\nuniform float polygonOpacity;\n#endif\n#ifdef HAS_AO_MAP\nuniform sampler2D occlusionTexture;\nvarying vec2 vTexCoord1;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D normalTexture;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D emissiveTexture;\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\nuniform vec4 diffuseFactor;\nuniform vec3 specularFactor;\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D diffuseTexture;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_MAP\nuniform sampler2D specularGlossinessTexture;\n#endif\n#endif\n#include <heatmap_render_frag>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#include <highlight_frag>\n#include <mask_frag>\n#include <vertex_color_frag>\nvec3 c() {\n \n#if defined(HAS_NORMAL_MAP)\nvec3 d = normalize(vNormal);\n vec3 e = texture2D(normalTexture, computeTexCoord(vTexCoord)).xyz * 2. - 1.;\n#if defined(HAS_TANGENT)\nvec3 t = normalize(vTangent.xyz);\n vec3 b = normalize(cross(d, t) * sign(vTangent.w));\n mat3 f = mat3(t, b, d);\n return normalize(f * e);\n#else\nreturn normalize(e);\n#endif\n#else\nreturn normalize(vNormal);\n#endif\n}\nvec4 h() {\n \n#if defined(HAS_BASECOLOR_MAP)\nreturn texture2D(baseColorTexture, computeTexCoord(vTexCoord));\n#elif defined(HAS_DIFFUSE_MAP)\nreturn texture2D(diffuseTexture, computeTexCoord(vTexCoord));\n#elif defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nreturn diffuseFactor;\n#else\nreturn baseColorFactor;\n#endif\n}\nvec3 i() {\n \n#if defined(HAS_SPECULARGLOSSINESS_MAP)\nreturn texture2D(specularGlossinessTexture, computeTexCoord(vTexCoord)).rgb;\n#elif defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nreturn specularFactor;\n#else\nreturn vec3(1.);\n#endif\n}\nvoid main() {\n vec4 j = h();\n#ifdef SHADING_MODEL_UNLIT\nvec3 k = vec3(1.);\n#else\nvec3 k = ambientColor;\n#endif\nvec3 l = environmentExposure * k * j.rgb;\n#ifdef HAS_INSTANCE_COLOR\nl *= vInstanceColor.rgb;\n#endif\nvec3 m = c();\n vec3 o = normalize(-light0_viewDirection);\n float u = max(dot(m, o), .0);\n#ifdef HAS_TOON\nfloat v = floor(u * toons);\n u = v / toons;\n#endif\n#ifdef SHADING_MODEL_UNLIT\nvec3 A = vec3(.0);\n#else\nvec3 A = light0_diffuse.rgb;\n#endif\nvec3 B = A * u * j.rgb;\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nvec3 C = vColor.rgb;\n#elif defined(IS_LINE_EXTRUSION)\nvec3 C = lineColor.rgb;\n#else\nvec3 C = polygonFill.rgb;\n#endif\n#ifdef HAS_INSTANCE_COLOR\nC *= vInstanceColor.rgb;\n#endif\nl *= C.rgb;\n B *= C.rgb;\n vec3 D = normalize(cameraPosition - vFragPos);\n vec3 E = normalize(o + D);\n float F = pow(max(dot(m, E), .0), materialShininess);\n#ifdef HAS_TOON\nfloat G = floor(F * specularToons);\n F = G / specularToons;\n#endif\n#ifdef SHADING_MODEL_UNLIT\nvec3 H = vec3(.0);\n#else\nvec3 H = lightSpecular;\n#endif\nvec3 I = specularStrength * H * F * i();\n#ifdef HAS_OCCLUSION_MAP\nfloat J = texture2D(occlusionTexture, computeTexCoord(vTexCoord1)).r;\n l *= J;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat K = shadow_computeShadow();\n B = shadow_blend(B, K).rgb;\n I = shadow_blend(I, K).rgb;\n l = shadow_blend(l, K).rgb;\n#endif\nvec3 L = l + B + I;\n#ifdef HAS_EMISSIVE_MAP\nvec3 M = texture2D(emissiveTexture, computeTexCoord(vTexCoord)).rgb;\n L += M;\n#endif\n#ifdef IS_LINE_EXTRUSION\nglFragColor = vec4(L, lineOpacity * j.a);\n#else\nglFragColor = vec4(L, polygonOpacity * j.a);\n#endif\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nfloat N = vColor.a;\n#elif defined(IS_LINE_EXTRUSION)\nfloat N = lineColor.a;\n#else\nfloat N = polygonFill.a;\n#endif\nglFragColor *= N;\n#ifdef HAS_EXTRUSION_OPACITY\nfloat O = extrusionOpacityRange.x;\n float P = extrusionOpacityRange.y;\n float Q = O + vExtrusionOpacity * (P - O);\n Q = clamp(Q, .0, 1.);\n glFragColor *= Q;\n#endif\nif(glFragColor.a < alphaTest) {\n discard;\n }\n#ifdef HAS_VERTEX_COLOR\nglFragColor *= vertexColor_get();\n#endif\n#ifdef HAS_HEATMAP\nglFragColor = heatmap_getColor(glFragColor);\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}",
19178
- wgslVert: "struct VertexInput {\n#if HAS_DRACO_POSITION || HAS_COMPRESSED_INT16_POSITION\n @location($i) aPosition: vec4i,\n#else\n #ifdef POSITION_IS_INT\n @location($i) aPosition: vec4i,\n #else\n @location($i) aPosition: vec3f,\n #endif\n#endif\n#ifdef HAS_MAP\n #if HAS_DRACO_TEXCOORD || HAS_COMPRESSED_INT16_TEXCOORD_0\n @location($i) aTexCoord: vec2i,\n #else\n @location($i) aTexCoord: vec2f,\n #endif\n#ifdef HAS_I3S_UVREGION\n @location($i) uvRegion: vec4f,\n#endif\n#ifdef HAS_AO_MAP\n @location($i) aTexCoord1: vec2f,\n#endif\n#endif\n#ifdef HAS_COLOR\n @location($i) aColor: vec4f,\n#elif HAS_COLOR0\n#if COLOR0_SIZE == 3\n @location($i) aColor0: vec3f,\n#else\n @location($i) aColor0: vec4f,\n#endif\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\n @location($i) aExtrusionOpacity: f32,\n#endif\n#ifdef HAS_TANGENT\n @location($i) aTangent: vec4f,\n#endif\n#ifdef HAS_NORMAL\n #ifdef NORMAL_IS_INT\n @location($i) aNormal: vec4i,\n #else\n @location($i) aNormal: vec3f,\n #endif\n#endif\n};\nstruct VertexOutput {\n @builtin(position) position : vec4f,\n @location($o) vFragPos: vec3f,\n @location($o) vNormal: vec3f,\n#ifdef HAS_MAP\n @location($o) vTexCoord: vec2f,\n#ifdef HAS_I3S_UVREGION\n @location($o) vUvRegion: vec4f,\n#endif\n#ifdef HAS_AO_MAP\n @location($o) vTexCoord1: vec2f,\n#endif\n#endif\n#ifdef HAS_COLOR || HAS_COLOR0\n @location($o) vColor: vec4f,\n#endif\n#if HAS_EXTRUSION_OPACITY\n @location($o) vExtrusionOpacity: f32,\n#endif\n#ifdef HAS_TANGENT\n @location($o) vTangent: vec4f,\n#endif\n};\nstruct MatrixUniforms {\n projMatrix: mat4x4f,\n projViewMatrix: mat4x4f,\n};\nstruct ModelUniforms {\n modelNormalMatrix: mat3x3f,\n modelViewMatrix: mat4x4f,\n modelMatrix: mat4x4f,\n positionMatrix: mat4x4f,\n};\nstruct UvUniforms {\n uvScale: vec2f,\n uvOffset: vec2f,\n};\nstruct JitterUniforms {\n halton: vec2f,\n outSize: vec2f,\n};\n@group(0) @binding($b) var<uniform> uniforms: MatrixUniforms;\n@group(0) @binding($b) var<uniform> modelUniforms: ModelUniforms;\n@group(0) @binding($b) var<uniform> uvUniforms: UvUniforms;\n@group(0) @binding($b) var<uniform> jitterUniforms: JitterUniforms;\n#include <line_extrusion_vert>\n#include <highlight_vert>\n#include <get_output>\n#if HAS_SHADOWING && !HAS_BLOOM\n#include <vsm_shadow_vert>\n#endif\n#include <vertex_color_vert>\nfn toTangentFrame1(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}\nfn toTangentFrame(q: vec4f, n: ptr<function, vec3f>, t: ptr<function, vec3f>) {\n *n = toTangentFrame1(q);\n *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}\n@vertex\nfn main(vertexInput: VertexInput) -> VertexOutput {\n var vertexOutput : VertexOutput;\n#if IS_LINE_EXTRUSION\n let localPosition = getPosition(getLineExtrudePosition(vec3f(vertexInput.aPosition.xyz), vertexInput), vertexInput);\n#else\n let localPosition = getPosition(vec3f(vertexInput.aPosition.xyz), vertexInput);\n#endif\n let localPositionMatrix = getPositionMatrix(vertexInput, &vertexOutput, modelUniforms.positionMatrix);\n vertexOutput.vFragPos = (modelUniforms.modelMatrix * localPositionMatrix * localPosition).xyz;\n#if HAS_NORMAL || HAS_TANGENT\n let localNormalMatrix = modelUniforms.modelNormalMatrix * mat3x3f(localPositionMatrix[0].xyz, localPositionMatrix[1].xyz, localPositionMatrix[2].xyz);\n var Normal: vec3f;\n#if HAS_TANGENT\n var t: vec3f;\n toTangentFrame(vertexInput.aTangent, Normal, t);\n vertexOutput.vTangent = vec4f(localNormalMatrix * t, vertexInput.aTangent.w);\n#else\n Normal = decode_getNormal(vec3f(vertexInput.aNormal.xyz));\n#endif\n let localNormal = appendMorphNormal(Normal, vertexInput);\n vertexOutput.vNormal = normalize(localNormalMatrix * localNormal);\n#else\n vertexOutput.vNormal = vec3f(0.0);\n#endif\n var jitteredProjection = uniforms.projMatrix;\n#ifdef HAS_MASK_EXTENT\n vertexOutput.position = jitteredProjection * getMaskPosition(localPositionMatrix * localPosition, uniforms.modelMatrix);\n#else\n vertexOutput.position = jitteredProjection * modelUniforms.modelViewMatrix * localPositionMatrix * localPosition;\n#endif\n#ifdef HAS_MAP\n let decodedTexCoord = decode_getTexcoord(vec2f(vertexInput.aTexCoord));\n vertexOutput.vTexCoord = decodedTexCoord * uvUniforms.uvScale + uvUniforms.uvOffset;\n#endif\n#ifdef HAS_AO_MAP\n let decodedTexCoord1 = decode_getTexcoord(vec2f(vertexInput.aTexCoord1));\n vertexOutput.vTexCoord1 = decodedTexCoord1 * uvUniforms.uvScale + uvUniforms.uvOffset;\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\n vertexOutput.vExtrusionOpacity = vertexInput.aExtrusionOpacity;\n#endif\n#if HAS_COLOR\n vertexOutput.vColor = vertexInput.aColor / 255.0;\n#elif HAS_COLOR0\n#if COLOR0_SIZE == 3\n vertexOutput.vColor = vec4f(vertexInput.aColor0 / 255.0, 1.0);\n#else\n vertexOutput.vColor = vertexInput.aColor0 / 255.0;\n#endif\n#endif\n#if HAS_SHADOWING && !HAS_BLOOM\n shadow_computeShadowPars(localPositionMatrix * localPosition, &vertexOutput);\n#endif\n#ifdef HAS_I3S_UVREGION\n vertexOutput.vUvRegion = vertexInput.uvRegion / 65535.0;\n#endif\n#if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n highlight_setVarying(vertexInput, &vertexOutput);\n#endif\n#ifdef HAS_VERTEX_COLOR\n vertexColor_update(vertexInput, &vertexOutput);\n#endif\n return vertexOutput;\n}",
19179
- wgslFrag: "struct LightUniforms {\n light0_viewDirection: vec3f,\n ambientColor: vec3f,\n light0_diffuse: vec4f,\n lightSpecular: vec3f,\n cameraPosition: vec3f,\n #ifdef HAS_LAYER_OPACITY\n layerOpacity: f32,\n #endif\n};\nstruct MaterialUniforms {\n environmentExposure: f32,\n specularStrength: f32,\n baseColorFactor: vec4f,\n materialShininess: f32,\n alphaTest: f32,\n#ifdef HAS_EXTRUSION_OPACITY\n extrusionOpacityRange: vec2f,\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n diffuseFactor: vec4f,\n specularFactor: vec3f,\n#endif\n#ifdef IS_LINE_EXTRUSION\n lineColor: vec4f,\n lineOpacity: f32,\n#else\n polygonFill: vec4f,\n polygonOpacity: f32,\n#endif\n};\n@group(0) @binding($b) var<uniform> lightUniforms: LightUniforms;\n@group(0) @binding($b) var<uniform> materialUniforms: MaterialUniforms;\n#ifdef HAS_BASECOLOR_MAP\n@group(0) @binding($b) var baseColorTextureSampler: sampler;\n@group(0) @binding($b) var baseColorTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_AO_MAP\n@group(0) @binding($b) var occlusionTextureSampler: sampler;\n@group(0) @binding($b) var occlusionTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_NORMAL_MAP\n@group(0) @binding($b) var normalTextureSampler: sampler;\n@group(0) @binding($b) var normalTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_EMISSIVE_MAP\n@group(0) @binding($b) var emissiveTextureSampler: sampler;\n@group(0) @binding($b) var emissiveTexture: texture_2d<f32>;\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n#ifdef HAS_DIFFUSE_MAP\n@group(0) @binding($b) var diffuseTextureSampler: sampler;\n@group(0) @binding($b0) var diffuseTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_MAP\n@group(0) @binding($b1) var specularGlossinessTextureSampler: sampler;\n@group(0) @binding($b2) var specularGlossinessTexture: texture_2d<f32>;\n#endif\n#endif\n#if HAS_SHADOWING && !HAS_BLOOM\n#include <vsm_shadow_frag>\n#endif\n#include <highlight_frag>\n#include <mask_frag>\n#include <vertex_color_frag>\n#ifdef HAS_MAP\n #include <compute_texcoord_frag>\n#endif\nfn transformNormal(vertexOutput: VertexOutput) -> vec3f {\n#ifdef HAS_NORMAL_MAP\n let n = normalize(vertexOutput.vNormal);\n let normal = textureSample(normalTexture, normalTextureSampler, computeTexCoord(vertexOutput)).xyz * 2.0 - 1.0;\n#ifdef HAS_TANGENT\n let t = normalize(vertexOutput.vTangent.xyz);\n let b = normalize(cross(n, t) * sign(vertexOutput.vTangent.w));\n let tbn = mat3x3f(t, b, n);\n return normalize(tbn * normal);\n#else\n return normalize(normal);\n#endif\n#else\n return normalize(vertexOutput.vNormal);\n#endif\n}\nfn getBaseColor(vertexOutput: VertexOutput) -> vec4f {\n#ifdef HAS_BASECOLOR_MAP\n return textureSample(baseColorTexture, baseColorTextureSampler, computeTexCoord(vertexOutput));\n#elif HAS_DIFFUSE_MAP\n return textureSample(diffuseTexture, diffuseTextureSampler, computeTexCoord(vertexOutput));\n#elif SHADING_MODEL_SPECULAR_GLOSSINESS\n return materialUniforms.diffuseFactor;\n#else\n return materialUniforms.baseColorFactor;\n#endif\n}\nfn getSpecularColor(vertexOutput: VertexOutput) -> vec3f {\n#ifdef HAS_SPECULARGLOSSINESS_MAP\n return textureSample(specularGlossinessTexture, specularGlossinessTextureSampler, computeTexCoord(vertexOutput)).rgb;\n#elif SHADING_MODEL_SPECULAR_GLOSSINESS\n return materialUniforms.specularFactor;\n#else\n return vec3f(1.0);\n#endif\n}\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n let baseColor = getBaseColor(vertexOutput);\n#ifdef SHADING_MODEL_UNLIT\n let ambientColor = vec3f(1.0);\n#else\n let ambientColor = lightUniforms.ambientColor;\n#endif\n var ambient = materialUniforms.environmentExposure * ambientColor * baseColor.rgb;\n#ifdef HAS_INSTANCE_COLOR\n ambient *= vertexOutput.vInstanceColor.rgb;\n#endif\n let norm = transformNormal(vertexOutput);\n let lightDir = normalize(-lightUniforms.light0_viewDirection);\n var diff = max(dot(norm, lightDir), 0.0);\n#ifdef SHADING_MODEL_UNLIT\n let lightDiffuse = vec3f(0.0);\n#else\n let lightDiffuse = lightUniforms.light0_diffuse.rgb;\n#endif\n var diffuse = lightDiffuse * diff * baseColor.rgb;\n#if HAS_COLOR || HAS_COLOR0\n var color = vertexOutput.vColor.rgb;\n#elif IS_LINE_EXTRUSION\n var color = materialUniforms.lineColor.rgb;\n#else\n var color = materialUniforms.polygonFill.rgb;\n#endif\n#ifdef HAS_INSTANCE_COLOR\n color *= vertexOutput.vInstanceColor.rgb;\n#endif\n ambient *= color.rgb;\n diffuse *= color.rgb;\n let viewDir = normalize(lightUniforms.cameraPosition - vertexOutput.vFragPos);\n let halfwayDir = normalize(lightDir + viewDir);\n var spec = pow(max(dot(norm, halfwayDir), 0.0), materialUniforms.materialShininess);\n#ifdef SHADING_MODEL_UNLIT\n let lightSpecular = vec3f(0.0);\n#else\n let lightSpecular = lightUniforms.lightSpecular;\n#endif\n var specular = materialUniforms.specularStrength * lightSpecular * spec * getSpecularColor(vertexOutput);\n#ifdef HAS_OCCLUSION_MAP\n let ao = textureSample(occlusionTexture, occlusionTextureSampler, computeTexCoord(vertexOutput1)).r;\n ambient *= ao;\n#endif\n#if HAS_SHADOWING && !HAS_BLOOM\n let shadowCoeff = shadow_computeShadow(vertexOutput);\n diffuse = shadow_blend(diffuse, shadowCoeff).rgb;\n specular = shadow_blend(specular, shadowCoeff).rgb;\n ambient = shadow_blend(ambient, shadowCoeff).rgb;\n#endif\n var result = ambient + diffuse + specular;\n#ifdef HAS_EMISSIVE_MAP\n let emit = textureSample(emissiveTexture, emissiveTextureSampler, computeTexCoord(vertexOutput)).rgb;\n result += emit;\n#endif\n#ifdef IS_LINE_EXTRUSION\n var fragColor = vec4f(result, materialUniforms.lineOpacity * baseColor.a);\n#else\n var fragColor = vec4f(result, materialUniforms.polygonOpacity * baseColor.a);\n#endif\n#if HAS_COLOR || HAS_COLOR0\n let colorAlpha = vertexOutput.vColor.a;\n#elif IS_LINE_EXTRUSION\n let colorAlpha = materialUniforms.lineColor.a;\n#else\n let colorAlpha = materialUniforms.polygonFill.a;\n#endif\n fragColor *= colorAlpha;\n#ifdef HAS_EXTRUSION_OPACITY\n let topAlpha = materialUniforms.extrusionOpacityRange.x;\n let bottomAlpha = materialUniforms.extrusionOpacityRange.y;\n let alpha = topAlpha + vertexOutput.vExtrusionOpacity * (bottomAlpha - topAlpha);\n let alpha = clamp(alpha, 0.0, 1.0);\n fragColor *= alpha;\n#endif\n if (fragColor.a < materialUniforms.alphaTest) {\n discard;\n }\n#ifdef HAS_VERTEX_COLOR\n fragColor *= vertexColor_get();\n#endif\n#ifdef HAS_HEATMAP\n fragColor = heatmap_getColor(fragColor);\n#endif\n#if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n fragColor = highlight_blendColor(fragColor, vertexOutput);\n#endif\n#ifdef HAS_LAYER_OPACITY\n fragColor *= lightUniforms.layerOpacity;\n#endif\n#ifdef HAS_MASK_EXTENT\n fragColor = setMask(fragColor);\n#endif\n return fragColor;\n}",
19209
+ wgslVert: "struct VertexInput {\n#if HAS_DRACO_POSITION || HAS_COMPRESSED_INT16_POSITION\n @location($i) aPosition: vec4i,\n#else\n #ifdef POSITION_IS_INT\n @location($i) aPosition: vec4i,\n #else\n @location($i) aPosition: vec3f,\n #endif\n#endif\n#ifdef HAS_MAP\n #if HAS_DRACO_TEXCOORD || HAS_COMPRESSED_INT16_TEXCOORD_0\n @location($i) aTexCoord: vec2i,\n #else\n @location($i) aTexCoord: vec2f,\n #endif\n#ifdef HAS_I3S_UVREGION\n @location($i) uvRegion: vec4f,\n#endif\n#ifdef HAS_AO_MAP\n @location($i) aTexCoord1: vec2f,\n#endif\n#endif\n#ifdef HAS_COLOR\n @location($i) aColor: vec4f,\n#elif HAS_COLOR0\n#if COLOR0_SIZE == 3\n @location($i) aColor0: vec3f,\n#else\n @location($i) aColor0: vec4f,\n#endif\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\n @location($i) aExtrusionOpacity: f32,\n#endif\n#ifdef HAS_TANGENT\n @location($i) aTangent: vec4f,\n#endif\n#ifdef HAS_NORMAL\n #ifdef NORMAL_IS_INT\n @location($i) aNormal: vec4i,\n #else\n @location($i) aNormal: vec3f,\n #endif\n#endif\n};\nstruct VertexOutput {\n @builtin(position) position : vec4f,\n @location($o) vFragPos: vec3f,\n @location($o) vNormal: vec3f,\n#ifdef HAS_MAP\n @location($o) vTexCoord: vec2f,\n#ifdef HAS_I3S_UVREGION\n @location($o) vUvRegion: vec4f,\n#endif\n#ifdef HAS_AO_MAP\n @location($o) vTexCoord1: vec2f,\n#endif\n#endif\n#ifdef HAS_COLOR || HAS_COLOR0\n @location($o) vColor: vec4f,\n#endif\n#if HAS_EXTRUSION_OPACITY\n @location($o) vExtrusionOpacity: f32,\n#endif\n#ifdef HAS_TANGENT\n @location($o) vTangent: vec4f,\n#endif\n};\nstruct MatrixUniforms {\n projMatrix: mat4x4f,\n projViewMatrix: mat4x4f,\n};\nstruct ModelUniforms {\n modelNormalMatrix: mat3x3f,\n modelViewMatrix: mat4x4f,\n modelMatrix: mat4x4f,\n positionMatrix: mat4x4f,\n uvScale: vec2f,\n uvOffset: vec2f,\n};\n@group(0) @binding($b) var<uniform> uniforms: MatrixUniforms;\n@group(0) @binding($b) var<uniform> modelUniforms: ModelUniforms;\n#include <line_extrusion_vert>\n#include <highlight_vert>\n#include <get_output>\n#if HAS_SHADOWING && !HAS_BLOOM\n#include <vsm_shadow_vert>\n#endif\n#include <vertex_color_vert>\nfn toTangentFrame1(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}\nfn toTangentFrame(q: vec4f, n: ptr<function, vec3f>, t: ptr<function, vec3f>) {\n *n = toTangentFrame1(q);\n *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}\n@vertex\nfn main(vertexInput: VertexInput) -> VertexOutput {\n var vertexOutput : VertexOutput;\n#if IS_LINE_EXTRUSION\n let localPosition = getPosition(getLineExtrudePosition(vec3f(vertexInput.aPosition.xyz), vertexInput), vertexInput);\n#else\n let localPosition = getPosition(vec3f(vertexInput.aPosition.xyz), vertexInput);\n#endif\n let localPositionMatrix = getPositionMatrix(vertexInput, &vertexOutput, modelUniforms.positionMatrix);\n vertexOutput.vFragPos = (modelUniforms.modelMatrix * localPositionMatrix * localPosition).xyz;\n#if HAS_NORMAL || HAS_TANGENT\n let localNormalMatrix = modelUniforms.modelNormalMatrix * mat3x3f(localPositionMatrix[0].xyz, localPositionMatrix[1].xyz, localPositionMatrix[2].xyz);\n var Normal: vec3f;\n#if HAS_TANGENT\n var t: vec3f;\n toTangentFrame(vertexInput.aTangent, Normal, t);\n vertexOutput.vTangent = vec4f(localNormalMatrix * t, vertexInput.aTangent.w);\n#else\n Normal = decode_getNormal(vec3f(vertexInput.aNormal.xyz));\n#endif\n let localNormal = appendMorphNormal(Normal, vertexInput);\n vertexOutput.vNormal = normalize(localNormalMatrix * localNormal);\n#else\n vertexOutput.vNormal = vec3f(0.0);\n#endif\n var jitteredProjection = uniforms.projMatrix;\n#ifdef HAS_MASK_EXTENT\n vertexOutput.position = jitteredProjection * getMaskPosition(localPositionMatrix * localPosition, uniforms.modelMatrix);\n#else\n vertexOutput.position = jitteredProjection * modelUniforms.modelViewMatrix * localPositionMatrix * localPosition;\n#endif\n#ifdef HAS_MAP\n let decodedTexCoord = decode_getTexcoord(vec2f(vertexInput.aTexCoord));\n vertexOutput.vTexCoord = decodedTexCoord * modelUniforms.uvScale + modelUniforms.uvOffset;\n#endif\n#ifdef HAS_AO_MAP\n let decodedTexCoord1 = decode_getTexcoord(vec2f(vertexInput.aTexCoord1));\n vertexOutput.vTexCoord1 = decodedTexCoord1 * modelUniforms.uvScale + modelUniforms.uvOffset;\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\n vertexOutput.vExtrusionOpacity = vertexInput.aExtrusionOpacity;\n#endif\n#if HAS_COLOR\n vertexOutput.vColor = vertexInput.aColor / 255.0;\n#elif HAS_COLOR0\n#if COLOR0_SIZE == 3\n vertexOutput.vColor = vec4f(vertexInput.aColor0 / 255.0, 1.0);\n#else\n vertexOutput.vColor = vertexInput.aColor0 / 255.0;\n#endif\n#endif\n#if HAS_SHADOWING && !HAS_BLOOM\n shadow_computeShadowPars(localPositionMatrix * localPosition, &vertexOutput);\n#endif\n#ifdef HAS_I3S_UVREGION\n vertexOutput.vUvRegion = vertexInput.uvRegion / 65535.0;\n#endif\n#if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n highlight_setVarying(vertexInput, &vertexOutput);\n#endif\n#ifdef HAS_VERTEX_COLOR\n vertexColor_update(vertexInput, &vertexOutput);\n#endif\n return vertexOutput;\n}",
19210
+ wgslFrag: "struct LightUniforms {\n light0_viewDirection: vec3f,\n ambientColor: vec3f,\n light0_diffuse: vec4f,\n lightSpecular: vec3f,\n cameraPosition: vec3f,\n #ifdef HAS_LAYER_OPACITY\n layerOpacity: f32,\n #endif\n};\nstruct MaterialUniforms {\n environmentExposure: f32,\n specularStrength: f32,\n baseColorFactor: vec4f,\n materialShininess: f32,\n alphaTest: f32,\n#ifdef HAS_EXTRUSION_OPACITY\n extrusionOpacityRange: vec2f,\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n diffuseFactor: vec4f,\n specularFactor: vec3f,\n#endif\n#ifdef IS_LINE_EXTRUSION\n lineColor: vec4f,\n lineOpacity: f32,\n#else\n polygonFill: vec4f,\n polygonOpacity: f32,\n#endif\n};\n@group(0) @binding($b) var<uniform> lightUniforms: LightUniforms;\n@group(0) @binding($b) var<uniform> materialUniforms: MaterialUniforms;\n#ifdef HAS_BASECOLOR_MAP\n@group(0) @binding($b) var baseColorTextureSampler: sampler;\n@group(0) @binding($b) var baseColorTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_AO_MAP\n@group(0) @binding($b) var occlusionTextureSampler: sampler;\n@group(0) @binding($b) var occlusionTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_NORMAL_MAP\n@group(0) @binding($b) var normalTextureSampler: sampler;\n@group(0) @binding($b) var normalTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_EMISSIVE_MAP\n@group(0) @binding($b) var emissiveTextureSampler: sampler;\n@group(0) @binding($b) var emissiveTexture: texture_2d<f32>;\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n#ifdef HAS_DIFFUSE_MAP\n@group(0) @binding($b) var diffuseTextureSampler: sampler;\n@group(0) @binding($b0) var diffuseTexture: texture_2d<f32>;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_MAP\n@group(0) @binding($b1) var specularGlossinessTextureSampler: sampler;\n@group(0) @binding($b2) var specularGlossinessTexture: texture_2d<f32>;\n#endif\n#endif\n#if HAS_SHADOWING && !HAS_BLOOM\n#include <vsm_shadow_frag>\n#endif\n#include <highlight_frag>\n#include <mask_frag>\n#include <vertex_color_frag>\n#ifdef HAS_MAP\n #include <compute_texcoord_frag>\n#endif\nfn transformNormal(vertexOutput: VertexOutput) -> vec3f {\n#ifdef HAS_NORMAL_MAP\n let n = normalize(vertexOutput.vNormal);\n let normal = textureSample(normalTexture, normalTextureSampler, computeTexCoord(vertexOutput.vTexCoord, vertexOutput)).xyz * 2.0 - 1.0;\n#ifdef HAS_TANGENT\n let t = normalize(vertexOutput.vTangent.xyz);\n let b = normalize(cross(n, t) * sign(vertexOutput.vTangent.w));\n let tbn = mat3x3f(t, b, n);\n return normalize(tbn * normal);\n#else\n return normalize(normal);\n#endif\n#else\n return normalize(vertexOutput.vNormal);\n#endif\n}\nfn getBaseColor(vertexOutput: VertexOutput) -> vec4f {\n#ifdef HAS_BASECOLOR_MAP\n return textureSample(baseColorTexture, baseColorTextureSampler, computeTexCoord(vertexOutput.vTexCoord, vertexOutput));\n#elif HAS_DIFFUSE_MAP\n return textureSample(diffuseTexture, diffuseTextureSampler, computeTexCoord(vertexOutput.vTexCoord, vertexOutput));\n#elif SHADING_MODEL_SPECULAR_GLOSSINESS\n return materialUniforms.diffuseFactor;\n#else\n return materialUniforms.baseColorFactor;\n#endif\n}\nfn getSpecularColor(vertexOutput: VertexOutput) -> vec3f {\n#ifdef HAS_SPECULARGLOSSINESS_MAP\n return textureSample(specularGlossinessTexture, specularGlossinessTextureSampler, computeTexCoord(vertexOutput.vTexCoord, vertexOutput)).rgb;\n#elif SHADING_MODEL_SPECULAR_GLOSSINESS\n return materialUniforms.specularFactor;\n#else\n return vec3f(1.0);\n#endif\n}\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n let baseColor = getBaseColor(vertexOutput);\n#ifdef SHADING_MODEL_UNLIT\n let ambientColor = vec3f(1.0);\n#else\n let ambientColor = lightUniforms.ambientColor;\n#endif\n var ambient = materialUniforms.environmentExposure * ambientColor * baseColor.rgb;\n#ifdef HAS_INSTANCE_COLOR\n ambient *= vertexOutput.vInstanceColor.rgb;\n#endif\n let norm = transformNormal(vertexOutput);\n let lightDir = normalize(-lightUniforms.light0_viewDirection);\n var diff = max(dot(norm, lightDir), 0.0);\n#ifdef SHADING_MODEL_UNLIT\n let lightDiffuse = vec3f(0.0);\n#else\n let lightDiffuse = lightUniforms.light0_diffuse.rgb;\n#endif\n var diffuse = lightDiffuse * diff * baseColor.rgb;\n#if HAS_COLOR || HAS_COLOR0\n var color = vertexOutput.vColor.rgb;\n#elif IS_LINE_EXTRUSION\n var color = materialUniforms.lineColor.rgb;\n#else\n var color = materialUniforms.polygonFill.rgb;\n#endif\n#ifdef HAS_INSTANCE_COLOR\n color *= vertexOutput.vInstanceColor.rgb;\n#endif\n ambient *= color.rgb;\n diffuse *= color.rgb;\n let viewDir = normalize(lightUniforms.cameraPosition - vertexOutput.vFragPos);\n let halfwayDir = normalize(lightDir + viewDir);\n var spec = pow(max(dot(norm, halfwayDir), 0.0), materialUniforms.materialShininess);\n#ifdef SHADING_MODEL_UNLIT\n let lightSpecular = vec3f(0.0);\n#else\n let lightSpecular = lightUniforms.lightSpecular;\n#endif\n var specular = materialUniforms.specularStrength * lightSpecular * spec * getSpecularColor(vertexOutput);\n#ifdef HAS_OCCLUSION_MAP\n let ao = textureSample(occlusionTexture, occlusionTextureSampler, computeTexCoord(vertexOutput.vTexCoord, vertexOutput1)).r;\n ambient *= ao;\n#endif\n#if HAS_SHADOWING && !HAS_BLOOM\n let shadowCoeff = shadow_computeShadow(vertexOutput);\n diffuse = shadow_blend(diffuse, shadowCoeff).rgb;\n specular = shadow_blend(specular, shadowCoeff).rgb;\n ambient = shadow_blend(ambient, shadowCoeff).rgb;\n#endif\n var result = ambient + diffuse + specular;\n#ifdef HAS_EMISSIVE_MAP\n let emit = textureSample(emissiveTexture, emissiveTextureSampler, computeTexCoord(vertexOutput.vTexCoord, vertexOutput)).rgb;\n result += emit;\n#endif\n#ifdef IS_LINE_EXTRUSION\n var fragColor = vec4f(result, materialUniforms.lineOpacity * baseColor.a);\n#else\n var fragColor = vec4f(result, materialUniforms.polygonOpacity * baseColor.a);\n#endif\n#if HAS_COLOR || HAS_COLOR0\n let colorAlpha = vertexOutput.vColor.a;\n#elif IS_LINE_EXTRUSION\n let colorAlpha = materialUniforms.lineColor.a;\n#else\n let colorAlpha = materialUniforms.polygonFill.a;\n#endif\n fragColor *= colorAlpha;\n#ifdef HAS_EXTRUSION_OPACITY\n let topAlpha = materialUniforms.extrusionOpacityRange.x;\n let bottomAlpha = materialUniforms.extrusionOpacityRange.y;\n let alpha = topAlpha + vertexOutput.vExtrusionOpacity * (bottomAlpha - topAlpha);\n let alpha = clamp(alpha, 0.0, 1.0);\n fragColor *= alpha;\n#endif\n if (fragColor.a < materialUniforms.alphaTest) {\n discard;\n }\n#ifdef HAS_VERTEX_COLOR\n fragColor *= vertexColor_get();\n#endif\n#ifdef HAS_HEATMAP\n fragColor = heatmap_getColor(fragColor);\n#endif\n#if HAS_HIGHLIGHT_OPACITY || HAS_HIGHLIGHT_COLOR\n fragColor = highlight_blendColor(fragColor, vertexOutput);\n#endif\n#ifdef HAS_LAYER_OPACITY\n fragColor *= lightUniforms.layerOpacity;\n#endif\n#ifdef HAS_MASK_EXTENT\n fragColor = setMask(fragColor);\n#endif\n return fragColor;\n}",
19180
19211
  uniforms: i,
19181
19212
  defines: e.defines || {},
19182
19213
  extraCommandProps: e.extraCommandProps || {}
@@ -19188,7 +19219,7 @@
19188
19219
  t;
19189
19220
  }
19190
19221
  },
19191
- PhongSpecularGlossinessMaterial: zt,
19222
+ PhongSpecularGlossinessMaterial: Gt,
19192
19223
  Plane: $r,
19193
19224
  PointLineShader: class extends Qi {
19194
19225
  constructor(e = {}) {
@@ -19209,12 +19240,12 @@
19209
19240
  PostProcessShader: co,
19210
19241
  QuadShader: io,
19211
19242
  REGLHelper: Tt,
19212
- RainRipplesPass: No,
19243
+ RainRipplesPass: Fo,
19213
19244
  Renderer: Sr,
19214
19245
  ResourceLoader: Mr,
19215
19246
  ScanEffectPass: Vo,
19216
19247
  ScanEffectShader: Co,
19217
- Scene: Er,
19248
+ Scene: Ir,
19218
19249
  Shader: Ji,
19219
19250
  ShaderLib: Kr,
19220
19251
  ShadowDisplayShader: ta,
@@ -19291,7 +19322,7 @@
19291
19322
  constructor(e = {}) {
19292
19323
  let t = e.extraCommandProps || {};
19293
19324
  const n = [];
19294
- t = I({}, t, {
19325
+ t = E({}, t, {
19295
19326
  blend: {
19296
19327
  enable: !0,
19297
19328
  func: {
@@ -19329,7 +19360,7 @@
19329
19360
  vec4: f
19330
19361
  });
19331
19362
 
19332
- function Ea(e) {
19363
+ function Ia(e) {
19333
19364
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
19334
19365
  }
19335
19366
 
@@ -19339,7 +19370,7 @@
19339
19370
  exports: {}
19340
19371
  }, La = function(e) {
19341
19372
  return !(!e || "string" == typeof e) && (e instanceof Array || Array.isArray(e) || e.length >= 0 && (e.splice instanceof Function || Object.getOwnPropertyDescriptor(e, e.length - 1) && "String" !== e.constructor.name));
19342
- }, Ha = Array.prototype.concat, Da = Array.prototype.slice, Na = Ra.exports = function(e) {
19373
+ }, Ha = Array.prototype.concat, Da = Array.prototype.slice, Fa = Ra.exports = function(e) {
19343
19374
  for (var t = [], n = 0, r = e.length; n < r; n++) {
19344
19375
  var i = e[n];
19345
19376
  La(i) ? t = Ha.call(t, Da.call(i)) : t.push(i);
@@ -19347,13 +19378,13 @@
19347
19378
  return t;
19348
19379
  };
19349
19380
 
19350
- Na.wrap = function(e) {
19381
+ Fa.wrap = function(e) {
19351
19382
  return function() {
19352
- return e(Na(arguments));
19383
+ return e(Fa(arguments));
19353
19384
  };
19354
19385
  };
19355
19386
 
19356
- var Fa = Ra.exports, Ba = {
19387
+ var Na = Ra.exports, Ba = {
19357
19388
  "aliceblue": [ 240, 248, 255 ],
19358
19389
  "antiquewhite": [ 250, 235, 215 ],
19359
19390
  "aqua": [ 0, 255, 255 ],
@@ -19502,9 +19533,9 @@
19502
19533
  "whitesmoke": [ 245, 245, 245 ],
19503
19534
  "yellow": [ 255, 255, 0 ],
19504
19535
  "yellowgreen": [ 154, 205, 50 ]
19505
- }, Ua = Fa, Ga = Object.hasOwnProperty, za = Object.create(null);
19536
+ }, Ua = Na, za = Object.hasOwnProperty, Ga = Object.create(null);
19506
19537
 
19507
- for (var Va in Ba) Ga.call(Ba, Va) && (za[Ba[Va]] = Va);
19538
+ for (var Va in Ba) za.call(Ba, Va) && (Ga[Ba[Va]] = Va);
19508
19539
 
19509
19540
  var ja = Pa.exports = {
19510
19541
  to: {},
@@ -19554,7 +19585,7 @@
19554
19585
  for (n = 0; n < 3; n++) i[n] = parseInt(t[n + 1], 0);
19555
19586
  t[4] && (t[5] ? i[3] = .01 * parseFloat(t[4]) : i[3] = parseFloat(t[4]));
19556
19587
  } else {
19557
- if (!(t = e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/))) return (t = e.match(/^(\w+)$/)) ? "transparent" === t[1] ? [ 0, 0, 0, 0 ] : Ga.call(Ba, t[1]) ? ((i = Ba[t[1]])[3] = 1,
19588
+ if (!(t = e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/))) return (t = e.match(/^(\w+)$/)) ? "transparent" === t[1] ? [ 0, 0, 0, 0 ] : za.call(Ba, t[1]) ? ((i = Ba[t[1]])[3] = 1,
19558
19589
  i) : null : null;
19559
19590
  for (n = 0; n < 3; n++) i[n] = Math.round(2.55 * parseFloat(t[n + 1]));
19560
19591
  t[4] && (t[5] ? i[3] = .01 * parseFloat(t[4]) : i[3] = parseFloat(t[4]));
@@ -19593,7 +19624,7 @@
19593
19624
  var e = Ua(arguments), t = "";
19594
19625
  return e.length >= 4 && 1 !== e[3] && (t = ", " + e[3]), "hwb(" + e[0] + ", " + e[1] + "%, " + e[2] + "%" + t + ")";
19595
19626
  }, ja.to.keyword = function(e) {
19596
- return za[e.slice(0, 3)];
19627
+ return Ga[e.slice(0, 3)];
19597
19628
  };
19598
19629
 
19599
19630
  var $a = Pa.exports, Xa = {
@@ -20346,7 +20377,7 @@
20346
20377
  }
20347
20378
  }));
20348
20379
 
20349
- var bl = Ea(gl);
20380
+ var bl = Ia(gl);
20350
20381
 
20351
20382
  const yl = "function" == typeof Object.assign, Sl = [];
20352
20383
 
@@ -20383,7 +20414,7 @@
20383
20414
  return Object.prototype.hasOwnProperty.call(e, t);
20384
20415
  }
20385
20416
 
20386
- function Il(e) {
20417
+ function El(e) {
20387
20418
  for (let t = 1; t < arguments.length; t++) {
20388
20419
  const n = arguments[t];
20389
20420
  if (n) for (let t = 0, r = n.length; t < r; t++) e.push(n[t]);
@@ -20391,12 +20422,12 @@
20391
20422
  return e.length;
20392
20423
  }
20393
20424
 
20394
- const El = {};
20425
+ const Il = {};
20395
20426
 
20396
20427
  function Pl(e, t) {
20397
20428
  if (!Array.isArray(t)) {
20398
20429
  const e = t;
20399
- t = El[e] = El[e] || bl(t).unitArray();
20430
+ t = Il[e] = Il[e] || bl(t).unitArray();
20400
20431
  }
20401
20432
  for (let n = 0; n < t.length; n++) e[n] = t[n];
20402
20433
  return 3 === t.length && (e[3] = 1), e;
@@ -20405,7 +20436,7 @@
20405
20436
  function Rl(e, t) {
20406
20437
  if (!Array.isArray(t)) {
20407
20438
  const e = t;
20408
- t = El[e] = El[e] || bl(t).unitArray();
20439
+ t = Il[e] = Il[e] || bl(t).unitArray();
20409
20440
  }
20410
20441
  for (let n = 0; n < t.length; n++) e[n] = 255 * t[n];
20411
20442
  return 3 === e.length && e.push(255), e;
@@ -20419,9 +20450,9 @@
20419
20450
 
20420
20451
  const Hl = [ 0, 0 ], Dl = [ 0, 0, 0 ];
20421
20452
 
20422
- let Nl;
20453
+ let Fl;
20423
20454
 
20424
- class Fl {
20455
+ class Nl {
20425
20456
  static getUniformDeclares() {
20426
20457
  const e = [], t = [];
20427
20458
  return t.push({
@@ -20469,10 +20500,10 @@
20469
20500
  d !== this._shadowPass.width && this._shadowPass.resize(d, d), this._tempMat0 = this._tempMat0 || [],
20470
20501
  this._tempMat1 = this._tempMat1 || [];
20471
20502
  const r = multiply$5(this._tempMat0, t, n), i = normalize$7(this._tempMat1, o);
20472
- Nl || (Nl = h.getContainerExtent());
20503
+ Fl || (Fl = h.getContainerExtent());
20473
20504
  let a = h.height;
20474
20505
  h.getPitch() > 62 && (a = h._getVisualHeight(62));
20475
- const l = Nl.set(0, h.height - a, h.width, h.height).convertTo((e => h._containerPointToPointAtRes(e, h.getGLRes()))).toArray();
20506
+ const l = Fl.set(0, h.height - a, h.width, h.height).convertTo((e => h._containerPointToPointAtRes(e, h.getGLRes()))).toArray();
20476
20507
  e && s.addMesh(this._ground);
20477
20508
  const f = l.map((e => [ e.x, e.y, 0, 1 ])), {lightProjViewMatrix: g, shadowMap: _, blurFBO: v} = this._shadowPass.render(s, {
20478
20509
  cameraProjViewMatrix: r,
@@ -20533,7 +20564,7 @@
20533
20564
  }
20534
20565
  _createGround() {
20535
20566
  const e = new $r;
20536
- e.generateBuffers(this.renderer.device), this._ground = new xr(e), this._groundScene = new Er([ this._ground ]);
20567
+ e.generateBuffers(this.renderer.device), this._ground = new xr(e), this._groundScene = new Ir([ this._ground ]);
20537
20568
  }
20538
20569
  _transformGround() {
20539
20570
  const e = this._layer.getMap(), t = Ol(this._ground.localTransform, e);
@@ -20541,10 +20572,10 @@
20541
20572
  }
20542
20573
  }
20543
20574
 
20544
- const Bl = [ 0, 0 ], Ul = new e__namespace.Coordinate(0, 0), Gl = new e__namespace.Coordinate(0, 0), zl = [], Vl = [], jl = [];
20575
+ const Bl = [ 0, 0 ], Ul = new e__namespace.Coordinate(0, 0), zl = new e__namespace.Coordinate(0, 0), Gl = [], Vl = [], jl = [];
20545
20576
 
20546
20577
  function Wl(e, t, n, r) {
20547
- const i = e.getGLRes(), o = e.distanceToPointAtRes(t, t, i, n ? Ul : null, Gl);
20578
+ const i = e.getGLRes(), o = e.distanceToPointAtRes(t, t, i, n ? Ul : null, zl);
20548
20579
  return r ? o.y : o.x;
20549
20580
  }
20550
20581
 
@@ -20661,7 +20692,7 @@
20661
20692
  $l(e, this.getMap());
20662
20693
  }
20663
20694
  _init() {
20664
- const e = this._getExtraCommandProps(), t = Fl.getUniformDeclares(), n = [];
20695
+ const e = this._getExtraCommandProps(), t = Nl.getUniformDeclares(), n = [];
20665
20696
  t.push({
20666
20697
  name: "projViewModelMatrix",
20667
20698
  type: "function",
@@ -20678,7 +20709,7 @@
20678
20709
  extraCommandProps: e,
20679
20710
  defines: {}
20680
20711
  });
20681
- const r = Fl.getUniformDeclares();
20712
+ const r = Nl.getUniformDeclares();
20682
20713
  r.push(...vo.getUniformDeclares()), this._standardShader = new Oa.StandardShader({
20683
20714
  uniforms: r,
20684
20715
  extraCommandProps: e
@@ -20736,19 +20767,19 @@
20736
20767
  castShadow: !1
20737
20768
  });
20738
20769
  const t = this._standardShader.getGeometryDefines(e);
20739
- this._ground.setDefines(t), this._groundScene = new Er([ this._ground ]);
20770
+ this._ground.setDefines(t), this._groundScene = new Ir([ this._ground ]);
20740
20771
  }
20741
20772
  _transformGround() {
20742
20773
  const e = this.getMap(), t = rc.getGroundTransform(this._ground.localTransform, e);
20743
20774
  this._ground.setLocalTransform(t);
20744
20775
  const n = e.getGLRes(), r = e._get2DExtentAtRes(n), i = r.getWidth(), o = r.getHeight(), s = e.cameraLookAt, a = s[0] - i, l = s[1] - o, c = this._polygonPatternFile ? this._polygonPatternFile.width / this._polygonPatternFile.height : 1, u = this.getSymbol(), f = this.material ? this.material.get("textureOrigin") : u.polygonPatternFileOrigin, h = !!(this.material ? this.material.get("uvOffsetInMeter") : u.uvOffsetInMeter), m = (this.material ? this.material.get("uvOffset") : u.uvOffset) || Yl, p = this.material && this.material.get("uvScale") || Zl, g = this.material ? this.material.get("textureWidth") : u.polygonPatternFileWidth, _ = this.material ? g * (p[1] / p[0]) : u.polygonPatternFileHeight, v = this._getUVOffsetAnim(), [x, b, y, S, T] = function(e, t, n, r, i, o, s, a, l, c, u) {
20745
20776
  const f = e.getGLRes();
20746
- r && (Ul.set(r[0], r[1]), e.coordToPointAtRes(Ul, f, Gl), t -= Gl.x, n -= Gl.y);
20777
+ r && (Ul.set(r[0], r[1]), e.coordToPointAtRes(Ul, f, zl), t -= zl.x, n -= zl.y);
20747
20778
  const h = r ? Ul : null;
20748
20779
  c = copy$1(Vl, c);
20749
20780
  const m = !l && c || Bl;
20750
20781
  let p = l && c || Bl;
20751
- p = copy$1(zl, p), p[0] && (p[0] = Wl(e, p[0], h)), p[1] && (p[1] = Wl(e, p[1], h, 1));
20782
+ p = copy$1(Gl, p), p[0] && (p[0] = Wl(e, p[0], h)), p[1] && (p[1] = Wl(e, p[1], h, 1));
20752
20783
  let g = .5;
20753
20784
  i && (g = Wl(e, i, h));
20754
20785
  let _ = g / s;
@@ -20945,7 +20976,7 @@
20945
20976
  height: 2
20946
20977
  });
20947
20978
  if (this._mesh = this._createRain(), !this._mesh) return;
20948
- this._scene = new Er(this._mesh);
20979
+ this._scene = new Ir(this._mesh);
20949
20980
  const t = this._getRainConfig();
20950
20981
  t.rainTexture ? this._creatRainTexture(t.rainTexture).then((e => {
20951
20982
  this._mesh.material.set("rainMap", e);
@@ -21106,7 +21137,7 @@
21106
21137
  extraCommandProps: {
21107
21138
  viewport: t
21108
21139
  }
21109
- }), this._shader.version = 300, this._scene = new Er, this._groundMask = this._createGroundMask(),
21140
+ }), this._shader.version = 300, this._scene = new Ir, this._groundMask = this._createGroundMask(),
21110
21141
  this._scene.setMeshes(this._groundMask), this.renderer = new Sr(this._regl);
21111
21142
  const n = this._getSnowConfig();
21112
21143
  n && (n.snowGroundTexture ? this._createSnowTexture(n.snowGroundTexture) : (this._groundNormal = this._regl.texture({
@@ -21187,7 +21218,7 @@
21187
21218
 
21188
21219
  const kc = [];
21189
21220
 
21190
- class Ic {
21221
+ class Ec {
21191
21222
  constructor(e, t, n) {
21192
21223
  this._regl = e, this._layer = t, this._config = n, this._init();
21193
21224
  }
@@ -21211,9 +21242,9 @@
21211
21242
  }), this.EMPTY_TEXTURE = this._regl.texture({
21212
21243
  width: 2,
21213
21244
  height: 2
21214
- }), this._rainPainter = new bc(this._regl, this._layer), this._rainRipplesPass = new No(this._regl, t),
21245
+ }), this._rainPainter = new bc(this._regl, this._layer), this._rainRipplesPass = new Fo(this._regl, t),
21215
21246
  this._snowPainter = new Oc(this._regl, this._layer), this._fogPass = new ko(this._regl, t, this._layer),
21216
- this._weatherShader = new Io, this._weatherShader.version = 300;
21247
+ this._weatherShader = new Eo, this._weatherShader.version = 300;
21217
21248
  }
21218
21249
  getMap() {
21219
21250
  return this._layer && this._layer.getMap();
@@ -21319,7 +21350,7 @@
21319
21350
  }
21320
21351
  }
21321
21352
 
21322
- const Ec = [], Pc = e => !!e.bloom, Rc = e => !!e.ssr;
21353
+ const Ic = [], Pc = e => !!e.bloom, Rc = e => !!e.ssr;
21323
21354
 
21324
21355
  class Lc {
21325
21356
  constructor(e, t) {
@@ -21400,7 +21431,7 @@
21400
21431
  !0 === this._layer.options.antialias ? h.HAS_MULTISAMPLED = 1 : delete h.HAS_MULTISAMPLED,
21401
21432
  this._fxaaShader.setDefines(h), this._renderer.render(this._fxaaShader, {
21402
21433
  textureSource: t,
21403
- resolution: set$1(Ec, t.width, t.height),
21434
+ resolution: set$1(Ic, t.width, t.height),
21404
21435
  enableFXAA: n,
21405
21436
  enableToneMapping: r,
21406
21437
  enableSharpen: i,
@@ -21428,7 +21459,7 @@
21428
21459
  postprocess(e, t, n) {
21429
21460
  this._postProcessShader || (this._postProcessShader = new co);
21430
21461
  const r = this._layer && this._layer.getRenderer(), i = n || r._getFBOColor(e);
21431
- return t.resolution = set$1(Ec, i.width, i.height), t.textureSource = i, t.timeGrain = performance.now(),
21462
+ return t.resolution = set$1(Ic, i.width, i.height), t.textureSource = i, t.timeGrain = performance.now(),
21432
21463
  this._renderer.render(this._postProcessShader, t), this._target;
21433
21464
  }
21434
21465
  dispose() {
@@ -21473,11 +21504,12 @@
21473
21504
  return e.depthStencil._texture.texture;
21474
21505
  }
21475
21506
 
21476
- class Nc extends io {
21507
+ class Fc extends io {
21477
21508
  constructor(e) {
21478
21509
  super({
21479
- vert: "#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}",
21510
+ name: "analysis",
21480
21511
  frag: "#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n#endif\nprecision mediump float;\n#include <gl2_frag>\nvarying vec2 vTexCoord;\n#ifdef HAS_FLOODANALYSE\nuniform vec3 flood_waterColor;\nuniform float flood_waterOpacity;\nuniform sampler2D floodMap;\n#endif\n#ifdef HAS_SKYLINE\nuniform sampler2D skylineMap;\n#endif\n#ifdef HAS_VIEWSHED\nuniform vec4 viewshed_visibleColor;\nuniform vec4 viewshed_invisibleColor;\nuniform sampler2D viewshedMap;\n#endif\n#ifdef HAS_INSIGHT\nuniform vec4 insight_visibleColor;\nuniform vec4 insight_invisibleColor;\nuniform sampler2D insightMap;\n#endif\n#ifdef HAS_CUT\nuniform sampler2D meshesMap;\nuniform sampler2D invisibleMap;\n#endif\n#ifdef HAS_EXCAVATE\nuniform sampler2D excavateMap;\n#endif\n#ifdef HAS_CROSSCUT\nuniform sampler2D crosscutMap;\nuniform vec4 cutLineColor;\n#endif\n#ifdef HAS_HEIGHTLIMIT\nuniform vec3 limitColor;\nuniform sampler2D heightLimitMap;\n#endif\nuniform sampler2D sceneMap;\nvoid main() {\n vec4 c = texture2D(sceneMap, vTexCoord);\n glFragColor = c;\n#ifdef HAS_VIEWSHED\nvec4 d = texture2D(viewshedMap, vTexCoord);\n if(d.r > .99) {\n glFragColor = vec4(mix(viewshed_invisibleColor.rgb, c.rgb, viewshed_invisibleColor.a), c.a);\n } else if(d.g > .99) {\n glFragColor = vec4(mix(viewshed_visibleColor.rgb, c.rgb, viewshed_visibleColor.a), c.a);\n } else if(d.a < .01) {\n glFragColor = vec4(d.rgb, 1.);\n }\n \n \n#endif\n#ifdef HAS_FLOODANALYSE\nvec4 e = texture2D(floodMap, vTexCoord);\n if(e.r > .0) {\n glFragColor = vec4(mix(glFragColor.rgb, flood_waterColor, flood_waterOpacity), glFragColor.a);\n }\n#endif\n#ifdef HAS_SKYLINE\nvec4 f = texture2D(skylineMap, vTexCoord);\n if(f.r > .0 || f.g > .0 || f.b > .0) {\n glFragColor = f;\n }\n#endif\n#ifdef HAS_INSIGHT\nvec4 h = texture2D(insightMap, vTexCoord);\n if(h.g > .0) {\n glFragColor = insight_visibleColor;\n } else if(h.r > .0) {\n glFragColor = insight_invisibleColor;\n }\n \n#endif\n#ifdef HAS_CUT\nvec4 i = texture2D(invisibleMap, vTexCoord);\n vec4 j = texture2D(meshesMap, vTexCoord);\n if(i.r == 1. && i.g == .0 && i.b == .0) {\n glFragColor = j;\n } else if(i.r == .0 && i.g == 1. && i.b == .0) {\n glFragColor = j;\n } else if(i.r == .0 && i.g == .0 && i.b == 1.) {\n glFragColor = c;\n }\n \n \n#endif\n#ifdef HAS_EXCAVATE\nvec4 k = texture2D(excavateMap, vTexCoord);\n if(k.r == 1. && k.g == .0 && k.b == .0) {\n glFragColor = c;\n } else {\n glFragColor = k;\n }\n#endif\n#ifdef HAS_CROSSCUT\nvec4 l = texture2D(crosscutMap, vTexCoord);\n if(l.r > .0) {\n glFragColor = vec4(mix(cutLineColor.rgb, glFragColor.rgb, .99), glFragColor.a);\n }\n#endif\n#ifdef HAS_HEIGHTLIMIT\nvec4 m = texture2D(heightLimitMap, vTexCoord);\n if(m.r > .0) {\n glFragColor = vec4(mix(limitColor, glFragColor.rgb, .6), glFragColor.a);\n }\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",
21512
+ wgslFrag: "struct FragmentUniforms {\n resolution: vec2f,\n #ifdef HAS_FLOODANALYSE\n flood_waterColor: vec3f,\n flood_waterOpacity: f32,\n #endif\n #ifdef HAS_VIEWSHED\n viewshed_visibleColor: vec4f,\n viewshed_invisibleColor: vec4f,\n #endif\n #ifdef HAS_INSIGHT\n insight_visibleColor: vec4f,\n insight_invisibleColor: vec4f,\n #endif\n #ifdef HAS_CROSSCUT\n cutLineColor: vec4f,\n #endif\n #ifdef HAS_HEIGHTLIMIT\n limitColor: vec3f,\n #endif\n};\n#ifdef HAS_FLOODANALYSE\n @group(0) @binding($b) var floodMap: texture_2d<f32>;\n @group(0) @binding($b) var floodMapSampler: sampler;\n#endif\n#ifdef HAS_SKYLINE\n @group(0) @binding($b) var skylineMap: texture_2d<f32>;\n @group(0) @binding($b) var skylineMapSampler: sampler;\n#endif\n#ifdef HAS_VIEWSHED\n @group(0) @binding($b) var viewshedMap: texture_2d<f32>;\n @group(0) @binding($b) var viewshedMapSampler: sampler;\n#endif\n#ifdef HAS_INSIGHT\n @group(0) @binding($b) var insightMap: texture_2d<f32>;\n @group(0) @binding($b) var insightMapSampler: sampler;\n#endif\n#ifdef HAS_CUT\n @group(0) @binding($b) var meshesMap: texture_2d<f32>;\n @group(0) @binding($b) var meshesMapSampler: sampler;\n @group(0) @binding($b) var invisibleMap: texture_2d<f32>;\n @group(0) @binding($b) var invisibleMapSampler: sampler;\n#endif\n#ifdef HAS_EXCAVATE\n @group(0) @binding($b) var excavateMap: texture_2d<f32>;\n @group(0) @binding($b) var excavateMapSampler: sampler;\n#endif\n#ifdef HAS_CROSSCUT\n @group(0) @binding($b) var crosscutMap: texture_2d<f32>;\n @group(0) @binding($b) var crosscutMapSampler: sampler;\n#endif\n#ifdef HAS_HEIGHTLIMIT\n @group(0) @binding($b) var heightLimitMap: texture_2d<f32>;\n @group(0) @binding($b) var heightLimitMapSampler: sampler;\n#endif\n#ifdef HAS_MULTISAMPLED\n @group(0) @binding($b) var sceneMap: texture_multisampled_2d<f32>;\n#else\n @group(0) @binding($b) var sceneMap: texture_2d<f32>;\n#endif\n@group(0) @binding($b) var sceneMapSampler: sampler;\n@group(0) @binding($b) var<uniform> uniforms: FragmentUniforms;\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n var glFragColor: vec4f;\n var uv = vertexOutput.vTexCoord;\n uv.y = 1.0 - uv.y;\n #ifdef HAS_MULTISAMPLED\n let sceneColor = textureLoad(sceneMap, vec2i(uv * uniforms.resolution), 0);\n #else\n let sceneColor = textureSample(sceneMap, sceneMapSampler, uv);\n #endif\n glFragColor = sceneColor;\n #ifdef HAS_VIEWSHED\n let viewshedColor = textureSample(viewshedMap, viewshedMapSampler, uv);\n if (viewshedColor.r > 0.99) {\n glFragColor = vec4f(\n mix(uniforms.viewshed_invisibleColor.rgb, sceneColor.rgb, uniforms.viewshed_invisibleColor.a),\n sceneColor.a\n );\n } else if (viewshedColor.g > 0.99) {\n glFragColor = vec4f(\n mix(uniforms.viewshed_visibleColor.rgb, sceneColor.rgb, uniforms.viewshed_visibleColor.a),\n sceneColor.a\n );\n } else if (viewshedColor.a < 0.01) {\n glFragColor = vec4f(viewshedColor.rgb, 1.0);\n }\n #endif\n #ifdef HAS_FLOODANALYSE\n let floodColor = textureSample(floodMap, floodMapSampler, uv);\n if (floodColor.r > 0.0) {\n glFragColor = vec4f(\n mix(glFragColor.rgb, uniforms.flood_waterColor, uniforms.flood_waterOpacity),\n glFragColor.a\n );\n }\n #endif\n #ifdef HAS_SKYLINE\n let skylineColor = textureSample(skylineMap, skylineMapSampler, uv);\n if (skylineColor.r > 0.0 || skylineColor.g > 0.0 || skylineColor.b > 0.0) {\n glFragColor = skylineColor;\n }\n #endif\n #ifdef HAS_INSIGHT\n let insightColor = textureSample(insightMap, insightMapSampler, uv);\n if (insightColor.g > 0.0) {\n glFragColor = uniforms.insight_visibleColor;\n } else if (insightColor.r > 0.0) {\n glFragColor = uniforms.insight_invisibleColor;\n }\n #endif\n #ifdef HAS_CUT\n let cutColor = textureSample(invisibleMap, invisibleMapSampler, uv);\n let meshesMapColor = textureSample(meshesMap, meshesMapSampler, uv);\n if (cutColor.r == 1.0 && cutColor.g == 0.0 && cutColor.b == 0.0) {\n glFragColor = meshesMapColor;\n } else if (cutColor.r == 0.0 && cutColor.g == 1.0 && cutColor.b == 0.0) {\n glFragColor = meshesMapColor;\n } else if (cutColor.r == 0.0 && cutColor.g == 0.0 && cutColor.b == 1.0) {\n glFragColor = sceneColor;\n }\n #endif\n #ifdef HAS_EXCAVATE\n let excavateColor = textureSample(excavateMap, excavateMapSampler, uv);\n if (excavateColor.r == 1.0 && excavateColor.g == 0.0 && excavateColor.b == 0.0) {\n glFragColor = sceneColor;\n } else {\n glFragColor = excavateColor;\n }\n #endif\n #ifdef HAS_CROSSCUT\n let crosscutColor = textureSample(crosscutMap, crosscutMapSampler, uv);\n if (crosscutColor.r > 0.0) {\n glFragColor = vec4f(\n mix(uniforms.cutLineColor.rgb, glFragColor.rgb, 0.99),\n glFragColor.a\n );\n }\n #endif\n #ifdef HAS_HEIGHTLIMIT\n let heightLimitColor = textureSample(heightLimitMap, heightLimitMapSampler, uv);\n if (heightLimitColor.r > 0.0) {\n glFragColor = vec4f(\n mix(uniforms.limitColor, glFragColor.rgb, 0.6),\n glFragColor.a\n );\n }\n #endif\n return glFragColor;\n}",
21481
21513
  extraCommandProps: {
21482
21514
  viewport: e,
21483
21515
  cull: {
@@ -21498,7 +21530,7 @@
21498
21530
  }
21499
21531
  }
21500
21532
 
21501
- class Fc {
21533
+ class Nc {
21502
21534
  constructor(e, t, n) {
21503
21535
  this._regl = e, this._layer = t, this._config = n, this._init();
21504
21536
  }
@@ -21519,7 +21551,7 @@
21519
21551
  min: "linear"
21520
21552
  }),
21521
21553
  depth: !0
21522
- }), this._shader = new Nc(t);
21554
+ }), this._shader = new Fc(t);
21523
21555
  }
21524
21556
  getMap() {
21525
21557
  return this._layer && this._layer.getMap();
@@ -21534,20 +21566,19 @@
21534
21566
  depth: 1,
21535
21567
  stencil: 0,
21536
21568
  framebuffer: this._fbo
21537
- }), delete this._shader.shaderDefines.HAS_FLOODANALYSE, delete this._shader.shaderDefines.HAS_VIEWSHED,
21538
- delete this._shader.shaderDefines.HAS_SKYLINE, delete this._shader.shaderDefines.HAS_INSIGHT,
21539
- delete this._shader.shaderDefines.HAS_CUT, delete this._shader.shaderDefines.HAS_CROSSCUT,
21540
- delete this._shader.shaderDefines.HAS_HEIGHTLIMIT;
21569
+ });
21570
+ const i = Tl({}, this._shader.shaderDefines);
21571
+ delete i.HAS_FLOODANALYSE, delete i.HAS_VIEWSHED, delete i.HAS_SKYLINE, delete i.HAS_INSIGHT,
21572
+ delete i.HAS_CUT, delete i.HAS_CROSSCUT, delete i.HAS_HEIGHTLIMIT, e.texture && e.texture.sampleCount > 1 && (i.HAS_MULTISAMPLED = 1);
21541
21573
  for (let e = 0; e < r.length; e++) {
21542
- const i = r[e];
21543
- if (!i.isEnable()) continue;
21544
- const o = i.getDefines();
21545
- Tl(this._shader.shaderDefines, o);
21546
- const s = this.getMap(), a = s.width, l = s.height, c = this._getToAnalysisMeshes(t, i.getExcludeLayers()), u = i.renderAnalysis(c, a, l);
21574
+ const o = r[e];
21575
+ if (!o.isEnable()) continue;
21576
+ Tl(i, o.getDefines());
21577
+ const s = this.getMap(), a = s.width, l = s.height, c = this._getToAnalysisMeshes(t, o.getExcludeLayers()), u = o.renderAnalysis(c, a, l);
21547
21578
  u && Tl(n, u);
21548
21579
  }
21549
- return n.sceneMap = e, this._shader.setDefines(this._shader.shaderDefines), this.renderer.render(this._shader, n, null, this._fbo),
21550
- this._fbo;
21580
+ return n.sceneMap = e, n.resolution = [ this._fbo.width, this._fbo.height ], this._shader.setDefines(i),
21581
+ this.renderer.render(this._shader, n, null, this._fbo), this._fbo;
21551
21582
  }
21552
21583
  _getToAnalysisMeshes(e, t) {
21553
21584
  let n = [];
@@ -21563,8 +21594,18 @@
21563
21594
  }
21564
21595
  return n;
21565
21596
  }
21597
+ getViewportSize() {
21598
+ let e, t;
21599
+ return this._viewport.width.data ? (e = e$2.Util.isFunction(this._viewport.width.data) ? this._viewport.width.data() : this._viewport.width,
21600
+ t = e$2.Util.isFunction(this._viewport.height.data) ? this._viewport.height.data() : this._viewport.height) : (e = e$2.Util.isFunction(this._viewport.width) ? this._viewport.width() : this._viewport.width,
21601
+ t = e$2.Util.isFunction(this._viewport.height) ? this._viewport.height() : this._viewport.height),
21602
+ {
21603
+ width: e,
21604
+ height: t
21605
+ };
21606
+ }
21566
21607
  _resize() {
21567
- const e = e$2.Util.isFunction(this._viewport.width.data) ? this._viewport.width.data() : this._viewport.width, t = e$2.Util.isFunction(this._viewport.height.data) ? this._viewport.height.data() : this._viewport.height;
21608
+ const {width: e, height: t} = this.getViewportSize();
21568
21609
  !this._fbo || this._fbo.width === e && this._fbo.height === t || this._fbo.resize(e, t);
21569
21610
  }
21570
21611
  _hasAnalysis() {
@@ -21577,9 +21618,9 @@
21577
21618
 
21578
21619
  const Bc = [], Uc = new e__namespace.Coordinate(0, 0);
21579
21620
 
21580
- let Gc = {};
21621
+ let zc = {};
21581
21622
 
21582
- class zc {
21623
+ class Gc {
21583
21624
  constructor(e, t) {
21584
21625
  this._regl = e, this._layer = t, this._init();
21585
21626
  }
@@ -21613,11 +21654,11 @@
21613
21654
  const n = this._layer.getMap();
21614
21655
  this._resize();
21615
21656
  const r = this._layer.getScanEffectConfig(), i = {}, {effects: o} = r, s = n.getGLRes(), a = [];
21616
- this._effectLength !== o.length && (Gc = {});
21657
+ this._effectLength !== o.length && (zc = {});
21617
21658
  for (let e = 0; e < o.length; e++) {
21618
21659
  const {center: t, radius: r, speed: i, color: l, direction: c, height: u} = o[e], f = Vc(t), d = n.coordinateToPointAtRes(f, s, Uc).toArray(), m = n.distanceToPointAtRes(r, 0, s).x, p = "vertical" === c ? 1 : 0, g = n.altitudeToPoint(u || 0, s);
21619
- Gc[e] = Gc[e] || [];
21620
- const _ = set$7(Gc[e], d[0], d[1], m, i, l[0], l[1], l[2], p, g);
21660
+ zc[e] = zc[e] || [];
21661
+ const _ = set$7(zc[e], d[0], d[1], m, i, l[0], l[1], l[2], p, g);
21621
21662
  a.push(_);
21622
21663
  }
21623
21664
  const l = {
@@ -21933,10 +21974,10 @@
21933
21974
  const o = t || i;
21934
21975
  this._groundPainter = new rc(o, this.layer), this._envPainter = new cc(o, this.layer);
21935
21976
  const s = this.layer.getWeatherConfig();
21936
- this._weatherPainter = new Ic(o, e, s), this._analysisPainter = new Fc(o, e), this._scanEffectPainter = new zc(o, e);
21977
+ this._weatherPainter = new Ec(o, e, s), this._analysisPainter = new Nc(o, e), this._scanEffectPainter = new Gc(o, e);
21937
21978
  const a = this.layer._getSceneConfig() || {}, l = a && a.postProcess, c = l && l.antialias && l.antialias.jitterRatio || .2;
21938
21979
  this._jitGetter = new mo(c), this._postProcessor = new Lc(o, this.layer, this._jitGetter),
21939
- this._shadowProcess = new Fl(o, this.layer);
21980
+ this._shadowProcess = new Nl(o, this.layer);
21940
21981
  }
21941
21982
  clearContext() {
21942
21983
  super.clearContext(), this._clearFramebuffers();
@@ -22159,11 +22200,11 @@
22159
22200
  const t = this.layer._getSceneConfig();
22160
22201
  if (!t || !t.shadow || !t.shadow.enable) return this._shadowProcess && (this._shadowProcess.dispose(),
22161
22202
  delete this._shadowProcess), null;
22162
- this._shadowProcess || (this._shadowProcess = new Fl(this.device, this.layer));
22203
+ this._shadowProcess || (this._shadowProcess = new Nl(this.device, this.layer));
22163
22204
  const n = {
22164
22205
  config: t.shadow,
22165
22206
  defines: this._shadowProcess.getDefines(),
22166
- uniformDeclares: Fl.getUniformDeclares()
22207
+ uniformDeclares: Nl.getUniformDeclares()
22167
22208
  };
22168
22209
  return n.renderUniforms = this._renderShadow(e), n;
22169
22210
  }
@@ -22176,7 +22217,7 @@
22176
22217
  if (Array.isArray(n)) for (let e = 0; e < n.length; e++) n[e] && (n[e].needUpdateShadow && (i = !0,
22177
22218
  n[e].needUpdateShadow = !1), n[e].hasFunctionUniform && (n[e].hasFunctionUniform("minAltitude") || n[e].setFunctionUniform("minAltitude", (() => t && t.options.altitude || 0)),
22178
22219
  r.push(n[e])));
22179
- })), this._shadowScene || (this._shadowScene = new Er), this._shadowScene.setMeshes(r);
22220
+ })), this._shadowScene || (this._shadowScene = new Ir), this._shadowScene.setMeshes(r);
22180
22221
  const o = this.getMap(), s = n.shadow, a = o.getLightManager(), l = a && a.getDirectionalLight().direction || Xc, c = !n.ground || !n.ground.enable;
22181
22222
  return this._shadowProcess.render(c, o.projMatrix, o.viewMatrix, s.color, s.opacity, l, this._shadowScene, this._jitter, t, i);
22182
22223
  }
@@ -22537,9 +22578,9 @@
22537
22578
  O(f);
22538
22579
  const k = A;
22539
22580
  O(h);
22540
- const I = A;
22541
- O(d);
22542
22581
  const E = A;
22582
+ O(d);
22583
+ const I = A;
22543
22584
  O(m);
22544
22585
  return {
22545
22586
  vertices: v,
@@ -22547,8 +22588,8 @@
22547
22588
  numVerticesWithoutSkirts: o,
22548
22589
  numTrianglesWithoutSkirts: s,
22549
22590
  leftSkirtIndex: k,
22550
- rightSkirtIndex: I,
22551
- bottomSkirtIndex: E,
22591
+ rightSkirtIndex: E,
22592
+ bottomSkirtIndex: I,
22552
22593
  topSkirtIndex: A
22553
22594
  };
22554
22595
  }
@@ -22702,7 +22743,7 @@
22702
22743
  constructor(e) {
22703
22744
  this.layer = e;
22704
22745
  const t = e.getRenderer();
22705
- this.device = t.regl || t.device, this.renderer = new Sr(this.device), this._leafScene = new Er;
22746
+ this.device = t.regl || t.device, this.renderer = new Sr(this.device), this._leafScene = new Ir;
22706
22747
  const n = new Uint8Array(16);
22707
22748
  n.fill(255), this._emptyTileTexture = this.device.texture({
22708
22749
  width: 2,
@@ -23005,8 +23046,8 @@
23005
23046
  }
23006
23047
  }
23007
23048
 
23008
- function Iu(e, t, n, r) {
23009
- const i = Eu.call(this, n, r);
23049
+ function Eu(e, t, n, r) {
23050
+ const i = Iu.call(this, n, r);
23010
23051
  this._projViewMatrix = t;
23011
23052
  const {colorExtent: o, modeExtent: s} = this._extentPass.render(i, t);
23012
23053
  this._maskUniforms = this._maskUniforms || {}, this._maskUniforms.mask_colorExtent = o,
@@ -23016,7 +23057,7 @@
23016
23057
  this.setToRedraw();
23017
23058
  }
23018
23059
 
23019
- function Eu(e, t) {
23060
+ function Iu(e, t) {
23020
23061
  const n = [], r = this.layer.getMasks();
23021
23062
  for (let i = 0; i < r.length; i++) {
23022
23063
  const o = r[i].getMesh(this.regl, e, t);
@@ -23027,7 +23068,7 @@
23027
23068
 
23028
23069
  function Pu() {
23029
23070
  if (!this._extentPass || !this._maskUniforms) return;
23030
- const e = this._maskUniforms.mask_heightRatio, t = this._maskUniforms.mask_heightOffset, n = Eu.call(this, e, t);
23071
+ const e = this._maskUniforms.mask_heightRatio, t = this._maskUniforms.mask_heightOffset, n = Iu.call(this, e, t);
23031
23072
  this._extentPass.render(n, this._projViewMatrix);
23032
23073
  const r = this.layer.getMasks();
23033
23074
  for (let e = 0; e < r.length; e++) r[e]._update && r[e]._update();
@@ -23054,9 +23095,9 @@
23054
23095
  y: 0,
23055
23096
  width: () => this.canvas ? this.canvas.width : 1,
23056
23097
  height: () => this.canvas ? this.canvas.height : 1
23057
- }), this._extentPass ? Iu.call(this, e, t, n, r) : this.regl ? (this._extentPass = new Uo(this.regl, this.viewport),
23058
- Iu.call(this, e, t, n, r)) : this.layer.once("contextcreate", (() => {
23059
- this._extentPass = new Uo(this.regl, this.viewport), Iu.call(this, e, t, n, r);
23098
+ }), this._extentPass ? Eu.call(this, e, t, n, r) : this.regl ? (this._extentPass = new Uo(this.regl, this.viewport),
23099
+ Eu.call(this, e, t, n, r)) : this.layer.once("contextcreate", (() => {
23100
+ this._extentPass = new Uo(this.regl, this.viewport), Eu.call(this, e, t, n, r);
23060
23101
  }), this);
23061
23102
  }
23062
23103
  needToRedraw() {
@@ -23138,7 +23179,7 @@
23138
23179
  }
23139
23180
  }
23140
23181
 
23141
- const {TileLayerRendererable: Nu, LayerAbstractRenderer: Fu} = e__namespace.renderer, Bu = new e__namespace.Point(0, 0), Uu = new e__namespace.Point(0, 0), Gu = new e__namespace.PointExtent(0, 0, 0, 0), zu = new e__namespace.Point(0, 0), Vu = {
23182
+ const {TileLayerRendererable: Fu, LayerAbstractRenderer: Nu} = e__namespace.renderer, Bu = new e__namespace.Point(0, 0), Uu = new e__namespace.Point(0, 0), zu = new e__namespace.PointExtent(0, 0, 0, 0), Gu = new e__namespace.Point(0, 0), Vu = {
23142
23183
  color: [ 0, 0, 0, 0 ],
23143
23184
  depth: 1,
23144
23185
  stencil: 0
@@ -23148,7 +23189,7 @@
23148
23189
  stencil: 0
23149
23190
  };
23150
23191
 
23151
- class Wu extends(Hu(Nu(Fu))){
23192
+ class Wu extends(Hu(Fu(Nu))){
23152
23193
  constructor(...e) {
23153
23194
  super(...e), this.init();
23154
23195
  }
@@ -23236,7 +23277,7 @@
23236
23277
  _recenterMapOnTerrain(e) {
23237
23278
  const t = this.getMap();
23238
23279
  if (t.updateCenterAltitude && void 0 === t.centerAltitude && e.z === this.getCurrentTileZoom()) {
23239
- const n = t._getPrjCenter(), r = t._prjToPointAtRes(n, e.res, zu);
23280
+ const n = t._getPrjCenter(), r = t._prjToPointAtRes(n, e.res, Gu);
23240
23281
  e.extent2d.contains(r) && t.updateCenterAltitude();
23241
23282
  }
23242
23283
  }
@@ -23256,10 +23297,10 @@
23256
23297
  this._newTerrainTileCounter = 0;
23257
23298
  const l = this.layer.getSkinCount(), c = new Set;
23258
23299
  if (s && s.length) {
23259
- Il(o, s.map((e => e.info)));
23300
+ El(o, s.map((e => e.info)));
23260
23301
  for (let e = 0; e < l; e++) this._renderChildTerrainSkin(e, s, c, a);
23261
23302
  }
23262
- Il(e, this._getTempTilesForMissed(o, a)), this._debugTile(e, "drawTiles");
23303
+ El(e, this._getTempTilesForMissed(o, a)), this._debugTile(e, "drawTiles");
23263
23304
  for (let t = 0; t < l; t++) this._renderChildTerrainSkin(t, e, c, a);
23264
23305
  for (let t = 0; t < e.length; t++) this._renderTerrainMeshSkin(e[t].info, e[t].image);
23265
23306
  for (let e = 0; e < a.length; e++) a[e] && a[e].texture && !a[e].refs.size && (this._skinImageCache.delete(a[e].tile.id),
@@ -23375,24 +23416,24 @@
23375
23416
  const k = M.map((e => e.info.id)).join();
23376
23417
  if (!u && !O && A.tileIds === k) return !1;
23377
23418
  A.tileIds = k;
23378
- let I = !1;
23419
+ let E = !1;
23379
23420
  A.currentSkins.clear(), A.length = 0;
23380
- const E = A.currentSkins;
23421
+ const I = A.currentSkins;
23381
23422
  let P = t.id;
23382
23423
  n.temp && (P += "-temp");
23383
23424
  for (let e = 0; e < M.length; e++) {
23384
23425
  const t = M[e].info.id;
23385
- E.add(t);
23426
+ I.add(t);
23386
23427
  let n = this._getCachedSkinImage(t);
23387
23428
  n && ((R = n) && R.texture) || (n = {
23388
23429
  tile: Tl({}, M[e]),
23389
23430
  layer: o,
23390
23431
  refs: new Set,
23391
23432
  texture: s.createTerrainTexture(this.device)
23392
- }, this._saveCachedSkinImage(t, n)), n.refs.add(P), A.push(n), I = !0;
23433
+ }, this._saveCachedSkinImage(t, n)), n.refs.add(P), A.push(n), E = !0;
23393
23434
  }
23394
23435
  var R;
23395
- return this._clearPrevSkinImages(t, n, C, E, r), I && this._newTerrainTileCounter++,
23436
+ return this._clearPrevSkinImages(t, n, C, I, r), E && this._newTerrainTileCounter++,
23396
23437
  n.skinImages[e] = A, o.fire("renderterrainskin", {
23397
23438
  tile: t,
23398
23439
  skinTiles: M
@@ -23781,7 +23822,7 @@
23781
23822
  Uu.set(l, c)._multi(n);
23782
23823
  const h = u._getTileNum(Uu, n, !0), d = Math.min(f.x, h.x), m = Math.max(f.x, h.x), p = Math.min(f.y, h.y), g = Math.max(f.y, h.y), _ = n / o;
23783
23824
  Bu.set(s, a)._multi(_), Uu.set(l, c)._multi(_);
23784
- const v = Gu.set(Bu.x, Bu.y, Uu.x, Uu.y), x = r.getTileSize().width + 1;
23825
+ const v = zu.set(Bu.x, Bu.y, Uu.x, Uu.y), x = r.getTileSize().width + 1;
23785
23826
  v._expand(v.getWidth() / x), e.array = e.array || new Float32Array(x * x);
23786
23827
  const b = e.tiles;
23787
23828
  e.complete = !0, e.array.fill(0);
@@ -23889,7 +23930,7 @@
23889
23930
  aPosition: t
23890
23931
  }, 0, 6, {
23891
23932
  positionSize: 2
23892
- }), this._skinGeometry.generateBuffers(this.device), this._skinScene = this._skinScene || new Er;
23933
+ }), this._skinGeometry.generateBuffers(this.device), this._skinScene = this._skinScene || new Ir;
23893
23934
  }
23894
23935
  updateMaterial(e) {
23895
23936
  this._painter && e && this._painter.updateMaterial && (void 0 === this._matVer && (this._matVer = 1),
@@ -24306,7 +24347,7 @@
24306
24347
  const Mf = new e__namespace.Coordinate(0, 0), Af = new e__namespace.Coordinate(0, 0), Cf = new e__namespace.Point(0, 0), Of = [], kf = {
24307
24348
  tileGrids: [],
24308
24349
  count: 0
24309
- }, If = "01", Ef = "1";
24350
+ }, Ef = "01", If = "1";
24310
24351
 
24311
24352
  class Pf extends(Tf(e__namespace.TileLayer)){
24312
24353
  constructor(e, t) {
@@ -24343,7 +24384,7 @@
24343
24384
  _createSkuToken() {
24344
24385
  let e = "";
24345
24386
  for (let t = 0; t < 10; t++) e += "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62 * Math.random())];
24346
- return [ Ef, If, e ].join("");
24387
+ return [ If, Ef, e ].join("");
24347
24388
  }
24348
24389
  _getExaggeration() {
24349
24390
  let e = this.options.exaggeration;
@@ -24520,7 +24561,7 @@
24520
24561
  "colors": []
24521
24562
  }), Pf.registerJSONType("TerrainLayer"), Pf.registerRenderer("gl", Wu), Pf.registerRenderer("gpu", Wu);
24522
24563
 
24523
- const Rf = [], Lf = [], Hf = [], Df = [], Nf = new e$2.Point(0, 0), Ff = [], Bf = [], Uf = [], Gf = [], zf = [], Vf = [], jf = [], Wf = [], qf = [];
24564
+ const Rf = [], Lf = [], Hf = [], Df = [], Ff = new e$2.Point(0, 0), Nf = [], Bf = [], Uf = [], zf = [], Gf = [], Vf = [], jf = [], Wf = [], qf = [];
24524
24565
 
24525
24566
  class $f {
24526
24567
  constructor(e, t, n = !0) {
@@ -24540,9 +24581,9 @@
24540
24581
  for (let e = 0; e < t.length; e++) {
24541
24582
  const r = t[e];
24542
24583
  if (!this._checkBBox(r.getBoundingBox(), l)) continue;
24543
- const s = r.localTransform, a = r.geometry, u = a.data[a.desc.positionAttribute].array, f = a.data[a.desc.altitudeAttribute] && a.data[a.desc.altitudeAttribute].array || Ff, h = a.indices;
24584
+ const s = r.localTransform, a = r.geometry, u = a.data[a.desc.positionAttribute].array, f = a.data[a.desc.altitudeAttribute] && a.data[a.desc.altitudeAttribute].array || Nf, h = a.indices;
24544
24585
  if (!(u && u.length && h && h.length)) continue;
24545
- const d = multiply$5(Gf, s, r.positionMatrix), m = this._testMesh(r, l, n, u, f, h, a.desc.positionSize, d, i);
24586
+ const d = multiply$5(zf, s, r.positionMatrix), m = this._testMesh(r, l, n, u, f, h, a.desc.positionSize, d, i);
24546
24587
  if (m) {
24547
24588
  const e = {
24548
24589
  mesh: r,
@@ -24557,13 +24598,13 @@
24557
24598
  const c = [], f = n.getGLRes();
24558
24599
  for (let h = 0; h < o.length && !(h > e.properties.skirtOffset); h += 3) {
24559
24600
  const e = o[h], d = o[h + 1], m = o[h + 2], p = e * s, g = d * s, _ = m * s;
24560
- zf[0] = r[p], zf[1] = r[p + 1], zf[2] = r[p + 2], Vf[0] = r[g], Vf[1] = r[g + 1],
24601
+ Gf[0] = r[p], Gf[1] = r[p + 1], Gf[2] = r[p + 2], Vf[0] = r[g], Vf[1] = r[g + 1],
24561
24602
  Vf[2] = r[g + 2], jf[0] = r[_], jf[1] = r[_ + 1], jf[2] = r[_ + 2];
24562
- const v = this._toWorldPosition(Lf, n, zf, i[e] / 100, a), x = this._toWorldPosition(Hf, n, Vf, i[d] / 100, a), b = this._toWorldPosition(Df, n, jf, i[m] / 100, a), y = set$5(Rf, v, x, b), S = sub$3(Bf, v, x), T = sub$3(Uf, v, b), w = this._testIntersection(Wf, y, t);
24603
+ const v = this._toWorldPosition(Lf, n, Gf, i[e] / 100, a), x = this._toWorldPosition(Hf, n, Vf, i[d] / 100, a), b = this._toWorldPosition(Df, n, jf, i[m] / 100, a), y = set$5(Rf, v, x, b), S = sub$3(Bf, v, x), T = sub$3(Uf, v, b), w = this._testIntersection(Wf, y, t);
24563
24604
  if (w) {
24564
24605
  const t = n.pointAtResToAltitude(w[2], f);
24565
- Nf.x = w[0], Nf.y = w[1];
24566
- const r = n.pointAtResToCoordinate(Nf, f);
24606
+ Ff.x = w[0], Ff.y = w[1];
24607
+ const r = n.pointAtResToCoordinate(Ff, f);
24567
24608
  if (r.z = t, c.push({
24568
24609
  coordinate: r,
24569
24610
  indices: [ e, d, m ],
@@ -25426,7 +25467,7 @@
25426
25467
  g && g.size > 0) {
25427
25468
  let n = [];
25428
25469
  i.forEach(((e, t) => {
25429
- g.has(t) || Il(n, e);
25470
+ g.has(t) || El(n, e);
25430
25471
  })), _.properties.hasInvisible = !0, wh(t, n);
25431
25472
  const r = {
25432
25473
  data: n,
@@ -25471,7 +25512,7 @@
25471
25512
  for (const e of s) {
25472
25513
  if (!i.has(e)) continue;
25473
25514
  const t = i.get(e);
25474
- t && Il(a, t);
25515
+ t && El(a, t);
25475
25516
  }
25476
25517
  wh(t, a), t.geometry.elements !== t.geometry.properties.oldElementsBeforeHighlight && t.geometry.elements.destroy && t.geometry.deleteElements();
25477
25518
  const l = {
@@ -25501,12 +25542,12 @@
25501
25542
  this._textures = [];
25502
25543
  }
25503
25544
  };
25504
- }, Ih = new e__namespace.Point(0, 0), Eh = [ 1, 1, 1, 1 ];
25545
+ }, Eh = new e__namespace.Point(0, 0), Ih = [ 1, 1, 1, 1 ];
25505
25546
 
25506
25547
  function Ph(e, t, n, r, i, o) {
25507
25548
  const s = n.xmax - n.xmin, a = n.ymax - n.ymin;
25508
25549
  r = r || [ 0, 0 ];
25509
- const l = Ih.set(n.xmin - r[0], n.ymax - r[1]), u = l.x * i, f = l.y * i, h = {
25550
+ const l = Eh.set(n.xmin - r[0], n.ymax - r[1]), u = l.x * i, f = l.y * i, h = {
25510
25551
  data: t,
25511
25552
  mag: "nearest",
25512
25553
  mipmap: !0,
@@ -25519,11 +25560,11 @@
25519
25560
  opacity: 1,
25520
25561
  debugLine: 0,
25521
25562
  alphaTest: 0,
25522
- baseColor: Eh,
25563
+ baseColor: Ih,
25523
25564
  baseColorTexture: d
25524
25565
  });
25525
25566
  const m = new Ht(o), p = new xr(e, m);
25526
- p.properties.minFilter = zr;
25567
+ p.properties.minFilter = Gr;
25527
25568
  const g = identity$2([]);
25528
25569
  return translate$1(g, g, [ u || 0, f || 0, 0 ]), scale$8(g, g, [ i * s, i * a, 1 ]),
25529
25570
  p.localTransform = g, p;
@@ -25533,20 +25574,20 @@
25533
25574
  const i = e__namespace.MapStateCache[n.id], o = i ? i.zoom : n.getZoom(), s = i ? i.devicePixelRatio : n.getDevicePixelRatio(), a = function(e, t) {
25534
25575
  const n = e.isMoving() && e.getRenderer().isViewChanged();
25535
25576
  let r;
25536
- r = n ? jr : e.getBearing() || e.getPitch() || !Number.isInteger(t) ? Vr : zr;
25577
+ r = n ? jr : e.getBearing() || e.getPitch() || !Number.isInteger(t) ? Vr : Gr;
25537
25578
  return r;
25538
25579
  }(n, o);
25539
25580
  if (t.properties.minFilter !== a) {
25540
25581
  t.material.get("baseColorTexture").setMinFilter(a), t.properties.minFilter = a;
25541
25582
  }
25542
25583
  const l = n.getResolution() !== r;
25543
- let c = zr;
25584
+ let c = Gr;
25544
25585
  if ((1 !== s || l) && (c = Vr), t.properties.magFilter !== c) {
25545
25586
  t.material.get("baseColorTexture").setMagFilter(c), t.properties.magFilter = c;
25546
25587
  }
25547
25588
  }
25548
25589
 
25549
- const {TileLayerRendererable: Lh, LayerAbstractRenderer: Hh} = e__namespace.renderer, Dh = new Int16Array([ 0, 0, 0, -1, 1, 0, 1, -1 ]), Nh = new Uint16Array([ 0, 0, 0, 1, 1, 0, 1, 1 ]), Fh = {
25590
+ const {TileLayerRendererable: Lh, LayerAbstractRenderer: Hh} = e__namespace.renderer, Dh = new Int16Array([ 0, 0, 0, -1, 1, 0, 1, -1 ]), Fh = new Uint16Array([ 0, 0, 0, 1, 1, 0, 1, 1 ]), Nh = {
25550
25591
  properties: {}
25551
25592
  }, Bh = new e__namespace.Point(20, 20);
25552
25593
 
@@ -25563,13 +25604,13 @@
25563
25604
  extraCommandProps: this._getCommandProps()
25564
25605
  }), this._tileGeometry = new Ye({
25565
25606
  aPosition: Dh,
25566
- aTexCoord: Nh
25607
+ aTexCoord: Fh
25567
25608
  }, 4, 0, {
25568
25609
  positionSize: 2,
25569
25610
  primitive: "triangle strip"
25570
25611
  });
25571
25612
  const {regl: e, device: t} = this.context;
25572
- this._tileGeometry.generateBuffers(e || t), this._tileMeshes = [], this._tileScene = new Er(this._tileMeshes),
25613
+ this._tileGeometry.generateBuffers(e || t), this._tileMeshes = [], this._tileScene = new Ir(this._tileMeshes),
25573
25614
  this._renderer = new Sr(e || t);
25574
25615
  }
25575
25616
  this._tileMeshes.length = 0, this.clearStencil(t);
@@ -25611,7 +25652,7 @@
25611
25652
  return n || (n = this._createTileMesh(t, e), e.mesh = n), super.consumeTile(e, t);
25612
25653
  }
25613
25654
  drawTile(e, t, n) {
25614
- if (n && n.sceneFilter && !n.sceneFilter(Fh)) return;
25655
+ if (n && n.sceneFilter && !n.sceneFilter(Nh)) return;
25615
25656
  const r = this.getMap();
25616
25657
  if (!e || !r || !t) return;
25617
25658
  let i = t.mesh;
@@ -25728,7 +25769,7 @@
25728
25769
  const a = s.getContext("2d");
25729
25770
  if (a.drawImage(t.image, 0, 0), i) {
25730
25771
  const {x: e, y: n, z: i} = t.info;
25731
- Gh(a, `${e}/${n}/${i}`, "yellow", 1, 0, 0, r, r, -18);
25772
+ zh(a, `${e}/${n}/${i}`, "yellow", 1, 0, 0, r, r, -18);
25732
25773
  }
25733
25774
  const l = {
25734
25775
  data: s,
@@ -25762,7 +25803,7 @@
25762
25803
  }
25763
25804
  }
25764
25805
 
25765
- function Gh(e, t, n, r, i, o, s, a, l = 0) {
25806
+ function zh(e, t, n, r, i, o, s, a, l = 0) {
25766
25807
  e.font = "20px monospace", e.fillStyle = n, Bh.y = a - 30, e.globalAlpha = 1, e.fillText(t, Bh.x + i, Bh.y + o + l),
25767
25808
  e.globalAlpha = .6, e.strokeStyle = n, e.lineWidth = r, e.beginPath(), e.moveTo(i, o),
25768
25809
  e.lineTo(i + s, o), e.lineTo(i + s, o + a), e.lineTo(i, o + a), e.lineTo(i, o),
@@ -25771,9 +25812,9 @@
25771
25812
 
25772
25813
  e__namespace.TileLayer.registerRenderer("gl", Uh), e__namespace.TileLayer.registerRenderer("gpu", Uh);
25773
25814
 
25774
- const {LayerAbstractRenderer: zh, ImageLayerRenderable: Vh} = e__namespace.renderer, jh = new Int16Array([ 0, 0, 0, -1, 1, 0, 1, -1 ]), Wh = new Uint16Array([ 0, 0, 0, 1, 1, 0, 1, 1 ]);
25815
+ const {LayerAbstractRenderer: Gh, ImageLayerRenderable: Vh} = e__namespace.renderer, jh = new Int16Array([ 0, 0, 0, -1, 1, 0, 1, -1 ]), Wh = new Uint16Array([ 0, 0, 0, 1, 1, 0, 1, 1 ]);
25775
25816
 
25776
- class qh extends(kh(Wc(Vh(zh)))){
25817
+ class qh extends(kh(Wc(Vh(Gh)))){
25777
25818
  constructor() {
25778
25819
  super(...arguments), this._imageMeshes = [];
25779
25820
  }
@@ -25825,7 +25866,7 @@
25825
25866
  primitive: "triangle strip"
25826
25867
  });
25827
25868
  const {regl: e, device: t} = this.context;
25828
- this._imageGeometry.generateBuffers(e || t), this._imageMeshes = [], this._imageScene = new Er(this._imageMeshes),
25869
+ this._imageGeometry.generateBuffers(e || t), this._imageMeshes = [], this._imageScene = new Ir(this._imageMeshes),
25829
25870
  this._renderer = new Sr(e || t);
25830
25871
  }
25831
25872
  _getCommandProps() {
@@ -25921,7 +25962,7 @@
25921
25962
  }
25922
25963
  _createGround() {
25923
25964
  const e = new $r;
25924
- e.generateBuffers(this.renderer.device), this._ground = new xr(e), this._groundScene = new Er([ this._ground ]);
25965
+ e.generateBuffers(this.renderer.device), this._ground = new xr(e), this._groundScene = new Ir([ this._ground ]);
25925
25966
  }
25926
25967
  _transformGround() {
25927
25968
  const e = this._layer.getMap(), t = rc.getGroundTransform(this._ground.localTransform, e);
@@ -26556,12 +26597,12 @@
26556
26597
 
26557
26598
  const e = "${"; const code = `function(t){
26558
26599
  /*!
26559
- * @maptalks/gltf-loader v0.120.0
26600
+ * @maptalks/gltf-loader v0.122.0
26560
26601
  * LICENSE : UNLICENSED
26561
26602
  * (c) 2016-2026 maptalks.org
26562
26603
  */
26563
- 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"),
26564
- /** @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};
26604
+ 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 h(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}!function(t){t[0]=0,t[1]=0,t[2]=0,t[3]=1}([]),"undefined"!=typeof TextDecoder&&new TextDecoder("utf-8");const c={get:function(t,e={},r){e||(e={}),e=h({},e);const n=new AbortController,i=n.signal,s=h({},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",c.get(t,e,r)),getJSON:function(t,e={},r){return e&&e.jsonp?c.jsonp(t):((e=e||{}).responseType="json",c.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"),
26605
+ /** @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 f="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 l,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};function g(t,e,r){return t[0]=e,t[1]=r,t}l=new f(3),f!=Float32Array&&(l[0]=0,l[1]=0,l[2]=0),function(){var t=function(){var t=new f(2);return f!=Float32Array&&(t[0]=0,t[1]=0),t}()}();class d{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 p(t,this)}}class p{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 y={};let m;const b={width:100,height:10};let 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(!m){const{width:t,height:e}=b;w?m=new OffscreenCanvas(t,e):(m=document.createElement("canvas"),m.width=t,m.height=e)}return m}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({},b,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]]}}var k="undefined"!=typeof Float32Array?Float32Array:Array;function E(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function x(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function T(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){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}var M=function(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t};
26565
26606
  /*!
26566
26607
  * Contains code from THREE.JS
26567
26608
  * https://github.com/mrdoob/three.js/
@@ -26569,7 +26610,7 @@ var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t
26569
26610
  *
26570
26611
  * Generate tangents per vertex.
26571
26612
  */
26572
- 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,a){"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)a(t?{empty:!0,originalError:t}:{error:{canceled:!0}});else{const e=t.data;let o=null;if("tianditu"===r){const t=Y(e,n);ot(i,t,n,null,s,a)}else if("cesium-ion"===r||"cesium"===r){o=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}}(o,n);ot(i,t,n,null,s,a)}else"mapbox"===r&&(o=function(t){const e=new self.Blob([new Uint8Array(t)]);return self.createImageBitmap(e)}(e),o.then((t=>{const e=ct(ht(t),n);ot(i,e,n,t,s,a)})))}})).catch((e=>{delete R[t],a({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,n){let i,s=p[r];s||(s=p[r]=new g(r)),i=s.createTile(e).getMeshWithSkirts(t,!0);const{triangles:a,vertices:o,leftSkirtIndex:h,rightSkirtIndex:c,bottomSkirtIndex:f,topSkirtIndex:l}=i;let{numVerticesWithoutSkirts:u,numTrianglesWithoutSkirts:d}=i;u||(u=o.length/2,d=a.length/3);const y=o.length/2,m=new Float32Array(3*y),b=new Float32Array(2*y);let w=1/0,A=-1/0;const v=r-1;for(let t=0;t<y;t++){const n=o[2*t],i=o[2*t+1];if(t>=u){const e=n/2*3;let r,i=.001;(t-(t<h/2?u:t<c/2?h/2:t<f/2?c/2:f/2))%3==0?(r=Math.min(0,w),i=0):r=m[e+2],m[3*t]=m[e],m[3*t+1]=m[e+1],m[3*t+2]=r,b[2*t]=m[e]/v+i,b[2*t+1]=-m[e+1]/v+i}else{const s=e[i*r+n];m[3*t]=1*n,m[3*t+1]=1*-i,m[3*t+2]=s,b[2*t]=n/v,b[2*t+1]=i/v,s<w&&(w=s),s>A&&(A=s)}}return{positions:m,texcoords:b,triangles:a,leftSkirtIndex:h,rightSkirtIndex:c,bottomSkirtIndex:f,topSkirtIndex:l,numTrianglesWithoutSkirts:d,numVerticesWithoutSkirts:u,minHeight:Math.min(0,w),maxHeight:A,terrainWidth:r}}(t,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*=2,i*=2;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,c=!0;if(h&&h.close){const t=ct(ht(h),a);return void ot(o,t,a,h,0,e)}const f=t.headers||j[i];if("tianditu"===i)st(r,f,i,a,o,c,e);else if("cesium-ion"===i){const h=t.cesiumIonTokenURL+s;L?st(r,f,i,a,o,c,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,f,i,a,o,c,e)})))}else("cesium"===i||"mapbox"===i)&&st(r,f,i,a,o,c,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}}`;
26613
+ function I(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){S(c,t,3*e),S(f,t,3*n),S(l,t,3*i),D(u,r,2*e),D(g,r,2*n),D(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],E=g[1]-u[1],U=d[1]-u[1],M=1/(v*U-k*E);x(p,(U*s-E*a)*M,(U*m-E*b)*M,(U*w-E*A)*M),x(y,(v*a-k*s)*M,(v*b-k*m)*M,(v*A-k*w)*M),T(o[e],o[e],p),T(o[n],o[n],p),T(o[i],o[i],p),T(h[e],h[e],y),T(h[n],h[n],y),T(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 k,I,F;function B(t){S(A,e,3*t),E(v,A),I=o[t],E(b,I),M(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,U(A,I))),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,I),F=U(w,h[t]),k=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]=k}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 S(t,e,r){return t[0]=e[r],t[1]=e[r+1],t[2]=e[r+2],t}function D(t,e,r){return t[0]=e[r],t[1]=e[r+1],t}function F(t){return"number"==typeof t&&!isNaN(t)}let B;!function(){var t=function(){var t=new k(3);return k!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();let z=null,N=null;const _=[0,0,0],C=[256,256];function O(){try{z||(z=new OffscreenCanvas(1,1))}catch(t){console.error(t)}}const R={},P={},j={width:64,height:64,elementsPerHeight:3,heightOffset:-1e3,exaggeration:1,heightScale:.001,elementMultiplier:256,stride:4,skirtHeight:.002,skirtOffset:.01},q={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,*/*"}};q["cesium-ion"]=q.cesium;const L=32767;let H=null,Y=null;function W(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),V.decode(n)));var n;const i=function(t){const e=t,r=j.width,n=j.height,i=new Uint8Array(r*n*j.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)/j.heightScale,u=j.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=j.elementsPerHeight,o=j.heightOffset,h=j.heightScale,c=j.elementMultiplier,f=j.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 V=new TextDecoder("utf-8");function Z(t){return t>>1^-(1&t)}const G=[];function $(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+=Z(t[o]),s+=Z(e[o]),t[o]=i,e[o]=s,r&&(a+=Z(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=G;for(let t=0;t<y;++t){const e=m[t],r=b[t],n=e/L,i=r/L,s=(v=a,k=o,(1-(E=w[t]/L))*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=[],tt=[];class et{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=u(J,this.p1,this.p0),c=u(K,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;g(X,this.p0[0],this.p0[1]),g(Q,this.p1[0],this.p1[1]),g(tt,this.p2[0],this.p2[1]);const r=st(X[0],X[1],Q[0],Q[1],tt[0],tt[1]);return st(t,e,X[0],X[1],tt[0],tt[1])+st(t,e,X[0],X[1],Q[0],Q[1])+st(t,e,Q[0],Q[1],tt[0],tt[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 rt=null;function nt(t,e,r){if(rt&&rt.contains(e,r))return rt.getHeight(e,r);for(let n=0;n<t.length;n++)if(t[n].contains(e,r))return rt=t[n],t[n].getHeight(e,r);return 0}const it=[];function st(t,e,r,n,i,s){return.5*Math.abs(t*n+r*s+i*e-t*s-r*e-i*n)}function at(t,e,r,n,i,s,a){"cesium-ion"===r&&(e.Authorization="Bearer "+H),function(t,e,r){const n={method:"GET",referrer:r,headers:e},i=c.getArrayBuffer(t,n),s=i.xhr;return P[t]=s,i.then((e=>(delete P[t],e)))}(t,e,origin).then((t=>{if(!t||t.message)a(t?{empty:!0,originalError:t}:{error:{canceled:!0}});else{const e=t.data;let o=null;if("tianditu"===r){const t=W(e,n);ht(i,t,n,null,s,a)}else if("cesium-ion"===r||"cesium"===r){o=$(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=it[h];e?e.set(r,s[t],s[t+1],s[t+2],2*a):e=it[h]=new et(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++]=nt(o,r/e*a*2,t/e*a*2);return{data:c,min:n,max:i,width:e,height:e}}(o,n);ht(i,t,n,null,s,a)}else"mapbox"===r&&(o=function(t){const e=new self.Blob([new Uint8Array(t)]);return self.createImageBitmap(e)}(e),o.then((t=>{const e=ft(ct(t),n);ht(i,e,n,t,s,a)})))}})).catch((e=>{delete P[t],a({empty:!0,originalError:e})}))}function ot(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 ht(t,e,r,n,i,s){const a=function(t,e,r,n){let i,s=y[r];s||(s=y[r]=new d(r)),i=s.createTile(e).getMeshWithSkirts(t,!0);const{triangles:a,vertices:o,leftSkirtIndex:h,rightSkirtIndex:c,bottomSkirtIndex:f,topSkirtIndex:l}=i;let{numVerticesWithoutSkirts:u,numTrianglesWithoutSkirts:g}=i;u||(u=o.length/2,g=a.length/3);const p=o.length/2,m=new Float32Array(3*p),b=new Float32Array(2*p);let w=1/0,A=-1/0;const v=r-1;for(let t=0;t<p;t++){const n=o[2*t],i=o[2*t+1];if(t>=u){const e=n/2*3;let r,i=.001;(t-(t<h/2?u:t<c/2?h/2:t<f/2?c/2:f/2))%3==0?(r=Math.min(0,w),i=0):r=m[e+2],m[3*t]=m[e],m[3*t+1]=m[e+1],m[3*t+2]=r,b[2*t]=m[e]/v+i,b[2*t+1]=-m[e+1]/v+i}else{const s=e[i*r+n];m[3*t]=1*n,m[3*t+1]=1*-i,m[3*t+2]=s,b[2*t]=n/v,b[2*t+1]=i/v,s<w&&(w=s),s>A&&(A=s)}}return{positions:m,texcoords:b,triangles:a,leftSkirtIndex:h,rightSkirtIndex:c,bottomSkirtIndex:f,topSkirtIndex:l,numTrianglesWithoutSkirts:g,numVerticesWithoutSkirts:u,minHeight:Math.min(0,w),maxHeight:A,terrainWidth:r}}(t,e.data,r),o=[a.positions.buffer,a.texcoords.buffer,a.triangles.buffer];n||(n=function(t){if(O(),!z)return;const{width:e,height:r,data:n}=t;if(e&&r&&n)try{let t=z.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]=ot(e,_),o=4*t;i.data[o]=r,i.data[o+1]=s,i.data[o+2]=a,i.data[o+3]=255}return z.width=e,z.height=r,t=z.getContext("2d",{willReadFrequently:!0}),lt(t),t.putImageData(i,0,0),z.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 ct(t){const{width:e,height:r}=t;return z||(z=new OffscreenCanvas(1,1),N=z.getContext("2d",{willReadFrequently:!0})),z.width=e,z.height=r,N.drawImage(t,0,0,e,r),N.getImageData(0,0,e,r)}function ft(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 lt(t){const e=t.canvas,{width:r,height:n}=e;t.clearRect(0,0,r,n)}function ut(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||C)[0]===n&&r[1]===i||(n=r[0],i=r[1]),n*=2,i*=2;try{if(O(),!z)return;const r=z;r.width=n,r.height=i;const s=r.getContext("2d",{willReadFrequently:!0});lt(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);R[r]||(R[r]=new v(e));const n=R[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,c=!0;if(h&&h.close){const t=ft(ct(h),a);return void ht(o,t,a,h,0,e)}const f=t.headers||q[i];if("tianditu"===i)at(r,f,i,a,o,c,e);else if("cesium-ion"===i){const h=t.cesiumIonTokenURL+s;H?at(r,f,i,a,o,c,e):(Y||(Y=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=>{H=t.accessToken,Y=null}))),Y.then((()=>{at(r,f,i,a,o,c,e)})))}else("cesium"===i||"mapbox"===i)&&at(r,f,i,a,o,c,e)}(r.params,((r,i)=>{i=i||[];const s=ut(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(!(F(i)&&F(s)&&F(a)&&F(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=I(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,P[n]&&(P[n].abort(),delete P[n]));var n}}`;
26573
26614
 
26574
26615
  // transcoders必须要在reshader.gl之前import,否则reshader.gl无法识别到GLTFLoader
26575
26616
  registerGLTFLoaderBundle(gltfLoaderExport);
@@ -26610,13 +26651,13 @@ function M(t,e,r,n,i){const s=t.length/3,a=new Array(4*s),o=[],h=[];for(let t=0;
26610
26651
  exports.mat4 = c;
26611
26652
  exports.quat = m;
26612
26653
  exports.quat2 = v;
26613
- exports.reshader = Ia;
26654
+ exports.reshader = Ea;
26614
26655
  exports.transcoders = transcoders;
26615
26656
  exports.vec2 = d;
26616
26657
  exports.vec3 = u$1;
26617
26658
  exports.vec4 = f;
26618
26659
 
26619
- typeof console !== 'undefined' && console.log('@maptalks/gpu v0.120.0');
26660
+ typeof console !== 'undefined' && console.log('@maptalks/gpu v0.122.0');
26620
26661
 
26621
26662
  }));
26622
26663
  //# sourceMappingURL=maptalksgpu.js.map