@volter/model-editor 0.5.66 → 0.5.67

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 (200) hide show
  1. package/dist/.vite/manifest.json +1022 -1006
  2. package/dist/assets/AudioViewer-DVXaSSYC.js +1 -0
  3. package/dist/assets/{BVHLoader-xUHWsz84.js → BVHLoader-msuIvJVn.js} +1 -1
  4. package/dist/assets/ColladaLoader-BpvxwqkB.js +3 -0
  5. package/dist/assets/EntityModelDocument-BtlQZcoU.js +1 -0
  6. package/dist/assets/EnvironmentAssetDocument-BH3zT9rt.js +1 -0
  7. package/dist/assets/FBXLoader-CsdO937F.js +1 -0
  8. package/dist/assets/{GameplaySessionTimeline-HJLZUV4Q.js → GameplaySessionTimeline-Dko95kB7.js} +10 -10
  9. package/dist/assets/ImageViewer-CZ_RMER2.js +1 -0
  10. package/dist/assets/{InspectorCanvasPreview-CLDhscy0.js → InspectorCanvasPreview-BLecDHpc.js} +1 -1
  11. package/dist/assets/InspectorObjectPreview-CSIWwJQE.js +1 -0
  12. package/dist/assets/JsonAssetDocument-CGYSeJyl.js +2 -0
  13. package/dist/assets/{LineSegments2-C8H20K8w.js → LineSegments2-BKEsgiC8.js} +2 -2
  14. package/dist/assets/LiveModuleDocument-CIvS-SUT.js +2 -0
  15. package/dist/assets/LutAssetDocument-BA70uU3w.js +1 -0
  16. package/dist/assets/{MTLLoader-C-rA0fNF.js → MTLLoader-DNh2pFDc.js} +2 -2
  17. package/dist/assets/ModelAssetDocument-D0lNEhOg.js +1 -0
  18. package/dist/assets/NonThreeAuthoringBootstrap-C0pCfkJ4.js +2 -0
  19. package/dist/assets/OBJLoader-DPi99VIm.js +5 -0
  20. package/dist/assets/Object3DDocumentToolbar-PGYkZEwr.js +1 -0
  21. package/dist/assets/Object3DPreview-BROKXSTC.js +2 -0
  22. package/dist/assets/OnlineAssetDetail-lEHnhdUS.js +1 -0
  23. package/dist/assets/OrbitControls-smIenN60.js +1 -0
  24. package/dist/assets/PLYLoader-Cx9Yc9xe.js +2 -0
  25. package/dist/assets/QuarksAssetDocument-C_8eG4KG.js +2 -0
  26. package/dist/assets/RectAreaLightUniformsLib-Iam8rS8R.js +1 -0
  27. package/dist/assets/STLLoader-BaJkM-k1.js +1 -0
  28. package/dist/assets/{ShaderAssetDocument-qlLeb2S3.js → ShaderAssetDocument-Gdp7OCfv.js} +5 -5
  29. package/dist/assets/SourceAssetViewer-l72u0hOa.js +1 -0
  30. package/dist/assets/StageHost-CdzuP0NS.js +1179 -0
  31. package/dist/assets/TDSLoader-BskhMiUy.js +1 -0
  32. package/dist/assets/ToolObject3DPreview-CU5klD6l.js +1 -0
  33. package/dist/assets/Toolbar-DI0LGx25.js +1 -0
  34. package/dist/assets/TransientHint-myZtSdd6.js +1 -0
  35. package/dist/assets/VideoViewer-z0JPXPKa.js +1 -0
  36. package/dist/assets/ViewportShadingMenu-CVU2bU_3.js +1 -0
  37. package/dist/assets/animation-mixers.service-DSIsxWG5.js +1 -0
  38. package/dist/assets/animation-timeline.utility-BEgDQC04.js +1 -0
  39. package/dist/assets/asset-editor-persistence-BtRQI8t6.js +1 -0
  40. package/dist/assets/bitmap-label-Ct4k6ehY.js +1 -0
  41. package/dist/assets/{blender-emscripten-engine-CEsWgnR7.js → blender-emscripten-engine-BeWFjMn-.js} +1 -1
  42. package/dist/assets/blender-node-editor.document-C_kpsARB.js +1 -0
  43. package/dist/assets/{blender-properties-tab-C5tUuCSv.js → blender-properties-tab-B_XBg6S8.js} +3 -3
  44. package/dist/assets/blender-runtime-host-CYhl4T9S.js +4 -0
  45. package/dist/assets/{blender-runtime-skin-DMq0XAvO.js → blender-runtime-skin-Bk6uXECD.js} +98 -51
  46. package/dist/assets/blender-runtime.document-CAPDRCvN.js +12 -0
  47. package/dist/assets/blender-timeline.document-CcEymQyL.js +1 -0
  48. package/dist/assets/blender-uv-editor.document-DSPvSEuE.js +1 -0
  49. package/dist/assets/blender-version.status-CEu7vCi3.js +1 -0
  50. package/dist/assets/{blender-wali-engine-D3iKpzn9.js → blender-wali-engine-da698rDf.js} +1 -1
  51. package/dist/assets/blender.command-BCb_c9lw.js +1 -0
  52. package/dist/assets/blender.keymap-_rF_vRX8.js +1 -0
  53. package/dist/assets/{blender.status-ujwGU6dU.js → blender.status-DrasQhJV.js} +1 -1
  54. package/dist/assets/{blender.style-CxfbTFcE.js → blender.style-DaIh9SiA.js} +1 -1
  55. package/dist/assets/{client-DNXj_opT.js → client-mkWk8S65.js} +1 -1
  56. package/dist/assets/content-bounds-_QWiKD5_.js +85 -0
  57. package/dist/assets/{hosted-asset-materialization-BXM49Qkc.js → hosted-asset-materialization-hUS3IhTD.js} +2 -2
  58. package/dist/assets/index-0Lm0Nf1M.css +1 -0
  59. package/dist/assets/{index-CJbYy-CF.js → index-7vd2obXq.js} +2 -2
  60. package/dist/assets/{index-DgapqSPi.js → index-BRLA7zdc.js} +1 -1
  61. package/dist/assets/{index-BtfYaG4D.js → index-CQG6JOSy.js} +18 -18
  62. package/dist/assets/{index-CanA16PU.js → index-CnvSS9lU.js} +1 -1
  63. package/dist/assets/{index-Bge9JUr6.js → index-DYNMP0kE.js} +1 -1
  64. package/dist/assets/index-Dm_h-T4x.js +1406 -0
  65. package/dist/assets/{index-gHZae-lw.js → index-Dz8qGBZc.js} +1 -1
  66. package/dist/assets/{index-BncK9THk.js → index-Fv4R0cYr.js} +1 -1
  67. package/dist/assets/{index-IEjydI9d.js → index-f-MQ14bP.js} +1 -1
  68. package/dist/assets/{index-D2LwEE0L.js → index-jib6KJY8.js} +6 -6
  69. package/dist/assets/{index-DUqP1RMl.js → index-ux8XhRyW.js} +1 -1
  70. package/dist/assets/{jsx-runtime-DPjLkJKQ.js → jsx-runtime-CAUTK36e.js} +1 -1
  71. package/dist/assets/layered-pick-CT4HlEpW.js +1 -0
  72. package/dist/assets/live-mixers-B-bwLZ7c.js +1 -0
  73. package/dist/assets/model-inspection-DDZE59vp.js +1 -0
  74. package/dist/assets/models.finder-Caf-3Yix.js +1 -0
  75. package/dist/assets/product-DbFrUS6F.js +1 -0
  76. package/dist/assets/properties-bone-constraints.inspector-DB3Rc_Hf.js +1 -0
  77. package/dist/assets/properties-bone.inspector-B7f7H_Co.js +1 -0
  78. package/dist/assets/properties-collection.inspector-JCtV3h3Y.js +1 -0
  79. package/dist/assets/properties-constraints.inspector-Cs8MwS-1.js +1 -0
  80. package/dist/assets/properties-data.inspector-DKGiHu8O.js +1 -0
  81. package/dist/assets/properties-material.inspector-Dc18RI13.js +1 -0
  82. package/dist/assets/properties-modifiers.inspector-DvGvXq2v.js +1 -0
  83. package/dist/assets/properties-object.inspector-Bl9nrytP.js +1 -0
  84. package/dist/assets/properties-output.inspector-B6QsU94n.js +1 -0
  85. package/dist/assets/properties-particles.inspector-B1dMnZSA.js +1 -0
  86. package/dist/assets/properties-physics.inspector-BwfNykfW.js +1 -0
  87. package/dist/assets/properties-render.inspector-KrL2EiTH.js +1 -0
  88. package/dist/assets/properties-scene.inspector-CewQnyRt.js +1 -0
  89. package/dist/assets/properties-texture.inspector-BITMzY-f.js +1 -0
  90. package/dist/assets/properties-view-layer.inspector-BpkDbmcb.js +1 -0
  91. package/dist/assets/properties-world.inspector-DLRH45Oj.js +1 -0
  92. package/dist/assets/{react-18-DyywM-Z2.js → react-18-D335xReo.js} +1 -1
  93. package/dist/assets/{react-story-board-B9V-j_Y5.js → react-story-board-CkaP4mEG.js} +1 -1
  94. package/dist/assets/{session-CsR0lApe.js → session-CTXsU1lK.js} +176 -1
  95. package/dist/assets/{spark.module-gG1EsWx8.js → spark.module-DMQ9J7rT.js} +11 -11
  96. package/dist/assets/stage-keyboard-BY7u9_MB.js +1 -0
  97. package/dist/assets/stage-overlay-set-DRFcVd27.js +1 -0
  98. package/dist/assets/stage-presence-markers-D2IpuOAY.js +1 -0
  99. package/dist/assets/stage-transform-tools-BGcIULoe.js +1 -0
  100. package/dist/assets/story-capture-RSWY8I8h.js +1 -0
  101. package/dist/assets/three-integration.service-0EyPpd5f.js +4 -0
  102. package/dist/assets/{three.module-ZILb6uB7.js → three.module-CrYDk-Xr.js} +1 -1
  103. package/dist/assets/transform-mode-request-Cz6fzydi.js +1 -0
  104. package/dist/assets/transport-strip-Co-ZDkf-.js +1 -0
  105. package/dist/assets/{vgai-shared-fontawesome-CFSkqz69.js → vgai-shared-fontawesome-2ZSGa7vM.js} +1 -1
  106. package/dist/assets/vgai-shared-jsx-dev-runtime-hkPLeIJV.js +1 -0
  107. package/dist/assets/vgai-shared-jsx-runtime-CUvvjEqj.js +1 -0
  108. package/dist/assets/{vgai-shared-react-dom-client-S0ozfl6_.js → vgai-shared-react-dom-client-CS681GK2.js} +1 -1
  109. package/dist/assets/{vgai-shared-three-DzfWDqlp.js → vgai-shared-three-CLJ0K3jQ.js} +1 -1
  110. package/dist/assets/viewport-door-BdL0u5rd.js +1 -0
  111. package/dist/assets/viewport-editor-controls-BYaAZ_Ku.js +1 -0
  112. package/dist/assets/viewport-surface-status-yS6CrXH7.js +24 -0
  113. package/dist/assets/{worker-B7zhIsFh.js → worker-CC9Ug5Ei.js} +1 -1
  114. package/dist/assets/world-documents-B5IWN-ng.js +3 -0
  115. package/dist/vgai-shared-react.json +4 -4
  116. package/dist/vgai-shared-three.json +1 -1
  117. package/dist-node/cli.js +248 -209
  118. package/dist-node/create.js +77 -77
  119. package/package.json +10 -10
  120. package/src/index.ts +1 -0
  121. package/dist/assets/AudioViewer-CRWsJVYN.js +0 -1
  122. package/dist/assets/ColladaLoader-Ccy_gHsu.js +0 -3
  123. package/dist/assets/EntityModelDocument-Dal8YnLK.js +0 -1
  124. package/dist/assets/EnvironmentAssetDocument-DFOFYX5v.js +0 -1
  125. package/dist/assets/FBXLoader-Dh0pOBW2.js +0 -1
  126. package/dist/assets/ImageViewer-BzqBpqL-.js +0 -1
  127. package/dist/assets/InspectorObjectPreview-BUZEp4xS.js +0 -1
  128. package/dist/assets/JsonAssetDocument-DCkqRS0N.js +0 -2
  129. package/dist/assets/LiveModuleDocument-CuOBVz3A.js +0 -2
  130. package/dist/assets/LutAssetDocument-IyEir1rq.js +0 -1
  131. package/dist/assets/ModelAssetDocument-DNStNyCc.js +0 -1
  132. package/dist/assets/NonThreeAuthoringBootstrap-BE15Wpmw.js +0 -2
  133. package/dist/assets/OBJLoader-CopWRneC.js +0 -5
  134. package/dist/assets/Object3DDocumentToolbar-5Dv_8caG.js +0 -1
  135. package/dist/assets/Object3DPreview-C09u9uQZ.js +0 -2
  136. package/dist/assets/OnlineAssetDetail-DOPUI1iu.js +0 -1
  137. package/dist/assets/OrbitControls-DrFzvAAB.js +0 -1
  138. package/dist/assets/PLYLoader-D_esTZ2f.js +0 -2
  139. package/dist/assets/QuarksAssetDocument-BbSJ970L.js +0 -2
  140. package/dist/assets/RectAreaLightUniformsLib-u1ciScuw.js +0 -1
  141. package/dist/assets/STLLoader-Cl5I0sAi.js +0 -1
  142. package/dist/assets/SourceAssetViewer-DwhuqbA4.js +0 -1
  143. package/dist/assets/StageHost-D-o8MsFS.js +0 -1122
  144. package/dist/assets/TDSLoader-KKBg8ef1.js +0 -1
  145. package/dist/assets/ToolObject3DPreview-ILbch3kN.js +0 -1
  146. package/dist/assets/Toolbar-DYJjJKTt.js +0 -1
  147. package/dist/assets/TransientHint-D94hsJSR.js +0 -1
  148. package/dist/assets/VideoViewer-Bx3FPbgE.js +0 -1
  149. package/dist/assets/ViewportShadingMenu-B3N6hSdN.js +0 -1
  150. package/dist/assets/animation-mixers.service-N9HxGOMf.js +0 -1
  151. package/dist/assets/asset-editor-persistence-DGD05u26.js +0 -1
  152. package/dist/assets/blender-node-editor.document-BT2M622g.js +0 -1
  153. package/dist/assets/blender-runtime-host-4ufXy47O.js +0 -4
  154. package/dist/assets/blender-runtime.document-DeFQQsF6.js +0 -8
  155. package/dist/assets/blender-timeline.document-BnlSdxy0.js +0 -1
  156. package/dist/assets/blender-uv-editor.document-UC-XeNn0.js +0 -1
  157. package/dist/assets/blender-version.status-BZP39oH7.js +0 -1
  158. package/dist/assets/blender.command-IGP5wuda.js +0 -1
  159. package/dist/assets/blender.keymap-GAQgeklK.js +0 -1
  160. package/dist/assets/browserAll-2r3AVaAO.js +0 -14
  161. package/dist/assets/canvas-preview-frames-CO60PDM7.js +0 -5
  162. package/dist/assets/index-B4bmKkgY.css +0 -1
  163. package/dist/assets/index-cpXNKgvz.js +0 -1498
  164. package/dist/assets/live-mixers-BRkRHd6g.js +0 -1
  165. package/dist/assets/material-preview.view-DqNcpd_b.js +0 -1
  166. package/dist/assets/model-inspection-JC6gbV8Q.js +0 -1
  167. package/dist/assets/models.finder-BplPGS4I.js +0 -1
  168. package/dist/assets/product-CfZaqLpw.js +0 -1
  169. package/dist/assets/properties-bone-constraints.inspector-Di8kNtAi.js +0 -1
  170. package/dist/assets/properties-bone.inspector-CqAIKNsE.js +0 -1
  171. package/dist/assets/properties-collection.inspector-DpHC_fXW.js +0 -1
  172. package/dist/assets/properties-constraints.inspector-C7G7NOZU.js +0 -1
  173. package/dist/assets/properties-data.inspector-D1sUUst6.js +0 -1
  174. package/dist/assets/properties-material.inspector-BUSjc8tl.js +0 -1
  175. package/dist/assets/properties-modifiers.inspector-Sq9bcfFz.js +0 -1
  176. package/dist/assets/properties-object.inspector-BzqiU_29.js +0 -1
  177. package/dist/assets/properties-output.inspector-BWpFqvfT.js +0 -1
  178. package/dist/assets/properties-particles.inspector-DO1KoaTz.js +0 -1
  179. package/dist/assets/properties-physics.inspector-BgkrTNSA.js +0 -1
  180. package/dist/assets/properties-render.inspector-BU5NOVoQ.js +0 -1
  181. package/dist/assets/properties-scene.inspector-DbMErJ48.js +0 -1
  182. package/dist/assets/properties-texture.inspector-toPpEwqp.js +0 -1
  183. package/dist/assets/properties-view-layer.inspector-COpx9iEK.js +0 -1
  184. package/dist/assets/properties-world.inspector-CxU0DrYX.js +0 -1
  185. package/dist/assets/react-three-rapier.esm-CN6t4A7c.js +0 -1
  186. package/dist/assets/stage-keyboard-CzlqI0nh.js +0 -1
  187. package/dist/assets/stage-overlay-set-DQeskS16.js +0 -1
  188. package/dist/assets/stage-presence-markers-S1lMOwIa.js +0 -1
  189. package/dist/assets/stage-transform-tools-Cqtv-ZQ1.js +0 -1
  190. package/dist/assets/story-capture-DmIUyEQn.js +0 -1
  191. package/dist/assets/story-mount-turn-2IYGgHob.js +0 -1
  192. package/dist/assets/story-pixi-preview-aw8xQhvF.js +0 -1
  193. package/dist/assets/story-three-preview-DDmMjlI8.js +0 -37
  194. package/dist/assets/transform-mode-request-DSPwviXs.js +0 -1
  195. package/dist/assets/vgai-shared-jsx-dev-runtime-DFDKL7fx.js +0 -1
  196. package/dist/assets/vgai-shared-jsx-runtime-DIqBpTut.js +0 -1
  197. package/dist/assets/viewport-pick-context-DkawXbEi.js +0 -1
  198. package/dist/assets/viewport-surface-status-DuININWe.js +0 -20
  199. package/dist/assets/webworkerAll-CqQUotBj.js +0 -101
  200. package/dist/assets/world-documents-DkBqH8VU.js +0 -3
@@ -1,4 +1,4 @@
1
- import{k as QQ,r as cB,a8 as JC,an as kB,a as OA,V as F,ao as RB,t as BQ,e as CQ,w as nI,Z as sI,ap as Hg,Q as Z,d as FA,a4 as lI,aq as BA,Y as v,g as vQ,aa as Ww,ar as UC,I as jw,L as gC,as as nC,at as eC,au as zQ,av as HC,l as EQ,aw as LC,al as iQ,ax as FB,u as og,h as YA,o as gI,B as dg,ay as RQ,az as pA,aA as Lg,aB as YC,aC as QC,aD as Yg,a0 as vw,a2 as zw,aE as _w,F as $w,aF as As,aG as Is,aH as gs,y as Qs,aI as FQ,ak as Bs,ab as Cs,$ as Es}from"./three.module-ZILb6uB7.js";import{U as SB}from"./index-cpXNKgvz.js";import"./index-DaQZGF7d.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";class _Q extends LC{constructor(A,I){super(),this.ordering=A,this.setAttribute("position",new iQ(is,3)),this.setIndex(new iQ(Ds,1)),this._maxInstanceCount=A.length,this.instanceCount=I,this.attribute=new Is(A,1,!1,1),this.attribute.setUsage(gs),this.setAttribute("splatIndex",this.attribute)}update(A,I){this.ordering=A,this.attribute.array=A,this.instanceCount=I,this.attribute.addUpdateRange(0,I),this.attribute.needsUpdate=!0}}const is=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Ds=new Uint16Array([0,1,2,0,2,3]),rC=`(function() {
1
+ import{c as QQ,S as cB,a2 as JC,z as kB,g as OA,V as F,bJ as RB,W as BQ,f as CQ,af as nI,R as sI,M as Hg,Q as Z,a as FA,l as lI,cy as BA,cj as v,P as vQ,at as Ww,cz as UC,L as jw,n as gC,cA as nC,cB as eC,Z as zQ,aA as HC,aw as EQ,E as Lg,C as YA,k as gI,cC as LC,ae as pA,cD as RQ,cE as FB,ab as og,$ as QC,O as Yg,aT as vw,aU as zw,t as dg,cF as _w,w as $w,K as As,aO as YC,i as iQ,aZ as Is,c1 as gs,cn as Qs,aD as FQ,B as Bs,ag as Cs,u as Es}from"./three.module-CrYDk-Xr.js";import{F as SB}from"./content-bounds-_QWiKD5_.js";class _Q extends YC{constructor(A,I){super(),this.ordering=A,this.setAttribute("position",new iQ(is,3)),this.setIndex(new iQ(Ds,1)),this._maxInstanceCount=A.length,this.instanceCount=I,this.attribute=new Is(A,1,!1,1),this.attribute.setUsage(gs),this.setAttribute("splatIndex",this.attribute)}update(A,I){this.ordering=A,this.attribute.array=A,this.instanceCount=I,this.attribute.addUpdateRange(0,I),this.attribute.needsUpdate=!0}}const is=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Ds=new Uint16Array([0,1,2,0,2,3]),rC=`(function() {
2
2
  "use strict";
3
3
  class CsplatArray {
4
4
  static __wrap(ptr) {
@@ -8167,7 +8167,7 @@ import{k as QQ,r as cB,a8 as JC,an as kB,a as OA,V as F,ao as RB,t as BQ,e as CQ
8167
8167
  initialize().catch(console.error);
8168
8168
  })();
8169
8169
  //# sourceMappingURL=oldWorker-DUF0ALOS.js.map
8170
- `,BC=typeof self<"u"&&self.Blob&&new Blob([rC],{type:"text/javascript;charset=utf-8"});function os(Q){let A;try{if(A=BC&&(self.URL||self.webkitURL).createObjectURL(BC),!A)throw"";const I=new Worker(A,{name:Q?.name});return I.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(A)}),I}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(rC),{name:Q?.name})}finally{A&&(self.URL||self.webkitURL).revokeObjectURL(A)}}var dA=Uint8Array,Jg=Uint16Array,ws=Int32Array,KC=new dA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),dC=new dA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ss=new dA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qC=function(Q,A){for(var I=new Jg(31),g=0;g<31;++g)I[g]=A+=1<<Q[g-1];for(var B=new ws(I[30]),g=1;g<30;++g)for(var C=I[g];C<I[g+1];++C)B[C]=C-I[g]<<5|g;return{b:I,r:B}},lC=qC(KC,2),xC=lC.b,Gs=lC.r;xC[28]=258,Gs[258]=28;var as=qC(dC,0),hs=as.b,pC=new Jg(32768);for(var yA=0;yA<32768;++yA){var YI=(yA&43690)>>1|(yA&21845)<<1;YI=(YI&52428)>>2|(YI&13107)<<2,YI=(YI&61680)>>4|(YI&3855)<<4,pC[yA]=((YI&65280)>>8|(YI&255)<<8)>>1}var Ug=function(Q,A,I){for(var g=Q.length,B=0,C=new Jg(A);B<g;++B)Q[B]&&++C[Q[B]-1];var E=new Jg(A);for(B=1;B<A;++B)E[B]=E[B-1]+C[B-1]<<1;var i;{i=new Jg(1<<A);var o=15-A;for(B=0;B<g;++B)if(Q[B])for(var D=B<<4|Q[B],s=A-Q[B],w=E[Q[B]-1]++<<s,G=w|(1<<s)-1;w<=G;++w)i[pC[w]>>o]=D}return i},qg=new dA(288);for(var yA=0;yA<144;++yA)qg[yA]=8;for(var yA=144;yA<256;++yA)qg[yA]=9;for(var yA=256;yA<280;++yA)qg[yA]=7;for(var yA=280;yA<288;++yA)qg[yA]=8;var fC=new dA(32);for(var yA=0;yA<32;++yA)fC[yA]=5;var ys=Ug(qg,9),cs=Ug(fC,5),uQ=function(Q){for(var A=Q[0],I=1;I<Q.length;++I)Q[I]>A&&(A=Q[I]);return A},EI=function(Q,A,I){var g=A/8|0;return(Q[g]|Q[g+1]<<8)>>(A&7)&I},PQ=function(Q,A){var I=A/8|0;return(Q[I]|Q[I+1]<<8|Q[I+2]<<16)>>(A&7)},bC=function(Q){return(Q+7)/8|0},Cg=function(Q,A,I){return(A==null||A<0)&&(A=0),(I==null||I>Q.length)&&(I=Q.length),new dA(Q.subarray(A,I))},ks=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],TA=function(Q,A,I){var g=new Error(A||ks[Q]);if(g.code=Q,Error.captureStackTrace&&Error.captureStackTrace(g,TA),!I)throw g;return g},uC=function(Q,A,I,g){var B=Q.length,C=g?g.length:0;if(!B||A.f&&!A.l)return I||new dA(0);var E=!I,i=E||A.i!=2,o=A.i;E&&(I=new dA(B*3));var D=function(NA){var wA=I.length;if(NA>wA){var aA=new dA(Math.max(wA*2,NA));aA.set(I),I=aA}},s=A.f||0,w=A.p||0,G=A.b||0,a=A.l,y=A.d,h=A.m,c=A.n,k=B*8;do{if(!a){s=EI(Q,w,1);var R=EI(Q,w+1,3);if(w+=3,R)if(R==1)a=ys,y=cs,h=9,c=5;else if(R==2){var J=EI(Q,w,31)+257,M=EI(Q,w+10,15)+4,U=J+EI(Q,w+5,31)+1;w+=14;for(var n=new dA(U),L=new dA(19),H=0;H<M;++H)L[ss[H]]=EI(Q,w+H*3,7);w+=M*3;for(var e=uQ(L),q=(1<<e)-1,Y=Ug(L,e),H=0;H<U;){var K=Y[EI(Q,w,q)];w+=K&15;var t=K>>4;if(t<16)n[H++]=t;else{var x=0,m=0;for(t==16?(m=3+EI(Q,w,3),w+=2,x=n[H-1]):t==17?(m=3+EI(Q,w,7),w+=3):t==18&&(m=11+EI(Q,w,127),w+=7);m--;)n[H++]=x}}var j=n.subarray(0,J),u=n.subarray(J);h=uQ(j),c=uQ(u),a=Ug(j,h),y=Ug(u,c)}else TA(1);else{var t=bC(w)+4,N=Q[t-4]|Q[t-3]<<8,S=t+N;if(S>B){o&&TA(0);break}i&&D(G+N),I.set(Q.subarray(t,S),G),A.b=G+=N,A.p=w=S*8,A.f=s;continue}if(w>k){o&&TA(0);break}}i&&D(G+131072);for(var CA=(1<<h)-1,V=(1<<c)-1,AA=w;;AA=w){var x=a[PQ(Q,w)&CA],O=x>>4;if(w+=x&15,w>k){o&&TA(0);break}if(x||TA(2),O<256)I[G++]=O;else if(O==256){AA=w,a=null;break}else{var P=O-254;if(O>264){var H=O-257,b=KC[H];P=EI(Q,w,(1<<b)-1)+xC[H],w+=b}var T=y[PQ(Q,w)&V],p=T>>4;T||TA(3),w+=T&15;var u=hs[p];if(p>3){var b=dC[p];u+=PQ(Q,w)&(1<<b)-1,w+=b}if(w>k){o&&TA(0);break}i&&D(G+131072);var SA=G+P;if(G<u){var GA=C-u,tA=Math.min(u,SA);for(GA+G<0&&TA(3);G<tA;++G)I[G]=g[GA+G]}for(;G<SA;++G)I[G]=I[G-u]}}A.l=a,A.p=AA,A.b=G,A.f=s,a&&(s=1,A.m=h,A.d=y,A.n=c)}while(!s);return G!=I.length&&E?Cg(I,0,G):I.subarray(0,G)},Rs=new dA(0),RI=function(Q,A){return Q[A]|Q[A+1]<<8},DI=function(Q,A){return(Q[A]|Q[A+1]<<8|Q[A+2]<<16|Q[A+3]<<24)>>>0},mQ=function(Q,A){return DI(Q,A)+DI(Q,A+4)*4294967296},Fs=function(Q){(Q[0]!=31||Q[1]!=139||Q[2]!=8)&&TA(6,"invalid gzip data");var A=Q[3],I=10;A&4&&(I+=(Q[10]|Q[11]<<8)+2);for(var g=(A>>3&1)+(A>>4&1);g>0;g-=!Q[I++]);return I+(A&2)},TQ=(function(){function Q(A,I){typeof A=="function"&&(I=A,A={}),this.ondata=I;var g=A&&A.dictionary&&A.dictionary.subarray(-32768);this.s={i:0,b:g?g.length:0},this.o=new dA(32768),this.p=new dA(0),g&&this.o.set(g)}return Q.prototype.e=function(A){if(this.ondata||TA(5),this.d&&TA(4),!this.p.length)this.p=A;else if(A.length){var I=new dA(this.p.length+A.length);I.set(this.p),I.set(A,this.p.length),this.p=I}},Q.prototype.c=function(A){this.s.i=+(this.d=A||!1);var I=this.s.b,g=uC(this.p,this.s,this.o);this.ondata(Cg(g,I,this.s.b),this.d),this.o=Cg(g,this.s.b-32768),this.s.b=this.o.length,this.p=Cg(this.p,this.s.p/8|0),this.s.p&=7},Q.prototype.push=function(A,I){this.e(A),this.c(I)},Q})();function Ss(Q,A){return uC(Q,{i:2},A&&A.out,A&&A.dictionary)}var ts=(function(){function Q(A,I){this.v=1,this.r=0,TQ.call(this,A,I)}return Q.prototype.push=function(A,I){if(TQ.prototype.e.call(this,A),this.r+=A.length,this.v){var g=this.p.subarray(this.v-1),B=g.length>3?Fs(g):4;if(B>g.length){if(!I)return}else this.v>1&&this.onmember&&this.onmember(this.r-g.length);this.p=g.subarray(B),this.v=0}TQ.prototype.c.call(this,I),this.s.f&&!this.s.l&&!I&&(this.v=bC(this.s.p)+9,this.s={i:0},this.o=new dA(0),this.push(new dA(0),I))},Q})(),$Q=typeof TextDecoder<"u"&&new TextDecoder,Ns=0;try{$Q.decode(Rs,{stream:!0}),Ns=1}catch{}var Ms=function(Q){for(var A="",I=0;;){var g=Q[I++],B=(g>127)+(g>223)+(g>239);if(I+B>Q.length)return{s:A,r:Cg(Q,I-1)};B?B==3?(g=((g&15)<<18|(Q[I++]&63)<<12|(Q[I++]&63)<<6|Q[I++]&63)-65536,A+=String.fromCharCode(55296|g>>10,56320|g&1023)):B&1?A+=String.fromCharCode((g&31)<<6|Q[I++]&63):A+=String.fromCharCode((g&15)<<12|(Q[I++]&63)<<6|Q[I++]&63):A+=String.fromCharCode(g)}};function Js(Q,A){if(A){for(var I="",g=0;g<Q.length;g+=16384)I+=String.fromCharCode.apply(null,Q.subarray(g,g+16384));return I}else{if($Q)return $Q.decode(Q);var B=Ms(Q),C=B.s,I=B.r;return I.length&&TA(8),C}}var Us=function(Q,A){return A+30+RI(Q,A+26)+RI(Q,A+28)},ns=function(Q,A,I){var g=RI(Q,A+28),B=Js(Q.subarray(A+46,A+46+g),!(RI(Q,A+8)&2048)),C=A+46+g,E=DI(Q,A+20),i=I&&E==4294967295?es(Q,C):[E,DI(Q,A+24),DI(Q,A+42)],o=i[0],D=i[1],s=i[2];return[RI(Q,A+10),o,D,B,C+RI(Q,A+30)+RI(Q,A+32),s]},es=function(Q,A){for(;RI(Q,A)!=1;A+=4+RI(Q,A+2));return[mQ(Q,A+12),mQ(Q,A+4),mQ(Q,A+20)]};function Hs(Q,A){for(var I={},g=Q.length-22;DI(Q,g)!=101010256;--g)(!g||Q.length-g>65558)&&TA(13);var B=RI(Q,g+8);if(!B)return{};var C=DI(Q,g+16),E=C==4294967295||B==65535;if(E){var i=DI(Q,g-12);E=DI(Q,i)==101075792,E&&(B=DI(Q,i+32),C=DI(Q,i+48))}for(var o=A&&A.filter,D=0;D<B;++D){var s=ns(Q,C,E),w=s[0],G=s[1],a=s[2],y=s[3],h=s[4],c=s[5],k=Us(Q,c);C=h,(!o||o({name:y,size:G,originalSize:a,compression:w}))&&(w?w==8?I[y]=Ss(Q.subarray(k,k+G),{out:new dA(a)}):TA(14,"unknown compression type "+w):I[y]=Cg(Q,k,k+G))}return I}const PA=-12,mA=9,Ls=Math.exp(PA),Ys=Math.exp(mA),PC=-30,OI=Math.exp(PC),tB=11,NB=11,mC=11,rs=tB+NB,f=1<<tB,zA=1<<NB,TC=1<<mC,MB=1,Ks=f-1,ds=zA-1,qs=TC-1,ls=!0,xs=!0;var cA=(Q=>(Q.PLY="ply",Q.SPZ="spz",Q.SPLAT="splat",Q.KSPLAT="ksplat",Q.PCSOGS="pcsogs",Q.PCSOGSZIP="pcsogszip",Q.RAD="rad",Q))(cA||{});const lg={rgbMin:0,rgbMax:1,lnScaleMin:PA,lnScaleMax:mA,sh1Max:1,sh2Max:1,sh3Max:1,lodOpacity:!1},uk=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SPLAT_ENCODING:lg,LN_SCALE_MAX:mA,LN_SCALE_MIN:PA,LN_SCALE_ZERO:PC,SCALE_MAX:Ys,SCALE_MIN:Ls,SCALE_ZERO:OI,SPLAT_TEX_DEPTH:TC,SPLAT_TEX_DEPTH_BITS:mC,SPLAT_TEX_DEPTH_MASK:qs,SPLAT_TEX_HEIGHT:zA,SPLAT_TEX_HEIGHT_BITS:NB,SPLAT_TEX_HEIGHT_MASK:ds,SPLAT_TEX_LAYER_BITS:rs,SPLAT_TEX_MIN_HEIGHT:MB,SPLAT_TEX_WIDTH:f,SPLAT_TEX_WIDTH_BITS:tB,SPLAT_TEX_WIDTH_MASK:Ks,SplatFileType:cA,USE_COMPILED_PARSER_FUNCTION:xs,WASM_SPLAT_SORT:ls},Symbol.toStringTag,{value:"Module"}));function vI(Q){return Q==="bool"||Q==="bvec2"||Q==="bvec3"||Q==="bvec4"}function zI(Q){return Q==="int"||Q==="uint"||Q==="float"}function fA(Q){return Q==="int"||Q==="ivec2"||Q==="ivec3"||Q==="ivec4"}function bA(Q){return Q==="uint"||Q==="uvec2"||Q==="uvec3"||Q==="uvec4"}function xg(Q){return Q==="float"||Q==="vec2"||Q==="vec3"||Q==="vec4"}function OC(Q){return Q==="mat2"||Q==="mat2x2"||Q==="mat2x3"||Q==="mat2x4"||Q==="mat3"||Q==="mat3x2"||Q==="mat3x3"||Q==="mat3x4"||Q==="mat4"||Q==="mat4x2"||Q==="mat4x3"||Q==="mat4x4"}function xI(Q){return xg(Q)||OC(Q)}function sg(Q){return Q==="vec2"||Q==="ivec2"||Q==="uvec2"}function Gg(Q){return Q==="vec3"||Q==="ivec3"||Q==="uvec3"}function pg(Q){return Q==="vec4"||Q==="ivec4"||Q==="uvec4"}function ps(Q){return sg(Q)||Gg(Q)||pg(Q)}function fI(Q){return Q==="mat2"||Q==="mat2x2"}function bI(Q){return Q==="mat3"||Q==="mat3x3"}function uI(Q){return Q==="mat4"||Q==="mat4x4"}function ZC(Q){switch(Q){case"vec2":return"float";case"vec3":return"float";case"vec4":return"float";case"ivec2":return"int";case"ivec3":return"int";case"ivec4":return"int";case"uvec2":return"uint";case"uvec3":return"uint";case"uvec4":return"uint";default:throw new Error(`Invalid vector type: ${Q}`)}}function VC(Q){switch(Q){case"vec2":case"ivec2":case"uvec2":return 2;case"vec3":case"ivec3":case"uvec3":return 3;case"vec4":case"ivec4":case"uvec4":return 4;default:throw new Error(`Invalid vector type: ${Q}`)}}function fs(Q){if(zI(Q))return"float";if(sg(Q))return"vec2";if(Gg(Q))return"vec3";if(pg(Q))return"vec4";throw new Error(`Invalid vector type: ${Q}`)}function XC(Q){if(zI(Q))return"uint";if(sg(Q))return"uvec2";if(Gg(Q))return"uvec3";if(pg(Q))return"uvec4";throw new Error(`Invalid vector type: ${Q}`)}function bs(Q){if(zI(Q))return"int";if(sg(Q))return"ivec2";if(Gg(Q))return"ivec3";if(pg(Q))return"ivec4";throw new Error(`Invalid vector type: ${Q}`)}function WC(Q){if(typeof Q=="string")return Q;if(typeof Q=="object"&&Q.type)return Q.type;throw new Error(`Invalid DynoType: ${String(Q)}`)}function nA(Q){return Math.trunc(Q).toString()}function eA(Q){return`${Math.max(0,Math.trunc(Q)).toString()}u`}function QA(Q){return Q===Number.POSITIVE_INFINITY?"INFINITY":Q===Number.NEGATIVE_INFINITY?"-INFINITY":Number.isInteger(Q)?Q.toFixed(1):Q.toString()}function iA(Q){return Q instanceof dI?Q.type:Q.dynoOut().type}class dI{constructor(A){this.__isDynoValue=!0,this.type=A}}class W extends dI{constructor(A,I){super(A.outTypes[I]),this.dyno=A,this.key=I}}class Eg extends dI{constructor(A,I){super(A),this.literal=I}getLiteral(){return this.literal}}function DQ(Q,A){return new Eg(Q,A)}class jC extends Eg{constructor(A,I){super(A,""),this.value=I}getLiteral(){const{type:A,value:I}=this;switch(A){case"bool":return I?"true":"false";case"uint":return eA(I);case"int":return nA(I);case"float":return QA(I);case"bvec2":{const g=I;return`bvec2(${g[0]}, ${g[1]})`}case"uvec2":{if(I instanceof OA)return`uvec2(${eA(I.x)}, ${eA(I.y)})`;const g=I;return`uvec2(${eA(g[0])}, ${eA(g[1])})`}case"ivec2":{if(I instanceof OA)return`ivec2(${nA(I.x)}, ${nA(I.y)})`;const g=I;return`ivec2(${nA(g[0])}, ${nA(g[1])})`}case"vec2":{if(I instanceof OA)return`vec2(${QA(I.x)}, ${QA(I.y)})`;const g=I;return`vec2(${QA(g[0])}, ${QA(g[1])})`}case"bvec3":{const g=I;return`bvec3(${g[0]}, ${g[1]}, ${g[2]})`}case"uvec3":{if(I instanceof F)return`uvec3(${eA(I.x)}, ${eA(I.y)}, ${eA(I.z)})`;const g=I;return`uvec3(${eA(g[0])}, ${eA(g[1])}, ${eA(g[2])})`}case"ivec3":{if(I instanceof F)return`ivec3(${nA(I.x)}, ${nA(I.y)}, ${nA(I.z)})`;const g=I;return`ivec3(${nA(g[0])}, ${nA(g[1])}, ${nA(g[2])})`}case"vec3":{if(I instanceof F)return`vec3(${QA(I.x)}, ${QA(I.y)}, ${QA(I.z)})`;const g=I;return`vec3(${QA(g[0])}, ${QA(g[1])}, ${QA(g[2])})`}case"bvec4":{const g=I;return`bvec4(${g[0]}, ${g[1]}, ${g[2]}, ${g[3]})`}case"uvec4":{if(I instanceof gI)return`uvec4(${eA(I.x)}, ${eA(I.y)}, ${eA(I.z)}, ${eA(I.w)})`;const g=I;return`uvec4(${eA(g[0])}, ${eA(g[1])}, ${eA(g[2])}, ${eA(g[3])})`}case"ivec4":{if(I instanceof gI)return`ivec4(${nA(I.x)}, ${nA(I.y)}, ${nA(I.z)}, ${nA(I.w)})`;const g=I;return`ivec4(${nA(g[0])}, ${nA(g[1])}, ${nA(g[2])}, ${nA(g[3])})`}case"vec4":{if(I instanceof gI)return`vec4(${QA(I.x)}, ${QA(I.y)}, ${QA(I.z)}, ${QA(I.w)})`;if(I instanceof Z)return`vec4(${QA(I.x)}, ${QA(I.y)}, ${QA(I.z)}, ${QA(I.w)})`;const g=I;return`vec4(${QA(g[0])}, ${QA(g[1])}, ${QA(g[2])}, ${QA(g[3])})`}case"mat2":case"mat2x2":{const g=I,B=g instanceof YC?g.elements:I,C=new Array(4).fill(0).map((E,i)=>QA(B[i]));return`${A}(${C.join(", ")})`}case"mat2x3":{const g=I,B=new Array(6).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat2x4":{const g=I,B=new Array(8).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat3":case"mat3x3":{const g=I,B=g instanceof Hg?g.elements:I,C=new Array(9).fill(0).map((E,i)=>QA(B[i]));return`${A}(${C.join(", ")})`}case"mat3x2":{const g=I,B=new Array(6).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat3x4":{const g=I,B=new Array(12).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat4":case"mat4x4":{const g=I,B=g instanceof FA?g.elements:I,C=new Array(16).fill(0).map((E,i)=>QA(B[i]));return`${A}(${C.join(", ")})`}case"mat4x2":{const g=I,B=new Array(8).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat4x3":{const g=I,B=new Array(12).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}default:throw new Error(`Type not implemented: ${String(A)}`)}}}function _(Q,A){return new jC(Q,A)}function Fg(Q){const A=String(Q);if(vI(Q))return`${A}(false)`;if(xI(Q))return`${A}(0.0)`;if(fA(Q))return`${A}(0)`;if(bA(Q))return`${A}(0u)`;throw new Error(`Type not implemented: ${A}`)}function us(Q){const A=String(Q);if(vI(Q))return`${A}(true)`;if(xI(Q))return`${A}(1.0)`;if(fA(Q))return`${A}(1)`;if(bA(Q))return`${A}(1u)`;throw new Error(`Type not implemented: ${A}`)}function Ps(Q){const A=String(Q);if(vI(Q))return`${A}(true)`;if(xI(Q))return`${A}(-1.0)`;if(fA(Q))return`${A}(-1)`;if(bA(Q))return`${A}(0xFFFFFFFFu)`;throw new Error(`Type not implemented: ${A}`)}const CC=" ";class vC{constructor({indent:A}={}){this.globals=new Set,this.statements=[],this.uniforms={},this.declares=new Set,this.updaters=[],this.sequence=0,this.indent=CC,this.indent=A??CC}nextSequence(){return this.sequence++}}class d{constructor({inTypes:A,outTypes:I,inputs:g,update:B,globals:C,statements:E,generate:i}){this.inTypes=A??{},this.outTypes=I??{},this.inputs=g??{},this.update=B,this.globals=C,this.statements=E,this.generate=i??(({inputs:o,outputs:D,compile:s})=>{var w,G;return{globals:(w=this.globals)==null?void 0:w.call(this,{inputs:o,outputs:D,compile:s}),statements:(G=this.statements)==null?void 0:G.call(this,{inputs:o,outputs:D,compile:s})}})}get outputs(){const A={};for(const I in this.outTypes)A[I]=new W(this,I);return A}apply(A){return Object.assign(this.inputs,A),this.outputs}compile({inputs:A,outputs:I,compile:g}){const B=[`// ${this.constructor.name}(${Object.values(A).join(", ")}) => (${Object.values(I).join(", ")})`],C=[];for(const D in I){const s=I[D];s&&!g.declares.has(s)&&(g.declares.add(s),C.push(D))}const{globals:E,statements:i,uniforms:o}=this.generate({inputs:A,outputs:I,compile:g});for(const D of E??[])g.globals.add(D);for(const D in o)g.uniforms[D]=o[D];this.update&&g.updaters.push(this.update);for(const D of C){const s=I[D];s&&(g.uniforms[s]||B.push(`${JB(s,this.outTypes[D])};`))}return i?.length&&(B.push("{"),B.push(...i.map(D=>g.indent+D)),B.push("}")),B}}class tI extends d{constructor({inTypes:A,outTypes:I,inputs:g,update:B,globals:C,construct:E}){super({inTypes:A,outTypes:I,inputs:g,update:B,globals:C,generate:i=>this.generateBlock(i)}),this.construct=E}generateBlock({inputs:A,outputs:I,compile:g}){var B,C;const E={},i={};for(const c in A)A[c]!=null&&(E[c]=new Eg(this.inTypes[c],A[c]));for(const c in I)I[c]!=null&&(i[c]=new dI(this.outTypes[c]));const o={roots:[]},D=this.construct(E,i,o);for(const c of((B=this.globals)==null?void 0:B.call(this,{inputs:A,outputs:I,compile:g}))??[])g.globals.add(c);const s=[],w=new Map;function G(c,k,R){let t=w.get(c);if(!t){t={sequence:g.nextSequence(),outNames:new Map,newOuts:new Set},w.set(c,t);for(const N in c.inputs){let S=c.inputs[N];for(;S;){if(S instanceof dI){S instanceof W&&G(S.dyno,S.key);break}if(typeof S.dynoOut!="function")throw new Error(`dynoOut is not a function for ${S.constructor.name}`);S=S.dynoOut()}}s.push(c)}k&&(R||t.newOuts.add(k),t.outNames.set(k,R??`${k}_${t.sequence}`))}for(const c of o.roots)G(c);for(const c in i){let k=D?.[c]??i[c];for(;k;){if(k instanceof dI){k instanceof W&&G(k.dyno,k.key,I[c]);break}k=k.dynoOut()}i[c]=k}const a=[];for(const c of s){const k={},R={};for(const S in c.inputs){let J=c.inputs[S];for(;J;){if(J instanceof dI){if(J instanceof Eg)k[S]=J.getLiteral();else if(J instanceof W){const M=(C=w.get(J.dyno))==null?void 0:C.outNames.get(J.key);if(!M)throw new Error(`Source not found for ${J.dyno.constructor.name}.${J.key}`);k[S]=M}break}J=J.dynoOut()}}const t=w.get(c)??{outNames:new Map};for(const[S,J]of t.outNames.entries())R[S]=J;const N=c.compile({inputs:k,outputs:R,compile:g});a.push(N)}const y=[];for(const c in I)i[c]instanceof Eg&&y.push(`${I[c]} = ${i[c].getLiteral()};`);return y.length>0&&a.push(y),{statements:a.flatMap((c,k)=>k===0?c:["",...c])}}}function JA(Q,A,I,{update:g,globals:B}={}){return new tI({inTypes:Q,outTypes:A,construct:I,update:g,globals:B})}function SQ({inTypes:Q,outTypes:A,inputs:I,update:g,globals:B,statements:C,generate:E}){return new d({inTypes:Q,outTypes:A,inputs:I,update:g,globals:B,statements:C,generate:E})}function JB(Q,A,I){const g=typeof A=="string"?A:A.type;if(!g)throw new Error(`Invalid DynoType: ${String(A)}`);return`${g} ${Q}${I!=null?`[${I}]`:""}`}function $(Q){var A;let I=!1;const g=Q.split(`
8170
+ `,BC=typeof self<"u"&&self.Blob&&new Blob([rC],{type:"text/javascript;charset=utf-8"});function os(Q){let A;try{if(A=BC&&(self.URL||self.webkitURL).createObjectURL(BC),!A)throw"";const I=new Worker(A,{name:Q?.name});return I.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(A)}),I}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(rC),{name:Q?.name})}finally{A&&(self.URL||self.webkitURL).revokeObjectURL(A)}}var dA=Uint8Array,Jg=Uint16Array,ws=Int32Array,KC=new dA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),dC=new dA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ss=new dA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qC=function(Q,A){for(var I=new Jg(31),g=0;g<31;++g)I[g]=A+=1<<Q[g-1];for(var B=new ws(I[30]),g=1;g<30;++g)for(var C=I[g];C<I[g+1];++C)B[C]=C-I[g]<<5|g;return{b:I,r:B}},lC=qC(KC,2),xC=lC.b,Gs=lC.r;xC[28]=258,Gs[258]=28;var as=qC(dC,0),hs=as.b,pC=new Jg(32768);for(var yA=0;yA<32768;++yA){var YI=(yA&43690)>>1|(yA&21845)<<1;YI=(YI&52428)>>2|(YI&13107)<<2,YI=(YI&61680)>>4|(YI&3855)<<4,pC[yA]=((YI&65280)>>8|(YI&255)<<8)>>1}var Ug=function(Q,A,I){for(var g=Q.length,B=0,C=new Jg(A);B<g;++B)Q[B]&&++C[Q[B]-1];var E=new Jg(A);for(B=1;B<A;++B)E[B]=E[B-1]+C[B-1]<<1;var i;{i=new Jg(1<<A);var o=15-A;for(B=0;B<g;++B)if(Q[B])for(var D=B<<4|Q[B],s=A-Q[B],w=E[Q[B]-1]++<<s,G=w|(1<<s)-1;w<=G;++w)i[pC[w]>>o]=D}return i},qg=new dA(288);for(var yA=0;yA<144;++yA)qg[yA]=8;for(var yA=144;yA<256;++yA)qg[yA]=9;for(var yA=256;yA<280;++yA)qg[yA]=7;for(var yA=280;yA<288;++yA)qg[yA]=8;var fC=new dA(32);for(var yA=0;yA<32;++yA)fC[yA]=5;var ys=Ug(qg,9),cs=Ug(fC,5),uQ=function(Q){for(var A=Q[0],I=1;I<Q.length;++I)Q[I]>A&&(A=Q[I]);return A},EI=function(Q,A,I){var g=A/8|0;return(Q[g]|Q[g+1]<<8)>>(A&7)&I},PQ=function(Q,A){var I=A/8|0;return(Q[I]|Q[I+1]<<8|Q[I+2]<<16)>>(A&7)},bC=function(Q){return(Q+7)/8|0},Cg=function(Q,A,I){return(A==null||A<0)&&(A=0),(I==null||I>Q.length)&&(I=Q.length),new dA(Q.subarray(A,I))},ks=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],TA=function(Q,A,I){var g=new Error(A||ks[Q]);if(g.code=Q,Error.captureStackTrace&&Error.captureStackTrace(g,TA),!I)throw g;return g},uC=function(Q,A,I,g){var B=Q.length,C=g?g.length:0;if(!B||A.f&&!A.l)return I||new dA(0);var E=!I,i=E||A.i!=2,o=A.i;E&&(I=new dA(B*3));var D=function(NA){var wA=I.length;if(NA>wA){var aA=new dA(Math.max(wA*2,NA));aA.set(I),I=aA}},s=A.f||0,w=A.p||0,G=A.b||0,a=A.l,y=A.d,h=A.m,c=A.n,k=B*8;do{if(!a){s=EI(Q,w,1);var R=EI(Q,w+1,3);if(w+=3,R)if(R==1)a=ys,y=cs,h=9,c=5;else if(R==2){var J=EI(Q,w,31)+257,M=EI(Q,w+10,15)+4,U=J+EI(Q,w+5,31)+1;w+=14;for(var n=new dA(U),L=new dA(19),H=0;H<M;++H)L[ss[H]]=EI(Q,w+H*3,7);w+=M*3;for(var e=uQ(L),q=(1<<e)-1,Y=Ug(L,e),H=0;H<U;){var K=Y[EI(Q,w,q)];w+=K&15;var t=K>>4;if(t<16)n[H++]=t;else{var x=0,m=0;for(t==16?(m=3+EI(Q,w,3),w+=2,x=n[H-1]):t==17?(m=3+EI(Q,w,7),w+=3):t==18&&(m=11+EI(Q,w,127),w+=7);m--;)n[H++]=x}}var j=n.subarray(0,J),u=n.subarray(J);h=uQ(j),c=uQ(u),a=Ug(j,h),y=Ug(u,c)}else TA(1);else{var t=bC(w)+4,N=Q[t-4]|Q[t-3]<<8,S=t+N;if(S>B){o&&TA(0);break}i&&D(G+N),I.set(Q.subarray(t,S),G),A.b=G+=N,A.p=w=S*8,A.f=s;continue}if(w>k){o&&TA(0);break}}i&&D(G+131072);for(var CA=(1<<h)-1,V=(1<<c)-1,AA=w;;AA=w){var x=a[PQ(Q,w)&CA],O=x>>4;if(w+=x&15,w>k){o&&TA(0);break}if(x||TA(2),O<256)I[G++]=O;else if(O==256){AA=w,a=null;break}else{var P=O-254;if(O>264){var H=O-257,b=KC[H];P=EI(Q,w,(1<<b)-1)+xC[H],w+=b}var T=y[PQ(Q,w)&V],p=T>>4;T||TA(3),w+=T&15;var u=hs[p];if(p>3){var b=dC[p];u+=PQ(Q,w)&(1<<b)-1,w+=b}if(w>k){o&&TA(0);break}i&&D(G+131072);var SA=G+P;if(G<u){var GA=C-u,tA=Math.min(u,SA);for(GA+G<0&&TA(3);G<tA;++G)I[G]=g[GA+G]}for(;G<SA;++G)I[G]=I[G-u]}}A.l=a,A.p=AA,A.b=G,A.f=s,a&&(s=1,A.m=h,A.d=y,A.n=c)}while(!s);return G!=I.length&&E?Cg(I,0,G):I.subarray(0,G)},Rs=new dA(0),RI=function(Q,A){return Q[A]|Q[A+1]<<8},DI=function(Q,A){return(Q[A]|Q[A+1]<<8|Q[A+2]<<16|Q[A+3]<<24)>>>0},mQ=function(Q,A){return DI(Q,A)+DI(Q,A+4)*4294967296},Fs=function(Q){(Q[0]!=31||Q[1]!=139||Q[2]!=8)&&TA(6,"invalid gzip data");var A=Q[3],I=10;A&4&&(I+=(Q[10]|Q[11]<<8)+2);for(var g=(A>>3&1)+(A>>4&1);g>0;g-=!Q[I++]);return I+(A&2)},TQ=(function(){function Q(A,I){typeof A=="function"&&(I=A,A={}),this.ondata=I;var g=A&&A.dictionary&&A.dictionary.subarray(-32768);this.s={i:0,b:g?g.length:0},this.o=new dA(32768),this.p=new dA(0),g&&this.o.set(g)}return Q.prototype.e=function(A){if(this.ondata||TA(5),this.d&&TA(4),!this.p.length)this.p=A;else if(A.length){var I=new dA(this.p.length+A.length);I.set(this.p),I.set(A,this.p.length),this.p=I}},Q.prototype.c=function(A){this.s.i=+(this.d=A||!1);var I=this.s.b,g=uC(this.p,this.s,this.o);this.ondata(Cg(g,I,this.s.b),this.d),this.o=Cg(g,this.s.b-32768),this.s.b=this.o.length,this.p=Cg(this.p,this.s.p/8|0),this.s.p&=7},Q.prototype.push=function(A,I){this.e(A),this.c(I)},Q})();function Ss(Q,A){return uC(Q,{i:2},A&&A.out,A&&A.dictionary)}var ts=(function(){function Q(A,I){this.v=1,this.r=0,TQ.call(this,A,I)}return Q.prototype.push=function(A,I){if(TQ.prototype.e.call(this,A),this.r+=A.length,this.v){var g=this.p.subarray(this.v-1),B=g.length>3?Fs(g):4;if(B>g.length){if(!I)return}else this.v>1&&this.onmember&&this.onmember(this.r-g.length);this.p=g.subarray(B),this.v=0}TQ.prototype.c.call(this,I),this.s.f&&!this.s.l&&!I&&(this.v=bC(this.s.p)+9,this.s={i:0},this.o=new dA(0),this.push(new dA(0),I))},Q})(),$Q=typeof TextDecoder<"u"&&new TextDecoder,Ns=0;try{$Q.decode(Rs,{stream:!0}),Ns=1}catch{}var Ms=function(Q){for(var A="",I=0;;){var g=Q[I++],B=(g>127)+(g>223)+(g>239);if(I+B>Q.length)return{s:A,r:Cg(Q,I-1)};B?B==3?(g=((g&15)<<18|(Q[I++]&63)<<12|(Q[I++]&63)<<6|Q[I++]&63)-65536,A+=String.fromCharCode(55296|g>>10,56320|g&1023)):B&1?A+=String.fromCharCode((g&31)<<6|Q[I++]&63):A+=String.fromCharCode((g&15)<<12|(Q[I++]&63)<<6|Q[I++]&63):A+=String.fromCharCode(g)}};function Js(Q,A){if(A){for(var I="",g=0;g<Q.length;g+=16384)I+=String.fromCharCode.apply(null,Q.subarray(g,g+16384));return I}else{if($Q)return $Q.decode(Q);var B=Ms(Q),C=B.s,I=B.r;return I.length&&TA(8),C}}var Us=function(Q,A){return A+30+RI(Q,A+26)+RI(Q,A+28)},ns=function(Q,A,I){var g=RI(Q,A+28),B=Js(Q.subarray(A+46,A+46+g),!(RI(Q,A+8)&2048)),C=A+46+g,E=DI(Q,A+20),i=I&&E==4294967295?es(Q,C):[E,DI(Q,A+24),DI(Q,A+42)],o=i[0],D=i[1],s=i[2];return[RI(Q,A+10),o,D,B,C+RI(Q,A+30)+RI(Q,A+32),s]},es=function(Q,A){for(;RI(Q,A)!=1;A+=4+RI(Q,A+2));return[mQ(Q,A+12),mQ(Q,A+4),mQ(Q,A+20)]};function Hs(Q,A){for(var I={},g=Q.length-22;DI(Q,g)!=101010256;--g)(!g||Q.length-g>65558)&&TA(13);var B=RI(Q,g+8);if(!B)return{};var C=DI(Q,g+16),E=C==4294967295||B==65535;if(E){var i=DI(Q,g-12);E=DI(Q,i)==101075792,E&&(B=DI(Q,i+32),C=DI(Q,i+48))}for(var o=A&&A.filter,D=0;D<B;++D){var s=ns(Q,C,E),w=s[0],G=s[1],a=s[2],y=s[3],h=s[4],c=s[5],k=Us(Q,c);C=h,(!o||o({name:y,size:G,originalSize:a,compression:w}))&&(w?w==8?I[y]=Ss(Q.subarray(k,k+G),{out:new dA(a)}):TA(14,"unknown compression type "+w):I[y]=Cg(Q,k,k+G))}return I}const PA=-12,mA=9,Ls=Math.exp(PA),Ys=Math.exp(mA),PC=-30,OI=Math.exp(PC),tB=11,NB=11,mC=11,rs=tB+NB,f=1<<tB,zA=1<<NB,TC=1<<mC,MB=1,Ks=f-1,ds=zA-1,qs=TC-1,ls=!0,xs=!0;var cA=(Q=>(Q.PLY="ply",Q.SPZ="spz",Q.SPLAT="splat",Q.KSPLAT="ksplat",Q.PCSOGS="pcsogs",Q.PCSOGSZIP="pcsogszip",Q.RAD="rad",Q))(cA||{});const lg={rgbMin:0,rgbMax:1,lnScaleMin:PA,lnScaleMax:mA,sh1Max:1,sh2Max:1,sh3Max:1,lodOpacity:!1},Kk=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_SPLAT_ENCODING:lg,LN_SCALE_MAX:mA,LN_SCALE_MIN:PA,LN_SCALE_ZERO:PC,SCALE_MAX:Ys,SCALE_MIN:Ls,SCALE_ZERO:OI,SPLAT_TEX_DEPTH:TC,SPLAT_TEX_DEPTH_BITS:mC,SPLAT_TEX_DEPTH_MASK:qs,SPLAT_TEX_HEIGHT:zA,SPLAT_TEX_HEIGHT_BITS:NB,SPLAT_TEX_HEIGHT_MASK:ds,SPLAT_TEX_LAYER_BITS:rs,SPLAT_TEX_MIN_HEIGHT:MB,SPLAT_TEX_WIDTH:f,SPLAT_TEX_WIDTH_BITS:tB,SPLAT_TEX_WIDTH_MASK:Ks,SplatFileType:cA,USE_COMPILED_PARSER_FUNCTION:xs,WASM_SPLAT_SORT:ls},Symbol.toStringTag,{value:"Module"}));function vI(Q){return Q==="bool"||Q==="bvec2"||Q==="bvec3"||Q==="bvec4"}function zI(Q){return Q==="int"||Q==="uint"||Q==="float"}function fA(Q){return Q==="int"||Q==="ivec2"||Q==="ivec3"||Q==="ivec4"}function bA(Q){return Q==="uint"||Q==="uvec2"||Q==="uvec3"||Q==="uvec4"}function xg(Q){return Q==="float"||Q==="vec2"||Q==="vec3"||Q==="vec4"}function OC(Q){return Q==="mat2"||Q==="mat2x2"||Q==="mat2x3"||Q==="mat2x4"||Q==="mat3"||Q==="mat3x2"||Q==="mat3x3"||Q==="mat3x4"||Q==="mat4"||Q==="mat4x2"||Q==="mat4x3"||Q==="mat4x4"}function xI(Q){return xg(Q)||OC(Q)}function sg(Q){return Q==="vec2"||Q==="ivec2"||Q==="uvec2"}function Gg(Q){return Q==="vec3"||Q==="ivec3"||Q==="uvec3"}function pg(Q){return Q==="vec4"||Q==="ivec4"||Q==="uvec4"}function ps(Q){return sg(Q)||Gg(Q)||pg(Q)}function fI(Q){return Q==="mat2"||Q==="mat2x2"}function bI(Q){return Q==="mat3"||Q==="mat3x3"}function uI(Q){return Q==="mat4"||Q==="mat4x4"}function ZC(Q){switch(Q){case"vec2":return"float";case"vec3":return"float";case"vec4":return"float";case"ivec2":return"int";case"ivec3":return"int";case"ivec4":return"int";case"uvec2":return"uint";case"uvec3":return"uint";case"uvec4":return"uint";default:throw new Error(`Invalid vector type: ${Q}`)}}function VC(Q){switch(Q){case"vec2":case"ivec2":case"uvec2":return 2;case"vec3":case"ivec3":case"uvec3":return 3;case"vec4":case"ivec4":case"uvec4":return 4;default:throw new Error(`Invalid vector type: ${Q}`)}}function fs(Q){if(zI(Q))return"float";if(sg(Q))return"vec2";if(Gg(Q))return"vec3";if(pg(Q))return"vec4";throw new Error(`Invalid vector type: ${Q}`)}function XC(Q){if(zI(Q))return"uint";if(sg(Q))return"uvec2";if(Gg(Q))return"uvec3";if(pg(Q))return"uvec4";throw new Error(`Invalid vector type: ${Q}`)}function bs(Q){if(zI(Q))return"int";if(sg(Q))return"ivec2";if(Gg(Q))return"ivec3";if(pg(Q))return"ivec4";throw new Error(`Invalid vector type: ${Q}`)}function WC(Q){if(typeof Q=="string")return Q;if(typeof Q=="object"&&Q.type)return Q.type;throw new Error(`Invalid DynoType: ${String(Q)}`)}function nA(Q){return Math.trunc(Q).toString()}function eA(Q){return`${Math.max(0,Math.trunc(Q)).toString()}u`}function QA(Q){return Q===Number.POSITIVE_INFINITY?"INFINITY":Q===Number.NEGATIVE_INFINITY?"-INFINITY":Number.isInteger(Q)?Q.toFixed(1):Q.toString()}function iA(Q){return Q instanceof dI?Q.type:Q.dynoOut().type}class dI{constructor(A){this.__isDynoValue=!0,this.type=A}}class W extends dI{constructor(A,I){super(A.outTypes[I]),this.dyno=A,this.key=I}}class Eg extends dI{constructor(A,I){super(A),this.literal=I}getLiteral(){return this.literal}}function DQ(Q,A){return new Eg(Q,A)}class jC extends Eg{constructor(A,I){super(A,""),this.value=I}getLiteral(){const{type:A,value:I}=this;switch(A){case"bool":return I?"true":"false";case"uint":return eA(I);case"int":return nA(I);case"float":return QA(I);case"bvec2":{const g=I;return`bvec2(${g[0]}, ${g[1]})`}case"uvec2":{if(I instanceof OA)return`uvec2(${eA(I.x)}, ${eA(I.y)})`;const g=I;return`uvec2(${eA(g[0])}, ${eA(g[1])})`}case"ivec2":{if(I instanceof OA)return`ivec2(${nA(I.x)}, ${nA(I.y)})`;const g=I;return`ivec2(${nA(g[0])}, ${nA(g[1])})`}case"vec2":{if(I instanceof OA)return`vec2(${QA(I.x)}, ${QA(I.y)})`;const g=I;return`vec2(${QA(g[0])}, ${QA(g[1])})`}case"bvec3":{const g=I;return`bvec3(${g[0]}, ${g[1]}, ${g[2]})`}case"uvec3":{if(I instanceof F)return`uvec3(${eA(I.x)}, ${eA(I.y)}, ${eA(I.z)})`;const g=I;return`uvec3(${eA(g[0])}, ${eA(g[1])}, ${eA(g[2])})`}case"ivec3":{if(I instanceof F)return`ivec3(${nA(I.x)}, ${nA(I.y)}, ${nA(I.z)})`;const g=I;return`ivec3(${nA(g[0])}, ${nA(g[1])}, ${nA(g[2])})`}case"vec3":{if(I instanceof F)return`vec3(${QA(I.x)}, ${QA(I.y)}, ${QA(I.z)})`;const g=I;return`vec3(${QA(g[0])}, ${QA(g[1])}, ${QA(g[2])})`}case"bvec4":{const g=I;return`bvec4(${g[0]}, ${g[1]}, ${g[2]}, ${g[3]})`}case"uvec4":{if(I instanceof gI)return`uvec4(${eA(I.x)}, ${eA(I.y)}, ${eA(I.z)}, ${eA(I.w)})`;const g=I;return`uvec4(${eA(g[0])}, ${eA(g[1])}, ${eA(g[2])}, ${eA(g[3])})`}case"ivec4":{if(I instanceof gI)return`ivec4(${nA(I.x)}, ${nA(I.y)}, ${nA(I.z)}, ${nA(I.w)})`;const g=I;return`ivec4(${nA(g[0])}, ${nA(g[1])}, ${nA(g[2])}, ${nA(g[3])})`}case"vec4":{if(I instanceof gI)return`vec4(${QA(I.x)}, ${QA(I.y)}, ${QA(I.z)}, ${QA(I.w)})`;if(I instanceof Z)return`vec4(${QA(I.x)}, ${QA(I.y)}, ${QA(I.z)}, ${QA(I.w)})`;const g=I;return`vec4(${QA(g[0])}, ${QA(g[1])}, ${QA(g[2])}, ${QA(g[3])})`}case"mat2":case"mat2x2":{const g=I,B=g instanceof LC?g.elements:I,C=new Array(4).fill(0).map((E,i)=>QA(B[i]));return`${A}(${C.join(", ")})`}case"mat2x3":{const g=I,B=new Array(6).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat2x4":{const g=I,B=new Array(8).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat3":case"mat3x3":{const g=I,B=g instanceof Hg?g.elements:I,C=new Array(9).fill(0).map((E,i)=>QA(B[i]));return`${A}(${C.join(", ")})`}case"mat3x2":{const g=I,B=new Array(6).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat3x4":{const g=I,B=new Array(12).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat4":case"mat4x4":{const g=I,B=g instanceof FA?g.elements:I,C=new Array(16).fill(0).map((E,i)=>QA(B[i]));return`${A}(${C.join(", ")})`}case"mat4x2":{const g=I,B=new Array(8).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}case"mat4x3":{const g=I,B=new Array(12).fill(0).map((C,E)=>QA(g[E]));return`${A}(${B.join(", ")})`}default:throw new Error(`Type not implemented: ${String(A)}`)}}}function _(Q,A){return new jC(Q,A)}function Fg(Q){const A=String(Q);if(vI(Q))return`${A}(false)`;if(xI(Q))return`${A}(0.0)`;if(fA(Q))return`${A}(0)`;if(bA(Q))return`${A}(0u)`;throw new Error(`Type not implemented: ${A}`)}function us(Q){const A=String(Q);if(vI(Q))return`${A}(true)`;if(xI(Q))return`${A}(1.0)`;if(fA(Q))return`${A}(1)`;if(bA(Q))return`${A}(1u)`;throw new Error(`Type not implemented: ${A}`)}function Ps(Q){const A=String(Q);if(vI(Q))return`${A}(true)`;if(xI(Q))return`${A}(-1.0)`;if(fA(Q))return`${A}(-1)`;if(bA(Q))return`${A}(0xFFFFFFFFu)`;throw new Error(`Type not implemented: ${A}`)}const CC=" ";class vC{constructor({indent:A}={}){this.globals=new Set,this.statements=[],this.uniforms={},this.declares=new Set,this.updaters=[],this.sequence=0,this.indent=CC,this.indent=A??CC}nextSequence(){return this.sequence++}}class d{constructor({inTypes:A,outTypes:I,inputs:g,update:B,globals:C,statements:E,generate:i}){this.inTypes=A??{},this.outTypes=I??{},this.inputs=g??{},this.update=B,this.globals=C,this.statements=E,this.generate=i??(({inputs:o,outputs:D,compile:s})=>{var w,G;return{globals:(w=this.globals)==null?void 0:w.call(this,{inputs:o,outputs:D,compile:s}),statements:(G=this.statements)==null?void 0:G.call(this,{inputs:o,outputs:D,compile:s})}})}get outputs(){const A={};for(const I in this.outTypes)A[I]=new W(this,I);return A}apply(A){return Object.assign(this.inputs,A),this.outputs}compile({inputs:A,outputs:I,compile:g}){const B=[`// ${this.constructor.name}(${Object.values(A).join(", ")}) => (${Object.values(I).join(", ")})`],C=[];for(const D in I){const s=I[D];s&&!g.declares.has(s)&&(g.declares.add(s),C.push(D))}const{globals:E,statements:i,uniforms:o}=this.generate({inputs:A,outputs:I,compile:g});for(const D of E??[])g.globals.add(D);for(const D in o)g.uniforms[D]=o[D];this.update&&g.updaters.push(this.update);for(const D of C){const s=I[D];s&&(g.uniforms[s]||B.push(`${JB(s,this.outTypes[D])};`))}return i?.length&&(B.push("{"),B.push(...i.map(D=>g.indent+D)),B.push("}")),B}}class tI extends d{constructor({inTypes:A,outTypes:I,inputs:g,update:B,globals:C,construct:E}){super({inTypes:A,outTypes:I,inputs:g,update:B,globals:C,generate:i=>this.generateBlock(i)}),this.construct=E}generateBlock({inputs:A,outputs:I,compile:g}){var B,C;const E={},i={};for(const c in A)A[c]!=null&&(E[c]=new Eg(this.inTypes[c],A[c]));for(const c in I)I[c]!=null&&(i[c]=new dI(this.outTypes[c]));const o={roots:[]},D=this.construct(E,i,o);for(const c of((B=this.globals)==null?void 0:B.call(this,{inputs:A,outputs:I,compile:g}))??[])g.globals.add(c);const s=[],w=new Map;function G(c,k,R){let t=w.get(c);if(!t){t={sequence:g.nextSequence(),outNames:new Map,newOuts:new Set},w.set(c,t);for(const N in c.inputs){let S=c.inputs[N];for(;S;){if(S instanceof dI){S instanceof W&&G(S.dyno,S.key);break}if(typeof S.dynoOut!="function")throw new Error(`dynoOut is not a function for ${S.constructor.name}`);S=S.dynoOut()}}s.push(c)}k&&(R||t.newOuts.add(k),t.outNames.set(k,R??`${k}_${t.sequence}`))}for(const c of o.roots)G(c);for(const c in i){let k=D?.[c]??i[c];for(;k;){if(k instanceof dI){k instanceof W&&G(k.dyno,k.key,I[c]);break}k=k.dynoOut()}i[c]=k}const a=[];for(const c of s){const k={},R={};for(const S in c.inputs){let J=c.inputs[S];for(;J;){if(J instanceof dI){if(J instanceof Eg)k[S]=J.getLiteral();else if(J instanceof W){const M=(C=w.get(J.dyno))==null?void 0:C.outNames.get(J.key);if(!M)throw new Error(`Source not found for ${J.dyno.constructor.name}.${J.key}`);k[S]=M}break}J=J.dynoOut()}}const t=w.get(c)??{outNames:new Map};for(const[S,J]of t.outNames.entries())R[S]=J;const N=c.compile({inputs:k,outputs:R,compile:g});a.push(N)}const y=[];for(const c in I)i[c]instanceof Eg&&y.push(`${I[c]} = ${i[c].getLiteral()};`);return y.length>0&&a.push(y),{statements:a.flatMap((c,k)=>k===0?c:["",...c])}}}function JA(Q,A,I,{update:g,globals:B}={}){return new tI({inTypes:Q,outTypes:A,construct:I,update:g,globals:B})}function SQ({inTypes:Q,outTypes:A,inputs:I,update:g,globals:B,statements:C,generate:E}){return new d({inTypes:Q,outTypes:A,inputs:I,update:g,globals:B,statements:C,generate:E})}function JB(Q,A,I){const g=typeof A=="string"?A:A.type;if(!g)throw new Error(`Invalid DynoType: ${String(A)}`);return`${g} ${Q}${I!=null?`[${I}]`:""}`}function $(Q){var A;let I=!1;const g=Q.split(`
8171
8171
  `).map(E=>{const i=E.trimEnd();return I?i:i.length>0?(I=!0,i):null}).filter(E=>E!=null);for(;g.length>0&&g[g.length-1].length===0;)g.pop();if(g.length===0)return[];const B=(A=g[0].match(/^\s*/))==null?void 0:A[0];if(!B)return g;const C=new RegExp(`^${B}`);return g.map(E=>E.replace(C,""))}function sA(Q){return $(Q).join(`
8172
8172
  `)}class r extends d{constructor({a:A,outKey:I,outTypeFunc:g}){const B={a:iA(A)},C=g(iA(A)),E={[I]:C};super({inTypes:B,outTypes:E,inputs:{a:A}}),this.outKey=I}dynoOut(){return new W(this,this.outKey)}}class oA extends d{constructor({a:A,b:I,outKey:g,outTypeFunc:B}){const C={a:iA(A),b:iA(I)},E=B(iA(A),iA(I)),i={[g]:E};super({inTypes:C,outTypes:i,inputs:{a:A,b:I}}),this.outKey=g}dynoOut(){return new W(this,this.outKey)}}class _I extends d{constructor({a:A,b:I,c:g,outKey:B,outTypeFunc:C}){const E={a:iA(A),b:iA(I),c:iA(g)},i=C(iA(A),iA(I),iA(g)),o={[B]:i};super({inTypes:E,outTypes:o,inputs:{a:A,b:I,c:g}}),this.outKey=B}dynoOut(){return new W(this,this.outKey)}}const zC=Number.parseInt(Qs),_C=zC>=179,fg=new Float32Array(1),tQ=new Uint32Array(fg.buffer),UB="Float16Array"in globalThis,oQ=UB?new globalThis.Float16Array(1):null,$C=new Uint16Array(oQ?.buffer);function AE(Q){const A=Math.sqrt(Q.reduce((I,g)=>I+g*g,0));return Q.map(I=>I/A)}function jg(Q){return fg[0]=Q,tQ[0]}function vg(Q){return tQ[0]=Q,fg[0]}const vA=UB?ms:Ts,MA=UB?Os:Zs;function ms(Q){return oQ[0]=Q,$C[0]}function Ts(Q){fg[0]=Q;const A=tQ[0],I=A>>31&1,g=A>>23&255,B=A&8388607,C=I<<15;if(g===255)return B!==0?C|32767:C|31744;const E=g-127+15;if(E>=31)return C|31744;if(E<=0){if(E<-10)return C;const o=(B|8388608)>>1-E+13;return C|o}const i=B>>13;return C|E<<10|i}function Os(Q){return $C[0]=Q,oQ[0]}function Zs(Q){const A=Q>>15&1,I=Q>>10&31,g=Q&1023;let B;if(I===0)if(g===0)B=A<<31;else{let C=g,E=-14;for(;(C&1024)===0;)C<<=1,E--;C&=1023;const i=E+127,o=C<<13;B=A<<31|i<<23|o}else if(I===31)g===0?B=A<<31|2139095040:B=A<<31|2143289344;else{const C=I-15+127,E=g<<13;B=A<<31|C<<23|E}return tQ[0]=B,fg[0]}function $A(Q){return Math.max(0,Math.min(255,Math.round(Q*255)))}function zg(Q){return Math.max(-127,Math.min(127,Math.round(Q*127)))}function Vs(Q){return Q/255}function Xs(Q){return Q/127}class Ws{constructor({asyncFetch:A,dispose:I,maxItems:g=5}){this.asyncFetch=A,this.dispose=I,this.maxItems=g,this.items=[],this.pending=new Map}has(A){return this.items.some(I=>I.key===A)}getImmediate(A){const I=this.items.findIndex(g=>g.key===A);if(I>=0){const g=this.items.splice(I,1)[0];return this.items.push(g),g.data}}async getFetch(A){const I=this.getImmediate(A);if(I!==void 0)return I;let g=this.pending.get(A);return g||(g=this.asyncFetch(A).then(B=>{for(this.pending.delete(A),this.items.push({key:A,data:B});this.items.length>this.maxItems;){const C=this.items.shift();C&&this.dispose&&this.dispose(C.data)}return B}),this.pending.set(A,g),g)}}function js(Q,A){const I=Object.entries(Q).map(([g,B])=>[g,A(B,g)]);return Object.fromEntries(I)}function vs(Q,A){const I=Object.entries(Q).map(([g,B])=>[g,A(B,g)]).filter(([g,B])=>B!==void 0);return Object.fromEntries(I)}function nB(Q){const A=[],I=new Set;function g(B){B&&typeof B=="object"&&!I.has(B)&&(I.add(B),B instanceof ArrayBuffer?A.push(B):ArrayBuffer.isView(B)?A.push(B.buffer):Array.isArray(B)?B.forEach(g):Object.values(B).forEach(g))}return g(Q),A}function AB(Q,A){return new Array(Q).fill(null).map((I,g)=>A(g))}class IE{constructor({allocate:A,dispose:I,valid:g}){this.items=[],this.allocate=A,this.dispose=I,this.valid=g}alloc(A){for(;;){const I=this.items.pop();if(!I)break;if(this.valid(I,A))return I;this.dispose&&this.dispose(I)}return this.allocate(A)}free(A){this.items.push(A)}disposeAll(){let A;for(A=this.items.pop();A;)this.dispose&&this.dispose(A),A=this.items.pop()}}function IB(Q,A,I,g,B,C,E,i,o,D,s,w,G,a,y,h){const c=A*4,[k,R]=Q;k[c]=jg(I),k[c+1]=jg(g),k[c+2]=jg(B),k[c+3]=vA(G),R[c]=vA(a)|vA(y)<<16,R[c+1]=vA(h)|vA(Math.log(C))<<16,R[c+2]=vA(Math.log(E))|vA(Math.log(i))<<16,R[c+3]=wE(o,D,s,w)}function wQ(Q,A){const I=eB,g=A*4,[B,C]=Q;return I.center.x=vg(B[g]),I.center.y=vg(B[g+1]),I.center.z=vg(B[g+2]),I.opacity=MA(B[g+3]&65535),I.color.r=MA(C[g]&65535),I.color.g=MA(C[g]>>>16),I.color.b=MA(C[g+1]&65535),I.scales.x=Math.exp(MA(C[g+1]>>>16)),I.scales.y=Math.exp(MA(C[g+2]&65535)),I.scales.z=Math.exp(MA(C[g+2]>>>16)),sE(C[g+3],I.quaternion),I}function gB(Q,A,I,g,B,C,E,i,o,D,s,w,G,a,y,h,c){const k=c?.rgbMin??0,t=(c?.rgbMax??1)-k,N=$A((a-k)/t),S=$A((y-k)/t),J=$A((h-k)/t),M=$A(c?.lodOpacity?.5*G:G),U=rB(gE.set(o,D,s,w)),n=U&255,L=U>>>8&255,H=U>>>16&255,e=c?.lnScaleMin??PA,Y=254/((c?.lnScaleMax??mA)-e),K=C<OI?0:Math.min(255,Math.max(1,Math.round((Math.log(C)-e)*Y)+1)),x=E<OI?0:Math.min(255,Math.max(1,Math.round((Math.log(E)-e)*Y)+1)),m=i<OI?0:Math.min(255,Math.max(1,Math.round((Math.log(i)-e)*Y)+1)),j=vA(I),u=vA(g),CA=vA(B),V=A*4;Q[V]=N|S<<8|J<<16|M<<24,Q[V+1]=j|u<<16,Q[V+2]=CA|n<<16|L<<24,Q[V+3]=K|x<<8|m<<16|H<<24}function zs(Q,A,I,g,B){const C=vA(I),E=vA(g),i=vA(B),o=A*4;Q[o+1]=C|E<<16,Q[o+2]=i|Q[o+2]&4294901760}function _s(Q,A,I,g,B,C){const E=C?.lnScaleMin??PA,o=254/((C?.lnScaleMax??mA)-E),D=I<OI?0:Math.min(255,Math.max(1,Math.round((Math.log(I)-E)*o)+1)),s=g<OI?0:Math.min(255,Math.max(1,Math.round((Math.log(g)-E)*o)+1)),w=B<OI?0:Math.min(255,Math.max(1,Math.round((Math.log(B)-E)*o)+1)),G=A*4;Q[G+3]=D|s<<8|w<<16|Q[G+3]&4278190080}const gE=new Z;function $s(Q,A,I,g,B,C){const E=rB(gE.set(I,g,B,C)),i=E&255,o=E>>>8&255,D=E>>>16&255,s=A*4;Q[s+2]=Q[s+2]&65535|i<<16|o<<24,Q[s+3]=Q[s+3]&16777215|D<<24}function A0(Q,A,I,g,B,C,E){const i=E?.rgbMin??0,D=(E?.rgbMax??1)-i,s=$A((I-i)/D),w=$A((g-i)/D),G=$A((B-i)/D),a=$A(E?.lodOpacity?.5*C:C),y=A*4;Q[y]=s|w<<8|G<<16|a<<24}function I0(Q,A,I,g,B,C){const E=C?.rgbMin??0,o=(C?.rgbMax??1)-E,D=$A((I-E)/o),s=$A((g-E)/o),w=$A((B-E)/o),G=A*4;Q[G]=D|s<<8|w<<16|Q[G]&4278190080}function g0(Q,A,I){const g=$A(I),B=A*4;Q[B]=Q[B]&16777215|g<<24}const Q0=new F,B0=new F,C0=new Z,E0=new YA,eB={center:Q0,scales:B0,quaternion:C0,color:E0,opacity:0};function sQ(Q,A,I){const g=eB,B=A*4,C=Q[B],E=Q[B+1],i=Q[B+2],o=Q[B+3],D=I?.rgbMin??0,w=(I?.rgbMax??1)-D;g.color.set(D+(C&255)/255*w,D+(C>>>8&255)/255*w,D+(C>>>16&255)/255*w),g.opacity=(C>>>24&255)/255,I?.lodOpacity&&(g.opacity=2*g.opacity),g.center.set(MA(E&65535),MA(E>>>16&65535),MA(i&65535));const G=I?.lnScaleMin??PA,y=((I?.lnScaleMax??mA)-G)/254,h=o&255;g.scales.x=h===0?0:Math.exp(G+(h-1)*y);const c=o>>>8&255;g.scales.y=c===0?0:Math.exp(G+(c-1)*y);const k=o>>>16&255;g.scales.z=k===0?0:Math.exp(G+(k-1)*y);const R=i>>>16&65535|o>>>8&16711680;return oE(R,g.quaternion),g}function EA(Q){const A=f,I=Math.max(MB,Math.min(zA,Math.ceil(Q/A))),g=Math.ceil(Q/(A*I)),B=A*I*g;return{width:A,height:I,depth:g,maxSplats:B}}function i0(Q){const A=f,I=Math.max(MB,Math.min(zA,Math.ceil(Q/A))),g=Math.ceil(Q/(A*I));return A*I*g}function GQ(){return navigator.platform.toLowerCase().startsWith("win")?!1:navigator.maxTouchPoints>0?!0:/Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/.test(navigator.userAgent)}function HB(){return/Android/.test(navigator.userAgent)||/Tizen/.test(navigator.userAgent)}function LB(){return!!navigator.xr&&/Oculus/.test(navigator.userAgent)}function D0(){return LB()&&/Quest 2/.test(navigator.userAgent)}function rg(){return/iPhone|iPad/.test(navigator.userAgent)}function QE(){return!!navigator.xr&&rg()&&/Safari/.test(navigator.userAgent)&&GQ()}function o0(Q,A,I){const g=new Uint8Array(A*4);for(let B=0;B<I/2;B++){const C=B*A*4,E=(I-1-B)*A*4;g.set(Q.subarray(C,C+A*4)),Q.set(Q.subarray(E,E+A*4),C),Q.set(g,E)}return Q}function w0(Q,A,I){const g=document.createElement("canvas");g.width=A,g.height=I;const B=g.getContext("2d");if(!B)throw new Error("Can't get 2d context");const C=B.createImageData(A,I);return C.data.set(Q),B.putImageData(C,0,0),g.toDataURL("image/png")}function YB(Q){const A=new RB(Q.autoStart);return A.startTime=Q.startTime,A.oldTime=Q.oldTime,A.elapsedTime=Q.elapsedTime,A.running=Q.running,A}function s0(Q){return Object.fromEntries(Object.entries(Q).filter(([A,I])=>I!==void 0))}const BE=sA(`
8173
8173
  precision highp float;
@@ -8177,7 +8177,7 @@ import{k as QQ,r as cB,a8 as JC,an as kB,a as OA,V as F,ao as RB,t as BQ,e as CQ
8177
8177
  void main() {
8178
8178
  gl_Position = vec4(position.xy, 0.0, 1.0);
8179
8179
  }
8180
- `);function CE(Q){const A=new F;for(const I of Q)A.add(I);return A.divideScalar(Q.length)}function EE(Q){if(Q.length===0)return new Z;const A=Q[0].clone();for(let I=1;I<Q.length;I++)Q[I].dot(Q[0])<0?(A.x-=Q[I].x,A.y-=Q[I].y,A.z-=Q[I].z,A.w-=Q[I].w):(A.x+=Q[I].x,A.y+=Q[I].y,A.z+=Q[I].z,A.w+=Q[I].w);return A.normalize()}function iE(Q,A){const I=new F(0,0,0).applyMatrix4(Q),g=new F(0,0,0).applyMatrix4(A),B=new F(0,0,-1).applyMatrix4(Q).sub(I).normalize(),C=new F(0,0,-1).applyMatrix4(A).sub(g).normalize(),E=I.distanceTo(g),i=B.dot(C);return{distance:E,coincidence:i}}function G0({matrix1:Q,matrix2:A,maxDistance:I}){const g=new F(0,0,0).applyMatrix4(Q),B=new F(0,0,0).applyMatrix4(A);return g.distanceTo(B)<=I}function a0({matrix1:Q,matrix2:A,maxDistance:I,minCoincidence:g}){const{distance:B,coincidence:C}=iE(Q,A);return B<=I&&(g==null||C>=g)}function DE(Q,A){const[I,g]=[new F,new Z],[B,C]=[new F,new Z];Q.decompose(I,g,new F),A.decompose(B,C,new F);const E=I.distanceTo(B),i=Math.abs(g.dot(C));return{distance:E,coorient:i}}function aQ({matrix1:Q,matrix2:A,maxDistance:I,minCoorient:g}){const{distance:B,coorient:C}=DE(Q,A);return B<=I&&(g==null||C>=g)}function h0(Q,A=.001){return Math.abs(Q)<A?0:Math.sign(Q)}function y0(Q){const A=Q.w<0,I=zg(A?-Q.x:Q.x),g=zg(A?-Q.y:Q.y),B=zg(A?-Q.z:Q.z),C=I&255,E=g&255,i=B&255;return C|E<<8|i<<16}function c0(Q,A){const I=Q<<24>>24,g=Q<<16>>24,B=Q<<8>>24;A.set(I/127,g/127,B/127,0);const C=A.x*A.x+A.y*A.y+A.z*A.z;return A.w=Math.sqrt(Math.max(0,1-C)),A}const k0=new Z,QB=new F;function rB(Q){const A=k0.copy(Q).normalize();A.w<0&&A.set(-A.x,-A.y,-A.z,-A.w);const I=2*Math.acos(A.w),g=Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z),B=g<1e-6?QB.set(1,0,0):QB.set(A.x,A.y,A.z).divideScalar(g),C=Math.abs(B.x)+Math.abs(B.y)+Math.abs(B.z);let E=B.x/C,i=B.y/C;if(B.z<0){const a=E;E=(1-Math.abs(i))*(E>=0?1:-1),i=(1-Math.abs(a))*(i>=0?1:-1)}const o=E*.5+.5,D=i*.5+.5,s=Math.round(o*255),w=Math.round(D*255);return Math.round(I*(255/Math.PI))<<16|w<<8|s}function oE(Q,A){const I=Q&255,g=Q>>>8&255,B=Q>>>16&255,C=I/255,E=g/255;let i=(C-.5)*2,o=(E-.5)*2;const D=1-(Math.abs(i)+Math.abs(o)),s=Math.max(-D,0);i+=i>=0?-s:s,o+=o>=0?-s:s;const w=QB.set(i,o,D).normalize(),a=B/255*Math.PI*.5,y=Math.sin(a),h=Math.cos(a);return A.set(w.x*y,w.y*y,w.z*y,h),A}function R0(Q){const A=Q.clone().normalize(),I=2*(A.w*A.x+A.y*A.z),g=1-2*(A.x*A.x+A.y*A.y),B=Math.atan2(I,g),C=2*(A.w*A.y-A.z*A.x),E=Math.abs(C)>=1?Math.sign(C)*(Math.PI/2):Math.asin(C),i=2*(A.w*A.z+A.x*A.y),o=1-2*(A.y*A.y+A.z*A.z),D=Math.atan2(i,o),s=(B+Math.PI)/(2*Math.PI),w=(E+Math.PI)/(2*Math.PI),G=(D+Math.PI)/(2*Math.PI),a=Math.round(s*255),y=Math.round(w*255);return Math.round(G*255)<<16|y<<8|a}function F0(Q,A){const I=Q&255,g=Q>>>8&255,B=Q>>>16&255,C=I/255,E=g/255,i=B/255,o=C*(2*Math.PI)-Math.PI,D=E*(2*Math.PI)-Math.PI,s=i*(2*Math.PI)-Math.PI,w=Math.cos(o*.5),G=Math.sin(o*.5),a=Math.cos(D*.5),y=Math.sin(D*.5),h=Math.cos(s*.5),c=Math.sin(s*.5);return A.w=w*a*h+G*y*c,A.x=G*a*h-w*y*c,A.y=w*y*h+G*a*c,A.z=w*a*c-G*y*h,A.normalize(),A}function wE(Q,A,I,g){const B=Math.sqrt(Q*Q+A*A+I*I+g*g),C=(g<0?-Q:Q)/B,E=(g<0?-A:A)/B,i=(g<0?-I:I)/B,o=(g<0?-g:g)/B,D=2*Math.acos(o),s=Math.sqrt(C*C+E*E+i*i),w=s<1e-6?1:C/s,G=s<1e-6?0:E/s,a=s<1e-6?0:i/s,y=Math.abs(w)+Math.abs(G)+Math.abs(a);let h=w/y,c=G/y;if(a<0){const J=h;h=(1-Math.abs(c))*(h>=0?1:-1),c=(1-Math.abs(J))*(c>=0?1:-1)}const k=h*.5+.5,R=c*.5+.5,t=Math.round(k*1023),N=Math.round(R*1023);return Math.round(D*(4095/Math.PI))<<20|N<<10|t}function sE(Q,A){const I=Q&1023,g=Q>>>10&1023,B=Q>>>20&4095,C=I/1023,E=g/1023;let i=(C-.5)*2,o=(E-.5)*2;const D=1-(Math.abs(i)+Math.abs(o)),s=Math.max(-D,0);i+=i>=0?-s:s,o+=o>=0?-s:s;const w=Math.sqrt(i*i+o*o+D*D),G=w<1e-6?0:i/w,a=w<1e-6?0:o/w,y=w<1e-6?0:D/w,c=B/4095*Math.PI*.5,k=Math.sin(c),R=Math.cos(c);return A.set(G*k,a*k,y*k,R),A}function mg(Q,A,I,g){const B=Math.round(Math.max(-127,Math.min(127,Q*127))),C=Math.round(Math.max(-127,Math.min(127,A*127))),E=Math.round(Math.max(-127,Math.min(127,I*127))),i=Math.round(Math.max(-127,Math.min(127,g*127)));return B&255|(C&255)<<8|(E&255)<<16|(i&255)<<24}function S0(Q,A,I,g){const C=63/(g?.sh1Max??1),E=A*2;for(let i=0;i<9;++i){const o=I[i]*C,D=Math.round(Math.max(-63,Math.min(63,o)))&127,s=i*7,w=s+7,G=Math.floor(s/32),a=s-G*32,y=D<<a&4294967295;if(Q[E+G]|=y,w>G*32+32){const h=D>>>32-a&4294967295;Q[E+G+1]|=h}}}function t0(Q,A,I,g){const C=1/(g?.sh2Max??1);Q[A*4+0]=mg(I[0]*C,I[1]*C,I[2]*C,I[3]*C),Q[A*4+1]=mg(I[4]*C,I[5]*C,I[6]*C,I[7]*C),Q[A*4+2]=mg(I[8]*C,I[9]*C,I[10]*C,I[11]*C),Q[A*4+3]=mg(I[12]*C,I[13]*C,I[14]*C,0)}function N0(Q,A,I,g){const C=31/(g?.sh3Max??1),E=A*4;for(let i=0;i<21;++i){const o=I[i]*C,D=Math.round(Math.max(-31,Math.min(31,o)))&63,s=i*6,w=s+6,G=Math.floor(s/32),a=s-G*32,y=D<<a&4294967295;if(Q[E+G]|=y,w>G*32+32){const h=D>>>32-a&4294967295;Q[E+G+1]|=h}}}function ZI(Q,A,I){const g=Math.abs(Q),B=Math.abs(A),C=Math.abs(I),E=Math.max(g,B,C),i=Math.floor(Math.log2(E)),o=Math.max(0,Math.min(31,i+15)),D=2**(o-15)/255,s=Math.round(Math.max(0,Math.min(255,g/D))),w=Math.round(Math.max(0,Math.min(255,B/D))),G=Math.round(Math.max(0,Math.min(255,C/D))),a=o<<3|((Q<0?1:0)|(A<0?2:0)|(I<0?4:0));return s|w<<8|G<<16|a<<24}function M0(Q){const A=eB.color,g=2**((Q>>>27&31)-15)/255,B=(Q&255)*g,C=(Q>>>8&255)*g,E=(Q>>>16&255)*g;return A.r=Q&16777216?-B:B,A.g=Q&33554432?-C:C,A.b=Q&67108864?-E:E,A}function J0(Q,A,I){const g=A*4;for(let B=0;B<3;++B){const C=B*3;Q[g+B]=ZI(I[C],I[C+1],I[C+2])}}function U0(Q,A,I,g,B){const C=I*4;for(let E=0;E<3;++E){const i=E*3;Q[C+E]=ZI(g[i],g[i+1],g[i+2])}Q[C+3]=ZI(B[0],B[1],B[2]);for(let E=1;E<5;++E){const i=E*5;A[C+(E-1)]=ZI(B[i],B[i+1],B[i+2])}}function n0(Q,A,I,g){const B=I*4;for(let C=0;C<4;++C){const E=C*3;Q[B+C]=ZI(g[E],g[E+1],g[E+2])}for(let C=4;C<7;++C){const E=C*3;A[B+(C-4)]=ZI(g[E],g[E+1],g[E+2])}}function GE(Q,A){const I=[];let g=0,B=null;const C=new ts((o,D)=>{if(I.push(o),g+=o.length,D||g>=A){const s=new Uint8Array(g);let w=0;for(const G of I)s.set(G,w),w+=G.length;B=s.slice(0,A)}}),E=1024;let i=0;for(;B==null&&i<Q.length;){const o=Q.slice(i,i+E);C.push(o,!1),i+=E}if(B==null&&(C.push(new Uint8Array,!0),B==null))throw new Error("Failed to decompress partial gzip");return B}class aE{constructor({fileBytes:A,chunkBytes:I=64*1024}){this.fileBytes=A,this.chunkBytes=I,this.chunks=[],this.totalBytes=0;const g=new DecompressionStream("gzip"),B=new Blob([A]).stream().pipeThrough(g);this.reader=B.getReader()}async read(A){for(;this.totalBytes<A;){const{value:C,done:E}=await this.reader.read();if(E)break;this.chunks.push(C),this.totalBytes+=C.length}if(this.totalBytes<A)throw new Error(`Unexpected EOF: needed ${A}, got ${this.totalBytes}`);const I=new Uint8Array(this.totalBytes);let g=0;for(const C of this.chunks)I.set(C,g),g+=C.length;const B=I.subarray(0,A);return this.chunks=[I.subarray(A)],this.totalBytes-=A,B}}const Pk=Object.freeze(Object.defineProperty({__proto__:null,DataCache:Ws,FreeList:IE,GunzipReader:aE,IDENT_VERTEX_SHADER:BE,Sint8ToFloat:Xs,Uint8ToFloat:Vs,averagePositions:CE,averageQuaternions:EE,cloneClock:YB,coinciDist:iE,computeMaxSplats:i0,coorientDist:DE,decodeExtRgb:M0,decodeExtSplat:wQ,decodeQuatEulerXyz888:F0,decodeQuatOctXy1010R12:sE,decodeQuatOctXy88R8:oE,decodeQuatXyz888:c0,decompressPartialGzip:GE,encodeExt3Rgb:n0,encodeExtRgb:ZI,encodeExtSh12Rgb:U0,encodeExtSh1Rgb:J0,encodeExtSplat:IB,encodeQuatEulerXyz888:R0,encodeQuatOctXy1010R12:wE,encodeQuatOctXy88R8:rB,encodeQuatXyz888:y0,encodeSh1Rgb:S0,encodeSh2Rgb:t0,encodeSh3Rgb:N0,epsilonSign:h0,flipPixels:o0,floatBitsToUint:jg,floatToSint8:zg,floatToUint8:$A,fromHalf:MA,getTextureSize:EA,getTransferable:nB,isAndroid:HB,isIos:rg,isMobile:GQ,isOculus:LB,isQuest2:D0,isVisionPro:QE,mapFilterObject:vs,mapObject:js,newArray:AB,normalize:AE,omitUndefined:s0,pixelsToPngUrl:w0,setPackedSplat:gB,setPackedSplatCenter:zs,setPackedSplatOpacity:g0,setPackedSplatQuat:$s,setPackedSplatRgb:I0,setPackedSplatRgba:A0,setPackedSplatScales:_s,threeMrtArray:_C,threeRevision:zC,toHalf:vA,uintBitsToFloat:vg,unpackSplat:sQ,withinCoinciDist:a0,withinCoorientDist:aQ,withinDist:G0},Symbol.toStringTag,{value:"Module"}));class e0{constructor(){this.messages={},this.messageIdNext=0,this.worker=new os,this.worker.onmessage=A=>this.onMessage(A)}makeMessageId(){return++this.messageIdNext}makeMessagePromiseId(){const A=this.makeMessageId(),I=new Promise((g,B)=>{this.messages[A]={resolve:g,reject:B}});return{id:A,promise:I}}onMessage(A){const{id:I,result:g,error:B}=A.data,C=this.messages[I];C&&(delete this.messages[I],B?C.reject(B):C.resolve(g))}async call(A,I){const{id:g,promise:B}=this.makeMessagePromiseId();return this.worker.postMessage({name:A,args:I,id:g},{transfer:nB(I)}),B}}let hE=4,hQ=0;const yE=[],cE=[];async function H0(){const Q=yE.shift();if(Q)return Q;if(hQ<hE){const A=new e0;return hQ+=1,A}return new Promise(A=>{cE.push(A)})}function L0(Q){if(hQ>hE){hQ-=1;return}const A=cE.shift();if(A){A(Q);return}yE.push(Q)}async function PI(Q){const A=await H0();try{return await Q(A)}finally{L0(A)}}const kE=`(function() {
8180
+ `);function CE(Q){const A=new F;for(const I of Q)A.add(I);return A.divideScalar(Q.length)}function EE(Q){if(Q.length===0)return new Z;const A=Q[0].clone();for(let I=1;I<Q.length;I++)Q[I].dot(Q[0])<0?(A.x-=Q[I].x,A.y-=Q[I].y,A.z-=Q[I].z,A.w-=Q[I].w):(A.x+=Q[I].x,A.y+=Q[I].y,A.z+=Q[I].z,A.w+=Q[I].w);return A.normalize()}function iE(Q,A){const I=new F(0,0,0).applyMatrix4(Q),g=new F(0,0,0).applyMatrix4(A),B=new F(0,0,-1).applyMatrix4(Q).sub(I).normalize(),C=new F(0,0,-1).applyMatrix4(A).sub(g).normalize(),E=I.distanceTo(g),i=B.dot(C);return{distance:E,coincidence:i}}function G0({matrix1:Q,matrix2:A,maxDistance:I}){const g=new F(0,0,0).applyMatrix4(Q),B=new F(0,0,0).applyMatrix4(A);return g.distanceTo(B)<=I}function a0({matrix1:Q,matrix2:A,maxDistance:I,minCoincidence:g}){const{distance:B,coincidence:C}=iE(Q,A);return B<=I&&(g==null||C>=g)}function DE(Q,A){const[I,g]=[new F,new Z],[B,C]=[new F,new Z];Q.decompose(I,g,new F),A.decompose(B,C,new F);const E=I.distanceTo(B),i=Math.abs(g.dot(C));return{distance:E,coorient:i}}function aQ({matrix1:Q,matrix2:A,maxDistance:I,minCoorient:g}){const{distance:B,coorient:C}=DE(Q,A);return B<=I&&(g==null||C>=g)}function h0(Q,A=.001){return Math.abs(Q)<A?0:Math.sign(Q)}function y0(Q){const A=Q.w<0,I=zg(A?-Q.x:Q.x),g=zg(A?-Q.y:Q.y),B=zg(A?-Q.z:Q.z),C=I&255,E=g&255,i=B&255;return C|E<<8|i<<16}function c0(Q,A){const I=Q<<24>>24,g=Q<<16>>24,B=Q<<8>>24;A.set(I/127,g/127,B/127,0);const C=A.x*A.x+A.y*A.y+A.z*A.z;return A.w=Math.sqrt(Math.max(0,1-C)),A}const k0=new Z,QB=new F;function rB(Q){const A=k0.copy(Q).normalize();A.w<0&&A.set(-A.x,-A.y,-A.z,-A.w);const I=2*Math.acos(A.w),g=Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z),B=g<1e-6?QB.set(1,0,0):QB.set(A.x,A.y,A.z).divideScalar(g),C=Math.abs(B.x)+Math.abs(B.y)+Math.abs(B.z);let E=B.x/C,i=B.y/C;if(B.z<0){const a=E;E=(1-Math.abs(i))*(E>=0?1:-1),i=(1-Math.abs(a))*(i>=0?1:-1)}const o=E*.5+.5,D=i*.5+.5,s=Math.round(o*255),w=Math.round(D*255);return Math.round(I*(255/Math.PI))<<16|w<<8|s}function oE(Q,A){const I=Q&255,g=Q>>>8&255,B=Q>>>16&255,C=I/255,E=g/255;let i=(C-.5)*2,o=(E-.5)*2;const D=1-(Math.abs(i)+Math.abs(o)),s=Math.max(-D,0);i+=i>=0?-s:s,o+=o>=0?-s:s;const w=QB.set(i,o,D).normalize(),a=B/255*Math.PI*.5,y=Math.sin(a),h=Math.cos(a);return A.set(w.x*y,w.y*y,w.z*y,h),A}function R0(Q){const A=Q.clone().normalize(),I=2*(A.w*A.x+A.y*A.z),g=1-2*(A.x*A.x+A.y*A.y),B=Math.atan2(I,g),C=2*(A.w*A.y-A.z*A.x),E=Math.abs(C)>=1?Math.sign(C)*(Math.PI/2):Math.asin(C),i=2*(A.w*A.z+A.x*A.y),o=1-2*(A.y*A.y+A.z*A.z),D=Math.atan2(i,o),s=(B+Math.PI)/(2*Math.PI),w=(E+Math.PI)/(2*Math.PI),G=(D+Math.PI)/(2*Math.PI),a=Math.round(s*255),y=Math.round(w*255);return Math.round(G*255)<<16|y<<8|a}function F0(Q,A){const I=Q&255,g=Q>>>8&255,B=Q>>>16&255,C=I/255,E=g/255,i=B/255,o=C*(2*Math.PI)-Math.PI,D=E*(2*Math.PI)-Math.PI,s=i*(2*Math.PI)-Math.PI,w=Math.cos(o*.5),G=Math.sin(o*.5),a=Math.cos(D*.5),y=Math.sin(D*.5),h=Math.cos(s*.5),c=Math.sin(s*.5);return A.w=w*a*h+G*y*c,A.x=G*a*h-w*y*c,A.y=w*y*h+G*a*c,A.z=w*a*c-G*y*h,A.normalize(),A}function wE(Q,A,I,g){const B=Math.sqrt(Q*Q+A*A+I*I+g*g),C=(g<0?-Q:Q)/B,E=(g<0?-A:A)/B,i=(g<0?-I:I)/B,o=(g<0?-g:g)/B,D=2*Math.acos(o),s=Math.sqrt(C*C+E*E+i*i),w=s<1e-6?1:C/s,G=s<1e-6?0:E/s,a=s<1e-6?0:i/s,y=Math.abs(w)+Math.abs(G)+Math.abs(a);let h=w/y,c=G/y;if(a<0){const J=h;h=(1-Math.abs(c))*(h>=0?1:-1),c=(1-Math.abs(J))*(c>=0?1:-1)}const k=h*.5+.5,R=c*.5+.5,t=Math.round(k*1023),N=Math.round(R*1023);return Math.round(D*(4095/Math.PI))<<20|N<<10|t}function sE(Q,A){const I=Q&1023,g=Q>>>10&1023,B=Q>>>20&4095,C=I/1023,E=g/1023;let i=(C-.5)*2,o=(E-.5)*2;const D=1-(Math.abs(i)+Math.abs(o)),s=Math.max(-D,0);i+=i>=0?-s:s,o+=o>=0?-s:s;const w=Math.sqrt(i*i+o*o+D*D),G=w<1e-6?0:i/w,a=w<1e-6?0:o/w,y=w<1e-6?0:D/w,c=B/4095*Math.PI*.5,k=Math.sin(c),R=Math.cos(c);return A.set(G*k,a*k,y*k,R),A}function mg(Q,A,I,g){const B=Math.round(Math.max(-127,Math.min(127,Q*127))),C=Math.round(Math.max(-127,Math.min(127,A*127))),E=Math.round(Math.max(-127,Math.min(127,I*127))),i=Math.round(Math.max(-127,Math.min(127,g*127)));return B&255|(C&255)<<8|(E&255)<<16|(i&255)<<24}function S0(Q,A,I,g){const C=63/(g?.sh1Max??1),E=A*2;for(let i=0;i<9;++i){const o=I[i]*C,D=Math.round(Math.max(-63,Math.min(63,o)))&127,s=i*7,w=s+7,G=Math.floor(s/32),a=s-G*32,y=D<<a&4294967295;if(Q[E+G]|=y,w>G*32+32){const h=D>>>32-a&4294967295;Q[E+G+1]|=h}}}function t0(Q,A,I,g){const C=1/(g?.sh2Max??1);Q[A*4+0]=mg(I[0]*C,I[1]*C,I[2]*C,I[3]*C),Q[A*4+1]=mg(I[4]*C,I[5]*C,I[6]*C,I[7]*C),Q[A*4+2]=mg(I[8]*C,I[9]*C,I[10]*C,I[11]*C),Q[A*4+3]=mg(I[12]*C,I[13]*C,I[14]*C,0)}function N0(Q,A,I,g){const C=31/(g?.sh3Max??1),E=A*4;for(let i=0;i<21;++i){const o=I[i]*C,D=Math.round(Math.max(-31,Math.min(31,o)))&63,s=i*6,w=s+6,G=Math.floor(s/32),a=s-G*32,y=D<<a&4294967295;if(Q[E+G]|=y,w>G*32+32){const h=D>>>32-a&4294967295;Q[E+G+1]|=h}}}function ZI(Q,A,I){const g=Math.abs(Q),B=Math.abs(A),C=Math.abs(I),E=Math.max(g,B,C),i=Math.floor(Math.log2(E)),o=Math.max(0,Math.min(31,i+15)),D=2**(o-15)/255,s=Math.round(Math.max(0,Math.min(255,g/D))),w=Math.round(Math.max(0,Math.min(255,B/D))),G=Math.round(Math.max(0,Math.min(255,C/D))),a=o<<3|((Q<0?1:0)|(A<0?2:0)|(I<0?4:0));return s|w<<8|G<<16|a<<24}function M0(Q){const A=eB.color,g=2**((Q>>>27&31)-15)/255,B=(Q&255)*g,C=(Q>>>8&255)*g,E=(Q>>>16&255)*g;return A.r=Q&16777216?-B:B,A.g=Q&33554432?-C:C,A.b=Q&67108864?-E:E,A}function J0(Q,A,I){const g=A*4;for(let B=0;B<3;++B){const C=B*3;Q[g+B]=ZI(I[C],I[C+1],I[C+2])}}function U0(Q,A,I,g,B){const C=I*4;for(let E=0;E<3;++E){const i=E*3;Q[C+E]=ZI(g[i],g[i+1],g[i+2])}Q[C+3]=ZI(B[0],B[1],B[2]);for(let E=1;E<5;++E){const i=E*5;A[C+(E-1)]=ZI(B[i],B[i+1],B[i+2])}}function n0(Q,A,I,g){const B=I*4;for(let C=0;C<4;++C){const E=C*3;Q[B+C]=ZI(g[E],g[E+1],g[E+2])}for(let C=4;C<7;++C){const E=C*3;A[B+(C-4)]=ZI(g[E],g[E+1],g[E+2])}}function GE(Q,A){const I=[];let g=0,B=null;const C=new ts((o,D)=>{if(I.push(o),g+=o.length,D||g>=A){const s=new Uint8Array(g);let w=0;for(const G of I)s.set(G,w),w+=G.length;B=s.slice(0,A)}}),E=1024;let i=0;for(;B==null&&i<Q.length;){const o=Q.slice(i,i+E);C.push(o,!1),i+=E}if(B==null&&(C.push(new Uint8Array,!0),B==null))throw new Error("Failed to decompress partial gzip");return B}class aE{constructor({fileBytes:A,chunkBytes:I=64*1024}){this.fileBytes=A,this.chunkBytes=I,this.chunks=[],this.totalBytes=0;const g=new DecompressionStream("gzip"),B=new Blob([A]).stream().pipeThrough(g);this.reader=B.getReader()}async read(A){for(;this.totalBytes<A;){const{value:C,done:E}=await this.reader.read();if(E)break;this.chunks.push(C),this.totalBytes+=C.length}if(this.totalBytes<A)throw new Error(`Unexpected EOF: needed ${A}, got ${this.totalBytes}`);const I=new Uint8Array(this.totalBytes);let g=0;for(const C of this.chunks)I.set(C,g),g+=C.length;const B=I.subarray(0,A);return this.chunks=[I.subarray(A)],this.totalBytes-=A,B}}const dk=Object.freeze(Object.defineProperty({__proto__:null,DataCache:Ws,FreeList:IE,GunzipReader:aE,IDENT_VERTEX_SHADER:BE,Sint8ToFloat:Xs,Uint8ToFloat:Vs,averagePositions:CE,averageQuaternions:EE,cloneClock:YB,coinciDist:iE,computeMaxSplats:i0,coorientDist:DE,decodeExtRgb:M0,decodeExtSplat:wQ,decodeQuatEulerXyz888:F0,decodeQuatOctXy1010R12:sE,decodeQuatOctXy88R8:oE,decodeQuatXyz888:c0,decompressPartialGzip:GE,encodeExt3Rgb:n0,encodeExtRgb:ZI,encodeExtSh12Rgb:U0,encodeExtSh1Rgb:J0,encodeExtSplat:IB,encodeQuatEulerXyz888:R0,encodeQuatOctXy1010R12:wE,encodeQuatOctXy88R8:rB,encodeQuatXyz888:y0,encodeSh1Rgb:S0,encodeSh2Rgb:t0,encodeSh3Rgb:N0,epsilonSign:h0,flipPixels:o0,floatBitsToUint:jg,floatToSint8:zg,floatToUint8:$A,fromHalf:MA,getTextureSize:EA,getTransferable:nB,isAndroid:HB,isIos:rg,isMobile:GQ,isOculus:LB,isQuest2:D0,isVisionPro:QE,mapFilterObject:vs,mapObject:js,newArray:AB,normalize:AE,omitUndefined:s0,pixelsToPngUrl:w0,setPackedSplat:gB,setPackedSplatCenter:zs,setPackedSplatOpacity:g0,setPackedSplatQuat:$s,setPackedSplatRgb:I0,setPackedSplatRgba:A0,setPackedSplatScales:_s,threeMrtArray:_C,threeRevision:zC,toHalf:vA,uintBitsToFloat:vg,unpackSplat:sQ,withinCoinciDist:a0,withinCoorientDist:aQ,withinDist:G0},Symbol.toStringTag,{value:"Module"}));class e0{constructor(){this.messages={},this.messageIdNext=0,this.worker=new os,this.worker.onmessage=A=>this.onMessage(A)}makeMessageId(){return++this.messageIdNext}makeMessagePromiseId(){const A=this.makeMessageId(),I=new Promise((g,B)=>{this.messages[A]={resolve:g,reject:B}});return{id:A,promise:I}}onMessage(A){const{id:I,result:g,error:B}=A.data,C=this.messages[I];C&&(delete this.messages[I],B?C.reject(B):C.resolve(g))}async call(A,I){const{id:g,promise:B}=this.makeMessagePromiseId();return this.worker.postMessage({name:A,args:I,id:g},{transfer:nB(I)}),B}}let hE=4,hQ=0;const yE=[],cE=[];async function H0(){const Q=yE.shift();if(Q)return Q;if(hQ<hE){const A=new e0;return hQ+=1,A}return new Promise(A=>{cE.push(A)})}function L0(Q){if(hQ>hE){hQ-=1;return}const A=cE.shift();if(A){A(Q);return}yE.push(Q)}async function PI(Q){const A=await H0();try{return await Q(A)}finally{L0(A)}}const kE=`(function() {
8181
8181
  "use strict";
8182
8182
  class ChunkDecoder {
8183
8183
  static __wrap(ptr) {
@@ -9888,7 +9888,7 @@ import{k as QQ,r as cB,a8 as JC,an as kB,a as OA,V as F,ao as RB,t as BQ,e as CQ
9888
9888
  uint pcg_mix(uvec4 value) {
9889
9889
  return value.x + 0x9e3779b9u * value.y + 0x85ebca6bu * value.z + 0xc2b2ae35u * value.w;
9890
9890
  }
9891
- `)],statements:({inputs:B,outputs:C})=>{const E=bA(I)?`${B.value}`:fA(I)?`${g}(${B.value})`:`floatBitsToUint(${B.value})`;return[`${g} bits = ${E};`,`${C.state} = pcg_mix(bits);`]}})}dynoOut(){return new W(this,"state")}}class bo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uint"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;return g=new AI({state:g}).outputs.state,new II({state:g}).outputs}})}dynoOut(){return new W(this,"hash")}}class uo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uvec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;g=new AI({state:g}).outputs.state;const B=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const C=new II({state:g}).outputs.hash;return{hash:FI({vectorType:"uvec2",x:B,y:C})}}})}dynoOut(){return new W(this,"hash")}}class Po extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uvec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;g=new AI({state:g}).outputs.state;const B=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const C=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const E=new II({state:g}).outputs.hash;return{hash:FI({vectorType:"uvec3",x:B,y:C,z:E})}}})}dynoOut(){return new W(this,"hash")}}class mo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uvec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;g=new AI({state:g}).outputs.state;const B=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const C=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const E=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const i=new II({state:g}).outputs.hash;return{hash:FI({vectorType:"uvec4",x:B,y:C,z:E,w:i})}}})}dynoOut(){return new W(this,"hash")}}class To extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"float"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=ro(I);return{hash:RA(YD(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Oo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"vec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=Ko(I);return{hash:RA(rD(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Zo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"vec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=qo(I);return{hash:RA(VI(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Vo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"vec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=lo(I);return{hash:RA(KD(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Xo extends d{constructor({z:A,zNear:I,zFar:g}){super({inTypes:{z:"float",zNear:"float",zFar:"float"},outTypes:{depth:"float"},inputs:{z:A,zNear:I,zFar:g},statements:({inputs:B,outputs:C})=>[`float clamped = clamp(${B.z}, ${B.zNear}, ${B.zFar});`,`${C.depth} = (log2(clamped + 1.0) - log2(${B.zNear} + 1.0)) / (log2(${B.zFar} + 1.0) - log2(${B.zNear} + 1.0));`]})}dynoOut(){return new W(this,"depth")}}class Wo extends d{constructor({index:A}){super({inTypes:{index:"int"},outTypes:{color:"vec3"},inputs:{index:A},statements:({inputs:I,outputs:g})=>[`${g.color} = debugColorHue(uint(${I.index}));`]})}dynoOut(){return new W(this,"color")}}const jo=(Q,{scale:A,scales:I,rotate:g,translate:B})=>new zo({position:Q,scale:A,scales:I,rotate:g,translate:B}).outputs.position,vo=(Q,{scale:A,scales:I,rotate:g})=>new _o({dir:Q,scale:A,scales:I,rotate:g}).outputs.dir,lh=(Q,{rotate:A})=>new $o({quaternion:Q,rotate:A}).outputs.quaternion;class zo extends d{constructor({position:A,scale:I,scales:g,rotate:B,translate:C}){super({inTypes:{position:"vec3",scale:"float",scales:"vec3",rotate:"vec4",translate:"vec3"},outTypes:{position:"vec3"},inputs:{position:A,scale:I,scales:g,rotate:B,translate:C},statements:({inputs:E,outputs:i})=>{const{position:o}=i;if(!o)return[];const{scale:D,scales:s,rotate:w,translate:G}=E;return[`${o} = ${E.position??"vec3(0.0, 0.0, 0.0)"};`,D?`${o} *= ${D};`:null,s?`${o} *= ${s};`:null,w?`${o} = quatVec(${w}, ${o});`:null,G?`${o} += ${G};`:null].filter(Boolean)}})}}class _o extends d{constructor({dir:A,scale:I,scales:g,rotate:B}){super({inTypes:{dir:"vec3",scale:"float",scales:"vec3",rotate:"vec4"},outTypes:{dir:"vec3"},inputs:{dir:A,scale:I,scales:g,rotate:B},statements:({inputs:C,outputs:E})=>{const{dir:i}=E;if(!i)return[];const{scale:o,scales:D,rotate:s}=C;return[`${i} = ${C.dir??"vec3(0.0, 0.0, 0.0)"};`,o?`${i} *= ${o};`:null,D?`${i} *= ${D};`:null,s?`${i} = quatVec(${s}, ${i});`:null].filter(Boolean)}})}}class $o extends d{constructor({quaternion:A,rotate:I}){super({inTypes:{quaternion:"vec4",rotate:"vec4"},outTypes:{quaternion:"vec4"},inputs:{quaternion:A,rotate:I},statements:({inputs:g,outputs:B})=>{const{quaternion:C}=B;return C?[`${C} = ${g.quaternion??"vec4(0.0, 0.0, 0.0, 1.0)"};`,I?`${C} = quatQuat(${g.rotate}, ${C});`:null].filter(Boolean):[]}})}}const xh=()=>{throw new Error("Not implemented")},ph=()=>{throw new Error("Not implemented")},fh=()=>{throw new Error("Not implemented")},bh=()=>{throw new Error("Not implemented")},uh=()=>{throw new Error("Not implemented")},Ph=()=>{throw new Error("Not implemented")},mh=(Q,A)=>new Aw({texture:Q,lod:A}),Th=(Q,A,I)=>new Iw({texture:Q,coord:A,bias:I}),Oh=(Q,A,I)=>new gw({texture:Q,coord:A,lod:I});class Aw extends d{constructor({texture:A,lod:I}){const g=iA(A);super({inTypes:{texture:g,lod:"int"},outTypes:{size:Qw(g)},inputs:{texture:A,lod:I},statements:({inputs:B,outputs:C})=>[`${C.size} = textureSize(${B.texture}, ${B.lod??"0"});`]})}dynoOut(){return new W(this,"size")}}class Iw extends d{constructor({texture:A,coord:I,bias:g}){const B=iA(A);super({inTypes:{texture:B,coord:Zh(B),bias:"float"},outTypes:{sample:Bw(B)},inputs:{texture:A,coord:I,bias:g},statements:({inputs:C,outputs:E})=>[`${E.sample} = texture(${C.texture}, ${C.coord}${C.bias?`, ${C.bias}`:""});`]})}dynoOut(){return new W(this,"sample")}}class gw extends d{constructor({texture:A,coord:I,lod:g}){const B=iA(A);super({inTypes:{texture:B,coord:Qw(B),lod:"int"},outTypes:{texel:Bw(B)},inputs:{texture:A,coord:I,lod:g},statements:({inputs:C,outputs:E})=>[`${E.texel} = texelFetch(${C.texture}, ${C.coord}, ${C.lod??"0"});`]})}dynoOut(){return new W(this,"texel")}}function Qw(Q){switch(Q){case"sampler2D":case"usampler2D":case"isampler2D":case"samplerCube":case"usamplerCube":case"isamplerCube":case"sampler2DShadow":case"samplerCubeShadow":return"ivec2";case"sampler3D":case"usampler3D":case"isampler3D":case"sampler2DArray":case"usampler2DArray":case"isampler2DArray":case"sampler2DArrayShadow":return"ivec3";default:throw new Error(`Invalid texture type: ${Q}`)}}function Zh(Q){switch(Q){case"sampler2D":case"usampler2D":case"isampler2D":return"vec2";case"sampler3D":case"usampler3D":case"isampler3D":case"samplerCube":case"usamplerCube":case"isamplerCube":case"sampler2DArray":case"usampler2DArray":case"isampler2DArray":case"sampler2DShadow":return"vec3";case"samplerCubeShadow":case"sampler2DArrayShadow":return"vec4";default:throw new Error(`Invalid texture type: ${Q}`)}}function Bw(Q){switch(Q){case"sampler2D":case"sampler2DArray":case"sampler3D":case"samplerCube":case"sampler2DShadow":return"vec4";case"usampler2D":case"usampler2DArray":case"usampler3D":case"usamplerCube":return"uvec4";case"isampler2D":case"isampler2DArray":case"isampler3D":case"isamplerCube":return"ivec4";case"samplerCubeShadow":case"sampler2DArrayShadow":return"float";default:throw new Error(`Invalid texture type: ${Q}`)}}const Vh=Q=>new Cw({degrees:Q}),Xh=Q=>new Ew({radians:Q}),sB=Q=>new iw({radians:Q}),Wh=Q=>new Dw({radians:Q}),jh=Q=>new ow({radians:Q}),vh=Q=>new ww({sin:Q}),zh=Q=>new sw({cos:Q}),_h=Q=>new Gw({tan:Q}),$h=(Q,A)=>new aw({y:Q,x:A}),Ay=Q=>new hw({x:Q}),Iy=Q=>new yw({x:Q}),gy=Q=>new cw({x:Q}),Qy=Q=>new kw({x:Q}),By=Q=>new Rw({x:Q}),Cy=Q=>new Fw({x:Q});class Cw extends r{constructor({degrees:A}){super({a:A,outTypeFunc:I=>I,outKey:"radians"}),this.statements=({inputs:I,outputs:g})=>[`${g.radians} = radians(${I.a});`]}}class Ew extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"degrees"}),this.statements=({inputs:I,outputs:g})=>[`${g.degrees} = degrees(${I.a});`]}}class iw extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"sin"}),this.statements=({inputs:I,outputs:g})=>[`${g.sin} = sin(${I.a});`]}}class Dw extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"cos"}),this.statements=({inputs:I,outputs:g})=>[`${g.cos} = cos(${I.a});`]}}class ow extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"tan"}),this.statements=({inputs:I,outputs:g})=>[`${g.tan} = tan(${I.a});`]}}class ww extends r{constructor({sin:A}){super({a:A,outTypeFunc:I=>I,outKey:"asin"}),this.statements=({inputs:I,outputs:g})=>[`${g.asin} = asin(${I.a});`]}}class sw extends r{constructor({cos:A}){super({a:A,outTypeFunc:I=>I,outKey:"acos"}),this.statements=({inputs:I,outputs:g})=>[`${g.acos} = acos(${I.a});`]}}class Gw extends r{constructor({tan:A}){super({a:A,outTypeFunc:I=>I,outKey:"atan"}),this.statements=({inputs:I,outputs:g})=>[`${g.atan} = atan(${I.a});`]}}class aw extends oA{constructor({y:A,x:I}){super({a:A,b:I,outTypeFunc:(g,B)=>g,outKey:"atan2"}),this.statements=({inputs:g,outputs:B})=>[`${B.atan2} = atan2(${g.a}, ${g.b});`]}}class hw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"sinh"}),this.statements=({inputs:I,outputs:g})=>[`${g.sinh} = sinh(${I.a});`]}}class yw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"cosh"}),this.statements=({inputs:I,outputs:g})=>[`${g.cosh} = cosh(${I.a});`]}}class cw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"tanh"}),this.statements=({inputs:I,outputs:g})=>[`${g.tanh} = tanh(${I.a});`]}}class kw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"asinh"}),this.statements=({inputs:I,outputs:g})=>[`${g.asinh} = asinh(${I.a});`]}}class Rw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"acosh"}),this.statements=({inputs:I,outputs:g})=>[`${g.acosh} = acosh(${I.a});`]}}class Fw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"atanh"}),this.statements=({inputs:I,outputs:g})=>[`${g.atanh} = atanh(${I.a});`]}}const mk=Object.freeze(Object.defineProperty({__proto__:null,Abs:Ti,Acos:sw,Acosh:Rw,Add:li,All:JD,And:aD,Any:MD,Asin:ww,Asinh:kw,Atan:Gw,Atan2:aw,Atanh:Fw,BVec2:uD,BVec3:PD,BVec4:mD,BinaryOp:oA,Bool:xD,Ceil:Vi,Clamp:ED,Combine:Lo,CombineCovSplat:fE,CombineGsplat:dE,CompMult:Mo,CompXor:eD,Compilation:vC,Cos:Dw,Cosh:yw,CovSplat:qA,Cross:co,DebugColorHue:Wo,Degrees:Ew,Determinant:no,Distance:ho,Div:fi,Dot:yo,Dyno:d,DynoBlock:tI,DynoBool:XI,DynoBvec2:vE,DynoBvec3:Ai,DynoBvec4:Qi,DynoConst:jC,DynoFloat:WI,DynoInt:aI,DynoIsampler2D:ki,DynoIsampler2DArray:Fi,DynoIsampler3D:Ni,DynoIsamplerCube:Ui,DynoIvec2:_E,DynoIvec3:gi,DynoIvec4:Ci,DynoLiteral:Eg,DynoMat2:Ei,DynoMat2x2:ii,DynoMat2x3:Di,DynoMat2x4:oi,DynoMat3:bB,DynoMat3x2:wi,DynoMat3x3:si,DynoMat3x4:Gi,DynoMat4:ai,DynoMat4x2:hi,DynoMat4x3:yi,DynoMat4x4:ci,DynoOutput:W,DynoProgram:UQ,DynoProgramTemplate:ug,DynoRemapIndex:fo,DynoSampler2D:Ri,DynoSampler2DArray:Si,DynoSampler2DArrayShadow:Hi,DynoSampler2DShadow:ei,DynoSampler3D:Mi,DynoSamplerCube:ni,DynoSamplerCubeShadow:Li,DynoUint:jE,DynoUniform:l,DynoUsampler2D:JQ,DynoUsampler2DArray:lA,DynoUsampler3D:ti,DynoUsamplerCube:Ji,DynoUvec2:zE,DynoUvec3:Ii,DynoUvec4:Bi,DynoValue:dI,DynoVec2:$E,DynoVec3:hI,DynoVec4:$I,Equal:tD,Exp:zi,Exp2:_i,ExtendVec:Fo,FaceForward:So,Float:bD,FloatBitsToInt:Io,FloatBitsToUint:go,Floor:Zi,Fract:ji,GreaterThan:FD,GreaterThanEqual:SD,Gsplat:X,GsplatNormal:lE,GsplatToCovSplat:rE,Hash:bo,Hash2:uo,Hash3:Po,Hash4:mo,HashFloat:To,HashVec2:Oo,HashVec3:Zo,HashVec4:Vo,IMod:bi,IVec2:TD,IVec3:OD,IVec4:ZD,Int:pD,IntBitsToFloat:Qo,Inverse:eo,InverseSqrt:QD,IsInf:sD,IsNan:wD,Length:ao,LessThan:kD,LessThanEqual:RD,Log:$i,Log2:AD,Mat2:_D,Mat3:$D,Mat4:Ao,Max:CD,Min:BD,Mix:iD,Mod:ui,Modf:Pi,Mul:pi,Neg:mi,Normalize:ko,NormalizedDepth:Xo,Not:cD,NotEqual:ND,NumCovSplats:LE,NumExtSplats:eE,NumPackedSplats:ME,Or:hD,Outer:Jo,OutputCovSplat:VE,OutputExtCovSplat:WE,OutputExtendedSplat:XE,OutputPackedSplat:ZE,OutputRgba8:fB,PackHalf2x16:oo,PackSnorm2x16:Co,PackUnorm2x16:io,PagedSplatTexCoord:uE,PcgHash:II,PcgMix:ag,PcgNext:AI,Pow:vi,ProjectH:Ro,Radians:Cw,ReadCovSplat:YE,ReadExtSplat:HE,ReadPackedSplat:UE,ReadPackedSplatRange:nE,ReflectVec:to,RefractVec:No,Round:Wi,Select:UD,Shl:LD,Shr:HD,Sign:Oi,SimpleCast:HA,Sin:iw,Sinh:hw,Smoothstep:oD,SplatTexCoord:bE,Split:Ho,SplitCovSplat:pE,SplitGsplat:KE,Sqr:ID,Sqrt:gD,Step:DD,Sub:xi,Swizzle:Yo,TCovSplats:SE,TExtSplats:KB,TPackedSplats:bg,Tan:ow,Tanh:cw,TexelFetch:gw,Texture:Iw,TextureSize:Aw,TransformDir:_o,TransformGsplat:xE,TransformPosition:zo,TransformQuaternion:$o,Transpose:Uo,TrinaryOp:_I,Trunc:Xi,UVec2:VD,UVec3:XD,UVec4:WD,Uint:fD,UintBitsToFloat:Bo,UintToRgba8:so,UnaryOp:r,UnpackHalf2x16:wo,UnpackSnorm2x16:Eo,UnpackUnorm2x16:Do,Vec2:jD,Vec3:vD,Vec4:zD,Xor:yD,abs:Ba,acos:zh,acosh:By,add:xA,all:xa,and:Ja,any:la,arrayIndex:uh,arrayLength:Ph,asin:vh,asinh:Qy,atan:_h,atan2:$h,atanh:Cy,bool:ua,bvec2:Ta,bvec3:Oa,bvec4:Za,ceil:ia,clamp:Fa,combine:FI,combineCovSplat:xB,combineGsplat:GI,comment:bh,compMult:kh,compXor:pa,cos:Wh,cosh:Iy,cross:wh,debugColorHue:qh,defineCovSplat:pI,defineExtSplats:lB,defineGsplat:rA,defineGsplatNormal:qE,definePackedSplats:MQ,degrees:Xh,determinant:Sh,distance:oh,div:_g,dot:Go,dyno:SQ,dynoBlock:JA,dynoBool:m0,dynoBvec2:Z0,dynoBvec3:j0,dynoBvec4:_0,dynoConst:_,dynoDeclare:JB,dynoFloat:cI,dynoFor:fh,dynoIf:xh,dynoInt:O0,dynoIsampler2D:yG,dynoIsampler2DArray:RG,dynoIsampler3D:tG,dynoIsamplerCube:JG,dynoIvec2:X0,dynoIvec3:z0,dynoIvec4:AG,dynoLiteral:DQ,dynoMat2:gG,dynoMat2x2:QG,dynoMat2x3:BG,dynoMat2x4:CG,dynoMat3:EG,dynoMat3x2:iG,dynoMat3x3:DG,dynoMat3x4:oG,dynoMat4:wG,dynoMat4x2:sG,dynoMat4x3:GG,dynoMat4x4:aG,dynoSampler2D:cG,dynoSampler2DArray:FG,dynoSampler2DArrayShadow:eG,dynoSampler2DShadow:nG,dynoSampler3D:NG,dynoSamplerCube:UG,dynoSamplerCubeShadow:HG,dynoSwitch:ph,dynoUint:T0,dynoUsampler2D:hG,dynoUsampler2DArray:kG,dynoUsampler3D:SG,dynoUsamplerCube:MG,dynoUvec2:V0,dynoUvec3:v0,dynoUvec4:$0,dynoVec2:W0,dynoVec3:rI,dynoVec4:IG,equal:da,exp:sa,exp2:Ga,extendVec:yh,faceforward:sh,float:YD,floatBitsToInt:dD,floatBitsToUint:qD,floor:Ea,fract:$g,greaterThan:Ka,greaterThanEqual:GD,gsplatNormal:CB,gsplatToCovSplat:yQ,hash:ro,hash2:Ko,hash3:qo,hash4:lo,hashFloat:Kh,hashVec2:dh,hashVec3:xo,hashVec4:wB,imod:DB,int:Pa,intBitsToFloat:Ih,inverse:th,inversesqrt:ka,isAllFloatType:xI,isBoolType:vI,isFloatType:xg,isInf:Ma,isIntType:fA,isMat2:fI,isMat3:bI,isMat4:uI,isMatFloatType:OC,isNan:Na,isScalarType:zI,isUintType:bA,isVector2Type:sg,isVector3Type:Gg,isVector4Type:pg,isVectorType:ps,ivec2:Va,ivec3:Xa,ivec4:Wa,length:Dh,lessThan:Ya,lessThanEqual:ra,literalNegOne:Ps,literalOne:us,literalZero:Fg,log:aa,log2:ha,mat2:_a,mat3:$a,mat4:Ah,max:di,min:Ra,mix:qi,mod:Ki,modf:Qa,mul:RA,neg:PB,normalize:Kg,normalizedDepth:po,not:ea,notEqual:qa,numCovSplats:q0,numExtSplats:d0,numPackedSplats:K0,numberAsFloat:QA,numberAsInt:nA,numberAsUint:eA,or:Ua,outer:Rh,outputCovSplat:PE,outputCovSplatDepth:OE,outputExtCovSplat:iB,outputExtendedSplat:mE,outputPackedSplat:pB,outputRgba8:f0,outputSplatDepth:TE,packHalf2x16:lD,packSnorm2x16:Qh,packUnorm2x16:Ch,pagedSplatTexCoord:EB,pcgHash:rh,pcgMix:Lh,pcgNext:Yh,pow:wa,projectH:hh,radians:Vh,readCovSplat:l0,readExtSplat:NE,readPackedSplat:ig,readPackedSplatRange:tE,reflectVec:Gh,refractVec:ah,remapIndex:Hh,round:oa,sameSizeIvec:bs,sameSizeUvec:XC,sameSizeVec:fs,select:mB,shl:La,shr:Ha,sign:Ca,sin:sB,sinh:Ay,smoothstep:ta,splatTexCoord:qB,split:Dg,splitCovSplat:cQ,splitGsplat:ZA,sqr:ya,sqrt:ca,step:Sa,sub:yI,swizzle:ch,tan:jh,tanh:gy,texelFetch:Oh,texture:Th,textureSize:mh,transformDir:vo,transformGsplat:dB,transformPos:jo,transformQuat:lh,transpose:Fh,trunc:Da,typeLiteral:WC,uint:ma,uintBitsToFloat:gh,uintToRgba8:oB,uniform:P0,unindent:sA,unindentLines:$,unpackHalf2x16:ih,unpackSnorm2x16:Bh,unpackUnorm2x16:Eh,uvec2:ja,uvec3:va,uvec4:za,valType:iA,vec2:rD,vec3:VI,vec4:KD,vectorDim:VC,vectorElementType:ZC,xor:na},Symbol.toStringTag,{value:"Module"})),eQ=class _A{constructor(A={}){this.maxSplats=0,this.numSplats=0,this.extra={},this.maxSh=3,this.isInitialized=!1,this.extArrays=[new Uint32Array(0),new Uint32Array(0)],this.textures=[_A.emptyTexture,_A.emptyTexture],this.extra={},this.dyno=new Ey({extSplats:this}),this.dynoNumSh=new aI({key:"numSh",value:0,update:()=>Math.min(this.getNumSh(),this.maxSh)}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,this.extra={},this.maxSplats=A.maxSplats??0,this.lod=A.lod,this.nonLod=A.nonLod,A.url||A.fileBytes||A.stream||A.construct?this.initialized=this.asyncInitialize(A).then(()=>(this.isInitialized=!0,this)):(this.initialize(A),this.isInitialized=!0,this.initialized=Promise.resolve(this))}initialize(A){this.extra=A.extra??{},this.lodSplats=A.lodSplats,A.extArrays?(this.extArrays=A.extArrays,this.maxSplats=Math.floor(Math.min(this.extArrays[0].length/4,this.extArrays[1].length/4)),this.numSplats=A.numSplats??this.maxSplats,this.maxSplats=Math.floor(this.maxSplats/f)*f,this.numSplats=Math.min(this.maxSplats,A.numSplats??Number.POSITIVE_INFINITY),this.updateTextures()):(this.maxSplats=A.maxSplats??0,this.numSplats=0,this.extArrays=[new Uint32Array(0),new Uint32Array(0)])}async asyncInitialize(A){const{url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,construct:o,lod:D,nonLod:s,lodAbove:w}=A;this.lod=D,this.nonLod=s;const G=new Hw;if((g||I||E)&&await G.loadInternalAsync({extSplats:this,url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,onProgress:A.onProgress,lodAbove:w}),o){const a=o(this);a instanceof Promise&&await a}}dispose(){this.textures[0]!==_A.emptyTexture&&(this.textures[0].dispose(),this.textures[0].source.data=null,this.textures[0]=_A.emptyTexture),this.textures[1]!==_A.emptyTexture&&(this.textures[1].dispose(),this.textures[1].source.data=null,this.textures[1]=_A.emptyTexture),this.extArrays=[new Uint32Array(0),new Uint32Array(0)];for(const A in this.extra){const I=this.extra[A];if(I instanceof l){const g=I.value;g?.isTexture&&(g.dispose(),g.source.data=null)}}this.extra={},this.disposeLodSplats()}prepareFetchSplat(){}getNumSplats(){return this.numSplats}hasRgbDir(){return Math.min(this.getNumSh(),this.maxSh)>0}getNumSh(){return this.extra.sh1?this.extra.sh2?!this.extra.sh3a||!this.extra.sh3b?2:3:1:0}setMaxSh(A){this.maxSh=A}fetchSplat({index:A,viewOrigin:I}){let g=NE(this.dyno,A);if(this.hasRgbDir()&&I){const B=ZA(g).outputs.center,C=Kg(yI(B,I)),{sh1Texture:E,sh2Texture:i,sh3TextureA:o,sh3TextureB:D}=this.ensureShTextures();let{rgb:s}=Sw({coord:qB(A),viewDir:C,numSh:this.dynoNumSh,sh1Texture:E,sh2Texture:i,sh3TextureA:o,sh3TextureB:D});s=xA(s,ZA(g).outputs.rgb),g=GI({gsplat:g,rgb:s})}return g}ensureShTextures(){if(!this.extra.sh1)return{};let A=this.extra.sh1Texture;if(!A){let C=this.extra.sh1;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh1=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");A=new lA({value:s,key:"sh1"}),this.extra.sh1Texture=A}if(!this.extra.sh2)return{sh1Texture:A};let I=this.extra.sh2Texture;if(!I){let C=this.extra.sh2;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh2=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");I=new lA({value:s,key:"sh2"}),this.extra.sh2Texture=I}if(!this.extra.sh3a||!this.extra.sh3b)return{sh1Texture:A,sh2Texture:I};let g=this.extra.sh3TextureA;if(!g){let C=this.extra.sh3a;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh3a=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");g=new lA({value:s,key:"sh3"}),this.extra.sh3TextureA=g}let B=this.extra.sh3TextureB;if(!B){let C=this.extra.sh3b;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh3b=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");B=new lA({value:s,key:"sh3b"}),this.extra.sh3TextureB=B}return{sh1Texture:A,sh2Texture:I,sh3TextureA:g,sh3TextureB:B}}ensureSplats(A){const I=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),g=this.extArrays[0]?this.extArrays[0].length/4:0;if(!this.extArrays[0]||I>g){this.maxSplats=EA(I).maxSplats;const B=new Uint32Array(this.maxSplats*4),C=new Uint32Array(this.maxSplats*4);this.extArrays[0]&&(B.set(this.extArrays[0]),C.set(this.extArrays[1])),this.extArrays[0]=B,this.extArrays[1]=C}return this.extArrays}getSplat(A){if(A>=this.numSplats)throw new Error("Invalid index");return wQ(this.extArrays,A)}setSplat(A,I,g,B,C,E){const i=this.ensureSplats(A+1);IB(i,A,I.x,I.y,I.z,g.x,g.y,g.z,B.x,B.y,B.z,B.w,C,E.r,E.g,E.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,I,g,B,C){const E=this.ensureSplats(this.numSplats+1);IB(E,this.numSplats,A.x,A.y,A.z,I.x,I.y,I.z,g.x,g.y,g.z,g.w,B,C.r,C.g,C.b),++this.numSplats}forEachSplat(A){if(this.numSplats)for(let I=0;I<this.numSplats;++I){const g=wQ(this.extArrays,I);A(I,g.center,g.scales,g.quaternion,g.opacity,g.color)}}updateTextures(){if(this.textures[0]!==_A.emptyTexture){const{width:A,height:I,depth:g}=this.textures[0].image;this.maxSplats!==A*I*g&&(this.textures[0].dispose(),this.textures[0]=_A.emptyTexture,this.textures[1].dispose(),this.textures[1]=_A.emptyTexture)}if(this.textures[0]===_A.emptyTexture){const{width:A,height:I,depth:g}=EA(this.maxSplats);this.textures[0]=mI(this.extArrays[0],A,I,g,BA,v,"RGBA32UI"),this.textures[1]=mI(this.extArrays[1],A,I,g,BA,v,"RGBA32UI")}else this.extArrays[0].buffer!==this.textures[0].image.data.buffer&&(this.textures[0].image.data=new Uint8Array(this.extArrays[0].buffer),this.textures[1].image.data=new Uint8Array(this.extArrays[1].buffer),this.textures[0].needsUpdate=!0,this.textures[1].needsUpdate=!0)}extractSplats(A,I){const g=EA(A.length).maxSplats,B=new _A({maxSplats:g});for(let C=0;C<A.length;C++){const E=this.getSplat(A[C]);if(I){let i=(A[C]>>>16)*.61803398875;i=i-Math.floor(i);const o=Math.max(0,Math.min(1,Math.abs(i*6-3)-1)),D=Math.max(0,Math.min(1,Math.abs(i*6+1)-1)),s=Math.max(0,Math.min(1,Math.abs(i*6-1)-1));E.color.r*=o,E.color.g*=D,E.color.b*=s}B.pushSplat(E.center,E.scales,E.quaternion,E.opacity,E.color)}return B}disposeLodSplats(){this.lodSplats&&(this.lodSplats.dispose(),this.lodSplats=void 0)}async createLodSplats({rgbaArray:A,quality:I}={}){const g=typeof this.lod=="number"?Math.max(1.1,Math.min(2,this.lod)):I?1.75:1.5,B=[this.extArrays[0].slice(),this.extArrays[1].slice()],C=A?(await A.getArray()).slice():void 0,E={sh1:this.extra.sh1?this.extra.sh1.slice():void 0,sh2:this.extra.sh2?this.extra.sh2.slice():void 0,sh3:this.extra.sh3?this.extra.sh3.slice():void 0},i=await NQ.withWorker(async D=>await D.call(I?"qualityLodExtSplats":"tinyLodExtSplats",{numSplats:this.numSplats,extArrays:B,extra:E,lodBase:g,rgba:C})),o=new _A(i);this.lodSplats&&this.lodSplats.dispose(),this.lodSplats=o,this.nonLod=!0,this.lod=I?"quality":!0}};eQ.emptyArray=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();eQ.emptyTexture=mI(null,1,1,1,BA,v,"RGBA32UI");eQ.emptyUint32x4=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();let qI=eQ;class Ey extends l{constructor({extSplats:A}={}){super({key:"extSplats",type:KB,globals:()=>[lB],value:{textureArray1:qI.emptyTexture,textureArray2:qI.emptyTexture,numSplats:0},update:I=>{var g,B,C;return I.textureArray1=((g=this.extSplats)==null?void 0:g.textures[0])??qI.emptyTexture,I.textureArray2=((B=this.extSplats)==null?void 0:B.textures[1])??qI.emptyTexture,I.numSplats=((C=this.extSplats)==null?void 0:C.numSplats)??0,I}}),this.extSplats=A}}const iy=sA(`
9891
+ `)],statements:({inputs:B,outputs:C})=>{const E=bA(I)?`${B.value}`:fA(I)?`${g}(${B.value})`:`floatBitsToUint(${B.value})`;return[`${g} bits = ${E};`,`${C.state} = pcg_mix(bits);`]}})}dynoOut(){return new W(this,"state")}}class bo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uint"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;return g=new AI({state:g}).outputs.state,new II({state:g}).outputs}})}dynoOut(){return new W(this,"hash")}}class uo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uvec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;g=new AI({state:g}).outputs.state;const B=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const C=new II({state:g}).outputs.hash;return{hash:FI({vectorType:"uvec2",x:B,y:C})}}})}dynoOut(){return new W(this,"hash")}}class Po extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uvec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;g=new AI({state:g}).outputs.state;const B=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const C=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const E=new II({state:g}).outputs.hash;return{hash:FI({vectorType:"uvec3",x:B,y:C,z:E})}}})}dynoOut(){return new W(this,"hash")}}class mo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"uvec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");let g=new ag({value:I}).outputs.state;g=new AI({state:g}).outputs.state;const B=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const C=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const E=new II({state:g}).outputs.hash;g=new AI({state:g}).outputs.state;const i=new II({state:g}).outputs.hash;return{hash:FI({vectorType:"uvec4",x:B,y:C,z:E,w:i})}}})}dynoOut(){return new W(this,"hash")}}class To extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"float"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=ro(I);return{hash:RA(YD(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Oo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"vec2"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=Ko(I);return{hash:RA(rD(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Zo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"vec3"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=qo(I);return{hash:RA(VI(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Vo extends tI{constructor({value:A}){super({inTypes:{value:iA(A)},outTypes:{hash:"vec4"},inputs:{value:A},construct:({value:I})=>{if(!I)throw new Error("value is required");const g=lo(I);return{hash:RA(KD(g),_("float",1/2**32))}}})}dynoOut(){return new W(this,"hash")}}class Xo extends d{constructor({z:A,zNear:I,zFar:g}){super({inTypes:{z:"float",zNear:"float",zFar:"float"},outTypes:{depth:"float"},inputs:{z:A,zNear:I,zFar:g},statements:({inputs:B,outputs:C})=>[`float clamped = clamp(${B.z}, ${B.zNear}, ${B.zFar});`,`${C.depth} = (log2(clamped + 1.0) - log2(${B.zNear} + 1.0)) / (log2(${B.zFar} + 1.0) - log2(${B.zNear} + 1.0));`]})}dynoOut(){return new W(this,"depth")}}class Wo extends d{constructor({index:A}){super({inTypes:{index:"int"},outTypes:{color:"vec3"},inputs:{index:A},statements:({inputs:I,outputs:g})=>[`${g.color} = debugColorHue(uint(${I.index}));`]})}dynoOut(){return new W(this,"color")}}const jo=(Q,{scale:A,scales:I,rotate:g,translate:B})=>new zo({position:Q,scale:A,scales:I,rotate:g,translate:B}).outputs.position,vo=(Q,{scale:A,scales:I,rotate:g})=>new _o({dir:Q,scale:A,scales:I,rotate:g}).outputs.dir,lh=(Q,{rotate:A})=>new $o({quaternion:Q,rotate:A}).outputs.quaternion;class zo extends d{constructor({position:A,scale:I,scales:g,rotate:B,translate:C}){super({inTypes:{position:"vec3",scale:"float",scales:"vec3",rotate:"vec4",translate:"vec3"},outTypes:{position:"vec3"},inputs:{position:A,scale:I,scales:g,rotate:B,translate:C},statements:({inputs:E,outputs:i})=>{const{position:o}=i;if(!o)return[];const{scale:D,scales:s,rotate:w,translate:G}=E;return[`${o} = ${E.position??"vec3(0.0, 0.0, 0.0)"};`,D?`${o} *= ${D};`:null,s?`${o} *= ${s};`:null,w?`${o} = quatVec(${w}, ${o});`:null,G?`${o} += ${G};`:null].filter(Boolean)}})}}class _o extends d{constructor({dir:A,scale:I,scales:g,rotate:B}){super({inTypes:{dir:"vec3",scale:"float",scales:"vec3",rotate:"vec4"},outTypes:{dir:"vec3"},inputs:{dir:A,scale:I,scales:g,rotate:B},statements:({inputs:C,outputs:E})=>{const{dir:i}=E;if(!i)return[];const{scale:o,scales:D,rotate:s}=C;return[`${i} = ${C.dir??"vec3(0.0, 0.0, 0.0)"};`,o?`${i} *= ${o};`:null,D?`${i} *= ${D};`:null,s?`${i} = quatVec(${s}, ${i});`:null].filter(Boolean)}})}}class $o extends d{constructor({quaternion:A,rotate:I}){super({inTypes:{quaternion:"vec4",rotate:"vec4"},outTypes:{quaternion:"vec4"},inputs:{quaternion:A,rotate:I},statements:({inputs:g,outputs:B})=>{const{quaternion:C}=B;return C?[`${C} = ${g.quaternion??"vec4(0.0, 0.0, 0.0, 1.0)"};`,I?`${C} = quatQuat(${g.rotate}, ${C});`:null].filter(Boolean):[]}})}}const xh=()=>{throw new Error("Not implemented")},ph=()=>{throw new Error("Not implemented")},fh=()=>{throw new Error("Not implemented")},bh=()=>{throw new Error("Not implemented")},uh=()=>{throw new Error("Not implemented")},Ph=()=>{throw new Error("Not implemented")},mh=(Q,A)=>new Aw({texture:Q,lod:A}),Th=(Q,A,I)=>new Iw({texture:Q,coord:A,bias:I}),Oh=(Q,A,I)=>new gw({texture:Q,coord:A,lod:I});class Aw extends d{constructor({texture:A,lod:I}){const g=iA(A);super({inTypes:{texture:g,lod:"int"},outTypes:{size:Qw(g)},inputs:{texture:A,lod:I},statements:({inputs:B,outputs:C})=>[`${C.size} = textureSize(${B.texture}, ${B.lod??"0"});`]})}dynoOut(){return new W(this,"size")}}class Iw extends d{constructor({texture:A,coord:I,bias:g}){const B=iA(A);super({inTypes:{texture:B,coord:Zh(B),bias:"float"},outTypes:{sample:Bw(B)},inputs:{texture:A,coord:I,bias:g},statements:({inputs:C,outputs:E})=>[`${E.sample} = texture(${C.texture}, ${C.coord}${C.bias?`, ${C.bias}`:""});`]})}dynoOut(){return new W(this,"sample")}}class gw extends d{constructor({texture:A,coord:I,lod:g}){const B=iA(A);super({inTypes:{texture:B,coord:Qw(B),lod:"int"},outTypes:{texel:Bw(B)},inputs:{texture:A,coord:I,lod:g},statements:({inputs:C,outputs:E})=>[`${E.texel} = texelFetch(${C.texture}, ${C.coord}, ${C.lod??"0"});`]})}dynoOut(){return new W(this,"texel")}}function Qw(Q){switch(Q){case"sampler2D":case"usampler2D":case"isampler2D":case"samplerCube":case"usamplerCube":case"isamplerCube":case"sampler2DShadow":case"samplerCubeShadow":return"ivec2";case"sampler3D":case"usampler3D":case"isampler3D":case"sampler2DArray":case"usampler2DArray":case"isampler2DArray":case"sampler2DArrayShadow":return"ivec3";default:throw new Error(`Invalid texture type: ${Q}`)}}function Zh(Q){switch(Q){case"sampler2D":case"usampler2D":case"isampler2D":return"vec2";case"sampler3D":case"usampler3D":case"isampler3D":case"samplerCube":case"usamplerCube":case"isamplerCube":case"sampler2DArray":case"usampler2DArray":case"isampler2DArray":case"sampler2DShadow":return"vec3";case"samplerCubeShadow":case"sampler2DArrayShadow":return"vec4";default:throw new Error(`Invalid texture type: ${Q}`)}}function Bw(Q){switch(Q){case"sampler2D":case"sampler2DArray":case"sampler3D":case"samplerCube":case"sampler2DShadow":return"vec4";case"usampler2D":case"usampler2DArray":case"usampler3D":case"usamplerCube":return"uvec4";case"isampler2D":case"isampler2DArray":case"isampler3D":case"isamplerCube":return"ivec4";case"samplerCubeShadow":case"sampler2DArrayShadow":return"float";default:throw new Error(`Invalid texture type: ${Q}`)}}const Vh=Q=>new Cw({degrees:Q}),Xh=Q=>new Ew({radians:Q}),sB=Q=>new iw({radians:Q}),Wh=Q=>new Dw({radians:Q}),jh=Q=>new ow({radians:Q}),vh=Q=>new ww({sin:Q}),zh=Q=>new sw({cos:Q}),_h=Q=>new Gw({tan:Q}),$h=(Q,A)=>new aw({y:Q,x:A}),Ay=Q=>new hw({x:Q}),Iy=Q=>new yw({x:Q}),gy=Q=>new cw({x:Q}),Qy=Q=>new kw({x:Q}),By=Q=>new Rw({x:Q}),Cy=Q=>new Fw({x:Q});class Cw extends r{constructor({degrees:A}){super({a:A,outTypeFunc:I=>I,outKey:"radians"}),this.statements=({inputs:I,outputs:g})=>[`${g.radians} = radians(${I.a});`]}}class Ew extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"degrees"}),this.statements=({inputs:I,outputs:g})=>[`${g.degrees} = degrees(${I.a});`]}}class iw extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"sin"}),this.statements=({inputs:I,outputs:g})=>[`${g.sin} = sin(${I.a});`]}}class Dw extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"cos"}),this.statements=({inputs:I,outputs:g})=>[`${g.cos} = cos(${I.a});`]}}class ow extends r{constructor({radians:A}){super({a:A,outTypeFunc:I=>I,outKey:"tan"}),this.statements=({inputs:I,outputs:g})=>[`${g.tan} = tan(${I.a});`]}}class ww extends r{constructor({sin:A}){super({a:A,outTypeFunc:I=>I,outKey:"asin"}),this.statements=({inputs:I,outputs:g})=>[`${g.asin} = asin(${I.a});`]}}class sw extends r{constructor({cos:A}){super({a:A,outTypeFunc:I=>I,outKey:"acos"}),this.statements=({inputs:I,outputs:g})=>[`${g.acos} = acos(${I.a});`]}}class Gw extends r{constructor({tan:A}){super({a:A,outTypeFunc:I=>I,outKey:"atan"}),this.statements=({inputs:I,outputs:g})=>[`${g.atan} = atan(${I.a});`]}}class aw extends oA{constructor({y:A,x:I}){super({a:A,b:I,outTypeFunc:(g,B)=>g,outKey:"atan2"}),this.statements=({inputs:g,outputs:B})=>[`${B.atan2} = atan2(${g.a}, ${g.b});`]}}class hw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"sinh"}),this.statements=({inputs:I,outputs:g})=>[`${g.sinh} = sinh(${I.a});`]}}class yw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"cosh"}),this.statements=({inputs:I,outputs:g})=>[`${g.cosh} = cosh(${I.a});`]}}class cw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"tanh"}),this.statements=({inputs:I,outputs:g})=>[`${g.tanh} = tanh(${I.a});`]}}class kw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"asinh"}),this.statements=({inputs:I,outputs:g})=>[`${g.asinh} = asinh(${I.a});`]}}class Rw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"acosh"}),this.statements=({inputs:I,outputs:g})=>[`${g.acosh} = acosh(${I.a});`]}}class Fw extends r{constructor({x:A}){super({a:A,outTypeFunc:I=>I,outKey:"atanh"}),this.statements=({inputs:I,outputs:g})=>[`${g.atanh} = atanh(${I.a});`]}}const qk=Object.freeze(Object.defineProperty({__proto__:null,Abs:Ti,Acos:sw,Acosh:Rw,Add:li,All:JD,And:aD,Any:MD,Asin:ww,Asinh:kw,Atan:Gw,Atan2:aw,Atanh:Fw,BVec2:uD,BVec3:PD,BVec4:mD,BinaryOp:oA,Bool:xD,Ceil:Vi,Clamp:ED,Combine:Lo,CombineCovSplat:fE,CombineGsplat:dE,CompMult:Mo,CompXor:eD,Compilation:vC,Cos:Dw,Cosh:yw,CovSplat:qA,Cross:co,DebugColorHue:Wo,Degrees:Ew,Determinant:no,Distance:ho,Div:fi,Dot:yo,Dyno:d,DynoBlock:tI,DynoBool:XI,DynoBvec2:vE,DynoBvec3:Ai,DynoBvec4:Qi,DynoConst:jC,DynoFloat:WI,DynoInt:aI,DynoIsampler2D:ki,DynoIsampler2DArray:Fi,DynoIsampler3D:Ni,DynoIsamplerCube:Ui,DynoIvec2:_E,DynoIvec3:gi,DynoIvec4:Ci,DynoLiteral:Eg,DynoMat2:Ei,DynoMat2x2:ii,DynoMat2x3:Di,DynoMat2x4:oi,DynoMat3:bB,DynoMat3x2:wi,DynoMat3x3:si,DynoMat3x4:Gi,DynoMat4:ai,DynoMat4x2:hi,DynoMat4x3:yi,DynoMat4x4:ci,DynoOutput:W,DynoProgram:UQ,DynoProgramTemplate:ug,DynoRemapIndex:fo,DynoSampler2D:Ri,DynoSampler2DArray:Si,DynoSampler2DArrayShadow:Hi,DynoSampler2DShadow:ei,DynoSampler3D:Mi,DynoSamplerCube:ni,DynoSamplerCubeShadow:Li,DynoUint:jE,DynoUniform:l,DynoUsampler2D:JQ,DynoUsampler2DArray:lA,DynoUsampler3D:ti,DynoUsamplerCube:Ji,DynoUvec2:zE,DynoUvec3:Ii,DynoUvec4:Bi,DynoValue:dI,DynoVec2:$E,DynoVec3:hI,DynoVec4:$I,Equal:tD,Exp:zi,Exp2:_i,ExtendVec:Fo,FaceForward:So,Float:bD,FloatBitsToInt:Io,FloatBitsToUint:go,Floor:Zi,Fract:ji,GreaterThan:FD,GreaterThanEqual:SD,Gsplat:X,GsplatNormal:lE,GsplatToCovSplat:rE,Hash:bo,Hash2:uo,Hash3:Po,Hash4:mo,HashFloat:To,HashVec2:Oo,HashVec3:Zo,HashVec4:Vo,IMod:bi,IVec2:TD,IVec3:OD,IVec4:ZD,Int:pD,IntBitsToFloat:Qo,Inverse:eo,InverseSqrt:QD,IsInf:sD,IsNan:wD,Length:ao,LessThan:kD,LessThanEqual:RD,Log:$i,Log2:AD,Mat2:_D,Mat3:$D,Mat4:Ao,Max:CD,Min:BD,Mix:iD,Mod:ui,Modf:Pi,Mul:pi,Neg:mi,Normalize:ko,NormalizedDepth:Xo,Not:cD,NotEqual:ND,NumCovSplats:LE,NumExtSplats:eE,NumPackedSplats:ME,Or:hD,Outer:Jo,OutputCovSplat:VE,OutputExtCovSplat:WE,OutputExtendedSplat:XE,OutputPackedSplat:ZE,OutputRgba8:fB,PackHalf2x16:oo,PackSnorm2x16:Co,PackUnorm2x16:io,PagedSplatTexCoord:uE,PcgHash:II,PcgMix:ag,PcgNext:AI,Pow:vi,ProjectH:Ro,Radians:Cw,ReadCovSplat:YE,ReadExtSplat:HE,ReadPackedSplat:UE,ReadPackedSplatRange:nE,ReflectVec:to,RefractVec:No,Round:Wi,Select:UD,Shl:LD,Shr:HD,Sign:Oi,SimpleCast:HA,Sin:iw,Sinh:hw,Smoothstep:oD,SplatTexCoord:bE,Split:Ho,SplitCovSplat:pE,SplitGsplat:KE,Sqr:ID,Sqrt:gD,Step:DD,Sub:xi,Swizzle:Yo,TCovSplats:SE,TExtSplats:KB,TPackedSplats:bg,Tan:ow,Tanh:cw,TexelFetch:gw,Texture:Iw,TextureSize:Aw,TransformDir:_o,TransformGsplat:xE,TransformPosition:zo,TransformQuaternion:$o,Transpose:Uo,TrinaryOp:_I,Trunc:Xi,UVec2:VD,UVec3:XD,UVec4:WD,Uint:fD,UintBitsToFloat:Bo,UintToRgba8:so,UnaryOp:r,UnpackHalf2x16:wo,UnpackSnorm2x16:Eo,UnpackUnorm2x16:Do,Vec2:jD,Vec3:vD,Vec4:zD,Xor:yD,abs:Ba,acos:zh,acosh:By,add:xA,all:xa,and:Ja,any:la,arrayIndex:uh,arrayLength:Ph,asin:vh,asinh:Qy,atan:_h,atan2:$h,atanh:Cy,bool:ua,bvec2:Ta,bvec3:Oa,bvec4:Za,ceil:ia,clamp:Fa,combine:FI,combineCovSplat:xB,combineGsplat:GI,comment:bh,compMult:kh,compXor:pa,cos:Wh,cosh:Iy,cross:wh,debugColorHue:qh,defineCovSplat:pI,defineExtSplats:lB,defineGsplat:rA,defineGsplatNormal:qE,definePackedSplats:MQ,degrees:Xh,determinant:Sh,distance:oh,div:_g,dot:Go,dyno:SQ,dynoBlock:JA,dynoBool:m0,dynoBvec2:Z0,dynoBvec3:j0,dynoBvec4:_0,dynoConst:_,dynoDeclare:JB,dynoFloat:cI,dynoFor:fh,dynoIf:xh,dynoInt:O0,dynoIsampler2D:yG,dynoIsampler2DArray:RG,dynoIsampler3D:tG,dynoIsamplerCube:JG,dynoIvec2:X0,dynoIvec3:z0,dynoIvec4:AG,dynoLiteral:DQ,dynoMat2:gG,dynoMat2x2:QG,dynoMat2x3:BG,dynoMat2x4:CG,dynoMat3:EG,dynoMat3x2:iG,dynoMat3x3:DG,dynoMat3x4:oG,dynoMat4:wG,dynoMat4x2:sG,dynoMat4x3:GG,dynoMat4x4:aG,dynoSampler2D:cG,dynoSampler2DArray:FG,dynoSampler2DArrayShadow:eG,dynoSampler2DShadow:nG,dynoSampler3D:NG,dynoSamplerCube:UG,dynoSamplerCubeShadow:HG,dynoSwitch:ph,dynoUint:T0,dynoUsampler2D:hG,dynoUsampler2DArray:kG,dynoUsampler3D:SG,dynoUsamplerCube:MG,dynoUvec2:V0,dynoUvec3:v0,dynoUvec4:$0,dynoVec2:W0,dynoVec3:rI,dynoVec4:IG,equal:da,exp:sa,exp2:Ga,extendVec:yh,faceforward:sh,float:YD,floatBitsToInt:dD,floatBitsToUint:qD,floor:Ea,fract:$g,greaterThan:Ka,greaterThanEqual:GD,gsplatNormal:CB,gsplatToCovSplat:yQ,hash:ro,hash2:Ko,hash3:qo,hash4:lo,hashFloat:Kh,hashVec2:dh,hashVec3:xo,hashVec4:wB,imod:DB,int:Pa,intBitsToFloat:Ih,inverse:th,inversesqrt:ka,isAllFloatType:xI,isBoolType:vI,isFloatType:xg,isInf:Ma,isIntType:fA,isMat2:fI,isMat3:bI,isMat4:uI,isMatFloatType:OC,isNan:Na,isScalarType:zI,isUintType:bA,isVector2Type:sg,isVector3Type:Gg,isVector4Type:pg,isVectorType:ps,ivec2:Va,ivec3:Xa,ivec4:Wa,length:Dh,lessThan:Ya,lessThanEqual:ra,literalNegOne:Ps,literalOne:us,literalZero:Fg,log:aa,log2:ha,mat2:_a,mat3:$a,mat4:Ah,max:di,min:Ra,mix:qi,mod:Ki,modf:Qa,mul:RA,neg:PB,normalize:Kg,normalizedDepth:po,not:ea,notEqual:qa,numCovSplats:q0,numExtSplats:d0,numPackedSplats:K0,numberAsFloat:QA,numberAsInt:nA,numberAsUint:eA,or:Ua,outer:Rh,outputCovSplat:PE,outputCovSplatDepth:OE,outputExtCovSplat:iB,outputExtendedSplat:mE,outputPackedSplat:pB,outputRgba8:f0,outputSplatDepth:TE,packHalf2x16:lD,packSnorm2x16:Qh,packUnorm2x16:Ch,pagedSplatTexCoord:EB,pcgHash:rh,pcgMix:Lh,pcgNext:Yh,pow:wa,projectH:hh,radians:Vh,readCovSplat:l0,readExtSplat:NE,readPackedSplat:ig,readPackedSplatRange:tE,reflectVec:Gh,refractVec:ah,remapIndex:Hh,round:oa,sameSizeIvec:bs,sameSizeUvec:XC,sameSizeVec:fs,select:mB,shl:La,shr:Ha,sign:Ca,sin:sB,sinh:Ay,smoothstep:ta,splatTexCoord:qB,split:Dg,splitCovSplat:cQ,splitGsplat:ZA,sqr:ya,sqrt:ca,step:Sa,sub:yI,swizzle:ch,tan:jh,tanh:gy,texelFetch:Oh,texture:Th,textureSize:mh,transformDir:vo,transformGsplat:dB,transformPos:jo,transformQuat:lh,transpose:Fh,trunc:Da,typeLiteral:WC,uint:ma,uintBitsToFloat:gh,uintToRgba8:oB,uniform:P0,unindent:sA,unindentLines:$,unpackHalf2x16:ih,unpackSnorm2x16:Bh,unpackUnorm2x16:Eh,uvec2:ja,uvec3:va,uvec4:za,valType:iA,vec2:rD,vec3:VI,vec4:KD,vectorDim:VC,vectorElementType:ZC,xor:na},Symbol.toStringTag,{value:"Module"})),eQ=class _A{constructor(A={}){this.maxSplats=0,this.numSplats=0,this.extra={},this.maxSh=3,this.isInitialized=!1,this.extArrays=[new Uint32Array(0),new Uint32Array(0)],this.textures=[_A.emptyTexture,_A.emptyTexture],this.extra={},this.dyno=new Ey({extSplats:this}),this.dynoNumSh=new aI({key:"numSh",value:0,update:()=>Math.min(this.getNumSh(),this.maxSh)}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,this.extra={},this.maxSplats=A.maxSplats??0,this.lod=A.lod,this.nonLod=A.nonLod,A.url||A.fileBytes||A.stream||A.construct?this.initialized=this.asyncInitialize(A).then(()=>(this.isInitialized=!0,this)):(this.initialize(A),this.isInitialized=!0,this.initialized=Promise.resolve(this))}initialize(A){this.extra=A.extra??{},this.lodSplats=A.lodSplats,A.extArrays?(this.extArrays=A.extArrays,this.maxSplats=Math.floor(Math.min(this.extArrays[0].length/4,this.extArrays[1].length/4)),this.numSplats=A.numSplats??this.maxSplats,this.maxSplats=Math.floor(this.maxSplats/f)*f,this.numSplats=Math.min(this.maxSplats,A.numSplats??Number.POSITIVE_INFINITY),this.updateTextures()):(this.maxSplats=A.maxSplats??0,this.numSplats=0,this.extArrays=[new Uint32Array(0),new Uint32Array(0)])}async asyncInitialize(A){const{url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,construct:o,lod:D,nonLod:s,lodAbove:w}=A;this.lod=D,this.nonLod=s;const G=new Hw;if((g||I||E)&&await G.loadInternalAsync({extSplats:this,url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,onProgress:A.onProgress,lodAbove:w}),o){const a=o(this);a instanceof Promise&&await a}}dispose(){this.textures[0]!==_A.emptyTexture&&(this.textures[0].dispose(),this.textures[0].source.data=null,this.textures[0]=_A.emptyTexture),this.textures[1]!==_A.emptyTexture&&(this.textures[1].dispose(),this.textures[1].source.data=null,this.textures[1]=_A.emptyTexture),this.extArrays=[new Uint32Array(0),new Uint32Array(0)];for(const A in this.extra){const I=this.extra[A];if(I instanceof l){const g=I.value;g?.isTexture&&(g.dispose(),g.source.data=null)}}this.extra={},this.disposeLodSplats()}prepareFetchSplat(){}getNumSplats(){return this.numSplats}hasRgbDir(){return Math.min(this.getNumSh(),this.maxSh)>0}getNumSh(){return this.extra.sh1?this.extra.sh2?!this.extra.sh3a||!this.extra.sh3b?2:3:1:0}setMaxSh(A){this.maxSh=A}fetchSplat({index:A,viewOrigin:I}){let g=NE(this.dyno,A);if(this.hasRgbDir()&&I){const B=ZA(g).outputs.center,C=Kg(yI(B,I)),{sh1Texture:E,sh2Texture:i,sh3TextureA:o,sh3TextureB:D}=this.ensureShTextures();let{rgb:s}=Sw({coord:qB(A),viewDir:C,numSh:this.dynoNumSh,sh1Texture:E,sh2Texture:i,sh3TextureA:o,sh3TextureB:D});s=xA(s,ZA(g).outputs.rgb),g=GI({gsplat:g,rgb:s})}return g}ensureShTextures(){if(!this.extra.sh1)return{};let A=this.extra.sh1Texture;if(!A){let C=this.extra.sh1;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh1=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");A=new lA({value:s,key:"sh1"}),this.extra.sh1Texture=A}if(!this.extra.sh2)return{sh1Texture:A};let I=this.extra.sh2Texture;if(!I){let C=this.extra.sh2;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh2=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");I=new lA({value:s,key:"sh2"}),this.extra.sh2Texture=I}if(!this.extra.sh3a||!this.extra.sh3b)return{sh1Texture:A,sh2Texture:I};let g=this.extra.sh3TextureA;if(!g){let C=this.extra.sh3a;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh3a=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");g=new lA({value:s,key:"sh3"}),this.extra.sh3TextureA=g}let B=this.extra.sh3TextureB;if(!B){let C=this.extra.sh3b;const{width:E,height:i,depth:o,maxSplats:D}=EA(C.length/4);if(C.length<D*4){const w=new Uint32Array(D*4);w.set(C),this.extra.sh3b=w,C=w}const s=mI(C,E,i,o,BA,v,"RGBA32UI");B=new lA({value:s,key:"sh3b"}),this.extra.sh3TextureB=B}return{sh1Texture:A,sh2Texture:I,sh3TextureA:g,sh3TextureB:B}}ensureSplats(A){const I=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),g=this.extArrays[0]?this.extArrays[0].length/4:0;if(!this.extArrays[0]||I>g){this.maxSplats=EA(I).maxSplats;const B=new Uint32Array(this.maxSplats*4),C=new Uint32Array(this.maxSplats*4);this.extArrays[0]&&(B.set(this.extArrays[0]),C.set(this.extArrays[1])),this.extArrays[0]=B,this.extArrays[1]=C}return this.extArrays}getSplat(A){if(A>=this.numSplats)throw new Error("Invalid index");return wQ(this.extArrays,A)}setSplat(A,I,g,B,C,E){const i=this.ensureSplats(A+1);IB(i,A,I.x,I.y,I.z,g.x,g.y,g.z,B.x,B.y,B.z,B.w,C,E.r,E.g,E.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,I,g,B,C){const E=this.ensureSplats(this.numSplats+1);IB(E,this.numSplats,A.x,A.y,A.z,I.x,I.y,I.z,g.x,g.y,g.z,g.w,B,C.r,C.g,C.b),++this.numSplats}forEachSplat(A){if(this.numSplats)for(let I=0;I<this.numSplats;++I){const g=wQ(this.extArrays,I);A(I,g.center,g.scales,g.quaternion,g.opacity,g.color)}}updateTextures(){if(this.textures[0]!==_A.emptyTexture){const{width:A,height:I,depth:g}=this.textures[0].image;this.maxSplats!==A*I*g&&(this.textures[0].dispose(),this.textures[0]=_A.emptyTexture,this.textures[1].dispose(),this.textures[1]=_A.emptyTexture)}if(this.textures[0]===_A.emptyTexture){const{width:A,height:I,depth:g}=EA(this.maxSplats);this.textures[0]=mI(this.extArrays[0],A,I,g,BA,v,"RGBA32UI"),this.textures[1]=mI(this.extArrays[1],A,I,g,BA,v,"RGBA32UI")}else this.extArrays[0].buffer!==this.textures[0].image.data.buffer&&(this.textures[0].image.data=new Uint8Array(this.extArrays[0].buffer),this.textures[1].image.data=new Uint8Array(this.extArrays[1].buffer),this.textures[0].needsUpdate=!0,this.textures[1].needsUpdate=!0)}extractSplats(A,I){const g=EA(A.length).maxSplats,B=new _A({maxSplats:g});for(let C=0;C<A.length;C++){const E=this.getSplat(A[C]);if(I){let i=(A[C]>>>16)*.61803398875;i=i-Math.floor(i);const o=Math.max(0,Math.min(1,Math.abs(i*6-3)-1)),D=Math.max(0,Math.min(1,Math.abs(i*6+1)-1)),s=Math.max(0,Math.min(1,Math.abs(i*6-1)-1));E.color.r*=o,E.color.g*=D,E.color.b*=s}B.pushSplat(E.center,E.scales,E.quaternion,E.opacity,E.color)}return B}disposeLodSplats(){this.lodSplats&&(this.lodSplats.dispose(),this.lodSplats=void 0)}async createLodSplats({rgbaArray:A,quality:I}={}){const g=typeof this.lod=="number"?Math.max(1.1,Math.min(2,this.lod)):I?1.75:1.5,B=[this.extArrays[0].slice(),this.extArrays[1].slice()],C=A?(await A.getArray()).slice():void 0,E={sh1:this.extra.sh1?this.extra.sh1.slice():void 0,sh2:this.extra.sh2?this.extra.sh2.slice():void 0,sh3:this.extra.sh3?this.extra.sh3.slice():void 0},i=await NQ.withWorker(async D=>await D.call(I?"qualityLodExtSplats":"tinyLodExtSplats",{numSplats:this.numSplats,extArrays:B,extra:E,lodBase:g,rgba:C})),o=new _A(i);this.lodSplats&&this.lodSplats.dispose(),this.lodSplats=o,this.nonLod=!0,this.lod=I?"quality":!0}};eQ.emptyArray=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();eQ.emptyTexture=mI(null,1,1,1,BA,v,"RGBA32UI");eQ.emptyUint32x4=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();let qI=eQ;class Ey extends l{constructor({extSplats:A}={}){super({key:"extSplats",type:KB,globals:()=>[lB],value:{textureArray1:qI.emptyTexture,textureArray2:qI.emptyTexture,numSplats:0},update:I=>{var g,B,C;return I.textureArray1=((g=this.extSplats)==null?void 0:g.textures[0])??qI.emptyTexture,I.textureArray2=((B=this.extSplats)==null?void 0:B.textures[1])??qI.emptyTexture,I.numSplats=((C=this.extSplats)==null?void 0:C.numSplats)??0,I}}),this.extSplats=A}}const iy=sA(`
9892
9892
  vec3 evaluateExtSH1(uvec4 packedData, vec3 viewDir) {
9893
9893
  vec3 sh1_0 = decodeExtRgb(packedData.x);
9894
9894
  vec3 sh1_1 = decodeExtRgb(packedData.y);
@@ -11282,7 +11282,7 @@ void main() {
11282
11282
  sampler2DArray texture;
11283
11283
  int count;
11284
11284
  };
11285
- `);function Tk(Q,A){return new d({inTypes:{rgba:OB,index:"int"},outTypes:{rgba:"vec4"},inputs:{rgba:Q,index:A},globals:()=>[Nw],statements:({inputs:g,outputs:B})=>$(`
11285
+ `);function lk(Q,A){return new d({inTypes:{rgba:OB,index:"int"},outTypes:{rgba:"vec4"},inputs:{rgba:Q,index:A},globals:()=>[Nw],statements:({inputs:g,outputs:B})=>$(`
11286
11286
  if ((${g.index} >= 0) && (${g.index} < ${g.rgba}.count)) {
11287
11287
  ${B.rgba} = texelFetch(${g.rgba}.texture, splatTexCoord(${g.index}), 0);
11288
11288
  } else {
@@ -11576,7 +11576,7 @@ void main() {
11576
11576
  : (indexMod4 == 2) ? packedData.z
11577
11577
  : packedData.w;
11578
11578
  ${e.rgba8} = uintToVec4(data);
11579
- `)}).outputs.rgba8}));return await S.renderReadback({reader:U,count:this.numSplats*J,renderer:A,readback:M})}}}checkVersions(A){if(this.mapping.length!==A.length)return{splatsUpdated:!0,mappingUpdated:!0};const I=this.mapping.some((B,C)=>{const E=A[C];return B.node!==E.node||B.base!==E.base||B.count!==E.count||B.mappingVersion!==E.mappingVersion});return I?{splatsUpdated:!0,mappingUpdated:!0}:{splatsUpdated:this.mapping.some((B,C)=>B.version!==A[C].version),mappingUpdated:I}}};QI.viewCenterUniform=new hI({value:new F});QI.viewDirUniform=new hI({value:new F});QI.sortRadialUniform=new XI({value:!0});QI.emptyTexture=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();QI.emptyTextures=[QI.emptyTexture,QI.emptyTexture];QI.programExtTemplate=new ug(hg().computeUvec4x2Vec4Template);QI.programTemplate=new ug(hg().computeUvec4Vec4Template);QI.generatorProgram=new WeakMap;QI.fullScreenQuad=new SB(new FQ({visible:!1}));let Rg=QI;class Oy extends LC{constructor(){super(),this.setAttribute("position",new iQ(Zy,3)),this.setIndex(new iQ(Vy,1))}}const Zy=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Vy=new Uint16Array([0,1,2,0,2,3]),YQ=class hA extends QQ{constructor(A){if(!A)throw new Error("SparkRenderer options are required");if(!A.renderer)throw new Error("renderer is required in SparkRenderer options");const I=hA.makeUniforms();Object.assign(I,A.extraUniforms??{});const g=hg(),B=A.premultipliedAlpha??!0,C=new Oy,E=new cB({glslVersion:kB,vertexShader:A.vertexShader??g.splatVertex,fragmentShader:A.fragmentShader??g.splatFragment,uniforms:I,premultipliedAlpha:B,transparent:A.transparent??!0,depthTest:A.depthTest??!0,depthWrite:A.depthWrite??!1,side:JC,allowOverride:!1});super(C,E),this.renderSize=new OA,this.lastFrame=-1,this.updateTimeoutId=-1,this.orderingTexture=null,this.maxSplats=0,this.activeSplats=0,this.accumulators=[],this.sorting=!1,this.sortDirty=!1,this.lastSortTime=0,this.sortWorker=null,this.sortTimeoutId=-1,this.sortedCenter=new F().setScalar(Number.NEGATIVE_INFINITY),this.sortedDir=new F().setScalar(0),this.readback32=new Uint32Array(0),this.lastLodRaycastTime=0,this.lodWorker=null,this.lodMeshes=[],this.lodDirty=!1,this.lodIds=new Map,this.lodIdToSplats=new Map,this.lodInitQueue=[],this.lodInstances=new Map,this.lodUpdates=[],this.lastTraverseTime=0,this.pagerId=0,this.superXY=1,this.flushAfterGenerate=!1,this.flushAfterRead=!1,this.readPause=1,this.sortPause=0,this.sortDelay=0,this.pageSizeWarning=!1,this.material=E,this.uniforms=I,this.frustumCulled=!1,this.renderer=A.renderer,this.onDirty=A.onDirty,this.dirty=!0,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!0,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.minPixelRadius=A.minPixelRadius??0,this.maxPixelRadius=A.maxPixelRadius??512,this.accumExtSplats=A.accumExtSplats??!1,this.covSplats=A.covSplats??!1,this.minAlpha=A.minAlpha??.5*(1/255),this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.focalDistance=A.focalDistance??0,this.apertureAngle=A.apertureAngle??0,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.focalAdjustment=A.focalAdjustment??1,this.encodeLinear=A.encodeLinear??!1,this.sortRadial=A.sortRadial??!0,this.minSortIntervalMs=A.minSortIntervalMs??0,this.enableLod=A.enableLod??!0,this.enableDriveLod=A.enableDriveLod??this.enableLod,this.enableLodFetching=A.enableLodFetching??!0,this.lodSplatCount=A.lodSplatCount,this.lodSplatScale=A.lodSplatScale??1,this.lodRenderScale=A.lodRenderScale??1,this.lodInflate=A.lodInflate??!1,this.pagedExtSplats=A.pagedExtSplats??!1;const i=GQ()?rg()?96:128:256;this.maxPagedSplats=A.maxPagedSplats??i*65536,this.numLodFetchers=A.numLodFetchers??3,this.behindFoveate=A.behindFoveate??.2,this.coneFov0=A.coneFov0??90,this.coneFov=A.coneFov??120,this.coneFoveate=A.coneFoveate??.4,this.lodRaycast=A.lodRaycast===void 0?GQ()?1e4:25e3:A.lodRaycast,this.lodRaycastIntervalMs=A.lodRaycastIntervalMs??500,this.clock=A.clock?YB(A.clock):new RB;const o={extSplats:this.accumExtSplats,covSplats:this.covSplats};if(this.display=new Rg(o),this.current=this.display,this.accumulators.push(new Rg(o)),this.accumulators.push(new Rg(o)),A.target){const{width:D,height:s,doubleBuffer:w,superXY:G,...a}=A.target,y=Math.max(1,Math.min(4,G??1));if(D*y>8192||s*y>8192)throw new Error("Target size too large");this.superXY=y;const h=D*y,c=s*y,k={format:sI,type:nI,colorSpace:CQ,...a};this.target=new BQ(h,c,k),w&&(this.backTarget=new BQ(h,c,k)),this.encodeLinear=A.encodeLinear??!0}}static makeUniforms(){return{renderSize:{value:new OA},near:{value:.1},far:{value:1e3},renderToViewQuat:{value:new Z},renderToViewPos:{value:new F},renderToViewBasis:{value:new Hg},renderToViewOffset:{value:new F},maxStdDev:{value:1},minPixelRadius:{value:0},maxPixelRadius:{value:512},minAlpha:{value:.00196078431372549},enable2DGS:{value:!1},lodInflate:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},focalDistance:{value:0},apertureAngle:{value:0},falloff:{value:1},clipXY:{value:1.4},focalAdjustment:{value:1},encodeLinear:{value:!1},ordering:{type:"t",value:hA.emptyOrdering},enableExtSplats:{value:!1},enableCovSplats:{value:!1},extSplats:{type:"t",value:Rg.emptyTexture},extSplats2:{type:"t",value:Rg.emptyTexture},time:{value:0},deltaTime:{value:0},debugFlag:{value:!1}}}dispose(){this.target&&(this.target.dispose(),this.target=void 0),this.backTarget&&(this.backTarget.dispose(),this.backTarget=void 0),this.orderingTexture&&(this.orderingTexture.dispose(),this.orderingTexture=null);const A=new Set;A.add(this.display),A.add(this.current);for(const g of this.accumulators)A.add(g);for(const g of A)g.dispose();const I=this.lodInstances.values();this.lodInstances.clear();for(const g of I)g.texture.dispose();this.sortWorker&&(this.sortWorker.dispose(),this.sortWorker=null),this.lodWorker&&(this.lodWorker.dispose(),this.lodWorker=null),this.pager&&(this.pager.dispose(),this.pager=void 0)}setDirty(){var A;this.dirty||(this.dirty=!0,(A=this.onDirty)==null||A.call(this))}onBeforeRender(A,I,g){var B;const C=hA.sparkOverride??this,E=A.info.render.frame,i=E!==C.lastFrame;if(C.lastFrame=E,C.target)C.renderSize.set(C.target.width,C.target.height);else{const y=A.getDrawingBufferSize(C.renderSize);if(A.xr.isPresenting&&y.x===1&&y.y===1){const h=(B=A.xr.getSession())==null?void 0:B.renderState.baseLayer;h&&(y.x=h.framebufferWidth,y.y=h.framebufferHeight)}}this.uniforms.renderSize.value.copy(C.renderSize);const o=g;this.uniforms.near.value=o.near,this.uniforms.far.value=o.far;const D=this.geometry;D.instanceCount=C.activeSplats;const s=new FA;this.display.extSplats||s.makeTranslation(C.display.viewOrigin);const a=g.matrixWorld.clone().invert().multiply(s);if(a.decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,new F),this.uniforms.renderToViewBasis.value.setFromMatrix4(a),this.uniforms.maxStdDev.value=C.maxStdDev,this.uniforms.minPixelRadius.value=C.minPixelRadius,this.uniforms.maxPixelRadius.value=C.maxPixelRadius,this.uniforms.minAlpha.value=C.minAlpha,this.uniforms.enable2DGS.value=C.enable2DGS,this.uniforms.lodInflate.value=C.lodInflate,this.uniforms.preBlurAmount.value=C.preBlurAmount,this.uniforms.blurAmount.value=C.blurAmount,this.uniforms.focalDistance.value=C.focalDistance,this.uniforms.apertureAngle.value=C.apertureAngle,this.uniforms.falloff.value=C.falloff,this.uniforms.clipXY.value=C.clipXY,this.uniforms.focalAdjustment.value=C.focalAdjustment,this.uniforms.encodeLinear.value=C.encodeLinear,this.uniforms.ordering.value=C.orderingTexture??hA.emptyOrdering,this.uniforms.enableExtSplats.value=this.display.extSplats,this.uniforms.enableCovSplats.value=this.display.covSplats,this.display.extSplats){const y=C.display.getTextures();this.uniforms.extSplats.value=y[0],this.uniforms.extSplats2.value=y[1]}else{const y=C.display.getTextures();this.uniforms.extSplats.value=y[0],this.uniforms.extSplats2.value=y[0]}if(this.uniforms.time.value=C.display.time,this.uniforms.deltaTime.value=C.display.deltaTime,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,C.autoUpdate&&i){const y=C.preUpdate&&!A.xr.isPresenting,h=A.xr.isPresenting?A.xr.getCamera():g;y?C.updateInternal({scene:I,camera:h,autoUpdate:!0}):C.updateTimeoutId===-1&&(C.updateTimeoutId=setTimeout(()=>{C.updateTimeoutId=-1,C.updateInternal({scene:I,camera:h,autoUpdate:!0})},1))}C.dirty=!1}clearSplats(){this.activeSplats=0,this.display.numSplats=0,this.setDirty()}async update({scene:A,camera:I}){await this.updateInternal({scene:A,camera:I,autoUpdate:!1})}async updateInternal({scene:A,camera:I,autoUpdate:g}){const B=this.renderer,C=this.time??this.clock.getElapsedTime(),E=I.getWorldPosition(new F),i=I.getWorldDirection(new F),o=E.distanceTo(this.sortedCenter)>.001||i.dot(this.sortedDir)<.999,D=this.accumulators.pop();if(!D)throw new Error("No next accumulator");if(D===this.current)throw new Error("Next accumulator is the same as the current accumulator");const{version:s,mappingVersion:w,visibleGenerators:G,generate:a}=D.prepareGenerate({renderer:B,scene:A,time:C,camera:I,sortRadial:this.sortRadial??!0,renderSize:this.renderSize,previous:this.current,lodInstances:this.enableLod?this.lodInstances:void 0});let y=!0;const h=o||s!==this.current.version,c=w!==this.display.mappingVersion;g&&!h&&(y=!1),c&&this.sorting&&(y=!1),y?(a(),this.flushAfterGenerate&&B.getContext().flush(),this.display.mappingVersion===D.mappingVersion?(this.accumulators.push(this.display),this.display=D):this.display!==this.current&&this.accumulators.push(this.current),this.current=D,this.sortDirty=!0,this.setDirty()):this.accumulators.push(D),this.enableDriveLod&&this.driveLod({visibleGenerators:G,camera:I,scene:A}),await this.driveSort()}async driveSort(){if(this.sorting||!this.sortDirty)return;this.sortTimeoutId!==-1&&(clearTimeout(this.sortTimeoutId),this.sortTimeoutId=-1);const A=performance.now(),I=this.lastSortTime?this.lastSortTime+this.minSortIntervalMs:A;if(A<I){this.sortTimeoutId=setTimeout(()=>{this.sortTimeoutId=-1,this.driveSort()},I-A);return}this.sorting=!0,this.sortDirty=!1,this.lastSortTime=A,this.readPause>0&&await new Promise(w=>setTimeout(w,this.readPause));const g=this.current;this.sortedCenter.copy(g.viewOrigin),this.sortedDir.copy(g.viewDirection);const{numSplats:B,maxSplats:C}=g,E=Math.max(1,Math.ceil(C/16384)),i=E*16384;this.maxSplats=Math.max(this.maxSplats,i);const o=new Uint32Array(this.maxSplats),D=LQ.ensureBuffer(C,this.readback32);this.readback32=D,await this.readbackDepth({current:g,renderer:this.renderer,numSplats:B,readback:D}),this.sortPause>0&&await new Promise(w=>setTimeout(w,this.sortPause)),this.sortWorker||(this.sortWorker=new BB);const s=await this.sortWorker.call("sortSplats32",{numSplats:B,readback:D,ordering:o});if(this.sortDelay>0&&await new Promise(w=>setTimeout(w,this.sortDelay)),this.readback32=s.readback,this.activeSplats=s.activeSplats,this.orderingTexture&&E>this.orderingTexture.image.height&&(this.orderingTexture.dispose(),this.orderingTexture=null),this.orderingTexture){const w=this.renderer,G=w.getContext();if(!w.properties.has(this.orderingTexture))this.orderingTexture.needsUpdate=!0;else{const y=w.properties.get(this.orderingTexture).__webglTexture;if(!y)throw new Error("ordering texture not found");w.state.activeTexture(G.TEXTURE0),w.state.bindTexture(G.TEXTURE_2D,y),G.bindBuffer(G.PIXEL_UNPACK_BUFFER,null),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,!1),G.texSubImage2D(G.TEXTURE_2D,0,0,0,4096,E,G.RGBA_INTEGER,G.UNSIGNED_INT,s.ordering),w.state.bindTexture(G.TEXTURE_2D,null)}}else{const w=new lI(s.ordering,4096,E,BA,v);w.internalFormat="RGBA32UI",w.needsUpdate=!0,this.orderingTexture=w}this.current.mappingVersion===g.mappingVersion&&this.current.mappingVersion!==this.display.mappingVersion&&(this.accumulators.push(this.display),this.display=this.current),this.sorting=!1,this.setDirty(),this.driveSort()}ensureLodWorker(){return this.lodWorker||(this.lodWorker=new BB),this.lodWorker}defaultSplatTarget(){return LB()?5e5:QE()?75e4:HB()?1e6:rg()?15e5:25e5}driveLod({visibleGenerators:A,camera:I,scene:g}){var B,C;const E=this.defaultSplatTarget(),o=(this.lodSplatCount??E)*this.lodSplatScale;let D=0;if(I instanceof vQ)D=2*Math.tan(.5*I.fov*Math.PI/180)/this.renderSize.y;else if(I instanceof Ww){const h=(I.top-I.bottom)/I.zoom,c=(I.right-I.left)/I.zoom,k=h/Math.max(1,this.renderSize.y),R=c/Math.max(1,this.renderSize.x);D=Math.min(R,k)}D*=this.lodRenderScale;const s=new F,w=new Z;if(this.current.viewToWorld.decompose(s,w,new F),this.lodPosOverride&&s.copy(this.lodPosOverride),this.lodQuatOverride&&w.copy(this.lodQuatOverride).normalize(),this.lastLod){(this.lastLod.pixelScaleLimit!==D||this.lastLod.maxSplats!==o)&&(this.lodDirty=!0);const h=s.distanceTo(this.lastLod.pos),c=Math.max(0,1-h/1),k=w.dot(this.lastLod.quat),R=Math.max(0,1-(1-k)/.01);c*R<.999&&(this.lodDirty=!0)}const G=this.enableLod?A.filter(h=>{var c,k;return h instanceof wI&&(((c=h.packedSplats)==null?void 0:c.lodSplats)||((k=h.extSplats)==null?void 0:k.lodSplats)||h.paged)&&h.enableLod!==!1}):[],a=G.some(h=>h.paged);this.lodMeshes.length!==G.length?this.lodDirty=!0:G.some((h,c)=>h!==this.lodMeshes[c].mesh||h.version>this.lodMeshes[c].version)&&(this.lodDirty=!0),this.lodMeshes=G.map(h=>({mesh:h,version:h.version+1})),this.lodInitQueue=[];const y=performance.now();for(const h of G){const c=((B=h.packedSplats)==null?void 0:B.lodSplats)??((C=h.extSplats)==null?void 0:C.lodSplats)??h.paged;if(c){const k=this.lodIds.get(c);k?k.lastTouched=y:this.lodInitQueue.push(c)}}this.ensureLodWorker().tryExclusive(async h=>{if(a&&!this.pager){this.pager=new Qg({renderer:this.renderer,extSplats:this.pagedExtSplats,maxSplats:this.maxPagedSplats,numFetchers:this.numLodFetchers});const{lodId:c}=await h.call("newLodTree",{capacity:this.pager.maxSplats});this.pagerId=c}if(this.pager)for(const{mesh:c}of this.lodMeshes)c.paged&&!c.paged.pager&&(c.paged.pager=this.pager);if(this.lodInitQueue.length>0){const c=this.lodInitQueue;for(this.lodInitQueue=[];c.length>0;){const k=c.shift();k&&(await this.initLodTree(h,k),this.lodDirty=!0)}}if(this.pager){const c=this.pager.consumeLodTreeUpdates();for(const{splats:k,page:R,chunk:t,numSplats:N,lodTree:S}of c){const J=this.lodIds.get(k);J&&(S&&t===0&&(J.rootPage=R),this.lodUpdates.push({lodId:J.lodId,pageBase:R*this.pager.pageSplats,chunkBase:t*this.pager.pageSplats,count:N,lodTreeData:S}))}}if(this.lodUpdates.length>0){const c=this.lodUpdates;this.lodUpdates=[],await h.call("updateLodTrees",{ranges:c}),this.lodDirty=!0}if(this.lodDirty){const c=performance.now(),k=new F;if(this.lastLod){const R=Math.max(1,c-this.lastLod.timestamp);k.copy(s).sub(this.lastLod.pos).multiplyScalar(this.lastTraverseTime/R)}this.lastLod={pos:s,quat:w,pixelScaleLimit:D,maxSplats:o,timestamp:c},this.lodDirty=!1,await this.updateLodInstances(h,k,G,o,s,w,D),this.currentLod=this.lastLod,this.setDirty()}await this.cleanupLodTrees(h)})}async initLodTree(A,I){if(I instanceof SI||I instanceof qI){const{lodId:g}=await A.call("initLodTree",{numSplats:I.numSplats??0,lodTree:I.extra.lodTree.slice()});this.lodIds.set(I,{lodId:g,lastTouched:performance.now()}),this.lodIdToSplats.set(g,I)}else{const{lodId:g}=await A.call("newSharedLodTree",{lodId:this.pagerId});this.lodIds.set(I,{lodId:g,lastTouched:performance.now()}),this.lodIdToSplats.set(g,I)}}async updateLodInstances(A,I,g,B,C,E,i){const o=new Map,D=new FA().compose(C,E,new F().setScalar(1)),s=g.reduce((k,R)=>{var t,N;o.set(R.uuid,R);const S=R.matrixWorld.clone().invert().multiply(D),J=((t=R.packedSplats)==null?void 0:t.lodSplats)??((N=R.extSplats)==null?void 0:N.lodSplats)??R.paged;if(!J)return k;const M=this.lodIds.get(J);return!M||this.pager&&R.paged&&M.rootPage===void 0||(k[R.uuid]={instanceId:R.uuid,lodId:M.lodId,rootPage:M.rootPage,viewToObjectCols:S.elements,lodScale:R.lodScale,behindFoveate:R.behindFoveate??this.behindFoveate,coneFov0:R.coneFov0??this.coneFov0,coneFov:R.coneFov??this.coneFov,coneFoveate:R.coneFoveate??this.coneFoveate}),k},{}),w=performance.now(),G=await A.call("traverseLodTrees",{maxSplats:B,pixelScaleLimit:i,lastPixelLimit:this.lastPixelLimit,instances:s});this.lastTraverseTime=performance.now()-w;const{keyIndices:a,chunks:y,pixelLimit:h}=G;this.lastPixelLimit=h;const c=Object.values(a).reduce((k,{numSplats:R})=>k+R,0);if(this.updateLodIndices(o,a),this.pager){this.pager.processUploads();const k=g.map(R=>{if(!R.paged||!this.pager)return null;const t=R.getWorldPosition(new F);return{splats:R.paged,distance:t.distanceTo(C)}}).filter(R=>R!==null);!this.pageSizeWarning&&k.length>this.pager.maxPages&&(this.pageSizeWarning=!0,console.warn(`# paged SplatMeshes exceeds maxPages: ${k.length} > ${this.pager.maxPages}`)),k.sort((R,t)=>R.distance-t.distance),this.pager.fetchPriority=k.map(({splats:R})=>({splats:R,chunk:0}));for(const[R,t]of y){const N=this.lodIdToSplats.get(R);N instanceof IQ&&t!==0&&this.pager.fetchPriority.push({splats:N,chunk:t})}this.pager.autoDrive=this.enableLodFetching,this.enableLodFetching&&this.pager.driveFetchers()}if(this.lodRaycast&&performance.now()-this.lastLodRaycastTime>=this.lodRaycastIntervalMs){this.lastLodRaycastTime=performance.now();const k=performance.now(),R=await A.call("traverseLodTrees",{maxSplats:Math.min(this.lodRaycast,Math.round(c*.1)),pixelScaleLimit:i,instances:s});performance.now()-k;const{keyIndices:t}=R;Object.values(t).reduce((N,{numSplats:S})=>N+S,0);for(const[N,S]of Object.entries(t)){const J=o.get(N);J.raycastIndices=S}}}async cleanupLodTrees(A){const g=performance.now();let B=null;for(const[C,E]of this.lodIds.entries())(B==null||E.lastTouched<B.lastTouched)&&(B={splats:C,lastTouched:E.lastTouched,lodId:E.lodId});if(!(!B||B.lastTouched>g-3e3)){this.lodIds.delete(B.splats),this.lodIdToSplats.delete(B.lodId);for(const[C,E]of this.lodInstances.entries())E.lodId===B.lodId&&(E.texture.dispose(),this.lodInstances.delete(C));await A.call("disposeLodTree",{lodId:B.lodId})}}updateLodIndices(A,I){for(const[g,B]of Object.entries(I)){const{lodId:C,numSplats:E,indices:i}=B,o=A.get(g);if(o.paged)o.paged.update(E,i);else{let D=this.lodInstances.get(o);D&&i.length>D.indices.length&&(D.texture.dispose(),D=void 0);const s=Math.ceil(i.length/16384);if(D){D.numSplats=E;const w=this.renderer,G=w.getContext();if(w.properties.has(D.texture)){const y=w.properties.get(D.texture).__webglTexture;if(!y)throw new Error("lodIndices texture not found");w.state.activeTexture(G.TEXTURE0),w.state.bindTexture(G.TEXTURE_2D,y),G.bindBuffer(G.PIXEL_UNPACK_BUFFER,null),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,!1),G.texSubImage2D(G.TEXTURE_2D,0,0,0,4096,s,G.RGBA_INTEGER,G.UNSIGNED_INT,i),w.state.bindTexture(G.TEXTURE_2D,null)}}else{const w=s*16384;if(i.length!==w)throw new Error("Indices length != capacity");const G=new lI(i,4096,s,BA,v);G.internalFormat="RGBA32UI",G.needsUpdate=!0,D={lodId:C,numSplats:E,indices:i,texture:G},this.lodInstances.set(o,D)}}o.updateMappingVersion()}}async readbackDepth({current:A,renderer:I,numSplats:g,readback:B}){if(!I)throw new Error("No renderer");if(!A.target)throw new Error("No target");const C=Math.ceil(g/f)*f;if(B.byteLength<C*4)throw new Error(`Readback buffer too small: ${B.byteLength} < ${C*4}`);const E=new Uint8Array(B.buffer),i=this.saveRenderState(I),o=f*zA;let D=0;const s=[];for(;D<g;){const w=Math.floor(D/o),G=w*o,a=Math.min(zA,Math.ceil((g-G)/f)),y=f*a*4,h=E.subarray(G*4,G*4+y);I.setRenderTarget(A.target,w);const c=I.readRenderTargetPixelsAsync(A.target,0,0,f,a,h,void 0,A.extSplats?2:1);s.push(c),this.flushAfterRead&&I.getContext().flush(),D+=f*a}return this.resetRenderState(I,i),Promise.all(s).then(()=>B)}saveRenderState(A){return{target:A.getRenderTarget(),xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,I){A.setRenderTarget(I.target),A.xr.enabled=I.xrEnabled,A.autoClear=I.autoClear}render(A,I){try{hA.sparkOverride=this,this.renderer.render(A,I)}finally{hA.sparkOverride=void 0}}renderTarget({scene:A,camera:I}){const g=this.backTarget??this.target;if(!g)throw new Error("No target");const B=this.renderer.getRenderTarget();try{this.renderer.setRenderTarget(g),hA.sparkOverride=this,this.renderer.render(A,I)}finally{hA.sparkOverride=void 0,this.renderer.setRenderTarget(B)}return g!==this.target&&([this.target,this.backTarget]=[this.backTarget,this.target]),g}async readTarget(){if(!this.target)throw new Error("Must initialize with target");const{width:A,height:I}=this.target,g=A*I*4;(!this.superPixels||this.superPixels.length<g)&&(this.superPixels=new Uint8Array(g));const B=this.superPixels;await this.renderer.readRenderTargetPixelsAsync(this.target,0,0,A,I,B);const{superXY:C}=this;if(C===1)return B;const E=A/C,i=I/C,o=E*i*4;(!this.targetPixels||this.targetPixels.length<o)&&(this.targetPixels=new Uint8Array(o));const D=this.targetPixels,s=C*C;for(let w=0;w<i;w++){const G=w*E;for(let a=0;a<E;a++){const y=a*C;let h=0,c=0,k=0,R=0;for(let N=0;N<C;N++){const S=(w*C+N)*A;for(let J=0;J<C;J++){const M=(S+y+J)*4;h+=B[M],c+=B[M+1],k+=B[M+2],R+=B[M+3]}}const t=(G+a)*4;D[t]=h/s,D[t+1]=c/s,D[t+2]=k/s,D[t+3]=R/s}}return D}async renderReadTarget({scene:A,camera:I}){return this.renderTarget({scene:A,camera:I}),this.readTarget()}async renderCubeMap({scene:A,worldCenter:I,size:g=256,near:B=.1,far:C=1e3,hideObjects:E=[],update:i=!0,filter:o=!1}){if(!hA.cubeRender||hA.cubeRender.target.width!==g||hA.cubeRender.near!==B||hA.cubeRender.far!==C){hA.cubeRender&&hA.cubeRender.target.dispose();const G=new UC(g,{format:sI,type:nI,generateMipmaps:o,minFilter:o?nC:gC,magFilter:gC,colorSpace:o?jw:CQ}),a=new eC(B,C,G);hA.cubeRender={target:G,cubeCamera:a,near:B,far:C}}const{target:D,cubeCamera:s}=hA.cubeRender;s.position.copy(I);const w=new Map;for(const G of E)w.set(G,G.visible),G.visible=!1;if(i){const G=new zQ;G.position.copy(I),await this.update({scene:A,camera:G})}try{hA.sparkOverride=this,s.update(this.renderer,A)}finally{hA.sparkOverride=void 0}for(const[G,a]of w.entries())G.visible=a;return D.texture}async readCubeTargets(){if(!hA.cubeRender)throw new Error("No cube render");const A=hA.cubeRender.target.texture,I=[],g=[];for(let B=0;B<A.images.length;++B){const{width:C,height:E}=A.images[B],i=C*E*4,o=new Uint8Array(i);g.push(o);const D=this.renderer.readRenderTargetPixelsAsync(hA.cubeRender.target,0,0,C,E,o,B);I.push(D)}return await Promise.all(I),g}async renderEnvMap({scene:A,worldCenter:I,size:g=256,near:B=.1,far:C=1e3,hideObjects:E=[],update:i=!0}){var o;const D=await this.renderCubeMap({scene:A,worldCenter:I,size:g,near:B,far:C,hideObjects:E,update:i,filter:!0});return hA.pmrem||(hA.pmrem=new HC(this.renderer)),(o=hA.pmrem)==null?void 0:o.fromCubemap(D).texture}recurseSetEnvMap(A,I){A.traverse(g=>{if(g instanceof QQ)if(Array.isArray(g.material))for(const B of g.material)B instanceof EQ&&(B.envMap=I);else g.material instanceof EQ&&(g.material.envMap=I)})}async getLodTreeLevel(A,I,g=!1){var B,C;const E=this.lodInstances.get(A);if(!E)return null;const i=await this.ensureLodWorker().exclusive(async o=>await o.call("getLodTreeLevel",{lodId:E.lodId,level:I}));if((B=A.packedSplats)!=null&&B.lodSplats){const o=A.packedSplats.lodSplats.extractSplats(i.indices,g);return new wI({packedSplats:o})}if((C=A.extSplats)!=null&&C.lodSplats){const o=A.extSplats.lodSplats.extractSplats(i.indices,g);return new wI({extSplats:o})}throw new Error("Only LoD-enabled PackedSplats and ExtSplats are supported")}get premultipliedAlpha(){return this.material.premultipliedAlpha}set premultipliedAlpha(A){this.material.premultipliedAlpha!==A&&(this.material.premultipliedAlpha=A,this.material.needsUpdate=!0)}};YQ.emptyOrdering=(()=>{const A=new Uint32Array(16384),I=new lI(A,4096,1);return I.format=BA,I.type=v,I.internalFormat="RGBA32UI",I.needsUpdate=!0,I})();YQ.cubeRender=null;YQ.pmrem=null;let aC=YQ;class IQ{constructor(A){var I;if(this.pager=A.pager,this.rootUrl=A.rootUrl??"",this.requestHeader=A.requestHeader,this.withCredentials=A.withCredentials,this.numSh=0,this.maxSh=((I=A.pager)==null?void 0:I.maxSh)??3,this.numSplats=0,this.dynoNumSplats=new aI({value:0}),this.dynoIndices=new JQ({value:Qg.emptyIndicesTexture}),this.rgbMinMaxLnScaleMinMax=new $I({value:new gI(0,1,PA,mA)}),this.lodOpacity=new XI({value:!1}),this.dynoNumSh=new aI({value:0}),this.shMax=new hI({value:new F}),this.fileBytes=A.fileBytes,this.fileType=A.fileType,!this.fileType&&this.fileBytes&&(this.fileType=vB(this.fileBytes)),!this.fileType&&this.rootUrl&&(this.fileType=zB(this.rootUrl)),!this.fileType)throw new Error("Unable to determine file type");this.fileType===cA.RAD&&(this.radMetaPromise=this.getRadMeta())}dispose(){this.dynoIndices.value!==Qg.emptyIndicesTexture&&(this.dynoIndices.value.dispose(),this.dynoIndices.value=Qg.emptyIndicesTexture)}setMaxSh(A){this.maxSh=A}getRadMeta(){return this.radMetaPromise?this.radMetaPromise:(this.radMetaPromise=(async()=>{if(await Xy,this.fileBytes){const A=DC(this.fileBytes.slice(0,1048576));if(A)return A;throw new Error("Failed to decode RAD header")}if(!this.rootUrl)throw new Error("No url or fileBytes provided");for(const A of[65536,256*1024,1024*1024]){const I=await VQ({url:this.rootUrl,requestHeader:this.requestHeader,withCredentials:this.withCredentials,offset:0,bytes:A}),g=DC(I);if(g)return g}throw new Error("Failed to decode RAD header")})().then(A=>A),this.radMetaPromise.catch(A=>{console.error(A)}),this.radMetaPromise)}chunkUrl(A){return this.rootUrl.replace(/-lod-0\./,`-lod-${A}.`)}async fetchDecodeChunk(A){let I;if(this.fileType===cA.RAD){const{meta:g,chunksStart:B}=await this.getRadMeta();if(A<0||A>=g.chunks.length)throw new Error(`Chunk index out of range: ${A} (max: ${g.chunks.length-1})`);let{offset:C,bytes:E,filename:i}=g.chunks[A];if(i){if(this.fileBytes)throw new Error("Chunked RAD file not supported with fileBytes");const o=new URL(this.rootUrl,window.location.href).toString(),D=new URL(i,o).toString();I=await VQ({url:D,requestHeader:this.requestHeader,withCredentials:this.withCredentials})}else if(C+=B,this.fileBytes){if(C<0||C+E>this.fileBytes.length)throw new Error(`Invalid chunk offset or bytes: ${C} + ${E} > ${this.fileBytes.length}`);I=this.fileBytes.slice(C,C+E)}else if(this.rootUrl)I=await VQ({url:this.rootUrl,requestHeader:this.requestHeader,withCredentials:this.withCredentials,offset:C,bytes:E});else throw new Error("No url or fileBytes provided")}else if(!this.fileBytes)if(this.rootUrl){const g=this.chunkUrl(A),B=new Request(g,{headers:this.requestHeader?new Headers(this.requestHeader):void 0,credentials:this.withCredentials?"include":"same-origin"}),C=await fetch(B);if(!C.ok||!C.body)throw new Error(`Failed to fetch "${g}": ${C.status} ${C.statusText}`);I=new Uint8Array(await C.arrayBuffer())}else throw new Error("No url or fileBytes provided");return await NQ.withWorker(async g=>{var B,C,E,i,o;if(!this.pager)throw new Error("PagedSplats.pager not set");if(!this.pager.extSplats){const a=(await g.call("loadPackedSplats",{fileBytes:I,pathName:this.chunkUrl(A),sh1Codes:(B=this.sh1Codes)==null?void 0:B.slice(),sh2Codes:(C=this.sh2Codes)==null?void 0:C.slice(),sh3Codes:(E=this.sh3Codes)==null?void 0:E.slice()})).lodSplats;return this.splatEncoding||(this.splatEncoding=a.splatEncoding,this.numSh=a.extra.sh3?3:a.extra.sh2?2:a.extra.sh1?1:0,this.rgbMinMaxLnScaleMinMax.value.set(this.splatEncoding.rgbMin??0,this.splatEncoding.rgbMax??1,this.splatEncoding.lnScaleMin??PA,this.splatEncoding.lnScaleMax??mA),this.lodOpacity.value=this.splatEncoding.lodOpacity??!1,this.shMax.value.set(this.splatEncoding.sh1Max??1,this.splatEncoding.sh2Max??1,this.splatEncoding.sh3Max??1)),this.sh1Codes=a.extra.sh1Codes??this.sh1Codes,this.sh2Codes=a.extra.sh2Codes??this.sh2Codes,this.sh3Codes=a.extra.sh3Codes??this.sh3Codes,a}const D=this.sh3Codes,w=(await g.call("loadExtSplats",{fileBytes:I,pathName:this.chunkUrl(A),sh1Codes:(i=this.sh1Codes)==null?void 0:i.slice(),sh2Codes:(o=this.sh2Codes)==null?void 0:o.slice(),sh3Codes:D?[D[0].slice(),D[1].slice()]:void 0})).lodSplats;return this.splatEncoding||(this.splatEncoding=lg,this.numSh=w.extra.sh3a&&w.extra.sh3b?3:w.extra.sh2?2:w.extra.sh1?1:0),this.sh1Codes=w.extra.sh1Codes??this.sh1Codes,this.sh2Codes=w.extra.sh2Codes??this.sh2Codes,this.sh3Codes=w.extra.sh3Codes??this.sh3Codes,w})}update(A,I){if(!this.pager)throw new Error("PagedSplats.pager not set");const g=this.pager.renderer;this.numSplats=A,this.dynoNumSplats.value=this.numSplats;const B=Math.ceil(A/16384);let C=this.dynoIndices.value===Qg.emptyIndicesTexture?void 0:this.dynoIndices.value;if(C&&B>C.image.height&&(C.dispose(),C=void 0),!C)C=new lI(I,4096,B,BA,v),C.internalFormat="RGBA32UI",C.needsUpdate=!0,g.initTexture(C),this.dynoIndices.value=C;else{C.image.data.set(I.subarray(0,A));const i=g.getContext();g.state.activeTexture(i.TEXTURE0),g.state.bindTexture(i.TEXTURE_2D,Uw(g,C)),i.bindBuffer(i.PIXEL_UNPACK_BUFFER,null),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.texSubImage2D(i.TEXTURE_2D,0,0,0,4096,B,i.RGBA_INTEGER,i.UNSIGNED_INT,I),g.state.bindTexture(i.TEXTURE_2D,null)}}prepareFetchSplat(){}getNumSplats(){return this.numSplats}hasRgbDir(){return this.pager?Math.min(this.numSh,this.pager.maxSh)>0:!1}getNumSh(){return this.numSh}fetchSplat({index:A,viewOrigin:I}){if(!this.pager)throw new Error("PagedSplats.pager not set");const g=this.pager.readIndex.apply({index:A,numSplats:this.dynoNumSplats,indices:this.dynoIndices}).index;return this.pager.extSplats?this.hasRgbDir()&&I?(this.dynoNumSh.value=Math.min(this.numSh,this.maxSh,this.pager.maxSh),this.pager.readSplatExtDir.apply({index:g,viewOrigin:I,numSh:this.dynoNumSh}).gsplat):this.pager.readSplatExt.apply({index:g}).gsplat:this.hasRgbDir()&&I?(this.dynoNumSh.value=Math.min(this.numSh,this.maxSh,this.pager.maxSh),this.pager.readSplatDir.apply({index:g,rgbMinMaxLnScaleMinMax:this.rgbMinMaxLnScaleMinMax,lodOpacity:this.lodOpacity,viewOrigin:I,numSh:this.dynoNumSh,shMax:this.shMax}).gsplat):this.pager.readSplat.apply({index:g,rgbMinMaxLnScaleMinMax:this.rgbMinMaxLnScaleMinMax,lodOpacity:this.lodOpacity}).gsplat}forEachSplat(A){if(!this.pager||!this.numSplats)return;const I=this.pager.extSplats,g=this.dynoIndices.value.image.data,B=this.pager.packedTexture.value.image.data,C=this.pager.extTexture.value.image.data,E=[B,C];for(let i=0;i<this.numSplats;++i){const o=g[i],D=I?wQ(E,o):sQ(B,o,this.splatEncoding);A(i,D.center,D.scales,D.quaternion,D.opacity,D.color)}}}const UA=class DA{constructor(A){this.fetchPause=0,this.splatsChunkToPage=new Map,this.pageToSplatsChunk=[],this.renderer=A.renderer,this.extSplats=A.extSplats??!1,this.pageSplats=65536,this.maxSplats=A.maxSplats??16777216,this.maxPages=Math.ceil(this.maxSplats/this.pageSplats),this.maxSplats=this.maxPages*this.pageSplats,this.maxSh=A.maxSh??3,this.curSh=0,this.autoDrive=A.autoDrive??!0,this.numFetchers=A.numFetchers??3,this.splatsChunkToPage=new Map,this.pageToSplatsChunk=new Array(this.maxPages),this.pageFreelist=Array.from({length:this.maxPages},(I,g)=>g),this.pageLru=new Set,this.freeablePages=[],this.newUploads=[],this.readyUploads=[],this.lodTreeUpdates=[],this.fetchers=[],this.fetched=[],this.fetchPriority=[],this.packedTexture=new lA({value:this.newUint32ArrayTexture(new Uint32Array(this.maxPages*256*256*4),256,256,this.maxPages,BA,v,"RGBA32UI")}),this.extTexture=new lA({value:this.extSplats?this.newUint32ArrayTexture(new Uint32Array(this.maxPages*256*256*4),256,256,this.maxPages,BA,v,"RGBA32UI"):DA.emptyExtTexture}),this.sh1Texture=new lA({value:this.extSplats?DA.emptyExtSh1Texture:DA.emptySh1Texture}),this.sh2Texture=new lA({value:this.extSplats?DA.emptyExtSh2Texture:DA.emptySh2Texture}),this.sh3Texture=new lA({value:this.extSplats?DA.emptyExtSh3Texture:DA.emptySh3Texture}),this.sh3TextureB=new lA({value:DA.emptyExtSh3BTexture}),this.readIndex=JA({index:"int",numSplats:"int",indices:"usampler2D"},{index:"int"},({index:I,numSplats:g,indices:B})=>new d({inTypes:{index:"int",numSplats:"int",indices:"usampler2D"},outTypes:{index:"int"},inputs:{index:I,numSplats:g,indices:B},statements:({inputs:C,outputs:E})=>$(`
11579
+ `)}).outputs.rgba8}));return await S.renderReadback({reader:U,count:this.numSplats*J,renderer:A,readback:M})}}}checkVersions(A){if(this.mapping.length!==A.length)return{splatsUpdated:!0,mappingUpdated:!0};const I=this.mapping.some((B,C)=>{const E=A[C];return B.node!==E.node||B.base!==E.base||B.count!==E.count||B.mappingVersion!==E.mappingVersion});return I?{splatsUpdated:!0,mappingUpdated:!0}:{splatsUpdated:this.mapping.some((B,C)=>B.version!==A[C].version),mappingUpdated:I}}};QI.viewCenterUniform=new hI({value:new F});QI.viewDirUniform=new hI({value:new F});QI.sortRadialUniform=new XI({value:!0});QI.emptyTexture=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();QI.emptyTextures=[QI.emptyTexture,QI.emptyTexture];QI.programExtTemplate=new ug(hg().computeUvec4x2Vec4Template);QI.programTemplate=new ug(hg().computeUvec4Vec4Template);QI.generatorProgram=new WeakMap;QI.fullScreenQuad=new SB(new FQ({visible:!1}));let Rg=QI;class Oy extends YC{constructor(){super(),this.setAttribute("position",new iQ(Zy,3)),this.setIndex(new iQ(Vy,1))}}const Zy=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Vy=new Uint16Array([0,1,2,0,2,3]),YQ=class hA extends QQ{constructor(A){if(!A)throw new Error("SparkRenderer options are required");if(!A.renderer)throw new Error("renderer is required in SparkRenderer options");const I=hA.makeUniforms();Object.assign(I,A.extraUniforms??{});const g=hg(),B=A.premultipliedAlpha??!0,C=new Oy,E=new cB({glslVersion:kB,vertexShader:A.vertexShader??g.splatVertex,fragmentShader:A.fragmentShader??g.splatFragment,uniforms:I,premultipliedAlpha:B,transparent:A.transparent??!0,depthTest:A.depthTest??!0,depthWrite:A.depthWrite??!1,side:JC,allowOverride:!1});super(C,E),this.renderSize=new OA,this.lastFrame=-1,this.updateTimeoutId=-1,this.orderingTexture=null,this.maxSplats=0,this.activeSplats=0,this.accumulators=[],this.sorting=!1,this.sortDirty=!1,this.lastSortTime=0,this.sortWorker=null,this.sortTimeoutId=-1,this.sortedCenter=new F().setScalar(Number.NEGATIVE_INFINITY),this.sortedDir=new F().setScalar(0),this.readback32=new Uint32Array(0),this.lastLodRaycastTime=0,this.lodWorker=null,this.lodMeshes=[],this.lodDirty=!1,this.lodIds=new Map,this.lodIdToSplats=new Map,this.lodInitQueue=[],this.lodInstances=new Map,this.lodUpdates=[],this.lastTraverseTime=0,this.pagerId=0,this.superXY=1,this.flushAfterGenerate=!1,this.flushAfterRead=!1,this.readPause=1,this.sortPause=0,this.sortDelay=0,this.pageSizeWarning=!1,this.material=E,this.uniforms=I,this.frustumCulled=!1,this.renderer=A.renderer,this.onDirty=A.onDirty,this.dirty=!0,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!0,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.minPixelRadius=A.minPixelRadius??0,this.maxPixelRadius=A.maxPixelRadius??512,this.accumExtSplats=A.accumExtSplats??!1,this.covSplats=A.covSplats??!1,this.minAlpha=A.minAlpha??.5*(1/255),this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.focalDistance=A.focalDistance??0,this.apertureAngle=A.apertureAngle??0,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.focalAdjustment=A.focalAdjustment??1,this.encodeLinear=A.encodeLinear??!1,this.sortRadial=A.sortRadial??!0,this.minSortIntervalMs=A.minSortIntervalMs??0,this.enableLod=A.enableLod??!0,this.enableDriveLod=A.enableDriveLod??this.enableLod,this.enableLodFetching=A.enableLodFetching??!0,this.lodSplatCount=A.lodSplatCount,this.lodSplatScale=A.lodSplatScale??1,this.lodRenderScale=A.lodRenderScale??1,this.lodInflate=A.lodInflate??!1,this.pagedExtSplats=A.pagedExtSplats??!1;const i=GQ()?rg()?96:128:256;this.maxPagedSplats=A.maxPagedSplats??i*65536,this.numLodFetchers=A.numLodFetchers??3,this.behindFoveate=A.behindFoveate??.2,this.coneFov0=A.coneFov0??90,this.coneFov=A.coneFov??120,this.coneFoveate=A.coneFoveate??.4,this.lodRaycast=A.lodRaycast===void 0?GQ()?1e4:25e3:A.lodRaycast,this.lodRaycastIntervalMs=A.lodRaycastIntervalMs??500,this.clock=A.clock?YB(A.clock):new RB;const o={extSplats:this.accumExtSplats,covSplats:this.covSplats};if(this.display=new Rg(o),this.current=this.display,this.accumulators.push(new Rg(o)),this.accumulators.push(new Rg(o)),A.target){const{width:D,height:s,doubleBuffer:w,superXY:G,...a}=A.target,y=Math.max(1,Math.min(4,G??1));if(D*y>8192||s*y>8192)throw new Error("Target size too large");this.superXY=y;const h=D*y,c=s*y,k={format:sI,type:nI,colorSpace:CQ,...a};this.target=new BQ(h,c,k),w&&(this.backTarget=new BQ(h,c,k)),this.encodeLinear=A.encodeLinear??!0}}static makeUniforms(){return{renderSize:{value:new OA},near:{value:.1},far:{value:1e3},renderToViewQuat:{value:new Z},renderToViewPos:{value:new F},renderToViewBasis:{value:new Hg},renderToViewOffset:{value:new F},maxStdDev:{value:1},minPixelRadius:{value:0},maxPixelRadius:{value:512},minAlpha:{value:.00196078431372549},enable2DGS:{value:!1},lodInflate:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},focalDistance:{value:0},apertureAngle:{value:0},falloff:{value:1},clipXY:{value:1.4},focalAdjustment:{value:1},encodeLinear:{value:!1},ordering:{type:"t",value:hA.emptyOrdering},enableExtSplats:{value:!1},enableCovSplats:{value:!1},extSplats:{type:"t",value:Rg.emptyTexture},extSplats2:{type:"t",value:Rg.emptyTexture},time:{value:0},deltaTime:{value:0},debugFlag:{value:!1}}}dispose(){this.target&&(this.target.dispose(),this.target=void 0),this.backTarget&&(this.backTarget.dispose(),this.backTarget=void 0),this.orderingTexture&&(this.orderingTexture.dispose(),this.orderingTexture=null);const A=new Set;A.add(this.display),A.add(this.current);for(const g of this.accumulators)A.add(g);for(const g of A)g.dispose();const I=this.lodInstances.values();this.lodInstances.clear();for(const g of I)g.texture.dispose();this.sortWorker&&(this.sortWorker.dispose(),this.sortWorker=null),this.lodWorker&&(this.lodWorker.dispose(),this.lodWorker=null),this.pager&&(this.pager.dispose(),this.pager=void 0)}setDirty(){var A;this.dirty||(this.dirty=!0,(A=this.onDirty)==null||A.call(this))}onBeforeRender(A,I,g){var B;const C=hA.sparkOverride??this,E=A.info.render.frame,i=E!==C.lastFrame;if(C.lastFrame=E,C.target)C.renderSize.set(C.target.width,C.target.height);else{const y=A.getDrawingBufferSize(C.renderSize);if(A.xr.isPresenting&&y.x===1&&y.y===1){const h=(B=A.xr.getSession())==null?void 0:B.renderState.baseLayer;h&&(y.x=h.framebufferWidth,y.y=h.framebufferHeight)}}this.uniforms.renderSize.value.copy(C.renderSize);const o=g;this.uniforms.near.value=o.near,this.uniforms.far.value=o.far;const D=this.geometry;D.instanceCount=C.activeSplats;const s=new FA;this.display.extSplats||s.makeTranslation(C.display.viewOrigin);const a=g.matrixWorld.clone().invert().multiply(s);if(a.decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,new F),this.uniforms.renderToViewBasis.value.setFromMatrix4(a),this.uniforms.maxStdDev.value=C.maxStdDev,this.uniforms.minPixelRadius.value=C.minPixelRadius,this.uniforms.maxPixelRadius.value=C.maxPixelRadius,this.uniforms.minAlpha.value=C.minAlpha,this.uniforms.enable2DGS.value=C.enable2DGS,this.uniforms.lodInflate.value=C.lodInflate,this.uniforms.preBlurAmount.value=C.preBlurAmount,this.uniforms.blurAmount.value=C.blurAmount,this.uniforms.focalDistance.value=C.focalDistance,this.uniforms.apertureAngle.value=C.apertureAngle,this.uniforms.falloff.value=C.falloff,this.uniforms.clipXY.value=C.clipXY,this.uniforms.focalAdjustment.value=C.focalAdjustment,this.uniforms.encodeLinear.value=C.encodeLinear,this.uniforms.ordering.value=C.orderingTexture??hA.emptyOrdering,this.uniforms.enableExtSplats.value=this.display.extSplats,this.uniforms.enableCovSplats.value=this.display.covSplats,this.display.extSplats){const y=C.display.getTextures();this.uniforms.extSplats.value=y[0],this.uniforms.extSplats2.value=y[1]}else{const y=C.display.getTextures();this.uniforms.extSplats.value=y[0],this.uniforms.extSplats2.value=y[0]}if(this.uniforms.time.value=C.display.time,this.uniforms.deltaTime.value=C.display.deltaTime,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,C.autoUpdate&&i){const y=C.preUpdate&&!A.xr.isPresenting,h=A.xr.isPresenting?A.xr.getCamera():g;y?C.updateInternal({scene:I,camera:h,autoUpdate:!0}):C.updateTimeoutId===-1&&(C.updateTimeoutId=setTimeout(()=>{C.updateTimeoutId=-1,C.updateInternal({scene:I,camera:h,autoUpdate:!0})},1))}C.dirty=!1}clearSplats(){this.activeSplats=0,this.display.numSplats=0,this.setDirty()}async update({scene:A,camera:I}){await this.updateInternal({scene:A,camera:I,autoUpdate:!1})}async updateInternal({scene:A,camera:I,autoUpdate:g}){const B=this.renderer,C=this.time??this.clock.getElapsedTime(),E=I.getWorldPosition(new F),i=I.getWorldDirection(new F),o=E.distanceTo(this.sortedCenter)>.001||i.dot(this.sortedDir)<.999,D=this.accumulators.pop();if(!D)throw new Error("No next accumulator");if(D===this.current)throw new Error("Next accumulator is the same as the current accumulator");const{version:s,mappingVersion:w,visibleGenerators:G,generate:a}=D.prepareGenerate({renderer:B,scene:A,time:C,camera:I,sortRadial:this.sortRadial??!0,renderSize:this.renderSize,previous:this.current,lodInstances:this.enableLod?this.lodInstances:void 0});let y=!0;const h=o||s!==this.current.version,c=w!==this.display.mappingVersion;g&&!h&&(y=!1),c&&this.sorting&&(y=!1),y?(a(),this.flushAfterGenerate&&B.getContext().flush(),this.display.mappingVersion===D.mappingVersion?(this.accumulators.push(this.display),this.display=D):this.display!==this.current&&this.accumulators.push(this.current),this.current=D,this.sortDirty=!0,this.setDirty()):this.accumulators.push(D),this.enableDriveLod&&this.driveLod({visibleGenerators:G,camera:I,scene:A}),await this.driveSort()}async driveSort(){if(this.sorting||!this.sortDirty)return;this.sortTimeoutId!==-1&&(clearTimeout(this.sortTimeoutId),this.sortTimeoutId=-1);const A=performance.now(),I=this.lastSortTime?this.lastSortTime+this.minSortIntervalMs:A;if(A<I){this.sortTimeoutId=setTimeout(()=>{this.sortTimeoutId=-1,this.driveSort()},I-A);return}this.sorting=!0,this.sortDirty=!1,this.lastSortTime=A,this.readPause>0&&await new Promise(w=>setTimeout(w,this.readPause));const g=this.current;this.sortedCenter.copy(g.viewOrigin),this.sortedDir.copy(g.viewDirection);const{numSplats:B,maxSplats:C}=g,E=Math.max(1,Math.ceil(C/16384)),i=E*16384;this.maxSplats=Math.max(this.maxSplats,i);const o=new Uint32Array(this.maxSplats),D=LQ.ensureBuffer(C,this.readback32);this.readback32=D,await this.readbackDepth({current:g,renderer:this.renderer,numSplats:B,readback:D}),this.sortPause>0&&await new Promise(w=>setTimeout(w,this.sortPause)),this.sortWorker||(this.sortWorker=new BB);const s=await this.sortWorker.call("sortSplats32",{numSplats:B,readback:D,ordering:o});if(this.sortDelay>0&&await new Promise(w=>setTimeout(w,this.sortDelay)),this.readback32=s.readback,this.activeSplats=s.activeSplats,this.orderingTexture&&E>this.orderingTexture.image.height&&(this.orderingTexture.dispose(),this.orderingTexture=null),this.orderingTexture){const w=this.renderer,G=w.getContext();if(!w.properties.has(this.orderingTexture))this.orderingTexture.needsUpdate=!0;else{const y=w.properties.get(this.orderingTexture).__webglTexture;if(!y)throw new Error("ordering texture not found");w.state.activeTexture(G.TEXTURE0),w.state.bindTexture(G.TEXTURE_2D,y),G.bindBuffer(G.PIXEL_UNPACK_BUFFER,null),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,!1),G.texSubImage2D(G.TEXTURE_2D,0,0,0,4096,E,G.RGBA_INTEGER,G.UNSIGNED_INT,s.ordering),w.state.bindTexture(G.TEXTURE_2D,null)}}else{const w=new lI(s.ordering,4096,E,BA,v);w.internalFormat="RGBA32UI",w.needsUpdate=!0,this.orderingTexture=w}this.current.mappingVersion===g.mappingVersion&&this.current.mappingVersion!==this.display.mappingVersion&&(this.accumulators.push(this.display),this.display=this.current),this.sorting=!1,this.setDirty(),this.driveSort()}ensureLodWorker(){return this.lodWorker||(this.lodWorker=new BB),this.lodWorker}defaultSplatTarget(){return LB()?5e5:QE()?75e4:HB()?1e6:rg()?15e5:25e5}driveLod({visibleGenerators:A,camera:I,scene:g}){var B,C;const E=this.defaultSplatTarget(),o=(this.lodSplatCount??E)*this.lodSplatScale;let D=0;if(I instanceof vQ)D=2*Math.tan(.5*I.fov*Math.PI/180)/this.renderSize.y;else if(I instanceof Ww){const h=(I.top-I.bottom)/I.zoom,c=(I.right-I.left)/I.zoom,k=h/Math.max(1,this.renderSize.y),R=c/Math.max(1,this.renderSize.x);D=Math.min(R,k)}D*=this.lodRenderScale;const s=new F,w=new Z;if(this.current.viewToWorld.decompose(s,w,new F),this.lodPosOverride&&s.copy(this.lodPosOverride),this.lodQuatOverride&&w.copy(this.lodQuatOverride).normalize(),this.lastLod){(this.lastLod.pixelScaleLimit!==D||this.lastLod.maxSplats!==o)&&(this.lodDirty=!0);const h=s.distanceTo(this.lastLod.pos),c=Math.max(0,1-h/1),k=w.dot(this.lastLod.quat),R=Math.max(0,1-(1-k)/.01);c*R<.999&&(this.lodDirty=!0)}const G=this.enableLod?A.filter(h=>{var c,k;return h instanceof wI&&(((c=h.packedSplats)==null?void 0:c.lodSplats)||((k=h.extSplats)==null?void 0:k.lodSplats)||h.paged)&&h.enableLod!==!1}):[],a=G.some(h=>h.paged);this.lodMeshes.length!==G.length?this.lodDirty=!0:G.some((h,c)=>h!==this.lodMeshes[c].mesh||h.version>this.lodMeshes[c].version)&&(this.lodDirty=!0),this.lodMeshes=G.map(h=>({mesh:h,version:h.version+1})),this.lodInitQueue=[];const y=performance.now();for(const h of G){const c=((B=h.packedSplats)==null?void 0:B.lodSplats)??((C=h.extSplats)==null?void 0:C.lodSplats)??h.paged;if(c){const k=this.lodIds.get(c);k?k.lastTouched=y:this.lodInitQueue.push(c)}}this.ensureLodWorker().tryExclusive(async h=>{if(a&&!this.pager){this.pager=new Qg({renderer:this.renderer,extSplats:this.pagedExtSplats,maxSplats:this.maxPagedSplats,numFetchers:this.numLodFetchers});const{lodId:c}=await h.call("newLodTree",{capacity:this.pager.maxSplats});this.pagerId=c}if(this.pager)for(const{mesh:c}of this.lodMeshes)c.paged&&!c.paged.pager&&(c.paged.pager=this.pager);if(this.lodInitQueue.length>0){const c=this.lodInitQueue;for(this.lodInitQueue=[];c.length>0;){const k=c.shift();k&&(await this.initLodTree(h,k),this.lodDirty=!0)}}if(this.pager){const c=this.pager.consumeLodTreeUpdates();for(const{splats:k,page:R,chunk:t,numSplats:N,lodTree:S}of c){const J=this.lodIds.get(k);J&&(S&&t===0&&(J.rootPage=R),this.lodUpdates.push({lodId:J.lodId,pageBase:R*this.pager.pageSplats,chunkBase:t*this.pager.pageSplats,count:N,lodTreeData:S}))}}if(this.lodUpdates.length>0){const c=this.lodUpdates;this.lodUpdates=[],await h.call("updateLodTrees",{ranges:c}),this.lodDirty=!0}if(this.lodDirty){const c=performance.now(),k=new F;if(this.lastLod){const R=Math.max(1,c-this.lastLod.timestamp);k.copy(s).sub(this.lastLod.pos).multiplyScalar(this.lastTraverseTime/R)}this.lastLod={pos:s,quat:w,pixelScaleLimit:D,maxSplats:o,timestamp:c},this.lodDirty=!1,await this.updateLodInstances(h,k,G,o,s,w,D),this.currentLod=this.lastLod,this.setDirty()}await this.cleanupLodTrees(h)})}async initLodTree(A,I){if(I instanceof SI||I instanceof qI){const{lodId:g}=await A.call("initLodTree",{numSplats:I.numSplats??0,lodTree:I.extra.lodTree.slice()});this.lodIds.set(I,{lodId:g,lastTouched:performance.now()}),this.lodIdToSplats.set(g,I)}else{const{lodId:g}=await A.call("newSharedLodTree",{lodId:this.pagerId});this.lodIds.set(I,{lodId:g,lastTouched:performance.now()}),this.lodIdToSplats.set(g,I)}}async updateLodInstances(A,I,g,B,C,E,i){const o=new Map,D=new FA().compose(C,E,new F().setScalar(1)),s=g.reduce((k,R)=>{var t,N;o.set(R.uuid,R);const S=R.matrixWorld.clone().invert().multiply(D),J=((t=R.packedSplats)==null?void 0:t.lodSplats)??((N=R.extSplats)==null?void 0:N.lodSplats)??R.paged;if(!J)return k;const M=this.lodIds.get(J);return!M||this.pager&&R.paged&&M.rootPage===void 0||(k[R.uuid]={instanceId:R.uuid,lodId:M.lodId,rootPage:M.rootPage,viewToObjectCols:S.elements,lodScale:R.lodScale,behindFoveate:R.behindFoveate??this.behindFoveate,coneFov0:R.coneFov0??this.coneFov0,coneFov:R.coneFov??this.coneFov,coneFoveate:R.coneFoveate??this.coneFoveate}),k},{}),w=performance.now(),G=await A.call("traverseLodTrees",{maxSplats:B,pixelScaleLimit:i,lastPixelLimit:this.lastPixelLimit,instances:s});this.lastTraverseTime=performance.now()-w;const{keyIndices:a,chunks:y,pixelLimit:h}=G;this.lastPixelLimit=h;const c=Object.values(a).reduce((k,{numSplats:R})=>k+R,0);if(this.updateLodIndices(o,a),this.pager){this.pager.processUploads();const k=g.map(R=>{if(!R.paged||!this.pager)return null;const t=R.getWorldPosition(new F);return{splats:R.paged,distance:t.distanceTo(C)}}).filter(R=>R!==null);!this.pageSizeWarning&&k.length>this.pager.maxPages&&(this.pageSizeWarning=!0,console.warn(`# paged SplatMeshes exceeds maxPages: ${k.length} > ${this.pager.maxPages}`)),k.sort((R,t)=>R.distance-t.distance),this.pager.fetchPriority=k.map(({splats:R})=>({splats:R,chunk:0}));for(const[R,t]of y){const N=this.lodIdToSplats.get(R);N instanceof IQ&&t!==0&&this.pager.fetchPriority.push({splats:N,chunk:t})}this.pager.autoDrive=this.enableLodFetching,this.enableLodFetching&&this.pager.driveFetchers()}if(this.lodRaycast&&performance.now()-this.lastLodRaycastTime>=this.lodRaycastIntervalMs){this.lastLodRaycastTime=performance.now();const k=performance.now(),R=await A.call("traverseLodTrees",{maxSplats:Math.min(this.lodRaycast,Math.round(c*.1)),pixelScaleLimit:i,instances:s});performance.now()-k;const{keyIndices:t}=R;Object.values(t).reduce((N,{numSplats:S})=>N+S,0);for(const[N,S]of Object.entries(t)){const J=o.get(N);J.raycastIndices=S}}}async cleanupLodTrees(A){const g=performance.now();let B=null;for(const[C,E]of this.lodIds.entries())(B==null||E.lastTouched<B.lastTouched)&&(B={splats:C,lastTouched:E.lastTouched,lodId:E.lodId});if(!(!B||B.lastTouched>g-3e3)){this.lodIds.delete(B.splats),this.lodIdToSplats.delete(B.lodId);for(const[C,E]of this.lodInstances.entries())E.lodId===B.lodId&&(E.texture.dispose(),this.lodInstances.delete(C));await A.call("disposeLodTree",{lodId:B.lodId})}}updateLodIndices(A,I){for(const[g,B]of Object.entries(I)){const{lodId:C,numSplats:E,indices:i}=B,o=A.get(g);if(o.paged)o.paged.update(E,i);else{let D=this.lodInstances.get(o);D&&i.length>D.indices.length&&(D.texture.dispose(),D=void 0);const s=Math.ceil(i.length/16384);if(D){D.numSplats=E;const w=this.renderer,G=w.getContext();if(w.properties.has(D.texture)){const y=w.properties.get(D.texture).__webglTexture;if(!y)throw new Error("lodIndices texture not found");w.state.activeTexture(G.TEXTURE0),w.state.bindTexture(G.TEXTURE_2D,y),G.bindBuffer(G.PIXEL_UNPACK_BUFFER,null),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,!1),G.texSubImage2D(G.TEXTURE_2D,0,0,0,4096,s,G.RGBA_INTEGER,G.UNSIGNED_INT,i),w.state.bindTexture(G.TEXTURE_2D,null)}}else{const w=s*16384;if(i.length!==w)throw new Error("Indices length != capacity");const G=new lI(i,4096,s,BA,v);G.internalFormat="RGBA32UI",G.needsUpdate=!0,D={lodId:C,numSplats:E,indices:i,texture:G},this.lodInstances.set(o,D)}}o.updateMappingVersion()}}async readbackDepth({current:A,renderer:I,numSplats:g,readback:B}){if(!I)throw new Error("No renderer");if(!A.target)throw new Error("No target");const C=Math.ceil(g/f)*f;if(B.byteLength<C*4)throw new Error(`Readback buffer too small: ${B.byteLength} < ${C*4}`);const E=new Uint8Array(B.buffer),i=this.saveRenderState(I),o=f*zA;let D=0;const s=[];for(;D<g;){const w=Math.floor(D/o),G=w*o,a=Math.min(zA,Math.ceil((g-G)/f)),y=f*a*4,h=E.subarray(G*4,G*4+y);I.setRenderTarget(A.target,w);const c=I.readRenderTargetPixelsAsync(A.target,0,0,f,a,h,void 0,A.extSplats?2:1);s.push(c),this.flushAfterRead&&I.getContext().flush(),D+=f*a}return this.resetRenderState(I,i),Promise.all(s).then(()=>B)}saveRenderState(A){return{target:A.getRenderTarget(),xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,I){A.setRenderTarget(I.target),A.xr.enabled=I.xrEnabled,A.autoClear=I.autoClear}render(A,I){try{hA.sparkOverride=this,this.renderer.render(A,I)}finally{hA.sparkOverride=void 0}}renderTarget({scene:A,camera:I}){const g=this.backTarget??this.target;if(!g)throw new Error("No target");const B=this.renderer.getRenderTarget();try{this.renderer.setRenderTarget(g),hA.sparkOverride=this,this.renderer.render(A,I)}finally{hA.sparkOverride=void 0,this.renderer.setRenderTarget(B)}return g!==this.target&&([this.target,this.backTarget]=[this.backTarget,this.target]),g}async readTarget(){if(!this.target)throw new Error("Must initialize with target");const{width:A,height:I}=this.target,g=A*I*4;(!this.superPixels||this.superPixels.length<g)&&(this.superPixels=new Uint8Array(g));const B=this.superPixels;await this.renderer.readRenderTargetPixelsAsync(this.target,0,0,A,I,B);const{superXY:C}=this;if(C===1)return B;const E=A/C,i=I/C,o=E*i*4;(!this.targetPixels||this.targetPixels.length<o)&&(this.targetPixels=new Uint8Array(o));const D=this.targetPixels,s=C*C;for(let w=0;w<i;w++){const G=w*E;for(let a=0;a<E;a++){const y=a*C;let h=0,c=0,k=0,R=0;for(let N=0;N<C;N++){const S=(w*C+N)*A;for(let J=0;J<C;J++){const M=(S+y+J)*4;h+=B[M],c+=B[M+1],k+=B[M+2],R+=B[M+3]}}const t=(G+a)*4;D[t]=h/s,D[t+1]=c/s,D[t+2]=k/s,D[t+3]=R/s}}return D}async renderReadTarget({scene:A,camera:I}){return this.renderTarget({scene:A,camera:I}),this.readTarget()}async renderCubeMap({scene:A,worldCenter:I,size:g=256,near:B=.1,far:C=1e3,hideObjects:E=[],update:i=!0,filter:o=!1}){if(!hA.cubeRender||hA.cubeRender.target.width!==g||hA.cubeRender.near!==B||hA.cubeRender.far!==C){hA.cubeRender&&hA.cubeRender.target.dispose();const G=new UC(g,{format:sI,type:nI,generateMipmaps:o,minFilter:o?nC:gC,magFilter:gC,colorSpace:o?jw:CQ}),a=new eC(B,C,G);hA.cubeRender={target:G,cubeCamera:a,near:B,far:C}}const{target:D,cubeCamera:s}=hA.cubeRender;s.position.copy(I);const w=new Map;for(const G of E)w.set(G,G.visible),G.visible=!1;if(i){const G=new zQ;G.position.copy(I),await this.update({scene:A,camera:G})}try{hA.sparkOverride=this,s.update(this.renderer,A)}finally{hA.sparkOverride=void 0}for(const[G,a]of w.entries())G.visible=a;return D.texture}async readCubeTargets(){if(!hA.cubeRender)throw new Error("No cube render");const A=hA.cubeRender.target.texture,I=[],g=[];for(let B=0;B<A.images.length;++B){const{width:C,height:E}=A.images[B],i=C*E*4,o=new Uint8Array(i);g.push(o);const D=this.renderer.readRenderTargetPixelsAsync(hA.cubeRender.target,0,0,C,E,o,B);I.push(D)}return await Promise.all(I),g}async renderEnvMap({scene:A,worldCenter:I,size:g=256,near:B=.1,far:C=1e3,hideObjects:E=[],update:i=!0}){var o;const D=await this.renderCubeMap({scene:A,worldCenter:I,size:g,near:B,far:C,hideObjects:E,update:i,filter:!0});return hA.pmrem||(hA.pmrem=new HC(this.renderer)),(o=hA.pmrem)==null?void 0:o.fromCubemap(D).texture}recurseSetEnvMap(A,I){A.traverse(g=>{if(g instanceof QQ)if(Array.isArray(g.material))for(const B of g.material)B instanceof EQ&&(B.envMap=I);else g.material instanceof EQ&&(g.material.envMap=I)})}async getLodTreeLevel(A,I,g=!1){var B,C;const E=this.lodInstances.get(A);if(!E)return null;const i=await this.ensureLodWorker().exclusive(async o=>await o.call("getLodTreeLevel",{lodId:E.lodId,level:I}));if((B=A.packedSplats)!=null&&B.lodSplats){const o=A.packedSplats.lodSplats.extractSplats(i.indices,g);return new wI({packedSplats:o})}if((C=A.extSplats)!=null&&C.lodSplats){const o=A.extSplats.lodSplats.extractSplats(i.indices,g);return new wI({extSplats:o})}throw new Error("Only LoD-enabled PackedSplats and ExtSplats are supported")}get premultipliedAlpha(){return this.material.premultipliedAlpha}set premultipliedAlpha(A){this.material.premultipliedAlpha!==A&&(this.material.premultipliedAlpha=A,this.material.needsUpdate=!0)}};YQ.emptyOrdering=(()=>{const A=new Uint32Array(16384),I=new lI(A,4096,1);return I.format=BA,I.type=v,I.internalFormat="RGBA32UI",I.needsUpdate=!0,I})();YQ.cubeRender=null;YQ.pmrem=null;let aC=YQ;class IQ{constructor(A){var I;if(this.pager=A.pager,this.rootUrl=A.rootUrl??"",this.requestHeader=A.requestHeader,this.withCredentials=A.withCredentials,this.numSh=0,this.maxSh=((I=A.pager)==null?void 0:I.maxSh)??3,this.numSplats=0,this.dynoNumSplats=new aI({value:0}),this.dynoIndices=new JQ({value:Qg.emptyIndicesTexture}),this.rgbMinMaxLnScaleMinMax=new $I({value:new gI(0,1,PA,mA)}),this.lodOpacity=new XI({value:!1}),this.dynoNumSh=new aI({value:0}),this.shMax=new hI({value:new F}),this.fileBytes=A.fileBytes,this.fileType=A.fileType,!this.fileType&&this.fileBytes&&(this.fileType=vB(this.fileBytes)),!this.fileType&&this.rootUrl&&(this.fileType=zB(this.rootUrl)),!this.fileType)throw new Error("Unable to determine file type");this.fileType===cA.RAD&&(this.radMetaPromise=this.getRadMeta())}dispose(){this.dynoIndices.value!==Qg.emptyIndicesTexture&&(this.dynoIndices.value.dispose(),this.dynoIndices.value=Qg.emptyIndicesTexture)}setMaxSh(A){this.maxSh=A}getRadMeta(){return this.radMetaPromise?this.radMetaPromise:(this.radMetaPromise=(async()=>{if(await Xy,this.fileBytes){const A=DC(this.fileBytes.slice(0,1048576));if(A)return A;throw new Error("Failed to decode RAD header")}if(!this.rootUrl)throw new Error("No url or fileBytes provided");for(const A of[65536,256*1024,1024*1024]){const I=await VQ({url:this.rootUrl,requestHeader:this.requestHeader,withCredentials:this.withCredentials,offset:0,bytes:A}),g=DC(I);if(g)return g}throw new Error("Failed to decode RAD header")})().then(A=>A),this.radMetaPromise.catch(A=>{console.error(A)}),this.radMetaPromise)}chunkUrl(A){return this.rootUrl.replace(/-lod-0\./,`-lod-${A}.`)}async fetchDecodeChunk(A){let I;if(this.fileType===cA.RAD){const{meta:g,chunksStart:B}=await this.getRadMeta();if(A<0||A>=g.chunks.length)throw new Error(`Chunk index out of range: ${A} (max: ${g.chunks.length-1})`);let{offset:C,bytes:E,filename:i}=g.chunks[A];if(i){if(this.fileBytes)throw new Error("Chunked RAD file not supported with fileBytes");const o=new URL(this.rootUrl,window.location.href).toString(),D=new URL(i,o).toString();I=await VQ({url:D,requestHeader:this.requestHeader,withCredentials:this.withCredentials})}else if(C+=B,this.fileBytes){if(C<0||C+E>this.fileBytes.length)throw new Error(`Invalid chunk offset or bytes: ${C} + ${E} > ${this.fileBytes.length}`);I=this.fileBytes.slice(C,C+E)}else if(this.rootUrl)I=await VQ({url:this.rootUrl,requestHeader:this.requestHeader,withCredentials:this.withCredentials,offset:C,bytes:E});else throw new Error("No url or fileBytes provided")}else if(!this.fileBytes)if(this.rootUrl){const g=this.chunkUrl(A),B=new Request(g,{headers:this.requestHeader?new Headers(this.requestHeader):void 0,credentials:this.withCredentials?"include":"same-origin"}),C=await fetch(B);if(!C.ok||!C.body)throw new Error(`Failed to fetch "${g}": ${C.status} ${C.statusText}`);I=new Uint8Array(await C.arrayBuffer())}else throw new Error("No url or fileBytes provided");return await NQ.withWorker(async g=>{var B,C,E,i,o;if(!this.pager)throw new Error("PagedSplats.pager not set");if(!this.pager.extSplats){const a=(await g.call("loadPackedSplats",{fileBytes:I,pathName:this.chunkUrl(A),sh1Codes:(B=this.sh1Codes)==null?void 0:B.slice(),sh2Codes:(C=this.sh2Codes)==null?void 0:C.slice(),sh3Codes:(E=this.sh3Codes)==null?void 0:E.slice()})).lodSplats;return this.splatEncoding||(this.splatEncoding=a.splatEncoding,this.numSh=a.extra.sh3?3:a.extra.sh2?2:a.extra.sh1?1:0,this.rgbMinMaxLnScaleMinMax.value.set(this.splatEncoding.rgbMin??0,this.splatEncoding.rgbMax??1,this.splatEncoding.lnScaleMin??PA,this.splatEncoding.lnScaleMax??mA),this.lodOpacity.value=this.splatEncoding.lodOpacity??!1,this.shMax.value.set(this.splatEncoding.sh1Max??1,this.splatEncoding.sh2Max??1,this.splatEncoding.sh3Max??1)),this.sh1Codes=a.extra.sh1Codes??this.sh1Codes,this.sh2Codes=a.extra.sh2Codes??this.sh2Codes,this.sh3Codes=a.extra.sh3Codes??this.sh3Codes,a}const D=this.sh3Codes,w=(await g.call("loadExtSplats",{fileBytes:I,pathName:this.chunkUrl(A),sh1Codes:(i=this.sh1Codes)==null?void 0:i.slice(),sh2Codes:(o=this.sh2Codes)==null?void 0:o.slice(),sh3Codes:D?[D[0].slice(),D[1].slice()]:void 0})).lodSplats;return this.splatEncoding||(this.splatEncoding=lg,this.numSh=w.extra.sh3a&&w.extra.sh3b?3:w.extra.sh2?2:w.extra.sh1?1:0),this.sh1Codes=w.extra.sh1Codes??this.sh1Codes,this.sh2Codes=w.extra.sh2Codes??this.sh2Codes,this.sh3Codes=w.extra.sh3Codes??this.sh3Codes,w})}update(A,I){if(!this.pager)throw new Error("PagedSplats.pager not set");const g=this.pager.renderer;this.numSplats=A,this.dynoNumSplats.value=this.numSplats;const B=Math.ceil(A/16384);let C=this.dynoIndices.value===Qg.emptyIndicesTexture?void 0:this.dynoIndices.value;if(C&&B>C.image.height&&(C.dispose(),C=void 0),!C)C=new lI(I,4096,B,BA,v),C.internalFormat="RGBA32UI",C.needsUpdate=!0,g.initTexture(C),this.dynoIndices.value=C;else{C.image.data.set(I.subarray(0,A));const i=g.getContext();g.state.activeTexture(i.TEXTURE0),g.state.bindTexture(i.TEXTURE_2D,Uw(g,C)),i.bindBuffer(i.PIXEL_UNPACK_BUFFER,null),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.texSubImage2D(i.TEXTURE_2D,0,0,0,4096,B,i.RGBA_INTEGER,i.UNSIGNED_INT,I),g.state.bindTexture(i.TEXTURE_2D,null)}}prepareFetchSplat(){}getNumSplats(){return this.numSplats}hasRgbDir(){return this.pager?Math.min(this.numSh,this.pager.maxSh)>0:!1}getNumSh(){return this.numSh}fetchSplat({index:A,viewOrigin:I}){if(!this.pager)throw new Error("PagedSplats.pager not set");const g=this.pager.readIndex.apply({index:A,numSplats:this.dynoNumSplats,indices:this.dynoIndices}).index;return this.pager.extSplats?this.hasRgbDir()&&I?(this.dynoNumSh.value=Math.min(this.numSh,this.maxSh,this.pager.maxSh),this.pager.readSplatExtDir.apply({index:g,viewOrigin:I,numSh:this.dynoNumSh}).gsplat):this.pager.readSplatExt.apply({index:g}).gsplat:this.hasRgbDir()&&I?(this.dynoNumSh.value=Math.min(this.numSh,this.maxSh,this.pager.maxSh),this.pager.readSplatDir.apply({index:g,rgbMinMaxLnScaleMinMax:this.rgbMinMaxLnScaleMinMax,lodOpacity:this.lodOpacity,viewOrigin:I,numSh:this.dynoNumSh,shMax:this.shMax}).gsplat):this.pager.readSplat.apply({index:g,rgbMinMaxLnScaleMinMax:this.rgbMinMaxLnScaleMinMax,lodOpacity:this.lodOpacity}).gsplat}forEachSplat(A){if(!this.pager||!this.numSplats)return;const I=this.pager.extSplats,g=this.dynoIndices.value.image.data,B=this.pager.packedTexture.value.image.data,C=this.pager.extTexture.value.image.data,E=[B,C];for(let i=0;i<this.numSplats;++i){const o=g[i],D=I?wQ(E,o):sQ(B,o,this.splatEncoding);A(i,D.center,D.scales,D.quaternion,D.opacity,D.color)}}}const UA=class DA{constructor(A){this.fetchPause=0,this.splatsChunkToPage=new Map,this.pageToSplatsChunk=[],this.renderer=A.renderer,this.extSplats=A.extSplats??!1,this.pageSplats=65536,this.maxSplats=A.maxSplats??16777216,this.maxPages=Math.ceil(this.maxSplats/this.pageSplats),this.maxSplats=this.maxPages*this.pageSplats,this.maxSh=A.maxSh??3,this.curSh=0,this.autoDrive=A.autoDrive??!0,this.numFetchers=A.numFetchers??3,this.splatsChunkToPage=new Map,this.pageToSplatsChunk=new Array(this.maxPages),this.pageFreelist=Array.from({length:this.maxPages},(I,g)=>g),this.pageLru=new Set,this.freeablePages=[],this.newUploads=[],this.readyUploads=[],this.lodTreeUpdates=[],this.fetchers=[],this.fetched=[],this.fetchPriority=[],this.packedTexture=new lA({value:this.newUint32ArrayTexture(new Uint32Array(this.maxPages*256*256*4),256,256,this.maxPages,BA,v,"RGBA32UI")}),this.extTexture=new lA({value:this.extSplats?this.newUint32ArrayTexture(new Uint32Array(this.maxPages*256*256*4),256,256,this.maxPages,BA,v,"RGBA32UI"):DA.emptyExtTexture}),this.sh1Texture=new lA({value:this.extSplats?DA.emptyExtSh1Texture:DA.emptySh1Texture}),this.sh2Texture=new lA({value:this.extSplats?DA.emptyExtSh2Texture:DA.emptySh2Texture}),this.sh3Texture=new lA({value:this.extSplats?DA.emptyExtSh3Texture:DA.emptySh3Texture}),this.sh3TextureB=new lA({value:DA.emptyExtSh3BTexture}),this.readIndex=JA({index:"int",numSplats:"int",indices:"usampler2D"},{index:"int"},({index:I,numSplats:g,indices:B})=>new d({inTypes:{index:"int",numSplats:"int",indices:"usampler2D"},outTypes:{index:"int"},inputs:{index:I,numSplats:g,indices:B},statements:({inputs:C,outputs:E})=>$(`
11580
11580
  if (${C.index} >= ${C.numSplats}) {
11581
11581
  return;
11582
11582
  }
@@ -11661,7 +11661,7 @@ void main() {
11661
11661
  item['${B}'] = PARSE_FIELD['${C.type}'](data, offset, ${A});
11662
11662
  offset += ${oI[C.type]};
11663
11663
  `)}I.push("return offset;");const g=new Function("data","offset","item","PARSE_FIELD",I.join(`
11664
- `));return(B,C,E)=>g(B,C,E,Bg)}function Qc(Q,A){const I=[];for(const[g,B]of Object.entries(Q)){const C=g.match(jB);if(C){const E=+C[1];I.push((i,o,D)=>(D.f_rest[E]=Bg[B.type](i,o,A),o+oI[B.type]))}else B.isList?I.push((E,i,o)=>{const D=o[g];D.length=Bg[B.countType](E,i,A);let s=i+oI[B.countType];for(let w=0;w<D.length;w++)D[w]=Bg[B.type](E,s,A),s+=oI[B.type];return s}):I.push((E,i,o)=>(o[g]=Bg[B.type](E,i,A),i+oI[B.type]))}return(g,B,C)=>{let E=B;for(let i=0;i<I.length;i++)E=I[i](g,E,C);return E}}function aB(Q){let A=0;for(;Q[`f_rest_${A}`];)A+=1;const I=jy[A];if(I==null)throw new Error(`Unsupported number of SH coefficients: ${A}`);return I}class Hw extends vw{constructor(A){super(A),this.fileLoader=new zw(A)}load(A,I,g,B){return this.loadInternal({url:A,onLoad:I,onProgress:g,onError:B})}async loadAsync(A,I){return new Promise((g,B)=>{this.load(A,C=>{g(C)},I,B)})}parse(A){return new wI({packedSplats:A})}loadInternal({packedSplats:A,extSplats:I,url:g,fileBytes:B,fileType:C,fileName:E,stream:i,streamLength:o,onLoad:D,onProgress:s,onError:w,lod:G,nonLod:a,lodAbove:y,lodBase:h}){B instanceof ArrayBuffer&&(B=new Uint8Array(B));const c=B?void 0:this.manager.resolveURL((this.path??"")+(g??""));let k=i?.getReader();this.manager.itemStart(c??""),NQ.withWorker(async R=>{const t=A?.lod??I?.lod;t&&(G=t);const N=A?.nonLod??I?.nonLod;N!==void 0&&(a=N);const S=async U=>{const{loaded:n,total:L}=U;if(n!==void 0&&s&&s(new ProgressEvent("progress",{lengthComputable:L!==0,loaded:n,total:L})),U.nextChunk){let H;if(!k)H=new Uint8Array(0);else{const{done:e,value:q}=await k.read();e?(k.releaseLock(),k=void 0,H=new Uint8Array(0)):H=q}R.call("nextChunk",{chunk:H})}},J=c?new URL(c,window.location.href).toString():void 0,M=await R.call(I?"loadExtSplats":"loadPackedSplats",{url:J,requestHeader:this.requestHeader,withCredentials:this.withCredentials,fileBytes:B?.slice(),fileType:C,pathName:c||E,chunked:i!==void 0,chunkedLength:o,encoding:A?.splatEncoding,lod:G,lodBase:h,nonLod:a,lodAbove:y},{onStatus:S});if(M.lodSplats&&(I?M.lodSplats=new qI({...M.lodSplats}):M.lodSplats=new SI({...M.lodSplats,maxSplats:A?.maxSplats})),I){const U={...M};I.initialize(U),D?.(I)}else{const U={...M};A?(A.initialize(U),D?.(A)):D?.(new SI(U))}}).catch(R=>{this.manager.itemError(c??""),w?.(R)}).finally(()=>{this.manager.itemEnd(c??"")})}async loadInternalAsync({packedSplats:A,extSplats:I,url:g,fileBytes:B,fileType:C,fileName:E,stream:i,streamLength:o,onProgress:D,lod:s,nonLod:w,lodAbove:G,lodBase:a}){return new Promise((y,h)=>{this.loadInternal({packedSplats:A,extSplats:I,url:g,fileBytes:B,fileType:C,fileName:E,stream:i,streamLength:o,onLoad:y,onProgress:D,onError:h,lod:s,nonLod:w,lodAbove:G,lodBase:a})})}}function vB(Q){const I=new DataView(Q.buffer).getUint32(0,!0);if((I&16777215)===7957616)return cA.PLY;if((I&16777215)===559903){const g=GE(Q,4);return new DataView(g.buffer).getUint32(0,!0)===1347635022?cA.SPZ:void 0}if(I===67324752)return Cc(Q)?cA.PCSOGSZIP:void 0;if(I===809779538)return cA.RAD}function Bc(Q){const A=Q.split(/[?#]/,1)[0],I=Math.max(A.lastIndexOf("/"),A.lastIndexOf("\\")),g=A.slice(I+1),B=g.lastIndexOf(".");return B<=0||B===g.length-1?"":g.slice(B+1).toLowerCase()}function zB(Q){const A=Bc(Q);if(A==="ply")return cA.PLY;if(A==="spz")return cA.SPZ;if(A==="splat")return cA.SPLAT;if(A==="ksplat")return cA.KSPLAT;if(A==="sog")return cA.PCSOGSZIP;if(A==="rad")return cA.RAD}function Ok(Q){return Lw(Q)!==void 0}function Lw(Q){try{let A;if(typeof Q=="string")A=Q;else{const B=Q instanceof ArrayBuffer?new Uint8Array(Q):Q;if(B.length>65536)return;A=new TextDecoder().decode(B)}const I=JSON.parse(A);if(!I||typeof I!="object"||Array.isArray(I))return;const g=I.version===2;for(const B of["means","scales","quats","sh0"]){if(!I[B]||typeof I[B]!="object"||Array.isArray(I[B]))return;if(g){if(!I[B].files||(B==="scales"||B==="sh0")&&!I[B].codebook||B==="means"&&(!I[B].mins||!I[B].maxs))return}else if(!I[B].shape||!I[B].files||B!=="quats"&&(!I[B].mins||!I[B].maxs))return}return I}catch{return}}function Cc(Q){try{const A=Q instanceof ArrayBuffer?new Uint8Array(Q):Q;let I=null;const g=Hs(A,{filter:({name:C})=>C.split(/[\\/]/).pop()==="meta.json"?(I=C,!0):!1});if(!I)return;const B=Lw(g[I]);return B?{name:I,json:B}:void 0}catch{return}}async function Zk({input:Q,extraFiles:A,fileType:I,pathOrUrl:g,splatEncoding:B}){const C=Q instanceof ArrayBuffer?new Uint8Array(Q):Q;let E=I;switch(I||(E=vB(C),!E&&g&&(E=zB(g))),E){case cA.PLY:{const i=new ew({fileBytes:C});await i.parseHeader();const o=i.numSplats,D=EA(o).maxSplats,s={fileBytes:C,packedArray:new Uint32Array(D*4),splatEncoding:B};return await PI(async w=>{const{packedArray:G,numSplats:a,extra:y}=await w.call("unpackPly",s);return{packedArray:G,numSplats:a,extra:y}})}case cA.SPZ:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodeSpz",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});case cA.SPLAT:return await PI(async i=>{const{packedArray:o,numSplats:D}=await i.call("decodeAntiSplat",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D}});case cA.KSPLAT:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodeKsplat",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});case cA.PCSOGS:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodePcSogs",{fileBytes:C,extraFiles:A,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});case cA.PCSOGSZIP:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodePcSogsZip",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});default:throw new Error(`Unknown splat file type: ${E}`)}}class Ec{constructor({maxSplats:A=1}={}){this.numSplats=0,this.maxSplats=EA(A).maxSplats,this.centers=new Float32Array(this.maxSplats*3),this.scales=new Float32Array(this.maxSplats*3),this.quaternions=new Float32Array(this.maxSplats*4),this.opacities=new Float32Array(this.maxSplats),this.colors=new Float32Array(this.maxSplats*3)}pushSplat(){const A=this.numSplats;return this.ensureIndex(A),this.numSplats+=1,A}unpushSplat(A){if(A===this.numSplats-1)this.numSplats-=1;else throw new Error("Cannot unpush splat from non-last position")}ensureCapacity(A){if(A>this.maxSplats){const I=Math.max(A,this.maxSplats*2),g=new Float32Array(I*3),B=new Float32Array(I*3),C=new Float32Array(I*4),E=new Float32Array(I),i=new Float32Array(I*3);if(g.set(this.centers),B.set(this.scales),C.set(this.quaternions),E.set(this.opacities),i.set(this.colors),this.centers=g,this.scales=B,this.quaternions=C,this.opacities=E,this.colors=i,this.sh1){const o=new Float32Array(I*9);o.set(this.sh1),this.sh1=o}if(this.sh2){const o=new Float32Array(I*15);o.set(this.sh2),this.sh2=o}if(this.sh3){const o=new Float32Array(I*21);o.set(this.sh3),this.sh3=o}this.maxSplats=I}}ensureIndex(A){this.ensureCapacity(A+1)}setCenter(A,I,g,B){this.centers[A*3]=I,this.centers[A*3+1]=g,this.centers[A*3+2]=B}setScale(A,I,g,B){this.scales[A*3]=I,this.scales[A*3+1]=g,this.scales[A*3+2]=B}setQuaternion(A,I,g,B,C){this.quaternions[A*4]=I,this.quaternions[A*4+1]=g,this.quaternions[A*4+2]=B,this.quaternions[A*4+3]=C}setOpacity(A,I){this.opacities[A]=I}setColor(A,I,g,B){this.colors[A*3]=I,this.colors[A*3+1]=g,this.colors[A*3+2]=B}setSh1(A,I){this.sh1||(this.sh1=new Float32Array(this.maxSplats*9));for(let g=0;g<9;++g)this.sh1[A*9+g]=I[g]}setSh2(A,I){this.sh2||(this.sh2=new Float32Array(this.maxSplats*15));for(let g=0;g<15;++g)this.sh2[A*15+g]=I[g]}setSh3(A,I){this.sh3||(this.sh3=new Float32Array(this.maxSplats*21));for(let g=0;g<21;++g)this.sh3[A*21+g]=I[g]}}const Ag=class iI{constructor(A={}){this.maxSplats=0,this.numSplats=0,this.packedArray=null,this.maxSh=3,this.isInitialized=!1,this.target=null,this.source=null,this.needsUpdate=!0,this.extra={},this.dyno=new _B({packedSplats:this}),this.dynoRgbMinMaxLnScaleMinMax=new $I({key:"rgbMinMaxLnScaleMinMax",value:new gI(0,1,PA,mA),update:I=>{var g,B,C,E;return I.set(((g=this.splatEncoding)==null?void 0:g.rgbMin)??0,((B=this.splatEncoding)==null?void 0:B.rgbMax)??1,((C=this.splatEncoding)==null?void 0:C.lnScaleMin)??PA,((E=this.splatEncoding)==null?void 0:E.lnScaleMax)??mA),I}}),this.dynoNumSh=new aI({key:"numSh",value:0,update:()=>Math.min(this.getNumSh(),this.maxSh)}),this.dynoShMax=new hI({key:"shMax",value:new F,update:I=>{var g,B,C;return I.set(((g=this.splatEncoding)==null?void 0:g.sh1Max)??1,((B=this.splatEncoding)==null?void 0:B.sh2Max)??1,((C=this.splatEncoding)==null?void 0:C.sh3Max)??1),I}}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,this.extra={},this.maxSplats=A.maxSplats??0,this.splatEncoding=A.splatEncoding,this.lod=A.lod,this.nonLod=A.nonLod,A.url||A.fileBytes||A.stream||A.construct?this.initialized=this.asyncInitialize(A).then(()=>(this.isInitialized=!0,this)):(this.initialize(A),this.isInitialized=!0,this.initialized=Promise.resolve(this))}initialize(A){this.extra=A.extra??{},this.splatEncoding=A.splatEncoding??this.splatEncoding,this.lodSplats=A.lodSplats,A.packedArray?(this.packedArray=A.packedArray,this.numSplats=A.numSplats??this.packedArray.length/4,this.maxSplats=Math.floor(this.packedArray.length/4),this.maxSplats=Math.floor(this.maxSplats/f)*f,this.numSplats=Math.min(this.maxSplats,A.numSplats??Number.POSITIVE_INFINITY)):(this.maxSplats=A.maxSplats??0,this.numSplats=0)}async asyncInitialize(A){const{url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,construct:o,lod:D,nonLod:s,lodAbove:w}=A;this.lod=D,this.nonLod=s;const G=new Hw;if((g||I||E)&&await G.loadInternalAsync({packedSplats:this,url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,onProgress:A.onProgress,lodAbove:w}),o){const a=o(this);a instanceof Promise&&await a}}dispose(){this.target&&(this.target.dispose(),this.target.texture.source.data=null,this.target=null),this.source&&(this.source.dispose(),this.source.source.data=null,this.source=null),this.packedArray=null;for(const A in this.extra){const I=this.extra[A];if(I instanceof l){const g=I.value;g?.isTexture&&(g.dispose(),g.source.data=null)}}this.extra={},this.disposeLodSplats()}prepareFetchSplat(){}getNumSplats(){return this.numSplats}hasRgbDir(){return Math.min(this.getNumSh(),this.maxSh)>0}getNumSh(){return this.extra.sh1?this.extra.sh2?this.extra.sh3?3:2:1:0}setMaxSh(A){this.maxSh=A}fetchSplat({index:A,viewOrigin:I}){let g=ig(this.dyno,A);if(this.hasRgbDir()&&I){const B=ZA(g).outputs.center,C=Kg(yI(B,I)),{sh1Texture:E,sh2Texture:i,sh3Texture:o}=this.ensureShTextures();let{rgb:D}=Yw({coord:qB(A),viewDir:C,numSh:this.dynoNumSh,sh1Texture:E,sh2Texture:i,sh3Texture:o,shMax:this.dynoShMax});D=xA(D,ZA(g).outputs.rgb),g=GI({gsplat:g,rgb:D})}return g}ensureShTextures(){if(!this.extra.sh1)return{};let A=this.extra.sh1Texture;if(!A){let B=this.extra.sh1;const{width:C,height:E,depth:i,maxSplats:o}=EA(B.length/2);if(B.length<o*2){const s=new Uint32Array(o*2);s.set(B),this.extra.sh1=s,B=s}const D=new pA(B,C,E,i);D.format=RQ,D.type=v,D.internalFormat="RG32UI",D.needsUpdate=!0,A=new lA({value:D,key:"sh1"}),this.extra.sh1Texture=A}if(!this.extra.sh2)return{sh1Texture:A};let I=this.extra.sh2Texture;if(!I){let B=this.extra.sh2;const{width:C,height:E,depth:i,maxSplats:o}=EA(B.length/4);if(B.length<o*4){const s=new Uint32Array(o*4);s.set(B),this.extra.sh2=s,B=s}const D=new pA(B,C,E,i);D.format=BA,D.type=v,D.internalFormat="RGBA32UI",D.needsUpdate=!0,I=new lA({value:D,key:"sh2"}),this.extra.sh2Texture=I}if(!this.extra.sh3)return{sh1Texture:A,sh2Texture:I};let g=this.extra.sh3Texture;if(!g){let B=this.extra.sh3;const{width:C,height:E,depth:i,maxSplats:o}=EA(B.length/4);if(B.length<o*4){const s=new Uint32Array(o*4);s.set(B),this.extra.sh3=s,B=s}const D=new pA(B,C,E,i);D.format=BA,D.type=v,D.internalFormat="RGBA32UI",D.needsUpdate=!0,g=new lA({value:D,key:"sh3"}),this.extra.sh3Texture=g}return{sh1Texture:A,sh2Texture:I,sh3Texture:g}}ensureSplats(A){const I=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),g=this.packedArray?this.packedArray.length/4:0;if(!this.packedArray||I>g){this.maxSplats=EA(I).maxSplats;const B=new Uint32Array(this.maxSplats*4);this.packedArray&&B.set(this.packedArray),this.packedArray=B}return this.packedArray}ensureSplatsSh(A,I){let g,B;if(A===0)return this.ensureSplats(I);if(A===1)g=2,B="sh1";else if(A===2)g=4,B="sh2";else if(A===3)g=4,B="sh3";else throw new Error(`Invalid level: ${A}`);let C=this.extra[B]?this.extra[B].length/g:0;const E=I<=C?C:Math.max(I,2*C);if(!this.extra[B]||E>C){C=EA(E).maxSplats;const i=new Uint32Array(C*g);this.extra[B]&&i.set(this.extra[B]),this.extra[B]=i}return this.extra[B]}getSplat(A){if(!this.packedArray||A>=this.numSplats)throw new Error("Invalid index");return sQ(this.packedArray,A,this.splatEncoding)}setSplat(A,I,g,B,C,E){const i=this.ensureSplats(A+1);gB(i,A,I.x,I.y,I.z,g.x,g.y,g.z,B.x,B.y,B.z,B.w,C,E.r,E.g,E.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,I,g,B,C){const E=this.ensureSplats(this.numSplats+1);gB(E,this.numSplats,A.x,A.y,A.z,I.x,I.y,I.z,g.x,g.y,g.z,g.w,B,C.r,C.g,C.b),++this.numSplats}forEachSplat(A){if(!(!this.packedArray||!this.numSplats))for(let I=0;I<this.numSplats;++I){const g=sQ(this.packedArray,I,this.splatEncoding);A(I,g.center,g.scales,g.quaternion,g.opacity,g.color)}}ensureGenerate(A){if(this.target&&(A??1)<=this.maxSplats)return!1;this.target&&this.target.dispose();const I=EA(A??1),{width:g,height:B,depth:C}=I;return this.maxSplats=I.maxSplats,this.target=new FB(g,B,C,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:og,minFilter:og}),this.target.texture.format=BA,this.target.texture.type=v,this.target.texture.internalFormat="RGBA32UI",this.target.scissorTest=!0,!0}generateMapping(A){let I=0;const g=A.map(B=>{const C=I,E=Math.ceil(B/f)*f;return I+=E,{base:C,count:B}});return{maxSplats:I,mapping:g}}getTexture(){return this.target?this.target.texture:this.source||this.packedArray?this.maybeUpdateSource():iI.getEmptyArray}maybeUpdateSource(){if(!this.packedArray)throw new Error("No packed splats");if(this.needsUpdate||!this.source){if(this.needsUpdate=!1,this.source){const{width:A,height:I,depth:g}=this.source.image;this.maxSplats!==A*I*g&&(this.source.dispose(),this.source=null)}if(this.source)this.packedArray.buffer!==this.source.image.data.buffer&&(this.source.image.data=new Uint8Array(this.packedArray.buffer));else{const{width:A,height:I,depth:g}=EA(this.maxSplats);this.source=new pA(this.packedArray,A,I,g),this.source.format=BA,this.source.type=v,this.source.internalFormat="RGBA32UI",this.source.needsUpdate=!0}this.source.needsUpdate=!0}return this.source}prepareProgramMaterial(A){let I=iI.generatorProgram.get(A);if(!I){const B=JA({index:"int"},{},({index:C},E,{roots:i})=>{A.inputs.index=C;const o=A.outputs.gsplat,D=pB(o,this.dynoRgbMinMaxLnScaleMinMax);i.push(D)});iI.programTemplate||(iI.programTemplate=new ug(hg().computeUvec4Template)),I=new UQ({graph:B,inputs:{index:"_index"},outputs:{output:"target"},template:iI.programTemplate}),Object.assign(I.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),iI.generatorProgram.set(A,I)}const g=I.prepareMaterial();return iI.fullScreenQuad.material=g,{program:I,material:g}}saveRenderState(A){return{target:A.getRenderTarget(),xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,I){A.setRenderTarget(I.target),A.xr.enabled=I.xrEnabled,A.autoClear=I.autoClear}generate({generator:A,base:I,count:g,renderer:B}){if(!this.target)throw new Error("Target must be initialized with ensureSplats");if(I+g>this.maxSplats)throw new Error("Base + count exceeds maxSplats");const{program:C,material:E}=this.prepareProgramMaterial(A);C.update();const i=this.saveRenderState(B),o=Math.ceil((I+g)/f)*f,D=f*zA;for(E.uniforms.targetBase.value=I,E.uniforms.targetCount.value=g;I<o;){const s=Math.floor(I/D);E.uniforms.targetLayer.value=s;const w=s*D,G=Math.floor((I-w)/f),a=Math.min(zA,Math.ceil((o-w)/f));this.target.scissor.set(0,G,f,a-G),B.setRenderTarget(this.target,s),B.xr.enabled=!1,B.autoClear=!1,iI.fullScreenQuad.render(B),I+=f*(a-G)}return this.resetRenderState(B,i),{nextBase:o}}disposeLodSplats(){this.lodSplats&&(this.lodSplats.dispose(),this.lodSplats=void 0)}async createLodSplats({rgbaArray:A,quality:I}={}){const g=typeof this.lod=="number"?Math.max(1.1,Math.min(2,this.lod)):I?1.75:1.5,B=this.packedArray.slice(),C=A?(await A.getArray()).slice():void 0,E={sh1:this.extra.sh1?this.extra.sh1.slice():void 0,sh2:this.extra.sh2?this.extra.sh2.slice():void 0,sh3:this.extra.sh3?this.extra.sh3.slice():void 0},i=await NQ.withWorker(async D=>await D.call(I?"qualityLodPackedSplats":"tinyLodPackedSplats",{numSplats:this.numSplats,packedArray:B,extra:E,lodBase:g,rgba:C,encoding:this.splatEncoding??lg})),o=new iI(i);this.lodSplats&&this.lodSplats.dispose(),this.lodSplats=o,this.nonLod=!0,this.lod=I?"quality":!0}extractSplats(A,I){const g=EA(A.length).maxSplats,B=new iI({maxSplats:g});for(let C=0;C<A.length;C++){const E=this.getSplat(A[C]);if(I){let i=(A[C]>>>16)*.61803398875;i=i-Math.floor(i);const o=Math.max(0,Math.min(1,Math.abs(i*6-3)-1)),D=Math.max(0,Math.min(1,Math.abs(i*6+1)-1)),s=Math.max(0,Math.min(1,Math.abs(i*6-1)-1));E.color.r*=o,E.color.g*=D,E.color.b*=s}B.pushSplat(E.center,E.scales,E.quaternion,E.opacity,E.color)}return B}};Ag.getEmptyArray=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();Ag.programTemplate=null;Ag.generatorProgram=new WeakMap;Ag.fullScreenQuad=new SB(new FQ({visible:!1}));Ag.emptyUint32x4=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();Ag.emptyUint32x2=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*2),C=new pA(B,Q,A,I);return C.format=RQ,C.type=v,C.internalFormat="RG32UI",C.needsUpdate=!0,C})();let SI=Ag;class _B extends l{constructor({packedSplats:A}={}){super({key:"packedSplats",type:bg,globals:()=>[MQ],value:{textureArray:SI.getEmptyArray,numSplats:0,rgbMinMaxLnScaleMinMax:new gI(0,1,PA,mA),lodOpacity:!1},update:I=>{var g,B,C,E,i,o,D,s,w,G,a,y;return I.textureArray=((g=this.packedSplats)==null?void 0:g.getTexture())??SI.getEmptyArray,I.numSplats=((B=this.packedSplats)==null?void 0:B.numSplats)??0,I.rgbMinMaxLnScaleMinMax.set(((E=(C=this.packedSplats)==null?void 0:C.splatEncoding)==null?void 0:E.rgbMin)??0,((o=(i=this.packedSplats)==null?void 0:i.splatEncoding)==null?void 0:o.rgbMax)??1,((s=(D=this.packedSplats)==null?void 0:D.splatEncoding)==null?void 0:s.lnScaleMin)??PA,((G=(w=this.packedSplats)==null?void 0:w.splatEncoding)==null?void 0:G.lnScaleMax)??mA),I.lodOpacity=((y=(a=this.packedSplats)==null?void 0:a.splatEncoding)==null?void 0:y.lodOpacity)??!1,I}}),this.packedSplats=A}}const ic=sA(`
11664
+ `));return(B,C,E)=>g(B,C,E,Bg)}function Qc(Q,A){const I=[];for(const[g,B]of Object.entries(Q)){const C=g.match(jB);if(C){const E=+C[1];I.push((i,o,D)=>(D.f_rest[E]=Bg[B.type](i,o,A),o+oI[B.type]))}else B.isList?I.push((E,i,o)=>{const D=o[g];D.length=Bg[B.countType](E,i,A);let s=i+oI[B.countType];for(let w=0;w<D.length;w++)D[w]=Bg[B.type](E,s,A),s+=oI[B.type];return s}):I.push((E,i,o)=>(o[g]=Bg[B.type](E,i,A),i+oI[B.type]))}return(g,B,C)=>{let E=B;for(let i=0;i<I.length;i++)E=I[i](g,E,C);return E}}function aB(Q){let A=0;for(;Q[`f_rest_${A}`];)A+=1;const I=jy[A];if(I==null)throw new Error(`Unsupported number of SH coefficients: ${A}`);return I}class Hw extends vw{constructor(A){super(A),this.fileLoader=new zw(A)}load(A,I,g,B){return this.loadInternal({url:A,onLoad:I,onProgress:g,onError:B})}async loadAsync(A,I){return new Promise((g,B)=>{this.load(A,C=>{g(C)},I,B)})}parse(A){return new wI({packedSplats:A})}loadInternal({packedSplats:A,extSplats:I,url:g,fileBytes:B,fileType:C,fileName:E,stream:i,streamLength:o,onLoad:D,onProgress:s,onError:w,lod:G,nonLod:a,lodAbove:y,lodBase:h}){B instanceof ArrayBuffer&&(B=new Uint8Array(B));const c=B?void 0:this.manager.resolveURL((this.path??"")+(g??""));let k=i?.getReader();this.manager.itemStart(c??""),NQ.withWorker(async R=>{const t=A?.lod??I?.lod;t&&(G=t);const N=A?.nonLod??I?.nonLod;N!==void 0&&(a=N);const S=async U=>{const{loaded:n,total:L}=U;if(n!==void 0&&s&&s(new ProgressEvent("progress",{lengthComputable:L!==0,loaded:n,total:L})),U.nextChunk){let H;if(!k)H=new Uint8Array(0);else{const{done:e,value:q}=await k.read();e?(k.releaseLock(),k=void 0,H=new Uint8Array(0)):H=q}R.call("nextChunk",{chunk:H})}},J=c?new URL(c,window.location.href).toString():void 0,M=await R.call(I?"loadExtSplats":"loadPackedSplats",{url:J,requestHeader:this.requestHeader,withCredentials:this.withCredentials,fileBytes:B?.slice(),fileType:C,pathName:c||E,chunked:i!==void 0,chunkedLength:o,encoding:A?.splatEncoding,lod:G,lodBase:h,nonLod:a,lodAbove:y},{onStatus:S});if(M.lodSplats&&(I?M.lodSplats=new qI({...M.lodSplats}):M.lodSplats=new SI({...M.lodSplats,maxSplats:A?.maxSplats})),I){const U={...M};I.initialize(U),D?.(I)}else{const U={...M};A?(A.initialize(U),D?.(A)):D?.(new SI(U))}}).catch(R=>{this.manager.itemError(c??""),w?.(R)}).finally(()=>{this.manager.itemEnd(c??"")})}async loadInternalAsync({packedSplats:A,extSplats:I,url:g,fileBytes:B,fileType:C,fileName:E,stream:i,streamLength:o,onProgress:D,lod:s,nonLod:w,lodAbove:G,lodBase:a}){return new Promise((y,h)=>{this.loadInternal({packedSplats:A,extSplats:I,url:g,fileBytes:B,fileType:C,fileName:E,stream:i,streamLength:o,onLoad:y,onProgress:D,onError:h,lod:s,nonLod:w,lodAbove:G,lodBase:a})})}}function vB(Q){const I=new DataView(Q.buffer).getUint32(0,!0);if((I&16777215)===7957616)return cA.PLY;if((I&16777215)===559903){const g=GE(Q,4);return new DataView(g.buffer).getUint32(0,!0)===1347635022?cA.SPZ:void 0}if(I===67324752)return Cc(Q)?cA.PCSOGSZIP:void 0;if(I===809779538)return cA.RAD}function Bc(Q){const A=Q.split(/[?#]/,1)[0],I=Math.max(A.lastIndexOf("/"),A.lastIndexOf("\\")),g=A.slice(I+1),B=g.lastIndexOf(".");return B<=0||B===g.length-1?"":g.slice(B+1).toLowerCase()}function zB(Q){const A=Bc(Q);if(A==="ply")return cA.PLY;if(A==="spz")return cA.SPZ;if(A==="splat")return cA.SPLAT;if(A==="ksplat")return cA.KSPLAT;if(A==="sog")return cA.PCSOGSZIP;if(A==="rad")return cA.RAD}function xk(Q){return Lw(Q)!==void 0}function Lw(Q){try{let A;if(typeof Q=="string")A=Q;else{const B=Q instanceof ArrayBuffer?new Uint8Array(Q):Q;if(B.length>65536)return;A=new TextDecoder().decode(B)}const I=JSON.parse(A);if(!I||typeof I!="object"||Array.isArray(I))return;const g=I.version===2;for(const B of["means","scales","quats","sh0"]){if(!I[B]||typeof I[B]!="object"||Array.isArray(I[B]))return;if(g){if(!I[B].files||(B==="scales"||B==="sh0")&&!I[B].codebook||B==="means"&&(!I[B].mins||!I[B].maxs))return}else if(!I[B].shape||!I[B].files||B!=="quats"&&(!I[B].mins||!I[B].maxs))return}return I}catch{return}}function Cc(Q){try{const A=Q instanceof ArrayBuffer?new Uint8Array(Q):Q;let I=null;const g=Hs(A,{filter:({name:C})=>C.split(/[\\/]/).pop()==="meta.json"?(I=C,!0):!1});if(!I)return;const B=Lw(g[I]);return B?{name:I,json:B}:void 0}catch{return}}async function pk({input:Q,extraFiles:A,fileType:I,pathOrUrl:g,splatEncoding:B}){const C=Q instanceof ArrayBuffer?new Uint8Array(Q):Q;let E=I;switch(I||(E=vB(C),!E&&g&&(E=zB(g))),E){case cA.PLY:{const i=new ew({fileBytes:C});await i.parseHeader();const o=i.numSplats,D=EA(o).maxSplats,s={fileBytes:C,packedArray:new Uint32Array(D*4),splatEncoding:B};return await PI(async w=>{const{packedArray:G,numSplats:a,extra:y}=await w.call("unpackPly",s);return{packedArray:G,numSplats:a,extra:y}})}case cA.SPZ:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodeSpz",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});case cA.SPLAT:return await PI(async i=>{const{packedArray:o,numSplats:D}=await i.call("decodeAntiSplat",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D}});case cA.KSPLAT:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodeKsplat",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});case cA.PCSOGS:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodePcSogs",{fileBytes:C,extraFiles:A,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});case cA.PCSOGSZIP:return await PI(async i=>{const{packedArray:o,numSplats:D,extra:s}=await i.call("decodePcSogsZip",{fileBytes:C,splatEncoding:B});return{packedArray:o,numSplats:D,extra:s}});default:throw new Error(`Unknown splat file type: ${E}`)}}class Ec{constructor({maxSplats:A=1}={}){this.numSplats=0,this.maxSplats=EA(A).maxSplats,this.centers=new Float32Array(this.maxSplats*3),this.scales=new Float32Array(this.maxSplats*3),this.quaternions=new Float32Array(this.maxSplats*4),this.opacities=new Float32Array(this.maxSplats),this.colors=new Float32Array(this.maxSplats*3)}pushSplat(){const A=this.numSplats;return this.ensureIndex(A),this.numSplats+=1,A}unpushSplat(A){if(A===this.numSplats-1)this.numSplats-=1;else throw new Error("Cannot unpush splat from non-last position")}ensureCapacity(A){if(A>this.maxSplats){const I=Math.max(A,this.maxSplats*2),g=new Float32Array(I*3),B=new Float32Array(I*3),C=new Float32Array(I*4),E=new Float32Array(I),i=new Float32Array(I*3);if(g.set(this.centers),B.set(this.scales),C.set(this.quaternions),E.set(this.opacities),i.set(this.colors),this.centers=g,this.scales=B,this.quaternions=C,this.opacities=E,this.colors=i,this.sh1){const o=new Float32Array(I*9);o.set(this.sh1),this.sh1=o}if(this.sh2){const o=new Float32Array(I*15);o.set(this.sh2),this.sh2=o}if(this.sh3){const o=new Float32Array(I*21);o.set(this.sh3),this.sh3=o}this.maxSplats=I}}ensureIndex(A){this.ensureCapacity(A+1)}setCenter(A,I,g,B){this.centers[A*3]=I,this.centers[A*3+1]=g,this.centers[A*3+2]=B}setScale(A,I,g,B){this.scales[A*3]=I,this.scales[A*3+1]=g,this.scales[A*3+2]=B}setQuaternion(A,I,g,B,C){this.quaternions[A*4]=I,this.quaternions[A*4+1]=g,this.quaternions[A*4+2]=B,this.quaternions[A*4+3]=C}setOpacity(A,I){this.opacities[A]=I}setColor(A,I,g,B){this.colors[A*3]=I,this.colors[A*3+1]=g,this.colors[A*3+2]=B}setSh1(A,I){this.sh1||(this.sh1=new Float32Array(this.maxSplats*9));for(let g=0;g<9;++g)this.sh1[A*9+g]=I[g]}setSh2(A,I){this.sh2||(this.sh2=new Float32Array(this.maxSplats*15));for(let g=0;g<15;++g)this.sh2[A*15+g]=I[g]}setSh3(A,I){this.sh3||(this.sh3=new Float32Array(this.maxSplats*21));for(let g=0;g<21;++g)this.sh3[A*21+g]=I[g]}}const Ag=class iI{constructor(A={}){this.maxSplats=0,this.numSplats=0,this.packedArray=null,this.maxSh=3,this.isInitialized=!1,this.target=null,this.source=null,this.needsUpdate=!0,this.extra={},this.dyno=new _B({packedSplats:this}),this.dynoRgbMinMaxLnScaleMinMax=new $I({key:"rgbMinMaxLnScaleMinMax",value:new gI(0,1,PA,mA),update:I=>{var g,B,C,E;return I.set(((g=this.splatEncoding)==null?void 0:g.rgbMin)??0,((B=this.splatEncoding)==null?void 0:B.rgbMax)??1,((C=this.splatEncoding)==null?void 0:C.lnScaleMin)??PA,((E=this.splatEncoding)==null?void 0:E.lnScaleMax)??mA),I}}),this.dynoNumSh=new aI({key:"numSh",value:0,update:()=>Math.min(this.getNumSh(),this.maxSh)}),this.dynoShMax=new hI({key:"shMax",value:new F,update:I=>{var g,B,C;return I.set(((g=this.splatEncoding)==null?void 0:g.sh1Max)??1,((B=this.splatEncoding)==null?void 0:B.sh2Max)??1,((C=this.splatEncoding)==null?void 0:C.sh3Max)??1),I}}),this.initialized=Promise.resolve(this),this.reinitialize(A)}reinitialize(A){this.isInitialized=!1,this.extra={},this.maxSplats=A.maxSplats??0,this.splatEncoding=A.splatEncoding,this.lod=A.lod,this.nonLod=A.nonLod,A.url||A.fileBytes||A.stream||A.construct?this.initialized=this.asyncInitialize(A).then(()=>(this.isInitialized=!0,this)):(this.initialize(A),this.isInitialized=!0,this.initialized=Promise.resolve(this))}initialize(A){this.extra=A.extra??{},this.splatEncoding=A.splatEncoding??this.splatEncoding,this.lodSplats=A.lodSplats,A.packedArray?(this.packedArray=A.packedArray,this.numSplats=A.numSplats??this.packedArray.length/4,this.maxSplats=Math.floor(this.packedArray.length/4),this.maxSplats=Math.floor(this.maxSplats/f)*f,this.numSplats=Math.min(this.maxSplats,A.numSplats??Number.POSITIVE_INFINITY)):(this.maxSplats=A.maxSplats??0,this.numSplats=0)}async asyncInitialize(A){const{url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,construct:o,lod:D,nonLod:s,lodAbove:w}=A;this.lod=D,this.nonLod=s;const G=new Hw;if((g||I||E)&&await G.loadInternalAsync({packedSplats:this,url:I,fileBytes:g,fileType:B,fileName:C,stream:E,streamLength:i,onProgress:A.onProgress,lodAbove:w}),o){const a=o(this);a instanceof Promise&&await a}}dispose(){this.target&&(this.target.dispose(),this.target.texture.source.data=null,this.target=null),this.source&&(this.source.dispose(),this.source.source.data=null,this.source=null),this.packedArray=null;for(const A in this.extra){const I=this.extra[A];if(I instanceof l){const g=I.value;g?.isTexture&&(g.dispose(),g.source.data=null)}}this.extra={},this.disposeLodSplats()}prepareFetchSplat(){}getNumSplats(){return this.numSplats}hasRgbDir(){return Math.min(this.getNumSh(),this.maxSh)>0}getNumSh(){return this.extra.sh1?this.extra.sh2?this.extra.sh3?3:2:1:0}setMaxSh(A){this.maxSh=A}fetchSplat({index:A,viewOrigin:I}){let g=ig(this.dyno,A);if(this.hasRgbDir()&&I){const B=ZA(g).outputs.center,C=Kg(yI(B,I)),{sh1Texture:E,sh2Texture:i,sh3Texture:o}=this.ensureShTextures();let{rgb:D}=Yw({coord:qB(A),viewDir:C,numSh:this.dynoNumSh,sh1Texture:E,sh2Texture:i,sh3Texture:o,shMax:this.dynoShMax});D=xA(D,ZA(g).outputs.rgb),g=GI({gsplat:g,rgb:D})}return g}ensureShTextures(){if(!this.extra.sh1)return{};let A=this.extra.sh1Texture;if(!A){let B=this.extra.sh1;const{width:C,height:E,depth:i,maxSplats:o}=EA(B.length/2);if(B.length<o*2){const s=new Uint32Array(o*2);s.set(B),this.extra.sh1=s,B=s}const D=new pA(B,C,E,i);D.format=RQ,D.type=v,D.internalFormat="RG32UI",D.needsUpdate=!0,A=new lA({value:D,key:"sh1"}),this.extra.sh1Texture=A}if(!this.extra.sh2)return{sh1Texture:A};let I=this.extra.sh2Texture;if(!I){let B=this.extra.sh2;const{width:C,height:E,depth:i,maxSplats:o}=EA(B.length/4);if(B.length<o*4){const s=new Uint32Array(o*4);s.set(B),this.extra.sh2=s,B=s}const D=new pA(B,C,E,i);D.format=BA,D.type=v,D.internalFormat="RGBA32UI",D.needsUpdate=!0,I=new lA({value:D,key:"sh2"}),this.extra.sh2Texture=I}if(!this.extra.sh3)return{sh1Texture:A,sh2Texture:I};let g=this.extra.sh3Texture;if(!g){let B=this.extra.sh3;const{width:C,height:E,depth:i,maxSplats:o}=EA(B.length/4);if(B.length<o*4){const s=new Uint32Array(o*4);s.set(B),this.extra.sh3=s,B=s}const D=new pA(B,C,E,i);D.format=BA,D.type=v,D.internalFormat="RGBA32UI",D.needsUpdate=!0,g=new lA({value:D,key:"sh3"}),this.extra.sh3Texture=g}return{sh1Texture:A,sh2Texture:I,sh3Texture:g}}ensureSplats(A){const I=A<=this.maxSplats?this.maxSplats:Math.max(A,2*this.maxSplats),g=this.packedArray?this.packedArray.length/4:0;if(!this.packedArray||I>g){this.maxSplats=EA(I).maxSplats;const B=new Uint32Array(this.maxSplats*4);this.packedArray&&B.set(this.packedArray),this.packedArray=B}return this.packedArray}ensureSplatsSh(A,I){let g,B;if(A===0)return this.ensureSplats(I);if(A===1)g=2,B="sh1";else if(A===2)g=4,B="sh2";else if(A===3)g=4,B="sh3";else throw new Error(`Invalid level: ${A}`);let C=this.extra[B]?this.extra[B].length/g:0;const E=I<=C?C:Math.max(I,2*C);if(!this.extra[B]||E>C){C=EA(E).maxSplats;const i=new Uint32Array(C*g);this.extra[B]&&i.set(this.extra[B]),this.extra[B]=i}return this.extra[B]}getSplat(A){if(!this.packedArray||A>=this.numSplats)throw new Error("Invalid index");return sQ(this.packedArray,A,this.splatEncoding)}setSplat(A,I,g,B,C,E){const i=this.ensureSplats(A+1);gB(i,A,I.x,I.y,I.z,g.x,g.y,g.z,B.x,B.y,B.z,B.w,C,E.r,E.g,E.b),this.numSplats=Math.max(this.numSplats,A+1)}pushSplat(A,I,g,B,C){const E=this.ensureSplats(this.numSplats+1);gB(E,this.numSplats,A.x,A.y,A.z,I.x,I.y,I.z,g.x,g.y,g.z,g.w,B,C.r,C.g,C.b),++this.numSplats}forEachSplat(A){if(!(!this.packedArray||!this.numSplats))for(let I=0;I<this.numSplats;++I){const g=sQ(this.packedArray,I,this.splatEncoding);A(I,g.center,g.scales,g.quaternion,g.opacity,g.color)}}ensureGenerate(A){if(this.target&&(A??1)<=this.maxSplats)return!1;this.target&&this.target.dispose();const I=EA(A??1),{width:g,height:B,depth:C}=I;return this.maxSplats=I.maxSplats,this.target=new FB(g,B,C,{depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,magFilter:og,minFilter:og}),this.target.texture.format=BA,this.target.texture.type=v,this.target.texture.internalFormat="RGBA32UI",this.target.scissorTest=!0,!0}generateMapping(A){let I=0;const g=A.map(B=>{const C=I,E=Math.ceil(B/f)*f;return I+=E,{base:C,count:B}});return{maxSplats:I,mapping:g}}getTexture(){return this.target?this.target.texture:this.source||this.packedArray?this.maybeUpdateSource():iI.getEmptyArray}maybeUpdateSource(){if(!this.packedArray)throw new Error("No packed splats");if(this.needsUpdate||!this.source){if(this.needsUpdate=!1,this.source){const{width:A,height:I,depth:g}=this.source.image;this.maxSplats!==A*I*g&&(this.source.dispose(),this.source=null)}if(this.source)this.packedArray.buffer!==this.source.image.data.buffer&&(this.source.image.data=new Uint8Array(this.packedArray.buffer));else{const{width:A,height:I,depth:g}=EA(this.maxSplats);this.source=new pA(this.packedArray,A,I,g),this.source.format=BA,this.source.type=v,this.source.internalFormat="RGBA32UI",this.source.needsUpdate=!0}this.source.needsUpdate=!0}return this.source}prepareProgramMaterial(A){let I=iI.generatorProgram.get(A);if(!I){const B=JA({index:"int"},{},({index:C},E,{roots:i})=>{A.inputs.index=C;const o=A.outputs.gsplat,D=pB(o,this.dynoRgbMinMaxLnScaleMinMax);i.push(D)});iI.programTemplate||(iI.programTemplate=new ug(hg().computeUvec4Template)),I=new UQ({graph:B,inputs:{index:"_index"},outputs:{output:"target"},template:iI.programTemplate}),Object.assign(I.uniforms,{targetLayer:{value:0},targetBase:{value:0},targetCount:{value:0}}),iI.generatorProgram.set(A,I)}const g=I.prepareMaterial();return iI.fullScreenQuad.material=g,{program:I,material:g}}saveRenderState(A){return{target:A.getRenderTarget(),xrEnabled:A.xr.enabled,autoClear:A.autoClear}}resetRenderState(A,I){A.setRenderTarget(I.target),A.xr.enabled=I.xrEnabled,A.autoClear=I.autoClear}generate({generator:A,base:I,count:g,renderer:B}){if(!this.target)throw new Error("Target must be initialized with ensureSplats");if(I+g>this.maxSplats)throw new Error("Base + count exceeds maxSplats");const{program:C,material:E}=this.prepareProgramMaterial(A);C.update();const i=this.saveRenderState(B),o=Math.ceil((I+g)/f)*f,D=f*zA;for(E.uniforms.targetBase.value=I,E.uniforms.targetCount.value=g;I<o;){const s=Math.floor(I/D);E.uniforms.targetLayer.value=s;const w=s*D,G=Math.floor((I-w)/f),a=Math.min(zA,Math.ceil((o-w)/f));this.target.scissor.set(0,G,f,a-G),B.setRenderTarget(this.target,s),B.xr.enabled=!1,B.autoClear=!1,iI.fullScreenQuad.render(B),I+=f*(a-G)}return this.resetRenderState(B,i),{nextBase:o}}disposeLodSplats(){this.lodSplats&&(this.lodSplats.dispose(),this.lodSplats=void 0)}async createLodSplats({rgbaArray:A,quality:I}={}){const g=typeof this.lod=="number"?Math.max(1.1,Math.min(2,this.lod)):I?1.75:1.5,B=this.packedArray.slice(),C=A?(await A.getArray()).slice():void 0,E={sh1:this.extra.sh1?this.extra.sh1.slice():void 0,sh2:this.extra.sh2?this.extra.sh2.slice():void 0,sh3:this.extra.sh3?this.extra.sh3.slice():void 0},i=await NQ.withWorker(async D=>await D.call(I?"qualityLodPackedSplats":"tinyLodPackedSplats",{numSplats:this.numSplats,packedArray:B,extra:E,lodBase:g,rgba:C,encoding:this.splatEncoding??lg})),o=new iI(i);this.lodSplats&&this.lodSplats.dispose(),this.lodSplats=o,this.nonLod=!0,this.lod=I?"quality":!0}extractSplats(A,I){const g=EA(A.length).maxSplats,B=new iI({maxSplats:g});for(let C=0;C<A.length;C++){const E=this.getSplat(A[C]);if(I){let i=(A[C]>>>16)*.61803398875;i=i-Math.floor(i);const o=Math.max(0,Math.min(1,Math.abs(i*6-3)-1)),D=Math.max(0,Math.min(1,Math.abs(i*6+1)-1)),s=Math.max(0,Math.min(1,Math.abs(i*6-1)-1));E.color.r*=o,E.color.g*=D,E.color.b*=s}B.pushSplat(E.center,E.scales,E.quaternion,E.opacity,E.color)}return B}};Ag.getEmptyArray=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();Ag.programTemplate=null;Ag.generatorProgram=new WeakMap;Ag.fullScreenQuad=new SB(new FQ({visible:!1}));Ag.emptyUint32x4=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*4),C=new pA(B,Q,A,I);return C.format=BA,C.type=v,C.internalFormat="RGBA32UI",C.needsUpdate=!0,C})();Ag.emptyUint32x2=(()=>{const{width:Q,height:A,depth:I,maxSplats:g}=EA(1),B=new Uint32Array(g*2),C=new pA(B,Q,A,I);return C.format=RQ,C.type=v,C.internalFormat="RG32UI",C.needsUpdate=!0,C})();let SI=Ag;class _B extends l{constructor({packedSplats:A}={}){super({key:"packedSplats",type:bg,globals:()=>[MQ],value:{textureArray:SI.getEmptyArray,numSplats:0,rgbMinMaxLnScaleMinMax:new gI(0,1,PA,mA),lodOpacity:!1},update:I=>{var g,B,C,E,i,o,D,s,w,G,a,y;return I.textureArray=((g=this.packedSplats)==null?void 0:g.getTexture())??SI.getEmptyArray,I.numSplats=((B=this.packedSplats)==null?void 0:B.numSplats)??0,I.rgbMinMaxLnScaleMinMax.set(((E=(C=this.packedSplats)==null?void 0:C.splatEncoding)==null?void 0:E.rgbMin)??0,((o=(i=this.packedSplats)==null?void 0:i.splatEncoding)==null?void 0:o.rgbMax)??1,((s=(D=this.packedSplats)==null?void 0:D.splatEncoding)==null?void 0:s.lnScaleMin)??PA,((G=(w=this.packedSplats)==null?void 0:w.splatEncoding)==null?void 0:G.lnScaleMax)??mA),I.lodOpacity=((y=(a=this.packedSplats)==null?void 0:a.splatEncoding)==null?void 0:y.lodOpacity)??!1,I}}),this.packedSplats=A}}const ic=sA(`
11665
11665
  vec3 evaluatePackedSH1(uvec2 packedData, vec3 viewDir, float sh1Max) {
11666
11666
  // Extract sint7 values packed into 2 x uint32
11667
11667
  vec3 sh1_0 = vec3(ivec3(
@@ -11805,7 +11805,7 @@ void main() {
11805
11805
  }
11806
11806
  `);function XQ({gsplat:Q,sortRadial:A,sortOrigin:I,sortDirection:g,sortDepthBias:B,sort360:C}){return SQ({inTypes:{gsplat:X,sortRadial:"bool",sortOrigin:"vec3",sortDirection:"vec3",sortDepthBias:"float",sort360:"bool"},outTypes:{metric:"float"},globals:()=>[rA,wc],inputs:{gsplat:Q,sortRadial:A,sortOrigin:I,sortDirection:g,sortDepthBias:B,sort360:C},statements:({inputs:E,outputs:i})=>{const{gsplat:o,sortRadial:D,sortOrigin:s,sortDirection:w,sortDepthBias:G,sort360:a}=E;return $(`
11807
11807
  ${i.metric} = computeSort(${o}, ${D}, ${s}, ${w}, ${G}, ${a});
11808
- `)}}).outputs.metric}class WQ{constructor(){this.splats=new SI,this.toWorld=new FA,this.mapping=[],this.refCount=0,this.splatsVersion=-1,this.mappingVersion=-1}ensureGenerate(A){this.splats.ensureGenerate(A)&&(this.mapping=[])}generateSplats({renderer:A,modifier:I,generators:g,forceUpdate:B,originToWorld:C}){const E=this.mapping.reduce((D,s)=>(D.set(s.node,s),D),new Map);let i=0,o=0;for(const{node:D,generator:s,version:w,base:G,count:a}of g){const y=E.get(D);if((B||s!==y?.generator||w!==y?.version||G!==y?.base||a!==y?.count)&&s&&a>0){const h=I.apply(s);try{this.splats.generate({generator:h,base:G,count:a,renderer:A})}catch(c){D.generator=void 0,D.generatorError=c}i+=1}o=Math.max(o,G+a)}return this.splats.numSplats=o,this.toWorld.copy(C),this.mapping=g,i!==0}hasCorrespondence(A){return this.mapping.length!==A.mapping.length?!1:this.mapping.every(({node:I,base:g,count:B},C)=>{const{node:E,base:i,count:o}=A.mapping[C];return I===E&&g===i&&B===o})}}const SC=5,rQ=class uA extends QQ{constructor(A){const I=uA.makeUniforms(),g=hg(),B=A.premultipliedAlpha??!0,C=new cB({glslVersion:kB,vertexShader:g.oldSplatVertex,fragmentShader:g.oldSplatFragment,uniforms:I,premultipliedAlpha:B,transparent:!0,depthTest:!0,depthWrite:!1,side:JC});super(tC,C),this.splatTexture=null,this.autoViewpoints=[],this.rotateToAccumulator=new $I({value:new Z}),this.translateToAccumulator=new hI({value:new F}),this.lastFrame=-1,this.lastUpdateTime=null,this.defaultCameras=[],this.lastStochastic=null,this.pendingUpdate={scene:null,originToWorld:new FA,timeoutId:-1},this.envViewpoint=null,this.frustumCulled=!1,this.renderer=A.renderer,this.material=C,this.uniforms=I;const E=JA({gsplat:X},{gsplat:X},({gsplat:i})=>{if(!i)throw new Error("gsplat not defined");return i=dB(i,{rotate:this.rotateToAccumulator,translate:this.translateToAccumulator}),{gsplat:i}});this.modifier=new Ty(E),this.premultipliedAlpha=B,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!1,this.needsUpdate=!1,this.originDistance=A.originDistance??1,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.minPixelRadius=A.minPixelRadius??0,this.maxPixelRadius=A.maxPixelRadius??512,this.minAlpha=A.minAlpha??.5*(1/255),this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.focalDistance=A.focalDistance??0,this.apertureAngle=A.apertureAngle??0,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.focalAdjustment=A.focalAdjustment??1,this.splatEncoding=A.splatEncoding??{...lg},this.active=new WQ,this.active.refCount=1,this.accumulatorCount=1,this.freeAccumulators=[];for(let i=0;i<1;++i)this.freeAccumulators.push(new WQ),this.accumulatorCount+=1;this.defaultView=new FC({...A.view,autoUpdate:!0,spark:this}),this.viewpoint=this.defaultView,this.prepareViewpoint(this.viewpoint),this.clock=A.clock?YB(A.clock):new RB}static makeUniforms(){return{renderSize:{value:new OA},near:{value:.1},far:{value:1e3},numSplats:{value:0},renderToViewQuat:{value:new Z},renderToViewPos:{value:new F},maxStdDev:{value:1},minPixelRadius:{value:0},maxPixelRadius:{value:512},minAlpha:{value:.00196078431372549},stochastic:{value:!1},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},focalDistance:{value:0},apertureAngle:{value:0},falloff:{value:1},clipXY:{value:1.4},focalAdjustment:{value:1},splatTexEnable:{value:!1},splatTexture:{type:"t",value:uA.EMPTY_SPLAT_TEXTURE},splatTexMul:{value:new YC},splatTexAdd:{value:new OA},splatTexNear:{value:.1},splatTexFar:{value:1e3},splatTexMid:{value:0},packedSplats:{type:"t",value:SI.getEmptyArray},rgbMinMaxLnScaleMinMax:{value:new gI},time:{value:0},deltaTime:{value:0},encodeLinear:{value:!1},debugFlag:{value:!1}}}canAllocAccumulator(){return this.freeAccumulators.length>0||this.accumulatorCount<SC}maybeAllocAccumulator(){let A=this.freeAccumulators.pop();if(A===void 0){if(this.accumulatorCount>=SC)return null;A=new WQ,this.accumulatorCount+=1}return A.refCount=1,A}releaseAccumulator(A){A.refCount-=1,A.refCount===0&&this.freeAccumulators.push(A)}newViewpoint(A){return new FC({...A,spark:this})}onBeforeRender(A,I,g){var B,C;const E=this.time??this.clock.getElapsedTime(),i=E-(this.viewpoint.lastTime??E);this.viewpoint.lastTime=E;const o=A.info.render.frame,D=o!==this.lastFrame;this.lastFrame=o;const s=this.viewpoint;if(s===this.defaultView){if(D)if(!A.xr.isPresenting)this.defaultView.viewToWorld=g.matrixWorld.clone(),this.defaultCameras=[this.defaultView.viewToWorld];else{const h=A.xr.getCamera().cameras;this.defaultCameras=h.map(c=>c.matrixWorld),this.defaultView.viewToWorld=sc(this.defaultCameras)??new FA}this.autoUpdate&&this.update({scene:I,viewToWorld:this.defaultView.viewToWorld})}if(D&&(this.material.premultipliedAlpha!==this.premultipliedAlpha&&(this.material.premultipliedAlpha=this.premultipliedAlpha,this.material.needsUpdate=!0),this.uniforms.time.value=E,this.uniforms.deltaTime.value=i,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,s.display&&s.stochastic&&(this.geometry.instanceCount=this.uniforms.numSplats.value)),s.target)this.uniforms.renderSize.value.set(s.target.width,s.target.height);else{const h=A.getDrawingBufferSize(this.uniforms.renderSize.value);if(h.x===1&&h.y===1){const c=(B=A.xr.getSession())==null?void 0:B.renderState.baseLayer;c&&(h.x=c.framebufferWidth,h.y=c.framebufferHeight)}}const w=g;if(this.uniforms.near.value=w.near,this.uniforms.far.value=w.far,this.uniforms.encodeLinear.value=s.encodeLinear,this.uniforms.maxStdDev.value=this.maxStdDev,this.uniforms.minPixelRadius.value=this.minPixelRadius,this.uniforms.maxPixelRadius.value=this.maxPixelRadius,this.uniforms.minAlpha.value=this.minAlpha,this.uniforms.stochastic.value=s.stochastic,this.uniforms.enable2DGS.value=this.enable2DGS,this.uniforms.preBlurAmount.value=this.preBlurAmount,this.uniforms.blurAmount.value=this.blurAmount,this.uniforms.focalDistance.value=this.focalDistance,this.uniforms.apertureAngle.value=this.apertureAngle,this.uniforms.falloff.value=this.falloff,this.uniforms.clipXY.value=this.clipXY,this.uniforms.focalAdjustment.value=this.focalAdjustment,this.lastStochastic!==!s.stochastic&&(this.lastStochastic=!s.stochastic,this.material.transparent=!s.stochastic,this.material.depthWrite=s.stochastic,this.material.needsUpdate=!0),this.splatTexture){const{enable:h,texture:c,multiply:k,add:R,near:t,far:N,mid:S}=this.splatTexture;h&&c?(this.uniforms.splatTexEnable.value=!0,this.uniforms.splatTexture.value=c,k?this.uniforms.splatTexMul.value.fromArray(k.elements):this.uniforms.splatTexMul.value.set(.5/this.maxStdDev,0,0,.5/this.maxStdDev),this.uniforms.splatTexAdd.value.set(R?.x??.5,R?.y??.5),this.uniforms.splatTexNear.value=t??this.uniforms.near.value,this.uniforms.splatTexFar.value=N??this.uniforms.far.value,this.uniforms.splatTexMid.value=S??0):(this.uniforms.splatTexEnable.value=!1,this.uniforms.splatTexture.value=uA.EMPTY_SPLAT_TEXTURE)}else this.uniforms.splatTexEnable.value=!1,this.uniforms.splatTexture.value=uA.EMPTY_SPLAT_TEXTURE;const G=((C=s.display)==null?void 0:C.accumulator.toWorld)??new FA,a=g.matrixWorld.clone().invert();G.clone().premultiply(a).decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,new F)}prepareViewpoint(A){var I,g,B,C;if(this.viewpoint=A??this.viewpoint,this.viewpoint.display){const{accumulator:E,geometry:i}=this.viewpoint.display;this.uniforms.numSplats.value=E.splats.numSplats,this.uniforms.packedSplats.value=E.splats.getTexture(),this.uniforms.rgbMinMaxLnScaleMinMax.value.set(((I=E.splats.splatEncoding)==null?void 0:I.rgbMin)??0,((g=E.splats.splatEncoding)==null?void 0:g.rgbMax)??1,((B=E.splats.splatEncoding)==null?void 0:B.lnScaleMin)??PA,((C=E.splats.splatEncoding)==null?void 0:C.lnScaleMax)??mA),this.geometry=i,this.material.transparent=!this.viewpoint.stochastic,this.material.depthWrite=this.viewpoint.stochastic,this.material.needsUpdate=!0}else this.uniforms.numSplats.value=0,this.uniforms.packedSplats.value=SI.getEmptyArray,this.geometry=tC}update({scene:A,viewToWorld:I}){const g=this.matrixWorld;this.preUpdate?this.updateInternal({scene:A,originToWorld:g.clone(),viewToWorld:I}):(this.pendingUpdate.scene=A,this.pendingUpdate.originToWorld.copy(g),this.pendingUpdate.timeoutId===-1&&(this.pendingUpdate.timeoutId=setTimeout(()=>{const{scene:B,originToWorld:C}=this.pendingUpdate;this.pendingUpdate.scene=null,this.pendingUpdate.timeoutId=-1,this.updateInternal({scene:B,originToWorld:C,viewToWorld:I})&&this.renderer.getContext().flush()},1)))}updateInternal({scene:A,originToWorld:I,viewToWorld:g}){var B;if(!this.canAllocAccumulator())return!1;I||(I=this.active.toWorld),g=g??I.clone();const C=this.time??this.clock.getElapsedTime(),E=C-(this.lastUpdateTime??C);this.lastUpdateTime=C;const i=this.active.mapping.reduce((h,c)=>(h.set(c.node,c),h),new Map),{generators:o,visibleGenerators:D,globalEdits:s}=this.compileScene(A);for(const h of o)(B=h.frameUpdate)==null||B.call(h,{renderer:this.renderer,object:h,time:C,deltaTime:E,viewToWorld:g,globalEdits:s});const w=new Set(D.map(h=>h.uuid));for(const h of o){const c=i.get(h),R=h.generator&&w.has(h.uuid)?h.numSplats:0;(this.needsUpdate||h.generator!==c?.generator||R!==c?.count)&&h.updateVersion()}const G=!aQ({matrix1:I,matrix2:this.active.toWorld,maxDistance:this.originDistance}),a=this.needsUpdate||G||o.length!==i.size||o.some(h=>{var c;return h.version!==((c=i.get(h))==null?void 0:c.version)});this.needsUpdate=!1;let y=null;if(a){if(y=this.maybeAllocAccumulator(),!y)throw new Error("Unreachable");const h=!aQ({matrix1:I,matrix2:y.toWorld,maxDistance:1e-5,minCoorient:.99999}),k=D.map((M,U)=>{const n=i.get(M);return n?[M.version-n.version,n.base,M]:[Number.POSITIVE_INFINITY,M.version,M]}).sort((M,U)=>M[0]!==U[0]?M[0]-U[0]:M[1]-U[1]).map(([M,U,n])=>n),R=k.map(M=>M.numSplats),{maxSplats:t,mapping:N}=y.splats.generateMapping(R),S=k.map((M,U)=>{const{base:n,count:L}=N[U];return{node:M,generator:M.generator,version:M.version,base:n,count:L}});I.clone().invert().decompose(this.translateToAccumulator.value,this.rotateToAccumulator.value,new F),y.ensureGenerate(t),y.splats.splatEncoding={...this.splatEncoding},y.generateSplats({renderer:this.renderer,modifier:this.modifier,generators:S,forceUpdate:h,originToWorld:I}),y.splatsVersion=this.active.splatsVersion+1;const J=y.hasCorrespondence(this.active);y.mappingVersion=this.active.mappingVersion+(J?0:1),this.releaseAccumulator(this.active),this.active=y,this.prepareViewpoint()}return setTimeout(()=>{for(const h of this.autoViewpoints)h.autoPoll({accumulator:y??void 0})},1),!0}compileScene(A){const I=[];A.traverse(C=>{C instanceof jI&&I.push(C)});const g=[];A.traverseVisible(C=>{C instanceof jI&&g.push(C)});const B=new Set;return A.traverseVisible(C=>{if(C instanceof ZB){let E=C.parent;for(;E!=null&&!(E instanceof wI);)E=E.parent;E==null&&B.add(C)}}),{generators:I,visibleGenerators:g,globalEdits:Array.from(B)}}async renderEnvMap({renderer:A,scene:I,worldCenter:g,size:B=256,near:C=.1,far:E=1e3,hideObjects:i=[],update:o=!1}){var D,s;if(this.envViewpoint||(this.envViewpoint=this.newViewpoint({sort360:!0})),!uA.cubeRender||uA.cubeRender.target.width!==B||uA.cubeRender.near!==C||uA.cubeRender.far!==E){uA.cubeRender&&uA.cubeRender.target.dispose();const h=new UC(B,{format:sI,generateMipmaps:!0,minFilter:nC}),c=new eC(C,E,h);uA.cubeRender={target:h,camera:c,near:C,far:E}}uA.pmrem||(uA.pmrem=new HC(A??this.renderer));const w=new FA().setPosition(g);await((D=this.envViewpoint)==null?void 0:D.prepare({scene:I,viewToWorld:w,update:o}));const{target:G,camera:a}=uA.cubeRender;a.position.copy(g);const y=new Map;for(const h of i)y.set(h,h.visible),h.visible=!1;this.prepareViewpoint(this.envViewpoint),a.update(A??this.renderer,I),this.prepareViewpoint(this.defaultView);for(const[h,c]of y.entries())h.visible=c;return(s=uA.pmrem)==null?void 0:s.fromCubemap(G.texture).texture}recurseSetEnvMap(A,I){A.traverse(g=>{if(g instanceof QQ)if(Array.isArray(g.material))for(const B of g.material)B instanceof EQ&&(B.envMap=I);else g.material instanceof EQ&&(g.material.envMap=I)})}getRgba({generator:A,rgba:I}){const g=this.active.mapping.find(({node:B})=>B===A);if(!g)throw new Error("Generator not found");return I=I??new qy,I.fromPackedSplats({packedSplats:this.active.splats,base:g.base,count:g.count,renderer:this.renderer}),I}async readRgba({generator:A,rgba:I}){return I=this.getRgba({generator:A,rgba:I}),I.read()}};rQ.cubeRender=null;rQ.pmrem=null;rQ.EMPTY_SPLAT_TEXTURE=new Es;let Vk=rQ;const tC=new _Q(new Uint32Array(1),0);JA({packedSplats:bg,index:"int"},{gsplat:X},({packedSplats:Q,index:A})=>{if(!Q||!A)throw new Error("Invalid input");return{gsplat:ig(Q,A)}});function sc(Q){if(Q.length===0)return null;const A=new F,I=new Z,g=new F,B=[],C=[];for(const E of Q)E.decompose(A,I,g),B.push(A),C.push(I);return new FA().compose(CE(B),EE(C),new F(1,1,1))}function Gc(Q,A,I){const g=Math.floor(Q.length/32);if(g*32!==Q.length)throw new Error("Invalid .splat file size");const B=new Float32Array(Q.buffer);for(let C=0;C<g;++C){const E=C*32,i=C*8,o=B[i+0],D=B[i+1],s=B[i+2],w=B[i+3],G=B[i+4],a=B[i+5],y=Q[E+24]/255,h=Q[E+25]/255,c=Q[E+26]/255,k=Q[E+27]/255,R=(Q[E+28]-128)/128,t=(Q[E+29]-128)/128,N=(Q[E+30]-128)/128,S=(Q[E+31]-128)/128;I(C,o,D,s,w,G,a,t,N,S,R,k,y,h,c)}}const NC={0:{bytesPerCenter:12,bytesPerScale:12,bytesPerRotation:16,bytesPerColor:4,bytesPerSphericalHarmonicsComponent:4,scaleOffsetBytes:12,rotationOffsetBytes:24,colorOffsetBytes:40,sphericalHarmonicsOffsetBytes:44,scaleRange:1},1:{bytesPerCenter:6,bytesPerScale:6,bytesPerRotation:8,bytesPerColor:4,bytesPerSphericalHarmonicsComponent:2,scaleOffsetBytes:6,rotationOffsetBytes:12,colorOffsetBytes:20,sphericalHarmonicsOffsetBytes:24,scaleRange:32767},2:{bytesPerCenter:6,bytesPerScale:6,bytesPerRotation:8,bytesPerColor:4,bytesPerSphericalHarmonicsComponent:1,scaleOffsetBytes:6,rotationOffsetBytes:12,colorOffsetBytes:20,sphericalHarmonicsOffsetBytes:24,scaleRange:32767}},ac={0:0,1:9,2:24,3:45};function hc(Q,A,I,g){var B;let i=0;const o=new DataView(Q.buffer,i,4096);i+=4096;const D=o.getUint8(0),s=o.getUint8(1);if(D!==0||s<1)throw new Error(`Unsupported .ksplat version: ${D}.${s}`);const w=o.getUint32(4,!0);o.getUint32(16,!0);const G=o.getUint16(20,!0);if(G<0||G>2)throw new Error(`Invalid .ksplat compression level: ${G}`);const a=o.getFloat32(36,!0)||-1.5,y=o.getFloat32(40,!0)||1.5;let h=4096+w*1024;for(let c=0;c<w;++c){let k=function(WA,gA){if(G===0)return IA.getFloat32(WA+b+gA*4,!0);if(G===1)return MA(IA.getUint16(WA+b+gA*2,!0));const NI=IA.getUint8(WA+b+gA)/255;return a+NI*(y-a)};const R=new DataView(Q.buffer,i,1024);i+=1024;const t=R.getUint32(0,!0),N=R.getUint32(4,!0),S=R.getUint32(8,!0),J=R.getUint32(12,!0),M=R.getFloat32(16,!0),U=R.getUint16(20,!0),n=(R.getUint32(24,!0)||((B=NC[G])==null?void 0:B.scaleRange))??1,L=R.getUint32(32,!0),H=L*S,e=R.getUint32(36,!0),q=e*4,Y=U*J+q,K=R.getUint16(40,!0),x=ac[K],{bytesPerCenter:m,bytesPerScale:j,bytesPerRotation:u,bytesPerColor:CA,bytesPerSphericalHarmonicsComponent:V,scaleOffsetBytes:AA,rotationOffsetBytes:O,colorOffsetBytes:P,sphericalHarmonicsOffsetBytes:b}=NC[G],T=m+j+u+CA+x*V,p=T*N,SA=p+Y,GA=[0,3,6,1,4,7,2,5,8],tA=[9,14,19,10,15,20,11,16,21,12,17,22,13,18,23],NA=[24,31,38,25,32,39,26,33,40,27,34,41,28,35,42,29,36,43,30,37,44],wA=K>=1?new Float32Array(9):void 0,aA=K>=2?new Float32Array(15):void 0,CI=K>=3?new Float32Array(21):void 0,VA=M/2/n,eI=h+q,HI=h+Y,IA=new DataView(Q.buffer,HI,p),XA=new Float32Array(Q.buffer,eI,J*3),KA=new Uint32Array(Q.buffer,h,e);let cg=L,Pg=H;for(let WA=0;WA<t;++WA){const gA=WA*T;let NI;if(WA<H)NI=Math.floor(WA/S);else{const LI=KA[cg-L];WA>=Pg+LI&&(cg+=1,Pg+=LI),NI=cg}const lQ=G===0?IA.getFloat32(gA+0,!0):(IA.getUint16(gA+0,!0)-n)*VA+XA[3*NI+0],xQ=G===0?IA.getFloat32(gA+4,!0):(IA.getUint16(gA+2,!0)-n)*VA+XA[3*NI+1],pQ=G===0?IA.getFloat32(gA+8,!0):(IA.getUint16(gA+4,!0)-n)*VA+XA[3*NI+2],fQ=G===0?IA.getFloat32(gA+AA+0,!0):MA(IA.getUint16(gA+AA+0,!0)),bQ=G===0?IA.getFloat32(gA+AA+4,!0):MA(IA.getUint16(gA+AA+2,!0)),bw=G===0?IA.getFloat32(gA+AA+8,!0):MA(IA.getUint16(gA+AA+4,!0)),uw=G===0?IA.getFloat32(gA+O+0,!0):MA(IA.getUint16(gA+O+0,!0)),Pw=G===0?IA.getFloat32(gA+O+4,!0):MA(IA.getUint16(gA+O+2,!0)),mw=G===0?IA.getFloat32(gA+O+8,!0):MA(IA.getUint16(gA+O+4,!0)),Tw=G===0?IA.getFloat32(gA+O+12,!0):MA(IA.getUint16(gA+O+6,!0)),Ow=IA.getUint8(gA+P+0)/255,Zw=IA.getUint8(gA+P+1)/255,Vw=IA.getUint8(gA+P+2)/255,Xw=IA.getUint8(gA+P+3)/255;if(I(WA,lQ,xQ,pQ,fQ,bQ,bw,Pw,mw,Tw,uw,Xw,Ow,Zw,Vw),K>=1&&wA){for(const[LI,kg]of GA.entries())wA[LI]=k(gA,kg);if(aA)for(const[LI,kg]of tA.entries())aA[LI]=k(gA,kg);if(CI)for(const[LI,kg]of NA.entries())CI[LI]=k(gA,kg);g?.(WA,wA,aA,CI)}}h+=SA}}class yc{constructor({fileBytes:A}){this.version=-1,this.numSplats=0,this.shDegree=0,this.fractionalBits=0,this.flags=0,this.flagAntiAlias=!1,this.flagLod=!1,this.reserved=0,this.headerParsed=!1,this.parsed=!1,this.fileBytes=A instanceof ArrayBuffer?new Uint8Array(A):A,this.reader=new aE({fileBytes:this.fileBytes})}async parseHeader(){if(this.headerParsed)throw new Error("SPZ file header already parsed");const A=new DataView((await this.reader.read(16)).buffer);if(A.getUint32(0,!0)!==1347635022)throw new Error("Invalid SPZ file");if(this.version=A.getUint32(4,!0),this.version<1||this.version>3)throw new Error(`Unsupported SPZ version: ${this.version}`);this.numSplats=A.getUint32(8,!0),this.shDegree=A.getUint8(12),this.fractionalBits=A.getUint8(13),this.flags=A.getUint8(14),this.flagAntiAlias=(this.flags&1)!==0,this.flagLod=(this.flags&128)!==0,this.reserved=A.getUint8(15),this.headerParsed=!0,this.parsed=!1}async parseSplats(A,I,g,B,C,E,{childCounts:i,childStarts:o}={}){if(!this.headerParsed)throw new Error("SPZ file header must be parsed first");if(this.parsed)throw new Error("SPZ file already parsed");if(this.parsed=!0,this.version===1){const D=await this.reader.read(this.numSplats*3*2),s=new Uint16Array(D.buffer);for(let w=0;w<this.numSplats;w++){const G=w*3,a=MA(s[G]),y=MA(s[G+1]),h=MA(s[G+2]);A?.(w,a,y,h)}}else if(this.version===2||this.version===3){const D=1<<this.fractionalBits,s=await this.reader.read(this.numSplats*3*3);for(let w=0;w<this.numSplats;w++){const G=w*9,a=((s[G+2]<<24|s[G+1]<<16|s[G]<<8)>>8)/D,y=((s[G+5]<<24|s[G+4]<<16|s[G+3]<<8)>>8)/D,h=((s[G+8]<<24|s[G+7]<<16|s[G+6]<<8)>>8)/D;A?.(w,a,y,h)}}else throw new Error("Unreachable");{const D=await this.reader.read(this.numSplats);for(let s=0;s<this.numSplats;s++)I?.(s,D[s]/255)}{const D=await this.reader.read(this.numSplats*3),s=Kw/.15;for(let w=0;w<this.numSplats;w++){const G=w*3,a=(D[G]/255-.5)*s+.5,y=(D[G+1]/255-.5)*s+.5,h=(D[G+2]/255-.5)*s+.5;g?.(w,a,y,h)}}{const D=await this.reader.read(this.numSplats*3);for(let s=0;s<this.numSplats;s++){const w=s*3,G=Math.exp(D[w]/16-10),a=Math.exp(D[w+1]/16-10),y=Math.exp(D[w+2]/16-10);B?.(s,G,a,y)}}if(this.version===3){const D=1/Math.sqrt(2),s=await this.reader.read(this.numSplats*4);for(let w=0;w<this.numSplats;w++){const G=w*4,a=[0,0,0,0],y=[s[G],s[G+1],s[G+2],s[G+3]],h=y[0]+(y[1]<<8)+(y[2]<<16)+(y[3]<<24),c=511,k=h>>>30;let R=h,t=0;for(let S=3;S>=0;--S)if(S!==k){const J=R&c,M=R>>>9&1;R=R>>>10,a[S]=D*(J/c),a[S]=M===0?a[S]:-a[S],t+=a[S]*a[S]}const N=1-t;a[k]=Math.sqrt(Math.max(N,0)),C?.(w,a[0],a[1],a[2],a[3])}}else{const D=await this.reader.read(this.numSplats*3);for(let s=0;s<this.numSplats;s++){const w=s*3,G=D[w]/127.5-1,a=D[w+1]/127.5-1,y=D[w+2]/127.5-1,h=Math.sqrt(Math.max(0,1-G*G-a*a-y*y));C?.(s,G,a,y,h)}}if(E&&this.shDegree>=1){const D=new Float32Array(9),s=this.shDegree>=2?new Float32Array(15):void 0,w=this.shDegree>=3?new Float32Array(21):void 0,G=await this.reader.read(this.numSplats*rw[this.shDegree]*3);let a=0;for(let y=0;y<this.numSplats;y++){for(let h=0;h<9;++h)D[h]=(G[a+h]-128)/128;if(a+=9,s){for(let h=0;h<15;++h)s[h]=(G[a+h]-128)/128;a+=15}if(w){for(let h=0;h<21;++h)w[h]=(G[a+h]-128)/128;a+=21}E?.(y,D,s,w)}}if(this.flagLod){let D=await this.reader.read(this.numSplats*2);for(let s=0;s<this.numSplats;s++){const w=s*2,G=D[w]+(D[w+1]<<8);i?.(s,G)}D=await this.reader.read(this.numSplats*4);for(let s=0;s<this.numSplats;s++){const w=s*4,G=D[w]+(D[w+1]<<8)+(D[w+2]<<16)+(D[w+3]<<24);o?.(s,G)}}}}const rw={1:3,2:8,3:15},Kw=.28209479177387814,cc=1347635022,kc=3,Rc=1;class KI{constructor({numSplats:A,shDegree:I,fractionalBits:g=12,flagAntiAlias:B=!0}){this.clippedCount=0;const C=20+(I>=1?9:0)+(I>=2?15:0)+(I>=3?21:0),E=16+A*C;this.buffer=new ArrayBuffer(E),this.view=new DataView(this.buffer),this.view.setUint32(0,cc,!0),this.view.setUint32(4,kc,!0),this.view.setUint32(8,A,!0),this.view.setUint8(12,I),this.view.setUint8(13,g),this.view.setUint8(14,B?Rc:0),this.view.setUint8(15,0),this.numSplats=A,this.shDegree=I,this.fractionalBits=g,this.fraction=1<<g,this.flagAntiAlias=B}setCenter(A,I,g,B){const C=Math.round(I*this.fraction),E=Math.max(-8388607,Math.min(8388607,C)),i=Math.round(g*this.fraction),o=Math.max(-8388607,Math.min(8388607,i)),D=Math.round(B*this.fraction),s=Math.max(-8388607,Math.min(8388607,D));(C!==E||i!==o||D!==s)&&(this.clippedCount+=1);const a=16+A*9;this.view.setUint8(a,E&255),this.view.setUint8(a+1,E>>8&255),this.view.setUint8(a+2,E>>16&255),this.view.setUint8(a+3,o&255),this.view.setUint8(a+4,o>>8&255),this.view.setUint8(a+5,o>>16&255),this.view.setUint8(a+6,s&255),this.view.setUint8(a+7,s>>8&255),this.view.setUint8(a+8,s>>16&255)}setAlpha(A,I){const g=16+this.numSplats*9+A;this.view.setUint8(g,Math.max(0,Math.min(255,Math.round(I*255))))}static scaleRgb(A){const I=((A-.5)/(Kw/.15)+.5)*255;return Math.max(0,Math.min(255,Math.round(I)))}setRgb(A,I,g,B){const C=16+this.numSplats*10+A*3;this.view.setUint8(C,KI.scaleRgb(I)),this.view.setUint8(C+1,KI.scaleRgb(g)),this.view.setUint8(C+2,KI.scaleRgb(B))}setScale(A,I,g,B){const C=16+this.numSplats*13+A*3;this.view.setUint8(C,Math.max(0,Math.min(255,Math.round((Math.log(I)+10)*16)))),this.view.setUint8(C+1,Math.max(0,Math.min(255,Math.round((Math.log(g)+10)*16)))),this.view.setUint8(C+2,Math.max(0,Math.min(255,Math.round((Math.log(B)+10)*16))))}setQuat(A,...I){const g=16+this.numSplats*16+A*4,B=AE(I);let C=0;for(let o=1;o<4;++o)Math.abs(B[o])>Math.abs(B[C])&&(C=o);const E=B[C]<0?1:0;let i=C;for(let o=0;o<4;++o)if(o!==C){const D=(B[o]<0?1:0)^E,s=Math.floor(511*(Math.abs(B[o])/Math.SQRT1_2)+.5);i=i<<10|D<<9|s}this.view.setUint8(g,i&255),this.view.setUint8(g+1,i>>8&255),this.view.setUint8(g+2,i>>16&255),this.view.setUint8(g+3,i>>>24&255)}static quantizeSh(A,I){const g=Math.round(A*128)+128,B=1<<8-I,C=Math.floor((g+B/2)/B)*B;return Math.max(0,Math.min(255,C))}setSh(A,I,g,B){const C=rw[this.shDegree]||0,E=16+this.numSplats*20+A*C*3;for(let i=0;i<9;++i)this.view.setUint8(E+i,KI.quantizeSh(I[i],5));if(g){const i=E+9;for(let o=0;o<15;++o)this.view.setUint8(i+o,KI.quantizeSh(g[o],4));if(B){const o=i+15;for(let D=0;D<21;++D)this.view.setUint8(o+D,KI.quantizeSh(B[D],4))}}}async finalize(){const A=new Uint8Array(this.buffer),g=new ReadableStream({async start(E){E.enqueue(A),E.close()}}).pipeThrough(new CompressionStream("gzip")),C=await new Response(g).arrayBuffer();return console.log("Compressed",A.length,"bytes to",C.byteLength,"bytes"),new Uint8Array(C)}}async function Xk(Q){var A,I,g;const B=new Ec,{inputs:C,clipXyz:E,maxSh:i,fractionalBits:o=12,opacityThreshold:D}=Q;for(const a of C){let y=function(U){return U.multiplyScalar(t),U.applyQuaternion(N),U.add(S),U},h=function(U){return U.multiplyScalar(t),U},c=function(U){return U.premultiply(N),U},k=function(U){return!J||J.containsPoint(U)},R=function(U){return D!==void 0?U>=D:!0};const t=((A=a.transform)==null?void 0:A.scale)??1,N=new Z().fromArray(((I=a.transform)==null?void 0:I.quaternion)??[0,0,0,1]),S=new F().fromArray(((g=a.transform)==null?void 0:g.translate)??[0,0,0]),J=E?new dg(new F().fromArray(E.min),new F().fromArray(E.max)):void 0;let M=a.fileType;switch(M||(M=vB(a.fileBytes),!M&&a.pathOrUrl&&(M=zB(a.pathOrUrl))),M){case cA.PLY:{const U=new ew({fileBytes:a.fileBytes});await U.parseHeader();let n=null;U.parseSplats((L,H,e,q,Y,K,x,m,j,u,CA,V,AA,O,P)=>{const b=y(new F(H,e,q));if(k(b)&&R(V)){n=B.pushSplat(),B.setCenter(n,b.x,b.y,b.z);const T=h(new F(Y,K,x));B.setScale(n,T.x,T.y,T.z);const p=c(new Z(m,j,u,CA));B.setQuaternion(n,p.x,p.y,p.z,p.w),B.setOpacity(n,V),B.setColor(n,AA,O,P)}else n=null},(L,H,e,q)=>{H&&n!==null&&B.setSh1(n,H),e&&n!==null&&B.setSh2(n,e),q&&n!==null&&B.setSh3(n,q)});break}case cA.SPZ:{const U=new yc({fileBytes:a.fileBytes});await U.parseHeader();const n=new Int32Array(U.numSplats);n.fill(-1);const L=new Float32Array(U.numSplats*3),H=new F;U.parseSplats((e,q,Y,K)=>{const x=y(new F(q,Y,K));L[e*3]=x.x,L[e*3+1]=x.y,L[e*3+2]=x.z},(e,q)=>{H.fromArray(L,e*3),k(H)&&R(q)&&(n[e]=B.pushSplat(),B.setCenter(n[e],H.x,H.y,H.z),B.setOpacity(n[e],q))},(e,q,Y,K)=>{n[e]>=0&&B.setColor(n[e],q,Y,K)},(e,q,Y,K)=>{if(n[e]>=0){const x=h(new F(q,Y,K));B.setScale(n[e],x.x,x.y,x.z)}},(e,q,Y,K,x)=>{if(n[e]>=0){const m=c(new Z(q,Y,K,x));B.setQuaternion(n[e],m.x,m.y,m.z,m.w)}},(e,q,Y,K)=>{n[e]>=0&&(B.setSh1(n[e],q),Y&&B.setSh2(n[e],Y),K&&B.setSh3(n[e],K))});break}case cA.SPLAT:Gc(a.fileBytes,U=>{},(U,n,L,H,e,q,Y,K,x,m,j,u,CA,V,AA)=>{const O=y(new F(n,L,H));if(k(O)&&R(u)){const P=B.pushSplat();B.setCenter(P,O.x,O.y,O.z);const b=h(new F(e,q,Y));B.setScale(P,b.x,b.y,b.z);const T=c(new Z(K,x,m,j));B.setQuaternion(P,T.x,T.y,T.z,T.w),B.setOpacity(P,u),B.setColor(P,CA,V,AA)}});break;case cA.KSPLAT:{let U=null;hc(a.fileBytes,n=>{},(n,L,H,e,q,Y,K,x,m,j,u,CA,V,AA,O)=>{const P=y(new F(L,H,e));if(k(P)&&R(CA)){U=B.pushSplat(),B.setCenter(U,P.x,P.y,P.z);const b=h(new F(q,Y,K));B.setScale(U,b.x,b.y,b.z);const T=c(new Z(x,m,j,u));B.setQuaternion(U,T.x,T.y,T.z,T.w),B.setOpacity(U,CA),B.setColor(U,V,AA,O)}else U=null},(n,L,H,e)=>{U!==null&&(B.setSh1(U,L),H&&B.setSh2(U,H),e&&B.setSh3(U,e))});break}default:throw new Error(`transcodeSpz not implemented for ${M}`)}}const s=Math.min(i??3,B.sh3?3:B.sh2?2:B.sh1?1:0),w=new KI({numSplats:B.numSplats,shDegree:s,fractionalBits:o,flagAntiAlias:!0});for(let a=0;a<B.numSplats;++a){const y=a*3,h=a*4;w.setCenter(a,B.centers[y],B.centers[y+1],B.centers[y+2]),w.setScale(a,B.scales[y],B.scales[y+1],B.scales[y+2]),w.setQuat(a,B.quaternions[h],B.quaternions[h+1],B.quaternions[h+2],B.quaternions[h+3]),w.setAlpha(a,B.opacities[a]),w.setRgb(a,B.colors[y],B.colors[y+1],B.colors[y+2]),B.sh1&&s>=1&&w.setSh(a,B.sh1.slice(a*9,(a+1)*9),s>=2&&B.sh2?B.sh2.slice(a*15,(a+1)*15):void 0,s>=3&&B.sh3?B.sh3.slice(a*21,(a+1)*21):void 0)}return{fileBytes:await w.finalize(),clippedCount:w.clippedCount}}var Fc=(Q=>(Q.DUAL_QUATERNION="dual_quaternion",Q.LINEAR_BLEND="linear_blend",Q))(Fc||{});const yg=class z{constructor(A){this.mesh=A.mesh,this.numSplats=A.numSplats??this.mesh.numSplats,this.mode=A.mode??"dual_quaternion";const{width:I,height:g,depth:B,maxSplats:C}=EA(this.numSplats);this.skinData=new Uint16Array(C*4),this.skinTexture=new pA(this.skinData,I,g,B),this.skinTexture.format=BA,this.skinTexture.type=_w,this.skinTexture.internalFormat="RGBA16UI",this.skinTexture.needsUpdate=!0,this.numBones=A.numBones??256,this.boneData=new Float32Array(this.numBones*16),this.boneTexture=new lI(this.boneData,4,this.numBones,sI,$w),this.boneTexture.internalFormat="RGBA32F",this.boneTexture.needsUpdate=!0,this.boneRestQuatPosScale=AB(this.numBones,()=>({quat:new Z,pos:new F,scale:new F})),this.mode==="linear_blend"?this.boneRestInvMats=AB(this.numBones,()=>new FA):this.boneRestInvMats=[],this.uniform=new l({key:"skinning",type:KQ,globals:()=>[dQ],value:{numSplats:this.numSplats,numBones:this.numBones,skinTexture:this.skinTexture,boneTexture:this.boneTexture}})}modify(A){if(this.mode==="linear_blend")throw new Error("Linear blend skinning requires covSplats=true");return tc(A,this.uniform)}modifyCov(A){return this.mode==="dual_quaternion"?Jc(A,this.uniform):Uc(A,this.uniform)}setRestQuatPos(A,I,g){this.boneRestQuatPosScale[A].quat.copy(I),this.boneRestQuatPosScale[A].pos.copy(g),this.boneRestQuatPosScale[A].scale.copy(z.UNIT_SCALE),this.mode==="linear_blend"&&this.boneRestInvMats[A].compose(g,I,z.UNIT_SCALE).invert(),this.setBoneQuatPos(A,I,g)}getRestQuatPos(A,I,g){I.copy(this.boneRestQuatPosScale[A].quat),g.copy(this.boneRestQuatPosScale[A].pos)}setRestQuatPosScale(A,I,g,B){this.boneRestQuatPosScale[A].quat.copy(I),this.boneRestQuatPosScale[A].pos.copy(g),this.boneRestQuatPosScale[A].scale.copy(B),this.mode==="linear_blend"&&this.boneRestInvMats[A].compose(g,I,B).invert(),this.setBoneQuatPosScale(A,I,g,B)}getRestQuatPosScale(A,I,g,B){I.copy(this.boneRestQuatPosScale[A].quat),g.copy(this.boneRestQuatPosScale[A].pos),B.copy(this.boneRestQuatPosScale[A].scale)}setRestMatrix(A,I){if(this.mode!=="linear_blend")throw new Error("setRestMat only supported for linear blend skinning");this.boneRestInvMats[A].copy(I).invert(),this.setBoneMatrix(A,I)}getRestMatrix(A,I){if(this.mode!=="linear_blend")throw new Error("getRestMat only supported for linear blend skinning");I.copy(this.boneRestInvMats[A]).invert()}setBoneQuatPos(A,I,g){if(this.mode==="dual_quaternion"){z.relQuat.copy(this.boneRestQuatPosScale[A].quat).invert(),z.relPos.copy(g).sub(this.boneRestQuatPosScale[A].pos),z.relQuat.multiply(I),z.dual.set(z.relPos.x,z.relPos.y,z.relPos.z,0).multiply(z.relQuat);const B=A*16;this.boneData[B+0]=z.relQuat.x,this.boneData[B+1]=z.relQuat.y,this.boneData[B+2]=z.relQuat.z,this.boneData[B+3]=z.relQuat.w,this.boneData[B+4]=.5*z.dual.x,this.boneData[B+5]=.5*z.dual.y,this.boneData[B+6]=.5*z.dual.z,this.boneData[B+7]=.5*z.dual.w}else this.setBoneQuatPosScale(A,I,g,z.UNIT_SCALE)}setBoneQuatPosScale(A,I,g,B){if(this.mode==="dual_quaternion")throw new Error("setBoneQuatPosScale only supported for linear blend skinning");z.skinMat.compose(g,I,B),this.setBoneMatrix(A,z.skinMat)}setBoneMatrix(A,I){if(this.mode!=="linear_blend")throw new Error("setBoneMatrix only supported for linear blend skinning");z.skinMat.multiplyMatrices(this.boneRestInvMats[A],I);const g=A*16;this.boneData[g+0]=z.skinMat.elements[0],this.boneData[g+1]=z.skinMat.elements[1],this.boneData[g+2]=z.skinMat.elements[2],this.boneData[g+3]=z.skinMat.elements[4],this.boneData[g+4]=z.skinMat.elements[5],this.boneData[g+5]=z.skinMat.elements[6],this.boneData[g+6]=z.skinMat.elements[8],this.boneData[g+7]=z.skinMat.elements[9],this.boneData[g+8]=z.skinMat.elements[10],this.boneData[g+9]=z.skinMat.elements[12],this.boneData[g+10]=z.skinMat.elements[13],this.boneData[g+11]=z.skinMat.elements[14]}setSplatBones(A,I,g){const B=A*4;this.skinData[B+0]=Math.min(255,Math.max(0,Math.round(g.x*255)))+(I.x<<8),this.skinData[B+1]=Math.min(255,Math.max(0,Math.round(g.y*255)))+(I.y<<8),this.skinData[B+2]=Math.min(255,Math.max(0,Math.round(g.z*255)))+(I.z<<8),this.skinData[B+3]=Math.min(255,Math.max(0,Math.round(g.w*255)))+(I.w<<8)}updateBones(){this.boneTexture.needsUpdate=!0,this.mesh.needsUpdate=!0}};yg.UNIT_SCALE=new F(1,1,1);yg.relQuat=new Z;yg.relPos=new F;yg.dual=new Z;yg.skinMat=new FA;let Wk=yg;const KQ={type:"GsplatSkinning"},dQ=sA(`
11808
+ `)}}).outputs.metric}class WQ{constructor(){this.splats=new SI,this.toWorld=new FA,this.mapping=[],this.refCount=0,this.splatsVersion=-1,this.mappingVersion=-1}ensureGenerate(A){this.splats.ensureGenerate(A)&&(this.mapping=[])}generateSplats({renderer:A,modifier:I,generators:g,forceUpdate:B,originToWorld:C}){const E=this.mapping.reduce((D,s)=>(D.set(s.node,s),D),new Map);let i=0,o=0;for(const{node:D,generator:s,version:w,base:G,count:a}of g){const y=E.get(D);if((B||s!==y?.generator||w!==y?.version||G!==y?.base||a!==y?.count)&&s&&a>0){const h=I.apply(s);try{this.splats.generate({generator:h,base:G,count:a,renderer:A})}catch(c){D.generator=void 0,D.generatorError=c}i+=1}o=Math.max(o,G+a)}return this.splats.numSplats=o,this.toWorld.copy(C),this.mapping=g,i!==0}hasCorrespondence(A){return this.mapping.length!==A.mapping.length?!1:this.mapping.every(({node:I,base:g,count:B},C)=>{const{node:E,base:i,count:o}=A.mapping[C];return I===E&&g===i&&B===o})}}const SC=5,rQ=class uA extends QQ{constructor(A){const I=uA.makeUniforms(),g=hg(),B=A.premultipliedAlpha??!0,C=new cB({glslVersion:kB,vertexShader:g.oldSplatVertex,fragmentShader:g.oldSplatFragment,uniforms:I,premultipliedAlpha:B,transparent:!0,depthTest:!0,depthWrite:!1,side:JC});super(tC,C),this.splatTexture=null,this.autoViewpoints=[],this.rotateToAccumulator=new $I({value:new Z}),this.translateToAccumulator=new hI({value:new F}),this.lastFrame=-1,this.lastUpdateTime=null,this.defaultCameras=[],this.lastStochastic=null,this.pendingUpdate={scene:null,originToWorld:new FA,timeoutId:-1},this.envViewpoint=null,this.frustumCulled=!1,this.renderer=A.renderer,this.material=C,this.uniforms=I;const E=JA({gsplat:X},{gsplat:X},({gsplat:i})=>{if(!i)throw new Error("gsplat not defined");return i=dB(i,{rotate:this.rotateToAccumulator,translate:this.translateToAccumulator}),{gsplat:i}});this.modifier=new Ty(E),this.premultipliedAlpha=B,this.autoUpdate=A.autoUpdate??!0,this.preUpdate=A.preUpdate??!1,this.needsUpdate=!1,this.originDistance=A.originDistance??1,this.maxStdDev=A.maxStdDev??Math.sqrt(8),this.minPixelRadius=A.minPixelRadius??0,this.maxPixelRadius=A.maxPixelRadius??512,this.minAlpha=A.minAlpha??.5*(1/255),this.enable2DGS=A.enable2DGS??!1,this.preBlurAmount=A.preBlurAmount??0,this.blurAmount=A.blurAmount??.3,this.focalDistance=A.focalDistance??0,this.apertureAngle=A.apertureAngle??0,this.falloff=A.falloff??1,this.clipXY=A.clipXY??1.4,this.focalAdjustment=A.focalAdjustment??1,this.splatEncoding=A.splatEncoding??{...lg},this.active=new WQ,this.active.refCount=1,this.accumulatorCount=1,this.freeAccumulators=[];for(let i=0;i<1;++i)this.freeAccumulators.push(new WQ),this.accumulatorCount+=1;this.defaultView=new FC({...A.view,autoUpdate:!0,spark:this}),this.viewpoint=this.defaultView,this.prepareViewpoint(this.viewpoint),this.clock=A.clock?YB(A.clock):new RB}static makeUniforms(){return{renderSize:{value:new OA},near:{value:.1},far:{value:1e3},numSplats:{value:0},renderToViewQuat:{value:new Z},renderToViewPos:{value:new F},maxStdDev:{value:1},minPixelRadius:{value:0},maxPixelRadius:{value:512},minAlpha:{value:.00196078431372549},stochastic:{value:!1},enable2DGS:{value:!1},preBlurAmount:{value:0},blurAmount:{value:.3},focalDistance:{value:0},apertureAngle:{value:0},falloff:{value:1},clipXY:{value:1.4},focalAdjustment:{value:1},splatTexEnable:{value:!1},splatTexture:{type:"t",value:uA.EMPTY_SPLAT_TEXTURE},splatTexMul:{value:new LC},splatTexAdd:{value:new OA},splatTexNear:{value:.1},splatTexFar:{value:1e3},splatTexMid:{value:0},packedSplats:{type:"t",value:SI.getEmptyArray},rgbMinMaxLnScaleMinMax:{value:new gI},time:{value:0},deltaTime:{value:0},encodeLinear:{value:!1},debugFlag:{value:!1}}}canAllocAccumulator(){return this.freeAccumulators.length>0||this.accumulatorCount<SC}maybeAllocAccumulator(){let A=this.freeAccumulators.pop();if(A===void 0){if(this.accumulatorCount>=SC)return null;A=new WQ,this.accumulatorCount+=1}return A.refCount=1,A}releaseAccumulator(A){A.refCount-=1,A.refCount===0&&this.freeAccumulators.push(A)}newViewpoint(A){return new FC({...A,spark:this})}onBeforeRender(A,I,g){var B,C;const E=this.time??this.clock.getElapsedTime(),i=E-(this.viewpoint.lastTime??E);this.viewpoint.lastTime=E;const o=A.info.render.frame,D=o!==this.lastFrame;this.lastFrame=o;const s=this.viewpoint;if(s===this.defaultView){if(D)if(!A.xr.isPresenting)this.defaultView.viewToWorld=g.matrixWorld.clone(),this.defaultCameras=[this.defaultView.viewToWorld];else{const h=A.xr.getCamera().cameras;this.defaultCameras=h.map(c=>c.matrixWorld),this.defaultView.viewToWorld=sc(this.defaultCameras)??new FA}this.autoUpdate&&this.update({scene:I,viewToWorld:this.defaultView.viewToWorld})}if(D&&(this.material.premultipliedAlpha!==this.premultipliedAlpha&&(this.material.premultipliedAlpha=this.premultipliedAlpha,this.material.needsUpdate=!0),this.uniforms.time.value=E,this.uniforms.deltaTime.value=i,this.uniforms.debugFlag.value=performance.now()/1e3%2<1,s.display&&s.stochastic&&(this.geometry.instanceCount=this.uniforms.numSplats.value)),s.target)this.uniforms.renderSize.value.set(s.target.width,s.target.height);else{const h=A.getDrawingBufferSize(this.uniforms.renderSize.value);if(h.x===1&&h.y===1){const c=(B=A.xr.getSession())==null?void 0:B.renderState.baseLayer;c&&(h.x=c.framebufferWidth,h.y=c.framebufferHeight)}}const w=g;if(this.uniforms.near.value=w.near,this.uniforms.far.value=w.far,this.uniforms.encodeLinear.value=s.encodeLinear,this.uniforms.maxStdDev.value=this.maxStdDev,this.uniforms.minPixelRadius.value=this.minPixelRadius,this.uniforms.maxPixelRadius.value=this.maxPixelRadius,this.uniforms.minAlpha.value=this.minAlpha,this.uniforms.stochastic.value=s.stochastic,this.uniforms.enable2DGS.value=this.enable2DGS,this.uniforms.preBlurAmount.value=this.preBlurAmount,this.uniforms.blurAmount.value=this.blurAmount,this.uniforms.focalDistance.value=this.focalDistance,this.uniforms.apertureAngle.value=this.apertureAngle,this.uniforms.falloff.value=this.falloff,this.uniforms.clipXY.value=this.clipXY,this.uniforms.focalAdjustment.value=this.focalAdjustment,this.lastStochastic!==!s.stochastic&&(this.lastStochastic=!s.stochastic,this.material.transparent=!s.stochastic,this.material.depthWrite=s.stochastic,this.material.needsUpdate=!0),this.splatTexture){const{enable:h,texture:c,multiply:k,add:R,near:t,far:N,mid:S}=this.splatTexture;h&&c?(this.uniforms.splatTexEnable.value=!0,this.uniforms.splatTexture.value=c,k?this.uniforms.splatTexMul.value.fromArray(k.elements):this.uniforms.splatTexMul.value.set(.5/this.maxStdDev,0,0,.5/this.maxStdDev),this.uniforms.splatTexAdd.value.set(R?.x??.5,R?.y??.5),this.uniforms.splatTexNear.value=t??this.uniforms.near.value,this.uniforms.splatTexFar.value=N??this.uniforms.far.value,this.uniforms.splatTexMid.value=S??0):(this.uniforms.splatTexEnable.value=!1,this.uniforms.splatTexture.value=uA.EMPTY_SPLAT_TEXTURE)}else this.uniforms.splatTexEnable.value=!1,this.uniforms.splatTexture.value=uA.EMPTY_SPLAT_TEXTURE;const G=((C=s.display)==null?void 0:C.accumulator.toWorld)??new FA,a=g.matrixWorld.clone().invert();G.clone().premultiply(a).decompose(this.uniforms.renderToViewPos.value,this.uniforms.renderToViewQuat.value,new F)}prepareViewpoint(A){var I,g,B,C;if(this.viewpoint=A??this.viewpoint,this.viewpoint.display){const{accumulator:E,geometry:i}=this.viewpoint.display;this.uniforms.numSplats.value=E.splats.numSplats,this.uniforms.packedSplats.value=E.splats.getTexture(),this.uniforms.rgbMinMaxLnScaleMinMax.value.set(((I=E.splats.splatEncoding)==null?void 0:I.rgbMin)??0,((g=E.splats.splatEncoding)==null?void 0:g.rgbMax)??1,((B=E.splats.splatEncoding)==null?void 0:B.lnScaleMin)??PA,((C=E.splats.splatEncoding)==null?void 0:C.lnScaleMax)??mA),this.geometry=i,this.material.transparent=!this.viewpoint.stochastic,this.material.depthWrite=this.viewpoint.stochastic,this.material.needsUpdate=!0}else this.uniforms.numSplats.value=0,this.uniforms.packedSplats.value=SI.getEmptyArray,this.geometry=tC}update({scene:A,viewToWorld:I}){const g=this.matrixWorld;this.preUpdate?this.updateInternal({scene:A,originToWorld:g.clone(),viewToWorld:I}):(this.pendingUpdate.scene=A,this.pendingUpdate.originToWorld.copy(g),this.pendingUpdate.timeoutId===-1&&(this.pendingUpdate.timeoutId=setTimeout(()=>{const{scene:B,originToWorld:C}=this.pendingUpdate;this.pendingUpdate.scene=null,this.pendingUpdate.timeoutId=-1,this.updateInternal({scene:B,originToWorld:C,viewToWorld:I})&&this.renderer.getContext().flush()},1)))}updateInternal({scene:A,originToWorld:I,viewToWorld:g}){var B;if(!this.canAllocAccumulator())return!1;I||(I=this.active.toWorld),g=g??I.clone();const C=this.time??this.clock.getElapsedTime(),E=C-(this.lastUpdateTime??C);this.lastUpdateTime=C;const i=this.active.mapping.reduce((h,c)=>(h.set(c.node,c),h),new Map),{generators:o,visibleGenerators:D,globalEdits:s}=this.compileScene(A);for(const h of o)(B=h.frameUpdate)==null||B.call(h,{renderer:this.renderer,object:h,time:C,deltaTime:E,viewToWorld:g,globalEdits:s});const w=new Set(D.map(h=>h.uuid));for(const h of o){const c=i.get(h),R=h.generator&&w.has(h.uuid)?h.numSplats:0;(this.needsUpdate||h.generator!==c?.generator||R!==c?.count)&&h.updateVersion()}const G=!aQ({matrix1:I,matrix2:this.active.toWorld,maxDistance:this.originDistance}),a=this.needsUpdate||G||o.length!==i.size||o.some(h=>{var c;return h.version!==((c=i.get(h))==null?void 0:c.version)});this.needsUpdate=!1;let y=null;if(a){if(y=this.maybeAllocAccumulator(),!y)throw new Error("Unreachable");const h=!aQ({matrix1:I,matrix2:y.toWorld,maxDistance:1e-5,minCoorient:.99999}),k=D.map((M,U)=>{const n=i.get(M);return n?[M.version-n.version,n.base,M]:[Number.POSITIVE_INFINITY,M.version,M]}).sort((M,U)=>M[0]!==U[0]?M[0]-U[0]:M[1]-U[1]).map(([M,U,n])=>n),R=k.map(M=>M.numSplats),{maxSplats:t,mapping:N}=y.splats.generateMapping(R),S=k.map((M,U)=>{const{base:n,count:L}=N[U];return{node:M,generator:M.generator,version:M.version,base:n,count:L}});I.clone().invert().decompose(this.translateToAccumulator.value,this.rotateToAccumulator.value,new F),y.ensureGenerate(t),y.splats.splatEncoding={...this.splatEncoding},y.generateSplats({renderer:this.renderer,modifier:this.modifier,generators:S,forceUpdate:h,originToWorld:I}),y.splatsVersion=this.active.splatsVersion+1;const J=y.hasCorrespondence(this.active);y.mappingVersion=this.active.mappingVersion+(J?0:1),this.releaseAccumulator(this.active),this.active=y,this.prepareViewpoint()}return setTimeout(()=>{for(const h of this.autoViewpoints)h.autoPoll({accumulator:y??void 0})},1),!0}compileScene(A){const I=[];A.traverse(C=>{C instanceof jI&&I.push(C)});const g=[];A.traverseVisible(C=>{C instanceof jI&&g.push(C)});const B=new Set;return A.traverseVisible(C=>{if(C instanceof ZB){let E=C.parent;for(;E!=null&&!(E instanceof wI);)E=E.parent;E==null&&B.add(C)}}),{generators:I,visibleGenerators:g,globalEdits:Array.from(B)}}async renderEnvMap({renderer:A,scene:I,worldCenter:g,size:B=256,near:C=.1,far:E=1e3,hideObjects:i=[],update:o=!1}){var D,s;if(this.envViewpoint||(this.envViewpoint=this.newViewpoint({sort360:!0})),!uA.cubeRender||uA.cubeRender.target.width!==B||uA.cubeRender.near!==C||uA.cubeRender.far!==E){uA.cubeRender&&uA.cubeRender.target.dispose();const h=new UC(B,{format:sI,generateMipmaps:!0,minFilter:nC}),c=new eC(C,E,h);uA.cubeRender={target:h,camera:c,near:C,far:E}}uA.pmrem||(uA.pmrem=new HC(A??this.renderer));const w=new FA().setPosition(g);await((D=this.envViewpoint)==null?void 0:D.prepare({scene:I,viewToWorld:w,update:o}));const{target:G,camera:a}=uA.cubeRender;a.position.copy(g);const y=new Map;for(const h of i)y.set(h,h.visible),h.visible=!1;this.prepareViewpoint(this.envViewpoint),a.update(A??this.renderer,I),this.prepareViewpoint(this.defaultView);for(const[h,c]of y.entries())h.visible=c;return(s=uA.pmrem)==null?void 0:s.fromCubemap(G.texture).texture}recurseSetEnvMap(A,I){A.traverse(g=>{if(g instanceof QQ)if(Array.isArray(g.material))for(const B of g.material)B instanceof EQ&&(B.envMap=I);else g.material instanceof EQ&&(g.material.envMap=I)})}getRgba({generator:A,rgba:I}){const g=this.active.mapping.find(({node:B})=>B===A);if(!g)throw new Error("Generator not found");return I=I??new qy,I.fromPackedSplats({packedSplats:this.active.splats,base:g.base,count:g.count,renderer:this.renderer}),I}async readRgba({generator:A,rgba:I}){return I=this.getRgba({generator:A,rgba:I}),I.read()}};rQ.cubeRender=null;rQ.pmrem=null;rQ.EMPTY_SPLAT_TEXTURE=new Es;let fk=rQ;const tC=new _Q(new Uint32Array(1),0);JA({packedSplats:bg,index:"int"},{gsplat:X},({packedSplats:Q,index:A})=>{if(!Q||!A)throw new Error("Invalid input");return{gsplat:ig(Q,A)}});function sc(Q){if(Q.length===0)return null;const A=new F,I=new Z,g=new F,B=[],C=[];for(const E of Q)E.decompose(A,I,g),B.push(A),C.push(I);return new FA().compose(CE(B),EE(C),new F(1,1,1))}function Gc(Q,A,I){const g=Math.floor(Q.length/32);if(g*32!==Q.length)throw new Error("Invalid .splat file size");const B=new Float32Array(Q.buffer);for(let C=0;C<g;++C){const E=C*32,i=C*8,o=B[i+0],D=B[i+1],s=B[i+2],w=B[i+3],G=B[i+4],a=B[i+5],y=Q[E+24]/255,h=Q[E+25]/255,c=Q[E+26]/255,k=Q[E+27]/255,R=(Q[E+28]-128)/128,t=(Q[E+29]-128)/128,N=(Q[E+30]-128)/128,S=(Q[E+31]-128)/128;I(C,o,D,s,w,G,a,t,N,S,R,k,y,h,c)}}const NC={0:{bytesPerCenter:12,bytesPerScale:12,bytesPerRotation:16,bytesPerColor:4,bytesPerSphericalHarmonicsComponent:4,scaleOffsetBytes:12,rotationOffsetBytes:24,colorOffsetBytes:40,sphericalHarmonicsOffsetBytes:44,scaleRange:1},1:{bytesPerCenter:6,bytesPerScale:6,bytesPerRotation:8,bytesPerColor:4,bytesPerSphericalHarmonicsComponent:2,scaleOffsetBytes:6,rotationOffsetBytes:12,colorOffsetBytes:20,sphericalHarmonicsOffsetBytes:24,scaleRange:32767},2:{bytesPerCenter:6,bytesPerScale:6,bytesPerRotation:8,bytesPerColor:4,bytesPerSphericalHarmonicsComponent:1,scaleOffsetBytes:6,rotationOffsetBytes:12,colorOffsetBytes:20,sphericalHarmonicsOffsetBytes:24,scaleRange:32767}},ac={0:0,1:9,2:24,3:45};function hc(Q,A,I,g){var B;let i=0;const o=new DataView(Q.buffer,i,4096);i+=4096;const D=o.getUint8(0),s=o.getUint8(1);if(D!==0||s<1)throw new Error(`Unsupported .ksplat version: ${D}.${s}`);const w=o.getUint32(4,!0);o.getUint32(16,!0);const G=o.getUint16(20,!0);if(G<0||G>2)throw new Error(`Invalid .ksplat compression level: ${G}`);const a=o.getFloat32(36,!0)||-1.5,y=o.getFloat32(40,!0)||1.5;let h=4096+w*1024;for(let c=0;c<w;++c){let k=function(WA,gA){if(G===0)return IA.getFloat32(WA+b+gA*4,!0);if(G===1)return MA(IA.getUint16(WA+b+gA*2,!0));const NI=IA.getUint8(WA+b+gA)/255;return a+NI*(y-a)};const R=new DataView(Q.buffer,i,1024);i+=1024;const t=R.getUint32(0,!0),N=R.getUint32(4,!0),S=R.getUint32(8,!0),J=R.getUint32(12,!0),M=R.getFloat32(16,!0),U=R.getUint16(20,!0),n=(R.getUint32(24,!0)||((B=NC[G])==null?void 0:B.scaleRange))??1,L=R.getUint32(32,!0),H=L*S,e=R.getUint32(36,!0),q=e*4,Y=U*J+q,K=R.getUint16(40,!0),x=ac[K],{bytesPerCenter:m,bytesPerScale:j,bytesPerRotation:u,bytesPerColor:CA,bytesPerSphericalHarmonicsComponent:V,scaleOffsetBytes:AA,rotationOffsetBytes:O,colorOffsetBytes:P,sphericalHarmonicsOffsetBytes:b}=NC[G],T=m+j+u+CA+x*V,p=T*N,SA=p+Y,GA=[0,3,6,1,4,7,2,5,8],tA=[9,14,19,10,15,20,11,16,21,12,17,22,13,18,23],NA=[24,31,38,25,32,39,26,33,40,27,34,41,28,35,42,29,36,43,30,37,44],wA=K>=1?new Float32Array(9):void 0,aA=K>=2?new Float32Array(15):void 0,CI=K>=3?new Float32Array(21):void 0,VA=M/2/n,eI=h+q,HI=h+Y,IA=new DataView(Q.buffer,HI,p),XA=new Float32Array(Q.buffer,eI,J*3),KA=new Uint32Array(Q.buffer,h,e);let cg=L,Pg=H;for(let WA=0;WA<t;++WA){const gA=WA*T;let NI;if(WA<H)NI=Math.floor(WA/S);else{const LI=KA[cg-L];WA>=Pg+LI&&(cg+=1,Pg+=LI),NI=cg}const lQ=G===0?IA.getFloat32(gA+0,!0):(IA.getUint16(gA+0,!0)-n)*VA+XA[3*NI+0],xQ=G===0?IA.getFloat32(gA+4,!0):(IA.getUint16(gA+2,!0)-n)*VA+XA[3*NI+1],pQ=G===0?IA.getFloat32(gA+8,!0):(IA.getUint16(gA+4,!0)-n)*VA+XA[3*NI+2],fQ=G===0?IA.getFloat32(gA+AA+0,!0):MA(IA.getUint16(gA+AA+0,!0)),bQ=G===0?IA.getFloat32(gA+AA+4,!0):MA(IA.getUint16(gA+AA+2,!0)),bw=G===0?IA.getFloat32(gA+AA+8,!0):MA(IA.getUint16(gA+AA+4,!0)),uw=G===0?IA.getFloat32(gA+O+0,!0):MA(IA.getUint16(gA+O+0,!0)),Pw=G===0?IA.getFloat32(gA+O+4,!0):MA(IA.getUint16(gA+O+2,!0)),mw=G===0?IA.getFloat32(gA+O+8,!0):MA(IA.getUint16(gA+O+4,!0)),Tw=G===0?IA.getFloat32(gA+O+12,!0):MA(IA.getUint16(gA+O+6,!0)),Ow=IA.getUint8(gA+P+0)/255,Zw=IA.getUint8(gA+P+1)/255,Vw=IA.getUint8(gA+P+2)/255,Xw=IA.getUint8(gA+P+3)/255;if(I(WA,lQ,xQ,pQ,fQ,bQ,bw,Pw,mw,Tw,uw,Xw,Ow,Zw,Vw),K>=1&&wA){for(const[LI,kg]of GA.entries())wA[LI]=k(gA,kg);if(aA)for(const[LI,kg]of tA.entries())aA[LI]=k(gA,kg);if(CI)for(const[LI,kg]of NA.entries())CI[LI]=k(gA,kg);g?.(WA,wA,aA,CI)}}h+=SA}}class yc{constructor({fileBytes:A}){this.version=-1,this.numSplats=0,this.shDegree=0,this.fractionalBits=0,this.flags=0,this.flagAntiAlias=!1,this.flagLod=!1,this.reserved=0,this.headerParsed=!1,this.parsed=!1,this.fileBytes=A instanceof ArrayBuffer?new Uint8Array(A):A,this.reader=new aE({fileBytes:this.fileBytes})}async parseHeader(){if(this.headerParsed)throw new Error("SPZ file header already parsed");const A=new DataView((await this.reader.read(16)).buffer);if(A.getUint32(0,!0)!==1347635022)throw new Error("Invalid SPZ file");if(this.version=A.getUint32(4,!0),this.version<1||this.version>3)throw new Error(`Unsupported SPZ version: ${this.version}`);this.numSplats=A.getUint32(8,!0),this.shDegree=A.getUint8(12),this.fractionalBits=A.getUint8(13),this.flags=A.getUint8(14),this.flagAntiAlias=(this.flags&1)!==0,this.flagLod=(this.flags&128)!==0,this.reserved=A.getUint8(15),this.headerParsed=!0,this.parsed=!1}async parseSplats(A,I,g,B,C,E,{childCounts:i,childStarts:o}={}){if(!this.headerParsed)throw new Error("SPZ file header must be parsed first");if(this.parsed)throw new Error("SPZ file already parsed");if(this.parsed=!0,this.version===1){const D=await this.reader.read(this.numSplats*3*2),s=new Uint16Array(D.buffer);for(let w=0;w<this.numSplats;w++){const G=w*3,a=MA(s[G]),y=MA(s[G+1]),h=MA(s[G+2]);A?.(w,a,y,h)}}else if(this.version===2||this.version===3){const D=1<<this.fractionalBits,s=await this.reader.read(this.numSplats*3*3);for(let w=0;w<this.numSplats;w++){const G=w*9,a=((s[G+2]<<24|s[G+1]<<16|s[G]<<8)>>8)/D,y=((s[G+5]<<24|s[G+4]<<16|s[G+3]<<8)>>8)/D,h=((s[G+8]<<24|s[G+7]<<16|s[G+6]<<8)>>8)/D;A?.(w,a,y,h)}}else throw new Error("Unreachable");{const D=await this.reader.read(this.numSplats);for(let s=0;s<this.numSplats;s++)I?.(s,D[s]/255)}{const D=await this.reader.read(this.numSplats*3),s=Kw/.15;for(let w=0;w<this.numSplats;w++){const G=w*3,a=(D[G]/255-.5)*s+.5,y=(D[G+1]/255-.5)*s+.5,h=(D[G+2]/255-.5)*s+.5;g?.(w,a,y,h)}}{const D=await this.reader.read(this.numSplats*3);for(let s=0;s<this.numSplats;s++){const w=s*3,G=Math.exp(D[w]/16-10),a=Math.exp(D[w+1]/16-10),y=Math.exp(D[w+2]/16-10);B?.(s,G,a,y)}}if(this.version===3){const D=1/Math.sqrt(2),s=await this.reader.read(this.numSplats*4);for(let w=0;w<this.numSplats;w++){const G=w*4,a=[0,0,0,0],y=[s[G],s[G+1],s[G+2],s[G+3]],h=y[0]+(y[1]<<8)+(y[2]<<16)+(y[3]<<24),c=511,k=h>>>30;let R=h,t=0;for(let S=3;S>=0;--S)if(S!==k){const J=R&c,M=R>>>9&1;R=R>>>10,a[S]=D*(J/c),a[S]=M===0?a[S]:-a[S],t+=a[S]*a[S]}const N=1-t;a[k]=Math.sqrt(Math.max(N,0)),C?.(w,a[0],a[1],a[2],a[3])}}else{const D=await this.reader.read(this.numSplats*3);for(let s=0;s<this.numSplats;s++){const w=s*3,G=D[w]/127.5-1,a=D[w+1]/127.5-1,y=D[w+2]/127.5-1,h=Math.sqrt(Math.max(0,1-G*G-a*a-y*y));C?.(s,G,a,y,h)}}if(E&&this.shDegree>=1){const D=new Float32Array(9),s=this.shDegree>=2?new Float32Array(15):void 0,w=this.shDegree>=3?new Float32Array(21):void 0,G=await this.reader.read(this.numSplats*rw[this.shDegree]*3);let a=0;for(let y=0;y<this.numSplats;y++){for(let h=0;h<9;++h)D[h]=(G[a+h]-128)/128;if(a+=9,s){for(let h=0;h<15;++h)s[h]=(G[a+h]-128)/128;a+=15}if(w){for(let h=0;h<21;++h)w[h]=(G[a+h]-128)/128;a+=21}E?.(y,D,s,w)}}if(this.flagLod){let D=await this.reader.read(this.numSplats*2);for(let s=0;s<this.numSplats;s++){const w=s*2,G=D[w]+(D[w+1]<<8);i?.(s,G)}D=await this.reader.read(this.numSplats*4);for(let s=0;s<this.numSplats;s++){const w=s*4,G=D[w]+(D[w+1]<<8)+(D[w+2]<<16)+(D[w+3]<<24);o?.(s,G)}}}}const rw={1:3,2:8,3:15},Kw=.28209479177387814,cc=1347635022,kc=3,Rc=1;class KI{constructor({numSplats:A,shDegree:I,fractionalBits:g=12,flagAntiAlias:B=!0}){this.clippedCount=0;const C=20+(I>=1?9:0)+(I>=2?15:0)+(I>=3?21:0),E=16+A*C;this.buffer=new ArrayBuffer(E),this.view=new DataView(this.buffer),this.view.setUint32(0,cc,!0),this.view.setUint32(4,kc,!0),this.view.setUint32(8,A,!0),this.view.setUint8(12,I),this.view.setUint8(13,g),this.view.setUint8(14,B?Rc:0),this.view.setUint8(15,0),this.numSplats=A,this.shDegree=I,this.fractionalBits=g,this.fraction=1<<g,this.flagAntiAlias=B}setCenter(A,I,g,B){const C=Math.round(I*this.fraction),E=Math.max(-8388607,Math.min(8388607,C)),i=Math.round(g*this.fraction),o=Math.max(-8388607,Math.min(8388607,i)),D=Math.round(B*this.fraction),s=Math.max(-8388607,Math.min(8388607,D));(C!==E||i!==o||D!==s)&&(this.clippedCount+=1);const a=16+A*9;this.view.setUint8(a,E&255),this.view.setUint8(a+1,E>>8&255),this.view.setUint8(a+2,E>>16&255),this.view.setUint8(a+3,o&255),this.view.setUint8(a+4,o>>8&255),this.view.setUint8(a+5,o>>16&255),this.view.setUint8(a+6,s&255),this.view.setUint8(a+7,s>>8&255),this.view.setUint8(a+8,s>>16&255)}setAlpha(A,I){const g=16+this.numSplats*9+A;this.view.setUint8(g,Math.max(0,Math.min(255,Math.round(I*255))))}static scaleRgb(A){const I=((A-.5)/(Kw/.15)+.5)*255;return Math.max(0,Math.min(255,Math.round(I)))}setRgb(A,I,g,B){const C=16+this.numSplats*10+A*3;this.view.setUint8(C,KI.scaleRgb(I)),this.view.setUint8(C+1,KI.scaleRgb(g)),this.view.setUint8(C+2,KI.scaleRgb(B))}setScale(A,I,g,B){const C=16+this.numSplats*13+A*3;this.view.setUint8(C,Math.max(0,Math.min(255,Math.round((Math.log(I)+10)*16)))),this.view.setUint8(C+1,Math.max(0,Math.min(255,Math.round((Math.log(g)+10)*16)))),this.view.setUint8(C+2,Math.max(0,Math.min(255,Math.round((Math.log(B)+10)*16))))}setQuat(A,...I){const g=16+this.numSplats*16+A*4,B=AE(I);let C=0;for(let o=1;o<4;++o)Math.abs(B[o])>Math.abs(B[C])&&(C=o);const E=B[C]<0?1:0;let i=C;for(let o=0;o<4;++o)if(o!==C){const D=(B[o]<0?1:0)^E,s=Math.floor(511*(Math.abs(B[o])/Math.SQRT1_2)+.5);i=i<<10|D<<9|s}this.view.setUint8(g,i&255),this.view.setUint8(g+1,i>>8&255),this.view.setUint8(g+2,i>>16&255),this.view.setUint8(g+3,i>>>24&255)}static quantizeSh(A,I){const g=Math.round(A*128)+128,B=1<<8-I,C=Math.floor((g+B/2)/B)*B;return Math.max(0,Math.min(255,C))}setSh(A,I,g,B){const C=rw[this.shDegree]||0,E=16+this.numSplats*20+A*C*3;for(let i=0;i<9;++i)this.view.setUint8(E+i,KI.quantizeSh(I[i],5));if(g){const i=E+9;for(let o=0;o<15;++o)this.view.setUint8(i+o,KI.quantizeSh(g[o],4));if(B){const o=i+15;for(let D=0;D<21;++D)this.view.setUint8(o+D,KI.quantizeSh(B[D],4))}}}async finalize(){const A=new Uint8Array(this.buffer),g=new ReadableStream({async start(E){E.enqueue(A),E.close()}}).pipeThrough(new CompressionStream("gzip")),C=await new Response(g).arrayBuffer();return console.log("Compressed",A.length,"bytes to",C.byteLength,"bytes"),new Uint8Array(C)}}async function bk(Q){var A,I,g;const B=new Ec,{inputs:C,clipXyz:E,maxSh:i,fractionalBits:o=12,opacityThreshold:D}=Q;for(const a of C){let y=function(U){return U.multiplyScalar(t),U.applyQuaternion(N),U.add(S),U},h=function(U){return U.multiplyScalar(t),U},c=function(U){return U.premultiply(N),U},k=function(U){return!J||J.containsPoint(U)},R=function(U){return D!==void 0?U>=D:!0};const t=((A=a.transform)==null?void 0:A.scale)??1,N=new Z().fromArray(((I=a.transform)==null?void 0:I.quaternion)??[0,0,0,1]),S=new F().fromArray(((g=a.transform)==null?void 0:g.translate)??[0,0,0]),J=E?new dg(new F().fromArray(E.min),new F().fromArray(E.max)):void 0;let M=a.fileType;switch(M||(M=vB(a.fileBytes),!M&&a.pathOrUrl&&(M=zB(a.pathOrUrl))),M){case cA.PLY:{const U=new ew({fileBytes:a.fileBytes});await U.parseHeader();let n=null;U.parseSplats((L,H,e,q,Y,K,x,m,j,u,CA,V,AA,O,P)=>{const b=y(new F(H,e,q));if(k(b)&&R(V)){n=B.pushSplat(),B.setCenter(n,b.x,b.y,b.z);const T=h(new F(Y,K,x));B.setScale(n,T.x,T.y,T.z);const p=c(new Z(m,j,u,CA));B.setQuaternion(n,p.x,p.y,p.z,p.w),B.setOpacity(n,V),B.setColor(n,AA,O,P)}else n=null},(L,H,e,q)=>{H&&n!==null&&B.setSh1(n,H),e&&n!==null&&B.setSh2(n,e),q&&n!==null&&B.setSh3(n,q)});break}case cA.SPZ:{const U=new yc({fileBytes:a.fileBytes});await U.parseHeader();const n=new Int32Array(U.numSplats);n.fill(-1);const L=new Float32Array(U.numSplats*3),H=new F;U.parseSplats((e,q,Y,K)=>{const x=y(new F(q,Y,K));L[e*3]=x.x,L[e*3+1]=x.y,L[e*3+2]=x.z},(e,q)=>{H.fromArray(L,e*3),k(H)&&R(q)&&(n[e]=B.pushSplat(),B.setCenter(n[e],H.x,H.y,H.z),B.setOpacity(n[e],q))},(e,q,Y,K)=>{n[e]>=0&&B.setColor(n[e],q,Y,K)},(e,q,Y,K)=>{if(n[e]>=0){const x=h(new F(q,Y,K));B.setScale(n[e],x.x,x.y,x.z)}},(e,q,Y,K,x)=>{if(n[e]>=0){const m=c(new Z(q,Y,K,x));B.setQuaternion(n[e],m.x,m.y,m.z,m.w)}},(e,q,Y,K)=>{n[e]>=0&&(B.setSh1(n[e],q),Y&&B.setSh2(n[e],Y),K&&B.setSh3(n[e],K))});break}case cA.SPLAT:Gc(a.fileBytes,U=>{},(U,n,L,H,e,q,Y,K,x,m,j,u,CA,V,AA)=>{const O=y(new F(n,L,H));if(k(O)&&R(u)){const P=B.pushSplat();B.setCenter(P,O.x,O.y,O.z);const b=h(new F(e,q,Y));B.setScale(P,b.x,b.y,b.z);const T=c(new Z(K,x,m,j));B.setQuaternion(P,T.x,T.y,T.z,T.w),B.setOpacity(P,u),B.setColor(P,CA,V,AA)}});break;case cA.KSPLAT:{let U=null;hc(a.fileBytes,n=>{},(n,L,H,e,q,Y,K,x,m,j,u,CA,V,AA,O)=>{const P=y(new F(L,H,e));if(k(P)&&R(CA)){U=B.pushSplat(),B.setCenter(U,P.x,P.y,P.z);const b=h(new F(q,Y,K));B.setScale(U,b.x,b.y,b.z);const T=c(new Z(x,m,j,u));B.setQuaternion(U,T.x,T.y,T.z,T.w),B.setOpacity(U,CA),B.setColor(U,V,AA,O)}else U=null},(n,L,H,e)=>{U!==null&&(B.setSh1(U,L),H&&B.setSh2(U,H),e&&B.setSh3(U,e))});break}default:throw new Error(`transcodeSpz not implemented for ${M}`)}}const s=Math.min(i??3,B.sh3?3:B.sh2?2:B.sh1?1:0),w=new KI({numSplats:B.numSplats,shDegree:s,fractionalBits:o,flagAntiAlias:!0});for(let a=0;a<B.numSplats;++a){const y=a*3,h=a*4;w.setCenter(a,B.centers[y],B.centers[y+1],B.centers[y+2]),w.setScale(a,B.scales[y],B.scales[y+1],B.scales[y+2]),w.setQuat(a,B.quaternions[h],B.quaternions[h+1],B.quaternions[h+2],B.quaternions[h+3]),w.setAlpha(a,B.opacities[a]),w.setRgb(a,B.colors[y],B.colors[y+1],B.colors[y+2]),B.sh1&&s>=1&&w.setSh(a,B.sh1.slice(a*9,(a+1)*9),s>=2&&B.sh2?B.sh2.slice(a*15,(a+1)*15):void 0,s>=3&&B.sh3?B.sh3.slice(a*21,(a+1)*21):void 0)}return{fileBytes:await w.finalize(),clippedCount:w.clippedCount}}var Fc=(Q=>(Q.DUAL_QUATERNION="dual_quaternion",Q.LINEAR_BLEND="linear_blend",Q))(Fc||{});const yg=class z{constructor(A){this.mesh=A.mesh,this.numSplats=A.numSplats??this.mesh.numSplats,this.mode=A.mode??"dual_quaternion";const{width:I,height:g,depth:B,maxSplats:C}=EA(this.numSplats);this.skinData=new Uint16Array(C*4),this.skinTexture=new pA(this.skinData,I,g,B),this.skinTexture.format=BA,this.skinTexture.type=_w,this.skinTexture.internalFormat="RGBA16UI",this.skinTexture.needsUpdate=!0,this.numBones=A.numBones??256,this.boneData=new Float32Array(this.numBones*16),this.boneTexture=new lI(this.boneData,4,this.numBones,sI,$w),this.boneTexture.internalFormat="RGBA32F",this.boneTexture.needsUpdate=!0,this.boneRestQuatPosScale=AB(this.numBones,()=>({quat:new Z,pos:new F,scale:new F})),this.mode==="linear_blend"?this.boneRestInvMats=AB(this.numBones,()=>new FA):this.boneRestInvMats=[],this.uniform=new l({key:"skinning",type:KQ,globals:()=>[dQ],value:{numSplats:this.numSplats,numBones:this.numBones,skinTexture:this.skinTexture,boneTexture:this.boneTexture}})}modify(A){if(this.mode==="linear_blend")throw new Error("Linear blend skinning requires covSplats=true");return tc(A,this.uniform)}modifyCov(A){return this.mode==="dual_quaternion"?Jc(A,this.uniform):Uc(A,this.uniform)}setRestQuatPos(A,I,g){this.boneRestQuatPosScale[A].quat.copy(I),this.boneRestQuatPosScale[A].pos.copy(g),this.boneRestQuatPosScale[A].scale.copy(z.UNIT_SCALE),this.mode==="linear_blend"&&this.boneRestInvMats[A].compose(g,I,z.UNIT_SCALE).invert(),this.setBoneQuatPos(A,I,g)}getRestQuatPos(A,I,g){I.copy(this.boneRestQuatPosScale[A].quat),g.copy(this.boneRestQuatPosScale[A].pos)}setRestQuatPosScale(A,I,g,B){this.boneRestQuatPosScale[A].quat.copy(I),this.boneRestQuatPosScale[A].pos.copy(g),this.boneRestQuatPosScale[A].scale.copy(B),this.mode==="linear_blend"&&this.boneRestInvMats[A].compose(g,I,B).invert(),this.setBoneQuatPosScale(A,I,g,B)}getRestQuatPosScale(A,I,g,B){I.copy(this.boneRestQuatPosScale[A].quat),g.copy(this.boneRestQuatPosScale[A].pos),B.copy(this.boneRestQuatPosScale[A].scale)}setRestMatrix(A,I){if(this.mode!=="linear_blend")throw new Error("setRestMat only supported for linear blend skinning");this.boneRestInvMats[A].copy(I).invert(),this.setBoneMatrix(A,I)}getRestMatrix(A,I){if(this.mode!=="linear_blend")throw new Error("getRestMat only supported for linear blend skinning");I.copy(this.boneRestInvMats[A]).invert()}setBoneQuatPos(A,I,g){if(this.mode==="dual_quaternion"){z.relQuat.copy(this.boneRestQuatPosScale[A].quat).invert(),z.relPos.copy(g).sub(this.boneRestQuatPosScale[A].pos),z.relQuat.multiply(I),z.dual.set(z.relPos.x,z.relPos.y,z.relPos.z,0).multiply(z.relQuat);const B=A*16;this.boneData[B+0]=z.relQuat.x,this.boneData[B+1]=z.relQuat.y,this.boneData[B+2]=z.relQuat.z,this.boneData[B+3]=z.relQuat.w,this.boneData[B+4]=.5*z.dual.x,this.boneData[B+5]=.5*z.dual.y,this.boneData[B+6]=.5*z.dual.z,this.boneData[B+7]=.5*z.dual.w}else this.setBoneQuatPosScale(A,I,g,z.UNIT_SCALE)}setBoneQuatPosScale(A,I,g,B){if(this.mode==="dual_quaternion")throw new Error("setBoneQuatPosScale only supported for linear blend skinning");z.skinMat.compose(g,I,B),this.setBoneMatrix(A,z.skinMat)}setBoneMatrix(A,I){if(this.mode!=="linear_blend")throw new Error("setBoneMatrix only supported for linear blend skinning");z.skinMat.multiplyMatrices(this.boneRestInvMats[A],I);const g=A*16;this.boneData[g+0]=z.skinMat.elements[0],this.boneData[g+1]=z.skinMat.elements[1],this.boneData[g+2]=z.skinMat.elements[2],this.boneData[g+3]=z.skinMat.elements[4],this.boneData[g+4]=z.skinMat.elements[5],this.boneData[g+5]=z.skinMat.elements[6],this.boneData[g+6]=z.skinMat.elements[8],this.boneData[g+7]=z.skinMat.elements[9],this.boneData[g+8]=z.skinMat.elements[10],this.boneData[g+9]=z.skinMat.elements[12],this.boneData[g+10]=z.skinMat.elements[13],this.boneData[g+11]=z.skinMat.elements[14]}setSplatBones(A,I,g){const B=A*4;this.skinData[B+0]=Math.min(255,Math.max(0,Math.round(g.x*255)))+(I.x<<8),this.skinData[B+1]=Math.min(255,Math.max(0,Math.round(g.y*255)))+(I.y<<8),this.skinData[B+2]=Math.min(255,Math.max(0,Math.round(g.z*255)))+(I.z<<8),this.skinData[B+3]=Math.min(255,Math.max(0,Math.round(g.w*255)))+(I.w<<8)}updateBones(){this.boneTexture.needsUpdate=!0,this.mesh.needsUpdate=!0}};yg.UNIT_SCALE=new F(1,1,1);yg.relQuat=new Z;yg.relPos=new F;yg.dual=new Z;yg.skinMat=new FA;let uk=yg;const KQ={type:"GsplatSkinning"},dQ=sA(`
11809
11809
  struct GsplatSkinning {
11810
11810
  int numSplats;
11811
11811
  int numBones;
@@ -12009,8 +12009,8 @@ void main() {
12009
12009
  ${E}.index, ${E}.center, ${E}.xxyyzz, ${E}.xyxzyz
12010
12010
  );
12011
12011
  }
12012
- `)}}).outputs.covsplat}function jk({splats:Q,extents:A,stepSize:I=1,pointRadius:g=.01,pointShadowScale:B=2,opacity:C=1,color:E}){const o=new F,D=new F,s=new Z(0,0,0,1);E==null&&(E=(G,a)=>G.set(.55+.45*Math.cos(a.x*1),.55+.45*Math.cos(a.y*1),.55+.45*Math.cos(a.z*1)));const w=new YA;for(let G=A.min.z;G<A.max.z+1e-6;G+=I)for(let a=A.min.y;a<A.max.y+1e-6;a+=I)for(let y=A.min.x;y<A.max.x+1e-6;y+=I){o.set(y,a,G);for(let h=0;h<2;++h)D.setScalar(g*(h?1:B)),h?typeof E=="function"?E(w,o):w.copy(E):w.setScalar(0),Q.pushSplat(o,D,s,C,w)}}function vk({splats:Q,scale:A=.25,axisRadius:I=.0075,axisShadowScale:g=2,origins:B=[new F]}){const C=new F,E=new F,i=new Z(0,0,0,1),o=new YA,D=1;for(const s of B)for(let w=0;w<3;++w){C.set(s.x+(w===0?A:0),s.y+(w===1?A:0),s.z+(w===2?A:0));for(let G=0;G<2;++G)E.set((w===0?A:I)*(G?1:g),(w===1?A:I)*(G?1:g),(w===2?A:I)*(G?1:g)),o.setRGB(G===0?0:w===0?1:0,G===0?0:w===1?1:0,G===0?0:w===2?1:0),Q.pushSplat(C,E,i,D,o)}}function zk({splats:Q,origin:A=new F,radius:I=1,maxDepth:g=3,filter:B=null,pointRadius:C=.02,pointThickness:E=.001,color:i=new YA(1,1,1)}){const o={};function D(h){if(B&&!B(h))return;const c=`${h.x},${h.y},${h.z}`;o[c]||(o[c]=h)}function s(h,c,k,R){if(D(c),D(k),D(R),h>=g)return;const t=new F().addVectors(c,k).normalize(),N=new F().addVectors(k,R).normalize(),S=new F().addVectors(R,c).normalize();s(h+1,c,t,S),s(h+1,t,k,N),s(h+1,S,N,R),s(h+1,t,N,S)}for(const h of[-1,1])for(const c of[-1,1])for(const k of[-1,1]){const R=new F(h,0,0),t=new F(0,c,0),N=new F(0,0,k);s(0,R,t,N)}const w=Object.values(o),G=new F(C,C,E),a=new Z,y=typeof i=="function"?new YA:i;for(const h of w)a.setFromUnitVectors(new F(0,0,-1),h),typeof i=="function"&&i(y,h),h.multiplyScalar(I),h.add(A),Q.pushSplat(h,G,a,1,y)}function _k({text:Q,font:A,fontSize:I,color:g,rgb:B,dotRadius:C,textAlign:E,lineHeight:i,objectScale:o}){A=A??"Arial",I=I??32,g=g??new YA(1,1,1),C=C??.8,E=E??"start",i=i??1,o=o??1;const D=Q.split(`
12013
- `),s=document.createElement("canvas"),w=s.getContext("2d");if(!w)throw new Error("Failed to create canvas context");w.font=`${I}px ${A}`,w.textAlign=E;const G=w.measureText(""),a=G.fontBoundingBoxAscent+G.fontBoundingBoxDescent;let y=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;for(let Y=0;Y<D.length;++Y){const K=w.measureText(D[Y]),x=a*i*Y;y=Math.min(y,-K.actualBoundingBoxLeft),h=Math.max(h,K.actualBoundingBoxRight),c=Math.min(c,x-K.actualBoundingBoxAscent),k=Math.max(k,x+K.actualBoundingBoxDescent)}const R=Math.floor(y),t=Math.floor(c),N=Math.ceil(h)-R,S=Math.ceil(k)-t;s.width=N,s.height=S,w.font=`${I}px ${A}`,w.textAlign=E,w.textBaseline="alphabetic",w.fillStyle="#FFFFFF";for(let Y=0;Y<D.length;++Y){const K=a*i*Y-t;w.fillText(D[Y],-R,K)}const J=w.getImageData(0,0,N,S),M=new Uint8Array(J.data.buffer),U=new SI,n=new F,L=new F().setScalar(C*o),H=new Z(0,0,0,1);B=B??new YA(1,1,1);let e=0;for(let Y=0;Y<S;++Y)for(let K=0;K<N;++K){const x=M[e+3];if(x>0){const m=x/255;n.set(K-.5*(N-1),.5*(S-1)-Y,0),n.multiplyScalar(o),U.pushSplat(n,L,H,m,B)}e+=4}const q=new wI({packedSplats:U});return q.recolor=g,q}function $k({url:Q,dotRadius:A,subXY:I,forEachSplat:g}){return A=A??.8,I=Math.max(1,Math.floor(I??1)),new wI({constructSplats:async B=>new Promise((C,E)=>{const i=new Image;i.crossOrigin="anonymous",i.onerror=E,i.onload=()=>{const{width:o,height:D}=i,s=document.createElement("canvas");s.width=o,s.height=D;const w=s.getContext("2d");if(!w){E(new Error("Failed to create canvas context"));return}w.imageSmoothingEnabled=!0,w.imageSmoothingQuality="high";const G=Math.round(o/I),a=Math.round(D/I);w.drawImage(i,0,0,G,a);try{const y=w.getImageData(0,0,G,a),h=new Uint8Array(y.data.buffer),c=new F,k=new F().setScalar(A),R=new Z(0,0,0,1),t=new YA;let N=0;for(let S=0;S<a;++S)for(let J=0;J<G;++J){const M=N*4,U=h[M+3];if(U>0){let n=U/255;t.set(h[M+0]/255,h[M+1]/255,h[M+2]/255),c.set(J-.5*(G-1),.5*(a-1)-S,0),k.setScalar(A),R.set(0,0,0,1);let L=!0;if(g){const H=g(G,a,N,c,k,R,n,t);n=H??n,L=H!==null}L&&B.pushSplat(c,k,R,n,t)}N+=1}C()}catch(y){E(y)}},i.src=Q})})}function nc({box:Q,cells:A,dotScale:I,color:g,opacity:B}){A.x=Math.max(1,Math.round(A.x)),A.y=Math.max(1,Math.round(A.y)),A.z=Math.max(1,Math.round(A.z)),B=B??1;const C=A.x*A.y*A.z,E=_("int",A.x),i=_("int",A.y);_("int",A.z);const o=cI(0),D=new jI({numSplats:C,generator:JA({index:"int"},{gsplat:X},({index:w})=>{if(!w)throw new Error("index is undefined");const G=DB(w,E),a=_g(w,E),y=DB(a,i),h=_g(a,i),c=FI({vectorType:"ivec3",x:G,y,z:h}),k=dD(o),R=FI({vectorType:"ivec2",x:w,y:k}),t=xo(R),N=_("vec3",Q.min),S=_("vec3",Q.max),J=yI(S,N),M=_g(xA(VI(c),t),_("vec3",A));let U,n,L;g?(U=_("float",g.r),n=_("float",g.g),L=_("float",g.b)):{r:U,g:n,b:L}=Dg(M).outputs;const H=FI({vectorType:"vec4",r:U,g:n,b:L,a:_("float",B)}),e=xA(N,RA(J,M)),q=VI(_("float",I)),Y=_("vec4",new Z(0,0,0,1));let K=GI({flags:DQ("uint","GSPLAT_FLAG_ACTIVE"),index:w,center:e,scales:q,quaternion:Y,rgba:H});return K=s.applyGsplat(K),{gsplat:K}},{globals:()=>[rA]}),update:({time:w})=>{o.value=w,s.update(D),D.updateVersion()}}),s=new gg;return D}const ec={box:new dg(new F(-1,-1,-1),new F(1,1,1)),density:100,fallDirection:new F(-1,-3,1).normalize(),fallVelocity:.02,wanderScale:.04,wanderVariance:2,color1:new YA(1,1,1),color2:new YA(.5,.5,1),minScale:.001,maxScale:.005,anisoScale:new F(1,1,1)},Hc={box:new dg(new F(-2,-1,-2),new F(2,5,2)),density:10,fallDirection:new F(0,-1,0),fallVelocity:2,wanderScale:.1,wanderVariance:1,color1:new YA(1,1,1),color2:new YA(.25,.25,.5),minScale:.005,maxScale:.01,anisoScale:new F(.1,1,.1)};function Lc({box:Q,minY:A,numSplats:I,density:g,anisoScale:B,minScale:C,maxScale:E,fallDirection:i,fallVelocity:o,wanderScale:D,wanderVariance:s,color1:w,color2:G,opacity:a,onFrame:y}){Q=Q??new dg(new F(-1,-1,-1),new F(1,1,1));const h=(Q.max.x-Q.min.x)*(Q.max.y-Q.min.y)*(Q.max.z-Q.min.z);g=g??100,I=I??Math.max(1,Math.min(1e6,Math.round(h*g)));const c=cI(C??.001),k=cI(E??.005),R=rI((B?.clone()??new F(1,1,1)).normalize()),t=rI((i??new F(0,-1,0)).normalize()),N=cI(o??.02),S=cI(D??.01),J=cI(s??2),M=rI(w??new YA(1,1,1)),U=rI(G??new YA(.5,.5,1)),n=cI(a??1),L=cI(0),H=rI(new F(0,0,0)),e=rI(Q.min),q=rI(Q.max),Y=cI(A??Number.NEGATIVE_INFINITY),K=yI(q,e),x=new jI({numSplats:I,generator:JA({index:"int"},{gsplat:X},({index:j})=>{if(!j)throw new Error("index not defined");const u=wB(j),CA=Dg(u).outputs.w;let V=VI(u),AA=$g(RA(CA,_("float",100)));AA=sB(RA(DQ("float","PI"),AA)),AA=xA(c,RA(AA,yI(k,c)));const O=RA(AA,R),P=$g(RA(CA,_("float",10))),b=$g(CA),T=qi(M,U,b),p=RA(T,P),SA=wB(FI({vectorType:"ivec2",x:j,y:_("int",6837)}));let GA=VI(SA),tA=RA(Dg(SA).outputs.w,J);tA=xA(L,tA),V=xA(V,H);const NA=Ki(V,_("vec3",new F(1,1,1)));V=xA(e,RA(K,NA));const wA=_("vec4",new Z(0,0,0,1));GA=sB(xA(VI(tA),GA)),GA=RA(GA,S);let aA=xA(V,GA),CI=Dg(aA).outputs.y;CI=di(Y,CI),aA=FI({vector:aA,y:CI});let VA=GI({flags:DQ("uint","GSPLAT_FLAG_ACTIVE"),index:j,center:aA,scales:O,quaternion:wA,rgb:p,opacity:n});return VA=m.applyGsplat(VA),{gsplat:VA}},{globals:()=>[rA]}),update:({object:j,time:u,deltaTime:CA})=>{L.value=u,m.update(x);const V=t.value.clone().multiplyScalar(N.value*CA);H.value.add(V),j.visible=n.value>0,y?.({object:j,time:u,deltaTime:CA}),x.updateVersion()}}),m=new gg;return{snow:x,min:e,max:q,minY:Y,color1:M,color2:U,opacity:n,fallVelocity:N,wanderVariance:J,wanderScale:S,fallDirection:t,minScale:c,maxScale:k,anisoScale:R}}const AR=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_RAIN:Hc,DEFAULT_SNOW:ec,snowBox:Lc,staticBox:nc},Symbol.toStringTag,{value:"Module"}));function dw(Q){return JA({gsplat:X},{gsplat:X},({gsplat:A})=>{if(!A)throw new Error("No gsplat input");let I=CB(A);const g=Q.applyGsplat(A),B=ZA(g).outputs.center,C=CB(g),E=Go(B,C),i=GD(E,_("float",0));I=mB(i,PB(I),I);const o=xA(RA(I,_("float",.5)),_("float",.5));return A=GI({gsplat:A,rgb:o}),{gsplat:A}})}function Yc(Q){Q.enableWorldToView=!0,Q.worldModifier=dw(Q.context.worldToView),Q.updateGenerator()}function qw(Q,A,I,g){return JA({gsplat:X},{gsplat:X},({gsplat:B})=>{if(!B)throw new Error("No gsplat input");let{center:C}=ZA(B).outputs;C=Q.apply(C);const{z:E}=Dg(C).outputs;let i=po(PB(E),A,I);return i=mB(g,yI(_("float",1),i),i),B=GI({gsplat:B,r:i,g:i,b:i}),{gsplat:B}})}function rc(Q,A,I,g){Q.enableWorldToView=!0;const B=_("float",A),C=_("float",I),E=_("bool",g??!1);return Q.worldModifier=qw(Q.context.worldToView,B,C,E),Q.updateGenerator(),{minDepth:B,maxDepth:C,reverse:E}}const IR=Object.freeze(Object.defineProperty({__proto__:null,makeDepthColorModifier:qw,makeNormalColorModifier:dw,setDepthColor:rc,setWorldNormalColor:Yc},Symbol.toStringTag,{value:"Module"})),Kc=1,MC=4,dc=2,qc=5,lc=1/5,gR=!1,xc=(Q,A)=>{var I,g,B,C;return Q.leftIsHand?new F:new F(((I=Q.left)==null?void 0:I.axes[2])??0,(((g=Q.left)==null?void 0:g.buttons[0].value)??0)-(((B=Q.left)==null?void 0:B.buttons[1].value)??0),((C=Q.left)==null?void 0:C.axes[3])??0)},pc=(Q,A)=>{var I;return Q.rightIsHand?new F:new F(((I=Q.right)==null?void 0:I.axes[2])??0,0,0)},fc=(Q,A)=>{var I,g;return Q.rightIsHand?!1:((g=(I=Q.right)==null?void 0:I.buttons[0])==null?void 0:g.pressed)??!1},bc=(Q,A)=>{var I,g;return Q.rightIsHand?!1:((g=(I=Q.right)==null?void 0:I.buttons[1])==null?void 0:g.pressed)??!1};var qQ=(Q=>(Q.w="wrist",Q.t0="thumb-metacarpal",Q.t1="thumb-phalanx-proximal",Q.t2="thumb-phalanx-distal",Q.t3="thumb-tip",Q.i0="index-finger-metacarpal",Q.i1="index-finger-phalanx-proximal",Q.i2="index-finger-phalanx-intermediate",Q.i3="index-finger-phalanx-distal",Q.i4="index-finger-tip",Q.m0="middle-finger-metacarpal",Q.m1="middle-finger-phalanx-proximal",Q.m2="middle-finger-phalanx-intermediate",Q.m3="middle-finger-phalanx-distal",Q.m4="middle-finger-tip",Q.r0="ring-finger-metacarpal",Q.r1="ring-finger-phalanx-proximal",Q.r2="ring-finger-phalanx-intermediate",Q.r3="ring-finger-phalanx-distal",Q.r4="ring-finger-tip",Q.p0="pinky-finger-metacarpal",Q.p1="pinky-finger-phalanx-proximal",Q.p2="pinky-finger-phalanx-intermediate",Q.p3="pinky-finger-phalanx-distal",Q.p4="pinky-finger-tip",Q))(qQ||{});const UI=Object.keys(qQ),uc=UI.length,Pc={w:0,t0:1,t1:2,t2:3,t3:4,i0:5,i1:6,i2:7,i3:8,i4:9,m0:10,m1:11,m2:12,m3:13,m4:14,r0:15,r1:16,r2:17,r3:18,r4:19,p0:20,p1:21,p2:22,p3:23,p4:24},lw={w:.02,t0:.015,t1:.012,t2:.0105,t3:.0085,i0:.022,i1:.012,i2:.0085,i3:.0075,i4:.0065,m0:.021,m1:.012,m2:.008,m3:.0075,m4:.0065,r0:.019,r1:.011,r2:.0075,r3:.007,r4:.006,p0:.012,p1:.01,p2:.007,p3:.0065,p4:.0055},mc=[["w","t0","t1","t2","t3"],["w","i0","i1","i2","i3","i4"],["w","m0","m1","m2","m3","m4"],["w","r0","r1","r2","r3","r4"],["w","p0","p1","p2","p3","p4"]],Tc=[[8,10,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6]],Oc=["t3","i4","m4","r4","p4"],Zc=["i4","m4","r4","p4"];var AC=(Q=>(Q.left="left",Q.right="right",Q))(AC||{});const Vc=Object.keys(AC),Xc=/Quest|OculusBrowser|VisionOS|XRBrowser|Pico|Lynx|MagicLeap/i;function Wc(){const Q=navigator.userAgent??"";if(Xc.test(Q))return!1;if(/Android/i.test(Q)||/Mobile/i.test(Q))return!0;const I=navigator.userAgentData;return I&&typeof I.mobile=="boolean"?I.mobile:!1}const BI=class xw{constructor(A){this.lastControllersUpdate=0,this.hands=[],this.renderer=A.renderer,this.xr=navigator.xr,this.mode="initializing",this.onEnterXr=A.onEnterXr,this.onExitXr=A.onExitXr,this.enableHands=A.enableHands??!1,this.controllers=A.controllers,Promise.resolve().then(()=>{var I;if(!this.xr){this.mode="not_supported";return}if(!A.allowMobileXr&&Wc()){this.mode="not_supported";return}this.enableHands&&(this.hands=[new kQ("left"),new kQ("right")]);let g,B;if(A.element?g=A.element:A.elementId?g=document.getElementById(A.elementId)??void 0:(g=xw.createButton(),B=A.button==null||typeof A.button=="boolean"?{}:A.button),!g)throw new Error("No element or button provided");g.style.display="none",g.classList.add("hidden"),this.button=B,this.element=g;const C=(I=A.onMouseLeaveOpacity)==null?void 0:I.toString();return C!==void 0&&(g.addEventListener("mouseleave",()=>{g.style.opacity=C}),g.addEventListener("mouseenter",()=>{g.style.opacity=""})),this.initializeXr(A)}).then(()=>{var I;return(I=A.onReady)==null?void 0:I.call(A,this.mode!=="not_supported")}).catch(I=>{alert(`Error initializing SparkXr: ${I}`)})}async initializeXr(A){var I,g;if(!this.xr||!this.element)return;const B=this.element,C={vr:["immersive-vr"],ar:["immersive-ar"],arvr:["immersive-ar","immersive-vr"],vrar:["immersive-vr","immersive-ar"]}[A.mode??"vrar"];if(!C)throw new Error(`Invalid mode: ${A.mode}`);let E=null;for(const w of C)if(await this.xr.isSessionSupported(w)){E=w;break}if(!E){this.mode="not_supported";return}this.mode=E;const i=A.referenceSpaceType??"local";this.renderer.xr.enabled=!0,this.renderer.xr.setReferenceSpaceType(i),A.fixedFoveation!==void 0&&this.renderer.xr.setFoveation(A.fixedFoveation);const o=A.frameBufferScaleFactor??.5;this.renderer.xr.setFramebufferScaleFactor(o);const D=((I=A.sessionInit)==null?void 0:I.optionalFeatures)??[];A.enableHands&&D.push("hand-tracking");const s=((g=A.sessionInit)==null?void 0:g.requiredFeatures)??[];s.push(i),this.sessionInit={...A.sessionInit,optionalFeatures:D,requiredFeatures:s},B.addEventListener("click",()=>{this.toggleXr()}),this.updateElement()}async toggleXr(){var A,I,g;if(!(!this.xr||!this.sessionInit))if(this.session)this.session.end();else try{const B=this.mode,C=await this.xr.requestSession(B,this.sessionInit);this.session=C;const E=()=>{var D;C?.removeEventListener("end",E),C?.removeEventListener("visibilitychange",o),this.session=void 0,this.updateElement(),(D=this.onExitXr)==null||D.call(this)};let i=C.visibilityState;const o=()=>{C?.visibilityState==="visible-blurred"&&i==="visible"&&C?.end(),i=C?.visibilityState};return(A=this.session)==null||A.addEventListener("end",E),(I=this.session)==null||I.addEventListener("visibilitychange",o),await this.renderer.xr.setSession(this.session),(g=this.onEnterXr)==null?void 0:g.call(this)}catch(B){console.error("Error requesting XR session",B);return}}updateElement(){const A=this.mode,I=this.element;if(I){I.style.display="",I.classList.remove("hidden");const g=typeof this.button=="boolean"?{}:this.button;if(g){if(this.session){const B=(A==="immersive-vr"?g.exitVrHtml:g.exitArHtml)??g.exitXrHtml,C=(A==="immersive-vr"?g.exitVrText:g.exitArText)??g.exitXrText;B?I.innerHTML=B:C?I.textContent=C:I.textContent=A==="immersive-vr"?"EXIT VR":"EXIT AR"}else{const B=(A==="immersive-vr"?g.enterVrHtml:g.enterArHtml)??g.enterXrHtml,C=(A==="immersive-vr"?g.enterVrText:g.enterArText)??g.enterXrText;B?I.innerHTML=B:C?I.textContent=C:I.textContent=A==="immersive-vr"?"ENTER VR":"ENTER AR"}I.style.display=""}}}static createButton(){const A=document.createElement("button");return Object.assign(A.style,{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",padding:"40px 40px",border:"2px solid #fff",borderRadius:"16px",background:"rgba(0,0,0,0.1)",color:"#fff",font:"bold 28px sans-serif",textAlign:"center",userSelect:"none",zIndex:"999"}),document.body.appendChild(A),A}xrSupported(){return!!this.xr}left(){return this.hands[0]}right(){return this.hands[1]}updateControllers(A){var I,g,B,C,E,i,o,D,s,w,G,a;const y=A.parent,h=performance.now(),c=(h-(this.lastControllersUpdate||h))/1e3;this.lastControllersUpdate=h;const k={};for(const S of((I=this.renderer.xr.getSession())==null?void 0:I.inputSources)??[]){const J=S.gamepad;J&&(S.handedness==="left"||S.handedness==="right")&&(k[S.handedness]=J,S.handedness==="left"?k.leftIsHand=!!S.hand:S.handedness==="right"&&(k.rightIsHand=!!S.hand))}const R=(((g=this.controllers)==null?void 0:g.getRotate)??pc)(k,this);if(R.multiply(new F(((B=this.controllers)==null?void 0:B.rotateSpeed)??MC,((C=this.controllers)==null?void 0:C.rotateSpeed)??MC,((E=this.controllers)==null?void 0:E.rollSpeed)??dc)),R.manhattanLength()>0){R.multiplyScalar(c);const S=new Lg(-R.y,-R.x,R.z,"YXZ"),J=new Z().setFromEuler(S),M=A.getWorldPosition(new F);(i=y.parent)==null||i.worldToLocal(M),y.position.sub(M),y.position.applyQuaternion(J),y.position.add(M),y.quaternion.premultiply(J)}const t=(((o=this.controllers)==null?void 0:o.getMove)??xc)(k,this);let N=((D=this.controllers)==null?void 0:D.moveSpeed)??Kc;(((s=this.controllers)==null?void 0:s.getFast)??fc)(k,this)&&(N*=qc),(((w=this.controllers)==null?void 0:w.getSlow)??bc)(k,this)&&(N*=lc),(G=this.controllers)!=null&&G.moveHeading?t.applyQuaternion(A.quaternion):(a=this.controllers)!=null&&a.moveDirection&&(Xg.setFromQuaternion(A.quaternion,"YXZ"),Xg.x=0,Xg.z=0,hB.setFromEuler(Xg),t.applyQuaternion(hB)),t.applyQuaternion(y.quaternion),t.multiplyScalar(c*N),y.position.add(t)}updateHands({xrFrame:A}){const I=this.renderer.xr.getSession();if(!I)return;const g=this.renderer.xr.getReferenceSpace();if(g&&A.getJointPose){for(const B of this.hands)B&&(B.lastJoints=B.joints,B.joints=void 0);for(const B of I.inputSources){if(!B.hand)continue;const C=B.handedness,E=this.hands[C==="left"?0:1];if(E)for(const i of UI){const o=B.hand.get(qQ[i]);if(o){const D=A.getJointPose(o,g);if(D){const{position:s,orientation:w}=D.transform;E.joints||(E.joints={}),E.joints[i]={position:new F(s.x,s.y,s.z),quaternion:new Z(w.x,w.y,w.z,w.w),radius:lw[i]}}}}}}}makeJointSplats(A){const I=new Qk(A);return I.onFrame=()=>{const g=this.hands[A==="left"?0:1],B=g?.joints;I.updateJoints(B)},I}snapshotHands(A){var I,g;const B=[(I=this.hands[0])==null?void 0:I.snapshotJoints(),(g=this.hands[1])==null?void 0:g.snapshotJoints()];return{time:A,hands:B}}};BI.JointEnum=qQ;BI.JOINT_IDS=UI;BI.NUM_JOINTS=uc;BI.JOINT_INDEX=Pc;BI.JOINT_RADIUS=lw;BI.JOINT_SEGMENTS=mc;BI.JOINT_SEGMENT_STEPS=Tc;BI.JOINT_TIPS=Oc;BI.FINGER_TIPS=Zc;BI.Hand=AC;BI.HANDS=Vc;let QR=BI;const jQ=Q=>Math.round(Q*1e4)/1e4,Xg=new Lg(0,0,0,"YXZ"),hB=new Z,jc=new Z;function BR(Q,A){if(!Q.length)return null;const I=Q[0],g=Q[Q.length-1];if(A<I.time||A>g.time)return null;const B=_c(Q,A);if(B===-1)return null;const C=Q[B],E=Q[B+1];if(!E)return zc(C,A);const i=E.time-C.time,o=i>0?(A-C.time)/i:0;return vc(C,E,o,A)}function vc(Q,A,I,g){const B=Math.max(Q.hands.length,A.hands.length),C=Array.from({length:B},(E,i)=>$c(Q.hands[i],A.hands[i],I));return{time:g,hands:C}}function zc(Q,A){return{time:A,hands:Q.hands.map(I=>Ik(I))}}class kQ{constructor(A){this.hand=A}static newFromSnapshot(A,I){const g=new kQ(A);g.joints={};for(const B of UI){const C=I[B];C&&(g.joints[B]={position:new F(C.pos[0],C.pos[1],C.pos[2]),quaternion:new Z(C.quat[0],C.quat[1],C.quat[2],C.quat[3]),radius:C.radius})}return g}valid(){return!!this.joints}snapshotJoints(){if(!this.joints)return;const A={};for(const I of UI){const g=this.joints[I];g&&(A[I]={pos:g.position.toArray().map(jQ),quat:g.quaternion.toArray().map(jQ),radius:jQ(g.radius)})}return A}toFlatArray(){if(!this.joints)return;const A=new Float32Array(176);A[0]=this.hand==="left"?0:1;let I=1;for(const g of UI){const B=this.joints[g];B&&(A[I]=B.position.x,A[I+1]=B.position.y,A[I+2]=B.position.z,A[I+3]=B.quaternion.x,A[I+4]=B.quaternion.y,A[I+5]=B.quaternion.z,A[I+6]=B.quaternion.w),I+=7}return A}}function _c(Q,A){let I=0,g=Q.length-1;for(;I<=g;){const B=I+g>>1;Q[B].time<=A?I=B+1:g=B-1}return g}function $c(Q,A,I=0){if(!Q||!A)return;const g={};for(const B of UI){const C=Ak(Q[B],A[B],I);C&&(g[B]=C)}return g}function Ak(Q,A,I=0){if(!Q||!A)return;const g=Q.pos.map((E,i)=>E+(A.pos[i]-E)*I),B=hB.fromArray(Q.quat).slerp(jc.fromArray(A.quat),I).toArray(),C=Q.radius+(A.radius-Q.radius)*I;return{pos:g,quat:B,radius:C}}function Ik(Q){if(!Q)return;const A={};for(const I of UI){const g=Q[I];g&&(A[I]=gk(g))}return A}function gk(Q){return{pos:[...Q.pos],quat:[...Q.quat],radius:Q.radius}}class Qk extends wI{constructor(A){super({}),this.scratchCenter=new F,this.scratchQuat=new Z(0,0,0,1),this.scratchScales=new F().setScalar(.01),this.scratchColor=new YA(1,1,1),this.hand=A}updateJoints(A){if(this.visible=!1,!A||!this.packedSplats)return;this.visible=!0;let I=0;for(const g of UI){const B=A[g];if(!B)continue;this.scratchCenter.copy(B.position),this.scratchQuat.copy(B.quaternion),this.scratchScales.set(B.radius,.75*B.radius,1.5*B.radius),this.packedSplats.setSplat(I,this.scratchCenter,this.scratchScales,this.scratchQuat,.75,this.scratchColor),I+=1}this.packedSplats.numSplats=I,this.packedSplats.needsUpdate=!0,this.numSplats=I,this.updateVersion()}}const Bk=.5,Ck=.5,Ek=0;var IC=(Q=>(Q.w="wrist",Q.t0="thumb-metacarpal",Q.t1="thumb-phalanx-proximal",Q.t2="thumb-phalanx-distal",Q.t3="thumb-tip",Q.i0="index-finger-metacarpal",Q.i1="index-finger-phalanx-proximal",Q.i2="index-finger-phalanx-intermediate",Q.i3="index-finger-phalanx-distal",Q.i4="index-finger-tip",Q.m0="middle-finger-metacarpal",Q.m1="middle-finger-phalanx-proximal",Q.m2="middle-finger-phalanx-intermediate",Q.m3="middle-finger-phalanx-distal",Q.m4="middle-finger-tip",Q.r0="ring-finger-metacarpal",Q.r1="ring-finger-phalanx-proximal",Q.r2="ring-finger-phalanx-intermediate",Q.r3="ring-finger-phalanx-distal",Q.r4="ring-finger-tip",Q.p0="pinky-finger-metacarpal",Q.p1="pinky-finger-phalanx-proximal",Q.p2="pinky-finger-phalanx-intermediate",Q.p3="pinky-finger-phalanx-distal",Q.p4="pinky-finger-tip",Q))(IC||{});const pw=Object.keys(IC),CR=pw.length,ER={w:0,t0:1,t1:2,t2:3,t3:4,i0:5,i1:6,i2:7,i3:8,i4:9,m0:10,m1:11,m2:12,m3:13,m4:14,r0:15,r1:16,r2:17,r3:18,r4:19,p0:20,p1:21,p2:22,p3:23,p4:24},Wg={w:.02,t0:.02,t1:.014,t2:.0115,t3:.0085,i0:.022,i1:.012,i2:.0085,i3:.0075,i4:.0065,m0:.021,m1:.012,m2:.008,m3:.0075,m4:.0065,r0:.019,r1:.011,r2:.0075,r3:.007,r4:.006,p0:.012,p1:.01,p2:.007,p3:.0065,p4:.0055},ik=[["w","t0","t1","t2","t3"],["w","i0","i1","i2","i3","i4"],["w","m0","m1","m2","m3","m4"],["w","r0","r1","r2","r3","r4"],["w","p0","p1","p2","p3","p4"]],Dk=[[8,10,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6]],iR=["t3","i4","m4","r4","p4"],DR=["i4","m4","r4","p4"];var fw=(Q=>(Q.left="left",Q.right="right",Q))(fw||{});const yB=Object.keys(fw);class oR{constructor(){this.hands={},this.last={},this.values={},this.tests={},this.lastTests={},this.updated=!1}update({xr:A,xrFrame:I}){const g=A.getSession();if(!g)return;const B=A.getReferenceSpace();if(B&&I.getJointPose){this.last=this.hands,this.lastTests=this.tests,this.hands={},this.values={},this.tests={};for(const C of g.inputSources){if(!C.hand)continue;const E=C.handedness;this.hands[E]={};for(const i of pw){const o=C.hand.get(IC[i]);if(o){const D=I.getJointPose(o,B);if(D){const{position:s,orientation:w}=D.transform;this.hands[E][i]={position:new F(s.x,s.y,s.z),quaternion:new Z(w.x,w.y,w.z,w.w),radius:D.radius||.001}}}}}for(const C of yB)for(const{key:E,value:i}of[{key:`${C}AllTips`,value:this.allTipsTouching(C)},{key:`${C}IndexThumb`,value:this.touching(C,"i4",C,"t3")},{key:`${C}MiddleThumb`,value:this.touching(C,"m4",C,"t3")},{key:`${C}RingThumb`,value:this.touching(C,"r4",C,"t3")},{key:`${C}PinkyThumb`,value:this.touching(C,"p4",C,"t3")},{key:`${C}TriTips`,value:this.triTipsTouching(C)}])this.values[E]=i,this.tests[E]=i===1?!0:i===0?!1:this.lastTests[E]??!1}}makeGhostMesh(){const A=new F,I=new F(.01,.01,.01),g=new Z(0,0,0,1),B=new YA(1,1,1),C=Math.PI*3;new YA(1,1,1);let E=1;const i=new wI({onFrame:()=>{if(!i.packedSplats)return;let o=0;for(const D of yB){const s=this.hands[D];for(const[w,G]of ik.entries())for(let a=1;a<G.length;++a){const y=Dk[w][a-1]*2,h=a+1===G.length,c=s?.[G[a-1]],k=s?.[G[a]];for(let R=0;R<y;++R){const t=(R+.5)/y;if(E=0,c&&k){A.copy(c.position).lerp(k.position,t),g.copy(c.quaternion).slerp(k.quaternion,t);const N=Wg[G[a-1]],S=Wg[G[a]];let J=(1-t)*N+t*S;h&&t>.8&&(J*=Math.sqrt(1-((t-.8)/.2)**2)),I.set(.65*J,.5*J,.003),B.set(.55+.45*Math.sin(A.x*C),.55+.45*Math.sin(A.y*C),.55+.45*Math.sin(A.z*C)),D==="right"&&B.set(1-B.r,1-B.g,1-B.b),E=.75}i.packedSplats.setSplat(o,A,I,g,E,B),o+=1}}}i.packedSplats.numSplats=o,i.packedSplats.needsUpdate=!0,i.numSplats=o,i.updateVersion()}});return i}distance(A,I,g,B,C=!1){const E=C?this.last[A]:this.hands[A],i=C?this.last[g]:this.hands[g],o=E?.[I],D=i?.[B];return!o||!D?Number.POSITIVE_INFINITY:o.position.distanceTo(D.position)}separation(A,I,g,B,C=!1){const E=this.distance(A,I,g,B,C);return E===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:E-Wg[I]-Wg[B]}touching(A,I,g,B,C=!1){const E=this.separation(A,I,g,B,C);return E===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:1-Math.max(0,Math.min(1,E/.01-Ek))}allTipsTouching(A,I=!1){return Math.min(this.touching(A,"t3",A,"i4",I),this.touching(A,"i4",A,"m4",I),this.touching(A,"m4",A,"r4",I),this.touching(A,"r4",A,"p4",I))}triTipsTouching(A,I=!1){return Math.min(this.touching(A,"t3",A,"i4",I),this.touching(A,"i4",A,"m4",I),this.touching(A,"m4",A,"t3",I))}}class wR{constructor({xrHands:A,control:I,moveInertia:g,rotateInertia:B}){this.lastGrip={},this.lastPivot=new F,this.rotateVelocity=0,this.velocity=new F,this.xrHands=A,this.control=I,this.moveInertia=g??Bk,this.rotateInertia=B??Ck}update(A){var I,g,B,C,E;const i={};for(const s of yB){const w=this.xrHands.hands[s];w&&this.xrHands.tests[`${s}MiddleThumb`]&&(i[s]=new F().add(((I=w.t3)==null?void 0:I.position)??new F).add(((g=w.i4)==null?void 0:g.position)??new F).add(((B=w.m4)==null?void 0:B.position)??new F).add(((C=w.r4)==null?void 0:C.position)??new F).add(((E=w.p4)==null?void 0:E.position)??new F).multiplyScalar(1/5))}if(i.left&&i.right&&this.lastGrip.left&&this.lastGrip.right){const s=i.left.clone().add(i.right).multiplyScalar(.5),w=this.lastGrip.left.clone().add(this.lastGrip.right).multiplyScalar(.5);this.lastPivot=s;const G=s.clone().applyMatrix4(this.control.matrix);G.sub(w.clone().applyMatrix4(this.control.matrix)),G.multiplyScalar(1/A),this.velocity.lerp(G,1-Math.exp(-20*A));const a=Math.atan2(i.left.z-s.z,i.left.x-s.x),y=Math.atan2(this.lastGrip.left.z-w.z,this.lastGrip.left.x-w.x);let h=a-y;h>Math.PI?h-=Math.PI*2:h<-Math.PI&&(h+=Math.PI*2);const c=h/A,k=Math.exp(-20*A);this.rotateVelocity=this.rotateVelocity*k+c*(1-k)}else if(this.rotateVelocity*=Math.exp(-A/this.rotateInertia),i.left&&this.lastGrip.left){const s=i.left.clone().applyMatrix4(this.control.matrix);s.sub(this.lastGrip.left.clone().applyMatrix4(this.control.matrix)),s.multiplyScalar(1/A),this.velocity.lerp(s,1-Math.exp(-20*A))}else if(i.right&&this.lastGrip.right){const s=i.right.clone().applyMatrix4(this.control.matrix);s.sub(this.lastGrip.right.clone().applyMatrix4(this.control.matrix)),s.multiplyScalar(1/A),this.velocity.lerp(s,1-Math.exp(-20*A))}else this.velocity.multiplyScalar(Math.exp(-A/this.moveInertia));const o=this.lastPivot.clone().negate(),D=new FA().makeTranslation(o).premultiply(new FA().makeRotationY(this.rotateVelocity*A)).premultiply(new FA().makeTranslation(this.lastPivot));this.control.matrix.multiply(D),this.control.matrix.decompose(this.control.position,this.control.quaternion,this.control.scale),this.control.updateMatrixWorld(!0),this.control.position.sub(this.velocity.clone().multiplyScalar(A)),this.lastGrip=i}}const ok=1,wk=2,sk=.002,Gk=.006,ak=.0015,hk=.15,yk=.15,ck=.1,kk=2,Rk=0,Fk=500,Sk=500,tk=200,Nk=400,Mk=25,kI=1e-4,Jk={KeyW:new F(0,0,-1),KeyS:new F(0,0,1),KeyA:new F(-1,0,0),KeyD:new F(1,0,0),KeyE:new F(0,1,0),KeyQ:new F(0,-1,0)},Uk={ArrowUp:new F(0,0,-1),ArrowDown:new F(0,0,1),ArrowLeft:new F(-1,0,0),ArrowRight:new F(1,0,0),PageUp:new F(0,1,0),PageDown:new F(0,-1,0)};new F(0,0,1),new F(0,0,-1);const nk={Home:new F(0,-1,0),End:new F(0,1,0),Insert:new F(-1,0,0),Delete:new F(1,0,0)};class sR{constructor({canvas:A}){this.lastTime=0,this.fpsMovement=new ek({}),this.pointerControls=new Hk({canvas:A})}update(A,I){const g=performance.now(),B=(g-(this.lastTime||g))/1e3;this.lastTime=g;let C=this.fpsMovement.update(B,A);return this.pointerControls.update(B,A,I)&&(C=!0),C}}class ek{constructor({moveSpeed:A,rollSpeed:I,stickThreshold:g,rotateSpeed:B,keycodeMoveMapping:C,keycodeRotateMapping:E,gamepadMapping:i,capsMultiplier:o,shiftMultiplier:D,ctrlMultiplier:s,xr:w}={}){this.enable=!0,this.extraMove=new F,this.moveSpeed=A??ok,this.rollSpeed=I??wk,this.stickThreshold=g??ck,this.rotateSpeed=B??kk,this.keycodeMoveMapping=C??{...Jk,...Uk},this.keycodeRotateMapping=E??{...nk},this.gamepadMapping=i??{4:"rollLeft",5:"rollRight",6:"ctrl",7:"shift"},this.capsMultiplier=o??10,this.shiftMultiplier=D??5,this.ctrlMultiplier=s??1/5,this.xr=w,this.keydown={},this.keycode={},document.addEventListener("keydown",G=>{this.keydown[G.key]=!0,this.keycode[G.code]=!0}),document.addEventListener("keyup",G=>{this.keydown[G.key]=!1,this.keycode[G.code]=!1}),window.addEventListener("blur",()=>{this.keydown={},this.keycode={}})}update(A,I){var g,B;if(!this.enable)return!1;const C=[new OA,new OA],E=navigator.getGamepads()[0];E&&(C[0].set(E.axes[0],E.axes[1]),C[1].set(E.axes[2],E.axes[3]));const i=E?.buttons.map(a=>a.pressed)||[],o=Array.from(((B=(g=this.xr)==null?void 0:g.getSession())==null?void 0:B.inputSources)??[]);for(const a of o){const y=a.gamepad;if(y)switch(a.handedness){case"none":{C[0].x+=y.axes[0],C[0].y+=y.axes[1],C[1].x+=y.axes[2],C[1].y+=y.axes[3];break}case"left":{C[0].x+=y.axes[2],C[0].y+=y.axes[3];break}case"right":{C[1].x+=y.axes[2],C[1].y+=y.axes[3];break}}}for(const a of C)a.x=Math.abs(a.x)>=this.stickThreshold?a.x:0,a.y=Math.abs(a.y)>=this.stickThreshold?a.y:0;const D=new F(C[1].x,C[1].y,0).multiplyScalar(this.rotateSpeed);for(const[a,y]of Object.entries(this.keycodeRotateMapping))this.keycode[a]&&D.add(y);for(const a in this.gamepadMapping)if(i[Number.parseInt(a)])switch(this.gamepadMapping[a]){case"rollLeft":D.z+=1;break;case"rollRight":D.z-=1;break}D.multiply(new F(this.rotateSpeed,this.rotateSpeed,this.rollSpeed));let s=D.length()>kI;if(D.manhattanLength()>0){D.multiplyScalar(A);const a=new Lg().setFromQuaternion(I.quaternion,"YXZ");a.y-=D.x,a.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,a.x-D.y)),a.z=Math.max(-Math.PI,Math.min(Math.PI,a.z+D.z)),I.quaternion.setFromEuler(a)}const w=new F(C[0].x,0,C[0].y);w.add(this.extraMove);for(const[a,y]of Object.entries(this.keycodeMoveMapping))this.keycode[a]&&w.add(y);let G=1;this.keydown.CapsLock&&(G*=this.capsMultiplier),(this.keycode.ShiftLeft||this.keycode.ShiftRight)&&(G*=this.shiftMultiplier),(this.keycode.ControlLeft||this.keycode.ControlRight)&&(G*=this.ctrlMultiplier);for(const a in this.gamepadMapping)if(i[Number.parseInt(a)])switch(this.gamepadMapping[a]){case"shift":G*=this.shiftMultiplier;break;case"ctrl":G*=this.ctrlMultiplier;break}return w.length()>kI&&(s=!0),w.applyQuaternion(I.quaternion),I.position.add(w.multiplyScalar(this.moveSpeed*G*A)),s}}class Hk{constructor({canvas:A,rotateSpeed:I,slideSpeed:g,scrollSpeed:B,swapRotateSlide:C,reverseRotate:E,reverseSlide:i,reverseSwipe:o,reverseScroll:D,moveInertia:s,rotateInertia:w,pointerRollScale:G,doublePress:a,pressMoveDelayMs:y,pressMoveAccelMs:h,pressMoveSpeed:c,doublePressMoveSpeed:k,triplePressMoveSpeed:R,pressMoveCenter:t}){this.enable=!0,this.canvas=A,this.rotateSpeed=I??sk,this.slideSpeed=g??Gk,this.scrollSpeed=B??ak,this.swapRotateSlide=C??!1,this.reverseRotate=E??(HB()||rg()),this.reverseSlide=i??!1,this.reverseSwipe=o??!1,this.reverseScroll=D??!1,this.moveInertia=s??yk,this.rotateInertia=w??hk,this.pointerRollScale=G??Rk,this.doublePress=a??(()=>{}),this.doublePressLimitMs=Nk,this.doublePressDistance=Mk,this.pressMoveDelayMs=y??Fk,this.pressMoveAccelMs=h??Sk,this.pressMoveSpeed=c??0,this.doublePressMoveSpeed=k??this.pressMoveSpeed*5,this.triplePressMoveSpeed=R??this.doublePressMoveSpeed*5,this.pressMoveCenter=t??!0,this.doublePressed=void 0,this.triplePressed=!1,this.lastUp=null,this.lastLastUp=null,this.rotating=null,this.sliding=null,this.lastDown=null,this.dualPress=!1,this.scroll=new F,this.rotateVelocity=new F,this.moveVelocity=new F,A.addEventListener("pointerdown",S=>{const J=this.getPointerPosition(S),M=J.clone(),U=J.clone(),n=!this.swapRotateSlide&&!this.rotating&&(S.pointerType!=="mouse"||S.button===0)||this.swapRotateSlide&&this.sliding&&!this.rotating&&(S.pointerType!=="mouse"||S.button===1),{pointerId:L}=S,H=performance.now();if(n)this.rotating={initial:M,last:U,position:J,pointerId:L,timeStamp:H},this.lastDown=this.rotating,A.setPointerCapture(S.pointerId),this.dualPress=!1;else if(!this.sliding){const e=S.pointerType==="mouse"?S.button:void 0;this.sliding={initial:M,last:U,position:J,pointerId:L,button:e,timeStamp:H},this.lastDown=this.sliding,A.setPointerCapture(S.pointerId),this.dualPress=this.rotating!=null&&H-this.rotating.timeStamp<tk}if(this.lastUp){const e=this.lastUp.position.distanceTo(J),q=H-this.lastUp.timeStamp;if(e<this.doublePressDistance&&q<this.doublePressLimitMs&&(this.doublePressed=performance.now(),this.triplePressed=!1,this.lastLastUp)){const Y=this.lastLastUp.position.distanceTo(this.lastUp.position),K=this.lastUp.timeStamp-this.lastLastUp.timeStamp;Y<this.doublePressDistance&&K<this.doublePressLimitMs&&(this.triplePressed=!0)}}});const N=S=>{var J,M;((J=this.rotating)==null?void 0:J.pointerId)===S.pointerId?(this.rotating=null,A.releasePointerCapture(S.pointerId),this.dualPress&&this.sliding&&(A.releasePointerCapture(this.sliding.pointerId),this.sliding=null)):((M=this.sliding)==null?void 0:M.pointerId)===S.pointerId&&(this.sliding=null,A.releasePointerCapture(S.pointerId),this.dualPress&&this.rotating&&(A.releasePointerCapture(this.rotating.pointerId),this.rotating=null)),this.doublePressed=void 0,this.triplePressed=!1;const U=this.getPointerPosition(S),n=this.lastUp;this.lastLastUp=this.lastUp;const L=performance.now();if(this.lastUp={position:U,timeStamp:L},n&&n.position.distanceTo(U)<this.doublePressDistance){const e=L-n.timeStamp;e<this.doublePressLimitMs&&this.doublePress({position:U,intervalMs:e})}};document.addEventListener("pointerup",N),document.addEventListener("pointercancel",N),document.addEventListener("pointermove",S=>{var J,M;((J=this.rotating)==null?void 0:J.pointerId)===S.pointerId?this.rotating.position=this.getPointerPosition(S):((M=this.sliding)==null?void 0:M.pointerId)===S.pointerId&&(this.sliding.position=this.getPointerPosition(S))}),A.addEventListener("contextmenu",S=>{S.preventDefault()}),A.addEventListener("wheel",S=>{this.scroll.add(new F(S.deltaX,S.deltaY,S.deltaZ)),S.preventDefault()})}getPointerPosition(A){const I=this.canvas.getBoundingClientRect();return new OA(A.clientX-I.left,A.clientY-I.top)}update(A,I,g){var B,C;if(!this.enable)return!1;const E=performance.now();let i=!1;if(this.dualPress&&this.rotating&&this.sliding){const D=[this.rotating.position.clone().sub(this.rotating.last),this.sliding.position.clone().sub(this.sliding.last)],s=D[0].dot(D[1]);if(s>=.2){const w=D[0].clone().add(D[1]),G=new F(w.x,-w.y,0);G.multiplyScalar(this.slideSpeed*(this.reverseSwipe?1:-1)),G.applyQuaternion(I.quaternion),I.position.add(G),this.moveVelocity=G.clone().multiplyScalar(1/A),G.length()>kI&&(i=!0)}else if(s<=-.2){const w=this.sliding.last.clone().sub(this.rotating.last),G=w.length();w.multiplyScalar(1/G).normalize();const a=new OA(-w.y,w.x),y=[D[0].dot(w),D[1].dot(w)],h=[D[0].dot(a),D[1].dot(a)],c=this.rotating.last.clone().add(this.sliding.last).multiplyScalar(.5);let k=new F;const R=g??(I instanceof zQ?I:void 0);if(R){const U=new OA(c.x/this.canvas.clientWidth*2-1,-(c.y/this.canvas.clientHeight)*2+1),n=new QC;n.setFromCamera(U,R),k=n.ray.direction}const t=y[1]-y[0],N=k.multiplyScalar(t*this.slideSpeed);I.position.add(N),this.moveVelocity=N.clone().multiplyScalar(1/A),N.length()>kI&&(i=!0);const S=[Math.atan(h[0]/(-.5*G)),Math.atan(h[1]/(.5*G))],J=.5*(S[0]+S[1])*this.pointerRollScale,M=new Lg().setFromQuaternion(I.quaternion,"YXZ");M.z=Math.max(-Math.PI,Math.min(Math.PI,M.z+.5*J)),I.quaternion.setFromEuler(M),Math.abs(J)>kI&&(i=!0)}this.rotating.last.copy(this.rotating.position),this.sliding.last.copy(this.sliding.position)}else{const D=new F;if(this.rotating&&!this.dualPress){const w=this.rotating.position.clone().sub(this.rotating.last);this.rotating.last.copy(this.rotating.position),D.set(w.x,w.y,0),D.multiplyScalar(this.rotateSpeed*(this.reverseRotate?-1:1)),this.rotateVelocity=D.clone().multiplyScalar(1/A),D.length()>kI&&(i=!0)}else this.rotateVelocity.multiplyScalar(Math.exp(-A/this.rotateInertia)),D.addScaledVector(this.rotateVelocity,A),this.rotateVelocity.length()*.1>kI&&(i=!0);const s=new Lg().setFromQuaternion(I.quaternion,"YXZ");if(s.y-=D.x,s.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,s.x-D.y)),s.z*=Math.exp(-0*A),I.quaternion.setFromEuler(s),this.sliding&&!this.dualPress){const w=this.sliding.position.clone().sub(this.sliding.last);this.sliding.last.copy(this.sliding.position);const G=this.sliding.button!==2?new F(w.x,0,w.y):new F(w.x,-w.y,0);G.multiplyScalar(this.slideSpeed*(this.reverseSlide?-1:1)),G.applyQuaternion(I.quaternion),I.position.add(G),this.moveVelocity=G.clone().multiplyScalar(1/A),G.length()>kI&&(i=!0)}else{const w=new F;if(this.sliding||this.rotating){const a=((B=this.lastDown)==null?void 0:B.last)??new OA,y=g??(I instanceof zQ?I:void 0);if(y){const h=this.pressMoveCenter?new OA(0,0):new OA(a.x/this.canvas.clientWidth*2-1,-(a.y/this.canvas.clientHeight)*2+1),c=new QC;c.setFromCamera(h,y),w.copy(c.ray.direction).normalize()}if(this.doublePressed){this.pressHeld=!1;let h=(performance.now()-this.doublePressed)/this.pressMoveAccelMs;h=Math.max(0,Math.min(1,h)),w.multiplyScalar((this.triplePressed?this.triplePressMoveSpeed:this.doublePressMoveSpeed)*h)}else{let h=0;this.lastDown&&(h=(E-(((C=this.lastDown)==null?void 0:C.timeStamp)??E)-this.pressMoveDelayMs)/this.pressMoveAccelMs,this.lastDown.position.distanceTo(this.lastDown.initial)<this.doublePressDistance?this.pressHeld===void 0&&h>0&&(this.pressHeld=!0):this.pressHeld===void 0&&(this.pressHeld=!1)),this.pressHeld?w.multiplyScalar(this.pressMoveSpeed*Math.max(0,Math.min(1,h))):w.set(0,0,0)}}else this.pressHeld=void 0;const G=Math.exp(-A/this.moveInertia);this.moveVelocity.lerpVectors(w,this.moveVelocity,G),I.position.addScaledVector(this.moveVelocity,A),this.moveVelocity.length()*.1>kI&&(i=!0)}}const o=this.scroll.multiplyScalar(this.scrollSpeed);return o.set(o.x,o.z,o.y),this.reverseScroll&&o.multiplyScalar(-1),o.applyQuaternion(I.quaternion),I.position.add(o),o.length()>kI&&(i=!0),this.scroll.set(0,0,0),i}}const Lk=`
12012
+ `)}}).outputs.covsplat}function Pk({splats:Q,extents:A,stepSize:I=1,pointRadius:g=.01,pointShadowScale:B=2,opacity:C=1,color:E}){const o=new F,D=new F,s=new Z(0,0,0,1);E==null&&(E=(G,a)=>G.set(.55+.45*Math.cos(a.x*1),.55+.45*Math.cos(a.y*1),.55+.45*Math.cos(a.z*1)));const w=new YA;for(let G=A.min.z;G<A.max.z+1e-6;G+=I)for(let a=A.min.y;a<A.max.y+1e-6;a+=I)for(let y=A.min.x;y<A.max.x+1e-6;y+=I){o.set(y,a,G);for(let h=0;h<2;++h)D.setScalar(g*(h?1:B)),h?typeof E=="function"?E(w,o):w.copy(E):w.setScalar(0),Q.pushSplat(o,D,s,C,w)}}function mk({splats:Q,scale:A=.25,axisRadius:I=.0075,axisShadowScale:g=2,origins:B=[new F]}){const C=new F,E=new F,i=new Z(0,0,0,1),o=new YA,D=1;for(const s of B)for(let w=0;w<3;++w){C.set(s.x+(w===0?A:0),s.y+(w===1?A:0),s.z+(w===2?A:0));for(let G=0;G<2;++G)E.set((w===0?A:I)*(G?1:g),(w===1?A:I)*(G?1:g),(w===2?A:I)*(G?1:g)),o.setRGB(G===0?0:w===0?1:0,G===0?0:w===1?1:0,G===0?0:w===2?1:0),Q.pushSplat(C,E,i,D,o)}}function Tk({splats:Q,origin:A=new F,radius:I=1,maxDepth:g=3,filter:B=null,pointRadius:C=.02,pointThickness:E=.001,color:i=new YA(1,1,1)}){const o={};function D(h){if(B&&!B(h))return;const c=`${h.x},${h.y},${h.z}`;o[c]||(o[c]=h)}function s(h,c,k,R){if(D(c),D(k),D(R),h>=g)return;const t=new F().addVectors(c,k).normalize(),N=new F().addVectors(k,R).normalize(),S=new F().addVectors(R,c).normalize();s(h+1,c,t,S),s(h+1,t,k,N),s(h+1,S,N,R),s(h+1,t,N,S)}for(const h of[-1,1])for(const c of[-1,1])for(const k of[-1,1]){const R=new F(h,0,0),t=new F(0,c,0),N=new F(0,0,k);s(0,R,t,N)}const w=Object.values(o),G=new F(C,C,E),a=new Z,y=typeof i=="function"?new YA:i;for(const h of w)a.setFromUnitVectors(new F(0,0,-1),h),typeof i=="function"&&i(y,h),h.multiplyScalar(I),h.add(A),Q.pushSplat(h,G,a,1,y)}function Ok({text:Q,font:A,fontSize:I,color:g,rgb:B,dotRadius:C,textAlign:E,lineHeight:i,objectScale:o}){A=A??"Arial",I=I??32,g=g??new YA(1,1,1),C=C??.8,E=E??"start",i=i??1,o=o??1;const D=Q.split(`
12013
+ `),s=document.createElement("canvas"),w=s.getContext("2d");if(!w)throw new Error("Failed to create canvas context");w.font=`${I}px ${A}`,w.textAlign=E;const G=w.measureText(""),a=G.fontBoundingBoxAscent+G.fontBoundingBoxDescent;let y=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,c=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;for(let Y=0;Y<D.length;++Y){const K=w.measureText(D[Y]),x=a*i*Y;y=Math.min(y,-K.actualBoundingBoxLeft),h=Math.max(h,K.actualBoundingBoxRight),c=Math.min(c,x-K.actualBoundingBoxAscent),k=Math.max(k,x+K.actualBoundingBoxDescent)}const R=Math.floor(y),t=Math.floor(c),N=Math.ceil(h)-R,S=Math.ceil(k)-t;s.width=N,s.height=S,w.font=`${I}px ${A}`,w.textAlign=E,w.textBaseline="alphabetic",w.fillStyle="#FFFFFF";for(let Y=0;Y<D.length;++Y){const K=a*i*Y-t;w.fillText(D[Y],-R,K)}const J=w.getImageData(0,0,N,S),M=new Uint8Array(J.data.buffer),U=new SI,n=new F,L=new F().setScalar(C*o),H=new Z(0,0,0,1);B=B??new YA(1,1,1);let e=0;for(let Y=0;Y<S;++Y)for(let K=0;K<N;++K){const x=M[e+3];if(x>0){const m=x/255;n.set(K-.5*(N-1),.5*(S-1)-Y,0),n.multiplyScalar(o),U.pushSplat(n,L,H,m,B)}e+=4}const q=new wI({packedSplats:U});return q.recolor=g,q}function Zk({url:Q,dotRadius:A,subXY:I,forEachSplat:g}){return A=A??.8,I=Math.max(1,Math.floor(I??1)),new wI({constructSplats:async B=>new Promise((C,E)=>{const i=new Image;i.crossOrigin="anonymous",i.onerror=E,i.onload=()=>{const{width:o,height:D}=i,s=document.createElement("canvas");s.width=o,s.height=D;const w=s.getContext("2d");if(!w){E(new Error("Failed to create canvas context"));return}w.imageSmoothingEnabled=!0,w.imageSmoothingQuality="high";const G=Math.round(o/I),a=Math.round(D/I);w.drawImage(i,0,0,G,a);try{const y=w.getImageData(0,0,G,a),h=new Uint8Array(y.data.buffer),c=new F,k=new F().setScalar(A),R=new Z(0,0,0,1),t=new YA;let N=0;for(let S=0;S<a;++S)for(let J=0;J<G;++J){const M=N*4,U=h[M+3];if(U>0){let n=U/255;t.set(h[M+0]/255,h[M+1]/255,h[M+2]/255),c.set(J-.5*(G-1),.5*(a-1)-S,0),k.setScalar(A),R.set(0,0,0,1);let L=!0;if(g){const H=g(G,a,N,c,k,R,n,t);n=H??n,L=H!==null}L&&B.pushSplat(c,k,R,n,t)}N+=1}C()}catch(y){E(y)}},i.src=Q})})}function nc({box:Q,cells:A,dotScale:I,color:g,opacity:B}){A.x=Math.max(1,Math.round(A.x)),A.y=Math.max(1,Math.round(A.y)),A.z=Math.max(1,Math.round(A.z)),B=B??1;const C=A.x*A.y*A.z,E=_("int",A.x),i=_("int",A.y);_("int",A.z);const o=cI(0),D=new jI({numSplats:C,generator:JA({index:"int"},{gsplat:X},({index:w})=>{if(!w)throw new Error("index is undefined");const G=DB(w,E),a=_g(w,E),y=DB(a,i),h=_g(a,i),c=FI({vectorType:"ivec3",x:G,y,z:h}),k=dD(o),R=FI({vectorType:"ivec2",x:w,y:k}),t=xo(R),N=_("vec3",Q.min),S=_("vec3",Q.max),J=yI(S,N),M=_g(xA(VI(c),t),_("vec3",A));let U,n,L;g?(U=_("float",g.r),n=_("float",g.g),L=_("float",g.b)):{r:U,g:n,b:L}=Dg(M).outputs;const H=FI({vectorType:"vec4",r:U,g:n,b:L,a:_("float",B)}),e=xA(N,RA(J,M)),q=VI(_("float",I)),Y=_("vec4",new Z(0,0,0,1));let K=GI({flags:DQ("uint","GSPLAT_FLAG_ACTIVE"),index:w,center:e,scales:q,quaternion:Y,rgba:H});return K=s.applyGsplat(K),{gsplat:K}},{globals:()=>[rA]}),update:({time:w})=>{o.value=w,s.update(D),D.updateVersion()}}),s=new gg;return D}const ec={box:new dg(new F(-1,-1,-1),new F(1,1,1)),density:100,fallDirection:new F(-1,-3,1).normalize(),fallVelocity:.02,wanderScale:.04,wanderVariance:2,color1:new YA(1,1,1),color2:new YA(.5,.5,1),minScale:.001,maxScale:.005,anisoScale:new F(1,1,1)},Hc={box:new dg(new F(-2,-1,-2),new F(2,5,2)),density:10,fallDirection:new F(0,-1,0),fallVelocity:2,wanderScale:.1,wanderVariance:1,color1:new YA(1,1,1),color2:new YA(.25,.25,.5),minScale:.005,maxScale:.01,anisoScale:new F(.1,1,.1)};function Lc({box:Q,minY:A,numSplats:I,density:g,anisoScale:B,minScale:C,maxScale:E,fallDirection:i,fallVelocity:o,wanderScale:D,wanderVariance:s,color1:w,color2:G,opacity:a,onFrame:y}){Q=Q??new dg(new F(-1,-1,-1),new F(1,1,1));const h=(Q.max.x-Q.min.x)*(Q.max.y-Q.min.y)*(Q.max.z-Q.min.z);g=g??100,I=I??Math.max(1,Math.min(1e6,Math.round(h*g)));const c=cI(C??.001),k=cI(E??.005),R=rI((B?.clone()??new F(1,1,1)).normalize()),t=rI((i??new F(0,-1,0)).normalize()),N=cI(o??.02),S=cI(D??.01),J=cI(s??2),M=rI(w??new YA(1,1,1)),U=rI(G??new YA(.5,.5,1)),n=cI(a??1),L=cI(0),H=rI(new F(0,0,0)),e=rI(Q.min),q=rI(Q.max),Y=cI(A??Number.NEGATIVE_INFINITY),K=yI(q,e),x=new jI({numSplats:I,generator:JA({index:"int"},{gsplat:X},({index:j})=>{if(!j)throw new Error("index not defined");const u=wB(j),CA=Dg(u).outputs.w;let V=VI(u),AA=$g(RA(CA,_("float",100)));AA=sB(RA(DQ("float","PI"),AA)),AA=xA(c,RA(AA,yI(k,c)));const O=RA(AA,R),P=$g(RA(CA,_("float",10))),b=$g(CA),T=qi(M,U,b),p=RA(T,P),SA=wB(FI({vectorType:"ivec2",x:j,y:_("int",6837)}));let GA=VI(SA),tA=RA(Dg(SA).outputs.w,J);tA=xA(L,tA),V=xA(V,H);const NA=Ki(V,_("vec3",new F(1,1,1)));V=xA(e,RA(K,NA));const wA=_("vec4",new Z(0,0,0,1));GA=sB(xA(VI(tA),GA)),GA=RA(GA,S);let aA=xA(V,GA),CI=Dg(aA).outputs.y;CI=di(Y,CI),aA=FI({vector:aA,y:CI});let VA=GI({flags:DQ("uint","GSPLAT_FLAG_ACTIVE"),index:j,center:aA,scales:O,quaternion:wA,rgb:p,opacity:n});return VA=m.applyGsplat(VA),{gsplat:VA}},{globals:()=>[rA]}),update:({object:j,time:u,deltaTime:CA})=>{L.value=u,m.update(x);const V=t.value.clone().multiplyScalar(N.value*CA);H.value.add(V),j.visible=n.value>0,y?.({object:j,time:u,deltaTime:CA}),x.updateVersion()}}),m=new gg;return{snow:x,min:e,max:q,minY:Y,color1:M,color2:U,opacity:n,fallVelocity:N,wanderVariance:J,wanderScale:S,fallDirection:t,minScale:c,maxScale:k,anisoScale:R}}const Vk=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_RAIN:Hc,DEFAULT_SNOW:ec,snowBox:Lc,staticBox:nc},Symbol.toStringTag,{value:"Module"}));function dw(Q){return JA({gsplat:X},{gsplat:X},({gsplat:A})=>{if(!A)throw new Error("No gsplat input");let I=CB(A);const g=Q.applyGsplat(A),B=ZA(g).outputs.center,C=CB(g),E=Go(B,C),i=GD(E,_("float",0));I=mB(i,PB(I),I);const o=xA(RA(I,_("float",.5)),_("float",.5));return A=GI({gsplat:A,rgb:o}),{gsplat:A}})}function Yc(Q){Q.enableWorldToView=!0,Q.worldModifier=dw(Q.context.worldToView),Q.updateGenerator()}function qw(Q,A,I,g){return JA({gsplat:X},{gsplat:X},({gsplat:B})=>{if(!B)throw new Error("No gsplat input");let{center:C}=ZA(B).outputs;C=Q.apply(C);const{z:E}=Dg(C).outputs;let i=po(PB(E),A,I);return i=mB(g,yI(_("float",1),i),i),B=GI({gsplat:B,r:i,g:i,b:i}),{gsplat:B}})}function rc(Q,A,I,g){Q.enableWorldToView=!0;const B=_("float",A),C=_("float",I),E=_("bool",g??!1);return Q.worldModifier=qw(Q.context.worldToView,B,C,E),Q.updateGenerator(),{minDepth:B,maxDepth:C,reverse:E}}const Xk=Object.freeze(Object.defineProperty({__proto__:null,makeDepthColorModifier:qw,makeNormalColorModifier:dw,setDepthColor:rc,setWorldNormalColor:Yc},Symbol.toStringTag,{value:"Module"})),Kc=1,MC=4,dc=2,qc=5,lc=1/5,Wk=!1,xc=(Q,A)=>{var I,g,B,C;return Q.leftIsHand?new F:new F(((I=Q.left)==null?void 0:I.axes[2])??0,(((g=Q.left)==null?void 0:g.buttons[0].value)??0)-(((B=Q.left)==null?void 0:B.buttons[1].value)??0),((C=Q.left)==null?void 0:C.axes[3])??0)},pc=(Q,A)=>{var I;return Q.rightIsHand?new F:new F(((I=Q.right)==null?void 0:I.axes[2])??0,0,0)},fc=(Q,A)=>{var I,g;return Q.rightIsHand?!1:((g=(I=Q.right)==null?void 0:I.buttons[0])==null?void 0:g.pressed)??!1},bc=(Q,A)=>{var I,g;return Q.rightIsHand?!1:((g=(I=Q.right)==null?void 0:I.buttons[1])==null?void 0:g.pressed)??!1};var qQ=(Q=>(Q.w="wrist",Q.t0="thumb-metacarpal",Q.t1="thumb-phalanx-proximal",Q.t2="thumb-phalanx-distal",Q.t3="thumb-tip",Q.i0="index-finger-metacarpal",Q.i1="index-finger-phalanx-proximal",Q.i2="index-finger-phalanx-intermediate",Q.i3="index-finger-phalanx-distal",Q.i4="index-finger-tip",Q.m0="middle-finger-metacarpal",Q.m1="middle-finger-phalanx-proximal",Q.m2="middle-finger-phalanx-intermediate",Q.m3="middle-finger-phalanx-distal",Q.m4="middle-finger-tip",Q.r0="ring-finger-metacarpal",Q.r1="ring-finger-phalanx-proximal",Q.r2="ring-finger-phalanx-intermediate",Q.r3="ring-finger-phalanx-distal",Q.r4="ring-finger-tip",Q.p0="pinky-finger-metacarpal",Q.p1="pinky-finger-phalanx-proximal",Q.p2="pinky-finger-phalanx-intermediate",Q.p3="pinky-finger-phalanx-distal",Q.p4="pinky-finger-tip",Q))(qQ||{});const UI=Object.keys(qQ),uc=UI.length,Pc={w:0,t0:1,t1:2,t2:3,t3:4,i0:5,i1:6,i2:7,i3:8,i4:9,m0:10,m1:11,m2:12,m3:13,m4:14,r0:15,r1:16,r2:17,r3:18,r4:19,p0:20,p1:21,p2:22,p3:23,p4:24},lw={w:.02,t0:.015,t1:.012,t2:.0105,t3:.0085,i0:.022,i1:.012,i2:.0085,i3:.0075,i4:.0065,m0:.021,m1:.012,m2:.008,m3:.0075,m4:.0065,r0:.019,r1:.011,r2:.0075,r3:.007,r4:.006,p0:.012,p1:.01,p2:.007,p3:.0065,p4:.0055},mc=[["w","t0","t1","t2","t3"],["w","i0","i1","i2","i3","i4"],["w","m0","m1","m2","m3","m4"],["w","r0","r1","r2","r3","r4"],["w","p0","p1","p2","p3","p4"]],Tc=[[8,10,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6]],Oc=["t3","i4","m4","r4","p4"],Zc=["i4","m4","r4","p4"];var AC=(Q=>(Q.left="left",Q.right="right",Q))(AC||{});const Vc=Object.keys(AC),Xc=/Quest|OculusBrowser|VisionOS|XRBrowser|Pico|Lynx|MagicLeap/i;function Wc(){const Q=navigator.userAgent??"";if(Xc.test(Q))return!1;if(/Android/i.test(Q)||/Mobile/i.test(Q))return!0;const I=navigator.userAgentData;return I&&typeof I.mobile=="boolean"?I.mobile:!1}const BI=class xw{constructor(A){this.lastControllersUpdate=0,this.hands=[],this.renderer=A.renderer,this.xr=navigator.xr,this.mode="initializing",this.onEnterXr=A.onEnterXr,this.onExitXr=A.onExitXr,this.enableHands=A.enableHands??!1,this.controllers=A.controllers,Promise.resolve().then(()=>{var I;if(!this.xr){this.mode="not_supported";return}if(!A.allowMobileXr&&Wc()){this.mode="not_supported";return}this.enableHands&&(this.hands=[new kQ("left"),new kQ("right")]);let g,B;if(A.element?g=A.element:A.elementId?g=document.getElementById(A.elementId)??void 0:(g=xw.createButton(),B=A.button==null||typeof A.button=="boolean"?{}:A.button),!g)throw new Error("No element or button provided");g.style.display="none",g.classList.add("hidden"),this.button=B,this.element=g;const C=(I=A.onMouseLeaveOpacity)==null?void 0:I.toString();return C!==void 0&&(g.addEventListener("mouseleave",()=>{g.style.opacity=C}),g.addEventListener("mouseenter",()=>{g.style.opacity=""})),this.initializeXr(A)}).then(()=>{var I;return(I=A.onReady)==null?void 0:I.call(A,this.mode!=="not_supported")}).catch(I=>{alert(`Error initializing SparkXr: ${I}`)})}async initializeXr(A){var I,g;if(!this.xr||!this.element)return;const B=this.element,C={vr:["immersive-vr"],ar:["immersive-ar"],arvr:["immersive-ar","immersive-vr"],vrar:["immersive-vr","immersive-ar"]}[A.mode??"vrar"];if(!C)throw new Error(`Invalid mode: ${A.mode}`);let E=null;for(const w of C)if(await this.xr.isSessionSupported(w)){E=w;break}if(!E){this.mode="not_supported";return}this.mode=E;const i=A.referenceSpaceType??"local";this.renderer.xr.enabled=!0,this.renderer.xr.setReferenceSpaceType(i),A.fixedFoveation!==void 0&&this.renderer.xr.setFoveation(A.fixedFoveation);const o=A.frameBufferScaleFactor??.5;this.renderer.xr.setFramebufferScaleFactor(o);const D=((I=A.sessionInit)==null?void 0:I.optionalFeatures)??[];A.enableHands&&D.push("hand-tracking");const s=((g=A.sessionInit)==null?void 0:g.requiredFeatures)??[];s.push(i),this.sessionInit={...A.sessionInit,optionalFeatures:D,requiredFeatures:s},B.addEventListener("click",()=>{this.toggleXr()}),this.updateElement()}async toggleXr(){var A,I,g;if(!(!this.xr||!this.sessionInit))if(this.session)this.session.end();else try{const B=this.mode,C=await this.xr.requestSession(B,this.sessionInit);this.session=C;const E=()=>{var D;C?.removeEventListener("end",E),C?.removeEventListener("visibilitychange",o),this.session=void 0,this.updateElement(),(D=this.onExitXr)==null||D.call(this)};let i=C.visibilityState;const o=()=>{C?.visibilityState==="visible-blurred"&&i==="visible"&&C?.end(),i=C?.visibilityState};return(A=this.session)==null||A.addEventListener("end",E),(I=this.session)==null||I.addEventListener("visibilitychange",o),await this.renderer.xr.setSession(this.session),(g=this.onEnterXr)==null?void 0:g.call(this)}catch(B){console.error("Error requesting XR session",B);return}}updateElement(){const A=this.mode,I=this.element;if(I){I.style.display="",I.classList.remove("hidden");const g=typeof this.button=="boolean"?{}:this.button;if(g){if(this.session){const B=(A==="immersive-vr"?g.exitVrHtml:g.exitArHtml)??g.exitXrHtml,C=(A==="immersive-vr"?g.exitVrText:g.exitArText)??g.exitXrText;B?I.innerHTML=B:C?I.textContent=C:I.textContent=A==="immersive-vr"?"EXIT VR":"EXIT AR"}else{const B=(A==="immersive-vr"?g.enterVrHtml:g.enterArHtml)??g.enterXrHtml,C=(A==="immersive-vr"?g.enterVrText:g.enterArText)??g.enterXrText;B?I.innerHTML=B:C?I.textContent=C:I.textContent=A==="immersive-vr"?"ENTER VR":"ENTER AR"}I.style.display=""}}}static createButton(){const A=document.createElement("button");return Object.assign(A.style,{position:"absolute",bottom:"20px",left:"50%",transform:"translateX(-50%)",padding:"40px 40px",border:"2px solid #fff",borderRadius:"16px",background:"rgba(0,0,0,0.1)",color:"#fff",font:"bold 28px sans-serif",textAlign:"center",userSelect:"none",zIndex:"999"}),document.body.appendChild(A),A}xrSupported(){return!!this.xr}left(){return this.hands[0]}right(){return this.hands[1]}updateControllers(A){var I,g,B,C,E,i,o,D,s,w,G,a;const y=A.parent,h=performance.now(),c=(h-(this.lastControllersUpdate||h))/1e3;this.lastControllersUpdate=h;const k={};for(const S of((I=this.renderer.xr.getSession())==null?void 0:I.inputSources)??[]){const J=S.gamepad;J&&(S.handedness==="left"||S.handedness==="right")&&(k[S.handedness]=J,S.handedness==="left"?k.leftIsHand=!!S.hand:S.handedness==="right"&&(k.rightIsHand=!!S.hand))}const R=(((g=this.controllers)==null?void 0:g.getRotate)??pc)(k,this);if(R.multiply(new F(((B=this.controllers)==null?void 0:B.rotateSpeed)??MC,((C=this.controllers)==null?void 0:C.rotateSpeed)??MC,((E=this.controllers)==null?void 0:E.rollSpeed)??dc)),R.manhattanLength()>0){R.multiplyScalar(c);const S=new Lg(-R.y,-R.x,R.z,"YXZ"),J=new Z().setFromEuler(S),M=A.getWorldPosition(new F);(i=y.parent)==null||i.worldToLocal(M),y.position.sub(M),y.position.applyQuaternion(J),y.position.add(M),y.quaternion.premultiply(J)}const t=(((o=this.controllers)==null?void 0:o.getMove)??xc)(k,this);let N=((D=this.controllers)==null?void 0:D.moveSpeed)??Kc;(((s=this.controllers)==null?void 0:s.getFast)??fc)(k,this)&&(N*=qc),(((w=this.controllers)==null?void 0:w.getSlow)??bc)(k,this)&&(N*=lc),(G=this.controllers)!=null&&G.moveHeading?t.applyQuaternion(A.quaternion):(a=this.controllers)!=null&&a.moveDirection&&(Xg.setFromQuaternion(A.quaternion,"YXZ"),Xg.x=0,Xg.z=0,hB.setFromEuler(Xg),t.applyQuaternion(hB)),t.applyQuaternion(y.quaternion),t.multiplyScalar(c*N),y.position.add(t)}updateHands({xrFrame:A}){const I=this.renderer.xr.getSession();if(!I)return;const g=this.renderer.xr.getReferenceSpace();if(g&&A.getJointPose){for(const B of this.hands)B&&(B.lastJoints=B.joints,B.joints=void 0);for(const B of I.inputSources){if(!B.hand)continue;const C=B.handedness,E=this.hands[C==="left"?0:1];if(E)for(const i of UI){const o=B.hand.get(qQ[i]);if(o){const D=A.getJointPose(o,g);if(D){const{position:s,orientation:w}=D.transform;E.joints||(E.joints={}),E.joints[i]={position:new F(s.x,s.y,s.z),quaternion:new Z(w.x,w.y,w.z,w.w),radius:lw[i]}}}}}}}makeJointSplats(A){const I=new Qk(A);return I.onFrame=()=>{const g=this.hands[A==="left"?0:1],B=g?.joints;I.updateJoints(B)},I}snapshotHands(A){var I,g;const B=[(I=this.hands[0])==null?void 0:I.snapshotJoints(),(g=this.hands[1])==null?void 0:g.snapshotJoints()];return{time:A,hands:B}}};BI.JointEnum=qQ;BI.JOINT_IDS=UI;BI.NUM_JOINTS=uc;BI.JOINT_INDEX=Pc;BI.JOINT_RADIUS=lw;BI.JOINT_SEGMENTS=mc;BI.JOINT_SEGMENT_STEPS=Tc;BI.JOINT_TIPS=Oc;BI.FINGER_TIPS=Zc;BI.Hand=AC;BI.HANDS=Vc;let jk=BI;const jQ=Q=>Math.round(Q*1e4)/1e4,Xg=new Lg(0,0,0,"YXZ"),hB=new Z,jc=new Z;function vk(Q,A){if(!Q.length)return null;const I=Q[0],g=Q[Q.length-1];if(A<I.time||A>g.time)return null;const B=_c(Q,A);if(B===-1)return null;const C=Q[B],E=Q[B+1];if(!E)return zc(C,A);const i=E.time-C.time,o=i>0?(A-C.time)/i:0;return vc(C,E,o,A)}function vc(Q,A,I,g){const B=Math.max(Q.hands.length,A.hands.length),C=Array.from({length:B},(E,i)=>$c(Q.hands[i],A.hands[i],I));return{time:g,hands:C}}function zc(Q,A){return{time:A,hands:Q.hands.map(I=>Ik(I))}}class kQ{constructor(A){this.hand=A}static newFromSnapshot(A,I){const g=new kQ(A);g.joints={};for(const B of UI){const C=I[B];C&&(g.joints[B]={position:new F(C.pos[0],C.pos[1],C.pos[2]),quaternion:new Z(C.quat[0],C.quat[1],C.quat[2],C.quat[3]),radius:C.radius})}return g}valid(){return!!this.joints}snapshotJoints(){if(!this.joints)return;const A={};for(const I of UI){const g=this.joints[I];g&&(A[I]={pos:g.position.toArray().map(jQ),quat:g.quaternion.toArray().map(jQ),radius:jQ(g.radius)})}return A}toFlatArray(){if(!this.joints)return;const A=new Float32Array(176);A[0]=this.hand==="left"?0:1;let I=1;for(const g of UI){const B=this.joints[g];B&&(A[I]=B.position.x,A[I+1]=B.position.y,A[I+2]=B.position.z,A[I+3]=B.quaternion.x,A[I+4]=B.quaternion.y,A[I+5]=B.quaternion.z,A[I+6]=B.quaternion.w),I+=7}return A}}function _c(Q,A){let I=0,g=Q.length-1;for(;I<=g;){const B=I+g>>1;Q[B].time<=A?I=B+1:g=B-1}return g}function $c(Q,A,I=0){if(!Q||!A)return;const g={};for(const B of UI){const C=Ak(Q[B],A[B],I);C&&(g[B]=C)}return g}function Ak(Q,A,I=0){if(!Q||!A)return;const g=Q.pos.map((E,i)=>E+(A.pos[i]-E)*I),B=hB.fromArray(Q.quat).slerp(jc.fromArray(A.quat),I).toArray(),C=Q.radius+(A.radius-Q.radius)*I;return{pos:g,quat:B,radius:C}}function Ik(Q){if(!Q)return;const A={};for(const I of UI){const g=Q[I];g&&(A[I]=gk(g))}return A}function gk(Q){return{pos:[...Q.pos],quat:[...Q.quat],radius:Q.radius}}class Qk extends wI{constructor(A){super({}),this.scratchCenter=new F,this.scratchQuat=new Z(0,0,0,1),this.scratchScales=new F().setScalar(.01),this.scratchColor=new YA(1,1,1),this.hand=A}updateJoints(A){if(this.visible=!1,!A||!this.packedSplats)return;this.visible=!0;let I=0;for(const g of UI){const B=A[g];if(!B)continue;this.scratchCenter.copy(B.position),this.scratchQuat.copy(B.quaternion),this.scratchScales.set(B.radius,.75*B.radius,1.5*B.radius),this.packedSplats.setSplat(I,this.scratchCenter,this.scratchScales,this.scratchQuat,.75,this.scratchColor),I+=1}this.packedSplats.numSplats=I,this.packedSplats.needsUpdate=!0,this.numSplats=I,this.updateVersion()}}const Bk=.5,Ck=.5,Ek=0;var IC=(Q=>(Q.w="wrist",Q.t0="thumb-metacarpal",Q.t1="thumb-phalanx-proximal",Q.t2="thumb-phalanx-distal",Q.t3="thumb-tip",Q.i0="index-finger-metacarpal",Q.i1="index-finger-phalanx-proximal",Q.i2="index-finger-phalanx-intermediate",Q.i3="index-finger-phalanx-distal",Q.i4="index-finger-tip",Q.m0="middle-finger-metacarpal",Q.m1="middle-finger-phalanx-proximal",Q.m2="middle-finger-phalanx-intermediate",Q.m3="middle-finger-phalanx-distal",Q.m4="middle-finger-tip",Q.r0="ring-finger-metacarpal",Q.r1="ring-finger-phalanx-proximal",Q.r2="ring-finger-phalanx-intermediate",Q.r3="ring-finger-phalanx-distal",Q.r4="ring-finger-tip",Q.p0="pinky-finger-metacarpal",Q.p1="pinky-finger-phalanx-proximal",Q.p2="pinky-finger-phalanx-intermediate",Q.p3="pinky-finger-phalanx-distal",Q.p4="pinky-finger-tip",Q))(IC||{});const pw=Object.keys(IC),zk=pw.length,_k={w:0,t0:1,t1:2,t2:3,t3:4,i0:5,i1:6,i2:7,i3:8,i4:9,m0:10,m1:11,m2:12,m3:13,m4:14,r0:15,r1:16,r2:17,r3:18,r4:19,p0:20,p1:21,p2:22,p3:23,p4:24},Wg={w:.02,t0:.02,t1:.014,t2:.0115,t3:.0085,i0:.022,i1:.012,i2:.0085,i3:.0075,i4:.0065,m0:.021,m1:.012,m2:.008,m3:.0075,m4:.0065,r0:.019,r1:.011,r2:.0075,r3:.007,r4:.006,p0:.012,p1:.01,p2:.007,p3:.0065,p4:.0055},ik=[["w","t0","t1","t2","t3"],["w","i0","i1","i2","i3","i4"],["w","m0","m1","m2","m3","m4"],["w","r0","r1","r2","r3","r4"],["w","p0","p1","p2","p3","p4"]],Dk=[[8,10,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6],[8,19,14,8,6]],$k=["t3","i4","m4","r4","p4"],AR=["i4","m4","r4","p4"];var fw=(Q=>(Q.left="left",Q.right="right",Q))(fw||{});const yB=Object.keys(fw);class IR{constructor(){this.hands={},this.last={},this.values={},this.tests={},this.lastTests={},this.updated=!1}update({xr:A,xrFrame:I}){const g=A.getSession();if(!g)return;const B=A.getReferenceSpace();if(B&&I.getJointPose){this.last=this.hands,this.lastTests=this.tests,this.hands={},this.values={},this.tests={};for(const C of g.inputSources){if(!C.hand)continue;const E=C.handedness;this.hands[E]={};for(const i of pw){const o=C.hand.get(IC[i]);if(o){const D=I.getJointPose(o,B);if(D){const{position:s,orientation:w}=D.transform;this.hands[E][i]={position:new F(s.x,s.y,s.z),quaternion:new Z(w.x,w.y,w.z,w.w),radius:D.radius||.001}}}}}for(const C of yB)for(const{key:E,value:i}of[{key:`${C}AllTips`,value:this.allTipsTouching(C)},{key:`${C}IndexThumb`,value:this.touching(C,"i4",C,"t3")},{key:`${C}MiddleThumb`,value:this.touching(C,"m4",C,"t3")},{key:`${C}RingThumb`,value:this.touching(C,"r4",C,"t3")},{key:`${C}PinkyThumb`,value:this.touching(C,"p4",C,"t3")},{key:`${C}TriTips`,value:this.triTipsTouching(C)}])this.values[E]=i,this.tests[E]=i===1?!0:i===0?!1:this.lastTests[E]??!1}}makeGhostMesh(){const A=new F,I=new F(.01,.01,.01),g=new Z(0,0,0,1),B=new YA(1,1,1),C=Math.PI*3;new YA(1,1,1);let E=1;const i=new wI({onFrame:()=>{if(!i.packedSplats)return;let o=0;for(const D of yB){const s=this.hands[D];for(const[w,G]of ik.entries())for(let a=1;a<G.length;++a){const y=Dk[w][a-1]*2,h=a+1===G.length,c=s?.[G[a-1]],k=s?.[G[a]];for(let R=0;R<y;++R){const t=(R+.5)/y;if(E=0,c&&k){A.copy(c.position).lerp(k.position,t),g.copy(c.quaternion).slerp(k.quaternion,t);const N=Wg[G[a-1]],S=Wg[G[a]];let J=(1-t)*N+t*S;h&&t>.8&&(J*=Math.sqrt(1-((t-.8)/.2)**2)),I.set(.65*J,.5*J,.003),B.set(.55+.45*Math.sin(A.x*C),.55+.45*Math.sin(A.y*C),.55+.45*Math.sin(A.z*C)),D==="right"&&B.set(1-B.r,1-B.g,1-B.b),E=.75}i.packedSplats.setSplat(o,A,I,g,E,B),o+=1}}}i.packedSplats.numSplats=o,i.packedSplats.needsUpdate=!0,i.numSplats=o,i.updateVersion()}});return i}distance(A,I,g,B,C=!1){const E=C?this.last[A]:this.hands[A],i=C?this.last[g]:this.hands[g],o=E?.[I],D=i?.[B];return!o||!D?Number.POSITIVE_INFINITY:o.position.distanceTo(D.position)}separation(A,I,g,B,C=!1){const E=this.distance(A,I,g,B,C);return E===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:E-Wg[I]-Wg[B]}touching(A,I,g,B,C=!1){const E=this.separation(A,I,g,B,C);return E===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:1-Math.max(0,Math.min(1,E/.01-Ek))}allTipsTouching(A,I=!1){return Math.min(this.touching(A,"t3",A,"i4",I),this.touching(A,"i4",A,"m4",I),this.touching(A,"m4",A,"r4",I),this.touching(A,"r4",A,"p4",I))}triTipsTouching(A,I=!1){return Math.min(this.touching(A,"t3",A,"i4",I),this.touching(A,"i4",A,"m4",I),this.touching(A,"m4",A,"t3",I))}}class gR{constructor({xrHands:A,control:I,moveInertia:g,rotateInertia:B}){this.lastGrip={},this.lastPivot=new F,this.rotateVelocity=0,this.velocity=new F,this.xrHands=A,this.control=I,this.moveInertia=g??Bk,this.rotateInertia=B??Ck}update(A){var I,g,B,C,E;const i={};for(const s of yB){const w=this.xrHands.hands[s];w&&this.xrHands.tests[`${s}MiddleThumb`]&&(i[s]=new F().add(((I=w.t3)==null?void 0:I.position)??new F).add(((g=w.i4)==null?void 0:g.position)??new F).add(((B=w.m4)==null?void 0:B.position)??new F).add(((C=w.r4)==null?void 0:C.position)??new F).add(((E=w.p4)==null?void 0:E.position)??new F).multiplyScalar(1/5))}if(i.left&&i.right&&this.lastGrip.left&&this.lastGrip.right){const s=i.left.clone().add(i.right).multiplyScalar(.5),w=this.lastGrip.left.clone().add(this.lastGrip.right).multiplyScalar(.5);this.lastPivot=s;const G=s.clone().applyMatrix4(this.control.matrix);G.sub(w.clone().applyMatrix4(this.control.matrix)),G.multiplyScalar(1/A),this.velocity.lerp(G,1-Math.exp(-20*A));const a=Math.atan2(i.left.z-s.z,i.left.x-s.x),y=Math.atan2(this.lastGrip.left.z-w.z,this.lastGrip.left.x-w.x);let h=a-y;h>Math.PI?h-=Math.PI*2:h<-Math.PI&&(h+=Math.PI*2);const c=h/A,k=Math.exp(-20*A);this.rotateVelocity=this.rotateVelocity*k+c*(1-k)}else if(this.rotateVelocity*=Math.exp(-A/this.rotateInertia),i.left&&this.lastGrip.left){const s=i.left.clone().applyMatrix4(this.control.matrix);s.sub(this.lastGrip.left.clone().applyMatrix4(this.control.matrix)),s.multiplyScalar(1/A),this.velocity.lerp(s,1-Math.exp(-20*A))}else if(i.right&&this.lastGrip.right){const s=i.right.clone().applyMatrix4(this.control.matrix);s.sub(this.lastGrip.right.clone().applyMatrix4(this.control.matrix)),s.multiplyScalar(1/A),this.velocity.lerp(s,1-Math.exp(-20*A))}else this.velocity.multiplyScalar(Math.exp(-A/this.moveInertia));const o=this.lastPivot.clone().negate(),D=new FA().makeTranslation(o).premultiply(new FA().makeRotationY(this.rotateVelocity*A)).premultiply(new FA().makeTranslation(this.lastPivot));this.control.matrix.multiply(D),this.control.matrix.decompose(this.control.position,this.control.quaternion,this.control.scale),this.control.updateMatrixWorld(!0),this.control.position.sub(this.velocity.clone().multiplyScalar(A)),this.lastGrip=i}}const ok=1,wk=2,sk=.002,Gk=.006,ak=.0015,hk=.15,yk=.15,ck=.1,kk=2,Rk=0,Fk=500,Sk=500,tk=200,Nk=400,Mk=25,kI=1e-4,Jk={KeyW:new F(0,0,-1),KeyS:new F(0,0,1),KeyA:new F(-1,0,0),KeyD:new F(1,0,0),KeyE:new F(0,1,0),KeyQ:new F(0,-1,0)},Uk={ArrowUp:new F(0,0,-1),ArrowDown:new F(0,0,1),ArrowLeft:new F(-1,0,0),ArrowRight:new F(1,0,0),PageUp:new F(0,1,0),PageDown:new F(0,-1,0)};new F(0,0,1),new F(0,0,-1);const nk={Home:new F(0,-1,0),End:new F(0,1,0),Insert:new F(-1,0,0),Delete:new F(1,0,0)};class QR{constructor({canvas:A}){this.lastTime=0,this.fpsMovement=new ek({}),this.pointerControls=new Hk({canvas:A})}update(A,I){const g=performance.now(),B=(g-(this.lastTime||g))/1e3;this.lastTime=g;let C=this.fpsMovement.update(B,A);return this.pointerControls.update(B,A,I)&&(C=!0),C}}class ek{constructor({moveSpeed:A,rollSpeed:I,stickThreshold:g,rotateSpeed:B,keycodeMoveMapping:C,keycodeRotateMapping:E,gamepadMapping:i,capsMultiplier:o,shiftMultiplier:D,ctrlMultiplier:s,xr:w}={}){this.enable=!0,this.extraMove=new F,this.moveSpeed=A??ok,this.rollSpeed=I??wk,this.stickThreshold=g??ck,this.rotateSpeed=B??kk,this.keycodeMoveMapping=C??{...Jk,...Uk},this.keycodeRotateMapping=E??{...nk},this.gamepadMapping=i??{4:"rollLeft",5:"rollRight",6:"ctrl",7:"shift"},this.capsMultiplier=o??10,this.shiftMultiplier=D??5,this.ctrlMultiplier=s??1/5,this.xr=w,this.keydown={},this.keycode={},document.addEventListener("keydown",G=>{this.keydown[G.key]=!0,this.keycode[G.code]=!0}),document.addEventListener("keyup",G=>{this.keydown[G.key]=!1,this.keycode[G.code]=!1}),window.addEventListener("blur",()=>{this.keydown={},this.keycode={}})}update(A,I){var g,B;if(!this.enable)return!1;const C=[new OA,new OA],E=navigator.getGamepads()[0];E&&(C[0].set(E.axes[0],E.axes[1]),C[1].set(E.axes[2],E.axes[3]));const i=E?.buttons.map(a=>a.pressed)||[],o=Array.from(((B=(g=this.xr)==null?void 0:g.getSession())==null?void 0:B.inputSources)??[]);for(const a of o){const y=a.gamepad;if(y)switch(a.handedness){case"none":{C[0].x+=y.axes[0],C[0].y+=y.axes[1],C[1].x+=y.axes[2],C[1].y+=y.axes[3];break}case"left":{C[0].x+=y.axes[2],C[0].y+=y.axes[3];break}case"right":{C[1].x+=y.axes[2],C[1].y+=y.axes[3];break}}}for(const a of C)a.x=Math.abs(a.x)>=this.stickThreshold?a.x:0,a.y=Math.abs(a.y)>=this.stickThreshold?a.y:0;const D=new F(C[1].x,C[1].y,0).multiplyScalar(this.rotateSpeed);for(const[a,y]of Object.entries(this.keycodeRotateMapping))this.keycode[a]&&D.add(y);for(const a in this.gamepadMapping)if(i[Number.parseInt(a)])switch(this.gamepadMapping[a]){case"rollLeft":D.z+=1;break;case"rollRight":D.z-=1;break}D.multiply(new F(this.rotateSpeed,this.rotateSpeed,this.rollSpeed));let s=D.length()>kI;if(D.manhattanLength()>0){D.multiplyScalar(A);const a=new Lg().setFromQuaternion(I.quaternion,"YXZ");a.y-=D.x,a.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,a.x-D.y)),a.z=Math.max(-Math.PI,Math.min(Math.PI,a.z+D.z)),I.quaternion.setFromEuler(a)}const w=new F(C[0].x,0,C[0].y);w.add(this.extraMove);for(const[a,y]of Object.entries(this.keycodeMoveMapping))this.keycode[a]&&w.add(y);let G=1;this.keydown.CapsLock&&(G*=this.capsMultiplier),(this.keycode.ShiftLeft||this.keycode.ShiftRight)&&(G*=this.shiftMultiplier),(this.keycode.ControlLeft||this.keycode.ControlRight)&&(G*=this.ctrlMultiplier);for(const a in this.gamepadMapping)if(i[Number.parseInt(a)])switch(this.gamepadMapping[a]){case"shift":G*=this.shiftMultiplier;break;case"ctrl":G*=this.ctrlMultiplier;break}return w.length()>kI&&(s=!0),w.applyQuaternion(I.quaternion),I.position.add(w.multiplyScalar(this.moveSpeed*G*A)),s}}class Hk{constructor({canvas:A,rotateSpeed:I,slideSpeed:g,scrollSpeed:B,swapRotateSlide:C,reverseRotate:E,reverseSlide:i,reverseSwipe:o,reverseScroll:D,moveInertia:s,rotateInertia:w,pointerRollScale:G,doublePress:a,pressMoveDelayMs:y,pressMoveAccelMs:h,pressMoveSpeed:c,doublePressMoveSpeed:k,triplePressMoveSpeed:R,pressMoveCenter:t}){this.enable=!0,this.canvas=A,this.rotateSpeed=I??sk,this.slideSpeed=g??Gk,this.scrollSpeed=B??ak,this.swapRotateSlide=C??!1,this.reverseRotate=E??(HB()||rg()),this.reverseSlide=i??!1,this.reverseSwipe=o??!1,this.reverseScroll=D??!1,this.moveInertia=s??yk,this.rotateInertia=w??hk,this.pointerRollScale=G??Rk,this.doublePress=a??(()=>{}),this.doublePressLimitMs=Nk,this.doublePressDistance=Mk,this.pressMoveDelayMs=y??Fk,this.pressMoveAccelMs=h??Sk,this.pressMoveSpeed=c??0,this.doublePressMoveSpeed=k??this.pressMoveSpeed*5,this.triplePressMoveSpeed=R??this.doublePressMoveSpeed*5,this.pressMoveCenter=t??!0,this.doublePressed=void 0,this.triplePressed=!1,this.lastUp=null,this.lastLastUp=null,this.rotating=null,this.sliding=null,this.lastDown=null,this.dualPress=!1,this.scroll=new F,this.rotateVelocity=new F,this.moveVelocity=new F,A.addEventListener("pointerdown",S=>{const J=this.getPointerPosition(S),M=J.clone(),U=J.clone(),n=!this.swapRotateSlide&&!this.rotating&&(S.pointerType!=="mouse"||S.button===0)||this.swapRotateSlide&&this.sliding&&!this.rotating&&(S.pointerType!=="mouse"||S.button===1),{pointerId:L}=S,H=performance.now();if(n)this.rotating={initial:M,last:U,position:J,pointerId:L,timeStamp:H},this.lastDown=this.rotating,A.setPointerCapture(S.pointerId),this.dualPress=!1;else if(!this.sliding){const e=S.pointerType==="mouse"?S.button:void 0;this.sliding={initial:M,last:U,position:J,pointerId:L,button:e,timeStamp:H},this.lastDown=this.sliding,A.setPointerCapture(S.pointerId),this.dualPress=this.rotating!=null&&H-this.rotating.timeStamp<tk}if(this.lastUp){const e=this.lastUp.position.distanceTo(J),q=H-this.lastUp.timeStamp;if(e<this.doublePressDistance&&q<this.doublePressLimitMs&&(this.doublePressed=performance.now(),this.triplePressed=!1,this.lastLastUp)){const Y=this.lastLastUp.position.distanceTo(this.lastUp.position),K=this.lastUp.timeStamp-this.lastLastUp.timeStamp;Y<this.doublePressDistance&&K<this.doublePressLimitMs&&(this.triplePressed=!0)}}});const N=S=>{var J,M;((J=this.rotating)==null?void 0:J.pointerId)===S.pointerId?(this.rotating=null,A.releasePointerCapture(S.pointerId),this.dualPress&&this.sliding&&(A.releasePointerCapture(this.sliding.pointerId),this.sliding=null)):((M=this.sliding)==null?void 0:M.pointerId)===S.pointerId&&(this.sliding=null,A.releasePointerCapture(S.pointerId),this.dualPress&&this.rotating&&(A.releasePointerCapture(this.rotating.pointerId),this.rotating=null)),this.doublePressed=void 0,this.triplePressed=!1;const U=this.getPointerPosition(S),n=this.lastUp;this.lastLastUp=this.lastUp;const L=performance.now();if(this.lastUp={position:U,timeStamp:L},n&&n.position.distanceTo(U)<this.doublePressDistance){const e=L-n.timeStamp;e<this.doublePressLimitMs&&this.doublePress({position:U,intervalMs:e})}};document.addEventListener("pointerup",N),document.addEventListener("pointercancel",N),document.addEventListener("pointermove",S=>{var J,M;((J=this.rotating)==null?void 0:J.pointerId)===S.pointerId?this.rotating.position=this.getPointerPosition(S):((M=this.sliding)==null?void 0:M.pointerId)===S.pointerId&&(this.sliding.position=this.getPointerPosition(S))}),A.addEventListener("contextmenu",S=>{S.preventDefault()}),A.addEventListener("wheel",S=>{this.scroll.add(new F(S.deltaX,S.deltaY,S.deltaZ)),S.preventDefault()})}getPointerPosition(A){const I=this.canvas.getBoundingClientRect();return new OA(A.clientX-I.left,A.clientY-I.top)}update(A,I,g){var B,C;if(!this.enable)return!1;const E=performance.now();let i=!1;if(this.dualPress&&this.rotating&&this.sliding){const D=[this.rotating.position.clone().sub(this.rotating.last),this.sliding.position.clone().sub(this.sliding.last)],s=D[0].dot(D[1]);if(s>=.2){const w=D[0].clone().add(D[1]),G=new F(w.x,-w.y,0);G.multiplyScalar(this.slideSpeed*(this.reverseSwipe?1:-1)),G.applyQuaternion(I.quaternion),I.position.add(G),this.moveVelocity=G.clone().multiplyScalar(1/A),G.length()>kI&&(i=!0)}else if(s<=-.2){const w=this.sliding.last.clone().sub(this.rotating.last),G=w.length();w.multiplyScalar(1/G).normalize();const a=new OA(-w.y,w.x),y=[D[0].dot(w),D[1].dot(w)],h=[D[0].dot(a),D[1].dot(a)],c=this.rotating.last.clone().add(this.sliding.last).multiplyScalar(.5);let k=new F;const R=g??(I instanceof zQ?I:void 0);if(R){const U=new OA(c.x/this.canvas.clientWidth*2-1,-(c.y/this.canvas.clientHeight)*2+1),n=new QC;n.setFromCamera(U,R),k=n.ray.direction}const t=y[1]-y[0],N=k.multiplyScalar(t*this.slideSpeed);I.position.add(N),this.moveVelocity=N.clone().multiplyScalar(1/A),N.length()>kI&&(i=!0);const S=[Math.atan(h[0]/(-.5*G)),Math.atan(h[1]/(.5*G))],J=.5*(S[0]+S[1])*this.pointerRollScale,M=new Lg().setFromQuaternion(I.quaternion,"YXZ");M.z=Math.max(-Math.PI,Math.min(Math.PI,M.z+.5*J)),I.quaternion.setFromEuler(M),Math.abs(J)>kI&&(i=!0)}this.rotating.last.copy(this.rotating.position),this.sliding.last.copy(this.sliding.position)}else{const D=new F;if(this.rotating&&!this.dualPress){const w=this.rotating.position.clone().sub(this.rotating.last);this.rotating.last.copy(this.rotating.position),D.set(w.x,w.y,0),D.multiplyScalar(this.rotateSpeed*(this.reverseRotate?-1:1)),this.rotateVelocity=D.clone().multiplyScalar(1/A),D.length()>kI&&(i=!0)}else this.rotateVelocity.multiplyScalar(Math.exp(-A/this.rotateInertia)),D.addScaledVector(this.rotateVelocity,A),this.rotateVelocity.length()*.1>kI&&(i=!0);const s=new Lg().setFromQuaternion(I.quaternion,"YXZ");if(s.y-=D.x,s.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,s.x-D.y)),s.z*=Math.exp(-0*A),I.quaternion.setFromEuler(s),this.sliding&&!this.dualPress){const w=this.sliding.position.clone().sub(this.sliding.last);this.sliding.last.copy(this.sliding.position);const G=this.sliding.button!==2?new F(w.x,0,w.y):new F(w.x,-w.y,0);G.multiplyScalar(this.slideSpeed*(this.reverseSlide?-1:1)),G.applyQuaternion(I.quaternion),I.position.add(G),this.moveVelocity=G.clone().multiplyScalar(1/A),G.length()>kI&&(i=!0)}else{const w=new F;if(this.sliding||this.rotating){const a=((B=this.lastDown)==null?void 0:B.last)??new OA,y=g??(I instanceof zQ?I:void 0);if(y){const h=this.pressMoveCenter?new OA(0,0):new OA(a.x/this.canvas.clientWidth*2-1,-(a.y/this.canvas.clientHeight)*2+1),c=new QC;c.setFromCamera(h,y),w.copy(c.ray.direction).normalize()}if(this.doublePressed){this.pressHeld=!1;let h=(performance.now()-this.doublePressed)/this.pressMoveAccelMs;h=Math.max(0,Math.min(1,h)),w.multiplyScalar((this.triplePressed?this.triplePressMoveSpeed:this.doublePressMoveSpeed)*h)}else{let h=0;this.lastDown&&(h=(E-(((C=this.lastDown)==null?void 0:C.timeStamp)??E)-this.pressMoveDelayMs)/this.pressMoveAccelMs,this.lastDown.position.distanceTo(this.lastDown.initial)<this.doublePressDistance?this.pressHeld===void 0&&h>0&&(this.pressHeld=!0):this.pressHeld===void 0&&(this.pressHeld=!1)),this.pressHeld?w.multiplyScalar(this.pressMoveSpeed*Math.max(0,Math.min(1,h))):w.set(0,0,0)}}else this.pressHeld=void 0;const G=Math.exp(-A/this.moveInertia);this.moveVelocity.lerpVectors(w,this.moveVelocity,G),I.position.addScaledVector(this.moveVelocity,A),this.moveVelocity.length()*.1>kI&&(i=!0)}}const o=this.scroll.multiplyScalar(this.scrollSpeed);return o.set(o.x,o.z,o.y),this.reverseScroll&&o.multiplyScalar(-1),o.applyQuaternion(I.quaternion),I.position.add(o),o.length()>kI&&(i=!0),this.scroll.set(0,0,0),i}}const Lk=`
12014
12014
  precision highp float;
12015
12015
  precision highp int;
12016
12016
 
@@ -12117,4 +12117,4 @@ void main() {
12117
12117
  fragColor = rgba;
12118
12118
  #endif
12119
12119
  }
12120
- `;class GR{constructor(A){this.portalPairs=[],this.lastCameraWorld=new F().setScalar(Number.NaN),this.prefetchActive=!1,this.scratch={quat:new Z,scale:new F,center0:new F,center1:new F,normal0:new F,normal1:new F,centerT:new F,normalT:new F,prevCameraWorld:new F,currCameraWorld:new F,hit:new F,offset:new F,camWorld:new FA,newCamWorld:new FA,invCamLocal:new FA,newLocalFrame:new FA,cameraWorldPos:new F,viewDir:new F,portalCenter:new F,toPortal:new F},this.renderer=A.renderer,this.scene=A.scene,this.camera=A.camera,this.localFrame=A.localFrame,this.defaultPortalRadius=A.defaultPortalRadius??1,this.portalCrossEps=A.portalCrossEps??1e-6;const I=A.sparkOptions??{};this.portalRenderer=new aC({renderer:this.renderer,extraUniforms:{diskCenter:{value:new F},diskNormal:{value:new F},diskRadius:{value:0},diskTwoSided:{value:!1}},fragmentShader:Lk,...I}),this.scene.add(this.portalRenderer),this.behindRenderer=new aC({renderer:this.renderer,enableDriveLod:!1,...I}),this.camera2=this.camera.clone(),this.scene.add(this.camera2)}addPortalPair(A){const I={entryPortal:new Yg,exitPortal:new Yg,radius:A?.radius??this.defaultPortalRadius,onCross:A?.onCross,_entryBefore:new FA,_exitBefore:new FA};return this.scene.add(I.entryPortal),this.scene.add(I.exitPortal),this.portalPairs.push(I),I}removePortalPair(A){const I=this.portalPairs.indexOf(A);I!==-1&&(this.scene.remove(A.entryPortal),this.scene.remove(A.exitPortal),this.portalPairs.splice(I,1))}getEntryToExitTransform(A){return A.entryPortal.matrixWorld.clone().invert().premultiply(A.exitPortal.matrixWorld)}getExitToEntryTransform(A){return A.exitPortal.matrixWorld.clone().invert().premultiply(A.entryPortal.matrixWorld)}setPortalDiskUniforms(A,I,g,B){A.updateMatrixWorld(!0),I.updateMatrixWorld(!0);const C=A.matrixWorld.clone().invert(),E=I.matrixWorld.clone().premultiply(C),i=new Z,o=this.portalRenderer.uniforms;E.decompose(o.diskCenter.value,i,new F),o.diskNormal.value.set(0,0,1).applyQuaternion(i),o.diskRadius.value=g,o.diskTwoSided.value=B}getPortalPlane(A,I,g){A.decompose(I,this.scratch.quat,this.scratch.scale),g.set(0,0,1).applyQuaternion(this.scratch.quat).normalize()}getSegmentDiskCrossing(A,I,g,B,C){this.getPortalPlane(g,this.scratch.center0,this.scratch.normal0),this.getPortalPlane(B,this.scratch.center1,this.scratch.normal1);const E=this.scratch.offset.copy(A).sub(this.scratch.center0).dot(this.scratch.normal0),i=this.scratch.offset.copy(I).sub(this.scratch.center1).dot(this.scratch.normal1);if(E>this.portalCrossEps&&i>this.portalCrossEps||E<-this.portalCrossEps&&i<-this.portalCrossEps)return null;const o=E-i;if(Math.abs(o)<this.portalCrossEps)return null;const D=E/o;return D<0||D>1||(this.scratch.hit.lerpVectors(A,I,D),this.scratch.centerT.copy(this.scratch.center0).lerp(this.scratch.center1,D),this.scratch.normalT.copy(this.scratch.normal0).lerp(this.scratch.normal1,D).normalize(),this.scratch.offset.copy(this.scratch.hit).sub(this.scratch.centerT),this.scratch.offset.addScaledVector(this.scratch.normalT,-this.scratch.offset.dot(this.scratch.normalT)),this.scratch.offset.lengthSq()>C*C)?null:D}teleport(A){this.scratch.camWorld.copy(this.camera.matrixWorld),this.scratch.newCamWorld.copy(this.scratch.camWorld).premultiply(A),this.scratch.invCamLocal.copy(this.camera.matrix).invert(),this.scratch.newLocalFrame.copy(this.scratch.newCamWorld).multiply(this.scratch.invCamLocal),this.scratch.newLocalFrame.decompose(this.localFrame.position,this.localFrame.quaternion,this.localFrame.scale),this.localFrame.updateMatrixWorld(!0),this.camera.updateMatrixWorld(!0)}updateTeleportation(){if(this.portalPairs.length===0)return;if(this.camera.getWorldPosition(this.scratch.currCameraWorld),!Number.isFinite(this.lastCameraWorld.x)){this.lastCameraWorld.copy(this.scratch.currCameraWorld);return}this.scratch.prevCameraWorld.copy(this.lastCameraWorld);let A=null,I=null,g=!0;for(const B of this.portalPairs){B.entryPortal.updateMatrixWorld(!0),B.exitPortal.updateMatrixWorld(!0),B._entryBefore.copy(B.entryPortal.matrixWorld),B._exitBefore.copy(B.exitPortal.matrixWorld);const C=this.getSegmentDiskCrossing(this.scratch.prevCameraWorld,this.scratch.currCameraWorld,B._entryBefore,B.entryPortal.matrixWorld,B.radius);C!==null&&(A===null||C<A)&&(A=C,I=B,g=!0);const E=this.getSegmentDiskCrossing(this.scratch.prevCameraWorld,this.scratch.currCameraWorld,B._exitBefore,B.exitPortal.matrixWorld,B.radius);E!==null&&(A===null||E<A)&&(A=E,I=B,g=!1)}if(I===null){this.lastCameraWorld.copy(this.scratch.currCameraWorld);return}g?this.teleport(this.getEntryToExitTransform(I)):this.teleport(this.getExitToEntryTransform(I)),this.camera.getWorldPosition(this.lastCameraWorld),I.onCross&&Promise.resolve(I.onCross(I,g)).catch(B=>{console.error("Error in portal onCross callback:",B)})}findPrimaryPortal(){if(this.portalPairs.length===0)return null;this.camera.getWorldPosition(this.scratch.cameraWorldPos),this.camera.getWorldDirection(this.scratch.viewDir);let A=Number.NEGATIVE_INFINITY,I=null,g=!0;for(const B of this.portalPairs){B.entryPortal.getWorldPosition(this.scratch.portalCenter),this.scratch.toPortal.copy(this.scratch.portalCenter).sub(this.scratch.cameraWorldPos);const C=this.scratch.toPortal.length(),E=this.scratch.toPortal.normalize().dot(this.scratch.viewDir)/C;E>A&&(A=E,I=B,g=!0),B.exitPortal.getWorldPosition(this.scratch.portalCenter),this.scratch.toPortal.copy(this.scratch.portalCenter).sub(this.scratch.cameraWorldPos);const i=this.scratch.toPortal.length(),o=this.scratch.toPortal.normalize().dot(this.scratch.viewDir)/i;o>A&&(A=o,I=B,g=!1)}return I?{pair:I,primaryIsEntry:g,primaryPortal:g?I.entryPortal:I.exitPortal,otherPortal:g?I.exitPortal:I.entryPortal}:null}render(){const A=this.findPrimaryPortal();if(!A){this.prefetchActive&&(this.prefetchActive=!1),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);return}this.prefetchActive||(this.prefetchActive=!0);const{pair:I,primaryIsEntry:g,primaryPortal:B,otherPortal:C}=A;(g?this.camera.matrixWorld.clone().premultiply(this.getEntryToExitTransform(I)):this.camera.matrixWorld.clone().premultiply(this.getExitToEntryTransform(I))).decompose(this.camera2.position,this.camera2.quaternion,this.camera2.scale),this.camera2.updateMatrixWorld(!0),this.shareLodInstances(),this.setPortalDiskUniforms(this.camera2,C,I.radius,!0),this.renderer.autoClear=!0,this.behindRenderer.render(this.scene,this.camera2),this.setPortalDiskUniforms(this.camera,B,-I.radius,!0),this.renderer.autoClear=!1,this.portalRenderer.render(this.scene,this.camera)}shareLodInstances(){this.behindRenderer.lodInstances.clear();for(const[A,I]of this.portalRenderer.lodInstances)this.behindRenderer.lodInstances.set(A,I)}animateLoopHook(){this.updateTeleportation(),this.render()}updateAspect(A){this.camera2.aspect=A,this.camera2.updateProjectionMatrix()}dispose(){this.scene.remove(this.portalRenderer),this.scene.remove(this.camera2);for(const A of this.portalPairs)this.scene.remove(A.entryPortal),this.scene.remove(A.exitPortal);this.portalPairs=[],this.portalRenderer.dispose(),this.behindRenderer.dispose()}}export{qc as DEFAULT_CONTROLLER_FAST_MULTIPLIER,fc as DEFAULT_CONTROLLER_GETFAST,xc as DEFAULT_CONTROLLER_GETMOVE,pc as DEFAULT_CONTROLLER_GETROTATE,bc as DEFAULT_CONTROLLER_GETSLOW,gR as DEFAULT_CONTROLLER_MOVE_HEADING,Kc as DEFAULT_CONTROLLER_MOVE_SPEED,dc as DEFAULT_CONTROLLER_ROLL_SPEED,MC as DEFAULT_CONTROLLER_ROTATE_SPEED,lc as DEFAULT_CONTROLLER_SLOW_MULTIPLIER,Lk as DISK_PORTAL_FRAGMENT_SHADER,qI as ExtSplats,DR as FINGER_TIPS,ek as FpsMovement,yB as HANDS,fw as Hand,wR as HandMovement,pw as JOINT_IDS,ER as JOINT_INDEX,Wg as JOINT_RADIUS,ik as JOINT_SEGMENTS,Dk as JOINT_SEGMENT_STEPS,iR as JOINT_TIPS,IC as JointEnum,Qk as JointSplats,mA as LN_SCALE_MAX,PA as LN_SCALE_MIN,CR as NUM_JOINTS,Vk as OldSparkRenderer,FC as OldSparkViewpoint,WQ as OldSplatAccumulator,SI as PackedSplats,IQ as PagedSplats,ew as PlyReader,Hk as PointerControls,LQ as Readback,qy as RgbaArray,Xs as Sint8ToFloat,sR as SparkControls,GR as SparkPortals,aC as SparkRenderer,QR as SparkXr,Rg as SplatAccumulator,ZB as SplatEdit,py as SplatEditRgbaBlendMode,by as SplatEditSdf,ly as SplatEditSdfType,uy as SplatEdits,cA as SplatFileType,jI as SplatGenerator,Hw as SplatLoader,wI as SplatMesh,Ty as SplatModifier,Qg as SplatPager,Wk as SplatSkinning,Fc as SplatSkinningMode,gg as SplatTransformer,yc as SpzReader,KI as SpzWriter,Vs as Uint8ToFloat,kQ as XrHand,oR as XrHands,vk as constructAxes,jk as constructGrid,zk as constructSpherePoints,uk as defines,mk as dyno,o0 as flipPixels,zg as floatToSint8,$A as floatToUint8,MA as fromHalf,AR as generators,vB as getSplatFileType,$k as imageSplats,HB as isAndroid,rg as isIos,GQ as isMobile,LB as isOculus,Ok as isPcSogs,D0 as isQuest2,QE as isVisionPro,BR as lerpHandsSnapshots,IR as modifiers,w0 as pixelsToPngUrl,Tk as readRgbaArray,gB as setPackedSplat,_k as textSplats,vA as toHalf,Xk as transcodeSpz,sQ as unpackSplat,Zk as unpackSplats,Pk as utils};
12120
+ `;class BR{constructor(A){this.portalPairs=[],this.lastCameraWorld=new F().setScalar(Number.NaN),this.prefetchActive=!1,this.scratch={quat:new Z,scale:new F,center0:new F,center1:new F,normal0:new F,normal1:new F,centerT:new F,normalT:new F,prevCameraWorld:new F,currCameraWorld:new F,hit:new F,offset:new F,camWorld:new FA,newCamWorld:new FA,invCamLocal:new FA,newLocalFrame:new FA,cameraWorldPos:new F,viewDir:new F,portalCenter:new F,toPortal:new F},this.renderer=A.renderer,this.scene=A.scene,this.camera=A.camera,this.localFrame=A.localFrame,this.defaultPortalRadius=A.defaultPortalRadius??1,this.portalCrossEps=A.portalCrossEps??1e-6;const I=A.sparkOptions??{};this.portalRenderer=new aC({renderer:this.renderer,extraUniforms:{diskCenter:{value:new F},diskNormal:{value:new F},diskRadius:{value:0},diskTwoSided:{value:!1}},fragmentShader:Lk,...I}),this.scene.add(this.portalRenderer),this.behindRenderer=new aC({renderer:this.renderer,enableDriveLod:!1,...I}),this.camera2=this.camera.clone(),this.scene.add(this.camera2)}addPortalPair(A){const I={entryPortal:new Yg,exitPortal:new Yg,radius:A?.radius??this.defaultPortalRadius,onCross:A?.onCross,_entryBefore:new FA,_exitBefore:new FA};return this.scene.add(I.entryPortal),this.scene.add(I.exitPortal),this.portalPairs.push(I),I}removePortalPair(A){const I=this.portalPairs.indexOf(A);I!==-1&&(this.scene.remove(A.entryPortal),this.scene.remove(A.exitPortal),this.portalPairs.splice(I,1))}getEntryToExitTransform(A){return A.entryPortal.matrixWorld.clone().invert().premultiply(A.exitPortal.matrixWorld)}getExitToEntryTransform(A){return A.exitPortal.matrixWorld.clone().invert().premultiply(A.entryPortal.matrixWorld)}setPortalDiskUniforms(A,I,g,B){A.updateMatrixWorld(!0),I.updateMatrixWorld(!0);const C=A.matrixWorld.clone().invert(),E=I.matrixWorld.clone().premultiply(C),i=new Z,o=this.portalRenderer.uniforms;E.decompose(o.diskCenter.value,i,new F),o.diskNormal.value.set(0,0,1).applyQuaternion(i),o.diskRadius.value=g,o.diskTwoSided.value=B}getPortalPlane(A,I,g){A.decompose(I,this.scratch.quat,this.scratch.scale),g.set(0,0,1).applyQuaternion(this.scratch.quat).normalize()}getSegmentDiskCrossing(A,I,g,B,C){this.getPortalPlane(g,this.scratch.center0,this.scratch.normal0),this.getPortalPlane(B,this.scratch.center1,this.scratch.normal1);const E=this.scratch.offset.copy(A).sub(this.scratch.center0).dot(this.scratch.normal0),i=this.scratch.offset.copy(I).sub(this.scratch.center1).dot(this.scratch.normal1);if(E>this.portalCrossEps&&i>this.portalCrossEps||E<-this.portalCrossEps&&i<-this.portalCrossEps)return null;const o=E-i;if(Math.abs(o)<this.portalCrossEps)return null;const D=E/o;return D<0||D>1||(this.scratch.hit.lerpVectors(A,I,D),this.scratch.centerT.copy(this.scratch.center0).lerp(this.scratch.center1,D),this.scratch.normalT.copy(this.scratch.normal0).lerp(this.scratch.normal1,D).normalize(),this.scratch.offset.copy(this.scratch.hit).sub(this.scratch.centerT),this.scratch.offset.addScaledVector(this.scratch.normalT,-this.scratch.offset.dot(this.scratch.normalT)),this.scratch.offset.lengthSq()>C*C)?null:D}teleport(A){this.scratch.camWorld.copy(this.camera.matrixWorld),this.scratch.newCamWorld.copy(this.scratch.camWorld).premultiply(A),this.scratch.invCamLocal.copy(this.camera.matrix).invert(),this.scratch.newLocalFrame.copy(this.scratch.newCamWorld).multiply(this.scratch.invCamLocal),this.scratch.newLocalFrame.decompose(this.localFrame.position,this.localFrame.quaternion,this.localFrame.scale),this.localFrame.updateMatrixWorld(!0),this.camera.updateMatrixWorld(!0)}updateTeleportation(){if(this.portalPairs.length===0)return;if(this.camera.getWorldPosition(this.scratch.currCameraWorld),!Number.isFinite(this.lastCameraWorld.x)){this.lastCameraWorld.copy(this.scratch.currCameraWorld);return}this.scratch.prevCameraWorld.copy(this.lastCameraWorld);let A=null,I=null,g=!0;for(const B of this.portalPairs){B.entryPortal.updateMatrixWorld(!0),B.exitPortal.updateMatrixWorld(!0),B._entryBefore.copy(B.entryPortal.matrixWorld),B._exitBefore.copy(B.exitPortal.matrixWorld);const C=this.getSegmentDiskCrossing(this.scratch.prevCameraWorld,this.scratch.currCameraWorld,B._entryBefore,B.entryPortal.matrixWorld,B.radius);C!==null&&(A===null||C<A)&&(A=C,I=B,g=!0);const E=this.getSegmentDiskCrossing(this.scratch.prevCameraWorld,this.scratch.currCameraWorld,B._exitBefore,B.exitPortal.matrixWorld,B.radius);E!==null&&(A===null||E<A)&&(A=E,I=B,g=!1)}if(I===null){this.lastCameraWorld.copy(this.scratch.currCameraWorld);return}g?this.teleport(this.getEntryToExitTransform(I)):this.teleport(this.getExitToEntryTransform(I)),this.camera.getWorldPosition(this.lastCameraWorld),I.onCross&&Promise.resolve(I.onCross(I,g)).catch(B=>{console.error("Error in portal onCross callback:",B)})}findPrimaryPortal(){if(this.portalPairs.length===0)return null;this.camera.getWorldPosition(this.scratch.cameraWorldPos),this.camera.getWorldDirection(this.scratch.viewDir);let A=Number.NEGATIVE_INFINITY,I=null,g=!0;for(const B of this.portalPairs){B.entryPortal.getWorldPosition(this.scratch.portalCenter),this.scratch.toPortal.copy(this.scratch.portalCenter).sub(this.scratch.cameraWorldPos);const C=this.scratch.toPortal.length(),E=this.scratch.toPortal.normalize().dot(this.scratch.viewDir)/C;E>A&&(A=E,I=B,g=!0),B.exitPortal.getWorldPosition(this.scratch.portalCenter),this.scratch.toPortal.copy(this.scratch.portalCenter).sub(this.scratch.cameraWorldPos);const i=this.scratch.toPortal.length(),o=this.scratch.toPortal.normalize().dot(this.scratch.viewDir)/i;o>A&&(A=o,I=B,g=!1)}return I?{pair:I,primaryIsEntry:g,primaryPortal:g?I.entryPortal:I.exitPortal,otherPortal:g?I.exitPortal:I.entryPortal}:null}render(){const A=this.findPrimaryPortal();if(!A){this.prefetchActive&&(this.prefetchActive=!1),this.renderer.autoClear=!0,this.renderer.render(this.scene,this.camera);return}this.prefetchActive||(this.prefetchActive=!0);const{pair:I,primaryIsEntry:g,primaryPortal:B,otherPortal:C}=A;(g?this.camera.matrixWorld.clone().premultiply(this.getEntryToExitTransform(I)):this.camera.matrixWorld.clone().premultiply(this.getExitToEntryTransform(I))).decompose(this.camera2.position,this.camera2.quaternion,this.camera2.scale),this.camera2.updateMatrixWorld(!0),this.shareLodInstances(),this.setPortalDiskUniforms(this.camera2,C,I.radius,!0),this.renderer.autoClear=!0,this.behindRenderer.render(this.scene,this.camera2),this.setPortalDiskUniforms(this.camera,B,-I.radius,!0),this.renderer.autoClear=!1,this.portalRenderer.render(this.scene,this.camera)}shareLodInstances(){this.behindRenderer.lodInstances.clear();for(const[A,I]of this.portalRenderer.lodInstances)this.behindRenderer.lodInstances.set(A,I)}animateLoopHook(){this.updateTeleportation(),this.render()}updateAspect(A){this.camera2.aspect=A,this.camera2.updateProjectionMatrix()}dispose(){this.scene.remove(this.portalRenderer),this.scene.remove(this.camera2);for(const A of this.portalPairs)this.scene.remove(A.entryPortal),this.scene.remove(A.exitPortal);this.portalPairs=[],this.portalRenderer.dispose(),this.behindRenderer.dispose()}}export{qc as DEFAULT_CONTROLLER_FAST_MULTIPLIER,fc as DEFAULT_CONTROLLER_GETFAST,xc as DEFAULT_CONTROLLER_GETMOVE,pc as DEFAULT_CONTROLLER_GETROTATE,bc as DEFAULT_CONTROLLER_GETSLOW,Wk as DEFAULT_CONTROLLER_MOVE_HEADING,Kc as DEFAULT_CONTROLLER_MOVE_SPEED,dc as DEFAULT_CONTROLLER_ROLL_SPEED,MC as DEFAULT_CONTROLLER_ROTATE_SPEED,lc as DEFAULT_CONTROLLER_SLOW_MULTIPLIER,Lk as DISK_PORTAL_FRAGMENT_SHADER,qI as ExtSplats,AR as FINGER_TIPS,ek as FpsMovement,yB as HANDS,fw as Hand,gR as HandMovement,pw as JOINT_IDS,_k as JOINT_INDEX,Wg as JOINT_RADIUS,ik as JOINT_SEGMENTS,Dk as JOINT_SEGMENT_STEPS,$k as JOINT_TIPS,IC as JointEnum,Qk as JointSplats,mA as LN_SCALE_MAX,PA as LN_SCALE_MIN,zk as NUM_JOINTS,fk as OldSparkRenderer,FC as OldSparkViewpoint,WQ as OldSplatAccumulator,SI as PackedSplats,IQ as PagedSplats,ew as PlyReader,Hk as PointerControls,LQ as Readback,qy as RgbaArray,Xs as Sint8ToFloat,QR as SparkControls,BR as SparkPortals,aC as SparkRenderer,jk as SparkXr,Rg as SplatAccumulator,ZB as SplatEdit,py as SplatEditRgbaBlendMode,by as SplatEditSdf,ly as SplatEditSdfType,uy as SplatEdits,cA as SplatFileType,jI as SplatGenerator,Hw as SplatLoader,wI as SplatMesh,Ty as SplatModifier,Qg as SplatPager,uk as SplatSkinning,Fc as SplatSkinningMode,gg as SplatTransformer,yc as SpzReader,KI as SpzWriter,Vs as Uint8ToFloat,kQ as XrHand,IR as XrHands,mk as constructAxes,Pk as constructGrid,Tk as constructSpherePoints,Kk as defines,qk as dyno,o0 as flipPixels,zg as floatToSint8,$A as floatToUint8,MA as fromHalf,Vk as generators,vB as getSplatFileType,Zk as imageSplats,HB as isAndroid,rg as isIos,GQ as isMobile,LB as isOculus,xk as isPcSogs,D0 as isQuest2,QE as isVisionPro,vk as lerpHandsSnapshots,Xk as modifiers,w0 as pixelsToPngUrl,lk as readRgbaArray,gB as setPackedSplat,Ok as textSplats,vA as toHalf,bk as transcodeSpz,sQ as unpackSplat,pk as unpackSplats,dk as utils};