@luma.gl/gltf 9.0.21 → 9.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.min.js CHANGED
@@ -4,7 +4,7 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- var __exports__=(()=>{var Ln=Object.create;var ot=Object.defineProperty;var Rn=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var vn=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty;var Kt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),wn=(e,t)=>{for(var n in t)ot(e,n,{get:t[n],enumerable:!0})},it=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of In(t))!Nn.call(e,s)&&s!==n&&ot(e,s,{get:()=>t[s],enumerable:!(r=Rn(t,s))||r.enumerable});return e},ct=(e,t,n)=>(it(e,t,"default"),n&&it(n,t,"default")),D=(e,t,n)=>(n=e!=null?Ln(vn(e)):{},it(t||!e||!e.__esModule?ot(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>it(ot({},"__esModule",{value:!0}),e);var j=Kt((Kr,Qt)=>{Qt.exports=globalThis.luma});var Pt=Kt((Js,ge)=>{ge.exports=globalThis.luma});var st={};wn(st,{GLTFAnimator:()=>W,createScenegraphsFromGLTF:()=>Tn,loadPBREnvironment:()=>xe,parsePBRMaterial:()=>at});ct(st,D(j(),1));var Zt=D(j(),1),C;(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"})(C||(C={}));function at(e,t,n,r){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:i}=r;return i&&(s.bindings.u_DiffuseEnvSampler=i.diffuseEnvSampler,s.bindings.u_SpecularEnvSampler=i.specularEnvSampler,s.bindings.u_brdfLUT=i.brdfLutTexture,s.uniforms.u_ScaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],s.uniforms.u_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&&On(e,t,s),s}function On(e,t,n){if(n.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Pn(e,t.pbrMetallicRoughness,n),t.normalTexture){K(e,t.normalTexture,"u_NormalSampler","HAS_NORMALMAP",n);let{scale:r=1}=t.normalTexture;n.uniforms.u_NormalScale=r}if(t.occlusionTexture){K(e,t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",n);let{strength:r=1}=t.occlusionTexture;n.uniforms.u_OcclusionStrength=r}switch(t.emissiveTexture&&(K(e,t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",n),n.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:r=.5}=t;n.defines.ALPHA_CUTOFF=1,n.uniforms.u_AlphaCutoff=r;break;case"BLEND":Zt.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=C.FUNC_ADD,n.glParameters.blendFunc=[C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA];break}}function Pn(e,t,n){t.baseColorTexture&&K(e,t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",n),n.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&K(e,t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",n);let{metallicFactor:r=1,roughnessFactor:s=1}=t;n.uniforms.u_MetallicRoughnessValues=[r,s]}function K(e,t,n,r=null,s){let i=t?.texture?.sampler?.parameters||{},o=t.texture.source.image,c,a={};o.compressed?(c=o,a={[C.TEXTURE_MIN_FILTER]:o.data.length>1?C.LINEAR_MIPMAP_NEAREST:C.LINEAR}):c={data:o};let f=e.createTexture({id:t.uniformName||t.id,parameters:{...i,...a},pixelStore:{[C.UNPACK_FLIP_Y_WEBGL]:!1},...c});s.bindings[n]=f,r&&(s.defines[r]=1),s.generatedTextures.push(f)}function q(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var B={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Cn=B.self||B.window||B.global||{},Bn=B.window||B.self||B.global||{},zn=B.global||B.self||B.window||{},kn=B.document||{};var Tt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Jt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Fn=Jt&&parseFloat(Jt[1])||0;var Un="",te={};function Lt(e){for(let t in te)if(e.startsWith(t)){let n=te[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Un}${e}`),e}var ee="4.2.1";var Vn=globalThis.loaders?.parseImageNode,Rt=typeof Image<"u",It=typeof ImageBitmap<"u",qn=Boolean(Vn),vt=Tt?!0:qn;function ne(e){switch(e){case"auto":return It||Rt||vt;case"imagebitmap":return It;case"image":return Rt;case"data":return vt;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function re(){if(It)return"imagebitmap";if(Rt)return"image";if(vt)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function se(e){let t=Dn(e);if(!t)throw new Error("Not an image");return t}function Nt(e){return ft(e)}function ft(e){switch(se(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Dn(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var Yn=/^data:image\/svg\+xml/,Hn=/\.svg((\?|#).*)?$/;function lt(e){return e&&(Yn.test(e)||Hn.test(e))}function ie(e,t){if(lt(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return wt(e,t)}function wt(e,t){if(lt(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function ht(e,t,n){let r=ie(e,n),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await Gn(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function Gn(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,s)=>{try{n.onload=()=>r(n),n.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var Wn={},oe=!0;async function ce(e,t,n){let r;lt(n)?r=await ht(e,t,n):r=wt(e,n);let s=t&&t.imagebitmap;return await $n(r,s)}async function $n(e,t=null){if((Xn(t)||!oe)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),oe=!1}return await createImageBitmap(e)}function Xn(e){for(let t in e||Wn)return!1;return!0}function ae(e){return!Zn(e,"ftyp",4)||!(e[8]&96)?null:jn(e)}function jn(e){switch(Kn(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Kn(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Qn(e){return[...e].map(t=>t.charCodeAt(0))}function Zn(e,t,n=0){let r=Qn(t);for(let s=0;s<r.length;++s)if(r[s]!==e[s+n])return!1;return!0}var z=!1,Q=!0;function pt(e){let t=Z(e);return tr(t)||rr(t)||er(t)||nr(t)||Jn(t)}function Jn(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=ae(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function tr(e){let t=Z(e);return t.byteLength>=24&&t.getUint32(0,z)===2303741511?{mimeType:"image/png",width:t.getUint32(16,z),height:t.getUint32(20,z)}:null}function er(e){let t=Z(e);return t.byteLength>=10&&t.getUint32(0,z)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,Q),height:t.getUint16(8,Q)}:null}function nr(e){let t=Z(e);return t.byteLength>=14&&t.getUint16(0,z)===16973&&t.getUint32(2,Q)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Q),height:t.getUint32(22,Q)}:null}function rr(e){let t=Z(e);if(!(t.byteLength>=3&&t.getUint16(0,z)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=sr(),i=2;for(;i+9<t.byteLength;){let o=t.getUint16(i,z);if(s.has(o))return{mimeType:"image/jpeg",height:t.getUint16(i+5,z),width:t.getUint16(i+7,z)};if(!r.has(o))return null;i+=2,i+=t.getUint16(i,z)}return null}function sr(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Z(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function fe(e,t){let{mimeType:n}=pt(e)||{},r=globalThis.loaders?.parseImageNode;return q(r),await r(e,n)}async function le(e,t,n){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=n||{},o=ir(s),c;switch(o){case"imagebitmap":c=await ce(e,t,i);break;case"image":c=await ht(e,t,i);break;case"data":c=await fe(e,t);break;default:q(!1)}return s==="data"&&(c=ft(c)),c}function ir(e){switch(e){case"auto":case"data":return re();default:return ne(e),e}}var or=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],cr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],ar={image:{type:"auto",decode:!0}},mt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:ee,mimeTypes:cr,extensions:or,parse:le,tests:[e=>Boolean(pt(new DataView(e)))],options:ar};function xt(e,t,n){let r=typeof e=="function"?e({...t,...n}):e,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),Lt(r)}var fr=e=>e&&typeof e=="object";async function he(e,t,n={}){return await bt(e,t,n)}async function bt(e,t,n){return Array.isArray(e)?await hr(e,t,n):fr(e)?await lr(e,t,n):await t(e,n)}async function lr(e,t,n){let r=[],s={};for(let i in e){let o=e[i],c=bt(o,t,n).then(a=>{s[i]=a});r.push(c)}return await Promise.all(r),s}async function hr(e,t,n={}){let r=e.map(s=>bt(s,t,n));return await Promise.all(r)}async function pe(e,t,n){return await he(e,r=>Ot(r,t,n))}async function Ot(e,t,n){let s=await(await fetch(e,n.fetch)).arrayBuffer();return await t(s,n)}async function J(e,t={}){let n=await pr(e,t);return await pe(n,mt.parse,t)}async function pr(e,t,n={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await mr(e,r,t,n):xt(e,t,n)}async function mr(e,t,n,r){let s=[];if(t==="auto"){let i=xt(e,n,{...r,lod:0}),o=await Ot(i,mt.parse,n),{width:c,height:a}=Nt(o);t=xr({width:c,height:a}),s.push(i)}q(t>0);for(let i=s.length;i<t;++i){let o=xt(e,n,{...r,lod:i});s.push(o)}return s}function xr(e){return 1+Math.floor(Math.log2(Math.max(e.width,e.height)))}function xe(e,t){let n=e.createTexture({id:"brdfLUT",sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"},data:J(t.brdfLutUrl)}),r=me(e,{id:"DiffuseEnvSampler",getTextureForFace:i=>J(t.getTexUrl("diffuse",i,0)),sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}}),s=me(e,{id:"SpecularEnvSampler",getTextureForFace:i=>{let o=[];for(let c=0;c<=t.specularMipLevels-1;c++)o.push(J(t.getTexUrl("specular",i,c)));return o},sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}});return{brdfLutTexture:n,diffuseEnvSampler:r,specularEnvSampler:s}}var gr=[0,1,2,3,4,5];function me(e,{id:t,getTextureForFace:n,sampler:r}){let s={};return gr.forEach(i=>{s[String(i)]=n(i)}),e.createTexture({id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var $=D(Pt(),1);var ti=1/Math.PI*180,ei=1/180*Math.PI,dr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...dr}};var L=globalThis.mathgl.config;function de(e,{precision:t=L.precision}={}){return e=Mr(e),`${parseFloat(e.toPrecision(t))}`}function Y(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ct(e,t,n){let r=L.EPSILON;n&&(L.EPSILON=n);try{if(e===t)return!0;if(Y(e)&&Y(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!Ct(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=L.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{L.EPSILON=r}}function Mr(e){return Math.round(e/L.EPSILON)*L.EPSILON}var V=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Y(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(L)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+de(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<this.ELEMENTS;++n)if(!Ct(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(L.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function ur(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function y(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function H(e,t,n=""){if(L.debug&&!ur(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Bt(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var gt=class extends V{get x(){return this[0]}set x(t){this[0]=y(t)}get y(){return this[1]}set y(t){this[1]=y(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return y(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return y(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Bt(t>=0&&t<this.ELEMENTS,"index is out of range"),y(this[t])}setComponent(t,n){return Bt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var R=typeof Float32Array<"u"?Float32Array:Array;var pi=Math.PI/180;function _r(){let e=new R(2);return R!=Float32Array&&(e[0]=0,e[1]=0),e}function _e(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var mi=function(){let e=_r();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function Ae(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function Se(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Ee(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function ye(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function zt(){let e=new R(3);return R!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Ar(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function kt(e,t,n){let r=new R(3);return r[0]=e,r[1]=t,r[2]=n,r}function Te(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Le(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function dt(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function Mt(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Re(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],f=t[2],l=s*f-i*a,h=i*c-r*f,p=r*a-s*c,m=s*p-i*h,x=i*l-r*p,g=r*h-s*l,d=o*2;return l*=d,h*=d,p*=d,m*=2,x*=2,g*=2,e[0]=c+l+m,e[1]=a+h+x,e[2]=f+p+g,e}var Ie=Ar;var di=function(){let e=zt();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var ut,G=class extends gt{static get ZERO(){return ut||(ut=new G(0,0,0,0),Object.freeze(ut)),ut}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),Y(t)&&arguments.length===1?this.copy(t):(L.debug&&(y(t),y(n),y(r),y(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return L.debug&&(y(t.x),y(t.y),y(t.z),y(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=y(t)}get w(){return this[3]}set w(t){this[3]=y(t)}transform(t){return Mt(this,this,t),this.check()}transformByMatrix3(t){return ye(this,this,t),this.check()}transformByMatrix2(t){return Ee(this,this,t),this.check()}transformByQuaternion(t){return Re(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var _t=class extends V{toString(){let t="[";if(L.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=y(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function ve(){let e=new R(9);return R!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function yr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ne(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function we(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],f=t[7],l=t[8],h=t[9],p=t[10],m=t[11],x=t[12],g=t[13],d=t[14],S=t[15],T=n*c-r*o,M=n*a-s*o,u=n*f-i*o,_=r*a-s*c,A=r*f-i*c,I=s*f-i*a,v=l*g-h*x,N=l*d-p*x,w=l*S-m*x,b=h*d-p*g,O=h*S-m*g,P=p*S-m*d,E=T*P-M*O+u*b+_*w-A*N+I*v;return E?(E=1/E,e[0]=(c*P-a*O+f*b)*E,e[1]=(s*O-r*P-i*b)*E,e[2]=(g*I-d*A+S*_)*E,e[3]=(p*A-h*I-m*_)*E,e[4]=(a*w-o*P-f*N)*E,e[5]=(n*P-s*w+i*N)*E,e[6]=(d*u-x*I-S*M)*E,e[7]=(l*I-p*u+m*M)*E,e[8]=(o*O-c*w+f*v)*E,e[9]=(r*w-n*O-i*v)*E,e[10]=(x*A-g*u+S*T)*E,e[11]=(h*u-l*A-m*T)*E,e[12]=(c*N-o*b-a*v)*E,e[13]=(n*b-r*N+s*v)*E,e[14]=(g*M-x*_-d*T)*E,e[15]=(l*_-h*M+p*T)*E,e):null}function be(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],f=e[8],l=e[9],h=e[10],p=e[11],m=e[12],x=e[13],g=e[14],d=e[15],S=t*o-n*i,T=t*c-r*i,M=n*c-r*o,u=f*x-l*m,_=f*g-h*m,A=l*g-h*x,I=t*A-n*_+r*u,v=i*A-o*_+c*u,N=f*M-l*T+h*S,w=m*M-x*T+g*S;return a*I-s*v+d*N-p*w}function Ft(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],f=t[6],l=t[7],h=t[8],p=t[9],m=t[10],x=t[11],g=t[12],d=t[13],S=t[14],T=t[15],M=n[0],u=n[1],_=n[2],A=n[3];return e[0]=M*r+u*c+_*h+A*g,e[1]=M*s+u*a+_*p+A*d,e[2]=M*i+u*f+_*m+A*S,e[3]=M*o+u*l+_*x+A*T,M=n[4],u=n[5],_=n[6],A=n[7],e[4]=M*r+u*c+_*h+A*g,e[5]=M*s+u*a+_*p+A*d,e[6]=M*i+u*f+_*m+A*S,e[7]=M*o+u*l+_*x+A*T,M=n[8],u=n[9],_=n[10],A=n[11],e[8]=M*r+u*c+_*h+A*g,e[9]=M*s+u*a+_*p+A*d,e[10]=M*i+u*f+_*m+A*S,e[11]=M*o+u*l+_*x+A*T,M=n[12],u=n[13],_=n[14],A=n[15],e[12]=M*r+u*c+_*h+A*g,e[13]=M*s+u*a+_*p+A*d,e[14]=M*i+u*f+_*m+A*S,e[15]=M*o+u*l+_*x+A*T,e}function Oe(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,f,l,h,p,m,x,g,d,S;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],f=t[3],l=t[4],h=t[5],p=t[6],m=t[7],x=t[8],g=t[9],d=t[10],S=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=f,e[4]=l,e[5]=h,e[6]=p,e[7]=m,e[8]=x,e[9]=g,e[10]=d,e[11]=S,e[12]=o*r+l*s+x*i+t[12],e[13]=c*r+h*s+g*i+t[13],e[14]=a*r+p*s+d*i+t[14],e[15]=f*r+m*s+S*i+t[15]),e}function Pe(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ce(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,f,l,h,p,m,x,g,d,S,T,M,u,_,A,I,v,N,w,b,O,P,E,X;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,f=Math.sin(n),a=Math.cos(n),l=1-a,h=t[0],p=t[1],m=t[2],x=t[3],g=t[4],d=t[5],S=t[6],T=t[7],M=t[8],u=t[9],_=t[10],A=t[11],I=s*s*l+a,v=i*s*l+o*f,N=o*s*l-i*f,w=s*i*l-o*f,b=i*i*l+a,O=o*i*l+s*f,P=s*o*l+i*f,E=i*o*l-s*f,X=o*o*l+a,e[0]=h*I+g*v+M*N,e[1]=p*I+d*v+u*N,e[2]=m*I+S*v+_*N,e[3]=x*I+T*v+A*N,e[4]=h*w+g*b+M*O,e[5]=p*w+d*b+u*O,e[6]=m*w+S*b+_*O,e[7]=x*w+T*b+A*O,e[8]=h*P+g*E+M*X,e[9]=p*P+d*E+u*X,e[10]=m*P+S*E+_*X,e[11]=x*P+T*E+A*X,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Be(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],f=t[8],l=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+f*r,e[5]=o*s+l*r,e[6]=c*s+h*r,e[7]=a*s+p*r,e[8]=f*s-i*r,e[9]=l*s-o*r,e[10]=h*s-c*r,e[11]=p*s-a*r,e}function ze(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],f=t[8],l=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-f*r,e[1]=o*s-l*r,e[2]=c*s-h*r,e[3]=a*s-p*r,e[8]=i*r+f*s,e[9]=o*r+l*s,e[10]=c*r+h*s,e[11]=a*r+p*s,e}function ke(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],f=t[4],l=t[5],h=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+f*r,e[1]=o*s+l*r,e[2]=c*s+h*r,e[3]=a*s+p*r,e[4]=f*s-i*r,e[5]=l*s-o*r,e[6]=h*s-c*r,e[7]=p*s-a*r,e}function Fe(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,f=n*o,l=r*o,h=r*c,p=s*o,m=s*c,x=s*a,g=i*o,d=i*c,S=i*a;return e[0]=1-h-x,e[1]=l+S,e[2]=p-d,e[3]=0,e[4]=l-S,e[5]=1-f-x,e[6]=m+g,e[7]=0,e[8]=p+d,e[9]=m-g,e[10]=1-f-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ue(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),f=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*f,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*f,e[15]=0,e}function Tr(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var Ve=Tr;function Lr(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),f=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*f,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*f,e[15]=1,e}var qe=Lr;function De(e,t,n,r){let s,i,o,c,a,f,l,h,p,m,x=t[0],g=t[1],d=t[2],S=r[0],T=r[1],M=r[2],u=n[0],_=n[1],A=n[2];return Math.abs(x-u)<1e-6&&Math.abs(g-_)<1e-6&&Math.abs(d-A)<1e-6?yr(e):(h=x-u,p=g-_,m=d-A,s=1/Math.sqrt(h*h+p*p+m*m),h*=s,p*=s,m*=s,i=T*m-M*p,o=M*h-S*m,c=S*p-T*h,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-m*o,f=m*i-h*c,l=h*o-p*i,s=Math.sqrt(a*a+f*f+l*l),s?(s=1/s,a*=s,f*=s,l*=s):(a=0,f=0,l=0),e[0]=i,e[1]=a,e[2]=h,e[3]=0,e[4]=o,e[5]=f,e[6]=p,e[7]=0,e[8]=c,e[9]=l,e[10]=m,e[11]=0,e[12]=-(i*x+o*g+c*d),e[13]=-(a*x+f*g+l*d),e[14]=-(h*x+p*g+m*d),e[15]=1,e)}function Rr(){let e=new R(4);return R!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Ye(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function He(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Ge(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function We(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function $e(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function Xe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function je(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function Ke(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function Qe(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],f=n[3],l=f*r+c*i-a*s,h=f*s+a*r-o*i,p=f*i+o*s-c*r,m=-o*r-c*s-a*i;return e[0]=l*f+m*-o+h*-a-p*-c,e[1]=h*f+m*-c+p*-o-l*-a,e[2]=p*f+m*-a+l*-c-h*-o,e[3]=t[3],e}var vi=function(){let e=Rr();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var qt;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(qt||(qt={}));var vr=45*Math.PI/180,Nr=1,Ut=.1,Vt=500,wr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),F=class extends _t{static get IDENTITY(){return Or()}static get ZERO(){return br()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return qt}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,f,l,h,p,m,x,g,d){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=f,this[9]=l,this[10]=h,this[11]=p,this[12]=m,this[13]=x,this[14]=g,this[15]=d,this.check()}setRowMajor(t,n,r,s,i,o,c,a,f,l,h,p,m,x,g,d){return this[0]=t,this[1]=i,this[2]=f,this[3]=m,this[4]=n,this[5]=o,this[6]=l,this[7]=x,this[8]=r,this[9]=c,this[10]=h,this[11]=g,this[12]=s,this[13]=a,this[14]=p,this[15]=d,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(wr)}fromObject(t){return this.check()}fromQuaternion(t){return Fe(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=Ut,far:c=Vt}=t;return c===1/0?Pr(this,n,r,s,i,o):Ue(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return De(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=Ut,far:c=Vt}=t;return qe(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=vr,aspect:r=Nr,focalDistance:s=1,near:i=Ut,far:o=Vt}=t;Ze(n);let c=n/2,a=s*Math.tan(c),f=a*r;return this.ortho({left:-f,right:f,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return Ze(n),Ve(this,n,r,s,i),this.check()}determinant(){return be(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return Ne(this,this),this.check()}invert(){return we(this,this),this.check()}multiplyLeft(t){return Ft(this,t,this),this.check()}multiplyRight(t){return Ft(this,this,t),this.check()}rotateX(t){return Be(this,this,t),this.check()}rotateY(t){return ze(this,this,t),this.check()}rotateZ(t){return ke(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return Ce(this,this,t,n),this.check()}scale(t){return Pe(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Oe(this,this,t),this.check()}transform(t,n){return t.length===4?(n=Ke(n||[-0,-0,-0,-0],t,this),H(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=_e(n||[-0,-0],t,this);break;case 3:s=Mt(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return H(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=Ae(n||[-0,-0],t,this);break;case 3:r=Se(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return H(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},At,St;function br(){return At||(At=new F([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(At)),At}function Or(){return St||(St=new F,Object.freeze(St)),St}function Ze(e){if(e>Math.PI*2)throw Error("expected radians")}function Pr(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),f=(s+r)/(s-r),l=-1,h=-1,p=-2*i;return e[0]=o,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]=p,e[15]=0,e}function Je(){let e=new R(4);return R!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function tn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Dt(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 Yt(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],f=n[2],l=n[3];return e[0]=r*l+o*c+s*f-i*a,e[1]=s*l+o*a+i*c-r*f,e[2]=i*l+o*f+r*a-s*c,e[3]=o*l-r*c-s*a-i*f,e}function en(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=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]=i*a-s*c,e[3]=o*a-r*c,e}function nn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=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]=i*a+r*c,e[3]=o*a-s*c,e}function rn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=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]=i*a+o*c,e[3]=o*a-i*c,e}function sn(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 et(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],f=n[1],l=n[2],h=n[3],p,m,x,g,d;return p=s*a+i*f+o*l+c*h,p<0&&(p=-p,a=-a,f=-f,l=-l,h=-h),1-p>1e-6?(m=Math.acos(p),d=Math.sin(m),x=Math.sin((1-r)*m)/d,g=Math.sin(r*m)/d):(x=1-r,g=r),e[0]=x*s+g*a,e[1]=x*i+g*f,e[2]=x*o+g*l,e[3]=x*c+g*h,e}function on(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function cn(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Ht(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 i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var an=Ye;var fn=He,ln=Xe,hn=je,pn=Ge;var mn=We;var xn=$e;var gn=function(){let e=zt(),t=kt(1,0,0),n=kt(0,1,0);return function(r,s,i){let o=Le(s,i);return o<-.999999?(dt(e,t,s),Ie(e)<1e-6&&dt(e,n,s),Te(e,e),Dt(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(dt(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,xn(r,r))}}(),Di=function(){let e=Je(),t=Je();return function(n,r,s,i,o,c){return et(e,r,o,c),et(t,s,i,c),et(n,e,t,2*c*(1-c)),n}}(),Yi=function(){let e=ve();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],xn(t,Ht(t,e))}}();var Cr=[0,0,0,1],nt=class extends V{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 Ht(this,t),this.check()}fromAxisRotation(t,n){return Dt(this,t,n),this.check()}identity(){return tn(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 pn(this)}lengthSquared(){return mn(this)}dot(t){return ln(this,t)}rotationTo(t,n){return gn(this,t,n),this.check()}add(t){return an(this,this,t),this.check()}calculateW(){return sn(this,this),this.check()}conjugate(){return cn(this,this),this.check()}invert(){return on(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(hn(this,t,n,r),this.check())}multiplyRight(t){return Yt(this,this,t),this.check()}multiplyLeft(t){return Yt(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 en(this,this,t),this.check()}rotateY(t){return nn(this,this,t),this.check()}rotateZ(t){return rn(this,this,t),this.check()}scale(t){return fn(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=Cr,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return et(this,s,i,o),this.check()}transformVector4(t,n=new G){return Qe(n,t,this),H(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 rt=D(j(),1);var Br={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Wt=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:i,path:o})=>{Dr(r,s,i,o),Fr(i,i._node)})}},W=class{animations;constructor(t){this.animations=t.animations.map((n,r)=>{let s=n.name||`Animation-${r}`,i=n.samplers.map(({input:c,interpolation:a="LINEAR",output:f})=>({input:dn(t.accessors[c]),interpolation:a,output:dn(t.accessors[f])})),o=n.channels.map(({sampler:c,target:a})=>({sampler:i[c],target:t.nodes[a.node],path:a.path}));return new Wt({name:s,channels:o})})}animate(t){this.setTime(t)}setTime(t){this.animations.forEach(n=>n.animate(t))}getAnimations(){return this.animations}};function dn(e){if(!e._animation){let t=zr[e.componentType],n=Br[e.type],r=n*e.count,{buffer:s,byteOffset:i}=e.bufferView.data,o=new t(s,i+(e.byteOffset||0),r);if(n===1)e._animation=Array.from(o);else{let c=[];for(let a=0;a<o.length;a+=n)c.push(Array.from(o.slice(a,a+n)));e._animation=c}}return e._animation}var kr=new F;function Fr(e,t){if(t.matrix.identity(),e.translation&&t.matrix.translate(e.translation),e.rotation){let n=kr.fromQuaternion(e.rotation);t.matrix.multiplyRight(n)}e.scale&&t.matrix.scale(e.scale)}var Gt=new nt;function Ur(e,t,n,r,s){if(t==="rotation"){Gt.slerp({start:n,target:r,ratio:s});for(let i=0;i<Gt.length;i++)e[t][i]=Gt[i]}else for(let i=0;i<n.length;i++)e[t][i]=s*r[i]+(1-s)*n[i]}function Vr(e,t,{p0:n,outTangent0:r,inTangent1:s,p1:i,tDiff:o,ratio:c}){for(let a=0;a<e[t].length;a++){let f=r[a]*o,l=s[a]*o;e[t][a]=(2*Math.pow(c,3)-3*Math.pow(c,2)+1)*n[a]+(Math.pow(c,3)-2*Math.pow(c,2)+c)*f+(-2*Math.pow(c,3)+3*Math.pow(c,2))*i[a]+(Math.pow(c,3)-Math.pow(c,2))*l}}function qr(e,t,n){for(let r=0;r<n.length;r++)e[t][r]=n[r]}function Dr(e,{input:t,interpolation:n,output:r},s,i){let o=t[t.length-1],c=e%o,a=t.findIndex(p=>p>=c),f=Math.max(0,a-1);if(!Array.isArray(s[i]))switch(i){case"translation":s[i]=[0,0,0];break;case"rotation":s[i]=[0,0,0,1];break;case"scale":s[i]=[1,1,1];break;default:rt.log.warn(`Bad animation path ${i}`)()}(0,rt.assert)(s[i].length===r[f].length);let l=t[f],h=t[a];switch(n){case"STEP":qr(s,i,r[f]);break;case"LINEAR":if(h>l){let p=(c-l)/(h-l);Ur(s,i,r[f],r[a],p)}break;case"CUBICSPLINE":if(h>l){let p=(c-l)/(h-l),m=h-l,x=r[3*f+1],g=r[3*f+2],d=r[3*a+0],S=r[3*a+1];Vr(s,i,{p0:x,outTangent0:g,inTangent1:d,p1:S,tDiff:m,ratio:p})}break;default:rt.log.warn(`Interpolation ${n} not supported`)();break}}var En=D(j(),1);var $t=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
7
+ var __exports__=(()=>{var In=Object.create;var at=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var wn=Object.getPrototypeOf,On=Object.prototype.hasOwnProperty;var Zt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Cn=(e,t)=>{for(var n in t)at(e,n,{get:t[n],enumerable:!0})},ct=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pn(t))!On.call(e,s)&&s!==n&&at(e,s,{get:()=>t[s],enumerable:!(r=Nn(t,s))||r.enumerable});return e},lt=(e,t,n)=>(ct(e,t,"default"),n&&ct(n,t,"default")),D=(e,t,n)=>(n=e!=null?In(wn(e)):{},ct(t||!e||!e.__esModule?at(n,"default",{value:e,enumerable:!0}):n,e)),Bn=e=>ct(at({},"__esModule",{value:!0}),e);var Y=Zt((ns,Jt)=>{Jt.exports=globalThis.luma});var Bt=Zt((ii,Me)=>{Me.exports=globalThis.luma});var ot={};Cn(ot,{GLTFAnimator:()=>G,createScenegraphsFromGLTF:()=>Rn,loadPBREnvironment:()=>de,parsePBRMaterial:()=>ft});lt(ot,D(Y(),1));var te=D(Y(),1),C;(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"})(C||(C={}));function ft(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:i}=r;return i&&(s.bindings.pbr_diffuseEnvSampler=i.diffuseEnvSampler,s.bindings.pbr_specularEnvSampler=i.specularEnvSampler,s.bindings.pbr_BrdfLUT=i.brdfLutTexture,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&&zn(e,t,s),s}function zn(e,t,n){if(n.uniforms.unlit=Boolean(t.unlit),t.pbrMetallicRoughness&&kn(e,t.pbrMetallicRoughness,n),t.normalTexture){K(e,t.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",n);let{scale:r=1}=t.normalTexture;n.uniforms.normalScale=r}if(t.occlusionTexture){K(e,t.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",n);let{strength:r=1}=t.occlusionTexture;n.uniforms.occlusionStrength=r}switch(t.emissiveTexture&&(K(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":te.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=C.FUNC_ADD,n.glParameters.blendFunc=[C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA];break}}function kn(e,t,n){t.baseColorTexture&&K(e,t.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",n),n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&K(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",n);let{metallicFactor:r=1,roughnessFactor:s=1}=t;n.uniforms.metallicRoughnessValues=[r,s]}function K(e,t,n,r=null,s){let i=t?.texture?.sampler?.parameters||{},o=t.texture.source.image,c,a={};o.compressed?(c=o,a={[C.TEXTURE_MIN_FILTER]:o.data.length>1?C.LINEAR_MIPMAP_NEAREST:C.LINEAR}):c={data:o};let l=e.createTexture({id:t.uniformName||t.id,parameters:{...i,...a},pixelStore:{[C.UNPACK_FLIP_Y_WEBGL]:!1},...c});s.bindings[n]=l,r&&(s.defines[r]=1),s.generatedTextures.push(l)}function q(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var B={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Fn=B.self||B.window||B.global||{},Un=B.window||B.self||B.global||{},Vn=B.global||B.self||B.window||{},Dn=B.document||{};var vt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var ee=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),qn=ee&&parseFloat(ee[1])||0;var Yn="",ne={};function _t(e){for(let t in ne)if(e.startsWith(t)){let n=ne[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Yn}${e}`),e}var re="4.2.1";var Wn=globalThis.loaders?.parseImageNode,Rt=typeof Image<"u",It=typeof ImageBitmap<"u",$n=Boolean(Wn),Nt=vt?!0:$n;function se(e){switch(e){case"auto":return It||Rt||Nt;case"imagebitmap":return It;case"image":return Rt;case"data":return Nt;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function ie(){if(It)return"imagebitmap";if(Rt)return"image";if(Nt)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function oe(e){let t=Hn(e);if(!t)throw new Error("Not an image");return t}function Pt(e){return ht(e)}function ht(e){switch(oe(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Hn(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var Gn=/^data:image\/svg\+xml/,jn=/\.svg((\?|#).*)?$/;function pt(e){return e&&(Gn.test(e)||jn.test(e))}function ce(e,t){if(pt(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return wt(e,t)}function wt(e,t){if(pt(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function mt(e,t,n){let r=ce(e,n),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await Xn(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function Xn(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,s)=>{try{n.onload=()=>r(n),n.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var Kn={},ae=!0;async function le(e,t,n){let r;pt(n)?r=await mt(e,t,n):r=wt(e,n);let s=t&&t.imagebitmap;return await Qn(r,s)}async function Qn(e,t=null){if((Zn(t)||!ae)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),ae=!1}return await createImageBitmap(e)}function Zn(e){for(let t in e||Kn)return!1;return!0}function fe(e){return!nr(e,"ftyp",4)||!(e[8]&96)?null:Jn(e)}function Jn(e){switch(tr(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function tr(e,t,n){return String.fromCharCode(...e.slice(t,n))}function er(e){return[...e].map(t=>t.charCodeAt(0))}function nr(e,t,n=0){let r=er(t);for(let s=0;s<r.length;++s)if(r[s]!==e[s+n])return!1;return!0}var z=!1,Q=!0;function xt(e){let t=Z(e);return sr(t)||cr(t)||ir(t)||or(t)||rr(t)}function rr(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=fe(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function sr(e){let t=Z(e);return t.byteLength>=24&&t.getUint32(0,z)===2303741511?{mimeType:"image/png",width:t.getUint32(16,z),height:t.getUint32(20,z)}:null}function ir(e){let t=Z(e);return t.byteLength>=10&&t.getUint32(0,z)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,Q),height:t.getUint16(8,Q)}:null}function or(e){let t=Z(e);return t.byteLength>=14&&t.getUint16(0,z)===16973&&t.getUint32(2,Q)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Q),height:t.getUint32(22,Q)}:null}function cr(e){let t=Z(e);if(!(t.byteLength>=3&&t.getUint16(0,z)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=ar(),i=2;for(;i+9<t.byteLength;){let o=t.getUint16(i,z);if(s.has(o))return{mimeType:"image/jpeg",height:t.getUint16(i+5,z),width:t.getUint16(i+7,z)};if(!r.has(o))return null;i+=2,i+=t.getUint16(i,z)}return null}function ar(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Z(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function he(e,t){let{mimeType:n}=xt(e)||{},r=globalThis.loaders?.parseImageNode;return q(r),await r(e,n)}async function pe(e,t,n){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=n||{},o=lr(s),c;switch(o){case"imagebitmap":c=await le(e,t,i);break;case"image":c=await mt(e,t,i);break;case"data":c=await he(e,t);break;default:q(!1)}return s==="data"&&(c=ht(c)),c}function lr(e){switch(e){case"auto":case"data":return ie();default:return se(e),e}}var fr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],hr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],pr={image:{type:"auto",decode:!0}},gt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:re,mimeTypes:hr,extensions:fr,parse:pe,tests:[e=>Boolean(xt(new DataView(e)))],options:pr};function dt(e,t,n){let r=typeof e=="function"?e({...t,...n}):e,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),_t(r)}var mr=e=>e&&typeof e=="object";async function me(e,t,n={}){return await Ot(e,t,n)}async function Ot(e,t,n){return Array.isArray(e)?await gr(e,t,n):mr(e)?await xr(e,t,n):await t(e,n)}async function xr(e,t,n){let r=[],s={};for(let i in e){let o=e[i],c=Ot(o,t,n).then(a=>{s[i]=a});r.push(c)}return await Promise.all(r),s}async function gr(e,t,n={}){let r=e.map(s=>Ot(s,t,n));return await Promise.all(r)}async function xe(e,t,n){return await me(e,r=>Ct(r,t,n))}async function Ct(e,t,n){let s=await(await fetch(e,n.fetch)).arrayBuffer();return await t(s,n)}async function J(e,t={}){let n=await dr(e,t);return await xe(n,gt.parse,t)}async function dr(e,t,n={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await Mr(e,r,t,n):dt(e,t,n)}async function Mr(e,t,n,r){let s=[];if(t==="auto"){let i=dt(e,n,{...r,lod:0}),o=await Ct(i,gt.parse,n),{width:c,height:a}=Pt(o);t=Ar({width:c,height:a}),s.push(i)}q(t>0);for(let i=s.length;i<t;++i){let o=dt(e,n,{...r,lod:i});s.push(o)}return s}function Ar(e){return 1+Math.floor(Math.log2(Math.max(e.width,e.height)))}function de(e,t){let n=e.createTexture({id:"brdfLUT",sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"},data:J(t.brdfLutUrl)}),r=ge(e,{id:"DiffuseEnvSampler",getTextureForFace:i=>J(t.getTexUrl("diffuse",i,0)),sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}}),s=ge(e,{id:"SpecularEnvSampler",getTextureForFace:i=>{let o=[];for(let c=0;c<=t.specularMipLevels-1;c++)o.push(J(t.getTexUrl("specular",i,c)));return o},sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}});return{brdfLutTexture:n,diffuseEnvSampler:r,specularEnvSampler:s}}var yr=[0,1,2,3,4,5];function ge(e,{id:t,getTextureForFace:n,sampler:r}){let s={};return yr.forEach(i=>{s[String(i)]=n(i)}),e.createTexture({id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var j=D(Bt(),1);var oi=1/Math.PI*180,ci=1/180*Math.PI,ur={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ur}};var T=globalThis.mathgl.config;function Ae(e,{precision:t=T.precision}={}){return e=Er(e),`${parseFloat(e.toPrecision(t))}`}function W(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function zt(e,t,n){let r=T.EPSILON;n&&(T.EPSILON=n);try{if(e===t)return!0;if(W(e)&&W(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!zt(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=T.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{T.EPSILON=r}}function Er(e){return Math.round(e/T.EPSILON)*T.EPSILON}var V=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:W(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(T)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Ae(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<this.ELEMENTS;++n)if(!zt(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(T.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function Sr(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function b(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function $(e,t,n=""){if(T.debug&&!Sr(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function kt(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Mt=class extends V{get x(){return this[0]}set x(t){this[0]=b(t)}get y(){return this[1]}set y(t){this[1]=b(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return b(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return b(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return kt(t>=0&&t<this.ELEMENTS,"index is out of range"),b(this[t])}setComponent(t,n){return kt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var v=typeof Float32Array<"u"?Float32Array:Array;var Ai=Math.PI/180;function br(){let e=new v(2);return v!=Float32Array&&(e[0]=0,e[1]=0),e}function Ee(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var yi=function(){let e=br();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function Se(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function be(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Le(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function Te(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function Ft(){let e=new v(3);return v!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Lr(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Ut(e,t,n){let r=new v(3);return r[0]=e,r[1]=t,r[2]=n,r}function ve(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function _e(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function At(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function yt(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Re(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],l=t[2],f=s*l-i*a,p=i*c-r*l,h=r*a-s*c,m=s*h-i*p,x=i*f-r*h,g=r*p-s*f,d=o*2;return f*=d,p*=d,h*=d,m*=2,x*=2,g*=2,e[0]=c+f+m,e[1]=a+p+x,e[2]=l+h+g,e}var Ie=Lr;var Si=function(){let e=Ft();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var ut,H=class extends Mt{static get ZERO(){return ut||(ut=new H(0,0,0,0),Object.freeze(ut)),ut}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),W(t)&&arguments.length===1?this.copy(t):(T.debug&&(b(t),b(n),b(r),b(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return T.debug&&(b(t.x),b(t.y),b(t.z),b(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=b(t)}get w(){return this[3]}set w(t){this[3]=b(t)}transform(t){return yt(this,this,t),this.check()}transformByMatrix3(t){return Te(this,this,t),this.check()}transformByMatrix2(t){return Le(this,this,t),this.check()}transformByQuaternion(t){return Re(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var Et=class extends V{toString(){let t="[";if(T.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=b(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function Ne(){let e=new v(9);return v!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function _r(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Pe(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function we(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],l=t[7],f=t[8],p=t[9],h=t[10],m=t[11],x=t[12],g=t[13],d=t[14],E=t[15],L=n*c-r*o,M=n*a-s*o,A=n*l-i*o,y=r*a-s*c,u=r*l-i*c,_=s*l-i*a,R=f*g-p*x,I=f*d-h*x,N=f*E-m*x,P=p*d-h*g,w=p*E-m*g,O=h*E-m*d,S=L*O-M*w+A*P+y*N-u*I+_*R;return S?(S=1/S,e[0]=(c*O-a*w+l*P)*S,e[1]=(s*w-r*O-i*P)*S,e[2]=(g*_-d*u+E*y)*S,e[3]=(h*u-p*_-m*y)*S,e[4]=(a*N-o*O-l*I)*S,e[5]=(n*O-s*N+i*I)*S,e[6]=(d*A-x*_-E*M)*S,e[7]=(f*_-h*A+m*M)*S,e[8]=(o*w-c*N+l*R)*S,e[9]=(r*N-n*w-i*R)*S,e[10]=(x*u-g*A+E*L)*S,e[11]=(p*A-f*u-m*L)*S,e[12]=(c*I-o*P-a*R)*S,e[13]=(n*P-r*I+s*R)*S,e[14]=(g*M-x*y-d*L)*S,e[15]=(f*y-p*M+h*L)*S,e):null}function Oe(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],l=e[8],f=e[9],p=e[10],h=e[11],m=e[12],x=e[13],g=e[14],d=e[15],E=t*o-n*i,L=t*c-r*i,M=n*c-r*o,A=l*x-f*m,y=l*g-p*m,u=f*g-p*x,_=t*u-n*y+r*A,R=i*u-o*y+c*A,I=l*M-f*L+p*E,N=m*M-x*L+g*E;return a*_-s*R+d*I-h*N}function Vt(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],l=t[6],f=t[7],p=t[8],h=t[9],m=t[10],x=t[11],g=t[12],d=t[13],E=t[14],L=t[15],M=n[0],A=n[1],y=n[2],u=n[3];return e[0]=M*r+A*c+y*p+u*g,e[1]=M*s+A*a+y*h+u*d,e[2]=M*i+A*l+y*m+u*E,e[3]=M*o+A*f+y*x+u*L,M=n[4],A=n[5],y=n[6],u=n[7],e[4]=M*r+A*c+y*p+u*g,e[5]=M*s+A*a+y*h+u*d,e[6]=M*i+A*l+y*m+u*E,e[7]=M*o+A*f+y*x+u*L,M=n[8],A=n[9],y=n[10],u=n[11],e[8]=M*r+A*c+y*p+u*g,e[9]=M*s+A*a+y*h+u*d,e[10]=M*i+A*l+y*m+u*E,e[11]=M*o+A*f+y*x+u*L,M=n[12],A=n[13],y=n[14],u=n[15],e[12]=M*r+A*c+y*p+u*g,e[13]=M*s+A*a+y*h+u*d,e[14]=M*i+A*l+y*m+u*E,e[15]=M*o+A*f+y*x+u*L,e}function Ce(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,l,f,p,h,m,x,g,d,E;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],l=t[3],f=t[4],p=t[5],h=t[6],m=t[7],x=t[8],g=t[9],d=t[10],E=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=l,e[4]=f,e[5]=p,e[6]=h,e[7]=m,e[8]=x,e[9]=g,e[10]=d,e[11]=E,e[12]=o*r+f*s+x*i+t[12],e[13]=c*r+p*s+g*i+t[13],e[14]=a*r+h*s+d*i+t[14],e[15]=l*r+m*s+E*i+t[15]),e}function Be(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ze(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,l,f,p,h,m,x,g,d,E,L,M,A,y,u,_,R,I,N,P,w,O,S,X;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,l=Math.sin(n),a=Math.cos(n),f=1-a,p=t[0],h=t[1],m=t[2],x=t[3],g=t[4],d=t[5],E=t[6],L=t[7],M=t[8],A=t[9],y=t[10],u=t[11],_=s*s*f+a,R=i*s*f+o*l,I=o*s*f-i*l,N=s*i*f-o*l,P=i*i*f+a,w=o*i*f+s*l,O=s*o*f+i*l,S=i*o*f-s*l,X=o*o*f+a,e[0]=p*_+g*R+M*I,e[1]=h*_+d*R+A*I,e[2]=m*_+E*R+y*I,e[3]=x*_+L*R+u*I,e[4]=p*N+g*P+M*w,e[5]=h*N+d*P+A*w,e[6]=m*N+E*P+y*w,e[7]=x*N+L*P+u*w,e[8]=p*O+g*S+M*X,e[9]=h*O+d*S+A*X,e[10]=m*O+E*S+y*X,e[11]=x*O+L*S+u*X,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function ke(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],l=t[8],f=t[9],p=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+l*r,e[5]=o*s+f*r,e[6]=c*s+p*r,e[7]=a*s+h*r,e[8]=l*s-i*r,e[9]=f*s-o*r,e[10]=p*s-c*r,e[11]=h*s-a*r,e}function Fe(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],l=t[8],f=t[9],p=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-l*r,e[1]=o*s-f*r,e[2]=c*s-p*r,e[3]=a*s-h*r,e[8]=i*r+l*s,e[9]=o*r+f*s,e[10]=c*r+p*s,e[11]=a*r+h*s,e}function Ue(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],l=t[4],f=t[5],p=t[6],h=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+l*r,e[1]=o*s+f*r,e[2]=c*s+p*r,e[3]=a*s+h*r,e[4]=l*s-i*r,e[5]=f*s-o*r,e[6]=p*s-c*r,e[7]=h*s-a*r,e}function Ve(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,l=n*o,f=r*o,p=r*c,h=s*o,m=s*c,x=s*a,g=i*o,d=i*c,E=i*a;return e[0]=1-p-x,e[1]=f+E,e[2]=h-d,e[3]=0,e[4]=f-E,e[5]=1-l-x,e[6]=m+g,e[7]=0,e[8]=h+d,e[9]=m-g,e[10]=1-l-p,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function De(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),l=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*l,e[15]=0,e}function Rr(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var qe=Rr;function Ir(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),l=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*l,e[15]=1,e}var Ye=Ir;function We(e,t,n,r){let s,i,o,c,a,l,f,p,h,m,x=t[0],g=t[1],d=t[2],E=r[0],L=r[1],M=r[2],A=n[0],y=n[1],u=n[2];return Math.abs(x-A)<1e-6&&Math.abs(g-y)<1e-6&&Math.abs(d-u)<1e-6?_r(e):(p=x-A,h=g-y,m=d-u,s=1/Math.sqrt(p*p+h*h+m*m),p*=s,h*=s,m*=s,i=L*m-M*h,o=M*p-E*m,c=E*h-L*p,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=h*c-m*o,l=m*i-p*c,f=p*o-h*i,s=Math.sqrt(a*a+l*l+f*f),s?(s=1/s,a*=s,l*=s,f*=s):(a=0,l=0,f=0),e[0]=i,e[1]=a,e[2]=p,e[3]=0,e[4]=o,e[5]=l,e[6]=h,e[7]=0,e[8]=c,e[9]=f,e[10]=m,e[11]=0,e[12]=-(i*x+o*g+c*d),e[13]=-(a*x+l*g+f*d),e[14]=-(p*x+h*g+m*d),e[15]=1,e)}function Nr(){let e=new v(4);return v!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function $e(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function He(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Ge(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function je(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function Xe(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function Ke(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Qe(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function Ze(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function Je(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],l=n[3],f=l*r+c*i-a*s,p=l*s+a*r-o*i,h=l*i+o*s-c*r,m=-o*r-c*s-a*i;return e[0]=f*l+m*-o+p*-a-h*-c,e[1]=p*l+m*-c+h*-o-f*-a,e[2]=h*l+m*-a+f*-c-p*-o,e[3]=t[3],e}var Ci=function(){let e=Nr();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var Yt;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Yt||(Yt={}));var wr=45*Math.PI/180,Or=1,Dt=.1,qt=500,Cr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),F=class extends Et{static get IDENTITY(){return zr()}static get ZERO(){return Br()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Yt}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,l,f,p,h,m,x,g,d){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=l,this[9]=f,this[10]=p,this[11]=h,this[12]=m,this[13]=x,this[14]=g,this[15]=d,this.check()}setRowMajor(t,n,r,s,i,o,c,a,l,f,p,h,m,x,g,d){return this[0]=t,this[1]=i,this[2]=l,this[3]=m,this[4]=n,this[5]=o,this[6]=f,this[7]=x,this[8]=r,this[9]=c,this[10]=p,this[11]=g,this[12]=s,this[13]=a,this[14]=h,this[15]=d,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Cr)}fromObject(t){return this.check()}fromQuaternion(t){return Ve(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=Dt,far:c=qt}=t;return c===1/0?kr(this,n,r,s,i,o):De(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return We(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=Dt,far:c=qt}=t;return Ye(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=wr,aspect:r=Or,focalDistance:s=1,near:i=Dt,far:o=qt}=t;tn(n);let c=n/2,a=s*Math.tan(c),l=a*r;return this.ortho({left:-l,right:l,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return tn(n),qe(this,n,r,s,i),this.check()}determinant(){return Oe(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return Pe(this,this),this.check()}invert(){return we(this,this),this.check()}multiplyLeft(t){return Vt(this,t,this),this.check()}multiplyRight(t){return Vt(this,this,t),this.check()}rotateX(t){return ke(this,this,t),this.check()}rotateY(t){return Fe(this,this,t),this.check()}rotateZ(t){return Ue(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return ze(this,this,t,n),this.check()}scale(t){return Be(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Ce(this,this,t),this.check()}transform(t,n){return t.length===4?(n=Ze(n||[-0,-0,-0,-0],t,this),$(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=Ee(n||[-0,-0],t,this);break;case 3:s=yt(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=Se(n||[-0,-0],t,this);break;case 3:r=be(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},St,bt;function Br(){return St||(St=new F([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(St)),St}function zr(){return bt||(bt=new F,Object.freeze(bt)),bt}function tn(e){if(e>Math.PI*2)throw Error("expected radians")}function kr(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),l=(s+r)/(s-r),f=-1,p=-1,h=-2*i;return e[0]=o,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]=l,e[10]=f,e[11]=p,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}function en(){let e=new v(4);return v!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function nn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Wt(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 $t(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],l=n[2],f=n[3];return e[0]=r*f+o*c+s*l-i*a,e[1]=s*f+o*a+i*c-r*l,e[2]=i*f+o*l+r*a-s*c,e[3]=o*f-r*c-s*a-i*l,e}function rn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=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]=i*a-s*c,e[3]=o*a-r*c,e}function sn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=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]=i*a+r*c,e[3]=o*a-s*c,e}function on(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=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]=i*a+o*c,e[3]=o*a-i*c,e}function cn(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 et(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],l=n[1],f=n[2],p=n[3],h,m,x,g,d;return h=s*a+i*l+o*f+c*p,h<0&&(h=-h,a=-a,l=-l,f=-f,p=-p),1-h>1e-6?(m=Math.acos(h),d=Math.sin(m),x=Math.sin((1-r)*m)/d,g=Math.sin(r*m)/d):(x=1-r,g=r),e[0]=x*s+g*a,e[1]=x*i+g*l,e[2]=x*o+g*f,e[3]=x*c+g*p,e}function an(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function ln(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Ht(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 i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var fn=$e;var hn=He,pn=Ke,mn=Qe,xn=Ge;var gn=je;var dn=Xe;var Mn=function(){let e=Ft(),t=Ut(1,0,0),n=Ut(0,1,0);return function(r,s,i){let o=_e(s,i);return o<-.999999?(At(e,t,s),Ie(e)<1e-6&&At(e,n,s),ve(e,e),Wt(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(At(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,dn(r,r))}}(),ji=function(){let e=en(),t=en();return function(n,r,s,i,o,c){return et(e,r,o,c),et(t,s,i,c),et(n,e,t,2*c*(1-c)),n}}(),Xi=function(){let e=Ne();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],dn(t,Ht(t,e))}}();var Fr=[0,0,0,1],nt=class extends V{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 Ht(this,t),this.check()}fromAxisRotation(t,n){return Wt(this,t,n),this.check()}identity(){return nn(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]=b(t)}get y(){return this[1]}set y(t){this[1]=b(t)}get z(){return this[2]}set z(t){this[2]=b(t)}get w(){return this[3]}set w(t){this[3]=b(t)}len(){return xn(this)}lengthSquared(){return gn(this)}dot(t){return pn(this,t)}rotationTo(t,n){return Mn(this,t,n),this.check()}add(t){return fn(this,this,t),this.check()}calculateW(){return cn(this,this),this.check()}conjugate(){return ln(this,this),this.check()}invert(){return an(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(mn(this,t,n,r),this.check())}multiplyRight(t){return $t(this,this,t),this.check()}multiplyLeft(t){return $t(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 rn(this,this,t),this.check()}rotateY(t){return sn(this,this,t),this.check()}rotateZ(t){return on(this,this,t),this.check()}scale(t){return hn(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=Fr,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return et(this,s,i,o),this.check()}transformVector4(t,n=new H){return Je(n,t,this),$(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 rt=D(Y(),1);var Ur={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Vr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jt=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:i,path:o})=>{Hr(r,s,i,o),qr(i,i._node)})}},G=class{animations;constructor(t){this.animations=t.animations.map((n,r)=>{let s=n.name||`Animation-${r}`,i=n.samplers.map(({input:c,interpolation:a="LINEAR",output:l})=>({input:An(t.accessors[c]),interpolation:a,output:An(t.accessors[l])})),o=n.channels.map(({sampler:c,target:a})=>({sampler:i[c],target:t.nodes[a.node],path:a.path}));return new jt({name:s,channels:o})})}animate(t){this.setTime(t)}setTime(t){this.animations.forEach(n=>n.animate(t))}getAnimations(){return this.animations}};function An(e){if(!e._animation){let t=Vr[e.componentType],n=Ur[e.type],r=n*e.count,{buffer:s,byteOffset:i}=e.bufferView.data,o=new t(s,i+(e.byteOffset||0),r);if(n===1)e._animation=Array.from(o);else{let c=[];for(let a=0;a<o.length;a+=n)c.push(Array.from(o.slice(a,a+n)));e._animation=c}}return e._animation}var Dr=new F;function qr(e,t){if(t.matrix.identity(),e.translation&&t.matrix.translate(e.translation),e.rotation){let n=Dr.fromQuaternion(e.rotation);t.matrix.multiplyRight(n)}e.scale&&t.matrix.scale(e.scale)}var Gt=new nt;function Yr(e,t,n,r,s){if(t==="rotation"){Gt.slerp({start:n,target:r,ratio:s});for(let i=0;i<Gt.length;i++)e[t][i]=Gt[i]}else for(let i=0;i<n.length;i++)e[t][i]=s*r[i]+(1-s)*n[i]}function Wr(e,t,{p0:n,outTangent0:r,inTangent1:s,p1:i,tDiff:o,ratio:c}){for(let a=0;a<e[t].length;a++){let l=r[a]*o,f=s[a]*o;e[t][a]=(2*Math.pow(c,3)-3*Math.pow(c,2)+1)*n[a]+(Math.pow(c,3)-2*Math.pow(c,2)+c)*l+(-2*Math.pow(c,3)+3*Math.pow(c,2))*i[a]+(Math.pow(c,3)-Math.pow(c,2))*f}}function $r(e,t,n){for(let r=0;r<n.length;r++)e[t][r]=n[r]}function Hr(e,{input:t,interpolation:n,output:r},s,i){let o=t[t.length-1],c=e%o,a=t.findIndex(h=>h>=c),l=Math.max(0,a-1);if(!Array.isArray(s[i]))switch(i){case"translation":s[i]=[0,0,0];break;case"rotation":s[i]=[0,0,0,1];break;case"scale":s[i]=[1,1,1];break;default:rt.log.warn(`Bad animation path ${i}`)()}(0,rt.assert)(s[i].length===r[l].length);let f=t[l],p=t[a];switch(n){case"STEP":$r(s,i,r[l]);break;case"LINEAR":if(p>f){let h=(c-f)/(p-f);Yr(s,i,r[l],r[a],h)}break;case"CUBICSPLINE":if(p>f){let h=(c-f)/(p-f),m=p-f,x=r[3*l+1],g=r[3*l+2],d=r[3*a+0],E=r[3*a+1];Wr(s,i,{p0:x,outTangent0:g,inTangent1:d,p1:E,tDiff:m,ratio:h})}break;default:rt.log.warn(`Interpolation ${n} not supported`)();break}}var vn=D(Y(),1);var Xt=`precision highp int;
8
8
  struct AmbientLight {
9
9
  vec3 color;
10
10
  };
@@ -17,22 +17,53 @@ struct DirectionalLight {
17
17
  vec3 color;
18
18
  vec3 direction;
19
19
  };
20
- uniform AmbientLight lighting_uAmbientLight;
21
- uniform PointLight lighting_uPointLight[MAX_LIGHTS];
22
- uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
23
- uniform int lighting_uPointLightCount;
24
- uniform int lighting_uDirectionalLightCount;
25
- uniform bool lighting_uEnabled;
20
+ uniform lightingUniforms {
21
+ int enabled;
22
+ int lightType;
23
+ int directionalLightCount;
24
+ int pointLightCount;
25
+ vec3 ambientColor;
26
+ vec3 lightColor0;
27
+ vec3 lightPosition0;
28
+ vec3 lightDirection0;
29
+ vec3 lightAttenuation0;
30
+ vec3 lightColor1;
31
+ vec3 lightPosition1;
32
+ vec3 lightDirection1;
33
+ vec3 lightAttenuation1;
34
+ vec3 lightColor2;
35
+ vec3 lightPosition2;
36
+ vec3 lightDirection2;
37
+ vec3 lightAttenuation2;
38
+ } lighting;
39
+ PointLight lighting_getPointLight(int index) {
40
+ switch (index) {
41
+ case 0:
42
+ return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
43
+ case 1:
44
+ return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
45
+ case 2:
46
+ default:
47
+ return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
48
+ }
49
+ }
50
+ DirectionalLight lighting_getDirectionalLight(int index) {
51
+ switch (index) {
52
+ case 0:
53
+ return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
54
+ case 1:
55
+ return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
56
+ case 2:
57
+ default:
58
+ return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
59
+ }
60
+ }
26
61
  float getPointLightAttenuation(PointLight pointLight, float distance) {
27
62
  return pointLight.attenuation.x
28
63
  + pointLight.attenuation.y * distance
29
64
  + pointLight.attenuation.z * distance * distance;
30
65
  }
31
- #endif
32
- `;var Yr={lightSources:{}};function Xt(e={}){let{color:t=[0,0,0],intensity:n=1}=e;return t.map(r=>r*n/255)}function Hr({ambientLight:e,pointLights:t=[],directionalLights:n=[]}){let r={};return e?r["lighting_uAmbientLight.color"]=Xt(e):r["lighting_uAmbientLight.color"]=[0,0,0],t.forEach((s,i)=>{r[`lighting_uPointLight[${i}].color`]=Xt(s),r[`lighting_uPointLight[${i}].position`]=s.position,r[`lighting_uPointLight[${i}].attenuation`]=s.attenuation||[1,0,0]}),r.lighting_uPointLightCount=t.length,n.forEach((s,i)=>{r[`lighting_uDirectionalLight[${i}].color`]=Xt(s),r[`lighting_uDirectionalLight[${i}].direction`]=s.direction}),r.lighting_uDirectionalLightCount=n.length,r}function Mn(e=Yr){if("lightSources"in e){let{ambientLight:t,pointLights:n,directionalLights:r}=e.lightSources||{};return t||n&&n.length>0||r&&r.length>0?Object.assign({},Hr({ambientLight:t,pointLights:n,directionalLights:r}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in e){let t={pointLights:[],directionalLights:[]};for(let n of e.lights||[])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 Mn({lightSources:t})}return{}}var un={name:"lights",vs:$t,fs:$t,getUniforms:Mn,defines:{MAX_LIGHTS:3}};var _n=`uniform mat4 u_MVPMatrix;
33
- uniform mat4 u_ModelMatrix;
34
- uniform mat4 u_NormalMatrix;
35
- out vec3 pbr_vPosition;
66
+ `;var yn=D(Y(),1),un=3,Gr=255,it;(function(e){e[e.POINT=0]="POINT",e[e.DIRECTIONAL=1]="DIRECTIONAL"})(it||(it={}));var st={name:"lighting",vs:Xt,fs:Xt,getUniforms(e,t){return jr(e)},defines:{MAX_LIGHTS:un},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:it.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]}};function jr(e,t={}){if(e=e&&{...e},!e)return{...st.defaultUniforms};e.lights&&(e={...e,...Kr(e.lights),lights:void 0});let{ambientLight:n,pointLights:r,directionalLights:s}=e||{};if(!(n||r&&r.length>0||s&&s.length>0))return{...st.defaultUniforms,enabled:0};let o={...st.defaultUniforms,...t,...Xr({ambientLight:n,pointLights:r,directionalLights:s})};return e.enabled!==void 0&&(o.enabled=e.enabled?1:0),o}function Xr({ambientLight:e,pointLights:t=[],directionalLights:n=[]}){let r={};r.ambientLightColor=Kt(e);let s=0;for(let i of t){r.lightType=it.POINT;let o=s;r[`lightColor${o}`]=Kt(i),r[`lightPosition${o}`]=i.position,r[`lightAttenuation${o}`]=i.attenuation||[1,0,0],s++}for(let i of n){r.lightType=it.DIRECTIONAL;let o=s;r[`lightColor${o}`]=Kt(i),r[`lightDirection${o}`]=i.direction,s++}return s>un&&yn.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=n.length,r.pointLightCount=t.length,r}function Kr(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 Kt(e={}){let{color:t=[0,0,0],intensity:n=1}=e;return t.map(r=>r*n/Gr)}var En=`out vec3 pbr_vPosition;
36
67
  out vec2 pbr_vUV;
37
68
  #ifdef HAS_NORMALS
38
69
  # ifdef HAS_TANGENTS
@@ -43,16 +74,16 @@ out vec3 pbr_vNormal;
43
74
  #endif
44
75
  void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
45
76
  {
46
- vec4 pos = u_ModelMatrix * position;
77
+ vec4 pos = pbrProjection.modelMatrix * position;
47
78
  pbr_vPosition = vec3(pos.xyz) / pos.w;
48
79
  #ifdef HAS_NORMALS
49
80
  #ifdef HAS_TANGENTS
50
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
51
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
81
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
82
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
52
83
  vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
53
84
  pbr_vTBN = mat3(tangentW, bitangentW, normalW);
54
85
  #else
55
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
86
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
56
87
  #endif
57
88
  #endif
58
89
  #ifdef HAS_UV
@@ -61,41 +92,45 @@ pbr_vUV = uv;
61
92
  pbr_vUV = vec2(0.,0.);
62
93
  #endif
63
94
  }
64
- `;var An=`precision highp float;
65
- uniform bool pbr_uUnlit;
66
- #ifdef USE_IBL
67
- uniform samplerCube u_DiffuseEnvSampler;
68
- uniform samplerCube u_SpecularEnvSampler;
69
- uniform sampler2D u_brdfLUT;
70
- uniform vec2 u_ScaleIBLAmbient;
71
- #endif
95
+ `;var Sn=`precision highp float;
96
+ uniform pbrMaterialUniforms {
97
+ bool unlit;
98
+ bool baseColorMapEnabled;
99
+ vec4 baseColorFactor;
100
+ bool normalMapEnabled;
101
+ float normalScale;
102
+ bool emissiveMapEnabled;
103
+ vec3 emissiveFactor;
104
+ vec2 metallicRoughnessValues;
105
+ bool metallicRoughnessMapEnabled;
106
+ bool occlusionMapEnabled;
107
+ float occlusionStrength;
108
+ bool alphaCutoffEnabled;
109
+ float alphaCutoff;
110
+ bool IBLenabled;
111
+ vec2 scaleIBLAmbient;
112
+ vec4 scaleDiffBaseMR;
113
+ vec4 scaleFGDSpec;
114
+ } pbrMaterial;
72
115
  #ifdef HAS_BASECOLORMAP
73
- uniform sampler2D u_BaseColorSampler;
116
+ uniform sampler2D pbr_baseColorSampler;
74
117
  #endif
75
118
  #ifdef HAS_NORMALMAP
76
- uniform sampler2D u_NormalSampler;
77
- uniform float u_NormalScale;
119
+ uniform sampler2D pbr_normalSampler;
78
120
  #endif
79
121
  #ifdef HAS_EMISSIVEMAP
80
- uniform sampler2D u_EmissiveSampler;
81
- uniform vec3 u_EmissiveFactor;
122
+ uniform sampler2D pbr_emissiveSampler;
82
123
  #endif
83
124
  #ifdef HAS_METALROUGHNESSMAP
84
- uniform sampler2D u_MetallicRoughnessSampler;
125
+ uniform sampler2D pbr_metallicRoughnessSampler;
85
126
  #endif
86
127
  #ifdef HAS_OCCLUSIONMAP
87
- uniform sampler2D u_OcclusionSampler;
88
- uniform float u_OcclusionStrength;
128
+ uniform sampler2D pbr_occlusionSampler;
89
129
  #endif
90
- #ifdef ALPHA_CUTOFF
91
- uniform float u_AlphaCutoff;
92
- #endif
93
- uniform vec2 u_MetallicRoughnessValues;
94
- uniform vec4 u_BaseColorFactor;
95
- uniform vec3 u_Camera;
96
- #ifdef PBR_DEBUG
97
- uniform vec4 u_ScaleDiffBaseMR;
98
- uniform vec4 u_ScaleFGDSpec;
130
+ #ifdef USE_IBL
131
+ uniform samplerCube pbr_diffuseEnvSampler;
132
+ uniform samplerCube pbr_specularEnvSampler;
133
+ uniform sampler2D pbr_brdfLUT;
99
134
  #endif
100
135
  in vec3 pbr_vPosition;
101
136
  in vec2 pbr_vUV;
@@ -106,8 +141,7 @@ in mat3 pbr_vTBN;
106
141
  in vec3 pbr_vNormal;
107
142
  #endif
108
143
  #endif
109
- struct PBRInfo
110
- {
144
+ struct PBRInfo {
111
145
  float NdotL;
112
146
  float NdotV;
113
147
  float NdotH;
@@ -159,107 +193,107 @@ mat3 tbn = mat3(t, b, ng);
159
193
  mat3 tbn = pbr_vTBN;
160
194
  #endif
161
195
  #ifdef HAS_NORMALMAP
162
- vec3 n = texture(u_NormalSampler, pbr_vUV).rgb;
163
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));
196
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
197
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
164
198
  #else
165
199
  vec3 n = normalize(tbn[2].xyz);
166
200
  #endif
167
201
  return n;
168
202
  }
169
203
  #ifdef USE_IBL
170
- vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)
204
+ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
171
205
  {
172
206
  float mipCount = 9.0;
173
- float lod = (pbrInputs.perceptualRoughness * mipCount);
174
- vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,
175
- vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;
176
- vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
207
+ float lod = (pbrInfo.perceptualRoughness * mipCount);
208
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
209
+ vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
210
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
177
211
  #ifdef USE_TEX_LOD
178
- vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
212
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
179
213
  #else
180
- vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
214
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
181
215
  #endif
182
- vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;
183
- vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);
184
- diffuse *= u_ScaleIBLAmbient.x;
185
- specular *= u_ScaleIBLAmbient.y;
216
+ vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
217
+ vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
218
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
219
+ specular *= pbrMaterial.scaleIBLAmbient.y;
186
220
  return diffuse + specular;
187
221
  }
188
222
  #endif
189
- vec3 diffuse(PBRInfo pbrInputs)
223
+ vec3 diffuse(PBRInfo pbrInfo)
190
224
  {
191
- return pbrInputs.diffuseColor / M_PI;
225
+ return pbrInfo.diffuseColor / M_PI;
192
226
  }
193
- vec3 specularReflection(PBRInfo pbrInputs)
227
+ vec3 specularReflection(PBRInfo pbrInfo)
194
228
  {
195
- return pbrInputs.reflectance0 +
196
- (pbrInputs.reflectance90 - pbrInputs.reflectance0) *
197
- pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);
229
+ return pbrInfo.reflectance0 +
230
+ (pbrInfo.reflectance90 - pbrInfo.reflectance0) *
231
+ pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
198
232
  }
199
- float geometricOcclusion(PBRInfo pbrInputs)
233
+ float geometricOcclusion(PBRInfo pbrInfo)
200
234
  {
201
- float NdotL = pbrInputs.NdotL;
202
- float NdotV = pbrInputs.NdotV;
203
- float r = pbrInputs.alphaRoughness;
235
+ float NdotL = pbrInfo.NdotL;
236
+ float NdotV = pbrInfo.NdotV;
237
+ float r = pbrInfo.alphaRoughness;
204
238
  float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
205
239
  float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
206
240
  return attenuationL * attenuationV;
207
241
  }
208
- float microfacetDistribution(PBRInfo pbrInputs)
242
+ float microfacetDistribution(PBRInfo pbrInfo)
209
243
  {
210
- float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
211
- float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;
244
+ float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
245
+ float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
212
246
  return roughnessSq / (M_PI * f * f);
213
247
  }
214
- void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {
215
- pbrInputs.NdotL = 1.0;
216
- pbrInputs.NdotH = 0.0;
217
- pbrInputs.LdotH = 0.0;
218
- pbrInputs.VdotH = 1.0;
248
+ void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {
249
+ pbrInfo.NdotL = 1.0;
250
+ pbrInfo.NdotH = 0.0;
251
+ pbrInfo.LdotH = 0.0;
252
+ pbrInfo.VdotH = 1.0;
219
253
  }
220
- void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {
221
- vec3 n = pbrInputs.n;
222
- vec3 v = pbrInputs.v;
254
+ void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {
255
+ vec3 n = pbrInfo.n;
256
+ vec3 v = pbrInfo.v;
223
257
  vec3 l = normalize(lightDirection);
224
258
  vec3 h = normalize(l+v);
225
- pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);
226
- pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);
227
- pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);
228
- pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);
259
+ pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);
260
+ pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);
261
+ pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);
262
+ pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);
229
263
  }
230
- void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {
264
+ void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {
231
265
  vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
232
- PBRInfo_setDirectionalLight(pbrInputs, light_direction);
266
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
233
267
  }
234
- vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {
235
- vec3 F = specularReflection(pbrInputs);
236
- float G = geometricOcclusion(pbrInputs);
237
- float D = microfacetDistribution(pbrInputs);
238
- vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
239
- vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);
240
- return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);
268
+ vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
269
+ vec3 F = specularReflection(pbrInfo);
270
+ float G = geometricOcclusion(pbrInfo);
271
+ float D = microfacetDistribution(pbrInfo);
272
+ vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
273
+ vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
274
+ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
241
275
  }
242
276
  vec4 pbr_filterColor(vec4 colorUnused)
243
277
  {
244
278
  #ifdef HAS_BASECOLORMAP
245
- vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;
279
+ vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
246
280
  #else
247
- vec4 baseColor = u_BaseColorFactor;
281
+ vec4 baseColor = pbrMaterial.baseColorFactor;
248
282
  #endif
249
283
  #ifdef ALPHA_CUTOFF
250
- if (baseColor.a < u_AlphaCutoff) {
284
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
251
285
  discard;
252
286
  }
253
287
  #endif
254
288
  vec3 color = vec3(0, 0, 0);
255
- if(pbr_uUnlit){
289
+ if(pbrMaterial.unlit){
256
290
  color.rgb = baseColor.rgb;
257
291
  }
258
292
  else{
259
- float perceptualRoughness = u_MetallicRoughnessValues.y;
260
- float metallic = u_MetallicRoughnessValues.x;
293
+ float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
294
+ float metallic = pbrMaterial.metallicRoughnessValues.x;
261
295
  #ifdef HAS_METALROUGHNESSMAP
262
- vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);
296
+ vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
263
297
  perceptualRoughness = mrSample.g * perceptualRoughness;
264
298
  metallic = mrSample.b * metallic;
265
299
  #endif
@@ -275,10 +309,10 @@ float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
275
309
  vec3 specularEnvironmentR0 = specularColor.rgb;
276
310
  vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
277
311
  vec3 n = getNormal();
278
- vec3 v = normalize(u_Camera - pbr_vPosition);
312
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition);
279
313
  float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
280
314
  vec3 reflection = -normalize(reflect(v, n));
281
- PBRInfo pbrInputs = PBRInfo(
315
+ PBRInfo pbrInfo = PBRInfo(
282
316
  0.0,
283
317
  NdotV,
284
318
  0.0,
@@ -295,42 +329,54 @@ n,
295
329
  v
296
330
  );
297
331
  #ifdef USE_LIGHTS
298
- PBRInfo_setAmbientLight(pbrInputs);
299
- color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);
300
- for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
301
- if (i < lighting_uDirectionalLightCount) {
302
- PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);
303
- color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);
332
+ PBRInfo_setAmbientLight(pbrInfo);
333
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
334
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
335
+ if (i < lighting.directionalLightCount) {
336
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
337
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
304
338
  }
305
339
  }
306
- for(int i = 0; i < lighting_uPointLightCount; i++) {
307
- if (i < lighting_uPointLightCount) {
308
- PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
309
- float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
310
- color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);
340
+ for(int i = 0; i < lighting.pointLightCount; i++) {
341
+ if (i < lighting.pointLightCount) {
342
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
343
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
344
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
311
345
  }
312
346
  }
313
347
  #endif
314
348
  #ifdef USE_IBL
315
- color += getIBLContribution(pbrInputs, n, reflection);
349
+ if (pbrMaterial.IBLenabled) {
350
+ color += getIBLContribution(pbrInfo, n, reflection);
351
+ }
316
352
  #endif
317
353
  #ifdef HAS_OCCLUSIONMAP
318
- float ao = texture(u_OcclusionSampler, pbr_vUV).r;
319
- color = mix(color, color * ao, u_OcclusionStrength);
354
+ if (pbrMaterial.occlusionMapEnabled) {
355
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
356
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
357
+ }
320
358
  #endif
321
359
  #ifdef HAS_EMISSIVEMAP
322
- vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;
360
+ if (pbrMaterial.emissiveMapEnabled) {
361
+ vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
323
362
  color += emissive;
363
+ }
324
364
  #endif
325
365
  #ifdef PBR_DEBUG
326
- color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);
327
- color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);
328
- color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
366
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
367
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
368
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
329
369
  #endif
330
370
  }
331
371
  return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
332
372
  }
333
- `;var jt={name:"pbr",vs:_n,fs:An,defines:{LIGHTING_FRAGMENT:1},dependencies:[un]};var Et=D(Pt(),1);var Gr=`
373
+ `;var bn=`uniform pbrProjectionUniforms {
374
+ mat4 modelViewProjectionMatrix;
375
+ mat4 modelMatrix;
376
+ mat4 normalMatrix;
377
+ vec3 camera;
378
+ } pbrProjection;
379
+ `,Ln={name:"pbrProjection",vs:bn,fs:bn,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<i32>"}};var Qt={name:"pbrMaterial",vs:En,fs:Sn,defines:{LIGHTING_FRAGMENT:1},getUniforms:e=>e,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"},dependencies:[st,Ln]};var Lt=D(Bt(),1);var Qr=`
334
380
  #pragma vscode_glsllint_stage: vert
335
381
  #if (__VERSION__ < 300)
336
382
  #define _attr attribute
@@ -373,9 +419,9 @@ return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
373
419
  #endif
374
420
 
375
421
  pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
376
- gl_Position = u_MVPMatrix * positions;
422
+ gl_Position = pbrProjection.modelViewProjectionMatrix * positions;
377
423
  }
378
- `,Wr=`
424
+ `,Zr=`
379
425
  #pragma vscode_glsllint_stage: frag
380
426
  #if (__VERSION__ < 300)
381
427
  #define fragmentColor gl_FragColor
@@ -387,7 +433,7 @@ return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
387
433
  vec3 pos = pbr_vPosition;
388
434
  fragmentColor = pbr_filterColor(vec4(1.0));
389
435
  }
390
- `;function yn(e,t){let{id:n,geometry:r,material:s,vertexCount:i,materialOptions:o,modelOptions:c}=t,a=at(e,s,r.attributes,o);En.log.info(4,"createGLTFModel defines: ",a.defines)();let f=[],l={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},h={id:n,geometry:r,topology:r.topology,vertexCount:i,modules:[jt],vs:Sn(e,Gr),fs:Sn(e,Wr),...c,bindings:{...a.bindings,...c.bindings},defines:{...a.defines,...c.defines},parameters:{...l,...a.parameters,...c.parameters},uniforms:{...a.uniforms,...c.uniforms}},p=new Et.Model(e,h);return new Et.ModelNode({managedResources:f,model:p})}function Sn(e,t){return`#version 300 es
391
- ${t}`}var $r={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},yt=class{device;options;gltf;constructor(t,n={}){this.device=t,this.options={...$r,...n}}instantiate(t){return this.gltf=t,(t.scenes||[]).map(r=>this.createScene(r))}createAnimator(){return Array.isArray(this.gltf.animations)?new W(this.gltf):null}createScene(t){let r=(t.nodes||[]).map(i=>this.createNode(i));return new $.GroupNode({id:t.name||t.id,children:r})}createNode(t){if(!t._node){let r=(t.children||[]).map(i=>this.createNode(i));t.mesh&&r.push(this.createMesh(t.mesh));let s=new $.GroupNode({id:t.name||t.id,children:r});if(t.matrix)s.setMatrix(t.matrix);else{if(s.matrix.identity(),t.translation&&s.matrix.translate(t.translation),t.rotation){let i=new F().fromQuaternion(t.rotation);s.matrix.multiplyRight(i)}t.scale&&s.matrix.scale(t.scale)}t._node=s}return t._node}createMesh(t){if(!t._mesh){let r=(t.primitives||[]).map((i,o)=>this.createPrimitive(i,o,t)),s=new $.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}`,i=Xr(t.mode||4),o=t.indices?t.indices.count:this.getVertexCount(t.attributes),c=yn(this.device,{id:s,geometry:this.createGeometry(s,t,i),material:t.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});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[i,o]of Object.entries(n.attributes)){let{components:c,size:a,value:f}=o;s[i]={size:a??c,value:f}}return new $.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}},U;(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"})(U||(U={}));function Xr(e){switch(e){case U.POINTS:return"point-list";case U.LINES:return"line-list";case U.LINE_STRIP:return"line-strip";case U.LINE_LOOP:return"line-loop-webgl";case U.TRIANGLES:return"triangle-list";case U.TRIANGLE_STRIP:return"triangle-strip";case U.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(e)}}function Tn(e,t,n){let r=new yt(e,n),s=r.instantiate(t),i=r.createAnimator();return{scenes:s,animator:i}}return bn(st);})();
436
+ `;function _n(e,t){let{id:n,geometry:r,material:s,vertexCount:i,materialOptions:o,modelOptions:c}=t,a=ft(e,s,r.attributes,o);vn.log.info(4,"createGLTFModel defines: ",a.defines)();let l=[],f={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},p={id:n,geometry:r,topology:r.topology,vertexCount:i,modules:[Qt],vs:Tn(e,Qr),fs:Tn(e,Zr),...c,defines:{...a.defines,...c.defines},parameters:{...f,...a.parameters,...c.parameters}},h=new Lt.Model(e,p),{camera:m,...x}={...a.uniforms,...c.uniforms,...a.bindings,...c.bindings};return h.shaderInputs.setProps({pbrMaterial:x,pbrProjection:{camera:m}}),new Lt.ModelNode({managedResources:l,model:h})}function Tn(e,t){return`#version 300 es
437
+ ${t}`}var Jr={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},Tt=class{device;options;gltf;constructor(t,n={}){this.device=t,this.options={...Jr,...n}}instantiate(t){return this.gltf=t,(t.scenes||[]).map(r=>this.createScene(r))}createAnimator(){return Array.isArray(this.gltf.animations)?new G(this.gltf):null}createScene(t){let r=(t.nodes||[]).map(i=>this.createNode(i));return new j.GroupNode({id:t.name||t.id,children:r})}createNode(t){if(!t._node){let r=(t.children||[]).map(i=>this.createNode(i));t.mesh&&r.push(this.createMesh(t.mesh));let s=new j.GroupNode({id:t.name||t.id,children:r});if(t.matrix)s.setMatrix(t.matrix);else{if(s.matrix.identity(),t.translation&&s.matrix.translate(t.translation),t.rotation){let i=new F().fromQuaternion(t.rotation);s.matrix.multiplyRight(i)}t.scale&&s.matrix.scale(t.scale)}t._node=s}return t._node}createMesh(t){if(!t._mesh){let r=(t.primitives||[]).map((i,o)=>this.createPrimitive(i,o,t)),s=new j.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}`,i=ts(t.mode||4),o=t.indices?t.indices.count:this.getVertexCount(t.attributes),c=_n(this.device,{id:s,geometry:this.createGeometry(s,t,i),material:t.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});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[i,o]of Object.entries(n.attributes)){let{components:c,size:a,value:l}=o;s[i]={size:a??c,value:l}}return new j.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}},U;(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"})(U||(U={}));function ts(e){switch(e){case U.POINTS:return"point-list";case U.LINES:return"line-list";case U.LINE_STRIP:return"line-strip";case U.LINE_LOOP:return"line-loop-webgl";case U.TRIANGLES:return"triangle-list";case U.TRIANGLE_STRIP:return"triangle-strip";case U.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(e)}}function Rn(e,t,n){let r=new Tt(e,n),s=r.instantiate(t),i=r.createAnimator();return{scenes:s,animator:i}}return Bn(ot);})();
392
438
  return __exports__;
393
439
  });