@maptalks/gpu 0.115.0 → 0.116.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,6 +1,6 @@
1
1
  /// <reference types="@webgpu/types" />
2
2
  /*!
3
- * @maptalks/gpu v0.115.0
3
+ * @maptalks/gpu v0.116.0
4
4
  * LICENSE : UNLICENSED
5
5
  * (c) 2016-2025 maptalks.com
6
6
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @maptalks/gpu v0.115.0
2
+ * @maptalks/gpu v0.116.0
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2025 maptalks.com
5
5
  */
@@ -67,7 +67,7 @@ transcoders.getTranscoder = getTranscoder;
67
67
 
68
68
  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;
69
69
  /*!
70
- * @maptalks/gltf-loader v0.115.0
70
+ * @maptalks/gltf-loader v0.116.0
71
71
  * LICENSE : UNLICENSED
72
72
  * (c) 2016-2025 maptalks.org
73
73
  */var s="undefined"!=typeof Float32Array?Float32Array:Array;function r(e,t,s){var r=t[0],n=t[1],i=t[2],a=t[3],o=t[4],f=t[5],u=t[6],h=t[7],c=t[8],l=t[9],d=t[10],m=t[11],g=t[12],p=t[13],b=t[14],_=t[15],y=s[0],x=s[1],w=s[2],T=s[3];return e[0]=y*r+x*o+w*c+T*g,e[1]=y*n+x*f+w*l+T*p,e[2]=y*i+x*u+w*d+T*b,e[3]=y*a+x*h+w*m+T*_,y=s[4],x=s[5],w=s[6],T=s[7],e[4]=y*r+x*o+w*c+T*g,e[5]=y*n+x*f+w*l+T*p,e[6]=y*i+x*u+w*d+T*b,e[7]=y*a+x*h+w*m+T*_,y=s[8],x=s[9],w=s[10],T=s[11],e[8]=y*r+x*o+w*c+T*g,e[9]=y*n+x*f+w*l+T*p,e[10]=y*i+x*u+w*d+T*b,e[11]=y*a+x*h+w*m+T*_,y=s[12],x=s[13],w=s[14],T=s[15],e[12]=y*r+x*o+w*c+T*g,e[13]=y*n+x*f+w*l+T*p,e[14]=y*i+x*u+w*d+T*b,e[15]=y*a+x*h+w*m+T*_,e}function n(){var e=new s(3);return s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function i(e,t,r){var n=new s(3);return n[0]=e,n[1]=t,n[2]=r,n}function a(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function o(e,t,s,r){return e[0]=t,e[1]=s,e[2]=r,e}function f(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e}function u(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function h(e,t,s,r,n){return e[0]=t,e[1]=s,e[2]=r,e[3]=n,e}function c(e,t,s){var r=t[0],n=t[1],i=t[2],a=t[3];return e[0]=s[0]*r+s[4]*n+s[8]*i+s[12]*a,e[1]=s[1]*r+s[5]*n+s[9]*i+s[13]*a,e[2]=s[2]*r+s[6]*n+s[10]*i+s[14]*a,e[3]=s[3]*r+s[7]*n+s[11]*i+s[15]*a,e}function l(){var e=new s(4);return s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),n(),function(){var e;e=new s(4),s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0);}();var d,m=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e};n(),i(1,0,0),i(0,1,0),l(),l(),d=new s(9),s!=Float32Array&&(d[1]=0,d[2]=0,d[3]=0,d[5]=0,d[6]=0,d[7]=0),d[0]=1,d[4]=1,d[8]=1;let g=0;function p(e){return null==e}function b(e){return !p(e)}function _(e){return !p(e)&&("string"==typeof e||null!==e.constructor&&e.constructor===String)}function y(e){for(let t=1;t<arguments.length;t++){const s=arguments[t];for(const t in s)e[t]=s[t];}return e}function x(e){switch(e){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+e)}function w(e){return 0===e.indexOf("data:")&&e.indexOf("base64,")>0}function T(e){const t=function(e){return "undefined"!=typeof self?self.atob(e):window.atob(e)}(e.substring(e.indexOf(",")+1)),s=t.length,r=new Uint8Array(s);for(let e=0;e<s;e++)r[e]=t.charCodeAt(e);return r.buffer}const E=[],O=[],I=[],R=[0,0,0],A=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}([]),q=[1,1,1];function B(e,t,s,r,n,i,a){const o=x(a),f=o.BYTES_PER_ELEMENT;if((0===n||n===r*f)&&i%f==0){const n=new o(t,i,s*r);return e.set(n),e}0===n&&(n=r*f);const u=new Uint8Array(r*f);for(let a=0;a<s;a++){let s=null;const h=new Uint8Array(t,n*a+i,r*f);u.set(h),s=new o(u.buffer,0,r);for(let t=0;t<r;t++)e[a*r+t]=s[t];}return e}const N="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function v(e,t,s){const r=new Uint8Array(e,t,s);return N.decode(r)}const P={get:function(e,t={},s){t||(t={});const r=new AbortController,n=r.signal,i=y({},t);i.signal=n,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),s&&(e=s(e));const a=fetch(e,i).then((e=>{const s=this._parseResponse(e,t.responseType);return s.message?s:s.then((s=>"arraybuffer"===t.responseType?{data:s,cacheControl:e.headers.get("Cache-Control"),expires:e.headers.get("Expires"),contentType:e.headers.get("Content-Type")}:s)).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}))})).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}));return a.xhr=r,a},_parseResponse:(e,t)=>200!==e.status?{status:e.status,statusText:e.statusText,message:`incorrect http request with status code(${e.status}): ${e.statusText}`}:"arraybuffer"===t?e.arrayBuffer():"json"===t?e.json():e.text(),getArrayBuffer:(e,t={},s)=>(t||(t={}),t.responseType="arraybuffer",P.get(e,t,s)),getJSON:function(e,t={},s){return t&&t.jsonp?P.jsonp(e):((t=t||{}).responseType="json",P.get(e,t,s))},jsonp:function(e){const t="_maptalks_jsonp_"+g++;e.match(/\?/)?e+="&callback="+t:e+="?callback="+t;let s=document.createElement("script");return s.type="text/javascript",s.src=e,new Promise((e=>{window[t]=function(r){document.getElementsByTagName("head")[0].removeChild(s),s=null,delete window[t],e(r);},document.getElementsByTagName("head")[0].appendChild(s);}))}};class M{constructor(e,t,s,r,n){this._requestImage=e,this.decoders=t,this._supportedFormats=s,this.images={},this._imgRequests={},this._fetchOptions=r||{},this._urlModifier=n;}requestImageFromBufferURI(e,t,s){if(this.buffers[e.id]){const r=this.buffers[e.id],n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}if(this._imgRequests[e.id])return this._imgRequests[e.id].then((()=>{const r=this.buffers[e.id],n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}));if(w(e.uri)){const r=this.buffers[e.id]=T(e.uri),n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}let r;const n=e.uri.indexOf("blob:")>=0;return r=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this._imgRequests[e.id]=P.getArrayBuffer(r,this._fetchOptions,this._urlModifier).then((r=>{const n=this.buffers[e.id]=r.data,i=this._createDataView(t,n);return this.getImageByBuffer(i,s)}))}getImageByBuffer(e,t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const s=this.decoders;if(s[t.mimeType])return s[t.mimeType](e,{supportedFormats:this._supportedFormats});if("image/crn"===t.mimeType||"image/ktx2"===t.mimeType||"image/cttf"===t.mimeType)throw new Error("missing transcoder for "+t.mimeType,"");return this._getImageInfo(t.id,e)}requestExternalImage(e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const t=0===e.uri.indexOf("data:image/")?e.uri:this.rootPath+"/"+e.uri;return this._imgRequests[e.id]?this._imgRequests[e.id].then((()=>this.images[e.id])):this._imgRequests[e.id]=this._getImageInfo(e.id,t)}_getImageInfo(e,t){return new Promise(((s,r)=>{let n=t;this._urlModifier&&(n=this._urlModifier(t)),this._requestImage(n,this._fetchOptions,((n,i)=>{n?r(n):(URL.revokeObjectURL(t),this.images[e]=i,s(this.images[e]));}));}))}}const S=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],V=[];class L{constructor(e,t,s,r,n){this.rootPath=e,this.gltf=t,this._enableInterleave=!1,this.glbBuffer=s,this.buffers={},this.requests={},this.accessors={},this._compareAccessor(),this._fetchOptions=r,this._urlModifier=n;}_requestData(e,t){const s=this.gltf,r=s.accessors[t];if(void 0===r.bufferView)return this.accessors[r.id]=this._toBufferData(e,t,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const n=s.bufferViews[r.bufferView];return this._requestBufferOfBufferView(n).then((s=>{const{buffer:n,byteOffset:i}=s;return this.accessors[r.id]=this._toBufferData(e,t,n,i)}))}_requestBufferOfBufferView(e){const t=this.gltf.buffers[e.buffer];if(this.buffers[t.id]){const e=this.buffers[t.id];return Promise.resolve({buffer:e,byteOffset:0})}if(this.requests[t.id])return this.requests[t.id].then((()=>{const e=this.buffers[t.id];return Promise.resolve({buffer:e,byteOffset:0})}));if("binary_glTF"!==e.buffer&&"KHR_binary_glTF"!==e.buffer&&t.uri){if(w(t.uri)){const e=this.buffers[t.id]=T(t.uri);return Promise.resolve({buffer:e,byteOffset:0})}let e;const s=t.uri.indexOf("blob:")>=0;return e=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.requests[t.id]=P.getArrayBuffer(e,this._fetchOptions,!s&&this._urlModifier).then((r=>(s&&URL.revokeObjectURL(e),{buffer:this.buffers[t.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_toBufferData(e,t,s,r=0){const n=this.gltf,i=n.accessors[t],a=void 0!==i.bufferView?n.bufferViews[i.bufferView]:{},o=(a.byteOffset||0)+r,f=this._getTypeItemSize(i.type),u=x(i.componentType),h=a.byteStride||0,l={array:void 0,name:e,accessorName:t,byteLength:i.count*f*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:f,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(l.min=i.min),i.max&&(l.max=i.max),s)if(this._enableInterleave)l.byteStride=h,l.byteOffset=o+(i.byteOffset||0),!h||h===f*u.BYTES_PER_ELEMENT||"indices"===e||"input"===e||"output"===e||e.indexOf("morph")>=0?(l.array=this._typedArray(s,i.count,f,o+(i.byteOffset||0),u),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(s,o,a.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const e=new u(i.count*f);if(l.array=B(e,s,i.count,f,h,o+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&f>2){const e=new Float32Array(l.array.length),{decodeMatrix:t}=l.extensions.WEB3D_quantized_attributes;for(let s=0;s<l.array.length;s+=f){V[0]=l.array[s],V[1]=l.array[s+1],V[2]=l.array[s+2],V[3]=1;const r=c(V,V,t);e[s]=r[0],e[s+1]=r[1],e[s+2]=r[2];}l.componentType=5126,l.array=e;}}else l.byteStride=0,l.array=this._typedArray(s,i.count,f,o+(i.byteOffset||0),u),l.byteOffset=l.array.byteOffset;else {l.array=new u(i.count);const e=l.min||l.max;e&&(l.array[0]=e[0],l.array[1]=e[1],l.array[2]=e[2]);}return l}_compareAccessor(){const e=this.gltf.accessors;if(Array.isArray(e))for(let t=0;t<e.length;t++)for(let s=0;s<e.length;s++)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);else for(const t in e)for(const s in e)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);}_typedArray(e,t,s,r,n){return r%n.BYTES_PER_ELEMENT!=0&&(e=e.slice(r,r+t*s*n.BYTES_PER_ELEMENT),r=0),new n(e,r,s*t)}_getTypeItemSize(e){const t=S.indexOf(e);return S[t+1]}requestKHRTechniquesWebgl(e){const{shaders:t}=e,s=t.map((e=>{if(void 0!==e.bufferView){const t=this.gltf.bufferViews[e.bufferView],{byteLength:s}=t;return this._requestBufferOfBufferView(t).then((r=>{const{buffer:n,byteOffset:i}=r,a=v(n,i+(t.byteOffset||0),s);return e.content=a,e}))}if(e.uri){if(w(e.uri)){const t=T(e.uri),s=v(t,0,t.byteLength);return e.content=s,Promise.resolve(e)}{const t=this.rootPath+"/"+e.uri;return P.get(t,this._fetchOptions,this._urlModifier).then((t=>(e.content=t,e)))}}return Promise.resolve(e)}));return Promise.all(s).then((()=>e))}}class D extends M{constructor(e,t,s,r,n,i,a,o){super(r,n,i,a,o),this.rootPath=e,this.gltf=t,this.requests={},this.buffers={},this.glbBuffer=s,this.accessor=new L(e,t,s,a,o);}iterate(e,t){const s=this.gltf[t];if(!s)return;let r=0;for(const t in s)e(t,s[t],r++);}createNode(e){const t={};if(b(e.name)&&(t.name=e.name),b(e.children)&&(t.children=e.children),b(e.jointName)&&(t.jointName=e.jointName),b(e.matrix)&&(t.matrix=e.matrix),b(e.rotation)&&(t.rotation=e.rotation),b(e.scale)&&(t.scale=e.scale),b(e.translation)&&(t.translation=e.translation),b(e.extras)&&(t.extras=e.extras),b(e.meshes)&&(t.mesh=e.meshes[0]),t.translation||t.rotation||t.scale){const e=function(e,t){if(t.matrix)return t.matrix;if(t.translation||t.scale||t.rotation){const s=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}(E,t.translation||R),n=function(e,t){var s=t[0],r=t[1],n=t[2],i=t[3],a=s+s,o=r+r,f=n+n,u=s*a,h=r*a,c=r*o,l=n*a,d=n*o,m=n*f,g=i*a,p=i*o,b=i*f;return e[0]=1-c-m,e[1]=h+b,e[2]=l-p,e[3]=0,e[4]=h-b,e[5]=1-u-m,e[6]=d+g,e[7]=0,e[8]=l+p,e[9]=d-g,e[10]=1-u-c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(O,t.rotation||A),i=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(I,t.scale||q);return r(i,n,i),r(e,s,i)}return function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(e)}([],t);delete t.translation,delete t.rotation,delete t.scale,t.matrix=e;}return t}_loadMaterials(e){const t={};for(const s in e){const r=e[s];let n,i;r.instanceTechnique&&r.instanceTechnique.values?(n=r.instanceTechnique,i=n.values.diffuse):(n=r,i=n.values.tex||n.values.diffuseTex||n.values.diffuse);const a={baseColorTexture:{index:i}};r.name&&(a.name=r.name),r.extensions&&(a.extensions=r.extensions),r.extras&&(a.extras=r.extras),t[s]=a;}return t}_loadImage(e){if(e.bufferView||e.extensions&&(e.extensions.KHR_binary_glTF||e.extensions.binary_glTF)){const t=e.bufferView?e:e.extensions.KHR_binary_glTF||e.extensions.binary_glTF;e.extensions&&(e.mimeType=t.mimeType,e.width=t.width,e.height=t.height);const s=this.gltf.bufferViews[t.bufferView],r=(s.byteOffset||0)+this.glbBuffer.byteOffset,n=s.byteLength,i=this.buffers[t.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,n);return this.getImageByBuffer(i,e)}return this.requestExternalImage(e)}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;const s=this.gltf.images[t.source];return this._loadImage(s).then((e=>{const r=this.gltf.samplers[t.sampler];return {image:{array:e.data,width:e.width,height:e.height,index:t.source,mimeType:s.mimeType,name:s.name,extras:s.extras},sampler:r}}))}getBaseColorTexture(e){const t=this.gltf.materials[e];let s,r;if(t.instanceTechnique&&t.instanceTechnique.values?(s=t.instanceTechnique,r=s.values.diffuse):(s=t,r=s.values.tex||s.values.diffuseTex||s.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const n=this.gltf.textures[r];if(!n)return null;const i=this.gltf.samplers[n.sampler];return {format:n.format||6408,internalFormat:n.internalFormat||6408,type:n.type||5121,sampler:i,source:this.gltf.images[n.source]}}getMaterial(){return null}getAnimations(){return null}}const U=9729;class C extends M{constructor(e,t,s,r,n,i,a,o){super(r,n,i,a,o),this.rootPath=e,this.gltf=t,this.glbBuffer=s,this.buffers={},this.requests={},this.accessor=new L(e,t,s,a,o);}iterate(e,t){const s=this.gltf[t];if(s)for(let t=0;t<s.length;t++)e(t,s[t],t);}createNode(e){const t={};return y(t,e),!b(e.weights)&&this.gltf.meshes&&b(t.mesh)?t.weights=this.gltf.meshes[t.mesh].weights:e.weights&&(t.weights=e.weights),t}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;let s=t.source;if(t.extensions&&t.extensions.EXT_texture_webp?s=t.extensions.EXT_texture_webp.source:t.extensions&&t.extensions.KHR_texture_basisu&&(s=t.extensions.KHR_texture_basisu.source),!b(s))return null;const r=this.gltf.images[s];return this._loadImage(r).then((e=>{if(!e)return null;const s={image:{array:e.data,mipmap:e.mipmap,width:e.width,height:e.height,index:t.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};y(s,t);const n=b(t.sampler)?this.gltf.samplers[t.sampler]:void 0;if(n&&(s.sampler=n,s.sampler.magFilter=n.magFilter||U,s.sampler.minFilter=n.minFilter||9987,s.sampler.wrapS=n.wrapS||10497,s.sampler.wrapT=n.wrapT||10497),"image/ktx2"===s.image.mimeType&&!s.image.mipmap&&s.sampler&&s.sampler.minFilter!==U&&9728!==s.sampler.minFilter){const e=s.sampler.minFilter;s.sampler.minFilter=9984===e||9986===e?9728:U;}return e.format&&(s.format=e.format),s}))}_loadImage(e){if(!b(e.bufferView))return this.requestExternalImage(e);{const t=this.gltf.bufferViews[e.bufferView],s=this.gltf.buffers[t.buffer];if(s.uri)return this.requestImageFromBufferURI(s,t,e);if(this.glbBuffer)return this._requestFromGlbBuffer(t,e)}return null}_requestFromGlbBuffer(e,t){const s=this._createDataView(e,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(s,t)}_createDataView(e,t,s){s=s||0;const r=(e.byteOffset||0)+s,n=e.byteLength;return new Uint8Array(t,r,n)}_transformArrayBufferToBase64(e,t){const s=new Array(e.byteLength);for(let t=0;t<e.byteLength;t++)s[t]=String.fromCharCode(e[t]);s.join("");const r="data:"+(t=t||"image/png")+";base64,"+function(e){return "undefined"!=typeof self?self.btoa(e):window.btoa(e)}(unescape(encodeURIComponent(s)));return r}getAnimations(e){const t=[];return e.forEach((e=>{t.push(this.getSamplers(e.samplers));})),Promise.all(t).then((t=>{for(let s=0;s<t.length;s++)e[s].samplers=t[s];return e}))}getSamplers(e){const t=[];for(let s=0;s<e.length;s++)(b(e[s].input)||b(e[s].output))&&(t.push(this.accessor._requestData("input",e[s].input)),t.push(this.accessor._requestData("output",e[s].output)));return Promise.all(t).then((t=>{for(let s=0;s<t.length/2;s++)e[s].input=t[2*s],e[s].output=t[2*s+1],e[s].interpolation||(e[s].interpolation="LINEAR");return e}))}}const F="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class k{static read(e,t=0,s=0){s||(s=e.byteLength);const r=new DataView(e,t,s),n=r.getUint32(4,!0);if(1===n)return k.readV1(r,t);if(2===n)return k.readV2(e,t);throw new Error("Unsupported glb version : "+n)}static readV1(e,t){const s=e.getUint32(8,!0),r=e.getUint32(12,!0);if(s!==e.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const n=X(e.buffer,20+t,r);return {json:JSON.parse(n),glbBuffer:{byteOffset:20+t+r,buffer:e.buffer,byteLength:s}}}static readV2(e,t){let s,r,n;const i=new DataView(e,t+12);let a=0;for(;a+8<i.byteLength;){const o=i.getUint32(a,!0);a+=4;const f=i.getUint32(a,!0);if(a+=4,1313821514===f)s=X(e,t+12+a,o);else if(5130562===f){n=t+12+a,r=o;break}a+=o;}return {json:JSON.parse(s),glbBuffer:{byteOffset:n,buffer:e,byteLength:r}}}}function X(e,t,s){if(F){const r=new Uint8Array(e,t,s);return F.decode(r)}return function(e){const t=e.length;let s="";for(let r=0;r<t;){let n=e[r++];if(128&n){let s=K[n>>3&7];if(!(64&n)||!s||r+s>t)return null;for(n&=63>>s;s>0;s-=1){const t=e[r++];if(128!=(192&t))return null;n=n<<6|63&t;}}s+=String.fromCharCode(n);}return s}(new Uint8Array(e,t,s))}const K=[1,1,1,1,2,2,3,0],H=[0,0,0],j=[0,0,0,1],z=[1,1,1],W={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},G={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Y={_getTRSW(e,t,s,r,n,i,o,f){const u=b(e)?t.animations:[t.animations[0]],h={};for(let t=0;t<u.length;t++){const c=u[t],l=c.name||t;if(b(e)&&l!==e)continue;const d=c.channelsMap[s];if(d)for(let e=0;e<d.length;e++){const t=d[e];"translation"===t.target.path?(this._getAnimateData(n,c.samplers[t.sampler],r,1),h.translation=a(H,n)):"rotation"===t.target.path?(this._getQuaternion(i,c.samplers[t.sampler],r,1),h.rotation=m(j,i)):"scale"===t.target.path?(this._getAnimateData(o,c.samplers[t.sampler],r,1),h.scale=a(z,o)):"weights"===t.target.path&&f&&(this._getAnimateData(f,c.samplers[t.sampler],r,f.length),h.weights=f);}}return h},_getAnimateData(e,t,s,r){switch(t.interpolation){case"LINEAR":{const n=this._getPreNext(G,t,s,1*r);n&&(e=function(e,t,s,r){for(let n=0;n<e.length;n++)e[n]=t[n]+r*(s[n]-t[n]);return e}(e,n.PREVIOUS,n.NEXT,n.INTERPOLATION));break}case"STEP":{const n=this._getPreNext(G,t,s,1*r);n&&(e=function(e,t){for(let s=0;s<e.length;s++)e[s]=t[s];return e}(e,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this._getPreNext(G,t,s,3*r);n&&(e=this._getCubicSpline(e,n,t.input.array,3*r));break}}return e},_getQuaternion(e,t,s){switch(t.interpolation){case"LINEAR":{const r=this._getPreNext(G,t,s,1);r&&function(e,t,s,r){var n,i,a,o,f,u=t[0],h=t[1],c=t[2],l=t[3],d=s[0],m=s[1],g=s[2],p=s[3];(i=u*d+h*m+c*g+l*p)<0&&(i=-i,d=-d,m=-m,g=-g,p=-p),1-i>1e-6?(n=Math.acos(i),a=Math.sin(n),o=Math.sin((1-r)*n)/a,f=Math.sin(r*n)/a):(o=1-r,f=r),e[0]=o*u+f*d,e[1]=o*h+f*m,e[2]=o*c+f*g,e[3]=o*l+f*p;}(e,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this._getPreNext(G,t,s,1);r&&(e=h(e,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this._getPreNext(G,t,s,3);if(r){for(let e=0;e<r.PREVIOUS.length;e++)r.PREVIOUS[e]=Math.acos(r.PREVIOUS[e]),r.NEXT[e]=Math.acos(r.NEXT[e]);e=this._getCubicSpline(e,r,t.input.array,3);for(let t=0;t<e.length;t++)e[t]=Math.cos(e[t]);}break}}return e},_search(e,t){const s=e.length;let r,n,i,a=0,o=s-1,f=Math.floor((a+o)/2);for(;a<=s-1&&o>=0;){if(a===o)return null;if(e[f]<=t&&t<=e[f+1]){const s=e[f];return r=f,n=f+1,i=(t-s)/(e[f+1]-s),{preIndx:r,nextIndex:n,interpolation:i}}t<e[f]?(o=f,f=Math.floor((a+o)/2)):e[f+1]<t&&(a=f,f=Math.floor((a+o)/2));}return null},_getPreNext(e,t,s,r){const n=t.input.array,i=t.output.array,a=t.output.itemSize;(s<n[0]||s>n[n.length-1])&&(s=Math.max(n[0],Math.min(n[n.length-1],s))),s===n[n.length-1]&&(s=n[0]);const o=this._search(n,s);if(!o||!o.nextIndex)return null;const{preIndx:f,nextIndex:u,interpolation:h}=o;e.PREINDEX=f,e.NEXTINDEX=u,e.INTERPOLATION=h;const c=a*r;return e.PREVIOUS=i.subarray(e.PREINDEX*c,(e.PREINDEX+1)*c),e.NEXT=i.subarray(e.NEXTINDEX*c,(e.NEXTINDEX+1)*c),e},_getCubicSpline(e,t,s,r){const n=t.INTERPOLATION,i=s[t.PREINDEX],a=s[t.NEXTINDEX];for(let s=0;s<3;s++){const o=t.PREVIOUS[r+s],f=(a-i)*t.PREVIOUS[2*r+s],u=t.NEXT[3+s],h=(a-i)*t.NEXT[s],c=(2*Math.pow(n,3)-3*Math.pow(n,2)+1)*o+(Math.pow(n,3)-2*Math.pow(n,2)+n)*f+(2*-Math.pow(n,3)+3*Math.pow(n,2))*u+(Math.pow(n,3)-Math.pow(n,2))*h;e[s]=c;}return e},getAnimationClip(e,t,s,r){const n=e.nodes[t]&&e.nodes[t].weights;return o(H,...W.TRANSLATION),h(j,...W.ROTATION),o(z,...W.SCALE),this._getTRSW(r,e,t,s,H,j,z,n)},getTimeSpan(e){if(!e.animations)return null;if(e.timeSpan)return e.timeSpan;const t=e.animations;return e.timeSpan={},t.forEach(((t,s)=>{let r=-1/0,n=1/0;const i=t.channels;for(let e=0;e<i.length;e++){const s=i[e],a=t.samplers[s.sampler].input.array;a[a.length-1]>r&&(r=a[a.length-1]),a[0]<n&&(n=a[0]);}const a=t.name||s;e.timeSpan[a]={max:r,min:n};})),e.timeSpan},getTimeSpanByName(e,t){const s=this.getTimeSpan(e);return s?b(t)?s[t]:s[Object.keys(s)[0]]:null}};let $=!1;if("undefined"!=typeof OffscreenCanvas){let e;try{e=new OffscreenCanvas(2,2).getContext("2d");}catch(s){}e&&"undefined"!=typeof createImageBitmap&&($=!0);}const J="undefined"==typeof document?null:document.createElement("canvas");function Q(e,t,s){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!J)return void s(new Error("There is no canvas to draw image!"));J.width=r.width,J.height=r.height;const e=J.getContext("2d",{willReadFrequently:!0});e.drawImage(r,0,0,r.width,r.height);const t=e.getImageData(0,0,r.width,r.height),n={width:r.width,height:r.height,data:new Uint8Array(t.data)};s(null,n);},r.onerror=function(e){s(e);},r.src=e;}const Z=[],ee=[],te=30;let se,re;function ne(e,t,s){se||(se=new OffscreenCanvas(2,2),re=se.getContext("2d",{willReadFrequently:!0}));let r=null;if(_(e))this.options.urlModifier&&(e=this.options.urlModifier(e)),Z.push([e,t,s,this]),ie();else {const t=new Blob([e]);r=createImageBitmap(t),r.then(ae.bind(this)).then((e=>{s(null,e);})).catch((e=>{console.warn(e),s(e);}));}}function ie(){if(!Z.length||ee.length>te)return;const e=Z.shift(),[t,s,r,n]=e;ee.push(e),fetch(t,s).then((e=>e.arrayBuffer())).then((e=>{const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)})).then(ae.bind(n)).then((t=>{r.call(n,null,t);const s=ee.indexOf(e);ee.splice(s,1),ie();})).catch((t=>{console.warn(t),r.call(n,t);const s=ee.indexOf(e);ee.splice(s,1),ie();}));}function ae(e){let{width:t,height:s}=e;oe(t)||(t=fe(t)),oe(s)||(s=fe(s));const r=this.options.maxTextureSize;r&&(t=Math.min(r,t),s=Math.min(r,s)),se.width=t,se.height=s,re.drawImage(e,0,0,t,s),e.close();const n=re.getImageData(0,0,t,s);return {width:t,height:s,data:new Uint8Array(n.data)}}function oe(e){return !(e&e-1)&&0!==e}function fe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function ue(e,t){for(const s in e)if(e[s]===t)return s;return t}e.Ajax=P,e.GLTFLoader=class{constructor(e,t,s){if(this.options=s||{},this.options.decoders||(this.options.decoders={}),this._fetchOptions=this.options.fetchOptions||{},t.buffer instanceof ArrayBuffer){const{json:s,glbBuffer:r}=k.read(t.buffer,t.byteOffset,t.byteLength);this._init(e,s,r);}else this._init(e,t);this._accessor=new L(this.rootPath,this.gltf,this.glbBuffer,this._fetchOptions,this.options.urlModifier),this._checkExtensions();}_checkExtensions(){const e=this.gltf.extensionsRequired;if(e){if(e.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(e.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(e.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}_loadExtensions(){const e=this.gltf.extensions;return e&&e.KHR_techniques_webgl?this._accessor.requestKHRTechniquesWebgl(e.KHR_techniques_webgl).then((t=>(e.KHR_techniques_webgl=t,e))):Promise.resolve(e)}_convertKhrTechiqueToTechiques(){if(!Array.isArray(this.gltf.programs))return;const e=this.gltf.materials;for(let t=0;t<e.length;t++)e[t]&&e[t].extensions&&e[t].extensions.KHR_technique_webgl&&(e[t].extensions.KHR_techniques_webgl=e[t].extensions.KHR_technique_webgl,delete e[t].extensions.KHR_technique_webgl);const t=this.gltf.extensions||{},s=this.gltf.techniques;t.KHR_techniques_webgl={programs:this.gltf.programs,shaders:this.gltf.shaders,techniques:s};for(let t=0;t<e.length;t++){const n=(r=e[t])&&r.extensions&&r.extensions.KHR_techniques_webgl;if(n){const{values:e,technique:t}=n,r=s[t];if(!r||!e)continue;const{uniforms:i,parameters:a}=r,o={};for(const t in e){const s=ue(i,t);o[s]=e[t],a[t]&&35678===a[t].type&&(o[s]={index:e[t]});}n.values=o;}}var r;for(let e=0;e<s.length;e++){const t=s[e];if(!t)continue;const{attributes:r,uniforms:n,parameters:i}=t;if(r)for(const e in r){const t=r[e];r[e]=i[t];}if(n)for(const e in n){const t=n[e];n[e]=i[t];}delete t.parameters;}return delete this.gltf.programs,delete this.gltf.shaders,delete this.gltf.techniques,this.gltf.extensions=t,t}load(e){e=e||{},this._convertKhrTechiqueToTechiques();const t=this._loadScene(e),s=this._loadAnimations(),r=this._loadTextures(),n=this._loadExtensions();return Promise.all([t,s,r,n]).then((e=>(e[0].animations=e[1],e[0].textures=e[2],e[0].extensions=e[3],e[0].transferables=this.transferables||[],this.createChannelsMap(e[0]),e[0])))}createChannelsMap(e){const t=e.animations;if(t)for(let e=0;e<t.length;e++){const s=t[e];s.channelsMap={};for(let e=0;e<s.channels.length;e++){const t=s.channels[e];s.channelsMap[t.target.node]||(s.channelsMap[t.target.node]=[]),s.channelsMap[t.target.node].push(t);}}}getExternalResources(){const e=[];if(this.gltf){const{buffers:t,images:s}=this.gltf;for(let s=0;s<t.length;s++)t[s].uri&&t[s].uri.indexOf("data:application/octet-stream;base64")<0&&e.push({type:"buffer",uri:t[s].uri});for(let t=0;t<s.length;t++)s[t].uri&&s[t].uri.indexOf("data:image/")<0&&e.push({type:"image",uri:s[t].uri});}return e}static getAnimationClip(e,t,s,r){return Y.getAnimationClip(e,t,s,r)}static getAnimationTimeSpan(e,t){return Y.getTimeSpanByName(e,t)}static getTypedArrayCtor(e){return x(e)}static readInterleavedArray(e,t,s,r,n,i,a){return B(e,t,s,r,n,i,a)}_init(e,t,s){this.gltf=t,this.glbBuffer=s,this.version=t.asset?+t.asset.version:1,this.rootPath=e,this.buffers={},this.requests={},this.options.requestImage=$?ne.bind(this):this.options.requestImage||Q,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new C(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions,this.options.urlModifier),this.adapter.iterate(((e,t,s)=>{t.id="buffer_"+s;}),"buffers"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s;}),"images"),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s;}),"accessors")):(this.adapter=new D(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions,this.options.urlModifier),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s;}),"accessors"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s;}),"images"));}_parseNodes(e,t){if(e.children&&e.children.length>0){if(!("number"==typeof(s=e.children[0])&&isFinite(s)||_(e.children[0])))return e;const r=e.children.map((e=>{const s=t[e];return s.nodeIndex=e,this._parseNodes(s,t)}));e.children=r;}var s;return e}_loadScene(e){return this._loadNodes(e).then((e=>{const t=this.scenes=[];let s;for(const t in e)e[t]=this._parseNodes(e[t],e),e[t].nodeIndex=Number(t)?Number(t):t;this.adapter.iterate(((r,n,i)=>{const a={};n.name&&(a.name=n.name),n.nodes&&(a.nodes=n.nodes.map((t=>e[t]))),this.gltf.scene===r&&(s=i),t.push(a);}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:s,scenes:t,nodes:e,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const e=this.adapter._loadMaterials(this.gltf.materials);r.materials=e;}return delete this.gltf.buffers,r.json=this.gltf,r}))}_loadNodes(e){return this._loadMeshes(e).then((()=>{const e=this.nodes={};return this.adapter.iterate(((t,s)=>{const r=this.adapter.createNode(s,this.meshes,this.skins);e[t]=r;}),"nodes"),e}))}_loadSkins(){this.skins=[];const e=[];return this.adapter.iterate(((t,s,r)=>{e.push(this._loadSkin(s).then((e=>{e.index=r,this.skins.push(e);})));}),"skins"),e}_loadSkin(e){const t=e.inverseBindMatrices;return this.adapter.accessor._requestData("inverseBindMatrices",t).then((t=>(e.inverseBindMatrices=t,t&&t.buffer&&this.transferables&&this.transferables.indexOf(t.buffer)<0&&this.transferables.push(t.buffer),e)))}_loadAnimations(){const e=this.gltf.animations;return b(e)?this.adapter.getAnimations(e):null}_loadMeshes(e){this.meshes={};let t=[];return this.adapter.iterate(((s,r,n)=>{t.push(this._loadMesh(r,e).then((e=>{e.index=n,this.meshes[s]=e;})));}),"meshes"),t=t.concat(this._loadSkins()),Promise.all(t)}_loadMesh(e,t){const s=e.primitives.map((e=>this._loadPrimitive(e,t))).filter((e=>!!e));return Promise.all(s).then((t=>{const s={};return y(s,e),s.primitives=t,s}))}_loadTextures(){const e=this.gltf.textures;if(!e)return null;const t=[];for(const s in e)t.push(this.adapter._getTexture(s));return Promise.all(t).then((t=>{if(this.transferables)for(let e=0;e<t.length;e++){const s=t[e]&&t[e].image.array;if(s){let e;e=s instanceof ImageBitmap?s:s.buffer,e&&this.transferables.indexOf(e)<0&&this.transferables.push(e);}}if(!Array.isArray(e)){const s={},r=Object.keys(e);for(let e=0;e<t.length;e++)t[e]&&(s[r[e]]=t[e]);return s}return t}))}_loadPrimitive(e,t){let s;const r=[],n=e.extensions;if(b(e.targets))for(let t=0;t<e.targets.length;t++){const s=e.targets[t];for(const e in s){const n=this.adapter.accessor._requestData(`morphTargets_${e}_${t}`,s[e]);n&&r.push(n);}}if(n&&n.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const e=this.options.decoders.draco,{bufferView:i,attributes:a}=n.KHR_draco_mesh_compression,o=this.gltf.bufferViews[i],f=this._accessor._requestBufferOfBufferView(o).then((s=>{const{buffer:r,byteOffset:n}=s;let{byteOffset:i}=o;const f=o.byteLength;i||(i=0);const u=new DataView(r,n+i,f),h={attributes:a,useUniqueIDs:!1,skipAttributeTransform:t.skipAttributeTransform};return e(u,h).then((e=>{const t=Object.values(e.attributes);return e.indices&&t.push(e.indices),t}))}));r.push(f),s=Promise.all(r);}else {const t=e.attributes;for(const e in t){const s=this.adapter.accessor._requestData(e,t[e]);s&&r.push(s);}if(b(e.indices)){const t=this.adapter.accessor._requestData("indices",e.indices);t&&r.push(t);}s=Promise.all(r);}return s.then((t=>{if(n&&n.KHR_draco_mesh_compression){const s=e.targets?e.targets.length:0;t[s]=t[s].concat(t.slice(0,s)),t=t[s];}let s,r;const i={attributes:t.reduce(((e,t)=>{if("indices"===t.name)s=t;else if(t.name.indexOf("morphTargets_")>-1)r=r||{},r[t.name.slice(13)]=t;else {if(!("POSITION"!==t.name||t.min&&t.max)){const e=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0],{itemSize:r,array:n}=t,i=n.length/r;for(let t=0;t<i;t++)for(let i=0;i<r;i++){const a=t*r+i;n[a]<e[i]&&(e[i]=n[a]),n[a]>s[i]&&(s[i]=n[a]);}if(t.quantization){const r=t.quantization,n=r.range/(1<<r.quantizationBits),i=r.minValues;u(e,e,n),f(e,e,i),u(s,s,n),f(s,s,i);}t.min=e,t.max=s;}e[t.name]=t;}return this.transferables&&t.array.buffer&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),e}),{}),material:e.material};return s&&(i.indices=s),r&&(i.morphTargets=r),i.mode=b(e.mode)?e.mode:4,b(e.extras)&&(i.extras=e.extras),i}))}},t().maptalks_gltf_loader=e;}gltfLoaderExport({});
@@ -13420,9 +13420,9 @@ var phongFrag = "precision mediump float;\n#include <gl2_frag>\nuniform vec4 bas
13420
13420
 
13421
13421
  var phongVert = "#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}";
13422
13422
 
13423
- var wgslVert$3 = "struct VertexInput {\n#if HAS_DRACO_POSITION || HAS_COMPRESSED_INT16_POSITION\n @location($i) aPosition: vec4i,\n#else\n @location($i) aPosition: vec3f,\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 @location($i) aNormal: vec3f,\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(vertexInput.aNormal);\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);\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}";
13423
+ var wgslVert$3 = "struct VertexInput {\n#if HAS_DRACO_POSITION || HAS_COMPRESSED_INT16_POSITION\n @location($i) aPosition: vec4i,\n#else\n @location($i) aPosition: vec3f,\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 @location($i) aNormal: vec3f,\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(vertexInput.aNormal);\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);\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}";
13424
13424
 
13425
- var wgslFrag$3 = "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\nstruct VertexOutput {\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};\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();\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 fragColor = highlight_blendColor(fragColor, vertexOutput);\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}";
13425
+ var wgslFrag$3 = "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\nstruct VertexOutput {\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};\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();\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}";
13426
13426
 
13427
13427
  class PhongShader extends MeshShader {
13428
13428
  constructor(config = {}) {
@@ -24650,7 +24650,11 @@ class GroupGLLayerRenderer extends canvasCompatible(LayerAbstractRenderer$3) {
24650
24650
 
24651
24651
  onAdd() {
24652
24652
  super.onAdd();
24653
- this.prepareCanvas();
24653
+ const map = this.getMap();
24654
+ const mapRenderer = map.getRenderer();
24655
+ if (mapRenderer.ready) {
24656
+ this.prepareCanvas();
24657
+ }
24654
24658
  }
24655
24659
 
24656
24660
  updateSceneConfig() {
@@ -25257,6 +25261,10 @@ class GroupGLLayerRenderer extends canvasCompatible(LayerAbstractRenderer$3) {
25257
25261
 
25258
25262
  onRemove() {
25259
25263
  //regl framebuffer for picking created by children layers
25264
+ if (!this.canvas) {
25265
+ super.onRemove();
25266
+ return;
25267
+ }
25260
25268
  const pickingFBO = this.canvas.pickingFBO;
25261
25269
  if (pickingFBO && pickingFBO.destroy && !pickingFBO['___disposed']) {
25262
25270
  pickingFBO['___disposed'] = true;
@@ -28278,8 +28286,8 @@ class TerrainLayerRenderer extends MaskRendererMixin(TileLayerRendererable$1(Lay
28278
28286
  _createTerrainMaskTexture() {
28279
28287
  const regl = this.device;
28280
28288
  const tileSize = this.layer.getTileSize().width;
28281
- const width = tileSize * 2;
28282
- const height = tileSize * 2;
28289
+ const width = tileSize / 2;
28290
+ const height = tileSize / 2;
28283
28291
  const color = regl.texture({
28284
28292
  // min 和 mag 必须用nearest,选择别的值会造成mask的高程值发生错误
28285
28293
  min: 'nearest',
@@ -28316,12 +28324,16 @@ class TerrainLayerRenderer extends MaskRendererMixin(TileLayerRendererable$1(Lay
28316
28324
  _createTerrainTexture(tileInfo/*, tileImage*/) {
28317
28325
  const tileSize = this.layer.getTileSize().width;
28318
28326
  // 乘以2是为了瓦片(缩放时)被放大后保持清晰度
28319
- const width = tileSize * 2;
28320
- const height = tileSize * 2;
28327
+ let width = tileSize * 2;
28328
+ let height = tileSize * 2;
28321
28329
  const regl = this.device;
28322
28330
  const colorsTexture = tileInfo.colorsTexture;
28323
28331
  let color;
28324
- if (maptalks.Util.isImageBitMap(colorsTexture)) {
28332
+ if (maptalks.Util.isImageBitMap(colorsTexture) && colorsTexture.width > 0) {
28333
+ //不同的打包环境下,framebuffer 的大小和texture不同的,有的报错,有的不报错,why? 我也不知道
28334
+ //确保framebuffer 的大小和texture相同
28335
+ width = colorsTexture.width;
28336
+ height = colorsTexture.height;
28325
28337
  color = regl.texture({
28326
28338
  data: colorsTexture,
28327
28339
  min: 'linear',
@@ -31817,8 +31829,7 @@ class MapGPURenderer extends renderer.MapAbstractRenderer {
31817
31829
  return true;
31818
31830
  }
31819
31831
  createContext() {
31820
- return __awaiter(this, void 0, void 0, function* () {
31821
- const { gpuDevice, gpuAdapter } = yield initGPUDevice();
31832
+ return initGPUDevice().then(({ gpuDevice, gpuAdapter }) => {
31822
31833
  const context = this.canvas.getContext('webgpu');
31823
31834
  this.device = new GraphicsDevice(gpuDevice, context, gpuAdapter);
31824
31835
  this.context = {
@@ -33468,7 +33479,10 @@ class Measure3DTool extends maptalks.DrawTool {
33468
33479
 
33469
33480
  _addHelperLayer() {
33470
33481
  const id = maptalks.INTERNAL_LAYER_PREFIX + 'drawtool';
33471
- this._map.getLayer(id).hide();
33482
+ const drawtoolLayer = this._map.getLayer(id);
33483
+ if (drawtoolLayer) {
33484
+ drawtoolLayer.hide();
33485
+ }
33472
33486
  }
33473
33487
 
33474
33488
  _afterEnable() {
@@ -33884,7 +33898,7 @@ class Height3DTool extends Measure3DTool {
33884
33898
 
33885
33899
  const e = "${"; const code$1 = `function(t){
33886
33900
  /*!
33887
- * @maptalks/gltf-loader v0.115.0
33901
+ * @maptalks/gltf-loader v0.116.0
33888
33902
  * LICENSE : UNLICENSED
33889
33903
  * (c) 2016-2025 maptalks.org
33890
33904
  */
@@ -33905,5 +33919,5 @@ maptalks.registerWorkerAdapter('maplight', code);
33905
33919
 
33906
33920
  export { Area3DTool, BoxInsideClipper as BoxInsideClipMask, BoxOutsideClipper as BoxOutsideClipMask, canvasCompatible as CanvasCompatible, ClipInsideMask, ClipOutsideMask, ColorMask, context as ContextUtil, Distance3DTool, ElevateMask, FlatInsideMask$1 as FlatInsideMask, FlatInsideMask as FlatOutsideMask, GroundPainter, GroupGLLayer, HeatmapProcess, Height3DTool, highlight as HighlightUtil, ImageMask, MapGLRenderer, MapGPURenderer, MaskLayerMixin, MaskRendererMixin, Measure3DTool, RayCaster, VideoMask, Color$1 as color, earcut$1 as earcut, index as reshader, transcoders };
33907
33921
 
33908
- typeof console !== 'undefined' && console.log('@maptalks/gpu v0.115.0');
33922
+ typeof console !== 'undefined' && console.log('@maptalks/gpu v0.116.0');
33909
33923
  //# sourceMappingURL=maptalksgpu.es.js.map