@luma.gl/gltf 9.2.6 → 9.3.0-alpha.11
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.dev.js +4064 -1967
- package/dist/dist.min.js +117 -46
- package/dist/gltf/animations/animations.d.ts +57 -5
- package/dist/gltf/animations/animations.d.ts.map +1 -1
- package/dist/gltf/animations/interpolate.d.ts +6 -3
- package/dist/gltf/animations/interpolate.d.ts.map +1 -1
- package/dist/gltf/animations/interpolate.js +47 -51
- package/dist/gltf/animations/interpolate.js.map +1 -1
- package/dist/gltf/create-gltf-model.d.ts +15 -1
- package/dist/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/create-gltf-model.js +168 -43
- package/dist/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/create-scenegraph-from-gltf.d.ts +39 -2
- package/dist/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/create-scenegraph-from-gltf.js +76 -6
- package/dist/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf-animator.d.ts +37 -0
- package/dist/gltf/gltf-animator.d.ts.map +1 -1
- package/dist/gltf/gltf-animator.js +112 -17
- package/dist/gltf/gltf-animator.js.map +1 -1
- package/dist/gltf/gltf-extension-support.d.ts +13 -0
- package/dist/gltf/gltf-extension-support.d.ts.map +1 -0
- package/dist/gltf/gltf-extension-support.js +178 -0
- package/dist/gltf/gltf-extension-support.js.map +1 -0
- package/dist/index.cjs +1806 -298
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/parsers/parse-gltf-animations.d.ts +1 -0
- package/dist/parsers/parse-gltf-animations.d.ts.map +1 -1
- package/dist/parsers/parse-gltf-animations.js +373 -27
- package/dist/parsers/parse-gltf-animations.js.map +1 -1
- package/dist/parsers/parse-gltf-lights.d.ts +5 -0
- package/dist/parsers/parse-gltf-lights.d.ts.map +1 -0
- package/dist/parsers/parse-gltf-lights.js +163 -0
- package/dist/parsers/parse-gltf-lights.js.map +1 -0
- package/dist/parsers/parse-gltf.d.ts +19 -2
- package/dist/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/parsers/parse-gltf.js +120 -67
- package/dist/parsers/parse-gltf.js.map +1 -1
- package/dist/parsers/parse-pbr-material.d.ts +115 -2
- package/dist/parsers/parse-pbr-material.d.ts.map +1 -1
- package/dist/parsers/parse-pbr-material.js +602 -53
- package/dist/parsers/parse-pbr-material.js.map +1 -1
- package/dist/pbr/pbr-environment.d.ts +10 -4
- package/dist/pbr/pbr-environment.d.ts.map +1 -1
- package/dist/pbr/pbr-environment.js +18 -15
- package/dist/pbr/pbr-environment.js.map +1 -1
- package/dist/pbr/pbr-material.d.ts +13 -3
- package/dist/pbr/pbr-material.d.ts.map +1 -1
- package/dist/pbr/texture-transform.d.ts +24 -0
- package/dist/pbr/texture-transform.d.ts.map +1 -0
- package/dist/pbr/texture-transform.js +98 -0
- package/dist/pbr/texture-transform.js.map +1 -0
- package/dist/webgl-to-webgpu/convert-webgl-attribute.d.ts +12 -1
- package/dist/webgl-to-webgpu/convert-webgl-attribute.d.ts.map +1 -1
- package/dist/webgl-to-webgpu/convert-webgl-attribute.js +3 -0
- package/dist/webgl-to-webgpu/convert-webgl-attribute.js.map +1 -1
- package/dist/webgl-to-webgpu/convert-webgl-sampler.d.ts +11 -5
- package/dist/webgl-to-webgpu/convert-webgl-sampler.d.ts.map +1 -1
- package/dist/webgl-to-webgpu/convert-webgl-sampler.js +16 -12
- package/dist/webgl-to-webgpu/convert-webgl-sampler.js.map +1 -1
- package/dist/webgl-to-webgpu/convert-webgl-topology.d.ts +2 -9
- package/dist/webgl-to-webgpu/convert-webgl-topology.d.ts.map +1 -1
- package/dist/webgl-to-webgpu/convert-webgl-topology.js +3 -15
- package/dist/webgl-to-webgpu/convert-webgl-topology.js.map +1 -1
- package/dist/webgl-to-webgpu/gltf-webgl-constants.d.ts +27 -0
- package/dist/webgl-to-webgpu/gltf-webgl-constants.d.ts.map +1 -0
- package/dist/webgl-to-webgpu/gltf-webgl-constants.js +34 -0
- package/dist/webgl-to-webgpu/gltf-webgl-constants.js.map +1 -0
- package/package.json +8 -9
- package/src/gltf/animations/animations.ts +88 -6
- package/src/gltf/animations/interpolate.ts +84 -96
- package/src/gltf/create-gltf-model.ts +233 -48
- package/src/gltf/create-scenegraph-from-gltf.ts +134 -11
- package/src/gltf/gltf-animator.ts +198 -20
- package/src/gltf/gltf-extension-support.ts +226 -0
- package/src/index.ts +11 -2
- package/src/parsers/parse-gltf-animations.ts +533 -32
- package/src/parsers/parse-gltf-lights.ts +218 -0
- package/src/parsers/parse-gltf.ts +189 -96
- package/src/parsers/parse-pbr-material.ts +974 -79
- package/src/pbr/pbr-environment.ts +44 -21
- package/src/pbr/pbr-material.ts +18 -3
- package/src/pbr/texture-transform.ts +263 -0
- package/src/webgl-to-webgpu/convert-webgl-attribute.ts +12 -1
- package/src/webgl-to-webgpu/convert-webgl-sampler.ts +38 -29
- package/src/webgl-to-webgpu/convert-webgl-topology.ts +3 -15
- package/src/webgl-to-webgpu/gltf-webgl-constants.ts +35 -0
- package/dist/utils/deep-copy.d.ts +0 -3
- package/dist/utils/deep-copy.d.ts.map +0 -1
- package/dist/utils/deep-copy.js +0 -21
- package/dist/utils/deep-copy.js.map +0 -1
- package/src/utils/deep-copy.ts +0 -22
package/dist/dist.min.js
CHANGED
|
@@ -4,52 +4,100 @@
|
|
|
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
|
-
"use strict";var __exports__=(()=>{var ve=Object.create;var st=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var it=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),qe=(n,t)=>{for(var e in t)st(n,e,{get:t[e],enumerable:!0})},rt=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ze(t))!Fe.call(n,s)&&s!==e&&st(n,s,{get:()=>t[s],enumerable:!(r=ke(t,s))||r.enumerable});return n},ct=(n,t,e)=>(rt(n,t,"default"),e&&rt(e,t,"default")),z=(n,t,e)=>(e=n!=null?ve(be(n)):{},rt(t||!n||!n.__esModule?st(e,"default",{value:n,enumerable:!0}):e,n)),Be=n=>rt(st({},"__esModule",{value:!0}),n);var D=it((cs,jt)=>{jt.exports=globalThis.luma});var ot=it((os,Qt)=>{Qt.exports=globalThis.luma});var zt=it((fi,xn)=>{xn.exports=globalThis.luma});var Te=it((yc,ye)=>{ye.exports=globalThis.luma});var et={};qe(et,{GLTFAnimator:()=>X,createScenegraphsFromGLTF:()=>ue,loadPBREnvironment:()=>mn,parsePBRMaterial:()=>xt});ct(et,z(D(),1));var kt=z(ot(),1);function V(n,t){if(!n)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},Ce=b.self||b.window||b.global||{},Ve=b.window||b.self||b.global||{},Ue=b.global||b.self||b.window||{},De=b.document||{};var Ot=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Zt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Ye=Zt&&parseFloat(Zt[1])||0;var $e="",Kt={};function Lt(n){for(let t in Kt)if(n.startsWith(t)){let e=Kt[t];n=n.replace(t,e)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${$e}${n}`),n}var Jt="4.3.2";var Ge=globalThis.loaders?.parseImageNode,Rt=typeof Image<"u",Nt=typeof ImageBitmap<"u",We=Boolean(Ge),Pt=Ot?!0:We;function tn(n){switch(n){case"auto":return Nt||Rt||Pt;case"imagebitmap":return Nt;case"image":return Rt;case"data":return Pt;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function nn(){if(Nt)return"imagebitmap";if(Rt)return"image";if(Pt)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function en(n){let t=Xe(n);if(!t)throw new Error("Not an image");return t}function _t(n){return at(n)}function at(n){switch(en(n)){case"data":return n;case"image":case"imagebitmap":let t=document.createElement("canvas"),e=t.getContext("2d");if(!e)throw new Error("getImageData");return t.width=n.width,t.height=n.height,e.drawImage(n,0,0),e.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function Xe(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var He=/^data:image\/svg\+xml/,je=/\.svg((\?|#).*)?$/;function ft(n){return n&&(He.test(n)||je.test(n))}function rn(n,t){if(ft(t)){let r=new TextDecoder().decode(n);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 It(n,t)}function It(n,t){if(ft(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function ht(n,t,e){let r=rn(n,e),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await Qe(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function Qe(n,t){let e=new Image;return e.src=n,t.image&&t.image.decode&&e.decode?(await e.decode(),e):await new Promise((r,s)=>{try{e.onload=()=>r(e),e.onerror=i=>{let c=i instanceof Error?i.message:"error";s(new Error(c))}}catch(i){s(i)}})}var Ze={},sn=!0;async function cn(n,t,e){let r;ft(e)?r=await ht(n,t,e):r=It(n,e);let s=t&&t.imagebitmap;return await Ke(r,s)}async function Ke(n,t=null){if((Je(t)||!sn)&&(t=null),t)try{return await createImageBitmap(n,t)}catch(e){console.warn(e),sn=!1}return await createImageBitmap(n)}function Je(n){for(let t in n||Ze)return!1;return!0}function on(n){return!rr(n,"ftyp",4)||!(n[8]&96)?null:tr(n)}function tr(n){switch(nr(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function nr(n,t,e){return String.fromCharCode(...n.slice(t,e))}function er(n){return[...n].map(t=>t.charCodeAt(0))}function rr(n,t,e=0){let r=er(t);for(let s=0;s<r.length;++s)if(r[s]!==n[s+e])return!1;return!0}var F=!1,j=!0;function lt(n){let t=Q(n);return ir(t)||ar(t)||cr(t)||or(t)||sr(t)}function sr(n){let t=new Uint8Array(n instanceof DataView?n.buffer:n),e=on(t);return e?{mimeType:e.mimeType,width:0,height:0}:null}function ir(n){let t=Q(n);return t.byteLength>=24&&t.getUint32(0,F)===2303741511?{mimeType:"image/png",width:t.getUint32(16,F),height:t.getUint32(20,F)}:null}function cr(n){let t=Q(n);return t.byteLength>=10&&t.getUint32(0,F)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,j),height:t.getUint16(8,j)}:null}function or(n){let t=Q(n);return t.byteLength>=14&&t.getUint16(0,F)===16973&&t.getUint32(2,j)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,j),height:t.getUint32(22,j)}:null}function ar(n){let t=Q(n);if(!(t.byteLength>=3&&t.getUint16(0,F)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=fr(),i=2;for(;i+9<t.byteLength;){let c=t.getUint16(i,F);if(s.has(c))return{mimeType:"image/jpeg",height:t.getUint16(i+5,F),width:t.getUint16(i+7,F)};if(!r.has(c))return null;i+=2,i+=t.getUint16(i,F)}return null}function fr(){let n=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)n.add(e);return{tableMarkers:n,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Q(n){if(n instanceof DataView)return n;if(ArrayBuffer.isView(n))return new DataView(n.buffer);if(n instanceof ArrayBuffer)return new DataView(n);throw new Error("toDataView")}async function an(n,t){let{mimeType:e}=lt(n)||{},r=globalThis.loaders?.parseImageNode;return V(r),await r(n,e)}async function fn(n,t,e){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=e||{},c=hr(s),o;switch(c){case"imagebitmap":o=await cn(n,t,i);break;case"image":o=await ht(n,t,i);break;case"data":o=await an(n,t);break;default:V(!1)}return s==="data"&&(o=at(o)),o}function hr(n){switch(n){case"auto":case"data":return nn();default:return tn(n),n}}var lr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],pr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],mr={image:{type:"auto",decode:!0}},pt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Jt,mimeTypes:pr,extensions:lr,parse:fn,tests:[n=>Boolean(lt(new DataView(n)))],options:mr};function mt(n,t,e){let r=typeof n=="function"?n({...t,...e}):n,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),Lt(r)}var xr=n=>n&&typeof n=="object";async function hn(n,t,e={}){return await ut(n,t,e)}async function ut(n,t,e){return Array.isArray(n)?await dr(n,t,e):xr(n)?await Mr(n,t,e):await t(n,e)}async function Mr(n,t,e){let r=[],s={};for(let i in n){let c=n[i],o=ut(c,t,e).then(a=>{s[i]=a});r.push(o)}return await Promise.all(r),s}async function dr(n,t,e={}){let r=n.map(s=>ut(s,t,e));return await Promise.all(r)}async function ln(n,t,e){return await hn(n,r=>vt(r,t,e))}async function vt(n,t,e){let s=await(await fetch(n,e.fetch)).arrayBuffer();return await t(s,e)}async function Z(n,t={}){let e=await gr(n,t);return await ln(e,pt.parse,t)}async function gr(n,t,e={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await yr(n,r,t,e):mt(n,t,e)}async function yr(n,t,e,r){let s=[];if(t==="auto"){let i=mt(n,e,{...r,lod:0}),c=await vt(i,pt.parse,e),{width:o,height:a}=_t(c);t=Tr({width:o,height:a}),s.push(i)}V(t>0);for(let i=s.length;i<t;++i){let c=mt(n,e,{...r,lod:i});s.push(c)}return s}function Tr(n){return 1+Math.floor(Math.log2(Math.max(n.width,n.height)))}function mn(n,t){let e=new kt.AsyncTexture(n,{id:"brdfLUT",sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"},data:Z(t.brdfLutUrl)}),r=pn(n,{id:"DiffuseEnvSampler",getTextureForFace:i=>Z(t.getTexUrl("diffuse",i,0)),sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}}),s=pn(n,{id:"SpecularEnvSampler",getTextureForFace:i=>{let c=[];for(let o=0;o<=t.specularMipLevels-1;o++)c.push(Z(t.getTexUrl("specular",i,o)));return c},sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}});return{brdfLutTexture:e,diffuseEnvSampler:r,specularEnvSampler:s}}var Ar=[0,1,2,3,4,5];function pn(n,{id:t,getTextureForFace:e,sampler:r}){let s={};return Ar.forEach(i=>{s[String(i)]=e(i)}),new kt.AsyncTexture(n,{id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var mi=z(zt(),1),gn=z(D(),1);var hi=z(zt(),1);function dn(n){return{addressModeU:Mn(n.wrapS),addressModeV:Mn(n.wrapT),magFilter:Er(n.magFilter),...wr(n.minFilter)}}function Mn(n){switch(n){case 33071:return"clamp-to-edge";case 10497:return"repeat";case 33648:return"mirror-repeat";default:return}}function Er(n){switch(n){case 9728:return"nearest";case 9729:return"linear";default:return}}function wr(n){switch(n){case 9728:return{minFilter:"nearest"};case 9729:return{minFilter:"linear"};case 9984:return{minFilter:"nearest",mipmapFilter:"nearest"};case 9985:return{minFilter:"linear",mipmapFilter:"nearest"};case 9986:return{minFilter:"nearest",mipmapFilter:"linear"};case 9987:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}function xt(n,t,e,r){let s={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:i}=r;return i&&(s.bindings.pbr_diffuseEnvSampler=i.diffuseEnvSampler.texture,s.bindings.pbr_specularEnvSampler=i.specularEnvSampler.texture,s.bindings.pbr_BrdfLUT=i.brdfLutTexture.texture,s.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=!0,s.uniforms.scaleDiffBaseMR=[0,0,0,0],s.uniforms.scaleFGDSpec=[0,0,0,0]),e.NORMAL&&(s.defines.HAS_NORMALS=!0),e.TANGENT&&r?.useTangents&&(s.defines.HAS_TANGENTS=!0),e.TEXCOORD_0&&(s.defines.HAS_UV=!0),r?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=!0),r?.lights&&(s.defines.USE_LIGHTS=!0),t&&Sr(n,t,s),s}function Sr(n,t,e){if(e.uniforms.unlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Or(n,t.pbrMetallicRoughness,e),t.normalTexture){K(n,t.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",e);let{scale:r=1}=t.normalTexture;e.uniforms.normalScale=r}if(t.occlusionTexture){K(n,t.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",e);let{strength:r=1}=t.occlusionTexture;e.uniforms.occlusionStrength=r}switch(t.emissiveTexture&&(K(n,t.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",e),e.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode||"MASK"){case"MASK":let{alphaCutoff:r=.5}=t;e.defines.ALPHA_CUTOFF=!0,e.uniforms.alphaCutoff=r;break;case"BLEND":gn.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),e.parameters.blend=!0,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="src-alpha",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.blendEquation=32774,e.glParameters.blendFunc=[770,771,1,771];break}}function Or(n,t,e){t.baseColorTexture&&K(n,t.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",e),e.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&K(n,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",e);let{metallicFactor:r=1,roughnessFactor:s=1}=t;e.uniforms.metallicRoughnessValues=[r,s]}function K(n,t,e,r,s){let i=t.texture.source.image,c;i.compressed?c=i:c={data:i};let o={wrapS:10497,wrapT:10497,...t?.texture?.sampler},a=n.createTexture({id:t.uniformName||t.id,sampler:dn(o),...c});s.bindings[e]=a,r&&(s.defines[r]=!0),s.generatedTextures.push(a)}var W=z(ot(),1);var gi=1/Math.PI*180,yi=1/180*Math.PI,Lr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Lr}};var L=globalThis.mathgl.config;function yn(n,{precision:t=L.precision}={}){return n=Rr(n),`${parseFloat(n.toPrecision(t))}`}function Y(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function bt(n,t,e){let r=L.EPSILON;e&&(L.EPSILON=e);try{if(n===t)return!0;if(Y(n)&&Y(t)){if(n.length!==t.length)return!1;for(let s=0;s<n.length;++s)if(!bt(n[s],t[s]))return!1;return!0}return n&&n.equals?n.equals(t):t&&t.equals?t.equals(n):typeof n=="number"&&typeof t=="number"?Math.abs(n-t)<=L.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{L.EPSILON=r}}function Rr(n){return Math.round(n/L.EPSILON)*L.EPSILON}var C=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+e];return this.check()}toArray(t=[],e=0){for(let r=0;r<this.ELEMENTS;++r)t[e+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 e="";for(let r=0;r<this.ELEMENTS;++r)e+=(r>0?", ":"")+yn(this[r],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!bt(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,r){if(r===void 0)return this.lerp(this,t,e);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],c=typeof e=="number"?e:e[s];this[s]=i+r*(c-i)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),e[r]);return this.check()}add(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=e[r];return this.check()}subtract(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=e[r];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=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 e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),e);return this.check()}get elements(){return this}};function Nr(n,t){if(n.length!==t)return!1;for(let e=0;e<n.length;++e)if(!Number.isFinite(n[e]))return!1;return!0}function S(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function $(n,t,e=""){if(L.debug&&!Nr(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}function Ft(n,t){if(!n)throw new Error(`math.gl assertion ${t}`)}var Mt=class extends C{get x(){return this[0]}set x(t){this[0]=S(t)}get y(){return this[1]}set y(t){this[1]=S(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];e+=s*s}return S(e)}dot(t){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*t[r];return S(e)}normalize(){let t=this.magnitude();if(t!==0)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=e[r];return this.check()}divide(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Ft(t>=0&&t<this.ELEMENTS,"index is out of range"),S(this[t])}setComponent(t,e){return Ft(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}};var R=typeof Float32Array<"u"?Float32Array:Array;var _i=Math.PI/180;function Pr(){let n=new R(2);return R!=Float32Array&&(n[0]=0,n[1]=0),n}function En(n,t,e){let r=t[0],s=t[1];return n[0]=e[0]*r+e[4]*s+e[12],n[1]=e[1]*r+e[5]*s+e[13],n}var Ii=function(){let n=Pr();return function(t,e,r,s,i,c){let o,a;for(e||(e=2),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],i(n,n,c),t[o]=n[0],t[o+1]=n[1];return t}}();function wn(n,t,e){let r=t[0],s=t[1],i=e[3]*r+e[7]*s||1;return n[0]=(e[0]*r+e[4]*s)/i,n[1]=(e[1]*r+e[5]*s)/i,n}function Sn(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[3]*r+e[7]*s+e[11]*i||1;return n[0]=(e[0]*r+e[4]*s+e[8]*i)/c,n[1]=(e[1]*r+e[5]*s+e[9]*i)/c,n[2]=(e[2]*r+e[6]*s+e[10]*i)/c,n}function On(n,t,e){let r=t[0],s=t[1];return n[0]=e[0]*r+e[2]*s,n[1]=e[1]*r+e[3]*s,n[2]=t[2],n[3]=t[3],n}function Ln(n,t,e){let r=t[0],s=t[1],i=t[2];return n[0]=e[0]*r+e[3]*s+e[6]*i,n[1]=e[1]*r+e[4]*s+e[7]*i,n[2]=e[2]*r+e[5]*s+e[8]*i,n[3]=t[3],n}function qt(){let n=new R(3);return R!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function _r(n){let t=n[0],e=n[1],r=n[2];return Math.sqrt(t*t+e*e+r*r)}function Bt(n,t,e){let r=new R(3);return r[0]=n,r[1]=t,r[2]=e,r}function Rn(n,t){let e=t[0],r=t[1],s=t[2],i=e*e+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),n[0]=t[0]*i,n[1]=t[1]*i,n[2]=t[2]*i,n}function Nn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function dt(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[0],o=e[1],a=e[2];return n[0]=s*a-i*o,n[1]=i*c-r*a,n[2]=r*o-s*c,n}function gt(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[3]*r+e[7]*s+e[11]*i+e[15];return c=c||1,n[0]=(e[0]*r+e[4]*s+e[8]*i+e[12])/c,n[1]=(e[1]*r+e[5]*s+e[9]*i+e[13])/c,n[2]=(e[2]*r+e[6]*s+e[10]*i+e[14])/c,n}function Pn(n,t,e){let r=e[0],s=e[1],i=e[2],c=e[3],o=t[0],a=t[1],f=t[2],h=s*f-i*a,l=i*o-r*f,p=r*a-s*o,m=s*p-i*l,x=i*h-r*p,M=r*l-s*h,d=c*2;return h*=d,l*=d,p*=d,m*=2,x*=2,M*=2,n[0]=o+h+m,n[1]=a+l+x,n[2]=f+p+M,n}var _n=_r;var ki=function(){let n=qt();return function(t,e,r,s,i,c){let o,a;for(e||(e=3),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],n[2]=t[o+2],i(n,n,c),t[o]=n[0],t[o+1]=n[1],t[o+2]=n[2];return t}}();var yt,G=class extends Mt{static get ZERO(){return yt||(yt=new G(0,0,0,0),Object.freeze(yt)),yt}constructor(t=0,e=0,r=0,s=0){super(-0,-0,-0,-0),Y(t)&&arguments.length===1?this.copy(t):(L.debug&&(S(t),S(e),S(r),S(s)),this[0]=t,this[1]=e,this[2]=r,this[3]=s)}set(t,e,r,s){return this[0]=t,this[1]=e,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&&(S(t.x),S(t.y),S(t.z),S(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]=S(t)}get w(){return this[3]}set w(t){this[3]=S(t)}transform(t){return gt(this,this,t),this.check()}transformByMatrix3(t){return Ln(this,this,t),this.check()}transformByMatrix2(t){return On(this,this,t),this.check()}transformByQuaternion(t){return Pn(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var Tt=class extends C{toString(){let t="[";if(L.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,r){return this[e*this.RANK+t]=S(r),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)e[s]=this[r+s];return e}setColumn(t,e){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=e[s];return this}};function In(){let n=new R(9);return R!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function vr(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function un(n,t){if(n===t){let e=t[1],r=t[2],s=t[3],i=t[6],c=t[7],o=t[11];n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[6]=t[9],n[7]=t[13],n[8]=r,n[9]=i,n[11]=t[14],n[12]=s,n[13]=c,n[14]=o}else n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15];return n}function vn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=t[4],o=t[5],a=t[6],f=t[7],h=t[8],l=t[9],p=t[10],m=t[11],x=t[12],M=t[13],d=t[14],E=t[15],O=e*o-r*c,g=e*a-s*c,y=e*f-i*c,T=r*a-s*o,A=r*f-i*o,N=s*f-i*a,P=h*M-l*x,_=h*d-p*x,I=h*E-m*x,u=l*d-p*M,v=l*E-m*M,k=p*E-m*d,w=O*k-g*v+y*u+T*I-A*_+N*P;return w?(w=1/w,n[0]=(o*k-a*v+f*u)*w,n[1]=(s*v-r*k-i*u)*w,n[2]=(M*N-d*A+E*T)*w,n[3]=(p*A-l*N-m*T)*w,n[4]=(a*I-c*k-f*_)*w,n[5]=(e*k-s*I+i*_)*w,n[6]=(d*y-x*N-E*g)*w,n[7]=(h*N-p*y+m*g)*w,n[8]=(c*v-o*I+f*P)*w,n[9]=(r*I-e*v-i*P)*w,n[10]=(x*A-M*y+E*O)*w,n[11]=(l*y-h*A-m*O)*w,n[12]=(o*_-c*u-a*P)*w,n[13]=(e*u-r*_+s*P)*w,n[14]=(M*g-x*T-d*O)*w,n[15]=(h*T-l*g+p*O)*w,n):null}function kn(n){let t=n[0],e=n[1],r=n[2],s=n[3],i=n[4],c=n[5],o=n[6],a=n[7],f=n[8],h=n[9],l=n[10],p=n[11],m=n[12],x=n[13],M=n[14],d=n[15],E=t*c-e*i,O=t*o-r*i,g=e*o-r*c,y=f*x-h*m,T=f*M-l*m,A=h*M-l*x,N=t*A-e*T+r*y,P=i*A-c*T+o*y,_=f*g-h*O+l*E,I=m*g-x*O+M*E;return a*N-s*P+d*_-p*I}function Ct(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3],o=t[4],a=t[5],f=t[6],h=t[7],l=t[8],p=t[9],m=t[10],x=t[11],M=t[12],d=t[13],E=t[14],O=t[15],g=e[0],y=e[1],T=e[2],A=e[3];return n[0]=g*r+y*o+T*l+A*M,n[1]=g*s+y*a+T*p+A*d,n[2]=g*i+y*f+T*m+A*E,n[3]=g*c+y*h+T*x+A*O,g=e[4],y=e[5],T=e[6],A=e[7],n[4]=g*r+y*o+T*l+A*M,n[5]=g*s+y*a+T*p+A*d,n[6]=g*i+y*f+T*m+A*E,n[7]=g*c+y*h+T*x+A*O,g=e[8],y=e[9],T=e[10],A=e[11],n[8]=g*r+y*o+T*l+A*M,n[9]=g*s+y*a+T*p+A*d,n[10]=g*i+y*f+T*m+A*E,n[11]=g*c+y*h+T*x+A*O,g=e[12],y=e[13],T=e[14],A=e[15],n[12]=g*r+y*o+T*l+A*M,n[13]=g*s+y*a+T*p+A*d,n[14]=g*i+y*f+T*m+A*E,n[15]=g*c+y*h+T*x+A*O,n}function zn(n,t,e){let r=e[0],s=e[1],i=e[2],c,o,a,f,h,l,p,m,x,M,d,E;return t===n?(n[12]=t[0]*r+t[4]*s+t[8]*i+t[12],n[13]=t[1]*r+t[5]*s+t[9]*i+t[13],n[14]=t[2]*r+t[6]*s+t[10]*i+t[14],n[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(c=t[0],o=t[1],a=t[2],f=t[3],h=t[4],l=t[5],p=t[6],m=t[7],x=t[8],M=t[9],d=t[10],E=t[11],n[0]=c,n[1]=o,n[2]=a,n[3]=f,n[4]=h,n[5]=l,n[6]=p,n[7]=m,n[8]=x,n[9]=M,n[10]=d,n[11]=E,n[12]=c*r+h*s+x*i+t[12],n[13]=o*r+l*s+M*i+t[13],n[14]=a*r+p*s+d*i+t[14],n[15]=f*r+m*s+E*i+t[15]),n}function bn(n,t,e){let r=e[0],s=e[1],i=e[2];return n[0]=t[0]*r,n[1]=t[1]*r,n[2]=t[2]*r,n[3]=t[3]*r,n[4]=t[4]*s,n[5]=t[5]*s,n[6]=t[6]*s,n[7]=t[7]*s,n[8]=t[8]*i,n[9]=t[9]*i,n[10]=t[10]*i,n[11]=t[11]*i,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function Fn(n,t,e,r){let s=r[0],i=r[1],c=r[2],o=Math.sqrt(s*s+i*i+c*c),a,f,h,l,p,m,x,M,d,E,O,g,y,T,A,N,P,_,I,u,v,k,w,H;return o<1e-6?null:(o=1/o,s*=o,i*=o,c*=o,f=Math.sin(e),a=Math.cos(e),h=1-a,l=t[0],p=t[1],m=t[2],x=t[3],M=t[4],d=t[5],E=t[6],O=t[7],g=t[8],y=t[9],T=t[10],A=t[11],N=s*s*h+a,P=i*s*h+c*f,_=c*s*h-i*f,I=s*i*h-c*f,u=i*i*h+a,v=c*i*h+s*f,k=s*c*h+i*f,w=i*c*h-s*f,H=c*c*h+a,n[0]=l*N+M*P+g*_,n[1]=p*N+d*P+y*_,n[2]=m*N+E*P+T*_,n[3]=x*N+O*P+A*_,n[4]=l*I+M*u+g*v,n[5]=p*I+d*u+y*v,n[6]=m*I+E*u+T*v,n[7]=x*I+O*u+A*v,n[8]=l*k+M*w+g*H,n[9]=p*k+d*w+y*H,n[10]=m*k+E*w+T*H,n[11]=x*k+O*w+A*H,t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n)}function qn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[4],c=t[5],o=t[6],a=t[7],f=t[8],h=t[9],l=t[10],p=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=i*s+f*r,n[5]=c*s+h*r,n[6]=o*s+l*r,n[7]=a*s+p*r,n[8]=f*s-i*r,n[9]=h*s-c*r,n[10]=l*s-o*r,n[11]=p*s-a*r,n}function Bn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[0],c=t[1],o=t[2],a=t[3],f=t[8],h=t[9],l=t[10],p=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*s-f*r,n[1]=c*s-h*r,n[2]=o*s-l*r,n[3]=a*s-p*r,n[8]=i*r+f*s,n[9]=c*r+h*s,n[10]=o*r+l*s,n[11]=a*r+p*s,n}function Cn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[0],c=t[1],o=t[2],a=t[3],f=t[4],h=t[5],l=t[6],p=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*s+f*r,n[1]=c*s+h*r,n[2]=o*s+l*r,n[3]=a*s+p*r,n[4]=f*s-i*r,n[5]=h*s-c*r,n[6]=l*s-o*r,n[7]=p*s-a*r,n}function Vn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e+e,o=r+r,a=s+s,f=e*c,h=r*c,l=r*o,p=s*c,m=s*o,x=s*a,M=i*c,d=i*o,E=i*a;return n[0]=1-l-x,n[1]=h+E,n[2]=p-d,n[3]=0,n[4]=h-E,n[5]=1-f-x,n[6]=m+M,n[7]=0,n[8]=p+d,n[9]=m-M,n[10]=1-f-l,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Un(n,t,e,r,s,i,c){let o=1/(e-t),a=1/(s-r),f=1/(i-c);return n[0]=i*2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*a,n[6]=0,n[7]=0,n[8]=(e+t)*o,n[9]=(s+r)*a,n[10]=(c+i)*f,n[11]=-1,n[12]=0,n[13]=0,n[14]=c*i*2*f,n[15]=0,n}function kr(n,t,e,r,s){let i=1/Math.tan(t/2);if(n[0]=i/e,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){let c=1/(r-s);n[10]=(s+r)*c,n[14]=2*s*r*c}else n[10]=-1,n[14]=-2*r;return n}var Dn=kr;function zr(n,t,e,r,s,i,c){let o=1/(t-e),a=1/(r-s),f=1/(i-c);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*f,n[11]=0,n[12]=(t+e)*o,n[13]=(s+r)*a,n[14]=(c+i)*f,n[15]=1,n}var Yn=zr;function $n(n,t,e,r){let s,i,c,o,a,f,h,l,p,m,x=t[0],M=t[1],d=t[2],E=r[0],O=r[1],g=r[2],y=e[0],T=e[1],A=e[2];return Math.abs(x-y)<1e-6&&Math.abs(M-T)<1e-6&&Math.abs(d-A)<1e-6?vr(n):(l=x-y,p=M-T,m=d-A,s=1/Math.sqrt(l*l+p*p+m*m),l*=s,p*=s,m*=s,i=O*m-g*p,c=g*l-E*m,o=E*p-O*l,s=Math.sqrt(i*i+c*c+o*o),s?(s=1/s,i*=s,c*=s,o*=s):(i=0,c=0,o=0),a=p*o-m*c,f=m*i-l*o,h=l*c-p*i,s=Math.sqrt(a*a+f*f+h*h),s?(s=1/s,a*=s,f*=s,h*=s):(a=0,f=0,h=0),n[0]=i,n[1]=a,n[2]=l,n[3]=0,n[4]=c,n[5]=f,n[6]=p,n[7]=0,n[8]=o,n[9]=h,n[10]=m,n[11]=0,n[12]=-(i*x+c*M+o*d),n[13]=-(a*x+f*M+h*d),n[14]=-(l*x+p*M+m*d),n[15]=1,n)}function br(){let n=new R(4);return R!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Gn(n,t,e){return n[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n[3]=t[3]+e[3],n}function Wn(n,t,e){return n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e,n}function Xn(n){let t=n[0],e=n[1],r=n[2],s=n[3];return Math.sqrt(t*t+e*e+r*r+s*s)}function Hn(n){let t=n[0],e=n[1],r=n[2],s=n[3];return t*t+e*e+r*r+s*s}function jn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e*e+r*r+s*s+i*i;return c>0&&(c=1/Math.sqrt(c)),n[0]=e*c,n[1]=r*c,n[2]=s*c,n[3]=i*c,n}function Qn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]}function Zn(n,t,e,r){let s=t[0],i=t[1],c=t[2],o=t[3];return n[0]=s+r*(e[0]-s),n[1]=i+r*(e[1]-i),n[2]=c+r*(e[2]-c),n[3]=o+r*(e[3]-o),n}function Kn(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3];return n[0]=e[0]*r+e[4]*s+e[8]*i+e[12]*c,n[1]=e[1]*r+e[5]*s+e[9]*i+e[13]*c,n[2]=e[2]*r+e[6]*s+e[10]*i+e[14]*c,n[3]=e[3]*r+e[7]*s+e[11]*i+e[15]*c,n}function Jn(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[0],o=e[1],a=e[2],f=e[3],h=f*r+o*i-a*s,l=f*s+a*r-c*i,p=f*i+c*s-o*r,m=-c*r-o*s-a*i;return n[0]=h*f+m*-c+l*-a-p*-o,n[1]=l*f+m*-o+p*-c-h*-a,n[2]=p*f+m*-a+h*-o-l*-c,n[3]=t[3],n}var Gi=function(){let n=br();return function(t,e,r,s,i,c){let o,a;for(e||(e=4),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],n[2]=t[o+2],n[3]=t[o+3],i(n,n,c),t[o]=n[0],t[o+1]=n[1],t[o+2]=n[2],t[o+3]=n[3];return t}}();var Dt;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Dt||(Dt={}));var qr=45*Math.PI/180,Br=1,Vt=.1,Ut=500,Cr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),B=class extends Tt{static get IDENTITY(){return Ur()}static get ZERO(){return Vr()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Dt}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,e,r,s,i,c,o,a,f,h,l,p,m,x,M,d){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this[4]=i,this[5]=c,this[6]=o,this[7]=a,this[8]=f,this[9]=h,this[10]=l,this[11]=p,this[12]=m,this[13]=x,this[14]=M,this[15]=d,this.check()}setRowMajor(t,e,r,s,i,c,o,a,f,h,l,p,m,x,M,d){return this[0]=t,this[1]=i,this[2]=f,this[3]=m,this[4]=e,this[5]=c,this[6]=h,this[7]=x,this[8]=r,this[9]=o,this[10]=l,this[11]=M,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(Cr)}fromObject(t){return this.check()}fromQuaternion(t){return Vn(this,t),this.check()}frustum(t){let{left:e,right:r,bottom:s,top:i,near:c=Vt,far:o=Ut}=t;return o===1/0?Dr(this,e,r,s,i,c):Un(this,e,r,s,i,c,o),this.check()}lookAt(t){let{eye:e,center:r=[0,0,0],up:s=[0,1,0]}=t;return $n(this,e,r,s),this.check()}ortho(t){let{left:e,right:r,bottom:s,top:i,near:c=Vt,far:o=Ut}=t;return Yn(this,e,r,s,i,c,o),this.check()}orthographic(t){let{fovy:e=qr,aspect:r=Br,focalDistance:s=1,near:i=Vt,far:c=Ut}=t;te(e);let o=e/2,a=s*Math.tan(o),f=a*r;return this.ortho({left:-f,right:f,bottom:-a,top:a,near:i,far:c})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return te(e),Dn(this,e,r,s,i),this.check()}determinant(){return kn(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,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let r=this.getScale(e),s=1/r[0],i=1/r[1],c=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*c,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*c,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let r=this.getScale(e),s=1/r[0],i=1/r[1],c=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*c,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*c,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*c,t}transpose(){return un(this,this),this.check()}invert(){return vn(this,this),this.check()}multiplyLeft(t){return Ct(this,t,this),this.check()}multiplyRight(t){return Ct(this,this,t),this.check()}rotateX(t){return qn(this,this,t),this.check()}rotateY(t){return Bn(this,this,t),this.check()}rotateZ(t){return Cn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return Fn(this,this,t,e),this.check()}scale(t){return bn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return zn(this,this,t),this.check()}transform(t,e){return t.length===4?(e=Kn(e||[-0,-0,-0,-0],t,this),$(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:r}=t,s;switch(r){case 2:s=En(e||[-0,-0],t,this);break;case 3:s=gt(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(s,t.length),s}transformAsVector(t,e){let r;switch(t.length){case 2:r=wn(e||[-0,-0],t,this);break;case 3:r=Sn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(r,t.length),r}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,r){return this.identity().translate([t,e,r])}},At,Et;function Vr(){return At||(At=new B([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(At)),At}function Ur(){return Et||(Et=new B,Object.freeze(Et)),Et}function te(n){if(n>Math.PI*2)throw Error("expected radians")}function Dr(n,t,e,r,s,i){let c=2*i/(e-t),o=2*i/(s-r),a=(e+t)/(e-t),f=(s+r)/(s-r),h=-1,l=-1,p=-2*i;return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o,n[6]=0,n[7]=0,n[8]=a,n[9]=f,n[10]=h,n[11]=l,n[12]=0,n[13]=0,n[14]=p,n[15]=0,n}function ne(){let n=new R(4);return R!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function ee(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Yt(n,t,e){e=e*.5;let r=Math.sin(e);return n[0]=r*t[0],n[1]=r*t[1],n[2]=r*t[2],n[3]=Math.cos(e),n}function $t(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3],o=e[0],a=e[1],f=e[2],h=e[3];return n[0]=r*h+c*o+s*f-i*a,n[1]=s*h+c*a+i*o-r*f,n[2]=i*h+c*f+r*a-s*o,n[3]=c*h-r*o-s*a-i*f,n}function re(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a+c*o,n[1]=s*a+i*o,n[2]=i*a-s*o,n[3]=c*a-r*o,n}function se(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a-i*o,n[1]=s*a+c*o,n[2]=i*a+r*o,n[3]=c*a-s*o,n}function ie(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a+s*o,n[1]=s*a-r*o,n[2]=i*a+c*o,n[3]=c*a-i*o,n}function ce(n,t){let e=t[0],r=t[1],s=t[2];return n[0]=e,n[1]=r,n[2]=s,n[3]=Math.sqrt(Math.abs(1-e*e-r*r-s*s)),n}function tt(n,t,e,r){let s=t[0],i=t[1],c=t[2],o=t[3],a=e[0],f=e[1],h=e[2],l=e[3],p,m,x,M,d;return p=s*a+i*f+c*h+o*l,p<0&&(p=-p,a=-a,f=-f,h=-h,l=-l),1-p>1e-6?(m=Math.acos(p),d=Math.sin(m),x=Math.sin((1-r)*m)/d,M=Math.sin(r*m)/d):(x=1-r,M=r),n[0]=x*s+M*a,n[1]=x*i+M*f,n[2]=x*c+M*h,n[3]=x*o+M*l,n}function oe(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e*e+r*r+s*s+i*i,o=c?1/c:0;return n[0]=-e*o,n[1]=-r*o,n[2]=-s*o,n[3]=i*o,n}function ae(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=t[3],n}function Gt(n,t){let e=t[0]+t[4]+t[8],r;if(e>0)r=Math.sqrt(e+1),n[3]=.5*r,r=.5/r,n[0]=(t[5]-t[7])*r,n[1]=(t[6]-t[2])*r,n[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,c=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[c*3+c]+1),n[s]=.5*r,r=.5/r,n[3]=(t[i*3+c]-t[c*3+i])*r,n[i]=(t[i*3+s]+t[s*3+i])*r,n[c]=(t[c*3+s]+t[s*3+c])*r}return n}var fe=Gn;var he=Wn,le=Qn,pe=Zn,me=Xn;var xe=Hn;var Me=jn;var de=function(){let n=qt(),t=Bt(1,0,0),e=Bt(0,1,0);return function(r,s,i){let c=Nn(s,i);return c<-.999999?(dt(n,t,s),_n(n)<1e-6&&dt(n,e,s),Rn(n,n),Yt(r,n,Math.PI),r):c>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(dt(n,s,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=1+c,Me(r,r))}}(),ic=function(){let n=ne(),t=ne();return function(e,r,s,i,c,o){return tt(n,r,c,o),tt(t,s,i,o),tt(e,n,t,2*o*(1-o)),e}}(),cc=function(){let n=In();return function(t,e,r,s){return n[0]=r[0],n[3]=r[1],n[6]=r[2],n[1]=s[0],n[4]=s[1],n[7]=s[2],n[2]=-e[0],n[5]=-e[1],n[8]=-e[2],Me(t,Gt(t,n))}}();var Yr=[0,0,0,1],nt=class extends C{constructor(t=0,e=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,e,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,e,r,s){return this[0]=t,this[1]=e,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 Gt(this,t),this.check()}fromAxisRotation(t,e){return Yt(this,t,e),this.check()}identity(){return ee(this),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=S(t)}get y(){return this[1]}set y(t){this[1]=S(t)}get z(){return this[2]}set z(t){this[2]=S(t)}get w(){return this[3]}set w(t){this[3]=S(t)}len(){return me(this)}lengthSquared(){return xe(this)}dot(t){return le(this,t)}rotationTo(t,e){return de(this,t,e),this.check()}add(t){return fe(this,this,t),this.check()}calculateW(){return ce(this,this),this.check()}conjugate(){return ae(this,this),this.check()}invert(){return oe(this,this),this.check()}lerp(t,e,r){return r===void 0?this.lerp(this,t,e):(pe(this,t,e,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(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,t===0&&(this[3]=1),this.check()}rotateX(t){return re(this,this,t),this.check()}rotateY(t){return se(this,this,t),this.check()}rotateZ(t){return ie(this,this,t),this.check()}scale(t){return he(this,this,t),this.check()}slerp(t,e,r){let s,i,c;switch(arguments.length){case 1:({start:s=Yr,target:i,ratio:c}=t);break;case 2:s=this,i=t,c=e;break;default:s=t,i=e,c=r}return tt(this,s,i,c),this.check()}transformVector4(t,e=new G){return Jn(e,t,this),$(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var U;(function(n){n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(U||(U={}));function ge(n){switch(n){case U.POINTS:return"point-list";case U.LINES:return"line-list";case U.LINE_STRIP:return"line-strip";case U.TRIANGLES:return"triangle-list";case U.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(n))}}var Ae=z(D(),1),Ee=z(Te(),1),wt=z(ot(),1),$r=`
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
"use strict";var __exports__=(()=>{var gr=Object.create;var ue=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var Tr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Rr=Object.prototype.hasOwnProperty;var Ke=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),yr=(t,e)=>{for(var n in e)ue(t,n,{get:e[n],enumerable:!0})},xe=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Tr(e))!Rr.call(t,s)&&s!==n&&ue(t,s,{get:()=>e[s],enumerable:!(r=Mr(e,s))||r.enumerable});return t},ge=(t,e,n)=>(xe(t,e,"default"),n&&xe(n,e,"default")),C=(t,e,n)=>(n=t!=null?gr(_r(t)):{},xe(e||!t||!t.__esModule?ue(n,"default",{value:t,enumerable:!0}):n,t)),Ar=t=>xe(ue({},"__esModule",{value:!0}),t);var X=Ke((Ko,Rt)=>{Rt.exports=globalThis.luma});var se=Ke((Do,yt)=>{yt.exports=globalThis.luma});var dt=Ke((lc,nr)=>{nr.exports=globalThis.luma});var de={};yr(de,{GLTFAnimator:()=>te,createScenegraphsFromGLTF:()=>xr,getGLTFExtensionSupport:()=>ze,loadPBREnvironment:()=>Ut,parseGLTFLights:()=>He,parsePBRMaterial:()=>pe});ge(de,C(X(),1));var je=C(se(),1);function j(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var D={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Er=D.self||D.window||D.global||{},Sr=D.window||D.self||D.global||{},wr=D.global||D.self||D.window||{},Nr=D.document||{};var De=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var At=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Or=At&&parseFloat(At[1])||0;var Lr="",Et={};function Be(t){for(let e in Et)if(t.startsWith(e)){let n=Et[e];t=t.replace(e,n)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${Lr}${t}`),t}var St="4.4.0-alpha.18";var br=globalThis.loaders?.parseImageNode,Ve=typeof Image<"u",qe=typeof ImageBitmap<"u",Ir=Boolean(br),$e=De?!0:Ir;function wt(t){switch(t){case"auto":return qe||Ve||$e;case"imagebitmap":return qe;case"image":return Ve;case"data":return $e;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function Nt(){if(qe)return"imagebitmap";if(Ve)return"image";if($e)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Ot(t){let e=Pr(t);if(!e)throw new Error("Not an image");return e}function We(t){return Me(t)}function Me(t){switch(Ot(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),n=e.getContext("2d");if(!n)throw new Error("getImageData");return e.width=t.width,e.height=t.height,n.drawImage(t,0,0),n.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function Pr(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var vr=/^data:image\/svg\+xml/,Fr=/\.svg((\?|#).*)?$/;function Te(t){return t&&(vr.test(t)||Fr.test(t))}function Lt(t,e){if(Te(e)){let r=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return Ye(t,e)}function Ye(t,e){if(Te(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function _e(t,e,n){let r=Lt(t,n),s=self.URL||self.webkitURL,o=typeof r!="string"&&s.createObjectURL(r);try{return await kr(o||r,e)}finally{o&&s.revokeObjectURL(o)}}async function kr(t,e){let n=new Image;return n.src=t,e.image&&e.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,s)=>{try{n.onload=()=>r(n),n.onerror=o=>{let i=o instanceof Error?o.message:"error";s(new Error(i))}}catch(o){s(o)}})}var bt=!0;async function It(t,e,n){let r;Te(n)?r=await _e(t,e,n):r=Ye(t,n);let s=e&&e.imagebitmap;return await Cr(r,s)}async function Cr(t,e=null){if((Hr(e)||!bt)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(n){console.warn(n),bt=!1}return await createImageBitmap(t)}function Hr(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Pt(t){return!Dr(t,"ftyp",4)||!(t[8]&96)?null:Ur(t)}function Ur(t){switch(zr(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function zr(t,e,n){return String.fromCharCode(...t.slice(e,n))}function Kr(t){return[...t].map(e=>e.charCodeAt(0))}function Dr(t,e,n=0){let r=Kr(e);for(let s=0;s<r.length;++s)if(r[s]!==t[s+n])return!1;return!0}var B=!1,oe=!0;function Re(t){let e=ie(t);return Vr(e)||Wr(e)||qr(e)||$r(e)||Br(e)}function Br(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),n=Pt(e);return n?{mimeType:n.mimeType,width:0,height:0}:null}function Vr(t){let e=ie(t);return e.byteLength>=24&&e.getUint32(0,B)===2303741511?{mimeType:"image/png",width:e.getUint32(16,B),height:e.getUint32(20,B)}:null}function qr(t){let e=ie(t);return e.byteLength>=10&&e.getUint32(0,B)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,oe),height:e.getUint16(8,oe)}:null}function $r(t){let e=ie(t);return e.byteLength>=14&&e.getUint16(0,B)===16973&&e.getUint32(2,oe)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,oe),height:e.getUint32(22,oe)}:null}function Wr(t){let e=ie(t);if(!(e.byteLength>=3&&e.getUint16(0,B)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=Yr(),o=2;for(;o+9<e.byteLength;){let i=e.getUint16(o,B);if(s.has(i))return{mimeType:"image/jpeg",height:e.getUint16(o+5,B),width:e.getUint16(o+7,B)};if(!r.has(i))return null;o+=2,o+=e.getUint16(o,B)}return null}function Yr(){let t=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)t.add(n);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ie(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function vt(t,e){let{mimeType:n}=Re(t)||{},r=globalThis.loaders?.parseImageNode;return j(r),await r(t,n)}async function Ft(t,e,n){e=e||{};let s=(e.image||{}).type||"auto",{url:o}=n||{},i=Gr(s),a;switch(i){case"imagebitmap":a=await It(t,e,o);break;case"image":a=await _e(t,e,o);break;case"data":a=await vt(t,e);break;default:j(!1)}return s==="data"&&(a=Me(a)),a}function Gr(t){switch(t){case"auto":case"data":return Nt();default:return wt(t),t}}var Xr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],jr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],Jr={image:{type:"auto",decode:!0}},ye={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:St,mimeTypes:jr,extensions:Xr,parse:Ft,tests:[t=>Boolean(Re(new DataView(t)))],options:Jr};function Ae(t,e,n){let r=typeof t=="function"?t({...e,...n}):t,s=e.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),Be(r)}var Qr=t=>t&&typeof t=="object";async function kt(t,e,n={}){return await Ge(t,e,n)}async function Ge(t,e,n){return Array.isArray(t)?await es(t,e,n):Qr(t)?await Zr(t,e,n):await e(t,n)}async function Zr(t,e,n){let r=[],s={};for(let o in t){let i=t[o],a=Ge(i,e,n).then(c=>{s[o]=c});r.push(a)}return await Promise.all(r),s}async function es(t,e,n={}){let r=t.map(s=>Ge(s,e,n));return await Promise.all(r)}async function Ct(t,e,n){return await kt(t,r=>Xe(r,e,n))}async function Xe(t,e,n){let s=await(await fetch(t,n.fetch)).arrayBuffer();return await e(s,n)}async function ae(t,e={}){let n=await ts(t,e);return await Ct(n,ye.parse,e)}async function ts(t,e,n={}){let r=e&&e.image&&e.image.mipLevels||0;return r!==0?await ns(t,r,e,n):Ae(t,e,n)}async function ns(t,e,n,r){let s=[];if(e==="auto"){let o=Ae(t,n,{...r,lod:0}),i=await Xe(o,ye.parse,n),{width:a,height:c}=We(i);e=rs({width:a,height:c}),s.push(o)}j(e>0);for(let o=s.length;o<e;++o){let i=Ae(t,n,{...r,lod:o});s.push(i)}return s}function rs(t){return 1+Math.floor(Math.log2(Math.max(t.width,t.height)))}function Ut(t,e){let n=e.specularMipLevels??1,r=new je.DynamicTexture(t,{id:"brdfLUT",sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"},data:ae(e.brdfLutUrl)}),s=Ht(t,{id:"DiffuseEnvSampler",getTextureForFace:i=>ae(e.getTexUrl("diffuse",Ee.indexOf(i),0)),sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}}),o=Ht(t,{id:"SpecularEnvSampler",getTextureForFace:i=>{let a=[],c=Ee.indexOf(i);for(let l=0;l<n;l++)a.push(ae(e.getTexUrl("specular",c,l)));return Promise.all(a)},sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}});return{brdfLutTexture:r,diffuseEnvSampler:s,specularEnvSampler:o}}var Ee=["+X","-X","+Y","-Y","+Z","-Z"];function Ht(t,{id:e,getTextureForFace:n,sampler:r}){let s=Promise.all(Ee.map(o=>n(o))).then(o=>{let i={};return Ee.forEach((a,c)=>{i[a]=o[c]}),i});return new je.DynamicTexture(t,{id:e,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var N=C(X(),1);var y;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ONE=1]="ONE",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST=9728]="NEAREST",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(y||(y={}));function Kt(t){return{addressModeU:zt(t.wrapS),addressModeV:zt(t.wrapT),magFilter:ss(t.magFilter),...os(t.minFilter)}}function zt(t){switch(t){case y.CLAMP_TO_EDGE:return"clamp-to-edge";case y.REPEAT:return"repeat";case y.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function ss(t){switch(t){case y.NEAREST:return"nearest";case y.LINEAR:return"linear";default:return}}function os(t){switch(t){case y.NEAREST:return{minFilter:"nearest"};case y.LINEAR:return{minFilter:"linear"};case y.NEAREST_MIPMAP_NEAREST:return{minFilter:"nearest",mipmapFilter:"nearest"};case y.LINEAR_MIPMAP_NEAREST:return{minFilter:"linear",mipmapFilter:"nearest"};case y.NEAREST_MIPMAP_LINEAR:return{minFilter:"nearest",mipmapFilter:"linear"};case y.LINEAR_MIPMAP_LINEAR:return{minFilter:"linear",mipmapFilter:"linear"};default:return{}}}var Yi=1/Math.PI*180,Gi=1/180*Math.PI,is={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...is}};var O=globalThis.mathgl.config;function Dt(t,{precision:e=O.precision}={}){return t=as(t),`${parseFloat(t.toPrecision(e))}`}function J(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Je(t,e,n){let r=O.EPSILON;n&&(O.EPSILON=n);try{if(t===e)return!0;if(J(t)&&J(e)){if(t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(!Je(t[s],e[s]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=O.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{O.EPSILON=r}}function as(t){return Math.round(t/O.EPSILON)*O.EPSILON}var W=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+n];return this.check()}toArray(e=[],n=0){for(let r=0;r<this.ELEMENTS;++r)e[n+r]=this[r];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:J(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Dt(this[r],e);return`${e.printTypes?this.constructor.name:""}[${n}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!Je(this[n],e[n]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==e[n])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,n,r){if(r===void 0)return this.lerp(this,e,n);for(let s=0;s<this.ELEMENTS;++s){let o=e[s],i=typeof n=="number"?n:n[s];this[s]=o+r*(i-o)}return this.check()}min(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(e[n],this[n]);return this.check()}max(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(e[n],this[n]);return this.check()}clamp(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),n[r]);return this.check()}add(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(e){if(typeof e=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;else for(let n=0;n<this.ELEMENTS&&n<e.length;++n)this[n]*=e[n];return this.check()}multiplyByScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)e=e&&Number.isFinite(this[n]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]=e;return this.check()}addScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let n=0;n<this.ELEMENTS;++n)this[n]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),n);return this.check()}get elements(){return this}};function cs(t,e){if(t.length!==e)return!1;for(let n=0;n<t.length;++n)if(!Number.isFinite(t[n]))return!1;return!0}function S(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Y(t,e,n=""){if(O.debug&&!cs(t,e))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return t}function Qe(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Se=class extends W{get x(){return this[0]}set x(e){this[0]=S(e)}get y(){return this[1]}set y(e){this[1]=S(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let n=0;n<this.ELEMENTS;++n)e+=this[n]*this[n];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-e[r];n+=s*s}return S(n)}dot(e){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*e[r];return S(n)}normalize(){let e=this.magnitude();if(e!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=e;return this.check()}multiply(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...e){for(let n of e)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Qe(e>=0&&e<this.ELEMENTS,"index is out of range"),S(this[e])}setComponent(e,n){return Qe(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=n,this.check()}addVectors(e,n){return this.copy(e).add(n)}subVectors(e,n){return this.copy(e).subtract(n)}multiplyVectors(e,n){return this.copy(e).multiply(n)}addScaledVector(e,n){return this.add(new this.constructor(e).multiplyScalar(n))}};var I=typeof Float32Array<"u"?Float32Array:Array;var oa=Math.PI/180;function ls(){let t=new I(2);return I!=Float32Array&&(t[0]=0,t[1]=0),t}function qt(t,e,n){let r=e[0],s=e[1];return t[0]=n[0]*r+n[3]*s+n[6],t[1]=n[1]*r+n[4]*s+n[7],t}function $t(t,e,n){let r=e[0],s=e[1];return t[0]=n[0]*r+n[4]*s+n[12],t[1]=n[1]*r+n[5]*s+n[13],t}var ia=function(){let t=ls();return function(e,n,r,s,o,i){let a,c;for(n||(n=2),r||(r=0),s?c=Math.min(s*n+r,e.length):c=e.length,a=r;a<c;a+=n)t[0]=e[a],t[1]=e[a+1],o(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}();function Wt(t,e,n){let r=e[0],s=e[1],o=n[3]*r+n[7]*s||1;return t[0]=(n[0]*r+n[4]*s)/o,t[1]=(n[1]*r+n[5]*s)/o,t}function Yt(t,e,n){let r=e[0],s=e[1],o=e[2],i=n[3]*r+n[7]*s+n[11]*o||1;return t[0]=(n[0]*r+n[4]*s+n[8]*o)/i,t[1]=(n[1]*r+n[5]*s+n[9]*o)/i,t[2]=(n[2]*r+n[6]*s+n[10]*o)/i,t}function Gt(t,e,n){let r=e[0],s=e[1];return t[0]=n[0]*r+n[2]*s,t[1]=n[1]*r+n[3]*s,t[2]=e[2],t[3]=e[3],t}function we(t,e,n){let r=e[0],s=e[1],o=e[2];return t[0]=n[0]*r+n[3]*s+n[6]*o,t[1]=n[1]*r+n[4]*s+n[7]*o,t[2]=n[2]*r+n[5]*s+n[8]*o,t[3]=e[3],t}function Ze(){let t=new I(3);return I!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function fs(t){let e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function et(t,e,n){let r=new I(3);return r[0]=t,r[1]=e,r[2]=n,r}function Xt(t,e){let n=e[0],r=e[1],s=e[2],o=n*n+r*r+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function jt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ne(t,e,n){let r=e[0],s=e[1],o=e[2],i=n[0],a=n[1],c=n[2];return t[0]=s*c-o*a,t[1]=o*i-r*c,t[2]=r*a-s*i,t}function Oe(t,e,n){let r=e[0],s=e[1],o=e[2],i=n[3]*r+n[7]*s+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*s+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*s+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*s+n[10]*o+n[14])/i,t}function Jt(t,e,n){let r=e[0],s=e[1],o=e[2];return t[0]=r*n[0]+s*n[3]+o*n[6],t[1]=r*n[1]+s*n[4]+o*n[7],t[2]=r*n[2]+s*n[5]+o*n[8],t}function Qt(t,e,n){let r=n[0],s=n[1],o=n[2],i=n[3],a=e[0],c=e[1],l=e[2],m=s*l-o*c,p=o*a-r*l,f=r*c-s*a,h=s*f-o*p,d=o*m-r*f,x=r*p-s*m,u=i*2;return m*=u,p*=u,f*=u,h*=2,d*=2,x*=2,t[0]=a+m+h,t[1]=c+p+d,t[2]=l+f+x,t}var Zt=fs;var la=function(){let t=Ze();return function(e,n,r,s,o,i){let a,c;for(n||(n=3),r||(r=0),s?c=Math.min(s*n+r,e.length):c=e.length,a=r;a<c;a+=n)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],o(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var Le,Q=class extends Se{static get ZERO(){return Le||(Le=new Q(0,0,0,0),Object.freeze(Le)),Le}constructor(e=0,n=0,r=0,s=0){super(-0,-0,-0,-0),J(e)&&arguments.length===1?this.copy(e):(O.debug&&(S(e),S(n),S(r),S(s)),this[0]=e,this[1]=n,this[2]=r,this[3]=s)}set(e,n,r,s){return this[0]=e,this[1]=n,this[2]=r,this[3]=s,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return O.debug&&(S(e.x),S(e.y),S(e.z),S(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=S(e)}get w(){return this[3]}set w(e){this[3]=S(e)}transform(e){return Oe(this,this,e),this.check()}transformByMatrix3(e){return we(this,this,e),this.check()}transformByMatrix2(e){return Gt(this,this,e),this.check()}transformByQuaternion(e){return Qt(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var Z=class extends W{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)e+=` ${this[r*this.RANK+n]}`}else{e+="column-major:";for(let n=0;n<this.ELEMENTS;++n)e+=` ${this[n]}`}return e+="]",e}getElementIndex(e,n){return n*this.RANK+e}getElement(e,n){return this[n*this.RANK+e]}setElement(e,n,r){return this[n*this.RANK+e]=S(r),this}getColumn(e,n=new Array(this.RANK).fill(-0)){let r=e*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(e,n){let r=e*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function en(){let t=new I(9);return I!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function tn(t,e){if(t===e){let n=e[1],r=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=r,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function nn(t,e){let n=e[0],r=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],m=e[8],p=m*i-a*l,f=-m*o+a*c,h=l*o-i*c,d=n*p+r*f+s*h;return d?(d=1/d,t[0]=p*d,t[1]=(-m*r+s*l)*d,t[2]=(a*r-s*i)*d,t[3]=f*d,t[4]=(m*n-s*c)*d,t[5]=(-a*n+s*o)*d,t[6]=h*d,t[7]=(-l*n+r*c)*d,t[8]=(i*n-r*o)*d,t):null}function rn(t){let e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*o-i*c)+n*(-l*s+i*a)+r*(c*s-o*a)}function tt(t,e,n){let r=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],m=e[7],p=e[8],f=n[0],h=n[1],d=n[2],x=n[3],u=n[4],g=n[5],A=n[6],M=n[7],T=n[8];return t[0]=f*r+h*i+d*l,t[1]=f*s+h*a+d*m,t[2]=f*o+h*c+d*p,t[3]=x*r+u*i+g*l,t[4]=x*s+u*a+g*m,t[5]=x*o+u*c+g*p,t[6]=A*r+M*i+T*l,t[7]=A*s+M*a+T*m,t[8]=A*o+M*c+T*p,t}function sn(t,e,n){let r=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],m=e[7],p=e[8],f=n[0],h=n[1];return t[0]=r,t[1]=s,t[2]=o,t[3]=i,t[4]=a,t[5]=c,t[6]=f*r+h*i+l,t[7]=f*s+h*a+m,t[8]=f*o+h*c+p,t}function on(t,e,n){let r=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],m=e[7],p=e[8],f=Math.sin(n),h=Math.cos(n);return t[0]=h*r+f*i,t[1]=h*s+f*a,t[2]=h*o+f*c,t[3]=h*i-f*r,t[4]=h*a-f*s,t[5]=h*c-f*o,t[6]=l,t[7]=m,t[8]=p,t}function nt(t,e,n){let r=n[0],s=n[1];return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function an(t,e){let n=e[0],r=e[1],s=e[2],o=e[3],i=n+n,a=r+r,c=s+s,l=n*i,m=r*i,p=r*a,f=s*i,h=s*a,d=s*c,x=o*i,u=o*a,g=o*c;return t[0]=1-p-d,t[3]=m-g,t[6]=f+u,t[1]=m+g,t[4]=1-l-d,t[7]=h-x,t[2]=f-u,t[5]=h+x,t[8]=1-l-p,t}var rt;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(rt||(rt={}));var hs=Object.freeze([1,0,0,0,1,0,0,0,1]),H=class extends Z{static get IDENTITY(){return xs()}static get ZERO(){return ds()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return rt}constructor(e,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):n.length>0?this.copy([e,...n]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(hs)}fromObject(e){return this.check()}fromQuaternion(e){return an(this,e),this.check()}set(e,n,r,s,o,i,a,c,l){return this[0]=e,this[1]=n,this[2]=r,this[3]=s,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,n,r,s,o,i,a,c,l){return this[0]=e,this[1]=s,this[2]=a,this[3]=n,this[4]=o,this[5]=c,this[6]=r,this[7]=i,this[8]=l,this.check()}determinant(){return rn(this)}transpose(){return tn(this,this),this.check()}invert(){return nn(this,this),this.check()}multiplyLeft(e){return tt(this,e,this),this.check()}multiplyRight(e){return tt(this,this,e),this.check()}rotate(e){return on(this,this,e),this.check()}scale(e){return Array.isArray(e)?nt(this,this,e):nt(this,this,[e,e]),this.check()}translate(e){return sn(this,this,e),this.check()}transform(e,n){let r;switch(e.length){case 2:r=qt(n||[-0,-0],e,this);break;case 3:r=Jt(n||[-0,-0,-0],e,this);break;case 4:r=we(n||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Y(r,e.length),r}transformVector(e,n){return this.transform(e,n)}transformVector2(e,n){return this.transform(e,n)}transformVector3(e,n){return this.transform(e,n)}},be,Ie=null;function ds(){return be||(be=new H([0,0,0,0,0,0,0,0,0]),Object.freeze(be)),be}function xs(){return Ie||(Ie=new H,Object.freeze(Ie)),Ie}function us(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function cn(t,e){if(t===e){let n=e[1],r=e[2],s=e[3],o=e[6],i=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=s,t[13]=i,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function ln(t,e){let n=e[0],r=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],m=e[8],p=e[9],f=e[10],h=e[11],d=e[12],x=e[13],u=e[14],g=e[15],A=n*a-r*i,M=n*c-s*i,T=n*l-o*i,_=r*c-s*a,R=r*l-o*a,P=s*l-o*c,v=m*x-p*d,F=m*u-f*d,k=m*g-h*d,U=p*u-f*x,z=p*g-h*x,K=f*g-h*u,E=A*K-M*z+T*U+_*k-R*F+P*v;return E?(E=1/E,t[0]=(a*K-c*z+l*U)*E,t[1]=(s*z-r*K-o*U)*E,t[2]=(x*P-u*R+g*_)*E,t[3]=(f*R-p*P-h*_)*E,t[4]=(c*k-i*K-l*F)*E,t[5]=(n*K-s*k+o*F)*E,t[6]=(u*T-d*P-g*M)*E,t[7]=(m*P-f*T+h*M)*E,t[8]=(i*z-a*k+l*v)*E,t[9]=(r*k-n*z-o*v)*E,t[10]=(d*R-x*T+g*A)*E,t[11]=(p*T-m*R-h*A)*E,t[12]=(a*F-i*U-c*v)*E,t[13]=(n*U-r*F+s*v)*E,t[14]=(x*M-d*_-u*A)*E,t[15]=(m*_-p*M+f*A)*E,t):null}function fn(t){let e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],i=t[5],a=t[6],c=t[7],l=t[8],m=t[9],p=t[10],f=t[11],h=t[12],d=t[13],x=t[14],u=t[15],g=e*i-n*o,A=e*a-r*o,M=n*a-r*i,T=l*d-m*h,_=l*x-p*h,R=m*x-p*d,P=e*R-n*_+r*T,v=o*R-i*_+a*T,F=l*M-m*A+p*g,k=h*M-d*A+x*g;return c*P-s*v+u*F-f*k}function st(t,e,n){let r=e[0],s=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],m=e[7],p=e[8],f=e[9],h=e[10],d=e[11],x=e[12],u=e[13],g=e[14],A=e[15],M=n[0],T=n[1],_=n[2],R=n[3];return t[0]=M*r+T*a+_*p+R*x,t[1]=M*s+T*c+_*f+R*u,t[2]=M*o+T*l+_*h+R*g,t[3]=M*i+T*m+_*d+R*A,M=n[4],T=n[5],_=n[6],R=n[7],t[4]=M*r+T*a+_*p+R*x,t[5]=M*s+T*c+_*f+R*u,t[6]=M*o+T*l+_*h+R*g,t[7]=M*i+T*m+_*d+R*A,M=n[8],T=n[9],_=n[10],R=n[11],t[8]=M*r+T*a+_*p+R*x,t[9]=M*s+T*c+_*f+R*u,t[10]=M*o+T*l+_*h+R*g,t[11]=M*i+T*m+_*d+R*A,M=n[12],T=n[13],_=n[14],R=n[15],t[12]=M*r+T*a+_*p+R*x,t[13]=M*s+T*c+_*f+R*u,t[14]=M*o+T*l+_*h+R*g,t[15]=M*i+T*m+_*d+R*A,t}function pn(t,e,n){let r=n[0],s=n[1],o=n[2],i,a,c,l,m,p,f,h,d,x,u,g;return e===t?(t[12]=e[0]*r+e[4]*s+e[8]*o+e[12],t[13]=e[1]*r+e[5]*s+e[9]*o+e[13],t[14]=e[2]*r+e[6]*s+e[10]*o+e[14],t[15]=e[3]*r+e[7]*s+e[11]*o+e[15]):(i=e[0],a=e[1],c=e[2],l=e[3],m=e[4],p=e[5],f=e[6],h=e[7],d=e[8],x=e[9],u=e[10],g=e[11],t[0]=i,t[1]=a,t[2]=c,t[3]=l,t[4]=m,t[5]=p,t[6]=f,t[7]=h,t[8]=d,t[9]=x,t[10]=u,t[11]=g,t[12]=i*r+m*s+d*o+e[12],t[13]=a*r+p*s+x*o+e[13],t[14]=c*r+f*s+u*o+e[14],t[15]=l*r+h*s+g*o+e[15]),t}function mn(t,e,n){let r=n[0],s=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function hn(t,e,n,r){let s=r[0],o=r[1],i=r[2],a=Math.sqrt(s*s+o*o+i*i),c,l,m,p,f,h,d,x,u,g,A,M,T,_,R,P,v,F,k,U,z,K,E,re;return a<1e-6?null:(a=1/a,s*=a,o*=a,i*=a,l=Math.sin(n),c=Math.cos(n),m=1-c,p=e[0],f=e[1],h=e[2],d=e[3],x=e[4],u=e[5],g=e[6],A=e[7],M=e[8],T=e[9],_=e[10],R=e[11],P=s*s*m+c,v=o*s*m+i*l,F=i*s*m-o*l,k=s*o*m-i*l,U=o*o*m+c,z=i*o*m+s*l,K=s*i*m+o*l,E=o*i*m-s*l,re=i*i*m+c,t[0]=p*P+x*v+M*F,t[1]=f*P+u*v+T*F,t[2]=h*P+g*v+_*F,t[3]=d*P+A*v+R*F,t[4]=p*k+x*U+M*z,t[5]=f*k+u*U+T*z,t[6]=h*k+g*U+_*z,t[7]=d*k+A*U+R*z,t[8]=p*K+x*E+M*re,t[9]=f*K+u*E+T*re,t[10]=h*K+g*E+_*re,t[11]=d*K+A*E+R*re,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function dn(t,e,n){let r=Math.sin(n),s=Math.cos(n),o=e[4],i=e[5],a=e[6],c=e[7],l=e[8],m=e[9],p=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*s+l*r,t[5]=i*s+m*r,t[6]=a*s+p*r,t[7]=c*s+f*r,t[8]=l*s-o*r,t[9]=m*s-i*r,t[10]=p*s-a*r,t[11]=f*s-c*r,t}function xn(t,e,n){let r=Math.sin(n),s=Math.cos(n),o=e[0],i=e[1],a=e[2],c=e[3],l=e[8],m=e[9],p=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s-l*r,t[1]=i*s-m*r,t[2]=a*s-p*r,t[3]=c*s-f*r,t[8]=o*r+l*s,t[9]=i*r+m*s,t[10]=a*r+p*s,t[11]=c*r+f*s,t}function un(t,e,n){let r=Math.sin(n),s=Math.cos(n),o=e[0],i=e[1],a=e[2],c=e[3],l=e[4],m=e[5],p=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*s+l*r,t[1]=i*s+m*r,t[2]=a*s+p*r,t[3]=c*s+f*r,t[4]=l*s-o*r,t[5]=m*s-i*r,t[6]=p*s-a*r,t[7]=f*s-c*r,t}function gn(t,e){let n=e[0],r=e[1],s=e[2],o=e[3],i=n+n,a=r+r,c=s+s,l=n*i,m=r*i,p=r*a,f=s*i,h=s*a,d=s*c,x=o*i,u=o*a,g=o*c;return t[0]=1-p-d,t[1]=m+g,t[2]=f-u,t[3]=0,t[4]=m-g,t[5]=1-l-d,t[6]=h+x,t[7]=0,t[8]=f+u,t[9]=h-x,t[10]=1-l-p,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Mn(t,e,n,r,s,o,i){let a=1/(n-e),c=1/(s-r),l=1/(o-i);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(n+e)*a,t[9]=(s+r)*c,t[10]=(i+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*o*2*l,t[15]=0,t}function gs(t,e,n,r,s){let o=1/Math.tan(e/2);if(t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let i=1/(r-s);t[10]=(s+r)*i,t[14]=2*s*r*i}else t[10]=-1,t[14]=-2*r;return t}var Tn=gs;function Ms(t,e,n,r,s,o,i){let a=1/(e-n),c=1/(r-s),l=1/(o-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+n)*a,t[13]=(s+r)*c,t[14]=(i+o)*l,t[15]=1,t}var _n=Ms;function Rn(t,e,n,r){let s,o,i,a,c,l,m,p,f,h,d=e[0],x=e[1],u=e[2],g=r[0],A=r[1],M=r[2],T=n[0],_=n[1],R=n[2];return Math.abs(d-T)<1e-6&&Math.abs(x-_)<1e-6&&Math.abs(u-R)<1e-6?us(t):(p=d-T,f=x-_,h=u-R,s=1/Math.sqrt(p*p+f*f+h*h),p*=s,f*=s,h*=s,o=A*h-M*f,i=M*p-g*h,a=g*f-A*p,s=Math.sqrt(o*o+i*i+a*a),s?(s=1/s,o*=s,i*=s,a*=s):(o=0,i=0,a=0),c=f*a-h*i,l=h*o-p*a,m=p*i-f*o,s=Math.sqrt(c*c+l*l+m*m),s?(s=1/s,c*=s,l*=s,m*=s):(c=0,l=0,m=0),t[0]=o,t[1]=c,t[2]=p,t[3]=0,t[4]=i,t[5]=l,t[6]=f,t[7]=0,t[8]=a,t[9]=m,t[10]=h,t[11]=0,t[12]=-(o*d+i*x+a*u),t[13]=-(c*d+l*x+m*u),t[14]=-(p*d+f*x+h*u),t[15]=1,t)}function Ts(){let t=new I(4);return I!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function yn(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t}function An(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}function En(t){let e=t[0],n=t[1],r=t[2],s=t[3];return Math.sqrt(e*e+n*n+r*r+s*s)}function Sn(t){let e=t[0],n=t[1],r=t[2],s=t[3];return e*e+n*n+r*r+s*s}function wn(t,e){let n=e[0],r=e[1],s=e[2],o=e[3],i=n*n+r*r+s*s+o*o;return i>0&&(i=1/Math.sqrt(i)),t[0]=n*i,t[1]=r*i,t[2]=s*i,t[3]=o*i,t}function Nn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function On(t,e,n,r){let s=e[0],o=e[1],i=e[2],a=e[3];return t[0]=s+r*(n[0]-s),t[1]=o+r*(n[1]-o),t[2]=i+r*(n[2]-i),t[3]=a+r*(n[3]-a),t}function Ln(t,e,n){let r=e[0],s=e[1],o=e[2],i=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*o+n[12]*i,t[1]=n[1]*r+n[5]*s+n[9]*o+n[13]*i,t[2]=n[2]*r+n[6]*s+n[10]*o+n[14]*i,t[3]=n[3]*r+n[7]*s+n[11]*o+n[15]*i,t}function bn(t,e,n){let r=e[0],s=e[1],o=e[2],i=n[0],a=n[1],c=n[2],l=n[3],m=l*r+a*o-c*s,p=l*s+c*r-i*o,f=l*o+i*s-a*r,h=-i*r-a*s-c*o;return t[0]=m*l+h*-i+p*-c-f*-a,t[1]=p*l+h*-a+f*-i-m*-c,t[2]=f*l+h*-c+m*-a-p*-i,t[3]=e[3],t}var Oa=function(){let t=Ts();return function(e,n,r,s,o,i){let a,c;for(n||(n=4),r||(r=0),s?c=Math.min(s*n+r,e.length):c=e.length,a=r;a<c;a+=n)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],o(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var at;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(at||(at={}));var Rs=45*Math.PI/180,ys=1,ot=.1,it=500,As=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),V=class extends Z{static get IDENTITY(){return Ss()}static get ZERO(){return Es()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return at}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,n,r,s,o,i,a,c,l,m,p,f,h,d,x,u){return this[0]=e,this[1]=n,this[2]=r,this[3]=s,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=m,this[10]=p,this[11]=f,this[12]=h,this[13]=d,this[14]=x,this[15]=u,this.check()}setRowMajor(e,n,r,s,o,i,a,c,l,m,p,f,h,d,x,u){return this[0]=e,this[1]=o,this[2]=l,this[3]=h,this[4]=n,this[5]=i,this[6]=m,this[7]=d,this[8]=r,this[9]=a,this[10]=p,this[11]=x,this[12]=s,this[13]=c,this[14]=f,this[15]=u,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(As)}fromObject(e){return this.check()}fromQuaternion(e){return gn(this,e),this.check()}frustum(e){let{left:n,right:r,bottom:s,top:o,near:i=ot,far:a=it}=e;return a===1/0?ws(this,n,r,s,o,i):Mn(this,n,r,s,o,i,a),this.check()}lookAt(e){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=e;return Rn(this,n,r,s),this.check()}ortho(e){let{left:n,right:r,bottom:s,top:o,near:i=ot,far:a=it}=e;return _n(this,n,r,s,o,i,a),this.check()}orthographic(e){let{fovy:n=Rs,aspect:r=ys,focalDistance:s=1,near:o=ot,far:i=it}=e;In(n);let a=n/2,c=s*Math.tan(a),l=c*r;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:i})}perspective(e){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:o=500}=e;return In(n),Tn(this,n,r,s,o),this.check()}determinant(){return fn(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,n){e=e||[-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],o=1/r[1],i=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*o,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*o,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,n){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],o=1/r[1],i=1/r[2];return e[0]=this[0]*s,e[1]=this[1]*o,e[2]=this[2]*i,e[3]=this[4]*s,e[4]=this[5]*o,e[5]=this[6]*i,e[6]=this[8]*s,e[7]=this[9]*o,e[8]=this[10]*i,e}transpose(){return cn(this,this),this.check()}invert(){return ln(this,this),this.check()}multiplyLeft(e){return st(this,e,this),this.check()}multiplyRight(e){return st(this,this,e),this.check()}rotateX(e){return dn(this,this,e),this.check()}rotateY(e){return xn(this,this,e),this.check()}rotateZ(e){return un(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,n){return hn(this,this,e,n),this.check()}scale(e){return mn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return pn(this,this,e),this.check()}transform(e,n){return e.length===4?(n=Ln(n||[-0,-0,-0,-0],e,this),Y(n,4),n):this.transformAsPoint(e,n)}transformAsPoint(e,n){let{length:r}=e,s;switch(r){case 2:s=$t(n||[-0,-0],e,this);break;case 3:s=Oe(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Y(s,e.length),s}transformAsVector(e,n){let r;switch(e.length){case 2:r=Wt(n||[-0,-0],e,this);break;case 3:r=Yt(n||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Y(r,e.length),r}transformPoint(e,n){return this.transformAsPoint(e,n)}transformVector(e,n){return this.transformAsPoint(e,n)}transformDirection(e,n){return this.transformAsVector(e,n)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,n,r){return this.identity().translate([e,n,r])}},Pe,ve;function Es(){return Pe||(Pe=new V([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Pe)),Pe}function Ss(){return ve||(ve=new V,Object.freeze(ve)),ve}function In(t){if(t>Math.PI*2)throw Error("expected radians")}function ws(t,e,n,r,s,o){let i=2*o/(n-e),a=2*o/(s-r),c=(n+e)/(n-e),l=(s+r)/(s-r),m=-1,p=-1,f=-2*o;return t[0]=i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=m,t[11]=p,t[12]=0,t[13]=0,t[14]=f,t[15]=0,t}function Pn(){let t=new I(4);return I!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function vn(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function ct(t,e,n){n=n*.5;let r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function lt(t,e,n){let r=e[0],s=e[1],o=e[2],i=e[3],a=n[0],c=n[1],l=n[2],m=n[3];return t[0]=r*m+i*a+s*l-o*c,t[1]=s*m+i*c+o*a-r*l,t[2]=o*m+i*l+r*c-s*a,t[3]=i*m-r*a-s*c-o*l,t}function Fn(t,e,n){n*=.5;let r=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(n),c=Math.cos(n);return t[0]=r*c+i*a,t[1]=s*c+o*a,t[2]=o*c-s*a,t[3]=i*c-r*a,t}function kn(t,e,n){n*=.5;let r=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(n),c=Math.cos(n);return t[0]=r*c-o*a,t[1]=s*c+i*a,t[2]=o*c+r*a,t[3]=i*c-s*a,t}function Cn(t,e,n){n*=.5;let r=e[0],s=e[1],o=e[2],i=e[3],a=Math.sin(n),c=Math.cos(n);return t[0]=r*c+s*a,t[1]=s*c-r*a,t[2]=o*c+i*a,t[3]=i*c-o*a,t}function Hn(t,e){let n=e[0],r=e[1],s=e[2];return t[0]=n,t[1]=r,t[2]=s,t[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),t}function le(t,e,n,r){let s=e[0],o=e[1],i=e[2],a=e[3],c=n[0],l=n[1],m=n[2],p=n[3],f,h,d,x,u;return f=s*c+o*l+i*m+a*p,f<0&&(f=-f,c=-c,l=-l,m=-m,p=-p),1-f>1e-6?(h=Math.acos(f),u=Math.sin(h),d=Math.sin((1-r)*h)/u,x=Math.sin(r*h)/u):(d=1-r,x=r),t[0]=d*s+x*c,t[1]=d*o+x*l,t[2]=d*i+x*m,t[3]=d*a+x*p,t}function Un(t,e){let n=e[0],r=e[1],s=e[2],o=e[3],i=n*n+r*r+s*s+o*o,a=i?1/i:0;return t[0]=-n*a,t[1]=-r*a,t[2]=-s*a,t[3]=o*a,t}function zn(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function ft(t,e){let n=e[0]+e[4]+e[8],r;if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{let s=0;e[4]>e[0]&&(s=1),e[8]>e[s*3+s]&&(s=2);let o=(s+1)%3,i=(s+2)%3;r=Math.sqrt(e[s*3+s]-e[o*3+o]-e[i*3+i]+1),t[s]=.5*r,r=.5/r,t[3]=(e[o*3+i]-e[i*3+o])*r,t[o]=(e[o*3+s]+e[s*3+o])*r,t[i]=(e[i*3+s]+e[s*3+i])*r}return t}var Kn=yn;var Dn=An,Bn=Nn,Vn=On,qn=En;var $n=Sn;var Wn=wn;var Yn=function(){let t=Ze(),e=et(1,0,0),n=et(0,1,0);return function(r,s,o){let i=jt(s,o);return i<-.999999?(Ne(t,e,s),Zt(t)<1e-6&&Ne(t,n,s),Xt(t,t),ct(r,t,Math.PI),r):i>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Ne(t,s,o),r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=1+i,Wn(r,r))}}(),Ba=function(){let t=Pn(),e=Pn();return function(n,r,s,o,i,a){return le(t,r,i,a),le(e,s,o,a),le(n,t,e,2*a*(1-a)),n}}(),Va=function(){let t=en();return function(e,n,r,s){return t[0]=r[0],t[3]=r[1],t[6]=r[2],t[1]=s[0],t[4]=s[1],t[7]=s[2],t[2]=-n[0],t[5]=-n[1],t[8]=-n[2],Wn(e,ft(e,t))}}();var Ns=[0,0,0,1],fe=class extends W{constructor(e=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,n,r,s)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,n,r,s){return this[0]=e,this[1]=n,this[2]=r,this[3]=s,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return ft(this,e),this.check()}fromAxisRotation(e,n){return ct(this,e,n),this.check()}identity(){return vn(this),this.check()}setAxisAngle(e,n){return this.fromAxisRotation(e,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=S(e)}get y(){return this[1]}set y(e){this[1]=S(e)}get z(){return this[2]}set z(e){this[2]=S(e)}get w(){return this[3]}set w(e){this[3]=S(e)}len(){return qn(this)}lengthSquared(){return $n(this)}dot(e){return Bn(this,e)}rotationTo(e,n){return Yn(this,e,n),this.check()}add(e){return Kn(this,this,e),this.check()}calculateW(){return Hn(this,this),this.check()}conjugate(){return zn(this,this),this.check()}invert(){return Un(this,this),this.check()}lerp(e,n,r){return r===void 0?this.lerp(this,e,n):(Vn(this,e,n,r),this.check())}multiplyRight(e){return lt(this,this,e),this.check()}multiplyLeft(e){return lt(this,e,this),this.check()}normalize(){let e=this.len(),n=e>0?1/e:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,e===0&&(this[3]=1),this.check()}rotateX(e){return Fn(this,this,e),this.check()}rotateY(e){return kn(this,this,e),this.check()}rotateZ(e){return Cn(this,this,e),this.check()}scale(e){return Dn(this,this,e),this.check()}slerp(e,n,r){let s,o,i;switch(arguments.length){case 1:({start:s=Ns,target:o,ratio:i}=e);break;case 2:s=this,o=e,i=n;break;default:s=e,o=n,i=r}return le(this,s,o,i),this.check()}transformVector4(e,n=new Q){return bn(n,e,this),Y(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,n){return this.setAxisAngle(e,n)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var pt=[L("baseColor","pbr_baseColorSampler","baseColorTexture",["pbrMetallicRoughness","baseColorTexture"]),L("metallicRoughness","pbr_metallicRoughnessSampler","metallicRoughnessTexture",["pbrMetallicRoughness","metallicRoughnessTexture"]),L("normal","pbr_normalSampler","normalTexture",["normalTexture"]),L("occlusion","pbr_occlusionSampler","occlusionTexture",["occlusionTexture"]),L("emissive","pbr_emissiveSampler","emissiveTexture",["emissiveTexture"]),L("specularColor","pbr_specularColorSampler","KHR_materials_specular.specularColorTexture",["extensions","KHR_materials_specular","specularColorTexture"]),L("specularIntensity","pbr_specularIntensitySampler","KHR_materials_specular.specularTexture",["extensions","KHR_materials_specular","specularTexture"]),L("transmission","pbr_transmissionSampler","KHR_materials_transmission.transmissionTexture",["extensions","KHR_materials_transmission","transmissionTexture"]),L("thickness","pbr_thicknessSampler","KHR_materials_volume.thicknessTexture",["extensions","KHR_materials_volume","thicknessTexture"]),L("clearcoat","pbr_clearcoatSampler","KHR_materials_clearcoat.clearcoatTexture",["extensions","KHR_materials_clearcoat","clearcoatTexture"]),L("clearcoatRoughness","pbr_clearcoatRoughnessSampler","KHR_materials_clearcoat.clearcoatRoughnessTexture",["extensions","KHR_materials_clearcoat","clearcoatRoughnessTexture"]),L("clearcoatNormal","pbr_clearcoatNormalSampler","KHR_materials_clearcoat.clearcoatNormalTexture",["extensions","KHR_materials_clearcoat","clearcoatNormalTexture"]),L("sheenColor","pbr_sheenColorSampler","KHR_materials_sheen.sheenColorTexture",["extensions","KHR_materials_sheen","sheenColorTexture"]),L("sheenRoughness","pbr_sheenRoughnessSampler","KHR_materials_sheen.sheenRoughnessTexture",["extensions","KHR_materials_sheen","sheenRoughnessTexture"]),L("iridescence","pbr_iridescenceSampler","KHR_materials_iridescence.iridescenceTexture",["extensions","KHR_materials_iridescence","iridescenceTexture"]),L("iridescenceThickness","pbr_iridescenceThicknessSampler","KHR_materials_iridescence.iridescenceThicknessTexture",["extensions","KHR_materials_iridescence","iridescenceThicknessTexture"]),L("anisotropy","pbr_anisotropySampler","KHR_materials_anisotropy.anisotropyTexture",["extensions","KHR_materials_anisotropy","anisotropyTexture"])],Os=new Map(pt.map(t=>[t.slot,t]));function L(t,e,n,r){return{slot:t,binding:e,displayName:n,pathSegments:r,uvSetUniform:`${t}UVSet`,uvTransformUniform:`${t}UVTransform`}}function Gn(){return pt}function ke(t){let e=Os.get(t);if(!e)throw new Error(`Unknown PBR texture transform slot ${t}`);return e}function Ce(t){let e=t?.extensions?.KHR_texture_transform;return{offset:e?.offset?[e.offset[0],e.offset[1]]:[0,0],rotation:e?.rotation??0,scale:e?.scale?[e.scale[0],e.scale[1]]:[1,1]}}function mt(t){return t?.extensions?.KHR_texture_transform?.texCoord??t?.texCoord??0}function Xn(t){return pt.find(e=>e.pathSegments.length===t.length&&e.pathSegments.every((n,r)=>t[r]===n))||null}function Fe(t){let e=new H().set(1,0,0,0,1,0,t.offset[0],t.offset[1],1),n=new H().set(Math.cos(t.rotation),Math.sin(t.rotation),0,-Math.sin(t.rotation),Math.cos(t.rotation),0,0,0,1),r=new H().set(t.scale[0],0,0,0,t.scale[1],0,0,0,1);return Array.from(e.multiplyRight(n).multiplyRight(r))}function jn(t,e){let n=new H(Fe(t)),r=new H(Fe(e)),s=new H(n).invert();return Array.from(r.multiplyRight(s))}function pe(t,e,n,r){let s={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=!0;let{imageBasedLightingEnvironment:o}=r;return o&&(s.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,s.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,s.bindings.pbr_brdfLUT=o.brdfLutTexture.texture,s.uniforms.IBLenabled=!0,s.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=!0,s.uniforms.scaleDiffBaseMR=[0,0,0,0],s.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(s.defines.HAS_NORMALS=!0),n.TANGENT&&r?.useTangents&&(s.defines.HAS_TANGENTS=!0),n.TEXCOORD_0&&(s.defines.HAS_UV=!0),n.TEXCOORD_1&&(s.defines.HAS_UV_1=!0),n.JOINTS_0&&n.WEIGHTS_0&&(s.defines.HAS_SKIN=!0),n.COLOR_0&&(s.defines.HAS_COLORS=!0),r?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=!0),r?.lights&&(s.defines.USE_LIGHTS=!0),e&&(r.validateAttributes!==!1&&Ls(e,n),Is(t,e,s,n,r.gltf)),s}function Ls(t,e){let n=Jn(t,0);n.length>0&&!e.TEXCOORD_0&&N.log.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)();let r=Jn(t,1);if(r.length>0&&!e.TEXCOORD_1&&N.log.warn(`glTF material uses ${r.join(", ")} with TEXCOORD_1 but primitive is missing TEXCOORD_1; those textures will be skipped`)(),Boolean(t.unlit||t.extensions?.KHR_materials_unlit)||e.NORMAL)return;let o=t.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";N.log.warn(`glTF primitive is missing NORMAL while using ${o}; shading will fall back to geometric normals`)()}function Jn(t,e){let n=[];for(let r of Gn()){let s=bs(t,r.pathSegments);s&&mt(s)===e&&n.push(r.displayName)}return n}function bs(t,e){let n=t;for(let r of e)if(n=n?.[r],!n)return null;return n}function Is(t,e,n,r,s){if(n.uniforms.unlit=Boolean(e.unlit||e.extensions?.KHR_materials_unlit),e.pbrMetallicRoughness&&Fs(t,e.pbrMetallicRoughness,n,r,s),e.normalTexture){b(t,e.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:s,attributes:r,textureTransformSlot:"normal"});let{scale:o=1}=e.normalTexture;n.uniforms.normalScale=o}if(e.occlusionTexture){b(t,e.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:s,attributes:r,textureTransformSlot:"occlusion"});let{strength:o=1}=e.occlusionTexture;n.uniforms.occlusionStrength=o}switch(n.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0],e.emissiveTexture&&b(t,e.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:s,attributes:r,textureTransformSlot:"emissive"}),ks(t,e.extensions,n,s,r),e.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:o=.5}=e;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoffEnabled=!0,n.uniforms.alphaCutoff=o;break}case"BLEND":N.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),Ps(n);break}}function Ps(t){t.parameters.blend=!0,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="src-alpha",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.blendEquation=y.FUNC_ADD,t.glParameters.blendFunc=[y.SRC_ALPHA,y.ONE_MINUS_SRC_ALPHA,y.ONE,y.ONE_MINUS_SRC_ALPHA]}function vs(t){t.parameters.blend=!0,t.parameters.depthWriteEnabled=!1,t.parameters.blendColorOperation="add",t.parameters.blendColorSrcFactor="one",t.parameters.blendColorDstFactor="one-minus-src-alpha",t.parameters.blendAlphaOperation="add",t.parameters.blendAlphaSrcFactor="one",t.parameters.blendAlphaDstFactor="one-minus-src-alpha",t.glParameters.blend=!0,t.glParameters.depthMask=!1,t.glParameters.blendEquation=y.FUNC_ADD,t.glParameters.blendFunc=[y.ONE,y.ONE_MINUS_SRC_ALPHA,y.ONE,y.ONE_MINUS_SRC_ALPHA]}function Fs(t,e,n,r,s){e.baseColorTexture&&b(t,e.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:s,attributes:r,textureTransformSlot:"baseColor"}),n.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&b(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:s,attributes:r,textureTransformSlot:"metallicRoughness"});let{metallicFactor:o=1,roughnessFactor:i=1}=e;n.uniforms.metallicRoughnessValues=[o,i]}function ks(t,e,n,r,s={}){e&&(Cs(e)&&(n.defines.USE_MATERIAL_EXTENSIONS=!0),Hs(t,e.KHR_materials_specular,n,r,s),Us(e.KHR_materials_ior,n),zs(t,e.KHR_materials_transmission,n,r,s),Ks(t,e.KHR_materials_volume,n,r,s),Ds(t,e.KHR_materials_clearcoat,n,r,s),Bs(t,e.KHR_materials_sheen,n,r,s),Vs(t,e.KHR_materials_iridescence,n,r,s),qs(t,e.KHR_materials_anisotropy,n,r,s),$s(e.KHR_materials_emissive_strength,n))}function Cs(t){return Boolean(t.KHR_materials_specular||t.KHR_materials_ior||t.KHR_materials_transmission||t.KHR_materials_volume||t.KHR_materials_clearcoat||t.KHR_materials_sheen||t.KHR_materials_iridescence||t.KHR_materials_anisotropy)}function Hs(t,e,n,r,s={}){e&&(e.specularColorFactor&&(n.uniforms.specularColorFactor=e.specularColorFactor),e.specularFactor!==void 0&&(n.uniforms.specularIntensityFactor=e.specularFactor),e.specularColorTexture&&b(t,e.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"specularColor"}),e.specularTexture&&b(t,e.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"specularIntensity"}))}function Us(t,e){t?.ior!==void 0&&(e.uniforms.ior=t.ior)}function zs(t,e,n,r,s={}){e&&(e.transmissionFactor!==void 0&&(n.uniforms.transmissionFactor=e.transmissionFactor),e.transmissionTexture&&b(t,e.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"transmission"}),((e.transmissionFactor??0)>0||e.transmissionTexture)&&(N.log.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),vs(n)))}function Ks(t,e,n,r,s={}){e&&(e.thicknessFactor!==void 0&&(n.uniforms.thicknessFactor=e.thicknessFactor),e.thicknessTexture&&b(t,e.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:r,attributes:s,textureTransformSlot:"thickness"}),e.attenuationDistance!==void 0&&(n.uniforms.attenuationDistance=e.attenuationDistance),e.attenuationColor&&(n.uniforms.attenuationColor=e.attenuationColor))}function Ds(t,e,n,r,s={}){e&&(e.clearcoatFactor!==void 0&&(n.uniforms.clearcoatFactor=e.clearcoatFactor),e.clearcoatRoughnessFactor!==void 0&&(n.uniforms.clearcoatRoughnessFactor=e.clearcoatRoughnessFactor),e.clearcoatTexture&&b(t,e.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"clearcoat"}),e.clearcoatRoughnessTexture&&b(t,e.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"clearcoatRoughness"}),e.clearcoatNormalTexture&&b(t,e.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:r,attributes:s,textureTransformSlot:"clearcoatNormal"}))}function Bs(t,e,n,r,s={}){e&&(e.sheenColorFactor&&(n.uniforms.sheenColorFactor=e.sheenColorFactor),e.sheenRoughnessFactor!==void 0&&(n.uniforms.sheenRoughnessFactor=e.sheenRoughnessFactor),e.sheenColorTexture&&b(t,e.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"sheenColor"}),e.sheenRoughnessTexture&&b(t,e.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"sheenRoughness"}))}function Vs(t,e,n,r,s={}){e&&(e.iridescenceFactor!==void 0&&(n.uniforms.iridescenceFactor=e.iridescenceFactor),e.iridescenceIor!==void 0&&(n.uniforms.iridescenceIor=e.iridescenceIor),(e.iridescenceThicknessMinimum!==void 0||e.iridescenceThicknessMaximum!==void 0)&&(n.uniforms.iridescenceThicknessRange=[e.iridescenceThicknessMinimum??100,e.iridescenceThicknessMaximum??400]),e.iridescenceTexture&&b(t,e.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"iridescence"}),e.iridescenceThicknessTexture&&b(t,e.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:r,attributes:s,textureTransformSlot:"iridescenceThickness"}))}function qs(t,e,n,r,s={}){e&&(e.anisotropyStrength!==void 0&&(n.uniforms.anisotropyStrength=e.anisotropyStrength),e.anisotropyRotation!==void 0&&(n.uniforms.anisotropyRotation=e.anisotropyRotation),e.anisotropyTexture&&b(t,e.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:r,attributes:s,textureTransformSlot:"anisotropy"}))}function $s(t,e){t?.emissiveStrength!==void 0&&(e.uniforms.emissiveStrength=t.emissiveStrength)}function b(t,e,n,r,s={}){let{featureOptions:o={},gltf:i,attributes:a={},textureTransformSlot:c}=s,{define:l,enabledUniformName:m}=o,p=mt(e);if(p>1){N.log.warn(`Skipping ${String(n)} because ${p} is not supported; only TEXCOORD_0 and TEXCOORD_1 are currently available`)();return}if(p===1&&!a.TEXCOORD_1){N.log.warn(`Skipping ${String(n)} because it requires TEXCOORD_1 but the primitive does not provide TEXCOORD_1`)();return}let f=Ws(e,i),h=f.texture?.source?.image;if(!h){N.log.warn(`Skipping unresolved glTF texture for ${String(n)}`)();return}let d={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...f?.texture?.sampler},x={id:f.uniformName||f.id,sampler:Kt(d)},u;if(h.compressed)u=Gs(t,h,x);else{let{width:g,height:A}=t.getExternalImageSize(h);u=t.createTexture({...x,width:g,height:A,data:h})}if(r.bindings[n]=u,l&&(r.defines[l]=!0),m&&(r.uniforms[m]=!0),c){let g=ke(c);r.uniforms[g.uvSetUniform]=p,r.uniforms[g.uvTransformUniform]=Fe(Ce(e))}r.generatedTextures.push(u)}function Ws(t,e){if(t.texture||t.index===void 0||!e?.textures)return t;let n=e.textures[t.index];return n?"texture"in n&&n.texture?{...n,...t,texture:n.texture}:"source"in n?{...t,texture:n}:t:t}function ht(t,e){return t.createTexture({...e,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function Qn(t){return t.textureFormat}function Ys(t,e,n){let{blockWidth:r=1,blockHeight:s=1}=N.textureFormatDecoder.getInfo(n),o=1;for(let i=1;;i++){let a=Math.max(1,t>>i),c=Math.max(1,e>>i);if(a<r||c<s)break;o++}return o}function Gs(t,e,n){let r;if(Array.isArray(e.data)&&e.data[0]?.data?r=e.data:"mipmaps"in e&&Array.isArray(e.mipmaps)?r=e.mipmaps:r=[],r.length===0||!r[0]?.data)return N.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),ht(t,n);let s=r[0],o=s.width??e.width??0,i=s.height??e.height??0;if(o<=0||i<=0)return N.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),ht(t,n);let a=Qn(s);if(!a)return N.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),ht(t,n);let c=Ys(o,i,a),l=Math.min(r.length,c),m=1;for(let f=1;f<l;f++){let h=r[f];if(!h.data||h.width<=0||h.height<=0){N.log.warn(`createCompressedTexture: mip level ${f} has invalid data/dimensions, truncating`)();break}let d=Qn(h);if(d&&d!==a){N.log.warn(`createCompressedTexture: mip level ${f} format '${d}' differs from base '${a}', truncating`)();break}let x=Math.max(1,o>>f),u=Math.max(1,i>>f);if(h.width!==x||h.height!==u){N.log.warn(`createCompressedTexture: mip level ${f} dimensions ${h.width}x${h.height} don't match expected ${x}x${u}, truncating`)();break}m++}let p=t.createTexture({...n,format:a,usage:N.Texture.TEXTURE|N.Texture.COPY_DST,width:o,height:i,mipLevels:m,data:s.data});for(let f=1;f<m;f++)p.writeData(r[f].data,{width:r[f].width,height:r[f].height,mipLevel:f});return p}var Xs=255;function He(t){let e=t.lights||t.extensions?.KHR_lights_punctual?.lights;if(!e||!Array.isArray(e)||e.length===0)return[];let n=[],r=eo(t.nodes||[]),s=new Map;for(let o of t.nodes||[]){let i=o.light??o.extensions?.KHR_lights_punctual?.light;if(typeof i!="number")continue;let a=e[i];if(!a)continue;let c=js(a.color||[1,1,1]),l=a.intensity??1,m=a.range,p=Zn(o,r,s);switch(a.type){case"directional":n.push(Qs(p,c,l));break;case"point":n.push(Js(p,c,l,m));break;case"spot":n.push(Zs(p,c,l,m,a.spot));break;default:break}}return n}function js(t){return t.map(e=>e*Xs)}function Js(t,e,n,r){let s=er(t),o=[1,0,0];return r!==void 0&&r>0&&(o=[1,0,1/(r*r)]),{type:"point",position:s,color:e,intensity:n,attenuation:o}}function Qs(t,e,n){return{type:"directional",direction:tr(t),color:e,intensity:n}}function Zs(t,e,n,r,s={}){let o=er(t),i=tr(t),a=[1,0,0];return r!==void 0&&r>0&&(a=[1,0,1/(r*r)]),{type:"spot",position:o,direction:i,color:e,intensity:n,attenuation:a,innerConeAngle:s.innerConeAngle??0,outerConeAngle:s.outerConeAngle??Math.PI/4}}function eo(t){let e=new Map;for(let n of t)for(let r of n.children||[])e.set(r.id,n);return e}function Zn(t,e,n){let r=n.get(t.id);if(r)return r;let s=to(t),o=e.get(t.id),i=o?new V(Zn(o,e,n)).multiplyRight(s):s;return n.set(t.id,i),i}function to(t){if(t.matrix)return new V(t.matrix);let e=new V;return t.translation&&e.translate(t.translation),t.rotation&&e.multiplyRight(new V().fromQuaternion(t.rotation)),t.scale&&e.scale(t.scale),e}function er(t){return t.transformAsPoint([0,0,0])}function tr(t){return t.transformDirection([0,0,-1])}var G=C(se(),1),ir=C(dt(),1);function rr(t){switch(t){case y.POINTS:return"point-list";case y.LINES:return"line-list";case y.LINE_STRIP:return"line-strip";case y.TRIANGLES:return"triangle-list";case y.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(t))}}var q=C(X(),1),sr=C(se(),1),me=C(dt(),1),ee=C(se(),1),no=`
|
|
8
|
+
struct VertexInputs {
|
|
9
|
+
@location(0) positions: vec3f,
|
|
10
|
+
#ifdef HAS_NORMALS
|
|
11
|
+
@location(1) normals: vec3f,
|
|
12
|
+
#endif
|
|
13
|
+
#ifdef HAS_TANGENTS
|
|
14
|
+
@location(2) TANGENT: vec4f,
|
|
15
|
+
#endif
|
|
16
|
+
#ifdef HAS_UV
|
|
17
|
+
@location(3) texCoords: vec2f,
|
|
18
|
+
#endif
|
|
19
|
+
#ifdef HAS_UV_1
|
|
20
|
+
@location(4) texCoords1: vec2f,
|
|
21
|
+
#endif
|
|
22
|
+
#ifdef HAS_SKIN
|
|
23
|
+
@location(5) JOINTS_0: vec4u,
|
|
24
|
+
@location(6) WEIGHTS_0: vec4f,
|
|
25
|
+
#endif
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
struct FragmentInputs {
|
|
29
|
+
@builtin(position) position: vec4f,
|
|
30
|
+
@location(0) pbrPosition: vec3f,
|
|
31
|
+
@location(1) pbrUV0: vec2f,
|
|
32
|
+
@location(2) pbrUV1: vec2f,
|
|
33
|
+
@location(3) pbrNormal: vec3f,
|
|
34
|
+
#ifdef HAS_TANGENTS
|
|
35
|
+
@location(4) pbrTangent: vec4f,
|
|
36
|
+
#endif
|
|
37
|
+
};
|
|
22
38
|
|
|
23
39
|
@vertex
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
|
|
41
|
+
var outputs: FragmentInputs;
|
|
42
|
+
var position = vec4f(inputs.positions, 1.0);
|
|
43
|
+
var normal = vec3f(0.0, 0.0, 1.0);
|
|
44
|
+
var tangent = vec4f(1.0, 0.0, 0.0, 1.0);
|
|
45
|
+
var uv0 = vec2f(0.0, 0.0);
|
|
46
|
+
var uv1 = vec2f(0.0, 0.0);
|
|
47
|
+
|
|
48
|
+
#ifdef HAS_NORMALS
|
|
49
|
+
normal = inputs.normals;
|
|
50
|
+
#endif
|
|
51
|
+
#ifdef HAS_UV
|
|
52
|
+
uv0 = inputs.texCoords;
|
|
53
|
+
#endif
|
|
54
|
+
#ifdef HAS_UV_1
|
|
55
|
+
uv1 = inputs.texCoords1;
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef HAS_TANGENTS
|
|
58
|
+
tangent = inputs.TANGENT;
|
|
59
|
+
#endif
|
|
60
|
+
#ifdef HAS_SKIN
|
|
61
|
+
let skinMatrix = getSkinMatrix(inputs.WEIGHTS_0, inputs.JOINTS_0);
|
|
62
|
+
position = skinMatrix * position;
|
|
63
|
+
normal = normalize((skinMatrix * vec4f(normal, 0.0)).xyz);
|
|
64
|
+
#ifdef HAS_TANGENTS
|
|
65
|
+
tangent = vec4f(normalize((skinMatrix * vec4f(tangent.xyz, 0.0)).xyz), tangent.w);
|
|
66
|
+
#endif
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
let worldPosition = pbrProjection.modelMatrix * position;
|
|
70
|
+
|
|
71
|
+
#ifdef HAS_NORMALS
|
|
72
|
+
normal = normalize((pbrProjection.normalMatrix * vec4f(normal, 0.0)).xyz);
|
|
73
|
+
#endif
|
|
74
|
+
#ifdef HAS_TANGENTS
|
|
75
|
+
let worldTangent = normalize((pbrProjection.modelMatrix * vec4f(tangent.xyz, 0.0)).xyz);
|
|
76
|
+
outputs.pbrTangent = vec4f(worldTangent, tangent.w);
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
outputs.position = pbrProjection.modelViewProjectionMatrix * position;
|
|
80
|
+
outputs.pbrPosition = worldPosition.xyz / worldPosition.w;
|
|
81
|
+
outputs.pbrUV0 = uv0;
|
|
82
|
+
outputs.pbrUV1 = uv1;
|
|
83
|
+
outputs.pbrNormal = normal;
|
|
84
|
+
return outputs;
|
|
85
|
+
}
|
|
44
86
|
|
|
45
87
|
@fragment
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
88
|
+
fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {
|
|
89
|
+
fragmentInputs.pbr_vPosition = inputs.pbrPosition;
|
|
90
|
+
fragmentInputs.pbr_vUV0 = inputs.pbrUV0;
|
|
91
|
+
fragmentInputs.pbr_vUV1 = inputs.pbrUV1;
|
|
92
|
+
fragmentInputs.pbr_vNormal = inputs.pbrNormal;
|
|
93
|
+
#ifdef HAS_TANGENTS
|
|
94
|
+
let tangent = normalize(inputs.pbrTangent.xyz);
|
|
95
|
+
let bitangent = normalize(cross(inputs.pbrNormal, tangent)) * inputs.pbrTangent.w;
|
|
96
|
+
fragmentInputs.pbr_vTBN = mat3x3f(tangent, bitangent, inputs.pbrNormal);
|
|
97
|
+
#endif
|
|
98
|
+
return pbr_filterColor(vec4f(1.0));
|
|
99
|
+
}
|
|
100
|
+
`,ro=`#version 300 es
|
|
53
101
|
|
|
54
102
|
// in vec4 POSITION;
|
|
55
103
|
in vec4 positions;
|
|
@@ -68,10 +116,20 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
68
116
|
in vec2 texCoords;
|
|
69
117
|
#endif
|
|
70
118
|
|
|
119
|
+
#ifdef HAS_UV_1
|
|
120
|
+
in vec2 texCoords1;
|
|
121
|
+
#endif
|
|
122
|
+
|
|
123
|
+
#ifdef HAS_SKIN
|
|
124
|
+
in uvec4 JOINTS_0;
|
|
125
|
+
in vec4 WEIGHTS_0;
|
|
126
|
+
#endif
|
|
127
|
+
|
|
71
128
|
void main(void) {
|
|
72
129
|
vec4 _NORMAL = vec4(0.);
|
|
73
130
|
vec4 _TANGENT = vec4(0.);
|
|
74
131
|
vec2 _TEXCOORD_0 = vec2(0.);
|
|
132
|
+
vec2 _TEXCOORD_1 = vec2(0.);
|
|
75
133
|
|
|
76
134
|
#ifdef HAS_NORMALS
|
|
77
135
|
_NORMAL = normals;
|
|
@@ -85,16 +143,29 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
85
143
|
_TEXCOORD_0 = texCoords;
|
|
86
144
|
#endif
|
|
87
145
|
|
|
88
|
-
|
|
89
|
-
|
|
146
|
+
#ifdef HAS_UV_1
|
|
147
|
+
_TEXCOORD_1 = texCoords1;
|
|
148
|
+
#endif
|
|
149
|
+
|
|
150
|
+
vec4 pos = positions;
|
|
151
|
+
|
|
152
|
+
#ifdef HAS_SKIN
|
|
153
|
+
mat4 skinMat = getSkinMatrix(WEIGHTS_0, JOINTS_0);
|
|
154
|
+
pos = skinMat * pos;
|
|
155
|
+
_NORMAL = skinMat * _NORMAL;
|
|
156
|
+
_TANGENT = vec4((skinMat * vec4(_TANGENT.xyz, 0.)).xyz, _TANGENT.w);
|
|
157
|
+
#endif
|
|
158
|
+
|
|
159
|
+
pbr_setPositionNormalTangentUV(pos, _NORMAL, _TANGENT, _TEXCOORD_0, _TEXCOORD_1);
|
|
160
|
+
gl_Position = pbrProjection.modelViewProjectionMatrix * pos;
|
|
90
161
|
}
|
|
91
|
-
`,
|
|
162
|
+
`,so=`#version 300 es
|
|
92
163
|
out vec4 fragmentColor;
|
|
93
164
|
|
|
94
165
|
void main(void) {
|
|
95
166
|
vec3 pos = pbr_vPosition;
|
|
96
167
|
fragmentColor = pbr_filterColor(vec4(1.0));
|
|
97
168
|
}
|
|
98
|
-
`;function we(n,t){let{id:e,geometry:r,parsedPPBRMaterial:s,vertexCount:i,modelOptions:c={}}=t;Ae.log.info(4,"createGLTFModel defines: ",s.defines)();let o=[],a={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},f={id:e,source:$r,vs:Gr,fs:Wr,geometry:r,topology:r.topology,vertexCount:i,modules:[Ee.pbrMaterial],...c,defines:{...s.defines,...c.defines},parameters:{...a,...s.parameters,...c.parameters}},h=new wt.Model(n,f),{camera:l,...p}={...s.uniforms,...c.uniforms,...s.bindings,...c.bindings};return h.shaderInputs.setProps({pbrMaterial:p,pbrProjection:{camera:l}}),new wt.ModelNode({managedResources:o,model:h})}var Xr={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1};function Oe(n,t,e={}){let r={...Xr,...e};return t.scenes.map(i=>Hr(n,i,t.nodes,r))}function Hr(n,t,e,r){let i=(t.nodes||[]).map(o=>Le(n,o,e,r));return new W.GroupNode({id:t.name||t.id,children:i})}function Le(n,t,e,r){if(!t._node){let c=(t.children||[]).map(a=>Le(n,a,e,r));t.mesh&&c.push(jr(n,t.mesh,r));let o=new W.GroupNode({id:t.name||t.id,children:c});if(t.matrix)o.setMatrix(t.matrix);else{if(o.matrix.identity(),t.translation&&o.matrix.translate(t.translation),t.rotation){let a=new B().fromQuaternion(t.rotation);o.matrix.multiplyRight(a)}t.scale&&o.matrix.scale(t.scale)}t._node=o}let s=e.find(i=>i.id===t.id);return s._node=t._node,t._node}function jr(n,t,e){if(!t._mesh){let s=(t.primitives||[]).map((c,o)=>Qr(n,c,o,t,e)),i=new W.GroupNode({id:t.name||t.id,children:s});t._mesh=i}return t._mesh}function Qr(n,t,e,r,s){let i=t.name||`${r.name||r.id}-primitive-${e}`,c=ge(t.mode||4),o=t.indices?t.indices.count:Zr(t.attributes),a=Se(i,t,c),f=xt(n,t.material,a.attributes,s),h=we(n,{id:i,geometry:Se(i,t,c),parsedPPBRMaterial:f,modelOptions:s.modelOptions,vertexCount:o});return h.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],h}function Zr(n){throw new Error("getVertexCount not implemented")}function Se(n,t,e){let r={};for(let[s,i]of Object.entries(t.attributes)){let{components:c,size:o,value:a}=i;r[s]={size:o??c,value:a}}return new W.Geometry({id:n,topology:e,indices:t.indices.value,attributes:r})}var Ne=z(D(),1);var Xt=z(D(),1);var Wt=new nt;function Re(n,{input:t,interpolation:e,output:r},s,i){let c=t[t.length-1],o=n%c,a=t.findIndex(p=>p>=o),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:Xt.log.warn(`Bad animation path ${i}`)()}let h=t[f],l=t[a];switch(e){case"STEP":ts(s,i,r[f]);break;case"LINEAR":if(l>h){let p=(o-h)/(l-h);Kr(s,i,r[f],r[a],p)}break;case"CUBICSPLINE":if(l>h){let p=(o-h)/(l-h),m=l-h,x=r[3*f+1],M=r[3*f+2],d=r[3*a+0],E=r[3*a+1];Jr(s,i,{p0:x,outTangent0:M,inTangent1:d,p1:E,tDiff:m,ratio:p})}break;default:Xt.log.warn(`Interpolation ${e} not supported`)();break}}function Kr(n,t,e,r,s){if(!n[t])throw new Error;if(t==="rotation"){Wt.slerp({start:e,target:r,ratio:s});for(let i=0;i<Wt.length;i++)n[t][i]=Wt[i]}else for(let i=0;i<e.length;i++)n[t][i]=s*r[i]+(1-s)*e[i]}function Jr(n,t,{p0:e,outTangent0:r,inTangent1:s,p1:i,tDiff:c,ratio:o}){if(!n[t])throw new Error;for(let a=0;a<n[t].length;a++){let f=r[a]*c,h=s[a]*c;n[t][a]=(2*Math.pow(o,3)-3*Math.pow(o,2)+1)*e[a]+(Math.pow(o,3)-2*Math.pow(o,2)+o)*f+(-2*Math.pow(o,3)+3*Math.pow(o,2))*i[a]+(Math.pow(o,3)-Math.pow(o,2))*h}}function ts(n,t,e){if(!n[t])throw new Error;for(let r=0;r<e.length;r++)n[t][r]=e[r]}var Ht=class{animation;startTime=0;playing=!0;speed=1;constructor(t){this.animation=t.animation,this.animation.name||="unnamed",Object.assign(this,t)}setTime(t){if(!this.playing)return;let r=(t/1e3-this.startTime)*this.speed;this.animation.channels.forEach(({sampler:s,target:i,path:c})=>{Re(r,s,i,c),es(i,i._node)})}},X=class{animations;constructor(t){this.animations=t.animations.map((e,r)=>{let s=e.name||`Animation-${r}`;return new Ht({animation:{name:s,channels:e.channels}})})}animate(t){Ne.log.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(t)}setTime(t){this.animations.forEach(e=>e.setTime(t))}getAnimations(){return this.animations}},ns=new B;function es(n,t){if(t.matrix.identity(),n.translation&&t.matrix.translate(n.translation),n.rotation){let e=ns.fromQuaternion(n.rotation);t.matrix.multiplyRight(e)}n.scale&&t.matrix.scale(n.scale)}var rs={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ss={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Pe(n){let t=ss[n.componentType],e=rs[n.type],r=e*n.count,{buffer:s,byteOffset:i=0}=n.bufferView?.data??{};return{typedArray:new t(s,i+(n.byteOffset||0),r),components:e}}function Ie(n){return(n.animations||[]).map((e,r)=>{let s=e.name||`Animation-${r}`,i=e.samplers.map(({input:o,interpolation:a="LINEAR",output:f})=>({input:_e(n.accessors[o]),interpolation:a,output:_e(n.accessors[f])})),c=e.channels.map(({sampler:o,target:a})=>({sampler:i[o],target:n.nodes[a.node??0],path:a.path}));return{name:s,channels:c}})}function _e(n){if(!n._animation){let{typedArray:t,components:e}=Pe(n);if(e===1)n._animation=Array.from(t);else{let r=[];for(let s=0;s<t.length;s+=e)r.push(Array.from(t.slice(s,s+e)));n._animation=r}}return n._animation}function St(n){if(ArrayBuffer.isView(n)||n instanceof ArrayBuffer||n instanceof ImageBitmap)return n;if(Array.isArray(n))return n.map(St);if(n&&typeof n=="object"){let t={};for(let e in n)t[e]=St(n[e]);return t}return n}function ue(n,t,e){t=St(t);let r=Oe(n,t,e),s=Ie(t),i=new X({animations:s});return{scenes:r,animator:i}}return Be(et);})();
|
|
169
|
+
`;function xt(t,e){let n=e.materialFactory||new ee.MaterialFactory(t,{modules:[me.pbrMaterial]}),r={...e.parsedPPBRMaterial.uniforms};delete r.camera;let s=Object.fromEntries(Object.entries({...r,...e.parsedPPBRMaterial.bindings}).filter(([i,a])=>n.ownsBinding(i)&&oo(a))),o=n.createMaterial({id:e.id,bindings:s});return o.setProps({pbrMaterial:r}),o}function or(t,e){let{id:n,geometry:r,parsedPPBRMaterial:s,vertexCount:o,modelOptions:i={}}=e;q.log.info(4,"createGLTFModel defines: ",s.defines)();let a=[],c={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},l={id:n,source:no,vs:ro,fs:so,geometry:r,topology:r.topology,vertexCount:o,modules:[me.pbrMaterial,me.skin],...i,defines:{...s.defines,...i.defines},parameters:{...c,...s.parameters,...i.parameters}},m=e.material||xt(t,{id:n?`${n}-material`:void 0,parsedPPBRMaterial:s});l.material=m;let p=new ee.Model(t,l),f={...s.uniforms,...i.uniforms,...s.bindings,...i.bindings},h=io(p.shaderInputs.getModules(),m,f);return p.shaderInputs.setProps(h),new ee.ModelNode({managedResources:a,model:p})}function oo(t){return t instanceof q.Buffer||t instanceof sr.DynamicTexture||t instanceof q.Sampler||t instanceof q.Texture||t instanceof q.TextureView}function io(t,e,n){let r=new Map;for(let o of t){for(let i of Object.keys(o.uniformTypes||{}))r.set(i,o.name);for(let i of o.bindingLayout||[])r.set(i.name,o.name)}let s={};for(let[o,i]of Object.entries(n)){if(i===void 0)continue;let a=r.get(o);!a||e.ownsModule(a)||(s[a]||={},s[a][o]=i)}return s}var ao={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1};function ar(t,e,n={}){let r={...ao,...n},s=new G.MaterialFactory(t,{modules:[ir.pbrMaterial]}),o=(e.materials||[]).map((p,f)=>xt(t,{id:ho(p,f),parsedPPBRMaterial:pe(t,p,{},{...r,gltf:e,validateAttributes:!1}),materialFactory:s})),i=new Map;(e.materials||[]).forEach((p,f)=>{i.set(p.id,o[f])});let a=new Map;e.meshes.forEach((p,f)=>{let h=lo(t,p,e,i,r);a.set(p.id,h)});let c=new Map,l=new Map;return e.nodes.forEach((p,f)=>{let h=co(t,p,r);c.set(f,h),l.set(p.id,h)}),e.nodes.forEach((p,f)=>{if(c.get(f).add((p.children??[]).map(({id:h})=>{let d=l.get(h);if(!d)throw new Error(`Cannot find child ${h} of node ${f}`);return d})),p.mesh){let h=a.get(p.mesh.id);if(!h)throw new Error(`Cannot find mesh child ${p.mesh.id} of node ${f}`);c.get(f).add(h)}}),{scenes:e.scenes.map(p=>{let f=(p.nodes||[]).map(({id:h})=>{let d=l.get(h);if(!d)throw new Error(`Cannot find child ${h} of scene ${p.name||p.id}`);return d});return new G.GroupNode({id:p.name||p.id,children:f})}),materials:o,gltfMeshIdToNodeMap:a,gltfNodeIdToNodeMap:l,gltfNodeIndexToNodeMap:c}}function co(t,e,n){return new G.GroupNode({id:e.name||e.id,children:[],matrix:e.matrix,position:e.translation,rotation:e.rotation,scale:e.scale})}function lo(t,e,n,r,s){let i=(e.primitives||[]).map((c,l)=>fo({device:t,gltfPrimitive:c,primitiveIndex:l,gltfMesh:e,gltf:n,gltfMaterialIdToMaterialMap:r,options:s}));return new G.GroupNode({id:e.name||e.id,children:i})}function fo({device:t,gltfPrimitive:e,primitiveIndex:n,gltfMesh:r,gltf:s,gltfMaterialIdToMaterialMap:o,options:i}){let a=e.name||`${r.name||r.id}-primitive-${n}`,c=rr(e.mode??4),l=e.indices?e.indices.count:po(e.attributes),m=mo(a,e,c),p=pe(t,e.material,m.attributes,{...i,gltf:s}),f=or(t,{id:a,geometry:m,material:e.material&&o.get(e.material.id)||null,parsedPPBRMaterial:p,modelOptions:i.modelOptions,vertexCount:l});return f.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],f}function po(t){let e=1/0;for(let n of Object.values(t))if(n){let{value:r,size:s,components:o}=n,i=s??o;r?.length!==void 0&&i>=1&&(e=Math.min(e,r.length/i))}if(!Number.isFinite(e))throw new Error("Could not determine vertex count from attributes");return e}function mo(t,e,n){let r={};for(let[s,o]of Object.entries(e.attributes)){let{components:i,size:a,value:c,normalized:l}=o;r[s]={size:a??i,value:c,normalized:l}}return new G.Geometry({id:t,topology:n,indices:e.indices?.value,attributes:r})}function ho(t,e){return t.name||t.id||`material-${e}`}var lr=C(X(),1);var ut=C(X(),1);function xo(t,e,n){switch(e){case"translation":return t.setPosition(n).updateMatrix();case"rotation":return t.setRotation(n).updateMatrix();case"scale":return t.setScale(n).updateMatrix();default:return ut.log.warn(`Bad animation path ${e}`)(),null}}function cr(t,{input:e,interpolation:n,output:r},s,o){let i=gt(t,{input:e,interpolation:n,output:r},o);i&&xo(s,o,i)}function gt(t,{input:e,interpolation:n,output:r},s){let o=e[e.length-1];if(!Number.isFinite(o)||o<=0)return r[0]||null;let i=t%o,a=e.findIndex(p=>p>=i);if(a<0)return r[r.length-1]||null;let c=Math.max(0,a-1),l=e[c],m=e[a];switch(n){case"STEP":return r[c];case"LINEAR":if(m>l){let p=(i-l)/(m-l);return uo(s,r[c],r[a],p)}return r[c]||null;case"CUBICSPLINE":if(m>l){let p=(i-l)/(m-l),f=m-l,h=r[3*c+1],d=r[3*c+2],x=r[3*a+0],u=r[3*a+1];return go({p0:h,outTangent0:d,inTangent1:x,p1:u,tDiff:f,ratio:p})}return r[3*c+1]||null;default:return ut.log.warn(`Interpolation ${n} not supported`)(),null}}function uo(t,e,n,r){if(t==="rotation")return new fe().slerp({start:e,target:n,ratio:r});let s=[];for(let o=0;o<e.length;o++)s[o]=r*n[o]+(1-r)*e[o];return s}function go({p0:t,outTangent0:e,inTangent1:n,p1:r,tDiff:s,ratio:o}){let i=[];for(let a=0;a<t.length;a++){let c=e[a]*s,l=n[a]*s;i[a]=(2*Math.pow(o,3)-3*Math.pow(o,2)+1)*t[a]+(Math.pow(o,3)-2*Math.pow(o,2)+o)*c+(-2*Math.pow(o,3)+3*Math.pow(o,2))*r[a]+(Math.pow(o,3)-Math.pow(o,2))*l}return i}var Mt=class{animation;gltfNodeIdToNodeMap;materials;startTime=0;playing=!0;speed=1;materialTextureTransformState=new Map;constructor(e){if(this.animation=e.animation,this.gltfNodeIdToNodeMap=e.gltfNodeIdToNodeMap,this.materials=e.materials||[],this.animation.name||="unnamed",Object.assign(this,e),this.animation.channels.some(n=>n.type!=="node")&&!this.materials.length)throw new Error(`Animation ${this.animation.name} targets materials, but GLTFAnimator was created without a materials array`)}setTime(e){if(!this.playing)return;let r=(e/1e3-this.startTime)*this.speed;this.animation.channels.forEach(s=>{if(s.type==="node"){let{sampler:a,targetNodeId:c,path:l}=s,m=this.gltfNodeIdToNodeMap.get(c);if(!m)throw new Error(`Cannot find animation target node ${c}`);cr(r,a,m,l);return}let o=this.materials[s.targetMaterialIndex];if(!o)throw new Error(`Cannot find animation target material ${s.targetMaterialIndex} for ${s.pointer}`);let i=gt(r,s.sampler);i&&(s.type==="material"?Mo(o,s,i):Ro(o,s,i,this.materialTextureTransformState))})}},te=class{animations;constructor(e){this.animations=e.animations.map((n,r)=>{let s=n.name||`Animation-${r}`;return new Mt({gltfNodeIdToNodeMap:e.gltfNodeIdToNodeMap,materials:e.materials,animation:{name:s,channels:n.channels}})})}animate(e){lr.log.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(e)}setTime(e){this.animations.forEach(n=>n.setTime(e))}getAnimations(){return this.animations}};function Mo(t,e,n){let r=e.component!==void 0?{[e.property]:_o(To(t,e.property),e.component,n[0])}:{[e.property]:n.length===1?n[0]:n};t.setProps({pbrMaterial:r})}function To(t,e){let r=t.shaderInputs.getUniformValues().pbrMaterial?.[e];return Array.isArray(r)?[...r]:[]}function _o(t,e,n){let r=[...t];return r[e]=n,r}function Ro(t,e,n,r){let s=ke(e.textureSlot),o=yo(r,t,e);switch(e.path){case"offset":e.component!==void 0?o.offset[e.component]=n[0]:o.offset=[n[0],n[1]];break;case"rotation":o.rotation=n[0];break;case"scale":e.component!==void 0?o.scale[e.component]=n[0]:o.scale=[n[0],n[1]];break}t.setProps({pbrMaterial:{[s.uvTransformUniform]:jn(e.baseTransform,o)}})}function yo(t,e,n){let r=t.get(e)||{},s=r[n.textureSlot];return s||(s={offset:[...n.baseTransform.offset],rotation:n.baseTransform.rotation,scale:[...n.baseTransform.scale]},r[n.textureSlot]=s,t.set(e,r)),s}var ne=C(X(),1);var Ao={supportLevel:"none",comment:"Not currently listed in the luma.gl glTF extension support registry."},fr={KHR_draco_mesh_compression:{supportLevel:"built-in",comment:"Decoded by loaders.gl before luma.gl builds the scenegraph."},EXT_meshopt_compression:{supportLevel:"built-in",comment:"Meshopt-compressed primitives are decoded during load."},KHR_mesh_quantization:{supportLevel:"built-in",comment:"Quantized accessors are unpacked before geometry creation."},KHR_lights_punctual:{supportLevel:"built-in",comment:"Parsed into luma.gl Light objects."},KHR_materials_unlit:{supportLevel:"built-in",comment:"Unlit materials bypass the default lighting path."},KHR_materials_emissive_strength:{supportLevel:"built-in",comment:"Applied by the stock PBR shader."},KHR_texture_basisu:{supportLevel:"built-in",comment:"BasisU / KTX2 textures pass through when the device supports them."},KHR_texture_transform:{supportLevel:"built-in",comment:"UV transforms are applied during load."},EXT_texture_webp:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},EXT_texture_avif:{supportLevel:"loader-only",comment:"Texture source is resolved during load; final support depends on browser and device decode support."},KHR_materials_specular:{supportLevel:"built-in",comment:"The stock shader now applies specular factors and textures to the dielectric F0 term."},KHR_materials_ior:{supportLevel:"built-in",comment:"The stock shader now drives dielectric reflectance from the glTF IOR value."},KHR_materials_transmission:{supportLevel:"built-in",comment:"The stock shader now applies transmission to the base layer and exposes transparency through alpha, without a scene-color refraction buffer."},KHR_materials_volume:{supportLevel:"built-in",comment:"Thickness and attenuation now tint transmitted light in the stock shader."},KHR_materials_clearcoat:{supportLevel:"built-in",comment:"The stock shader now adds a secondary clearcoat specular lobe."},KHR_materials_sheen:{supportLevel:"built-in",comment:"The stock shader now adds a sheen lobe for cloth-like materials."},KHR_materials_iridescence:{supportLevel:"built-in",comment:"The stock shader now tints specular response with a view-dependent thin-film iridescence approximation."},KHR_materials_anisotropy:{supportLevel:"built-in",comment:"The stock shader now shapes highlights and IBL response with an anisotropy-direction approximation."},KHR_materials_pbrSpecularGlossiness:{supportLevel:"loader-only",comment:"Extension data can be loaded, but it is not translated into the default metallic-roughness material path."},KHR_materials_variants:{supportLevel:"loader-only",comment:"Variant metadata can be loaded, but applications must choose and apply variants."},EXT_mesh_gpu_instancing:{supportLevel:"none",comment:"GPU instancing data is not yet converted into luma.gl instanced draw setup."},KHR_node_visibility:{supportLevel:"none",comment:"Node-visibility animations and toggles are not mapped onto runtime scenegraph state."},KHR_animation_pointer:{supportLevel:"parsed-and-wired",comment:"Selected node TRS, material factor, and KHR_texture_transform offset/rotation/scale pointers are wired to runtime updates; unsupported targets are skipped."},KHR_materials_diffuse_transmission:{supportLevel:"none",comment:"Diffuse-transmission shading is not implemented in the stock PBR shader."},KHR_materials_dispersion:{supportLevel:"none",comment:"Chromatic dispersion is not implemented in the stock PBR shader."},KHR_materials_volume_scatter:{supportLevel:"none",comment:"Volume scattering is not implemented in the stock PBR shader."},KHR_xmp:{supportLevel:"none",comment:"Metadata payloads remain in the loaded glTF, but luma.gl does not interpret them."},KHR_xmp_json_ld:{supportLevel:"none",comment:"Metadata is preserved in the glTF, but luma.gl does not interpret it."},EXT_lights_image_based:{supportLevel:"none",comment:"Use loadPBREnvironment() or custom environment setup instead."},EXT_texture_video:{supportLevel:"none",comment:"Video textures are not created automatically by the stock pipeline."},MSFT_lod:{supportLevel:"none",comment:"Level-of-detail switching is not implemented in the stock scenegraph loader."}};function ze(t){let n=Array.from(Eo(t)).sort().map(r=>{let s=fr[r]||Ao;return[r,{extensionName:r,supported:s.supportLevel==="built-in"||s.supportLevel==="parsed-and-wired",supportLevel:s.supportLevel,comment:s.comment}]});return new Map(n)}function Tt(t){return fr[t]||null}function Eo(t){let e=t,n=new Set;return Ue(n,t.extensionsUsed),Ue(n,t.extensionsRequired),Ue(n,e.extensionsRemoved),Ue(n,Object.keys(t.extensions||{})),(e.lights?.length||(t.nodes||[]).some(r=>"light"in r))&&n.add("KHR_lights_punctual"),(t.materials||[]).some(r=>{let s=r;return s.unlit||s.extensions?.KHR_materials_unlit})&&n.add("KHR_materials_unlit"),n}function Ue(t,e=[]){for(let n of e)t.add(n)}var So={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function _t(t){let e=wo[t.componentType],n=So[t.type],r=n*t.count,{buffer:s,byteOffset:o=0}=t.bufferView?.data??{};return{typedArray:new e(s,o+(t.byteOffset||0),r),components:n}}function pr(t){let e=t.animations||[],n=new Map,r=new Map;return e.flatMap((s,o)=>{let i=s.name||`Animation-${o}`,a=new Map,c=s.channels.flatMap(({sampler:l,target:m})=>{let p=a.get(l);if(!p){let h=s.samplers[l];if(!h)throw new Error(`Cannot find animation sampler ${l}`);let{input:d,interpolation:x="LINEAR",output:u}=h;p={input:Co(t.accessors[d],n),interpolation:x,output:Ho(t.accessors[u],r)},a.set(l,p)}let f=No(t,m,p);return f?[f]:[]});return c.length?[{name:i,channels:c}]:[]})}function No(t,e,n){if(e.path==="pointer")return Oo(t,e,n);let r=mr(e.path);if(!r)return null;let s=t.nodes[e.node??0];if(!s)throw new Error(`Cannot find animation target ${e.node}`);return{type:"node",sampler:n,targetNodeId:s.id,path:r}}function Oo(t,e,n){let r=e.extensions?.KHR_animation_pointer?.pointer;if(typeof r!="string"||!r.startsWith("/"))return ne.log.warn("KHR_animation_pointer channel is missing a valid JSON pointer and will be skipped")(),null;let s=Fo(r);switch(s[0]){case"nodes":return Lo(t,s,n,r);case"materials":return bo(t,s,n,r);default:return he(r,`top-level target "${s[0]}" has no runtime animation mapping`),null}}function Lo(t,e,n,r){if(e.length!==3)return he(r,"node pointers must use /nodes/{index}/{translation|rotation|scale|weights}"),null;let s=Number(e[1]),o=t.nodes[s];if(!Number.isInteger(s)||!o)return ne.log.warn(`KHR_animation_pointer target ${r} references a missing node and will be skipped`)(),null;let i=mr(e[2]);return i?i==="weights"?(ne.log.warn(`KHR_animation_pointer target ${r} will be skipped because morph weights are not implemented in GLTFAnimator`)(),null):{type:"node",sampler:n,targetNodeId:o.id,path:i}:(he(r,`node property "${e[2]}" has no runtime animation mapping`),null)}function bo(t,e,n,r){if(e.length<3)return he(r,"material pointers must include a material index and target property path"),null;let s=Number(e[1]),o=t.materials[s];if(!Number.isInteger(s)||!o)return ne.log.warn(`KHR_animation_pointer target ${r} references a missing material and will be skipped`)(),null;let i=Io(o,e.slice(2));return"reason"in i?(he(r,i.reason),null):{sampler:n,pointer:r,targetMaterialIndex:s,...i}}function mr(t){switch(t){case"translation":case"rotation":case"scale":case"weights":return t;default:return null}}function Io(t,e){let n=Po(t,e);if(!("reason"in n)||n.reason!=="not-a-texture-transform-target")return n;switch(e.join("/")){case"pbrMetallicRoughness/baseColorFactor":return t.pbrMetallicRoughness?{type:"material",property:"baseColorFactor"}:{reason:w(e)};case"pbrMetallicRoughness/metallicFactor":return t.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:0}:{reason:w(e)};case"pbrMetallicRoughness/roughnessFactor":return t.pbrMetallicRoughness?{type:"material",property:"metallicRoughnessValues",component:1}:{reason:w(e)};case"normalTexture/scale":return t.normalTexture?{type:"material",property:"normalScale"}:{reason:w(e)};case"occlusionTexture/strength":return t.occlusionTexture?{type:"material",property:"occlusionStrength"}:{reason:w(e)};case"emissiveFactor":return{type:"material",property:"emissiveFactor"};case"alphaCutoff":return{type:"material",property:"alphaCutoff"};case"extensions/KHR_materials_specular/specularFactor":return t.extensions?.KHR_materials_specular?{type:"material",property:"specularIntensityFactor"}:{reason:w(e)};case"extensions/KHR_materials_specular/specularColorFactor":return t.extensions?.KHR_materials_specular?{type:"material",property:"specularColorFactor"}:{reason:w(e)};case"extensions/KHR_materials_ior/ior":return t.extensions?.KHR_materials_ior?{type:"material",property:"ior"}:{reason:w(e)};case"extensions/KHR_materials_transmission/transmissionFactor":return t.extensions?.KHR_materials_transmission?{type:"material",property:"transmissionFactor"}:{reason:w(e)};case"extensions/KHR_materials_volume/thicknessFactor":return t.extensions?.KHR_materials_volume?{type:"material",property:"thicknessFactor"}:{reason:w(e)};case"extensions/KHR_materials_volume/attenuationDistance":return t.extensions?.KHR_materials_volume?{type:"material",property:"attenuationDistance"}:{reason:w(e)};case"extensions/KHR_materials_volume/attenuationColor":return t.extensions?.KHR_materials_volume?{type:"material",property:"attenuationColor"}:{reason:w(e)};case"extensions/KHR_materials_clearcoat/clearcoatFactor":return t.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatFactor"}:{reason:w(e)};case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":return t.extensions?.KHR_materials_clearcoat?{type:"material",property:"clearcoatRoughnessFactor"}:{reason:w(e)};case"extensions/KHR_materials_sheen/sheenColorFactor":return t.extensions?.KHR_materials_sheen?{type:"material",property:"sheenColorFactor"}:{reason:w(e)};case"extensions/KHR_materials_sheen/sheenRoughnessFactor":return t.extensions?.KHR_materials_sheen?{type:"material",property:"sheenRoughnessFactor"}:{reason:w(e)};case"extensions/KHR_materials_iridescence/iridescenceFactor":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceFactor"}:{reason:w(e)};case"extensions/KHR_materials_iridescence/iridescenceIor":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceIor"}:{reason:w(e)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:0}:{reason:w(e)};case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":return t.extensions?.KHR_materials_iridescence?{type:"material",property:"iridescenceThicknessRange",component:1}:{reason:w(e)};case"extensions/KHR_materials_anisotropy/anisotropyStrength":return t.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyStrength"}:{reason:w(e)};case"extensions/KHR_materials_anisotropy/anisotropyRotation":return t.extensions?.KHR_materials_anisotropy?{type:"material",property:"anisotropyRotation"}:{reason:w(e)};case"extensions/KHR_materials_emissive_strength/emissiveStrength":return t.extensions?.KHR_materials_emissive_strength?{type:"material",property:"emissiveStrength"}:{reason:w(e)};default:return{reason:w(e)}}}function Po(t,e){let n=e.lastIndexOf("extensions");if(n<0||e[n+1]!=="KHR_texture_transform"||n<1)return{reason:"not-a-texture-transform-target"};let r=Xn(e.slice(0,n));if(!r)return{reason:ko(e.slice(0,n))};let s=vo(t,r.pathSegments);if(!s)return{reason:`texture-transform target "${e.slice(0,n).join("/")}" does not exist on the referenced material`};let o=e[n+2];if(o==="texCoord")return{reason:"animated KHR_texture_transform.texCoord is unsupported because texCoord selection is structural, not a runtime float/vector update"};if(o!=="offset"&&o!=="rotation"&&o!=="scale")return{reason:`KHR_texture_transform property "${o}" is not animatable; supported properties are offset, rotation, and scale`};let i=e[n+3];if(e.length>n+4)return{reason:`KHR_texture_transform.${o} does not support nested property paths`};let a;if(i!==void 0){if(a=Number(i),o==="rotation")return{reason:"KHR_texture_transform.rotation does not support component indices"};if(!Number.isInteger(a)||a<0||a>1)return{reason:`KHR_texture_transform.${o} component index "${i}" is invalid; only 0 and 1 are supported`}}return{type:"textureTransform",textureSlot:r.slot,path:o,component:a,baseTransform:Ce(s)}}function vo(t,e){let n=t;for(let r of e)if(n=n?.[r],!n)return null;return n}function Fo(t){return t.slice(1).split("/").map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~"))}function w(t){let e=hr(t);if(e){let n=Tt(e);if(n?.supportLevel==="none")return`${e} is referenced by this pointer, but ${n.comment.charAt(0).toLowerCase()}${n.comment.slice(1)}`}return`no runtime target exists for material property "${t.join("/")}"`}function ko(t){let e=hr(t);if(e){let n=Tt(e);if(n?.supportLevel==="none")return`${e} is referenced by this pointer, but ${n.comment.charAt(0).toLowerCase()}${n.comment.slice(1)}`}return`texture-transform target "${t.join("/")}" has no runtime texture-slot mapping`}function hr(t){let e=t.indexOf("extensions"),n=t[e+1];return e>=0&&n?n:null}function he(t,e){ne.log.warn(`KHR_animation_pointer target ${t} will be skipped because ${e}`)()}function Co(t,e){if(e.has(t))return e.get(t);let{typedArray:n,components:r}=_t(t);dr(r===1,"accessorToJsArray1D must have exactly 1 component");let s=Array.from(n);return e.set(t,s),s}function Ho(t,e){if(e.has(t))return e.get(t);let{typedArray:n,components:r}=_t(t);dr(r>=1,"accessorToJsArray2D must have at least 1 component");let s=[];for(let o=0;o<n.length;o+=r)s.push(Array.from(n.slice(o,o+r)));return e.set(t,s),s}function dr(t,e){if(!t)throw new Error(e)}function xr(t,e,n){let{scenes:r,materials:s,gltfMeshIdToNodeMap:o,gltfNodeIdToNodeMap:i,gltfNodeIndexToNodeMap:a}=ar(t,e,n),c=pr(e),l=new te({animations:c,gltfNodeIdToNodeMap:i,materials:s}),m=He(e),p=ze(e),f=r.map(d=>ur(d.getBounds())),h=Uo(f);return{scenes:r,materials:s,animator:l,lights:m,extensionSupport:p,sceneBounds:f,modelBounds:h,gltfMeshIdToNodeMap:o,gltfNodeIdToNodeMap:i,gltfNodeIndexToNodeMap:a,gltf:e}}function ur(t){if(!t)return{bounds:null,center:[0,0,0],size:[0,0,0],radius:.5,recommendedOrbitDistance:1};let e=[[t[0][0],t[0][1],t[0][2]],[t[1][0],t[1][1],t[1][2]]],n=[e[1][0]-e[0][0],e[1][1]-e[0][1],e[1][2]-e[0][2]],r=[e[0][0]+n[0]*.5,e[0][1]+n[1]*.5,e[0][2]+n[2]*.5],s=Math.max(n[0],n[1],n[2])*.5,o=Math.max(.5*Math.hypot(n[0],n[1],n[2]),.001);return{bounds:e,center:r,size:n,radius:o,recommendedOrbitDistance:Math.max(Math.max(s,.001)/Math.tan(Math.PI/6)*1.15,o*1.1)}}function Uo(t){let e=null;for(let n of t)if(n.bounds){if(!e){e=[[...n.bounds[0]],[...n.bounds[1]]];continue}for(let r=0;r<3;r++)e[0][r]=Math.min(e[0][r],n.bounds[0][r]),e[1][r]=Math.max(e[1][r],n.bounds[1][r])}return ur(e)}return Ar(de);})();
|
|
99
170
|
return __exports__;
|
|
100
171
|
});
|
|
@@ -1,16 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
/** Parsed glTF animation definition. */
|
|
2
2
|
export type GLTFAnimation = {
|
|
3
|
+
/** Application-visible animation name. */
|
|
3
4
|
name: string;
|
|
5
|
+
/** Channels that drive runtime node or material properties. */
|
|
4
6
|
channels: GLTFAnimationChannel[];
|
|
5
7
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
/** Supported glTF animation target paths. */
|
|
9
|
+
export type GLTFAnimationPath = 'translation' | 'rotation' | 'scale' | 'weights';
|
|
10
|
+
/** Parsed glTF animation channel that targets a scenegraph node. */
|
|
11
|
+
export type GLTFNodeAnimationChannel = {
|
|
12
|
+
/** Channel target kind. */
|
|
13
|
+
type: 'node';
|
|
14
|
+
/** Node property written by this channel. */
|
|
15
|
+
path: GLTFAnimationPath;
|
|
16
|
+
/** Time/value sampler used to evaluate the channel. */
|
|
8
17
|
sampler: GLTFAnimationSampler;
|
|
9
|
-
|
|
18
|
+
/** Target node identifier in the generated scenegraph. */
|
|
19
|
+
targetNodeId: string;
|
|
10
20
|
};
|
|
21
|
+
/** Material uniform property targeted by a parsed animation pointer. */
|
|
22
|
+
export type GLTFMaterialAnimationProperty = 'alphaCutoff' | 'anisotropyRotation' | 'anisotropyStrength' | 'attenuationColor' | 'attenuationDistance' | 'baseColorFactor' | 'clearcoatFactor' | 'clearcoatRoughnessFactor' | 'emissiveFactor' | 'emissiveStrength' | 'ior' | 'iridescenceFactor' | 'iridescenceIor' | 'iridescenceThicknessRange' | 'metallicRoughnessValues' | 'normalScale' | 'occlusionStrength' | 'sheenColorFactor' | 'sheenRoughnessFactor' | 'specularColorFactor' | 'specularIntensityFactor' | 'thicknessFactor' | 'transmissionFactor';
|
|
23
|
+
/** Parsed glTF animation channel that targets a material uniform. */
|
|
24
|
+
export type GLTFMaterialAnimationChannel = {
|
|
25
|
+
/** Channel target kind. */
|
|
26
|
+
type: 'material';
|
|
27
|
+
/** Time/value sampler used to evaluate the channel. */
|
|
28
|
+
sampler: GLTFAnimationSampler;
|
|
29
|
+
/** Original JSON pointer from `KHR_animation_pointer`. */
|
|
30
|
+
pointer: string;
|
|
31
|
+
/** Target material index in the source glTF. */
|
|
32
|
+
targetMaterialIndex: number;
|
|
33
|
+
/** Material uniform property updated by this channel. */
|
|
34
|
+
property: GLTFMaterialAnimationProperty;
|
|
35
|
+
/** Component index inside a packed material uniform, when only one element is animated. */
|
|
36
|
+
component?: number;
|
|
37
|
+
};
|
|
38
|
+
/** Parsed glTF animation channel that targets a runtime texture-transform delta. */
|
|
39
|
+
export type GLTFTextureTransformAnimationChannel = {
|
|
40
|
+
/** Channel target kind. */
|
|
41
|
+
type: 'textureTransform';
|
|
42
|
+
/** Time/value sampler used to evaluate the channel. */
|
|
43
|
+
sampler: GLTFAnimationSampler;
|
|
44
|
+
/** Original JSON pointer from `KHR_animation_pointer`. */
|
|
45
|
+
pointer: string;
|
|
46
|
+
/** Target material index in the source glTF. */
|
|
47
|
+
targetMaterialIndex: number;
|
|
48
|
+
/** Texture slot updated by this channel. */
|
|
49
|
+
textureSlot: import('../../pbr/texture-transform').PBRTextureTransformSlot;
|
|
50
|
+
/** Texture transform component updated by this channel. */
|
|
51
|
+
path: import('../../pbr/texture-transform').PBRTextureTransformPath;
|
|
52
|
+
/** Component index when animating a single offset or scale element. */
|
|
53
|
+
component?: number;
|
|
54
|
+
/** Static source transform baked by loaders.gl before runtime animation. */
|
|
55
|
+
baseTransform: import('../../pbr/texture-transform').PBRTextureTransform;
|
|
56
|
+
};
|
|
57
|
+
/** Parsed glTF animation channel. */
|
|
58
|
+
export type GLTFAnimationChannel = GLTFNodeAnimationChannel | GLTFMaterialAnimationChannel | GLTFTextureTransformAnimationChannel;
|
|
59
|
+
/** Parsed glTF animation sampler. */
|
|
11
60
|
export type GLTFAnimationSampler = {
|
|
61
|
+
/** Keyframe times in seconds. */
|
|
12
62
|
input: number[];
|
|
63
|
+
/** glTF interpolation mode. */
|
|
13
64
|
interpolation: string;
|
|
14
|
-
|
|
65
|
+
/** Keyframe values, already expanded into JS arrays. */
|
|
66
|
+
output: number[][];
|
|
15
67
|
};
|
|
16
68
|
//# sourceMappingURL=animations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../../src/gltf/animations/animations.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../../src/gltf/animations/animations.ts"],"names":[],"mappings":"AAIA,wCAAwC;AACxC,MAAM,MAAM,aAAa,GAAG;IAC1B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,QAAQ,EAAE,oBAAoB,EAAE,CAAC;CAClC,CAAC;AAEF,6CAA6C;AAC7C,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAEjF,oEAAoE;AACpE,MAAM,MAAM,wBAAwB,GAAG;IACrC,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EAAE,iBAAiB,CAAC;IACxB,uDAAuD;IACvD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,6BAA6B,GACrC,aAAa,GACb,oBAAoB,GACpB,oBAAoB,GACpB,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,0BAA0B,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,KAAK,GACL,mBAAmB,GACnB,gBAAgB,GAChB,2BAA2B,GAC3B,yBAAyB,GACzB,aAAa,GACb,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,qBAAqB,GACrB,yBAAyB,GACzB,iBAAiB,GACjB,oBAAoB,CAAC;AAEzB,qEAAqE;AACrE,MAAM,MAAM,4BAA4B,GAAG;IACzC,2BAA2B;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,uDAAuD;IACvD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,EAAE,6BAA6B,CAAC;IACxC,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oFAAoF;AACpF,MAAM,MAAM,oCAAoC,GAAG;IACjD,2BAA2B;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,uDAAuD;IACvD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,4CAA4C;IAC5C,WAAW,EAAE,OAAO,6BAA6B,EAAE,uBAAuB,CAAC;IAC3E,2DAA2D;IAC3D,IAAI,EAAE,OAAO,6BAA6B,EAAE,uBAAuB,CAAC;IACpE,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,aAAa,EAAE,OAAO,6BAA6B,EAAE,mBAAmB,CAAC;CAC1E,CAAC;AAEF,qCAAqC;AACrC,MAAM,MAAM,oBAAoB,GAC5B,wBAAwB,GACxB,4BAA4B,GAC5B,oCAAoC,CAAC;AAEzC,qCAAqC;AACrC,MAAM,MAAM,oBAAoB,GAAG;IACjC,iCAAiC;IACjC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { GLTFAnimationPath, GLTFAnimationSampler } from "./animations.js";
|
|
2
|
+
import { GroupNode } from '@luma.gl/engine';
|
|
3
|
+
/** Evaluates a glTF animation sampler at the supplied time and applies the result to a node. */
|
|
4
|
+
export declare function interpolate(time: number, { input, interpolation, output }: GLTFAnimationSampler, target: GroupNode, path: GLTFAnimationPath): void;
|
|
5
|
+
/** Evaluates a glTF animation sampler at the supplied time. */
|
|
6
|
+
export declare function evaluateSampler(time: number, { input, interpolation, output }: GLTFAnimationSampler, path?: GLTFAnimationPath): number[] | null;
|
|
4
7
|
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../../src/gltf/animations/interpolate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../../src/gltf/animations/interpolate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,iBAAiB,EAAE,oBAAoB,EAAC,wBAAqB;AACrE,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAwB1C,gGAAgG;AAChG,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAC,EAAE,oBAAoB,EACpD,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,iBAAiB,QAMxB;AAED,+DAA+D;AAC/D,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAC,EAAE,oBAAoB,EACpD,IAAI,CAAC,EAAE,iBAAiB,GACvB,MAAM,EAAE,GAAG,IAAI,CA8CjB"}
|