tangram-core 0.2.0__cp313-cp313-win_amd64.whl

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 (171) hide show
  1. tangram_core/App.vue +335 -0
  2. tangram_core/__init__.py +5 -0
  3. tangram_core/__main__.py +141 -0
  4. tangram_core/_core.cp313-win_amd64.pyd +0 -0
  5. tangram_core/_core.pyi +38 -0
  6. tangram_core/api.ts +456 -0
  7. tangram_core/backend.py +335 -0
  8. tangram_core/colour.ts +71 -0
  9. tangram_core/config.py +122 -0
  10. tangram_core/dist-frontend/aggregation-layers.js +521 -0
  11. tangram_core/dist-frontend/aggregation-layers.js.map +1 -0
  12. tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js +2 -0
  13. tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js.map +1 -0
  14. tangram_core/dist-frontend/assets/array-utils-flat-wyE8tIYR.js +11 -0
  15. tangram_core/dist-frontend/assets/array-utils-flat-wyE8tIYR.js.map +1 -0
  16. tangram_core/dist-frontend/assets/assert-hrfsarFU.js +3 -0
  17. tangram_core/dist-frontend/assets/assert-hrfsarFU.js.map +1 -0
  18. tangram_core/dist-frontend/assets/b612-latin-400-italic-DePNXA0a.woff +0 -0
  19. tangram_core/dist-frontend/assets/b612-latin-400-italic-a-4GLPtl.woff2 +0 -0
  20. tangram_core/dist-frontend/assets/b612-latin-400-normal-CC98FVm_.woff2 +0 -0
  21. tangram_core/dist-frontend/assets/b612-latin-400-normal-JbZ7xwUX.woff +0 -0
  22. tangram_core/dist-frontend/assets/b612-latin-700-normal-B_Snq1wd.woff +0 -0
  23. tangram_core/dist-frontend/assets/b612-latin-700-normal-BinQrnoB.woff2 +0 -0
  24. tangram_core/dist-frontend/assets/clip-extension-DTCP51Ak.js +26 -0
  25. tangram_core/dist-frontend/assets/clip-extension-DTCP51Ak.js.map +1 -0
  26. tangram_core/dist-frontend/assets/color-CUNNsFV-.js +17 -0
  27. tangram_core/dist-frontend/assets/color-CUNNsFV-.js.map +1 -0
  28. tangram_core/dist-frontend/assets/cube-geometry-CzJ_uBWa.js +2 -0
  29. tangram_core/dist-frontend/assets/cube-geometry-CzJ_uBWa.js.map +1 -0
  30. tangram_core/dist-frontend/assets/deep-equal-uriyKJca.js +2 -0
  31. tangram_core/dist-frontend/assets/deep-equal-uriyKJca.js.map +1 -0
  32. tangram_core/dist-frontend/assets/fly-to-interpolator-DlKiy9_S.js +2 -0
  33. tangram_core/dist-frontend/assets/fly-to-interpolator-DlKiy9_S.js.map +1 -0
  34. tangram_core/dist-frontend/assets/geojson-layer-CLhXLxdI.js +1010 -0
  35. tangram_core/dist-frontend/assets/geojson-layer-CLhXLxdI.js.map +1 -0
  36. tangram_core/dist-frontend/assets/globe-view-DKhftlA1.js +94 -0
  37. tangram_core/dist-frontend/assets/globe-view-DKhftlA1.js.map +1 -0
  38. tangram_core/dist-frontend/assets/globe-viewport-CPES4D4P.js +2 -0
  39. tangram_core/dist-frontend/assets/globe-viewport-CPES4D4P.js.map +1 -0
  40. tangram_core/dist-frontend/assets/image-loader-ClbNCMXW.js +2 -0
  41. tangram_core/dist-frontend/assets/image-loader-ClbNCMXW.js.map +1 -0
  42. tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-DTZQ6lD6.woff2 +0 -0
  43. tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-HYADljCo.woff +0 -0
  44. tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-ByjKuJjN.woff2 +0 -0
  45. tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-DzgUY3Rl.woff +0 -0
  46. tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-BaHVOdFB.woff2 +0 -0
  47. tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-yvPjCxxx.woff +0 -0
  48. tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-D0Kpgs_9.woff2 +0 -0
  49. tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-Dlt-daqV.woff +0 -0
  50. tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-ByiM2lek.woff +0 -0
  51. tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-DfC_iMic.woff2 +0 -0
  52. tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DLCFFAUf.woff +0 -0
  53. tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DuasYmn8.woff2 +0 -0
  54. tangram_core/dist-frontend/assets/index-UPPakSLR.css +1 -0
  55. tangram_core/dist-frontend/assets/index-r8T0kY2p.js +821 -0
  56. tangram_core/dist-frontend/assets/index-r8T0kY2p.js.map +1 -0
  57. tangram_core/dist-frontend/assets/layer-DO63TrsS.js +555 -0
  58. tangram_core/dist-frontend/assets/layer-DO63TrsS.js.map +1 -0
  59. tangram_core/dist-frontend/assets/layer-extension-CZ3zsHuN.js +2 -0
  60. tangram_core/dist-frontend/assets/layer-extension-CZ3zsHuN.js.map +1 -0
  61. tangram_core/dist-frontend/assets/mesh-layers-BSECKarm.js +1123 -0
  62. tangram_core/dist-frontend/assets/mesh-layers-BSECKarm.js.map +1 -0
  63. tangram_core/dist-frontend/assets/orthographic-viewport-CzZmHDEZ.js +2 -0
  64. tangram_core/dist-frontend/assets/orthographic-viewport-CzZmHDEZ.js.map +1 -0
  65. tangram_core/dist-frontend/assets/pick-layers-pass-xhWsgZtf.js +2 -0
  66. tangram_core/dist-frontend/assets/pick-layers-pass-xhWsgZtf.js.map +1 -0
  67. tangram_core/dist-frontend/assets/project-CrvReKGW.js +760 -0
  68. tangram_core/dist-frontend/assets/project-CrvReKGW.js.map +1 -0
  69. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-4qS3_zkX.woff2 +0 -0
  70. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-CDK-EZBY.woff +0 -0
  71. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-Bgns473E.woff +0 -0
  72. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-_T2aQlWs.woff2 +0 -0
  73. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-CvEVpWxD.woff +0 -0
  74. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-s4PklZE0.woff2 +0 -0
  75. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-9RN-Z7cI.woff2 +0 -0
  76. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-BGMkBBYx.woff +0 -0
  77. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-C7erd-g8.woff +0 -0
  78. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-DR5R5TWx.woff2 +0 -0
  79. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-DGo1Ayjq.woff2 +0 -0
  80. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-WtM1l1qc.woff +0 -0
  81. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-C8FNIdXm.woff2 +0 -0
  82. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-TLDmfi3Q.woff +0 -0
  83. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CTXjXnze.woff2 +0 -0
  84. tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CWPRiRXS.woff +0 -0
  85. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-CR6qj4Z4.woff2 +0 -0
  86. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-DHRaIs10.woff +0 -0
  87. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-D5vBSIyg.woff2 +0 -0
  88. tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-FabMgVmk.woff +0 -0
  89. tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-BIN62cw9.woff +0 -0
  90. tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-Hsn-wDIp.woff2 +0 -0
  91. tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-89Up2Xly.woff +0 -0
  92. tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-DWMOA2VK.woff2 +0 -0
  93. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-D_BR-3LG.woff2 +0 -0
  94. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-om57GXsO.woff +0 -0
  95. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-BICmKrXV.woff2 +0 -0
  96. tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-D2e7XwB1.woff +0 -0
  97. tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-3p2daRJW.woff2 +0 -0
  98. tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-Dc9bsamC.woff +0 -0
  99. tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-BOl6B_hI.woff +0 -0
  100. tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-DRbp0YnP.woff2 +0 -0
  101. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-BXrkWnoY.woff +0 -0
  102. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-Bhem1d5z.woff2 +0 -0
  103. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-DT8nEsYA.woff +0 -0
  104. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-OHaX69iP.woff2 +0 -0
  105. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-CcSTXKtO.woff2 +0 -0
  106. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-JgPl2bDS.woff +0 -0
  107. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-B004qtqu.woff2 +0 -0
  108. tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-O6H_RRvN.woff +0 -0
  109. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-BwUYFJ2t.woff2 +0 -0
  110. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-DV8QogUk.woff +0 -0
  111. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-0o1laQ-g.woff2 +0 -0
  112. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-CPsdS8_S.woff +0 -0
  113. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-G9shSJ2z.woff +0 -0
  114. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-TFWhjk13.woff2 +0 -0
  115. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-BtNeb9D6.woff +0 -0
  116. tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-D35V1G0s.woff2 +0 -0
  117. tangram_core/dist-frontend/assets/shader-BJmsOfPx.js +843 -0
  118. tangram_core/dist-frontend/assets/shader-BJmsOfPx.js.map +1 -0
  119. tangram_core/dist-frontend/assets/solid-polygon-layer-DiarVGxh.js +392 -0
  120. tangram_core/dist-frontend/assets/solid-polygon-layer-DiarVGxh.js.map +1 -0
  121. tangram_core/dist-frontend/assets/tesselator-49Dw9L5A.js +2 -0
  122. tangram_core/dist-frontend/assets/tesselator-49Dw9L5A.js.map +1 -0
  123. tangram_core/dist-frontend/assets/webgl-developer-tools-CZl8qVFg.js +7 -0
  124. tangram_core/dist-frontend/assets/webgl-developer-tools-CZl8qVFg.js.map +1 -0
  125. tangram_core/dist-frontend/assets/webgl-device-BY0-CUP6.js +3 -0
  126. tangram_core/dist-frontend/assets/webgl-device-BY0-CUP6.js.map +1 -0
  127. tangram_core/dist-frontend/assets/widget-BbOeHGj0.js +2 -0
  128. tangram_core/dist-frontend/assets/widget-BbOeHGj0.js.map +1 -0
  129. tangram_core/dist-frontend/core.js +60 -0
  130. tangram_core/dist-frontend/core.js.map +1 -0
  131. tangram_core/dist-frontend/extensions.js +609 -0
  132. tangram_core/dist-frontend/extensions.js.map +1 -0
  133. tangram_core/dist-frontend/favicon.ico +0 -0
  134. tangram_core/dist-frontend/favicon.png +0 -0
  135. tangram_core/dist-frontend/font-awesome.min.css +4 -0
  136. tangram_core/dist-frontend/fonts/FontAwesome.otf +0 -0
  137. tangram_core/dist-frontend/fonts/fontawesome-webfont.eot +0 -0
  138. tangram_core/dist-frontend/fonts/fontawesome-webfont.svg +2671 -0
  139. tangram_core/dist-frontend/fonts/fontawesome-webfont.ttf +0 -0
  140. tangram_core/dist-frontend/fonts/fontawesome-webfont.woff +0 -0
  141. tangram_core/dist-frontend/fonts/fontawesome-webfont.woff2 +0 -0
  142. tangram_core/dist-frontend/geo-layers.js +115 -0
  143. tangram_core/dist-frontend/geo-layers.js.map +1 -0
  144. tangram_core/dist-frontend/index.html +38 -0
  145. tangram_core/dist-frontend/json.js +3 -0
  146. tangram_core/dist-frontend/json.js.map +1 -0
  147. tangram_core/dist-frontend/layers.js +268 -0
  148. tangram_core/dist-frontend/layers.js.map +1 -0
  149. tangram_core/dist-frontend/lit-html.js +7 -0
  150. tangram_core/dist-frontend/lit-html.js.map +1 -0
  151. tangram_core/dist-frontend/mapbox.js +2 -0
  152. tangram_core/dist-frontend/mapbox.js.map +1 -0
  153. tangram_core/dist-frontend/maplibre-gl.js +59 -0
  154. tangram_core/dist-frontend/maplibre-gl.js.map +1 -0
  155. tangram_core/dist-frontend/mesh-layers.js +2 -0
  156. tangram_core/dist-frontend/mesh-layers.js.map +1 -0
  157. tangram_core/dist-frontend/rs1090_wasm.js +813 -0
  158. tangram_core/dist-frontend/rs1090_wasm_bg.wasm +0 -0
  159. tangram_core/dist-frontend/vue.esm-browser.prod.js +13 -0
  160. tangram_core/dist-frontend/widgets.js +3 -0
  161. tangram_core/dist-frontend/widgets.js.map +1 -0
  162. tangram_core/main.ts +16 -0
  163. tangram_core/plugin.py +70 -0
  164. tangram_core/plugin.ts +41 -0
  165. tangram_core/redis.py +89 -0
  166. tangram_core/user.css +114 -0
  167. tangram_core/vite-plugin-tangram.mjs +88 -0
  168. tangram_core-0.2.0.dist-info/METADATA +37 -0
  169. tangram_core-0.2.0.dist-info/RECORD +171 -0
  170. tangram_core-0.2.0.dist-info/WHEEL +4 -0
  171. tangram_core-0.2.0.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,1123 @@
1
+ import{l as qt,c as $t,L as Bt,p as mt,h as en,d as ht,G as $}from"./layer-DO63TrsS.js";import{ap as tn,aq as nn,H as Je,ar as g,aC as sn,aD as pt,aE as rn,aF as on,aG as se,aH as an,aI as cn,au as ln,aJ as Ct,aK as fn,aL as un,aM as An,aN as dn,aO as Bn,e as mn,aP as hn,aQ as we,aB as pn,aR as Ae,d as Cn,aS as bn,aT as gn,aU as En,aV as In,aW as Mn,b as x,N as G,A as L,O as de,x as ee}from"./deep-equal-uriyKJca.js";import{T as Tn}from"./array-utils-flat-wyE8tIYR.js";import{u as yn,M as bt}from"./shader-BJmsOfPx.js";import{t as V,u as Fn,V as _n,v as Oe,a as K,i as Rn,s as gt}from"./webgl-developer-tools-CZl8qVFg.js";import{g as Gn,a as vn,I as Dn}from"./image-loader-ClbNCMXW.js";async function Et(t,e,n,s){return s._parse(t,e,n,s)}function Sn(t){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t)}function On(t){return globalThis.loaders?.modules?.[t]||null}const Be={};async function v(t,e=null,n={},s=null){return e&&(t=xn(t,e,n,s)),Be[t]=Be[t]||Ln(t),await Be[t]}function xn(t,e,n={},s=null){if(!n.useLocalLibraries&&t.startsWith("http"))return t;s=s||t;const r=n.modules||{};return r[s]?r[s]:V?n.CDN?(Fn(n.CDN.startsWith("http")),`${n.CDN}/${e}@${_n}/dist/libs/${s}`):Oe?`../src/libs/${s}`:`modules/${e}/src/libs/${s}`:`modules/${e}/dist/libs/${s}`}async function Ln(t){if(t.endsWith("wasm"))return await Pn(t);if(!V)try{const{requireFromFile:n}=globalThis.loaders||{};return await n?.(t)}catch(n){return console.error(n),null}if(Oe)return importScripts(t);const e=await Un(t);return Hn(e,t)}function Hn(t,e){if(!V){const{requireFromString:s}=globalThis.loaders||{};return s?.(t,e)}if(Oe)return eval.call(globalThis,t),null;const n=document.createElement("script");n.id=e;try{n.appendChild(document.createTextNode(t))}catch{n.text=t}return document.body.appendChild(n),null}async function Pn(t){const{readFileAsArrayBuffer:e}=globalThis.loaders||{};return V||!e||t.startsWith("http")?await(await fetch(t)).arrayBuffer():await e(t)}async function Un(t){const{readFileAsText:e}=globalThis.loaders||{};return V||!e||t.startsWith("http")?await(await fetch(t)).text():await e(t)}function Nn(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Ke(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Ke(t,0,e):""}function Ke(t,e,n){if(t.byteLength<=e+n)return"";const s=new DataView(t);let r="";for(let o=0;o<n;o++)r+=String.fromCharCode(s.getUint8(e+o));return r}function Jn(t){try{return JSON.parse(t)}catch{throw new Error(`Failed to parse JSON from data starting with "${Nn(t)}"`)}}function X(t,e){return K(t>=0),K(e>0),t+(e-1)&-4}function wn(t,e,n){let s;if(t instanceof ArrayBuffer)s=new Uint8Array(t);else{const r=t.byteOffset,o=t.byteLength;s=new Uint8Array(t.buffer||t.arrayBuffer,r,o)}return e.set(s,n),n+X(s.byteLength,4)}function Kn(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function It(t){let e=1/0,n=1/0,s=1/0,r=-1/0,o=-1/0,i=-1/0;const a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){const f=a[l],u=a[l+1],A=a[l+2];e=f<e?f:e,n=u<n?u:n,s=A<s?A:s,r=f>r?f:r,o=u>o?u:o,i=A>i?A:i}return[[e,n,s],[r,o,i]]}function jn(t,e,n){const s=Kn(e.value),r=n||Vn(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:s}]},nullable:!1,metadata:r}}function Vn(t){const e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}const me={};function Xn(t){if(me[t]===void 0){const e=Rn?Yn(t):Qn(t);me[t]=e}return me[t]}function Qn(t){const e=["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.imageFormatsNode||e;return!!globalThis.loaders?.parseImageNode&&n.includes(t)}function Yn(t){switch(t){case"image/avif":case"image/webp":return kn(t);default:return!0}}function kn(t){try{return document.createElement("canvas").toDataURL(t).indexOf(`data:${t}`)===0}catch{return!1}}let Y;class xe extends tn{static get ZERO(){return Y||(Y=new xe(0,0,0,0),Object.freeze(Y)),Y}constructor(e=0,n=0,s=0,r=0){super(-0,-0,-0,-0),nn(e)&&arguments.length===1?this.copy(e):(Je.debug&&(g(e),g(n),g(s),g(r)),this[0]=e,this[1]=n,this[2]=s,this[3]=r)}set(e,n,s,r){return this[0]=e,this[1]=n,this[2]=s,this[3]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Je.debug&&(g(e.x),g(e.y),g(e.z),g(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=g(e)}get w(){return this[3]}set w(e){this[3]=g(e)}transform(e){return sn(this,this,e),this.check()}transformByMatrix3(e){return pt(this,this,e),this.check()}transformByMatrix2(e){return rn(this,this,e),this.check()}transformByQuaternion(e){return on(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function zn(){const t=new se(9);return se!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function Wn(t,e){if(t===e){const n=e[1],s=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=s,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function Zn(t,e){const n=e[0],s=e[1],r=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=f*i-a*l,A=-f*o+a*c,d=l*o-i*c;let B=n*u+s*A+r*d;return B?(B=1/B,t[0]=u*B,t[1]=(-f*s+r*l)*B,t[2]=(a*s-r*i)*B,t[3]=A*B,t[4]=(f*n-r*c)*B,t[5]=(-a*n+r*o)*B,t[6]=d*B,t[7]=(-l*n+s*c)*B,t[8]=(i*n-s*o)*B,t):null}function qn(t){const e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*o-i*c)+n*(-l*r+i*a)+s*(c*r-o*a)}function je(t,e,n){const s=e[0],r=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],A=n[0],d=n[1],B=n[2],m=n[3],p=n[4],C=n[5],I=n[6],h=n[7],N=n[8];return t[0]=A*s+d*i+B*l,t[1]=A*r+d*a+B*f,t[2]=A*o+d*c+B*u,t[3]=m*s+p*i+C*l,t[4]=m*r+p*a+C*f,t[5]=m*o+p*c+C*u,t[6]=I*s+h*i+N*l,t[7]=I*r+h*a+N*f,t[8]=I*o+h*c+N*u,t}function $n(t,e,n){const s=e[0],r=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],A=n[0],d=n[1];return t[0]=s,t[1]=r,t[2]=o,t[3]=i,t[4]=a,t[5]=c,t[6]=A*s+d*i+l,t[7]=A*r+d*a+f,t[8]=A*o+d*c+u,t}function es(t,e,n){const s=e[0],r=e[1],o=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],u=e[8],A=Math.sin(n),d=Math.cos(n);return t[0]=d*s+A*i,t[1]=d*r+A*a,t[2]=d*o+A*c,t[3]=d*i-A*s,t[4]=d*a-A*r,t[5]=d*c-A*o,t[6]=l,t[7]=f,t[8]=u,t}function Ve(t,e,n){const s=n[0],r=n[1];return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=r*e[3],t[4]=r*e[4],t[5]=r*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ts(t,e){const n=e[0],s=e[1],r=e[2],o=e[3],i=n+n,a=s+s,c=r+r,l=n*i,f=s*i,u=s*a,A=r*i,d=r*a,B=r*c,m=o*i,p=o*a,C=o*c;return t[0]=1-u-B,t[3]=f-C,t[6]=A+p,t[1]=f+C,t[4]=1-l-B,t[7]=d-m,t[2]=A-p,t[5]=d+m,t[8]=1-l-u,t}var _e;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(_e||(_e={}));const ns=Object.freeze([1,0,0,0,1,0,0,0,1]);class Q extends an{static get IDENTITY(){return rs()}static get ZERO(){return ss()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return _e}constructor(e,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):n.length>0?this.copy([e,...n]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(ns)}fromObject(e){return this.check()}fromQuaternion(e){return ts(this,e),this.check()}set(e,n,s,r,o,i,a,c,l){return this[0]=e,this[1]=n,this[2]=s,this[3]=r,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,n,s,r,o,i,a,c,l){return this[0]=e,this[1]=r,this[2]=a,this[3]=n,this[4]=o,this[5]=c,this[6]=s,this[7]=i,this[8]=l,this.check()}determinant(){return qn(this)}transpose(){return Wn(this,this),this.check()}invert(){return Zn(this,this),this.check()}multiplyLeft(e){return je(this,e,this),this.check()}multiplyRight(e){return je(this,this,e),this.check()}rotate(e){return es(this,this,e),this.check()}scale(e){return Array.isArray(e)?Ve(this,this,e):Ve(this,this,[e,e]),this.check()}translate(e){return $n(this,this,e),this.check()}transform(e,n){let s;switch(e.length){case 2:s=ln(n||[-0,-0],e,this);break;case 3:s=cn(n||[-0,-0,-0],e,this);break;case 4:s=pt(n||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ct(s,e.length),s}transformVector(e,n){return this.transform(e,n)}transformVector2(e,n){return this.transform(e,n)}transformVector3(e,n){return this.transform(e,n)}}let k,z=null;function ss(){return k||(k=new Q([0,0,0,0,0,0,0,0,0]),Object.freeze(k)),k}function rs(){return z||(z=new Q,Object.freeze(z)),z}function Xe(){const t=new se(4);return se!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function os(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Mt(t,e,n){n=n*.5;const s=Math.sin(n);return t[0]=s*e[0],t[1]=s*e[1],t[2]=s*e[2],t[3]=Math.cos(n),t}function Qe(t,e,n){const s=e[0],r=e[1],o=e[2],i=e[3],a=n[0],c=n[1],l=n[2],f=n[3];return t[0]=s*f+i*a+r*l-o*c,t[1]=r*f+i*c+o*a-s*l,t[2]=o*f+i*l+s*c-r*a,t[3]=i*f-s*a-r*c-o*l,t}function is(t,e,n){n*=.5;const s=e[0],r=e[1],o=e[2],i=e[3],a=Math.sin(n),c=Math.cos(n);return t[0]=s*c+i*a,t[1]=r*c+o*a,t[2]=o*c-r*a,t[3]=i*c-s*a,t}function as(t,e,n){n*=.5;const s=e[0],r=e[1],o=e[2],i=e[3],a=Math.sin(n),c=Math.cos(n);return t[0]=s*c-o*a,t[1]=r*c+i*a,t[2]=o*c+s*a,t[3]=i*c-r*a,t}function cs(t,e,n){n*=.5;const s=e[0],r=e[1],o=e[2],i=e[3],a=Math.sin(n),c=Math.cos(n);return t[0]=s*c+r*a,t[1]=r*c-s*a,t[2]=o*c+i*a,t[3]=i*c-o*a,t}function ls(t,e){const n=e[0],s=e[1],r=e[2];return t[0]=n,t[1]=s,t[2]=r,t[3]=Math.sqrt(Math.abs(1-n*n-s*s-r*r)),t}function te(t,e,n,s){const r=e[0],o=e[1],i=e[2],a=e[3];let c=n[0],l=n[1],f=n[2],u=n[3],A,d,B,m,p;return A=r*c+o*l+i*f+a*u,A<0&&(A=-A,c=-c,l=-l,f=-f,u=-u),1-A>En?(d=Math.acos(A),p=Math.sin(d),B=Math.sin((1-s)*d)/p,m=Math.sin(s*d)/p):(B=1-s,m=s),t[0]=B*r+m*c,t[1]=B*o+m*l,t[2]=B*i+m*f,t[3]=B*a+m*u,t}function fs(t,e){const n=e[0],s=e[1],r=e[2],o=e[3],i=n*n+s*s+r*r+o*o,a=i?1/i:0;return t[0]=-n*a,t[1]=-s*a,t[2]=-r*a,t[3]=o*a,t}function us(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function Tt(t,e){const n=e[0]+e[4]+e[8];let s;if(n>0)s=Math.sqrt(n+1),t[3]=.5*s,s=.5/s,t[0]=(e[5]-e[7])*s,t[1]=(e[6]-e[2])*s,t[2]=(e[1]-e[3])*s;else{let r=0;e[4]>e[0]&&(r=1),e[8]>e[r*3+r]&&(r=2);const o=(r+1)%3,i=(r+2)%3;s=Math.sqrt(e[r*3+r]-e[o*3+o]-e[i*3+i]+1),t[r]=.5*s,s=.5/s,t[3]=(e[o*3+i]-e[i*3+o])*s,t[o]=(e[o*3+r]+e[r*3+o])*s,t[i]=(e[i*3+r]+e[r*3+i])*s}return t}const As=dn,ds=mn,Bs=An,ms=Bn,hs=fn,ps=un,yt=gn,Cs=(function(){const t=hn(),e=we(1,0,0),n=we(0,1,0);return function(s,r,o){const i=pn(r,o);return i<-.999999?(Ae(t,e,r),Cn(t)<1e-6&&Ae(t,n,r),bn(t,t),Mt(s,t,Math.PI),s):i>.999999?(s[0]=0,s[1]=0,s[2]=0,s[3]=1,s):(Ae(t,r,o),s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=1+i,yt(s,s))}})();(function(){const t=Xe(),e=Xe();return function(n,s,r,o,i,a){return te(t,s,i,a),te(e,r,o,a),te(n,t,e,2*a*(1-a)),n}})();(function(){const t=zn();return function(e,n,s,r){return t[0]=s[0],t[3]=s[1],t[6]=s[2],t[1]=r[0],t[4]=r[1],t[7]=r[2],t[2]=-n[0],t[5]=-n[1],t[8]=-n[2],yt(e,Tt(e,t))}})();const bs=[0,0,0,1];class gs extends In{constructor(e=0,n=0,s=0,r=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,n,s,r)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,n,s,r){return this[0]=e,this[1]=n,this[2]=s,this[3]=r,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return Tt(this,e),this.check()}fromAxisRotation(e,n){return Mt(this,e,n),this.check()}identity(){return os(this),this.check()}setAxisAngle(e,n){return this.fromAxisRotation(e,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=g(e)}get y(){return this[1]}set y(e){this[1]=g(e)}get z(){return this[2]}set z(e){this[2]=g(e)}get w(){return this[3]}set w(e){this[3]=g(e)}len(){return hs(this)}lengthSquared(){return ps(this)}dot(e){return Bs(this,e)}rotationTo(e,n){return Cs(this,e,n),this.check()}add(e){return As(this,this,e),this.check()}calculateW(){return ls(this,this),this.check()}conjugate(){return us(this,this),this.check()}invert(){return fs(this,this),this.check()}lerp(e,n,s){return s===void 0?this.lerp(this,e,n):(ms(this,e,n,s),this.check())}multiplyRight(e){return Qe(this,this,e),this.check()}multiplyLeft(e){return Qe(this,e,this),this.check()}normalize(){const e=this.len(),n=e>0?1/e:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,e===0&&(this[3]=1),this.check()}rotateX(e){return is(this,this,e),this.check()}rotateY(e){return as(this,this,e),this.check()}rotateZ(e){return cs(this,this,e),this.check()}scale(e){return ds(this,this,e),this.check()}slerp(e,n,s){let r,o,i;switch(arguments.length){case 1:({start:r=bs,target:o,ratio:i}=e);break;case 2:r=this,o=e,i=n;break;default:r=e,o=n,i=s}return te(this,r,o,i),this.check()}transformVector4(e,n=new xe){return Mn(n,e,this),Ct(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,n){return this.setAxisAngle(e,n)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const Es=`out vec3 pbr_vPosition;
2
+ out vec2 pbr_vUV;
3
+
4
+ #ifdef HAS_NORMALS
5
+ # ifdef HAS_TANGENTS
6
+ out mat3 pbr_vTBN;
7
+ # else
8
+ out vec3 pbr_vNormal;
9
+ # endif
10
+ #endif
11
+
12
+ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
13
+ {
14
+ vec4 pos = pbrProjection.modelMatrix * position;
15
+ pbr_vPosition = vec3(pos.xyz) / pos.w;
16
+
17
+ #ifdef HAS_NORMALS
18
+ #ifdef HAS_TANGENTS
19
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
20
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
21
+ vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
22
+ pbr_vTBN = mat3(tangentW, bitangentW, normalW);
23
+ #else // HAS_TANGENTS != 1
24
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
25
+ #endif
26
+ #endif
27
+
28
+ #ifdef HAS_UV
29
+ pbr_vUV = uv;
30
+ #else
31
+ pbr_vUV = vec2(0.,0.);
32
+ #endif
33
+ }
34
+ `,Is=`precision highp float;
35
+
36
+ uniform pbrMaterialUniforms {
37
+ // Material is unlit
38
+ bool unlit;
39
+
40
+ // Base color map
41
+ bool baseColorMapEnabled;
42
+ vec4 baseColorFactor;
43
+
44
+ bool normalMapEnabled;
45
+ float normalScale; // #ifdef HAS_NORMALMAP
46
+
47
+ bool emissiveMapEnabled;
48
+ vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP
49
+
50
+ vec2 metallicRoughnessValues;
51
+ bool metallicRoughnessMapEnabled;
52
+
53
+ bool occlusionMapEnabled;
54
+ float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP
55
+
56
+ bool alphaCutoffEnabled;
57
+ float alphaCutoff; // #ifdef ALPHA_CUTOFF
58
+
59
+ // IBL
60
+ bool IBLenabled;
61
+ vec2 scaleIBLAmbient; // #ifdef USE_IBL
62
+
63
+ // debugging flags used for shader output of intermediate PBR variables
64
+ // #ifdef PBR_DEBUG
65
+ vec4 scaleDiffBaseMR;
66
+ vec4 scaleFGDSpec;
67
+ // #endif
68
+ } pbrMaterial;
69
+
70
+ // Samplers
71
+ #ifdef HAS_BASECOLORMAP
72
+ uniform sampler2D pbr_baseColorSampler;
73
+ #endif
74
+ #ifdef HAS_NORMALMAP
75
+ uniform sampler2D pbr_normalSampler;
76
+ #endif
77
+ #ifdef HAS_EMISSIVEMAP
78
+ uniform sampler2D pbr_emissiveSampler;
79
+ #endif
80
+ #ifdef HAS_METALROUGHNESSMAP
81
+ uniform sampler2D pbr_metallicRoughnessSampler;
82
+ #endif
83
+ #ifdef HAS_OCCLUSIONMAP
84
+ uniform sampler2D pbr_occlusionSampler;
85
+ #endif
86
+ #ifdef USE_IBL
87
+ uniform samplerCube pbr_diffuseEnvSampler;
88
+ uniform samplerCube pbr_specularEnvSampler;
89
+ uniform sampler2D pbr_brdfLUT;
90
+ #endif
91
+
92
+ // Inputs from vertex shader
93
+
94
+ in vec3 pbr_vPosition;
95
+ in vec2 pbr_vUV;
96
+
97
+ #ifdef HAS_NORMALS
98
+ #ifdef HAS_TANGENTS
99
+ in mat3 pbr_vTBN;
100
+ #else
101
+ in vec3 pbr_vNormal;
102
+ #endif
103
+ #endif
104
+
105
+ // Encapsulate the various inputs used by the various functions in the shading equation
106
+ // We store values in this struct to simplify the integration of alternative implementations
107
+ // of the shading terms, outlined in the Readme.MD Appendix.
108
+ struct PBRInfo {
109
+ float NdotL; // cos angle between normal and light direction
110
+ float NdotV; // cos angle between normal and view direction
111
+ float NdotH; // cos angle between normal and half vector
112
+ float LdotH; // cos angle between light direction and half vector
113
+ float VdotH; // cos angle between view direction and half vector
114
+ float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)
115
+ float metalness; // metallic value at the surface
116
+ vec3 reflectance0; // full reflectance color (normal incidence angle)
117
+ vec3 reflectance90; // reflectance color at grazing angle
118
+ float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])
119
+ vec3 diffuseColor; // color contribution from diffuse lighting
120
+ vec3 specularColor; // color contribution from specular lighting
121
+ vec3 n; // normal at surface point
122
+ vec3 v; // vector from surface point to camera
123
+ };
124
+
125
+ const float M_PI = 3.141592653589793;
126
+ const float c_MinRoughness = 0.04;
127
+
128
+ vec4 SRGBtoLINEAR(vec4 srgbIn)
129
+ {
130
+ #ifdef MANUAL_SRGB
131
+ #ifdef SRGB_FAST_APPROXIMATION
132
+ vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
133
+ #else // SRGB_FAST_APPROXIMATION
134
+ vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
135
+ vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
136
+ #endif //SRGB_FAST_APPROXIMATION
137
+ return vec4(linOut,srgbIn.w);;
138
+ #else //MANUAL_SRGB
139
+ return srgbIn;
140
+ #endif //MANUAL_SRGB
141
+ }
142
+
143
+ // Find the normal for this fragment, pulling either from a predefined normal map
144
+ // or from the interpolated mesh normal and tangent attributes.
145
+ vec3 getNormal()
146
+ {
147
+ // Retrieve the tangent space matrix
148
+ #ifndef HAS_TANGENTS
149
+ vec3 pos_dx = dFdx(pbr_vPosition);
150
+ vec3 pos_dy = dFdy(pbr_vPosition);
151
+ vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));
152
+ vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));
153
+ vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
154
+
155
+ #ifdef HAS_NORMALS
156
+ vec3 ng = normalize(pbr_vNormal);
157
+ #else
158
+ vec3 ng = cross(pos_dx, pos_dy);
159
+ #endif
160
+
161
+ t = normalize(t - ng * dot(ng, t));
162
+ vec3 b = normalize(cross(ng, t));
163
+ mat3 tbn = mat3(t, b, ng);
164
+ #else // HAS_TANGENTS
165
+ mat3 tbn = pbr_vTBN;
166
+ #endif
167
+
168
+ #ifdef HAS_NORMALMAP
169
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
170
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
171
+ #else
172
+ // The tbn matrix is linearly interpolated, so we need to re-normalize
173
+ vec3 n = normalize(tbn[2].xyz);
174
+ #endif
175
+
176
+ return n;
177
+ }
178
+
179
+ // Calculation of the lighting contribution from an optional Image Based Light source.
180
+ // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
181
+ // See our README.md on Environment Maps [3] for additional discussion.
182
+ #ifdef USE_IBL
183
+ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
184
+ {
185
+ float mipCount = 9.0; // resolution of 512x512
186
+ float lod = (pbrInfo.perceptualRoughness * mipCount);
187
+ // retrieve a scale and bias to F0. See [1], Figure 3
188
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
189
+ vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
190
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
191
+
192
+ #ifdef USE_TEX_LOD
193
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
194
+ #else
195
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
196
+ #endif
197
+
198
+ vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
199
+ vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
200
+
201
+ // For presentation, this allows us to disable IBL terms
202
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
203
+ specular *= pbrMaterial.scaleIBLAmbient.y;
204
+
205
+ return diffuse + specular;
206
+ }
207
+ #endif
208
+
209
+ // Basic Lambertian diffuse
210
+ // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
211
+ // See also [1], Equation 1
212
+ vec3 diffuse(PBRInfo pbrInfo)
213
+ {
214
+ return pbrInfo.diffuseColor / M_PI;
215
+ }
216
+
217
+ // The following equation models the Fresnel reflectance term of the spec equation (aka F())
218
+ // Implementation of fresnel from [4], Equation 15
219
+ vec3 specularReflection(PBRInfo pbrInfo)
220
+ {
221
+ return pbrInfo.reflectance0 +
222
+ (pbrInfo.reflectance90 - pbrInfo.reflectance0) *
223
+ pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
224
+ }
225
+
226
+ // This calculates the specular geometric attenuation (aka G()),
227
+ // where rougher material will reflect less light back to the viewer.
228
+ // This implementation is based on [1] Equation 4, and we adopt their modifications to
229
+ // alphaRoughness as input as originally proposed in [2].
230
+ float geometricOcclusion(PBRInfo pbrInfo)
231
+ {
232
+ float NdotL = pbrInfo.NdotL;
233
+ float NdotV = pbrInfo.NdotV;
234
+ float r = pbrInfo.alphaRoughness;
235
+
236
+ float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
237
+ float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
238
+ return attenuationL * attenuationV;
239
+ }
240
+
241
+ // The following equation(s) model the distribution of microfacet normals across
242
+ // the area being drawn (aka D())
243
+ // Implementation from "Average Irregularity Representation of a Roughened Surface
244
+ // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
245
+ // Follows the distribution function recommended in the SIGGRAPH 2013 course notes
246
+ // from EPIC Games [1], Equation 3.
247
+ float microfacetDistribution(PBRInfo pbrInfo)
248
+ {
249
+ float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
250
+ float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
251
+ return roughnessSq / (M_PI * f * f);
252
+ }
253
+
254
+ void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {
255
+ pbrInfo.NdotL = 1.0;
256
+ pbrInfo.NdotH = 0.0;
257
+ pbrInfo.LdotH = 0.0;
258
+ pbrInfo.VdotH = 1.0;
259
+ }
260
+
261
+ void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {
262
+ vec3 n = pbrInfo.n;
263
+ vec3 v = pbrInfo.v;
264
+ vec3 l = normalize(lightDirection); // Vector from surface point to light
265
+ vec3 h = normalize(l+v); // Half vector between both l and v
266
+
267
+ pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);
268
+ pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);
269
+ pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);
270
+ pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);
271
+ }
272
+
273
+ void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {
274
+ vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
275
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
276
+ }
277
+
278
+ vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
279
+ // Calculate the shading terms for the microfacet specular shading model
280
+ vec3 F = specularReflection(pbrInfo);
281
+ float G = geometricOcclusion(pbrInfo);
282
+ float D = microfacetDistribution(pbrInfo);
283
+
284
+ // Calculation of analytical lighting contribution
285
+ vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
286
+ vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
287
+ // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
288
+ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
289
+ }
290
+
291
+ vec4 pbr_filterColor(vec4 colorUnused)
292
+ {
293
+ // The albedo may be defined from a base texture or a flat color
294
+ #ifdef HAS_BASECOLORMAP
295
+ vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
296
+ #else
297
+ vec4 baseColor = pbrMaterial.baseColorFactor;
298
+ #endif
299
+
300
+ #ifdef ALPHA_CUTOFF
301
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
302
+ discard;
303
+ }
304
+ #endif
305
+
306
+ vec3 color = vec3(0, 0, 0);
307
+
308
+ if(pbrMaterial.unlit){
309
+ color.rgb = baseColor.rgb;
310
+ }
311
+ else{
312
+ // Metallic and Roughness material properties are packed together
313
+ // In glTF, these factors can be specified by fixed scalar values
314
+ // or from a metallic-roughness map
315
+ float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
316
+ float metallic = pbrMaterial.metallicRoughnessValues.x;
317
+ #ifdef HAS_METALROUGHNESSMAP
318
+ // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
319
+ // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
320
+ vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
321
+ perceptualRoughness = mrSample.g * perceptualRoughness;
322
+ metallic = mrSample.b * metallic;
323
+ #endif
324
+ perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
325
+ metallic = clamp(metallic, 0.0, 1.0);
326
+ // Roughness is authored as perceptual roughness; as is convention,
327
+ // convert to material roughness by squaring the perceptual roughness [2].
328
+ float alphaRoughness = perceptualRoughness * perceptualRoughness;
329
+
330
+ vec3 f0 = vec3(0.04);
331
+ vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
332
+ diffuseColor *= 1.0 - metallic;
333
+ vec3 specularColor = mix(f0, baseColor.rgb, metallic);
334
+
335
+ // Compute reflectance.
336
+ float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
337
+
338
+ // For typical incident reflectance range (between 4% to 100%) set the grazing
339
+ // reflectance to 100% for typical fresnel effect.
340
+ // For very low reflectance range on highly diffuse objects (below 4%),
341
+ // incrementally reduce grazing reflecance to 0%.
342
+ float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
343
+ vec3 specularEnvironmentR0 = specularColor.rgb;
344
+ vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
345
+
346
+ vec3 n = getNormal(); // normal at surface point
347
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
348
+
349
+ float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
350
+ vec3 reflection = -normalize(reflect(v, n));
351
+
352
+ PBRInfo pbrInfo = PBRInfo(
353
+ 0.0, // NdotL
354
+ NdotV,
355
+ 0.0, // NdotH
356
+ 0.0, // LdotH
357
+ 0.0, // VdotH
358
+ perceptualRoughness,
359
+ metallic,
360
+ specularEnvironmentR0,
361
+ specularEnvironmentR90,
362
+ alphaRoughness,
363
+ diffuseColor,
364
+ specularColor,
365
+ n,
366
+ v
367
+ );
368
+
369
+
370
+ #ifdef USE_LIGHTS
371
+ // Apply ambient light
372
+ PBRInfo_setAmbientLight(pbrInfo);
373
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
374
+
375
+ // Apply directional light
376
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
377
+ if (i < lighting.directionalLightCount) {
378
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
379
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
380
+ }
381
+ }
382
+
383
+ // Apply point light
384
+ for(int i = 0; i < lighting.pointLightCount; i++) {
385
+ if (i < lighting.pointLightCount) {
386
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
387
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
388
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
389
+ }
390
+ }
391
+ #endif
392
+
393
+ // Calculate lighting contribution from image based lighting source (IBL)
394
+ #ifdef USE_IBL
395
+ if (pbrMaterial.IBLenabled) {
396
+ color += getIBLContribution(pbrInfo, n, reflection);
397
+ }
398
+ #endif
399
+
400
+ // Apply optional PBR terms for additional (optional) shading
401
+ #ifdef HAS_OCCLUSIONMAP
402
+ if (pbrMaterial.occlusionMapEnabled) {
403
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
404
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
405
+ }
406
+ #endif
407
+
408
+ #ifdef HAS_EMISSIVEMAP
409
+ if (pbrMaterial.emissiveMapEnabled) {
410
+ vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
411
+ color += emissive;
412
+ }
413
+ #endif
414
+
415
+ // This section uses mix to override final color for reference app visualization
416
+ // of various parameters in the lighting equation.
417
+ #ifdef PBR_DEBUG
418
+ // TODO: Figure out how to debug multiple lights
419
+
420
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
421
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
422
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
423
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
424
+
425
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
426
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
427
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
428
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
429
+ #endif
430
+
431
+ }
432
+
433
+ return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
434
+ }
435
+ `,Ms=`struct PBRFragmentInputs {
436
+ pbr_vPosition: vec3f,
437
+ pbr_vUV: vec2f,
438
+ pbr_vTBN: mat3f,
439
+ pbr_vNormal: vec3f
440
+ };
441
+
442
+ var fragmentInputs: PBRFragmentInputs;
443
+
444
+ fn pbr_setPositionNormalTangentUV(position: vec4f, normal: vec4f, tangent: vec4f, uv: vec2f)
445
+ {
446
+ var pos: vec4f = pbrProjection.modelMatrix * position;
447
+ pbr_vPosition = vec3(pos.xyz) / pos.w;
448
+
449
+ #ifdef HAS_NORMALS
450
+ #ifdef HAS_TANGENTS
451
+ let normalW: vec3f = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
452
+ let tangentW: vec3f = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
453
+ let bitangentW: vec3f = cross(normalW, tangentW) * tangent.w;
454
+ fragmentInputs,pbr_vTBN = mat3(tangentW, bitangentW, normalW);
455
+ #else // HAS_TANGENTS != 1
456
+ fragmentInputs.pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
457
+ #endif
458
+ #endif
459
+
460
+ #ifdef HAS_UV
461
+ pbr_vUV = uv;
462
+ #else
463
+ pbr_vUV = vec2(0.,0.);
464
+ #endif
465
+ }
466
+
467
+ struct pbrMaterialUniforms {
468
+ // Material is unlit
469
+ unlit: uint32,
470
+
471
+ // Base color map
472
+ baseColorMapEnabled: uint32,
473
+ baseColorFactor: vec4f,
474
+
475
+ normalMapEnabled : uint32,
476
+ normalScale: f32, // #ifdef HAS_NORMALMAP
477
+
478
+ emissiveMapEnabled: uint32,
479
+ emissiveFactor: vec3f, // #ifdef HAS_EMISSIVEMAP
480
+
481
+ metallicRoughnessValues: vec2f,
482
+ metallicRoughnessMapEnabled: uint32,
483
+
484
+ occlusionMapEnabled: i32,
485
+ occlusionStrength: f32, // #ifdef HAS_OCCLUSIONMAP
486
+
487
+ alphaCutoffEnabled: i32,
488
+ alphaCutoff: f32, // #ifdef ALPHA_CUTOFF
489
+
490
+ // IBL
491
+ IBLenabled: i32,
492
+ scaleIBLAmbient: vec2f, // #ifdef USE_IBL
493
+
494
+ // debugging flags used for shader output of intermediate PBR variables
495
+ // #ifdef PBR_DEBUG
496
+ scaleDiffBaseMR: vec4f,
497
+ scaleFGDSpec: vec4f
498
+ // #endif
499
+ }
500
+
501
+ @binding(2) @group(0) var<uniform> material : pbrMaterialUniforms;
502
+
503
+ // Samplers
504
+ #ifdef HAS_BASECOLORMAP
505
+ uniform sampler2D pbr_baseColorSampler;
506
+ #endif
507
+ #ifdef HAS_NORMALMAP
508
+ uniform sampler2D pbr_normalSampler;
509
+ #endif
510
+ #ifdef HAS_EMISSIVEMAP
511
+ uniform sampler2D pbr_emissiveSampler;
512
+ #endif
513
+ #ifdef HAS_METALROUGHNESSMAP
514
+ uniform sampler2D pbr_metallicRoughnessSampler;
515
+ #endif
516
+ #ifdef HAS_OCCLUSIONMAP
517
+ uniform sampler2D pbr_occlusionSampler;
518
+ #endif
519
+ #ifdef USE_IBL
520
+ uniform samplerCube pbr_diffuseEnvSampler;
521
+ uniform samplerCube pbr_specularEnvSampler;
522
+ uniform sampler2D pbr_brdfLUT;
523
+ #endif
524
+
525
+ // Encapsulate the various inputs used by the various functions in the shading equation
526
+ // We store values in this struct to simplify the integration of alternative implementations
527
+ // of the shading terms, outlined in the Readme.MD Appendix.
528
+ struct PBRInfo {
529
+ NdotL: f32, // cos angle between normal and light direction
530
+ NdotV: f32, // cos angle between normal and view direction
531
+ NdotH: f32, // cos angle between normal and half vector
532
+ LdotH: f32, // cos angle between light direction and half vector
533
+ VdotH: f32, // cos angle between view direction and half vector
534
+ perceptualRoughness: f32, // roughness value, as authored by the model creator (input to shader)
535
+ metalness: f32, // metallic value at the surface
536
+ reflectance0: vec3f, // full reflectance color (normal incidence angle)
537
+ reflectance90: vec3f, // reflectance color at grazing angle
538
+ alphaRoughness: f32, // roughness mapped to a more linear change in the roughness (proposed by [2])
539
+ diffuseColor: vec3f, // color contribution from diffuse lighting
540
+ specularColor: vec3f, // color contribution from specular lighting
541
+ n: vec3f, // normal at surface point
542
+ v: vec3f, // vector from surface point to camera
543
+ };
544
+
545
+ const M_PI = 3.141592653589793;
546
+ const c_MinRoughness = 0.04;
547
+
548
+ fn SRGBtoLINEAR(srgbIn: vec4f ) -> vec4f
549
+ {
550
+ #ifdef MANUAL_SRGB
551
+ #ifdef SRGB_FAST_APPROXIMATION
552
+ var linOut: vec3f = pow(srgbIn.xyz,vec3(2.2));
553
+ #else // SRGB_FAST_APPROXIMATION
554
+ var bLess: vec3f = step(vec3(0.04045),srgbIn.xyz);
555
+ var linOut: vec3f = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
556
+ #endif //SRGB_FAST_APPROXIMATION
557
+ return vec4f(linOut,srgbIn.w);;
558
+ #else //MANUAL_SRGB
559
+ return srgbIn;
560
+ #endif //MANUAL_SRGB
561
+ }
562
+
563
+ // Find the normal for this fragment, pulling either from a predefined normal map
564
+ // or from the interpolated mesh normal and tangent attributes.
565
+ fn getNormal() -> vec3f
566
+ {
567
+ // Retrieve the tangent space matrix
568
+ #ifndef HAS_TANGENTS
569
+ var pos_dx: vec3f = dFdx(pbr_vPosition);
570
+ var pos_dy: vec3f = dFdy(pbr_vPosition);
571
+ var tex_dx: vec3f = dFdx(vec3(pbr_vUV, 0.0));
572
+ var tex_dy: vec3f = dFdy(vec3(pbr_vUV, 0.0));
573
+ var t: vec3f = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
574
+
575
+ #ifdef HAS_NORMALS
576
+ var ng: vec3f = normalize(pbr_vNormal);
577
+ #else
578
+ var ng: vec3f = cross(pos_dx, pos_dy);
579
+ #endif
580
+
581
+ t = normalize(t - ng * dot(ng, t));
582
+ var b: vec3f = normalize(cross(ng, t));
583
+ var tbn: mat3f = mat3f(t, b, ng);
584
+ #else // HAS_TANGENTS
585
+ var tbn: mat3f = pbr_vTBN;
586
+ #endif
587
+
588
+ #ifdef HAS_NORMALMAP
589
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
590
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
591
+ #else
592
+ // The tbn matrix is linearly interpolated, so we need to re-normalize
593
+ vec3 n = normalize(tbn[2].xyz);
594
+ #endif
595
+
596
+ return n;
597
+ }
598
+
599
+ // Calculation of the lighting contribution from an optional Image Based Light source.
600
+ // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
601
+ // See our README.md on Environment Maps [3] for additional discussion.
602
+ #ifdef USE_IBL
603
+ fn getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection) -> vec3f
604
+ {
605
+ float mipCount = 9.0; // resolution of 512x512
606
+ float lod = (pbrInfo.perceptualRoughness * mipCount);
607
+ // retrieve a scale and bias to F0. See [1], Figure 3
608
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
609
+ vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
610
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
611
+
612
+ #ifdef USE_TEX_LOD
613
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
614
+ #else
615
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
616
+ #endif
617
+
618
+ vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
619
+ vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
620
+
621
+ // For presentation, this allows us to disable IBL terms
622
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
623
+ specular *= pbrMaterial.scaleIBLAmbient.y;
624
+
625
+ return diffuse + specular;
626
+ }
627
+ #endif
628
+
629
+ // Basic Lambertian diffuse
630
+ // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
631
+ // See also [1], Equation 1
632
+ fn diffuse(pbrInfo: PBRInfo) -> vec3<f32> {
633
+ return pbrInfo.diffuseColor / PI;
634
+ }
635
+
636
+ // The following equation models the Fresnel reflectance term of the spec equation (aka F())
637
+ // Implementation of fresnel from [4], Equation 15
638
+ fn specularReflection(pbrInfo: PBRInfo) -> vec3<f32> {
639
+ return pbrInfo.reflectance0 +
640
+ (pbrInfo.reflectance90 - pbrInfo.reflectance0) *
641
+ pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
642
+ }
643
+
644
+ // This calculates the specular geometric attenuation (aka G()),
645
+ // where rougher material will reflect less light back to the viewer.
646
+ // This implementation is based on [1] Equation 4, and we adopt their modifications to
647
+ // alphaRoughness as input as originally proposed in [2].
648
+ fn geometricOcclusion(pbrInfo: PBRInfo) -> f32 {
649
+ let NdotL: f32 = pbrInfo.NdotL;
650
+ let NdotV: f32 = pbrInfo.NdotV;
651
+ let r: f32 = pbrInfo.alphaRoughness;
652
+
653
+ let attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
654
+ let attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
655
+ return attenuationL * attenuationV;
656
+ }
657
+
658
+ // The following equation(s) model the distribution of microfacet normals across
659
+ // the area being drawn (aka D())
660
+ // Implementation from "Average Irregularity Representation of a Roughened Surface
661
+ // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
662
+ // Follows the distribution function recommended in the SIGGRAPH 2013 course notes
663
+ // from EPIC Games [1], Equation 3.
664
+ fn microfacetDistribution(pbrInfo: PBRInfo) -> f32 {
665
+ let roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
666
+ let f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
667
+ return roughnessSq / (PI * f * f);
668
+ }
669
+
670
+ fn PBRInfo_setAmbientLight(pbrInfo: ptr<function, PBRInfo>) {
671
+ (*pbrInfo).NdotL = 1.0;
672
+ (*pbrInfo).NdotH = 0.0;
673
+ (*pbrInfo).LdotH = 0.0;
674
+ (*pbrInfo).VdotH = 1.0;
675
+ }
676
+
677
+ fn PBRInfo_setDirectionalLight(pbrInfo: ptr<function, PBRInfo>, lightDirection: vec3<f32>) {
678
+ let n = (*pbrInfo).n;
679
+ let v = (*pbrInfo).v;
680
+ let l = normalize(lightDirection); // Vector from surface point to light
681
+ let h = normalize(l + v); // Half vector between both l and v
682
+
683
+ (*pbrInfo).NdotL = clamp(dot(n, l), 0.001, 1.0);
684
+ (*pbrInfo).NdotH = clamp(dot(n, h), 0.0, 1.0);
685
+ (*pbrInfo).LdotH = clamp(dot(l, h), 0.0, 1.0);
686
+ (*pbrInfo).VdotH = clamp(dot(v, h), 0.0, 1.0);
687
+ }
688
+
689
+ fn PBRInfo_setPointLight(pbrInfo: ptr<function, PBRInfo>, pointLight: PointLight) {
690
+ let light_direction = normalize(pointLight.position - pbr_vPosition);
691
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
692
+ }
693
+
694
+ fn calculateFinalColor(pbrInfo: PBRInfo, lightColor: vec3<f32>) -> vec3<f32> {
695
+ // Calculate the shading terms for the microfacet specular shading model
696
+ let F = specularReflection(pbrInfo);
697
+ let G = geometricOcclusion(pbrInfo);
698
+ let D = microfacetDistribution(pbrInfo);
699
+
700
+ // Calculation of analytical lighting contribution
701
+ let diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
702
+ let specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
703
+ // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
704
+ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
705
+ }
706
+
707
+ fn pbr_filterColor(colorUnused: vec4<f32>) -> vec4<f32> {
708
+ // The albedo may be defined from a base texture or a flat color
709
+ var baseColor: vec4<f32>;
710
+ #ifdef HAS_BASECOLORMAP
711
+ baseColor = SRGBtoLINEAR(textureSample(pbr_baseColorSampler, pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
712
+ #else
713
+ baseColor = pbrMaterial.baseColorFactor;
714
+ #endif
715
+
716
+ #ifdef ALPHA_CUTOFF
717
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
718
+ discard;
719
+ }
720
+ #endif
721
+
722
+ var color = vec3<f32>(0.0, 0.0, 0.0);
723
+
724
+ if (pbrMaterial.unlit) {
725
+ color = baseColor.rgb;
726
+ } else {
727
+ // Metallic and Roughness material properties are packed together
728
+ // In glTF, these factors can be specified by fixed scalar values
729
+ // or from a metallic-roughness map
730
+ var perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
731
+ var metallic = pbrMaterial.metallicRoughnessValues.x;
732
+ #ifdef HAS_METALROUGHNESSMAP
733
+ // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
734
+ // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
735
+ let mrSample = textureSample(pbr_metallicRoughnessSampler, pbr_metallicRoughnessSampler, pbr_vUV);
736
+ perceptualRoughness = mrSample.g * perceptualRoughness;
737
+ metallic = mrSample.b * metallic;
738
+ #endif
739
+ perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
740
+ metallic = clamp(metallic, 0.0, 1.0);
741
+ // Roughness is authored as perceptual roughness; as is convention,
742
+ // convert to material roughness by squaring the perceptual roughness [2].
743
+ let alphaRoughness = perceptualRoughness * perceptualRoughness;
744
+
745
+ let f0 = vec3<f32>(0.04);
746
+ var diffuseColor = baseColor.rgb * (vec3<f32>(1.0) - f0);
747
+ diffuseColor *= 1.0 - metallic;
748
+ let specularColor = mix(f0, baseColor.rgb, metallic);
749
+
750
+ // Compute reflectance.
751
+ let reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
752
+
753
+ // For typical incident reflectance range (between 4% to 100%) set the grazing
754
+ // reflectance to 100% for typical fresnel effect.
755
+ // For very low reflectance range on highly diffuse objects (below 4%),
756
+ // incrementally reduce grazing reflectance to 0%.
757
+ let reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
758
+ let specularEnvironmentR0 = specularColor;
759
+ let specularEnvironmentR90 = vec3<f32>(1.0, 1.0, 1.0) * reflectance90;
760
+
761
+ let n = getNormal(); // normal at surface point
762
+ let v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
763
+
764
+ let NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
765
+ let reflection = -normalize(reflect(v, n));
766
+
767
+ var pbrInfo = PBRInfo(
768
+ 0.0, // NdotL
769
+ NdotV,
770
+ 0.0, // NdotH
771
+ 0.0, // LdotH
772
+ 0.0, // VdotH
773
+ perceptualRoughness,
774
+ metallic,
775
+ specularEnvironmentR0,
776
+ specularEnvironmentR90,
777
+ alphaRoughness,
778
+ diffuseColor,
779
+ specularColor,
780
+ n,
781
+ v
782
+ );
783
+
784
+ #ifdef USE_LIGHTS
785
+ // Apply ambient light
786
+ PBRInfo_setAmbientLight(&pbrInfo);
787
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
788
+
789
+ // Apply directional light
790
+ for (var i = 0; i < lighting.directionalLightCount; i++) {
791
+ if (i < lighting.directionalLightCount) {
792
+ PBRInfo_setDirectionalLight(&pbrInfo, lighting_getDirectionalLight(i).direction);
793
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
794
+ }
795
+ }
796
+
797
+ // Apply point light
798
+ for (var i = 0; i < lighting.pointLightCount; i++) {
799
+ if (i < lighting.pointLightCount) {
800
+ PBRInfo_setPointLight(&pbrInfo, lighting_getPointLight(i));
801
+ let attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
802
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
803
+ }
804
+ }
805
+ #endif
806
+
807
+ // Calculate lighting contribution from image based lighting source (IBL)
808
+ #ifdef USE_IBL
809
+ if (pbrMaterial.IBLenabled) {
810
+ color += getIBLContribution(pbrInfo, n, reflection);
811
+ }
812
+ #endif
813
+
814
+ // Apply optional PBR terms for additional (optional) shading
815
+ #ifdef HAS_OCCLUSIONMAP
816
+ if (pbrMaterial.occlusionMapEnabled) {
817
+ let ao = textureSample(pbr_occlusionSampler, pbr_occlusionSampler, pbr_vUV).r;
818
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
819
+ }
820
+ #endif
821
+
822
+ #ifdef HAS_EMISSIVEMAP
823
+ if (pbrMaterial.emissiveMapEnabled) {
824
+ let emissive = SRGBtoLINEAR(textureSample(pbr_emissiveSampler, pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
825
+ color += emissive;
826
+ }
827
+ #endif
828
+
829
+ // This section uses mix to override final color for reference app visualization
830
+ // of various parameters in the lighting equation.
831
+ #ifdef PBR_DEBUG
832
+ // TODO: Figure out how to debug multiple lights
833
+
834
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
835
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
836
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
837
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
838
+
839
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
840
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
841
+ color = mix(color, vec3<f32>(metallic), pbrMaterial.scaleDiffBaseMR.z);
842
+ color = mix(color, vec3<f32>(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
843
+ #endif
844
+ }
845
+
846
+ return vec4<f32>(pow(color, vec3<f32>(1.0 / 2.2)), baseColor.a);
847
+ }
848
+ `,Ye=`uniform pbrProjectionUniforms {
849
+ mat4 modelViewProjectionMatrix;
850
+ mat4 modelMatrix;
851
+ mat4 normalMatrix;
852
+ vec3 camera;
853
+ } pbrProjection;
854
+ `,Ts={name:"pbrProjection",vs:Ye,fs:Ye,getUniforms:t=>t,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<i32>"}},Ft={props:{},uniforms:{},name:"pbrMaterial",dependencies:[qt,Ts],source:Ms,vs:Es,fs:Is,defines:{LIGHTING_FRAGMENT:!0,HAS_NORMALMAP:!1,HAS_EMISSIVEMAP:!1,HAS_OCCLUSIONMAP:!1,HAS_BASECOLORMAP:!1,HAS_METALROUGHNESSMAP:!1,ALPHA_CUTOFF:!1,USE_IBL:!1,PBR_DEBUG:!1},getUniforms:t=>t,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"}};class re{id;matrix=new x;display=!0;position=new G;rotation=new G;scale=new G(1,1,1);userData={};props={};constructor(e={}){const{id:n}=e;this.id=n||yn(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return this.position=e,this}setRotation(e){return this.rotation=e,this}setScale(e){return this.scale=e,this}setMatrix(e,n=!0){n?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:n,rotation:s,scale:r,update:o=!0}=e;return n&&this.setPosition(n),s&&this.setRotation(s),r&&this.setScale(r),o&&this.updateMatrix(),this}updateMatrix(){const e=this.position,n=this.rotation,s=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(n),this.matrix.scale(s),this}update(e={}){const{position:n,rotation:s,scale:r}=e;return n&&this.setPosition(n),s&&this.setRotation(s),r&&this.setScale(r),this.updateMatrix(),this}getCoordinateUniforms(e,n){n=n||this.matrix;const s=new x(e).multiplyRight(n),r=s.invert(),o=r.transpose();return{viewMatrix:e,modelMatrix:n,objectMatrix:n,worldMatrix:s,worldInverseMatrix:r,worldInverseTransposeMatrix:o}}_setScenegraphNodeProps(e){"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}}class U extends re{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:n=[]}=e;L.assert(n.every(s=>s instanceof re),"every child must an instance of ScenegraphNode"),super(e),this.children=n}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((n,{worldMatrix:s})=>{const r=n.getBounds();if(!r)return;const[o,i]=r,a=new G(o).add(i).divide([2,2,2]);s.transformAsPoint(a,a);const c=new G(i).subtract(o).divide([2,2,2]);s.transformAsVector(c,c);for(let l=0;l<8;l++){const f=new G(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let u=0;u<3;u++)e[0][u]=Math.min(e[0][u],f[u]),e[1][u]=Math.max(e[1][u],f[u])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const n of e)Array.isArray(n)?this.add(...n):this.children.push(n);return this}remove(e){const n=this.children,s=n.indexOf(e);return s>-1&&n.splice(s,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:n=new x}={}){const s=new x(n).multiplyRight(this.matrix);for(const r of this.children)r instanceof U?r.traverse(e,{worldMatrix:s}):e(r,{worldMatrix:s})}}class Re extends re{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}}const he=Math.PI/180,W=new Float32Array(16),ke=new Float32Array(12);function ze(t,e,n){const s=e[0]*he,r=e[1]*he,o=e[2]*he,i=Math.sin(o),a=Math.sin(s),c=Math.sin(r),l=Math.cos(o),f=Math.cos(s),u=Math.cos(r),A=n[0],d=n[1],B=n[2];t[0]=A*u*f,t[1]=A*c*f,t[2]=A*-a,t[3]=d*(-c*l+u*a*i),t[4]=d*(u*l+c*a*i),t[5]=d*f*i,t[6]=B*(c*i+u*a*l),t[7]=B*(-u*i+c*a*l),t[8]=B*f*l}function We(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}const _t={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(t,{startRow:e,endRow:n}){const{data:s,getOrientation:r,getScale:o,getTranslation:i,getTransformMatrix:a}=this.props,c=Array.isArray(a),l=c&&a.length===16,f=Array.isArray(o),u=Array.isArray(r),A=Array.isArray(i),d=l||!c&&!!a(s[0]);d?t.constant=l:t.constant=u&&f&&A;const B=t.value;if(t.constant){let m;d?(W.set(a),m=We(W)):(m=ke,ze(m,r,o),m.set(i,9)),t.value=new Float32Array(m)}else{let m=e*t.size;const{iterable:p,objectInfo:C}=$t(s,e,n);for(const I of p){C.index++;let h;if(d)W.set(l?a:a(I,C)),h=We(W);else{h=ke;const N=u?r:r(I,C),Zt=f?o:o(I,C);ze(h,N,Zt),h.set(A?i:i(I,C),9)}B[m++]=h[0],B[m++]=h[1],B[m++]=h[2],B[m++]=h[3],B[m++]=h[4],B[m++]=h[5],B[m++]=h[6],B[m++]=h[7],B[m++]=h[8],B[m++]=h[9],B[m++]=h[10],B[m++]=h[11]}}}};function Rt(t,e){return e===de.CARTESIAN||e===de.METER_OFFSETS||e===de.DEFAULT&&!t.isGeospatial}const Ze=`uniform simpleMeshUniforms {
855
+ float sizeScale;
856
+ bool composeModelMatrix;
857
+ bool hasTexture;
858
+ bool flatShading;
859
+ } simpleMesh;
860
+ `,ys={name:"simpleMesh",vs:Ze,fs:Ze,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}},Fs=`#version 300 es
861
+ #define SHADER_NAME simple-mesh-layer-vs
862
+ in vec3 positions;
863
+ in vec3 normals;
864
+ in vec3 colors;
865
+ in vec2 texCoords;
866
+ in vec3 instancePositions;
867
+ in vec3 instancePositions64Low;
868
+ in vec4 instanceColors;
869
+ in vec3 instancePickingColors;
870
+ in vec3 instanceModelMatrixCol0;
871
+ in vec3 instanceModelMatrixCol1;
872
+ in vec3 instanceModelMatrixCol2;
873
+ in vec3 instanceTranslation;
874
+ out vec2 vTexCoord;
875
+ out vec3 cameraPosition;
876
+ out vec3 normals_commonspace;
877
+ out vec4 position_commonspace;
878
+ out vec4 vColor;
879
+ void main(void) {
880
+ geometry.worldPosition = instancePositions;
881
+ geometry.uv = texCoords;
882
+ geometry.pickingColor = instancePickingColors;
883
+ vTexCoord = texCoords;
884
+ cameraPosition = project.cameraPosition;
885
+ vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
886
+ mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
887
+ vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation;
888
+ if (simpleMesh.composeModelMatrix) {
889
+ DECKGL_FILTER_SIZE(pos, geometry);
890
+ normals_commonspace = project_normal(instanceModelMatrix * normals);
891
+ geometry.worldPosition += pos;
892
+ gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);
893
+ geometry.position = position_commonspace;
894
+ }
895
+ else {
896
+ pos = project_size(pos);
897
+ DECKGL_FILTER_SIZE(pos, geometry);
898
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);
899
+ geometry.position = position_commonspace;
900
+ normals_commonspace = project_normal(instanceModelMatrix * normals);
901
+ }
902
+ geometry.normal = normals_commonspace;
903
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
904
+ DECKGL_FILTER_COLOR(vColor, geometry);
905
+ }
906
+ `,_s=`#version 300 es
907
+ #define SHADER_NAME simple-mesh-layer-fs
908
+ precision highp float;
909
+ uniform sampler2D sampler;
910
+ in vec2 vTexCoord;
911
+ in vec3 cameraPosition;
912
+ in vec3 normals_commonspace;
913
+ in vec4 position_commonspace;
914
+ in vec4 vColor;
915
+ out vec4 fragColor;
916
+ void main(void) {
917
+ geometry.uv = vTexCoord;
918
+ vec3 normal;
919
+ if (simpleMesh.flatShading) {
920
+ normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
921
+ } else {
922
+ normal = normals_commonspace;
923
+ }
924
+ vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
925
+ DECKGL_FILTER_COLOR(color, geometry);
926
+ vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
927
+ fragColor = vec4(lightColor, color.a * layer.opacity);
928
+ }
929
+ `;function pe(t){const e=t.positions||t.POSITION;ee.assert(e,'no "postions" or "POSITION" attribute in mesh');const n=e.value.length/e.size;let s=t.COLOR_0||t.colors;s||(s={size:3,value:new Float32Array(n*3).fill(1)});let r=t.NORMAL||t.normals;r||(r={size:3,value:new Float32Array(n*3).fill(0)});let o=t.TEXCOORD_0||t.texCoords;return o||(o={size:2,value:new Float32Array(n*2).fill(0)}),{positions:e,colors:s,normals:r,texCoords:o}}function qe(t){return t instanceof $?(t.attributes=pe(t.attributes),t):t.attributes?new $({...t,topology:"triangle-list",attributes:pe(t.attributes)}):new $({topology:"triangle-list",attributes:pe(t)})}const Rs=[0,0,0,255],Gs={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:Rs},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}};class Gt extends Bt{getShaders(){return super.getShaders({vs:Fs,fs:_s,modules:[mt,en,ht,ys]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;const{mesh:n}=this.props;if(!n)return null;if(e=n.header?.boundingBox,!e){const{attributes:s}=qe(n);s.POSITION=s.POSITION||s.positions,e=It(s)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:_t}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:n,oldProps:s,changeFlags:r}=e;if(n.mesh!==s.mesh||r.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),n.mesh){this.state.model=this.getModel(n.mesh);const o=n.mesh.attributes||n.mesh;this.setState({hasNormals:!!(o.NORMAL||o.normals)})}this.getAttributeManager().invalidateAll()}n.texture!==s.texture&&n.texture instanceof Tn&&this.setTexture(n.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){const{model:n}=this.state;if(!n)return;const{viewport:s,renderPass:r}=this.context,{sizeScale:o,coordinateSystem:i,_instanced:a}=this.props,c={sizeScale:o,composeModelMatrix:!a||Rt(s,i),flatShading:!this.state.hasNormals};n.shaderInputs.setProps({simpleMesh:c}),n.draw(r)}get isLoaded(){return!!(this.state?.model&&super.isLoaded)}getModel(e){const n=new bt(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:qe(e),isInstanced:!0}),{texture:s}=this.props,{emptyTexture:r}=this.state,o={sampler:s||r,hasTexture:!!s};return n.shaderInputs.setProps({simpleMesh:o}),n}setTexture(e){const{emptyTexture:n,model:s}=this.state;if(s){const r={sampler:e||n,hasTexture:!!e};s.shaderInputs.setProps({simpleMesh:r})}}}Gt.defaultProps=Gs;Gt.layerName="SimpleMeshLayer";const vs="4.3.3",oe={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"};let $e;async function et(t){Sn(t.modules);const e=On("basis");return e||($e||=Ds(t),await $e)}async function Ds(t){let e=null,n=null;return[e,n]=await Promise.all([await v(oe.TRANSCODER,"textures",t),await v(oe.TRANSCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await Ss(e,n)}function Ss(t,e){const n={};return e&&(n.wasmBinary=e),new Promise(s=>{t(n).then(r=>{const{BasisFile:o,initializeBasis:i}=r;i(),s({BasisFile:o})})})}let Ce;async function tt(t){const e=t.modules||{};return e.basisEncoder?e.basisEncoder:(Ce=Ce||Os(t),await Ce)}async function Os(t){let e=null,n=null;return[e,n]=await Promise.all([await v(oe.ENCODER,"textures",t),await v(oe.ENCODER_WASM,"textures",t)]),e=e||globalThis.BASIS,await xs(e,n)}function xs(t,e){const n={};return e&&(n.wasmBinary=e),new Promise(s=>{t(n).then(r=>{const{BasisFile:o,KTX2File:i,initializeBasis:a,BasisEncoder:c}=r;a(),s({BasisFile:o,KTX2File:i,BasisEncoder:c})})})}const D={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGBA_ASTC_4X4_KHR:37808},Ls=["","WEBKIT_","MOZ_"],nt={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let Z=null;function Hs(t){if(!Z){t=t||Ps()||void 0,Z=new Set;for(const e of Ls)for(const n in nt)if(t&&t.getExtension(`${e}${n}`)){const s=nt[n];Z.add(s)}}return Z}function Ps(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}const M=[171,75,84,88,32,50,48,187,13,10,26,10];function Us(t){const e=new Uint8Array(t);return!(e.byteLength<M.length||e[0]!==M[0]||e[1]!==M[1]||e[2]!==M[2]||e[3]!==M[3]||e[4]!==M[4]||e[5]!==M[5]||e[6]!==M[6]||e[7]!==M[7]||e[8]!==M[8]||e[9]!==M[9]||e[10]!==M[10]||e[11]!==M[11])}const Ns={etc1:{basisFormat:0,compressed:!0,format:D.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:D.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:D.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:D.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:D.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:D.COMPRESSED_RGBA_ASTC_4X4_KHR},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};async function Js(t,e){if(e.basis.containerFormat==="auto"){if(Us(t)){const s=await tt(e);return st(s.KTX2File,t,e)}const{BasisFile:n}=await et(e);return be(n,t,e)}switch(e.basis.module){case"encoder":const n=await tt(e);switch(e.basis.containerFormat){case"ktx2":return st(n.KTX2File,t,e);case"basis":default:return be(n.BasisFile,t,e)}case"transcoder":default:const{BasisFile:s}=await et(e);return be(s,t,e)}}function be(t,e,n){const s=new t(new Uint8Array(e));try{if(!s.startTranscoding())throw new Error("Failed to start basis transcoding");const r=s.getNumImages(),o=[];for(let i=0;i<r;i++){const a=s.getNumLevels(i),c=[];for(let l=0;l<a;l++)c.push(ws(s,i,l,n));o.push(c)}return o}finally{s.close(),s.delete()}}function ws(t,e,n,s){const r=t.getImageWidth(e,n),o=t.getImageHeight(e,n),i=t.getHasAlpha(),{compressed:a,format:c,basisFormat:l}=vt(s,i),f=t.getImageTranscodedSizeInBytes(e,n,l),u=new Uint8Array(f);if(!t.transcodeImage(u,e,n,l,0,0))throw new Error("failed to start Basis transcoding");return{width:r,height:o,data:u,compressed:a,format:c,hasAlpha:i}}function st(t,e,n){const s=new t(new Uint8Array(e));try{if(!s.startTranscoding())throw new Error("failed to start KTX2 transcoding");const r=s.getLevels(),o=[];for(let i=0;i<r;i++)o.push(Ks(s,i,n));return[o]}finally{s.close(),s.delete()}}function Ks(t,e,n){const{alphaFlag:s,height:r,width:o}=t.getImageLevelInfo(e,0,0),{compressed:i,format:a,basisFormat:c}=vt(n,s),l=t.getImageTranscodedSizeInBytes(e,0,0,c),f=new Uint8Array(l);if(!t.transcodeImage(f,e,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:o,height:r,data:f,compressed:i,levelSize:l,hasAlpha:s,format:a}}function vt(t,e){let n=t&&t.basis&&t.basis.format;return n==="auto"&&(n=Dt()),typeof n=="object"&&(n=e?n.alpha:n.noAlpha),n=n.toLowerCase(),Ns[n]}function Dt(){const t=Hs();return t.has("astc")?"astc-4x4":t.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:t.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:t.has("etc1")?"etc1":t.has("etc2")?"etc2":"rgb565"}const js={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:vs,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},Vs={...js,parse:Js};function Xs(t){return{addressModeU:rt(t.wrapS),addressModeV:rt(t.wrapT),magFilter:Qs(t.magFilter),...Ys(t.minFilter)}}function rt(t){switch(t){case 33071:return"clamp-to-edge";case 10497:return"repeat";case 33648:return"mirror-repeat";default:return}}function Qs(t){switch(t){case 9728:return"nearest";case 9729:return"linear";default:return}}function Ys(t){switch(t){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 ks(t,e,n,s){const r={defines:{MANUAL_SRGB:!0,SRGB_FAST_APPROXIMATION:!0},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};r.defines.USE_TEX_LOD=!0;const{imageBasedLightingEnvironment:o}=s;return o&&(r.bindings.pbr_diffuseEnvSampler=o.diffuseEnvSampler.texture,r.bindings.pbr_specularEnvSampler=o.specularEnvSampler.texture,r.bindings.pbr_BrdfLUT=o.brdfLutTexture.texture,r.uniforms.scaleIBLAmbient=[1,1]),s?.pbrDebug&&(r.defines.PBR_DEBUG=!0,r.uniforms.scaleDiffBaseMR=[0,0,0,0],r.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(r.defines.HAS_NORMALS=!0),n.TANGENT&&s?.useTangents&&(r.defines.HAS_TANGENTS=!0),n.TEXCOORD_0&&(r.defines.HAS_UV=!0),s?.imageBasedLightingEnvironment&&(r.defines.USE_IBL=!0),s?.lights&&(r.defines.USE_LIGHTS=!0),e&&zs(t,e,r),r}function zs(t,e,n){if(n.uniforms.unlit=!!e.unlit,e.pbrMetallicRoughness&&Ws(t,e.pbrMetallicRoughness,n),e.normalTexture){w(t,e.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",n);const{scale:s=1}=e.normalTexture;n.uniforms.normalScale=s}if(e.occlusionTexture){w(t,e.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",n);const{strength:s=1}=e.occlusionTexture;n.uniforms.occlusionStrength=s}switch(e.emissiveTexture&&(w(t,e.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",n),n.uniforms.emissiveFactor=e.emissiveFactor||[0,0,0]),e.alphaMode||"MASK"){case"MASK":const{alphaCutoff:s=.5}=e;n.defines.ALPHA_CUTOFF=!0,n.uniforms.alphaCutoff=s;break;case"BLEND":L.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 Ws(t,e,n){e.baseColorTexture&&w(t,e.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",n),n.uniforms.baseColorFactor=e.baseColorFactor||[1,1,1,1],e.metallicRoughnessTexture&&w(t,e.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",n);const{metallicFactor:s=1,roughnessFactor:r=1}=e;n.uniforms.metallicRoughnessValues=[s,r]}function w(t,e,n,s,r){const o=e.texture.source.image;let i;o.compressed?i=o:i={data:o};const a={wrapS:10497,wrapT:10497,...e?.texture?.sampler},c=t.createTexture({id:e.uniformName||e.id,sampler:Xs(a),...i});r.bindings[n]=c,s&&(r.defines[s]=!0),r.generatedTextures.push(c)}var _;(function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(_||(_={}));function Zs(t){switch(t){case _.POINTS:return"point-list";case _.LINES:return"line-list";case _.LINE_STRIP:return"line-strip";case _.TRIANGLES:return"triangle-list";case _.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(t))}}const qs=`
930
+ layout(0) positions: vec4; // in vec4 POSITION;
931
+
932
+ #ifdef HAS_NORMALS
933
+ in vec4 normals; // in vec4 NORMAL;
934
+ #endif
935
+
936
+ #ifdef HAS_TANGENTS
937
+ in vec4 TANGENT;
938
+ #endif
939
+
940
+ #ifdef HAS_UV
941
+ // in vec2 TEXCOORD_0;
942
+ in vec2 texCoords;
943
+ #endif
944
+
945
+ @vertex
946
+ void main(void) {
947
+ vec4 _NORMAL = vec4(0.);
948
+ vec4 _TANGENT = vec4(0.);
949
+ vec2 _TEXCOORD_0 = vec2(0.);
950
+
951
+ #ifdef HAS_NORMALS
952
+ _NORMAL = normals;
953
+ #endif
954
+
955
+ #ifdef HAS_TANGENTS
956
+ _TANGENT = TANGENT;
957
+ #endif
958
+
959
+ #ifdef HAS_UV
960
+ _TEXCOORD_0 = texCoords;
961
+ #endif
962
+
963
+ pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
964
+ gl_Position = u_MVPMatrix * positions;
965
+ }
966
+
967
+ @fragment
968
+ out vec4 fragmentColor;
969
+
970
+ void main(void) {
971
+ vec3 pos = pbr_vPosition;
972
+ fragmentColor = pbr_filterColor(vec4(1.0));
973
+ }
974
+ `,$s=`#version 300 es
975
+
976
+ // in vec4 POSITION;
977
+ in vec4 positions;
978
+
979
+ #ifdef HAS_NORMALS
980
+ // in vec4 NORMAL;
981
+ in vec4 normals;
982
+ #endif
983
+
984
+ #ifdef HAS_TANGENTS
985
+ in vec4 TANGENT;
986
+ #endif
987
+
988
+ #ifdef HAS_UV
989
+ // in vec2 TEXCOORD_0;
990
+ in vec2 texCoords;
991
+ #endif
992
+
993
+ void main(void) {
994
+ vec4 _NORMAL = vec4(0.);
995
+ vec4 _TANGENT = vec4(0.);
996
+ vec2 _TEXCOORD_0 = vec2(0.);
997
+
998
+ #ifdef HAS_NORMALS
999
+ _NORMAL = normals;
1000
+ #endif
1001
+
1002
+ #ifdef HAS_TANGENTS
1003
+ _TANGENT = TANGENT;
1004
+ #endif
1005
+
1006
+ #ifdef HAS_UV
1007
+ _TEXCOORD_0 = texCoords;
1008
+ #endif
1009
+
1010
+ pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
1011
+ gl_Position = pbrProjection.modelViewProjectionMatrix * positions;
1012
+ }
1013
+ `,er=`#version 300 es
1014
+ out vec4 fragmentColor;
1015
+
1016
+ void main(void) {
1017
+ vec3 pos = pbr_vPosition;
1018
+ fragmentColor = pbr_filterColor(vec4(1.0));
1019
+ }
1020
+ `;function tr(t,e){const{id:n,geometry:s,parsedPPBRMaterial:r,vertexCount:o,modelOptions:i={}}=e;L.info(4,"createGLTFModel defines: ",r.defines)();const a=[],c={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},l={id:n,source:qs,vs:$s,fs:er,geometry:s,topology:s.topology,vertexCount:o,modules:[Ft],...i,defines:{...r.defines,...i.defines},parameters:{...c,...r.parameters,...i.parameters}},f=new bt(t,l),{camera:u,...A}={...r.uniforms,...i.uniforms,...r.bindings,...i.bindings};return f.shaderInputs.setProps({pbrMaterial:A,pbrProjection:{camera:u}}),new Re({managedResources:a,model:f})}const nr={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:void 0,lights:!0,useTangents:!1};function sr(t,e,n={}){const s={...nr,...n};return e.scenes.map(o=>rr(t,o,e.nodes,s))}function rr(t,e,n,s){const o=(e.nodes||[]).map(a=>St(t,a,n,s));return new U({id:e.name||e.id,children:o})}function St(t,e,n,s){if(!e._node){const i=(e.children||[]).map(c=>St(t,c,n,s));e.mesh&&i.push(or(t,e.mesh,s));const a=new U({id:e.name||e.id,children:i});if(e.matrix)a.setMatrix(e.matrix);else{if(a.matrix.identity(),e.translation&&a.matrix.translate(e.translation),e.rotation){const c=new x().fromQuaternion(e.rotation);a.matrix.multiplyRight(c)}e.scale&&a.matrix.scale(e.scale)}e._node=a}const r=n.find(o=>o.id===e.id);return r._node=e._node,e._node}function or(t,e,n){if(!e._mesh){const r=(e.primitives||[]).map((i,a)=>ir(t,i,a,e,n)),o=new U({id:e.name||e.id,children:r});e._mesh=o}return e._mesh}function ir(t,e,n,s,r){const o=e.name||`${s.name||s.id}-primitive-${n}`,i=Zs(e.mode||4),a=e.indices?e.indices.count:ar(e.attributes),c=ot(o,e,i),l=ks(t,e.material,c.attributes,r),f=tr(t,{id:o,geometry:ot(o,e,i),parsedPPBRMaterial:l,modelOptions:r.modelOptions,vertexCount:a});return f.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],f}function ar(t){throw new Error("getVertexCount not implemented")}function ot(t,e,n){const s={};for(const[r,o]of Object.entries(e.attributes)){const{components:i,size:a,value:c}=o;s[r]={size:a??i,value:c}}return new $({id:t,topology:n,indices:e.indices.value,attributes:s})}const ge=new gs;function cr(t,{input:e,interpolation:n,output:s},r,o){const i=e[e.length-1],a=t%i,c=e.findIndex(A=>A>=a),l=Math.max(0,c-1);if(!Array.isArray(r[o]))switch(o){case"translation":r[o]=[0,0,0];break;case"rotation":r[o]=[0,0,0,1];break;case"scale":r[o]=[1,1,1];break;default:L.warn(`Bad animation path ${o}`)()}const f=e[l],u=e[c];switch(n){case"STEP":ur(r,o,s[l]);break;case"LINEAR":if(u>f){const A=(a-f)/(u-f);lr(r,o,s[l],s[c],A)}break;case"CUBICSPLINE":if(u>f){const A=(a-f)/(u-f),d=u-f,B=s[3*l+1],m=s[3*l+2],p=s[3*c+0],C=s[3*c+1];fr(r,o,{p0:B,outTangent0:m,inTangent1:p,p1:C,tDiff:d,ratio:A})}break;default:L.warn(`Interpolation ${n} not supported`)();break}}function lr(t,e,n,s,r){if(!t[e])throw new Error;if(e==="rotation"){ge.slerp({start:n,target:s,ratio:r});for(let o=0;o<ge.length;o++)t[e][o]=ge[o]}else for(let o=0;o<n.length;o++)t[e][o]=r*s[o]+(1-r)*n[o]}function fr(t,e,{p0:n,outTangent0:s,inTangent1:r,p1:o,tDiff:i,ratio:a}){if(!t[e])throw new Error;for(let c=0;c<t[e].length;c++){const l=s[c]*i,f=r[c]*i;t[e][c]=(2*Math.pow(a,3)-3*Math.pow(a,2)+1)*n[c]+(Math.pow(a,3)-2*Math.pow(a,2)+a)*l+(-2*Math.pow(a,3)+3*Math.pow(a,2))*o[c]+(Math.pow(a,3)-Math.pow(a,2))*f}}function ur(t,e,n){if(!t[e])throw new Error;for(let s=0;s<n.length;s++)t[e][s]=n[s]}class Ar{animation;startTime=0;playing=!0;speed=1;constructor(e){this.animation=e.animation,this.animation.name||="unnamed",Object.assign(this,e)}setTime(e){if(!this.playing)return;const s=(e/1e3-this.startTime)*this.speed;this.animation.channels.forEach(({sampler:r,target:o,path:i})=>{cr(s,r,o,i),mr(o,o._node)})}}class dr{animations;constructor(e){this.animations=e.animations.map((n,s)=>{const r=n.name||`Animation-${s}`;return new Ar({animation:{name:r,channels:n.channels}})})}animate(e){L.warn("GLTFAnimator#animate is deprecated. Use GLTFAnimator#setTime instead")(),this.setTime(e)}setTime(e){this.animations.forEach(n=>n.setTime(e))}getAnimations(){return this.animations}}const Br=new x;function mr(t,e){if(e.matrix.identity(),t.translation&&e.matrix.translate(t.translation),t.rotation){const n=Br.fromQuaternion(t.rotation);e.matrix.multiplyRight(n)}t.scale&&e.matrix.scale(t.scale)}const hr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},pr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Cr(t){const e=pr[t.componentType],n=hr[t.type],s=n*t.count,{buffer:r,byteOffset:o=0}=t.bufferView?.data??{};return{typedArray:new e(r,o+(t.byteOffset||0),s),components:n}}function br(t){return(t.animations||[]).map((n,s)=>{const r=n.name||`Animation-${s}`,o=n.samplers.map(({input:a,interpolation:c="LINEAR",output:l})=>({input:it(t.accessors[a]),interpolation:c,output:it(t.accessors[l])})),i=n.channels.map(({sampler:a,target:c})=>({sampler:o[a],target:t.nodes[c.node??0],path:c.path}));return{name:r,channels:i}})}function it(t){if(!t._animation){const{typedArray:e,components:n}=Cr(t);if(n===1)t._animation=Array.from(e);else{const s=[];for(let r=0;r<e.length;r+=n)s.push(Array.from(e.slice(r,r+n)));t._animation=s}}return t._animation}function Ge(t){if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ImageBitmap)return t;if(Array.isArray(t))return t.map(Ge);if(t&&typeof t=="object"){const e={};for(const n in t)e[n]=Ge(t[n]);return e}return t}function gr(t,e,n){e=Ge(e);const s=sr(t,e,n),r=br(e),o=new dr({animations:r});return{scenes:s,animator:o}}function T(t,e){if(!t)throw new Error(e||"assert failed: gltf")}const Ot={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xt={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Er=1.33,at=["SCALAR","VEC2","VEC3","VEC4"],Ir=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Mr=new Map(Ir),Tr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yr={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Fr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Lt(t){return at[t-1]||at[0]}function ce(t){const e=Mr.get(t.constructor);if(!e)throw new Error("Illegal typed array");return e}function Le(t,e){const n=Fr[t.componentType],s=Tr[t.type],r=yr[t.componentType],o=t.count*s,i=t.count*s*r;T(i>=0&&i<=e.byteLength);const a=xt[t.componentType],c=Ot[t.type];return{ArrayType:n,length:o,byteLength:i,componentByteSize:a,numberOfComponentsInElement:c}}function za(t){let{images:e,bufferViews:n}=t;e=e||[],n=n||[];const s=e.map(i=>i.bufferView);n=n.filter(i=>!s.includes(i));const r=n.reduce((i,a)=>i+a.byteLength,0),o=e.reduce((i,a)=>{const{width:c,height:l}=a.image;return i+c*l},0);return r+Math.ceil(4*o*Er)}function _r(t,e,n){const s=t.bufferViews[n];T(s);const r=s.buffer,o=e[r];T(o);const i=(s.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,i,s.byteLength)}function Rr(t,e,n){const s=typeof n=="number"?t.accessors?.[n]:n;if(!s)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);const r=t.bufferViews?.[s.bufferView||0];if(!r)throw new Error(`No gltf buffer view for accessor ${r}`);const{arrayBuffer:o,byteOffset:i}=e[r.buffer],a=(i||0)+(s.byteOffset||0)+(r.byteOffset||0),{ArrayType:c,length:l,componentByteSize:f,numberOfComponentsInElement:u}=Le(s,r),A=f*u,d=r.byteStride||A;if(typeof r.byteStride>"u"||r.byteStride===A)return new c(o,a,l);const B=new c(l);for(let m=0;m<s.count;m++){const p=new c(o,a+m*d,u);B.set(p,m*u)}return B}function Gr(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}class b{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||Gr(),buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const n=this.getUsedExtensions().find(r=>r===e),s=this.getRequiredExtensions().find(r=>r===e);return typeof n=="string"||typeof s=="string"}getExtension(e){const n=this.getUsedExtensions().find(r=>r===e),s=this.json.extensions||{};return n?s[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(s=>s===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,n){return(e.extensions||{})[n]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,n){if(typeof n=="object")return n;const s=this.json[e]&&this.json[e][n];if(!s)throw new Error(`glTF file error: Could not find ${e}[${n}]`);return s}getTypedArrayForBufferView(e){e=this.getBufferView(e);const n=e.buffer,s=this.gltf.buffers[n];T(s);const r=(e.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){const n=this.getAccessor(e);return Rr(this.gltf.json,this.gltf.buffers,n)}getTypedArrayForImageData(e){e=this.getAccessor(e);const n=this.getBufferView(e.bufferView),r=this.getBuffer(n.buffer).data,o=n.byteOffset||0;return new Uint8Array(r,o,n.byteLength)}addApplicationData(e,n){return this.json[e]=n,this}addExtraData(e,n){return this.json.extras=this.json.extras||{},this.json.extras[e]=n,this}addObjectExtension(e,n,s){return e.extensions=e.extensions||{},e.extensions[n]=s,this.registerUsedExtension(n),this}setObjectExtension(e,n,s){const r=e.extensions||{};r[n]=s}removeObjectExtension(e,n){const s=e?.extensions||{};if(s[n]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const r=this.json.extensionsRemoved;r.includes(n)||r.push(n)}delete s[n]}addExtension(e,n={}){return T(n),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=n,this.registerUsedExtension(e),n}addRequiredExtension(e,n={}){return T(n),this.addExtension(e,n),this.registerRequiredExtension(e),n}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(n=>n===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(n=>n===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const n=this.json.extensionsRemoved;n.includes(e)||n.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:n}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:n}),this.json.scenes.length-1}addNode(e){const{meshIndex:n,matrix:s}=e;this.json.nodes=this.json.nodes||[];const r={mesh:n};return s&&(r.matrix=s),this.json.nodes.push(r),this.json.nodes.length-1}addMesh(e){const{attributes:n,indices:s,material:r,mode:o=4}=e,a={primitives:[{attributes:this._addAttributes(n),mode:o}]};if(s){const c=this._addIndices(s);a.primitives[0].indices=c}return Number.isFinite(r)&&(a.primitives[0].material=r),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){const s={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addImage(e,n){const s=Gn(e),r=n||s?.mimeType,i={bufferView:this.addBufferView(e),mimeType:r};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e,n=0,s=this.byteLength){const r=e.byteLength;T(Number.isFinite(r)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const o={buffer:n,byteOffset:s,byteLength:r};return this.byteLength+=X(r,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(o),this.json.bufferViews.length-1}addAccessor(e,n){const s={bufferView:e,type:Lt(n.size),componentType:n.componentType,count:n.count,max:n.max,min:n.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(s),this.json.accessors.length-1}addBinaryBuffer(e,n={size:3}){const s=this.addBufferView(e);let r={min:n.min,max:n.max};(!r.min||!r.max)&&(r=this._getAccessorMinMax(e,n.size));const o={size:n.size,componentType:ce(e),count:Math.round(e.length/n.size),min:r.min,max:r.max};return this.addAccessor(s,Object.assign(o,n))}addTexture(e){const{imageIndex:n}=e,s={source:n};return this.json.textures=this.json.textures||[],this.json.textures.push(s),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){const e=this.byteLength,n=new ArrayBuffer(e),s=new Uint8Array(n);let r=0;for(const o of this.sourceBuffers||[])r=wn(o,s,r);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=n,this.sourceBuffers=[n],this.gltf.buffers=[{arrayBuffer:n,byteOffset:0,byteLength:n.byteLength}]}_removeStringFromArray(e,n){let s=!0;for(;s;){const r=e.indexOf(n);r>-1?e.splice(r,1):s=!1}}_addAttributes(e={}){const n={};for(const s in e){const r=e[s],o=this._getGltfAttributeName(s),i=this.addBinaryBuffer(r.value,r);n[o]=i}return n}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,n){const s={min:null,max:null};if(e.length<n)return s;s.min=[],s.max=[];const r=e.subarray(0,n);for(const o of r)s.min.push(o),s.max.push(o);for(let o=n;o<e.length;o+=n)for(let i=0;i<n;i++)s.min[0+i]=Math.min(s.min[0+i],e[o+i]),s.max[0+i]=Math.max(s.max[0+i],e[o+i]);return s}}function ct(t){return(t%1+1)%1}const Ht={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},vr={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},Pt={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function He(t,e){return Pt[e]*Ht[t]}function le(t,e,n,s){if(n!=="UINT8"&&n!=="UINT16"&&n!=="UINT32"&&n!=="UINT64")return null;const r=t.getTypedArrayForBufferView(e),o=fe(r,"SCALAR",n,s+1);return o instanceof BigInt64Array||o instanceof BigUint64Array?null:o}function fe(t,e,n,s=1){const r=Ht[e],o=vr[n],i=Pt[n],a=s*r,c=a*i;let l=t.buffer,f=t.byteOffset;return f%i!==0&&(l=new Uint8Array(l).slice(f,f+c).buffer,f=0),new o(l,f,a)}function Pe(t,e,n){const s=`TEXCOORD_${e.texCoord||0}`,r=n.attributes[s],o=t.getTypedArrayForAccessor(r),i=t.gltf.json,a=e.index,c=i.textures?.[a]?.source;if(typeof c<"u"){const l=i.images?.[c]?.mimeType,f=t.gltf.images?.[c];if(f&&typeof f.width<"u"){const u=[];for(let A=0;A<o.length;A+=2){const d=Dr(f,l,o,A,e.channels);u.push(d)}return u}}return[]}function Ut(t,e,n,s,r){if(!n?.length)return;const o=[];for(const f of n){let u=s.findIndex(A=>A===f);u===-1&&(u=s.push(f)-1),o.push(u)}const i=new Uint32Array(o),a=t.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,c=t.addBufferView(i,a,0),l=t.addAccessor(c,{size:1,componentType:ce(i),count:i.length});r.attributes[e]=l}function Dr(t,e,n,s,r=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=n[s],a=n[s+1];let c=1;e&&(e.indexOf("image/jpeg")!==-1||e.indexOf("image/png")!==-1)&&(c=4);const l=Sr(i,a,t,c);let f=0;for(const u of r){const A=typeof u=="number"?Object.values(o)[u]:o[u],d=l+A.offset,B=vn(t);if(B.data.length<=d)throw new Error(`${B.data.length} <= ${d}`);const m=B.data[d];f|=m<<A.shift}return f}function Sr(t,e,n,s=1){const r=n.width,o=ct(t)*(r-1),i=Math.round(o),a=n.height,c=ct(e)*(a-1),l=Math.round(c),f=n.components?n.components:s;return(l*r+i)*f}function Nt(t,e,n,s,r){const o=[];for(let i=0;i<e;i++){const a=n[i],c=n[i+1]-n[i];if(c+a>s)break;const l=a/r,f=c/r;o.push(t.slice(l,l+f))}return o}function Jt(t,e,n){const s=[];for(let r=0;r<e;r++){const o=r*n;s.push(t.slice(o,o+n))}return s}function wt(t,e,n,s){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(s){const r=[],o=new TextDecoder("utf8");let i=0;for(let a=0;a<t;a++){const c=s[a+1]-s[a];if(c+i<=e.length){const l=e.subarray(i,c+i),f=o.decode(l);r.push(f),i+=c}}return r}return[]}const O="EXT_mesh_features",Or=O;async function xr(t,e){const n=new b(t);Hr(n,e)}function Lr(t,e){const n=new b(t);return Ur(n),n.createBinaryChunk(),n.gltf}function Hr(t,e){const n=t.gltf.json;if(n.meshes)for(const s of n.meshes)for(const r of s.primitives)Pr(t,r,e)}function Pr(t,e,n){if(!n?.gltf?.loadBuffers)return;const r=e.extensions?.[O]?.featureIds;if(r)for(const o of r){let i;if(typeof o.attribute<"u"){const a=`_FEATURE_ID_${o.attribute}`,c=e.attributes[a];i=t.getTypedArrayForAccessor(c)}else typeof o.texture<"u"&&n?.gltf?.loadImages?i=Pe(t,o.texture,e):i=[];o.data=i}}function Ur(t,e){const n=t.gltf.json.meshes;if(n)for(const s of n)for(const r of s.primitives)Jr(t,r)}function Nr(t,e,n,s){e.extensions||(e.extensions={});let r=e.extensions[O];r||(r={featureIds:[]},e.extensions[O]=r);const{featureIds:o}=r,i={featureCount:n.length,propertyTable:s,data:n};o.push(i),t.addObjectExtension(e,O,r)}function Jr(t,e){const n=e.extensions?.[O];if(!n)return;const s=n.featureIds;s.forEach((r,o)=>{if(r.data){const{accessorKey:i,index:a}=wr(e.attributes),c=new Uint32Array(r.data);s[o]={featureCount:c.length,propertyTable:r.propertyTable,attribute:a},t.gltf.buffers.push({arrayBuffer:c.buffer,byteOffset:c.byteOffset,byteLength:c.byteLength});const l=t.addBufferView(c),f=t.addAccessor(l,{size:1,componentType:ce(c),count:c.length});e.attributes[i]=f}})}function wr(t){const e="_FEATURE_ID_",n=Object.keys(t).filter(o=>o.indexOf(e)===0);let s=-1;for(const o of n){const i=Number(o.substring(e.length));i>s&&(s=i)}return s++,{accessorKey:`${e}${s}`,index:s}}const Kr=Object.freeze(Object.defineProperty({__proto__:null,createExtMeshFeatures:Nr,decode:xr,encode:Lr,name:Or},Symbol.toStringTag,{value:"Module"})),H="EXT_structural_metadata",jr=H;async function Vr(t,e){const n=new b(t);Qr(n,e)}function Xr(t,e){const n=new b(t);return co(n),n.createBinaryChunk(),n.gltf}function Qr(t,e){if(!e.gltf?.loadBuffers)return;const n=t.getExtension(H);n&&(e.gltf?.loadImages&&Yr(t,n),kr(t,n))}function Yr(t,e){const n=e.propertyTextures,s=t.gltf.json;if(n&&s.meshes)for(const r of s.meshes)for(const o of r.primitives)Wr(t,n,o,e)}function kr(t,e){const n=e.schema;if(!n)return;const s=n.classes,r=e.propertyTables;if(s&&r)for(const o in s){const i=zr(r,o);i&&qr(t,n,i)}}function zr(t,e){for(const n of t)if(n.class===e)return n;return null}function Wr(t,e,n,s){if(!e)return;const o=n.extensions?.[H]?.propertyTextures;if(o)for(const i of o){const a=e[i];Zr(t,a,n,s)}}function Zr(t,e,n,s){if(!e.properties)return;s.dataAttributeNames||(s.dataAttributeNames=[]);const r=e.class;for(const o in e.properties){const i=`${r}_${o}`,a=e.properties?.[o];if(!a)continue;a.data||(a.data=[]);const c=a.data,l=Pe(t,a,n);l!==null&&(Ut(t,i,l,c,n),a.data=c,s.dataAttributeNames.push(i))}}function qr(t,e,n){const s=e.classes?.[n.class];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const o in s.properties){const i=s.properties[o],a=n.properties?.[o];if(a){const c=$r(t,e,i,r,a);a.data=c}}}function $r(t,e,n,s,r){let o=[];const i=r.values,a=t.getTypedArrayForBufferView(i),c=eo(t,n,r,s),l=to(t,r,s);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{o=no(n,s,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":{o=wt(s,a,c,l);break}case"ENUM":{o=so(e,n,s,a,c);break}default:throw new Error(`Unknown classProperty type ${n.type}`)}return o}function eo(t,e,n,s){return e.array&&typeof e.count>"u"&&typeof n.arrayOffsets<"u"?le(t,n.arrayOffsets,n.arrayOffsetType||"UINT32",s):null}function to(t,e,n){return typeof e.stringOffsets<"u"?le(t,e.stringOffsets,e.stringOffsetType||"UINT32",n):null}function no(t,e,n,s){const r=t.array,o=t.count,i=He(t.type,t.componentType),a=n.byteLength/i;let c;return t.componentType?c=fe(n,t.type,t.componentType,a):c=n,r?s?Nt(c,e,s,n.length,i):o?Jt(c,e,o):[]:c}function so(t,e,n,s,r){const o=e.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const i=t.enums?.[o];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);const a=i.valueType||"UINT16",c=He(e.type,a),l=s.byteLength/c;let f=fe(s,e.type,a,l);if(f||(f=s),e.array){if(r)return ro({valuesData:f,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:s.length,elementSize:c,enumEntry:i});const u=e.count;return u?oo(f,n,u,i):[]}return Ue(f,0,n,i)}function ro(t){const{valuesData:e,numberOfElements:n,arrayOffsets:s,valuesDataBytesLength:r,elementSize:o,enumEntry:i}=t,a=[];for(let c=0;c<n;c++){const l=s[c],f=s[c+1]-s[c];if(f+l>r)break;const u=l/o,A=f/o,d=Ue(e,u,A,i);a.push(d)}return a}function oo(t,e,n,s){const r=[];for(let o=0;o<e;o++){const i=n*o,a=Ue(t,i,n,s);r.push(a)}return r}function Ue(t,e,n,s){const r=[];for(let o=0;o<n;o++)if(t instanceof BigInt64Array||t instanceof BigUint64Array)r.push("");else{const i=t[e+o],a=io(s,i);a?r.push(a.name):r.push("")}return r}function io(t,e){for(const n of t.values)if(n.value===e)return n;return null}const ao="schemaClassId";function co(t,e){const n=t.getExtension(H);if(n&&n.propertyTables)for(const s of n.propertyTables){const r=s.class,o=n.schema?.classes?.[r];s.properties&&o&&lo(s,o,t)}}function lo(t,e,n){for(const s in t.properties){const r=t.properties[s].data;if(r){const o=e.properties[s];if(o){const i=Bo(r,o,n);t.properties[s]=i}}}}function fo(t,e,n=ao){let s=t.getExtension(H);s||(s=t.addExtension(H)),s.schema=uo(e,n,s.schema);const r=Ao(e,n,s.schema);return s.propertyTables||(s.propertyTables=[]),s.propertyTables.push(r)-1}function uo(t,e,n){const s=n??{id:"schema_id"},r={properties:{}};for(const o of t){const i={type:o.elementType,componentType:o.componentType};r.properties[o.name]=i}return s.classes={},s.classes[e]=r,s}function Ao(t,e,n){const s={class:e,count:0};let r=0;const o=n.classes?.[e];for(const i of t){if(r===0&&(r=i.values.length),r!==i.values.length&&i.values.length)throw new Error("Illegal values in attributes");o?.properties[i.name]&&(s.properties||(s.properties={}),s.properties[i.name]={values:0,data:i.values})}return s.count=r,s}function Bo(t,e,n){const s={values:0};if(e.type==="STRING"){const{stringData:r,stringOffsets:o}=po(t);s.stringOffsets=Ee(o,n),s.values=Ee(r,n)}else if(e.type==="SCALAR"&&e.componentType){const r=ho(t,e.componentType);s.values=Ee(r,n)}return s}const mo={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:Int32Array,UINT64:Uint32Array,FLOAT32:Float32Array,FLOAT64:Float64Array};function ho(t,e){const n=[];for(const r of t)n.push(Number(r));const s=mo[e];if(!s)throw new Error("Illegal component type");return new s(n)}function po(t){const e=new TextEncoder,n=[];let s=0;for(const c of t){const l=e.encode(c);s+=l.length,n.push(l)}const r=new Uint8Array(s),o=[];let i=0;for(const c of n)r.set(c,i),o.push(i),i+=c.length;o.push(i);const a=new Uint32Array(o);return{stringData:r,stringOffsets:a}}function Ee(t,e){return e.gltf.buffers.push({arrayBuffer:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength}),e.addBufferView(t)}const Co=Object.freeze(Object.defineProperty({__proto__:null,createExtStructuralMetadata:fo,decode:Vr,encode:Xr,name:jr},Symbol.toStringTag,{value:"Module"})),Kt="EXT_feature_metadata",bo=Kt;async function go(t,e){const n=new b(t);Eo(n,e)}function Eo(t,e){if(!e.gltf?.loadBuffers)return;const n=t.getExtension(Kt);n&&(e.gltf?.loadImages&&Io(t,n),Mo(t,n))}function Io(t,e){const n=e.schema;if(!n)return;const s=n.classes,{featureTextures:r}=e;if(s&&r)for(const o in s){const i=s[o],a=yo(r,o);a&&_o(t,a,i)}}function Mo(t,e){const n=e.schema;if(!n)return;const s=n.classes,r=e.featureTables;if(s&&r)for(const o in s){const i=To(r,o);i&&Fo(t,n,i)}}function To(t,e){for(const n in t){const s=t[n];if(s.class===e)return s}return null}function yo(t,e){for(const n in t){const s=t[n];if(s.class===e)return s}return null}function Fo(t,e,n){if(!n.class)return;const s=e.classes?.[n.class];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);const r=n.count;for(const o in s.properties){const i=s.properties[o],a=n.properties?.[o];if(a){const c=Ro(t,e,i,r,a);a.data=c}}}function _o(t,e,n){const s=e.class;for(const r in n.properties){const o=e?.properties?.[r];if(o){const i=Oo(t,o,s);o.data=i}}}function Ro(t,e,n,s,r){let o=[];const i=r.bufferView,a=t.getTypedArrayForBufferView(i),c=Go(t,n,r,s),l=vo(t,n,r,s);return n.type==="STRING"||n.componentType==="STRING"?o=wt(s,a,c,l):Do(n)&&(o=So(n,s,a,c)),o}function Go(t,e,n,s){return e.type==="ARRAY"&&typeof e.componentCount>"u"&&typeof n.arrayOffsetBufferView<"u"?le(t,n.arrayOffsetBufferView,n.offsetType||"UINT32",s):null}function vo(t,e,n,s){return typeof n.stringOffsetBufferView<"u"?le(t,n.stringOffsetBufferView,n.offsetType||"UINT32",s):null}function Do(t){const e=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return e.includes(t.type)||typeof t.componentType<"u"&&e.includes(t.componentType)}function So(t,e,n,s){const r=t.type==="ARRAY",o=t.componentCount,i="SCALAR",a=t.componentType||t.type,c=He(i,a),l=n.byteLength/c,f=fe(n,i,a,l);return r?s?Nt(f,e,s,n.length,c):o?Jt(f,e,o):[]:f}function Oo(t,e,n){const s=t.gltf.json;if(!s.meshes)return[];const r=[];for(const o of s.meshes)for(const i of o.primitives)xo(t,n,e,r,i);return r}function xo(t,e,n,s,r){const o={channels:n.channels,...n.texture},i=Pe(t,o,r);i&&Ut(t,e,i,s,r)}const Lo=Object.freeze(Object.defineProperty({__proto__:null,decode:go,name:bo},Symbol.toStringTag,{value:"Module"})),Ho="4.3.3",P=!0,lt=1735152710,Ne=12,ie=8,Po=1313821514,Uo=5130562,No=0,Jo=0,wo=1;function Ko(t,e=0){return`${String.fromCharCode(t.getUint8(e+0))}${String.fromCharCode(t.getUint8(e+1))}${String.fromCharCode(t.getUint8(e+2))}${String.fromCharCode(t.getUint8(e+3))}`}function jo(t,e=0,n={}){const s=new DataView(t),{magic:r=lt}=n,o=s.getUint32(e,!1);return o===r||o===lt}function Vo(t,e,n=0,s={}){const r=new DataView(e),o=Ko(r,n+0),i=r.getUint32(n+4,P),a=r.getUint32(n+8,P);switch(Object.assign(t,{header:{byteOffset:n,byteLength:a,hasBinChunk:!1},type:o,version:i,json:{},binChunks:[]}),n+=Ne,t.version){case 1:return Xo(t,r,n);case 2:return Qo(t,r,n,s={});default:throw new Error(`Invalid GLB version ${t.version}. Only supports version 1 and 2.`)}}function Xo(t,e,n){K(t.header.byteLength>Ne+ie);const s=e.getUint32(n+0,P),r=e.getUint32(n+4,P);return n+=ie,K(r===No),ve(t,e,n,s),n+=s,n+=De(t,e,n,t.header.byteLength),n}function Qo(t,e,n,s){return K(t.header.byteLength>Ne+ie),Yo(t,e,n,s),n+t.header.byteLength}function Yo(t,e,n,s){for(;n+8<=t.header.byteLength;){const r=e.getUint32(n+0,P),o=e.getUint32(n+4,P);switch(n+=ie,o){case Po:ve(t,e,n,r);break;case Uo:De(t,e,n,r);break;case Jo:s.strict||ve(t,e,n,r);break;case wo:s.strict||De(t,e,n,r);break}n+=X(r,4)}return n}function ve(t,e,n,s){const r=new Uint8Array(e.buffer,n,s),i=new TextDecoder("utf8").decode(r);return t.json=JSON.parse(i),X(s,4)}function De(t,e,n,s){return t.header.hasBinChunk=!0,t.binChunks.push({byteOffset:n,byteLength:s,arrayBuffer:e.buffer}),X(s,4)}function jt(t,e){if(t.startsWith("data:")||t.startsWith("http:")||t.startsWith("https:"))return t;const s=e.baseUri||e.uri;if(!s)throw new Error(`'baseUri' must be provided to resolve relative url ${t}`);return s.substr(0,s.lastIndexOf("/")+1)+t}const ko="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J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F9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",Wo=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),Zo=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),qo={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},$o={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function ei(t,e,n,s,r,o="NONE"){const i=await ti();ri(i,i.exports[$o[r]],t,e,n,s,i.exports[qo[o||"NONE"]])}let Ie;async function ti(){return Ie||(Ie=ni()),Ie}async function ni(){let t=ko;WebAssembly.validate(Wo)&&(t=zo,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const e=await WebAssembly.instantiate(si(t),{});return await e.instance.exports.__wasm_call_ctors(),e.instance}function si(t){const e=new Uint8Array(t.length);for(let s=0;s<t.length;++s){const r=t.charCodeAt(s);e[s]=r>96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let n=0;for(let s=0;s<t.length;++s)e[n++]=e[s]<60?Zo[e[s]]:(e[s]-60)*64+e[++s];return e.buffer.slice(0,n)}function ri(t,e,n,s,r,o,i){const a=t.exports.sbrk,c=s+3&-4,l=a(c*r),f=a(o.length),u=new Uint8Array(t.exports.memory.buffer);u.set(o,f);const A=e(l,s,r,f,o.length);if(A===0&&i&&i(l,c,r),n.set(u.subarray(l,l+s*r)),a(l-a(0)),A!==0)throw new Error(`Malformed buffer data: ${A}`)}const ae="EXT_meshopt_compression",oi=ae;async function ii(t,e){const n=new b(t);if(!e?.gltf?.decompressMeshes||!e.gltf?.loadBuffers)return;const s=[];for(const r of t.json.bufferViews||[])s.push(ai(n,r));await Promise.all(s),n.removeExtension(ae)}async function ai(t,e){const n=t.getObjectExtension(e,ae);if(n){const{byteOffset:s=0,byteLength:r=0,byteStride:o,count:i,mode:a,filter:c="NONE",buffer:l}=n,f=t.gltf.buffers[l],u=new Uint8Array(f.arrayBuffer,f.byteOffset+s,r),A=new Uint8Array(t.gltf.buffers[e.buffer].arrayBuffer,e.byteOffset,e.byteLength);await ei(A,i,o,u,a,c),t.removeObjectExtension(e,ae)}}const ci=Object.freeze(Object.defineProperty({__proto__:null,decode:ii,name:oi},Symbol.toStringTag,{value:"Module"})),S="EXT_texture_webp",li=S;function fi(t,e){const n=new b(t);if(!Xn("image/webp")){if(n.getRequiredExtensions().includes(S))throw new Error(`gltf: Required extension ${S} not supported by browser`);return}const{json:s}=n;for(const r of s.textures||[]){const o=n.getObjectExtension(r,S);o&&(r.source=o.source),n.removeObjectExtension(r,S)}n.removeExtension(S)}const ui=Object.freeze(Object.defineProperty({__proto__:null,name:li,preprocess:fi},Symbol.toStringTag,{value:"Module"})),ne="KHR_texture_basisu",Ai=ne;function di(t,e){const n=new b(t),{json:s}=n;for(const r of s.textures||[]){const o=n.getObjectExtension(r,ne);o&&(r.source=o.source,n.removeObjectExtension(r,ne))}n.removeExtension(ne)}const Bi=Object.freeze(Object.defineProperty({__proto__:null,name:Ai,preprocess:di},Symbol.toStringTag,{value:"Module"})),mi="4.3.3",hi={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:mi,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function pi(t,e,n){const s=Vt(e.metadata),r=[],o=Ci(e.attributes);for(const i in t){const a=t[i],c=ft(i,a,o[i]);r.push(c)}if(n){const i=ft("indices",n);r.push(i)}return{fields:r,metadata:s}}function Ci(t){const e={};for(const n in t){const s=t[n];e[s.name||"undefined"]=s}return e}function ft(t,e,n){const s=n?Vt(n.metadata):void 0;return jn(t,e,s)}function Vt(t){Object.entries(t);const e={};for(const n in t)e[`${n}.string`]=JSON.stringify(t[n]);return e}const ut={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},bi={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},gi=4;class Ei{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,n={}){const s=new this.draco.DecoderBuffer;s.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(n);const r=this.decoder.GetEncodedGeometryType(s),o=r===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(r){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(s,o);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(s,o);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!o.ptr){const A=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(A)}const a=this._getDracoLoaderData(o,r,n),c=this._getMeshData(o,a,n),l=It(c.attributes),f=pi(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:o.num_points(),boundingBox:l},...c,schema:f}}finally{this.draco.destroy(s),o&&this.draco.destroy(o)}}_getDracoLoaderData(e,n,s){const r=this._getTopLevelMetadata(e),o=this._getDracoAttributes(e,s);return{geometry_type:n,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:r,attributes:o}}_getDracoAttributes(e,n){const s={};for(let r=0;r<e.num_attributes();r++){const o=this.decoder.GetAttribute(e,r),i=this._getAttributeMetadata(e,r);s[o.unique_id()]={unique_id:o.unique_id(),attribute_type:o.attribute_type(),data_type:o.data_type(),num_components:o.num_components(),byte_offset:o.byte_offset(),byte_stride:o.byte_stride(),normalized:o.normalized(),attribute_index:r,metadata:i};const a=this._getQuantizationTransform(o,n);a&&(s[o.unique_id()].quantization_transform=a);const c=this._getOctahedronTransform(o,n);c&&(s[o.unique_id()].octahedron_transform=c)}return s}_getMeshData(e,n,s){const r=this._getMeshAttributes(n,e,s);if(!r.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(s.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:r,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:r,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:r}}_getMeshAttributes(e,n,s){const r={};for(const o of Object.values(e.attributes)){const i=this._deduceAttributeName(o,s);o.name=i;const a=this._getAttributeValues(n,o);if(a){const{value:c,size:l}=a;r[i]={value:c,size:l,byteOffset:o.byte_offset,byteStride:o.byte_stride,normalized:o.normalized}}}return r}_getTriangleListIndices(e){const s=e.num_faces()*3,r=s*gi,o=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(e,r,o),new Uint32Array(this.draco.HEAPF32.buffer,o,s).slice()}finally{this.draco._free(o)}}_getTriangleStripIndices(e){const n=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,n),Ti(n)}finally{this.draco.destroy(n)}}_getAttributeValues(e,n){const s=bi[n.data_type];if(!s)return console.warn(`DRACO: Unsupported attribute type ${n.data_type}`),null;const r=n.num_components,i=e.num_points()*r,a=i*s.BYTES_PER_ELEMENT,c=Ii(this.draco,s);let l;const f=this.draco._malloc(a);try{const u=this.decoder.GetAttribute(e,n.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,u,c,a,f),l=new s(this.draco.HEAPF32.buffer,f,i).slice()}finally{this.draco._free(f)}return{value:l,size:r}}_deduceAttributeName(e,n){const s=e.unique_id;for(const[i,a]of Object.entries(n.extraAttributes||{}))if(a===s)return i;const r=e.attribute_type;for(const i in ut)if(this.draco[i]===r)return ut[i];const o=n.attributeNameEntry||"name";return e.metadata[o]?e.metadata[o].string:`CUSTOM_ATTRIBUTE_${s}`}_getTopLevelMetadata(e){const n=this.decoder.GetMetadata(e);return this._getDracoMetadata(n)}_getAttributeMetadata(e,n){const s=this.decoder.GetAttributeMetadata(e,n);return this._getDracoMetadata(s)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const n={},s=this.metadataQuerier.NumEntries(e);for(let r=0;r<s;r++){const o=this.metadataQuerier.GetEntryName(e,r);n[o]=this._getDracoMetadataField(e,o)}return n}_getDracoMetadataField(e,n){const s=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,n,s);const r=Mi(s);return{int:this.metadataQuerier.GetIntEntry(e,n),string:this.metadataQuerier.GetStringEntry(e,n),double:this.metadataQuerier.GetDoubleEntry(e,n),intArray:r}}finally{this.draco.destroy(s)}}_disableAttributeTransforms(e){const{quantizedAttributes:n=[],octahedronAttributes:s=[]}=e,r=[...n,...s];for(const o of r)this.decoder.SkipAttributeTransform(this.draco[o])}_getQuantizationTransform(e,n){const{quantizedAttributes:s=[]}=n,r=e.attribute_type();if(s.map(i=>this.decoder[i]).includes(r)){const i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(a=>i.min_value(a))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(e,n){const{octahedronAttributes:s=[]}=n,r=e.attribute_type();if(s.map(i=>this.decoder[i]).includes(r)){const i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}}function Ii(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function Mi(t){const e=t.size(),n=new Int32Array(e);for(let s=0;s<e;s++)n[s]=t.GetValue(s);return n}function Ti(t){const e=t.size(),n=new Int32Array(e);for(let s=0;s<e;s++)n[s]=t.GetValue(s);return n}const yi="1.5.6",Fi="1.4.1",Me=`https://www.gstatic.com/draco/versioned/decoders/${yi}`,E={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},Te={[E.DECODER]:`${Me}/${E.DECODER}`,[E.DECODER_WASM]:`${Me}/${E.DECODER_WASM}`,[E.FALLBACK_DECODER]:`${Me}/${E.FALLBACK_DECODER}`,[E.ENCODER]:`https://raw.githubusercontent.com/google/draco/${Fi}/javascript/${E.ENCODER}`};let ye;async function _i(t){const e=t.modules||{};return e.draco3d?ye||=e.draco3d.createDecoderModule({}).then(n=>({draco:n})):ye||=Ri(t),await ye}async function Ri(t){let e,n;switch(t.draco&&t.draco.decoderType){case"js":e=await v(Te[E.FALLBACK_DECODER],"draco",t,E.FALLBACK_DECODER);break;case"wasm":default:[e,n]=await Promise.all([await v(Te[E.DECODER],"draco",t,E.DECODER),await v(Te[E.DECODER_WASM],"draco",t,E.DECODER_WASM)])}return e=e||globalThis.DracoDecoderModule,await Gi(e,n)}function Gi(t,e){const n={};return e&&(n.wasmBinary=e),new Promise(s=>{t({...n,onModuleLoaded:r=>s({draco:r})})})}const vi={...hi,parse:Di};async function Di(t,e){const{draco:n}=await _i(e),s=new Ei(n);try{return s.parseSync(t,e?.draco)}finally{s.destroy()}}function Si(t){const e={};for(const n in t){const s=t[n];if(n!=="indices"){const r=Xt(s);e[n]=r}}return e}function Xt(t){const{buffer:e,size:n,count:s}=Oi(t);return{value:e,size:n,byteOffset:0,count:s,type:Lt(n),componentType:ce(e)}}function Oi(t){let e=t,n=1,s=0;return t&&t.value&&(e=t.value,n=t.size||1),e&&(ArrayBuffer.isView(e)||(e=xi(e,Float32Array)),s=e.length/n),{buffer:e,size:n,count:s}}function xi(t,e,n=!1){return t?Array.isArray(t)?new e(t):n&&!(t instanceof e)?new e(t):t:null}const F="KHR_draco_mesh_compression",Li=F;function Hi(t,e,n){const s=new b(t);for(const r of Qt(s))s.getObjectExtension(r,F)}async function Pi(t,e,n){if(!e?.gltf?.decompressMeshes)return;const s=new b(t),r=[];for(const o of Qt(s))s.getObjectExtension(o,F)&&r.push(Ni(s,o,e,n));await Promise.all(r),s.removeExtension(F)}function Ui(t,e={}){const n=new b(t);for(const s of n.json.meshes||[])Ji(s),n.addRequiredExtension(F)}async function Ni(t,e,n,s){const r=t.getObjectExtension(e,F);if(!r)return;const o=t.getTypedArrayForBufferView(r.bufferView),i=gt(o.buffer,o.byteOffset),a={...n};delete a["3d-tiles"];const c=await Et(i,vi,a,s),l=Si(c.attributes);for(const[f,u]of Object.entries(l))if(f in e.attributes){const A=e.attributes[f],d=t.getAccessor(A);d?.min&&d?.max&&(u.min=d.min,u.max=d.max)}e.attributes=l,c.indices&&(e.indices=Xt(c.indices)),t.removeObjectExtension(e,F),wi(e)}function Ji(t,e,n=4,s,r){if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=s.DracoWriter.encodeSync({attributes:t}),i=r?.parseSync?.({attributes:t}),a=s._addFauxAttributes(i.attributes),c=s.addBufferView(o);return{primitives:[{attributes:a,mode:n,extensions:{[F]:{bufferView:c,attributes:a}}}]}}function wi(t){if(!t.attributes&&Object.keys(t.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*Qt(t){for(const e of t.json.meshes||[])for(const n of e.primitives)yield n}const Ki=Object.freeze(Object.defineProperty({__proto__:null,decode:Pi,encode:Ui,name:Li,preprocess:Hi},Symbol.toStringTag,{value:"Module"})),ue="KHR_texture_transform",ji=ue,q=new G,Vi=new Q,Xi=new Q;async function Qi(t,e){if(!new b(t).hasExtension(ue)||!e.gltf?.loadBuffers)return;const r=t.json.materials||[];for(let o=0;o<r.length;o++)Yi(o,t)}function Yi(t,e){const n=e.json.materials?.[t],s=[n?.pbrMetallicRoughness?.baseColorTexture,n?.emissiveTexture,n?.normalTexture,n?.occlusionTexture,n?.pbrMetallicRoughness?.metallicRoughnessTexture],r=[];for(const o of s)o&&o?.extensions?.[ue]&&ki(e,t,o,r)}function ki(t,e,n,s){const r=zi(n,s);if(!r)return;const o=t.json.meshes||[];for(const i of o)for(const a of i.primitives){const c=a.material;Number.isFinite(c)&&e===c&&Wi(t,a,r)}}function zi(t,e){const n=t.extensions?.[ue],{texCoord:s=0}=t,{texCoord:r=s}=n;if(!(e.findIndex(([i,a])=>i===s&&a===r)!==-1)){const i=$i(n);return s!==r&&(t.texCoord=r),e.push([s,r]),{originalTexCoord:s,texCoord:r,matrix:i}}return null}function Wi(t,e,n){const{originalTexCoord:s,texCoord:r,matrix:o}=n,i=e.attributes[`TEXCOORD_${s}`];if(Number.isFinite(i)){const a=t.json.accessors?.[i];if(a&&a.bufferView){const c=t.json.bufferViews?.[a.bufferView];if(c){const{arrayBuffer:l,byteOffset:f}=t.buffers[c.buffer],u=(f||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:A,length:d}=Le(a,c),B=xt[a.componentType],m=Ot[a.type],p=c.byteStride||B*m,C=new Float32Array(d);for(let I=0;I<a.count;I++){const h=new A(l,u+I*p,2);q.set(h[0],h[1],1),q.transformByMatrix3(o),C.set([q[0],q[1]],I*m)}s===r?Zi(a,c,t.buffers,C):qi(r,a,e,t,C)}}}}function Zi(t,e,n,s){t.componentType=5126,n.push({arrayBuffer:s.buffer,byteOffset:0,byteLength:s.buffer.byteLength}),e.buffer=n.length-1,e.byteLength=s.buffer.byteLength,e.byteOffset=0,delete e.byteStride}function qi(t,e,n,s,r){s.buffers.push({arrayBuffer:r.buffer,byteOffset:0,byteLength:r.buffer.byteLength});const o=s.json.bufferViews;if(!o)return;o.push({buffer:s.buffers.length-1,byteLength:r.buffer.byteLength,byteOffset:0});const i=s.json.accessors;i&&(i.push({bufferView:o?.length-1,byteOffset:0,componentType:5126,count:e.count,type:"VEC2"}),n.attributes[`TEXCOORD_${t}`]=i.length-1)}function $i(t){const{offset:e=[0,0],rotation:n=0,scale:s=[1,1]}=t,r=new Q().set(1,0,0,0,1,0,e[0],e[1],1),o=Vi.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),i=Xi.set(s[0],0,0,0,s[1],0,0,0,1);return r.multiplyRight(o).multiplyRight(i)}const ea=Object.freeze(Object.defineProperty({__proto__:null,decode:Qi,name:ji},Symbol.toStringTag,{value:"Module"})),R="KHR_lights_punctual",ta=R;async function na(t){const e=new b(t),{json:n}=e,s=e.getExtension(R);s&&(e.json.lights=s.lights,e.removeExtension(R));for(const r of n.nodes||[]){const o=e.getObjectExtension(r,R);o&&(r.light=o.light),e.removeObjectExtension(r,R)}}async function sa(t){const e=new b(t),{json:n}=e;if(n.lights){const s=e.addExtension(R);T(!s.lights),s.lights=n.lights,delete n.lights}if(e.json.lights){for(const s of e.json.lights){const r=s.node;e.addObjectExtension(r,R,s)}delete e.json.lights}}const ra=Object.freeze(Object.defineProperty({__proto__:null,decode:na,encode:sa,name:ta},Symbol.toStringTag,{value:"Module"})),j="KHR_materials_unlit",oa=j;async function ia(t){const e=new b(t),{json:n}=e;for(const s of n.materials||[])s.extensions&&s.extensions.KHR_materials_unlit&&(s.unlit=!0),e.removeObjectExtension(s,j);e.removeExtension(j)}function aa(t){const e=new b(t),{json:n}=e;if(e.materials)for(const s of n.materials||[])s.unlit&&(delete s.unlit,e.addObjectExtension(s,j,{}),e.addExtension(j))}const ca=Object.freeze(Object.defineProperty({__proto__:null,decode:ia,encode:aa,name:oa},Symbol.toStringTag,{value:"Module"})),J="KHR_techniques_webgl",la=J;async function fa(t){const e=new b(t),{json:n}=e,s=e.getExtension(J);if(s){const r=Aa(s,e);for(const o of n.materials||[]){const i=e.getObjectExtension(o,J);i&&(o.technique=Object.assign({},i,r[i.technique]),o.technique.values=da(o.technique,e)),e.removeObjectExtension(o,J)}e.removeExtension(J)}}async function ua(t,e){}function Aa(t,e){const{programs:n=[],shaders:s=[],techniques:r=[]}=t,o=new TextDecoder;return s.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=o.decode(e.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),n.forEach(i=>{i.fragmentShader=s[i.fragmentShader],i.vertexShader=s[i.vertexShader]}),r.forEach(i=>{i.program=n[i.program]}),r}function da(t,e){const n=Object.assign({},t.values);return Object.keys(t.uniforms||{}).forEach(s=>{t.uniforms[s].value&&!(s in n)&&(n[s]=t.uniforms[s].value)}),Object.keys(n).forEach(s=>{typeof n[s]=="object"&&n[s].index!==void 0&&(n[s].texture=e.getTexture(n[s].index))}),n}const Ba=Object.freeze(Object.defineProperty({__proto__:null,decode:fa,encode:ua,name:la},Symbol.toStringTag,{value:"Module"})),Yt=[Co,Kr,ci,ui,Bi,Ki,ra,ca,Ba,ea,Lo];function ma(t,e={},n){const s=Yt.filter(r=>kt(r.name,e));for(const r of s)r.preprocess?.(t,e,n)}async function ha(t,e={},n){const s=Yt.filter(r=>kt(r.name,e));for(const r of s)await r.decode?.(t,e,n)}function kt(t,e){const n=e?.gltf?.excludeExtensions||{};return!(t in n&&!n[t])}const Fe="KHR_binary_glTF";function pa(t){const e=new b(t),{json:n}=e;for(const s of n.images||[]){const r=e.getObjectExtension(s,Fe);r&&Object.assign(s,r),e.removeObjectExtension(s,Fe)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,e.removeExtension(Fe)}const At={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Ca={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class ba{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,n){this.json=e.json;const s=e.json;switch(s.asset&&s.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${s.asset.version}`);return}if(!n.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(s),this._convertTopLevelObjectsToArrays(s),pa(e),this._convertObjectIdsToArrayIndices(s),this._updateObjects(s),this._updateMaterial(s)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const n in At)this._convertTopLevelObjectToArray(e,n)}_convertTopLevelObjectToArray(e,n){const s=e[n];if(!(!s||Array.isArray(s))){e[n]=[];for(const r in s){const o=s[r];o.id=o.id||r;const i=e[n].length;e[n].push(o),this.idToIndexMap[n][r]=i}}}_convertObjectIdsToArrayIndices(e){for(const n in At)this._convertIdsToIndices(e,n);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const n of e.textures)this._convertTextureIds(n);for(const n of e.meshes)this._convertMeshIds(n);for(const n of e.nodes)this._convertNodeIds(n);for(const n of e.scenes)this._convertSceneIds(n)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const n of e.primitives){const{attributes:s,indices:r,material:o}=n;for(const i in s)s[i]=this._convertIdToIndex(s[i],"accessor");r&&(n.indices=this._convertIdToIndex(r,"accessor")),o&&(n.material=this._convertIdToIndex(o,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(n=>this._convertIdToIndex(n,"node"))),e.meshes&&(e.meshes=e.meshes.map(n=>this._convertIdToIndex(n,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(n=>this._convertIdToIndex(n,"node")))}_convertIdsToIndices(e,n){e[n]||(console.warn(`gltf v1: json doesn't contain attribute ${n}`),e[n]=[]);for(const s of e[n])for(const r in s){const o=s[r],i=this._convertIdToIndex(o,r);s[r]=i}}_convertIdToIndex(e,n){const s=Ca[n];if(s in this.idToIndexMap){const r=this.idToIndexMap[s][e];if(!Number.isFinite(r))throw new Error(`gltf v1: failed to resolve ${n} with id ${e}`);return r}return e}_updateObjects(e){for(const n of this.json.buffers)delete n.type}_updateMaterial(e){for(const n of e.materials){n.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const s=n.values?.tex||n.values?.texture2d_0||n.values?.diffuseTex,r=e.textures.findIndex(o=>o.id===s);r!==-1&&(n.pbrMetallicRoughness.baseColorTexture={index:r})}}}function ga(t,e={}){return new ba().normalize(t,e)}async function Ea(t,e,n=0,s,r){return Ia(t,e,n,s),ga(t,{normalize:s?.gltf?.normalize}),ma(t,s,r),s?.gltf?.loadBuffers&&t.json.buffers&&await Ma(t,s,r),s?.gltf?.loadImages&&await Ta(t,s,r),await ha(t,s,r),t}function Ia(t,e,n,s){if(s.uri&&(t.baseUri=s.uri),e instanceof ArrayBuffer&&!jo(e,n,s)&&(e=new TextDecoder().decode(e)),typeof e=="string")t.json=Jn(e);else if(e instanceof ArrayBuffer){const i={};n=Vo(i,e,n,s.glb),T(i.type==="glTF",`Invalid GLB magic string ${i.type}`),t._glb=i,t.json=i.json}else T(!1,"GLTF: must be ArrayBuffer or string");const r=t.json.buffers||[];if(t.buffers=new Array(r.length).fill(null),t._glb&&t._glb.header.hasBinChunk){const{binChunks:i}=t._glb;t.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}const o=t.json.images||[];t.images=new Array(o.length).fill({})}async function Ma(t,e,n){const s=t.json.buffers||[];for(let r=0;r<s.length;++r){const o=s[r];if(o.uri){const{fetch:i}=n;T(i);const a=jt(o.uri,e),l=await(await n?.fetch?.(a))?.arrayBuffer?.();t.buffers[r]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete o.uri}else t.buffers[r]===null&&(t.buffers[r]={arrayBuffer:new ArrayBuffer(o.byteLength),byteOffset:0,byteLength:o.byteLength})}}async function Ta(t,e,n){const s=ya(t),r=t.json.images||[],o=[];for(const i of s)o.push(Fa(t,r[i],i,e,n));return await Promise.all(o)}function ya(t){const e=new Set,n=t.json.textures||[];for(const s of n)s.source!==void 0&&e.add(s.source);return Array.from(e).sort()}async function Fa(t,e,n,s,r){let o;if(e.uri&&!e.hasOwnProperty("bufferView")){const a=jt(e.uri,s),{fetch:c}=r;o=await(await c(a)).arrayBuffer(),e.bufferView={data:o}}if(Number.isFinite(e.bufferView)){const a=_r(t.json,t.buffers,e.bufferView);o=gt(a.buffer,a.byteOffset,a.byteLength)}T(o,"glTF image has no data");let i=await Et(o,[Dn,Vs],{...s,mimeType:e.mimeType,basis:s.basis||{format:Dt()}},r);i&&i[0]&&(i={compressed:!0,mipmaps:!1,width:i[0].width,height:i[0].height,data:i[0]}),t.images=t.images||[],t.images[n]=i}const Se={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:Ho,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:_a,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};async function _a(t,e={},n){e={...Se.options,...e},e.gltf={...Se.options.gltf,...e.gltf};const{byteOffset:s=0}=e;return await Ea({},t,s,e,n)}const Ra={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ga={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},y={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},va={magFilter:y.TEXTURE_MAG_FILTER,minFilter:y.TEXTURE_MIN_FILTER,wrapS:y.TEXTURE_WRAP_S,wrapT:y.TEXTURE_WRAP_T},Da={[y.TEXTURE_MAG_FILTER]:y.LINEAR,[y.TEXTURE_MIN_FILTER]:y.NEAREST_MIPMAP_LINEAR,[y.TEXTURE_WRAP_S]:y.REPEAT,[y.TEXTURE_WRAP_T]:y.REPEAT};function Sa(){return{id:"default-sampler",parameters:Da}}function Oa(t){return Ga[t]}function xa(t){return Ra[t]}class La{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,n={}){const{json:s,buffers:r=[],images:o=[]}=e,{baseUri:i=""}=e;return T(s),this.baseUri=i,this.buffers=r,this.images=o,this.jsonUnprocessed=s,this.json=this._resolveTree(e.json,n),this.json}_resolveTree(e,n={}){const s={...e};return this.json=s,e.bufferViews&&(s.bufferViews=e.bufferViews.map((r,o)=>this._resolveBufferView(r,o))),e.images&&(s.images=e.images.map((r,o)=>this._resolveImage(r,o))),e.samplers&&(s.samplers=e.samplers.map((r,o)=>this._resolveSampler(r,o))),e.textures&&(s.textures=e.textures.map((r,o)=>this._resolveTexture(r,o))),e.accessors&&(s.accessors=e.accessors.map((r,o)=>this._resolveAccessor(r,o))),e.materials&&(s.materials=e.materials.map((r,o)=>this._resolveMaterial(r,o))),e.meshes&&(s.meshes=e.meshes.map((r,o)=>this._resolveMesh(r,o))),e.nodes&&(s.nodes=e.nodes.map((r,o)=>this._resolveNode(r,o)),s.nodes=s.nodes.map((r,o)=>this._resolveNodeChildren(r))),e.skins&&(s.skins=e.skins.map((r,o)=>this._resolveSkin(r,o))),e.scenes&&(s.scenes=e.scenes.map((r,o)=>this._resolveScene(r,o))),typeof this.json.scene=="number"&&s.scenes&&(s.scene=s.scenes[this.json.scene]),s}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,n){if(typeof n=="object")return n;const s=e&&e[n];return s||console.warn(`glTF file error: Could not find ${e}[${n}]`),s}_resolveScene(e,n){return{...e,id:e.id||`scene-${n}`,nodes:(e.nodes||[]).map(s=>this.getNode(s))}}_resolveNode(e,n){const s={...e,id:e?.id||`node-${n}`};return e.mesh!==void 0&&(s.mesh=this.getMesh(e.mesh)),e.camera!==void 0&&(s.camera=this.getCamera(e.camera)),e.skin!==void 0&&(s.skin=this.getSkin(e.skin)),e.meshes!==void 0&&e.meshes.length&&(s.mesh=e.meshes.reduce((r,o)=>{const i=this.getMesh(o);return r.id=i.id,r.primitives=r.primitives.concat(i.primitives),r},{primitives:[]})),s}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(n=>this.getNode(n))),e}_resolveSkin(e,n){const s=typeof e.inverseBindMatrices=="number"?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${n}`,inverseBindMatrices:s}}_resolveMesh(e,n){const s={...e,id:e.id||`mesh-${n}`,primitives:[]};return e.primitives&&(s.primitives=e.primitives.map(r=>{const o={...r,attributes:{},indices:void 0,material:void 0},i=r.attributes;for(const a in i)o.attributes[a]=this.getAccessor(i[a]);return r.indices!==void 0&&(o.indices=this.getAccessor(r.indices)),r.material!==void 0&&(o.material=this.getMaterial(r.material)),o})),s}_resolveMaterial(e,n){const s={...e,id:e.id||`material-${n}`};if(s.normalTexture&&(s.normalTexture={...s.normalTexture},s.normalTexture.texture=this.getTexture(s.normalTexture.index)),s.occlusionTexture&&(s.occlusionTexture={...s.occlusionTexture},s.occlusionTexture.texture=this.getTexture(s.occlusionTexture.index)),s.emissiveTexture&&(s.emissiveTexture={...s.emissiveTexture},s.emissiveTexture.texture=this.getTexture(s.emissiveTexture.index)),s.emissiveFactor||(s.emissiveFactor=s.emissiveTexture?[1,1,1]:[0,0,0]),s.pbrMetallicRoughness){s.pbrMetallicRoughness={...s.pbrMetallicRoughness};const r=s.pbrMetallicRoughness;r.baseColorTexture&&(r.baseColorTexture={...r.baseColorTexture},r.baseColorTexture.texture=this.getTexture(r.baseColorTexture.index)),r.metallicRoughnessTexture&&(r.metallicRoughnessTexture={...r.metallicRoughnessTexture},r.metallicRoughnessTexture.texture=this.getTexture(r.metallicRoughnessTexture.index))}return s}_resolveAccessor(e,n){const s=Oa(e.componentType),r=xa(e.type),o=s*r,i={...e,id:e.id||`accessor-${n}`,bytesPerComponent:s,components:r,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(e.bufferView!==void 0&&(i.bufferView=this.getBufferView(e.bufferView)),i.bufferView){const a=i.bufferView.buffer,{ArrayType:c,byteLength:l}=Le(i,i.bufferView),f=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+a.byteOffset;let u=a.arrayBuffer.slice(f,f+l);i.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(a,f,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new c(u)}return i}_getValueFromInterleavedBuffer(e,n,s,r,o){const i=new Uint8Array(o*r);for(let a=0;a<o;a++){const c=n+a*s;i.set(new Uint8Array(e.arrayBuffer.slice(c,c+r)),a*r)}return i.buffer}_resolveTexture(e,n){return{...e,id:e.id||`texture-${n}`,sampler:typeof e.sampler=="number"?this.getSampler(e.sampler):Sa(),source:typeof e.source=="number"?this.getImage(e.source):void 0}}_resolveSampler(e,n){const s={id:e.id||`sampler-${n}`,...e,parameters:{}};for(const r in s){const o=this._enumSamplerParameter(r);o!==void 0&&(s.parameters[o]=s[r])}return s}_enumSamplerParameter(e){return va[e]}_resolveImage(e,n){const s={...e,id:e.id||`image-${n}`,image:null,bufferView:e.bufferView!==void 0?this.getBufferView(e.bufferView):void 0},r=this.images[n];return r&&(s.image=r),s}_resolveBufferView(e,n){const s=e.buffer,r=this.buffers[s].arrayBuffer;let o=this.buffers[s].byteOffset||0;return e.byteOffset&&(o+=e.byteOffset),{id:`bufferView-${n}`,...e,buffer:this.buffers[s],data:new Uint8Array(r,o,e.byteLength)}}_resolveCamera(e,n){const s={...e,id:e.id||`camera-${n}`};return s.perspective,s.orthographic,s}}function Ha(t,e){return new La().postProcess(t,e)}async function Pa(t){const e=[];return t.scenes.forEach(n=>{n.traverse(s=>{})}),await Ua(()=>e.some(n=>!n.loaded))}async function Ua(t){for(;t();)await new Promise(e=>requestAnimationFrame(e))}const dt=`uniform scenegraphUniforms {
1021
+ float sizeScale;
1022
+ float sizeMinPixels;
1023
+ float sizeMaxPixels;
1024
+ mat4 sceneModelMatrix;
1025
+ bool composeModelMatrix;
1026
+ } scenegraph;
1027
+ `,Na={name:"scenegraph",vs:dt,fs:dt,uniformTypes:{sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",sceneModelMatrix:"mat4x4<f32>",composeModelMatrix:"f32"}},Ja=`#version 300 es
1028
+ #define SHADER_NAME scenegraph-layer-vertex-shader
1029
+ in vec3 instancePositions;
1030
+ in vec3 instancePositions64Low;
1031
+ in vec4 instanceColors;
1032
+ in vec3 instancePickingColors;
1033
+ in vec3 instanceModelMatrixCol0;
1034
+ in vec3 instanceModelMatrixCol1;
1035
+ in vec3 instanceModelMatrixCol2;
1036
+ in vec3 instanceTranslation;
1037
+ in vec3 positions;
1038
+ #ifdef HAS_UV
1039
+ in vec2 texCoords;
1040
+ #endif
1041
+ #ifdef LIGHTING_PBR
1042
+ #ifdef HAS_NORMALS
1043
+ in vec3 normals;
1044
+ #endif
1045
+ #endif
1046
+ out vec4 vColor;
1047
+ #ifndef LIGHTING_PBR
1048
+ #ifdef HAS_UV
1049
+ out vec2 vTEXCOORD_0;
1050
+ #endif
1051
+ #endif
1052
+ void main(void) {
1053
+ #if defined(HAS_UV) && !defined(LIGHTING_PBR)
1054
+ vTEXCOORD_0 = texCoords;
1055
+ geometry.uv = texCoords;
1056
+ #endif
1057
+ geometry.worldPosition = instancePositions;
1058
+ geometry.pickingColor = instancePickingColors;
1059
+ mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
1060
+ vec3 normal = vec3(0.0, 0.0, 1.0);
1061
+ #ifdef LIGHTING_PBR
1062
+ #ifdef HAS_NORMALS
1063
+ normal = instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(normals, 0.0)).xyz;
1064
+ #endif
1065
+ #endif
1066
+ float originalSize = project_size_to_pixel(scenegraph.sizeScale);
1067
+ float clampedSize = clamp(originalSize, scenegraph.sizeMinPixels, scenegraph.sizeMaxPixels);
1068
+ vec3 pos = (instanceModelMatrix * (scenegraph.sceneModelMatrix * vec4(positions, 1.0)).xyz) * scenegraph.sizeScale * (clampedSize / originalSize) + instanceTranslation;
1069
+ if(scenegraph.composeModelMatrix) {
1070
+ DECKGL_FILTER_SIZE(pos, geometry);
1071
+ geometry.normal = project_normal(normal);
1072
+ geometry.worldPosition += pos;
1073
+ gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
1074
+ }
1075
+ else {
1076
+ pos = project_size(pos);
1077
+ DECKGL_FILTER_SIZE(pos, geometry);
1078
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);
1079
+ geometry.normal = project_normal(normal);
1080
+ }
1081
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
1082
+ #ifdef LIGHTING_PBR
1083
+ pbr_vPosition = geometry.position.xyz;
1084
+ #ifdef HAS_NORMALS
1085
+ pbr_vNormal = geometry.normal;
1086
+ #endif
1087
+ #ifdef HAS_UV
1088
+ pbr_vUV = texCoords;
1089
+ #else
1090
+ pbr_vUV = vec2(0., 0.);
1091
+ #endif
1092
+ geometry.uv = pbr_vUV;
1093
+ #endif
1094
+ vColor = instanceColors;
1095
+ DECKGL_FILTER_COLOR(vColor, geometry);
1096
+ }
1097
+ `,wa=`#version 300 es
1098
+ #define SHADER_NAME scenegraph-layer-fragment-shader
1099
+ in vec4 vColor;
1100
+ out vec4 fragColor;
1101
+ #ifndef LIGHTING_PBR
1102
+ #if defined(HAS_UV) && defined(HAS_BASECOLORMAP)
1103
+ in vec2 vTEXCOORD_0;
1104
+ uniform sampler2D pbr_baseColorSampler;
1105
+ #endif
1106
+ #endif
1107
+ void main(void) {
1108
+ #ifdef LIGHTING_PBR
1109
+ fragColor = vColor * pbr_filterColor(vec4(0));
1110
+ geometry.uv = pbr_vUV;
1111
+ #else
1112
+ #if defined(HAS_UV) && defined(HAS_BASECOLORMAP)
1113
+ fragColor = vColor * texture(pbr_baseColorSampler, vTEXCOORD_0);
1114
+ geometry.uv = vTEXCOORD_0;
1115
+ #else
1116
+ fragColor = vColor;
1117
+ #endif
1118
+ #endif
1119
+ fragColor.a *= layer.opacity;
1120
+ DECKGL_FILTER_COLOR(fragColor, geometry);
1121
+ }
1122
+ `,zt=[255,255,255,255],Ka={scenegraph:{type:"object",value:null,async:!0},getScene:t=>t&&t.scenes?typeof t.scene=="object"?t.scene:t.scenes[t.scene||0]:t,getAnimator:t=>t&&t.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:zt},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[Se]};class Wt extends Bt{getShaders(){const e={};let n;this.props._lighting==="pbr"?(n=Ft,e.LIGHTING_PBR=1):n={name:"pbrMaterial"};const s=[mt,ht,Na,n];return super.getShaders({defines:e,vs:Ja,fs:wa,modules:s})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:zt,transition:!0},instanceModelMatrix:_t})}updateState(e){super.updateState(e);const{props:n,oldProps:s}=e;n.scenegraph!==s.scenegraph?this._updateScenegraph():n._animations!==s._animations&&this._applyAnimationsProp(this.state.animator,n._animations)}finalizeState(e){super.finalizeState(e),this.state.scenegraph?.destroy()}get isLoaded(){return!!(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){const e=this.props,{device:n}=this.context;let s=null;if(e.scenegraph instanceof re)s={scenes:[e.scenegraph]};else if(e.scenegraph&&typeof e.scenegraph=="object"){const a=e.scenegraph,c=a.json?Ha(a):a,l=gr(n,c,this._getModelOptions());s={gltf:c,...l},Pa(l).then(()=>{this.setNeedsRedraw()}).catch(f=>{this.raiseError(f,"loading glTF")})}const r={layer:this,device:this.context.device},o=e.getScene(s,r),i=e.getAnimator(s,r);if(o instanceof U){this.state.scenegraph?.destroy(),this._applyAnimationsProp(i,e._animations);const a=[];o.traverse(c=>{c instanceof Re&&a.push(c.model)}),this.setState({scenegraph:o,animator:i,models:a}),this.getAttributeManager().invalidateAll()}else o!==null&&ee.warn("invalid scenegraph:",o)()}_applyAnimationsProp(e,n){if(!e||!n)return;const s=e.getAnimations();Object.keys(n).sort().forEach(r=>{const o=n[r];if(r==="*")s.forEach(i=>{Object.assign(i,o)});else if(Number.isFinite(Number(r))){const i=Number(r);i>=0&&i<s.length?Object.assign(s[i],o):ee.warn(`animation ${r} not found`)()}else{const i=s.find(({animation:a})=>a.name===r);i?Object.assign(i,o):ee.warn(`animation ${r} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let n;return e&&(typeof e=="function"?n=e({gl:this.context.gl,layer:this}):n=e),{imageBasedLightingEnvironment:n,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(e.timeline.getTime()),this.setNeedsRedraw());const{viewport:n,renderPass:s}=this.context,{sizeScale:r,sizeMinPixels:o,sizeMaxPixels:i,coordinateSystem:a}=this.props,c={camera:n.cameraPosition},l=this.getNumInstances();this.state.scenegraph.traverse((f,{worldMatrix:u})=>{if(f instanceof Re){const{model:A}=f;A.setInstanceCount(l);const d={sizeScale:r,sizeMinPixels:o,sizeMaxPixels:i,composeModelMatrix:Rt(n,a),sceneModelMatrix:u};A.shaderInputs.setProps({pbrProjection:c,scenegraph:d}),A.draw(s)}})}}Wt.defaultProps=Ka;Wt.layerName="ScenegraphLayer";export{vi as D,Se as G,Q as M,gs as Q,Gt as S,ks as a,Et as b,Ha as c,Wt as d,za as g,Ft as p};
1123
+ //# sourceMappingURL=mesh-layers-BSECKarm.js.map