@luma.gl/gltf 9.3.0-alpha.6 → 9.3.0-alpha.9

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.
Files changed (65) hide show
  1. package/dist/dist.dev.js +942 -141
  2. package/dist/dist.min.js +4 -4
  3. package/dist/gltf/create-gltf-model.d.ts +9 -1
  4. package/dist/gltf/create-gltf-model.d.ts.map +1 -1
  5. package/dist/gltf/create-gltf-model.js +58 -4
  6. package/dist/gltf/create-gltf-model.js.map +1 -1
  7. package/dist/gltf/create-scenegraph-from-gltf.d.ts +22 -1
  8. package/dist/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
  9. package/dist/gltf/create-scenegraph-from-gltf.js +63 -1
  10. package/dist/gltf/create-scenegraph-from-gltf.js.map +1 -1
  11. package/dist/gltf/gltf-extension-support.d.ts +10 -0
  12. package/dist/gltf/gltf-extension-support.d.ts.map +1 -0
  13. package/dist/gltf/gltf-extension-support.js +173 -0
  14. package/dist/gltf/gltf-extension-support.js.map +1 -0
  15. package/dist/index.cjs +899 -114
  16. package/dist/index.cjs.map +4 -4
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/parsers/parse-gltf-animations.d.ts.map +1 -1
  22. package/dist/parsers/parse-gltf-animations.js +34 -12
  23. package/dist/parsers/parse-gltf-animations.js.map +1 -1
  24. package/dist/parsers/parse-gltf-lights.d.ts.map +1 -1
  25. package/dist/parsers/parse-gltf-lights.js +86 -20
  26. package/dist/parsers/parse-gltf-lights.js.map +1 -1
  27. package/dist/parsers/parse-gltf.d.ts +3 -1
  28. package/dist/parsers/parse-gltf.d.ts.map +1 -1
  29. package/dist/parsers/parse-gltf.js +41 -9
  30. package/dist/parsers/parse-gltf.js.map +1 -1
  31. package/dist/parsers/parse-pbr-material.d.ts +69 -1
  32. package/dist/parsers/parse-pbr-material.d.ts.map +1 -1
  33. package/dist/parsers/parse-pbr-material.js +429 -42
  34. package/dist/parsers/parse-pbr-material.js.map +1 -1
  35. package/dist/pbr/pbr-environment.d.ts.map +1 -1
  36. package/dist/pbr/pbr-environment.js +14 -12
  37. package/dist/pbr/pbr-environment.js.map +1 -1
  38. package/dist/pbr/pbr-material.d.ts +8 -3
  39. package/dist/pbr/pbr-material.d.ts.map +1 -1
  40. package/dist/webgl-to-webgpu/convert-webgl-sampler.d.ts +5 -5
  41. package/dist/webgl-to-webgpu/convert-webgl-sampler.d.ts.map +1 -1
  42. package/dist/webgl-to-webgpu/convert-webgl-sampler.js +12 -12
  43. package/dist/webgl-to-webgpu/convert-webgl-sampler.js.map +1 -1
  44. package/dist/webgl-to-webgpu/convert-webgl-topology.d.ts +1 -10
  45. package/dist/webgl-to-webgpu/convert-webgl-topology.d.ts.map +1 -1
  46. package/dist/webgl-to-webgpu/convert-webgl-topology.js +1 -15
  47. package/dist/webgl-to-webgpu/convert-webgl-topology.js.map +1 -1
  48. package/dist/webgl-to-webgpu/gltf-webgl-constants.d.ts +27 -0
  49. package/dist/webgl-to-webgpu/gltf-webgl-constants.d.ts.map +1 -0
  50. package/dist/webgl-to-webgpu/gltf-webgl-constants.js +34 -0
  51. package/dist/webgl-to-webgpu/gltf-webgl-constants.js.map +1 -0
  52. package/package.json +5 -6
  53. package/src/gltf/create-gltf-model.ts +113 -5
  54. package/src/gltf/create-scenegraph-from-gltf.ts +97 -6
  55. package/src/gltf/gltf-extension-support.ts +214 -0
  56. package/src/index.ts +10 -1
  57. package/src/parsers/parse-gltf-animations.ts +39 -15
  58. package/src/parsers/parse-gltf-lights.ts +114 -25
  59. package/src/parsers/parse-gltf.ts +86 -19
  60. package/src/parsers/parse-pbr-material.ts +664 -69
  61. package/src/pbr/pbr-environment.ts +29 -16
  62. package/src/pbr/pbr-material.ts +13 -3
  63. package/src/webgl-to-webgpu/convert-webgl-sampler.ts +29 -29
  64. package/src/webgl-to-webgpu/convert-webgl-topology.ts +1 -15
  65. package/src/webgl-to-webgpu/gltf-webgl-constants.ts +35 -0
package/dist/dist.min.js CHANGED
@@ -4,7 +4,7 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['luma'] = factory();
6
6
  else root['luma'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var kn=Object.create;var it=Object.defineProperty;var zn=Object.getOwnPropertyDescriptor;var Fn=Object.getOwnPropertyNames;var qn=Object.getPrototypeOf,Bn=Object.prototype.hasOwnProperty;var ot=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Cn=(e,t)=>{for(var n in t)it(e,n,{get:t[n],enumerable:!0})},st=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Fn(t))!Bn.call(e,s)&&s!==n&&it(e,s,{get:()=>t[s],enumerable:!(r=zn(t,s))||r.enumerable});return e},ct=(e,t,n)=>(st(e,t,"default"),n&&st(n,t,"default")),z=(e,t,n)=>(n=e!=null?kn(qn(e)):{},st(t||!e||!e.__esModule?it(n,"default",{value:e,enumerable:!0}):n,e)),Vn=e=>st(it({},"__esModule",{value:!0}),e);var $=ot((ps,Qt)=>{Qt.exports=globalThis.luma});var at=ot((ms,te)=>{te.exports=globalThis.luma});var qt=ot((Mi,ge)=>{ge.exports=globalThis.luma});var un=ot((Ro,Sn)=>{Sn.exports=globalThis.luma});var rt={};Cn(rt,{GLTFAnimator:()=>j,createScenegraphsFromGLTF:()=>bn,loadPBREnvironment:()=>Me,parseGLTFLights:()=>St,parsePBRMaterial:()=>dt});ct(rt,z($(),1));var Ft=z(at(),1);function U(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var F={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Un=F.self||F.window||F.global||{},Dn=F.window||F.self||F.global||{},$n=F.global||F.self||F.window||{},Gn=F.document||{};var Ot=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var ee=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Yn=ee&&parseFloat(ee[1])||0;var Wn="",ne={};function Rt(e){for(let t in ne)if(e.startsWith(t)){let n=ne[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Wn}${e}`),e}var re="4.4.0-alpha.18";var Hn=globalThis.loaders?.parseImageNode,It=typeof Image<"u",Pt=typeof ImageBitmap<"u",jn=Boolean(Hn),_t=Ot?!0:jn;function se(e){switch(e){case"auto":return Pt||It||_t;case"imagebitmap":return Pt;case"image":return It;case"data":return _t;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function ie(){if(Pt)return"imagebitmap";if(It)return"image";if(_t)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function oe(e){let t=Xn(e);if(!t)throw new Error("Not an image");return t}function vt(e){return ft(e)}function ft(e){switch(oe(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Xn(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var Kn=/^data:image\/svg\+xml/,Jn=/\.svg((\?|#).*)?$/;function ht(e){return e&&(Kn.test(e)||Jn.test(e))}function ce(e,t){if(ht(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return bt(e,t)}function bt(e,t){if(ht(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function lt(e,t,n){let r=ce(e,n),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await Zn(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function Zn(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,s)=>{try{n.onload=()=>r(n),n.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var ae=!0;async function fe(e,t,n){let r;ht(n)?r=await lt(e,t,n):r=bt(e,n);let s=t&&t.imagebitmap;return await Qn(r,s)}async function Qn(e,t=null){if((tr(t)||!ae)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),ae=!1}return await createImageBitmap(e)}function tr(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function he(e){return!sr(e,"ftyp",4)||!(e[8]&96)?null:er(e)}function er(e){switch(nr(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function nr(e,t,n){return String.fromCharCode(...e.slice(t,n))}function rr(e){return[...e].map(t=>t.charCodeAt(0))}function sr(e,t,n=0){let r=rr(t);for(let s=0;s<r.length;++s)if(r[s]!==e[s+n])return!1;return!0}var q=!1,K=!0;function pt(e){let t=J(e);return or(t)||fr(t)||cr(t)||ar(t)||ir(t)}function ir(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=he(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function or(e){let t=J(e);return t.byteLength>=24&&t.getUint32(0,q)===2303741511?{mimeType:"image/png",width:t.getUint32(16,q),height:t.getUint32(20,q)}:null}function cr(e){let t=J(e);return t.byteLength>=10&&t.getUint32(0,q)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,K),height:t.getUint16(8,K)}:null}function ar(e){let t=J(e);return t.byteLength>=14&&t.getUint16(0,q)===16973&&t.getUint32(2,K)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,K),height:t.getUint32(22,K)}:null}function fr(e){let t=J(e);if(!(t.byteLength>=3&&t.getUint16(0,q)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=hr(),i=2;for(;i+9<t.byteLength;){let o=t.getUint16(i,q);if(s.has(o))return{mimeType:"image/jpeg",height:t.getUint16(i+5,q),width:t.getUint16(i+7,q)};if(!r.has(o))return null;i+=2,i+=t.getUint16(i,q)}return null}function hr(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function J(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function le(e,t){let{mimeType:n}=pt(e)||{},r=globalThis.loaders?.parseImageNode;return U(r),await r(e,n)}async function pe(e,t,n){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=n||{},o=lr(s),c;switch(o){case"imagebitmap":c=await fe(e,t,i);break;case"image":c=await lt(e,t,i);break;case"data":c=await le(e,t);break;default:U(!1)}return s==="data"&&(c=ft(c)),c}function lr(e){switch(e){case"auto":case"data":return ie();default:return se(e),e}}var pr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],mr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],xr={image:{type:"auto",decode:!0}},mt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:re,mimeTypes:mr,extensions:pr,parse:pe,tests:[e=>Boolean(pt(new DataView(e)))],options:xr};function xt(e,t,n){let r=typeof e=="function"?e({...t,...n}):e,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),Rt(r)}var dr=e=>e&&typeof e=="object";async function me(e,t,n={}){return await kt(e,t,n)}async function kt(e,t,n){return Array.isArray(e)?await gr(e,t,n):dr(e)?await Mr(e,t,n):await t(e,n)}async function Mr(e,t,n){let r=[],s={};for(let i in e){let o=e[i],c=kt(o,t,n).then(a=>{s[i]=a});r.push(c)}return await Promise.all(r),s}async function gr(e,t,n={}){let r=e.map(s=>kt(s,t,n));return await Promise.all(r)}async function xe(e,t,n){return await me(e,r=>zt(r,t,n))}async function zt(e,t,n){let s=await(await fetch(e,n.fetch)).arrayBuffer();return await t(s,n)}async function Z(e,t={}){let n=await yr(e,t);return await xe(n,mt.parse,t)}async function yr(e,t,n={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await Tr(e,r,t,n):xt(e,t,n)}async function Tr(e,t,n,r){let s=[];if(t==="auto"){let i=xt(e,n,{...r,lod:0}),o=await zt(i,mt.parse,n),{width:c,height:a}=vt(o);t=Ar({width:c,height:a}),s.push(i)}U(t>0);for(let i=s.length;i<t;++i){let o=xt(e,n,{...r,lod:i});s.push(o)}return s}function Ar(e){return 1+Math.floor(Math.log2(Math.max(e.width,e.height)))}function Me(e,t){let n=new Ft.DynamicTexture(e,{id:"brdfLUT",sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"},data:Z(t.brdfLutUrl)}),r=de(e,{id:"DiffuseEnvSampler",getTextureForFace:i=>Z(t.getTexUrl("diffuse",i,0)),sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}}),s=de(e,{id:"SpecularEnvSampler",getTextureForFace:i=>{let o=[];for(let c=0;c<=t.specularMipLevels-1;c++)o.push(Z(t.getTexUrl("specular",i,c)));return o},sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}});return{brdfLutTexture:n,diffuseEnvSampler:r,specularEnvSampler:s}}var Er=[0,1,2,3,4,5];function de(e,{id:t,getTextureForFace:n,sampler:r}){let s={};return Er.forEach(i=>{s[String(i)]=n(i)}),new Ft.DynamicTexture(e,{id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var _=z($(),1),Ai=z(qt(),1);var gi=z(qt(),1);function Te(e){return{addressModeU:ye(e.wrapS),addressModeV:ye(e.wrapT),magFilter:wr(e.magFilter),...Sr(e.minFilter)}}function ye(e){switch(e){case 33071:return"clamp-to-edge";case 10497:return"repeat";case 33648:return"mirror-repeat";default:return}}function wr(e){switch(e){case 9728:return"nearest";case 9729:return"linear";default:return}}function Sr(e){switch(e){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 dt(e,t,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: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]),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.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),t&&ur(e,t,s),s}function ur(e,t,n){if(n.uniforms.unlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Nr(e,t.pbrMetallicRoughness,n),t.normalTexture){Q(e,t.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",n);let{scale:r=1}=t.normalTexture;n.uniforms.normalScale=r}if(t.occlusionTexture){Q(e,t.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",n);let{strength:r=1}=t.occlusionTexture;n.uniforms.occlusionStrength=r}switch(t.emissiveTexture&&(Q(e,t.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",n),n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode||"MASK"){case"MASK":let{alphaCutoff:r=.5}=t;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoff=r;break;case"BLEND":_.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),n.parameters.blend=!0,n.parameters.blendColorOperation="add",n.parameters.blendColorSrcFactor="src-alpha",n.parameters.blendColorDstFactor="one-minus-src-alpha",n.parameters.blendAlphaOperation="add",n.parameters.blendAlphaSrcFactor="one",n.parameters.blendAlphaDstFactor="one-minus-src-alpha",n.glParameters.blend=!0,n.glParameters.blendEquation=32774,n.glParameters.blendFunc=[770,771,1,771];break}}function Nr(e,t,n){t.baseColorTexture&&Q(e,t.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",n),n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&Q(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",n);let{metallicFactor:r=1,roughnessFactor:s=1}=t;n.uniforms.metallicRoughnessValues=[r,s]}function Q(e,t,n,r,s){let i=t.texture.source.image,o={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...t?.texture?.sampler},c={id:t.uniformName||t.id,sampler:Te(o)},a;if(i.compressed)a=Or(e,i,c);else{let{width:f,height:h}=e.getExternalImageSize(i);a=e.createTexture({...c,width:f,height:h,data:i})}s.bindings[n]=a,r&&(s.defines[r]=!0),s.generatedTextures.push(a)}function Bt(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function Ae(e){return e.textureFormat}function Lr(e,t,n){let{blockWidth:r=1,blockHeight:s=1}=_.textureFormatDecoder.getInfo(n),i=1;for(let o=1;;o++){let c=Math.max(1,e>>o),a=Math.max(1,t>>o);if(c<r||a<s)break;i++}return i}function Or(e,t,n){let r;if(Array.isArray(t.data)&&t.data[0]?.data?r=t.data:"mipmaps"in t&&Array.isArray(t.mipmaps)?r=t.mipmaps:r=[],r.length===0||!r[0]?.data)return _.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),Bt(e,n);let s=r[0],i=s.width??t.width??0,o=s.height??t.height??0;if(i<=0||o<=0)return _.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),Bt(e,n);let c=Ae(s);if(!c)return _.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),Bt(e,n);let a=Lr(i,o,c),f=Math.min(r.length,a),h=1;for(let p=1;p<f;p++){let m=r[p];if(!m.data||m.width<=0||m.height<=0){_.log.warn(`createCompressedTexture: mip level ${p} has invalid data/dimensions, truncating`)();break}let x=Ae(m);if(x&&x!==c){_.log.warn(`createCompressedTexture: mip level ${p} format '${x}' differs from base '${c}', truncating`)();break}let d=Math.max(1,i>>p),M=Math.max(1,o>>p);if(m.width!==d||m.height!==M){_.log.warn(`createCompressedTexture: mip level ${p} dimensions ${m.width}x${m.height} don't match expected ${d}x${M}, truncating`)();break}h++}let l=e.createTexture({...n,format:c,usage:_.Texture.TEXTURE|_.Texture.COPY_DST,width:i,height:o,mipLevels:h,data:s.data});for(let p=1;p<h;p++)l.writeData(r[p].data,{width:r[p].width,height:r[p].height,mipLevel:p});return l}var ui=1/Math.PI*180,Ni=1/180*Math.PI,Rr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Rr}};var N=globalThis.mathgl.config;function Ee(e,{precision:t=N.precision}={}){return e=Ir(e),`${parseFloat(e.toPrecision(t))}`}function G(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ct(e,t,n){let r=N.EPSILON;n&&(N.EPSILON=n);try{if(e===t)return!0;if(G(e)&&G(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!Ct(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=N.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{N.EPSILON=r}}function Ir(e){return Math.round(e/N.EPSILON)*N.EPSILON}var V=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:G(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(N)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Ee(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!Ct(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(N.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function Pr(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function S(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Y(e,t,n=""){if(N.debug&&!Pr(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Vt(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Mt=class extends V{get x(){return this[0]}set x(t){this[0]=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 n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return S(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return S(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Vt(t>=0&&t<this.ELEMENTS,"index is out of range"),S(this[t])}setComponent(t,n){return Vt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var L=typeof Float32Array<"u"?Float32Array:Array;var Fi=Math.PI/180;function _r(){let e=new L(2);return L!=Float32Array&&(e[0]=0,e[1]=0),e}function ue(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var qi=function(){let e=_r();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function Ne(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function Le(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Oe(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function Re(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function Ut(){let e=new L(3);return L!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function vr(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Dt(e,t,n){let r=new L(3);return r[0]=e,r[1]=t,r[2]=n,r}function Ie(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Pe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function gt(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function yt(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function _e(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],f=t[2],h=s*f-i*a,l=i*c-r*f,p=r*a-s*c,m=s*p-i*l,x=i*h-r*p,d=r*l-s*h,M=o*2;return h*=M,l*=M,p*=M,m*=2,x*=2,d*=2,e[0]=c+h+m,e[1]=a+l+x,e[2]=f+p+d,e}var ve=vr;var Vi=function(){let e=Ut();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var Tt,W=class extends Mt{static get ZERO(){return Tt||(Tt=new W(0,0,0,0),Object.freeze(Tt)),Tt}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),G(t)&&arguments.length===1?this.copy(t):(N.debug&&(S(t),S(n),S(r),S(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return N.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 yt(this,this,t),this.check()}transformByMatrix3(t){return Re(this,this,t),this.check()}transformByMatrix2(t){return Oe(this,this,t),this.check()}transformByQuaternion(t){return _e(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var At=class extends V{toString(){let t="[";if(N.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=S(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function be(){let e=new L(9);return L!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function zr(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ke(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function ze(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],f=t[7],h=t[8],l=t[9],p=t[10],m=t[11],x=t[12],d=t[13],M=t[14],E=t[15],u=n*c-r*o,g=n*a-s*o,y=n*f-i*o,T=r*a-s*c,A=r*f-i*c,O=s*f-i*a,R=h*d-l*x,I=h*M-p*x,P=h*E-m*x,v=l*M-p*d,b=l*E-m*d,k=p*E-m*M,w=u*k-g*b+y*v+T*P-A*I+O*R;return w?(w=1/w,e[0]=(c*k-a*b+f*v)*w,e[1]=(s*b-r*k-i*v)*w,e[2]=(d*O-M*A+E*T)*w,e[3]=(p*A-l*O-m*T)*w,e[4]=(a*P-o*k-f*I)*w,e[5]=(n*k-s*P+i*I)*w,e[6]=(M*y-x*O-E*g)*w,e[7]=(h*O-p*y+m*g)*w,e[8]=(o*b-c*P+f*R)*w,e[9]=(r*P-n*b-i*R)*w,e[10]=(x*A-d*y+E*u)*w,e[11]=(l*y-h*A-m*u)*w,e[12]=(c*I-o*v-a*R)*w,e[13]=(n*v-r*I+s*R)*w,e[14]=(d*g-x*T-M*u)*w,e[15]=(h*T-l*g+p*u)*w,e):null}function Fe(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],f=e[8],h=e[9],l=e[10],p=e[11],m=e[12],x=e[13],d=e[14],M=e[15],E=t*o-n*i,u=t*c-r*i,g=n*c-r*o,y=f*x-h*m,T=f*d-l*m,A=h*d-l*x,O=t*A-n*T+r*y,R=i*A-o*T+c*y,I=f*g-h*u+l*E,P=m*g-x*u+d*E;return a*O-s*R+M*I-p*P}function $t(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],f=t[6],h=t[7],l=t[8],p=t[9],m=t[10],x=t[11],d=t[12],M=t[13],E=t[14],u=t[15],g=n[0],y=n[1],T=n[2],A=n[3];return e[0]=g*r+y*c+T*l+A*d,e[1]=g*s+y*a+T*p+A*M,e[2]=g*i+y*f+T*m+A*E,e[3]=g*o+y*h+T*x+A*u,g=n[4],y=n[5],T=n[6],A=n[7],e[4]=g*r+y*c+T*l+A*d,e[5]=g*s+y*a+T*p+A*M,e[6]=g*i+y*f+T*m+A*E,e[7]=g*o+y*h+T*x+A*u,g=n[8],y=n[9],T=n[10],A=n[11],e[8]=g*r+y*c+T*l+A*d,e[9]=g*s+y*a+T*p+A*M,e[10]=g*i+y*f+T*m+A*E,e[11]=g*o+y*h+T*x+A*u,g=n[12],y=n[13],T=n[14],A=n[15],e[12]=g*r+y*c+T*l+A*d,e[13]=g*s+y*a+T*p+A*M,e[14]=g*i+y*f+T*m+A*E,e[15]=g*o+y*h+T*x+A*u,e}function qe(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,f,h,l,p,m,x,d,M,E;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],f=t[3],h=t[4],l=t[5],p=t[6],m=t[7],x=t[8],d=t[9],M=t[10],E=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=f,e[4]=h,e[5]=l,e[6]=p,e[7]=m,e[8]=x,e[9]=d,e[10]=M,e[11]=E,e[12]=o*r+h*s+x*i+t[12],e[13]=c*r+l*s+d*i+t[13],e[14]=a*r+p*s+M*i+t[14],e[15]=f*r+m*s+E*i+t[15]),e}function Be(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ce(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,f,h,l,p,m,x,d,M,E,u,g,y,T,A,O,R,I,P,v,b,k,w,X;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,f=Math.sin(n),a=Math.cos(n),h=1-a,l=t[0],p=t[1],m=t[2],x=t[3],d=t[4],M=t[5],E=t[6],u=t[7],g=t[8],y=t[9],T=t[10],A=t[11],O=s*s*h+a,R=i*s*h+o*f,I=o*s*h-i*f,P=s*i*h-o*f,v=i*i*h+a,b=o*i*h+s*f,k=s*o*h+i*f,w=i*o*h-s*f,X=o*o*h+a,e[0]=l*O+d*R+g*I,e[1]=p*O+M*R+y*I,e[2]=m*O+E*R+T*I,e[3]=x*O+u*R+A*I,e[4]=l*P+d*v+g*b,e[5]=p*P+M*v+y*b,e[6]=m*P+E*v+T*b,e[7]=x*P+u*v+A*b,e[8]=l*k+d*w+g*X,e[9]=p*k+M*w+y*X,e[10]=m*k+E*w+T*X,e[11]=x*k+u*w+A*X,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Ve(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],f=t[8],h=t[9],l=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+f*r,e[5]=o*s+h*r,e[6]=c*s+l*r,e[7]=a*s+p*r,e[8]=f*s-i*r,e[9]=h*s-o*r,e[10]=l*s-c*r,e[11]=p*s-a*r,e}function Ue(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],f=t[8],h=t[9],l=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-f*r,e[1]=o*s-h*r,e[2]=c*s-l*r,e[3]=a*s-p*r,e[8]=i*r+f*s,e[9]=o*r+h*s,e[10]=c*r+l*s,e[11]=a*r+p*s,e}function De(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],f=t[4],h=t[5],l=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+f*r,e[1]=o*s+h*r,e[2]=c*s+l*r,e[3]=a*s+p*r,e[4]=f*s-i*r,e[5]=h*s-o*r,e[6]=l*s-c*r,e[7]=p*s-a*r,e}function $e(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,f=n*o,h=r*o,l=r*c,p=s*o,m=s*c,x=s*a,d=i*o,M=i*c,E=i*a;return e[0]=1-l-x,e[1]=h+E,e[2]=p-M,e[3]=0,e[4]=h-E,e[5]=1-f-x,e[6]=m+d,e[7]=0,e[8]=p+M,e[9]=m-d,e[10]=1-f-l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ge(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),f=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*f,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*f,e[15]=0,e}function Fr(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var Ye=Fr;function qr(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),f=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*f,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*f,e[15]=1,e}var We=qr;function He(e,t,n,r){let s,i,o,c,a,f,h,l,p,m,x=t[0],d=t[1],M=t[2],E=r[0],u=r[1],g=r[2],y=n[0],T=n[1],A=n[2];return Math.abs(x-y)<1e-6&&Math.abs(d-T)<1e-6&&Math.abs(M-A)<1e-6?zr(e):(l=x-y,p=d-T,m=M-A,s=1/Math.sqrt(l*l+p*p+m*m),l*=s,p*=s,m*=s,i=u*m-g*p,o=g*l-E*m,c=E*p-u*l,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-m*o,f=m*i-l*c,h=l*o-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),e[0]=i,e[1]=a,e[2]=l,e[3]=0,e[4]=o,e[5]=f,e[6]=p,e[7]=0,e[8]=c,e[9]=h,e[10]=m,e[11]=0,e[12]=-(i*x+o*d+c*M),e[13]=-(a*x+f*d+h*M),e[14]=-(l*x+p*d+m*M),e[15]=1,e)}function Br(){let e=new L(4);return L!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function je(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function Xe(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Ke(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function Je(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function Ze(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function Qe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function tn(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function en(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function nn(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],f=n[3],h=f*r+c*i-a*s,l=f*s+a*r-o*i,p=f*i+o*s-c*r,m=-o*r-c*s-a*i;return e[0]=h*f+m*-o+l*-a-p*-c,e[1]=l*f+m*-c+p*-o-h*-a,e[2]=p*f+m*-a+h*-c-l*-o,e[3]=t[3],e}var Zi=function(){let e=Br();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var Wt;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Wt||(Wt={}));var Vr=45*Math.PI/180,Ur=1,Gt=.1,Yt=500,Dr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),C=class extends At{static get IDENTITY(){return Gr()}static get ZERO(){return $r()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Wt}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,f,h,l,p,m,x,d,M){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=f,this[9]=h,this[10]=l,this[11]=p,this[12]=m,this[13]=x,this[14]=d,this[15]=M,this.check()}setRowMajor(t,n,r,s,i,o,c,a,f,h,l,p,m,x,d,M){return this[0]=t,this[1]=i,this[2]=f,this[3]=m,this[4]=n,this[5]=o,this[6]=h,this[7]=x,this[8]=r,this[9]=c,this[10]=l,this[11]=d,this[12]=s,this[13]=a,this[14]=p,this[15]=M,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(Dr)}fromObject(t){return this.check()}fromQuaternion(t){return $e(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=Gt,far:c=Yt}=t;return c===1/0?Yr(this,n,r,s,i,o):Ge(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return He(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=Gt,far:c=Yt}=t;return We(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=Vr,aspect:r=Ur,focalDistance:s=1,near:i=Gt,far:o=Yt}=t;rn(n);let c=n/2,a=s*Math.tan(c),f=a*r;return this.ortho({left:-f,right:f,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return rn(n),Ye(this,n,r,s,i),this.check()}determinant(){return Fe(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return ke(this,this),this.check()}invert(){return ze(this,this),this.check()}multiplyLeft(t){return $t(this,t,this),this.check()}multiplyRight(t){return $t(this,this,t),this.check()}rotateX(t){return Ve(this,this,t),this.check()}rotateY(t){return Ue(this,this,t),this.check()}rotateZ(t){return De(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return Ce(this,this,t,n),this.check()}scale(t){return Be(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return qe(this,this,t),this.check()}transform(t,n){return t.length===4?(n=en(n||[-0,-0,-0,-0],t,this),Y(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=ue(n||[-0,-0],t,this);break;case 3:s=yt(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Y(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=Ne(n||[-0,-0],t,this);break;case 3:r=Le(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Y(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},Et,wt;function $r(){return Et||(Et=new C([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Et)),Et}function Gr(){return wt||(wt=new C,Object.freeze(wt)),wt}function rn(e){if(e>Math.PI*2)throw Error("expected radians")}function Yr(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),f=(s+r)/(s-r),h=-1,l=-1,p=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=f,e[10]=h,e[11]=l,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}function sn(){let e=new L(4);return L!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function on(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Ht(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function jt(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],f=n[2],h=n[3];return e[0]=r*h+o*c+s*f-i*a,e[1]=s*h+o*a+i*c-r*f,e[2]=i*h+o*f+r*a-s*c,e[3]=o*h-r*c-s*a-i*f,e}function cn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*c,e[1]=s*a+i*c,e[2]=i*a-s*c,e[3]=o*a-r*c,e}function an(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-i*c,e[1]=s*a+o*c,e[2]=i*a+r*c,e[3]=o*a-s*c,e}function fn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function hn(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function et(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],f=n[1],h=n[2],l=n[3],p,m,x,d,M;return p=s*a+i*f+o*h+c*l,p<0&&(p=-p,a=-a,f=-f,h=-h,l=-l),1-p>1e-6?(m=Math.acos(p),M=Math.sin(m),x=Math.sin((1-r)*m)/M,d=Math.sin(r*m)/M):(x=1-r,d=r),e[0]=x*s+d*a,e[1]=x*i+d*f,e[2]=x*o+d*h,e[3]=x*c+d*l,e}function ln(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function pn(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Xt(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var mn=je;var xn=Xe,dn=Qe,Mn=tn,gn=Ke;var yn=Je;var Tn=Ze;var An=function(){let e=Ut(),t=Dt(1,0,0),n=Dt(0,1,0);return function(r,s,i){let o=Pe(s,i);return o<-.999999?(gt(e,t,s),ve(e)<1e-6&&gt(e,n,s),Ie(e,e),Ht(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(gt(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,Tn(r,r))}}(),po=function(){let e=sn(),t=sn();return function(n,r,s,i,o,c){return et(e,r,o,c),et(t,s,i,c),et(n,e,t,2*c*(1-c)),n}}(),mo=function(){let e=be();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],Tn(t,Xt(t,e))}}();var Wr=[0,0,0,1],nt=class extends V{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Xt(this,t),this.check()}fromAxisRotation(t,n){return Ht(this,t,n),this.check()}identity(){return on(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=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 gn(this)}lengthSquared(){return yn(this)}dot(t){return dn(this,t)}rotationTo(t,n){return An(this,t,n),this.check()}add(t){return mn(this,this,t),this.check()}calculateW(){return hn(this,this),this.check()}conjugate(){return pn(this,this),this.check()}invert(){return ln(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(Mn(this,t,n,r),this.check())}multiplyRight(t){return jt(this,this,t),this.check()}multiplyLeft(t){return jt(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return cn(this,this,t),this.check()}rotateY(t){return an(this,this,t),this.check()}rotateZ(t){return fn(this,this,t),this.check()}scale(t){return xn(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=Wr,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return et(this,s,i,o),this.check()}transformVector4(t,n=new W){return nn(n,t,this),Y(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};function St(e){let t=e.lights||e.extensions?.KHR_lights_punctual?.lights;if(!t||!Array.isArray(t)||t.length===0)return[];let n=[];for(let r of e.nodes||[]){let s=r.light??r.extensions?.KHR_lights_punctual?.light;if(typeof s!="number")continue;let i=t[s];if(!i)continue;let o=i.color||[1,1,1],c=i.intensity??1,a=i.range;switch(i.type){case"directional":n.push(Hr(r,o,c));break;case"point":n.push(En(r,o,c,a));break;case"spot":n.push(En(r,o,c,a));break;default:break}}return n}function En(e,t,n,r){let s=jr(e),i=[1,0,0];return r!==void 0&&r>0&&(i=[1,0,1/(r*r)]),{type:"point",position:s,color:t,intensity:n,attenuation:i}}function Hr(e,t,n){return{type:"directional",direction:Xr(e),color:t,intensity:n}}function jr(e){return e.matrix?new C(e.matrix).transformAsPoint([0,0,0]):e.translation?[...e.translation]:[0,0,0]}function Xr(e){return e.matrix?new C(e.matrix).transformDirection([0,0,-1]):e.rotation?new C().fromQuaternion(e.rotation).transformDirection([0,0,-1]):[0,0,-1]}var H=z(at(),1);var D;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(D||(D={}));function wn(e){switch(e){case D.POINTS:return"point-list";case D.LINES:return"line-list";case D.LINE_STRIP:return"line-strip";case D.TRIANGLES:return"triangle-list";case D.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(e))}}var Nn=z($(),1),ut=z(un(),1),Nt=z(at(),1),Kr=`
7
+ "use strict";var __exports__=(()=>{var qn=Object.create;var ft=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var $n=Object.getPrototypeOf,Wn=Object.prototype.hasOwnProperty;var It=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Yn=(e,t)=>{for(var n in t)ft(e,n,{get:t[n],enumerable:!0})},lt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Kn(t))!Wn.call(e,s)&&s!==n&&ft(e,s,{get:()=>t[s],enumerable:!(r=Vn(t,s))||r.enumerable});return e},pt=(e,t,n)=>(lt(e,t,"default"),n&&lt(n,t,"default")),F=(e,t,n)=>(n=e!=null?qn($n(e)):{},lt(t||!e||!e.__esModule?ft(n,"default",{value:e,enumerable:!0}):n,e)),Gn=e=>lt(ft({},"__esModule",{value:!0}),e);var $=It((Ys,se)=>{se.exports=globalThis.luma});var Z=It((Gs,ie)=>{ie.exports=globalThis.luma});var Zt=It((oc,Ln)=>{Ln.exports=globalThis.luma});var at={};Yn(at,{GLTFAnimator:()=>J,createScenegraphsFromGLTF:()=>Bn,getGLTFExtensionSupport:()=>Ot,loadPBREnvironment:()=>Ee,parseGLTFLights:()=>Nt,parsePBRMaterial:()=>rt});pt(at,F($(),1));var Bt=F(Z(),1);function W(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var H={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Xn=H.self||H.window||H.global||{},jn=H.window||H.self||H.global||{},Jn=H.global||H.self||H.window||{},Qn=H.document||{};var Pt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var oe=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Zn=oe&&parseFloat(oe[1])||0;var tr="",ce={};function bt(e){for(let t in ce)if(e.startsWith(t)){let n=ce[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${tr}${e}`),e}var ae="4.4.0-alpha.18";var er=globalThis.loaders?.parseImageNode,vt=typeof Image<"u",Ft=typeof ImageBitmap<"u",nr=Boolean(er),kt=Pt?!0:nr;function le(e){switch(e){case"auto":return Ft||vt||kt;case"imagebitmap":return Ft;case"image":return vt;case"data":return kt;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function fe(){if(Ft)return"imagebitmap";if(vt)return"image";if(kt)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function pe(e){let t=rr(e);if(!t)throw new Error("Not an image");return t}function Ct(e){return ht(e)}function ht(e){switch(pe(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function rr(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var sr=/^data:image\/svg\+xml/,ir=/\.svg((\?|#).*)?$/;function mt(e){return e&&(sr.test(e)||ir.test(e))}function he(e,t){if(mt(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return zt(e,t)}function zt(e,t){if(mt(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function dt(e,t,n){let r=he(e,n),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await or(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function or(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,s)=>{try{n.onload=()=>r(n),n.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var me=!0;async function de(e,t,n){let r;mt(n)?r=await dt(e,t,n):r=zt(e,n);let s=t&&t.imagebitmap;return await cr(r,s)}async function cr(e,t=null){if((ar(t)||!me)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),me=!1}return await createImageBitmap(e)}function ar(e){if(!e)return!0;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function xe(e){return!hr(e,"ftyp",4)||!(e[8]&96)?null:lr(e)}function lr(e){switch(fr(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function fr(e,t,n){return String.fromCharCode(...e.slice(t,n))}function pr(e){return[...e].map(t=>t.charCodeAt(0))}function hr(e,t,n=0){let r=pr(t);for(let s=0;s<r.length;++s)if(r[s]!==e[s+n])return!1;return!0}var U=!1,tt=!0;function xt(e){let t=et(e);return dr(t)||gr(t)||xr(t)||ur(t)||mr(t)}function mr(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=xe(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function dr(e){let t=et(e);return t.byteLength>=24&&t.getUint32(0,U)===2303741511?{mimeType:"image/png",width:t.getUint32(16,U),height:t.getUint32(20,U)}:null}function xr(e){let t=et(e);return t.byteLength>=10&&t.getUint32(0,U)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,tt),height:t.getUint16(8,tt)}:null}function ur(e){let t=et(e);return t.byteLength>=14&&t.getUint16(0,U)===16973&&t.getUint32(2,tt)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,tt),height:t.getUint32(22,tt)}:null}function gr(e){let t=et(e);if(!(t.byteLength>=3&&t.getUint16(0,U)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=Mr(),i=2;for(;i+9<t.byteLength;){let o=t.getUint16(i,U);if(s.has(o))return{mimeType:"image/jpeg",height:t.getUint16(i+5,U),width:t.getUint16(i+7,U)};if(!r.has(o))return null;i+=2,i+=t.getUint16(i,U)}return null}function Mr(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function et(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function ue(e,t){let{mimeType:n}=xt(e)||{},r=globalThis.loaders?.parseImageNode;return W(r),await r(e,n)}async function ge(e,t,n){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=n||{},o=Tr(s),c;switch(o){case"imagebitmap":c=await de(e,t,i);break;case"image":c=await dt(e,t,i);break;case"data":c=await ue(e,t);break;default:W(!1)}return s==="data"&&(c=ht(c)),c}function Tr(e){switch(e){case"auto":case"data":return fe();default:return le(e),e}}var Ar=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],Er=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],yr={image:{type:"auto",decode:!0}},ut={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:ae,mimeTypes:Er,extensions:Ar,parse:ge,tests:[e=>Boolean(xt(new DataView(e)))],options:yr};function gt(e,t,n){let r=typeof e=="function"?e({...t,...n}):e,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),bt(r)}var _r=e=>e&&typeof e=="object";async function Me(e,t,n={}){return await Ht(e,t,n)}async function Ht(e,t,n){return Array.isArray(e)?await Sr(e,t,n):_r(e)?await Rr(e,t,n):await t(e,n)}async function Rr(e,t,n){let r=[],s={};for(let i in e){let o=e[i],c=Ht(o,t,n).then(a=>{s[i]=a});r.push(c)}return await Promise.all(r),s}async function Sr(e,t,n={}){let r=e.map(s=>Ht(s,t,n));return await Promise.all(r)}async function Te(e,t,n){return await Me(e,r=>Ut(r,t,n))}async function Ut(e,t,n){let s=await(await fetch(e,n.fetch)).arrayBuffer();return await t(s,n)}async function nt(e,t={}){let n=await Nr(e,t);return await Te(n,ut.parse,t)}async function Nr(e,t,n={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await wr(e,r,t,n):gt(e,t,n)}async function wr(e,t,n,r){let s=[];if(t==="auto"){let i=gt(e,n,{...r,lod:0}),o=await Ut(i,ut.parse,n),{width:c,height:a}=Ct(o);t=Lr({width:c,height:a}),s.push(i)}W(t>0);for(let i=s.length;i<t;++i){let o=gt(e,n,{...r,lod:i});s.push(o)}return s}function Lr(e){return 1+Math.floor(Math.log2(Math.max(e.width,e.height)))}function Ee(e,t){let n=t.specularMipLevels??1,r=new Bt.DynamicTexture(e,{id:"brdfLUT",sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"},data:nt(t.brdfLutUrl)}),s=Ae(e,{id:"DiffuseEnvSampler",getTextureForFace:o=>nt(t.getTexUrl("diffuse",Mt.indexOf(o),0)),sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}}),i=Ae(e,{id:"SpecularEnvSampler",getTextureForFace:o=>{let c=[],a=Mt.indexOf(o);for(let l=0;l<n;l++)c.push(nt(t.getTexUrl("specular",a,l)));return Promise.all(c)},sampler:{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"linear",magFilter:"linear"}});return{brdfLutTexture:r,diffuseEnvSampler:s,specularEnvSampler:i}}var Mt=["+X","-X","+Y","-Y","+Z","-Z"];function Ae(e,{id:t,getTextureForFace:n,sampler:r}){let s=Promise.all(Mt.map(i=>n(i))).then(i=>{let o={};return Mt.forEach((c,a)=>{o[c]=i[a]}),o});return new Bt.DynamicTexture(e,{id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var N=F($(),1);var y;(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST=9728]="NEAREST",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(y||(y={}));function _e(e){return{addressModeU:ye(e.wrapS),addressModeV:ye(e.wrapT),magFilter:Or(e.magFilter),...Ir(e.minFilter)}}function ye(e){switch(e){case y.CLAMP_TO_EDGE:return"clamp-to-edge";case y.REPEAT:return"repeat";case y.MIRRORED_REPEAT:return"mirror-repeat";default:return}}function Or(e){switch(e){case y.NEAREST:return"nearest";case y.LINEAR:return"linear";default:return}}function Ir(e){switch(e){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{}}}function rt(e,t,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: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.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.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),t&&(r.validateAttributes!==!1&&Pr(t,n),vr(e,t,s,r.gltf)),s}function Pr(e,t){let n=br(e);if(n.length>0&&!t.TEXCOORD_0&&N.log.warn(`glTF material uses ${n.join(", ")} but primitive is missing TEXCOORD_0; textured shading will sample the default UV coordinates`)(),Boolean(e.unlit||e.extensions?.KHR_materials_unlit)||t.NORMAL)return;let s=e.normalTexture?"lit PBR shading with normalTexture":"lit PBR shading";N.log.warn(`glTF primitive is missing NORMAL while using ${s}; shading will fall back to geometric normals`)()}function br(e){let t=[];return e.pbrMetallicRoughness?.baseColorTexture&&t.push("baseColorTexture"),e.pbrMetallicRoughness?.metallicRoughnessTexture&&t.push("metallicRoughnessTexture"),e.normalTexture&&t.push("normalTexture"),e.occlusionTexture&&t.push("occlusionTexture"),e.emissiveTexture&&t.push("emissiveTexture"),e.extensions?.KHR_materials_specular?.specularTexture&&t.push("KHR_materials_specular.specularTexture"),e.extensions?.KHR_materials_specular?.specularColorTexture&&t.push("KHR_materials_specular.specularColorTexture"),e.extensions?.KHR_materials_transmission?.transmissionTexture&&t.push("KHR_materials_transmission.transmissionTexture"),e.extensions?.KHR_materials_clearcoat?.clearcoatTexture&&t.push("KHR_materials_clearcoat.clearcoatTexture"),e.extensions?.KHR_materials_clearcoat?.clearcoatRoughnessTexture&&t.push("KHR_materials_clearcoat.clearcoatRoughnessTexture"),e.extensions?.KHR_materials_sheen?.sheenColorTexture&&t.push("KHR_materials_sheen.sheenColorTexture"),e.extensions?.KHR_materials_sheen?.sheenRoughnessTexture&&t.push("KHR_materials_sheen.sheenRoughnessTexture"),e.extensions?.KHR_materials_iridescence?.iridescenceTexture&&t.push("KHR_materials_iridescence.iridescenceTexture"),e.extensions?.KHR_materials_anisotropy?.anisotropyTexture&&t.push("KHR_materials_anisotropy.anisotropyTexture"),t}function vr(e,t,n,r){if(n.uniforms.unlit=Boolean(t.unlit||t.extensions?.KHR_materials_unlit),t.pbrMetallicRoughness&&Cr(e,t.pbrMetallicRoughness,n,r),t.normalTexture){w(e,t.normalTexture,"pbr_normalSampler",n,{featureOptions:{define:"HAS_NORMALMAP",enabledUniformName:"normalMapEnabled"},gltf:r});let{scale:s=1}=t.normalTexture;n.uniforms.normalScale=s}if(t.occlusionTexture){w(e,t.occlusionTexture,"pbr_occlusionSampler",n,{featureOptions:{define:"HAS_OCCLUSIONMAP",enabledUniformName:"occlusionMapEnabled"},gltf:r});let{strength:s=1}=t.occlusionTexture;n.uniforms.occlusionStrength=s}switch(n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0],t.emissiveTexture&&w(e,t.emissiveTexture,"pbr_emissiveSampler",n,{featureOptions:{define:"HAS_EMISSIVEMAP",enabledUniformName:"emissiveMapEnabled"},gltf:r}),zr(e,t.extensions,n,r),t.alphaMode||"OPAQUE"){case"OPAQUE":break;case"MASK":{let{alphaCutoff:s=.5}=t;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoffEnabled=!0,n.uniforms.alphaCutoff=s;break}case"BLEND":N.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),Fr(n);break}}function Fr(e){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=y.FUNC_ADD,e.glParameters.blendFunc=[y.SRC_ALPHA,y.ONE_MINUS_SRC_ALPHA,y.ONE,y.ONE_MINUS_SRC_ALPHA]}function kr(e){e.parameters.blend=!0,e.parameters.depthWriteEnabled=!1,e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="one",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.depthMask=!1,e.glParameters.blendEquation=y.FUNC_ADD,e.glParameters.blendFunc=[y.ONE,y.ONE_MINUS_SRC_ALPHA,y.ONE,y.ONE_MINUS_SRC_ALPHA]}function Cr(e,t,n,r){t.baseColorTexture&&w(e,t.baseColorTexture,"pbr_baseColorSampler",n,{featureOptions:{define:"HAS_BASECOLORMAP",enabledUniformName:"baseColorMapEnabled"},gltf:r}),n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&w(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler",n,{featureOptions:{define:"HAS_METALROUGHNESSMAP",enabledUniformName:"metallicRoughnessMapEnabled"},gltf:r});let{metallicFactor:s=1,roughnessFactor:i=1}=t;n.uniforms.metallicRoughnessValues=[s,i]}function zr(e,t,n,r){t&&(Hr(t)&&(n.defines.USE_MATERIAL_EXTENSIONS=!0),Ur(e,t.KHR_materials_specular,n,r),Br(t.KHR_materials_ior,n),Dr(e,t.KHR_materials_transmission,n,r),qr(e,t.KHR_materials_volume,n,r),Vr(e,t.KHR_materials_clearcoat,n,r),Kr(e,t.KHR_materials_sheen,n,r),$r(e,t.KHR_materials_iridescence,n,r),Wr(e,t.KHR_materials_anisotropy,n,r),Yr(t.KHR_materials_emissive_strength,n))}function Hr(e){return Boolean(e.KHR_materials_specular||e.KHR_materials_ior||e.KHR_materials_transmission||e.KHR_materials_volume||e.KHR_materials_clearcoat||e.KHR_materials_sheen||e.KHR_materials_iridescence||e.KHR_materials_anisotropy)}function Ur(e,t,n,r){t&&(t.specularColorFactor&&(n.uniforms.specularColorFactor=t.specularColorFactor),t.specularFactor!==void 0&&(n.uniforms.specularIntensityFactor=t.specularFactor),t.specularColorTexture&&w(e,t.specularColorTexture,"pbr_specularColorSampler",n,{featureOptions:{define:"HAS_SPECULARCOLORMAP",enabledUniformName:"specularColorMapEnabled"},gltf:r}),t.specularTexture&&w(e,t.specularTexture,"pbr_specularIntensitySampler",n,{featureOptions:{define:"HAS_SPECULARINTENSITYMAP",enabledUniformName:"specularIntensityMapEnabled"},gltf:r}))}function Br(e,t){e?.ior!==void 0&&(t.uniforms.ior=e.ior)}function Dr(e,t,n,r){t&&(t.transmissionFactor!==void 0&&(n.uniforms.transmissionFactor=t.transmissionFactor),t.transmissionTexture&&w(e,t.transmissionTexture,"pbr_transmissionSampler",n,{featureOptions:{define:"HAS_TRANSMISSIONMAP",enabledUniformName:"transmissionMapEnabled"},gltf:r}),((t.transmissionFactor??0)>0||t.transmissionTexture)&&(N.log.warn("KHR_materials_transmission uses a premultiplied-alpha blending approximation and may require mesh sorting")(),kr(n)))}function qr(e,t,n,r){t&&(t.thicknessFactor!==void 0&&(n.uniforms.thicknessFactor=t.thicknessFactor),t.thicknessTexture&&w(e,t.thicknessTexture,"pbr_thicknessSampler",n,{featureOptions:{define:"HAS_THICKNESSMAP"},gltf:r}),t.attenuationDistance!==void 0&&(n.uniforms.attenuationDistance=t.attenuationDistance),t.attenuationColor&&(n.uniforms.attenuationColor=t.attenuationColor))}function Vr(e,t,n,r){t&&(t.clearcoatFactor!==void 0&&(n.uniforms.clearcoatFactor=t.clearcoatFactor),t.clearcoatRoughnessFactor!==void 0&&(n.uniforms.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor),t.clearcoatTexture&&w(e,t.clearcoatTexture,"pbr_clearcoatSampler",n,{featureOptions:{define:"HAS_CLEARCOATMAP",enabledUniformName:"clearcoatMapEnabled"},gltf:r}),t.clearcoatRoughnessTexture&&w(e,t.clearcoatRoughnessTexture,"pbr_clearcoatRoughnessSampler",n,{featureOptions:{define:"HAS_CLEARCOATROUGHNESSMAP",enabledUniformName:"clearcoatRoughnessMapEnabled"},gltf:r}),t.clearcoatNormalTexture&&w(e,t.clearcoatNormalTexture,"pbr_clearcoatNormalSampler",n,{featureOptions:{define:"HAS_CLEARCOATNORMALMAP"},gltf:r}))}function Kr(e,t,n,r){t&&(t.sheenColorFactor&&(n.uniforms.sheenColorFactor=t.sheenColorFactor),t.sheenRoughnessFactor!==void 0&&(n.uniforms.sheenRoughnessFactor=t.sheenRoughnessFactor),t.sheenColorTexture&&w(e,t.sheenColorTexture,"pbr_sheenColorSampler",n,{featureOptions:{define:"HAS_SHEENCOLORMAP",enabledUniformName:"sheenColorMapEnabled"},gltf:r}),t.sheenRoughnessTexture&&w(e,t.sheenRoughnessTexture,"pbr_sheenRoughnessSampler",n,{featureOptions:{define:"HAS_SHEENROUGHNESSMAP",enabledUniformName:"sheenRoughnessMapEnabled"},gltf:r}))}function $r(e,t,n,r){t&&(t.iridescenceFactor!==void 0&&(n.uniforms.iridescenceFactor=t.iridescenceFactor),t.iridescenceIor!==void 0&&(n.uniforms.iridescenceIor=t.iridescenceIor),(t.iridescenceThicknessMinimum!==void 0||t.iridescenceThicknessMaximum!==void 0)&&(n.uniforms.iridescenceThicknessRange=[t.iridescenceThicknessMinimum??100,t.iridescenceThicknessMaximum??400]),t.iridescenceTexture&&w(e,t.iridescenceTexture,"pbr_iridescenceSampler",n,{featureOptions:{define:"HAS_IRIDESCENCEMAP",enabledUniformName:"iridescenceMapEnabled"},gltf:r}),t.iridescenceThicknessTexture&&w(e,t.iridescenceThicknessTexture,"pbr_iridescenceThicknessSampler",n,{featureOptions:{define:"HAS_IRIDESCENCETHICKNESSMAP"},gltf:r}))}function Wr(e,t,n,r){t&&(t.anisotropyStrength!==void 0&&(n.uniforms.anisotropyStrength=t.anisotropyStrength),t.anisotropyRotation!==void 0&&(n.uniforms.anisotropyRotation=t.anisotropyRotation),t.anisotropyTexture&&w(e,t.anisotropyTexture,"pbr_anisotropySampler",n,{featureOptions:{define:"HAS_ANISOTROPYMAP",enabledUniformName:"anisotropyMapEnabled"},gltf:r}))}function Yr(e,t){e?.emissiveStrength!==void 0&&(t.uniforms.emissiveStrength=e.emissiveStrength)}function w(e,t,n,r,s={}){let{featureOptions:i={},gltf:o}=s,{define:c,enabledUniformName:a}=i,l=Gr(t,o),h=l.texture?.source?.image;if(!h){N.log.warn(`Skipping unresolved glTF texture for ${String(n)}`)();return}let f={wrapS:10497,wrapT:10497,minFilter:9729,magFilter:9729,...l?.texture?.sampler},p={id:l.uniformName||l.id,sampler:_e(f)},m;if(h.compressed)m=jr(e,h,p);else{let{width:d,height:x}=e.getExternalImageSize(h);m=e.createTexture({...p,width:d,height:x,data:h})}r.bindings[n]=m,c&&(r.defines[c]=!0),a&&(r.uniforms[a]=!0),r.generatedTextures.push(m)}function Gr(e,t){if(e.texture||e.index===void 0||!t?.textures)return e;let n=t.textures[e.index];return n?"texture"in n&&n.texture?{...n,...e,texture:n.texture}:"source"in n?{...e,texture:n}:e:e}function Dt(e,t){return e.createTexture({...t,format:"rgba8unorm",width:1,height:1,mipLevels:1})}function Re(e){return e.textureFormat}function Xr(e,t,n){let{blockWidth:r=1,blockHeight:s=1}=N.textureFormatDecoder.getInfo(n),i=1;for(let o=1;;o++){let c=Math.max(1,e>>o),a=Math.max(1,t>>o);if(c<r||a<s)break;i++}return i}function jr(e,t,n){let r;if(Array.isArray(t.data)&&t.data[0]?.data?r=t.data:"mipmaps"in t&&Array.isArray(t.mipmaps)?r=t.mipmaps:r=[],r.length===0||!r[0]?.data)return N.log.warn("createCompressedTexture: compressed image has no valid mip levels, creating fallback")(),Dt(e,n);let s=r[0],i=s.width??t.width??0,o=s.height??t.height??0;if(i<=0||o<=0)return N.log.warn("createCompressedTexture: base level has invalid dimensions, creating fallback")(),Dt(e,n);let c=Re(s);if(!c)return N.log.warn("createCompressedTexture: compressed image has no textureFormat, creating fallback")(),Dt(e,n);let a=Xr(i,o,c),l=Math.min(r.length,a),h=1;for(let p=1;p<l;p++){let m=r[p];if(!m.data||m.width<=0||m.height<=0){N.log.warn(`createCompressedTexture: mip level ${p} has invalid data/dimensions, truncating`)();break}let d=Re(m);if(d&&d!==c){N.log.warn(`createCompressedTexture: mip level ${p} format '${d}' differs from base '${c}', truncating`)();break}let x=Math.max(1,i>>p),u=Math.max(1,o>>p);if(m.width!==x||m.height!==u){N.log.warn(`createCompressedTexture: mip level ${p} dimensions ${m.width}x${m.height} don't match expected ${x}x${u}, truncating`)();break}h++}let f=e.createTexture({...n,format:c,usage:N.Texture.TEXTURE|N.Texture.COPY_DST,width:i,height:o,mipLevels:h,data:s.data});for(let p=1;p<h;p++)f.writeData(r[p].data,{width:r[p].width,height:r[p].height,mipLevel:p});return f}var ro=1/Math.PI*180,so=1/180*Math.PI,Jr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Jr}};var L=globalThis.mathgl.config;function Se(e,{precision:t=L.precision}={}){return e=Qr(e),`${parseFloat(e.toPrecision(t))}`}function Y(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function qt(e,t,n){let r=L.EPSILON;n&&(L.EPSILON=n);try{if(e===t)return!0;if(Y(e)&&Y(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!qt(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=L.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{L.EPSILON=r}}function Qr(e){return Math.round(e/L.EPSILON)*L.EPSILON}var V=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Y(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(L)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Se(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!qt(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(L.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function Zr(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function R(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function G(e,t,n=""){if(L.debug&&!Zr(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Vt(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Tt=class extends V{get x(){return this[0]}set x(t){this[0]=R(t)}get y(){return this[1]}set y(t){this[1]=R(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return R(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return R(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Vt(t>=0&&t<this.ELEMENTS,"index is out of range"),R(this[t])}setComponent(t,n){return Vt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var O=typeof Float32Array<"u"?Float32Array:Array;var uo=Math.PI/180;function ts(){let e=new O(2);return O!=Float32Array&&(e[0]=0,e[1]=0),e}function Le(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var go=function(){let e=ts();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function Oe(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function Ie(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Pe(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function be(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function Kt(){let e=new O(3);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function es(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function $t(e,t,n){let r=new O(3);return r[0]=e,r[1]=t,r[2]=n,r}function ve(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Fe(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function At(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function Et(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function ke(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],l=t[2],h=s*l-i*a,f=i*c-r*l,p=r*a-s*c,m=s*p-i*f,d=i*h-r*p,x=r*f-s*h,u=o*2;return h*=u,f*=u,p*=u,m*=2,d*=2,x*=2,e[0]=c+h+m,e[1]=a+f+d,e[2]=l+p+x,e}var Ce=es;var Ao=function(){let e=Kt();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var yt,X=class extends Tt{static get ZERO(){return yt||(yt=new X(0,0,0,0),Object.freeze(yt)),yt}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),Y(t)&&arguments.length===1?this.copy(t):(L.debug&&(R(t),R(n),R(r),R(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return L.debug&&(R(t.x),R(t.y),R(t.z),R(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]=R(t)}get w(){return this[3]}set w(t){this[3]=R(t)}transform(t){return Et(this,this,t),this.check()}transformByMatrix3(t){return be(this,this,t),this.check()}transformByMatrix2(t){return Pe(this,this,t),this.check()}transformByQuaternion(t){return ke(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var _t=class extends V{toString(){let t="[";if(L.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=R(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function ze(){let e=new O(9);return O!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function ss(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function He(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Ue(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],l=t[7],h=t[8],f=t[9],p=t[10],m=t[11],d=t[12],x=t[13],u=t[14],E=t[15],S=n*c-r*o,g=n*a-s*o,M=n*l-i*o,T=r*a-s*c,A=r*l-i*c,I=s*l-i*a,P=h*x-f*d,b=h*u-p*d,v=h*E-m*d,k=f*u-p*x,C=f*E-m*x,z=p*E-m*u,_=S*z-g*C+M*k+T*v-A*b+I*P;return _?(_=1/_,e[0]=(c*z-a*C+l*k)*_,e[1]=(s*C-r*z-i*k)*_,e[2]=(x*I-u*A+E*T)*_,e[3]=(p*A-f*I-m*T)*_,e[4]=(a*v-o*z-l*b)*_,e[5]=(n*z-s*v+i*b)*_,e[6]=(u*M-d*I-E*g)*_,e[7]=(h*I-p*M+m*g)*_,e[8]=(o*C-c*v+l*P)*_,e[9]=(r*v-n*C-i*P)*_,e[10]=(d*A-x*M+E*S)*_,e[11]=(f*M-h*A-m*S)*_,e[12]=(c*b-o*k-a*P)*_,e[13]=(n*k-r*b+s*P)*_,e[14]=(x*g-d*T-u*S)*_,e[15]=(h*T-f*g+p*S)*_,e):null}function Be(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],l=e[8],h=e[9],f=e[10],p=e[11],m=e[12],d=e[13],x=e[14],u=e[15],E=t*o-n*i,S=t*c-r*i,g=n*c-r*o,M=l*d-h*m,T=l*x-f*m,A=h*x-f*d,I=t*A-n*T+r*M,P=i*A-o*T+c*M,b=l*g-h*S+f*E,v=m*g-d*S+x*E;return a*I-s*P+u*b-p*v}function Wt(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],l=t[6],h=t[7],f=t[8],p=t[9],m=t[10],d=t[11],x=t[12],u=t[13],E=t[14],S=t[15],g=n[0],M=n[1],T=n[2],A=n[3];return e[0]=g*r+M*c+T*f+A*x,e[1]=g*s+M*a+T*p+A*u,e[2]=g*i+M*l+T*m+A*E,e[3]=g*o+M*h+T*d+A*S,g=n[4],M=n[5],T=n[6],A=n[7],e[4]=g*r+M*c+T*f+A*x,e[5]=g*s+M*a+T*p+A*u,e[6]=g*i+M*l+T*m+A*E,e[7]=g*o+M*h+T*d+A*S,g=n[8],M=n[9],T=n[10],A=n[11],e[8]=g*r+M*c+T*f+A*x,e[9]=g*s+M*a+T*p+A*u,e[10]=g*i+M*l+T*m+A*E,e[11]=g*o+M*h+T*d+A*S,g=n[12],M=n[13],T=n[14],A=n[15],e[12]=g*r+M*c+T*f+A*x,e[13]=g*s+M*a+T*p+A*u,e[14]=g*i+M*l+T*m+A*E,e[15]=g*o+M*h+T*d+A*S,e}function De(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,l,h,f,p,m,d,x,u,E;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],l=t[3],h=t[4],f=t[5],p=t[6],m=t[7],d=t[8],x=t[9],u=t[10],E=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=l,e[4]=h,e[5]=f,e[6]=p,e[7]=m,e[8]=d,e[9]=x,e[10]=u,e[11]=E,e[12]=o*r+h*s+d*i+t[12],e[13]=c*r+f*s+x*i+t[13],e[14]=a*r+p*s+u*i+t[14],e[15]=l*r+m*s+E*i+t[15]),e}function qe(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ve(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,l,h,f,p,m,d,x,u,E,S,g,M,T,A,I,P,b,v,k,C,z,_,Q;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,l=Math.sin(n),a=Math.cos(n),h=1-a,f=t[0],p=t[1],m=t[2],d=t[3],x=t[4],u=t[5],E=t[6],S=t[7],g=t[8],M=t[9],T=t[10],A=t[11],I=s*s*h+a,P=i*s*h+o*l,b=o*s*h-i*l,v=s*i*h-o*l,k=i*i*h+a,C=o*i*h+s*l,z=s*o*h+i*l,_=i*o*h-s*l,Q=o*o*h+a,e[0]=f*I+x*P+g*b,e[1]=p*I+u*P+M*b,e[2]=m*I+E*P+T*b,e[3]=d*I+S*P+A*b,e[4]=f*v+x*k+g*C,e[5]=p*v+u*k+M*C,e[6]=m*v+E*k+T*C,e[7]=d*v+S*k+A*C,e[8]=f*z+x*_+g*Q,e[9]=p*z+u*_+M*Q,e[10]=m*z+E*_+T*Q,e[11]=d*z+S*_+A*Q,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Ke(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],l=t[8],h=t[9],f=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+l*r,e[5]=o*s+h*r,e[6]=c*s+f*r,e[7]=a*s+p*r,e[8]=l*s-i*r,e[9]=h*s-o*r,e[10]=f*s-c*r,e[11]=p*s-a*r,e}function $e(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],l=t[8],h=t[9],f=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-l*r,e[1]=o*s-h*r,e[2]=c*s-f*r,e[3]=a*s-p*r,e[8]=i*r+l*s,e[9]=o*r+h*s,e[10]=c*r+f*s,e[11]=a*r+p*s,e}function We(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],l=t[4],h=t[5],f=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+l*r,e[1]=o*s+h*r,e[2]=c*s+f*r,e[3]=a*s+p*r,e[4]=l*s-i*r,e[5]=h*s-o*r,e[6]=f*s-c*r,e[7]=p*s-a*r,e}function Ye(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,l=n*o,h=r*o,f=r*c,p=s*o,m=s*c,d=s*a,x=i*o,u=i*c,E=i*a;return e[0]=1-f-d,e[1]=h+E,e[2]=p-u,e[3]=0,e[4]=h-E,e[5]=1-l-d,e[6]=m+x,e[7]=0,e[8]=p+u,e[9]=m-x,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ge(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),l=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*l,e[15]=0,e}function is(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var Xe=is;function os(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),l=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*l,e[15]=1,e}var je=os;function Je(e,t,n,r){let s,i,o,c,a,l,h,f,p,m,d=t[0],x=t[1],u=t[2],E=r[0],S=r[1],g=r[2],M=n[0],T=n[1],A=n[2];return Math.abs(d-M)<1e-6&&Math.abs(x-T)<1e-6&&Math.abs(u-A)<1e-6?ss(e):(f=d-M,p=x-T,m=u-A,s=1/Math.sqrt(f*f+p*p+m*m),f*=s,p*=s,m*=s,i=S*m-g*p,o=g*f-E*m,c=E*p-S*f,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-m*o,l=m*i-f*c,h=f*o-p*i,s=Math.sqrt(a*a+l*l+h*h),s?(s=1/s,a*=s,l*=s,h*=s):(a=0,l=0,h=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=l,e[6]=p,e[7]=0,e[8]=c,e[9]=h,e[10]=m,e[11]=0,e[12]=-(i*d+o*x+c*u),e[13]=-(a*d+l*x+h*u),e[14]=-(f*d+p*x+m*u),e[15]=1,e)}function cs(){let e=new O(4);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Qe(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function Ze(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function tn(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function en(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function nn(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function rn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function sn(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function on(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function cn(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],l=n[3],h=l*r+c*i-a*s,f=l*s+a*r-o*i,p=l*i+o*s-c*r,m=-o*r-c*s-a*i;return e[0]=h*l+m*-o+f*-a-p*-c,e[1]=f*l+m*-c+p*-o-h*-a,e[2]=p*l+m*-a+h*-c-f*-o,e[3]=t[3],e}var bo=function(){let e=cs();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var Xt;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Xt||(Xt={}));var ls=45*Math.PI/180,fs=1,Yt=.1,Gt=500,ps=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),B=class extends _t{static get IDENTITY(){return ms()}static get ZERO(){return hs()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Xt}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,l,h,f,p,m,d,x,u){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=l,this[9]=h,this[10]=f,this[11]=p,this[12]=m,this[13]=d,this[14]=x,this[15]=u,this.check()}setRowMajor(t,n,r,s,i,o,c,a,l,h,f,p,m,d,x,u){return this[0]=t,this[1]=i,this[2]=l,this[3]=m,this[4]=n,this[5]=o,this[6]=h,this[7]=d,this[8]=r,this[9]=c,this[10]=f,this[11]=x,this[12]=s,this[13]=a,this[14]=p,this[15]=u,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(ps)}fromObject(t){return this.check()}fromQuaternion(t){return Ye(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=Yt,far:c=Gt}=t;return c===1/0?ds(this,n,r,s,i,o):Ge(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return Je(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=Yt,far:c=Gt}=t;return je(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=ls,aspect:r=fs,focalDistance:s=1,near:i=Yt,far:o=Gt}=t;an(n);let c=n/2,a=s*Math.tan(c),l=a*r;return this.ortho({left:-l,right:l,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return an(n),Xe(this,n,r,s,i),this.check()}determinant(){return Be(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return He(this,this),this.check()}invert(){return Ue(this,this),this.check()}multiplyLeft(t){return Wt(this,t,this),this.check()}multiplyRight(t){return Wt(this,this,t),this.check()}rotateX(t){return Ke(this,this,t),this.check()}rotateY(t){return $e(this,this,t),this.check()}rotateZ(t){return We(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return Ve(this,this,t,n),this.check()}scale(t){return qe(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return De(this,this,t),this.check()}transform(t,n){return t.length===4?(n=on(n||[-0,-0,-0,-0],t,this),G(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=Le(n||[-0,-0],t,this);break;case 3:s=Et(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return G(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=Oe(n||[-0,-0],t,this);break;case 3:r=Ie(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return G(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},Rt,St;function hs(){return Rt||(Rt=new B([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Rt)),Rt}function ms(){return St||(St=new B,Object.freeze(St)),St}function an(e){if(e>Math.PI*2)throw Error("expected radians")}function ds(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),l=(s+r)/(s-r),h=-1,f=-1,p=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=l,e[10]=h,e[11]=f,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}function ln(){let e=new O(4);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function fn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function jt(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function Jt(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],l=n[2],h=n[3];return e[0]=r*h+o*c+s*l-i*a,e[1]=s*h+o*a+i*c-r*l,e[2]=i*h+o*l+r*a-s*c,e[3]=o*h-r*c-s*a-i*l,e}function pn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*c,e[1]=s*a+i*c,e[2]=i*a-s*c,e[3]=o*a-r*c,e}function hn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-i*c,e[1]=s*a+o*c,e[2]=i*a+r*c,e[3]=o*a-s*c,e}function mn(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function dn(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function it(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],l=n[1],h=n[2],f=n[3],p,m,d,x,u;return p=s*a+i*l+o*h+c*f,p<0&&(p=-p,a=-a,l=-l,h=-h,f=-f),1-p>1e-6?(m=Math.acos(p),u=Math.sin(m),d=Math.sin((1-r)*m)/u,x=Math.sin(r*m)/u):(d=1-r,x=r),e[0]=d*s+x*a,e[1]=d*i+x*l,e[2]=d*o+x*h,e[3]=d*c+x*f,e}function xn(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function un(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Qt(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var gn=Qe;var Mn=Ze,Tn=rn,An=sn,En=tn;var yn=en;var _n=nn;var Rn=function(){let e=Kt(),t=$t(1,0,0),n=$t(0,1,0);return function(r,s,i){let o=Fe(s,i);return o<-.999999?(At(e,t,s),Ce(e)<1e-6&&At(e,n,s),ve(e,e),jt(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(At(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,_n(r,r))}}(),Wo=function(){let e=ln(),t=ln();return function(n,r,s,i,o,c){return it(e,r,o,c),it(t,s,i,c),it(n,e,t,2*c*(1-c)),n}}(),Yo=function(){let e=ze();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],_n(t,Qt(t,e))}}();var xs=[0,0,0,1],ot=class extends V{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Qt(this,t),this.check()}fromAxisRotation(t,n){return jt(this,t,n),this.check()}identity(){return fn(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=R(t)}get y(){return this[1]}set y(t){this[1]=R(t)}get z(){return this[2]}set z(t){this[2]=R(t)}get w(){return this[3]}set w(t){this[3]=R(t)}len(){return En(this)}lengthSquared(){return yn(this)}dot(t){return Tn(this,t)}rotationTo(t,n){return Rn(this,t,n),this.check()}add(t){return gn(this,this,t),this.check()}calculateW(){return dn(this,this),this.check()}conjugate(){return un(this,this),this.check()}invert(){return xn(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(An(this,t,n,r),this.check())}multiplyRight(t){return Jt(this,this,t),this.check()}multiplyLeft(t){return Jt(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return pn(this,this,t),this.check()}rotateY(t){return hn(this,this,t),this.check()}rotateZ(t){return mn(this,this,t),this.check()}scale(t){return Mn(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=xs,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return it(this,s,i,o),this.check()}transformVector4(t,n=new X){return cn(n,t,this),G(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var us=255;function Nt(e){let t=e.lights||e.extensions?.KHR_lights_punctual?.lights;if(!t||!Array.isArray(t)||t.length===0)return[];let n=[],r=Es(e.nodes||[]),s=new Map;for(let i of e.nodes||[]){let o=i.light??i.extensions?.KHR_lights_punctual?.light;if(typeof o!="number")continue;let c=t[o];if(!c)continue;let a=gs(c.color||[1,1,1]),l=c.intensity??1,h=c.range,f=Sn(i,r,s);switch(c.type){case"directional":n.push(Ts(f,a,l));break;case"point":n.push(Ms(f,a,l,h));break;case"spot":n.push(As(f,a,l,h,c.spot));break;default:break}}return n}function gs(e){return e.map(t=>t*us)}function Ms(e,t,n,r){let s=Nn(e),i=[1,0,0];return r!==void 0&&r>0&&(i=[1,0,1/(r*r)]),{type:"point",position:s,color:t,intensity:n,attenuation:i}}function Ts(e,t,n){return{type:"directional",direction:wn(e),color:t,intensity:n}}function As(e,t,n,r,s={}){let i=Nn(e),o=wn(e),c=[1,0,0];return r!==void 0&&r>0&&(c=[1,0,1/(r*r)]),{type:"spot",position:i,direction:o,color:t,intensity:n,attenuation:c,innerConeAngle:s.innerConeAngle??0,outerConeAngle:s.outerConeAngle??Math.PI/4}}function Es(e){let t=new Map;for(let n of e)for(let r of n.children||[])t.set(r.id,n);return t}function Sn(e,t,n){let r=n.get(e.id);if(r)return r;let s=ys(e),i=t.get(e.id),o=i?new B(Sn(i,t,n)).multiplyRight(s):s;return n.set(e.id,o),o}function ys(e){if(e.matrix)return new B(e.matrix);let t=new B;return e.translation&&t.translate(e.translation),e.rotation&&t.multiplyRight(new B().fromQuaternion(e.rotation)),e.scale&&t.scale(e.scale),t}function Nn(e){return e.transformAsPoint([0,0,0])}function wn(e){return e.transformDirection([0,0,-1])}var K=F(Z(),1),vn=F(Zt(),1);function On(e){switch(e){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(e))}}var D=F($(),1),In=F(Z(),1),ct=F(Zt(),1),j=F(Z(),1),_s=`
8
8
  struct VertexInputs {
9
9
  @location(0) positions: vec3f,
10
10
  #ifdef HAS_NORMALS
@@ -87,7 +87,7 @@ fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {
87
87
  #endif
88
88
  return pbr_filterColor(vec4f(1.0));
89
89
  }
90
- `,Jr=`#version 300 es
90
+ `,Rs=`#version 300 es
91
91
 
92
92
  // in vec4 POSITION;
93
93
  in vec4 positions;
@@ -140,13 +140,13 @@ fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {
140
140
  pbr_setPositionNormalTangentUV(pos, _NORMAL, _TANGENT, _TEXCOORD_0);
141
141
  gl_Position = pbrProjection.modelViewProjectionMatrix * pos;
142
142
  }
143
- `,Zr=`#version 300 es
143
+ `,Ss=`#version 300 es
144
144
  out vec4 fragmentColor;
145
145
 
146
146
  void main(void) {
147
147
  vec3 pos = pbr_vPosition;
148
148
  fragmentColor = pbr_filterColor(vec4(1.0));
149
149
  }
150
- `;function Ln(e,t){let{id:n,geometry:r,parsedPPBRMaterial:s,vertexCount:i,modelOptions:o={}}=t;Nn.log.info(4,"createGLTFModel defines: ",s.defines)();let c=[],a={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},f={id:n,source:Kr,vs:Jr,fs:Zr,geometry:r,topology:r.topology,vertexCount:i,modules:[ut.pbrMaterial,ut.skin],...o,defines:{...s.defines,...o.defines},parameters:{...a,...s.parameters,...o.parameters}},h=new Nt.Model(e,f),{camera:l,...p}={...s.uniforms,...o.uniforms,...s.bindings,...o.bindings};return h.shaderInputs.setProps({pbrMaterial:p,pbrProjection:{camera:l}}),new Nt.ModelNode({managedResources:c,model:h})}var Qr={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1};function Rn(e,t,n={}){let r={...Qr,...n},s=new Map;t.meshes.forEach((a,f)=>{let h=es(e,a,r);s.set(a.id,h)});let i=new Map,o=new Map;return t.nodes.forEach((a,f)=>{let h=ts(e,a,r);i.set(f,h),o.set(a.id,h)}),t.nodes.forEach((a,f)=>{if(i.get(f).add((a.children??[]).map(({id:h})=>{let l=o.get(h);if(!l)throw new Error(`Cannot find child ${h} of node ${f}`);return l})),a.mesh){let h=s.get(a.mesh.id);if(!h)throw new Error(`Cannot find mesh child ${a.mesh.id} of node ${f}`);i.get(f).add(h)}}),{scenes:t.scenes.map(a=>{let f=(a.nodes||[]).map(({id:h})=>{let l=o.get(h);if(!l)throw new Error(`Cannot find child ${h} of scene ${a.name||a.id}`);return l});return new H.GroupNode({id:a.name||a.id,children:f})}),gltfMeshIdToNodeMap:s,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:i}}function ts(e,t,n){return new H.GroupNode({id:t.name||t.id,children:[],matrix:t.matrix,position:t.translation,rotation:t.rotation,scale:t.scale})}function es(e,t,n){let s=(t.primitives||[]).map((o,c)=>ns(e,o,c,t,n));return new H.GroupNode({id:t.name||t.id,children:s})}function ns(e,t,n,r,s){let i=t.name||`${r.name||r.id}-primitive-${n}`,o=wn(t.mode||4),c=t.indices?t.indices.count:rs(t.attributes),a=On(i,t,o),f=dt(e,t.material,a.attributes,s),h=Ln(e,{id:i,geometry:On(i,t,o),parsedPPBRMaterial:f,modelOptions:s.modelOptions,vertexCount:c});return h.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],h}function rs(e){throw new Error("getVertexCount not implemented")}function On(e,t,n){let r={};for(let[s,i]of Object.entries(t.attributes)){let{components:o,size:c,value:a}=i;r[s]={size:c??o,value:a}}return new H.Geometry({id:e,topology:n,indices:t.indices.value,attributes:r})}var Pn=z($(),1);var Kt=z($(),1);function Lt(e,t,n){switch(t){case"translation":return e.setPosition(n).updateMatrix();case"rotation":return e.setRotation(n).updateMatrix();case"scale":return e.setScale(n).updateMatrix();default:return Kt.log.warn(`Bad animation path ${t}`)(),null}}function In(e,{input:t,interpolation:n,output:r},s,i){let o=t[t.length-1],c=e%o,a=t.findIndex(p=>p>=c),f=Math.max(0,a-1),h=t[f],l=t[a];switch(n){case"STEP":os(s,i,r[f]);break;case"LINEAR":if(l>h){let p=(c-h)/(l-h);ss(s,i,r[f],r[a],p)}break;case"CUBICSPLINE":if(l>h){let p=(c-h)/(l-h),m=l-h,x=r[3*f+1],d=r[3*f+2],M=r[3*a+0],E=r[3*a+1];is(s,i,{p0:x,outTangent0:d,inTangent1:M,p1:E,tDiff:m,ratio:p})}break;default:Kt.log.warn(`Interpolation ${n} not supported`)();break}}function ss(e,t,n,r,s){if(t==="rotation")Lt(e,t,new nt().slerp({start:n,target:r,ratio:s}));else{let i=[];for(let o=0;o<n.length;o++)i[o]=s*r[o]+(1-s)*n[o];Lt(e,t,i)}}function is(e,t,{p0:n,outTangent0:r,inTangent1:s,p1:i,tDiff:o,ratio:c}){let a=[];for(let f=0;f<n.length;f++){let h=r[f]*o,l=s[f]*o;a[f]=(2*Math.pow(c,3)-3*Math.pow(c,2)+1)*n[f]+(Math.pow(c,3)-2*Math.pow(c,2)+c)*h+(-2*Math.pow(c,3)+3*Math.pow(c,2))*i[f]+(Math.pow(c,3)-Math.pow(c,2))*l}Lt(e,t,a)}function os(e,t,n){Lt(e,t,n)}var Jt=class{animation;gltfNodeIdToNodeMap;startTime=0;playing=!0;speed=1;constructor(t){this.animation=t.animation,this.gltfNodeIdToNodeMap=t.gltfNodeIdToNodeMap,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,targetNodeId:i,path:o})=>{let c=this.gltfNodeIdToNodeMap.get(i);if(!c)throw new Error(`Cannot find animation target node ${i}`);In(r,s,c,o)})}},j=class{animations;constructor(t){this.animations=t.animations.map((n,r)=>{let s=n.name||`Animation-${r}`;return new Jt({gltfNodeIdToNodeMap:t.gltfNodeIdToNodeMap,animation:{name:s,channels:n.channels}})})}animate(t){Pn.log.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(t)}setTime(t){this.animations.forEach(n=>n.setTime(t))}getAnimations(){return this.animations}};var cs={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},as={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Zt(e){let t=as[e.componentType],n=cs[e.type],r=n*e.count,{buffer:s,byteOffset:i=0}=e.bufferView?.data??{};return{typedArray:new t(s,i+(e.byteOffset||0),r),components:n}}function _n(e){let t=e.animations||[],n=new Map,r=new Map;return t.map((s,i)=>{let o=s.name||`Animation-${i}`,c=s.samplers.map(({input:f,interpolation:h="LINEAR",output:l})=>({input:fs(e.accessors[f],n),interpolation:h,output:hs(e.accessors[l],r)})),a=s.channels.map(({sampler:f,target:h})=>{let l=e.nodes[h.node??0];if(!l)throw new Error(`Cannot find animation target ${h.node}`);return{sampler:c[f],targetNodeId:l.id,path:h.path}});return{name:o,channels:a}})}function fs(e,t){if(t.has(e))return t.get(e);let{typedArray:n,components:r}=Zt(e);vn(r===1,"accessorToJsArray1D must have exactly 1 component");let s=Array.from(n);return t.set(e,s),s}function hs(e,t){if(t.has(e))return t.get(e);let{typedArray:n,components:r}=Zt(e);vn(r>1,"accessorToJsArray2D must have more than 1 component");let s=[];for(let i=0;i<n.length;i+=r)s.push(Array.from(n.slice(i,i+r)));return t.set(e,s),s}function vn(e,t){if(!e)throw new Error(t)}function bn(e,t,n){let{scenes:r,gltfMeshIdToNodeMap:s,gltfNodeIdToNodeMap:i,gltfNodeIndexToNodeMap:o}=Rn(e,t,n),c=_n(t),a=new j({animations:c,gltfNodeIdToNodeMap:i}),f=St(t);return{scenes:r,animator:a,lights:f,gltfMeshIdToNodeMap:s,gltfNodeIdToNodeMap:i,gltfNodeIndexToNodeMap:o,gltf:t}}return Vn(rt);})();
150
+ `;function te(e,t){let n=t.materialFactory||new j.MaterialFactory(e,{modules:[ct.pbrMaterial]}),r={...t.parsedPPBRMaterial.uniforms};delete r.camera;let s=Object.fromEntries(Object.entries({...r,...t.parsedPPBRMaterial.bindings}).filter(([o,c])=>n.ownsBinding(o)&&Ns(c))),i=n.createMaterial({id:t.id,bindings:s});return i.setProps({pbrMaterial:r}),i}function Pn(e,t){let{id:n,geometry:r,parsedPPBRMaterial:s,vertexCount:i,modelOptions:o={}}=t;D.log.info(4,"createGLTFModel defines: ",s.defines)();let c=[],a={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},l={id:n,source:_s,vs:Rs,fs:Ss,geometry:r,topology:r.topology,vertexCount:i,modules:[ct.pbrMaterial,ct.skin],...o,defines:{...s.defines,...o.defines},parameters:{...a,...s.parameters,...o.parameters}},h=t.material||te(e,{id:n?`${n}-material`:void 0,parsedPPBRMaterial:s});l.material=h;let f=new j.Model(e,l),p={...s.uniforms,...o.uniforms,...s.bindings,...o.bindings},m=ws(f.shaderInputs.getModules(),h,p);return f.shaderInputs.setProps(m),new j.ModelNode({managedResources:c,model:f})}function Ns(e){return e instanceof D.Buffer||e instanceof In.DynamicTexture||e instanceof D.Sampler||e instanceof D.Texture||e instanceof D.TextureView}function ws(e,t,n){let r=new Map;for(let i of e){for(let o of Object.keys(i.uniformTypes||{}))r.set(o,i.name);for(let o of i.bindingLayout||[])r.set(o.name,i.name)}let s={};for(let[i,o]of Object.entries(n)){if(o===void 0)continue;let c=r.get(i);!c||t.ownsModule(c)||(s[c]||={},s[c][i]=o)}return s}var Ls={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1};function Fn(e,t,n={}){let r={...Ls,...n},s=new K.MaterialFactory(e,{modules:[vn.pbrMaterial]}),i=(t.materials||[]).map((f,p)=>te(e,{id:vs(f,p),parsedPPBRMaterial:rt(e,f,{},{...r,gltf:t,validateAttributes:!1}),materialFactory:s})),o=new Map;(t.materials||[]).forEach((f,p)=>{o.set(f.id,i[p])});let c=new Map;t.meshes.forEach((f,p)=>{let m=Is(e,f,t,o,r);c.set(f.id,m)});let a=new Map,l=new Map;return t.nodes.forEach((f,p)=>{let m=Os(e,f,r);a.set(p,m),l.set(f.id,m)}),t.nodes.forEach((f,p)=>{if(a.get(p).add((f.children??[]).map(({id:m})=>{let d=l.get(m);if(!d)throw new Error(`Cannot find child ${m} of node ${p}`);return d})),f.mesh){let m=c.get(f.mesh.id);if(!m)throw new Error(`Cannot find mesh child ${f.mesh.id} of node ${p}`);a.get(p).add(m)}}),{scenes:t.scenes.map(f=>{let p=(f.nodes||[]).map(({id:m})=>{let d=l.get(m);if(!d)throw new Error(`Cannot find child ${m} of scene ${f.name||f.id}`);return d});return new K.GroupNode({id:f.name||f.id,children:p})}),materials:i,gltfMeshIdToNodeMap:c,gltfNodeIdToNodeMap:l,gltfNodeIndexToNodeMap:a}}function Os(e,t,n){return new K.GroupNode({id:t.name||t.id,children:[],matrix:t.matrix,position:t.translation,rotation:t.rotation,scale:t.scale})}function Is(e,t,n,r,s){let o=(t.primitives||[]).map((a,l)=>Ps({device:e,gltfPrimitive:a,primitiveIndex:l,gltfMesh:t,gltf:n,gltfMaterialIdToMaterialMap:r,options:s}));return new K.GroupNode({id:t.name||t.id,children:o})}function Ps({device:e,gltfPrimitive:t,primitiveIndex:n,gltfMesh:r,gltf:s,gltfMaterialIdToMaterialMap:i,options:o}){let c=t.name||`${r.name||r.id}-primitive-${n}`,a=On(t.mode||4),l=t.indices?t.indices.count:bs(t.attributes),h=bn(c,t,a),f=rt(e,t.material,h.attributes,{...o,gltf:s}),p=Pn(e,{id:c,geometry:bn(c,t,a),material:t.material&&i.get(t.material.id)||null,parsedPPBRMaterial:f,modelOptions:o.modelOptions,vertexCount:l});return p.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],p}function bs(e){throw new Error("getVertexCount not implemented")}function bn(e,t,n){let r={};for(let[s,i]of Object.entries(t.attributes)){let{components:o,size:c,value:a}=i;r[s]={size:c??o,value:a}}return new K.Geometry({id:e,topology:n,indices:t.indices.value,attributes:r})}function vs(e,t){return e.name||e.id||`material-${t}`}var Cn=F($(),1);var ee=F($(),1);function wt(e,t,n){switch(t){case"translation":return e.setPosition(n).updateMatrix();case"rotation":return e.setRotation(n).updateMatrix();case"scale":return e.setScale(n).updateMatrix();default:return ee.log.warn(`Bad animation path ${t}`)(),null}}function kn(e,{input:t,interpolation:n,output:r},s,i){let o=t[t.length-1],c=e%o,a=t.findIndex(p=>p>=c),l=Math.max(0,a-1),h=t[l],f=t[a];switch(n){case"STEP":Cs(s,i,r[l]);break;case"LINEAR":if(f>h){let p=(c-h)/(f-h);Fs(s,i,r[l],r[a],p)}break;case"CUBICSPLINE":if(f>h){let p=(c-h)/(f-h),m=f-h,d=r[3*l+1],x=r[3*l+2],u=r[3*a+0],E=r[3*a+1];ks(s,i,{p0:d,outTangent0:x,inTangent1:u,p1:E,tDiff:m,ratio:p})}break;default:ee.log.warn(`Interpolation ${n} not supported`)();break}}function Fs(e,t,n,r,s){if(t==="rotation")wt(e,t,new ot().slerp({start:n,target:r,ratio:s}));else{let i=[];for(let o=0;o<n.length;o++)i[o]=s*r[o]+(1-s)*n[o];wt(e,t,i)}}function ks(e,t,{p0:n,outTangent0:r,inTangent1:s,p1:i,tDiff:o,ratio:c}){let a=[];for(let l=0;l<n.length;l++){let h=r[l]*o,f=s[l]*o;a[l]=(2*Math.pow(c,3)-3*Math.pow(c,2)+1)*n[l]+(Math.pow(c,3)-2*Math.pow(c,2)+c)*h+(-2*Math.pow(c,3)+3*Math.pow(c,2))*i[l]+(Math.pow(c,3)-Math.pow(c,2))*f}wt(e,t,a)}function Cs(e,t,n){wt(e,t,n)}var ne=class{animation;gltfNodeIdToNodeMap;startTime=0;playing=!0;speed=1;constructor(t){this.animation=t.animation,this.gltfNodeIdToNodeMap=t.gltfNodeIdToNodeMap,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,targetNodeId:i,path:o})=>{let c=this.gltfNodeIdToNodeMap.get(i);if(!c)throw new Error(`Cannot find animation target node ${i}`);kn(r,s,c,o)})}},J=class{animations;constructor(t){this.animations=t.animations.map((n,r)=>{let s=n.name||`Animation-${r}`;return new ne({gltfNodeIdToNodeMap:t.gltfNodeIdToNodeMap,animation:{name:s,channels:n.channels}})})}animate(t){Cn.log.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(t)}setTime(t){this.animations.forEach(n=>n.setTime(t))}getAnimations(){return this.animations}};var zn=F($(),1);var zs={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function re(e){let t=Hs[e.componentType],n=zs[e.type],r=n*e.count,{buffer:s,byteOffset:i=0}=e.bufferView?.data??{};return{typedArray:new t(s,i+(e.byteOffset||0),r),components:n}}function Hn(e){let t=e.animations||[],n=new Map,r=new Map;return t.flatMap((s,i)=>{let o=s.name||`Animation-${i}`,c=new Map,a=s.channels.flatMap(({sampler:l,target:h})=>{let f=Us(h.path);if(!f)return[];let p=e.nodes[h.node??0];if(!p)throw new Error(`Cannot find animation target ${h.node}`);let m=c.get(l);if(!m){let d=s.samplers[l];if(!d)throw new Error(`Cannot find animation sampler ${l}`);let{input:x,interpolation:u="LINEAR",output:E}=d;m={input:Bs(e.accessors[x],n),interpolation:u,output:Ds(e.accessors[E],r)},c.set(l,m)}return{sampler:m,targetNodeId:p.id,path:f}});return a.length?[{name:o,channels:a}]:[]})}function Us(e){return e==="pointer"?(zn.log.warn("KHR_animation_pointer channels are not supported and will be skipped")(),null):e}function Bs(e,t){if(t.has(e))return t.get(e);let{typedArray:n,components:r}=re(e);Un(r===1,"accessorToJsArray1D must have exactly 1 component");let s=Array.from(n);return t.set(e,s),s}function Ds(e,t){if(t.has(e))return t.get(e);let{typedArray:n,components:r}=re(e);Un(r>=1,"accessorToJsArray2D must have at least 1 component");let s=[];for(let i=0;i<n.length;i+=r)s.push(Array.from(n.slice(i,i+r)));return t.set(e,s),s}function Un(e,t){if(!e)throw new Error(t)}var qs={supportLevel:"none",comment:"Not currently listed in the luma.gl glTF extension support registry."},Vs={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:"none",comment:"Animation pointers are not mapped onto runtime scenegraph updates."},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 Ot(e){let n=Array.from(Ks(e)).sort().map(r=>{let s=Vs[r]||qs;return[r,{extensionName:r,supported:s.supportLevel==="built-in",supportLevel:s.supportLevel,comment:s.comment}]});return new Map(n)}function Ks(e){let t=e,n=new Set;return Lt(n,e.extensionsUsed),Lt(n,e.extensionsRequired),Lt(n,t.extensionsRemoved),Lt(n,Object.keys(e.extensions||{})),(t.lights?.length||e.nodes.some(r=>"light"in r))&&n.add("KHR_lights_punctual"),e.materials.some(r=>{let s=r;return s.unlit||s.extensions?.KHR_materials_unlit})&&n.add("KHR_materials_unlit"),n}function Lt(e,t=[]){for(let n of t)e.add(n)}function Bn(e,t,n){let{scenes:r,materials:s,gltfMeshIdToNodeMap:i,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:c}=Fn(e,t,n),a=Hn(t),l=new J({animations:a,gltfNodeIdToNodeMap:o}),h=Nt(t),f=Ot(t),p=r.map(d=>Dn(d.getBounds())),m=$s(p);return{scenes:r,materials:s,animator:l,lights:h,extensionSupport:f,sceneBounds:p,modelBounds:m,gltfMeshIdToNodeMap:i,gltfNodeIdToNodeMap:o,gltfNodeIndexToNodeMap:c,gltf:t}}function Dn(e){if(!e)return{bounds:null,center:[0,0,0],size:[0,0,0],radius:.5,recommendedOrbitDistance:1};let t=[[e[0][0],e[0][1],e[0][2]],[e[1][0],e[1][1],e[1][2]]],n=[t[1][0]-t[0][0],t[1][1]-t[0][1],t[1][2]-t[0][2]],r=[t[0][0]+n[0]*.5,t[0][1]+n[1]*.5,t[0][2]+n[2]*.5],s=Math.max(n[0],n[1],n[2])*.5,i=Math.max(.5*Math.hypot(n[0],n[1],n[2]),.001);return{bounds:t,center:r,size:n,radius:i,recommendedOrbitDistance:Math.max(Math.max(s,.001)/Math.tan(Math.PI/6)*1.15,i*1.1)}}function $s(e){let t=null;for(let n of e)if(n.bounds){if(!t){t=[[...n.bounds[0]],[...n.bounds[1]]];continue}for(let r=0;r<3;r++)t[0][r]=Math.min(t[0][r],n.bounds[0][r]),t[1][r]=Math.max(t[1][r],n.bounds[1][r])}return Dn(t)}return Gn(at);})();
151
151
  return __exports__;
152
152
  });
@@ -1,5 +1,5 @@
1
1
  import { Device } from '@luma.gl/core';
2
- import { Geometry, ModelNode, type ModelProps } from '@luma.gl/engine';
2
+ import { Geometry, Material, MaterialFactory, ModelNode, type ModelProps } from '@luma.gl/engine';
3
3
  import { type ParsedPBRMaterial } from "../pbr/pbr-material.js";
4
4
  /** Options used to instantiate a `ModelNode` for one glTF primitive. */
5
5
  export type CreateGLTFModelOptions = {
@@ -11,9 +11,17 @@ export type CreateGLTFModelOptions = {
11
11
  geometry: Geometry;
12
12
  /** Parsed PBR material state for the primitive. */
13
13
  parsedPPBRMaterial: ParsedPBRMaterial;
14
+ /** Pre-created material aligned with the source glTF material entry, when available. */
15
+ material?: Material | null;
14
16
  /** Additional model props merged into the generated model. */
15
17
  modelOptions?: Partial<ModelProps>;
16
18
  };
19
+ export type CreateGLTFMaterialOptions = {
20
+ id?: string;
21
+ parsedPPBRMaterial: ParsedPBRMaterial;
22
+ materialFactory?: MaterialFactory;
23
+ };
24
+ export declare function createGLTFMaterial(device: Device, options: CreateGLTFMaterialOptions): Material;
17
25
  /** Creates a luma.gl Model from GLTF data*/
18
26
  export declare function createGLTFModel(device: Device, options: CreateGLTFModelOptions): ModelNode;
19
27
  //# sourceMappingURL=create-gltf-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-gltf-model.d.ts","sourceRoot":"","sources":["../../src/gltf/create-gltf-model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAqC,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAC,QAAQ,EAAS,SAAS,EAAE,KAAK,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAC,KAAK,iBAAiB,EAAC,+BAA4B;AA2J3D,wEAAwE;AACxE,MAAM,MAAM,sBAAsB,GAAG;IACnC,mDAAmD;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,EAAE,QAAQ,CAAC;IACnB,mDAAmD;IACnD,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,8DAA8D;IAC9D,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF,4CAA4C;AAC5C,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,SAAS,CA6C1F"}
1
+ {"version":3,"file":"create-gltf-model.d.ts","sourceRoot":"","sources":["../../src/gltf/create-gltf-model.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,MAAM,EAOP,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,eAAe,EAEf,SAAS,EACT,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,KAAK,iBAAiB,EAAC,+BAA4B;AA2J3D,wEAAwE;AACxE,MAAM,MAAM,sBAAsB,GAAG;IACnC,mDAAmD;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,EAAE,QAAQ,CAAC;IACnB,mDAAmD;IACnD,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,wFAAwF;IACxF,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,QAAQ,CAsB/F;AAED,4CAA4C;AAC5C,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAyD1F"}
@@ -1,9 +1,10 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { log } from '@luma.gl/core';
4
+ import { Buffer, Sampler, Texture, TextureView, log } from '@luma.gl/core';
5
+ import { DynamicTexture } from '@luma.gl/engine';
5
6
  import { pbrMaterial, skin } from '@luma.gl/shadertools';
6
- import { Model, ModelNode } from '@luma.gl/engine';
7
+ import { MaterialFactory, Model, ModelNode } from '@luma.gl/engine';
7
8
  const SHADER = /* WGSL */ `
8
9
  struct VertexInputs {
9
10
  @location(0) positions: vec3f,
@@ -154,6 +155,21 @@ const fs = /* glsl */ `\
154
155
  fragmentColor = pbr_filterColor(vec4(1.0));
155
156
  }
156
157
  `;
158
+ export function createGLTFMaterial(device, options) {
159
+ const materialFactory = options.materialFactory || new MaterialFactory(device, { modules: [pbrMaterial] });
160
+ const pbrMaterialProps = { ...options.parsedPPBRMaterial.uniforms };
161
+ delete pbrMaterialProps.camera;
162
+ const materialBindings = Object.fromEntries(Object.entries({
163
+ ...pbrMaterialProps,
164
+ ...options.parsedPPBRMaterial.bindings
165
+ }).filter(([name, value]) => materialFactory.ownsBinding(name) && isMaterialBindingResource(value)));
166
+ const material = materialFactory.createMaterial({
167
+ id: options.id,
168
+ bindings: materialBindings
169
+ });
170
+ material.setProps({ pbrMaterial: pbrMaterialProps });
171
+ return material;
172
+ }
157
173
  /** Creates a luma.gl Model from GLTF data*/
158
174
  export function createGLTFModel(device, options) {
159
175
  const { id, geometry, parsedPPBRMaterial, vertexCount, modelOptions = {} } = options;
@@ -183,14 +199,52 @@ export function createGLTFModel(device, options) {
183
199
  defines: { ...parsedPPBRMaterial.defines, ...modelOptions.defines },
184
200
  parameters: { ...parameters, ...parsedPPBRMaterial.parameters, ...modelOptions.parameters }
185
201
  };
202
+ const material = options.material ||
203
+ createGLTFMaterial(device, {
204
+ id: id ? `${id}-material` : undefined,
205
+ parsedPPBRMaterial
206
+ });
207
+ modelProps.material = material;
186
208
  const model = new Model(device, modelProps);
187
- const { camera, ...pbrMaterialProps } = {
209
+ const sceneShaderInputValues = {
188
210
  ...parsedPPBRMaterial.uniforms,
189
211
  ...modelOptions.uniforms,
190
212
  ...parsedPPBRMaterial.bindings,
191
213
  ...modelOptions.bindings
192
214
  };
193
- model.shaderInputs.setProps({ pbrMaterial: pbrMaterialProps, pbrProjection: { camera } });
215
+ const sceneShaderInputProps = getSceneShaderInputProps(model.shaderInputs.getModules(), material, sceneShaderInputValues);
216
+ model.shaderInputs.setProps(sceneShaderInputProps);
194
217
  return new ModelNode({ managedResources, model });
195
218
  }
219
+ function isMaterialBindingResource(value) {
220
+ return (value instanceof Buffer ||
221
+ value instanceof DynamicTexture ||
222
+ value instanceof Sampler ||
223
+ value instanceof Texture ||
224
+ value instanceof TextureView);
225
+ }
226
+ function getSceneShaderInputProps(modules, material, shaderInputValues) {
227
+ const propertyToModuleNameMap = new Map();
228
+ for (const module of modules) {
229
+ for (const uniformName of Object.keys(module.uniformTypes || {})) {
230
+ propertyToModuleNameMap.set(uniformName, module.name);
231
+ }
232
+ for (const binding of module.bindingLayout || []) {
233
+ propertyToModuleNameMap.set(binding.name, module.name);
234
+ }
235
+ }
236
+ const sceneShaderInputProps = {};
237
+ for (const [propertyName, value] of Object.entries(shaderInputValues)) {
238
+ if (value === undefined) {
239
+ continue;
240
+ }
241
+ const moduleName = propertyToModuleNameMap.get(propertyName);
242
+ if (!moduleName || material.ownsModule(moduleName)) {
243
+ continue;
244
+ }
245
+ sceneShaderInputProps[moduleName] ||= {};
246
+ sceneShaderInputProps[moduleName][propertyName] = value;
247
+ }
248
+ return sceneShaderInputProps;
249
+ }
196
250
  //# sourceMappingURL=create-gltf-model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-gltf-model.js","sourceRoot":"","sources":["../../src/gltf/create-gltf-model.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAwC,GAAG,EAAC,MAAM,eAAe,CAAC;AACzE,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAW,KAAK,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AAG5E,MAAM,MAAM,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AqB,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC;IAC1D,CAAC;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
@@ -1,17 +1,38 @@
1
1
  import { Device } from '@luma.gl/core';
2
- import { GroupNode } from '@luma.gl/engine';
2
+ import { GroupNode, Material } from '@luma.gl/engine';
3
3
  import { GLTFPostprocessed } from '@loaders.gl/gltf';
4
4
  import { Light } from '@luma.gl/shadertools';
5
5
  import { type ParseGLTFOptions } from "../parsers/parse-gltf.js";
6
6
  import { GLTFAnimator } from "./gltf-animator.js";
7
+ import { type GLTFExtensionSupport } from "./gltf-extension-support.js";
8
+ export type GLTFScenegraphBounds = {
9
+ /** World-space axis-aligned bounds for the scene or model. */
10
+ bounds: [[number, number, number], [number, number, number]] | null;
11
+ /** World-space center of the bounds. */
12
+ center: [number, number, number];
13
+ /** World-space bounds size on each axis. */
14
+ size: [number, number, number];
15
+ /** Half of the world-space bounds diagonal, clamped to a small practical minimum. */
16
+ radius: number;
17
+ /** Suggested orbit distance for a 60-degree field of view camera. */
18
+ recommendedOrbitDistance: number;
19
+ };
7
20
  /** Scenegraph bundle returned from a parsed glTF asset. */
8
21
  export type GLTFScenegraphs = {
9
22
  /** Scene roots produced from the glTF scenes array. */
10
23
  scenes: GroupNode[];
24
+ /** Materials aligned with the source glTF `materials` array. */
25
+ materials: Material[];
11
26
  /** Animation controller for glTF animations. */
12
27
  animator: GLTFAnimator;
13
28
  /** Parsed punctual lights from the asset. */
14
29
  lights: Light[];
30
+ /** Extensions reported by the asset and whether luma.gl supports them. */
31
+ extensionSupport: Map<string, GLTFExtensionSupport>;
32
+ /** Camera-friendly bounds for each scene in `scenes`, in matching order. */
33
+ sceneBounds: GLTFScenegraphBounds[];
34
+ /** Combined camera-friendly bounds for the entire loaded asset. */
35
+ modelBounds: GLTFScenegraphBounds;
15
36
  /** Map from glTF mesh ids to generated mesh group nodes. */
16
37
  gltfMeshIdToNodeMap: Map<string, GroupNode>;
17
38
  /** Map from glTF node indices to generated scenegraph nodes. */
@@ -1 +1 @@
1
- {"version":3,"file":"create-scenegraph-from-gltf.d.ts","sourceRoot":"","sources":["../../src/gltf/create-scenegraph-from-gltf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAY,KAAK,gBAAgB,EAAC,iCAA8B;AAEvE,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAG7C,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG;IAC5B,uDAAuD;IACvD,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,gDAAgD;IAChD,QAAQ,EAAE,YAAY,CAAC;IACvB,6CAA6C;IAC7C,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB,4DAA4D;IAC5D,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5C,gEAAgE;IAChE,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC/C,4DAA4D;IAC5D,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAE5C,6CAA6C;IAC7C,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,gGAAgG;AAChG,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAoBjB"}
1
+ {"version":3,"file":"create-scenegraph-from-gltf.d.ts","sourceRoot":"","sources":["../../src/gltf/create-scenegraph-from-gltf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAC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MAAM,EAAE,SAAS,CAAC,CAAC;IAC5C,gEAAgE;IAChE,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC/C,4DAA4D;IAC5D,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAE5C,6CAA6C;IAC7C,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,gGAAgG;AAChG,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,gBAAgB,GACzB,eAAe,CAwBjB"}
@@ -5,20 +5,82 @@ import { parseGLTF } from "../parsers/parse-gltf.js";
5
5
  import { parseGLTFLights } from "../parsers/parse-gltf-lights.js";
6
6
  import { GLTFAnimator } from "./gltf-animator.js";
7
7
  import { parseGLTFAnimations } from "../parsers/parse-gltf-animations.js";
8
+ import { getGLTFExtensionSupport } from "./gltf-extension-support.js";
8
9
  /** Converts a post-processed glTF asset into luma.gl scenegraph nodes and animation helpers. */
9
10
  export function createScenegraphsFromGLTF(device, gltf, options) {
10
- const { scenes, gltfMeshIdToNodeMap, gltfNodeIdToNodeMap, gltfNodeIndexToNodeMap } = parseGLTF(device, gltf, options);
11
+ const { scenes, materials, gltfMeshIdToNodeMap, gltfNodeIdToNodeMap, gltfNodeIndexToNodeMap } = parseGLTF(device, gltf, options);
11
12
  const animations = parseGLTFAnimations(gltf);
12
13
  const animator = new GLTFAnimator({ animations, gltfNodeIdToNodeMap });
13
14
  const lights = parseGLTFLights(gltf);
15
+ const extensionSupport = getGLTFExtensionSupport(gltf);
16
+ const sceneBounds = scenes.map(scene => getScenegraphBounds(scene.getBounds()));
17
+ const modelBounds = getCombinedScenegraphBounds(sceneBounds);
14
18
  return {
15
19
  scenes,
20
+ materials,
16
21
  animator,
17
22
  lights,
23
+ extensionSupport,
24
+ sceneBounds,
25
+ modelBounds,
18
26
  gltfMeshIdToNodeMap,
19
27
  gltfNodeIdToNodeMap,
20
28
  gltfNodeIndexToNodeMap,
21
29
  gltf
22
30
  };
23
31
  }
32
+ function getScenegraphBounds(bounds) {
33
+ if (!bounds) {
34
+ return {
35
+ bounds: null,
36
+ center: [0, 0, 0],
37
+ size: [0, 0, 0],
38
+ radius: 0.5,
39
+ recommendedOrbitDistance: 1
40
+ };
41
+ }
42
+ const normalizedBounds = [
43
+ [bounds[0][0], bounds[0][1], bounds[0][2]],
44
+ [bounds[1][0], bounds[1][1], bounds[1][2]]
45
+ ];
46
+ const size = [
47
+ normalizedBounds[1][0] - normalizedBounds[0][0],
48
+ normalizedBounds[1][1] - normalizedBounds[0][1],
49
+ normalizedBounds[1][2] - normalizedBounds[0][2]
50
+ ];
51
+ const center = [
52
+ normalizedBounds[0][0] + size[0] * 0.5,
53
+ normalizedBounds[0][1] + size[1] * 0.5,
54
+ normalizedBounds[0][2] + size[2] * 0.5
55
+ ];
56
+ const maxHalfExtent = Math.max(size[0], size[1], size[2]) * 0.5;
57
+ const radius = Math.max(0.5 * Math.hypot(size[0], size[1], size[2]), 0.001);
58
+ return {
59
+ bounds: normalizedBounds,
60
+ center,
61
+ size,
62
+ radius,
63
+ recommendedOrbitDistance: Math.max((Math.max(maxHalfExtent, 0.001) / Math.tan(Math.PI / 6)) * 1.15, radius * 1.1)
64
+ };
65
+ }
66
+ function getCombinedScenegraphBounds(sceneBounds) {
67
+ let combinedBounds = null;
68
+ for (const sceneBoundInfo of sceneBounds) {
69
+ if (!sceneBoundInfo.bounds) {
70
+ continue;
71
+ }
72
+ if (!combinedBounds) {
73
+ combinedBounds = [
74
+ [...sceneBoundInfo.bounds[0]],
75
+ [...sceneBoundInfo.bounds[1]]
76
+ ];
77
+ continue;
78
+ }
79
+ for (let axis = 0; axis < 3; axis++) {
80
+ combinedBounds[0][axis] = Math.min(combinedBounds[0][axis], sceneBoundInfo.bounds[0][axis]);
81
+ combinedBounds[1][axis] = Math.max(combinedBounds[1][axis], sceneBoundInfo.bounds[1][axis]);
82
+ }
83
+ }
84
+ return getScenegraphBounds(combinedBounds);
85
+ }
24
86
  //# sourceMappingURL=create-scenegraph-from-gltf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-scenegraph-from-gltf.js","sourceRoot":"","sources":["../../src/gltf/create-scenegraph-from-gltf.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAMpC,OAAO,EAAC,SAAS,EAAwB,iCAA8B;AACvE,OAAO,EAAC,eAAe,EAAC,wCAAqC;AAC7D,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,mBAAmB,EAAC,4CAAyC;AAsBrE,gGAAgG;AAChG,MAAM,UAAU,yBAAyB,CACvC,MAAc,EACd,IAAuB,EACvB,OAA0B;IAE1B,MAAM,EAAC,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,sBAAsB,EAAC,GAAG,SAAS,CAC1F,MAAM,EACN,IAAI,EACJ,OAAO,CACR,CAAC;IAEF,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,EAAC,UAAU,EAAE,mBAAmB,EAAC,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO;QACL,MAAM;QACN,QAAQ;QACR,MAAM;QACN,mBAAmB;QACnB,mBAAmB;QACnB,sBAAsB;QACtB,IAAI;KACL,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"create-scenegraph-from-gltf.js","sourceRoot":"","sources":["../../src/gltf/create-scenegraph-from-gltf.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAMpC,OAAO,EAAC,SAAS,EAAwB,iCAA8B;AACvE,OAAO,EAAC,eAAe,EAAC,wCAAqC;AAC7D,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAC7C,OAAO,EAAC,mBAAmB,EA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M,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { GLTFPostprocessed } from '@loaders.gl/gltf';
2
+ export type GLTFExtensionSupportLevel = 'built-in' | 'parsed-and-wired' | 'loader-only' | 'none';
3
+ export type GLTFExtensionSupport = {
4
+ extensionName: string;
5
+ supported: boolean;
6
+ supportLevel: GLTFExtensionSupportLevel;
7
+ comment: string;
8
+ };
9
+ export declare function getGLTFExtensionSupport(gltf: GLTFPostprocessed): Map<string, GLTFExtensionSupport>;
10
+ //# sourceMappingURL=gltf-extension-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltf-extension-support.d.ts","sourceRoot":"","sources":["../../src/gltf/gltf-extension-support.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG,kBAAkB,GAAG,aAAa,GAAG,MAAM,CAAC;AAEjG,MAAM,MAAM,oBAAoB,GAAG;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,yBAAyB,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmJF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,iBAAiB,GACtB,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAoBnC"}