(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['deck'] = factory(); else root['deck'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var Mi=Object.create;var ee=Object.defineProperty;var Ci=Object.getOwnPropertyDescriptor;var Ei=Object.getOwnPropertyNames;var _i=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var He=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),N=(e,t)=>{for(var n in t)ee(e,n,{get:t[n],enumerable:!0})},te=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ei(t))!Ti.call(e,s)&&s!==n&&ee(e,s,{get:()=>t[s],enumerable:!(r=Ci(t,s))||r.enumerable});return e},tt=(e,t,n)=>(te(e,t,"default"),n&&te(n,t,"default")),F=(e,t,n)=>(n=e!=null?Mi(_i(e)):{},te(t||!e||!e.__esModule?ee(n,"default",{value:e,enumerable:!0}):n,e)),yi=e=>te(ee({},"__esModule",{value:!0}),e);var At=He((Ul,or)=>{or.exports=globalThis.deck});var pt=He((Jl,cr)=>{cr.exports=globalThis.luma});var Dt=He((Kl,ar)=>{ar.exports=globalThis.luma});var $t={};N($t,{ScenegraphLayer:()=>xi,SimpleMeshLayer:()=>Ss});var j={},ir=F(At(),1);tt(j,F(At(),1));if(!ir.Layer)throw new Error("@deck.gl/core is not found");tt($t,j);var nt=F(At(),1),Is=F(pt(),1),Bt=F(Dt(),1);var Xl=1/Math.PI*180,Vl=1/180*Math.PI,bi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...bi}};var R=globalThis.mathgl.config;function fr(e,{precision:t=R.precision}={}){return e=Ri(e),`${parseFloat(e.toPrecision(t))}`}function mt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Je(e,t,n){let r=R.EPSILON;n&&(R.EPSILON=n);try{if(e===t)return!0;if(mt(e)&&mt(t)){if(e.length!==t.length)return!1;for(let s=0;s0?", ":"")+fr(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n=0&&t=0&&t0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Br(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function re(e,t,n){let r=t[0],s=t[1],o=t[2],i=n[0],c=n[1],a=n[2];return e[0]=s*a-o*c,e[1]=o*i-r*a,e[2]=r*c-s*i,e}function se(e,t,n){let r=t[0],s=t[1],o=t[2],i=n[3]*r+n[7]*s+n[11]*o+n[15];return i=i||1,e[0]=(n[0]*r+n[4]*s+n[8]*o+n[12])/i,e[1]=(n[1]*r+n[5]*s+n[9]*o+n[13])/i,e[2]=(n[2]*r+n[6]*s+n[10]*o+n[14])/i,e}function xr(e,t,n){let r=n[0],s=n[1],o=n[2],i=n[3],c=t[0],a=t[1],f=t[2],l=s*f-o*a,h=o*c-r*f,A=r*a-s*c,p=s*A-o*h,m=o*l-r*A,d=r*h-s*l,u=i*2;return l*=u,h*=u,A*=u,p*=2,m*=2,d*=2,e[0]=c+l+p,e[1]=a+h+m,e[2]=f+A+d,e}var Mr=Li;var oh=function(){let e=Xe();return function(t,n,r,s,o,i){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c0&&(i=1/Math.sqrt(i)),e[0]=n*i,e[1]=r*i,e[2]=s*i,e[3]=o*i,e}function Jr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Kr(e,t,n,r){let s=t[0],o=t[1],i=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=o+r*(n[1]-o),e[2]=i+r*(n[2]-i),e[3]=c+r*(n[3]-c),e}function Xr(e,t,n){let r=t[0],s=t[1],o=t[2],i=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*o+n[12]*i,e[1]=n[1]*r+n[5]*s+n[9]*o+n[13]*i,e[2]=n[2]*r+n[6]*s+n[10]*o+n[14]*i,e[3]=n[3]*r+n[7]*s+n[11]*o+n[15]*i,e}function Vr(e,t,n){let r=t[0],s=t[1],o=t[2],i=n[0],c=n[1],a=n[2],f=n[3],l=f*r+c*o-a*s,h=f*s+a*r-i*o,A=f*o+i*s-c*r,p=-i*r-c*s-a*o;return e[0]=l*f+p*-i+h*-a-A*-c,e[1]=h*f+p*-c+A*-i-l*-a,e[2]=A*f+p*-a+l*-c-h*-i,e[3]=t[3],e}var gh=function(){let e=Pi();return function(t,n,r,s,o,i){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;cMath.PI*2)throw Error("expected radians")}function Xi(e,t,n,r,s,o){let i=2*o/(n-t),c=2*o/(s-r),a=(n+t)/(n-t),f=(s+r)/(s-r),l=-1,h=-1,A=-2*o;return e[0]=i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=f,e[10]=l,e[11]=h,e[12]=0,e[13]=0,e[14]=A,e[15]=0,e}function kr(){let e=new S(4);return S!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Yr(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Qe(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function We(e,t,n){let r=t[0],s=t[1],o=t[2],i=t[3],c=n[0],a=n[1],f=n[2],l=n[3];return e[0]=r*l+i*c+s*f-o*a,e[1]=s*l+i*a+o*c-r*f,e[2]=o*l+i*f+r*a-s*c,e[3]=i*l-r*c-s*a-o*f,e}function zr(e,t,n){n*=.5;let r=t[0],s=t[1],o=t[2],i=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+i*c,e[1]=s*a+o*c,e[2]=o*a-s*c,e[3]=i*a-r*c,e}function Qr(e,t,n){n*=.5;let r=t[0],s=t[1],o=t[2],i=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-o*c,e[1]=s*a+i*c,e[2]=o*a+r*c,e[3]=i*a-s*c,e}function Wr(e,t,n){n*=.5;let r=t[0],s=t[1],o=t[2],i=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=o*a+i*c,e[3]=i*a-o*c,e}function qr(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function Gt(e,t,n,r){let s=t[0],o=t[1],i=t[2],c=t[3],a=n[0],f=n[1],l=n[2],h=n[3],A,p,m,d,u;return A=s*a+o*f+i*l+c*h,A<0&&(A=-A,a=-a,f=-f,l=-l,h=-h),1-A>1e-6?(p=Math.acos(A),u=Math.sin(p),m=Math.sin((1-r)*p)/u,d=Math.sin(r*p)/u):(m=1-r,d=r),e[0]=m*s+d*a,e[1]=m*o+d*f,e[2]=m*i+d*l,e[3]=m*c+d*h,e}function Zr(e,t){let n=t[0],r=t[1],s=t[2],o=t[3],i=n*n+r*r+s*s+o*o,c=i?1/i:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=o*c,e}function $r(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function qe(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let o=(s+1)%3,i=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[o*3+o]-t[i*3+i]+1),e[s]=.5*r,r=.5/r,e[3]=(t[o*3+i]-t[i*3+o])*r,e[o]=(t[o*3+s]+t[s*3+o])*r,e[i]=(t[i*3+s]+t[s*3+i])*r}return e}var ts=Pr;var es=wr,ns=Jr,rs=Kr,ss=Nr;var os=Ur;var is=Hr;var cs=function(){let e=Xe(),t=Ve(1,0,0),n=Ve(0,1,0);return function(r,s,o){let i=Br(s,o);return i<-.999999?(re(e,t,s),Mr(e)<1e-6&&re(e,n,s),gr(e,e),Qe(r,e,Math.PI),r):i>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(re(e,s,o),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+i,is(r,r))}}(),Fh=function(){let e=kr(),t=kr();return function(n,r,s,o,i,c){return Gt(e,r,i,c),Gt(t,s,o,c),Gt(n,e,t,2*c*(1-c)),n}}(),Dh=function(){let e=Cr();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],is(t,qe(t,e))}}();var Vi=[0,0,0,1],vt=class extends et{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return qe(this,t),this.check()}fromAxisRotation(t,n){return Qe(this,t,n),this.check()}identity(){return Yr(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=y(t)}get y(){return this[1]}set y(t){this[1]=y(t)}get z(){return this[2]}set z(t){this[2]=y(t)}get w(){return this[3]}set w(t){this[3]=y(t)}len(){return ss(this)}lengthSquared(){return os(this)}dot(t){return ns(this,t)}rotationTo(t,n){return cs(this,t,n),this.check()}add(t){return ts(this,this,t),this.check()}calculateW(){return qr(this,this),this.check()}conjugate(){return $r(this,this),this.check()}invert(){return Zr(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(rs(this,t,n,r),this.check())}multiplyRight(t){return We(this,this,t),this.check()}multiplyLeft(t){return We(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return zr(this,this,t),this.check()}rotateY(t){return Qr(this,this,t),this.check()}rotateZ(t){return Wr(this,this,t),this.check()}scale(t){return es(this,this,t),this.check()}slerp(t,n,r){let s,o,i;switch(arguments.length){case 1:({start:s=Vi,target:o,ratio:i}=t);break;case 2:s=this,o=t,i=n;break;default:s=t,o=n,i=r}return Gt(this,s,o,i),this.check()}transformVector4(t,n=new ut){return Vr(n,t,this),dt(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var fs=F(pt(),1);var Ze=`precision highp int; // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { vec3 color; }; struct PointLight { vec3 color; vec3 position; vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential }; struct DirectionalLight { vec3 color; vec3 direction; }; uniform lightingUniforms { int enabled; int lightType; int directionalLightCount; int pointLightCount; vec3 ambientColor; vec3 lightColor0; vec3 lightPosition0; vec3 lightDirection0; vec3 lightAttenuation0; vec3 lightColor1; vec3 lightPosition1; vec3 lightDirection1; vec3 lightAttenuation1; vec3 lightColor2; vec3 lightPosition2; vec3 lightDirection2; vec3 lightAttenuation2; } lighting; PointLight lighting_getPointLight(int index) { switch (index) { case 0: return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0); case 1: return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1); case 2: default: return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2); } } DirectionalLight lighting_getDirectionalLight(int index) { switch (index) { case 0: return DirectionalLight(lighting.lightColor0, lighting.lightDirection0); case 1: return DirectionalLight(lighting.lightColor1, lighting.lightDirection1); case 2: default: return DirectionalLight(lighting.lightColor2, lighting.lightDirection2); } } float getPointLightAttenuation(PointLight pointLight, float distance) { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } // #endif `;var as=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { color: vec3, }; struct PointLight { color: vec3, position: vec3, attenuation: vec3, // 2nd order x:Constant-y:Linear-z:Exponential }; struct DirectionalLight { color: vec3, direction: vec3, }; struct lightingUniforms { enabled: i32, poightCount: i32, directionalLightCount: i32, ambientColor: vec3, // TODO - support multiple lights by uncommenting arrays below lightType: i32, lightColor: vec3, lightDirection: vec3, lightPosition: vec3, lightAttenuation: vec3, // AmbientLight ambientLight; // PointLight pointLight[MAX_LIGHTS]; // DirectionalLight directionalLight[MAX_LIGHTS]; }; // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls) @binding(1) @group(0) var lighting : lightingUniforms; fn lighting_getPointLight(index: i32) -> PointLight { return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation); } fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { return DirectionalLight(lighting.lightColor, lighting.lightDirection); } fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } `;var ls=3,ji=255,Pt;(function(e){e[e.POINT=0]="POINT",e[e.DIRECTIONAL=1]="DIRECTIONAL"})(Pt||(Pt={}));var ot={props:{},uniforms:{},name:"lighting",defines:{MAX_LIGHTS:ls},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3",lightColor0:"vec3",lightPosition0:"vec3",lightDirection0:"vec3",lightAttenuation0:"vec3",lightColor1:"vec3",lightPosition1:"vec3",lightDirection1:"vec3",lightAttenuation1:"vec3",lightColor2:"vec3",lightPosition2:"vec3",lightDirection2:"vec3",lightAttenuation2:"vec3"},defaultUniforms:{enabled:1,lightType:Pt.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:as,vs:Ze,fs:Ze,getUniforms:ki};function ki(e,t={}){if(e=e&&{...e},!e)return{...ot.defaultUniforms};e.lights&&(e={...e,...zi(e.lights),lights:void 0});let{ambientLight:n,pointLights:r,directionalLights:s}=e||{};if(!(n||r&&r.length>0||s&&s.length>0))return{...ot.defaultUniforms,enabled:0};let i={...ot.defaultUniforms,...t,...Yi({ambientLight:n,pointLights:r,directionalLights:s})};return e.enabled!==void 0&&(i.enabled=e.enabled?1:0),i}function Yi({ambientLight:e,pointLights:t=[],directionalLights:n=[]}){let r={};r.ambientLightColor=$e(e);let s=0;for(let o of t){r.lightType=Pt.POINT;let i=s;r[`lightColor${i}`]=$e(o),r[`lightPosition${i}`]=o.position,r[`lightAttenuation${i}`]=o.attenuation||[1,0,0],s++}for(let o of n){r.lightType=Pt.DIRECTIONAL;let i=s;r[`lightColor${i}`]=$e(o),r[`lightDirection${i}`]=o.direction,s++}return s>ls&&fs.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=n.length,r.pointLightCount=t.length,r}function zi(e){let t={pointLights:[],directionalLights:[]};for(let n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":t.directionalLights?.push(n);break;case"point":t.pointLights?.push(n);break;default:}return t}function $e(e={}){let{color:t=[0,0,0],intensity:n=1}=e;return t.map(r=>r*n/ji)}var hs=`uniform phongMaterialUniforms { uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; `,As=`uniform phongMaterialUniforms { uniform float ambient; uniform float diffuse; uniform float shininess; uniform vec3 specularColor; } material; vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { vec3 halfway_direction = normalize(light_direction + view_direction); float lambertian = dot(light_direction, normal_worldspace); float specular = 0.0; if (lambertian > 0.0) { float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, material.shininess); } lambertian = max(lambertian, 0.0); return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color; } vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { vec3 lightColor = surfaceColor; if (lighting.enabled == 0) { return lightColor; } vec3 view_direction = normalize(cameraPosition - position_worldspace); lightColor = material.ambient * surfaceColor * lighting.ambientColor; for (int i = 0; i < lighting.pointLightCount; i++) { PointLight pointLight = lighting_getPointLight(i); vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); } int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount); for (int i = lighting.pointLightCount; i < totalLights; i++) { DirectionalLight directionalLight = lighting_getDirectionalLight(i); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } return lightColor; } `;var ps=`struct phongMaterialUniforms { ambient: f32, diffuse: f32, shininess: f32, specularColor: vec3, }; @binding(2) @group(0) var material : phongMaterialUniforms; fn lighting_getLightColor(surfaceColor: vec3, light_direction: vec3, view_direction: vec3, normal_worldspace: vec3, color: vec3) -> vec3 { let halfway_direction: vec3 = normalize(light_direction + view_direction); var lambertian: f32 = dot(light_direction, normal_worldspace); var specular: f32 = 0.0; if (lambertian > 0.0) { let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); specular = pow(specular_angle, material.shininess); } lambertian = max(lambertian, 0.0); return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color; } fn lighting_getLightColor2(surfaceColor: vec3, cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3 { var lightColor: vec3 = surfaceColor; if (lighting.enabled == 0) { return lightColor; } let view_direction: vec3 = normalize(cameraPosition - position_worldspace); lightColor = material.ambient * surfaceColor * lighting.ambientColor; if (lighting.lightType == 0) { let pointLight: PointLight = lighting_getPointLight(0); let light_position_worldspace: vec3 = pointLight.position; let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } else if (lighting.lightType == 1) { var directionalLight: DirectionalLight = lighting_getDirectionalLight(0); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } return lightColor; /* for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting.pointLightCount) { break; } PointLight pointLight = lighting.pointLight[i]; vec3 light_position_worldspace = pointLight.position; vec3 light_direction = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } for (int i = 0; i < MAX_LIGHTS; i++) { if (i >= lighting.directionalLightCount) { break; } DirectionalLight directionalLight = lighting.directionalLight[i]; lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } */ } fn lighting_getSpecularLightColor(cameraPosition: vec3, position_worldspace: vec3, normal_worldspace: vec3) -> vec3{ var lightColor = vec3(0, 0, 0); let surfaceColor = vec3(0, 0, 0); if (lighting.enabled == 0) { let view_direction = normalize(cameraPosition - position_worldspace); switch (lighting.lightType) { case 0, default: { let pointLight: PointLight = lighting_getPointLight(0); let light_position_worldspace: vec3 = pointLight.position; let light_direction: vec3 = normalize(light_position_worldspace - position_worldspace); lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); } case 1: { let directionalLight: DirectionalLight = lighting_getDirectionalLight(0); lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); } } } return lightColor; } `;var fe={name:"phongMaterial",dependencies:[ot],source:ps,vs:hs,fs:As,defines:{LIGHTING_FRAGMENT:1},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(e){let t={...e};return t.specularColor&&(t.specularColor=t.specularColor.map(n=>n/255)),{...fe.defaultUniforms,...t}}};var ms=`out vec3 pbr_vPosition; out vec2 pbr_vUV; #ifdef HAS_NORMALS # ifdef HAS_TANGENTS out mat3 pbr_vTBN; # else out vec3 pbr_vNormal; # endif #endif void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv) { vec4 pos = pbrProjection.modelMatrix * position; pbr_vPosition = vec3(pos.xyz) / pos.w; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0))); vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0))); vec3 bitangentW = cross(normalW, tangentW) * tangent.w; pbr_vTBN = mat3(tangentW, bitangentW, normalW); #else // HAS_TANGENTS != 1 pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0))); #endif #endif #ifdef HAS_UV pbr_vUV = uv; #else pbr_vUV = vec2(0.,0.); #endif } `;var ds=`precision highp float; uniform pbrMaterialUniforms { // Material is unlit bool unlit; // Base color map bool baseColorMapEnabled; vec4 baseColorFactor; bool normalMapEnabled; float normalScale; // #ifdef HAS_NORMALMAP bool emissiveMapEnabled; vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP vec2 metallicRoughnessValues; bool metallicRoughnessMapEnabled; bool occlusionMapEnabled; float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP bool alphaCutoffEnabled; float alphaCutoff; // #ifdef ALPHA_CUTOFF // IBL bool IBLenabled; vec2 scaleIBLAmbient; // #ifdef USE_IBL // debugging flags used for shader output of intermediate PBR variables // #ifdef PBR_DEBUG vec4 scaleDiffBaseMR; vec4 scaleFGDSpec; // #endif } pbrMaterial; // Samplers #ifdef HAS_BASECOLORMAP uniform sampler2D pbr_baseColorSampler; #endif #ifdef HAS_NORMALMAP uniform sampler2D pbr_normalSampler; #endif #ifdef HAS_EMISSIVEMAP uniform sampler2D pbr_emissiveSampler; #endif #ifdef HAS_METALROUGHNESSMAP uniform sampler2D pbr_metallicRoughnessSampler; #endif #ifdef HAS_OCCLUSIONMAP uniform sampler2D pbr_occlusionSampler; #endif #ifdef USE_IBL uniform samplerCube pbr_diffuseEnvSampler; uniform samplerCube pbr_specularEnvSampler; uniform sampler2D pbr_brdfLUT; #endif // Inputs from vertex shader in vec3 pbr_vPosition; in vec2 pbr_vUV; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS in mat3 pbr_vTBN; #else in vec3 pbr_vNormal; #endif #endif // Encapsulate the various inputs used by the various functions in the shading equation // We store values in this struct to simplify the integration of alternative implementations // of the shading terms, outlined in the Readme.MD Appendix. struct PBRInfo { float NdotL; // cos angle between normal and light direction float NdotV; // cos angle between normal and view direction float NdotH; // cos angle between normal and half vector float LdotH; // cos angle between light direction and half vector float VdotH; // cos angle between view direction and half vector float perceptualRoughness; // roughness value, as authored by the model creator (input to shader) float metalness; // metallic value at the surface vec3 reflectance0; // full reflectance color (normal incidence angle) vec3 reflectance90; // reflectance color at grazing angle float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2]) vec3 diffuseColor; // color contribution from diffuse lighting vec3 specularColor; // color contribution from specular lighting vec3 n; // normal at surface point vec3 v; // vector from surface point to camera }; const float M_PI = 3.141592653589793; const float c_MinRoughness = 0.04; vec4 SRGBtoLINEAR(vec4 srgbIn) { #ifdef MANUAL_SRGB #ifdef SRGB_FAST_APPROXIMATION vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); #else // SRGB_FAST_APPROXIMATION vec3 bLess = step(vec3(0.04045),srgbIn.xyz); vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); #endif //SRGB_FAST_APPROXIMATION return vec4(linOut,srgbIn.w);; #else //MANUAL_SRGB return srgbIn; #endif //MANUAL_SRGB } // Find the normal for this fragment, pulling either from a predefined normal map // or from the interpolated mesh normal and tangent attributes. vec3 getNormal() { // Retrieve the tangent space matrix #ifndef HAS_TANGENTS vec3 pos_dx = dFdx(pbr_vPosition); vec3 pos_dy = dFdy(pbr_vPosition); vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0)); vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0)); vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); #ifdef HAS_NORMALS vec3 ng = normalize(pbr_vNormal); #else vec3 ng = cross(pos_dx, pos_dy); #endif t = normalize(t - ng * dot(ng, t)); vec3 b = normalize(cross(ng, t)); mat3 tbn = mat3(t, b, ng); #else // HAS_TANGENTS mat3 tbn = pbr_vTBN; #endif #ifdef HAS_NORMALMAP vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb; n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0))); #else // The tbn matrix is linearly interpolated, so we need to re-normalize vec3 n = normalize(tbn[2].xyz); #endif return n; } // Calculation of the lighting contribution from an optional Image Based Light source. // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1]. // See our README.md on Environment Maps [3] for additional discussion. #ifdef USE_IBL vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection) { float mipCount = 9.0; // resolution of 512x512 float lod = (pbrInfo.perceptualRoughness * mipCount); // retrieve a scale and bias to F0. See [1], Figure 3 vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT, vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb; vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb; #ifdef USE_TEX_LOD vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb; #else vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb; #endif vec3 diffuse = diffuseLight * pbrInfo.diffuseColor; vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y); // For presentation, this allows us to disable IBL terms diffuse *= pbrMaterial.scaleIBLAmbient.x; specular *= pbrMaterial.scaleIBLAmbient.y; return diffuse + specular; } #endif // Basic Lambertian diffuse // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog // See also [1], Equation 1 vec3 diffuse(PBRInfo pbrInfo) { return pbrInfo.diffuseColor / M_PI; } // The following equation models the Fresnel reflectance term of the spec equation (aka F()) // Implementation of fresnel from [4], Equation 15 vec3 specularReflection(PBRInfo pbrInfo) { return pbrInfo.reflectance0 + (pbrInfo.reflectance90 - pbrInfo.reflectance0) * pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0); } // This calculates the specular geometric attenuation (aka G()), // where rougher material will reflect less light back to the viewer. // This implementation is based on [1] Equation 4, and we adopt their modifications to // alphaRoughness as input as originally proposed in [2]. float geometricOcclusion(PBRInfo pbrInfo) { float NdotL = pbrInfo.NdotL; float NdotV = pbrInfo.NdotV; float r = pbrInfo.alphaRoughness; float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); return attenuationL * attenuationV; } // The following equation(s) model the distribution of microfacet normals across // the area being drawn (aka D()) // Implementation from "Average Irregularity Representation of a Roughened Surface // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz // Follows the distribution function recommended in the SIGGRAPH 2013 course notes // from EPIC Games [1], Equation 3. float microfacetDistribution(PBRInfo pbrInfo) { float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness; float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0; return roughnessSq / (M_PI * f * f); } void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) { pbrInfo.NdotL = 1.0; pbrInfo.NdotH = 0.0; pbrInfo.LdotH = 0.0; pbrInfo.VdotH = 1.0; } void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) { vec3 n = pbrInfo.n; vec3 v = pbrInfo.v; vec3 l = normalize(lightDirection); // Vector from surface point to light vec3 h = normalize(l+v); // Half vector between both l and v pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0); pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0); pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0); pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0); } void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) { vec3 light_direction = normalize(pointLight.position - pbr_vPosition); PBRInfo_setDirectionalLight(pbrInfo, light_direction); } vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) { // Calculate the shading terms for the microfacet specular shading model vec3 F = specularReflection(pbrInfo); float G = geometricOcclusion(pbrInfo); float D = microfacetDistribution(pbrInfo); // Calculation of analytical lighting contribution vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo); vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV); // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law) return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib); } vec4 pbr_filterColor(vec4 colorUnused) { // The albedo may be defined from a base texture or a flat color #ifdef HAS_BASECOLORMAP vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor; #else vec4 baseColor = pbrMaterial.baseColorFactor; #endif #ifdef ALPHA_CUTOFF if (baseColor.a < pbrMaterial.alphaCutoff) { discard; } #endif vec3 color = vec3(0, 0, 0); if(pbrMaterial.unlit){ color.rgb = baseColor.rgb; } else{ // Metallic and Roughness material properties are packed together // In glTF, these factors can be specified by fixed scalar values // or from a metallic-roughness map float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y; float metallic = pbrMaterial.metallicRoughnessValues.x; #ifdef HAS_METALROUGHNESSMAP // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel. // This layout intentionally reserves the 'r' channel for (optional) occlusion map data vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV); perceptualRoughness = mrSample.g * perceptualRoughness; metallic = mrSample.b * metallic; #endif perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); metallic = clamp(metallic, 0.0, 1.0); // Roughness is authored as perceptual roughness; as is convention, // convert to material roughness by squaring the perceptual roughness [2]. float alphaRoughness = perceptualRoughness * perceptualRoughness; vec3 f0 = vec3(0.04); vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); diffuseColor *= 1.0 - metallic; vec3 specularColor = mix(f0, baseColor.rgb, metallic); // Compute reflectance. float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); // For typical incident reflectance range (between 4% to 100%) set the grazing // reflectance to 100% for typical fresnel effect. // For very low reflectance range on highly diffuse objects (below 4%), // incrementally reduce grazing reflecance to 0%. float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = specularColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; vec3 n = getNormal(); // normal at surface point vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); vec3 reflection = -normalize(reflect(v, n)); PBRInfo pbrInfo = PBRInfo( 0.0, // NdotL NdotV, 0.0, // NdotH 0.0, // LdotH 0.0, // VdotH perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS // Apply ambient light PBRInfo_setAmbientLight(pbrInfo); color += calculateFinalColor(pbrInfo, lighting.ambientColor); // Apply directional light for(int i = 0; i < lighting.directionalLightCount; i++) { if (i < lighting.directionalLightCount) { PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction); color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color); } } // Apply point light for(int i = 0; i < lighting.pointLightCount; i++) { if (i < lighting.pointLightCount) { PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i)); float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition)); color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation); } } #endif // Calculate lighting contribution from image based lighting source (IBL) #ifdef USE_IBL if (pbrMaterial.IBLenabled) { color += getIBLContribution(pbrInfo, n, reflection); } #endif // Apply optional PBR terms for additional (optional) shading #ifdef HAS_OCCLUSIONMAP if (pbrMaterial.occlusionMapEnabled) { float ao = texture(pbr_occlusionSampler, pbr_vUV).r; color = mix(color, color * ao, pbrMaterial.occlusionStrength); } #endif #ifdef HAS_EMISSIVEMAP if (pbrMaterial.emissiveMapEnabled) { vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor; color += emissive; } #endif // This section uses mix to override final color for reference app visualization // of various parameters in the lighting equation. #ifdef PBR_DEBUG // TODO: Figure out how to debug multiple lights // color = mix(color, F, pbr_scaleFGDSpec.x); // color = mix(color, vec3(G), pbr_scaleFGDSpec.y); // color = mix(color, vec3(D), pbr_scaleFGDSpec.z); // color = mix(color, specContrib, pbr_scaleFGDSpec.w); // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x); color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y); color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z); color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w); #endif } return vec4(pow(color,vec3(1.0/2.2)), baseColor.a); } `;var us=`uniform pbrProjectionUniforms { mat4 modelViewProjectionMatrix; mat4 modelMatrix; mat4 normalMatrix; vec3 camera; } pbrProjection; `,gs={name:"pbrProjection",vs:us,fs:us,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4",modelMatrix:"mat4x4",normalMatrix:"mat4x4",camera:"vec3"}};var wt={props:{},uniforms:{},name:"pbrMaterial",dependencies:[ot,gs],vs:ms,fs:ds,defines:{LIGHTING_FRAGMENT:1},getUniforms:e=>e,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3",metallicRoughnessValues:"vec2",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2",scaleDiffBaseMR:"vec4",scaleFGDSpec:"vec4"}};var gt=F(At(),1),tn=Math.PI/180,le=new Float32Array(16),Bs=new Float32Array(12);function xs(e,t,n){let r=t[0]*tn,s=t[1]*tn,o=t[2]*tn,i=Math.sin(o),c=Math.sin(r),a=Math.sin(s),f=Math.cos(o),l=Math.cos(r),h=Math.cos(s),A=n[0],p=n[1],m=n[2];e[0]=A*h*l,e[1]=A*a*l,e[2]=A*-c,e[3]=p*(-a*f+h*c*i),e[4]=p*(h*f+a*c*i),e[5]=p*l*i,e[6]=m*(a*i+h*c*f),e[7]=m*(-h*i+a*c*f),e[8]=m*l*f}function Ms(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}var he={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(e,{startRow:t,endRow:n}){let{data:r,getOrientation:s,getScale:o,getTranslation:i,getTransformMatrix:c}=this.props,a=Array.isArray(c),f=a&&c.length===16,l=Array.isArray(o),h=Array.isArray(s),A=Array.isArray(i),p=f||!a&&Boolean(c(r[0]));p?e.constant=f:e.constant=h&&l&&A;let m=e.value;if(e.constant){let d;p?(le.set(c),d=Ms(le)):(d=Bs,xs(d,s,o),d.set(i,9)),e.value=new Float32Array(d)}else{let d=t*e.size,{iterable:u,objectInfo:B}=(0,gt.createIterable)(r,t,n);for(let E of u){B.index++;let g;if(p)le.set(f?c:c(E,B)),g=Ms(le);else{g=Bs;let x=h?s:s(E,B),M=l?o:o(E,B);xs(g,x,M),g.set(A?i:i(E,B),9)}m[d++]=g[0],m[d++]=g[1],m[d++]=g[2],m[d++]=g[3],m[d++]=g[4],m[d++]=g[5],m[d++]=g[6],m[d++]=g[7],m[d++]=g[8],m[d++]=g[9],m[d++]=g[10],m[d++]=g[11]}}}};function Ae(e,t){return t===gt.COORDINATE_SYSTEM.CARTESIAN||t===gt.COORDINATE_SYSTEM.METER_OFFSETS||t===gt.COORDINATE_SYSTEM.DEFAULT&&!e.isGeospatial}var Cs=`uniform simpleMeshUniforms { float sizeScale; bool composeModelMatrix; bool hasTexture; bool flatShading; } simpleMesh; `,Es={name:"simpleMesh",vs:Cs,fs:Cs,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};var _s=`#version 300 es #define SHADER_NAME simple-mesh-layer-vs in vec3 positions; in vec3 normals; in vec3 colors; in vec2 texCoords; in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; out vec2 vTexCoord; out vec3 cameraPosition; out vec3 normals_commonspace; out vec4 position_commonspace; out vec4 vColor; void main(void) { geometry.worldPosition = instancePositions; geometry.uv = texCoords; geometry.pickingColor = instancePickingColors; vTexCoord = texCoords; cameraPosition = project.cameraPosition; vColor = vec4(colors * instanceColors.rgb, instanceColors.a); mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation; if (simpleMesh.composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); normals_commonspace = project_normal(instanceModelMatrix * normals); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace); geometry.position = position_commonspace; } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace); geometry.position = position_commonspace; normals_commonspace = project_normal(instanceModelMatrix * normals); } geometry.normal = normals_commonspace; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); DECKGL_FILTER_COLOR(vColor, geometry); } `;var Ts=`#version 300 es #define SHADER_NAME simple-mesh-layer-fs precision highp float; uniform sampler2D sampler; in vec2 vTexCoord; in vec3 cameraPosition; in vec3 normals_commonspace; in vec4 position_commonspace; in vec4 vColor; out vec4 fragColor; void main(void) { geometry.uv = vTexCoord; vec3 normal; if (simpleMesh.flatShading) { normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); } else { normal = normals_commonspace; } vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor; DECKGL_FILTER_COLOR(color, geometry); vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); fragColor = vec4(lightColor, color.a * layer.opacity); } `;function ys(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function Nt(e){let t=1/0,n=1/0,r=1/0,s=-1/0,o=-1/0,i=-1/0,c=e.POSITION?e.POSITION.value:[],a=c&&c.length;for(let f=0;fs?l:s,o=h>o?h:o,i=A>i?A:i}return[[t,n,r],[s,o,i]]}function en(e,t,n){let r=ys(t.value),s=n||bs(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:s}}function bs(e){let t={};return"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10)),"byteStride"in e&&(t.byteStride=e.byteStride.toString(10)),"normalized"in e&&(t.normalized=e.normalized.toString()),t}function nn(e){let t=e.positions||e.POSITION;nt.log.assert(t,'no "postions" or "POSITION" attribute in mesh');let n=t.value.length/t.size,r=e.COLOR_0||e.colors;r||(r={size:3,value:new Float32Array(n*3).fill(1)});let s=e.NORMAL||e.normals;s||(s={size:3,value:new Float32Array(n*3).fill(0)});let o=e.TEXCOORD_0||e.texCoords;return o||(o={size:2,value:new Float32Array(n*2).fill(0)}),{positions:t,colors:r,normals:s,texCoords:o}}function Rs(e){return e instanceof Bt.Geometry?(e.attributes=nn(e.attributes),e):e.attributes?new Bt.Geometry({...e,topology:"triangle-list",attributes:nn(e.attributes)}):new Bt.Geometry({topology:"triangle-list",attributes:nn(e)})}var Qi=[0,0,0,255],Wi={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:Qi},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}},Ut=class extends nt.Layer{getShaders(){return super.getShaders({vs:_s,fs:Ts,modules:[nt.project32,fe,nt.picking,Es]})}getBounds(){if(this.props._instanced)return super.getBounds();let t=this.state.positionBounds;if(t)return t;let{mesh:n}=this.props;if(!n)return null;if(t=n.header?.boundingBox,!t){let{attributes:r}=Rs(n);r.POSITION=r.POSITION||r.positions,t=Nt(r)}return this.state.positionBounds=t,t}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:he}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(t){super.updateState(t);let{props:n,oldProps:r,changeFlags:s}=t;if(n.mesh!==r.mesh||s.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),n.mesh){this.state.model=this.getModel(n.mesh);let o=n.mesh.attributes||n.mesh;this.setState({hasNormals:Boolean(o.NORMAL||o.normals)})}this.getAttributeManager().invalidateAll()}n.texture!==r.texture&&n.texture instanceof Is.Texture&&this.setTexture(n.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(t){super.finalizeState(t),this.state.emptyTexture.delete()}draw({uniforms:t}){let{model:n}=this.state;if(!n)return;let{viewport:r,renderPass:s}=this.context,{sizeScale:o,coordinateSystem:i,_instanced:c}=this.props,a={sizeScale:o,composeModelMatrix:!c||Ae(r,i),flatShading:!this.state.hasNormals};n.shaderInputs.setProps({simpleMesh:a}),n.draw(s)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(t){let n=new Bt.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:Rs(t),isInstanced:!0}),{texture:r}=this.props,{emptyTexture:s}=this.state,o={sampler:r||s,hasTexture:Boolean(r)};return n.shaderInputs.setProps({simpleMesh:o}),n}setTexture(t){let{emptyTexture:n,model:r}=this.state;if(r){let s={sampler:t||n,hasTexture:Boolean(t)};r.shaderInputs.setProps({simpleMesh:s})}}};Ut.defaultProps=Wi;Ut.layerName="SimpleMeshLayer";var Ss=Ut;var W=F(At(),1);var ht=F(Dt(),1);var Ls=F(pt(),1),V;(function(e){e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.LINEAR=9729]="LINEAR",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(V||(V={}));function Fs(e,t,n,r){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:o}=r;return o&&(s.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,s.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,s.bindings.pbr_BrdfLUT=o.brdfLutTexture.texture,s.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.scaleDiffBaseMR=[0,0,0,0],s.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(s.defines.HAS_NORMALS=1),n.TANGENT&&r?.useTangents&&(s.defines.HAS_TANGENTS=1),n.TEXCOORD_0&&(s.defines.HAS_UV=1),r?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=1),r?.lights&&(s.defines.USE_LIGHTS=1),t&&qi(e,t,s),s}function qi(e,t,n){if(n.uniforms.unlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Zi(e,t.pbrMetallicRoughness,n),t.normalTexture){Ht(e,t.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",n);let{scale:r=1}=t.normalTexture;n.uniforms.normalScale=r}if(t.occlusionTexture){Ht(e,t.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",n);let{strength:r=1}=t.occlusionTexture;n.uniforms.occlusionStrength=r}switch(t.emissiveTexture&&(Ht(e,t.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",n),n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:r=.5}=t;n.defines.ALPHA_CUTOFF=1,n.uniforms.alphaCutoff=r;break;case"BLEND":Ls.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),n.parameters.blendColorOperation="add",n.parameters.blendColorSrcFactor="src-alpha",n.parameters.blendColorDstFactor="one-minus-src-alpha",n.parameters.blendAlphaOperation="add",n.parameters.blendAlphaSrcFactor="one",n.parameters.blendAlphaDstFactor="one-minus-src-alpha",n.glParameters.blend=!0,n.glParameters.blendEquation=V.FUNC_ADD,n.glParameters.blendFunc=[V.SRC_ALPHA,V.ONE_MINUS_SRC_ALPHA,V.ONE,V.ONE_MINUS_SRC_ALPHA];break}}function Zi(e,t,n){t.baseColorTexture&&Ht(e,t.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",n),n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&Ht(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",n);let{metallicFactor:r=1,roughnessFactor:s=1}=t;n.uniforms.metallicRoughnessValues=[r,s]}function Ht(e,t,n,r=null,s){let o=t?.texture?.sampler?.parameters||{},i=t.texture.source.image,c,a={};i.compressed?(c=i,a={[V.TEXTURE_MIN_FILTER]:i.data.length>1?V.LINEAR_MIPMAP_NEAREST:V.LINEAR}):c={data:i};let f=e.createTexture({id:t.uniformName||t.id,parameters:{...o,...a},pixelStore:{[V.UNPACK_FLIP_Y_WEBGL]:!1},...c});s.bindings[n]=f,r&&(s.defines[r]=1),s.generatedTextures.push(f)}var Ds="4.2.1";async function Jt(e,t,n,r){return r._parse(e,t,n,r)}function U(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var k={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},$i=k.self||k.window||k.global||{},tc=k.window||k.self||k.global||{},ec=k.global||k.self||k.window||{},nc=k.document||{};var Kt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Os=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),rc=Os&&parseFloat(Os[1])||0;function rn(e){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,e)}function sn(e){return globalThis.loaders?.modules?.[e]||null}function sc(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.1"),globalThis._loadersgl_.version}var Gs=sc();function vs(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}var Y={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},UA=Y.self||Y.window||Y.global||{},HA=Y.window||Y.self||Y.global||{},JA=Y.global||Y.self||Y.window||{},KA=Y.document||{};var xt=typeof process!="object"||String(process)!=="[object process]"||process.browser,pe=typeof importScripts=="function",XA=typeof window<"u"&&typeof window.orientation<"u",Ps=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),VA=Ps&&parseFloat(Ps[1])||0;var on={};async function z(e,t=null,n={},r=null){return t&&(e=ws(e,t,n,r)),on[e]=on[e]||oc(e),await on[e]}function ws(e,t,n={},r=null){if(!n.useLocalLibraries&&e.startsWith("http"))return e;r=r||e;let s=n.modules||{};return s[r]?s[r]:xt?n.CDN?(vs(n.CDN.startsWith("http")),`${n.CDN}/${t}@${Gs}/dist/libs/${r}`):pe?`../src/libs/${r}`:`modules/${t}/src/libs/${r}`:`modules/${t}/dist/libs/${r}`}async function oc(e){if(e.endsWith("wasm"))return await cc(e);if(!xt)try{let{requireFromFile:n}=globalThis.loaders||{};return await n?.(e)}catch(n){return console.error(n),null}if(pe)return importScripts(e);let t=await ac(e);return ic(t,e)}function ic(e,t){if(!xt){let{requireFromString:r}=globalThis.loaders||{};return r?.(e,t)}if(pe)return eval.call(globalThis,e),null;let n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch{n.text=e}return document.body.appendChild(n),null}async function cc(e){let{readFileAsArrayBuffer:t}=globalThis.loaders||{};return xt||!t||e.startsWith("http")?await(await fetch(e)).arrayBuffer():await t(e)}async function ac(e){let{readFileAsText:t}=globalThis.loaders||{};return xt||!t||e.startsWith("http")?await(await fetch(e)).text():await t(e)}function Us(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?Ns(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?Ns(e,0,t):""}function Ns(e,t,n){if(e.byteLength<=t+n)return"";let r=new DataView(e),s="";for(let o=0;o=0),U(t>0),e+(t-1)&~(t-1)}function an(e,t,n){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{let s=e.byteOffset,o=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,s,o)}return t.set(r,n),n+rt(r.byteLength,4)}var me={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},Hs;async function ln(e){rn(e.modules);let t=sn("basis");return t||(Hs||=fc(e),await Hs)}async function fc(e){let t=null,n=null;return[t,n]=await Promise.all([await z(me.TRANSCODER,"textures",e),await z(me.TRANSCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await lc(t,n)}function lc(e,t){let n={};return t&&(n.wasmBinary=t),new Promise(r=>{e(n).then(s=>{let{BasisFile:o,initializeBasis:i}=s;i(),r({BasisFile:o})})})}var fn;async function hn(e){let t=e.modules||{};return t.basisEncoder?t.basisEncoder:(fn=fn||hc(e),await fn)}async function hc(e){let t=null,n=null;return[t,n]=await Promise.all([await z(me.ENCODER,"textures",e),await z(me.ENCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await Ac(t,n)}function Ac(e,t){let n={};return t&&(n.wasmBinary=t),new Promise(r=>{e(n).then(s=>{let{BasisFile:o,KTX2File:i,initializeBasis:c,BasisEncoder:a}=s;c(),r({BasisFile:o,KTX2File:i,BasisEncoder:a})})})}var it={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919};var pc=["","WEBKIT_","MOZ_"],Js={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},de=null;function Ks(e){if(!de){e=e||mc()||void 0,de=new Set;for(let t of pc)for(let n in Js)if(e&&e.getExtension(`${t}${n}`)){let r=Js[n];de.add(r)}}return de}function mc(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var Ip=new Uint8Array([0]);var Xs,Vs,js,ks,Ys,zs,Qs,Ws;(function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"})(Xs||(Xs={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Vs||(Vs={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(js||(js={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(ks||(ks={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(Ys||(Ys={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(zs||(zs={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(Qs||(Qs={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(Ws||(Ws={}));var w=[171,75,84,88,32,50,48,187,13,10,26,10];function qs(e){let t=new Uint8Array(e);return!(t.byteLength{try{n.onload=()=>r(n),n.onerror=o=>{let i=o instanceof Error?o.message:"error";s(new Error(i))}}catch(o){s(o)}})}var Tc={},io=!0;async function co(e,t,n){let r;ge(n)?r=await Be(e,t,n):r=Bn(e,n);let s=t&&t.imagebitmap;return await yc(r,s)}async function yc(e,t=null){if((bc(t)||!io)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),io=!1}return await createImageBitmap(e)}function bc(e){for(let t in e||Tc)return!1;return!0}function ao(e){return!Lc(e,"ftyp",4)||!(e[8]&96)?null:Rc(e)}function Rc(e){switch(Ic(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Ic(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Sc(e){return[...e].map(t=>t.charCodeAt(0))}function Lc(e,t,n=0){let r=Sc(t);for(let s=0;s=24&&t.getUint32(0,Q)===2303741511?{mimeType:"image/png",width:t.getUint32(16,Q),height:t.getUint32(20,Q)}:null}function Oc(e){let t=kt(e);return t.byteLength>=10&&t.getUint32(0,Q)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,jt),height:t.getUint16(8,jt)}:null}function Gc(e){let t=kt(e);return t.byteLength>=14&&t.getUint16(0,Q)===16973&&t.getUint32(2,jt)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,jt),height:t.getUint32(22,jt)}:null}function vc(e){let t=kt(e);if(!(t.byteLength>=3&&t.getUint16(0,Q)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=Pc(),o=2;for(;o+9Boolean(ct(new DataView(e)))],options:Hc};var Mn={};function Cn(e){if(Mn[e]===void 0){let t=Kt?Kc(e):Jc(e);Mn[e]=t}return Mn[e]}function Jc(e){let t=["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.imageFormatsNode||t,r=globalThis.loaders?.parseImageNode;return Boolean(r)&&n.includes(e)}function Kc(e){switch(e){case"image/avif":case"image/webp":return Xc(e);default:return!0}}function Xc(e){try{return document.createElement("canvas").toDataURL(e).indexOf(`data:${e}`)===0}catch{return!1}}var Mt=F(Dt(),1);var _n=F(pt(),1);var Vc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jc={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Tn=class{name;startTime=0;playing=!0;speed=1;channels=[];constructor(t){Object.assign(this,t)}animate(t){if(!this.playing)return;let r=(t/1e3-this.startTime)*this.speed;this.channels.forEach(({sampler:s,target:o,path:i})=>{qc(r,s,o,i),Yc(o,o._node)})}},xe=class{animations;constructor(t){this.animations=t.animations.map((n,r)=>{let s=n.name||`Animation-${r}`,o=n.samplers.map(({input:c,interpolation:a="LINEAR",output:f})=>({input:ho(t.accessors[c]),interpolation:a,output:ho(t.accessors[f])})),i=n.channels.map(({sampler:c,target:a})=>({sampler:o[c],target:t.nodes[a.node],path:a.path}));return new Tn({name:s,channels:i})})}animate(t){this.setTime(t)}setTime(t){this.animations.forEach(n=>n.animate(t))}getAnimations(){return this.animations}};function ho(e){if(!e._animation){let t=jc[e.componentType],n=Vc[e.type],r=n*e.count,{buffer:s,byteOffset:o}=e.bufferView.data,i=new t(s,o+(e.byteOffset||0),r);if(n===1)e._animation=Array.from(i);else{let c=[];for(let a=0;aA>=c),f=Math.max(0,a-1);if(!Array.isArray(s[o]))switch(o){case"translation":s[o]=[0,0,0];break;case"rotation":s[o]=[0,0,0,1];break;case"scale":s[o]=[1,1,1];break;default:_n.log.warn(`Bad animation path ${o}`)()}let l=t[f],h=t[a];switch(n){case"STEP":Wc(s,o,r[f]);break;case"LINEAR":if(h>l){let A=(c-l)/(h-l);zc(s,o,r[f],r[a],A)}break;case"CUBICSPLINE":if(h>l){let A=(c-l)/(h-l),p=h-l,m=r[3*f+1],d=r[3*f+2],u=r[3*a+0],B=r[3*a+1];Qc(s,o,{p0:m,outTangent0:d,inTangent1:u,p1:B,tDiff:p,ratio:A})}break;default:_n.log.warn(`Interpolation ${n} not supported`)();break}}var Ao=F(pt(),1);var Me=F(Dt(),1);var Zc=` layout(0) positions: vec4; // in vec4 POSITION; #ifdef HAS_NORMALS in vec4 normals; // in vec4 NORMAL; #endif #ifdef HAS_TANGENTS in vec4 TANGENT; #endif #ifdef HAS_UV // in vec2 TEXCOORD_0; in vec2 texCoords; #endif @vertex void main(void) { vec4 _NORMAL = vec4(0.); vec4 _TANGENT = vec4(0.); vec2 _TEXCOORD_0 = vec2(0.); #ifdef HAS_NORMALS _NORMAL = normals; #endif #ifdef HAS_TANGENTS _TANGENT = TANGENT; #endif #ifdef HAS_UV _TEXCOORD_0 = texCoords; #endif pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0); gl_Position = u_MVPMatrix * positions; } @fragment out vec4 fragmentColor; void main(void) { vec3 pos = pbr_vPosition; fragmentColor = pbr_filterColor(vec4(1.0)); } `,$c=`#version 300 es // in vec4 POSITION; in vec4 positions; #ifdef HAS_NORMALS // in vec4 NORMAL; in vec4 normals; #endif #ifdef HAS_TANGENTS in vec4 TANGENT; #endif #ifdef HAS_UV // in vec2 TEXCOORD_0; in vec2 texCoords; #endif void main(void) { vec4 _NORMAL = vec4(0.); vec4 _TANGENT = vec4(0.); vec2 _TEXCOORD_0 = vec2(0.); #ifdef HAS_NORMALS _NORMAL = normals; #endif #ifdef HAS_TANGENTS _TANGENT = TANGENT; #endif #ifdef HAS_UV _TEXCOORD_0 = texCoords; #endif pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0); gl_Position = pbrProjection.modelViewProjectionMatrix * positions; } `,ta=`#version 300 es out vec4 fragmentColor; void main(void) { vec3 pos = pbr_vPosition; fragmentColor = pbr_filterColor(vec4(1.0)); } `;function po(e,t){let{id:n,geometry:r,material:s,vertexCount:o,materialOptions:i,modelOptions:c}=t,a=Fs(e,s,r.attributes,i);Ao.log.info(4,"createGLTFModel defines: ",a.defines)();let f=[],l={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},h={id:n,source:Zc,vs:$c,fs:ta,geometry:r,topology:r.topology,vertexCount:o,modules:[wt],...c,defines:{...a.defines,...c.defines},parameters:{...l,...a.parameters,...c.parameters}},A=new Me.Model(e,h),{camera:p,...m}={...a.uniforms,...c.uniforms,...a.bindings,...c.bindings};return A.shaderInputs.setProps({pbrMaterial:m,pbrProjection:{camera:p}}),new Me.ModelNode({managedResources:f,model:A})}var at;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(at||(at={}));function mo(e){switch(e){case at.POINTS:return"point-list";case at.LINES:return"line-list";case at.LINE_STRIP:return"line-strip";case at.TRIANGLES:return"triangle-list";case at.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(e))}}var ea={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},Ce=class{device;options;gltf;constructor(t,n={}){this.device=t,this.options={...ea,...n}}instantiate(t){return this.gltf=yn(t),(this.gltf.scenes||[]).map(r=>this.createScene(r))}createAnimator(){return Array.isArray(this.gltf.animations)?new xe(this.gltf):null}createScene(t){let r=(t.nodes||[]).map(o=>this.createNode(o));return new Mt.GroupNode({id:t.name||t.id,children:r})}createNode(t){if(!t._node){let s=(t.children||[]).map(i=>this.createNode(i));t.mesh&&s.push(this.createMesh(t.mesh));let o=new Mt.GroupNode({id:t.name||t.id,children:s});if(t.matrix)o.setMatrix(t.matrix);else{if(o.matrix.identity(),t.translation&&o.matrix.translate(t.translation),t.rotation){let i=new Z().fromQuaternion(t.rotation);o.matrix.multiplyRight(i)}t.scale&&o.matrix.scale(t.scale)}t._node=o}let n=this.gltf.nodes.find(r=>r.id===t.id);return n._node=t._node,t._node}createMesh(t){if(!t._mesh){let r=(t.primitives||[]).map((o,i)=>this.createPrimitive(o,i,t)),s=new Mt.GroupNode({id:t.name||t.id,children:r});t._mesh=s}return t._mesh}createPrimitive(t,n,r){let s=t.name||`${r.name||r.id}-primitive-${n}`,o=mo(t.mode||4),i=t.indices?t.indices.count:this.getVertexCount(t.attributes),c=po(this.device,{id:s,geometry:this.createGeometry(s,t,o),material:t.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:i});return c.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],c}getVertexCount(t){throw new Error("getVertexCount not implemented")}createGeometry(t,n,r){let s={};for(let[o,i]of Object.entries(n.attributes)){let{components:c,size:a,value:f}=i;s[o]={size:a??c,value:f}}return new Mt.Geometry({id:t,topology:r,indices:n.indices.value,attributes:s})}createBuffer(t,n){t.bufferView||(t.bufferView={});let{bufferView:r}=t;return r.lumaBuffers||(r.lumaBuffers={}),r.lumaBuffers[n]||(r.lumaBuffers[n]=this.device.createBuffer({id:`from-${r.id}`,data:r.data||t.value})),r.lumaBuffers[n]}createSampler(t){return t}needsPOT(){return!1}};function yn(e){if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof ImageBitmap)return e;if(Array.isArray(e))return e.map(yn);if(e&&typeof e=="object"){let t={};for(let n in e)t[n]=yn(e[n]);return t}return e}function bn(e,t,n){let r=new Ce(e,n),s=r.instantiate(t),o=r.createAnimator();return{scenes:s,animator:o}}var Rn={};N(Rn,{decode:()=>Aa,name:()=>ha});function b(e,t){if(!e)throw new Error(t||"assert failed: gltf")}var Ee={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},_e={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var uo=["SCALAR","VEC2","VEC3","VEC4"],na=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],ra=new Map(na),sa={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},oa={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ia={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Te(e){return uo[e-1]||uo[0]}function Ct(e){let t=ra.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Et(e,t){let n=ia[e.componentType],r=sa[e.type],s=oa[e.componentType],o=e.count*r,i=e.count*r*s;b(i>=0&&i<=t.byteLength);let c=_e[e.componentType],a=Ee[e.type];return{ArrayType:n,length:o,byteLength:i,componentByteSize:c,numberOfComponentsInElement:a}}function go(e,t,n){let r=e.bufferViews[n];b(r);let s=r.buffer,o=t[s];b(o);let i=(r.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,i,r.byteLength)}function Bo(e,t,n){let r=typeof n=="number"?e.accessors?.[n]:n;if(!r)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);let s=e.bufferViews?.[r.bufferView||0];if(!s)throw new Error(`No gltf buffer view for accessor ${s}`);let{arrayBuffer:o,byteOffset:i}=t[s.buffer],c=(i||0)+(r.byteOffset||0)+(s.byteOffset||0),{ArrayType:a,length:f,componentByteSize:l,numberOfComponentsInElement:h}=Et(r,s),A=l*h,p=s.byteStride||A;if(typeof s.byteStride>"u"||s.byteStride===A)return new a(o,c,f);let m=new a(f);for(let d=0;ds===t),r=this.getRequiredExtensions().find(s=>s===t);return typeof n=="string"||typeof r=="string"}getExtension(t){let n=this.getUsedExtensions().find(s=>s===t),r=this.json.extensions||{};return n?r[t]:null}getRequiredExtension(t){return this.getRequiredExtensions().find(r=>r===t)?this.getExtension(t):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(t,n){return(t.extensions||{})[n]}getScene(t){return this.getObject("scenes",t)}getNode(t){return this.getObject("nodes",t)}getSkin(t){return this.getObject("skins",t)}getMesh(t){return this.getObject("meshes",t)}getMaterial(t){return this.getObject("materials",t)}getAccessor(t){return this.getObject("accessors",t)}getTexture(t){return this.getObject("textures",t)}getSampler(t){return this.getObject("samplers",t)}getImage(t){return this.getObject("images",t)}getBufferView(t){return this.getObject("bufferViews",t)}getBuffer(t){return this.getObject("buffers",t)}getObject(t,n){if(typeof n=="object")return n;let r=this.json[t]&&this.json[t][n];if(!r)throw new Error(`glTF file error: Could not find ${t}[${n}]`);return r}getTypedArrayForBufferView(t){t=this.getBufferView(t);let n=t.buffer,r=this.gltf.buffers[n];b(r);let s=(t.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,t.byteLength)}getTypedArrayForAccessor(t){let n=this.getAccessor(t);return Bo(this.gltf.json,this.gltf.buffers,n)}getTypedArrayForImageData(t){t=this.getAccessor(t);let n=this.getBufferView(t.bufferView),s=this.getBuffer(n.buffer).data,o=n.byteOffset||0;return new Uint8Array(s,o,n.byteLength)}addApplicationData(t,n){return this.json[t]=n,this}addExtraData(t,n){return this.json.extras=this.json.extras||{},this.json.extras[t]=n,this}addObjectExtension(t,n,r){return t.extensions=t.extensions||{},t.extensions[n]=r,this.registerUsedExtension(n),this}setObjectExtension(t,n,r){let s=t.extensions||{};s[n]=r}removeObjectExtension(t,n){let r=t?.extensions||{};if(r[n]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let s=this.json.extensionsRemoved;s.includes(n)||s.push(n)}delete r[n]}addExtension(t,n={}){return b(n),this.json.extensions=this.json.extensions||{},this.json.extensions[t]=n,this.registerUsedExtension(t),n}addRequiredExtension(t,n={}){return b(n),this.addExtension(t,n),this.registerRequiredExtension(t),n}registerUsedExtension(t){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(n=>n===t)||this.json.extensionsUsed.push(t)}registerRequiredExtension(t){this.registerUsedExtension(t),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(n=>n===t)||this.json.extensionsRequired.push(t)}removeExtension(t){if(this.json.extensions?.[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let n=this.json.extensionsRemoved;n.includes(t)||n.push(t)}this.json.extensions&&delete this.json.extensions[t],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,t),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,t)}setDefaultScene(t){this.json.scene=t}addScene(t){let{nodeIndices:n}=t;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:n}),this.json.scenes.length-1}addNode(t){let{meshIndex:n,matrix:r}=t;this.json.nodes=this.json.nodes||[];let s={mesh:n};return r&&(s.matrix=r),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(t){let{attributes:n,indices:r,material:s,mode:o=4}=t,c={primitives:[{attributes:this._addAttributes(n),mode:o}]};if(r){let a=this._addIndices(r);c.primitives[0].indices=a}return Number.isFinite(s)&&(c.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(c),this.json.meshes.length-1}addPointCloud(t){let r={primitives:[{attributes:this._addAttributes(t),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addImage(t,n){let r=ct(t),s=n||r?.mimeType,i={bufferView:this.addBufferView(t),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(t,n=0,r=this.byteLength){let s=t.byteLength;b(Number.isFinite(s)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(t);let o={buffer:n,byteOffset:r,byteLength:s};return this.byteLength+=rt(s,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(o),this.json.bufferViews.length-1}addAccessor(t,n){let r={bufferView:t,type:Te(n.size),componentType:n.componentType,count:n.count,max:n.max,min:n.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(t,n={size:3}){let r=this.addBufferView(t),s={min:n.min,max:n.max};(!s.min||!s.max)&&(s=this._getAccessorMinMax(t,n.size));let o={size:n.size,componentType:Ct(t),count:Math.round(t.length/n.size),min:s.min,max:s.max};return this.addAccessor(r,Object.assign(o,n))}addTexture(t){let{imageIndex:n}=t,r={source:n};return this.json.textures=this.json.textures||[],this.json.textures.push(r),this.json.textures.length-1}addMaterial(t){return this.json.materials=this.json.materials||[],this.json.materials.push(t),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];let t=this.byteLength,n=new ArrayBuffer(t),r=new Uint8Array(n),s=0;for(let o of this.sourceBuffers||[])s=an(o,r,s);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=t:this.json.buffers=[{byteLength:t}],this.gltf.binary=n,this.sourceBuffers=[n]}_removeStringFromArray(t,n){let r=!0;for(;r;){let s=t.indexOf(n);s>-1?t.splice(s,1):r=!1}}_addAttributes(t={}){let n={};for(let r in t){let s=t[r],o=this._getGltfAttributeName(r),i=this.addBinaryBuffer(s.value,s);n[o]=i}return n}_addIndices(t){return this.addBinaryBuffer(t,{size:1})}_getGltfAttributeName(t){switch(t.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return t}}_getAccessorMinMax(t,n){let r={min:null,max:null};if(t.lengthA===l);h===-1&&(h=r.push(l)-1),o.push(h)}let i=new Uint32Array(o),c=e.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,a=e.addBufferView(i,c,0),f=e.addAccessor(a,{size:1,componentType:Ct(i),count:i.length});s.attributes[t]=f}function fa(e,t,n,r,s=[0]){let o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=n[r],c=n[r+1],a=1;t&&(t.indexOf("image/jpeg")!==-1||t.indexOf("image/png")!==-1)&&(a=4);let f=la(i,c,e,a),l=0;for(let h of s){let A=typeof h=="number"?Object.values(o)[h]:o[h],p=f+A.offset,m=Vt(e);if(m.data.length<=p)throw new Error(`${m.data.length} <= ${p}`);let d=m.data[p];l|=d<r)break;let f=c/s,l=a/s;o.push(e.slice(f,f+l))}return o}function Re(e,t,n){let r=[];for(let s=0;sua,name:()=>da});var In="EXT_structural_metadata",da=In;async function ua(e,t){let n=new _(e);ga(n,t)}function ga(e,t){if(!t.gltf?.loadBuffers)return;let n=e.getExtension(In);n&&(t.gltf?.loadImages&&Ba(e,n),xa(e,n))}function Ba(e,t){let n=t.propertyTextures,r=e.gltf.json;if(n&&r.meshes)for(let s of r.meshes)for(let o of s.primitives)Ca(e,n,o,t)}function xa(e,t){let n=t.schema;if(!n)return;let r=n.classes,s=t.propertyTables;if(r&&s)for(let o in r){let i=Ma(s,o);i&&_a(e,n,i)}}function Ma(e,t){for(let n of e)if(n.class===t)return n;return null}function Ca(e,t,n,r){if(!t)return;let o=n.extensions?.[In]?.propertyTextures;if(o)for(let i of o){let c=t[i];Ea(e,c,n,r)}}function Ea(e,t,n,r){if(!t.properties)return;r.dataAttributeNames||(r.dataAttributeNames=[]);let s=t.class;for(let o in t.properties){let i=`${s}_${o}`,c=t.properties?.[o];if(!c)continue;c.data||(c.data=[]);let a=c.data,f=yt(e,c,n);f!==null&&(ye(e,i,f,a,n),c.data=a,r.dataAttributeNames.push(i))}}function _a(e,t,n){let r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);let s=n.count;for(let o in r.properties){let i=r.properties[o],c=n.properties?.[o];if(c){let a=Ta(e,t,i,s,c);c.data=a}}}function Ta(e,t,n,r,s){let o=[],i=s.values,c=e.getTypedArrayForBufferView(i),a=ya(e,n,s,r),f=ba(e,s,r);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{o=Ra(n,r,c,a);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":{o=Ie(r,c,a,f);break}case"ENUM":{o=Ia(t,n,r,c,a);break}default:throw new Error(`Unknown classProperty type ${n.type}`)}return o}function ya(e,t,n,r){return t.array&&typeof t.count>"u"&&typeof n.arrayOffsets<"u"?_t(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",r):null}function ba(e,t,n){return typeof t.stringOffsets<"u"?_t(e,t.stringOffsets,t.stringOffsetType||"UINT32",n):null}function Ra(e,t,n,r){let s=e.array,o=e.count,i=Yt(e.type,e.componentType),c=n.byteLength/i,a;return e.componentType?a=Tt(n,e.type,e.componentType,c):a=n,s?r?be(a,t,r,n.length,i):o?Re(a,t,o):[]:a}function Ia(e,t,n,r,s){let o=t.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let i=e.enums?.[o];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);let c=i.valueType||"UINT16",a=Yt(t.type,c),f=r.byteLength/a,l=Tt(r,t.type,c,f);if(l||(l=r),t.array){if(s)return Sa({valuesData:l,numberOfElements:n,arrayOffsets:s,valuesDataBytesLength:r.length,elementSize:a,enumEntry:i});let h=t.count;return h?La(l,n,h,i):[]}return Sn(l,0,n,i)}function Sa(e){let{valuesData:t,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:s,elementSize:o,enumEntry:i}=e,c=[];for(let a=0;as)break;let h=f/o,A=l/o,p=Sn(t,h,A,i);c.push(p)}return c}function La(e,t,n,r){let s=[];for(let o=0;oOa,name:()=>Da});var _o="EXT_feature_metadata",Da=_o;async function Oa(e,t){let n=new _(e);Ga(n,t)}function Ga(e,t){if(!t.gltf?.loadBuffers)return;let n=e.getExtension(_o);n&&(t.gltf?.loadImages&&va(e,n),Pa(e,n))}function va(e,t){let n=t.schema;if(!n)return;let r=n.classes,{featureTextures:s}=t;if(r&&s)for(let o in r){let i=r[o],c=Na(s,o);c&&Ha(e,c,i)}}function Pa(e,t){let n=t.schema;if(!n)return;let r=n.classes,s=t.featureTables;if(r&&s)for(let o in r){let i=wa(s,o);i&&Ua(e,n,i)}}function wa(e,t){for(let n in e){let r=e[n];if(r.class===t)return r}return null}function Na(e,t){for(let n in e){let r=e[n];if(r.class===t)return r}return null}function Ua(e,t,n){if(!n.class)return;let r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);let s=n.count;for(let o in r.properties){let i=r.properties[o],c=n.properties?.[o];if(c){let a=Ja(e,t,i,s,c);c.data=a}}}function Ha(e,t,n){let r=t.class;for(let s in n.properties){let o=t?.properties?.[s];if(o){let i=ka(e,o,r);o.data=i}}}function Ja(e,t,n,r,s){let o=[],i=s.bufferView,c=e.getTypedArrayForBufferView(i),a=Ka(e,n,s,r),f=Xa(e,n,s,r);return n.type==="STRING"||n.componentType==="STRING"?o=Ie(r,c,a,f):Va(n)&&(o=ja(n,r,c,a)),o}function Ka(e,t,n,r){return t.type==="ARRAY"&&typeof t.componentCount>"u"&&typeof n.arrayOffsetBufferView<"u"?_t(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",r):null}function Xa(e,t,n,r){return typeof n.stringOffsetBufferView<"u"?_t(e,n.stringOffsetBufferView,n.offsetType||"UINT32",r):null}function Va(e){let t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||typeof e.componentType<"u"&&t.includes(e.componentType)}function ja(e,t,n,r){let s=e.type==="ARRAY",o=e.componentCount,i="SCALAR",c=e.componentType||e.type,a=Yt(i,c),f=n.byteLength/a,l=Tt(n,i,c,f);return s?r?be(l,t,r,n.length,a):o?Re(l,t,o):[]:l}function ka(e,t,n){let r=e.gltf.json;if(!r.meshes)return[];let s=[];for(let o of r.meshes)for(let i of o.primitives)Ya(e,n,t,s,i);return s}function Ya(e,t,n,r,s){let o={channels:n.channels,...n.texture},i=yt(e,o,s);i&&ye(e,t,i,r,s)}var To="4.2.1";var bt=!0,yo=1735152710,Gn=12,Se=8,za=1313821514,Qa=5130562,Wa=0,qa=0,Za=1;function $a(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}function bo(e,t=0,n={}){let r=new DataView(e),{magic:s=yo}=n,o=r.getUint32(t,!1);return o===s||o===yo}function Ro(e,t,n=0,r={}){let s=new DataView(t),o=$a(s,n+0),i=s.getUint32(n+4,bt),c=s.getUint32(n+8,bt);switch(Object.assign(e,{header:{byteOffset:n,byteLength:c,hasBinChunk:!1},type:o,version:i,json:{},binChunks:[]}),n+=Gn,e.version){case 1:return tf(e,s,n);case 2:return ef(e,s,n,r={});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function tf(e,t,n){U(e.header.byteLength>Gn+Se);let r=t.getUint32(n+0,bt),s=t.getUint32(n+4,bt);return n+=Se,U(s===Wa),Dn(e,t,n,r),n+=r,n+=On(e,t,n,e.header.byteLength),n}function ef(e,t,n,r){return U(e.header.byteLength>Gn+Se),nf(e,t,n,r),n+e.header.byteLength}function nf(e,t,n,r){for(;n+8<=e.header.byteLength;){let s=t.getUint32(n+0,bt),o=t.getUint32(n+4,bt);switch(n+=Se,o){case za:Dn(e,t,n,s);break;case Qa:On(e,t,n,s);break;case qa:r.strict||Dn(e,t,n,s);break;case Za:r.strict||On(e,t,n,s);break;default:break}n+=rt(s,4)}return n}function Dn(e,t,n,r){let s=new Uint8Array(t.buffer,n,r),i=new TextDecoder("utf8").decode(s);return e.json=JSON.parse(i),rt(r,4)}function On(e,t,n,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer}),rt(r,4)}function vn(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;let r=t.baseUri||t.uri;if(!r)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return r.substr(0,r.lastIndexOf("/")+1)+e}var wn={};N(wn,{decode:()=>df,name:()=>mf});var rf="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZ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F9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",of=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),cf=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),af={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},ff={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Io(e,t,n,r,s,o="NONE"){let i=await lf();pf(i,i.exports[ff[s]],e,t,n,r,i.exports[af[o||"NONE"]])}var Pn;async function lf(){return Pn||(Pn=hf()),Pn}async function hf(){let e=rf;WebAssembly.validate(of)&&(e=sf,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let t=await WebAssembly.instantiate(Af(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}function Af(e){let t=new Uint8Array(e.length);for(let r=0;r96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let n=0;for(let r=0;rgf,preprocess:()=>Bf});var Rt="EXT_texture_webp",gf=Rt;function Bf(e,t){let n=new _(e);if(!Cn("image/webp")){if(n.getRequiredExtensions().includes(Rt))throw new Error(`gltf: Required extension ${Rt} not supported by browser`);return}let{json:r}=n;for(let s of r.textures||[]){let o=n.getObjectExtension(s,Rt);o&&(s.source=o.source),n.removeObjectExtension(s,Rt)}n.removeExtension(Rt)}var Un={};N(Un,{name:()=>xf,preprocess:()=>Mf});var Fe="KHR_texture_basisu",xf=Fe;function Mf(e,t){let n=new _(e),{json:r}=n;for(let s of r.textures||[]){let o=n.getObjectExtension(s,Fe);o&&(s.source=o.source,n.removeObjectExtension(s,Fe))}n.removeExtension(Fe)}var Vn={};N(Vn,{decode:()=>Pf,encode:()=>wf,name:()=>Gf,preprocess:()=>vf});var So="4.2.1";var Lo={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:So,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function Do(e,t,n){let r=Oo(t.metadata),s=[],o=Cf(t.attributes);for(let i in e){let c=e[i],a=Fo(i,c,o[i]);s.push(a)}if(n){let i=Fo("indices",n);s.push(i)}return{fields:s,metadata:r}}function Cf(e){let t={};for(let n in e){let r=e[n];t[r.name||"undefined"]=r}return t}function Fo(e,t,n){let r=n?Oo(n.metadata):void 0;return en(e,t,r)}function Oo(e){Object.entries(e);let t={};for(let n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}var Go={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Ef={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},_f=4,zt=class{draco;decoder;metadataQuerier;constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,n={}){let r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(n);let s=this.decoder.GetEncodedGeometryType(r),o=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(s){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(r,o);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(r,o);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!o.ptr){let A=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(A)}let c=this._getDracoLoaderData(o,s,n),a=this._getMeshData(o,c,n),f=Nt(a.attributes),l=Do(a.attributes,c,a.indices);return{loader:"draco",loaderData:c,header:{vertexCount:o.num_points(),boundingBox:f},...a,schema:l}}finally{this.draco.destroy(r),o&&this.draco.destroy(o)}}_getDracoLoaderData(t,n,r){let s=this._getTopLevelMetadata(t),o=this._getDracoAttributes(t,r);return{geometry_type:n,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:s,attributes:o}}_getDracoAttributes(t,n){let r={};for(let s=0;sthis.decoder[i]).includes(s)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(c=>i.min_value(c))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(t,n){let{octahedronAttributes:r=[]}=n,s=t.attribute_type();if(r.map(i=>this.decoder[i]).includes(s)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function Tf(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}function yf(e){let t=e.size(),n=new Int32Array(t);for(let r=0;r({draco:n})):Kn||=Sf(e),await Kn}async function Sf(e){let t,n;switch(e.draco&&e.draco.decoderType){case"js":t=await z(Jn[D.FALLBACK_DECODER],"draco",e,D.FALLBACK_DECODER);break;case"wasm":default:[t,n]=await Promise.all([await z(Jn[D.DECODER],"draco",e,D.DECODER),await z(Jn[D.DECODER_WASM],"draco",e,D.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await Lf(t,n)}function Lf(e,t){let n={};return t&&(n.wasmBinary=t),new Promise(r=>{e({...n,onModuleLoaded:s=>r({draco:s})})})}var Po={...Lo,parse:Ff};async function Ff(e,t){let{draco:n}=await vo(t),r=new zt(n);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}function wo(e){let t={};for(let n in e){let r=e[n];if(n!=="indices"){let s=Xn(r);t[n]=s}}return t}function Xn(e){let{buffer:t,size:n,count:r}=Df(e);return{value:t,size:n,byteOffset:0,count:r,type:Te(n),componentType:Ct(t)}}function Df(e){let t=e,n=1,r=0;return e&&e.value&&(t=e.value,n=e.size||1),t&&(ArrayBuffer.isView(t)||(t=Of(t,Float32Array)),r=t.length/n),{buffer:t,size:n,count:r}}function Of(e,t,n=!1){return e?Array.isArray(e)?new t(e):n&&!(e instanceof t)?new t(e):e:null}var st="KHR_draco_mesh_compression",Gf=st;function vf(e,t,n){let r=new _(e);for(let s of No(r))r.getObjectExtension(s,st)}async function Pf(e,t,n){if(!t?.gltf?.decompressMeshes)return;let r=new _(e),s=[];for(let o of No(r))r.getObjectExtension(o,st)&&s.push(Nf(r,o,t,n));await Promise.all(s),r.removeExtension(st)}function wf(e,t={}){let n=new _(e);for(let r of n.json.meshes||[])Uf(r,t),n.addRequiredExtension(st)}async function Nf(e,t,n,r){let s=e.getObjectExtension(t,st);if(!s)return;let o=e.getTypedArrayForBufferView(s.bufferView),i=Xt(o.buffer,o.byteOffset),c={...n};delete c["3d-tiles"];let a=await Jt(i,Po,c,r),f=wo(a.attributes);for(let[l,h]of Object.entries(f))if(l in t.attributes){let A=t.attributes[l],p=e.getAccessor(A);p?.min&&p?.max&&(h.min=p.min,h.max=p.max)}t.attributes=f,a.indices&&(t.indices=Xn(a.indices)),e.removeObjectExtension(t,st),Hf(t)}function Uf(e,t,n=4,r,s){if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let o=r.DracoWriter.encodeSync({attributes:e}),i=s?.parseSync?.({attributes:e}),c=r._addFauxAttributes(i.attributes),a=r.addBufferView(o);return{primitives:[{attributes:c,mode:n,extensions:{[st]:{bufferView:a,attributes:c}}}]}}function Hf(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*No(e){for(let t of e.json.meshes||[])for(let n of t.primitives)yield n}var qn={};N(qn,{decode:()=>nl,name:()=>$f});var Hd=1/Math.PI*180,Jd=1/180*Math.PI,Jf={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Jf}};var I=globalThis.mathgl.config;function Uo(e,{precision:t=I.precision}={}){return e=Kf(e),`${parseFloat(e.toPrecision(t))}`}function It(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function jn(e,t,n){let r=I.EPSILON;n&&(I.EPSILON=n);try{if(e===t)return!0;if(It(e)&&It(t)){if(e.length!==t.length)return!1;for(let s=0;s0?", ":"")+Uo(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n=0&&t=0&&t0?this.copy([t,...n]):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}identity(){return this.copy(Wf)}fromObject(t){return this.check()}fromQuaternion(t){return si(this,t),this.check()}set(t,n,r,s,o,i,c,a,f){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=o,this[5]=i,this[6]=c,this[7]=a,this[8]=f,this.check()}setRowMajor(t,n,r,s,o,i,c,a,f){return this[0]=t,this[1]=s,this[2]=c,this[3]=n,this[4]=o,this[5]=a,this[6]=r,this[7]=i,this[8]=f,this.check()}determinant(){return ei(this)}transpose(){return $o(this,this),this.check()}invert(){return ti(this,this),this.check()}multiplyLeft(t){return zn(this,t,this),this.check()}multiplyRight(t){return zn(this,this,t),this.check()}rotate(t){return ri(this,this,t),this.check()}scale(t){return Array.isArray(t)?Qn(this,this,t):Qn(this,this,[t,t]),this.check()}translate(t){return ni(this,this,t),this.check()}transform(t,n){let r;switch(t.length){case 2:r=Ko(n||[-0,-0],t,this);break;case 3:r=Oe(n||[-0,-0,-0],t,this);break;case 4:r=jo(n||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Ho(r,t.length),r}transformVector(t,n){return this.transform(t,n)}transformVector2(t,n){return this.transform(t,n)}transformVector3(t,n){return this.transform(t,n)}},Pe,we=null;function qf(){return Pe||(Pe=new $([0,0,0,0,0,0,0,0,0]),Object.freeze(Pe)),Pe}function Zf(){return we||(we=new $,Object.freeze(we)),we}var Ue="KHR_texture_transform",$f=Ue,Ne=new ft,tl=new $,el=new $;async function nl(e,t){if(!new _(e).hasExtension(Ue)||!t.gltf?.loadBuffers)return;let s=e.json.materials||[];for(let o=0;oi===r&&c===s)!==-1)){let i=fl(n);return r!==s&&(e.texCoord=s),t.push([r,s]),{originalTexCoord:r,texCoord:s,matrix:i}}return null}function il(e,t,n){let{originalTexCoord:r,texCoord:s,matrix:o}=n,i=t.attributes[`TEXCOORD_${r}`];if(Number.isFinite(i)){let c=e.json.accessors?.[i];if(c&&c.bufferView){let a=e.json.bufferViews?.[c.bufferView];if(a){let{arrayBuffer:f,byteOffset:l}=e.buffers[a.buffer],h=(l||0)+(c.byteOffset||0)+(a.byteOffset||0),{ArrayType:A,length:p}=Et(c,a),m=_e[c.componentType],d=Ee[c.type],u=a.byteStride||m*d,B=new Float32Array(p);for(let E=0;Ehl,encode:()=>Al,name:()=>ll});var lt="KHR_lights_punctual",ll=lt;async function hl(e){let t=new _(e),{json:n}=t,r=t.getExtension(lt);r&&(t.json.lights=r.lights,t.removeExtension(lt));for(let s of n.nodes||[]){let o=t.getObjectExtension(s,lt);o&&(s.light=o.light),t.removeObjectExtension(s,lt)}}async function Al(e){let t=new _(e),{json:n}=t;if(n.lights){let r=t.addExtension(lt);b(!r.lights),r.lights=n.lights,delete n.lights}if(t.json.lights){for(let r of t.json.lights){let s=r.node;t.addObjectExtension(s,lt,r)}delete t.json.lights}}var $n={};N($n,{decode:()=>ml,encode:()=>dl,name:()=>pl});var Qt="KHR_materials_unlit",pl=Qt;async function ml(e){let t=new _(e),{json:n}=t;for(let r of n.materials||[])r.extensions&&r.extensions.KHR_materials_unlit&&(r.unlit=!0),t.removeObjectExtension(r,Qt);t.removeExtension(Qt)}function dl(e){let t=new _(e),{json:n}=t;if(t.materials)for(let r of n.materials||[])r.unlit&&(delete r.unlit,t.addObjectExtension(r,Qt,{}),t.addExtension(Qt))}var tr={};N(tr,{decode:()=>gl,encode:()=>Bl,name:()=>ul});var Wt="KHR_techniques_webgl",ul=Wt;async function gl(e){let t=new _(e),{json:n}=t,r=t.getExtension(Wt);if(r){let s=xl(r,t);for(let o of n.materials||[]){let i=t.getObjectExtension(o,Wt);i&&(o.technique=Object.assign({},i,s[i.technique]),o.technique.values=Ml(o.technique,t)),t.removeObjectExtension(o,Wt)}t.removeExtension(Wt)}}async function Bl(e,t){}function xl(e,t){let{programs:n=[],shaders:r=[],techniques:s=[]}=e,o=new TextDecoder;return r.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=o.decode(t.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),n.forEach(i=>{i.fragmentShader=r[i.fragmentShader],i.vertexShader=r[i.vertexShader]}),s.forEach(i=>{i.program=n[i.program]}),s}function Ml(e,t){let n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(r=>{e.uniforms[r].value&&!(r in n)&&(n[r]=e.uniforms[r].value)}),Object.keys(n).forEach(r=>{typeof n[r]=="object"&&n[r].index!==void 0&&(n[r].texture=t.getTexture(n[r].index))}),n}var oi=[Ln,Rn,wn,Nn,Un,Vn,Zn,$n,tr,qn,Fn];function ii(e,t={},n){let r=oi.filter(s=>ai(s.name,t));for(let s of r)s.preprocess?.(e,t,n)}async function ci(e,t={},n){let r=oi.filter(s=>ai(s.name,t));for(let s of r)await s.decode?.(e,t,n)}function ai(e,t){let n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}var er="KHR_binary_glTF";function fi(e){let t=new _(e),{json:n}=t;for(let r of n.images||[]){let s=t.getObjectExtension(r,er);s&&Object.assign(r,s),t.removeObjectExtension(r,er)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(er)}var li={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},El={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},nr=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(t,n){this.json=t.json;let r=t.json;switch(r.asset&&r.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${r.asset.version}`);return}if(!n.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(r),this._convertTopLevelObjectsToArrays(r),fi(t),this._convertObjectIdsToArrayIndices(r),this._updateObjects(r),this._updateMaterial(r)}_addAsset(t){t.asset=t.asset||{},t.asset.version="2.0",t.asset.generator=t.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(t){for(let n in li)this._convertTopLevelObjectToArray(t,n)}_convertTopLevelObjectToArray(t,n){let r=t[n];if(!(!r||Array.isArray(r))){t[n]=[];for(let s in r){let o=r[s];o.id=o.id||s;let i=t[n].length;t[n].push(o),this.idToIndexMap[n][s]=i}}}_convertObjectIdsToArrayIndices(t){for(let n in li)this._convertIdsToIndices(t,n);"scene"in t&&(t.scene=this._convertIdToIndex(t.scene,"scene"));for(let n of t.textures)this._convertTextureIds(n);for(let n of t.meshes)this._convertMeshIds(n);for(let n of t.nodes)this._convertNodeIds(n);for(let n of t.scenes)this._convertSceneIds(n)}_convertTextureIds(t){t.source&&(t.source=this._convertIdToIndex(t.source,"image"))}_convertMeshIds(t){for(let n of t.primitives){let{attributes:r,indices:s,material:o}=n;for(let i in r)r[i]=this._convertIdToIndex(r[i],"accessor");s&&(n.indices=this._convertIdToIndex(s,"accessor")),o&&(n.material=this._convertIdToIndex(o,"material"))}}_convertNodeIds(t){t.children&&(t.children=t.children.map(n=>this._convertIdToIndex(n,"node"))),t.meshes&&(t.meshes=t.meshes.map(n=>this._convertIdToIndex(n,"mesh")))}_convertSceneIds(t){t.nodes&&(t.nodes=t.nodes.map(n=>this._convertIdToIndex(n,"node")))}_convertIdsToIndices(t,n){t[n]||(console.warn(`gltf v1: json doesn't contain attribute ${n}`),t[n]=[]);for(let r of t[n])for(let s in r){let o=r[s],i=this._convertIdToIndex(o,s);r[s]=i}}_convertIdToIndex(t,n){let r=El[n];if(r in this.idToIndexMap){let s=this.idToIndexMap[r][t];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${n} with id ${t}`);return s}return t}_updateObjects(t){for(let n of this.json.buffers)delete n.type}_updateMaterial(t){for(let n of t.materials){n.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let r=n.values?.tex||n.values?.texture2d_0||n.values?.diffuseTex,s=t.textures.findIndex(o=>o.id===r);s!==-1&&(n.pbrMetallicRoughness.baseColorTexture={index:s})}}};function hi(e,t={}){return new nr().normalize(e,t)}async function Ai(e,t,n=0,r,s){return _l(e,t,n,r),hi(e,{normalize:r?.gltf?.normalize}),ii(e,r,s),r?.gltf?.loadBuffers&&e.json.buffers&&await Tl(e,r,s),r?.gltf?.loadImages&&await yl(e,r,s),await ci(e,r,s),e}function _l(e,t,n,r){if(r.uri&&(e.baseUri=r.uri),t instanceof ArrayBuffer&&!bo(t,n,r)&&(t=new TextDecoder().decode(t)),typeof t=="string")e.json=cn(t);else if(t instanceof ArrayBuffer){let i={};n=Ro(i,t,n,r.glb),b(i.type==="glTF",`Invalid GLB magic string ${i.type}`),e._glb=i,e.json=i.json}else b(!1,"GLTF: must be ArrayBuffer or string");let s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){let{binChunks:i}=e._glb;e.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}let o=e.json.images||[];e.images=new Array(o.length).fill({})}async function Tl(e,t,n){let r=e.json.buffers||[];for(let s=0;sthis._resolveBufferView(s,o))),t.images&&(r.images=t.images.map((s,o)=>this._resolveImage(s,o))),t.samplers&&(r.samplers=t.samplers.map((s,o)=>this._resolveSampler(s,o))),t.textures&&(r.textures=t.textures.map((s,o)=>this._resolveTexture(s,o))),t.accessors&&(r.accessors=t.accessors.map((s,o)=>this._resolveAccessor(s,o))),t.materials&&(r.materials=t.materials.map((s,o)=>this._resolveMaterial(s,o))),t.meshes&&(r.meshes=t.meshes.map((s,o)=>this._resolveMesh(s,o))),t.nodes&&(r.nodes=t.nodes.map((s,o)=>this._resolveNode(s,o)),r.nodes=r.nodes.map((s,o)=>this._resolveNodeChildren(s))),t.skins&&(r.skins=t.skins.map((s,o)=>this._resolveSkin(s,o))),t.scenes&&(r.scenes=t.scenes.map((s,o)=>this._resolveScene(s,o))),typeof this.json.scene=="number"&&r.scenes&&(r.scene=r.scenes[this.json.scene]),r}getScene(t){return this._get(this.json.scenes,t)}getNode(t){return this._get(this.json.nodes,t)}getSkin(t){return this._get(this.json.skins,t)}getMesh(t){return this._get(this.json.meshes,t)}getMaterial(t){return this._get(this.json.materials,t)}getAccessor(t){return this._get(this.json.accessors,t)}getCamera(t){return this._get(this.json.cameras,t)}getTexture(t){return this._get(this.json.textures,t)}getSampler(t){return this._get(this.json.samplers,t)}getImage(t){return this._get(this.json.images,t)}getBufferView(t){return this._get(this.json.bufferViews,t)}getBuffer(t){return this._get(this.json.buffers,t)}_get(t,n){if(typeof n=="object")return n;let r=t&&t[n];return r||console.warn(`glTF file error: Could not find ${t}[${n}]`),r}_resolveScene(t,n){return{...t,id:t.id||`scene-${n}`,nodes:(t.nodes||[]).map(r=>this.getNode(r))}}_resolveNode(t,n){let r={...t,id:t?.id||`node-${n}`};return t.mesh!==void 0&&(r.mesh=this.getMesh(t.mesh)),t.camera!==void 0&&(r.camera=this.getCamera(t.camera)),t.skin!==void 0&&(r.skin=this.getSkin(t.skin)),t.meshes!==void 0&&t.meshes.length&&(r.mesh=t.meshes.reduce((s,o)=>{let i=this.getMesh(o);return s.id=i.id,s.primitives=s.primitives.concat(i.primitives),s},{primitives:[]})),r}_resolveNodeChildren(t){return t.children&&(t.children=t.children.map(n=>this.getNode(n))),t}_resolveSkin(t,n){let r=typeof t.inverseBindMatrices=="number"?this.getAccessor(t.inverseBindMatrices):void 0;return{...t,id:t.id||`skin-${n}`,inverseBindMatrices:r}}_resolveMesh(t,n){let r={...t,id:t.id||`mesh-${n}`,primitives:[]};return t.primitives&&(r.primitives=t.primitives.map(s=>{let o={...s,attributes:{},indices:void 0,material:void 0},i=s.attributes;for(let c in i)o.attributes[c]=this.getAccessor(i[c]);return s.indices!==void 0&&(o.indices=this.getAccessor(s.indices)),s.material!==void 0&&(o.material=this.getMaterial(s.material)),o})),r}_resolveMaterial(t,n){let r={...t,id:t.id||`material-${n}`};if(r.normalTexture&&(r.normalTexture={...r.normalTexture},r.normalTexture.texture=this.getTexture(r.normalTexture.index)),r.occlusionTexture&&(r.occlusionTexture={...r.occlusionTexture},r.occlusionTexture.texture=this.getTexture(r.occlusionTexture.index)),r.emissiveTexture&&(r.emissiveTexture={...r.emissiveTexture},r.emissiveTexture.texture=this.getTexture(r.emissiveTexture.index)),r.emissiveFactor||(r.emissiveFactor=r.emissiveTexture?[1,1,1]:[0,0,0]),r.pbrMetallicRoughness){r.pbrMetallicRoughness={...r.pbrMetallicRoughness};let s=r.pbrMetallicRoughness;s.baseColorTexture&&(s.baseColorTexture={...s.baseColorTexture},s.baseColorTexture.texture=this.getTexture(s.baseColorTexture.index)),s.metallicRoughnessTexture&&(s.metallicRoughnessTexture={...s.metallicRoughnessTexture},s.metallicRoughnessTexture.texture=this.getTexture(s.metallicRoughnessTexture.index))}return r}_resolveAccessor(t,n){let r=Gl(t.componentType),s=vl(t.type),o=r*s,i={...t,id:t.id||`accessor-${n}`,bytesPerComponent:r,components:s,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(t.bufferView!==void 0&&(i.bufferView=this.getBufferView(t.bufferView)),i.bufferView){let c=i.bufferView.buffer,{ArrayType:a,byteLength:f}=Et(i,i.bufferView),l=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+c.byteOffset,h=c.arrayBuffer.slice(l,l+f);i.bufferView.byteStride&&(h=this._getValueFromInterleavedBuffer(c,l,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new a(h)}return i}_getValueFromInterleavedBuffer(t,n,r,s,o){let i=new Uint8Array(o*s);for(let c=0;c{n.traverse(r=>{Object.values(r.model.uniforms).forEach(s=>{s.loaded===!1&&t.push(s)})})}),await Pl(()=>t.some(n=>!n.loaded))}async function Pl(e){for(;e();)await new Promise(t=>requestAnimationFrame(t))}var mi=`uniform scenegraphUniforms { float sizeScale; float sizeMinPixels; float sizeMaxPixels; mat4 sceneModelMatrix; bool composeModelMatrix; } scenegraph; `,di={name:"scenegraph",vs:mi,fs:mi,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4",composeModelMatrix:"f32"}};var ui=`#version 300 es #define SHADER_NAME scenegraph-layer-vertex-shader in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; in vec3 positions; #ifdef HAS_UV in vec2 texCoords; #endif #ifdef LIGHTING_PBR #ifdef HAS_NORMALS in vec3 normals; #endif #endif out vec4 vColor; #ifndef LIGHTING_PBR #ifdef HAS_UV out vec2 vTEXCOORD_0; #endif #endif void main(void) { #if defined(HAS_UV) && !defined(LIGHTING_PBR) vTEXCOORD_0 = texCoords; geometry.uv = texCoords; #endif geometry.worldPosition = instancePositions; geometry.pickingColor = instancePickingColors; mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 normal = vec3(0.0, 0.0, 1.0); #ifdef LIGHTING_PBR #ifdef HAS_NORMALS normal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(normals, 0.0)).xyz; #endif #endif float originalSize = project_size_to_pixel(scenegraph.sizeScale); float clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels); vec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * (clampedSize / originalSize) + instanceTranslation; if(scenegraph.composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); geometry.normal = project_normal(normal); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position); } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position); geometry.normal = project_normal(normal); } DECKGL_FILTER_GL_POSITION(gl_Position, geometry); #ifdef LIGHTING_PBR pbr_vPosition = geometry.position.xyz; #ifdef HAS_NORMALS pbr_vNormal = geometry.normal; #endif #ifdef HAS_UV pbr_vUV = texCoords; #else pbr_vUV = vec2(0., 0.); #endif geometry.uv = pbr_vUV; #endif vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); } `;var gi=`#version 300 es #define SHADER_NAME scenegraph-layer-fragment-shader in vec4 vColor; out vec4 fragColor; #ifndef LIGHTING_PBR #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) in vec2 vTEXCOORD_0; uniform sampler2D pbr_baseColorSampler; #endif #endif void main(void) { #ifdef LIGHTING_PBR fragColor = vColor * pbr_filterColor(vec4(0)); geometry.uv = pbr_vUV; #else #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) fragColor = vColor * texture(pbr_baseColorSampler, vTEXCOORD_0); geometry.uv = vTEXCOORD_0; #else fragColor = vColor; #endif #endif fragColor.a *= layer.opacity; DECKGL_FILTER_COLOR(fragColor, geometry); } `;var Bi=[255,255,255,255],wl={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?typeof e.scene=="object"?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:Bi},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[qt]},Zt=class extends W.Layer{getShaders(){let t={},n;this.props._lighting==="pbr"?(n=wt,t.LIGHTING_PBR=1):n={name:"pbrMaterial"};let r=[W.project32,W.picking,di,n];return super.getShaders({defines:t,vs:ui,fs:gi,modules:r})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:Bi,transition:!0},instanceModelMatrix:he})}updateState(t){super.updateState(t);let{props:n,oldProps:r}=t;n.scenegraph!==r.scenegraph?this._updateScenegraph():n._animations!==r._animations&&this._applyAnimationsProp(this.state.animator,n._animations)}finalizeState(t){super.finalizeState(t),this.state.scenegraph?.destroy()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){let t=this.props,{device:n}=this.context,r=null;if(t.scenegraph instanceof ht.ScenegraphNode)r={scenes:[t.scenegraph]};else if(t.scenegraph&&typeof t.scenegraph=="object"){let c=t.scenegraph,a=c.json?sr(c):c,f=bn(n,a,this._getModelOptions());r={gltf:a,...f},pi(f).then(()=>{this.setNeedsRedraw()}).catch(l=>{this.raiseError(l,"loading glTF")})}let s={layer:this,device:this.context.device},o=t.getScene(r,s),i=t.getAnimator(r,s);if(o instanceof ht.GroupNode){this.state.scenegraph?.destroy(),this._applyAnimationsProp(i,t._animations);let c=[];o.traverse(a=>{a instanceof ht.ModelNode&&c.push(a.model)}),this.setState({scenegraph:o,animator:i,models:c}),this.getAttributeManager().invalidateAll()}else o!==null&&W.log.warn("invalid scenegraph:",o)()}_applyAnimationsProp(t,n){if(!t||!n)return;let r=t.getAnimations();Object.keys(n).sort().forEach(s=>{let o=n[s];if(s==="*")r.forEach(i=>{Object.assign(i,o)});else if(Number.isFinite(Number(s))){let i=Number(s);i>=0&&ic===s);i?Object.assign(i,o):W.log.warn(`animation ${s} not found`)()}})}_getModelOptions(){let{_imageBasedLightingEnvironment:t}=this.props,n;return t&&(typeof t=="function"?n=t({gl:this.context.gl,layer:this}):n=t),{imageBasedLightingEnvironment:n,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:t}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(t.timeline.getTime()),this.setNeedsRedraw());let{viewport:n,renderPass:r}=this.context,{sizeScale:s,sizeMinPixels:o,sizeMaxPixels:i,coordinateSystem:c}=this.props,a=this.getNumInstances();this.state.scenegraph.traverse((f,{worldMatrix:l})=>{if(f instanceof ht.ModelNode){let{model:h}=f;h.setInstanceCount(a);let A={camera:h.uniforms.cameraPosition},p={sizeScale:s,sizeMinPixels:o,sizeMaxPixels:i,composeModelMatrix:Ae(n,c),sceneModelMatrix:l};h.shaderInputs.setProps({pbrProjection:A,scenegraph:p}),h.draw(r)}})}};Zt.defaultProps=wl;Zt.layerName="ScenegraphLayer";var xi=Zt;return yi($t);})(); return __exports__; });