@maptalks/gpu 0.120.0 → 0.121.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.
- package/dist/maptalksgpu.d.ts +10 -7
- package/dist/maptalksgpu.es.js +272 -166
- package/dist/maptalksgpu.es.js.map +1 -1
- package/dist/maptalksgpu.js +411 -370
- package/dist/maptalksgpu.js.map +1 -1
- package/dist/transcoders.js +1 -1
- package/package.json +4 -4
package/dist/maptalksgpu.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/gpu v0.
|
|
2
|
+
* @maptalks/gpu v0.121.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2026 maptalks.com
|
|
5
5
|
*/
|
|
@@ -67,10 +67,10 @@ 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.
|
|
70
|
+
* @maptalks/gltf-loader v0.121.0
|
|
71
71
|
* LICENSE : UNLICENSED
|
|
72
72
|
* (c) 2016-2026 maptalks.org
|
|
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;}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({});
|
|
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={}),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",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({});
|
|
74
74
|
|
|
75
75
|
const getGlobal = function () {
|
|
76
76
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -609,7 +609,8 @@ function isTextureDestroyed(texture) {
|
|
|
609
609
|
return true;
|
|
610
610
|
}
|
|
611
611
|
function isTextureLike(texture) {
|
|
612
|
-
|
|
612
|
+
// not a GPUBuffer or a REGLBuffer
|
|
613
|
+
return texture && !texture.mapAsync && (texture.dispose || texture.destroy);
|
|
613
614
|
}
|
|
614
615
|
|
|
615
616
|
var Util = /*#__PURE__*/Object.freeze({
|
|
@@ -1862,7 +1863,7 @@ class Geometry {
|
|
|
1862
1863
|
return device.buffer(data);
|
|
1863
1864
|
}
|
|
1864
1865
|
}
|
|
1865
|
-
static padGPUBufferAlignment(array, vertexCount) {
|
|
1866
|
+
static padGPUBufferAlignment(array, vertexCount, transient = false) {
|
|
1866
1867
|
if (vertexCount === 0) {
|
|
1867
1868
|
return array;
|
|
1868
1869
|
}
|
|
@@ -1877,7 +1878,13 @@ class Geometry {
|
|
|
1877
1878
|
if (itemSize === 3) {
|
|
1878
1879
|
// itemSize 为 3时,补位为 4,wgsl中需要相应修改类型声明
|
|
1879
1880
|
const newItemSize = ensureAlignment(itemSize, bytesPerElement);
|
|
1880
|
-
|
|
1881
|
+
let newArray;
|
|
1882
|
+
if (transient) {
|
|
1883
|
+
newArray = getTempParamArray(ctor, newItemSize * vertexCount); //new ctor(newItemSize * vertexCount);
|
|
1884
|
+
}
|
|
1885
|
+
else {
|
|
1886
|
+
newArray = new ctor(newItemSize * vertexCount);
|
|
1887
|
+
}
|
|
1881
1888
|
for (let i = 0; i < vertexCount; i++) {
|
|
1882
1889
|
for (let ii = 0; ii < itemSize; ii++) {
|
|
1883
1890
|
newArray[i * newItemSize + ii] = array[i * itemSize + ii];
|
|
@@ -1888,7 +1895,13 @@ class Geometry {
|
|
|
1888
1895
|
else {
|
|
1889
1896
|
// itemSize 为 1或2时,提升数组的类型,不影响wgsl中的类型声明
|
|
1890
1897
|
const newCtor = getPadArrayCtor(ctor, itemSize);
|
|
1891
|
-
|
|
1898
|
+
let newArray;
|
|
1899
|
+
if (transient) {
|
|
1900
|
+
newArray = getTempParamArray(newCtor, itemSize * vertexCount); //new newCtor(itemSize * vertexCount);
|
|
1901
|
+
}
|
|
1902
|
+
else {
|
|
1903
|
+
newArray = new newCtor(itemSize * vertexCount);
|
|
1904
|
+
}
|
|
1892
1905
|
newArray.set(array);
|
|
1893
1906
|
return newArray;
|
|
1894
1907
|
}
|
|
@@ -2162,11 +2175,20 @@ class Geometry {
|
|
|
2162
2175
|
}
|
|
2163
2176
|
}
|
|
2164
2177
|
else {
|
|
2165
|
-
|
|
2166
|
-
const dimension = arr.length / vertexCount;
|
|
2178
|
+
let arr = data[key].data ? data[key].data : data[key];
|
|
2179
|
+
const dimension = Math.floor(arr.length / vertexCount);
|
|
2180
|
+
if (dimension * vertexCount !== arr.length) {
|
|
2181
|
+
arr = arr.slice(0, vertexCount * dimension);
|
|
2182
|
+
if (data[key].data) {
|
|
2183
|
+
data[key].data = arr;
|
|
2184
|
+
}
|
|
2185
|
+
else {
|
|
2186
|
+
data[key] = arr;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2167
2189
|
let bufferData = arr;
|
|
2168
2190
|
if (isWebGPU) {
|
|
2169
|
-
bufferData = Geometry.padGPUBufferAlignment(arr, vertexCount);
|
|
2191
|
+
bufferData = Geometry.padGPUBufferAlignment(arr, vertexCount, true);
|
|
2170
2192
|
}
|
|
2171
2193
|
const info = data[key].data ? data[key] : {};
|
|
2172
2194
|
info.data = bufferData;
|
|
@@ -2327,7 +2349,7 @@ class Geometry {
|
|
|
2327
2349
|
if (buffer) {
|
|
2328
2350
|
if (buffer.buffer.mapState) {
|
|
2329
2351
|
//webgpu buffer
|
|
2330
|
-
data = Geometry.padGPUBufferAlignment(data, this._vertexCount);
|
|
2352
|
+
data = Geometry.padGPUBufferAlignment(data, this._vertexCount, true);
|
|
2331
2353
|
buffer.buffer = this._updateGPUBuffer(buffer.buffer, data, 0, data.buffer.byteLength);
|
|
2332
2354
|
}
|
|
2333
2355
|
else {
|
|
@@ -2378,7 +2400,7 @@ class Geometry {
|
|
|
2378
2400
|
const itemSize = buffer.buffer.itemCount / this._vertexCount;
|
|
2379
2401
|
const itemCount = data.length / itemSize;
|
|
2380
2402
|
//webgpu buffer
|
|
2381
|
-
data = Geometry.padGPUBufferAlignment(data, itemCount);
|
|
2403
|
+
data = Geometry.padGPUBufferAlignment(data, itemCount, true);
|
|
2382
2404
|
const byteWidth = buffer.buffer.bytesPerElement;
|
|
2383
2405
|
if (data.BYTES_PER_ELEMENT !== byteWidth) {
|
|
2384
2406
|
const ctor = getTypeCtor(data, byteWidth);
|
|
@@ -3043,7 +3065,7 @@ function getItemFormat(data, itemSize) {
|
|
|
3043
3065
|
return itemSize > 1 ? (format + 'x' + itemSize) : format;
|
|
3044
3066
|
}
|
|
3045
3067
|
function getAttrArray(data) {
|
|
3046
|
-
return data.data || (data.buffer.destroy && data.buffer) || data;
|
|
3068
|
+
return data.data || (data.buffer && data.buffer.destroy && data.buffer) || data;
|
|
3047
3069
|
}
|
|
3048
3070
|
function createGPUBuffer(device, data, usage, label) {
|
|
3049
3071
|
data = data.data || data;
|
|
@@ -8700,7 +8722,7 @@ class InstancedMesh extends Mesh {
|
|
|
8700
8722
|
data[key] = new Float32Array(data[key]);
|
|
8701
8723
|
}
|
|
8702
8724
|
else if (isWebGPU && isArray(data[key])) {
|
|
8703
|
-
data[key] = Geometry.padGPUBufferAlignment(data[key], instanceCount);
|
|
8725
|
+
data[key] = Geometry.padGPUBufferAlignment(data[key], instanceCount, true);
|
|
8704
8726
|
}
|
|
8705
8727
|
const attrBuf = data[key];
|
|
8706
8728
|
if (attrBuf.buffer !== undefined && attrBuf.buffer.destroy) {
|
|
@@ -9843,7 +9865,7 @@ function replace(match, include) {
|
|
|
9843
9865
|
return parseIncludes(replace);
|
|
9844
9866
|
}
|
|
9845
9867
|
|
|
9846
|
-
const vert$
|
|
9868
|
+
const vert$p = /* wgsl */ `
|
|
9847
9869
|
@group(0) @binding($b) var<uniform> terrainAltitudeScale: f32;
|
|
9848
9870
|
|
|
9849
9871
|
// 获取实例属性矩阵函数
|
|
@@ -9914,11 +9936,11 @@ const attributes$5 = [
|
|
|
9914
9936
|
}
|
|
9915
9937
|
];
|
|
9916
9938
|
var instance = {
|
|
9917
|
-
vert: vert$
|
|
9939
|
+
vert: vert$p, attributes: attributes$5,
|
|
9918
9940
|
defines: ['HAS_INSTANCE']
|
|
9919
9941
|
};
|
|
9920
9942
|
|
|
9921
|
-
const vert$
|
|
9943
|
+
const vert$o = /* wgsl */ `
|
|
9922
9944
|
// 矩阵求逆函数
|
|
9923
9945
|
fn invert_matrix(matrix: mat4x4f) -> mat4x4f {
|
|
9924
9946
|
let vector1 = matrix[0];
|
|
@@ -10023,12 +10045,12 @@ fn transpose_matrix(matrix: mat4x4f) -> mat4x4f {
|
|
|
10023
10045
|
return m;
|
|
10024
10046
|
}
|
|
10025
10047
|
`;
|
|
10026
|
-
const frag$t = vert$
|
|
10048
|
+
const frag$t = vert$o;
|
|
10027
10049
|
var invert_matrix = {
|
|
10028
|
-
vert: vert$
|
|
10050
|
+
vert: vert$o, frag: frag$t
|
|
10029
10051
|
};
|
|
10030
10052
|
|
|
10031
|
-
const vert$
|
|
10053
|
+
const vert$n = /* wgsl */ `
|
|
10032
10054
|
#define ALTITUDE_SCALE 32767.0
|
|
10033
10055
|
#define EXTRUDE_SCALE 63.0
|
|
10034
10056
|
|
|
@@ -10084,12 +10106,12 @@ const attributes$4 = [
|
|
|
10084
10106
|
}
|
|
10085
10107
|
];
|
|
10086
10108
|
var line_extrusion = {
|
|
10087
|
-
vert: vert$
|
|
10109
|
+
vert: vert$n,
|
|
10088
10110
|
attributes: attributes$4,
|
|
10089
10111
|
defines: ['IS_LINE_EXTRUSION']
|
|
10090
10112
|
};
|
|
10091
10113
|
|
|
10092
|
-
const vert$
|
|
10114
|
+
const vert$m = /* wgsl */ `
|
|
10093
10115
|
#ifdef HAS_MASK_EXTENT
|
|
10094
10116
|
struct MaskUniforms {
|
|
10095
10117
|
mask_extent: vec4f,
|
|
@@ -10190,11 +10212,11 @@ const varyings$4 = [
|
|
|
10190
10212
|
];
|
|
10191
10213
|
var mask = {
|
|
10192
10214
|
defines: ['HAS_MASK_EXTENT'],
|
|
10193
|
-
vert: vert$
|
|
10215
|
+
vert: vert$m,
|
|
10194
10216
|
varyings: varyings$4
|
|
10195
10217
|
};
|
|
10196
10218
|
|
|
10197
|
-
const vert$
|
|
10219
|
+
const vert$l = /* wgsl */ `
|
|
10198
10220
|
#include <invert_matrix>
|
|
10199
10221
|
#include <draco_decode_vert>
|
|
10200
10222
|
|
|
@@ -10392,10 +10414,10 @@ const attributes$3 = [
|
|
|
10392
10414
|
var get_output = {
|
|
10393
10415
|
attributes: attributes$3,
|
|
10394
10416
|
varyings: varyings$3,
|
|
10395
|
-
vert: vert$
|
|
10417
|
+
vert: vert$l
|
|
10396
10418
|
};
|
|
10397
10419
|
|
|
10398
|
-
const vert$
|
|
10420
|
+
const vert$k = /* wgsl */ `
|
|
10399
10421
|
// 定义 uniform 变量
|
|
10400
10422
|
struct JoinUniforms {
|
|
10401
10423
|
numJoints: f32, // 关节数量
|
|
@@ -10444,13 +10466,13 @@ const attributes$2 = [
|
|
|
10444
10466
|
}
|
|
10445
10467
|
];
|
|
10446
10468
|
var skin = {
|
|
10447
|
-
vert: vert$
|
|
10469
|
+
vert: vert$k,
|
|
10448
10470
|
attributes: attributes$2,
|
|
10449
10471
|
defines: ['HAS_SKIN']
|
|
10450
10472
|
};
|
|
10451
10473
|
|
|
10452
10474
|
//用于识别顶点颜色类型: topPolygonFill 还是 bottomPolygonFill
|
|
10453
|
-
const vert$
|
|
10475
|
+
const vert$j = /* wgsl */ `
|
|
10454
10476
|
struct VertexColorsUniforms {
|
|
10455
10477
|
vertexColorsOfType: array<vec4f, VERTEX_TYPES_COUNT>
|
|
10456
10478
|
}
|
|
@@ -10483,11 +10505,11 @@ const varyings$2 = [
|
|
|
10483
10505
|
}
|
|
10484
10506
|
];
|
|
10485
10507
|
var vertex_color = {
|
|
10486
|
-
vert: vert$
|
|
10508
|
+
vert: vert$j, frag: frag$s, attributes: attributes$1, varyings: varyings$2,
|
|
10487
10509
|
defines: ['HAS_VERTEX_COLOR']
|
|
10488
10510
|
};
|
|
10489
10511
|
|
|
10490
|
-
const vert$
|
|
10512
|
+
const vert$i = /* wgsl */ `
|
|
10491
10513
|
struct ShadowUniforms {
|
|
10492
10514
|
shadow_lightProjViewModelMatrix: mat4x4f,
|
|
10493
10515
|
};
|
|
@@ -10566,10 +10588,10 @@ var vsm_shadow = {
|
|
|
10566
10588
|
defines: (defines) => {
|
|
10567
10589
|
return defines['HAS_SHADOWING'] && !defines['HAS_BLOOM'];
|
|
10568
10590
|
},
|
|
10569
|
-
vert: vert$
|
|
10591
|
+
vert: vert$i, frag: frag$r, varyings: varyings$1
|
|
10570
10592
|
};
|
|
10571
10593
|
|
|
10572
|
-
const vert$
|
|
10594
|
+
const vert$h = /* wgsl */ `
|
|
10573
10595
|
#if HAS_DRACO_NORMAL || HAS_DRACO_POSITION || HAS_DRACO_TEXCOORD || HAS_WEB3D_QUANTIZED_ATTRIBUTES_TEXCOORD || HAS_COMPRESSED_INT16
|
|
10574
10596
|
// 定义 uniform 变量
|
|
10575
10597
|
struct DracoUniforms {
|
|
@@ -10716,10 +10738,10 @@ const vert$i = /* wgsl */ `
|
|
|
10716
10738
|
}
|
|
10717
10739
|
`;
|
|
10718
10740
|
var draco_decode = {
|
|
10719
|
-
vert: vert$
|
|
10741
|
+
vert: vert$h
|
|
10720
10742
|
};
|
|
10721
10743
|
|
|
10722
|
-
const vert$
|
|
10744
|
+
const vert$g = /* wgsl */ `
|
|
10723
10745
|
|
|
10724
10746
|
// 顶点着色器函数
|
|
10725
10747
|
fn highlight_setVarying(input: VertexInput, output: ptr<function, VertexOutput>) {
|
|
@@ -10786,7 +10808,7 @@ var highlight$1 = {
|
|
|
10786
10808
|
defines: (defines) => {
|
|
10787
10809
|
return defines['HAS_HIGHLIGHT_OPACITY'] || defines['HAS_HIGHLIGHT_COLOR'];
|
|
10788
10810
|
},
|
|
10789
|
-
vert: vert$
|
|
10811
|
+
vert: vert$g, frag: frag$q, attributes, varyings
|
|
10790
10812
|
};
|
|
10791
10813
|
|
|
10792
10814
|
const frag$p = /* wgsl */ `
|
|
@@ -10829,7 +10851,7 @@ var compute_texcoord = {
|
|
|
10829
10851
|
frag: frag$p
|
|
10830
10852
|
};
|
|
10831
10853
|
|
|
10832
|
-
const vert$
|
|
10854
|
+
const vert$f = /*wgsl*/ `
|
|
10833
10855
|
//--------------------------
|
|
10834
10856
|
// Picking
|
|
10835
10857
|
//
|
|
@@ -10868,7 +10890,7 @@ fn fbo_picking_setData(input: VertexInput, output: ptr<function, VertexOutput>,
|
|
|
10868
10890
|
}
|
|
10869
10891
|
`;
|
|
10870
10892
|
var fbo_picking = {
|
|
10871
|
-
vert: vert$
|
|
10893
|
+
vert: vert$f,
|
|
10872
10894
|
attributes: [
|
|
10873
10895
|
{
|
|
10874
10896
|
defines: (defines) => {
|
|
@@ -10901,7 +10923,7 @@ var fbo_picking = {
|
|
|
10901
10923
|
]
|
|
10902
10924
|
};
|
|
10903
10925
|
|
|
10904
|
-
const vert$
|
|
10926
|
+
const vert$e = /* wgsl */ `
|
|
10905
10927
|
const COMMON_FLOAT_MAX: f32 = 1.70141184e38;
|
|
10906
10928
|
const COMMON_FLOAT_MIN: f32 = 1.17549435e-38;
|
|
10907
10929
|
|
|
@@ -10997,12 +11019,12 @@ fn decodeFloat32(inputRgba: vec4f) -> f32 {
|
|
|
10997
11019
|
return Result;
|
|
10998
11020
|
}
|
|
10999
11021
|
`;
|
|
11000
|
-
const frag$o = vert$
|
|
11022
|
+
const frag$o = vert$e;
|
|
11001
11023
|
var common_pack_float = {
|
|
11002
|
-
vert: vert$
|
|
11024
|
+
vert: vert$e, frag: frag$o
|
|
11003
11025
|
};
|
|
11004
11026
|
|
|
11005
|
-
const vert$
|
|
11027
|
+
const vert$d = /*wgsl*/ `
|
|
11006
11028
|
#ifdef HAS_EXCAVATE_ANALYSIS
|
|
11007
11029
|
struct ExcavateUniforms {
|
|
11008
11030
|
excavateExtent: vec4f
|
|
@@ -11061,7 +11083,7 @@ fn excavateColor(fragColor: vec4f, vertexOutput: VertexOutput) -> vec4f {
|
|
|
11061
11083
|
`;
|
|
11062
11084
|
var excavate = {
|
|
11063
11085
|
defines: ['HAS_EXCAVATE_ANALYSIS'],
|
|
11064
|
-
vert: vert$
|
|
11086
|
+
vert: vert$d,
|
|
11065
11087
|
frag: frag$n,
|
|
11066
11088
|
varyings: [
|
|
11067
11089
|
{
|
|
@@ -11228,7 +11250,7 @@ var terrain_normal = {
|
|
|
11228
11250
|
frag: frag$j
|
|
11229
11251
|
};
|
|
11230
11252
|
|
|
11231
|
-
const vert$
|
|
11253
|
+
const vert$c = /*wgsl*/ `
|
|
11232
11254
|
#include <fbo_picking_vert>
|
|
11233
11255
|
#include <get_output>
|
|
11234
11256
|
|
|
@@ -11268,7 +11290,7 @@ fn main(input: VertexInput) -> VertexOutput {
|
|
|
11268
11290
|
}
|
|
11269
11291
|
`;
|
|
11270
11292
|
var mesh_picking = {
|
|
11271
|
-
vert: vert$
|
|
11293
|
+
vert: vert$c
|
|
11272
11294
|
};
|
|
11273
11295
|
|
|
11274
11296
|
const frag$i = /*wgsl*/ `
|
|
@@ -11607,8 +11629,8 @@ class PipelineDescriptor {
|
|
|
11607
11629
|
}
|
|
11608
11630
|
this.depthBias = depthBias;
|
|
11609
11631
|
this.depthBiasSlopeScale = depthBiasSlopeScale;
|
|
11610
|
-
let depthCompare = '
|
|
11611
|
-
let depthWriteEnable =
|
|
11632
|
+
let depthCompare = 'less';
|
|
11633
|
+
let depthWriteEnable = true;
|
|
11612
11634
|
const depthProps = commandProps.depth;
|
|
11613
11635
|
if (depthEnabled && depthProps && isEnable(depthProps.enable, uniformValues)) {
|
|
11614
11636
|
if (depthProps.func) {
|
|
@@ -11792,6 +11814,7 @@ class GraphicsTexture {
|
|
|
11792
11814
|
this.device = device;
|
|
11793
11815
|
this.config = config;
|
|
11794
11816
|
this.gpuFormat = toTextureFormat(config.format, config.type);
|
|
11817
|
+
this.dirty = false;
|
|
11795
11818
|
this._updateTexture();
|
|
11796
11819
|
}
|
|
11797
11820
|
get width() {
|
|
@@ -11813,41 +11836,34 @@ class GraphicsTexture {
|
|
|
11813
11836
|
if (this.texture && this.texture.width === width && this.texture.height === height) {
|
|
11814
11837
|
return;
|
|
11815
11838
|
}
|
|
11839
|
+
this.dirty = true;
|
|
11816
11840
|
this.config.width = width;
|
|
11817
11841
|
this.config.height = height;
|
|
11818
11842
|
this._updateTexture();
|
|
11819
11843
|
}
|
|
11820
11844
|
update(config) {
|
|
11845
|
+
if (this.texture) {
|
|
11846
|
+
this.dirty = this._isDirty(config);
|
|
11847
|
+
}
|
|
11848
|
+
const { width, height } = this._getSize(config);
|
|
11821
11849
|
extend$1(this.config, config);
|
|
11850
|
+
this.config.width = width;
|
|
11851
|
+
this.config.height = height;
|
|
11822
11852
|
this.gpuFormat = toTextureFormat(this.config.format, this.config.type);
|
|
11823
11853
|
this._updateTexture();
|
|
11824
11854
|
}
|
|
11825
11855
|
_updateTexture() {
|
|
11826
11856
|
const config = this.config;
|
|
11857
|
+
const { width, height } = this._getSize(config);
|
|
11827
11858
|
const device = this.device.wgpu;
|
|
11828
|
-
if (this.
|
|
11859
|
+
if (this.dirty) {
|
|
11829
11860
|
this.version++;
|
|
11830
11861
|
this.device.addToDestroyList(this.texture);
|
|
11862
|
+
this.texture = null;
|
|
11863
|
+
this.dirty = false;
|
|
11831
11864
|
}
|
|
11832
|
-
let texture;
|
|
11865
|
+
let texture = this.texture;
|
|
11833
11866
|
{
|
|
11834
|
-
let width = isFunction$1(config.width) ? config.width() : config.width;
|
|
11835
|
-
let height = isFunction$1(config.height) ? config.height() : config.height;
|
|
11836
|
-
if (width === undefined || height === undefined) {
|
|
11837
|
-
const data = config.data;
|
|
11838
|
-
if (!data) {
|
|
11839
|
-
width = height = 1;
|
|
11840
|
-
}
|
|
11841
|
-
else if (isArray(config.data)) {
|
|
11842
|
-
const length = config.data.length;
|
|
11843
|
-
width = Math.sqrt(length / 4);
|
|
11844
|
-
height = width;
|
|
11845
|
-
}
|
|
11846
|
-
else {
|
|
11847
|
-
width = data.width;
|
|
11848
|
-
height = data.height;
|
|
11849
|
-
}
|
|
11850
|
-
}
|
|
11851
11867
|
const format = this.gpuFormat.format;
|
|
11852
11868
|
const isDepth = format === 'depth24plus' || format === 'depth24plus-stencil8';
|
|
11853
11869
|
const usage = isDepth ?
|
|
@@ -11863,13 +11879,55 @@ class GraphicsTexture {
|
|
|
11863
11879
|
if (config.sampleCount) {
|
|
11864
11880
|
options.sampleCount = config.sampleCount;
|
|
11865
11881
|
}
|
|
11866
|
-
texture = device.createTexture(options);
|
|
11882
|
+
texture = texture || device.createTexture(options);
|
|
11867
11883
|
this.fillData(texture, width, height);
|
|
11868
11884
|
}
|
|
11869
11885
|
this.texture = texture;
|
|
11870
11886
|
}
|
|
11871
|
-
|
|
11872
|
-
|
|
11887
|
+
_isDirty(newConfig) {
|
|
11888
|
+
if (!this.texture) {
|
|
11889
|
+
return false;
|
|
11890
|
+
}
|
|
11891
|
+
const { width, height } = this._getSize(newConfig);
|
|
11892
|
+
if (width !== this.texture.width) {
|
|
11893
|
+
return true;
|
|
11894
|
+
}
|
|
11895
|
+
if (height !== this.texture.height) {
|
|
11896
|
+
return true;
|
|
11897
|
+
}
|
|
11898
|
+
if (newConfig.format && newConfig.format !== this.config.format) {
|
|
11899
|
+
return true;
|
|
11900
|
+
}
|
|
11901
|
+
if (newConfig.type && newConfig.type !== this.config.type) {
|
|
11902
|
+
return true;
|
|
11903
|
+
}
|
|
11904
|
+
if (this.getMipLevelCount(newConfig.data) !== this.getMipLevelCount()) {
|
|
11905
|
+
return true;
|
|
11906
|
+
}
|
|
11907
|
+
return false;
|
|
11908
|
+
}
|
|
11909
|
+
_getSize(config) {
|
|
11910
|
+
let width = isFunction$1(config.width) ? config.width() : config.width;
|
|
11911
|
+
let height = isFunction$1(config.height) ? config.height() : config.height;
|
|
11912
|
+
if (width === undefined || height === undefined) {
|
|
11913
|
+
const data = config.data;
|
|
11914
|
+
if (!data) {
|
|
11915
|
+
width = height = 1;
|
|
11916
|
+
}
|
|
11917
|
+
else if (isArray(config.data)) {
|
|
11918
|
+
const length = config.data.length;
|
|
11919
|
+
width = Math.sqrt(length / 4);
|
|
11920
|
+
height = width;
|
|
11921
|
+
}
|
|
11922
|
+
else {
|
|
11923
|
+
width = data.videoWidth || data.width;
|
|
11924
|
+
height = data.videoHeight || data.height;
|
|
11925
|
+
}
|
|
11926
|
+
}
|
|
11927
|
+
return { width, height };
|
|
11928
|
+
}
|
|
11929
|
+
getMipLevelCount(data) {
|
|
11930
|
+
data = data || this.config.data;
|
|
11873
11931
|
if (data && data.mipmap) {
|
|
11874
11932
|
return data.mipmap.length;
|
|
11875
11933
|
}
|
|
@@ -12055,6 +12113,22 @@ class GraphicsFramebuffer {
|
|
|
12055
12113
|
}
|
|
12056
12114
|
}
|
|
12057
12115
|
}
|
|
12116
|
+
getCommandKey() {
|
|
12117
|
+
if (this._cmdKey) {
|
|
12118
|
+
return this._cmdKey;
|
|
12119
|
+
}
|
|
12120
|
+
const colorTexture = this.colorTexture;
|
|
12121
|
+
const depthTexture = this.depthTexture;
|
|
12122
|
+
let key = '';
|
|
12123
|
+
if (colorTexture) {
|
|
12124
|
+
key += `${colorTexture.gpuFormat.format}-${colorTexture.config.sampleCount};`;
|
|
12125
|
+
}
|
|
12126
|
+
if (depthTexture) {
|
|
12127
|
+
key += `${depthTexture.gpuFormat.format};`;
|
|
12128
|
+
}
|
|
12129
|
+
this._cmdKey = key;
|
|
12130
|
+
return key;
|
|
12131
|
+
}
|
|
12058
12132
|
_update() {
|
|
12059
12133
|
let color = this.options.colors && this.options.colors[0] || this.options.color;
|
|
12060
12134
|
const colorFormat = this.options.colorFormat;
|
|
@@ -12977,7 +13051,8 @@ class CommandBuilder {
|
|
|
12977
13051
|
},
|
|
12978
13052
|
primitive: {
|
|
12979
13053
|
topology: pipelineDesc.topology,
|
|
12980
|
-
cullMode: pipelineDesc.cullMode
|
|
13054
|
+
cullMode: pipelineDesc.cullMode,
|
|
13055
|
+
frontFace: pipelineDesc.frontFace
|
|
12981
13056
|
}
|
|
12982
13057
|
};
|
|
12983
13058
|
const sampleCount = fbo && fbo.colorTexture && fbo.colorTexture.config.sampleCount;
|
|
@@ -13456,17 +13531,21 @@ const pipelineDesc = new PipelineDescriptor();
|
|
|
13456
13531
|
class GPUShader extends GLShader {
|
|
13457
13532
|
getShaderCommandKey(device, mesh, renderProps) {
|
|
13458
13533
|
if (device && device.wgpu) {
|
|
13534
|
+
let fboKey = '';
|
|
13535
|
+
if (this._gpuFramebuffer) {
|
|
13536
|
+
fboKey = `-${this._gpuFramebuffer.getCommandKey()}`;
|
|
13537
|
+
}
|
|
13459
13538
|
// 获取pipeline所需要的特征变量,即任何变量发生变化后,就需要创建新的pipeline
|
|
13460
13539
|
const fnValues = mesh.getShaderFnValues(this.uid);
|
|
13461
13540
|
if (fnValues) {
|
|
13462
13541
|
const { funcs, key, commandKey } = fnValues;
|
|
13463
13542
|
if (!funcs.length) {
|
|
13464
|
-
return commandKey;
|
|
13543
|
+
return commandKey + fboKey;
|
|
13465
13544
|
}
|
|
13466
13545
|
const values = funcs.map(func => func(null, renderProps));
|
|
13467
13546
|
const currentKey = pipelineDesc.generateValuesKey(values);
|
|
13468
13547
|
if (currentKey === key) {
|
|
13469
|
-
return commandKey;
|
|
13548
|
+
return commandKey + fboKey;
|
|
13470
13549
|
}
|
|
13471
13550
|
}
|
|
13472
13551
|
const fbo = this._gpuFramebuffer;
|
|
@@ -13478,7 +13557,7 @@ class GPUShader extends GLShader {
|
|
|
13478
13557
|
key: pipelineDesc.getFnValuesKey(),
|
|
13479
13558
|
commandKey
|
|
13480
13559
|
});
|
|
13481
|
-
return commandKey;
|
|
13560
|
+
return commandKey + fboKey;
|
|
13482
13561
|
}
|
|
13483
13562
|
else {
|
|
13484
13563
|
// regl
|
|
@@ -13872,9 +13951,9 @@ var phongFrag = "precision mediump float;\n#include <gl2_frag>\nuniform vec4 bas
|
|
|
13872
13951
|
|
|
13873
13952
|
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}";
|
|
13874
13953
|
|
|
13875
|
-
var wgslVert$
|
|
13954
|
+
var wgslVert$5 = "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}";
|
|
13876
13955
|
|
|
13877
|
-
var wgslFrag$
|
|
13956
|
+
var wgslFrag$9 = "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}";
|
|
13878
13957
|
|
|
13879
13958
|
class PhongShader extends MeshShader {
|
|
13880
13959
|
constructor(config = {}) {
|
|
@@ -13904,8 +13983,8 @@ class PhongShader extends MeshShader {
|
|
|
13904
13983
|
name: 'phong',
|
|
13905
13984
|
vert: config.vert || phongVert,
|
|
13906
13985
|
frag: config.frag || phongFrag,
|
|
13907
|
-
wgslVert: wgslVert$
|
|
13908
|
-
wgslFrag: wgslFrag$
|
|
13986
|
+
wgslVert: wgslVert$5,
|
|
13987
|
+
wgslFrag: wgslFrag$9,
|
|
13909
13988
|
uniforms,
|
|
13910
13989
|
defines: config.defines || {},
|
|
13911
13990
|
extraCommandProps: config.extraCommandProps || {}
|
|
@@ -13949,9 +14028,9 @@ class PointLineShader extends MeshShader {
|
|
|
13949
14028
|
}
|
|
13950
14029
|
}
|
|
13951
14030
|
|
|
13952
|
-
var vert$
|
|
14031
|
+
var vert$b = "#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}";
|
|
13953
14032
|
|
|
13954
|
-
var wgslVert$
|
|
14033
|
+
var wgslVert$4 = "struct VertexOutput {\n @builtin(position) position : vec4f,\n @location($o) vTexCoord: vec2f\n}\n@vertex\nfn main(\n @location($i) aPosition: vec2f,\n @location($i) aTexCoord: vec2f\n) -> VertexOutput {\n var output: VertexOutput;\n output.position = vec4f(aPosition, 0., 1.);\n output.vTexCoord = aTexCoord;\n return output;\n}";
|
|
13955
14034
|
|
|
13956
14035
|
const quadVertices$1 = new Float32Array([
|
|
13957
14036
|
// positions
|
|
@@ -13973,8 +14052,8 @@ const quadTexcoords$1 = new Float32Array([
|
|
|
13973
14052
|
|
|
13974
14053
|
class QuadShader extends MeshShader {
|
|
13975
14054
|
constructor(config) {
|
|
13976
|
-
config.vert = config.vert || vert$
|
|
13977
|
-
config.wgslVert = config.wgslVert || wgslVert$
|
|
14055
|
+
config.vert = config.vert || vert$b;
|
|
14056
|
+
config.wgslVert = config.wgslVert || wgslVert$4;
|
|
13978
14057
|
config.extraCommandProps = config.extraCommandProps || {};
|
|
13979
14058
|
if (!config.extraCommandProps.depth) {
|
|
13980
14059
|
//disable depth
|
|
@@ -13999,12 +14078,14 @@ class QuadShader extends MeshShader {
|
|
|
13999
14078
|
return super.draw(regl, this._quadMesh);
|
|
14000
14079
|
}
|
|
14001
14080
|
|
|
14002
|
-
getMeshCommand(regl) {
|
|
14003
|
-
const
|
|
14004
|
-
|
|
14005
|
-
|
|
14081
|
+
getMeshCommand(regl, mesh, renderProps) {
|
|
14082
|
+
const key = this.dkey || '';
|
|
14083
|
+
const shaderKey = this.getShaderCommandKey(regl, mesh, renderProps);
|
|
14084
|
+
const cmdKey = key + shaderKey + '_quad';
|
|
14085
|
+
if (!this.commands[cmdKey]) {
|
|
14086
|
+
this.commands[cmdKey] = this.createMeshCommand(regl, mesh);
|
|
14006
14087
|
}
|
|
14007
|
-
return this.commands[
|
|
14088
|
+
return this.commands[cmdKey];
|
|
14008
14089
|
}
|
|
14009
14090
|
|
|
14010
14091
|
_createQuadMesh(regl) {
|
|
@@ -14037,13 +14118,13 @@ class QuadShader extends MeshShader {
|
|
|
14037
14118
|
|
|
14038
14119
|
var frag$h = "#define SHADER_NAME FXAA\nprecision mediump float;\nvarying vec2 vTexCoord;\nuniform float enableFXAA;\nuniform float enableToneMapping;\nuniform float enableSharpen;\nuniform vec2 resolution;\nuniform sampler2D textureSource;\n#ifdef HAS_NOAA_TEX\nuniform sampler2D noAaTextureSource;\n#endif\n#ifdef HAS_POINT_TEX\nuniform sampler2D pointTextureSource;\n#endif\n#ifdef HAS_TAA_TEX\nuniform sampler2D taaTextureSource;\n#ifdef HAS_FXAA_TEX\nuniform sampler2D fxaaTextureSource;\n#endif\n#endif\nuniform float pixelRatio;\nuniform float sharpFactor;\n#ifdef HAS_OUTLINE_TEX\nuniform sampler2D textureOutline;\nuniform float highlightFactor;\nuniform float outlineFactor;\nuniform float outlineWidth;\nuniform vec3 outlineColor;\n#endif\nvec2 c;\nvec4 d(vec2 e) {\n \n#ifdef HAS_TAA_TEX\nvec4 f = texture2D(textureSource, e);\n vec4 taa = texture2D(taaTextureSource, e);\n#ifdef HAS_FXAA_TEX\nvec4 h = texture2D(fxaaTextureSource, e);\n#else\nvec4 h = vec4(.0);\n#endif\nvec4 i = taa + f * (1. - taa.a);\n return h + i * (1. - h.a);\n#else\nreturn texture2D(textureSource, e);\n#endif\n}\nvec3 j(const in vec3 k, const float l) {\n vec2 m = pixelRatio / resolution.xy;\n float n = .0;\n vec4 o = texture2D(textureSource, c + m * vec2(-1., -1.));\n o.rgb = mix(vec3(.0), o.rgb, sign(o.a));\n n += mix(.0, 1., sign(o.a));\n vec4 u = texture2D(textureSource, c + m * vec2(1.));\n u.rgb = mix(vec3(.0), u.rgb, sign(u.a));\n n += mix(.0, 1., sign(u.a));\n vec4 v = texture2D(textureSource, c + m * vec2(1., -1.));\n v.rgb = mix(vec3(.0), v.rgb, sign(v.a));\n n += mix(.0, 1., sign(v.a));\n vec4 A = texture2D(textureSource, c + m * vec2(-1., 1.));\n A.rgb = mix(vec3(.0), A.rgb, sign(A.a));\n n += mix(.0, 1., sign(A.a));\n return k + l * (n * k - o.rgb - v.rgb - A.rgb - u.rgb);\n}\nvec4 B(const in vec4 k) {\n return vec4(j(k.rgb, sharpFactor), k.a);\n}\nvec3 C(const vec3 x) {\n const float a = 2.51;\n const float b = .03;\n const float D = 2.43;\n const float E = .59;\n const float F = .14;\n return (x * (a * x + b)) / (x * (D * x + E) + F);\n}\nvec3 G(vec3 k) {\n k = k / (k + vec3(1.));\n return k = pow(k, vec3(1. / 2.2));\n}\n#ifdef HAS_OUTLINE_TEX\nvec4 H() {\n float I = 2.;\n float J = 1.;\n float K = pixelRatio / resolution[0] * outlineWidth;\n float L = pixelRatio / resolution[1] * outlineWidth;\n vec4 M = (texture2D(textureOutline, c + vec2(K, L)));\n vec4 N = (texture2D(textureOutline, c + vec2(K, .0)));\n vec4 O = (texture2D(textureOutline, c + vec2(K, -L)));\n vec4 P = (texture2D(textureOutline, c + vec2(.0, -L)));\n vec4 Q = (texture2D(textureOutline, c + vec2(-K, -L)));\n vec4 R = (texture2D(textureOutline, c + vec2(-K, .0)));\n vec4 S = (texture2D(textureOutline, c + vec2(-K, L)));\n vec4 T = (texture2D(textureOutline, c + vec2(.0, L)));\n vec4 U = -I * R + I * N + -J * S + J * M + -J * Q + J * O;\n vec4 V = -I * P + I * T + -J * Q + J * S + -J * O + J * M;\n float W = sqrt(dot(V, V) + dot(U, U));\n bool X = W < 1. / 65025.;\n vec3 Y = (texture2D(textureOutline, c)).r * outlineColor;\n if(Y == vec3(.0) || (highlightFactor == .0 && X)) {\n return vec4(.0);\n }\n float Z = X ? highlightFactor : min(1., sqrt(W) * outlineFactor);\n return Z * vec4(Y, 1.);\n}\nvec4 ba(const in vec4 k) {\n vec4 H = H();\n return H + vec4(k) * (1. - H.a);\n}\n#endif\nvoid main() {\n c = vTexCoord;\n vec4 k;\n if(enableFXAA == 1.) {\n \n } else {\n k = d(vTexCoord);\n }\n if(enableSharpen == 1.) {\n k = B(k);\n }\n#if defined(HAS_NOAA_TEX) || defined(HAS_POINT_TEX)\nvec4 bb = vec4(.0);\n vec4 bc = vec4(.0);\n#ifdef HAS_POINT_TEX\nbb = texture2D(pointTextureSource, vTexCoord);\n#endif\n#ifdef HAS_NOAA_TEX\nbc = texture2D(noAaTextureSource, vTexCoord);\n#endif\nvec4 bd = bb + bc * (1. - bb.a);\n k = bd + k * (1. - bd.a);\n#endif\nif(enableToneMapping == 1.) {\n k.rgb = G(k.rgb);\n }\n#ifdef HAS_OUTLINE_TEX\nk = ba(k);\n#endif\ngl_FragColor = k;\n}";
|
|
14039
14120
|
|
|
14040
|
-
var wgslFrag$
|
|
14121
|
+
var wgslFrag$8 = "struct FxaaUniforms {\n enableFXAA: f32,\n enableToneMapping: f32,\n enableSharpen: f32,\n resolution: vec2f,\n pixelRatio: f32,\n sharpFactor: f32,\n #ifdef HAS_OUTLINE_TEX\n highlightFactor: f32,\n outlineFactor: f32,\n outlineWidth: f32,\n outlineColor: vec3f,\n #endif\n};\n@binding($b) @group(0) var<uniform> uniforms: FxaaUniforms;\n#ifdef HAS_MULTISAMPLED\n@binding($b) @group(0) var textureSource: texture_multisampled_2d<f32>;\n#else\n@binding($b) @group(0) var textureSource: texture_2d<f32>;\n#endif\n@binding($b) @group(0) var textureSourceSampler: sampler;\n#ifdef HAS_OUTLINE_TEX\n#ifdef HAS_MULTISAMPLED\n@binding($b) @group(0) var textureOutline: texture_multisampled_2d<f32>;\n#else\n@binding($b) @group(0) var textureOutline: texture_2d<f32>;\n#endif\n@binding($b) @group(0) var textureOutlineSampler: sampler;\n#endif\nvar<private> gTexCoord: vec2f;\nfn fetchSourceTexel(uv: vec2f) -> vec4f {\n let flipUV = vec2f(uv.x, 1.0 - uv.y);\n#ifdef HAS_MULTISAMPLED\n return textureLoad(textureSource, vec2i(flipUV * vec2f(uniforms.resolution)), 0);\n#else\n return textureSample(textureSource, textureSourceSampler, flipUV);\n#endif\n}\n#ifdef HAS_OUTLINE_TEX\n fn fetchOutlineTexel(uv: vec2f) -> vec4f {\n let flipUV = vec2f(uv.x, 1.0 - uv.y);\n #ifdef HAS_MULTISAMPLED\n return textureLoad(textureOutline, vec2i(flipUV * vec2f(uniforms.resolution)), 0);\n #else\n return textureSample(textureOutline, textureOutlineSampler, flipUV);\n #endif\n }\n#endif\nfn readFXAATexture(uv: vec2f) -> vec4f {\n return fetchSourceTexel(uv);\n}\nfn sharpColorFactor(color: vec3f, sharp: f32) -> vec3f {\n let off = uniforms.pixelRatio / uniforms.resolution;\n var count: f32 = 0.0;\n let rgbNW = fetchSourceTexel(gTexCoord + off * vec2f(-1.0, -1.0));\n let rgbNW_rgb = select(vec3f(0.0), rgbNW.rgb, rgbNW.a > 0.0);\n count += select(0.0, 1.0, rgbNW.a > 0.0);\n let rgbSE = fetchSourceTexel(gTexCoord + off * vec2f(1.0, 1.0));\n let rgbSE_rgb = select(vec3f(0.0), rgbSE.rgb, rgbSE.a > 0.0);\n count += select(0.0, 1.0, rgbSE.a > 0.0);\n let rgbNE = fetchSourceTexel(gTexCoord + off * vec2f(1.0, -1.0));\n let rgbNE_rgb = select(vec3f(0.0), rgbNE.rgb, rgbNE.a > 0.0);\n count += select(0.0, 1.0, rgbNE.a > 0.0);\n let rgbSW = fetchSourceTexel(gTexCoord + off * vec2f(-1.0, 1.0));\n let rgbSW_rgb = select(vec3f(0.0), rgbSW.rgb, rgbSW.a > 0.0);\n count += select(0.0, 1.0, rgbSW.a > 0.0);\n return color + sharp * (count * color - rgbNW_rgb - rgbNE_rgb - rgbSW_rgb - rgbSE_rgb);\n}\nfn sharpen(color: vec4f) -> vec4f {\n return vec4f(sharpColorFactor(color.rgb, uniforms.sharpFactor), color.a);\n}\nfn HDR_ACES(x: vec3f) -> vec3f {\n let a: f32 = 2.51;\n let b: f32 = 0.03;\n let c: f32 = 2.43;\n let d: f32 = 0.59;\n let e: f32 = 0.14;\n return (x * (a * x + b)) / (x * (c * x + d) + e);\n}\nfn tonemap(color: vec3f) -> vec3f {\n var result = color / (color + vec3f(1.0));\n result = pow(result, vec3f(1.0 / 2.2));\n return result;\n}\n#ifdef HAS_OUTLINE_TEX\nfn outline() -> vec4f {\n let offsetx = uniforms.pixelRatio / uniforms.resolution.x * uniforms.outlineWidth;\n let offsety = uniforms.pixelRatio / uniforms.resolution.y * uniforms.outlineWidth;\n let fac0: f32 = 2.0;\n let fac1: f32 = 1.0;\n let texel0 = fetchOutlineTexel(gTexCoord + vec2f(offsetx, offsety));\n let texel1 = fetchOutlineTexel(gTexCoord + vec2f(offsetx, 0.0));\n let texel2 = fetchOutlineTexel(gTexCoord + vec2f(offsetx, -offsety));\n let texel3 = fetchOutlineTexel(gTexCoord + vec2f(0.0, -offsety));\n let texel4 = fetchOutlineTexel(gTexCoord + vec2f(-offsetx, -offsety));\n let texel5 = fetchOutlineTexel(gTexCoord + vec2f(-offsetx, 0.0));\n let texel6 = fetchOutlineTexel(gTexCoord + vec2f(-offsetx, offsety));\n let texel7 = fetchOutlineTexel(gTexCoord + vec2f(0.0, offsety));\n let rowx = -fac0 * texel5 + fac0 * texel1 + -fac1 * texel6 + fac1 * texel0 + -fac1 * texel4 + fac1 * texel2;\n let rowy = -fac0 * texel3 + fac0 * texel7 + -fac1 * texel4 + fac1 * texel6 + -fac1 * texel2 + fac1 * texel0;\n let magSqr = sqrt(dot(rowy, rowy) + dot(rowx, rowx));\n let infMag = magSqr < 1.0 / 65025.0;\n let texelCenter = fetchOutlineTexel(gTexCoord).r * uniforms.outlineColor;\n if (all(texelCenter == vec3f(0.0)) || (uniforms.highlightFactor == 0.0 && infMag)) {\n return vec4f(0.0);\n }\n let finalFactor = select(min(1.0, sqrt(magSqr) * uniforms.outlineFactor), uniforms.highlightFactor, infMag);\n return finalFactor * vec4f(texelCenter, 1.0);\n}\nfn composeOutline(color: vec4f) -> vec4f {\n let outlineColor = outline();\n return outlineColor + color * (1.0 - outlineColor.a);\n}\n#endif\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n gTexCoord = vertexOutput.vTexCoord;\n var color: vec4f;\n if (uniforms.enableFXAA == 1.0) {\n color = readFXAATexture(vertexOutput.vTexCoord);\n } else {\n color = readFXAATexture(vertexOutput.vTexCoord);\n }\n if (uniforms.enableSharpen == 1.0) {\n color = sharpen(color);\n }\n if (uniforms.enableToneMapping == 1.0) {\n color = vec4(tonemap(color.rgb), color.a);\n }\n #ifdef HAS_OUTLINE_TEX\n color = composeOutline(color);\n #endif\n return color;\n}";
|
|
14041
14122
|
|
|
14042
14123
|
class FxaaShader extends QuadShader {
|
|
14043
14124
|
constructor() {
|
|
14044
14125
|
super({
|
|
14045
14126
|
name: 'fxaa',
|
|
14046
|
-
frag: frag$h, wgslFrag: wgslFrag$
|
|
14127
|
+
frag: frag$h, wgslFrag: wgslFrag$8,
|
|
14047
14128
|
extraCommandProps: {
|
|
14048
14129
|
viewport: {
|
|
14049
14130
|
x: 0,
|
|
@@ -14058,15 +14139,6 @@ class FxaaShader extends QuadShader {
|
|
|
14058
14139
|
}
|
|
14059
14140
|
});
|
|
14060
14141
|
}
|
|
14061
|
-
|
|
14062
|
-
getMeshCommand(regl, mesh) {
|
|
14063
|
-
const key = this.dkey || '';
|
|
14064
|
-
const cmdKey = key + '_fxaa';
|
|
14065
|
-
if (!this.commands[cmdKey]) {
|
|
14066
|
-
this.commands[cmdKey] = this.createMeshCommand(regl, mesh);
|
|
14067
|
-
}
|
|
14068
|
-
return this.commands[cmdKey];
|
|
14069
|
-
}
|
|
14070
14142
|
}
|
|
14071
14143
|
|
|
14072
14144
|
var frag$g = "precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D textureSource;\nuniform vec2 resolution;\nuniform float ignoreTransparent;\nvoid main() {\n vec4 c = vec4(.0);\n float d = .0;\n for(int x = -BOXBLUR_OFFSET; x <= BOXBLUR_OFFSET; ++x)\n for(int y = -BOXBLUR_OFFSET; y <= BOXBLUR_OFFSET; ++y) {\n vec2 e = vTexCoord.st + vec2(float(x) / resolution.x, float(y) / resolution.y);\n e = clamp(e, .0, 1.);\n vec4 f = texture2D(textureSource, e);\n float h;\n if(ignoreTransparent == 1.) {\n h = sign(f.a);\n } else {\n h = 1.;\n }\n d += h;\n c += h * f;\n }\n gl_FragColor = c / max(d, 1.) * clamp(sign(d - 1.), .0, 1.);\n}";
|
|
@@ -14075,7 +14147,7 @@ class BoxBlurShader extends QuadShader {
|
|
|
14075
14147
|
|
|
14076
14148
|
constructor({ blurOffset }) {
|
|
14077
14149
|
super({
|
|
14078
|
-
vert: vert$
|
|
14150
|
+
vert: vert$b, frag: frag$g,
|
|
14079
14151
|
defines : {
|
|
14080
14152
|
'BOXBLUR_OFFSET' : blurOffset || 2
|
|
14081
14153
|
},
|
|
@@ -14104,26 +14176,26 @@ class BoxBlurShader extends QuadShader {
|
|
|
14104
14176
|
}
|
|
14105
14177
|
}
|
|
14106
14178
|
|
|
14107
|
-
var vert$
|
|
14179
|
+
var vert$a = "#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}";
|
|
14108
14180
|
|
|
14109
14181
|
var frag$f = "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}";
|
|
14110
14182
|
|
|
14111
|
-
var wgslVert$
|
|
14183
|
+
var wgslVert$3 = "struct Uniforms {\n projViewModelMatrix : mat4x4f\n}\n@group(0) @binding(0) var<uniform> uniforms : Uniforms;\nstruct VertexOutput {\n @builtin(position) Position : vec4f,\n @location(0) vTexCoord : vec2f\n}\n@vertex\nfn main(\n @location(0) aPosition : vec2i,\n @location(1) aTexCoord : vec2u\n) -> VertexOutput {\n var output : VertexOutput;\n output.Position = uniforms.projViewModelMatrix * vec4f(vec2f(aPosition), 0.0, 1.0);\n output.vTexCoord = vec2f(aTexCoord);\n return output;\n}";
|
|
14112
14184
|
|
|
14113
|
-
var wgslFrag$
|
|
14185
|
+
var wgslFrag$7 = "struct Scene {\n opacity : f32,\n baseColor : vec4f,\n alphaTest : f32,\n}\n@group(0) @binding(1) var<uniform> scene: Scene;\n@group(0) @binding(2) var baseColorTextureSampler: sampler;\n@group(0) @binding(3) var baseColorTexture: texture_2d<f32>;\n#if HAS_DEBUG\n @group(0) @binding(4) var debugTextureSampler: sampler;\n @group(0) @binding(5) var debugTexture: texture_2d<f32>;\n#endif\n@fragment\nfn main(\n input : VertexOutput,\n) -> @location(0) vec4f {\n var fragColor = textureSample(baseColorTexture, baseColorTextureSampler, input.vTexCoord);\n fragColor *= scene.baseColor;\n #if HAS_DEBUG\n var debugColor = textureSample(debugTexture, debugTextureSampler, input.vTexCoord);\n fragColor = vec4f(\n debugColor.rgb + fragColor.rgb * (1.0 - debugColor.a),\n debugColor.a + fragColor.a * (1.0 - debugColor.a)\n );\n #endif\n if (fragColor.a < scene.alphaTest) {\n discard;\n }\n return fragColor * scene.opacity;\n}";
|
|
14114
14186
|
|
|
14115
14187
|
class ImageShader extends MeshShader {
|
|
14116
14188
|
constructor(config) {
|
|
14117
14189
|
const projViewModelMatrix = [];
|
|
14118
14190
|
const extraCommandProps = config ? config.extraCommandProps || {} : {};
|
|
14119
|
-
config.vert = vert$
|
|
14191
|
+
config.vert = vert$a;
|
|
14120
14192
|
config.frag = frag$f;
|
|
14121
14193
|
super({
|
|
14122
14194
|
name: 'image',
|
|
14123
|
-
vert: vert$
|
|
14195
|
+
vert: vert$a,
|
|
14124
14196
|
frag: frag$f,
|
|
14125
|
-
wgslVert: wgslVert$
|
|
14126
|
-
wgslFrag: wgslFrag$
|
|
14197
|
+
wgslVert: wgslVert$3,
|
|
14198
|
+
wgslFrag: wgslFrag$7,
|
|
14127
14199
|
uniforms: [
|
|
14128
14200
|
{
|
|
14129
14201
|
name: 'projViewModelMatrix',
|
|
@@ -14153,7 +14225,7 @@ var frag$e = "precision mediump float;\nvarying vec2 vTexCoord;\nuniform vec2 re
|
|
|
14153
14225
|
class PostProcessShader extends QuadShader {
|
|
14154
14226
|
constructor() {
|
|
14155
14227
|
super({
|
|
14156
|
-
vert: vert$
|
|
14228
|
+
vert: vert$b, frag: frag$e,
|
|
14157
14229
|
extraCommandProps: {
|
|
14158
14230
|
viewport: {
|
|
14159
14231
|
x: 0,
|
|
@@ -14583,7 +14655,7 @@ class BlurPass {
|
|
|
14583
14655
|
_initShaders() {
|
|
14584
14656
|
if (!this._blur0Shader) {
|
|
14585
14657
|
const config = {
|
|
14586
|
-
vert: vert$
|
|
14658
|
+
vert: vert$b,
|
|
14587
14659
|
extraCommandProps: {
|
|
14588
14660
|
viewport: {
|
|
14589
14661
|
x: 0,
|
|
@@ -14766,9 +14838,9 @@ class BloomPass {
|
|
|
14766
14838
|
this._blurPass = new BlurPass(this._regl, false);
|
|
14767
14839
|
this._combineShader = new QuadShader({
|
|
14768
14840
|
name: 'bloom-combine',
|
|
14769
|
-
vert: vert$
|
|
14841
|
+
vert: vert$b,
|
|
14770
14842
|
frag: combineFrag,
|
|
14771
|
-
wgslVert: wgslVert$
|
|
14843
|
+
wgslVert: wgslVert$4,
|
|
14772
14844
|
wgslFrag: combineFragWgsl,
|
|
14773
14845
|
extraCommandProps: {
|
|
14774
14846
|
viewport
|
|
@@ -14780,7 +14852,7 @@ class BloomPass {
|
|
|
14780
14852
|
|
|
14781
14853
|
var frag$d = "precision highp float;\n#include <gl2_frag>\n#define SHADER_NAME COPY_DEPTH\nuniform sampler2D TextureDepth;\nuniform vec2 textureSize;\n#include <common_pack_float>\nvoid main(void) {\n vec2 c = gl_FragCoord.xy / textureSize.xy;\n float d = texture2D(TextureDepth, c).r;\n glFragColor = common_encodeDepth(d);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}";
|
|
14782
14854
|
|
|
14783
|
-
var wgslFrag$
|
|
14855
|
+
var wgslFrag$6 = "#define SHADER_NAME COPY_DEPTH\n#include <common_pack_float>\nstruct CopyDepthUniforms {\n textureSize: vec2f,\n};\n@group(0) @binding($b) var<uniform> uniforms: CopyDepthUniforms;\n#ifdef HAS_MULTISAMPLED\n @group(0) @binding($b) var TextureDepth: texture_depth_multisampled_2d;\n#else\n @group(0) @binding($b) var TextureDepth: texture_depth_2d;\n#endif\n@group(0) @binding($b) var TextureDepthSampler: sampler;\n@fragment\nfn main(\n vertexOutput: VertexOutput\n) -> @location(0) vec4f {\n let uv = vertexOutput.vTexCoord;\n #ifdef HAS_MULTISAMPLED\n let depth = textureLoad(TextureDepth, vec2i(uv * uniforms.textureSize), 0);\n #else\n let depth = textureSample(TextureDepth, TextureDepthSampler, uv);\n #endif\n var fragColor = common_encodeDepth(depth);\n return fragColor;\n}";
|
|
14784
14856
|
|
|
14785
14857
|
//DEPRECATED
|
|
14786
14858
|
|
|
@@ -14789,8 +14861,8 @@ class CopyDepthShader extends QuadShader {
|
|
|
14789
14861
|
const size = [];
|
|
14790
14862
|
super({
|
|
14791
14863
|
name: 'copy-depth',
|
|
14792
|
-
vert: vert$
|
|
14793
|
-
wgslVert: wgslVert$
|
|
14864
|
+
vert: vert$b, frag: frag$d,
|
|
14865
|
+
wgslVert: wgslVert$4, wgslFrag: wgslFrag$6,
|
|
14794
14866
|
uniforms: [
|
|
14795
14867
|
{
|
|
14796
14868
|
name: 'textureSize',
|
|
@@ -15075,7 +15147,7 @@ class SsrPass {
|
|
|
15075
15147
|
}
|
|
15076
15148
|
}
|
|
15077
15149
|
|
|
15078
|
-
var vert$
|
|
15150
|
+
var vert$9 = "#define SHADER_NAME HEATMAP\nuniform mat4 projViewModelMatrix;\nuniform float extrudeScale;\nuniform float heatmapIntensity;\nattribute vec3 aPosition;\nvarying vec2 vExtrude;\n#ifdef HAS_HEAT_WEIGHT\nattribute highp float aWeight;\nvarying highp float weight;\n#else\nuniform highp float heatmapWeight;\n#endif\nuniform mediump float heatmapRadius;\nconst highp float c = 1. / 255. / 16.;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n \n#ifdef HAS_HEAT_WEIGHT\nhighp float d = aWeight / 255.;\n weight = d;\n#else\nhighp float d = heatmapWeight;\n#endif\nmediump float e = heatmapRadius;\n vec2 f = vec2(mod(aPosition.xy, 2.) * 2. - 1.);\n float h = sqrt(-2. * log(c / d / heatmapIntensity / GAUSS_COEF)) / 3.;\n vExtrude = h * f;\n vec2 i = vExtrude * e * extrudeScale;\n vec4 j = vec4(floor(aPosition.xy * .5) + i, aPosition.z, 1);\n gl_Position = projViewModelMatrix * j;\n}";
|
|
15079
15151
|
|
|
15080
15152
|
var frag$c = "#define SHADER_NAME HEATMAP\nprecision mediump float;\nuniform highp float heatmapIntensity;\nvarying vec2 vExtrude;\n#ifdef HAS_HEAT_WEIGHT\nvarying highp float weight;\n#else\nuniform highp float heatmapWeight;\n#endif\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n \n#ifdef HAS_HEAT_WEIGHT\nhighp float c = weight;\n#else\nhighp float c = heatmapWeight;\n#endif\nfloat d = -.5 * 3. * 3. * dot(vExtrude, vExtrude);\n float e = c * heatmapIntensity * GAUSS_COEF * exp(d);\n gl_FragColor = vec4(e, 1., 1., 1.);\n}";
|
|
15081
15153
|
|
|
@@ -15084,7 +15156,7 @@ class HeatmapShader extends MeshShader {
|
|
|
15084
15156
|
const extraCommandProps = config ? config.extraCommandProps || {} : {};
|
|
15085
15157
|
const projViewModelMatrix = [];
|
|
15086
15158
|
super({
|
|
15087
|
-
vert: vert$
|
|
15159
|
+
vert: vert$9, frag: frag$c,
|
|
15088
15160
|
uniforms: [
|
|
15089
15161
|
{
|
|
15090
15162
|
name: 'extrudeScale',
|
|
@@ -15162,15 +15234,22 @@ var skyboxData = {
|
|
|
15162
15234
|
]
|
|
15163
15235
|
};
|
|
15164
15236
|
|
|
15165
|
-
var vert$
|
|
15237
|
+
var vert$8 = "#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}";
|
|
15166
15238
|
|
|
15167
15239
|
var skyboxRawFrag = "#define SHADER_NAME SKYBOX\n#if __VERSION__ == 100\n#ifdef 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#else\n#define textureCubeLod(tex, uv, lod) textureLod(tex, uv, lod)\n#endif\nprecision highp float;\n#define saturate(x) clamp(x, 0.0, 1.0)\n#include <gl2_frag>\n#include <hsv_frag>\nuniform vec3 hsv;\nvarying vec3 vWorldPos;\n#ifdef USE_AMBIENT\nuniform vec3 diffuseSPH[9];\n#else\nuniform samplerCube cubeMap;\nuniform float bias;\nuniform float size;\n#endif\nuniform float environmentExposure;\nuniform float backgroundIntensity;\nvec4 c(const in samplerCube d, const in vec3 e, const in float f, const in float h) {\n vec3 i = e;\n return textureCubeLod(d, i, h);\n}\nvec3 j(const in vec3 k, const in vec3 l[9]) {\n float x = k.x;\n float y = k.y;\n float z = k.z;\n vec3 m = (l[0] + l[1] * x + l[2] * y + l[3] * z + l[4] * z * x + l[5] * y * z + l[6] * y * x + l[7] * (3. * z * z - 1.) + l[8] * (x * x - y * y));\n return max(m, vec3(.0));\n}\nfloat n(const in vec2 o) {\n vec3 u = fract(vec3(o.xyx) * .1031);\n u += dot(u, u.yzx + 19.19);\n return fract((u.x + u.y) * u.z);\n}\n#if defined(TONE_MAPPING)\nconst float v = 1.;\nvec3 A(vec3 B) {\n vec3 a = B * (B + .0245786) - .000090537;\n vec3 b = B * (.983729 * B + .4329510) + .238081;\n return a / b;\n}\nvec3 C(vec3 D) {\n const mat3 E = mat3(vec3(.59719, .07600, .02840), vec3(.35458, .90834, .13383), vec3(.04823, .01566, .83777));\n const mat3 F = mat3(vec3(1.60475, -.10208, -.00327), vec3(-.53108, 1.10813, -.07276), vec3(-.07367, -.00605, 1.07602));\n D *= v / .6;\n D = E * D;\n D = A(D);\n D = F * D;\n return saturate(D);\n}\nvec3 G(vec3 D) {\n return C(D);\n}\nvec4 H(in vec4 I) {\n return vec4(mix(pow(I.rgb, vec3(.41666)) * 1.055 - vec3(.055), I.rgb * 12.92, vec3(lessThanEqual(I.rgb, vec3(.0031308)))), I.a);\n}\nvec4 J(vec4 I) {\n return (H(I));\n}\n#endif\nvoid main() {\n vec4 K;\n#ifdef USE_AMBIENT\nvec3 k = normalize(vWorldPos + mix(-.5 / 255., .5 / 255., n(gl_FragCoord.xy)) * 2.);\n K = vec4(j(k, diffuseSPH), 1.);\n#else\nK = c(cubeMap, vWorldPos, size, bias);\n#endif\nK.rgb *= environmentExposure;\n K.rgb *= backgroundIntensity;\n glFragColor = K;\n if(length(hsv) > .0) {\n glFragColor.rgb = hsv_apply(clamp(glFragColor.rgb, .0, 1.), hsv);\n }\n#if defined(TONE_MAPPING)\nglFragColor.rgb = G(glFragColor.rgb);\n glFragColor = J(glFragColor);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}";
|
|
15168
15240
|
|
|
15241
|
+
var wgslVert$2 = "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}";
|
|
15242
|
+
|
|
15243
|
+
var wgslFrag$5 = "#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}";
|
|
15244
|
+
|
|
15169
15245
|
class SkyboxShader extends MeshShader {
|
|
15170
15246
|
constructor() {
|
|
15171
15247
|
const config = {
|
|
15172
|
-
|
|
15248
|
+
name: 'skybox',
|
|
15249
|
+
vert: vert$8,
|
|
15173
15250
|
frag: skyboxRawFrag,
|
|
15251
|
+
wgslVert: wgslVert$2,
|
|
15252
|
+
wgslFrag: wgslFrag$5,
|
|
15174
15253
|
extraCommandProps: {
|
|
15175
15254
|
depth: {
|
|
15176
15255
|
enable : true,
|
|
@@ -15180,8 +15259,8 @@ class SkyboxShader extends MeshShader {
|
|
|
15180
15259
|
viewport: {
|
|
15181
15260
|
x: 0,
|
|
15182
15261
|
y: 0,
|
|
15183
|
-
width: (
|
|
15184
|
-
height: (
|
|
15262
|
+
width: (_, props) => { return props.resolution[0]; },
|
|
15263
|
+
height: (_, props) => { return props.resolution[1]; },
|
|
15185
15264
|
}
|
|
15186
15265
|
}
|
|
15187
15266
|
};
|
|
@@ -15219,7 +15298,7 @@ class SkyboxShader extends MeshShader {
|
|
|
15219
15298
|
_createSkyboxMesh(regl) {
|
|
15220
15299
|
const geometry = new Geometry(
|
|
15221
15300
|
{
|
|
15222
|
-
aPosition: new
|
|
15301
|
+
aPosition: new Float32Array(skyboxData.vertices)
|
|
15223
15302
|
},
|
|
15224
15303
|
null,
|
|
15225
15304
|
skyboxData.vertices.length / 3
|
|
@@ -15243,7 +15322,7 @@ class SkyboxShader extends MeshShader {
|
|
|
15243
15322
|
}
|
|
15244
15323
|
}
|
|
15245
15324
|
|
|
15246
|
-
var vert$
|
|
15325
|
+
var vert$7 = "#define SHADER_NAME HEATMAP_DISPLAY\nuniform mat4 projViewModelMatrix;\nattribute vec3 aPosition;\nvoid main() {\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.);\n}";
|
|
15247
15326
|
|
|
15248
15327
|
var frag$b = "#define SHADER_NAME HEATMAP_DISPLAY\nprecision mediump float;\nuniform sampler2D inputTexture;\nuniform sampler2D colorRamp;\nuniform vec2 textureOutputSize;\nuniform float heatmapOpacity;\nvoid main() {\n vec2 c = gl_FragCoord.xy / textureOutputSize.xy;\n float t = texture2D(inputTexture, c).r;\n vec4 d = texture2D(colorRamp, vec2(t, .5));\n gl_FragColor = d * heatmapOpacity;\n}";
|
|
15249
15328
|
|
|
@@ -15265,7 +15344,7 @@ class HeatmapDisplayShader extends MeshShader {
|
|
|
15265
15344
|
}
|
|
15266
15345
|
const projViewModelMatrix = [];
|
|
15267
15346
|
super({
|
|
15268
|
-
vert: vert$
|
|
15347
|
+
vert: vert$7, frag: frag$b,
|
|
15269
15348
|
uniforms: [
|
|
15270
15349
|
{
|
|
15271
15350
|
name: 'projViewModelMatrix',
|
|
@@ -15297,13 +15376,13 @@ class WaterShader extends MeshShader {
|
|
|
15297
15376
|
|
|
15298
15377
|
var frag$a = "precision highp float;\nuniform sampler2D texture;\nuniform vec2 size;\nuniform float enableSharpen;\nuniform float sharpFactor;\nuniform float pixelRatio;\nvec2 c;\nvec3 d(const in vec3 e, const float f) {\n vec2 h = pixelRatio / size.xy;\n float i = .0;\n vec4 j = texture2D(texture, c + h * vec2(-1., -1.));\n j.rgb = mix(vec3(.0), j.rgb, sign(j.a));\n i += mix(.0, 1., sign(j.a));\n vec4 k = texture2D(texture, c + h * vec2(1.));\n k.rgb = mix(vec3(.0), k.rgb, sign(k.a));\n i += mix(.0, 1., sign(k.a));\n vec4 l = texture2D(texture, c + h * vec2(1., -1.));\n l.rgb = mix(vec3(.0), l.rgb, sign(l.a));\n i += mix(.0, 1., sign(l.a));\n vec4 m = texture2D(texture, c + h * vec2(-1., 1.));\n m.rgb = mix(vec3(.0), m.rgb, sign(m.a));\n i += mix(.0, 1., sign(m.a));\n return e + f * (i * e - j.rgb - l.rgb - m.rgb - k.rgb);\n}\nvoid main() {\n c = gl_FragCoord.xy / size;\n vec4 e = texture2D(texture, c);\n if(enableSharpen == 1.) {\n e.rgb = d(e.rgb, sharpFactor);\n }\n gl_FragColor = e;\n}";
|
|
15299
15378
|
|
|
15300
|
-
var wgslFrag$
|
|
15379
|
+
var wgslFrag$4 = "struct SharpenUniforms {\n size: vec2f,\n enableSharpen: f32,\n sharpFactor: f32,\n pixelRatio: f32,\n};\n@group(0) @binding($b) var<uniform> uniforms: SharpenUniforms;\n#ifdef HAS_MULTISAMPLED\n@binding($b) @group(0) var texture: texture_multisampled_2d<f32>;\n#else\n@binding($b) @group(0) var texture: texture_2d<f32>;\n#endif\n@group(0) @binding($b) var textureSampler: sampler;\nvar<private> gTexCoord: vec2f;\nfn fetchSourceTexel(uv: vec2f) -> vec4f {\n#ifdef HAS_MULTISAMPLED\n return textureLoad(texture, vec2i(uv * vec2f(uniforms.size)), 0);\n#else\n return textureSample(texture, textureSampler, uv);\n#endif\n}\nfn sharpColorFactor(color: vec3f, sharp: f32) -> vec3f {\n let off = uniforms.pixelRatio / uniforms.size;\n var count: f32 = 0.0;\n var rgbNW = fetchSourceTexel(gTexCoord + off * vec2f(-1.0, -1.0));\n rgbNW = vec4f(select(vec3f(0.0), rgbNW.rgb, rgbNW.a > 0.0), rgbNW.a);\n count += select(0.0, 1.0, rgbNW.a > 0.0);\n var rgbSE = fetchSourceTexel(gTexCoord + off * vec2f(1.0, 1.0));\n rgbSE = vec4f(select(vec3f(0.0), rgbSE.rgb, rgbSE.a > 0.0), rgbSE.a);\n count += select(0.0, 1.0, rgbSE.a > 0.0);\n var rgbNE = fetchSourceTexel(gTexCoord + off * vec2f(1.0, -1.0));\n rgbNE = vec4f(select(vec3f(0.0), rgbNE.rgb, rgbNE.a > 0.0), rgbNE.a);\n count += select(0.0, 1.0, rgbNE.a > 0.0);\n var rgbSW = fetchSourceTexel(gTexCoord + off * vec2f(-1.0, 1.0));\n rgbSW = vec4f(select(vec3f(0.0), rgbSW.rgb, rgbSW.a > 0.0), rgbSW.a);\n count += select(0.0, 1.0, rgbSW.a > 0.0);\n return color + sharp * (count * color - rgbNW.rgb - rgbNE.rgb - rgbSW.rgb - rgbSE.rgb);\n}\n@fragment\nfn main(\n input : VertexOutput,\n) -> @location(0) vec4f {\n gTexCoord = input.position.xy / uniforms.size;\n var color = fetchSourceTexel(gTexCoord);\n if (uniforms.enableSharpen == 1.0) {\n color = vec4f(sharpColorFactor(color.rgb, uniforms.sharpFactor), color.a);\n }\n return color;\n}";
|
|
15301
15380
|
|
|
15302
15381
|
class CopyShader extends QuadShader {
|
|
15303
15382
|
constructor() {
|
|
15304
15383
|
super({
|
|
15305
15384
|
name: 'copy',
|
|
15306
|
-
wgslFrag: wgslFrag$
|
|
15385
|
+
wgslFrag: wgslFrag$4,
|
|
15307
15386
|
frag: frag$a,
|
|
15308
15387
|
extraCommandProps: {
|
|
15309
15388
|
viewport: {
|
|
@@ -15332,7 +15411,7 @@ class CopyShader extends QuadShader {
|
|
|
15332
15411
|
|
|
15333
15412
|
var frag$9 = "precision mediump float;\nuniform vec4 lineColor;\nuniform float lineOpacity;\nvoid main() {\n gl_FragColor = lineColor;\n gl_FragColor.a *= lineOpacity;\n}";
|
|
15334
15413
|
|
|
15335
|
-
var vert$
|
|
15414
|
+
var vert$6 = "attribute vec3 aPosition;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 modelViewMatrix;\n#include <get_output>\nvoid main() {\n vec4 c = getPosition(aPosition);\n mat4 d = getPositionMatrix();\n gl_Position = projMatrix * modelViewMatrix * d * c;\n}";
|
|
15336
15415
|
|
|
15337
15416
|
class EdgeShader extends MeshShader {
|
|
15338
15417
|
constructor(config = {}) {
|
|
@@ -15351,7 +15430,7 @@ class EdgeShader extends MeshShader {
|
|
|
15351
15430
|
uniforms.push(...extraUniforms);
|
|
15352
15431
|
}
|
|
15353
15432
|
super({
|
|
15354
|
-
vert: vert$
|
|
15433
|
+
vert: vert$6,
|
|
15355
15434
|
frag: frag$9,
|
|
15356
15435
|
uniforms,
|
|
15357
15436
|
defines: config.defines || {},
|
|
@@ -15362,7 +15441,7 @@ class EdgeShader extends MeshShader {
|
|
|
15362
15441
|
|
|
15363
15442
|
var frag$8 = "#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>\nuniform vec3 hsv;\n#define GET_BASEMAP(UV) (texture2D(baseColorTexture, (UV)))\nuniform mat4 viewMatrix;\nuniform mat4 projMatrix;\nuniform vec3 cameraPosition;\n#if defined(HAS_IBL_LIGHTING)\nuniform mat4 viewMatrixInverse;\n#endif\nuniform vec4 baseColorFactor;\nuniform vec3 emissiveFactor;\nuniform vec3 specularFactor;\nuniform float opacity;\nuniform float envRotationSin;\nuniform float envRotationCos;\nuniform float rgbmRange;\n#if defined(HAS_MAP)\n#include <compute_texcoord_frag>\n#endif\n#ifdef HAS_BASECOLOR_MAP\nuniform sampler2D baseColorTexture;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D normalTexture;\nvec3 c(vec3 d, vec3 e) {\n vec3 f = dFdx(d.xyz);\n vec3 h = dFdy(d.xyz);\n vec3 i = normalize(f - h);\n vec3 j = normalize(-f + h);\n vec3 k = normalize(e);\n vec3 l = texture2D(normalTexture, computeTexCoord(vTexCoord)).rgb * 2. - 1.;\n mat3 m = mat3(i, j, k);\n return normalize(m * l);\n}\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D emissiveTexture;\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\nuniform vec4 diffuseFactor;\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D diffuseTexture;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_MAP\nuniform sampler2D specularGlossinessTexture;\n#endif\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nvarying vec4 vColor;\n#endif\n#ifdef GAMMA_INPUT\nvec3 n(vec3 o) {\n return o * o;\n}\nfloat n(float o) {\n return o * o;\n}\n#else\nvec3 n(vec3 o) {\n return o;\n}\nfloat n(float o) {\n return o;\n}\n#endif\nvec3 u() {\n \n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n#ifdef HAS_SPECULARGLOSSINESS_MAP\nreturn texture2D(specularGlossinessTexture, computeTexCoord(vTexCoord)).rgb;\n#else\nreturn specularFactor;\n#endif\n#else\nreturn specularFactor;\n#endif\n}\nvec3 v() {\n \n#ifdef HAS_EMISSIVE_MAP\nreturn texture2D(emissiveTexture, computeTexCoord(vTexCoord)).rgb;\n#else\nreturn emissiveFactor;\n#endif\n}\n#if defined(TONEMAP_OUTPUT)\n#if TONEMAP_OUTPUT > 0\nuniform float exposureBias;\nfloat A(vec3 rgb) {\n return dot(rgb, vec3(.299, .587, .114));\n}\nfloat B(vec3 rgb) {\n return dot(rgb, vec3(.212671, .715160, .072169));\n}\nvec3 C(vec3 xyz) {\n vec3 D = vec3(3.240479, -1.53715, -.498535);\n vec3 E = vec3(-.969256, 1.875992, .041556);\n vec3 F = vec3(.055648, -.204043, 1.057311);\n vec3 rgb;\n rgb.b = dot(xyz, F);\n rgb.g = dot(xyz, E);\n rgb.r = dot(xyz, D);\n return rgb;\n}\nvec3 H(vec3 rgb) {\n vec3 I = vec3(.412453, .35758, .180423);\n vec3 J = vec3(.212671, .71516, .0721688);\n vec3 K = vec3(.0193338, .119194, .950227);\n vec3 xyz;\n xyz.x = dot(rgb, I);\n xyz.y = dot(rgb, J);\n xyz.z = dot(rgb, K);\n return xyz;\n}\nvec3 L(vec3 xyz) {\n float M = xyz.x + xyz.y + xyz.z;\n M = 1. / M;\n vec3 O;\n O.z = xyz.y;\n O.x = xyz.x * M;\n O.y = xyz.y * M;\n return O;\n}\nvec3 P(vec3 O) {\n float x = O.x;\n float y = O.y;\n float J = O.z;\n vec3 xyz;\n xyz.y = J;\n xyz.x = x * (J / y);\n xyz.z = (1. - x - y) * (J / y);\n return xyz;\n}\nfloat Q(float x) {\n float U = pow(x, 1.60525727);\n float V = ((1.05542877 * 4.68037409) * U) / (4.68037409 * U + 1.);\n return clamp(V, .0, 1.);\n}\nconst float W = 1. / .18;\nfloat ba(float x) {\n x *= W;\n const float bb = .2;\n const float F = .34;\n const float bc = .002;\n const float bd = 1.68;\n const float be = .0005;\n const float bf = .252;\n const float bg = 1. / .833837;\n return ((x * (bb * x + bc * F) + bd * be) / (x * (bb * x + F) + bd * bf) - be / bf) * bg;\n}\nvec3 bh(vec3 x) {\n x *= W;\n const float bb = .27;\n const float F = .29;\n const float bc = .052;\n const float bd = .2;\n const float bf = .18;\n const float bg = 1. / .897105;\n return ((x * (bb * x + bc * F)) / (x * (bb * x + F) + bd * bf)) * bg;\n}\nvec3 bi(vec3 x) {\n vec3 bj = x.rgb;\n bj = min(bj, vec3(3.));\n float bk = B(bj);\n if(bk > .0) {\n float bl = Q(bk);\n bj = bj * (bl / bk);\n bj = clamp(bj, vec3(.0), vec3(1.));\n }\n float bm = 1. / 2.2;\n bj = pow(bj, vec3(bm));\n return bj;\n}\n#endif\n#endif\n#if defined(IRR_RGBM) || defined(ENV_RGBM) || defined(ENV_GAMMA) || defined(IRR_GAMMA)\nuniform float envMapExposure;\n#endif\nuniform vec4 themingColor;\nuniform mat3 environmentTransform;\nvec3 bn(vec3 bo, vec3 bp) {\n \n#if defined(HAS_SHADOWMAP)\nfloat bq = dot(shadowLightDir, bp);\n float br = (bq + 1.) / 2.;\n br = min(1., br * 1.5);\n float bs = 1.;\n vec3 bt = bo * min(bs, br);\n return bt;\n#else\nreturn bo;\n#endif\n}\n#ifdef HAS_IBL_LIGHTING\nuniform float reflectivity;\nuniform vec3 hdrHSV;\nuniform samplerCube prefilterMap;\nuniform vec3 diffuseSPH[9];\nuniform vec2 prefilterMiplevel;\nuniform vec2 prefilterSize;\n#else\nuniform vec3 ambientColor;\n#endif\n#if defined(HAS_IBL_LIGHTING)\nvec3 bu(const in vec3 bv) {\n vec3 bw = environmentTransform * bv;\n float x = bw.x;\n float y = bw.y;\n float z = bw.z;\n vec3 bt = (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 bt = hsv_apply(bt, hdrHSV);\n }\n return max(bt, vec3(.0));\n}\nvec3 bx(const in vec4 by, const in float bz) {\n if(bz <= .0)\n return by.rgb;\n return bz * by.rgb * by.a;\n}\nfloat bA(const in float bB) {\n return bB;\n}\nvec3 bC(const in float bD, const in vec3 D) {\n vec3 bE = D;\n float bF = prefilterMiplevel.x;\n float bG = min(bF, bA(bD) * prefilterMiplevel.y);\n vec3 bH = bx(textureCubeLod(prefilterMap, bE, bG), rgbmRange);\n if(length(hdrHSV) > .0) {\n return hsv_apply(bH, hdrHSV);\n } else {\n return bH;\n }\n}\nvec3 bI(const in vec3 k, const in vec3 D, const in float bJ) {\n float bK = 1. - bJ;\n float bL = bK * (sqrt(bK) + bJ);\n return mix(k, D, bL);\n}\nvec3 bM(const in vec3 bv, const in vec3 bN, const in float bO, const in vec3 bP) {\n vec3 D = reflect(-bN, bv);\n D = bI(bv, D, bO);\n vec3 bQ = bC(bO, environmentTransform * D);\n float bR = clamp(1. + dot(D, bP), .0, 1.);\n bQ *= bR * bR;\n return bQ;\n}\n#else\nvec3 bM(const in vec3 bv, const in vec3 bN, const in float bO, const in vec3 bP) {\n return ambientColor;\n}\n#endif\nvarying highp vec3 vViewPosition;\nvec3 bS(vec3 bT, float bU) {\n float bV = max(1. - bU, .0);\n return bT + (1. - bT) * pow(bV, 5.);\n}\nfloat bW(float bT, float bU) {\n float bV = max(1. - bU, .0);\n return bT + (1. - bT) * pow(bV, 5.);\n}\n#include <srgb_frag>\nvoid main() {\n glFragColor = vec4(vec3(1.), opacity);\n#ifdef HAS_BASECOLOR_MAP\nvec4 bX = GET_BASEMAP(computeTexCoord(vTexCoord));\n#ifdef GAMMA_INPUT\nbX.xyz *= bX.xyz;\n#endif\nglFragColor = glFragColor * bX;\n#endif\n#ifdef ALPHATEST\nif(glFragColor.a < ALPHATEST)\n discard;\n \n#endif\nfloat bY = 1.;\n vec3 bZ = dFdx(vViewPosition);\n vec3 ca = dFdy(vViewPosition);\n vec3 bv = normalize(cross(bZ, ca));\n vec3 cb;\n if(projMatrix[3][3] == .0) {\n cb = normalize(vViewPosition);\n } else {\n cb = vec3(.0, .0, 1.);\n }\n bv = faceforward(bv, -cb, bv);\n vec3 cc = bv;\n#ifdef HAS_NORMAL_MAP\nbv = c(-vViewPosition, bv);\n#endif\nvec3 cd = vec3(.0);\n vec3 ce = vec3(.0);\n#ifdef HAS_IBL_LIGHTING\nvec3 bp = mat3(viewMatrixInverse) * bv;\n vec3 cf = glFragColor.rgb * bu(bp) * .5;\n cf = bn(cf, bp);\n cd += n(baseColorFactor.rgb) * cf;\n#endif\nvec3 cg = v();\n#ifdef METAL\nglFragColor.xyz = glFragColor.xyz * (n(cg) + cd + n(baseColorFactor.rgb) + ce);\n#else\nglFragColor.xyz = glFragColor.xyz * (n(cg) + cd + n(baseColorFactor.rgb)) + ce;\n#endif\nvec3 ch;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat ci = shadow_computeShadow();\n ch = shadow_blend(ch, ci).rgb;\n#endif\n#ifdef HAS_COLOR\nglFragColor = glFragColor * vColor;\n#endif\nglFragColor.rgb += ch;\n glFragColor.rgb = linearTosRGB(glFragColor.rgb);\n#if defined(HAS_IBL_LIGHTING)\nvec3 cj;\n#if defined(HAS_NORMAL_MAP)\n#ifdef ENVMAP_MODE_REFLECTION\ncj = reflect(-cb, bv);\n#else\ncj = refract(-cb, bv, 1.);\n#endif\n#else\ncj = reflect(-cb, bv);\n#endif\ncj = mat3(viewMatrixInverse) * cj;\n float ck = 1.;\n vec3 cl;\n#ifdef HAS_IBL_LIGHTING\ncl = vec3(.0);\n#elif\ncl = ambientColor;\n#endif\ncl *= ck;\n float bV = dot(cb, bv);\n if(bV < -1e-2 || reflectivity == .0)\n bV = 1.;\n else\n bV = max(1e-6, bV);\n vec3 cm;\n vec3 cn = u();\n#ifdef METAL\ncm = n(cn);\n#else\ncm = bS(n(cn), bV) * (1. - envRotationSin);\n glFragColor.a = mix(glFragColor.a, bW(glFragColor.a, bV), reflectivity) * envRotationCos;\n float co = pow(1. - bV * .5, 5.);\n float cp = (28. / 23.) * (1. - co) * (1. - co);\n glFragColor.rgb *= cp * (1. - n(cn));\n#endif\nglFragColor.rgb += cl.rgb * bY * cm.rgb;\n#endif\n#if defined(TONEMAP_OUTPUT)\n#if TONEMAP_OUTPUT == 1\nglFragColor.rgb = bi(exposureBias * glFragColor.rgb);\n#elif TONEMAP_OUTPUT == 2\nglFragColor.rgb = bh(exposureBias * glFragColor.rgb);\n#endif\n#endif\nglFragColor.rgb = mix(glFragColor.rgb, themingColor.rgb, themingColor.a);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}";
|
|
15364
15443
|
|
|
15365
|
-
var vert$
|
|
15444
|
+
var vert$5 = "precision mediump float;\n#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#endif\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\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\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 <get_output>\n#include <heatmap_render_vert>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\n \n#ifdef IS_LINE_EXTRUSION\nvec4 c = getPosition(getLineExtrudePosition(aPosition));\n#else\nvec4 c = getPosition(aPosition);\n#endif\nmat4 d = getPositionMatrix();\n mat4 e = projMatrix;\n e[2].xy += halton.xy / outSize.xy;\n#ifdef HAS_MASK_EXTENT\ngl_Position = e * getMaskPosition(d * c, modelMatrix);\n#else\ngl_Position = e * modelViewMatrix * d * c;\n#endif\nvec4 f = modelViewMatrix * d * c;\n vViewPosition = -f.xyz;\n#ifdef HAS_MAP\nvec2 h = decode_getTexcoord(aTexCoord);\n vTexCoord = h * uvScale + uvOffset;\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}";
|
|
15366
15445
|
|
|
15367
15446
|
const TEMP_MAT4$1 = [];
|
|
15368
15447
|
const environmentTransform = [];
|
|
@@ -15398,7 +15477,7 @@ class StandardLiteShader extends MeshShader {
|
|
|
15398
15477
|
uniforms.push(...extraUniforms);
|
|
15399
15478
|
}
|
|
15400
15479
|
super({
|
|
15401
|
-
vert: vert$
|
|
15480
|
+
vert: vert$5,
|
|
15402
15481
|
frag: frag$8,
|
|
15403
15482
|
uniforms,
|
|
15404
15483
|
defines: config.defines || {},
|
|
@@ -15413,7 +15492,7 @@ var frag$7 = "#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#exten
|
|
|
15413
15492
|
class EffectShader extends QuadShader {
|
|
15414
15493
|
constructor() {
|
|
15415
15494
|
super({
|
|
15416
|
-
vert: vert$
|
|
15495
|
+
vert: vert$b, frag: frag$7,
|
|
15417
15496
|
extraCommandProps: {
|
|
15418
15497
|
viewport: {
|
|
15419
15498
|
x: 0,
|
|
@@ -15515,7 +15594,7 @@ var frag$6 = "#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#exten
|
|
|
15515
15594
|
class FogShader extends QuadShader {
|
|
15516
15595
|
constructor() {
|
|
15517
15596
|
super({
|
|
15518
|
-
vert: vert$
|
|
15597
|
+
vert: vert$b, frag: frag$6,
|
|
15519
15598
|
extraCommandProps: {
|
|
15520
15599
|
viewport: {
|
|
15521
15600
|
x: 0,
|
|
@@ -15692,7 +15771,7 @@ class RainRipplePass {
|
|
|
15692
15771
|
}
|
|
15693
15772
|
}
|
|
15694
15773
|
|
|
15695
|
-
var vert$
|
|
15774
|
+
var vert$4 = "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}";
|
|
15696
15775
|
|
|
15697
15776
|
var maskColorExtent = "#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}";
|
|
15698
15777
|
|
|
@@ -15738,7 +15817,7 @@ class ExtentPass {
|
|
|
15738
15817
|
}
|
|
15739
15818
|
];
|
|
15740
15819
|
this._maskColorShader = new MeshShader({
|
|
15741
|
-
vert: vert$
|
|
15820
|
+
vert: vert$4,
|
|
15742
15821
|
frag: maskColorExtent,
|
|
15743
15822
|
uniforms,
|
|
15744
15823
|
extraCommandProps: {
|
|
@@ -15750,7 +15829,7 @@ class ExtentPass {
|
|
|
15750
15829
|
}
|
|
15751
15830
|
});
|
|
15752
15831
|
this._maskModeShader = new MeshShader({
|
|
15753
|
-
vert: vert$
|
|
15832
|
+
vert: vert$4,
|
|
15754
15833
|
frag: maskModeExtent,
|
|
15755
15834
|
uniforms,
|
|
15756
15835
|
extraCommandProps: {
|
|
@@ -15822,7 +15901,7 @@ class ExtentPass {
|
|
|
15822
15901
|
|
|
15823
15902
|
// import vert from './scaneffect.vert';
|
|
15824
15903
|
// import frag from './scaneffect.frag';
|
|
15825
|
-
const vert$
|
|
15904
|
+
const vert$3 = `#include <gl2_vert>
|
|
15826
15905
|
#define SHADER_NAME SCANEFFECT
|
|
15827
15906
|
precision highp float;
|
|
15828
15907
|
attribute vec3 aPosition;
|
|
@@ -15935,7 +16014,7 @@ class ScanEffectPass {
|
|
|
15935
16014
|
}
|
|
15936
16015
|
const fragStr = this._createFragSource(effectInfos);
|
|
15937
16016
|
this._shader = new MeshShader({
|
|
15938
|
-
vert: vert$
|
|
16017
|
+
vert: vert$3,
|
|
15939
16018
|
frag: fragStr,
|
|
15940
16019
|
uniforms: [
|
|
15941
16020
|
{
|
|
@@ -17264,7 +17343,13 @@ const renderToCube = function () {
|
|
|
17264
17343
|
const aspect = 1;
|
|
17265
17344
|
const near = 0.5;
|
|
17266
17345
|
const far = 1.1;
|
|
17267
|
-
const
|
|
17346
|
+
const isWebGPU = !!regl.wgpu;
|
|
17347
|
+
let projMatrix;
|
|
17348
|
+
if (isWebGPU) {
|
|
17349
|
+
projMatrix = mat4.perspectiveZO(pmat, fov, aspect, near, far);
|
|
17350
|
+
} else {
|
|
17351
|
+
projMatrix = mat4.perspective(pmat, fov, aspect, near, far);
|
|
17352
|
+
}
|
|
17268
17353
|
|
|
17269
17354
|
const config = {
|
|
17270
17355
|
context : {
|
|
@@ -18184,13 +18269,13 @@ class StandardMaterial extends Material {
|
|
|
18184
18269
|
class StandardSpecularGlossinessMaterial extends SpecularGlossinessMixin(StandardMaterial) {
|
|
18185
18270
|
}
|
|
18186
18271
|
|
|
18187
|
-
var vert$
|
|
18272
|
+
var vert$2 = "#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}";
|
|
18188
18273
|
|
|
18189
18274
|
var frag$4 = "#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}";
|
|
18190
18275
|
|
|
18191
|
-
var wgslVert$1 = "#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(
|
|
18276
|
+
var wgslVert$1 = "#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}";
|
|
18192
18277
|
|
|
18193
|
-
var wgslFrag$2 = "#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}";
|
|
18278
|
+
var wgslFrag$3 = "#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}";
|
|
18194
18279
|
|
|
18195
18280
|
//http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/
|
|
18196
18281
|
class StandardShader extends MeshShader {
|
|
@@ -18280,10 +18365,10 @@ class StandardShader extends MeshShader {
|
|
|
18280
18365
|
if (extraUniforms) {
|
|
18281
18366
|
uniforms.push(...extraUniforms);
|
|
18282
18367
|
}
|
|
18283
|
-
const vertSource = config.vert || vert$
|
|
18368
|
+
const vertSource = config.vert || vert$2;
|
|
18284
18369
|
const fragSource = config.frag || frag$4;
|
|
18285
18370
|
const wgslVertSource = config.wgslVert || wgslVert$1;
|
|
18286
|
-
const wgslFragSource = config.wgslFrag || wgslFrag$
|
|
18371
|
+
const wgslFragSource = config.wgslFrag || wgslFrag$3;
|
|
18287
18372
|
const shaderConfig = {
|
|
18288
18373
|
vert: vertSource,
|
|
18289
18374
|
frag: fragSource,
|
|
@@ -18316,7 +18401,7 @@ class StandardShader extends MeshShader {
|
|
|
18316
18401
|
}
|
|
18317
18402
|
}
|
|
18318
18403
|
|
|
18319
|
-
var vert$
|
|
18404
|
+
var vert$1 = "#define SHADER_NAME depth_vert\nattribute vec3 aPosition;\n#include <line_extrusion_vert>\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\nuniform vec2 outSize;\nuniform vec2 halton;\n#include <get_output>\nvoid main() {\n mat4 c = getPositionMatrix();\n#ifdef IS_LINE_EXTRUSION\nvec4 d = getPosition(getLineExtrudePosition(aPosition));\n#else\nvec4 d = getPosition(aPosition);\n#endif\nvec4 e = modelViewMatrix * c * d;\n mat4 f = projMatrix;\n f[2].xy += halton.xy / outSize.xy;\n gl_Position = f * e;\n}";
|
|
18320
18405
|
|
|
18321
18406
|
var frag$3 = "#define SHADER_NAME depth_frag\nprecision highp float;\nvoid main() {\n gl_FragColor = vec4(1., .0, .0, 1.);\n}";
|
|
18322
18407
|
|
|
@@ -18336,7 +18421,7 @@ class StandardDepthShader extends MeshShader {
|
|
|
18336
18421
|
];
|
|
18337
18422
|
const extraCommandProps = config.extraCommandProps;
|
|
18338
18423
|
super({
|
|
18339
|
-
vert: vert$
|
|
18424
|
+
vert: vert$1,
|
|
18340
18425
|
frag: frag$3,
|
|
18341
18426
|
uniforms,
|
|
18342
18427
|
extraCommandProps,
|
|
@@ -18584,7 +18669,7 @@ class ShadowMapShader extends MeshShader {
|
|
|
18584
18669
|
|
|
18585
18670
|
var frag$2 = "precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D textureSource;\nuniform vec2 resolution;\n#include <common_pack_float>\nvoid main() {\n float c = .0;\n float d = .0;\n for(int x = -BOXBLUR_OFFSET; x <= BOXBLUR_OFFSET; ++x)\n for(int y = -BOXBLUR_OFFSET; y <= BOXBLUR_OFFSET; ++y) {\n vec2 e = vTexCoord.st + vec2(float(x) / resolution.x, float(y) / resolution.y);\n e = clamp(e, .0, 1.);\n float f = common_decodeDepth(texture2D(textureSource, e));\n float s = max(.0, sign(1. - f));\n d += sign(f) * s;\n c += f;\n }\n float h = c / max(1., d);\n gl_FragColor = common_encodeDepth(h);\n}";
|
|
18586
18671
|
|
|
18587
|
-
var wgslFrag$
|
|
18672
|
+
var wgslFrag$2 = "#include <common_pack_float>\nstruct Uniforms {\n resolution: vec2f\n};\n@group(0) @binding($b) var<uniform> uniforms: Uniforms;\n#ifdef HAS_MULTISAMPLED\n@binding($b) @group(0) var textureSource: texture_multisampled_2d<f32>;\n#else\n@binding($b) @group(0) var textureSource: texture_2d<f32>;\n#endif\n@group(0) @binding($b) var textureSourceSampler: sampler;\nfn sign_positive(x: f32) -> f32 {\n return select(0.0, 1.0, x > 0.0);\n}\n@fragment\nfn main(vertexOutput: VertexOutput) -> @location(0) vec4f {\n var c: f32 = 0.0;\n var weight: f32 = 0.0;\n let offset = BOXBLUR_OFFSET;\n for (var x: i32 = -offset; x <= offset; x++) {\n for (var y: i32 = -offset; y <= offset; y++) {\n var uv: vec2f = vertexOutput.vTexCoord + vec2f(f32(x) / uniforms.resolution.x, f32(y) / uniforms.resolution.y);\n uv = clamp(uv, vec2f(0.0), vec2f(1.0));\n #ifdef HAS_MULTISAMPLED\n let texColor = textureLoad(textureSource, vec2i(uv * vec2f(uniforms.resolution)), 0);\n #else\n let texColor = textureSample(textureSource, textureSourceSampler, uv);\n #endif\n let depth = common_decodeDepth(texColor);\n let s = max(0.0, sign_positive(1.0 - depth));\n weight += sign(depth) * s;\n c += depth;\n }\n }\n let avgDepth: f32 = c / max(1.0, weight);\n let encodedDepth = common_encodeDepth(avgDepth);\n return encodedDepth;\n}";
|
|
18588
18673
|
|
|
18589
18674
|
class BoxShadowBlurShader extends QuadShader {
|
|
18590
18675
|
|
|
@@ -18592,7 +18677,7 @@ class BoxShadowBlurShader extends QuadShader {
|
|
|
18592
18677
|
super({
|
|
18593
18678
|
name: 'box-shadow-blur',
|
|
18594
18679
|
frag: frag$2,
|
|
18595
|
-
wgslFrag: wgslFrag$
|
|
18680
|
+
wgslFrag: wgslFrag$2,
|
|
18596
18681
|
defines : {
|
|
18597
18682
|
'BOXBLUR_OFFSET' : blurOffset || 2
|
|
18598
18683
|
}
|
|
@@ -20326,6 +20411,9 @@ class GraphicsDevice {
|
|
|
20326
20411
|
}
|
|
20327
20412
|
// implementation of regl.texture
|
|
20328
20413
|
texture(width, height) {
|
|
20414
|
+
if (width === undefined) {
|
|
20415
|
+
width = 1;
|
|
20416
|
+
}
|
|
20329
20417
|
let config = width;
|
|
20330
20418
|
if (isNumber$2(width)) {
|
|
20331
20419
|
config = {
|
|
@@ -20513,7 +20601,7 @@ class GraphicsDevice {
|
|
|
20513
20601
|
_getClearPipeline(fbo) {
|
|
20514
20602
|
const isDefault = fbo === this.getDefaultFramebuffer();
|
|
20515
20603
|
const sampleCount = fbo.colorTexture && fbo.colorTexture.config.sampleCount || 1;
|
|
20516
|
-
const
|
|
20604
|
+
const depthFormat = isDefault || fbo.depthTexture && fbo.depthTexture.gpuFormat.format;
|
|
20517
20605
|
let format;
|
|
20518
20606
|
if (fbo.colorTexture) {
|
|
20519
20607
|
format = fbo.colorTexture.gpuFormat.format;
|
|
@@ -20522,7 +20610,7 @@ class GraphicsDevice {
|
|
|
20522
20610
|
format = navigator.gpu.getPreferredCanvasFormat();
|
|
20523
20611
|
}
|
|
20524
20612
|
this._clearPipelines = this._clearPipelines || {};
|
|
20525
|
-
const key = format + '-' + isDefault + '-' +
|
|
20613
|
+
const key = format + '-' + isDefault + '-' + depthFormat + '-' + sampleCount;
|
|
20526
20614
|
if (this._clearPipelines[key]) {
|
|
20527
20615
|
return this._clearPipelines[key];
|
|
20528
20616
|
}
|
|
@@ -20553,11 +20641,11 @@ class GraphicsDevice {
|
|
|
20553
20641
|
targets: [{ format }],
|
|
20554
20642
|
},
|
|
20555
20643
|
};
|
|
20556
|
-
if (
|
|
20644
|
+
if (depthFormat) {
|
|
20557
20645
|
options.depthStencil = {
|
|
20558
20646
|
depthWriteEnabled: false,
|
|
20559
20647
|
depthCompare: 'always',
|
|
20560
|
-
format: 'depth24plus-stencil8',
|
|
20648
|
+
format: depthFormat === true ? 'depth24plus-stencil8' : depthFormat,
|
|
20561
20649
|
};
|
|
20562
20650
|
}
|
|
20563
20651
|
if (sampleCount > 1) {
|
|
@@ -25016,16 +25104,18 @@ function getDepthTexture$1(fbo) {
|
|
|
25016
25104
|
return fbo.depthStencil._texture.texture;
|
|
25017
25105
|
}
|
|
25018
25106
|
|
|
25019
|
-
var vert$1 = "#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}";
|
|
25020
|
-
|
|
25021
25107
|
var frag$1 = "#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}";
|
|
25022
25108
|
|
|
25109
|
+
var wgslFrag$1 = "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}";
|
|
25110
|
+
|
|
25023
25111
|
// import QuadShader from '../shader/QuadShader.js';
|
|
25024
25112
|
|
|
25025
25113
|
class AnalysisShader extends QuadShader {
|
|
25026
25114
|
constructor(viewport) {
|
|
25027
25115
|
super({
|
|
25028
|
-
|
|
25116
|
+
name: 'analysis',
|
|
25117
|
+
frag: frag$1,
|
|
25118
|
+
wgslFrag: wgslFrag$1,
|
|
25029
25119
|
extraCommandProps: {
|
|
25030
25120
|
viewport,
|
|
25031
25121
|
cull: {
|
|
@@ -25100,20 +25190,24 @@ class AnalysisPainter {
|
|
|
25100
25190
|
stencil : 0,
|
|
25101
25191
|
framebuffer : this._fbo
|
|
25102
25192
|
});
|
|
25103
|
-
|
|
25104
|
-
delete
|
|
25105
|
-
delete
|
|
25106
|
-
delete
|
|
25107
|
-
delete
|
|
25108
|
-
delete
|
|
25109
|
-
delete
|
|
25193
|
+
const shaderDefines = extend({}, this._shader.shaderDefines);
|
|
25194
|
+
delete shaderDefines['HAS_FLOODANALYSE'];
|
|
25195
|
+
delete shaderDefines['HAS_VIEWSHED'];
|
|
25196
|
+
delete shaderDefines['HAS_SKYLINE'];
|
|
25197
|
+
delete shaderDefines['HAS_INSIGHT'];
|
|
25198
|
+
delete shaderDefines['HAS_CUT'];
|
|
25199
|
+
delete shaderDefines['HAS_CROSSCUT'];
|
|
25200
|
+
delete shaderDefines['HAS_HEIGHTLIMIT'];
|
|
25201
|
+
if (tex.texture && tex.texture.sampleCount > 1) {
|
|
25202
|
+
shaderDefines['HAS_MULTISAMPLED'] = 1;
|
|
25203
|
+
}
|
|
25110
25204
|
for (let i = 0; i < analysisTaskList.length; i++) {
|
|
25111
25205
|
const task = analysisTaskList[i];
|
|
25112
25206
|
if (!task.isEnable()) {
|
|
25113
25207
|
continue;
|
|
25114
25208
|
}
|
|
25115
25209
|
const defines = task.getDefines();
|
|
25116
|
-
extend(
|
|
25210
|
+
extend(shaderDefines, defines);
|
|
25117
25211
|
const map = this.getMap();
|
|
25118
25212
|
const width = map.width, height = map.height;
|
|
25119
25213
|
const toAanalysisMeshes = this._getToAnalysisMeshes(layers, task.getExcludeLayers());
|
|
@@ -25123,7 +25217,8 @@ class AnalysisPainter {
|
|
|
25123
25217
|
}
|
|
25124
25218
|
}
|
|
25125
25219
|
uniforms['sceneMap'] = tex;
|
|
25126
|
-
this.
|
|
25220
|
+
uniforms['resolution'] = [this._fbo.width, this._fbo.height];
|
|
25221
|
+
this._shader.setDefines(shaderDefines);
|
|
25127
25222
|
this.renderer.render(this._shader, uniforms, null, this._fbo);
|
|
25128
25223
|
return this._fbo;
|
|
25129
25224
|
}
|
|
@@ -25146,9 +25241,20 @@ class AnalysisPainter {
|
|
|
25146
25241
|
return toAnalysisMeshes;
|
|
25147
25242
|
}
|
|
25148
25243
|
|
|
25244
|
+
getViewportSize() {
|
|
25245
|
+
let width, height;
|
|
25246
|
+
if (this._viewport.width.data) {
|
|
25247
|
+
width = Util$1.isFunction(this._viewport.width.data) ? this._viewport.width.data() : this._viewport.width;
|
|
25248
|
+
height = Util$1.isFunction(this._viewport.height.data) ? this._viewport.height.data() : this._viewport.height;
|
|
25249
|
+
} else {
|
|
25250
|
+
width = Util$1.isFunction(this._viewport.width) ? this._viewport.width() : this._viewport.width;
|
|
25251
|
+
height = Util$1.isFunction(this._viewport.height) ? this._viewport.height() : this._viewport.height;
|
|
25252
|
+
}
|
|
25253
|
+
return { width, height };
|
|
25254
|
+
}
|
|
25255
|
+
|
|
25149
25256
|
_resize() {
|
|
25150
|
-
const width
|
|
25151
|
-
const height = Util$1.isFunction(this._viewport.height.data) ? this._viewport.height.data() : this._viewport.height;
|
|
25257
|
+
const { width, height } = this.getViewportSize();
|
|
25152
25258
|
if (this._fbo && (this._fbo.width !== width || this._fbo.height !== height)) {
|
|
25153
25259
|
this._fbo.resize(width, height);
|
|
25154
25260
|
}
|
|
@@ -34830,12 +34936,12 @@ class Height3DTool extends Measure3DTool {
|
|
|
34830
34936
|
|
|
34831
34937
|
const e = "${"; const code$1 = `function(t){
|
|
34832
34938
|
/*!
|
|
34833
|
-
* @maptalks/gltf-loader v0.
|
|
34939
|
+
* @maptalks/gltf-loader v0.121.0
|
|
34834
34940
|
* LICENSE : UNLICENSED
|
|
34835
34941
|
* (c) 2016-2026 maptalks.org
|
|
34836
34942
|
*/
|
|
34837
|
-
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
|
|
34838
|
-
/** @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};
|
|
34943
|
+
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"),
|
|
34944
|
+
/** @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};
|
|
34839
34945
|
/*!
|
|
34840
34946
|
* Contains code from THREE.JS
|
|
34841
34947
|
* https://github.com/mrdoob/three.js/
|
|
@@ -34843,7 +34949,7 @@ var e,r,n="undefined"!=typeof Float32Array?Float32Array:Array;function i(){var t
|
|
|
34843
34949
|
*
|
|
34844
34950
|
* Generate tangents per vertex.
|
|
34845
34951
|
*/
|
|
34846
|
-
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}}`;
|
|
34952
|
+
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}}`;
|
|
34847
34953
|
|
|
34848
34954
|
const code = `function(t){var n,r="undefined"!=typeof Float32Array?Float32Array:Array;function o(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t}function e(t,n,r,o){return t[0]=n[0]+r[0]*o,t[1]=n[1]+r[1]*o,t[2]=n[2]+r[2]*o,t}function a(t,n){var r=n[0],o=n[1],e=n[2],a=r*r+o*o+e*e;return a>0&&(a=1/Math.sqrt(a)),t[0]=n[0]*a,t[1]=n[1]*a,t[2]=n[2]*a,t}
|
|
34849
34955
|
/*!
|
|
@@ -34859,5 +34965,5 @@ maptalks.registerWorkerAdapter('maplight', code);
|
|
|
34859
34965
|
|
|
34860
34966
|
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 };
|
|
34861
34967
|
|
|
34862
|
-
typeof console !== 'undefined' && console.log('@maptalks/gpu v0.
|
|
34968
|
+
typeof console !== 'undefined' && console.log('@maptalks/gpu v0.121.0');
|
|
34863
34969
|
//# sourceMappingURL=maptalksgpu.es.js.map
|