@volter/game-editor 0.5.138 → 0.5.139

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 (295) hide show
  1. package/BUNDLED_NOTICES +22 -22
  2. package/catalog/entries/blender.json +2 -2
  3. package/catalog/entries/music.json +2 -2
  4. package/dist/.vite/manifest.json +2181 -2181
  5. package/dist/assets/{AssetBudgetPanel-BHIwMy_1.js → AssetBudgetPanel-CjuDQvXh.js} +3 -3
  6. package/dist/assets/{AudioViewer-CuLR_cTm.js → AudioViewer-CNqYeRNi.js} +1 -1
  7. package/dist/assets/{CanvasBoardDocument-CwW6iT46.js → CanvasBoardDocument-CmNuR9ae.js} +1 -1
  8. package/dist/assets/{CanvasSceneViewport-DEtjbzl1.js → CanvasSceneViewport-DvTkPUgn.js} +1 -1
  9. package/dist/assets/{ColorInput-EJqds8Dg.js → ColorInput-BwQW6U_s.js} +1 -1
  10. package/dist/assets/{ColorPicker-1j5n_93h.js → ColorPicker-BW6cWcGu.js} +1 -1
  11. package/dist/assets/{EntityModelDocument-B-a4Bg0P.js → EntityModelDocument-B45uREqB.js} +1 -1
  12. package/dist/assets/{EnvironmentAssetDocument-btLkZ1qY.js → EnvironmentAssetDocument-8F0JNdiM.js} +1 -1
  13. package/dist/assets/{GameplaySessionTimeline-CItKX4Kr.js → GameplaySessionTimeline-fGpjyiDW.js} +1 -1
  14. package/dist/assets/{ImageViewer-DJk9xi-D.js → ImageViewer-lE0hupl1.js} +1 -1
  15. package/dist/assets/InspectorObjectPreview-DE5nmrtn.js +1 -0
  16. package/dist/assets/{JsonAssetDocument-K5bEMcqx.js → JsonAssetDocument-BzW0mX2D.js} +1 -1
  17. package/dist/assets/{LiveModuleDocument-DFrSDCEK.js → LiveModuleDocument-C4KOPaQ2.js} +1 -1
  18. package/dist/assets/{LutAssetDocument-BCbtxOKD.js → LutAssetDocument-DM8eFFMW.js} +1 -1
  19. package/dist/assets/{ModelAssetDocument-DXC1RtoM.js → ModelAssetDocument-B66Nc9mt.js} +1 -1
  20. package/dist/assets/{NonThreeAuthoringBootstrap-CZWc7G5S.js → NonThreeAuthoringBootstrap-BNAfKZfR.js} +1 -1
  21. package/dist/assets/{Object3DDocumentToolbar-iTP9Eu_I.js → Object3DDocumentToolbar-CPWckRgr.js} +1 -1
  22. package/dist/assets/Object3DDocumentViewport-BMrvQ5Kf.js +2 -0
  23. package/dist/assets/{Object3DPreview-CzCajTGg.js → Object3DPreview-36lk0UIE.js} +1 -1
  24. package/dist/assets/{OnlineAssetDetail-IB4NHnh1.js → OnlineAssetDetail-B9BScq83.js} +1 -1
  25. package/dist/assets/{PlayBar-D7_p0d8C.js → PlayBar-DEZQZ-nr.js} +1 -1
  26. package/dist/assets/{QuarksAssetDocument-B6HoQ0uQ.js → QuarksAssetDocument-BLOfOnE3.js} +1 -1
  27. package/dist/assets/{ReactCanvasControls-D6ZjGG05.js → ReactCanvasControls-B1FLc-mq.js} +1 -1
  28. package/dist/assets/{RootSelectionOverlay-B3miWoWq.js → RootSelectionOverlay-DM1Rf518.js} +1 -1
  29. package/dist/assets/{ShaderAssetDocument-Cc_sxNhw.js → ShaderAssetDocument-BXbdllfL.js} +1 -1
  30. package/dist/assets/{ShadowEditor-DfEsZMPh.js → ShadowEditor-_VQupFN-.js} +1 -1
  31. package/dist/assets/{SourceAssetViewer-DdDB6rVv.js → SourceAssetViewer-DMgNpg0D.js} +1 -1
  32. package/dist/assets/{StageHost-rrAaudhd.js → StageHost-ludQj81x.js} +2 -2
  33. package/dist/assets/{StoryPreviewMount-LkxAF-dZ.js → StoryPreviewMount-DUnK9kFG.js} +1 -1
  34. package/dist/assets/{ThreeBoardDocument-pMsZlPCw.js → ThreeBoardDocument-CE4_ot0k.js} +2 -2
  35. package/dist/assets/{ThreeIsolationSceneContent-DqRMTGCX.js → ThreeIsolationSceneContent-BOLqBhuv.js} +1 -1
  36. package/dist/assets/{ToolObject3DPreview-Dmj0VEKI.js → ToolObject3DPreview-CFpKP0XW.js} +1 -1
  37. package/dist/assets/{Toolbar-DL2yJN91.js → Toolbar-Bp9rS6kO.js} +1 -1
  38. package/dist/assets/{TransientHint-DKn1rO3Z.js → TransientHint-DBoWuJlJ.js} +1 -1
  39. package/dist/assets/{VideoViewer-CHodGfb7.js → VideoViewer-CFyD9Kgi.js} +1 -1
  40. package/dist/assets/{ViewportShadingMenu-B7ajCUNW.js → ViewportShadingMenu-BkqTtt1s.js} +1 -1
  41. package/dist/assets/{active-ingest-Dv_OdTlX.js → active-ingest-UClxAck1.js} +2 -2
  42. package/dist/assets/{animation-clock-BZq_g9Tm.js → animation-clock-DL7eB0yc.js} +1 -1
  43. package/dist/assets/{animation-mixers.service-CNGY-DZD.js → animation-mixers.service-53pK8xiS.js} +1 -1
  44. package/dist/assets/{animation-timeline.utility-BRYd6DOo.js → animation-timeline.utility-7M6hGJn-.js} +1 -1
  45. package/dist/assets/{asset-budget-asset.menu-DnLhREKe.js → asset-budget-asset.menu-DS7nTJj-.js} +1 -1
  46. package/dist/assets/{asset-budget.action-DNnZBGA_.js → asset-budget.action-CLLlqLpV.js} +1 -1
  47. package/dist/assets/{asset-budget.document-Dtqevh6E.js → asset-budget.document-CBj__W_j.js} +1 -1
  48. package/dist/assets/{asset-budget.menu-BeAUf2fa.js → asset-budget.menu-Dpit56eW.js} +1 -1
  49. package/dist/assets/{asset-editor-persistence-Kup62rrY.js → asset-editor-persistence-Bug7RRIw.js} +1 -1
  50. package/dist/assets/{asset-loaders-Ct_J9rzC.js → asset-loaders-D6nZhO7W.js} +1 -1
  51. package/dist/assets/{asset-preview-JYD38Zp4.js → asset-preview-DuK7on8l.js} +1 -1
  52. package/dist/assets/{audio-unlock.service-Cj4u44gK.js → audio-unlock.service-B4S6nX06.js} +1 -1
  53. package/dist/assets/{audio.utility-BH33ZS9l.js → audio.utility-BpuEWRtk.js} +1 -1
  54. package/dist/assets/autoplay.service-QRbYvo5H.js +1 -0
  55. package/dist/assets/{babylon-authoring-adapter-DBDJMWVk.js → babylon-authoring-adapter-DUiLnYTl.js} +1 -1
  56. package/dist/assets/{binding-resolver-BJmpG_Yc.js → binding-resolver-D9Q2MV2d.js} +2 -2
  57. package/dist/assets/{blender-node-editor.document-BIdVY2G-.js → blender-node-editor.document-CM46THXO.js} +1 -1
  58. package/dist/assets/{blender-properties-tab-CgBl9_ef.js → blender-properties-tab-DsmyRjvf.js} +1 -1
  59. package/dist/assets/{blender-runtime-host-BWzMRxSe.js → blender-runtime-host-CzU1tMpu.js} +3 -3
  60. package/dist/assets/{blender-runtime-skin-Uyz-hCLU.js → blender-runtime-skin-Cym5LZv7.js} +14 -14
  61. package/dist/assets/blender-runtime.document-BALwDLT4.js +13 -0
  62. package/dist/assets/{blender-screenshot.menu-DYPDHOLq.js → blender-screenshot.menu-DFKYLZFA.js} +1 -1
  63. package/dist/assets/{blender-timeline.document-Cb1mEzKv.js → blender-timeline.document-jaXu4ErX.js} +1 -1
  64. package/dist/assets/{blender-uv-editor.document-BXXhwMHP.js → blender-uv-editor.document-CR8chOjw.js} +1 -1
  65. package/dist/assets/{blender-version.status-CsdeHlCG.js → blender-version.status-BMvh4Fb7.js} +1 -1
  66. package/dist/assets/{blender.command-B74rl9y7.js → blender.command-2ZCwq83N.js} +1 -1
  67. package/dist/assets/{board-guides-DCZVS9SH.js → board-guides-B9_M1_yw.js} +1 -1
  68. package/dist/assets/{bridge.command-CUP2L2Fi.js → bridge.command-CY4biuRb.js} +3 -3
  69. package/dist/assets/{browserAll-Dg2ntR5k.js → browserAll-BJ6HgrrM.js} +1 -1
  70. package/dist/assets/{build-player.document-Ck9k0fvm.js → build-player.document-yfN6ppi_.js} +1 -1
  71. package/dist/assets/{build-profiles.document-COpGLAdK.js → build-profiles.document-C78x96wQ.js} +1 -1
  72. package/dist/assets/{build-progress.status-BxQ6kGlS.js → build-progress.status-CRH236cv.js} +1 -1
  73. package/dist/assets/{build-session-DEcdvDa_.js → build-session-B-jVkhsK.js} +1 -1
  74. package/dist/assets/{build.action-BNdIMwYu.js → build.action-CaOwQVWx.js} +1 -1
  75. package/dist/assets/{build.command-775MrR2D.js → build.command-TZ1XDxzG.js} +1 -1
  76. package/dist/assets/{build.header-CyAzV_8B.js → build.header-uSfplnt6.js} +1 -1
  77. package/dist/assets/{build.menu-BfJfKu1c.js → build.menu-BaFMcWMc.js} +1 -1
  78. package/dist/assets/{build.service-ze-yHQ_3.js → build.service-Cev-zNra.js} +1 -1
  79. package/dist/assets/{camera-CMNsR2sN.js → camera-Bno1KyTP.js} +1 -1
  80. package/dist/assets/{camera-runtime.inspector-1aOipNlB.js → camera-runtime.inspector-D86JI7ys.js} +1 -1
  81. package/dist/assets/{canvas-design-mount-BRIUOTHL.js → canvas-design-mount-C2Taz437.js} +3 -3
  82. package/dist/assets/{canvas-entry-runtime-BSfyLrCN.js → canvas-entry-runtime-Bfp_EKOs.js} +2 -2
  83. package/dist/assets/{canvas-preview-frames-DBeCiVxG.js → canvas-preview-frames-CzoYoSt0.js} +1 -1
  84. package/dist/assets/{canvas-story-capture.service-B_KVdQHq.js → canvas-story-capture.service-B_8qdRMx.js} +2 -2
  85. package/dist/assets/{capability-coverage-B3dpc4Vr.js → capability-coverage-DzW3P6PB.js} +1 -1
  86. package/dist/assets/{collaboration-presence-C6_5pE_F.js → collaboration-presence-D56QA1uu.js} +1 -1
  87. package/dist/assets/{collider-qdfzXiWh.js → collider-2ycsuTVp.js} +1 -1
  88. package/dist/assets/{component-board.service-BriDxYSH.js → component-board.service-CMSPFS7M.js} +2 -2
  89. package/dist/assets/{component-board.service-CJpeoHhL.js → component-board.service-Cgr3rV5m.js} +2 -2
  90. package/dist/assets/{component-board.service-BMyUzF63.js → component-board.service-qLwbD7ZX.js} +2 -2
  91. package/dist/assets/{component-contracts.service-CZfEDaoy.js → component-contracts.service-DaycBgEy.js} +1 -1
  92. package/dist/assets/{component-instance-root-L097uFNh.js → component-instance-root-BtcOmix2.js} +1 -1
  93. package/dist/assets/{component-verbs.command-DBa9Sapc.js → component-verbs.command-CgASCZ_i.js} +1 -1
  94. package/dist/assets/{component-verbs.service-adeyYjAC.js → component-verbs.service-MYm0Fubr.js} +1 -1
  95. package/dist/assets/{config-pmlId-XO.js → config-DAHx_OTe.js} +2 -2
  96. package/dist/assets/{configurations-Bh18GHAL.js → configurations-B_3y0ROf.js} +1 -1
  97. package/dist/assets/{connection.status-_r5e7IHq.js → connection.status-DdvXX0nH.js} +1 -1
  98. package/dist/assets/{constraints.inspector-GruG63LN.js → constraints.inspector-BEYExuvJ.js} +1 -1
  99. package/dist/assets/{content-bounds-gCMH0ZWN.js → content-bounds-uy3hDTXw.js} +1 -1
  100. package/dist/assets/{contract-system-adapters-BSVvCjkf.js → contract-system-adapters-DbOhqD2p.js} +1 -1
  101. package/dist/assets/{coverage.service-eT8_TDMQ.js → coverage.service-3wf81o3O.js} +1 -1
  102. package/dist/assets/{create-runtime-DrD9USBs.js → create-runtime-B_RHkiy2.js} +1 -1
  103. package/dist/assets/{curve-gysShrCJ.js → curve-Cbvp5PDK.js} +1 -1
  104. package/dist/assets/{data-asset-Cv5efoD3.js → data-asset-S-DmCs5W.js} +1 -1
  105. package/dist/assets/{data-ref-CC5xGtfi.js → data-ref-Bkfs_TKL.js} +1 -1
  106. package/dist/assets/{debug-bridge-CTZe2WbV.js → debug-bridge-Dw_lsP-r.js} +1 -1
  107. package/dist/assets/{debug-registry-By-N2Qt3.js → debug-registry-BhFgg7r8.js} +1 -1
  108. package/dist/assets/{deferred-ingest-play-Bbj_Xo7m.js → deferred-ingest-play-BV2x0R2h.js} +2 -2
  109. package/dist/assets/{design-time-canvas-mount-De7pe1uW.js → design-time-canvas-mount-Dt2zC5Ld.js} +2 -2
  110. package/dist/assets/{design-time-layers-Duu-wSgO.js → design-time-layers-Bx9HWC84.js} +1 -1
  111. package/dist/assets/{design-time-mount.service-BnApZYmC.js → design-time-mount.service-DRCUW2Mi.js} +2 -2
  112. package/dist/assets/{design-time-mount.service-C_rsJzXl.js → design-time-mount.service-bOSnO2Tq.js} +2 -2
  113. package/dist/assets/{design-time-react-mount-dst1xSiF.js → design-time-react-mount-B5uOG0H7.js} +1 -1
  114. package/dist/assets/{document-preview-three-DA2AAo-_.js → document-preview-three-BfnCwrpV.js} +1 -1
  115. package/dist/assets/{dom-authoring-adapter-srFRABzp.js → dom-authoring-adapter-BSC2MYSr.js} +1 -1
  116. package/dist/assets/{draco3d-C5WLoJCV.js → draco3d-Dyoe3IcD.js} +1 -1
  117. package/dist/assets/{edit-mode-audio.service-BMklAAG1.js → edit-mode-audio.service-CoCle552.js} +1 -1
  118. package/dist/assets/{edit-mode-authoring-DygJkh1f.js → edit-mode-authoring-B2Kesn9N.js} +1 -1
  119. package/dist/assets/{edit-mode-networking.service-Cm-vAD9j.js → edit-mode-networking.service-DtyT4MnP.js} +1 -1
  120. package/dist/assets/{editor-api-Du05tL35.js → editor-api-D2w0Wuf7.js} +1 -1
  121. package/dist/assets/{editor-layers-D-_AuXmZ.js → editor-layers-dgmb9OkA.js} +1 -1
  122. package/dist/assets/{editor-shell-store-DAlfX1aI.js → editor-shell-store-OpESIM4a.js} +1 -1
  123. package/dist/assets/{entity-object-DI8C17HY.js → entity-object-B79hRIdx.js} +1 -1
  124. package/dist/assets/{extend-w_ilWOUC.js → extend-DCwSMDqN.js} +1 -1
  125. package/dist/assets/{fork-menu-Oa5VTcwj.js → fork-menu-VNthv9S2.js} +1 -1
  126. package/dist/assets/{frame-debugger-store-DNZOm_Si.js → frame-debugger-store-Ljo9g747.js} +1 -1
  127. package/dist/assets/{game-contract-seams-_r-6Gjsb.js → game-contract-seams-DUJgCAbE.js} +1 -1
  128. package/dist/assets/{game-css-scope-transform-CfITus_d.js → game-css-scope-transform-CuwV1R3U.js} +1 -1
  129. package/dist/assets/{game-document.service-oqdzJgb5.js → game-document.service-CgOMkodb.js} +1 -1
  130. package/dist/assets/{game-eval.command-C94P_EJC.js → game-eval.command-DqFJazUI.js} +1 -1
  131. package/dist/assets/{game-module-access-spcEw9oX.js → game-module-access-DLq6IxVQ.js} +1 -1
  132. package/dist/assets/{game-network-DniciiFm.js → game-network-rngD8A9s.js} +3 -3
  133. package/dist/assets/{gameplay-export-CVpKJDFb.js → gameplay-export-yv4RxuAP.js} +1 -1
  134. package/dist/assets/{gameplay-replay-CAOWnrZ_.js → gameplay-replay-DXNRtWAq.js} +1 -1
  135. package/dist/assets/{gameplay.command-KQkOgMi1.js → gameplay.command-B9l-Zd_e.js} +1 -1
  136. package/dist/assets/{generation-jobs-Dn89ggtS.js → generation-jobs-DjMjddEZ.js} +1 -1
  137. package/dist/assets/{generation.service-CQdVUg62.js → generation.service-B65RZ3Xj.js} +1 -1
  138. package/dist/assets/{generations-Dvg4A8qW.js → generations-BogXUq8R.js} +1 -1
  139. package/dist/assets/{generations.status-B2uzxDGf.js → generations.status-DQ-cKRbO.js} +1 -1
  140. package/dist/assets/{hierarchy-marks-CrjPi0wR.js → hierarchy-marks--hCaQPWK.js} +1 -1
  141. package/dist/assets/{hosted-asset-materialization-44EdbMuh.js → hosted-asset-materialization-E4oslMed.js} +1 -1
  142. package/dist/assets/{index-CXxG_n76.js → index-8Wua2fLA.js} +1 -1
  143. package/dist/assets/{index-M0s8PQyx.js → index-B1cMcOkR.js} +1 -1
  144. package/dist/assets/{index-_K_il-3e.js → index-BU5Wa6YB.js} +1 -1
  145. package/dist/assets/{index-Bq2dTWiW.js → index-BY6LqkgI.js} +1 -1
  146. package/dist/assets/{index-CPzTYyBe.js → index-BYv-VrM5.js} +1 -1
  147. package/dist/assets/{index-B_kfqokr.js → index-COR1kS33.js} +2 -2
  148. package/dist/assets/{index-jJyzinl6.js → index-CQ2mBTB3.js} +7 -7
  149. package/dist/assets/{index-CL5reJEA.js → index-DB3OomiZ.js} +1 -1
  150. package/dist/assets/{index-Bmsups4o.js → index-sMqw9o3s.js} +1 -1
  151. package/dist/assets/{inference-diagnostics-DxBo7WDw.js → inference-diagnostics-H8BhQPo1.js} +1 -1
  152. package/dist/assets/{ingest-boot-viewport-BwKxL4xX.js → ingest-boot-viewport-7rPgtMec.js} +1 -1
  153. package/dist/assets/{ingest-siblings-CVAH3Hu_.js → ingest-siblings-jS7uWpHB.js} +1 -1
  154. package/dist/assets/{ingest-source-persistence-CVljy1iW.js → ingest-source-persistence-DAeIROgB.js} +1 -1
  155. package/dist/assets/{ingest.service-CUBzToex.js → ingest.service-slwcN_Zt.js} +1 -1
  156. package/dist/assets/{inspect-CT9c1MHO.js → inspect-C5cLskKr.js} +1 -1
  157. package/dist/assets/instances.command-DXvKf1k6.js +1 -0
  158. package/dist/assets/{json-history-resource-DnU0FBDZ.js → json-history-resource-Bm80nf1w.js} +1 -1
  159. package/dist/assets/{layered-pick-C3nuefTC.js → layered-pick-BN_u4vpH.js} +1 -1
  160. package/dist/assets/{light-jcwM0PKm.js → light-BPAKY7kG.js} +1 -1
  161. package/dist/assets/{live-project-verbs-DPmz6pMS.js → live-project-verbs-BCv08_fa.js} +1 -1
  162. package/dist/assets/{machine.document-FCngPRuE.js → machine.document-CEnp_rCc.js} +1 -1
  163. package/dist/assets/{machines.finder-ChDhu2Qe.js → machines.finder-BER4T2lc.js} +1 -1
  164. package/dist/assets/{material-DKBuqT4w.js → material-3JMiH9rk.js} +1 -1
  165. package/dist/assets/{material-factory-fVKO9QOn.js → material-factory-Du7WUqib.js} +1 -1
  166. package/dist/assets/{mesh-CZAcYO1_.js → mesh-DMH0PrCb.js} +1 -1
  167. package/dist/assets/{model-asset-sections.service-uYP3RhFU.js → model-asset-sections.service-CrwDT75X.js} +1 -1
  168. package/dist/assets/{model-inspection-CttU5qku.js → model-inspection-RazLBT4Q.js} +1 -1
  169. package/dist/assets/{model-thumbnail-CT6QIUlc.js → model-thumbnail-DlJcpPzi.js} +1 -1
  170. package/dist/assets/{models.finder-DFJqax4P.js → models.finder-DIFXBoQE.js} +1 -1
  171. package/dist/assets/{module-mode-BR94HESo.js → module-mode-BSqPULWZ.js} +2 -2
  172. package/dist/assets/{mount-canvas-ingest-root-BA9-8GR4.js → mount-canvas-ingest-root-DcHtUiIX.js} +2 -2
  173. package/dist/assets/{mount-dom-ingest-root-DVJ5Ae_A.js → mount-dom-ingest-root-BT-SneoF.js} +2 -2
  174. package/dist/assets/{mount-ingest-root-BY863v4N.js → mount-ingest-root-BWqm1g8h.js} +2 -2
  175. package/dist/assets/{mount-manifest-pmwLLraN.js → mount-manifest-Dk2kIP9S.js} +1 -1
  176. package/dist/assets/{mount-three-ingest-root-A4ixbU-c.js → mount-three-ingest-root-DC7XVSNu.js} +1 -1
  177. package/dist/assets/{mounted-authoring-VQMCawDe.js → mounted-authoring-42mbkzQk.js} +1 -1
  178. package/dist/assets/{mounted-story-viewport-source-Cn0YUl2d.js → mounted-story-viewport-source-DNALyUeR.js} +1 -1
  179. package/dist/assets/{native-debug-module-B9i2evat.js → native-debug-module-2WtZMm25.js} +1 -1
  180. package/dist/assets/{navigation-DxwQfC-b.js → navigation-BiKzso-N.js} +1 -1
  181. package/dist/assets/{navmesh.menu-BISOVogR.js → navmesh.menu-CRpN60zw.js} +1 -1
  182. package/dist/assets/{navmesh.service-DatopdaF.js → navmesh.service-DrEBUXWK.js} +1 -1
  183. package/dist/assets/network-observer.service-B8KW6Gxu.js +1 -0
  184. package/dist/assets/{network.utility-tbSigi0u.js → network.utility-Don7G5oX.js} +1 -1
  185. package/dist/assets/{object3d-document-session-registry-D6X_XC3g.js → object3d-document-session-registry-BhLWtMoZ.js} +2 -2
  186. package/dist/assets/{oid-transform-Cs6QIDn-.js → oid-transform-B_w-y892.js} +1 -1
  187. package/dist/assets/{particles-BSIwmP84.js → particles-Bcxa0rSB.js} +1 -1
  188. package/dist/assets/{pixi-authoring-adapter-BBRLTeD0.js → pixi-authoring-adapter-DNLOjEpY.js} +1 -1
  189. package/dist/assets/{pixi-live-write-target-C2HcS5j5.js → pixi-live-write-target-BfoISjV8.js} +1 -1
  190. package/dist/assets/{play.command-Cq585oqN.js → play.command-C75rc-GE.js} +2 -2
  191. package/dist/assets/{presentation-CgbanT6d.js → presentation-BJiNf5OD.js} +1 -1
  192. package/dist/assets/{product-YaVJAuWv.js → product-lR88S-ss.js} +1 -1
  193. package/dist/assets/{profiler.action-D4weLnOX.js → profiler.action-Bb0chqRo.js} +1 -1
  194. package/dist/assets/{profiler.menu-DM06JPhJ.js → profiler.menu-BSEfnsIH.js} +1 -1
  195. package/dist/assets/{profiler.utility--d5DAmrx.js → profiler.utility-BHTVOPh5.js} +1 -1
  196. package/dist/assets/{project-authoring-session-r3MZmwZy.js → project-authoring-session-Cmgm10J-.js} +2 -2
  197. package/dist/assets/{properties-bone-constraints.inspector-BbRP_hVC.js → properties-bone-constraints.inspector-DzkkZoCm.js} +1 -1
  198. package/dist/assets/{properties-bone.inspector-0xkD1-Nl.js → properties-bone.inspector-KyF4U4m5.js} +1 -1
  199. package/dist/assets/{properties-collection.inspector-dSsRIihH.js → properties-collection.inspector-PVgsrACR.js} +1 -1
  200. package/dist/assets/{properties-constraints.inspector-Dj24cURl.js → properties-constraints.inspector-CaVHavgQ.js} +1 -1
  201. package/dist/assets/{properties-data.inspector-Chle8El4.js → properties-data.inspector-7KR8NYvm.js} +1 -1
  202. package/dist/assets/{properties-material.inspector-DWHWFt5c.js → properties-material.inspector-Dxzt8Xcs.js} +1 -1
  203. package/dist/assets/{properties-modifiers.inspector-UAW9fDDK.js → properties-modifiers.inspector-esK_INJG.js} +1 -1
  204. package/dist/assets/{properties-object.inspector-DKmvJAUm.js → properties-object.inspector-Twn0WNsN.js} +1 -1
  205. package/dist/assets/{properties-output.inspector-jDgETnN3.js → properties-output.inspector-BpZE-DAu.js} +1 -1
  206. package/dist/assets/{properties-particles.inspector-DAHYKYH4.js → properties-particles.inspector-DFMWK_pm.js} +1 -1
  207. package/dist/assets/{properties-physics.inspector-Dw4dmPBe.js → properties-physics.inspector-ldvafNIb.js} +1 -1
  208. package/dist/assets/{properties-render.inspector-DmcUt39z.js → properties-render.inspector-Bul6aacN.js} +1 -1
  209. package/dist/assets/{properties-scene.inspector-m75tF0Y8.js → properties-scene.inspector-HVMqQVke.js} +1 -1
  210. package/dist/assets/{properties-texture.inspector-il7vLSQC.js → properties-texture.inspector-DVqbNfLB.js} +1 -1
  211. package/dist/assets/{properties-view-layer.inspector-CJLq6Plq.js → properties-view-layer.inspector-CWXcsbp9.js} +1 -1
  212. package/dist/assets/{properties-world.inspector-7Mgl3KCi.js → properties-world.inspector-rIgkn5hU.js} +1 -1
  213. package/dist/assets/{r3f-design-session-g3K8SA7_.js → r3f-design-session-NIeKhBOo.js} +2 -2
  214. package/dist/assets/{r3f-physics-binding-0Z-Q7TAs.js → r3f-physics-binding-Bnz_0MBc.js} +1 -1
  215. package/dist/assets/{r3f-source-authoring-adapter-BUkL26ZV.js → r3f-source-authoring-adapter-CmYnK9fs.js} +1 -1
  216. package/dist/assets/{react-canvas-navigation-Bl-C3u5d.js → react-canvas-navigation-DgfbnHxA.js} +1 -1
  217. package/dist/assets/{react-inspector.service-BNqCWQss.js → react-inspector.service-DIEnbFP5.js} +1 -1
  218. package/dist/assets/{react-story-board-Dfa-xkXN.js → react-story-board-ChhZ3xMR.js} +1 -1
  219. package/dist/assets/{react-three-rapier.esm-CpqSvopE.js → react-three-rapier.esm-CBGmsKYj.js} +1 -1
  220. package/dist/assets/{react-world-authoring-adapter-DI3eOEo4.js → react-world-authoring-adapter-CbLvc5Xf.js} +1 -1
  221. package/dist/assets/{realm-services-tDPiRCPb.js → realm-services-Hkd3KXxA.js} +1 -1
  222. package/dist/assets/{reflection-probe-capture.inspector-C2CVNZrp.js → reflection-probe-capture.inspector-BmLhQ6Rt.js} +1 -1
  223. package/dist/assets/{registry-ySka_qLr.js → registry-f7eUI3vB.js} +1 -1
  224. package/dist/assets/{relative-import-specifier-BRERqZAW.js → relative-import-specifier-N1r5PU5l.js} +1 -1
  225. package/dist/assets/{render-env-D45z89Rv.js → render-env-BmsPMzMD.js} +1 -1
  226. package/dist/assets/{render-features-C7cSRZN3.js → render-features-8WptNlDn.js} +1 -1
  227. package/dist/assets/{render-settings-DR5QBOKs.js → render-settings-k4Hd5jrC.js} +1 -1
  228. package/dist/assets/{resolve-three-C8S71ght.js → resolve-three-B6AVoQHZ.js} +3 -3
  229. package/dist/assets/{root-seam-contract-C9h43-BR.js → root-seam-contract-8hLS1SBd.js} +1 -1
  230. package/dist/assets/{run-selection-CLJcMxnx.js → run-selection-BelqeQ8J.js} +1 -1
  231. package/dist/assets/{scene-capture-C6fhSnrF.js → scene-capture-CNkinvGl.js} +1 -1
  232. package/dist/assets/{scene-document.service-d3mKJ6Jk.js → scene-document.service-BZNMZjtI.js} +2 -2
  233. package/dist/assets/{scene-framing-CBoB2huQ.js → scene-framing-BxR6xAtj.js} +1 -1
  234. package/dist/assets/{seeded-random-L-zxMJEn.js → seeded-random-BTfLEYmi.js} +1 -1
  235. package/dist/assets/{setup-renderer-DdAahdeK.js → setup-renderer-Hy8DUu6u.js} +1 -1
  236. package/dist/assets/{source-object3d-authoring-adapter-TyL6ep4h.js → source-object3d-authoring-adapter-CabVbvF1.js} +1 -1
  237. package/dist/assets/{source-persistence-backend-5r7ZgVcg.js → source-persistence-backend-DfO7BsJw.js} +1 -1
  238. package/dist/assets/{stage-keyboard-DC91cAwr.js → stage-keyboard-Cch0eYUh.js} +1 -1
  239. package/dist/assets/{stage-overlay-set-Cgk76ZzW.js → stage-overlay-set-DFAZ4FXc.js} +1 -1
  240. package/dist/assets/{stage-presence-markers-Dk46moW6.js → stage-presence-markers-CMEeirt8.js} +1 -1
  241. package/dist/assets/{stage-transform-tools-B8Kvrs95.js → stage-transform-tools-Czje_10c.js} +1 -1
  242. package/dist/assets/{standard-viewport-dressing-DOOhsVb3.js → standard-viewport-dressing-DTn1Fpqc.js} +1 -1
  243. package/dist/assets/{state-watch.action-DwFC99SK.js → state-watch.action-DXMjTYPm.js} +1 -1
  244. package/dist/assets/{state-watch.menu-UmYaSwVm.js → state-watch.menu-mvWgMuJs.js} +1 -1
  245. package/dist/assets/{state-watch.utility-USYESLNF.js → state-watch.utility-huAfMHMT.js} +1 -1
  246. package/dist/assets/{story-capture-D1Wz32iJ.js → story-capture-BfudQb8A.js} +1 -1
  247. package/dist/assets/{story-documents-DSeKExWG.js → story-documents-Bb4raAKr.js} +1 -1
  248. package/dist/assets/{story-documents.service-iZz78esz.js → story-documents.service-DhtikHPg.js} +1 -1
  249. package/dist/assets/{story-documents.service-BZCK67uk.js → story-documents.service-DjMSTc_l.js} +1 -1
  250. package/dist/assets/{story-media-presence-DqK7tIb-.js → story-media-presence-Dw2XtQ1w.js} +1 -1
  251. package/dist/assets/{story-pixi-preview-qioYZRuo.js → story-pixi-preview-CNosFkIF.js} +1 -1
  252. package/dist/assets/{story-presentation-BHabgaRo.js → story-presentation-BqyC-AzE.js} +1 -1
  253. package/dist/assets/{story-three-preview-D9C1V1jL.js → story-three-preview-DqncZLn4.js} +2 -2
  254. package/dist/assets/{studio-environment-5zHk3LgJ.js → studio-environment-CR1cIDh0.js} +1 -1
  255. package/dist/assets/{surface-state-UWlyGOeO.js → surface-state-CG7Ou_Jh.js} +1 -1
  256. package/dist/assets/{syntactic-prop-specs-D9Ns_3Sv.js → syntactic-prop-specs-aeB8_VU3.js} +1 -1
  257. package/dist/assets/{team-playtest.service-DIMS_U0z.js → team-playtest.service-pb1LDXeP.js} +1 -1
  258. package/dist/assets/{three-B770IJ5T.js → three-D94Cuk32.js} +1 -1
  259. package/dist/assets/{three-authoring-adapter-DBZVysyV.js → three-authoring-adapter-BUj0tjgD.js} +1 -1
  260. package/dist/assets/three-authoring.service-p9it1aT8.js +2 -0
  261. package/dist/assets/{three-ingest-runtime-BDJKnfM6.js → three-ingest-runtime-DxmN_s10.js} +1 -1
  262. package/dist/assets/{three-integration-v8HFwk_-.js → three-integration-BiI_lkIf.js} +2 -2
  263. package/dist/assets/three-integration.service-D3CYzRfO.js +1 -0
  264. package/dist/assets/{three-projection-core-CL3f2zFU.js → three-projection-core-C7CgCiKg.js} +1 -1
  265. package/dist/assets/{three-state-Cn8djDVD.js → three-state-CXVRdni_.js} +1 -1
  266. package/dist/assets/{three-story-capture.service-BIQEIr7q.js → three-story-capture.service-CsTBiEBK.js} +2 -2
  267. package/dist/assets/{three-story-model-CsjeOqvj.js → three-story-model-AMTDnnn-.js} +1 -1
  268. package/dist/assets/{three-viewport-presentation-DmNPG_uN.js → three-viewport-presentation-DbG0uCGP.js} +1 -1
  269. package/dist/assets/{transform-mode-request-Z6z1PjWr.js → transform-mode-request-LePIz6b6.js} +1 -1
  270. package/dist/assets/{transport-strip-Dc537gpa.js → transport-strip-DnuulxI4.js} +1 -1
  271. package/dist/assets/transport.header-CwcmYZNa.js +1 -0
  272. package/dist/assets/{tuples-ViUF6EQ5.js → tuples-CNWCQlPR.js} +1 -1
  273. package/dist/assets/{ui-board-document-oD7Nd8Sp.js → ui-board-document-BBrzbh95.js} +2 -2
  274. package/dist/assets/{user-data-M952sdEx.js → user-data-Bs7aRC-I.js} +1 -1
  275. package/dist/assets/{utility-view-state-CS4SRaKQ.js → utility-view-state-96_iVt4c.js} +1 -1
  276. package/dist/assets/{viewport-door-WO4YhuvC.js → viewport-door-d0NZ7oI-.js} +1 -1
  277. package/dist/assets/{viewport-root-presentation-rUMkCfQc.js → viewport-root-presentation-Bqr2fF0N.js} +1 -1
  278. package/dist/assets/{viewport-surface-status-ANAus83L.js → viewport-surface-status-Baan57-I.js} +1 -1
  279. package/dist/assets/{webworkerAll-CqA0j4Hi.js → webworkerAll-C5Q6lZd-.js} +1 -1
  280. package/dist/assets/{workspace-arrangement-BbI2Bg0l.js → workspace-arrangement-rUj27SGX.js} +1 -1
  281. package/dist/assets/{world-documents-DM0fZTkd.js → world-documents-D7UiOblt.js} +1 -1
  282. package/dist/assets/{world-root-stage-binding-BN8R3cm2.js → world-root-stage-binding-Bn462UiR.js} +1 -1
  283. package/dist/assets/{xstate-animation-binding-ByxPB4zT.js → xstate-animation-binding-jpldSq-l.js} +1 -1
  284. package/dist/assets/{xstate-animation-meta-DJ4PCMt-.js → xstate-animation-meta-B2NNMu30.js} +1 -1
  285. package/dist-node/cli.js +16 -16
  286. package/package.json +16 -16
  287. package/dist/assets/InspectorObjectPreview-B8LA0-Oq.js +0 -1
  288. package/dist/assets/Object3DDocumentViewport-CORiL1nJ.js +0 -2
  289. package/dist/assets/autoplay.service-DRaQhfiu.js +0 -1
  290. package/dist/assets/blender-runtime.document-BySU9w2T.js +0 -13
  291. package/dist/assets/instances.command-F9j8CuNc.js +0 -1
  292. package/dist/assets/network-observer.service-3W-Q-z6i.js +0 -1
  293. package/dist/assets/three-authoring.service-BySEsRQS.js +0 -2
  294. package/dist/assets/three-integration.service-Cw5JibT0.js +0 -1
  295. package/dist/assets/transport.header-DGUCeqJm.js +0 -1
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RectAreaLightUniformsLib-DpPyArRG.js","assets/three.module-BLhyNg0e.js","assets/three.core-3arARmh6.js"])))=>i.map(i=>d[i]);
2
- import{a as mo,b as _o,L as ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ft,cl as po,fo as b,cm as q,N as un,a$ as Nt,em as be,b4 as Ko,co as Ft,ey as Jo,cp as kn,_ as Tt,ej as Bt,fd as Kt,er as ta,M as ut,cj as wt,dp as Mt,aV as na,cW as go,aE as vo,c7 as bt,j as ea,f6 as oa,fp as Bn,au as Un,dw as Wn,bi as ye,aT as aa,c1 as Jt,dd as ie,eC as se,e7 as Fn,aw as vn,da as Gt,I as ln,as as ra,e8 as ia,b0 as xo,K as sa,B as la,b9 as fa,Y as bo,cw as fn,ed as ca,cA as ua,fx as ma,db as yo,el as da,R as _a,e6 as ha,c0 as wo,bX as pa,aI as le,ao as ga,eG as va,d3 as xa,cs as ba,b5 as qn,bu as Oo,aM as Ao,ex as To,cO as $n,cY as ya,eU as wa,cE as fe,c5 as So,at as Oa,ff as Aa,eW as Ta,f7 as Sa,F as Ma,ev as Pa,et as Ea,dq as Na,fq as Ra,n as Ia,l as za,cf as Fa}from"./three.core-3arARmh6.js";import{u as N,v as L,w as z,c5 as at,c4 as Y,c6 as I,e2 as W,_ as Da,mB as Mo,d_ as Ut,x as X,kE as Ot,e1 as Po,mC as G,dZ as Ca,mD as ka}from"./index-jJyzinl6.js";import{S as Xt}from"./three.module-BLhyNg0e.js";import{t as $a}from"./blender-runtime-host-BWzMRxSe.js";const ce=new Set;function gt(){for(const e of[...ce])e()}function La(e){return ce.add(e),()=>{ce.delete(e)}}function ue(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}const mn=I().finite(),Va=N({name:z(),parent:z().nullable(),connected:at(),hide:at(),length:mn,matrix:L(W([mn,mn,mn,mn])).length(4),select:at(),active:at(),lockedWeight:at()}).strict(),ja=N({object:z(),displayType:Y(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:at(),mode:z(),bones:L(Va)}).strict(),Et={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function Ba(e){return new Tt(e.r*e.r*.1,e.g*e.g*.1,e.b*e.b*.1)}const Hn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],Re=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],Ct=Math.SQRT1_2,Ua=[[Ct,-Ct,0],[0,-Ct,-Ct],[-Ct,-Ct,0],[0,-Ct,Ct],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],Wa=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],qa=.05;function Ie(e){return e.select||e.active?2:1}const Ha=10,Ga=4,Xa=`
2
+ import{a as mo,b as _o,L as ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ft,cl as po,fo as b,cm as q,N as un,a$ as Nt,em as be,b4 as Ko,co as Dt,ey as Jo,cp as kn,_ as Tt,ej as Bt,fd as Kt,er as ta,M as ut,cj as wt,dp as Mt,aV as na,cW as go,aE as vo,c7 as bt,j as ea,f6 as oa,fp as Un,au as Wn,dw as qn,bi as ye,aT as aa,c1 as Jt,dd as se,eC as le,e7 as Dn,aw as vn,da as Gt,I as ln,as as ra,e8 as ia,b0 as xo,K as sa,B as la,b9 as fa,Y as bo,cw as fn,ed as ca,cA as ua,fx as ma,db as yo,el as da,R as _a,e6 as ha,c0 as wo,bX as pa,aI as $n,ao as ga,eG as va,d3 as xa,cs as ba,b5 as Hn,bu as Oo,aM as Ao,ex as To,cO as Ln,cY as ya,eU as wa,cE as fe,c5 as So,at as Oa,ff as Aa,eW as Ta,f7 as Sa,F as Ma,ev as Pa,et as Ea,dq as Na,fq as Ra,n as Ia,l as za,cf as Da}from"./three.core-3arARmh6.js";import{u as N,v as L,w as z,c5 as at,c4 as Y,c6 as I,e2 as W,_ as Fa,mB as Mo,d_ as Ut,x as X,kE as Ot,e1 as Po,mC as G,dZ as Ca,mD as ka}from"./index-CQ2mBTB3.js";import{S as Xt}from"./three.module-BLhyNg0e.js";import{t as $a}from"./blender-runtime-host-CzU1tMpu.js";const ce=new Set;function gt(){for(const e of[...ce])e()}function La(e){return ce.add(e),()=>{ce.delete(e)}}function ue(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}const mn=I().finite(),Va=N({name:z(),parent:z().nullable(),connected:at(),hide:at(),length:mn,matrix:L(W([mn,mn,mn,mn])).length(4),select:at(),active:at(),lockedWeight:at()}).strict(),ja=N({object:z(),displayType:Y(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:at(),mode:z(),bones:L(Va)}).strict(),Et={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function Ba(e){return new Tt(e.r*e.r*.1,e.g*e.g*.1,e.b*e.b*.1)}const Gn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],Re=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],Ct=Math.SQRT1_2,Ua=[[Ct,-Ct,0],[0,-Ct,-Ct],[-Ct,-Ct,0],[0,-Ct,Ct],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],Wa=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],qa=.05;function Ie(e){return e.select||e.active?2:1}const Ha=10,Ga=4,Xa=`
3
3
  attribute vec3 aSolid;
4
4
  attribute vec3 aHint;
5
5
  varying vec3 vColor;
@@ -16,7 +16,7 @@ import{a as mo,b as _o,L as ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ft
16
16
  gl_FragColor = vec4(vColor, 1.0);
17
17
  #include <colorspace_fragment>
18
18
  }
19
- `;function $t(e){return new Tt().setHex(e,Bt)}function ze(e,t){const n=e.mode==="POSE";let o;return n?t.active&&t.select?o=$t(Et.poseActive):t.active?o=$t(Et.poseActiveUnsel):t.select?o=$t(Et.pose):o=$t(Et.wire):o=$t(Et.vertex),n&&t.lockedWeight&&o.lerp($t(Et.lockedWeight),Et.lockedWeightFactor),o}function Fe(e,t){const n=$t(Et.solid);return e.mode==="POSE"&&t.lockedWeight&&n.lerp($t(Et.lockedWeight),Et.lockedWeightFactor),n}const Za=new q,Qa=new b,De=new po;function Ce(e,t){return new q().set(...t.matrix.flat()).premultiply(e).scale(new b().setScalar(t.length))}class Ka{constructor(){this.group=new ft,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const o=[],r=JSON.stringify(t);if(r===this.signature)return o;this.signature=r,this.clear();for(const a of Object.values(t)){const i=n(a.object);if(i===null)continue;a.displayType!=="OCTAHEDRAL"&&a.displayType!=="STICK"&&o.push(`armature ${a.object}: Blender's ${a.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),a.mode==="EDIT"&&o.push(`armature ${a.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const f=a.bones.filter(d=>!d.hide);if(f.length===0)continue;const u=a.displayType==="STICK"?this.buildStick(a,f,i):this.buildOctahedral(a,f,i);a.showInFront&&u.traverse(d=>{const l=d.material;l&&"depthTest"in l&&(l.depthTest=!1),d.renderOrder=10}),this.group.add(u)}return o}buildOctahedral(t,n,o){const r=new ft;r.name=`${t.object}:bones`;const a=[],i=[],f=[],u=[],d=[],l=[],s=[],c=[],m=[],_=[];for(const h of n){const g=Ce(o,h),p=Fe(t,h),v=Ba(p),y=ze(t,h);De.setFromMatrix4(g).invert().transpose();for(let S=0;S<Re.length;S++){const T=Qa.set(...Ua[S]).applyMatrix3(De).normalize().clone();for(const O of Re[S]){const R=new b(...Hn[O]).applyMatrix4(g);a.push(R.x,R.y,R.z),i.push(T.x,T.y,T.z),f.push(p.r,p.g,p.b),u.push(v.r,v.g,v.b)}}const w=Ie(h)===2?s:d,P=Ie(h)===2?c:l;for(const[S,T]of Wa){const O=new b(...Hn[S]).applyMatrix4(g),R=new b(...Hn[T]).applyMatrix4(g);w.push(O.x,O.y,O.z,R.x,R.y,R.z),P.push(y.r,y.g,y.b,y.r,y.g,y.b)}h.parent!==null&&h.connected||(m.push(g.clone()),_.push(p)),m.push(g.clone().multiply(Za.makeTranslation(0,1,0))),_.push(p)}r.add(this.solidMesh(a,i,f,u)),d.length&&r.add(this.lines(d,l,1)),s.length&&r.add(this.lines(s,c,2));for(let h=0;h<m.length;h++)r.add(this.point(m[h],_[h]));return r}buildStick(t,n,o){const r=new ft;r.name=`${t.object}:bones`;const a=[],i=[],f=[],u=[];for(const d of n){const l=Ce(o,d),s=new b().setFromMatrixPosition(l),c=new b(0,1,0).applyMatrix4(l),m=ze(t,d),_=Fe(t,d);a.push(s.x,s.y,s.z,c.x,c.y,c.z),i.push(m.r,m.g,m.b,m.r,m.g,m.b),f.push(s.x,s.y,s.z,c.x,c.y,c.z),u.push(_.r,_.g,_.b,_.r,_.g,_.b)}return r.add(this.lines(a,i,Ha)),r.add(this.lines(f,u,Ga)),r}solidMesh(t,n,o,r){const a=new un;a.setAttribute("position",new Nt(t,3)),a.setAttribute("normal",new Nt(n,3)),a.setAttribute("aSolid",new Nt(o,3)),a.setAttribute("aHint",new Nt(r,3));const i=new be({vertexShader:Xa,fragmentShader:Ya,side:Ko});this.disposables.push(a,i);const f=new Ft(a,i);return f.frustumCulled=!1,f}lines(t,n,o){const r=new mo;r.setPositions(t),r.setColors(n);const a=new _o({linewidth:o,vertexColors:!0});this.disposables.push(r,a);const i=new ho(r,a);return i.frustumCulled=!1,i}point(t,n){const o=new Jo(qa,12,8),r=new kn({color:n});this.disposables.push(o,r);const a=new Ft(o,r);return a.applyMatrix4(t),a.frustumCulled=!1,a}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const ke="RUNTIME_FRAME_UNKNOWN_GEOMETRY",dn="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ja(e){const t=Math.fround,n=t(t(t(e[0]*e[0])+t(e[1]*e[1]))+t(e[2]*e[2]));if(n>1e-35){const o=t(Math.sqrt(n)),r=t(1/o);return{unit:[t(e[0]*r),t(e[1]*r),t(e[2]*r)],length:o}}return{unit:[0,0,0],length:0}}const F=Math.fround,Ln=F(2*Math.PI),Gn=F(1-1e-4),Yt=(e,t)=>F(F(F(e[0]*t[0])+F(e[1]*t[1]))+F(e[2]*t[2])),wn=(e,t,n=1)=>e.map((o,r)=>F(o+F(t[r]*n))),tr=(e,t)=>e.map((n,o)=>F(n-t[o]));function _n(e){const t=F(Math.sqrt(Yt(e,e)));return t>0?e.map(n=>F(n/t)):[0,0,0]}function hn(e){const t=Math.abs(e)<1?F(1-F(1-Math.abs(e))):1;let n=F(F(.077980478)+F(t*F(-.02164095)));n=F(F(-.213300989)+F(t*n)),n=F(F(1.5707963267)+F(t*n));const o=F(F(Math.sqrt(F(1-t)))*n);return e<0?F(F(Math.PI)-o):o}function nr(e){let t=e.at(-1);const n=[0,0,0];for(const o of e){for(let r=0;r<3;r++){const a=(r+1)%3,i=(r+2)%3;n[r]=F(n[r]+F(F(t[a]-o[a])*F(t[i]+o[i])))}t=o}return n}function er(e){const t=[],n=[],o=(_,h)=>_<h?`${_}:${h}`:`${h}:${_}`,r=new Map((e.edge_order??[]).map(([_,h],g)=>[o(_,h),g])),a=new Set((e.sharp??[]).map(([_,h])=>o(_,h))),i=new Map;for(const[_,h]of e.f.entries()){const g=t.length,p=Ja(nr(h.map(v=>e.v[v]))).unit;n.push(p.some(Boolean)?p:[0,0,1]);for(let v=0;v<h.length;v++){const y=o(h[v],h[(v+1)%h.length]);r.has(y)||r.set(y,r.size);const w=e.face_edges?.[_]?.[v]??r.get(y),P=t.length;t.push({vertex:h[v],face:_,edge:w,prev:g+(v+h.length-1)%h.length,next:g+(v+1)%h.length});const S=i.get(w)??[];S.push(P),i.set(w,S)}}const f=new Map,u=new Map;for(const[_,h]of i){if(h.length!==2||e.edge_sharp?.[_])continue;const[g,p]=h,v=t[g],y=t[p];!e.s?.[v.face]||!e.s?.[y.face]||v.vertex!==t[y.next].vertex||y.vertex!==t[v.next].vertex||!e.edge_sharp&&a.has(o(v.vertex,y.vertex))||(u.set(g,y.next),f.set(y.next,g),u.set(p,v.next),f.set(v.next,p))}const d=[],l=[],s=[],c=[],m=(_,h)=>_n(tr(e.v[t[t[_][h]].vertex],e.v[t[_].vertex]));for(let _=0;_<t.length;_++){if(l[_]!==void 0)continue;let h=_;const g=new Set([h]);for(;u.has(h)&&!g.has(u.get(h));)h=u.get(h),g.add(h);u.has(h)&&(h=Math.min(...g));const p=[h];for(;f.has(p.at(-1))&&f.get(p.at(-1))!==h;)p.push(f.get(p.at(-1)));let v=[0,0,0];if(p.length===1)v=n[t[h].face];else{for(const R of p)v=wn(v,n[t[R].face],hn(Yt(m(R,"prev"),m(R,"next"))));v=_n(v)}const y=m(h,"next"),w=p.at(-1),P=m(w,"prev"),S=Yt(y,v),T=Yt(P,v),O={normal:v,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(S)<Gn&&Math.abs(T)<Gn){const R=p.length>1?p.map(et=>m(et,"next")):[];R.length&&t[t[w].prev].edge!==t[h].edge&&R.push(P),O.alpha=R.length?F(R.reduce((et,x)=>F(et+hn(Yt(x,v))),0)/R.length):F(F(hn(S)+hn(T))/2),O.reference=_n(wn(y,v,-S));const $=v,j=O.reference;O.ortho=_n([F(F($[1]*j[2])-F($[2]*j[1])),F(F($[2]*j[0])-F($[0]*j[2])),F(F($[0]*j[1])-F($[1]*j[0]))]);const H=_n(wn(P,v,-T)),tt=Yt(O.reference,H),Z=hn(tt);O.beta=tt<Gn?Yt(O.ortho,H)<0?F(Ln-Z):Z:Ln}O.alpha===0&&(O.normal=[0,0,0]);for(const R of p)l[R]=d.length;d.push(p),s.push(O),c.push(v)}return{corners:t,fans:d,fanOf:l,spaces:s,faceNormals:n,fanNormals:c}}function or(e,t){if(!t[0]||e.alpha===0||e.beta===0)return e.normal;const n=F(t[0]/32767),o=F(t[1]/32767),r=F((n>0?e.alpha:F(Ln-e.alpha))*n),a=F((o>0?e.beta:F(Ln-e.beta))*o);let i=e.normal.map(f=>F(f*F(Math.cos(r))));return i=wn(i,e.reference,F(F(Math.sin(r))*F(Math.cos(a)))),o!==0&&(i=wn(i,e.ortho,F(F(Math.sin(r))*F(Math.sin(a))))),i}function Eo(e,t){if(!t)return null;const{corners:n,fans:o,spaces:r}=er(e);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(n.length);for(const[i,f]of o.entries()){const u=f.reduce((l,s)=>{const c=t.data[s];return[l[0]+c[0],l[1]+c[1]]},[0,0]),d=or(r[i],u.map(l=>Math.trunc(l/f.length)));for(const l of f)a[l]=d}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,i)=>{const f=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:i;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Xn={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},ar=1e-6;function rr(e){const t=new b;for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length];t.x+=(o.y-r.y)*(o.z+r.z),t.y+=(o.z-r.z)*(o.x+r.x),t.z+=(o.x-r.x)*(o.y+r.y)}return t.multiplyScalar(.5)}const ir=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),$e=e=>Array.from({length:e-2},(t,n)=>[0,n+1,n+2]);function sr(e){let t=0;for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return t}function Le(e,t,n){if(e.length!==t.length-2||!(Math.abs(n)>0))return!1;const o=Math.sign(n);let r=0;for(const[a,i,f]of e){const u=ir(t[a],t[i],t[f]);if(u*o<0)return!1;r+=Math.abs(u)}return Math.abs(r-Math.abs(n))<=ar*Math.abs(n)}function lr(e){const t=e.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=rr(e),o=n.length();if(!(o>0)||!Number.isFinite(o))return{triangles:$e(t),sound:!1,method:"fan"};const r=n.clone().divideScalar(o),a=Math.abs(r.x)<.9?new b(1,0,0):new b(0,1,0),i=new b().crossVectors(a,r).normalize(),f=new b().crossVectors(r,i),u=e[0],d=e.map(m=>{const _=m.clone().sub(u);return new Kt(_.dot(i),_.dot(f))}),l=sr(d),s=$e(t);if(Le(s,d,l))return{triangles:s,sound:!0,method:"fan"};let c=[];try{c=ta.triangulateShape(d,[]).map(m=>[m[0],m[1],m[2]])}catch{return{triangles:s,sound:!1,method:"fan"}}return Le(c,d,l)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:s,sound:!1,method:c.length>0?"earcut":"fan"}}const fr=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Yn(e){const t=e/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Zn(e,t,n){switch(e){case"FLOAT":{const o=Number(t[n]);return[o,o,o,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[Yn(Number(t[n*4])),Yn(Number(t[n*4+1])),Yn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function we(e,t){return e.filter(n=>fr.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const o=t(n.data,n.type),r=[0,0,0,0];return{name:n.name,domain:n.domain,read:(a,i,f)=>n.domain==="POINT"?Zn(n.type,o,a):n.domain==="CORNER"?i===void 0?r:Zn(n.type,o,i):f===void 0?r:Zn(n.type,o,f)}})}function No(e){const t=e.vertexCount,n=e.starts.length-1,o=e.starts,r=e.cornerVerts,a=o[n];let i=t;for(let x=0;x<n;x++)i+=(o[x+1]-o[x]-2)*3;const f=new Uint32Array(a),u=new Uint8Array(a),d=new Uint8Array(t),l=new Uint32Array(a);let s=!1;for(let x=0;x<n;x++)if(e.smooth(x)){s=!0;break}const c=(x,E)=>t<94906265?Math.min(x,E)*t+Math.max(x,E):`${Math.min(x,E)}:${Math.max(x,E)}`,m=new Map,_=new Set;for(const[x,E]of e.sharp)_.add(c(x,E));if(e.edges)for(const[x,E]of e.edges){if(x===E)throw new Error("Runtime mesh edge needs distinct vertices");m.set(c(x,E),-1)}const h=x=>{for(;l[x]!==x;)l[x]=l[l[x]],x=l[x];return x},g=(x,E)=>{const A=h(x),U=h(E);l[Math.max(A,U)]=Math.min(A,U)};for(let x=0;x<n;x++){const E=o[x],A=o[x+1]-E,U=e.smooth(x)?1:0;for(let k=0;k<A;k++){const C=E+k;d[r[C]]=1,f[C]=E+(k+1)%A,u[C]=U,l[C]=C}}for(let x=0;x<a;x++){const E=f[x],A=r[x],U=r[E],k=c(A,U),C=m.get(k);if(C!==void 0&&C>=0&&u[x]&&u[C]&&!_.has(k)){const M=f[C];g(x,r[C]===A?C:M),g(E,r[C]===A?M:C)}(C===void 0||C<0||!u[C]&&u[x])&&m.set(k,x)}const p=e.uv,v=new Float32Array(i*3),y=new Float32Array(i*2),w=new Uint32Array(i),P=(e.uvLayers??[]).map(x=>({...x,data:new Float32Array(i*2)})),S=(e.attributeLayers??[]).map(x=>({...x,data:new Float32Array(i*4)})),T=e.orco?new Float32Array(i*3):null,O=new Uint32Array(i),R=new Map,$=[],j=e.normals||e.cornerNormal?new Float32Array(i*3):null;let H=0,tt=0;const Z=(x,E,A,U,k)=>{const C=H++;for(const M of S)M.data.set(M.read(x,U,k),C*4);if(T)for(let M=0;M<3;M++)T[C*3+M]=e.orco[x*3+M]*.5+.5;if(w[C]=x,e.co(x).toArray(v,C*3),E&&y.set(E,C*2),A&&j.set(A,C*3),U!==void 0)for(const M of P)M.data.set(M.read(U),C*2);return C},et=(x,E)=>{const A=p?.(x),U=e.cornerNormal?[e.cornerNormal[x*3],e.cornerNormal[x*3+1],e.cornerNormal[x*3+2]]:e.normals?.[x];if(!s)return Z(r[x],A,U,x,E);const k=`${u[x]?h(x):x}${A?`:${A[0]}:${A[1]}`:""}${U?`:n${U.join(":")}`:""}${P.map(M=>":"+M.read(x).join(":")).join("")}${S.map(M=>M.domain==="POINT"?"":":"+Array.from(M.read(r[x],x,E)).join(":")).join("")}`;let C=R.get(k);return C===void 0&&(C=Z(r[x],A,U,x,E),R.set(k,C)),C};for(let x=0;x<n;x++){const E=tt,A=o[x],U=o[x+1]-A,k=[];for(let B=0;B<U;B++)k.push(e.co(r[A+B]));for(const B of lr(k).triangles)for(const Q of B)O[tt++]=et(A+Q,x);const C=e.material(x),M=$.at(-1);M?.materialIndex===C?M.count+=tt-E:$.push({start:E,count:tt-E,materialIndex:C})}for(let x=0;x<t;x++)d[x]||Z(x);return{positions:v.slice(0,H*3),normals:j?.slice(0,H*3)??null,uv:p?y.slice(0,H*2):null,uvLayers:P.map(x=>({name:x.name,data:x.data.slice(0,H*2)})),attributeLayers:S.map(x=>({name:x.name,data:x.data.slice(0,H*4)})),orco:T?T.slice(0,H*3):null,indices:O.slice(0,tt),sourceVertex:w.slice(0,H),groups:$}}function jt(e){return`blenderA_${Array.from(new TextEncoder().encode(e),t=>t.toString(16).padStart(2,"0")).join("")}`}function Dn(e){const t=new un;t.setAttribute("position",new ut(e.positions,3)),t.setAttribute("uv",new ut(e.uv??new Float32Array(e.positions.length/3*2),2)),t.setIndex(new ut(e.indices,1));const n=Object.create(null);for(const[o,r]of(e.uvLayers??[]).entries()){if(o>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[r.name]=o+1,t.setAttribute(`uv${o+1}`,new ut(r.data,2))}t.userData.blenderUvChannels=n;for(const o of e.attributeLayers??[])t.setAttribute(jt(o.name),new ut(o.data,4));t.userData.blenderAttributes=(e.attributeLayers??[]).map(o=>o.name),e.orco&&(t.setAttribute("blenderOrco",new ut(e.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const o of e.groups)t.addGroup(o.start,o.count,o.materialIndex);return e.normals?t.setAttribute("normal",new ut(e.normals,3)):t.computeVertexNormals(),e.sourceVertex&&t.setAttribute("blenderVertex",new ut(e.sourceVertex,1)),t}function cr(e,t){const n=e.cornerTri,o=e.cornerNormal,r=e.co.length/3,a=e.corner.length,i=e.faceStart.length-1,f=e.attributes.filter(M=>M.type==="FLOAT2"&&M.domain==="CORNER"),u=e.renderUv??e.activeUv??f[0]?.name,d=f.findIndex(M=>M.name===u);if(u&&d<0)throw new Error(`Runtime UV map ${u} is missing`);const l=we(e.attributes,M=>M),s=3+f.length*2+l.length*4,c=new Float32Array(s),m=new Float32Array(s),_=new Uint32Array(c.buffer),h=new Uint32Array(m.buffer),g=new Uint32Array(a),p=new Uint32Array(a),v=new Uint32Array(a),y=new Uint32Array(a),w=new Uint8Array(r);let P=1;for(;P<Math.max(1,a*2);)P*=2;const S=new Uint32Array(P),T=(M,B,Q,ot)=>{let ct=0;for(let nt=0;nt<3;nt++)ot[ct++]=o[M*3+nt];for(const nt of f)for(let rt=0;rt<2;rt++)ot[ct++]=Number(nt.data[M*2+rt]);for(const nt of l){const rt=nt.read(Q,M,B);for(let K=0;K<4;K++)ot[ct++]=Number(rt[K])}};let O=0;for(let M=0;M<i;M++)for(let B=e.faceStart[M];B<e.faceStart[M+1];B++){const Q=e.corner[B];if(Q>=r)throw new Error("Native mesh corner references a missing vertex");g[B]=M,w[Q]=1,T(B,M,Q,c);let ot=Math.imul(Q^2166136261,16777619);for(const rt of _)ot=Math.imul(ot^rt,16777619);const ct=ot>>>0&P-1;let nt=-1;for(let rt=S[ct];rt;rt=y[rt-1]){const K=rt-1,mt=v[K];if(e.corner[mt]!==Q)continue;T(mt,g[mt],Q,m);let St=!0;for(let Wt=0;Wt<s;Wt++)if(_[Wt]!==h[Wt]){St=!1;break}if(St){nt=K;break}}nt<0&&(nt=O++,v[nt]=B,y[nt]=S[ct],S[ct]=nt+1),p[B]=nt}let R=0;for(const M of w)M||R++;const $=O+R,j=new Float32Array($*3),H=new Float32Array($*3),tt=new Uint32Array($),Z=f.map(M=>({name:M.name,data:new Float32Array($*2)})),et=l.map(M=>({name:M.name,data:new Float32Array($*4)})),x=e.orco?new Float32Array($*3):null,E=(M,B)=>{tt[M]=B;for(let Q=0;Q<3;Q++)j[M*3+Q]=e.co[B*3+Q],x&&(x[M*3+Q]=e.orco[B*3+Q]*.5+.5)};for(let M=0;M<O;M++){const B=v[M],Q=e.corner[B];E(M,Q),T(B,g[B],Q,c),H.set(c.subarray(0,3),M*3);let ot=3;for(const ct of Z)ct.data.set(c.subarray(ot,ot+2),M*2),ot+=2;for(const ct of et)ct.data.set(c.subarray(ot,ot+4),M*4),ot+=4}let A=O;for(let M=0;M<r;M++)if(!w[M]){E(A,M);for(let B=0;B<l.length;B++)et[B].data.set(l[B].read(M,void 0,void 0),A*4);A++}const U=new Uint32Array(n.length),k=[];let C=0;for(let M=0;M<i;M++){const B=e.faceStart[M],Q=e.faceStart[M+1],ot=Math.max(0,Q-B-2)*3;if(C+ot>n.length)throw new Error("Native mesh triangulation is incomplete");for(let rt=0;rt<ot;rt++){const K=n[C+rt];if(K<B||K>=Q)throw new Error("Native triangle references a different face");U[C+rt]=p[K]}const ct=e.material[M],nt=k.at(-1);nt?.materialIndex===ct?nt.count+=ot:k.push({start:C,count:ot,materialIndex:ct}),C+=ot}if(C!==n.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:j,normals:H,sourceVertex:tt,uv:d<0?null:Z[d].data,uvLayers:Z,attributeLayers:et,orco:x,indices:U,groups:k,hash:t}}function Ve(e,t){if(e.cornerTri&&e.cornerNormal)return cr(e,t);const n=e.co.length/3,o=e.attributes.filter(h=>h.type==="FLOAT2"&&h.domain==="CORNER"),r=e.renderUv??e.activeUv??o[0]?.name,a=o.find(h=>h.name===r);if(r&&!a)throw new Error(`Runtime UV map ${r} is missing`);const i=a?a.data:null,f=e.edge.length/2,u=new Array(f);for(let h=0;h<f;h++)u[h]=[e.edge[h*2],e.edge[h*2+1]];const d=[];for(let h=0;h<f;h++)e.edgeSharp[h]===1&&d.push(u[h]);const l=e.cornerNormal?void 0:e.attributes.find(h=>h.name==="custom_normal"),s=l?{v:Array.from({length:n},(h,g)=>[e.co[g*3],e.co[g*3+1],e.co[g*3+2]]),f:Array.from({length:e.faceStart.length-1},(h,g)=>Array.from(e.corner.subarray(e.faceStart[g],e.faceStart[g+1]))),s:Array.from(e.smooth,Boolean),edge_order:u,sharp:d,face_edges:Array.from({length:e.faceStart.length-1},(h,g)=>Array.from(e.cornerEdge.subarray(e.faceStart[g],e.faceStart[g+1]))),edge_sharp:Array.from(e.edgeSharp,Boolean)}:null,c=l?{type:l.type,domain:l.domain,data:Array.from({length:l.data.length/Xn[l.type].size},(h,g)=>Array.from({length:Xn[l.type].size},(p,v)=>Number(l.data[g*Xn[l.type].size+v])))}:void 0,m=new b,_={vertexCount:n,normals:s?Eo(s,c):null,cornerNormal:e.cornerNormal,orco:e.orco,co:h=>m.set(e.co[h*3],e.co[h*3+1],e.co[h*3+2]).clone(),starts:e.faceStart,cornerVerts:e.corner,smooth:h=>e.smooth[h]===1,material:h=>e.material[h],edges:u,sharp:d,uv:i?h=>[i[h*2],i[h*2+1]]:null,uvLayers:o.map(h=>({name:h.name,read:g=>[Number(h.data[g*2]),Number(h.data[g*2+1])]})),attributeLayers:we(e.attributes,h=>h)};return{...No(_),hash:t}}function ur(e){const t=e.v.map(s=>new b(...s)),n=s=>{const c=t[s];if(!c)throw new Error(`Runtime mesh vertex ${s} is missing`);return c},o=new Uint32Array(e.f.length+1);e.f.forEach((s,c)=>{if(s.length<3||new Set(s).size!==s.length)throw new Error("Runtime mesh face needs at least three distinct vertices");o[c+1]=o[c]+s.length});const r=new Uint32Array(o[e.f.length]);e.f.forEach((s,c)=>s.forEach((m,_)=>{n(m),r[o[c]+_]=m}));for(const[s,c]of e.edge_order??e.e??[])n(s),n(c);const a={POINT:t.length,EDGE:(e.edge_order??e.e??[]).length,FACE:e.f.length,CORNER:r.length};for(const s of e.attributes??[])if(s.domain!=="EDGE"&&s.data.length!==a[s.domain])throw new Error(`Runtime attribute ${s.name} has ${s.data.length} values for ${a[s.domain]} ${s.domain} elements`);const i=(e.attributes??[]).filter(s=>s.type==="FLOAT2"&&s.domain==="CORNER"),f=e.render_uv??e.active_uv??i[0]?.name,u=i.find(s=>s.name===f);if(f&&!u)throw new Error(`Runtime UV map ${f} is missing`);const d=u?.data,l={vertexCount:t.length,normals:Eo(e,e.attributes?.find(s=>s.name==="custom_normal")),co:n,starts:o,cornerVerts:r,smooth:s=>!!e.s?.[s],material:s=>e.m?.[s]??0,edges:e.edge_order??e.e??null,sharp:e.sharp??[],uv:d?s=>d[s]:null,uvLayers:i.map(s=>({name:s.name,read:c=>s.data[c]})),attributeLayers:we(e.attributes??[],s=>Array.from(s).flat())};return Dn(No(l))}const On=1.5707963267948966,Zt=6.283185307179586,Ro=.3183098861837067,Io=.0795774715459476,mr=.3,dr=Io,_r=3/16*Ro,me=.8,je=me*me,Qt=6371,zo=100,de=Qt+zo,Be=64,Ue=64,dt=256,qt=64,hr=[1.679,1.828,1.986,1.307],pr=[.006605,.01067,.01842,.03156],gr=[3472e-28,3914e-28,1349e-28,1103e-29],vr=334.5,xr=[28722e-28,46168e-28,79706e-28,13578e-27],br=[15908e-26,17711e-26,20942e-26,24033e-26],We=13681e16,yr=2e6,wr=.73,Qn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],Rt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],Vn=e=>e*e,xn=e=>e<0?0:e>1?1:e,zt=(e,t,n)=>e+n*(t-e),Or=e=>Math.sqrt(Math.max(e,0)),Fo=e=>[-Math.sqrt(1-e*e),0,e];function _e(e,t,n,o,r,a,i){const f=e*o+t*r+n*a,u=e*e+t*t+n*n-i*i;if(u>0&&f>0)return-1;const d=f*f-u;return d<0?-1:d>=f*f?-f+Math.sqrt(d):-f-Math.sqrt(d)}const Ar=e=>_r*(1+Vn(e));function Tr(e){const t=1+je+2*me*e;return Io*(1-je)/(t*Math.sqrt(t))}const Sr=e=>We*(Math.exp(-e/wr)+yr/We);function Oe(e,t){let n=e%Zt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let o=t;return(n>=On||n<=-On)&&(n=Math.sign(n)*Math.PI-n,o+=Math.PI),o=o%Zt,o<0&&(o+=Zt),o=Zt-o,[n,o]}class Mr{constructor(t,n,o){this.air=t,this.aerosol=n,this.ozone=o,this.lut=new Float32Array(qt*dt*4)}coefficients(t,n){const o=Sr(t)*this.aerosol,r=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-Vn(r-3.22261)*5.55555555-r),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=xr[f]*o,n[4+f]=br[f]*o,n[8+f]=gr[f]*vr*a*this.ozone,n[12+f]=pr[f]*i*this.air}transmittance(t,n,o){const[r,a,i]=Fo(t),f=zt(Qt,de,n),d=_e(0,0,f,r,a,i,de)/Be,l=[0,0,0,0],s=new Float64Array(16);for(let c=0;c<Be;c++){const m=(c+.5)*d,_=r*m,h=a*m,g=f+i*m,p=Math.max(Math.hypot(_,h,g)-Qt,0);this.coefficients(p,s);for(let v=0;v<4;v++)l[v]+=(s[v]+s[4+v]+s[8+v]+s[12+v])*d}for(let c=0;c<4;c++)o[c]=Math.exp(-l[c])}precompute(){const t=new Float64Array(4);for(let n=0;n<qt;n++)for(let o=0;o<dt;o++){const r=o/(dt-1),a=n/(qt-1);this.transmittance(r*2-1,a,t);const i=(n*dt+o)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,n,o){const r=(dt-1)*xn(t*.5+.5),a=(qt-1)*xn(n),i=Math.trunc(r),f=Math.trunc(a),u=Math.min(i+1,dt-1),d=Math.min(f+1,qt-1),l=r-i,s=a-f,c=(f*dt+i)*4,m=(f*dt+u)*4,_=(d*dt+i)*4,h=(d*dt+u)*4;for(let g=0;g<4;g++)o[g]=zt(zt(this.lut[c+g],this.lut[m+g],l),zt(this.lut[_+g],this.lut[h+g],l),s)}lookupAtGround(t,n){const o=(dt-1)*xn(t*.5+.5),r=Math.trunc(o),a=Math.min(r+1,dt-1),i=o-r;for(let f=0;f<4;f++)n[f]=zt(this.lut[r*4+f],this.lut[a*4+f],i)}lookupToSun(t,n){const o=(qt-1)*xn(t),r=Math.trunc(o),a=Math.min(r+1,qt-1),i=o-r,f=dt-1;for(let u=0;u<4;u++)n[u]=zt(this.lut[(r*dt+f)*4+u],this.lut[(a*dt+f)*4+u],i)}inscattering(t,n,o,r,a,i,f,u,d){const l=-(a*t[0]+i*t[1]+f*t[2]),s=Ar(l),c=Tr(l),m=u/Ue,_=new Float64Array(16),h=new Float64Array(4),g=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),y=new Float64Array(4),w=[0,0,0,0],P=[1,1,1,1];for(let S=0;S<Ue;S++){const T=(S+.5)*m,O=n+a*T,R=o+i*T,$=r+f*T,j=Math.hypot(O,R,$),H=Math.max(j-Qt,0),tt=H/zo,Z=(O*t[0]+R*t[1]+$*t[2])/j;this.coefficients(H,_),this.lookup(Z,tt,h);const et=Zt*(1-Or(1-Vn(Qt/j)));this.lookupAtGround(Z,p),this.lookupToSun(0,v),this.lookupToSun(tt,y);const x=1/(1+5*Math.exp(-17.92*Z)),E=[.217,.347,.594,1];for(let A=0;A<4;A++){const U=v[A]/y[A],k=dr*et*(mr*Ro)*p[A]*U*Z;g[A]=.02*E[A]*x+k}for(let A=0;A<4;A++){const U=_[A]+_[4+A]+_[8+A]+_[12+A],k=hr[A]*(_[12+A]*(s*h[A]+g[A])+_[4+A]*(c*h[A]+g[A])),C=Math.exp(-m*U),M=Math.max(U,1e-7);w[A]+=P[A]*((k-k*C)/M),P[A]*=C}}for(let S=0;S<4;S++)d[S]=w[S]}}const vt=512,an=256;function Do(e,t){const n=new Mr(e.airDensity,e.aerosolDensity,e.ozoneDensity);n.precompute();const o=Math.min(Math.max(e.altitude,1),99999)/1e3,r=Fo(Math.cos(On-t)),a=new Float32Array(vt*an*3),i=vt/2,f=new Float64Array(4);for(let u=0;u<an;u++)for(let d=0;d<i;d++){const l=(d+.5)/vt,s=(u+.5)/an,c=Zt*l,m=s*2-1,_=Math.sign(m)*Vn(m)*On,h=Math.cos(_)*Math.cos(c),g=Math.cos(_)*Math.sin(c),p=Math.sin(_),v=Qt+o,y=_e(0,0,v,h,g,p,de),w=_e(0,0,v,h,g,p,Qt),P=w<0?y:w;n.inscattering(r,0,0,v,h,g,p,P,f);let S=0,T=0,O=0;for(let j=0;j<4;j++)S+=Qn[j][0]*f[j],T+=Qn[j][1]*f[j],O+=Qn[j][2]*f[j];const R=(u*vt+d)*3;a[R]=S,a[R+1]=T,a[R+2]=O;const $=(u*vt+(vt-d-1))*3;a[$]=S,a[$+1]=T,a[$+2]=O}return a}function Pr(e){const[t]=Oe(e.sunElevation,e.sunRotation);return Do(e,t)}function Ae(e){const[t]=Oe(e.sunElevation,e.sunRotation);return JSON.stringify([t,e.altitude,e.airDensity,e.aerosolDensity,e.ozoneDensity])}const Er=6,en=new Map;function Nr(e){return en.has(Ae(e))}function Co(e,t){en.set(Ae(e),t),en.size>Er&&en.delete(en.keys().next().value)}function Rr(e){const[t,n]=Oe(e.sunElevation,e.sunRotation),o=Ae(e);let r=en.get(o);r===void 0&&(r=Do(e,t),Co(e,r));const a=new b;return i=>{const f=Math.hypot(i.x,i.y),u=Math.atan2(i.z,f);let l=(Math.atan2(i.x,i.y)+Math.PI+n)/Zt;l-=Math.floor(l);const s=Math.abs(u),c=xn(Math.sqrt(s/On)*Math.sign(u)*.5+.5),m=l*vt-.5,_=c*an-.5,h=Math.floor(m),g=Math.floor(_),p=m-h,v=_-g,y=$=>($%vt+vt)%vt,w=$=>$<0?0:$>an-1?an-1:$,P=y(h),S=y(h+1),T=w(g),O=w(g+1),R=[0,0,0];for(let $=0;$<3;$++){const j=zt(r[(T*vt+P)*3+$],r[(T*vt+S)*3+$],p),H=zt(r[(O*vt+P)*3+$],r[(O*vt+S)*3+$],p);R[$]=zt(j,H,v)}return a.set(Rt[0][0]*R[0]+Rt[0][1]*R[1]+Rt[0][2]*R[2],Rt[1][0]*R[0]+Rt[1][1]*R[1]+Rt[1][2]*R[2],Rt[2][0]*R[0]+Rt[2][1]*R[1]+Rt[2][2]*R[2])}}let kt=null,Tn=!1,Ir=0;const bn=new Map;function zr(){if(kt||Tn)return kt;if(typeof Worker>"u")return Tn=!0,null;try{kt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return Tn=!0,null}return kt.onmessage=e=>{const{id:t,pixels:n,error:o}=e.data,r=bn.get(t);r&&(bn.delete(t),n?r.resolve(n):r.reject(new Error(o??"sky worker returned nothing")))},kt.onerror=e=>{const t=new Error(`sky worker failed: ${e.message||"unknown error"}`);for(const n of bn.values())n.reject(t);bn.clear(),kt?.terminate(),kt=null,Tn=!0},kt}function Fr(e){const t=zr();if(!t)return Promise.resolve(Pr(e));const n=Ir++,o={id:n,parameters:e};return new Promise((r,a)=>{bn.set(n,{resolve:r,reject:a}),t.postMessage(o)})}function Dr(e,t,n,o={}){switch(o.type??"LINEAR"){case"QUADRATIC":{const r=Math.max(e,0);return r*r}case"EASING":{const r=Math.min(1,Math.max(0,e));return r*r*(3-2*r)}case"DIAGONAL":return(e+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(e,t,n),0);case"QUADRATIC_SPHERE":{const r=Math.max(.999999-Math.hypot(e,t,n),0);return r*r}case"RADIAL":return Math.atan2(t,e)/(2*Math.PI)+.5;default:return e}}const Kn=(e,t)=>t!==0?e/t:0,qe=e=>Math.min(1,Math.max(-1,e)),He=(e,t,n)=>{const o=n!==0?Math.max(n-Math.abs(e-t),0)/n:0;return Math.min(e,t)-o*o*o*n/6},ko={ADD:(e,t)=>e+t,SUBTRACT:(e,t)=>e-t,MULTIPLY:(e,t)=>e*t,DIVIDE:Kn,POWER:(e,t)=>t===0?1:e===0||e<0&&!Number.isInteger(t)?0:e**t,LOGARITHM:(e,t)=>e<=0||t<=0?0:Kn(Math.log(e),Math.log(t)),SQRT:e=>Math.sqrt(Math.max(e,0)),INVERSE_SQRT:e=>e>0?1/Math.sqrt(e):0,ABSOLUTE:Math.abs,RADIANS:e=>e*Math.PI/180,DEGREES:e=>e*180/Math.PI,MINIMUM:(e,t)=>Math.min(e,t),MAXIMUM:(e,t)=>Math.max(e,t),LESS_THAN:(e,t)=>+(e<t),GREATER_THAN:(e,t)=>+(e>t),ROUND:e=>Math.floor(e+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:e=>e-Math.floor(e),MODULO:(e,t)=>t!==0?e%t:0,FLOORED_MODULO:(e,t)=>t!==0?e-Math.floor(e/t)*t:0,TRUNC:Math.trunc,SNAP:(e,t)=>Math.floor(Kn(e,t))*t,WRAP:(e,t,n)=>t!==n?e-(t-n)*Math.floor((e-n)/(t-n)):n,PINGPONG:(e,t)=>{if(t===0)return 0;const n=(e-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:e=>Math.asin(qe(e)),ARCCOSINE:e=>Math.acos(qe(e)),ARCTANGENT:Math.atan,ARCTAN2:(e,t)=>e===0&&t===0?0:Math.atan2(e,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(e,t,n)=>+(e===t||Math.abs(e-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(e,t,n)=>e*t+n,SMOOTH_MIN:He,SMOOTH_MAX:(e,t,n)=>-He(-e,-t,n)};function lt(e,t){if(typeof e=="number")return()=>e;if(Array.isArray(e)){const r=new b(...e);return()=>r}if(e.kind==="direction")return r=>r;if(e.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(e.kind==="gradient"){const r=lt(e.vector,t),a={type:e.gradient_type},i=new b;return f=>{const u=r(f),d=typeof u=="number"?u:u.x,l=typeof u=="number"?u:u.y,s=typeof u=="number"?u:u.z,c=wt.clamp(Dr(d,l,s,a),0,1);return e.output==="Fac"?c:i.setScalar(c)}}if(e.kind==="to_float"){const r=lt(e.value,t);return a=>{const i=r(a);return typeof i=="number"?i:Math.fround(e.source_type==="RGBA"?i.x*.212639+i.y*.7151687+i.z*.0721923:(i.x+i.y+i.z)/3)}}if(e.kind==="math"){const r=e.inputs.map(f=>lt(f,t)),a=ko[e.operation],i=(f,u)=>{const d=r[f]?.(u)??0;if(typeof d!="number")throw new Error("World Math needs scalar inputs");return Math.fround(d)};return f=>{const u=Math.fround(a(i(0,f),i(1,f),i(2,f)));return e.clamp?wt.clamp(u,0,1):u}}if(e.kind==="mix_color"){const r=lt(e.factor,t),a=lt(e.a,t),i=lt(e.b,t),f=new b,u=new b;return d=>{const l=r(d);if(typeof l!="number")throw new Error("World color Mix needs a scalar factor");const s=a(d);typeof s=="number"?f.setScalar(s):f.copy(s);const c=i(d);return typeof c=="number"?u.setScalar(c):u.copy(c),f.lerp(u,e.clamp_factor?wt.clamp(l,0,1):l),e.clamp_result&&f.clampScalar(0,1),f}}if(e.kind==="sky"){const r=Rr({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return a=>r(a)}if(e.kind==="mapping"){const r=lt(e.vector,t),a=new b(...e.location),i=new b(...e.scale),f=new Mt().setFromEuler(new na(e.rotation[0],e.rotation[1],e.rotation[2],"ZYX")),u=f.clone().invert(),d=new b(...e.scale.map(s=>s===0?0:1/s)),l=new b;return s=>{const c=r(s);switch(typeof c=="number"?l.setScalar(c):l.copy(c),e.vector_type??"POINT"){case"TEXTURE":return l.sub(a).applyQuaternion(u).multiply(d);case"VECTOR":return l.multiply(i).applyQuaternion(f);case"NORMAL":return l.multiply(d).applyQuaternion(f).normalize();case"POINT":return l.multiply(i).applyQuaternion(f).add(a)}}}if(e.kind==="map_range"){const r=lt(e.value,t),a=lt(e.from_min,t),i=lt(e.from_max,t),f=lt(e.to_min,t),u=lt(e.to_max,t),d=lt(e.steps,t),l=(m,_)=>{const h=m(_);if(typeof h!="number")throw new Error("World Map Range needs scalar inputs");return h},s=e.interpolation,c=e.clamp;return m=>{const _=l(r,m),h=l(a,m),g=l(i,m),p=l(f,m),v=l(u,m);if(h===g)return 0;let y;if(s==="STEPPED"){const P=l(d,m),S=(_-h)/(g-h);y=P>0?Math.floor(S*(P+1))/P:0}else if(s==="SMOOTHSTEP"||s==="SMOOTHERSTEP"){const P=wt.clamp((_-Math.min(h,g))/(Math.max(h,g)-Math.min(h,g)),0,1),S=s==="SMOOTHSTEP"?P*P*(3-2*P):P*P*P*(P*(P*6-15)+10);y=h>g?1-S:S}else y=(_-h)/(g-h);const w=p+y*(v-p);return c?p>v?wt.clamp(w,v,p):wt.clamp(w,p,v):w}}if(e.kind==="separate"){const r=lt(e.vector,t);return a=>{const i=r(a);return typeof i=="number"?i:i.getComponent(e.axis)}}const n=lt(e.factor,t),o=new b;return r=>{const a=n(r);if(typeof a!="number")throw new Error("World ColorRamp needs a scalar factor");const i=wt.clamp(a,0,1)*256,f=Math.floor(i),u=e.colors[f],d=e.colors[Math.min(f+1,256)],l=e.interpolate?i-f:0;return o.set(wt.lerp(u[0],d[0],l),wt.lerp(u[1],d[1],l),wt.lerp(u[2],d[2],l))}}function Cr(e,t,n,o){const r=new Float32Array(t*n*3),a=lt(e,o),i=new b;for(let f=0;f<n;f++){const u=((f+.5)/n-.5)*Math.PI;for(let d=0;d<t;d++){const l=((d+.5)/t-.5)*2*Math.PI;i.set(Math.cos(u)*Math.cos(l),-Math.cos(u)*Math.sin(l),Math.sin(u));const s=a(i),c=(f*t+d)*3;r[c]=typeof s=="number"?s:s.x,r[c+1]=typeof s=="number"?s:s.y,r[c+2]=typeof s=="number"?s:s.z}}return r}function Ge(e){const t=[],n=o=>{if(!(typeof o=="number"||Array.isArray(o)))switch(o.kind){case"sky":t.push({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return;case"mapping":case"gradient":case"separate":n(o.vector);return;case"ramp":n(o.factor);return;case"mix_color":n(o.factor),n(o.a),n(o.b);return;case"math":o.inputs.forEach(n);return;case"to_float":n(o.value);return;case"map_range":n(o.value),n(o.from_min),n(o.from_max),n(o.to_min),n(o.to_max),n(o.steps);return;default:return}};return n(e),t}function Lt(e){if(typeof e=="number"||Array.isArray(e))return!1;switch(e.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Lt(e.vector);case"ramp":return Lt(e.factor);case"mix_color":return[e.factor,e.a,e.b].some(Lt);case"math":return e.inputs.some(Lt);case"to_float":return Lt(e.value);case"map_range":return[e.value,e.from_min,e.from_max,e.to_min,e.to_max,e.steps].some(Lt);default:return!1}}function kr(e,t,n,o){o.updateMatrixWorld();const r=new Float32Array(t*n*3),a=new b,i=lt(e,()=>a),f=new b,u=o.getWorldPosition(new b),d=o.getWorldDirection(new b);for(let l=0;l<n;l++)for(let s=0;s<t;s++){const c=(s+.5)/t,m=(l+.5)/n;a.set(c,m,0),o.isOrthographicCamera?f.copy(d):f.set(c*2-1,m*2-1,.5).unproject(o).sub(u).normalize(),f.set(f.x,-f.z,f.y);const _=i(f),h=(l*t+s)*3;r[h]=typeof _=="number"?_:_.x,r[h+1]=typeof _=="number"?_:_.y,r[h+2]=typeof _=="number"?_:_.z}return r}const st=I().finite(),$r=N({type:Y(["POINT","SUN","SPOT","AREA"]),color:W([st,st,st]),energy:st,use_shadow:at().default(!0),radius:st.optional(),spot_size:st.optional(),spot_blend:st.optional(),shape:Y(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:st.optional(),size_y:st.optional()}).strict();let he;function Lr(){return he??=Da(async()=>{const{RectAreaLightUniformsLib:e}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:e}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:e})=>{e.init(),gt()}),he}function Vr(){return he??Promise.resolve()}const jr=e=>{const t=e.size??0,n=e.size_y??t;if(e.shape==="RECTANGLE")return[t,n];if(e.shape==="DISK"){const o=Math.sqrt(Math.PI*t*t/4);return[o,o]}if(e.shape==="ELLIPSE"){const o=Math.sqrt(Math.PI/4);return[t*o,n*o]}return[t,t]};function Br(e,t){const n=(i,f)=>t&&f(t)?t:new i;if(e.type==="SUN"){const i=n(vo,f=>f.isDirectionalLight);return i.intensity=e.energy,i.color.setRGB(e.color[0],e.color[1],e.color[2],bt),i.castShadow=e.use_shadow,i}if(e.type==="POINT"){const i=n(ie,f=>f.isPointLight);return i.intensity=e.energy/(4*Math.PI),i.distance=0,i.decay=2,i.color.setRGB(e.color[0],e.color[1],e.color[2],bt),i.castShadow=e.use_shadow,i}if(e.type==="SPOT"){const i=n(se,f=>f.isSpotLight);return i.intensity=e.energy/(4*Math.PI),i.distance=0,i.decay=2,i.angle=(e.spot_size??0)/2,i.penumbra=e.spot_blend??0,i.color.setRGB(e.color[0],e.color[1],e.color[2],bt),i.castShadow=e.use_shadow,i}Lr();const o=n(Fn,i=>i.isRectAreaLight),[r,a]=jr(e);return o.width=r,o.height=a,o.intensity=e.energy/(Math.max(r*a,Number.MIN_VALUE)*Math.PI),o.color.setRGB(e.color[0],e.color[1],e.color[2],bt),o}function Ur(e,t,n){if(!e.castShadow||n<=0)return;const r=e.getWorldPosition(new b).distanceTo(t),a=e.shadow;if(!a)return;const i=a.camera;i.near=Math.max(n*.001,r-n),i.far=r+n,e.isDirectionalLight&&(i.left=-n,i.right=n,i.top=n,i.bottom=-n),i.updateProjectionMatrix()}function Wr(e,t){e.position.set(0,0,0);const n=e;e.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const Te=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],Xe=.69;class qr{constructor(){this.group=new ft,this.lights=[],this.group.name="BlenderSolidStudio";const t=new go;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new Tt(0,0,0);for(const[r,a]of Te.entries()){const i=(1+a.smooth)**2,f=new vo(16777215,Math.PI*Xe/i);f.name=`BlenderSolidLight${r}`,f.color.setRGB(a.diffuse[0],a.diffuse[1],a.diffuse[2],bt),f.position.set(a.direction[0],a.direction[1],a.direction[2]),f.target=t,this.group.add(f),this.lights.push(f),n.r+=a.diffuse[0]*a.smooth/i,n.g+=a.diffuse[1]*a.smooth/i,n.b+=a.diffuse[2]*a.smooth/i}const o=new ea(16777215,Math.PI*Xe);o.name="BlenderSolidWrapFill",o.color.copy(n),this.group.add(o),this.lights.push(o)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const nn=W([st,st,st]),J=Mo(()=>Ut([st,nn,N({kind:X("direction")}).strict(),N({kind:X("window")}).strict(),N({kind:X("gradient"),gradient_type:Y(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:Y(["Fac","Color"]),vector:J}).strict(),N({kind:X("to_float"),source_type:Y(["RGBA","VECTOR"]),value:J}).strict(),N({kind:X("math"),operation:Y(Object.keys(ko)),clamp:at(),inputs:L(J).min(1).max(3)}).strict(),N({kind:X("mix_color"),factor:J,a:J,b:J,clamp_factor:at(),clamp_result:at()}).strict(),N({kind:X("mapping"),vector_type:Y(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:J,location:nn,rotation:nn,scale:nn}).strict(),N({kind:X("separate"),vector:J,axis:I().int().min(0).max(2)}).strict(),N({kind:X("ramp"),factor:J,colors:L(nn).length(257),interpolate:at()}).strict(),N({kind:X("map_range"),interpolation:Y(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:at(),value:J,from_min:J,from_max:J,to_min:J,to_max:J,steps:J}).strict(),N({kind:X("sky"),sun_elevation:st,sun_rotation:st,altitude:st,air_density:st,aerosol_density:st,ozone_density:st}).strict()])),Ye=N({color:nn,strength:st,shader:J.optional()}),Hr=Ye.extend({volume:L(N({kind:Y(["absorption","scatter","principled","emission"]),phase:z(),alpha:J,weight:J,color:J,density:J,anisotropy:J,absorption_color:J,emission_color:J,emission_strength:J,blackbody_intensity:J,temperature:J,blackbody_tint:J}).strict()).optional(),lighting:Ye.strict().optional()}).strict(),Gr=4,pn=new Map,Jn=new Set;function Ze(e,t,n){const a=Lt(e);if(a&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const i=JSON.stringify([e,a?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),f=pn.get(i);if(f!==void 0)return pe(f,t,256,128);const u=new b,d=new Bn,l=n?new q().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,s=n?.getWorldPosition(new b),m=Cr(e,256,128,a?_=>(u.set(_.x,_.z,-_.y),n.isPerspectiveCamera&&u.add(s),d.set(u.x,u.y,u.z,1).applyMatrix4(l),d.w===0?u.set(0,0,0):u.set(d.x/d.w*.5+.5,d.y/d.w*.5+.5,0)):void 0);return pn.set(i,m),pn.size>Gr&&pn.delete(pn.keys().next().value),pe(m,t,256,128)}function Xr(e,t,n,o){const r=vn.toHalfFloat(1);for(let a=0;a<o;a++)e[a*4]=vn.toHalfFloat(t[a*3]*n),e[a*4+1]=vn.toHalfFloat(t[a*3+1]*n),e[a*4+2]=vn.toHalfFloat(t[a*3+2]*n),e[a*4+3]=r}function pe(e,t,n,o){const r=new Uint16Array(n*o*4);Xr(r,e,t,n*o);const a=new Un(r,n,o,Wn,ye);return a.mapping=aa,a.colorSpace=bt,a.minFilter=Jt,a.magFilter=Jt,a.needsUpdate=!0,a}class Se{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,o){if(this.clear(),this.pending=null,!n)return;const r=Se.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=n.shader??n.color,i=this.generation,u=[...Ge(a),...n.lighting?Ge(n.lighting.shader??n.lighting.color):[]].filter(l=>!Nr(l));if(u.length===0){this.compose(r,n,a,o);return}const d=(async()=>{const l=await Promise.all(u.map(Fr));u.forEach((s,c)=>{Co(s,l[c])}),!(this.generation!==i||this.applied?.scene!==r)&&(this.compose(r,n,a,o),gt())})();this.pending=d,Jn.add(d),d.then(()=>Jn.delete(d),()=>Jn.delete(d))}compose(t,n,o,r){if(this.texture=Ze(o,n.strength,r),Lt(o)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=pe(kr(o,512,512,r),n.strength,512,512),this.screenTexture.mapping=oa,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const i=r.getWorldDirection(new b);i.set(i.x,-i.z,i.y);const f=lt(n.shader??n.color)(i);t.background=typeof f=="number"?new Tt().setRGB(f,f,f).multiplyScalar(n.strength):new Tt().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:a}=n;this.environmentTexture=a?Ze(a.shader??a.color,a.strength,r):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function $o(e){return[e.min.x,e.max.x].flatMap(t=>[e.min.y,e.max.y].flatMap(n=>[e.min.z,e.max.z].map(o=>new b(t,n,o))))}function Yr(e,t){if(e.isEmpty()||!t.intersectsBox(e))return[];const n=$o(e);if(n.every(l=>t.containsPoint(l)))return n;const o=[...t.planes,new Gt(new b(1,0,0),-e.min.x),new Gt(new b(-1,0,0),e.max.x),new Gt(new b(0,1,0),-e.min.y),new Gt(new b(0,-1,0),e.max.y),new Gt(new b(0,0,1),-e.min.z),new Gt(new b(0,0,-1),e.max.z)],r=[],a=new b,i=new b,f=new b,u=new b,d=Math.max(1,e.min.length(),e.max.length())*1e-8;for(let l=0;l<o.length;l++)for(let s=l+1;s<o.length;s++)for(let c=s+1;c<o.length;c++){const m=o[l],_=o[s],h=o[c];a.crossVectors(_.normal,h.normal);const g=m.normal.dot(a);Math.abs(g)<1e-12||(i.crossVectors(h.normal,m.normal),f.crossVectors(m.normal,_.normal),u.copy(a).multiplyScalar(-m.constant).addScaledVector(i,-_.constant).addScaledVector(f,-h.constant).divideScalar(g),o.every(p=>p.distanceToPoint(u)>=-d)&&r.push(u.clone()))}return r}function Zr(e,t,n){if(!e.castShadow||!t.length)return;e.shadow.updateMatrices(e);const o=e.shadow.camera,r=o.matrixWorldInverse,a=new ln().setFromPoints(t.map(c=>c.clone().applyMatrix4(r))),i=a.getSize(new b),f=Math.max(i.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,d=Math.max(i.x,i.y,f)/Math.max(1,Math.min(e.shadow.mapSize.x,e.shadow.mapSize.y)-2*u),l=2*Math.SQRT2*d,s=u*d;a.min.x-=s,a.min.y-=s,a.max.x+=s,a.max.y+=s;for(const c of n){if(c.isEmpty())continue;const m=new ln().setFromPoints($o(c).map(_=>_.applyMatrix4(r)));m.max.x<a.min.x||m.min.x>a.max.x||m.max.y<a.min.y||m.min.y>a.max.y||(a.min.z=Math.min(a.min.z,m.min.z),a.max.z=Math.max(a.max.z,m.max.z))}o.left=a.min.x,o.right=a.max.x,o.bottom=a.min.y,o.top=a.max.y,o.near=-a.max.z-l-f,o.far=-a.min.z+l+f,o.updateProjectionMatrix(),e.shadow.normalBias=l}const rn=I().finite(),Qe=W([rn,rn,rn]),Lo=N({min:W([I().int(),I().int(),I().int()]),max:W([I().int(),I().int(),I().int()]),density:L(rn),voxelSize:rn.positive(),color:Qe,emission:Qe,densityScale:rn.nonnegative()}).strict();function Qr(e){const t=e.max.map((l,s)=>l-e.min[s]+1);if(t.some(l=>l<=0)||t.reduce((l,s)=>l*s,1)!==e.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new ra(new Float32Array(e.density),t[0],t[1],t[2]);n.format=ia,n.type=xo,n.minFilter=n.magFilter=Jt,n.unpackAlignment=1,n.needsUpdate=!0;const o=new b(...e.min).addScalar(-.5).multiplyScalar(e.voxelSize),r=new b(t[0],t[1],t[2]).multiplyScalar(e.voxelSize),a=new sa(r.x,r.y,r.z),i=a.getAttribute("position");for(let l=0;l<i.count;l++)i.setXYZ(l,o.x+(i.getX(l)>0?r.x:0),o.y+(i.getY(l)>0?r.y:0),o.z+(i.getZ(l)>0?r.z:0));i.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const f=new be({glslVersion:fa,side:la,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:o},extent:{value:r},voxelSize:{value:e.voxelSize},densityScale:{value:e.densityScale},volumeColor:{value:new b(...e.color)},emission:{value:new b(...e.emission)},cameraLocal:{value:new b},rayLocal:{value:new b},orthographic:{value:!1},worldScale:{value:new po}},vertexShader:`
19
+ `;function $t(e){return new Tt().setHex(e,Bt)}function ze(e,t){const n=e.mode==="POSE";let o;return n?t.active&&t.select?o=$t(Et.poseActive):t.active?o=$t(Et.poseActiveUnsel):t.select?o=$t(Et.pose):o=$t(Et.wire):o=$t(Et.vertex),n&&t.lockedWeight&&o.lerp($t(Et.lockedWeight),Et.lockedWeightFactor),o}function De(e,t){const n=$t(Et.solid);return e.mode==="POSE"&&t.lockedWeight&&n.lerp($t(Et.lockedWeight),Et.lockedWeightFactor),n}const Za=new q,Qa=new b,Fe=new po;function Ce(e,t){return new q().set(...t.matrix.flat()).premultiply(e).scale(new b().setScalar(t.length))}class Ka{constructor(){this.group=new ft,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const o=[],r=JSON.stringify(t);if(r===this.signature)return o;this.signature=r,this.clear();for(const a of Object.values(t)){const i=n(a.object);if(i===null)continue;a.displayType!=="OCTAHEDRAL"&&a.displayType!=="STICK"&&o.push(`armature ${a.object}: Blender's ${a.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),a.mode==="EDIT"&&o.push(`armature ${a.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const f=a.bones.filter(d=>!d.hide);if(f.length===0)continue;const u=a.displayType==="STICK"?this.buildStick(a,f,i):this.buildOctahedral(a,f,i);a.showInFront&&u.traverse(d=>{const l=d.material;l&&"depthTest"in l&&(l.depthTest=!1),d.renderOrder=10}),this.group.add(u)}return o}buildOctahedral(t,n,o){const r=new ft;r.name=`${t.object}:bones`;const a=[],i=[],f=[],u=[],d=[],l=[],s=[],c=[],m=[],_=[];for(const h of n){const g=Ce(o,h),p=De(t,h),v=Ba(p),y=ze(t,h);Fe.setFromMatrix4(g).invert().transpose();for(let S=0;S<Re.length;S++){const T=Qa.set(...Ua[S]).applyMatrix3(Fe).normalize().clone();for(const O of Re[S]){const R=new b(...Gn[O]).applyMatrix4(g);a.push(R.x,R.y,R.z),i.push(T.x,T.y,T.z),f.push(p.r,p.g,p.b),u.push(v.r,v.g,v.b)}}const w=Ie(h)===2?s:d,P=Ie(h)===2?c:l;for(const[S,T]of Wa){const O=new b(...Gn[S]).applyMatrix4(g),R=new b(...Gn[T]).applyMatrix4(g);w.push(O.x,O.y,O.z,R.x,R.y,R.z),P.push(y.r,y.g,y.b,y.r,y.g,y.b)}h.parent!==null&&h.connected||(m.push(g.clone()),_.push(p)),m.push(g.clone().multiply(Za.makeTranslation(0,1,0))),_.push(p)}r.add(this.solidMesh(a,i,f,u)),d.length&&r.add(this.lines(d,l,1)),s.length&&r.add(this.lines(s,c,2));for(let h=0;h<m.length;h++)r.add(this.point(m[h],_[h]));return r}buildStick(t,n,o){const r=new ft;r.name=`${t.object}:bones`;const a=[],i=[],f=[],u=[];for(const d of n){const l=Ce(o,d),s=new b().setFromMatrixPosition(l),c=new b(0,1,0).applyMatrix4(l),m=ze(t,d),_=De(t,d);a.push(s.x,s.y,s.z,c.x,c.y,c.z),i.push(m.r,m.g,m.b,m.r,m.g,m.b),f.push(s.x,s.y,s.z,c.x,c.y,c.z),u.push(_.r,_.g,_.b,_.r,_.g,_.b)}return r.add(this.lines(a,i,Ha)),r.add(this.lines(f,u,Ga)),r}solidMesh(t,n,o,r){const a=new un;a.setAttribute("position",new Nt(t,3)),a.setAttribute("normal",new Nt(n,3)),a.setAttribute("aSolid",new Nt(o,3)),a.setAttribute("aHint",new Nt(r,3));const i=new be({vertexShader:Xa,fragmentShader:Ya,side:Ko});this.disposables.push(a,i);const f=new Dt(a,i);return f.frustumCulled=!1,f}lines(t,n,o){const r=new mo;r.setPositions(t),r.setColors(n);const a=new _o({linewidth:o,vertexColors:!0});this.disposables.push(r,a);const i=new ho(r,a);return i.frustumCulled=!1,i}point(t,n){const o=new Jo(qa,12,8),r=new kn({color:n});this.disposables.push(o,r);const a=new Dt(o,r);return a.applyMatrix4(t),a.frustumCulled=!1,a}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const ke="RUNTIME_FRAME_UNKNOWN_GEOMETRY",dn="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ja(e){const t=Math.fround,n=t(t(t(e[0]*e[0])+t(e[1]*e[1]))+t(e[2]*e[2]));if(n>1e-35){const o=t(Math.sqrt(n)),r=t(1/o);return{unit:[t(e[0]*r),t(e[1]*r),t(e[2]*r)],length:o}}return{unit:[0,0,0],length:0}}const D=Math.fround,Vn=D(2*Math.PI),Xn=D(1-1e-4),Yt=(e,t)=>D(D(D(e[0]*t[0])+D(e[1]*t[1]))+D(e[2]*t[2])),wn=(e,t,n=1)=>e.map((o,r)=>D(o+D(t[r]*n))),tr=(e,t)=>e.map((n,o)=>D(n-t[o]));function _n(e){const t=D(Math.sqrt(Yt(e,e)));return t>0?e.map(n=>D(n/t)):[0,0,0]}function hn(e){const t=Math.abs(e)<1?D(1-D(1-Math.abs(e))):1;let n=D(D(.077980478)+D(t*D(-.02164095)));n=D(D(-.213300989)+D(t*n)),n=D(D(1.5707963267)+D(t*n));const o=D(D(Math.sqrt(D(1-t)))*n);return e<0?D(D(Math.PI)-o):o}function nr(e){let t=e.at(-1);const n=[0,0,0];for(const o of e){for(let r=0;r<3;r++){const a=(r+1)%3,i=(r+2)%3;n[r]=D(n[r]+D(D(t[a]-o[a])*D(t[i]+o[i])))}t=o}return n}function er(e){const t=[],n=[],o=(_,h)=>_<h?`${_}:${h}`:`${h}:${_}`,r=new Map((e.edge_order??[]).map(([_,h],g)=>[o(_,h),g])),a=new Set((e.sharp??[]).map(([_,h])=>o(_,h))),i=new Map;for(const[_,h]of e.f.entries()){const g=t.length,p=Ja(nr(h.map(v=>e.v[v]))).unit;n.push(p.some(Boolean)?p:[0,0,1]);for(let v=0;v<h.length;v++){const y=o(h[v],h[(v+1)%h.length]);r.has(y)||r.set(y,r.size);const w=e.face_edges?.[_]?.[v]??r.get(y),P=t.length;t.push({vertex:h[v],face:_,edge:w,prev:g+(v+h.length-1)%h.length,next:g+(v+1)%h.length});const S=i.get(w)??[];S.push(P),i.set(w,S)}}const f=new Map,u=new Map;for(const[_,h]of i){if(h.length!==2||e.edge_sharp?.[_])continue;const[g,p]=h,v=t[g],y=t[p];!e.s?.[v.face]||!e.s?.[y.face]||v.vertex!==t[y.next].vertex||y.vertex!==t[v.next].vertex||!e.edge_sharp&&a.has(o(v.vertex,y.vertex))||(u.set(g,y.next),f.set(y.next,g),u.set(p,v.next),f.set(v.next,p))}const d=[],l=[],s=[],c=[],m=(_,h)=>_n(tr(e.v[t[t[_][h]].vertex],e.v[t[_].vertex]));for(let _=0;_<t.length;_++){if(l[_]!==void 0)continue;let h=_;const g=new Set([h]);for(;u.has(h)&&!g.has(u.get(h));)h=u.get(h),g.add(h);u.has(h)&&(h=Math.min(...g));const p=[h];for(;f.has(p.at(-1))&&f.get(p.at(-1))!==h;)p.push(f.get(p.at(-1)));let v=[0,0,0];if(p.length===1)v=n[t[h].face];else{for(const R of p)v=wn(v,n[t[R].face],hn(Yt(m(R,"prev"),m(R,"next"))));v=_n(v)}const y=m(h,"next"),w=p.at(-1),P=m(w,"prev"),S=Yt(y,v),T=Yt(P,v),O={normal:v,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(S)<Xn&&Math.abs(T)<Xn){const R=p.length>1?p.map(et=>m(et,"next")):[];R.length&&t[t[w].prev].edge!==t[h].edge&&R.push(P),O.alpha=R.length?D(R.reduce((et,x)=>D(et+hn(Yt(x,v))),0)/R.length):D(D(hn(S)+hn(T))/2),O.reference=_n(wn(y,v,-S));const $=v,j=O.reference;O.ortho=_n([D(D($[1]*j[2])-D($[2]*j[1])),D(D($[2]*j[0])-D($[0]*j[2])),D(D($[0]*j[1])-D($[1]*j[0]))]);const H=_n(wn(P,v,-T)),tt=Yt(O.reference,H),Z=hn(tt);O.beta=tt<Xn?Yt(O.ortho,H)<0?D(Vn-Z):Z:Vn}O.alpha===0&&(O.normal=[0,0,0]);for(const R of p)l[R]=d.length;d.push(p),s.push(O),c.push(v)}return{corners:t,fans:d,fanOf:l,spaces:s,faceNormals:n,fanNormals:c}}function or(e,t){if(!t[0]||e.alpha===0||e.beta===0)return e.normal;const n=D(t[0]/32767),o=D(t[1]/32767),r=D((n>0?e.alpha:D(Vn-e.alpha))*n),a=D((o>0?e.beta:D(Vn-e.beta))*o);let i=e.normal.map(f=>D(f*D(Math.cos(r))));return i=wn(i,e.reference,D(D(Math.sin(r))*D(Math.cos(a)))),o!==0&&(i=wn(i,e.ortho,D(D(Math.sin(r))*D(Math.sin(a))))),i}function Eo(e,t){if(!t)return null;const{corners:n,fans:o,spaces:r}=er(e);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(n.length);for(const[i,f]of o.entries()){const u=f.reduce((l,s)=>{const c=t.data[s];return[l[0]+c[0],l[1]+c[1]]},[0,0]),d=or(r[i],u.map(l=>Math.trunc(l/f.length)));for(const l of f)a[l]=d}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,i)=>{const f=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:i;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Yn={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},ar=1e-6;function rr(e){const t=new b;for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length];t.x+=(o.y-r.y)*(o.z+r.z),t.y+=(o.z-r.z)*(o.x+r.x),t.z+=(o.x-r.x)*(o.y+r.y)}return t.multiplyScalar(.5)}const ir=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),$e=e=>Array.from({length:e-2},(t,n)=>[0,n+1,n+2]);function sr(e){let t=0;for(let n=0;n<e.length;n++){const o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return t}function Le(e,t,n){if(e.length!==t.length-2||!(Math.abs(n)>0))return!1;const o=Math.sign(n);let r=0;for(const[a,i,f]of e){const u=ir(t[a],t[i],t[f]);if(u*o<0)return!1;r+=Math.abs(u)}return Math.abs(r-Math.abs(n))<=ar*Math.abs(n)}function lr(e){const t=e.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=rr(e),o=n.length();if(!(o>0)||!Number.isFinite(o))return{triangles:$e(t),sound:!1,method:"fan"};const r=n.clone().divideScalar(o),a=Math.abs(r.x)<.9?new b(1,0,0):new b(0,1,0),i=new b().crossVectors(a,r).normalize(),f=new b().crossVectors(r,i),u=e[0],d=e.map(m=>{const _=m.clone().sub(u);return new Kt(_.dot(i),_.dot(f))}),l=sr(d),s=$e(t);if(Le(s,d,l))return{triangles:s,sound:!0,method:"fan"};let c=[];try{c=ta.triangulateShape(d,[]).map(m=>[m[0],m[1],m[2]])}catch{return{triangles:s,sound:!1,method:"fan"}}return Le(c,d,l)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:s,sound:!1,method:c.length>0?"earcut":"fan"}}const fr=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Zn(e){const t=e/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Qn(e,t,n){switch(e){case"FLOAT":{const o=Number(t[n]);return[o,o,o,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[Zn(Number(t[n*4])),Zn(Number(t[n*4+1])),Zn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function we(e,t){return e.filter(n=>fr.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const o=t(n.data,n.type),r=[0,0,0,0];return{name:n.name,domain:n.domain,read:(a,i,f)=>n.domain==="POINT"?Qn(n.type,o,a):n.domain==="CORNER"?i===void 0?r:Qn(n.type,o,i):f===void 0?r:Qn(n.type,o,f)}})}function No(e){const t=e.vertexCount,n=e.starts.length-1,o=e.starts,r=e.cornerVerts,a=o[n];let i=t;for(let x=0;x<n;x++)i+=(o[x+1]-o[x]-2)*3;const f=new Uint32Array(a),u=new Uint8Array(a),d=new Uint8Array(t),l=new Uint32Array(a);let s=!1;for(let x=0;x<n;x++)if(e.smooth(x)){s=!0;break}const c=(x,E)=>t<94906265?Math.min(x,E)*t+Math.max(x,E):`${Math.min(x,E)}:${Math.max(x,E)}`,m=new Map,_=new Set;for(const[x,E]of e.sharp)_.add(c(x,E));if(e.edges)for(const[x,E]of e.edges){if(x===E)throw new Error("Runtime mesh edge needs distinct vertices");m.set(c(x,E),-1)}const h=x=>{for(;l[x]!==x;)l[x]=l[l[x]],x=l[x];return x},g=(x,E)=>{const A=h(x),U=h(E);l[Math.max(A,U)]=Math.min(A,U)};for(let x=0;x<n;x++){const E=o[x],A=o[x+1]-E,U=e.smooth(x)?1:0;for(let k=0;k<A;k++){const C=E+k;d[r[C]]=1,f[C]=E+(k+1)%A,u[C]=U,l[C]=C}}for(let x=0;x<a;x++){const E=f[x],A=r[x],U=r[E],k=c(A,U),C=m.get(k);if(C!==void 0&&C>=0&&u[x]&&u[C]&&!_.has(k)){const M=f[C];g(x,r[C]===A?C:M),g(E,r[C]===A?M:C)}(C===void 0||C<0||!u[C]&&u[x])&&m.set(k,x)}const p=e.uv,v=new Float32Array(i*3),y=new Float32Array(i*2),w=new Uint32Array(i),P=(e.uvLayers??[]).map(x=>({...x,data:new Float32Array(i*2)})),S=(e.attributeLayers??[]).map(x=>({...x,data:new Float32Array(i*4)})),T=e.orco?new Float32Array(i*3):null,O=new Uint32Array(i),R=new Map,$=[],j=e.normals||e.cornerNormal?new Float32Array(i*3):null;let H=0,tt=0;const Z=(x,E,A,U,k)=>{const C=H++;for(const M of S)M.data.set(M.read(x,U,k),C*4);if(T)for(let M=0;M<3;M++)T[C*3+M]=e.orco[x*3+M]*.5+.5;if(w[C]=x,e.co(x).toArray(v,C*3),E&&y.set(E,C*2),A&&j.set(A,C*3),U!==void 0)for(const M of P)M.data.set(M.read(U),C*2);return C},et=(x,E)=>{const A=p?.(x),U=e.cornerNormal?[e.cornerNormal[x*3],e.cornerNormal[x*3+1],e.cornerNormal[x*3+2]]:e.normals?.[x];if(!s)return Z(r[x],A,U,x,E);const k=`${u[x]?h(x):x}${A?`:${A[0]}:${A[1]}`:""}${U?`:n${U.join(":")}`:""}${P.map(M=>":"+M.read(x).join(":")).join("")}${S.map(M=>M.domain==="POINT"?"":":"+Array.from(M.read(r[x],x,E)).join(":")).join("")}`;let C=R.get(k);return C===void 0&&(C=Z(r[x],A,U,x,E),R.set(k,C)),C};for(let x=0;x<n;x++){const E=tt,A=o[x],U=o[x+1]-A,k=[];for(let B=0;B<U;B++)k.push(e.co(r[A+B]));for(const B of lr(k).triangles)for(const Q of B)O[tt++]=et(A+Q,x);const C=e.material(x),M=$.at(-1);M?.materialIndex===C?M.count+=tt-E:$.push({start:E,count:tt-E,materialIndex:C})}for(let x=0;x<t;x++)d[x]||Z(x);return{positions:v.slice(0,H*3),normals:j?.slice(0,H*3)??null,uv:p?y.slice(0,H*2):null,uvLayers:P.map(x=>({name:x.name,data:x.data.slice(0,H*2)})),attributeLayers:S.map(x=>({name:x.name,data:x.data.slice(0,H*4)})),orco:T?T.slice(0,H*3):null,indices:O.slice(0,tt),sourceVertex:w.slice(0,H),groups:$}}function jt(e){return`blenderA_${Array.from(new TextEncoder().encode(e),t=>t.toString(16).padStart(2,"0")).join("")}`}function Fn(e){const t=new un;t.setAttribute("position",new ut(e.positions,3)),t.setAttribute("uv",new ut(e.uv??new Float32Array(e.positions.length/3*2),2)),t.setIndex(new ut(e.indices,1));const n=Object.create(null);for(const[o,r]of(e.uvLayers??[]).entries()){if(o>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[r.name]=o+1,t.setAttribute(`uv${o+1}`,new ut(r.data,2))}t.userData.blenderUvChannels=n;for(const o of e.attributeLayers??[])t.setAttribute(jt(o.name),new ut(o.data,4));t.userData.blenderAttributes=(e.attributeLayers??[]).map(o=>o.name),e.orco&&(t.setAttribute("blenderOrco",new ut(e.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const o of e.groups)t.addGroup(o.start,o.count,o.materialIndex);return e.normals?t.setAttribute("normal",new ut(e.normals,3)):t.computeVertexNormals(),e.sourceVertex&&t.setAttribute("blenderVertex",new ut(e.sourceVertex,1)),t}function cr(e,t){const n=e.cornerTri,o=e.cornerNormal,r=e.co.length/3,a=e.corner.length,i=e.faceStart.length-1,f=e.attributes.filter(M=>M.type==="FLOAT2"&&M.domain==="CORNER"),u=e.renderUv??e.activeUv??f[0]?.name,d=f.findIndex(M=>M.name===u);if(u&&d<0)throw new Error(`Runtime UV map ${u} is missing`);const l=we(e.attributes,M=>M),s=3+f.length*2+l.length*4,c=new Float32Array(s),m=new Float32Array(s),_=new Uint32Array(c.buffer),h=new Uint32Array(m.buffer),g=new Uint32Array(a),p=new Uint32Array(a),v=new Uint32Array(a),y=new Uint32Array(a),w=new Uint8Array(r);let P=1;for(;P<Math.max(1,a*2);)P*=2;const S=new Uint32Array(P),T=(M,B,Q,ot)=>{let ct=0;for(let nt=0;nt<3;nt++)ot[ct++]=o[M*3+nt];for(const nt of f)for(let rt=0;rt<2;rt++)ot[ct++]=Number(nt.data[M*2+rt]);for(const nt of l){const rt=nt.read(Q,M,B);for(let K=0;K<4;K++)ot[ct++]=Number(rt[K])}};let O=0;for(let M=0;M<i;M++)for(let B=e.faceStart[M];B<e.faceStart[M+1];B++){const Q=e.corner[B];if(Q>=r)throw new Error("Native mesh corner references a missing vertex");g[B]=M,w[Q]=1,T(B,M,Q,c);let ot=Math.imul(Q^2166136261,16777619);for(const rt of _)ot=Math.imul(ot^rt,16777619);const ct=ot>>>0&P-1;let nt=-1;for(let rt=S[ct];rt;rt=y[rt-1]){const K=rt-1,mt=v[K];if(e.corner[mt]!==Q)continue;T(mt,g[mt],Q,m);let St=!0;for(let Wt=0;Wt<s;Wt++)if(_[Wt]!==h[Wt]){St=!1;break}if(St){nt=K;break}}nt<0&&(nt=O++,v[nt]=B,y[nt]=S[ct],S[ct]=nt+1),p[B]=nt}let R=0;for(const M of w)M||R++;const $=O+R,j=new Float32Array($*3),H=new Float32Array($*3),tt=new Uint32Array($),Z=f.map(M=>({name:M.name,data:new Float32Array($*2)})),et=l.map(M=>({name:M.name,data:new Float32Array($*4)})),x=e.orco?new Float32Array($*3):null,E=(M,B)=>{tt[M]=B;for(let Q=0;Q<3;Q++)j[M*3+Q]=e.co[B*3+Q],x&&(x[M*3+Q]=e.orco[B*3+Q]*.5+.5)};for(let M=0;M<O;M++){const B=v[M],Q=e.corner[B];E(M,Q),T(B,g[B],Q,c),H.set(c.subarray(0,3),M*3);let ot=3;for(const ct of Z)ct.data.set(c.subarray(ot,ot+2),M*2),ot+=2;for(const ct of et)ct.data.set(c.subarray(ot,ot+4),M*4),ot+=4}let A=O;for(let M=0;M<r;M++)if(!w[M]){E(A,M);for(let B=0;B<l.length;B++)et[B].data.set(l[B].read(M,void 0,void 0),A*4);A++}const U=new Uint32Array(n.length),k=[];let C=0;for(let M=0;M<i;M++){const B=e.faceStart[M],Q=e.faceStart[M+1],ot=Math.max(0,Q-B-2)*3;if(C+ot>n.length)throw new Error("Native mesh triangulation is incomplete");for(let rt=0;rt<ot;rt++){const K=n[C+rt];if(K<B||K>=Q)throw new Error("Native triangle references a different face");U[C+rt]=p[K]}const ct=e.material[M],nt=k.at(-1);nt?.materialIndex===ct?nt.count+=ot:k.push({start:C,count:ot,materialIndex:ct}),C+=ot}if(C!==n.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:j,normals:H,sourceVertex:tt,uv:d<0?null:Z[d].data,uvLayers:Z,attributeLayers:et,orco:x,indices:U,groups:k,hash:t}}function Ve(e,t){if(e.cornerTri&&e.cornerNormal)return cr(e,t);const n=e.co.length/3,o=e.attributes.filter(h=>h.type==="FLOAT2"&&h.domain==="CORNER"),r=e.renderUv??e.activeUv??o[0]?.name,a=o.find(h=>h.name===r);if(r&&!a)throw new Error(`Runtime UV map ${r} is missing`);const i=a?a.data:null,f=e.edge.length/2,u=new Array(f);for(let h=0;h<f;h++)u[h]=[e.edge[h*2],e.edge[h*2+1]];const d=[];for(let h=0;h<f;h++)e.edgeSharp[h]===1&&d.push(u[h]);const l=e.cornerNormal?void 0:e.attributes.find(h=>h.name==="custom_normal"),s=l?{v:Array.from({length:n},(h,g)=>[e.co[g*3],e.co[g*3+1],e.co[g*3+2]]),f:Array.from({length:e.faceStart.length-1},(h,g)=>Array.from(e.corner.subarray(e.faceStart[g],e.faceStart[g+1]))),s:Array.from(e.smooth,Boolean),edge_order:u,sharp:d,face_edges:Array.from({length:e.faceStart.length-1},(h,g)=>Array.from(e.cornerEdge.subarray(e.faceStart[g],e.faceStart[g+1]))),edge_sharp:Array.from(e.edgeSharp,Boolean)}:null,c=l?{type:l.type,domain:l.domain,data:Array.from({length:l.data.length/Yn[l.type].size},(h,g)=>Array.from({length:Yn[l.type].size},(p,v)=>Number(l.data[g*Yn[l.type].size+v])))}:void 0,m=new b,_={vertexCount:n,normals:s?Eo(s,c):null,cornerNormal:e.cornerNormal,orco:e.orco,co:h=>m.set(e.co[h*3],e.co[h*3+1],e.co[h*3+2]).clone(),starts:e.faceStart,cornerVerts:e.corner,smooth:h=>e.smooth[h]===1,material:h=>e.material[h],edges:u,sharp:d,uv:i?h=>[i[h*2],i[h*2+1]]:null,uvLayers:o.map(h=>({name:h.name,read:g=>[Number(h.data[g*2]),Number(h.data[g*2+1])]})),attributeLayers:we(e.attributes,h=>h)};return{...No(_),hash:t}}function ur(e){const t=e.v.map(s=>new b(...s)),n=s=>{const c=t[s];if(!c)throw new Error(`Runtime mesh vertex ${s} is missing`);return c},o=new Uint32Array(e.f.length+1);e.f.forEach((s,c)=>{if(s.length<3||new Set(s).size!==s.length)throw new Error("Runtime mesh face needs at least three distinct vertices");o[c+1]=o[c]+s.length});const r=new Uint32Array(o[e.f.length]);e.f.forEach((s,c)=>s.forEach((m,_)=>{n(m),r[o[c]+_]=m}));for(const[s,c]of e.edge_order??e.e??[])n(s),n(c);const a={POINT:t.length,EDGE:(e.edge_order??e.e??[]).length,FACE:e.f.length,CORNER:r.length};for(const s of e.attributes??[])if(s.domain!=="EDGE"&&s.data.length!==a[s.domain])throw new Error(`Runtime attribute ${s.name} has ${s.data.length} values for ${a[s.domain]} ${s.domain} elements`);const i=(e.attributes??[]).filter(s=>s.type==="FLOAT2"&&s.domain==="CORNER"),f=e.render_uv??e.active_uv??i[0]?.name,u=i.find(s=>s.name===f);if(f&&!u)throw new Error(`Runtime UV map ${f} is missing`);const d=u?.data,l={vertexCount:t.length,normals:Eo(e,e.attributes?.find(s=>s.name==="custom_normal")),co:n,starts:o,cornerVerts:r,smooth:s=>!!e.s?.[s],material:s=>e.m?.[s]??0,edges:e.edge_order??e.e??null,sharp:e.sharp??[],uv:d?s=>d[s]:null,uvLayers:i.map(s=>({name:s.name,read:c=>s.data[c]})),attributeLayers:we(e.attributes??[],s=>Array.from(s).flat())};return Fn(No(l))}const On=1.5707963267948966,Zt=6.283185307179586,Ro=.3183098861837067,Io=.0795774715459476,mr=.3,dr=Io,_r=3/16*Ro,me=.8,je=me*me,Qt=6371,zo=100,de=Qt+zo,Be=64,Ue=64,dt=256,qt=64,hr=[1.679,1.828,1.986,1.307],pr=[.006605,.01067,.01842,.03156],gr=[3472e-28,3914e-28,1349e-28,1103e-29],vr=334.5,xr=[28722e-28,46168e-28,79706e-28,13578e-27],br=[15908e-26,17711e-26,20942e-26,24033e-26],We=13681e16,yr=2e6,wr=.73,Kn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],Rt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],jn=e=>e*e,xn=e=>e<0?0:e>1?1:e,zt=(e,t,n)=>e+n*(t-e),Or=e=>Math.sqrt(Math.max(e,0)),Do=e=>[-Math.sqrt(1-e*e),0,e];function _e(e,t,n,o,r,a,i){const f=e*o+t*r+n*a,u=e*e+t*t+n*n-i*i;if(u>0&&f>0)return-1;const d=f*f-u;return d<0?-1:d>=f*f?-f+Math.sqrt(d):-f-Math.sqrt(d)}const Ar=e=>_r*(1+jn(e));function Tr(e){const t=1+je+2*me*e;return Io*(1-je)/(t*Math.sqrt(t))}const Sr=e=>We*(Math.exp(-e/wr)+yr/We);function Oe(e,t){let n=e%Zt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let o=t;return(n>=On||n<=-On)&&(n=Math.sign(n)*Math.PI-n,o+=Math.PI),o=o%Zt,o<0&&(o+=Zt),o=Zt-o,[n,o]}class Mr{constructor(t,n,o){this.air=t,this.aerosol=n,this.ozone=o,this.lut=new Float32Array(qt*dt*4)}coefficients(t,n){const o=Sr(t)*this.aerosol,r=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-jn(r-3.22261)*5.55555555-r),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=xr[f]*o,n[4+f]=br[f]*o,n[8+f]=gr[f]*vr*a*this.ozone,n[12+f]=pr[f]*i*this.air}transmittance(t,n,o){const[r,a,i]=Do(t),f=zt(Qt,de,n),d=_e(0,0,f,r,a,i,de)/Be,l=[0,0,0,0],s=new Float64Array(16);for(let c=0;c<Be;c++){const m=(c+.5)*d,_=r*m,h=a*m,g=f+i*m,p=Math.max(Math.hypot(_,h,g)-Qt,0);this.coefficients(p,s);for(let v=0;v<4;v++)l[v]+=(s[v]+s[4+v]+s[8+v]+s[12+v])*d}for(let c=0;c<4;c++)o[c]=Math.exp(-l[c])}precompute(){const t=new Float64Array(4);for(let n=0;n<qt;n++)for(let o=0;o<dt;o++){const r=o/(dt-1),a=n/(qt-1);this.transmittance(r*2-1,a,t);const i=(n*dt+o)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,n,o){const r=(dt-1)*xn(t*.5+.5),a=(qt-1)*xn(n),i=Math.trunc(r),f=Math.trunc(a),u=Math.min(i+1,dt-1),d=Math.min(f+1,qt-1),l=r-i,s=a-f,c=(f*dt+i)*4,m=(f*dt+u)*4,_=(d*dt+i)*4,h=(d*dt+u)*4;for(let g=0;g<4;g++)o[g]=zt(zt(this.lut[c+g],this.lut[m+g],l),zt(this.lut[_+g],this.lut[h+g],l),s)}lookupAtGround(t,n){const o=(dt-1)*xn(t*.5+.5),r=Math.trunc(o),a=Math.min(r+1,dt-1),i=o-r;for(let f=0;f<4;f++)n[f]=zt(this.lut[r*4+f],this.lut[a*4+f],i)}lookupToSun(t,n){const o=(qt-1)*xn(t),r=Math.trunc(o),a=Math.min(r+1,qt-1),i=o-r,f=dt-1;for(let u=0;u<4;u++)n[u]=zt(this.lut[(r*dt+f)*4+u],this.lut[(a*dt+f)*4+u],i)}inscattering(t,n,o,r,a,i,f,u,d){const l=-(a*t[0]+i*t[1]+f*t[2]),s=Ar(l),c=Tr(l),m=u/Ue,_=new Float64Array(16),h=new Float64Array(4),g=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),y=new Float64Array(4),w=[0,0,0,0],P=[1,1,1,1];for(let S=0;S<Ue;S++){const T=(S+.5)*m,O=n+a*T,R=o+i*T,$=r+f*T,j=Math.hypot(O,R,$),H=Math.max(j-Qt,0),tt=H/zo,Z=(O*t[0]+R*t[1]+$*t[2])/j;this.coefficients(H,_),this.lookup(Z,tt,h);const et=Zt*(1-Or(1-jn(Qt/j)));this.lookupAtGround(Z,p),this.lookupToSun(0,v),this.lookupToSun(tt,y);const x=1/(1+5*Math.exp(-17.92*Z)),E=[.217,.347,.594,1];for(let A=0;A<4;A++){const U=v[A]/y[A],k=dr*et*(mr*Ro)*p[A]*U*Z;g[A]=.02*E[A]*x+k}for(let A=0;A<4;A++){const U=_[A]+_[4+A]+_[8+A]+_[12+A],k=hr[A]*(_[12+A]*(s*h[A]+g[A])+_[4+A]*(c*h[A]+g[A])),C=Math.exp(-m*U),M=Math.max(U,1e-7);w[A]+=P[A]*((k-k*C)/M),P[A]*=C}}for(let S=0;S<4;S++)d[S]=w[S]}}const vt=512,an=256;function Fo(e,t){const n=new Mr(e.airDensity,e.aerosolDensity,e.ozoneDensity);n.precompute();const o=Math.min(Math.max(e.altitude,1),99999)/1e3,r=Do(Math.cos(On-t)),a=new Float32Array(vt*an*3),i=vt/2,f=new Float64Array(4);for(let u=0;u<an;u++)for(let d=0;d<i;d++){const l=(d+.5)/vt,s=(u+.5)/an,c=Zt*l,m=s*2-1,_=Math.sign(m)*jn(m)*On,h=Math.cos(_)*Math.cos(c),g=Math.cos(_)*Math.sin(c),p=Math.sin(_),v=Qt+o,y=_e(0,0,v,h,g,p,de),w=_e(0,0,v,h,g,p,Qt),P=w<0?y:w;n.inscattering(r,0,0,v,h,g,p,P,f);let S=0,T=0,O=0;for(let j=0;j<4;j++)S+=Kn[j][0]*f[j],T+=Kn[j][1]*f[j],O+=Kn[j][2]*f[j];const R=(u*vt+d)*3;a[R]=S,a[R+1]=T,a[R+2]=O;const $=(u*vt+(vt-d-1))*3;a[$]=S,a[$+1]=T,a[$+2]=O}return a}function Pr(e){const[t]=Oe(e.sunElevation,e.sunRotation);return Fo(e,t)}function Ae(e){const[t]=Oe(e.sunElevation,e.sunRotation);return JSON.stringify([t,e.altitude,e.airDensity,e.aerosolDensity,e.ozoneDensity])}const Er=6,en=new Map;function Nr(e){return en.has(Ae(e))}function Co(e,t){en.set(Ae(e),t),en.size>Er&&en.delete(en.keys().next().value)}function Rr(e){const[t,n]=Oe(e.sunElevation,e.sunRotation),o=Ae(e);let r=en.get(o);r===void 0&&(r=Fo(e,t),Co(e,r));const a=new b;return i=>{const f=Math.hypot(i.x,i.y),u=Math.atan2(i.z,f);let l=(Math.atan2(i.x,i.y)+Math.PI+n)/Zt;l-=Math.floor(l);const s=Math.abs(u),c=xn(Math.sqrt(s/On)*Math.sign(u)*.5+.5),m=l*vt-.5,_=c*an-.5,h=Math.floor(m),g=Math.floor(_),p=m-h,v=_-g,y=$=>($%vt+vt)%vt,w=$=>$<0?0:$>an-1?an-1:$,P=y(h),S=y(h+1),T=w(g),O=w(g+1),R=[0,0,0];for(let $=0;$<3;$++){const j=zt(r[(T*vt+P)*3+$],r[(T*vt+S)*3+$],p),H=zt(r[(O*vt+P)*3+$],r[(O*vt+S)*3+$],p);R[$]=zt(j,H,v)}return a.set(Rt[0][0]*R[0]+Rt[0][1]*R[1]+Rt[0][2]*R[2],Rt[1][0]*R[0]+Rt[1][1]*R[1]+Rt[1][2]*R[2],Rt[2][0]*R[0]+Rt[2][1]*R[1]+Rt[2][2]*R[2])}}let kt=null,Tn=!1,Ir=0;const bn=new Map;function zr(){if(kt||Tn)return kt;if(typeof Worker>"u")return Tn=!0,null;try{kt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return Tn=!0,null}return kt.onmessage=e=>{const{id:t,pixels:n,error:o}=e.data,r=bn.get(t);r&&(bn.delete(t),n?r.resolve(n):r.reject(new Error(o??"sky worker returned nothing")))},kt.onerror=e=>{const t=new Error(`sky worker failed: ${e.message||"unknown error"}`);for(const n of bn.values())n.reject(t);bn.clear(),kt?.terminate(),kt=null,Tn=!0},kt}function Dr(e){const t=zr();if(!t)return Promise.resolve(Pr(e));const n=Ir++,o={id:n,parameters:e};return new Promise((r,a)=>{bn.set(n,{resolve:r,reject:a}),t.postMessage(o)})}function Fr(e,t,n,o={}){switch(o.type??"LINEAR"){case"QUADRATIC":{const r=Math.max(e,0);return r*r}case"EASING":{const r=Math.min(1,Math.max(0,e));return r*r*(3-2*r)}case"DIAGONAL":return(e+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(e,t,n),0);case"QUADRATIC_SPHERE":{const r=Math.max(.999999-Math.hypot(e,t,n),0);return r*r}case"RADIAL":return Math.atan2(t,e)/(2*Math.PI)+.5;default:return e}}const Jn=(e,t)=>t!==0?e/t:0,qe=e=>Math.min(1,Math.max(-1,e)),He=(e,t,n)=>{const o=n!==0?Math.max(n-Math.abs(e-t),0)/n:0;return Math.min(e,t)-o*o*o*n/6},ko={ADD:(e,t)=>e+t,SUBTRACT:(e,t)=>e-t,MULTIPLY:(e,t)=>e*t,DIVIDE:Jn,POWER:(e,t)=>t===0?1:e===0||e<0&&!Number.isInteger(t)?0:e**t,LOGARITHM:(e,t)=>e<=0||t<=0?0:Jn(Math.log(e),Math.log(t)),SQRT:e=>Math.sqrt(Math.max(e,0)),INVERSE_SQRT:e=>e>0?1/Math.sqrt(e):0,ABSOLUTE:Math.abs,RADIANS:e=>e*Math.PI/180,DEGREES:e=>e*180/Math.PI,MINIMUM:(e,t)=>Math.min(e,t),MAXIMUM:(e,t)=>Math.max(e,t),LESS_THAN:(e,t)=>+(e<t),GREATER_THAN:(e,t)=>+(e>t),ROUND:e=>Math.floor(e+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:e=>e-Math.floor(e),MODULO:(e,t)=>t!==0?e%t:0,FLOORED_MODULO:(e,t)=>t!==0?e-Math.floor(e/t)*t:0,TRUNC:Math.trunc,SNAP:(e,t)=>Math.floor(Jn(e,t))*t,WRAP:(e,t,n)=>t!==n?e-(t-n)*Math.floor((e-n)/(t-n)):n,PINGPONG:(e,t)=>{if(t===0)return 0;const n=(e-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:e=>Math.asin(qe(e)),ARCCOSINE:e=>Math.acos(qe(e)),ARCTANGENT:Math.atan,ARCTAN2:(e,t)=>e===0&&t===0?0:Math.atan2(e,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(e,t,n)=>+(e===t||Math.abs(e-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(e,t,n)=>e*t+n,SMOOTH_MIN:He,SMOOTH_MAX:(e,t,n)=>-He(-e,-t,n)};function lt(e,t){if(typeof e=="number")return()=>e;if(Array.isArray(e)){const r=new b(...e);return()=>r}if(e.kind==="direction")return r=>r;if(e.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(e.kind==="gradient"){const r=lt(e.vector,t),a={type:e.gradient_type},i=new b;return f=>{const u=r(f),d=typeof u=="number"?u:u.x,l=typeof u=="number"?u:u.y,s=typeof u=="number"?u:u.z,c=wt.clamp(Fr(d,l,s,a),0,1);return e.output==="Fac"?c:i.setScalar(c)}}if(e.kind==="to_float"){const r=lt(e.value,t);return a=>{const i=r(a);return typeof i=="number"?i:Math.fround(e.source_type==="RGBA"?i.x*.212639+i.y*.7151687+i.z*.0721923:(i.x+i.y+i.z)/3)}}if(e.kind==="math"){const r=e.inputs.map(f=>lt(f,t)),a=ko[e.operation],i=(f,u)=>{const d=r[f]?.(u)??0;if(typeof d!="number")throw new Error("World Math needs scalar inputs");return Math.fround(d)};return f=>{const u=Math.fround(a(i(0,f),i(1,f),i(2,f)));return e.clamp?wt.clamp(u,0,1):u}}if(e.kind==="mix_color"){const r=lt(e.factor,t),a=lt(e.a,t),i=lt(e.b,t),f=new b,u=new b;return d=>{const l=r(d);if(typeof l!="number")throw new Error("World color Mix needs a scalar factor");const s=a(d);typeof s=="number"?f.setScalar(s):f.copy(s);const c=i(d);return typeof c=="number"?u.setScalar(c):u.copy(c),f.lerp(u,e.clamp_factor?wt.clamp(l,0,1):l),e.clamp_result&&f.clampScalar(0,1),f}}if(e.kind==="sky"){const r=Rr({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return a=>r(a)}if(e.kind==="mapping"){const r=lt(e.vector,t),a=new b(...e.location),i=new b(...e.scale),f=new Mt().setFromEuler(new na(e.rotation[0],e.rotation[1],e.rotation[2],"ZYX")),u=f.clone().invert(),d=new b(...e.scale.map(s=>s===0?0:1/s)),l=new b;return s=>{const c=r(s);switch(typeof c=="number"?l.setScalar(c):l.copy(c),e.vector_type??"POINT"){case"TEXTURE":return l.sub(a).applyQuaternion(u).multiply(d);case"VECTOR":return l.multiply(i).applyQuaternion(f);case"NORMAL":return l.multiply(d).applyQuaternion(f).normalize();case"POINT":return l.multiply(i).applyQuaternion(f).add(a)}}}if(e.kind==="map_range"){const r=lt(e.value,t),a=lt(e.from_min,t),i=lt(e.from_max,t),f=lt(e.to_min,t),u=lt(e.to_max,t),d=lt(e.steps,t),l=(m,_)=>{const h=m(_);if(typeof h!="number")throw new Error("World Map Range needs scalar inputs");return h},s=e.interpolation,c=e.clamp;return m=>{const _=l(r,m),h=l(a,m),g=l(i,m),p=l(f,m),v=l(u,m);if(h===g)return 0;let y;if(s==="STEPPED"){const P=l(d,m),S=(_-h)/(g-h);y=P>0?Math.floor(S*(P+1))/P:0}else if(s==="SMOOTHSTEP"||s==="SMOOTHERSTEP"){const P=wt.clamp((_-Math.min(h,g))/(Math.max(h,g)-Math.min(h,g)),0,1),S=s==="SMOOTHSTEP"?P*P*(3-2*P):P*P*P*(P*(P*6-15)+10);y=h>g?1-S:S}else y=(_-h)/(g-h);const w=p+y*(v-p);return c?p>v?wt.clamp(w,v,p):wt.clamp(w,p,v):w}}if(e.kind==="separate"){const r=lt(e.vector,t);return a=>{const i=r(a);return typeof i=="number"?i:i.getComponent(e.axis)}}const n=lt(e.factor,t),o=new b;return r=>{const a=n(r);if(typeof a!="number")throw new Error("World ColorRamp needs a scalar factor");const i=wt.clamp(a,0,1)*256,f=Math.floor(i),u=e.colors[f],d=e.colors[Math.min(f+1,256)],l=e.interpolate?i-f:0;return o.set(wt.lerp(u[0],d[0],l),wt.lerp(u[1],d[1],l),wt.lerp(u[2],d[2],l))}}function Cr(e,t,n,o){const r=new Float32Array(t*n*3),a=lt(e,o),i=new b;for(let f=0;f<n;f++){const u=((f+.5)/n-.5)*Math.PI;for(let d=0;d<t;d++){const l=((d+.5)/t-.5)*2*Math.PI;i.set(Math.cos(u)*Math.cos(l),-Math.cos(u)*Math.sin(l),Math.sin(u));const s=a(i),c=(f*t+d)*3;r[c]=typeof s=="number"?s:s.x,r[c+1]=typeof s=="number"?s:s.y,r[c+2]=typeof s=="number"?s:s.z}}return r}function Ge(e){const t=[],n=o=>{if(!(typeof o=="number"||Array.isArray(o)))switch(o.kind){case"sky":t.push({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return;case"mapping":case"gradient":case"separate":n(o.vector);return;case"ramp":n(o.factor);return;case"mix_color":n(o.factor),n(o.a),n(o.b);return;case"math":o.inputs.forEach(n);return;case"to_float":n(o.value);return;case"map_range":n(o.value),n(o.from_min),n(o.from_max),n(o.to_min),n(o.to_max),n(o.steps);return;default:return}};return n(e),t}function Lt(e){if(typeof e=="number"||Array.isArray(e))return!1;switch(e.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Lt(e.vector);case"ramp":return Lt(e.factor);case"mix_color":return[e.factor,e.a,e.b].some(Lt);case"math":return e.inputs.some(Lt);case"to_float":return Lt(e.value);case"map_range":return[e.value,e.from_min,e.from_max,e.to_min,e.to_max,e.steps].some(Lt);default:return!1}}function kr(e,t,n,o){o.updateMatrixWorld();const r=new Float32Array(t*n*3),a=new b,i=lt(e,()=>a),f=new b,u=o.getWorldPosition(new b),d=o.getWorldDirection(new b);for(let l=0;l<n;l++)for(let s=0;s<t;s++){const c=(s+.5)/t,m=(l+.5)/n;a.set(c,m,0),o.isOrthographicCamera?f.copy(d):f.set(c*2-1,m*2-1,.5).unproject(o).sub(u).normalize(),f.set(f.x,-f.z,f.y);const _=i(f),h=(l*t+s)*3;r[h]=typeof _=="number"?_:_.x,r[h+1]=typeof _=="number"?_:_.y,r[h+2]=typeof _=="number"?_:_.z}return r}const st=I().finite(),$r=N({type:Y(["POINT","SUN","SPOT","AREA"]),color:W([st,st,st]),energy:st,use_shadow:at().default(!0),radius:st.optional(),spot_size:st.optional(),spot_blend:st.optional(),shape:Y(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:st.optional(),size_y:st.optional()}).strict();let he;function Lr(){return he??=Fa(async()=>{const{RectAreaLightUniformsLib:e}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:e}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:e})=>{e.init(),gt()}),he}function Vr(){return he??Promise.resolve()}const jr=e=>{const t=e.size??0,n=e.size_y??t;if(e.shape==="RECTANGLE")return[t,n];if(e.shape==="DISK"){const o=Math.sqrt(Math.PI*t*t/4);return[o,o]}if(e.shape==="ELLIPSE"){const o=Math.sqrt(Math.PI/4);return[t*o,n*o]}return[t,t]};function Br(e,t){const n=(i,f)=>t&&f(t)?t:new i;if(e.type==="SUN"){const i=n(vo,f=>f.isDirectionalLight);return i.intensity=e.energy,i.color.setRGB(e.color[0],e.color[1],e.color[2],bt),i.castShadow=e.use_shadow,i}if(e.type==="POINT"){const i=n(se,f=>f.isPointLight);return i.intensity=e.energy/(4*Math.PI),i.distance=0,i.decay=2,i.color.setRGB(e.color[0],e.color[1],e.color[2],bt),i.castShadow=e.use_shadow,i}if(e.type==="SPOT"){const i=n(le,f=>f.isSpotLight);return i.intensity=e.energy/(4*Math.PI),i.distance=0,i.decay=2,i.angle=(e.spot_size??0)/2,i.penumbra=e.spot_blend??0,i.color.setRGB(e.color[0],e.color[1],e.color[2],bt),i.castShadow=e.use_shadow,i}Lr();const o=n(Dn,i=>i.isRectAreaLight),[r,a]=jr(e);return o.width=r,o.height=a,o.intensity=e.energy/(Math.max(r*a,Number.MIN_VALUE)*Math.PI),o.color.setRGB(e.color[0],e.color[1],e.color[2],bt),o}function Ur(e,t,n){if(!e.castShadow||n<=0)return;const r=e.getWorldPosition(new b).distanceTo(t),a=e.shadow;if(!a)return;const i=a.camera;i.near=Math.max(n*.001,r-n),i.far=r+n,e.isDirectionalLight&&(i.left=-n,i.right=n,i.top=n,i.bottom=-n),i.updateProjectionMatrix()}function Wr(e,t){e.position.set(0,0,0);const n=e;e.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const Te=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],Xe=.69;class qr{constructor(){this.group=new ft,this.lights=[],this.group.name="BlenderSolidStudio";const t=new go;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new Tt(0,0,0);for(const[r,a]of Te.entries()){const i=(1+a.smooth)**2,f=new vo(16777215,Math.PI*Xe/i);f.name=`BlenderSolidLight${r}`,f.color.setRGB(a.diffuse[0],a.diffuse[1],a.diffuse[2],bt),f.position.set(a.direction[0],a.direction[1],a.direction[2]),f.target=t,this.group.add(f),this.lights.push(f),n.r+=a.diffuse[0]*a.smooth/i,n.g+=a.diffuse[1]*a.smooth/i,n.b+=a.diffuse[2]*a.smooth/i}const o=new ea(16777215,Math.PI*Xe);o.name="BlenderSolidWrapFill",o.color.copy(n),this.group.add(o),this.lights.push(o)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const nn=W([st,st,st]),J=Mo(()=>Ut([st,nn,N({kind:X("direction")}).strict(),N({kind:X("window")}).strict(),N({kind:X("gradient"),gradient_type:Y(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:Y(["Fac","Color"]),vector:J}).strict(),N({kind:X("to_float"),source_type:Y(["RGBA","VECTOR"]),value:J}).strict(),N({kind:X("math"),operation:Y(Object.keys(ko)),clamp:at(),inputs:L(J).min(1).max(3)}).strict(),N({kind:X("mix_color"),factor:J,a:J,b:J,clamp_factor:at(),clamp_result:at()}).strict(),N({kind:X("mapping"),vector_type:Y(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:J,location:nn,rotation:nn,scale:nn}).strict(),N({kind:X("separate"),vector:J,axis:I().int().min(0).max(2)}).strict(),N({kind:X("ramp"),factor:J,colors:L(nn).length(257),interpolate:at()}).strict(),N({kind:X("map_range"),interpolation:Y(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:at(),value:J,from_min:J,from_max:J,to_min:J,to_max:J,steps:J}).strict(),N({kind:X("sky"),sun_elevation:st,sun_rotation:st,altitude:st,air_density:st,aerosol_density:st,ozone_density:st}).strict()])),Ye=N({color:nn,strength:st,shader:J.optional()}),Hr=Ye.extend({volume:L(N({kind:Y(["absorption","scatter","principled","emission"]),phase:z(),alpha:J,weight:J,color:J,density:J,anisotropy:J,absorption_color:J,emission_color:J,emission_strength:J,blackbody_intensity:J,temperature:J,blackbody_tint:J}).strict()).optional(),lighting:Ye.strict().optional()}).strict(),Gr=4,pn=new Map,te=new Set;function Ze(e,t,n){const a=Lt(e);if(a&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const i=JSON.stringify([e,a?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),f=pn.get(i);if(f!==void 0)return pe(f,t,256,128);const u=new b,d=new Un,l=n?new q().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,s=n?.getWorldPosition(new b),m=Cr(e,256,128,a?_=>(u.set(_.x,_.z,-_.y),n.isPerspectiveCamera&&u.add(s),d.set(u.x,u.y,u.z,1).applyMatrix4(l),d.w===0?u.set(0,0,0):u.set(d.x/d.w*.5+.5,d.y/d.w*.5+.5,0)):void 0);return pn.set(i,m),pn.size>Gr&&pn.delete(pn.keys().next().value),pe(m,t,256,128)}function Xr(e,t,n,o){const r=vn.toHalfFloat(1);for(let a=0;a<o;a++)e[a*4]=vn.toHalfFloat(t[a*3]*n),e[a*4+1]=vn.toHalfFloat(t[a*3+1]*n),e[a*4+2]=vn.toHalfFloat(t[a*3+2]*n),e[a*4+3]=r}function pe(e,t,n,o){const r=new Uint16Array(n*o*4);Xr(r,e,t,n*o);const a=new Wn(r,n,o,qn,ye);return a.mapping=aa,a.colorSpace=bt,a.minFilter=Jt,a.magFilter=Jt,a.needsUpdate=!0,a}class Se{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,o){if(this.clear(),this.pending=null,!n)return;const r=Se.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=n.shader??n.color,i=this.generation,u=[...Ge(a),...n.lighting?Ge(n.lighting.shader??n.lighting.color):[]].filter(l=>!Nr(l));if(u.length===0){this.compose(r,n,a,o);return}const d=(async()=>{const l=await Promise.all(u.map(Dr));u.forEach((s,c)=>{Co(s,l[c])}),!(this.generation!==i||this.applied?.scene!==r)&&(this.compose(r,n,a,o),gt())})();this.pending=d,te.add(d),d.then(()=>te.delete(d),()=>te.delete(d))}compose(t,n,o,r){if(this.texture=Ze(o,n.strength,r),Lt(o)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=pe(kr(o,512,512,r),n.strength,512,512),this.screenTexture.mapping=oa,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const i=r.getWorldDirection(new b);i.set(i.x,-i.z,i.y);const f=lt(n.shader??n.color)(i);t.background=typeof f=="number"?new Tt().setRGB(f,f,f).multiplyScalar(n.strength):new Tt().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:a}=n;this.environmentTexture=a?Ze(a.shader??a.color,a.strength,r):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function $o(e){return[e.min.x,e.max.x].flatMap(t=>[e.min.y,e.max.y].flatMap(n=>[e.min.z,e.max.z].map(o=>new b(t,n,o))))}function Yr(e,t){if(e.isEmpty()||!t.intersectsBox(e))return[];const n=$o(e);if(n.every(l=>t.containsPoint(l)))return n;const o=[...t.planes,new Gt(new b(1,0,0),-e.min.x),new Gt(new b(-1,0,0),e.max.x),new Gt(new b(0,1,0),-e.min.y),new Gt(new b(0,-1,0),e.max.y),new Gt(new b(0,0,1),-e.min.z),new Gt(new b(0,0,-1),e.max.z)],r=[],a=new b,i=new b,f=new b,u=new b,d=Math.max(1,e.min.length(),e.max.length())*1e-8;for(let l=0;l<o.length;l++)for(let s=l+1;s<o.length;s++)for(let c=s+1;c<o.length;c++){const m=o[l],_=o[s],h=o[c];a.crossVectors(_.normal,h.normal);const g=m.normal.dot(a);Math.abs(g)<1e-12||(i.crossVectors(h.normal,m.normal),f.crossVectors(m.normal,_.normal),u.copy(a).multiplyScalar(-m.constant).addScaledVector(i,-_.constant).addScaledVector(f,-h.constant).divideScalar(g),o.every(p=>p.distanceToPoint(u)>=-d)&&r.push(u.clone()))}return r}function Zr(e,t,n){if(!e.castShadow||!t.length)return;e.shadow.updateMatrices(e);const o=e.shadow.camera,r=o.matrixWorldInverse,a=new ln().setFromPoints(t.map(c=>c.clone().applyMatrix4(r))),i=a.getSize(new b),f=Math.max(i.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,d=Math.max(i.x,i.y,f)/Math.max(1,Math.min(e.shadow.mapSize.x,e.shadow.mapSize.y)-2*u),l=2*Math.SQRT2*d,s=u*d;a.min.x-=s,a.min.y-=s,a.max.x+=s,a.max.y+=s;for(const c of n){if(c.isEmpty())continue;const m=new ln().setFromPoints($o(c).map(_=>_.applyMatrix4(r)));m.max.x<a.min.x||m.min.x>a.max.x||m.max.y<a.min.y||m.min.y>a.max.y||(a.min.z=Math.min(a.min.z,m.min.z),a.max.z=Math.max(a.max.z,m.max.z))}o.left=a.min.x,o.right=a.max.x,o.bottom=a.min.y,o.top=a.max.y,o.near=-a.max.z-l-f,o.far=-a.min.z+l+f,o.updateProjectionMatrix(),e.shadow.normalBias=l}const rn=I().finite(),Qe=W([rn,rn,rn]),Lo=N({min:W([I().int(),I().int(),I().int()]),max:W([I().int(),I().int(),I().int()]),density:L(rn),voxelSize:rn.positive(),color:Qe,emission:Qe,densityScale:rn.nonnegative()}).strict();function Qr(e){const t=e.max.map((l,s)=>l-e.min[s]+1);if(t.some(l=>l<=0)||t.reduce((l,s)=>l*s,1)!==e.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new ra(new Float32Array(e.density),t[0],t[1],t[2]);n.format=ia,n.type=xo,n.minFilter=n.magFilter=Jt,n.unpackAlignment=1,n.needsUpdate=!0;const o=new b(...e.min).addScalar(-.5).multiplyScalar(e.voxelSize),r=new b(t[0],t[1],t[2]).multiplyScalar(e.voxelSize),a=new sa(r.x,r.y,r.z),i=a.getAttribute("position");for(let l=0;l<i.count;l++)i.setXYZ(l,o.x+(i.getX(l)>0?r.x:0),o.y+(i.getY(l)>0?r.y:0),o.z+(i.getZ(l)>0?r.z:0));i.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const f=new be({glslVersion:fa,side:la,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:o},extent:{value:r},voxelSize:{value:e.voxelSize},densityScale:{value:e.densityScale},volumeColor:{value:new b(...e.color)},emission:{value:new b(...e.emission)},cameraLocal:{value:new b},rayLocal:{value:new b},orthographic:{value:!1},worldScale:{value:new po}},vertexShader:`
20
20
  out vec3 localPosition;
21
21
  void main() {
22
22
  localPosition = position;
@@ -58,7 +58,7 @@ import{a as mo,b as _o,L as ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ft
58
58
  outputColor = vec4(radiance, 1.0 - transmission);
59
59
  #include <tonemapping_fragment>
60
60
  #include <colorspace_fragment>
61
- }`}),u=new Ft(a,f),d=new q;return u.onBeforeRender=(l,s,c)=>{d.copy(u.matrixWorld).invert(),f.uniforms.cameraLocal.value.setFromMatrixPosition(c.matrixWorld).applyMatrix4(d),c.getWorldDirection(f.uniforms.rayLocal.value).transformDirection(d),f.uniforms.orthographic.value=!!c.isOrthographicCamera,f.uniforms.worldScale.value.setFromMatrix4(u.matrixWorld)},f.addEventListener("dispose",()=>n.dispose()),u}const Kr=`#define constexpr const
61
+ }`}),u=new Dt(a,f),d=new q;return u.onBeforeRender=(l,s,c)=>{d.copy(u.matrixWorld).invert(),f.uniforms.cameraLocal.value.setFromMatrixPosition(c.matrixWorld).applyMatrix4(d),c.getWorldDirection(f.uniforms.rayLocal.value).transformDirection(d),f.uniforms.orthographic.value=!!c.isOrthographicCamera,f.uniforms.worldScale.value.setFromMatrix4(u.matrixWorld)},f.addEventListener("dispose",()=>n.dispose()),u}const Kr=`#define constexpr const
62
62
  #define bool32_t bool
63
63
  #define bool2 bvec2
64
64
  #define bool3 bvec3
@@ -6879,7 +6879,7 @@ void curves_float_mixed(float factor,
6879
6879
  curves_float(
6880
6880
  value, curve_map, layer, range_minimum, range_divider, start_slope, end_slope, result);
6881
6881
  result = mix(value, result, factor);
6882
- }`}},Ke=I().finite(),te=Y(["float","vec2","vec3","vec4"]),Vo=Ut([Ke,L(Ke)]),jo=W([z(),I().int().nonnegative()]),Cn=Ut([N({value:Vo}).strict(),N({link:jo}).strict()]),Jr=["ShaderNodeTexCoord","ShaderNodeUVMap","ShaderNodeValue","ShaderNodeRGB","ShaderNodeTexImage","ShaderNodeMapping","ShaderNodeMath","ShaderNodeVectorMath","ShaderNodeMix","ShaderNodeMixRGB","ShaderNodeValToRGB","ShaderNodeInvert","ShaderNodeSeparateXYZ","ShaderNodeCombineXYZ","ShaderNodeTexNoise","ShaderNodeTexVoronoi","ShaderNodeTexChecker","ShaderNodeTexWhiteNoise","ShaderNodeTexWave","ShaderNodeTexGradient","ShaderNodeTexMagic","ShaderNodeTexBrick","ShaderNodeMapRange","ShaderNodeClamp","ShaderNodeHueSaturation","ShaderNodeBrightContrast","ShaderNodeGamma","ShaderNodeRGBToBW","ShaderNodeSeparateColor","ShaderNodeCombineColor","ShaderNodeVectorRotate","ShaderNodeFresnel","ShaderNodeLayerWeight","ShaderNodeBump","ShaderNodeNormalMap","ShaderNodeNewGeometry","ShaderNodeVertexColor","ShaderNodeAttribute","ShaderNodeRGBCurve","ShaderNodeVectorCurve","ShaderNodeFloatCurve"],ti=N({type:Y(Jr),props:Ot(z(),Po()),inputs:L(Ut([N({value:Vo,id:z(),gpu:te,enabled:at()}).strict(),N({link:jo,id:z(),gpu:te,enabled:at()}).strict()])),outputs:L(N({id:z(),gpu:te.or(X("closure")).nullable()}).strict())}).strict(),yn=Mo(()=>Ut([N({principled:X(!0)}).strict(),N({emission:W([Cn,Cn])}).strict(),N({transparent:I()}).strict(),N({none:X(!0)}).strict(),N({mix:W([Cn,yn,yn])}).strict(),N({add:W([yn,yn])}).strict()])),ni=N({surface:Y(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:Ot(z(),Cn),closure:yn.optional(),nodes:Ot(z(),ti)}).strict();function ei(e){const t=e.inputs.Alpha,n=o=>"transparent"in o||"mix"in o&&(n(o.mix[1])||n(o.mix[2]))||"add"in o&&(n(o.add[0])||n(o.add[1]));return t!==void 0&&"link"in t||e.closure!==void 0&&n(e.closure)}const Bo="vec3(0.2126729, 0.7151522, 0.0721750)",oi=e=>e==="float"?1:Number(e[3]);function ai(e,t){const n=typeof t=="number"?[t]:t,o=oi(e);return Array.from({length:o},(r,a)=>n[a]??(a===3?1:0))}function ri(e,t,n){if(t===n)return e;const o=a=>a==="float"?"float":`float${a[3]}`,r=t==="vec4"&&n==="float"?`, ${Bo}`:"";return`${o(n)}_from_${o(t)}(${e}${r})`}const ii={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},si={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},Je={MIX:"blend",ADD:"add",MULTIPLY:"mult",SUBTRACT:"sub",SCREEN:"screen",DIVIDE:"div_fallback",DIFFERENCE:"diff",EXCLUSION:"exclusion",DARKEN:"dark",LIGHTEN:"light",OVERLAY:"overlay",DODGE:"dodge",BURN:"burn",HUE:"hue",SATURATION:"sat",VALUE:"val",COLOR:"color",SOFT_LIGHT:"soft",LINEAR_LIGHT:"linear"},li={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},fi={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},ci={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},ui=(()=>{const e=new Map;for(const[t,n]of Object.entries(ge))for(const o of n.code.matchAll(/^(?:void|float\d?)\s+([A-Za-z_]\w*)\s*\(/gm))e.has(o[1])||e.set(o[1],t);return e})();function V(e,t){if(!(t in e.props))throw new Error(`${e.type} arrived without its '${t}' property`);return e.props[t]}const mi=`
6882
+ }`}},Ke=I().finite(),ne=Y(["float","vec2","vec3","vec4"]),Vo=Ut([Ke,L(Ke)]),jo=W([z(),I().int().nonnegative()]),Cn=Ut([N({value:Vo}).strict(),N({link:jo}).strict()]),Jr=["ShaderNodeTexCoord","ShaderNodeUVMap","ShaderNodeValue","ShaderNodeRGB","ShaderNodeTexImage","ShaderNodeMapping","ShaderNodeMath","ShaderNodeVectorMath","ShaderNodeMix","ShaderNodeMixRGB","ShaderNodeValToRGB","ShaderNodeInvert","ShaderNodeSeparateXYZ","ShaderNodeCombineXYZ","ShaderNodeTexNoise","ShaderNodeTexVoronoi","ShaderNodeTexChecker","ShaderNodeTexWhiteNoise","ShaderNodeTexWave","ShaderNodeTexGradient","ShaderNodeTexMagic","ShaderNodeTexBrick","ShaderNodeMapRange","ShaderNodeClamp","ShaderNodeHueSaturation","ShaderNodeBrightContrast","ShaderNodeGamma","ShaderNodeRGBToBW","ShaderNodeSeparateColor","ShaderNodeCombineColor","ShaderNodeVectorRotate","ShaderNodeFresnel","ShaderNodeLayerWeight","ShaderNodeBump","ShaderNodeNormalMap","ShaderNodeNewGeometry","ShaderNodeVertexColor","ShaderNodeAttribute","ShaderNodeRGBCurve","ShaderNodeVectorCurve","ShaderNodeFloatCurve"],ti=N({type:Y(Jr),props:Ot(z(),Po()),inputs:L(Ut([N({value:Vo,id:z(),gpu:ne,enabled:at()}).strict(),N({link:jo,id:z(),gpu:ne,enabled:at()}).strict()])),outputs:L(N({id:z(),gpu:ne.or(X("closure")).nullable()}).strict())}).strict(),yn=Mo(()=>Ut([N({principled:X(!0)}).strict(),N({emission:W([Cn,Cn])}).strict(),N({transparent:I()}).strict(),N({none:X(!0)}).strict(),N({mix:W([Cn,yn,yn])}).strict(),N({add:W([yn,yn])}).strict()])),ni=N({surface:Y(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:Ot(z(),Cn),closure:yn.optional(),nodes:Ot(z(),ti)}).strict();function ei(e){const t=e.inputs.Alpha,n=o=>"transparent"in o||"mix"in o&&(n(o.mix[1])||n(o.mix[2]))||"add"in o&&(n(o.add[0])||n(o.add[1]));return t!==void 0&&"link"in t||e.closure!==void 0&&n(e.closure)}const Bo="vec3(0.2126729, 0.7151522, 0.0721750)",oi=e=>e==="float"?1:Number(e[3]);function ai(e,t){const n=typeof t=="number"?[t]:t,o=oi(e);return Array.from({length:o},(r,a)=>n[a]??(a===3?1:0))}function ri(e,t,n){if(t===n)return e;const o=a=>a==="float"?"float":`float${a[3]}`,r=t==="vec4"&&n==="float"?`, ${Bo}`:"";return`${o(n)}_from_${o(t)}(${e}${r})`}const ii={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},si={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},Je={MIX:"blend",ADD:"add",MULTIPLY:"mult",SUBTRACT:"sub",SCREEN:"screen",DIVIDE:"div_fallback",DIFFERENCE:"diff",EXCLUSION:"exclusion",DARKEN:"dark",LIGHTEN:"light",OVERLAY:"overlay",DODGE:"dodge",BURN:"burn",HUE:"hue",SATURATION:"sat",VALUE:"val",COLOR:"color",SOFT_LIGHT:"soft",LINEAR_LIGHT:"linear"},li={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},fi={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},ci={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},ui=(()=>{const e=new Map;for(const[t,n]of Object.entries(ge))for(const o of n.code.matchAll(/^(?:void|float\d?)\s+([A-Za-z_]\w*)\s*\(/gm))e.has(o[1])||e.set(o[1],t);return e})();function V(e,t){if(!(t in e.props))throw new Error(`${e.type} arrived without its '${t}' property`);return e.props[t]}const mi=`
6883
6883
  #define GPU_FRAGMENT_SHADER
6884
6884
  #define FrontFacing gl_FrontFacing
6885
6885
  #ifndef USE_TRANSMISSION
@@ -7034,7 +7034,7 @@ vec3 blender_reflection() {
7034
7034
  uniform highp sampler2D ${s.uniform}Map;`:`uniform sampler2D ${s.uniform};`),...this.ramps.map(s=>`uniform sampler2D ${s.uniform};`),...Object.values(n).map(s=>`${s.type} ${s.global};`),...a?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,d].join(`
7035
7035
  `);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:l,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:a!==void 0}}}function _i(e,t){const n=[],o=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let r=0;for(let u;u=o.exec(e);){if(u.index<r)continue;let d=u.index+u[0].length;for(let m=1;d<e.length&&m>0;d++)m+=e[d]==="("?1:e[d]===")"?-1:0;const l=e.slice(d).match(/^\s*(\{|;)/);if(!l||/^\s*#/.test(e.slice(e.lastIndexOf(`
7036
7036
  `,u.index)+1,u.index+1))||e.slice(Math.max(0,u.index-2),u.index).endsWith(`\\
7037
- `))continue;let c=d+l[0].length;if(l[1]==="{")for(let m=1;c<e.length&&m>0;c++)m+=e[c]==="{"?1:e[c]==="}"?-1:0;n.push({text:e.slice(r,u.index),name:null}),n.push({text:e.slice(u.index,c),name:u[1]}),r=c,o.lastIndex=c}n.push({text:e.slice(r),name:null});const a=new Set(n.filter(u=>u.name===null)),i=new Set,f=u=>{for(const d of u.matchAll(/[A-Za-z_]\w*/g))i.add(d[0])};f(t);for(const u of a)f(u.text);for(let u=!0;u;){u=!1;for(const d of n)a.has(d)||d.name===null||!i.has(d.name)||(a.add(d),f(d.text),u=!0)}return n.filter(u=>a.has(u)).map(u=>u.text).join("")}function ve(e){return`v${jt(e)}`}function on(e){return e===""?"vBlenderUvRender":`vBlenderUv_${[...e].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function hi(e){return new Me(e).compile()}function pi(e){const t=new Uint16Array(e.length*4);e.forEach((o,r)=>t.set([o[0]??0,o[1]??0,o[2]??0,o[3]??1].map(a=>vn.toHalfFloat(a)),r*4));const n=new Un(t,e.length,1,Wn,ye);return n.minFilter=n.magFilter=Jt,n.wrapS=n.wrapT=bo,n.needsUpdate=!0,n}const xt=new WeakMap,Uo=new Set,Vt=new WeakMap,Sn=new WeakMap;function Mn(e){const t=Vt.get(e);if(t){Vt.delete(e);for(const n of t.binding.ramps)n.dispose()}}function gi(e,t,n,o=!1){const r=xt.get(e);if(t&&Uo.has(t.key)&&(t=null),!t){if(Mn(e),r){for(const f of r.ramps)f.dispose();xt.delete(e),e.needsUpdate=!0}return}if(r&&r.compiled.key===t.key){Mn(e),Pn(r,t,n);return}if(o){Mn(e);for(const u of r?.ramps??[])u.dispose();const f={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};Pn(f,t,n),xt.set(e,f),e.needsUpdate=!0;return}const a=Vt.get(e);if(a&&a.binding.compiled.key===t.key){Pn(a.binding,t,n);return}Mn(e);const i={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};Pn(i,t,n),Vt.set(e,{binding:i,started:!1})}function Pn(e,t,n){e.compiled=t;for(const[o,r]of t.uniforms){const a=typeof r=="number"?r:r.length===2?new Kt(...r):r.length===3?new b(...r):new Bn(...r),i=e.uniforms[o];i?i.value=a:e.uniforms[o]={value:a}}for(const o of e.ramps)o.dispose();e.ramps=t.ramps.map(o=>{const r=pi(o.table);return(e.uniforms[o.uniform]??={value:null}).value=r,r});for(const o of t.images){const r=n(o);if(o.tiled){const a=r!==null&&"tiles"in r?r:null;(e.uniforms[o.uniform]??={value:null}).value=a?.tiles??null,(e.uniforms[`${o.uniform}Map`]??={value:null}).value=a?.map??null}else(e.uniforms[o.uniform]??={value:null}).value=r!==null&&"tiles"in r?null:r}}function vi(e){const t=xt.get(e);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function xi(e){return Object.values(xt.get(e)?.channels??{})}function Wo(e,t){const n=new Set(["position","normal","uv"]);if(t.hasAttribute("tangent")&&n.add("tangent"),e.vertexColors&&n.add("color"),!(e instanceof fn))return n;const o=t.userData.blenderUvChannels,r=a=>{const i=a===""?0:o?.[a]??9;n.add(i===0?"uv":`uv${i}`)};for(const a of[e.map,e.roughnessMap,e.normalMap])a&&r(a.userData.blenderUvName??"");for(const a of[xt.get(e),Vt.get(e)?.binding])if(a){n.add("blenderOrco");for(const i of a.compiled.uvs)r(i);for(const i of a.compiled.attributes)n.add(jt(i))}return n}function to(e,t){const n=t.userData.blenderUvChannels,o=t.getAttribute("position")?.count??0,r={};for(const a of e.uvs){let i=a===""?0:n?.[a];i===void 0&&(i=9,t.getAttribute("uv9")?.count!==o&&t.setAttribute("uv9",new ut(new Float32Array(o*2),2))),r[a]=i}return r}function bi(e,t,n,o,r,a,i){const f=Sn.get(e);f&&++f.draws>1&&(f.shadow.dispose(),Sn.delete(e));const u=Vt.get(e);if(u&&!u.started){u.started=!0,u.binding.channels=to(u.binding.compiled,t);const c=i(e);xt.set(c,u.binding);const m=new Ft(t,c);m.castShadow=a.castShadow,m.receiveShadow=a.receiveShadow;const _=()=>{if(Vt.get(e)!==u){c.dispose();return}Vt.delete(e);for(const h of xt.get(e)?.ramps??[])h.dispose();xt.set(e,u.binding),e.needsUpdate=!0,Sn.get(e)?.shadow.dispose(),Sn.set(e,{shadow:c,draws:0}),gt()};n.compileAsync(m,r,o).then(_,_)}const d=xt.get(e);if(!d)return;const l=n.properties.get(e).currentProgram;if(l?.diagnostics?.runnable===!1&&l.cacheKey?.includes(d.compiled.key)){Uo.add(d.compiled.key),xt.delete(e),e.needsUpdate=!0;const c=l.diagnostics.fragmentShader.log.split(`
7037
+ `))continue;let c=d+l[0].length;if(l[1]==="{")for(let m=1;c<e.length&&m>0;c++)m+=e[c]==="{"?1:e[c]==="}"?-1:0;n.push({text:e.slice(r,u.index),name:null}),n.push({text:e.slice(u.index,c),name:u[1]}),r=c,o.lastIndex=c}n.push({text:e.slice(r),name:null});const a=new Set(n.filter(u=>u.name===null)),i=new Set,f=u=>{for(const d of u.matchAll(/[A-Za-z_]\w*/g))i.add(d[0])};f(t);for(const u of a)f(u.text);for(let u=!0;u;){u=!1;for(const d of n)a.has(d)||d.name===null||!i.has(d.name)||(a.add(d),f(d.text),u=!0)}return n.filter(u=>a.has(u)).map(u=>u.text).join("")}function ve(e){return`v${jt(e)}`}function on(e){return e===""?"vBlenderUvRender":`vBlenderUv_${[...e].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function hi(e){return new Me(e).compile()}function pi(e){const t=new Uint16Array(e.length*4);e.forEach((o,r)=>t.set([o[0]??0,o[1]??0,o[2]??0,o[3]??1].map(a=>vn.toHalfFloat(a)),r*4));const n=new Wn(t,e.length,1,qn,ye);return n.minFilter=n.magFilter=Jt,n.wrapS=n.wrapT=bo,n.needsUpdate=!0,n}const xt=new WeakMap,Uo=new Set,Vt=new WeakMap,Sn=new WeakMap;function Mn(e){const t=Vt.get(e);if(t){Vt.delete(e);for(const n of t.binding.ramps)n.dispose()}}function gi(e,t,n,o=!1){const r=xt.get(e);if(t&&Uo.has(t.key)&&(t=null),!t){if(Mn(e),r){for(const f of r.ramps)f.dispose();xt.delete(e),e.needsUpdate=!0}return}if(r&&r.compiled.key===t.key){Mn(e),Pn(r,t,n);return}if(o){Mn(e);for(const u of r?.ramps??[])u.dispose();const f={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};Pn(f,t,n),xt.set(e,f),e.needsUpdate=!0;return}const a=Vt.get(e);if(a&&a.binding.compiled.key===t.key){Pn(a.binding,t,n);return}Mn(e);const i={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};Pn(i,t,n),Vt.set(e,{binding:i,started:!1})}function Pn(e,t,n){e.compiled=t;for(const[o,r]of t.uniforms){const a=typeof r=="number"?r:r.length===2?new Kt(...r):r.length===3?new b(...r):new Un(...r),i=e.uniforms[o];i?i.value=a:e.uniforms[o]={value:a}}for(const o of e.ramps)o.dispose();e.ramps=t.ramps.map(o=>{const r=pi(o.table);return(e.uniforms[o.uniform]??={value:null}).value=r,r});for(const o of t.images){const r=n(o);if(o.tiled){const a=r!==null&&"tiles"in r?r:null;(e.uniforms[o.uniform]??={value:null}).value=a?.tiles??null,(e.uniforms[`${o.uniform}Map`]??={value:null}).value=a?.map??null}else(e.uniforms[o.uniform]??={value:null}).value=r!==null&&"tiles"in r?null:r}}function vi(e){const t=xt.get(e);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function xi(e){return Object.values(xt.get(e)?.channels??{})}function Wo(e,t){const n=new Set(["position","normal","uv"]);if(t.hasAttribute("tangent")&&n.add("tangent"),e.vertexColors&&n.add("color"),!(e instanceof fn))return n;const o=t.userData.blenderUvChannels,r=a=>{const i=a===""?0:o?.[a]??9;n.add(i===0?"uv":`uv${i}`)};for(const a of[e.map,e.roughnessMap,e.normalMap])a&&r(a.userData.blenderUvName??"");for(const a of[xt.get(e),Vt.get(e)?.binding])if(a){n.add("blenderOrco");for(const i of a.compiled.uvs)r(i);for(const i of a.compiled.attributes)n.add(jt(i))}return n}function to(e,t){const n=t.userData.blenderUvChannels,o=t.getAttribute("position")?.count??0,r={};for(const a of e.uvs){let i=a===""?0:n?.[a];i===void 0&&(i=9,t.getAttribute("uv9")?.count!==o&&t.setAttribute("uv9",new ut(new Float32Array(o*2),2))),r[a]=i}return r}function bi(e,t,n,o,r,a,i){const f=Sn.get(e);f&&++f.draws>1&&(f.shadow.dispose(),Sn.delete(e));const u=Vt.get(e);if(u&&!u.started){u.started=!0,u.binding.channels=to(u.binding.compiled,t);const c=i(e);xt.set(c,u.binding);const m=new Dt(t,c);m.castShadow=a.castShadow,m.receiveShadow=a.receiveShadow;const _=()=>{if(Vt.get(e)!==u){c.dispose();return}Vt.delete(e);for(const h of xt.get(e)?.ramps??[])h.dispose();xt.set(e,u.binding),e.needsUpdate=!0,Sn.get(e)?.shadow.dispose(),Sn.set(e,{shadow:c,draws:0}),gt()};n.compileAsync(m,r,o).then(_,_)}const d=xt.get(e);if(!d)return;const l=n.properties.get(e).currentProgram;if(l?.diagnostics?.runnable===!1&&l.cacheKey?.includes(d.compiled.key)){Uo.add(d.compiled.key),xt.delete(e),e.needsUpdate=!0;const c=l.diagnostics.fragmentShader.log.split(`
7038
7038
  `).find(m=>m.startsWith("ERROR"))??"";console.warn(`Blender material "${e.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${c}`);return}const s=to(d.compiled,t);JSON.stringify(s)!==JSON.stringify(d.channels)&&(d.channels=s,e.needsUpdate=!0)}function yi(e){const t=Array.isArray(e.material)?e.material:[e.material];if(!t.some(u=>u instanceof fn&&xt.has(u)))return;const n=e.geometry,o=e.userData.blenderTexspace??null,r=n.getAttribute("position"),a=JSON.stringify([o,r?.version??0,r?.count??0]);!n.userData.blenderOrcoFromDoor&&n.userData.blenderOrcoStamp!==a&&(n.setAttribute("blenderOrco",wi(n,o)),n.userData.blenderOrcoStamp=a);const i=r?.count??0,f=e.userData.blenderDefaultColor;for(const u of t){const d=u instanceof fn?xt.get(u):void 0;for(const l of d?.compiled.attributes??[]){const s=jt(l),c=l===""?f===void 0?void 0:n.getAttribute(jt(f)):n.getAttribute(s);c&&c.count===i?n.getAttribute(s)!==c&&n.setAttribute(s,c):n.getAttribute(s)?.count!==i&&n.setAttribute(s,new ut(new Float32Array(i*4),4))}}}function wi(e,t){const n=e.getAttribute("position");let o,r;if(t)o=[...t[0]],r=[...t[1]];else{e.computeBoundingBox();const i=e.boundingBox;o=[(i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2],r=[(i.max.x-i.min.x)/2,(i.max.y-i.min.y)/2,(i.max.z-i.min.z)/2]}r=r.map(i=>i===0?1:i);const a=new Float32Array(n.count*3);for(let i=0;i<n.count;i++)a[i*3]=(n.getX(i)-o[0])/r[0]*.5+.5,a[i*3+1]=(n.getY(i)-o[1])/r[1]*.5+.5,a[i*3+2]=(n.getZ(i)-o[2])/r[2]*.5+.5;return new ut(a,3)}function Oi(e,t){const n=xt.get(e);if(!n)return;const{compiled:o,channels:r}=n;Object.assign(t.uniforms,n.uniforms,{blenderViewport:{value:qo}});const a=p=>p===0?"uv":`uv${p}`,i=`varying vec3 vBlenderObjectPosition;
7039
7039
  varying vec3 vBlenderObjectNormal;
7040
7040
  varying vec3 vBlenderWorldPosition;
@@ -7076,7 +7076,7 @@ ${h}
7076
7076
  void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
7077
7077
  blenderGraph();`);for(const[p,v,y]of d){if(!g.includes(p))throw new Error(`three's physical shader has no ${p}`);g=g.replace(p,y?`${v}
7078
7078
  ${p}`:`${p}
7079
- ${v}`)}t.fragmentShader=g}const qo=new Kt(1,1);function Ai(e){e.getDrawingBufferSize(qo)}function Ti(e,t){const n=t.userData.blenderUvChannels;for(const o of[e.map,e.roughnessMap,e.normalMap]){if(!o)continue;const r=o.userData.blenderUvName;let a=r?n?.[r]:0;if(a===void 0){a=9;const i=t.getAttribute("position")?.count;if(i===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==i&&t.setAttribute("uv9",new ut(new Float32Array(i*2),2))}o.channel!==a&&(o.channel=a,e.needsUpdate=!0)}}class Si{constructor(){this.bindings=new Map}get(t,n,o,r,a=""){let i=this.bindings.get(t);if(!i||i.source!==n){this.delete(t),i={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,i);const d=i;r&&r.then(()=>{d.disposed||(d.texture.needsUpdate=!0,d.version=n.version,gt())},()=>{})}const f=o==="REPEAT"?ca:o==="MIRROR"?ua:bo,u=i.texture.wrapS!==f||i.texture.wrapT!==f;return i.texture.wrapS=i.texture.wrapT=f,i.texture.userData.blenderUvName=a,n.image&&(u||i.version!==n.version)&&(i.texture.needsUpdate=!0,i.version=n.version),i.texture}delete(t){const n=this.bindings.get(t);n&&(n.disposed=!0,n.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const At=I().finite(),ne=W([At,At,At]),Mi=N({coat:At,coat_roughness:At,coat_ior:At,coat_tint:ne,sheen:At,sheen_roughness:At,sheen_tint:ne,anisotropy:At,anisotropy_rotation:At,specular_level:At,specular_tint:ne,film_thickness:At,film_ior:At}).strict(),Pi={coat:0,coat_roughness:.03,coat_ior:1.5,coat_tint:[1,1,1],sheen:0,sheen_roughness:.5,sheen_tint:[1,1,1],anisotropy:0,anisotropy_rotation:0,specular_level:.5,specular_tint:[1,1,1],film_thickness:0,film_ior:1.33},cn=new WeakMap;function Ei(e,t){cn.has(e)||Pe(e),cn.get(e).blenderWorldExtinction.value.copy(t)}function Ni(e){const t=new fn,n=cn.get(e);Pe(t),t.copy(e);const o=cn.get(t);return n&&(o.blenderCoatIor.value=n.blenderCoatIor.value,o.blenderCoatTint.value.copy(n.blenderCoatTint.value),o.blenderMapClip.value=n.blenderMapClip.value,o.blenderRoughnessClip.value=n.blenderRoughnessClip.value,o.blenderNormalClip.value=n.blenderNormalClip.value,o.blenderWorldExtinction.value.copy(n.blenderWorldExtinction.value)),t}function Pe(e,t,n={}){const o=t??Pi;e.clearcoat=o.coat,e.clearcoatRoughness=o.coat_roughness,e.sheen=o.sheen,e.sheenRoughness=o.sheen_roughness,e.sheenColor.setRGB(...o.sheen_tint,bt),e.anisotropy=o.anisotropy,e.anisotropyRotation=o.anisotropy_rotation*Math.PI*2,e.specularIntensity=o.specular_level*2,e.specularColor.setRGB(...o.specular_tint,bt),e.iridescence=o.film_thickness>0?1:0,e.iridescenceIOR=o.film_ior,e.iridescenceThicknessRange=[o.film_thickness,o.film_thickness];let r=cn.get(e);if(!r){r={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new Tt(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new b}},cn.set(e,r);const a=r;e.customProgramCacheKey=()=>`blender-principled-physical-v5${vi(e)}`,e.onBeforeRender=(i,f,u,d,l)=>{Ti(e,d),bi(e,d,i,f,u,l,Ni),Ai(i)},e.onBeforeCompile=i=>{const f=new Set([e.map,e.roughnessMap,e.normalMap].flatMap(_=>_?[_.channel]:[]).concat(xi(e)));i.vertexShader=[...f].filter(_=>_>0).sort((_,h)=>_-h).map(_=>_<=3?`#ifndef USE_UV${_}
7079
+ ${v}`)}t.fragmentShader=g}const qo=new Kt(1,1);function Ai(e){e.getDrawingBufferSize(qo)}function Ti(e,t){const n=t.userData.blenderUvChannels;for(const o of[e.map,e.roughnessMap,e.normalMap]){if(!o)continue;const r=o.userData.blenderUvName;let a=r?n?.[r]:0;if(a===void 0){a=9;const i=t.getAttribute("position")?.count;if(i===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==i&&t.setAttribute("uv9",new ut(new Float32Array(i*2),2))}o.channel!==a&&(o.channel=a,e.needsUpdate=!0)}}class Si{constructor(){this.bindings=new Map}get(t,n,o,r,a=""){let i=this.bindings.get(t);if(!i||i.source!==n){this.delete(t),i={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,i);const d=i;r&&r.then(()=>{d.disposed||(d.texture.needsUpdate=!0,d.version=n.version,gt())},()=>{})}const f=o==="REPEAT"?ca:o==="MIRROR"?ua:bo,u=i.texture.wrapS!==f||i.texture.wrapT!==f;return i.texture.wrapS=i.texture.wrapT=f,i.texture.userData.blenderUvName=a,n.image&&(u||i.version!==n.version)&&(i.texture.needsUpdate=!0,i.version=n.version),i.texture}delete(t){const n=this.bindings.get(t);n&&(n.disposed=!0,n.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const At=I().finite(),ee=W([At,At,At]),Mi=N({coat:At,coat_roughness:At,coat_ior:At,coat_tint:ee,sheen:At,sheen_roughness:At,sheen_tint:ee,anisotropy:At,anisotropy_rotation:At,specular_level:At,specular_tint:ee,film_thickness:At,film_ior:At}).strict(),Pi={coat:0,coat_roughness:.03,coat_ior:1.5,coat_tint:[1,1,1],sheen:0,sheen_roughness:.5,sheen_tint:[1,1,1],anisotropy:0,anisotropy_rotation:0,specular_level:.5,specular_tint:[1,1,1],film_thickness:0,film_ior:1.33},cn=new WeakMap;function Ei(e,t){cn.has(e)||Pe(e),cn.get(e).blenderWorldExtinction.value.copy(t)}function Ni(e){const t=new fn,n=cn.get(e);Pe(t),t.copy(e);const o=cn.get(t);return n&&(o.blenderCoatIor.value=n.blenderCoatIor.value,o.blenderCoatTint.value.copy(n.blenderCoatTint.value),o.blenderMapClip.value=n.blenderMapClip.value,o.blenderRoughnessClip.value=n.blenderRoughnessClip.value,o.blenderNormalClip.value=n.blenderNormalClip.value,o.blenderWorldExtinction.value.copy(n.blenderWorldExtinction.value)),t}function Pe(e,t,n={}){const o=t??Pi;e.clearcoat=o.coat,e.clearcoatRoughness=o.coat_roughness,e.sheen=o.sheen,e.sheenRoughness=o.sheen_roughness,e.sheenColor.setRGB(...o.sheen_tint,bt),e.anisotropy=o.anisotropy,e.anisotropyRotation=o.anisotropy_rotation*Math.PI*2,e.specularIntensity=o.specular_level*2,e.specularColor.setRGB(...o.specular_tint,bt),e.iridescence=o.film_thickness>0?1:0,e.iridescenceIOR=o.film_ior,e.iridescenceThicknessRange=[o.film_thickness,o.film_thickness];let r=cn.get(e);if(!r){r={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new Tt(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new b}},cn.set(e,r);const a=r;e.customProgramCacheKey=()=>`blender-principled-physical-v5${vi(e)}`,e.onBeforeRender=(i,f,u,d,l)=>{Ti(e,d),bi(e,d,i,f,u,l,Ni),Ai(i)},e.onBeforeCompile=i=>{const f=new Set([e.map,e.roughnessMap,e.normalMap].flatMap(_=>_?[_.channel]:[]).concat(xi(e)));i.vertexShader=[...f].filter(_=>_>0).sort((_,h)=>_-h).map(_=>_<=3?`#ifndef USE_UV${_}
7080
7080
  attribute vec2 uv${_};
7081
7081
  #endif`:`attribute vec2 uv${_};`).join(`
7082
7082
  `)+`
@@ -7097,10 +7097,10 @@ attribute vec2 uv${_};
7097
7097
  float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
7098
7098
  blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
7099
7099
  outgoingLight *= mix(vec3(1.0), pow(max(blenderCoatTint, vec3(0.0)), vec3(coatPath)), material.clearcoat);
7100
- vec3 Fcc = F_Schlick`),Oi(e,i)},e.needsUpdate=!0}r.blenderCoatIor.value=Math.max(1,o.coat_ior),r.blenderCoatTint.value.setRGB(...o.coat_tint,bt),r.blenderMapClip.value=n.map===!0,r.blenderRoughnessClip.value=n.roughness===!0,r.blenderNormalClip.value=n.normal===!0}function Ee(e){const t=r=>{if(!(!r||typeof r!="object")){if("kind"in r&&["direction","window","sky"].includes(String(r.kind)))throw new Error(`World volume spatial input ${r.kind} is not implemented`);for(const a of Object.values(r))t(a)}};t(e);const n=lt(e)(new b);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function tn(e){const t=Ee(e);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function En(e){const t=Ee(e);return(typeof t=="number"?new b().setScalar(t):t.clone()).max(new b)}function Ri(e){if(e<800)return new b(5.413294490189271,0,0);if(e>=12e3)return new b(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(a=>e>=a).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],o=[[-488.999748,.000604330754,-.0755807526],[-755.994277,.000316730098,.478306139],[-1023.63977,.00012022347,.936662319],[-1265.71316,487340896e-14,1.27054498],[-1425.29332,-401150431e-13,1.43972784],[-1175.54822,-216378048e-13,1.30408023],[-500.799571,-459832026e-14,1.09098763]][t],r=[[596945309e-19,-485742887e-16,-970622247e-13,-.00407936148],[240430366e-19,555021075e-16,-.000198503712,.0289312858],[-140949732e-19,189878968e-15,-.000356632824,.0910767778],[-361460868e-19,284822009e-15,-.000493211319,.15672344],[-197075738e-19,175359352e-15,-.000250542825,-.0222783266],[-161997957e-21,-164216008e-16,.000386216271,-.738077418],[672650283e-21,-273078809e-16,.000424098264,-.752335691]][t];return new b(n[0]/e+n[1]*e+n[2],o[0]/e+o[1]*e+o[2],((r[0]*e+r[1])*e+r[2])*e+r[3]).max(new b)}function no(e){if(!e?.volume?.length)return null;const t={extinction:new b,emission:new b,lobes:[]};for(const n of e.volume){const o=tn(n.weight);if(o===0)continue;const r=En(n.color),a=tn(n.density),i=new b,f=new b;if(n.kind==="absorption"&&i.set(1-r.x,1-r.y,1-r.z).max(new b).multiplyScalar(a),n.kind==="scatter"||n.kind==="principled"){f.copy(r).multiplyScalar(a);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const d=Ee(n.anisotropy);if(typeof d!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:f.clone().multiplyScalar(o),g:u==="RAYLEIGH"?0:wt.clamp(d,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?tn(n.alpha):0})}if(n.kind==="principled"){const u=En(n.absorption_color);i.set(Math.max(1-r.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-r.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-r.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(a);const d=tn(n.blackbody_intensity);if(d>.001){const l=tn(n.temperature),s=5670373e-20/Math.PI*(1+d*(l**4-1));t.emission.add(Ri(l).multiply(En(n.blackbody_tint)).multiplyScalar(s*o))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?r:En(n.emission_color)).multiplyScalar(tn(n.emission_strength)*o)),t.extinction.add(i.add(f).multiplyScalar(o))}for(const n of["x","y","z"])if(t.extinction[n]===0&&t.emission[n]>0)throw new Error("Unbounded emissive World volume with zero extinction has divergent radiance");return t}class Ii{constructor(t){this.medium=t,this.target=new ma(1,1,{type:ye,depthBuffer:!1}),this.geometry=new yo(2,2),this.scene=new da,this.camera=new _a}render(t,n,o,r){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const a={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:r.projectionMatrixInverse},cameraWorld:{value:r.matrixWorld},orthographic:{value:r.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let i="",f="",u=0,d=2;o.traverseVisible(m=>{if(!(m instanceof ie||m instanceof se||m instanceof Fn))return;const _=m,h=u++,g=_.getWorldPosition(new b);a[`lp${h}`]={value:g},a[`lc${h}`]={value:_.color.clone().multiplyScalar(_.intensity)},i+=`uniform vec3 lp${h}, lc${h};
7101
- `;let p="1.0",v="1.0";if(_ instanceof se&&(a[`ld${h}`]={value:_.target.getWorldPosition(new b).sub(g).normalize()},a[`cone${h}`]={value:new Kt(Math.cos(_.angle),Math.cos(_.angle*(1-_.penumbra)))},i+=`uniform vec3 ld${h}; uniform vec2 cone${h};
7102
- `,v=`smoothstep(cone${h}.x, max(cone${h}.x+1e-6,cone${h}.y),dot(-L,ld${h}))`),!(_ instanceof Fn)&&_.castShadow&&_.shadow.map){if(++d>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");a[`sm${h}`]={value:_.shadow.map.texture},a[`sx${h}`]={value:_.shadow.matrix},a[`ss${h}`]={value:_.shadow.mapSize},a[`sb${h}`]={value:_.shadow.bias},a[`sn${h}`]={value:_.shadow.camera.near},a[`sf${h}`]={value:_.shadow.camera.far},i+=`uniform sampler2D sm${h}; uniform mat4 sx${h}; uniform vec2 ss${h}; uniform float sb${h},sn${h},sf${h};
7103
- `,p=_ instanceof ie?`getPointShadow(sm${h},ss${h},1.0,sb${h},1.0,sx${h}*vec4(p,1.0),sn${h},sf${h})`:`getShadow(sm${h},ss${h},1.0,sb${h},1.0,sx${h}*vec4(p,1.0))`}if(_ instanceof Fn){const y=new q().extractRotation(_.matrixWorld);a[`lx${h}`]={value:new b(_.width,0,0).applyMatrix4(y)},a[`ly${h}`]={value:new b(0,_.height,0).applyMatrix4(y)},a[`ln${h}`]={value:new b(0,0,-1).transformDirection(y)},i+=`uniform vec3 lx${h},ly${h},ln${h};
7100
+ vec3 Fcc = F_Schlick`),Oi(e,i)},e.needsUpdate=!0}r.blenderCoatIor.value=Math.max(1,o.coat_ior),r.blenderCoatTint.value.setRGB(...o.coat_tint,bt),r.blenderMapClip.value=n.map===!0,r.blenderRoughnessClip.value=n.roughness===!0,r.blenderNormalClip.value=n.normal===!0}function Ee(e){const t=r=>{if(!(!r||typeof r!="object")){if("kind"in r&&["direction","window","sky"].includes(String(r.kind)))throw new Error(`World volume spatial input ${r.kind} is not implemented`);for(const a of Object.values(r))t(a)}};t(e);const n=lt(e)(new b);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function tn(e){const t=Ee(e);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function En(e){const t=Ee(e);return(typeof t=="number"?new b().setScalar(t):t.clone()).max(new b)}function Ri(e){if(e<800)return new b(5.413294490189271,0,0);if(e>=12e3)return new b(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(a=>e>=a).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],o=[[-488.999748,.000604330754,-.0755807526],[-755.994277,.000316730098,.478306139],[-1023.63977,.00012022347,.936662319],[-1265.71316,487340896e-14,1.27054498],[-1425.29332,-401150431e-13,1.43972784],[-1175.54822,-216378048e-13,1.30408023],[-500.799571,-459832026e-14,1.09098763]][t],r=[[596945309e-19,-485742887e-16,-970622247e-13,-.00407936148],[240430366e-19,555021075e-16,-.000198503712,.0289312858],[-140949732e-19,189878968e-15,-.000356632824,.0910767778],[-361460868e-19,284822009e-15,-.000493211319,.15672344],[-197075738e-19,175359352e-15,-.000250542825,-.0222783266],[-161997957e-21,-164216008e-16,.000386216271,-.738077418],[672650283e-21,-273078809e-16,.000424098264,-.752335691]][t];return new b(n[0]/e+n[1]*e+n[2],o[0]/e+o[1]*e+o[2],((r[0]*e+r[1])*e+r[2])*e+r[3]).max(new b)}function no(e){if(!e?.volume?.length)return null;const t={extinction:new b,emission:new b,lobes:[]};for(const n of e.volume){const o=tn(n.weight);if(o===0)continue;const r=En(n.color),a=tn(n.density),i=new b,f=new b;if(n.kind==="absorption"&&i.set(1-r.x,1-r.y,1-r.z).max(new b).multiplyScalar(a),n.kind==="scatter"||n.kind==="principled"){f.copy(r).multiplyScalar(a);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const d=Ee(n.anisotropy);if(typeof d!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:f.clone().multiplyScalar(o),g:u==="RAYLEIGH"?0:wt.clamp(d,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?tn(n.alpha):0})}if(n.kind==="principled"){const u=En(n.absorption_color);i.set(Math.max(1-r.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-r.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-r.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(a);const d=tn(n.blackbody_intensity);if(d>.001){const l=tn(n.temperature),s=5670373e-20/Math.PI*(1+d*(l**4-1));t.emission.add(Ri(l).multiply(En(n.blackbody_tint)).multiplyScalar(s*o))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?r:En(n.emission_color)).multiplyScalar(tn(n.emission_strength)*o)),t.extinction.add(i.add(f).multiplyScalar(o))}for(const n of["x","y","z"])if(t.extinction[n]===0&&t.emission[n]>0)throw new Error("Unbounded emissive World volume with zero extinction has divergent radiance");return t}class Ii{constructor(t){this.medium=t,this.target=new ma(1,1,{type:ye,depthBuffer:!1}),this.geometry=new yo(2,2),this.scene=new da,this.camera=new _a}render(t,n,o,r){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const a={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:r.projectionMatrixInverse},cameraWorld:{value:r.matrixWorld},orthographic:{value:r.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let i="",f="",u=0,d=2;o.traverseVisible(m=>{if(!(m instanceof se||m instanceof le||m instanceof Dn))return;const _=m,h=u++,g=_.getWorldPosition(new b);a[`lp${h}`]={value:g},a[`lc${h}`]={value:_.color.clone().multiplyScalar(_.intensity)},i+=`uniform vec3 lp${h}, lc${h};
7101
+ `;let p="1.0",v="1.0";if(_ instanceof le&&(a[`ld${h}`]={value:_.target.getWorldPosition(new b).sub(g).normalize()},a[`cone${h}`]={value:new Kt(Math.cos(_.angle),Math.cos(_.angle*(1-_.penumbra)))},i+=`uniform vec3 ld${h}; uniform vec2 cone${h};
7102
+ `,v=`smoothstep(cone${h}.x, max(cone${h}.x+1e-6,cone${h}.y),dot(-L,ld${h}))`),!(_ instanceof Dn)&&_.castShadow&&_.shadow.map){if(++d>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");a[`sm${h}`]={value:_.shadow.map.texture},a[`sx${h}`]={value:_.shadow.matrix},a[`ss${h}`]={value:_.shadow.mapSize},a[`sb${h}`]={value:_.shadow.bias},a[`sn${h}`]={value:_.shadow.camera.near},a[`sf${h}`]={value:_.shadow.camera.far},i+=`uniform sampler2D sm${h}; uniform mat4 sx${h}; uniform vec2 ss${h}; uniform float sb${h},sn${h},sf${h};
7103
+ `,p=_ instanceof se?`getPointShadow(sm${h},ss${h},1.0,sb${h},1.0,sx${h}*vec4(p,1.0),sn${h},sf${h})`:`getShadow(sm${h},ss${h},1.0,sb${h},1.0,sx${h}*vec4(p,1.0))`}if(_ instanceof Dn){const y=new q().extractRotation(_.matrixWorld);a[`lx${h}`]={value:new b(_.width,0,0).applyMatrix4(y)},a[`ly${h}`]={value:new b(0,_.height,0).applyMatrix4(y)},a[`ln${h}`]={value:new b(0,0,-1).transformDirection(y)},i+=`uniform vec3 lx${h},ly${h},ln${h};
7104
7104
  `,f+=`for(int ax=0;ax<4;ax++) for(int ay=0;ay<4;ay++) {
7105
7105
  vec3 delta=lp${h}+lx${h}*((float(ax)+.5)/4.-.5)+ly${h}*((float(ay)+.5)/4.-.5)-p;
7106
7106
  float d=length(delta); vec3 L=delta/max(d,1e-6);
@@ -7141,10 +7141,10 @@ attribute vec2 uv${_};
7141
7141
  radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
7142
7142
  }
7143
7143
  gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
7144
- }`}),this.scene.clear(),this.scene.add(new Ft(this.geometry,this.material)),this.target.setSize(n.width,n.height);const c=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(c)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const zi=N({object:z(),group:z(),groupIndex:I().int().nonnegative(),count:I().int().nonnegative(),digest:z(),alertMode:Y(["NONE","ACTIVE","ALL"]),unchanged:X(!0).optional(),weightsBase64:z().optional(),alertBase64:z().optional()}).strict();function Fi(e){const n=e<0?0:e>1?1:e,o=(.5+.5*n)**1.5,[r,a,i]=Di(2/3*(1-n)),f=new Tt;return f.setRGB((r*o)**(1/1.5),(a*o)**(1/1.5),(i*o)**(1/1.5),Bt),f}function Di(e){const t=(e%1+1)%1,n=Math.floor(t*6),o=t*6-n;switch(n%6){case 0:return[1,o,0];case 1:return[1-o,1,0];case 2:return[0,1,o];case 3:return[0,1-o,1];case 4:return[o,0,1];default:return[1,0,1-o]}}const Ci=0;function eo(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}class ki{constructor(){this.group=new ft,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,o){if(t===null||n===null||!n.isMesh||o===null)return this.clear(),this.signature="",null;const r=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==r)return this.clear(),`weights: the session sent a reference to ${r} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${r} carried neither an array nor a reference`;const _=eo(t.weightsBase64);this.held={key:r,weights:new Float32Array(_.buffer,_.byteOffset,t.count),alerts:eo(t.alertBase64)}}const a=this.held;if(a===null)return null;const i=`${r}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${o.elements.join(",")}`;if(i===this.signature&&this.mesh!==null)return null;this.signature=i,this.clear();const f=n.geometry.clone(),u=f.getAttribute("position"),d=f.getAttribute("blenderVertex");if(d===void 0)return f.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const l=new Float32Array(u.count*3),s=new Tt().setHex(Ci,Bt);for(let _=0;_<u.count;_++){const h=d.getX(_),p=t.alertMode!=="NONE"&&a.alerts[h]===1?s:Fi(a.weights[h]??0);l[_*3]=p.r,l[_*3+1]=p.g,l[_*3+2]=p.b}f.setAttribute("color",new ut(l,3)),f.deleteAttribute("blenderVertex");const c=new kn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),m=new Ft(f,c);return m.name=`${t.object}:weights`,m.frustumCulled=!1,m.matrixAutoUpdate=!1,m.matrix.copy(o),m.matrix.decompose(m.position,m.quaternion,m.scale),this.geometry=f,this.material=c,this.mesh=m,this.group.add(m),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const Nn=I().finite(),$i=L(W([Nn,Nn,Nn,Nn])).length(4),Li=20,oo=[16724818,9165824,2658559];function Vi(e){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new Tt().setRGB(t(e>>16&255),t(e>>8&255),t(e&255),Bt)}function Ho(){return new pa({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function ji(){const e=[],t=[],n=new Tt(0,0,0),o=(a,i,f,u,d)=>{for(const l of[a,i]){const s=[0,0,0];s[f]=l*u,e.push(...s),t.push(d.r,d.g,d.b)}};for(let a=0;a<3;a++){const i=new Tt().setHex(oo[a],Bt);o(1,.85,a,1,i),o(.85,.25,a,1,n),o(1,.85,a,-1,Vi(oo[a])),o(.85,.25,a,-1,n)}const r=new un;return r.setAttribute("position",new Nt(e,3)),r.setAttribute("color",new Nt(t,3)),new wo(r,Ho())}function Bi(){const t=[],n=[],o=new Tt(1,0,0),r=new Tt(1,1,1);for(let i=0;i<12;i++){const f=(i+1)%2===0?r:o;for(const u of[i,i+1]){const d=2*Math.PI*u/12;t.push(.5*Math.cos(d),.5*Math.sin(d),0),n.push(f.r,f.g,f.b)}}const a=new un;return a.setAttribute("position",new Nt(t,3)),a.setAttribute("color",new Nt(n,3)),new wo(a,Ho())}class Ui{constructor(){this.group=new ft,this.anchor=new ft,this.lines=ji(),this.circle=Bi(),this.seen=null,this.size=new Kt,this.scratch=new b,this.parentQuat=new Mt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,o)=>this.fit(t,o),this.circle.onBeforeRender=(t,n,o)=>this.fit(t,o)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,o,r,a]=t.rotation;this.anchor.matrix.compose(new b(...t.location),new Mt(o,r,a,n),new b(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const o=Math.max(this.size.y,1),r=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let a;if(n.isOrthographicCamera){const f=n;a=(f.top-f.bottom)/f.zoom/o}else{const f=n;a=2*Math.max(-r.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(f.fov)/2)/f.zoom/o}const i=a*Li;this.lines.scale.setScalar(i),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(i),this.circle.updateMatrixWorld(!0)}placementAt(t,n,o,r,a){const i=this.seen;if(i===null||o!==i.canvas)return null;const f=i.canvas.getBoundingClientRect(),u=new Kt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),d=new ha;d.setFromCamera(u,i.camera);const l=h=>{for(let g=h;g!==null;g=g.parent)if(!g.visible)return!1;return!0},s=d.intersectObject(r,!0).find(h=>h.object.isMesh&&a(h.object)&&l(h.object));let c=s?s.point.clone():null;if(c===null){const h=new b().setFromMatrixPosition(this.anchor.matrixWorld),g=i.camera.getWorldDirection(new b),p=i.camera.getWorldPosition(new b),v=h.clone().sub(p).dot(g);v<=0&&h.addScaledVector(g,-2*v+(v===0?1:0)),c=d.ray.intersectPlane(new Gt().setFromNormalAndCoplanarPoint(g,h),new b)}if(c===null)return null;r.updateWorldMatrix(!0,!1);const m=r.worldToLocal(c),_=r.getWorldQuaternion(new Mt).invert().multiply(i.camera.getWorldQuaternion(new Mt));return{location:[m.x,m.y,m.z],rotation:[_.w,_.x,_.y,_.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Ht=I().finite(),Wi=N({display:Y(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Ht,image:N({name:z().nullable(),offset:W([Ht,Ht]),depth:Y(["DEFAULT","FRONT","BACK"]),side:Y(["DOUBLE_SIDED","FRONT","BACK"]),perspective:at(),orthographic:at(),axis_aligned:at(),opacity:Ht.nullable(),tint:W([Ht,Ht,Ht]).default([1,1,1]),premultiplied:at().default(!1)}).optional()}),It={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},qi=1,it=(e,t,n)=>e.push(t[0],t[1],t[2],n[0],n[1],n[2]);function _t(e,t){return Array.from({length:t},(n,o)=>{const r=2*Math.PI*o/t;return[e*Math.cos(r),e*Math.sin(r)]})}function yt(e,t,n=0,o=!1){const r=o?2:1;for(let a=0;a<Math.floor(t.length/r);a++){const i=t[a*r%t.length],f=t[(a*r+1)%t.length];it(e,[i[0],i[1],n],[f[0],f[1],n])}}function Hi(e){if(!e.isMesh||e.userData.volterOverrideStandDown)return;e.userData.volterOverrideStandDown=!0;const t=e.onBeforeRender.bind(e),n=e.onAfterRender.bind(e),o=new q;let r=!1;e.onBeforeRender=(a,i,f,u,d,l)=>{t(a,i,f,u,d,l),i.overrideMaterial&&(o.copy(e.matrixWorld),e.matrixWorld.makeScale(0,0,0),r=!0)},e.onAfterRender=(a,i,f,u,d,l)=>{r&&(e.matrixWorld.copy(o),r=!1),n(a,i,f,u,d,l)}}class Gi{constructor(){this.cameras=new ft,this.lights=new ft,this.empties=new ft,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new b,this.size=new Kt,this.parentQuat=new Mt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const o of t.objects){const r=o.selected?o.name===t.active?It.active:It.selected:o.type==="CAMERA"?It.camera:o.type==="LIGHT"?It.light:It.empty,a=o.type==="CAMERA"&&o.name!==t.lookingThrough?t.cameras[o.name]:void 0,i=o.type==="LIGHT"&&o.light?t.lights[o.light]:void 0,f=o.type==="EMPTY"?t.empties[o.name]:void 0;if(!a&&!i&&!f)continue;n.add(o.name);const u=i&&o.light?t.lightDistances[o.light]??null:null,d=f?.image?.name?t.image(f.image.name):null,l=JSON.stringify([d?[d.texture.uuid,d.width,d.height]:null,o.matrix,r,a,i,u,f,a?[o.name===t.sceneCamera,t.renderAspect]:null]),s=this.drawn.get(o.name),c=t.presented(o.name);if(s?.key===l){for(const p of s.parts)p.userData.volterPicksAs=c;continue}s&&this.remove(s.parts);const m=new q().set(...o.matrix.flat()),_=a?this.cameras:i?this.lights:this.empties,h=new Set(_.children);a?this.camera(a,m,r,o.name===t.sceneCamera,t.renderAspect):i?this.light(i,m,r,u):f&&this.empty(f,m,r,d);const g=_.children.filter(p=>!h.has(p));for(const p of g)p.userData.volterPicksAs=c,p.traverse(Hi);this.drawn.set(o.name,{key:l,parts:g})}for(const[o,r]of this.drawn)n.has(o)||(this.remove(r.parts),this.drawn.delete(o))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,o,r,a){const i=t.display_size,u=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let d,l,s,c;if(t.type==="ORTHO")s=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],c=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],l=-i,d=.5*t.ortho_scale;else{const T=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new b().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;d=i/2/((1/O.x+1/O.y+1/O.z)/3),l=d*t.lens/-T,s=[d*u[0],d*u[1]],c=[t.shift_x*d*2,t.shift_y*d*2]}const m=[[c[0]+s[0],c[1]+s[1],l],[c[0]+s[0],c[1]-s[1],l],[c[0]-s[0],c[1]-s[1],l],[c[0]-s[0],c[1]+s[1],l]],_=[];for(let T=0;T<4;T++)it(_,m[T],m[(T+1)%4]),it(_,m[T],[0,0,0]);const h=.7*d,g=.1*d,p=c[1]+s[1]+g,v=[[c[0]-h,p,l],[c[0]+h,p,l],[c[0],p+h,l]],y=ee(n);this.cameras.add(this.lines(_,o,1,y));let w;if(r){const T=new un;T.setAttribute("position",new Nt(v.flat(),3)),w=new Ft(T,this.fill(o)),w.matrixAutoUpdate=!1,w.matrix.copy(y)}else{const T=[];for(let O=0;O<3;O++)it(T,v[O],v[(O+1)%3]);w=this.lines(T,o,1,y)}const P=new b,S=w.onBeforeRender.bind(w);w.onBeforeRender=(T,O,R,$,j,H)=>{P.setFromMatrixPosition(y).applyMatrix4(this.cameras.matrixWorld);const tt=R.getWorldPosition(this.scratch).distanceToSquared(P)>1e-8;w.matrix.copy(y),tt||w.matrix.scale(new b(0,0,0)),w.updateMatrixWorld(!0),S(T,O,R,$,j,H)},this.cameras.add(w)}light(t,n,o,r){const a=new b().setFromMatrixPosition(n),i=[];it(i,[a.x,a.y,a.z],[a.x,a.y,0]),this.lights.add(this.lines(i,It.light,It.lightAlpha,new q));const f=[];yt(f,_t(1.35,4)),this.lights.add(this.screen(f,It.light,It.lightAlpha,new b(a.x,a.y,0)));const u=[],d=9;if(yt(u,_t(d*.3,4)),yt(u,_t(d,16),0,!0),yt(u,_t(d*1.33,20),0,!0),t.type==="SUN")for(const[c,m]of _t(d,8))it(u,[c*1.6,m*1.6,0],[c*1.9,m*1.9,0]),it(u,[c*2.2,m*2.2,0],[c*2.5,m*2.5,0]);this.lights.add(this.screen(u,o,1,a));const l=ee(n),s=[];if(t.type==="SUN")it(s,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const c=(t.size??1)/2,m=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?yt(s,_t(1,32).map(([_,h])=>[_*c,h*m])):yt(s,[[c,m],[-c,m],[-c,-m],[c,-m]])}if(s.length>0&&this.lights.add(this.lines(s,o,1,n.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const c=new b(0,0,-1).transformDirection(n),m=p=>a.clone().addScaledVector(c,p),[_,h]=r,g=[];it(g,m(_).toArray(),m(h).toArray()),this.lights.add(this.lines(g,o,1,new q));for(const p of[_,h]){const v=[];yt(v,_t(1.2,4)),this.lights.add(this.screen(v,o,1,m(p)))}}if(t.type==="SPOT"){const c=(t.spot_size??Math.PI/4)/2,m=Math.cos(c),_=t.spot_blend??.15,h=m*_-m-_,g=Math.sqrt((m*m-m*m*h*h)/(h*h-m*m*h*h)),p=Math.sqrt(1-m*m),v=ee(n).multiply(new q().makeScale(10,10,10)),y=[];yt(y,_t(p,32),-m),yt(y,_t(p*g,32),-m),this.lights.add(this.lines(y,o,1,v.clone())),this.lights.add(this.silhouette(p,m,o,v))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const c=[];yt(c,_t(t.radius,32)),this.lights.add(this.facing(c,o,new b().setFromMatrixPosition(l)))}}empty(t,n,o,r){const a=t.size,i=[],f=(d,l)=>{const s=_t(1,l);for(let c=0;c<l;c++){const[m,_]=s[c],[h,g]=s[(c+1)%l],p=(v,y)=>d==="xy"?[v,y,0]:d==="xz"?[v,0,y]:[0,v,y];it(i,p(m,_),p(h,g))}};switch(t.display){case"PLAIN_AXES":it(i,[0,-1,0],[0,1,0]),it(i,[-1,0,0],[1,0,0]),it(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{it(i,[0,0,0],[0,0,.75]);for(const[d,l]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])it(i,[0,0,1],[d,l,.75]);yt(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[d,l]of Xi)it(i,ao[d],ao[l]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const d=_t(1,8);for(let l=0;l<8;l++){const[s,c]=d[l],[m,_]=d[(l+1)%8];it(i,[s,0,c],[0,2,0]),it(i,[s,0,c],[m,0,_])}break}case"ARROWS":for(let d=0;d<3;d++){const l=[0,0,0];l[d]=1,it(i,[0,0,0],l)}break;case"IMAGE":this.imageEmpty(t,n,o,r);return}const u=n.clone().multiply(new q().makeScale(a,a,a));this.empties.add(this.lines(i,o,1,u)),t.display==="ARROWS"&&this.axisNames(n,a,o)}silhouette(t,n,o,r){const a=this.lines(new Array(192).fill(0),o,1,r);a.frustumCulled=!1;const i=a.geometry.getAttribute("instanceStart").data,f=_t(1,32).map(([m,_])=>new b(m*t,_*t,-n)),u=new b,d=new q,l=new b,s=new b,c=new b;return this.onDraw(a,(m,_)=>{d.copy(a.matrixWorld).invert();const h=_.isOrthographicCamera;h?_.getWorldDirection(u).negate().transformDirection(d):u.setFromMatrixPosition(_.matrixWorld).applyMatrix4(d);const g=i.array;let p=!1;for(let v=0;v<32;v++){const y=f[v];l.crossVectors(y,f[(v+31)%32]),s.crossVectors(f[(v+1)%32],y),h?c.copy(u):c.copy(u).sub(y);const w=l.dot(c)>0!=s.dot(c)>0;(g[v*6+3]!==0||g[v*6+5]!==0)!==w&&(p=!0),g.set([0,0,0,w?y.x:0,w?y.y:0,w?y.z:0],v*6)}p&&(i.needsUpdate=!0,gt())}),a}imageEmpty(t,n,o,r){const a=t.image;if(!a)return;const i=r?.width??0,f=r?.height??0,u=i>0&&f>0?i>=f?[1,f/i]:[i/f,1]:[1,1],d=new b,l=new b,s=new b;n.extractBasis(d,l,s),d.multiplyScalar(u[0]*.5*t.size),l.multiplyScalar(u[1]*.5*t.size);const c=new b().setFromMatrixPosition(n).addScaledVector(d,a.offset[0]*2+1).addScaledVector(l,a.offset[1]*2+1),m=new q().makeBasis(d,l,s.clone()).setPosition(c),_=[];yt(_,[[-1,-1],[1,-1],[1,1],[-1,1]]);const h=this.lines(_,o,1,m),g=s.clone().normalize(),p=new b,v=new b,y=(R,$)=>{const j=R.isOrthographicCamera===!0;if(j?!a.orthographic:!a.perspective)return!1;if(!$)return!0;const H=g.clone().transformDirection(this.empties.matrixWorld);R.getWorldDirection(v);let tt,Z;if(j)tt=H.dot(v.clone().negate()),Z=1e-5;else{const et=c.clone().applyMatrix4(this.empties.matrixWorld);tt=H.dot(p.setFromMatrixPosition(R.matrixWorld).sub(et)),Z=0}return!(a.side==="FRONT"&&tt<Z||a.side==="BACK"&&tt>-Z||a.axis_aligned&&H.clone().projectOnPlane(v).lengthSq()>1e-5)},w=(R,$)=>{const j=R.onBeforeRender.bind(R);R.onBeforeRender=(H,tt,Z,et,x,E)=>{R.matrix.copy(m),y(Z,$)||R.matrix.scale(new b(0,0,0)),R.updateMatrixWorld(!0),j(H,tt,Z,et,x,E)}};if(w(h,!1),this.empties.add(h),!r||a.opacity!==null&&a.opacity<=0)return;const P=a.opacity!==null,S=a.depth==="BACK",T=new kn({map:r.texture,side:le,transparent:P&&!S,opacity:a.opacity??1,alphaTest:P?0:.05,toneMapped:!1,depthTest:a.depth==="DEFAULT",depthWrite:a.depth==="DEFAULT"&&!P});T.color.setRGB(...a.tint,bt),P&&S&&(T.blending=ga,T.blendSrc=va,T.blendDst=xa),T.onBeforeCompile=R=>{const $=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
7144
+ }`}),this.scene.clear(),this.scene.add(new Dt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const c=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(c)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const zi=N({object:z(),group:z(),groupIndex:I().int().nonnegative(),count:I().int().nonnegative(),digest:z(),alertMode:Y(["NONE","ACTIVE","ALL"]),unchanged:X(!0).optional(),weightsBase64:z().optional(),alertBase64:z().optional()}).strict();function Di(e){const n=e<0?0:e>1?1:e,o=(.5+.5*n)**1.5,[r,a,i]=Fi(2/3*(1-n)),f=new Tt;return f.setRGB((r*o)**(1/1.5),(a*o)**(1/1.5),(i*o)**(1/1.5),Bt),f}function Fi(e){const t=(e%1+1)%1,n=Math.floor(t*6),o=t*6-n;switch(n%6){case 0:return[1,o,0];case 1:return[1-o,1,0];case 2:return[0,1,o];case 3:return[0,1-o,1];case 4:return[o,0,1];default:return[1,0,1-o]}}const Ci=0;function eo(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}class ki{constructor(){this.group=new ft,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,o){if(t===null||n===null||!n.isMesh||o===null)return this.clear(),this.signature="",null;const r=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==r)return this.clear(),`weights: the session sent a reference to ${r} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${r} carried neither an array nor a reference`;const _=eo(t.weightsBase64);this.held={key:r,weights:new Float32Array(_.buffer,_.byteOffset,t.count),alerts:eo(t.alertBase64)}}const a=this.held;if(a===null)return null;const i=`${r}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${o.elements.join(",")}`;if(i===this.signature&&this.mesh!==null)return null;this.signature=i,this.clear();const f=n.geometry.clone(),u=f.getAttribute("position"),d=f.getAttribute("blenderVertex");if(d===void 0)return f.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const l=new Float32Array(u.count*3),s=new Tt().setHex(Ci,Bt);for(let _=0;_<u.count;_++){const h=d.getX(_),p=t.alertMode!=="NONE"&&a.alerts[h]===1?s:Di(a.weights[h]??0);l[_*3]=p.r,l[_*3+1]=p.g,l[_*3+2]=p.b}f.setAttribute("color",new ut(l,3)),f.deleteAttribute("blenderVertex");const c=new kn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),m=new Dt(f,c);return m.name=`${t.object}:weights`,m.frustumCulled=!1,m.matrixAutoUpdate=!1,m.matrix.copy(o),m.matrix.decompose(m.position,m.quaternion,m.scale),this.geometry=f,this.material=c,this.mesh=m,this.group.add(m),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const Nn=I().finite(),$i=L(W([Nn,Nn,Nn,Nn])).length(4),Li=20,oo=[16724818,9165824,2658559];function Vi(e){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new Tt().setRGB(t(e>>16&255),t(e>>8&255),t(e&255),Bt)}function Ho(){return new pa({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function ji(){const e=[],t=[],n=new Tt(0,0,0),o=(a,i,f,u,d)=>{for(const l of[a,i]){const s=[0,0,0];s[f]=l*u,e.push(...s),t.push(d.r,d.g,d.b)}};for(let a=0;a<3;a++){const i=new Tt().setHex(oo[a],Bt);o(1,.85,a,1,i),o(.85,.25,a,1,n),o(1,.85,a,-1,Vi(oo[a])),o(.85,.25,a,-1,n)}const r=new un;return r.setAttribute("position",new Nt(e,3)),r.setAttribute("color",new Nt(t,3)),new wo(r,Ho())}function Bi(){const t=[],n=[],o=new Tt(1,0,0),r=new Tt(1,1,1);for(let i=0;i<12;i++){const f=(i+1)%2===0?r:o;for(const u of[i,i+1]){const d=2*Math.PI*u/12;t.push(.5*Math.cos(d),.5*Math.sin(d),0),n.push(f.r,f.g,f.b)}}const a=new un;return a.setAttribute("position",new Nt(t,3)),a.setAttribute("color",new Nt(n,3)),new wo(a,Ho())}class Ui{constructor(){this.group=new ft,this.anchor=new ft,this.lines=ji(),this.circle=Bi(),this.seen=null,this.size=new Kt,this.scratch=new b,this.parentQuat=new Mt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,o)=>this.fit(t,o),this.circle.onBeforeRender=(t,n,o)=>this.fit(t,o)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,o,r,a]=t.rotation;this.anchor.matrix.compose(new b(...t.location),new Mt(o,r,a,n),new b(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const o=Math.max(this.size.y,1),r=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let a;if(n.isOrthographicCamera){const f=n;a=(f.top-f.bottom)/f.zoom/o}else{const f=n;a=2*Math.max(-r.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(f.fov)/2)/f.zoom/o}const i=a*Li;this.lines.scale.setScalar(i),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(i),this.circle.updateMatrixWorld(!0)}placementAt(t,n,o,r,a){const i=this.seen;if(i===null||o!==i.canvas)return null;const f=i.canvas.getBoundingClientRect(),u=new Kt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),d=new ha;d.setFromCamera(u,i.camera);const l=h=>{for(let g=h;g!==null;g=g.parent)if(!g.visible)return!1;return!0},s=d.intersectObject(r,!0).find(h=>h.object.isMesh&&a(h.object)&&l(h.object));let c=s?s.point.clone():null;if(c===null){const h=new b().setFromMatrixPosition(this.anchor.matrixWorld),g=i.camera.getWorldDirection(new b),p=i.camera.getWorldPosition(new b),v=h.clone().sub(p).dot(g);v<=0&&h.addScaledVector(g,-2*v+(v===0?1:0)),c=d.ray.intersectPlane(new Gt().setFromNormalAndCoplanarPoint(g,h),new b)}if(c===null)return null;r.updateWorldMatrix(!0,!1);const m=r.worldToLocal(c),_=r.getWorldQuaternion(new Mt).invert().multiply(i.camera.getWorldQuaternion(new Mt));return{location:[m.x,m.y,m.z],rotation:[_.w,_.x,_.y,_.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Ht=I().finite(),Wi=N({display:Y(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Ht,image:N({name:z().nullable(),offset:W([Ht,Ht]),depth:Y(["DEFAULT","FRONT","BACK"]),side:Y(["DOUBLE_SIDED","FRONT","BACK"]),perspective:at(),orthographic:at(),axis_aligned:at(),opacity:Ht.nullable(),tint:W([Ht,Ht,Ht]).default([1,1,1]),premultiplied:at().default(!1)}).optional()}),It={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},qi=1,it=(e,t,n)=>e.push(t[0],t[1],t[2],n[0],n[1],n[2]);function _t(e,t){return Array.from({length:t},(n,o)=>{const r=2*Math.PI*o/t;return[e*Math.cos(r),e*Math.sin(r)]})}function yt(e,t,n=0,o=!1){const r=o?2:1;for(let a=0;a<Math.floor(t.length/r);a++){const i=t[a*r%t.length],f=t[(a*r+1)%t.length];it(e,[i[0],i[1],n],[f[0],f[1],n])}}function Hi(e){if(!e.isMesh||e.userData.volterOverrideStandDown)return;e.userData.volterOverrideStandDown=!0;const t=e.onBeforeRender.bind(e),n=e.onAfterRender.bind(e),o=new q;let r=!1;e.onBeforeRender=(a,i,f,u,d,l)=>{t(a,i,f,u,d,l),i.overrideMaterial&&(o.copy(e.matrixWorld),e.matrixWorld.makeScale(0,0,0),r=!0)},e.onAfterRender=(a,i,f,u,d,l)=>{r&&(e.matrixWorld.copy(o),r=!1),n(a,i,f,u,d,l)}}class Gi{constructor(){this.cameras=new ft,this.lights=new ft,this.empties=new ft,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new b,this.size=new Kt,this.parentQuat=new Mt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const o of t.objects){const r=o.selected?o.name===t.active?It.active:It.selected:o.type==="CAMERA"?It.camera:o.type==="LIGHT"?It.light:It.empty,a=o.type==="CAMERA"&&o.name!==t.lookingThrough?t.cameras[o.name]:void 0,i=o.type==="LIGHT"&&o.light?t.lights[o.light]:void 0,f=o.type==="EMPTY"?t.empties[o.name]:void 0;if(!a&&!i&&!f)continue;n.add(o.name);const u=i&&o.light?t.lightDistances[o.light]??null:null,d=f?.image?.name?t.image(f.image.name):null,l=JSON.stringify([d?[d.texture.uuid,d.width,d.height]:null,o.matrix,r,a,i,u,f,a?[o.name===t.sceneCamera,t.renderAspect]:null]),s=this.drawn.get(o.name),c=t.presented(o.name);if(s?.key===l){for(const p of s.parts)p.userData.volterPicksAs=c;continue}s&&this.remove(s.parts);const m=new q().set(...o.matrix.flat()),_=a?this.cameras:i?this.lights:this.empties,h=new Set(_.children);a?this.camera(a,m,r,o.name===t.sceneCamera,t.renderAspect):i?this.light(i,m,r,u):f&&this.empty(f,m,r,d);const g=_.children.filter(p=>!h.has(p));for(const p of g)p.userData.volterPicksAs=c,p.traverse(Hi);this.drawn.set(o.name,{key:l,parts:g})}for(const[o,r]of this.drawn)n.has(o)||(this.remove(r.parts),this.drawn.delete(o))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,o,r,a){const i=t.display_size,u=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let d,l,s,c;if(t.type==="ORTHO")s=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],c=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],l=-i,d=.5*t.ortho_scale;else{const T=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new b().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;d=i/2/((1/O.x+1/O.y+1/O.z)/3),l=d*t.lens/-T,s=[d*u[0],d*u[1]],c=[t.shift_x*d*2,t.shift_y*d*2]}const m=[[c[0]+s[0],c[1]+s[1],l],[c[0]+s[0],c[1]-s[1],l],[c[0]-s[0],c[1]-s[1],l],[c[0]-s[0],c[1]+s[1],l]],_=[];for(let T=0;T<4;T++)it(_,m[T],m[(T+1)%4]),it(_,m[T],[0,0,0]);const h=.7*d,g=.1*d,p=c[1]+s[1]+g,v=[[c[0]-h,p,l],[c[0]+h,p,l],[c[0],p+h,l]],y=oe(n);this.cameras.add(this.lines(_,o,1,y));let w;if(r){const T=new un;T.setAttribute("position",new Nt(v.flat(),3)),w=new Dt(T,this.fill(o)),w.matrixAutoUpdate=!1,w.matrix.copy(y)}else{const T=[];for(let O=0;O<3;O++)it(T,v[O],v[(O+1)%3]);w=this.lines(T,o,1,y)}const P=new b,S=w.onBeforeRender.bind(w);w.onBeforeRender=(T,O,R,$,j,H)=>{P.setFromMatrixPosition(y).applyMatrix4(this.cameras.matrixWorld);const tt=R.getWorldPosition(this.scratch).distanceToSquared(P)>1e-8;w.matrix.copy(y),tt||w.matrix.scale(new b(0,0,0)),w.updateMatrixWorld(!0),S(T,O,R,$,j,H)},this.cameras.add(w)}light(t,n,o,r){const a=new b().setFromMatrixPosition(n),i=[];it(i,[a.x,a.y,a.z],[a.x,a.y,0]),this.lights.add(this.lines(i,It.light,It.lightAlpha,new q));const f=[];yt(f,_t(1.35,4)),this.lights.add(this.screen(f,It.light,It.lightAlpha,new b(a.x,a.y,0)));const u=[],d=9;if(yt(u,_t(d*.3,4)),yt(u,_t(d,16),0,!0),yt(u,_t(d*1.33,20),0,!0),t.type==="SUN")for(const[c,m]of _t(d,8))it(u,[c*1.6,m*1.6,0],[c*1.9,m*1.9,0]),it(u,[c*2.2,m*2.2,0],[c*2.5,m*2.5,0]);this.lights.add(this.screen(u,o,1,a));const l=oe(n),s=[];if(t.type==="SUN")it(s,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const c=(t.size??1)/2,m=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?yt(s,_t(1,32).map(([_,h])=>[_*c,h*m])):yt(s,[[c,m],[-c,m],[-c,-m],[c,-m]])}if(s.length>0&&this.lights.add(this.lines(s,o,1,n.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const c=new b(0,0,-1).transformDirection(n),m=p=>a.clone().addScaledVector(c,p),[_,h]=r,g=[];it(g,m(_).toArray(),m(h).toArray()),this.lights.add(this.lines(g,o,1,new q));for(const p of[_,h]){const v=[];yt(v,_t(1.2,4)),this.lights.add(this.screen(v,o,1,m(p)))}}if(t.type==="SPOT"){const c=(t.spot_size??Math.PI/4)/2,m=Math.cos(c),_=t.spot_blend??.15,h=m*_-m-_,g=Math.sqrt((m*m-m*m*h*h)/(h*h-m*m*h*h)),p=Math.sqrt(1-m*m),v=oe(n).multiply(new q().makeScale(10,10,10)),y=[];yt(y,_t(p,32),-m),yt(y,_t(p*g,32),-m),this.lights.add(this.lines(y,o,1,v.clone())),this.lights.add(this.silhouette(p,m,o,v))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const c=[];yt(c,_t(t.radius,32)),this.lights.add(this.facing(c,o,new b().setFromMatrixPosition(l)))}}empty(t,n,o,r){const a=t.size,i=[],f=(d,l)=>{const s=_t(1,l);for(let c=0;c<l;c++){const[m,_]=s[c],[h,g]=s[(c+1)%l],p=(v,y)=>d==="xy"?[v,y,0]:d==="xz"?[v,0,y]:[0,v,y];it(i,p(m,_),p(h,g))}};switch(t.display){case"PLAIN_AXES":it(i,[0,-1,0],[0,1,0]),it(i,[-1,0,0],[1,0,0]),it(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{it(i,[0,0,0],[0,0,.75]);for(const[d,l]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])it(i,[0,0,1],[d,l,.75]);yt(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[d,l]of Xi)it(i,ao[d],ao[l]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const d=_t(1,8);for(let l=0;l<8;l++){const[s,c]=d[l],[m,_]=d[(l+1)%8];it(i,[s,0,c],[0,2,0]),it(i,[s,0,c],[m,0,_])}break}case"ARROWS":for(let d=0;d<3;d++){const l=[0,0,0];l[d]=1,it(i,[0,0,0],l)}break;case"IMAGE":this.imageEmpty(t,n,o,r);return}const u=n.clone().multiply(new q().makeScale(a,a,a));this.empties.add(this.lines(i,o,1,u)),t.display==="ARROWS"&&this.axisNames(n,a,o)}silhouette(t,n,o,r){const a=this.lines(new Array(192).fill(0),o,1,r);a.frustumCulled=!1;const i=a.geometry.getAttribute("instanceStart").data,f=_t(1,32).map(([m,_])=>new b(m*t,_*t,-n)),u=new b,d=new q,l=new b,s=new b,c=new b;return this.onDraw(a,(m,_)=>{d.copy(a.matrixWorld).invert();const h=_.isOrthographicCamera;h?_.getWorldDirection(u).negate().transformDirection(d):u.setFromMatrixPosition(_.matrixWorld).applyMatrix4(d);const g=i.array;let p=!1;for(let v=0;v<32;v++){const y=f[v];l.crossVectors(y,f[(v+31)%32]),s.crossVectors(f[(v+1)%32],y),h?c.copy(u):c.copy(u).sub(y);const w=l.dot(c)>0!=s.dot(c)>0;(g[v*6+3]!==0||g[v*6+5]!==0)!==w&&(p=!0),g.set([0,0,0,w?y.x:0,w?y.y:0,w?y.z:0],v*6)}p&&(i.needsUpdate=!0,gt())}),a}imageEmpty(t,n,o,r){const a=t.image;if(!a)return;const i=r?.width??0,f=r?.height??0,u=i>0&&f>0?i>=f?[1,f/i]:[i/f,1]:[1,1],d=new b,l=new b,s=new b;n.extractBasis(d,l,s),d.multiplyScalar(u[0]*.5*t.size),l.multiplyScalar(u[1]*.5*t.size);const c=new b().setFromMatrixPosition(n).addScaledVector(d,a.offset[0]*2+1).addScaledVector(l,a.offset[1]*2+1),m=new q().makeBasis(d,l,s.clone()).setPosition(c),_=[];yt(_,[[-1,-1],[1,-1],[1,1],[-1,1]]);const h=this.lines(_,o,1,m),g=s.clone().normalize(),p=new b,v=new b,y=(R,$)=>{const j=R.isOrthographicCamera===!0;if(j?!a.orthographic:!a.perspective)return!1;if(!$)return!0;const H=g.clone().transformDirection(this.empties.matrixWorld);R.getWorldDirection(v);let tt,Z;if(j)tt=H.dot(v.clone().negate()),Z=1e-5;else{const et=c.clone().applyMatrix4(this.empties.matrixWorld);tt=H.dot(p.setFromMatrixPosition(R.matrixWorld).sub(et)),Z=0}return!(a.side==="FRONT"&&tt<Z||a.side==="BACK"&&tt>-Z||a.axis_aligned&&H.clone().projectOnPlane(v).lengthSq()>1e-5)},w=(R,$)=>{const j=R.onBeforeRender.bind(R);R.onBeforeRender=(H,tt,Z,et,x,E)=>{R.matrix.copy(m),y(Z,$)||R.matrix.scale(new b(0,0,0)),R.updateMatrixWorld(!0),j(H,tt,Z,et,x,E)}};if(w(h,!1),this.empties.add(h),!r||a.opacity!==null&&a.opacity<=0)return;const P=a.opacity!==null,S=a.depth==="BACK",T=new kn({map:r.texture,side:$n,transparent:P&&!S,opacity:a.opacity??1,alphaTest:P?0:.05,toneMapped:!1,depthTest:a.depth==="DEFAULT",depthWrite:a.depth==="DEFAULT"&&!P});T.color.setRGB(...a.tint,bt),P&&S&&(T.blending=ga,T.blendSrc=va,T.blendDst=xa),T.onBeforeCompile=R=>{const $=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
7145
7145
  `:"";R.fragmentShader=R.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
7146
7146
  ${$}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",P?"#include <alphatest_fragment>":`#include <alphatest_fragment>
7147
- diffuseColor.a = 1.0;`)},T.customProgramCacheKey=()=>`volter-blender-image:${a.premultiplied}:${P}`;const O=new Ft(new yo(2,2),T);O.matrixAutoUpdate=!1,O.matrix.copy(m),O.renderOrder=a.depth==="FRONT"?1e3:a.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,w(O,!0),this.empties.add(O)}axisNames(t,n,o){const r=[new b,new b,new b];t.extractBasis(r[0],r[1],r[2]);for(let a=0;a<3;a++){const i=r[a].length()*n,f=new b(0,0,0);f.setComponent(a,1.25*n),f.applyMatrix4(t);const u=new b(0,0,0);u.setComponent(a,n),u.applyMatrix4(t);const d=[];for(let c=1;c<=6;c++)yt(d,_t(.007*(4*c/6)*i,4));this.empties.add(this.facing(d,o,u));const l=Yi[a],s=[];for(let c=0;c+1<l.length;c+=2){const[m,_]=l[c],[h,g]=l[c+1];it(s,[m*4*i,_*4*i,0],[h*4*i,g*4*i,0])}this.empties.add(this.facing(s,o,f))}}material(t,n){const o=`${t}:${n}`;let r=this.lineMaterials.get(o);return r||(r=new _o({color:t,linewidth:qi,transparent:n<1,opacity:n,depthTest:!0,depthWrite:n>=1,toneMapped:!1}),this.lineMaterials.set(o,r)),r}fill(t){let n=this.fillMaterials.get(t);return n||(n=new kn({color:t,side:le,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,o,r){const a=new mo().setPositions(t),i=new ho(a,this.material(n,o));return i.matrixAutoUpdate=!1,i.matrix.copy(r),i.computeLineDistances(),i}screen(t,n,o,r){const a=this.lines(t,n,o,new q);return a.matrixAutoUpdate=!0,a.position.copy(r),a.scale.setScalar(0),a.frustumCulled=!1,this.onDraw(a,(i,f)=>this.face(a,i,f,!0)),a}facing(t,n,o){const r=this.lines(t,n,1,new q);return r.matrixAutoUpdate=!0,r.position.copy(o),this.onDraw(r,(a,i)=>this.face(r,a,i,!1)),r}onDraw(t,n){const o=t,r=o.onBeforeRender.bind(o);o.onBeforeRender=(a,i,f,u,d,l)=>{n(a,f),r(a,i,f,u,d,l)}}face(t,n,o,r){t.parent?.getWorldQuaternion(this.parentQuat).invert(),o.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let a=1;if(r){n.getSize(this.size);const i=Math.max(this.size.y,1),f=this.scratch.setFromMatrixPosition(t.matrixWorld);if(o.isOrthographicCamera){const u=o;a=(u.top-u.bottom)/u.zoom/i}else{const u=o;a=2*Math.max(-f.applyMatrix4(o.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(u.fov)/2)/u.zoom/i}}t.scale.setScalar(a),t.updateMatrixWorld(!0)}dispose(){for(const t of this.drawn.values())this.remove(t.parts);this.drawn.clear();for(const t of this.lineMaterials.values())t.dispose();for(const t of this.fillMaterials.values())t.dispose();this.lineMaterials.clear(),this.fillMaterials.clear()}}function ee(e){const t=new b,n=new Mt;return e.decompose(t,n,new b),new q().compose(t,n,new b(1,1,1))}const ao=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],Xi=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Yi=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([e,t])=>[e*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([e,t])=>[e*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([e,t])=>[e*.02,t*.025])],ht=I().finite(),ro=N({name:z(),type:z(),lens:ht,sensor_width:ht,sensor_height:ht,sensor_fit:Y(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:ht,clip_start:ht,clip_end:ht,shift_x:ht,shift_y:ht,matrix:L(W([ht,ht,ht,ht])).length(4),passepartout:ht.default(0),display_size:ht.default(1)}),Zi={opening:.5,min:.1657359312880715,max:44.98528137423857},Rn={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function Qi(e,t,n,o){const r=a=>Math.min(1,Math.max(-1,a));return[r(e[0]-n/(2*t)),r(e[1]+o/(2*t))]}function io(e,t,n,o){const r=e.type==="ORTHO",a=e.sensor_fit==="VERTICAL"?e.sensor_height:e.sensor_width,i=e.sensor_fit==="AUTO"?t>=n:e.sensor_fit==="HORIZONTAL",f=(r?e.ortho_scale:a/e.lens)/2*o;return i?[f,f*n/t]:[f*t/n,f]}function Ki(e,t,n,o,r,a){const i=Math.max(n.width,1),f=Math.max(n.height,1),[u,d]=io(e,i,f,1/o),[l,s]=io(e,a,1,1),m=2*((e.sensor_fit==="AUTO"?a>=1:e.sensor_fit==="HORIZONTAL")?l:s),_=l/u,h=s/d,g=-2*r[0]*o,p=2*r[1]*o,v=e.shift_x*m-g*2*u,y=e.shift_y*m+p*2*d,w=new q().set(...e.matrix.flat()).premultiply(t),P=new b,S=new Mt;return w.decompose(P,S,new b),{name:e.name,position:P.toArray(),quaternion:[S.x,S.y,S.z,S.w],projection:e.type==="ORTHO"?"orthographic":"perspective",window:{left:v-u,right:v+u,top:y+d,bottom:y-d},near:e.clip_start,far:e.clip_end,frame:{left:.5-_/2+g,top:.5-h/2+p,width:_,height:h},passepartout:{color:Rn.passepartout,opacity:e.passepartout},border:{solid:Rn.back,dashed:Rn.overlay,locked:Rn.redalert}}}const Ji={color:[.8,.8,.8,1],roughness:.5,metallic:0},ts=`
7147
+ diffuseColor.a = 1.0;`)},T.customProgramCacheKey=()=>`volter-blender-image:${a.premultiplied}:${P}`;const O=new Dt(new yo(2,2),T);O.matrixAutoUpdate=!1,O.matrix.copy(m),O.renderOrder=a.depth==="FRONT"?1e3:a.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,w(O,!0),this.empties.add(O)}axisNames(t,n,o){const r=[new b,new b,new b];t.extractBasis(r[0],r[1],r[2]);for(let a=0;a<3;a++){const i=r[a].length()*n,f=new b(0,0,0);f.setComponent(a,1.25*n),f.applyMatrix4(t);const u=new b(0,0,0);u.setComponent(a,n),u.applyMatrix4(t);const d=[];for(let c=1;c<=6;c++)yt(d,_t(.007*(4*c/6)*i,4));this.empties.add(this.facing(d,o,u));const l=Yi[a],s=[];for(let c=0;c+1<l.length;c+=2){const[m,_]=l[c],[h,g]=l[c+1];it(s,[m*4*i,_*4*i,0],[h*4*i,g*4*i,0])}this.empties.add(this.facing(s,o,f))}}material(t,n){const o=`${t}:${n}`;let r=this.lineMaterials.get(o);return r||(r=new _o({color:t,linewidth:qi,transparent:n<1,opacity:n,depthTest:!0,depthWrite:n>=1,toneMapped:!1}),this.lineMaterials.set(o,r)),r}fill(t){let n=this.fillMaterials.get(t);return n||(n=new kn({color:t,side:$n,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,o,r){const a=new mo().setPositions(t),i=new ho(a,this.material(n,o));return i.matrixAutoUpdate=!1,i.matrix.copy(r),i.computeLineDistances(),i}screen(t,n,o,r){const a=this.lines(t,n,o,new q);return a.matrixAutoUpdate=!0,a.position.copy(r),a.scale.setScalar(0),a.frustumCulled=!1,this.onDraw(a,(i,f)=>this.face(a,i,f,!0)),a}facing(t,n,o){const r=this.lines(t,n,1,new q);return r.matrixAutoUpdate=!0,r.position.copy(o),this.onDraw(r,(a,i)=>this.face(r,a,i,!1)),r}onDraw(t,n){const o=t,r=o.onBeforeRender.bind(o);o.onBeforeRender=(a,i,f,u,d,l)=>{n(a,f),r(a,i,f,u,d,l)}}face(t,n,o,r){t.parent?.getWorldQuaternion(this.parentQuat).invert(),o.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let a=1;if(r){n.getSize(this.size);const i=Math.max(this.size.y,1),f=this.scratch.setFromMatrixPosition(t.matrixWorld);if(o.isOrthographicCamera){const u=o;a=(u.top-u.bottom)/u.zoom/i}else{const u=o;a=2*Math.max(-f.applyMatrix4(o.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(u.fov)/2)/u.zoom/i}}t.scale.setScalar(a),t.updateMatrixWorld(!0)}dispose(){for(const t of this.drawn.values())this.remove(t.parts);this.drawn.clear();for(const t of this.lineMaterials.values())t.dispose();for(const t of this.fillMaterials.values())t.dispose();this.lineMaterials.clear(),this.fillMaterials.clear()}}function oe(e){const t=new b,n=new Mt;return e.decompose(t,n,new b),new q().compose(t,n,new b(1,1,1))}const ao=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],Xi=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Yi=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([e,t])=>[e*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([e,t])=>[e*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([e,t])=>[e*.02,t*.025])],ht=I().finite(),ro=N({name:z(),type:z(),lens:ht,sensor_width:ht,sensor_height:ht,sensor_fit:Y(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:ht,clip_start:ht,clip_end:ht,shift_x:ht,shift_y:ht,matrix:L(W([ht,ht,ht,ht])).length(4),passepartout:ht.default(0),display_size:ht.default(1)}),Zi={opening:.5,min:.1657359312880715,max:44.98528137423857},Rn={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function Qi(e,t,n,o){const r=a=>Math.min(1,Math.max(-1,a));return[r(e[0]-n/(2*t)),r(e[1]+o/(2*t))]}function io(e,t,n,o){const r=e.type==="ORTHO",a=e.sensor_fit==="VERTICAL"?e.sensor_height:e.sensor_width,i=e.sensor_fit==="AUTO"?t>=n:e.sensor_fit==="HORIZONTAL",f=(r?e.ortho_scale:a/e.lens)/2*o;return i?[f,f*n/t]:[f*t/n,f]}function Ki(e,t,n,o,r,a){const i=Math.max(n.width,1),f=Math.max(n.height,1),[u,d]=io(e,i,f,1/o),[l,s]=io(e,a,1,1),m=2*((e.sensor_fit==="AUTO"?a>=1:e.sensor_fit==="HORIZONTAL")?l:s),_=l/u,h=s/d,g=-2*r[0]*o,p=2*r[1]*o,v=e.shift_x*m-g*2*u,y=e.shift_y*m+p*2*d,w=new q().set(...e.matrix.flat()).premultiply(t),P=new b,S=new Mt;return w.decompose(P,S,new b),{name:e.name,position:P.toArray(),quaternion:[S.x,S.y,S.z,S.w],projection:e.type==="ORTHO"?"orthographic":"perspective",window:{left:v-u,right:v+u,top:y+d,bottom:y-d},near:e.clip_start,far:e.clip_end,frame:{left:.5-_/2+g,top:.5-h/2+p,width:_,height:h},passepartout:{color:Rn.passepartout,opacity:e.passepartout},border:{solid:Rn.back,dashed:Rn.overlay,locked:Rn.redalert}}}const Ji={color:[.8,.8,.8,1],roughness:.5,metallic:0},ts=`
7148
7148
  uniform vec3 wbDir[4];
7149
7149
  uniform vec3 wbDiffuse[4];
7150
7150
  uniform vec3 wbSpecular[4];
@@ -7186,6 +7186,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
7186
7186
  diffuseLight *= diffuseColor * (1.0 - specEnergy);
7187
7187
  return diffuseLight + specularLight;
7188
7188
  }
7189
- `,Ne=e=>Te.map(t=>{const[n=0,o=0,r=0]=e(t);return new b(n,o,r)}),ns=Ne(e=>e.direction).map(e=>e.normalize()),es=Ne(e=>e.diffuse),os=Ne(e=>e.specular),as=new Bn(...Te.map(e=>e.smooth));function rs(e,t){const[n,o,r]=e.color,a=new ba({side:t});return a.color.setRGB(n,o,r,bt),a.name="volter:blender-solid",a.onBeforeCompile=i=>{i.uniforms.wbDir={value:ns},i.uniforms.wbDiffuse={value:es},i.uniforms.wbSpecular={value:os},i.uniforms.wbWrap={value:as},i.uniforms.wbRoughness={value:e.roughness},i.uniforms.wbMetallic={value:e.metallic},i.fragmentShader=i.fragmentShader.replace("void main() {",`${ts}
7189
+ `,Ne=e=>Te.map(t=>{const[n=0,o=0,r=0]=e(t);return new b(n,o,r)}),ns=Ne(e=>e.direction).map(e=>e.normalize()),es=Ne(e=>e.diffuse),os=Ne(e=>e.specular),as=new Un(...Te.map(e=>e.smooth));function rs(e,t){const[n,o,r]=e.color,a=new ba({side:t});return a.color.setRGB(n,o,r,bt),a.name="volter:blender-solid",a.onBeforeCompile=i=>{i.uniforms.wbDir={value:ns},i.uniforms.wbDiffuse={value:es},i.uniforms.wbSpecular={value:os},i.uniforms.wbWrap={value:as},i.uniforms.wbRoughness={value:e.roughness},i.uniforms.wbMetallic={value:e.metallic},i.fragmentShader=i.fragmentShader.replace("void main() {",`${ts}
7190
7190
  void main() {`).replace("#include <opaque_fragment>",`outgoingLight = volterWorkbenchLighting(diffuseColor.rgb, normal, isOrthographic ? vec3(0.0, 0.0, 1.0) : normalize(vViewPosition));
7191
- #include <opaque_fragment>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const is=64;function ss(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>n===t[o]):e===t}function sn(e){for(let t=e;t;t=t.parent)if(!t.visible)return!1;return!0}function xe(e){if(e.determinant()<=0)return!1;const t=e.elements,n=Math.hypot(t[0],t[1],t[2]),o=Math.hypot(t[4],t[5],t[6]),r=Math.hypot(t[8],t[9],t[10]),a=(i,f)=>t[i]*t[f]+t[i+1]*t[f+1]+t[i+2]*t[f+2];return Number.isFinite(n+o+r)&&Math.min(n,o,r)>0&&Math.abs(a(0,4))<=1e-7*n*o&&Math.abs(a(0,8))<=1e-7*n*r&&Math.abs(a(4,8))<=1e-7*o*r}class ls{constructor(t){this.root=t,this.batches=[],this.inverse=new q,this.matrix=new q,this.box=new ln,this.projection=new q,this.frustum=new qn,this.camera=null,this.eligible=0,this.excluded={}}rebuild(t,n){if(this.clear(),!n)return;const o=new Map,r=a=>{this.excluded[a]=(this.excluded[a]??0)+1};this.inverse.copy(this.root.matrixWorld).invert();for(const a of t){const i=a;if(!i.isMesh)continue;if(i.isSkinnedMesh||i.isInstancedMesh||i.morphTargetInfluences||i.layers.mask!==1){r("deformationOrLayers");continue}const f=Array.isArray(i.material)?i.material:[i.material];if(f.some(l=>l.transparent||l.transmission>0||l.isShaderMaterial)){r("material");continue}if(f.some(l=>Wo(l,i.geometry).size>12)){r("attributeBudget");continue}if(this.matrix.multiplyMatrices(this.inverse,i.matrixWorld),!xe(this.matrix)){r("transform");continue}this.eligible++;const u=`${i.geometry.id}:${Array.isArray(i.material)?"slots":"single"}:`+f.map(l=>l.uuid).join(",")+`:${i.renderOrder}`,d=o.get(u);d?d.push(i):o.set(u,[i])}for(const a of o.values()){if(a.length<2)continue;const i=f=>{if(f.length>is){this.box.makeEmpty();for(const _ of f)this.box.expandByPoint(new b().setFromMatrixPosition(_.matrixWorld));const s=this.box.getSize(new b),c=s.x>=s.y&&s.x>=s.z?12:s.y>=s.z?13:14;f.sort((_,h)=>_.matrixWorld.elements[c]-h.matrixWorld.elements[c]);const m=Math.floor(f.length/2);i(f.slice(0,m)),i(f.slice(m));return}if(f.length<2)return;const u=f[0],d=new Oo(u.geometry,u.material,f.length);d.name="Blender repeated geometry",d.userData.engineInternal=!0,d.matrixAutoUpdate=!1,d.renderOrder=u.renderOrder,d.instanceMatrix.setUsage(Ao);const l={draw:d,members:f.map(s=>({mesh:s,layers:s.layers.mask}))};d.raycast=(s,c)=>{for(const{mesh:m}of l.members)m.layers.mask===0&&sn(m)&&m.raycast(s,c)},this.root.add(d),d.updateMatrixWorld(!0),this.batches.push(l)};i(a)}this.sync()}sync(){if(this.batches.length){this.inverse.copy(this.root.matrixWorld).invert();for(const{draw:t,members:n}of this.batches){let o=0,r=!1;for(const a of n){const{mesh:i}=a;if(this.matrix.multiplyMatrices(this.inverse,i.matrixWorld),!(i.parent!==null&&i.geometry===t.geometry&&ss(i.material,t.material)&&xe(this.matrix))){i.layers.mask|=a.layers;continue}if(i.layers.mask&=~a.layers,!sn(i)||this.camera&&(!this.camera.layers.isEnabled(0)||i.frustumCulled&&!this.frustum.intersectsObject(i)))continue;const u=o*16;this.matrix.elements.some((d,l)=>Math.fround(d)!==t.instanceMatrix.array[u+l])&&(t.setMatrixAt(o,this.matrix),r=!0),o++}r||=t.count!==o||t.boundingSphere===null,t.count=o,r&&(t.instanceMatrix.needsUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere())}}}prepareDraw(t){t.updateMatrixWorld(),this.camera=t,this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection)}finishDraw(){this.camera=null}clear(){this.camera=null;for(const{draw:t,members:n}of this.batches){for(const{mesh:o,layers:r}of n)o.layers.mask|=r;t.removeFromParent(),t.dispose()}this.batches.length=0,this.eligible=0,this.excluded={}}inspect(){return{batches:this.batches.length,instances:this.batches.reduce((t,{draw:n})=>t+n.count,0),eligible:this.eligible,excluded:{...this.excluded}}}}const gn=64;function so(e){for(let t=e.parent;t;t=t.parent)if(t.isGroup)return t.renderOrder;return 0}class fs{constructor(t){this.root=t,this.objects=[],this.pools=new Map,this.hidden=[],this.inverse=new q,this.matrix=new q,this.projection=new q,this.frustum=new qn,this.centre=new b,this.depth=new Bn,this.batches=0,this.instances=0,this.planState=[],this.planned=[],this.stateIndex=0,this.stateChanged=!1}setObjects(t){this.clear(),this.objects=[...t].filter(n=>n.isMesh===!0)}prepare(t){if(this.finishDraw(),!this.objects.length)return;if(t.updateMatrixWorld(),this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),!this.planChanged(t)){for(const a of this.planned){a.mesh.visible=!0;for(const i of a.members)i.layers.disable(0),this.hidden.push(i)}return}this.planned.length=0;for(const a of this.pools.values())for(const i of a)i.mesh.visible=!1,i.members.length=0;this.batches=this.instances=0,this.frustum.setFromProjectionMatrix(this.projection),this.inverse.copy(this.root.matrixWorld).invert();const n=[],o=new Map;for(const a of this.objects){const i=Array.isArray(a.material)?a.material:[a.material];if(!i.some(_=>_.visible&&_.transparent)||!sn(a)||!a.layers.test(t.layers)||a.frustumCulled&&!this.frustum.intersectsObject(a))continue;const f=a;f.boundingSphere!==void 0?(f.boundingSphere===null&&f.computeBoundingSphere?.(),this.centre.copy(f.boundingSphere.center)):(a.geometry.boundingSphere||a.geometry.computeBoundingSphere(),this.centre.copy(a.geometry.boundingSphere.center)),this.centre.applyMatrix4(a.matrixWorld);const u=this.centre.clone(),d=this.depth.set(u.x,u.y,u.z,1).applyMatrix4(this.projection).z;let l=null,s=null;const c=i.length===1?i[0]:null,m=so(a);if(c&&c.visible&&c.transparent&&!c.isShaderMaterial&&!(c.transmission>0)&&(c.side!==le||c.forceSinglePass)&&!a.isSkinnedMesh&&!a.morphTargetInfluences&&!a.isInstancedMesh&&a.layers.mask===1&&m===this.root.renderOrder){const _=a.geometry,h=_.index?.count??_.getAttribute("position").count,g=!Array.isArray(a.material)||_.groups.length===1&&_.groups[0].start===0&&_.groups[0].count===h&&_.groups[0].materialIndex===0,p=`${_.id}:${c.uuid}:${a.renderOrder}`;let v=o.get(p);v===void 0&&(v=Wo(c,_).size<=12,o.set(p,v)),this.matrix.multiplyMatrices(this.inverse,a.matrixWorld),g&&v&&xe(this.matrix)&&(l=c,s=p)}n.push({mesh:a,material:l,key:s,groupOrder:m,z:d,centre:u})}n.sort((a,i)=>a.groupOrder-i.groupOrder||a.mesh.renderOrder-i.mesh.renderOrder||i.z-a.z||a.mesh.id-i.mesh.id);const r=new Map;for(let a=0;a<n.length;){const i=n[a];let f=a+1;if(i.key!==null)for(;f<n.length&&n[f].key===i.key;)f++;const u=n[a-1],d=n[f],l=u?.z===i.z&&u.mesh.renderOrder===i.mesh.renderOrder||d?.z===n[f-1].z&&d.mesh.renderOrder===i.mesh.renderOrder;if(i.key!==null&&f-a>=2&&!l){let s=!0;for(let c=a+gn;c<f;c+=gn)n[c-1].z===n[c].z&&(s=!1);if(s)for(let c=a;c<f;c+=gn){const m=Math.min(gn,f-c);if(m<2)continue;const _=n[c],h=r.get(i.key)??0;r.set(i.key,h+1);let g=this.pools.get(i.key);g||(g=[],this.pools.set(i.key,g));let p=g[h];if(!p){const v=new Oo(i.mesh.geometry,i.material,gn);v.name="Blender ordered transparency",v.userData.engineInternal=!0,v.matrixAutoUpdate=!1,v.frustumCulled=!1,v.boundingSphere=new To,v.instanceMatrix.setUsage(Ao),p={mesh:v,members:[]};const y=p;v.raycast=(w,P)=>{if(v.visible)for(const S of y.members)sn(S)&&S.raycast(w,P)},g.push(p),this.root.add(v)}p.mesh.visible=!0,p.mesh.renderOrder=_.mesh.renderOrder,p.mesh.boundingSphere.center.copy(_.centre).applyMatrix4(this.inverse),p.mesh.updateMatrixWorld(!0);for(let v=0;v<m;v++){const y=n[c+v].mesh;this.matrix.multiplyMatrices(this.inverse,y.matrixWorld),p.mesh.setMatrixAt(v,this.matrix),p.members.push(y),y.layers.disable(0),this.hidden.push(y)}p.mesh.count=m,p.mesh.instanceMatrix.needsUpdate=!0,this.planned.push(p),this.batches++,this.instances+=m}}a=f}}inspect(){return{batches:this.batches,instances:this.instances}}observe(t){this.planState[this.stateIndex]!==t&&(this.planState[this.stateIndex]=t,this.stateChanged=!0),this.stateIndex++}planChanged(t){this.stateIndex=0,this.stateChanged=this.planState.length===0,this.observe(t.layers.mask);for(const n of this.projection.elements)this.observe(n);for(const n of this.root.matrixWorld.elements)this.observe(n);for(const n of this.objects){this.observe(n.parent?.id??-1),this.observe(sn(n)?1:0),this.observe(n.layers.mask),this.observe(n.renderOrder),this.observe(so(n)),this.observe(n.frustumCulled?1:0),this.observe(n.morphTargetInfluences?1:0);for(const i of n.matrixWorld.elements)this.observe(i);const o=n.geometry;this.observe(o.id),this.observe(o.drawRange.start),this.observe(o.drawRange.count),this.observe(o.index?.count??o.getAttribute("position").count),this.observe(o.groups.length);for(const i of o.groups)this.observe(i.start),this.observe(i.count),this.observe(i.materialIndex??0);const r=n.boundingSphere??o.boundingSphere;this.observe(r?.center.x??0),this.observe(r?.center.y??0),this.observe(r?.center.z??0),this.observe(r?.radius??-1);const a=Array.isArray(n.material)?n.material:null;if(this.observe(a?.length??-1),a)for(const i of a)this.observeMaterial(i);else this.observeMaterial(n.material)}return this.stateChanged||=this.planState.length!==this.stateIndex,this.planState.length=this.stateIndex,this.stateChanged}observeMaterial(t){this.observe(t.uuid),this.observe(t.version),this.observe(t.visible?1:0),this.observe(t.transparent?1:0),this.observe(t.side),this.observe(t.forceSinglePass?1:0),this.observe(t.transmission??0)}finishDraw(){for(const t of this.hidden)t.layers.enable(0);this.hidden.length=0;for(const t of this.pools.values())for(const{mesh:n}of t)n.visible=!1}clear(){this.finishDraw();for(const t of this.pools.values())for(const{mesh:n}of t)n.removeFromParent(),n.dispose();this.pools.clear(),this.planned.length=0,this.planState.length=0,this.objects=[],this.batches=this.instances=0}}const oe=64*1024*1024,lo=150,In=49152,Pt=8192,fo=Symbol("navigation geometry replaced");class cs{constructor(t){this.invalidate=t,this.groups=new Map,this.cache=new Map,this.swapped=[],this.queue=[],this.worker=null,this.pending=null,this.generation=0,this.building=!1,this.nextId=0,this.signature="",this.identities=new WeakMap,this.nextIdentity=0,this.bytes=0,this.unavailable=null,this.reductions=[],this.timer=null,this.cameraWorld=new q,this.cameraProjection=new q,this.cameraKnown=!1,this.movedAt=-1/0,this.projection=new q,this.frustum=new qn,this.centre=new b,this.drawnMeshes=0,this.fullTriangles=0,this.motionTriangles=0,this.lastNavigation={meshes:0,fullTriangles:0,motionTriangles:0,tooClose:0},this.quietTimer=null}setObjects(t){const n=new Map;for(const i of t){const f=i;if(!f.isMesh||f.isSkinnedMesh||f.isInstancedMesh||f.morphTargetInfluences)continue;const u=f.geometry,d=u.getAttribute("position");if(!u.index||u.index.count<6144||!d||d.count>8e6||Object.values(u.attributes).some(s=>!(s instanceof ut)||s.isFloat16BufferAttribute||s.isInstancedBufferAttribute)||Object.keys(u.morphAttributes).length||u.drawRange.start!==0||u.drawRange.count<u.index.count)continue;if(Array.isArray(f.material)){let s=0;if(!u.groups.length||u.groups.some(c=>{const m=c.start===s&&c.count>0&&c.count%3===0&&Number.isInteger(c.materialIndex)&&c.materialIndex>=0&&c.materialIndex<f.material.length;return s=c.start+c.count,!m})||s!==u.index.count)continue}const l=n.get(u);l?l.push(f):n.set(u,[f])}this.groups=n;const o=i=>{let f=this.identities.get(i);return f===void 0&&(f=++this.nextIdentity,this.identities.set(i,f)),f},r=[...n].map(([i,f])=>`${i.id}:${o(i.index)}:${i.index.version}:${Array.isArray(f[0].material)}:${JSON.stringify(i.groups)}:`+Object.entries(i.attributes).map(([u,d])=>`${u}:${o(d)}:${d.version}`).join(",")).join(";");if(r===this.signature)return;this.releaseCopies(),this.signature=r,this.unavailable=null;const a=[...n].filter(([,i])=>i.length>=3);a.reduce((i,[f,u])=>i+f.index.count*u.length,0)<6e6||(a.sort(([i,f],[u,d])=>u.index.count*d.length-i.index.count*f.length),this.queue=a.map(([i])=>i),this.next())}async next(){if(this.building||this.unavailable||this.bytes>=oe)return;const t=this.queue.shift();if(!t){this.worker?.terminate(),this.worker=null;return}this.building=!0;const n=this.generation,o=()=>{if(n!==this.generation)throw fo;if(this.unavailable)throw new Error(this.unavailable)},r=async()=>{await new Promise(a=>setTimeout(a,0)),o()};try{this.worker||(this.worker=new Worker(new URL("/assets/blender-motion-worker-CtT2cV3V.js",import.meta.url),{type:"module"}),this.worker.onmessage=x=>{if(this.pending?.id===x.data.id){const E=this.pending;this.pending=null,E.resolve(x.data)}},this.worker.onerror=x=>{this.unavailable=x.message||"Navigation geometry worker unavailable",this.worker?.terminate(),this.worker=null;const E=this.pending;this.pending=null,E?.resolve({id:E.id,refusal:this.unavailable})});const a=t.getAttribute("position"),i=this.groups.get(t),f=Array.isArray(i[0].material);if(i.some(x=>Array.isArray(x.material)!==f))return;const u=f?t.groups:[{start:0,count:t.index.count}],d=u.flatMap(x=>{const E=[];for(let A=x.start;A<x.start+x.count;A+=In)E.push({start:A,count:Math.min(In,x.start+x.count-A),materialIndex:x.materialIndex});return E}),l=t.getAttribute("blenderVertex"),s=new Uint32Array(a.count),c=new Uint8Array(a.count),m=x=>l?l.getX(x):x;for(let x=0;x<d.length;x++){const E=d[x];for(let A=E.start;A<E.start+E.count;A+=Pt){await r();for(let U=A;U<Math.min(A+Pt,E.start+E.count);U++){const k=m(t.index.getX(U));if(!Number.isInteger(k)||k<0||k>=s.length)return;s[k]?s[k]!==x+1&&(c[k]=1):s[k]=x+1}}}const _=Object.entries(t.attributes).filter(([x])=>x!=="position"&&x!=="blenderVertex"),h=_.reduce((x,[,E])=>x+E.itemSize,0);if(h>32)return;const g=[];let p=0;for(const[x,E]of _)for(let A=0;A<E.itemSize;A++,p++)x!=="normal"&&g.push(p);const v=_.flatMap(([x,E])=>Array(E.itemSize).fill(x==="normal"?.5:1)),y=t.boundingBox?.clone()??new ln;if(!t.boundingBox){const x=new b;for(let E=0;E<a.count;E+=Pt){await r();for(let A=E;A<Math.min(E+Pt,a.count);A++)y.expandByPoint(x.fromBufferAttribute(a,A))}}if(!t.boundingSphere)return;const w=Math.max(y.max.x-y.min.x,y.max.y-y.min.y,y.max.z-y.min.z)*.002,P=[],S=[];let T=0,O=0;for(const x of u){const E=T;for(let A=x.start;A<x.start+x.count;A+=In){await r();const U=Math.min(A+In,x.start+x.count),k=[],C=new Map,M=new Uint32Array(U-A);for(let K=A;K<U;K++){const mt=t.index.getX(K);let St=C.get(mt);St===void 0&&(St=k.length,k.push(mt),C.set(mt,St)),M[K-A]=St}const B=new Uint8Array(k.length),Q=new Float32Array(k.length*3),ot=new Float32Array(k.length*h);for(let K=0;K<k.length;K+=Pt){await r();for(let mt=K;mt<Math.min(K+Pt,k.length);mt++){const St=k[mt];B[mt]=c[m(St)];for(let Dt=0;Dt<3;Dt++)Q[mt*3+Dt]=a.getComponent(St,Dt);let Wt=0;for(const[,Dt]of _){for(let An=0;An<Dt.itemSize;An++)ot[mt*h+Wt+An]=Dt.getComponent(St,An);Wt+=Dt.itemSize}}}const ct=++this.nextId,nt=await new Promise(K=>{this.pending={id:ct,resolve:K};const mt={id:ct,positions:Q,indices:M,attributes:ot,stride:h,weights:v,absoluteError:w,protectedComponents:g,locks:B};this.worker.postMessage(mt,[Q.buffer,M.buffer,ot.buffer,B.buffer])});if(o(),nt.refusal)throw new Error(nt.refusal);if(!nt.indices||!Number.isFinite(nt.error))throw new Error("Invalid navigation geometry response");const rt=nt.indices;for(let K=0;K<rt.length;K++)rt[K]=k[rt[K]];if(T+=rt.length,T*4>oe-this.bytes)return;P.push(rt),O=Math.max(O,nt.error)}f&&S.push({start:E,count:T-E,materialIndex:x.materialIndex})}const R={vertices:a.count,fullTriangles:t.index.count/3,reducedTriangles:T/3,error:O,accepted:!1};if(this.reductions.length<32&&this.reductions.push(R),!T||T>=t.index.count*.75)return;const $=new Int32Array(a.count).fill(-1),j=[],H=new Uint32Array(T);let tt=0;for(const x of P){for(let E=0;E<x.length;E+=Pt){await r();for(let A=E;A<Math.min(E+Pt,x.length);A++){const U=x[A];let k=$[U];k<0&&(k=j.length,j.push(U),$[U]=k),H[tt+A]=k}}tt+=x.length}const Z=H.byteLength+Object.values(t.attributes).reduce((x,E)=>x+j.length*E.itemSize*E.array.BYTES_PER_ELEMENT,0);if(R.bytes=Z,this.bytes+Z>oe)return;const et=new un;et.setIndex(new ut(H,1));for(const[x,E]of Object.entries(t.attributes)){const A=E,U=A.array.constructor,k=new U(j.length*A.itemSize);for(let C=0;C<j.length;C+=Pt){await r();for(let M=C;M<Math.min(C+Pt,j.length);M++)for(let B=0;B<A.itemSize;B++)k[M*A.itemSize+B]=A.array[j[M]*A.itemSize+B]}et.setAttribute(x,new ut(k,A.itemSize,A.normalized))}et.boundingSphere=t.boundingSphere.clone(),et.boundingBox=y.clone();for(const x of S)et.addGroup(x.start,x.count,x.materialIndex);et.userData={...t.userData},R.accepted=!0,this.cache.set(t,{geometry:et,error:O,bytes:Z}),this.bytes+=Z}catch(a){if(a===fo)return;this.unavailable=String(a),this.worker?.terminate(),this.worker=null,this.pending=null,this.queue.length=0}finally{n===this.generation&&(this.building=!1,this.timer=setTimeout(()=>{this.timer=null,this.next()},0))}}prepare(t,n,o){if(this.finish(),this.drawnMeshes=this.fullTriangles=this.motionTriangles=0,!n||!(o>0))return!1;const r=performance.now(),a=this.cameraKnown&&(!t.matrixWorld.equals(this.cameraWorld)||!t.projectionMatrix.equals(this.cameraProjection));if(this.cameraKnown=!0,this.cameraWorld.copy(t.matrixWorld),this.cameraProjection.copy(t.projectionMatrix),a&&(this.movedAt=r,this.quietTimer&&clearTimeout(this.quietTimer),this.quietTimer=setTimeout(()=>{this.quietTimer=null,this.invalidate()},lo+1)),r-this.movedAt>lo)return!1;this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection);let i=0;for(const[f,u]of this.cache)for(const d of this.groups.get(f)??[]){if(!sn(d)||d.frustumCulled&&!this.frustum.intersectsObject(d))continue;const l=d.matrixWorld.elements,s=Math.hypot(l[0],l[1],l[2],l[4],l[5],l[6],l[8],l[9],l[10]),c=f.boundingSphere;this.centre.copy(c.center).applyMatrix4(d.matrixWorld).applyMatrix4(t.matrixWorldInverse);const m=t.isPerspectiveCamera?-this.centre.z-c.radius*s:1,_=u.error*s*Math.abs(t.projectionMatrix.elements[5])*o/(2*m);if(!(m>0)||_>1){i++;continue}this.swapped.push({mesh:d,geometry:f}),d.geometry=u.geometry,this.drawnMeshes++,this.fullTriangles+=f.index.count/3,this.motionTriangles+=u.geometry.index.count/3}return this.lastNavigation={meshes:this.drawnMeshes,fullTriangles:this.fullTriangles,motionTriangles:this.motionTriangles,tooClose:i},this.swapped.length>0}finish(){for(const{mesh:t,geometry:n}of this.swapped)t.geometry=n;this.swapped.length=0}inspect(){return{copies:this.cache.size,bytes:this.bytes,queued:this.queue.length,pending:this.building,unavailable:this.unavailable,reductions:this.reductions.map(t=>({...t})),lastNavigation:{...this.lastNavigation}}}releaseCopies(){this.finish(),this.timer&&clearTimeout(this.timer),this.timer=null,this.generation++,this.worker?.terminate(),this.worker=null,this.pending?.resolve({id:this.pending.id,refusal:"Navigation geometry replaced"}),this.pending=null,this.building=!1,this.queue=[];for(const t of this.cache.values())t.geometry.dispose();this.cache.clear(),this.bytes=0,this.reductions=[]}clear(){this.releaseCopies(),this.quietTimer&&clearTimeout(this.quietTimer),this.quietTimer=null,this.groups.clear(),this.signature="",this.cameraKnown=!1,this.movedAt=-1/0}}const us={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},D=I().finite(),Go=W([D,D,D]),zn=W([I().int().nonnegative(),I().int().nonnegative()]),pt={name:z(),domain:Y(["POINT","EDGE","FACE","CORNER"])},ms=Ca("type",[N({...pt,type:X("FLOAT2"),data:L(W([D,D]))}).strict(),N({...pt,type:X("FLOAT_VECTOR"),data:L(Go)}).strict(),N({...pt,type:X("FLOAT_COLOR"),data:L(W([D,D,D,D]))}).strict(),N({...pt,type:X("BYTE_COLOR"),data:L(W([D,D,D,D]))}).strict(),N({...pt,type:X("QUATERNION"),data:L(W([D,D,D,D]))}).strict(),N({...pt,type:X("FLOAT4"),data:L(W([D,D,D,D]))}).strict(),N({...pt,type:X("FLOAT4X4"),data:L(L(D).length(16))}).strict(),N({...pt,type:X("INT16_2D"),data:L(W([I().int(),I().int()]))}).strict(),N({...pt,type:X("INT32_2D"),data:L(W([I().int(),I().int()]))}).strict(),N({...pt,type:X("FLOAT"),data:L(D)}).strict(),N({...pt,type:X("INT"),data:L(I().int())}).strict(),N({...pt,type:X("INT8"),data:L(I().int())}).strict(),N({...pt,type:X("BOOLEAN"),data:L(at())}).strict(),N({...pt,type:X("STRING"),data:L(z())}).strict()]),ds=N({positions:G(Float32Array),normals:G(Float32Array).nullable(),uv:G(Float32Array).nullable(),uvLayers:L(N({name:z(),data:G(Float32Array)}).strict()).optional(),attributeLayers:L(N({name:z(),data:G(Float32Array)}).strict()).optional(),orco:G(Float32Array).nullable().optional(),indices:G(Uint32Array),groups:L(N({start:I().int().nonnegative(),count:I().int().nonnegative(),materialIndex:I().int().nonnegative()}).strict()),hash:z()}).strict(),_s=N({v:L(Go),f:L(L(I().int().nonnegative())),e:L(zn).optional(),edge_order:L(zn).optional(),m:L(I().int().nonnegative()).optional(),s:L(at()).optional(),sharp:L(zn).optional(),seams:L(zn).optional(),creases:L(W([D,D,D])).optional(),attributes:L(ms).optional(),active_uv:z().nullable().optional(),render_uv:z().nullable().optional()}).strict(),hs=N({store:I().int().optional(),revision:I().int(),unchanged:X(!0)}).strict(),ps=N({co:Ut([G(Float32Array),G(Float64Array)]),cornerNormal:G(Float32Array).optional(),cornerTri:G(Uint32Array).optional(),orco:G(Float32Array).optional(),faceStart:G(Uint32Array),corner:G(Uint32Array),cornerEdge:G(Int32Array),edge:G(Uint32Array),edgeSharp:G(Uint8Array),edgeSeam:G(Uint8Array),edgeCrease:G(Float32Array),material:G(Uint32Array),smooth:G(Uint8Array),vertSelect:G(Uint8Array),vertHide:G(Uint8Array),edgeSelect:G(Uint8Array),edgeHide:G(Uint8Array),faceSelect:G(Uint8Array),faceHide:G(Uint8Array)}).strict(),gs=N({name:z(),domain:Y(["POINT","EDGE","FACE","CORNER"]),type:z(),data:ka(e=>ArrayBuffer.isView(e))}).strict(),Xo=N({columns:ps,attributes:L(gs),activeUv:z().nullable(),renderUv:z().nullable(),counts:N({verts:I().int().nonnegative(),edges:I().int().nonnegative(),faces:I().int().nonnegative(),corners:I().int().nonnegative()}).strict(),revision:I().int().nonnegative()}).strict(),vs=Ut([ds,Xo,_s,hs]),co=new Set;function xs(e,t){const n=new Blob([e],{type:t}),o=new Ta;let r=!1;o.addEventListener("dispose",()=>{r=!0,o.image?.close?.()});const a=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(i=>{if(r){i.close();return}o.image=i,o.needsUpdate=!0,gt()}).finally(()=>{co.delete(a)});return co.add(a),a.catch(()=>{}),{texture:o,ready:a}}function bs(e,t,n,o){const r=new Un(e,t,n,Wn,Aa);return r.flipY=!1,r.colorSpace=o==="data"?$n:Bt,r.needsUpdate=!0,r}function ys(e,t,n){if(t.length===0)throw new Error(`Runtime image ${e} is tiled with no tiles`);const o=Math.max(...t.map(l=>l.width)),r=Math.max(...t.map(l=>l.height)),a=new Uint8Array(o*r*4*t.length),i=Math.max(...t.map(l=>l.number-1001))+1,f=new Float32Array(i*2*4);for(let l=0;l<i;l++)f[l*4]=-1;t.forEach((l,s)=>{const c=l.rgba??(l.rgbaBase64?ue(l.rgbaBase64):void 0);if(!c)throw new Error(`Runtime image ${e} tile ${l.number} carries no raster`);for(let _=0;_<l.height;_++)a.set(c.subarray(_*l.width*4,(_+1)*l.width*4),(s*r+_)*o*4);const m=l.number-1001;f[m*4]=s,f.set([0,0,l.width/o,l.height/r],(i+m)*4)});const u=new Oa(a,o,r,t.length);u.colorSpace=n==="data"?$n:Bt,u.magFilter=Jt,u.minFilter=So,u.generateMipmaps=!0,u.needsUpdate=!0;const d=new Un(f,i,2,Wn,xo);return d.magFilter=d.minFilter=fe,d.needsUpdate=!0,{tiles:u,map:d,frame:t}}const ws=N({width:I().int().positive(),height:I().int().positive(),revision:I().int().nonnegative(),rgba:G(Uint8Array).optional(),rgbaBase64:z().optional(),colorspace:Y(["sRGB","data"]).optional(),tiles:L(N({number:I().int().min(1001),width:I().int().positive(),height:I().int().positive(),rgba:G(Uint8Array).optional(),rgbaBase64:z().optional()}).strict()).optional()}).strict(),Os=N({revision:I().int().nonnegative(),encoded:G(Uint8Array).optional(),encodedBase64:z().optional(),mime:Y(["image/png","image/jpeg"]),colorspace:Y(["sRGB","data"]).optional()}).strict(),Yo=Ut([ws,Os]),ae=N({image:N({name:z(),revision:I().int().nonnegative()}).strict(),extension:Y(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:z(),tint:W([D,D,D]).optional()}).strict(),As=N({name:z(),color:W([D,D,D,D]),roughness:D,metallic:D,transmission:D,ior:D,physical:Mi.optional(),normal_texture:ae.optional(),normal_strength:D.default(1),normal_space:Y(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:at().default(!1),texture:ae.optional(),roughness_texture:ae.optional(),emission:N({color:W([D,D,D]),strength:D}).strict().optional(),graph:ni.optional(),viewport:N({color:W([D,D,D,D]),roughness:D,metallic:D}).strict().optional()}).strict(),Ts=N({session:z(),revision:I().int().nonnegative(),volumes:Ot(z(),Lo).default({}),lights:Ot(z(),$r).default({}),world:Hr.nullable().default(null),meshes:Ot(z(),vs),materials:Ot(z(),As),images:Ot(z(),Yo).default({}),objects:L(N({id:z(),name:z(),type:Y(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:z().nullable(),volume:z().nullable().optional(),light:z().nullable().optional(),materials:L(z().nullable()),matrix:L(W([D,D,D,D])).length(4),visible:at(),render_visible:at().default(!0),selected:at(),parent:z().nullable(),texspace:W([W([D,D,D]),W([D,D,D])]).optional(),default_color:z().optional()}).strict()),active:z().nullable(),mode:z(),cameras:Ot(z(),Ot(z(),Po())).default({}),warnings:L(z()).default([]),updated:L(z()).default([]),frame:I().int().default(0),armatures:Ot(z(),ja).default({}),weights:zi.nullable().default(null),cursor:$i.optional(),camera_view:N({scene_camera:z().nullable(),view_layer_cameras:L(z()),aspect:I().finite().positive()}).optional(),light_distances:Ot(z(),W([I().finite(),I().finite()])).default({}),empties:Ot(z(),Wi).default({}),view:N({location:W([I(),I(),I()]),rotation:W([I(),I(),I(),I()]),distance:I().finite(),perspective:Y(["PERSP","ORTHO","CAMERA"]),lens:I().finite().positive().default(50),shading:Y(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:N({frame:I().int(),body:z(),markers:L(W([I().int(),z()]))}).optional(),units:N({system:Y(["NONE","METRIC","IMPERIAL"]),scale_length:I().finite()}).optional()}).strict();function Ss(e,t){for(let n=0,o=e.length-1;n<e.length&&o>=0;n++,o--){if(e[n][0]===t)return e[n][1];if(n===o)break;if(e[o][0]===t)return e[o][1]}return null}const Ms={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class jn{constructor(){this.root=new ft,this.instances=new ls(this.root),this.transparentInstances=new fs(this.root),this.motionGeometry=new cs(gt),this.drawBatching=!0,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new qr,this.world=new Se,this.armatureOverlay=new Ka,this.weightOverlay=new ki,this.cursorOverlay=new Ui,this.extrasOverlay=new Gi,this.armatureRoot=new ft,this.weightRoot=new ft,this.cursorRoot=new ft,this.cameraExtrasRoot=new ft,this.lightExtrasRoot=new ft,this.emptyExtrasRoot=new ft,this.rendered=!1,this.heldRendered=null,this.worldApplied=null,this.worldKey="null",this.capturing=!1,this.workbench=!1,this.workbenchMaterials=new Map,this.fallback=new fn({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new Si,this.graphSamplers=new Map,this.photograph=!1,this.graphs=new Map,this.frame=null,this.retiredSessions=new Set,this.geometryBuilds=0,this.submittedMeshes=new Map,this.submitted=null,this.submittedSession=null,this.photographs=[],this.frameListeners=new Set,this.followers=new Set,this.leader=null,this.cameraViewZoom=Zi,this.cameraViewPan=Qi,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,this.staged=null;const t=this.root.updateMatrixWorld.bind(this.root);this.root.updateMatrixWorld=n=>{t(n),this.instances.sync()},this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[n,o]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group],[this.cursorRoot,this.cursorOverlay.group],[this.cameraExtrasRoot,this.extrasOverlay.cameras],[this.lightExtrasRoot,this.extrasOverlay.lights],[this.emptyExtrasRoot,this.extrasOverlay.empties]])n.matrixAutoUpdate=!1,n.matrix.copy(this.root.matrix),n.add(o),n.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const n of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])n.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let o=this.graphs.get(n);return o||(o=hi(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,o)),o}mirrorPose(t){let n=null;for(const[a,i]of this.objects)if(i===t){n=a;break}if(n===null)return;const o=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let r=!1;for(const a of o){if(a===this)continue;const i=a.objects.get(n);i!==void 0&&(i.matrix.copy(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),r=!0)}r&&gt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),o=La(t);return()=>{n(),o()}}blenderObjectName(t){for(const[n,o]of this.objects)if(o===t)return this.frame?.objects.find(r=>r.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,o,r,a]=t.rotation,i=new Mt(o,r,a,n),f=new b(...t.location).applyMatrix4(this.root.matrix),u=d=>d.applyQuaternion(i).applyMatrix4(this.root.matrix).normalize();return{target:f.toArray(),direction:u(new b(0,0,1)).toArray(),up:u(new b(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?us[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(o=>t.cameras[o])??null}blenderPose(t,n){const o=new q().copy(this.root.matrix).invert(),r=new q().compose(new b(...t),new Mt(...n),new b(1,1,1)).premultiply(o),a=new b,i=new Mt;return r.decompose(a,i,new b),{location:a.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,n,o,r){const a=this.frame,i=ro.safeParse(a?.cameras[t]);return!a?.camera_view||!i.success?null:Ki(i.data,this.root.matrix,n,o,r,a.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const o=t??n.frame,r=Ss(n.markers,o);return`(${o})${n.body}${r===null?"":` <${r}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const o=Ms[n.system],r=6*t,a=1/(n.scale_length||1);return(o.find(([f])=>f*a>r)??o[o.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(o=>o.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[o,r]of this.objects)if(r===t){const a=t.parent,i=[...t.children];t.removeFromParent();for(const f of i)n.add(f);a?.add(n),this.objects.set(o,n),this.rebuildInstances();return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,o){const r=new Set(this.objects.values()),a=this.cursorOverlay.placementAt(t,n,o,this.root,i=>r.has(i));return a!==null&&(this.cursorOverlay.show(a),gt()),a}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const o=t.isOrthographicCamera?t.getWorldDirection(new b).toArray().map(r=>r.toFixed(1)).join(","):"";return`${t.uuid}:${o}:${this.worldKey}`}report(t){t.then(gt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),gt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const o of this.frame?.objects??[]){if(o.mesh===null||o.volume)continue;const r=this.objects.get(o.id);if(!r?.isMesh)continue;const i=(o.materials.length?o.materials:[null]).map(f=>{const u=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,u.side,n):u});r.material=o.materials.length?i:i[0]}for(const[o,r]of this.workbenchMaterials)n.has(o)||(r.dispose(),this.workbenchMaterials.delete(o));this.rebuildInstances()}rebuildInstances(){this.transparentInstances.clear(),this.instances.rebuild(this.objects.values(),this.drawBatching&&!this.rendered),this.drawBatching&&!this.rendered&&this.transparentInstances.setObjects(this.objects.values()),this.motionGeometry.setObjects(this.objects.values())}setDrawBatching(t){t!==this.drawBatching&&(this.drawBatching=t,this.rebuildInstances(),gt())}prepareDraw(t,n){try{this.instances.prepareDraw(t),this.root.updateMatrixWorld(!0),this.motionGeometry.prepare(t,!this.rendered&&(this.mode??this.frame?.mode)==="OBJECT"&&n?.interactive===!0,n?.height??0)&&this.instances.sync(),this.transparentInstances.prepare(t)}catch(o){throw this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw(),o}return()=>{this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw()}}workbenchFor(t,n,o){const r=(t!==null?this.frame?.materials[t]?.viewport:void 0)??Ji,a=`${r.color.join(",")}|${r.roughness}|${r.metallic}|${n}`;o.add(a);let i=this.workbenchMaterials.get(a);return i||(i=rs(r,n),this.workbenchMaterials.set(a,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const o=(t?no(this.frame?.world)?.extinction:null)??new b;for(const a of[...this.materials.values(),this.fallback])Ei(a,o);this.rendered=t,this.lighting.setRendered(t);const r=t&&n?this.worldKeyFor(n):null;t?(this.capturing||r!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:r,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await Vr(),await Promise.all([...this.textures.values()].map(a=>a.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const o=[];for(const u of this.objects.values()){const d=u;if(d.isMesh&&(d.castShadow=t,d.receiveShadow=t,t&&d.visible)){const l=new ln().setFromObject(d);l.isEmpty()||o.push(l)}}if(!t||!o.length)return;const a=o.reduce((u,d)=>u.union(d),new ln).getBoundingSphere(new To),i=n?new qn().setFromProjectionMatrix(new q().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=i?o.flatMap(u=>Yr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Zr(u,f,o):Ur(u,a.center,a.radius)}applyOverlays(t){const n=i=>{const f=t.objects.find(u=>u.name===i);return f===void 0?null:new q().set(...f.matrix.flat())},o=[...this.armatureOverlay.apply(t.armatures,n)],r=t.weights?this.objects.get(t.objects.find(i=>i.name===t.weights?.object)?.id??""):void 0,a=this.weightOverlay.apply(t.weights,r??null,t.weights?n(t.weights.object):null);return a!==null&&o.push(a),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),o}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),gt())}applyExtras(t){const n={};for(const[o,r]of Object.entries(t.cameras)){const a=ro.safeParse(r);a.success&&(n[o]=a.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(o=>o.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:o=>{const r=t.objects.find(a=>a.name===o);return r?this.objects.get(r.id)??null:null},image:o=>{const r=this.textures.get(o);if(!r)return null;const a=r.texture.image,i=r.width||a?.width||0,f=r.height||a?.height||0;return(i===0||f===0)&&r.ready&&!this.awaitedImages.has(o)&&(this.awaitedImages.add(o),r.ready.then(()=>{this.awaitedImages.delete(o),this.frame&&this.applyExtras(this.frame),gt()},()=>this.awaitedImages.delete(o))),{texture:r.texture,width:i,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const o=this.lights.get(t.light);o&&(o.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.capturing,this.weightOverlay.group.visible=!this.capturing,this.cursorOverlay.group.visible=!this.capturing;for(const t of[this.extrasOverlay.cameras,this.extrasOverlay.lights,this.extrasOverlay.empties])t.visible=!this.capturing}stageFrame(t){if(t.abort||!t.mesh&&!t.image){for(const o of this.staged?.meshes.values()??[])o.geometry.dispose();this.staged=t.abort?null:{session:t.session,revision:t.revision,meshes:new Map,images:new Map};return}const n=this.staged;if(!n||n.session!==t.session||n.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const o=Xo.parse(t.piece);if(n.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const r=`revision:${o.revision}`;n.meshes.set(t.mesh,{signature:r,geometry:Dn(Ve({...o.columns,attributes:o.attributes,activeUv:o.activeUv,renderUv:o.renderUv},r))})}else if(t.image!==void 0){if(n.images.has(t.image))throw new Error("Duplicate Blender image piece");n.images.set(t.image,Yo.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},o=Ts.parse(t),r=this.staged;if(r&&(r.session!==o.session||r.revision!==o.revision))throw new Error("Blender frame manifest does not match its staged revision");if(r)for(const[l,s]of r.images)o.images[l]=s;if(this.retiredSessions.has(o.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===o.session&&o.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const a=new Set(o.objects.map(l=>l.id));if(a.size!==o.objects.length)throw new Error("Runtime object IDs must be unique");const i=new Map(o.objects.map(l=>[l.id,l]));for(const l of o.objects){if(l.mesh!==null&&!o.meshes[l.mesh])throw new Error(`Missing runtime mesh ${l.mesh}`);if(l.volume&&(!o.volumes[l.volume]||l.mesh!==null))throw new Error(`Invalid runtime volume ${l.volume}`);if(l.light&&(!o.lights[l.light]||l.mesh!==null))throw new Error(`Invalid runtime light ${l.light}`);for(const m of l.materials)if(m!==null&&!o.materials[m])throw new Error(`Missing runtime material ${m}`);const s=new Set([l.id]);let c=l.parent;for(;c!==null;){if(s.has(c))throw new Error("Runtime parent cycle");s.add(c);const m=i.get(c);if(!m)throw new Error(`Missing runtime parent ${c}`);c=m.parent}}const f=new Map,u=new Map;try{for(const[l,s]of Object.entries(o.volumes)){const c=JSON.stringify(s);this.frame?.session===o.session&&this.volumes.get(l)?.signature===c||u.set(l,{signature:c,mesh:Qr(s)})}for(const[l,s]of Object.entries(o.meshes)){if("unchanged"in s){const h=r?.meshes.get(l);if(h){if(h.signature!==`revision:${s.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(l,h);continue}const g=this.meshes.get(l)?.signature;if(this.frame?.session===o.session&&g!==void 0&&(g===`revision:${s.revision}`||!g.startsWith("revision:")))continue;throw new Error(g===void 0?`${ke}: the presenter does not hold runtime mesh ${l} (store ${s.store}, revision ${s.revision})`:`${ke}: the presenter holds runtime mesh ${l} at ${g}, not revision ${s.revision}`)}const c="hash"in s,m="columns"in s,_=m?`revision:${s.revision}`:c?s.hash:JSON.stringify(s);this.frame?.session===o.session&&this.meshes.get(l)?.signature===_||f.set(l,{signature:_,geometry:m?Dn(Ve({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},_)):c?Dn(s):ur(s)})}}catch(l){for(const s of f.values())s.geometry.dispose();for(const{mesh:s}of u.values())s.geometry.dispose(),s.material.dispose();throw l}if(r){for(const[l,s]of r.meshes)f.has(l)||s.geometry.dispose();this.staged=null}this.frame?.session!==o.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[l,s]of u){const c=this.volumes.get(l)?.mesh;c&&(c.removeFromParent(),c.geometry.dispose(),c.material.dispose()),this.volumes.set(l,s)}for(const[l,s]of f)this.meshes.get(l)?.geometry.dispose(),this.meshes.set(l,s),this.geometryBuilds++;for(const[l,s]of Object.entries(o.images)){const c=this.textures.get(l);if("width"in s){const p=s.rgba??(s.rgbaBase64?ue(s.rgbaBase64):void 0);if(!p)throw new Error(`Runtime image ${l} carries no raster`);const v=s.tiles?ys(l,s.tiles,s.colorspace??"sRGB"):void 0;if(c?.udim&&(c.udim.tiles.dispose(),c.udim.map.dispose(),delete c.udim),c&&c.width===s.width&&c.height===s.height){const y=c.texture.image;if(y.data){y.data.set(p),c.texture.needsUpdate=!0,c.revision=s.revision,v&&(c.udim=v);continue}}c?.texture.dispose(),this.textures.set(l,{texture:bs(p,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...v?{udim:v}:{}});continue}const m=s.encoded??(s.encodedBase64?ue(s.encodedBase64):void 0);if(!m)throw new Error(`Runtime image ${l} carries no bytes`);c?.texture.dispose(),c?.udim?.tiles.dispose(),c?.udim?.map.dispose();const _=s.colorspace??"sRGB",{texture:h,ready:g}=xs(m,s.mime);h.colorSpace=_==="data"?$n:Bt,this.textures.set(l,{texture:h,ready:g,width:0,height:0,revision:s.revision,encoded:{bytes:m.slice(),mime:s.mime,colorspace:_}})}for(const[l,s]of Object.entries(o.materials)){const c=this.materials.get(l)??new fn;c.name=s.name;const m=s.texture?.tint;s.texture!==void 0?c.color.setRGB(m?.[0]??1,m?.[1]??1,m?.[2]??1,bt):c.color.setRGB(s.color[0],s.color[1],s.color[2],bt),c.opacity=s.color[3];const _=c.opacity<1||s.graph!==void 0&&ei(s.graph);c.transparent!==_&&(c.transparent=_,c.needsUpdate=!0),c.roughness=s.roughness,c.metalness=s.metallic,c.transmission=s.transmission,c.ior=s.ior,Pe(c,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const h=s.normal_texture?.image.name;if(h===void 0)c.normalMap&&(this.textureSamplers.delete(`${l}:normal`),c.normalMap=null,c.needsUpdate=!0);else{const w=this.textures.get(h);if(!w)throw new Error(`${dn}: missing normal image ${h}`);const P=this.textureSamplers.get(`${l}:normal`,w.texture,s.normal_texture.extension,w.ready,s.normal_texture.uv);c.normalMap!==P&&(c.normalMap=P,c.needsUpdate=!0);const S=s.normal_space==="OBJECT"?ya:wa;c.normalMapType!==S&&(c.normalMapType=S,c.needsUpdate=!0),c.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(c.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],bt),c.emissiveIntensity=s.emission.strength):(c.emissive.setRGB(0,0,0),c.emissiveIntensity=1);const g=s.roughness_texture?.image.name??null;if(g===null)this.roughnessTextureNames.has(l)&&(this.textureSamplers.delete(`${l}:roughness`),c.roughnessMap=null,this.roughnessTextureNames.delete(l),c.needsUpdate=!0);else{const w=this.textures.get(g);if(!w)throw new Error(`${dn}: the presenter does not hold runtime image ${g} (revision ${s.roughness_texture.image.revision})`);const P=this.textureSamplers.get(`${l}:roughness`,w.texture,s.roughness_texture.extension,w.ready,s.roughness_texture.uv);c.roughnessMap!==P&&(c.roughnessMap=P,this.roughnessTextureNames.set(l,g),c.needsUpdate=!0)}const p=s.texture?.image.name??null;if(p===null)this.textureNames.has(l)&&(this.textureSamplers.delete(`${l}:color`),c.map=null,this.textureNames.delete(l),c.needsUpdate=!0);else{const w=this.textures.get(p);if(!w)throw new Error(`${dn}: the presenter does not hold runtime image ${p} (revision ${s.texture.image.revision})`);const P=this.textureSamplers.get(`${l}:color`,w.texture,s.texture.extension,w.ready,s.texture.uv);c.map!==P&&(c.map=P,this.textureNames.set(l,p),c.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,y=new Set;gi(c,v,w=>{const P=this.textures.get(w.name);if(!P)throw new Error(`${dn}: the presenter does not hold runtime image ${w.name} (revision ${w.revision})`);if(w.tiled){if(!P.udim)throw new Error(`${dn}: runtime image ${w.name} arrived without its UDIM tiles`);return P.udim}const S=`${l}:graph:${w.node}`;y.add(S);const T=this.textureSamplers.get(S,P.texture,w.extension,P.ready),O=w.closest?fe:Jt,R=w.closest?fe:w.mipmap?So:Jt;return(T.magFilter!==O||T.minFilter!==R)&&(T.magFilter=O,T.minFilter=R,T.needsUpdate=!0),T},this.photograph);for(const w of this.graphSamplers.get(l)??[])y.has(w)||this.textureSamplers.delete(w);this.graphSamplers.set(l,y),this.materials.set(l,c)}for(const l of o.objects){let s=this.objects.get(l.id);const c=l.volume?this.volumes.get(l.volume).mesh:null;if((!s||(c?s!==c:!!s.isMesh!=(l.mesh!==null)))&&(s?.removeFromParent(),s=c??(l.mesh!==null?new Ft(this.meshes.get(l.mesh).geometry,this.fallback):new go),this.objects.set(l.id,s)),s.name=l.name,l.type==="CAMERA"||l.type==="LIGHT"||l.type==="EMPTY"?s.userData.volterOwnOverlay=!0:delete s.userData.volterOwnOverlay,s.matrixAutoUpdate=!1,s.matrix.set(...l.matrix.flat()),l.parent){const m=new q().set(...i.get(l.parent).matrix.flat());s.matrix.premultiply(m.invert())}if(s.matrix.decompose(s.position,s.quaternion,s.scale),l.texspace?s.userData.blenderTexspace=l.texspace:delete s.userData.blenderTexspace,l.default_color!==void 0?s.userData.blenderDefaultColor=l.default_color:delete s.userData.blenderDefaultColor,l.mesh!==null){const m=s;m.geometry=this.meshes.get(l.mesh).geometry,m.material=l.materials.length?l.materials.map(_=>_===null?this.fallback:this.materials.get(_)):this.fallback,yi(m)}if(l.light){const m=this.lights.get(l.light)??null,_=Br(o.lights[l.light],m);m&&m!==_&&(m.removeFromParent(),m.dispose()),_.parent!==s&&s.add(_),_.userData.volterOwnOverlay=!0,Wr(_,s),this.lights.set(l.light,_)}}for(const l of o.objects){const s=this.objects.get(l.id),c=l.parent===null?this.root:this.objects.get(l.parent);s.parent!==c&&c.add(s)}for(const[l,s]of this.objects)a.has(l)||(s.removeFromParent(),this.objects.delete(l));for(const[l,s]of this.volumes)o.volumes[l]||(s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.volumes.delete(l));for(const[l,s]of this.meshes)o.meshes[l]||(s.geometry.dispose(),this.meshes.delete(l));for(const[l,s]of this.materials)if(!o.materials[l]){for(const c of["normal","roughness","color"])this.textureSamplers.delete(`${l}:${c}`);for(const c of this.graphSamplers.get(l)??[])this.textureSamplers.delete(c);this.graphSamplers.delete(l),s.dispose(),this.materials.delete(l)}for(const[l,s]of this.lights)o.lights[l]||(s.removeFromParent(),s.dispose(),this.lights.delete(l));this.root.updateMatrixWorld(!0),this.frame={...o,meshes:{},volumes:{},images:{}},this.worldKey=JSON.stringify(o.world??null);const d=this.applyOverlays(o);d.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...d]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const l of[...this.frameListeners])l();for(const l of this.followers)try{l.applyFrame(t)}catch{l.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,instancing:this.drawStatistics(),objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}drawStatistics(){return{enabled:this.drawBatching,opaque:this.instances.inspect(),transparent:this.transparentInstances.inspect(),motion:this.motionGeometry.inspect()}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[r,{signature:a,geometry:i}]of this.meshes){const f=l=>{const s=i.getAttribute(l);if(!s)return null;if(!(s instanceof ut))throw new Error(`Blender capture cannot copy interleaved ${l}`);return new Float32Array(s.array)},u=f("position");if(!u)throw new Error(`Blender capture mesh ${r} has no positions`);const d=i.getIndex();n.meshes[r]={hash:a,positions:u,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(i.userData.blenderUvChannels??{}).map(([l,s])=>{const c=f(`uv${s}`);if(!c)throw new Error(`Blender capture mesh ${r} is missing UV layer ${l}`);return{name:l,data:c}}),orco:i.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(i.userData.blenderAttributes??[]).map(l=>{const s=f(jt(l));if(!s)throw new Error(`Blender capture mesh ${r} is missing attribute ${l}`);return{name:l,data:s}}),indices:d?new Uint32Array(d.array):Uint32Array.from({length:u.length/3},(l,s)=>s),groups:i.groups.map(l=>({start:l.start,count:l.count,materialIndex:l.materialIndex??0}))}}for(const[r,{signature:a}]of this.volumes)n.volumes[r]=Lo.parse(JSON.parse(a));const o=new Set(Object.values(n.materials).flatMap(r=>[r.texture?.image.name,r.roughness_texture?.image.name,r.normal_texture?.image.name,...Object.values(r.graph?.nodes??{}).map(a=>a.props.image?.name)].filter(a=>a!==void 0)));for(const r of o){const a=this.textures.get(r);if(!a)throw new Error(`Blender capture image ${r} is not resident`);if(a.encoded)n.images[r]={revision:a.revision,encoded:a.encoded.bytes.slice(),mime:a.encoded.mime,colorspace:a.encoded.colorspace};else{const i=a.texture.image?.data;if(!(i instanceof Uint8Array))throw new Error(`Blender capture image ${r} has no resident raster`);n.images[r]={revision:a.revision,width:a.width,height:a.height,rgba:i.slice(),colorspace:a.texture.colorSpace===$n?"data":"sRGB",...a.udim?{tiles:a.udim.frame}:{}}}}return n}follow(){const t=new jn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,o=this.createWorldVolumePass(),r=new jn;r.photograph=!0;let a=!1;const i=()=>{a||(a=!0,o?.dispose(),r.dispose(),r.root.removeFromParent())};try{r.applyFrame(t),this.root.updateWorldMatrix(!0,!1),r.root.matrix.copy(this.root.matrixWorld),r.root.updateMatrixWorld(!0)}catch(f){throw i(),f}return{effect:o,root:r.root,session:n.session,revision:n.revision,prepare:f=>{if(a)throw new Error("Blender capture snapshot is disposed");return r.setRendered(!0,f)},dispose:i}}createWorldVolumePass(){const t=no(this.frame?.world);return t?new Ii(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,o=n.meshes;if(typeof o!="object"||o===null)return;const r=typeof n.session=="string"?n.session:null;r!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=r);const a=o;for(const[i,f]of Object.entries(a))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(i,f);for(const i of[...this.submittedMeshes.keys()])i in a||this.submittedMeshes.delete(i);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){this.motionGeometry.clear(),this.transparentInstances.clear(),this.instances.clear();for(const t of this.staged?.meshes.values()??[])t.geometry.dispose();this.staged=null;for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const Cs=new jn;function Zo(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function re(e){const t=Zo(e);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function Ps(e){const t=Zo(e);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function Es(e){return new q().set(...e.flat())}function uo(e,t){return[e.object,e.mesh,e.armature,e.vertexCount,e.bones.length,t].join("|")}class Ns{#n=new Map;#o=null;#a=null;#t=null;#r=null;#e=null;#s=null;#l=new Set;#u=0;#m=[];#i=0;get version(){return this.#u}get engineCalls(){return this.#i}subscribe(t){return this.#l.add(t),()=>this.#l.delete(t)}#f(){this.#u++;for(const t of[...this.#l])t()}state(){const t=this.#t,n=t?.frameStart??1,o=t?.frameEnd??250,r=t?.fps??24;return{frame:this.frame(),start:n,end:o,fps:r,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((a,i)=>a+i.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#m,engineCalls:this.#i,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return this.#r!==null?this.#r:!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:t.clipStart+this.#a.time*t.fps}get playable(){return this.#t!==null&&this.#e!==null}async bind(t,n){this.#i++;const o=await n.rig();if(!o)return;const r=[],a=new Set;let i=!1;for(const m of o.rigs){if(!m.object||!m.armature||!m.skinIndexBase64||!m.skinWeightBase64){m.reason&&r.push(m.reason);continue}a.add(m.object);const _=uo(m,o.frame);if(this.#n.get(m.object)?.signature===_)continue;const h=this.#_(t,m,o.frame,r);h&&(this.#n.get(m.object)?.skeleton.dispose(),this.#n.set(m.object,h),i=!0)}for(const[m,_]of[...this.#n])a.has(m)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(m),i=!0);this.#i++;const f=await n.clip(),u=this.#t,d=f?.frameStart!==u?.frameStart||f?.frameEnd!==u?.frameEnd||f?.fps!==u?.fps,l=f?.action!==u?.action||f?.tracks.length!==u?.tracks.length||f?.clipStart!==u?.clipStart||f?.clipEnd!==u?.clipEnd;this.#t=f??null,(!f||f.scene!==u?.scene)&&(this.#r=null),f?.reason&&r.push(f.reason),f&&(l||i)&&this.#h(t,f,r);const s=this.#e?.snapshot().activeSubject;d&&s&&this.#e?.setActiveSubject(s);const c=this.#e?.snapshot().playbackState==="playing";f&&!c&&(d||u?.frameCurrent!==f.frameCurrent)&&(this.#c(f.frameCurrent),this.#e&&f.fps>0&&this.#e.seek(f.frameCurrent/f.fps)),this.#m=r,this.#f()}#_(t,n,o,r){const a=t.objectForBlenderName(n.object??""),i=t.objectForBlenderName(n.armature??"");if(!a||!i)return null;const f=a,u=f.geometry;if(!u)return null;const d=u.getAttribute("blenderVertex");if(!d)return r.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let l=0;for(let S=0;S<d.count;S++)l=Math.max(l,d.getX(S));if(l>=n.vertexCount)return r.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${l} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const s=Ps(n.skinIndexBase64??""),c=re(n.skinWeightBase64??""),m=d.count,_=new Uint16Array(m*4),h=new Float32Array(m*4);for(let S=0;S<m;S++){const T=d.getX(S);for(let O=0;O<4;O++)_[S*4+O]=s[T*4+O]??0,h[S*4+O]=c[T*4+O]??0}u.setAttribute("skinIndex",new Sa(_,4)),u.setAttribute("skinWeight",new Nt(h,4));const g=new ft;g.name=`${n.armature}:bones`;const p=[],v=n.bones.map(S=>Es(S.pose)),y=new Map(n.bones.map((S,T)=>[S.name,T]));n.bones.forEach((S,T)=>{const O=new Ma;O.name=S.name,p.push(O);const R=S.parent===null?void 0:y.get(S.parent);(R===void 0?v[T].clone():v[R].clone().invert().multiply(v[T])).decompose(O.position,O.quaternion,O.scale),(R===void 0?g:p[R]).add(O)}),i.add(g);const w=new Pa(u,f.material);w.name=f.name,w.matrixAutoUpdate=!1,w.matrix.copy(f.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=f.userData,w.frustumCulled=!1,t.replacePresentedObject(f,w),t.root.updateMatrixWorld(!0);const P=new Ea(p);return w.bind(P,w.matrixWorld.clone()),n.constrainedBones?.length&&r.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&r.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:w,boneRoot:g,bones:p,skeleton:P,frame:o,signature:uo(n,o)}}#h(t,n,o){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const r=n.armature?t.objectForBlenderName(n.armature):null;if(!r)return;const a=new Map;for(const s of this.#n.values())if(s.armature===n.armature)for(const c of s.bones)a.set(c.name,c);const i=[],f=new Set;for(const s of n.tracks){const c=a.get(s.bone);if(!c){f.add(s.bone);continue}const m=re(s.timeBase64),_=re(s.valueBase64),h=`${c.uuid}.${s.property}`;i.push(s.property==="quaternion"?new Na(h,Array.from(m),Array.from(_)):new Ra(h,Array.from(m),Array.from(_)))}if(f.size&&o.push(`${n.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!i.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,d=new Ia(r),l=d.clipAction(new za(n.action??"action",u,i));l.setLoop(Fa,Number.POSITIVE_INFINITY),l.play(),this.#o=d,this.#a=l,this.#c(n.frameCurrent),this.#d()}#c(t){const n=this.#t;if(!n)return;const o=Math.min(n.frameEnd,Math.max(n.frameStart,t));if(this.#r=o,!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const r=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.max(0,Math.min(r-1e-4,(o-n.clipStart)/n.fps))),this.#d()}#d(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const o=n.scene;return!o||n.frameCurrent===t||(this.#i++,await $a(`bpy.data.scenes[${JSON.stringify(o)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#s?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const i=this.#t,f=i?.fps||24;return{start:(i?.frameStart??1)/f,end:(i?.frameEnd??250)/f,fps:f}},seek:i=>this.seekSeconds(i)}),o=t.onSettled(()=>{this.writeBookmark()}),r=()=>{o(),n(),this.#e===t&&(this.#e=null),this.#s=null};this.#s=r;const a=this.#t;return a&&a.fps>0&&t.seek(a.frameCurrent/a.fps),r}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#s?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null,this.#t=null,this.#r=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const Qo=new Ns;function ks(e){return Qo.subscribe(e)}function $s(){return Qo.version}export{Qo as a,$s as b,Cs as c,ks as s};
7191
+ #include <opaque_fragment>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const is=64;function ss(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,o)=>n===t[o]):e===t}function sn(e){for(let t=e;t;t=t.parent)if(!t.visible)return!1;return!0}function xe(e){if(e.determinant()<=0)return!1;const t=e.elements,n=Math.hypot(t[0],t[1],t[2]),o=Math.hypot(t[4],t[5],t[6]),r=Math.hypot(t[8],t[9],t[10]),a=(i,f)=>t[i]*t[f]+t[i+1]*t[f+1]+t[i+2]*t[f+2];return Number.isFinite(n+o+r)&&Math.min(n,o,r)>0&&Math.abs(a(0,4))<=1e-7*n*o&&Math.abs(a(0,8))<=1e-7*n*r&&Math.abs(a(4,8))<=1e-7*o*r}class ls{constructor(t){this.root=t,this.batches=[],this.inverse=new q,this.matrix=new q,this.box=new ln,this.projection=new q,this.frustum=new Hn,this.camera=null,this.eligible=0,this.excluded={}}rebuild(t,n){if(this.clear(),!n)return;const o=new Map,r=a=>{this.excluded[a]=(this.excluded[a]??0)+1};this.inverse.copy(this.root.matrixWorld).invert();for(const a of t){const i=a;if(!i.isMesh)continue;if(i.isSkinnedMesh||i.isInstancedMesh||i.morphTargetInfluences||i.layers.mask!==1){r("deformationOrLayers");continue}const f=Array.isArray(i.material)?i.material:[i.material];if(f.some(l=>l.transparent||l.transmission>0||l.isShaderMaterial)){r("material");continue}if(f.some(l=>Wo(l,i.geometry).size>12)){r("attributeBudget");continue}if(this.matrix.multiplyMatrices(this.inverse,i.matrixWorld),!xe(this.matrix)){r("transform");continue}this.eligible++;const u=`${i.geometry.id}:${Array.isArray(i.material)?"slots":"single"}:`+f.map(l=>l.uuid).join(",")+`:${i.renderOrder}`,d=o.get(u);d?d.push(i):o.set(u,[i])}for(const a of o.values()){if(a.length<2)continue;const i=f=>{if(f.length>is){this.box.makeEmpty();for(const _ of f)this.box.expandByPoint(new b().setFromMatrixPosition(_.matrixWorld));const s=this.box.getSize(new b),c=s.x>=s.y&&s.x>=s.z?12:s.y>=s.z?13:14;f.sort((_,h)=>_.matrixWorld.elements[c]-h.matrixWorld.elements[c]);const m=Math.floor(f.length/2);i(f.slice(0,m)),i(f.slice(m));return}if(f.length<2)return;const u=f[0],d=new Oo(u.geometry,u.material,f.length);d.name="Blender repeated geometry",d.userData.engineInternal=!0,d.matrixAutoUpdate=!1,d.renderOrder=u.renderOrder,d.instanceMatrix.setUsage(Ao);const l={draw:d,members:f.map(s=>({mesh:s,layers:s.layers.mask}))};d.raycast=(s,c)=>{for(const{mesh:m}of l.members)m.layers.mask===0&&sn(m)&&m.raycast(s,c)},this.root.add(d),d.updateMatrixWorld(!0),this.batches.push(l)};i(a)}this.sync()}sync(){if(this.batches.length){this.inverse.copy(this.root.matrixWorld).invert();for(const{draw:t,members:n}of this.batches){let o=0,r=!1;for(const a of n){const{mesh:i}=a;if(this.matrix.multiplyMatrices(this.inverse,i.matrixWorld),!(i.parent!==null&&i.geometry===t.geometry&&ss(i.material,t.material)&&xe(this.matrix))){i.layers.mask|=a.layers;continue}if(i.layers.mask&=~a.layers,!sn(i)||this.camera&&(!this.camera.layers.isEnabled(0)||i.frustumCulled&&!this.frustum.intersectsObject(i)))continue;const u=o*16;this.matrix.elements.some((d,l)=>Math.fround(d)!==t.instanceMatrix.array[u+l])&&(t.setMatrixAt(o,this.matrix),r=!0),o++}r||=t.count!==o||t.boundingSphere===null,t.count=o,r&&(t.instanceMatrix.needsUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere())}}}prepareDraw(t){t.updateMatrixWorld(),this.camera=t,this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection)}finishDraw(){this.camera=null}clear(){this.camera=null;for(const{draw:t,members:n}of this.batches){for(const{mesh:o,layers:r}of n)o.layers.mask|=r;t.removeFromParent(),t.dispose()}this.batches.length=0,this.eligible=0,this.excluded={}}inspect(){return{batches:this.batches.length,instances:this.batches.reduce((t,{draw:n})=>t+n.count,0),eligible:this.eligible,excluded:{...this.excluded}}}}const gn=64;function so(e){for(let t=e.parent;t;t=t.parent)if(t.isGroup)return t.renderOrder;return 0}class fs{constructor(t){this.root=t,this.objects=[],this.pools=new Map,this.hidden=[],this.inverse=new q,this.matrix=new q,this.projection=new q,this.frustum=new Hn,this.centre=new b,this.depth=new Un,this.batches=0,this.instances=0,this.excluded={},this.planState=[],this.planned=[],this.stateIndex=0,this.stateChanged=!1}setObjects(t){this.clear(),this.objects=[...t].filter(n=>n.isMesh===!0)}prepare(t){if(this.finishDraw(),!this.objects.length)return;if(t.updateMatrixWorld(),this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),!this.planChanged(t)){for(const a of this.planned){a.mesh.visible=!0;for(const i of a.members)i.layers.disable(0),this.hidden.push(i)}return}this.planned.length=0;for(const a of this.pools.values())for(const i of a)i.mesh.visible=!1,i.members.length=0;this.batches=this.instances=0,this.excluded={},this.frustum.setFromProjectionMatrix(this.projection),this.inverse.copy(this.root.matrixWorld).invert();const n=[],o=new Map;for(const a of this.objects){const i=Array.isArray(a.material)?a.material:[a.material];if(!i.some(_=>_.visible&&_.transparent)||!sn(a)||!a.layers.test(t.layers)||a.frustumCulled&&!this.frustum.intersectsObject(a))continue;const f=a;f.boundingSphere!==void 0?(f.boundingSphere===null&&f.computeBoundingSphere?.(),this.centre.copy(f.boundingSphere.center)):(a.geometry.boundingSphere||a.geometry.computeBoundingSphere(),this.centre.copy(a.geometry.boundingSphere.center)),this.centre.applyMatrix4(a.matrixWorld);const u=this.centre.clone(),d=this.depth.set(u.x,u.y,u.z,1).applyMatrix4(this.projection).z;let l=null,s=null;const c=i.length===1?i[0]:null,m=so(a);if(c&&c.visible&&c.transparent&&!c.isShaderMaterial&&!(c.transmission>0)&&(c.side!==$n||c.forceSinglePass)&&!a.isSkinnedMesh&&!a.morphTargetInfluences&&!a.isInstancedMesh&&a.layers.mask===1&&m===this.root.renderOrder){const _=a.geometry,h=_.index?.count??_.getAttribute("position").count,g=!Array.isArray(a.material)||_.groups.length===1&&_.groups[0].start===0&&_.groups[0].count===h&&_.groups[0].materialIndex===0,p=`${_.id}:${c.uuid}:${a.renderOrder}`;let v=o.get(p);v===void 0&&(v=Wo(c,_).size<=12,o.set(p,v)),this.matrix.multiplyMatrices(this.inverse,a.matrixWorld),g&&v&&xe(this.matrix)&&(l=c,s=p)}if(s===null){const _=c?c.isShaderMaterial?"customShader":c.transmission>0?"transmission":c.side===$n&&!c.forceSinglePass?"twoPass":"geometryLayersOrTransform":"multipleMaterials";this.excluded[_]=(this.excluded[_]??0)+1}n.push({mesh:a,material:l,key:s,groupOrder:m,z:d,centre:u})}n.sort((a,i)=>a.groupOrder-i.groupOrder||a.mesh.renderOrder-i.mesh.renderOrder||i.z-a.z||a.mesh.id-i.mesh.id);const r=new Map;for(let a=0;a<n.length;){const i=n[a];let f=a+1;if(i.key!==null)for(;f<n.length&&n[f].key===i.key;)f++;const u=n[a-1],d=n[f],l=u?.z===i.z&&u.mesh.renderOrder===i.mesh.renderOrder||d?.z===n[f-1].z&&d.mesh.renderOrder===i.mesh.renderOrder;if(i.key!==null&&f-a>=2&&!l){let s=!0;for(let c=a+gn;c<f;c+=gn)n[c-1].z===n[c].z&&(s=!1);if(s)for(let c=a;c<f;c+=gn){const m=Math.min(gn,f-c);if(m<2)continue;const _=n[c],h=r.get(i.key)??0;r.set(i.key,h+1);let g=this.pools.get(i.key);g||(g=[],this.pools.set(i.key,g));let p=g[h];if(!p){const v=new Oo(i.mesh.geometry,i.material,gn);v.name="Blender ordered transparency",v.userData.engineInternal=!0,v.matrixAutoUpdate=!1,v.frustumCulled=!1,v.boundingSphere=new To,v.instanceMatrix.setUsage(Ao),p={mesh:v,members:[]};const y=p;v.raycast=(w,P)=>{if(v.visible)for(const S of y.members)sn(S)&&S.raycast(w,P)},g.push(p),this.root.add(v)}p.mesh.visible=!0,p.mesh.renderOrder=_.mesh.renderOrder,p.mesh.boundingSphere.center.copy(_.centre).applyMatrix4(this.inverse),p.mesh.updateMatrixWorld(!0);for(let v=0;v<m;v++){const y=n[c+v].mesh;this.matrix.multiplyMatrices(this.inverse,y.matrixWorld),p.mesh.setMatrixAt(v,this.matrix),p.members.push(y),y.layers.disable(0),this.hidden.push(y)}p.mesh.count=m,p.mesh.instanceMatrix.needsUpdate=!0,this.planned.push(p),this.batches++,this.instances+=m}}a=f}}inspect(){return{batches:this.batches,instances:this.instances,excluded:{...this.excluded}}}observe(t){this.planState[this.stateIndex]!==t&&(this.planState[this.stateIndex]=t,this.stateChanged=!0),this.stateIndex++}planChanged(t){this.stateIndex=0,this.stateChanged=this.planState.length===0,this.observe(t.layers.mask);for(const n of this.projection.elements)this.observe(n);for(const n of this.root.matrixWorld.elements)this.observe(n);for(const n of this.objects){this.observe(n.parent?.id??-1),this.observe(sn(n)?1:0),this.observe(n.layers.mask),this.observe(n.renderOrder),this.observe(so(n)),this.observe(n.frustumCulled?1:0),this.observe(n.morphTargetInfluences?1:0);for(const i of n.matrixWorld.elements)this.observe(i);const o=n.geometry;this.observe(o.id),this.observe(o.drawRange.start),this.observe(o.drawRange.count),this.observe(o.index?.count??o.getAttribute("position").count),this.observe(o.groups.length);for(const i of o.groups)this.observe(i.start),this.observe(i.count),this.observe(i.materialIndex??0);const r=n.boundingSphere??o.boundingSphere;this.observe(r?.center.x??0),this.observe(r?.center.y??0),this.observe(r?.center.z??0),this.observe(r?.radius??-1);const a=Array.isArray(n.material)?n.material:null;if(this.observe(a?.length??-1),a)for(const i of a)this.observeMaterial(i);else this.observeMaterial(n.material)}return this.stateChanged||=this.planState.length!==this.stateIndex,this.planState.length=this.stateIndex,this.stateChanged}observeMaterial(t){this.observe(t.uuid),this.observe(t.version),this.observe(t.visible?1:0),this.observe(t.transparent?1:0),this.observe(t.side),this.observe(t.forceSinglePass?1:0),this.observe(t.transmission??0)}finishDraw(){for(const t of this.hidden)t.layers.enable(0);this.hidden.length=0;for(const t of this.pools.values())for(const{mesh:n}of t)n.visible=!1}clear(){this.finishDraw();for(const t of this.pools.values())for(const{mesh:n}of t)n.removeFromParent(),n.dispose();this.pools.clear(),this.planned.length=0,this.planState.length=0,this.objects=[],this.batches=this.instances=0}}const ae=64*1024*1024,lo=150,In=49152,Pt=8192,fo=Symbol("navigation geometry replaced");class cs{constructor(t){this.invalidate=t,this.groups=new Map,this.cache=new Map,this.swapped=[],this.queue=[],this.worker=null,this.pending=null,this.generation=0,this.building=!1,this.nextId=0,this.signature="",this.identities=new WeakMap,this.nextIdentity=0,this.bytes=0,this.unavailable=null,this.reductions=[],this.timer=null,this.cameraWorld=new q,this.cameraProjection=new q,this.cameraKnown=!1,this.movedAt=-1/0,this.projection=new q,this.frustum=new Hn,this.centre=new b,this.drawnMeshes=0,this.fullTriangles=0,this.motionTriangles=0,this.lastNavigation={meshes:0,fullTriangles:0,motionTriangles:0,tooClose:0},this.quietTimer=null}setObjects(t){const n=new Map;for(const i of t){const f=i;if(!f.isMesh||f.isSkinnedMesh||f.isInstancedMesh||f.morphTargetInfluences)continue;const u=f.geometry,d=u.getAttribute("position");if(!u.index||u.index.count<6144||!d||d.count>8e6||Object.values(u.attributes).some(s=>!(s instanceof ut)||s.isFloat16BufferAttribute||s.isInstancedBufferAttribute)||Object.keys(u.morphAttributes).length||u.drawRange.start!==0||u.drawRange.count<u.index.count)continue;if(Array.isArray(f.material)){let s=0;if(!u.groups.length||u.groups.some(c=>{const m=c.start===s&&c.count>0&&c.count%3===0&&Number.isInteger(c.materialIndex)&&c.materialIndex>=0&&c.materialIndex<f.material.length;return s=c.start+c.count,!m})||s!==u.index.count)continue}const l=n.get(u);l?l.push(f):n.set(u,[f])}this.groups=n;const o=i=>{let f=this.identities.get(i);return f===void 0&&(f=++this.nextIdentity,this.identities.set(i,f)),f},r=[...n].map(([i,f])=>`${i.id}:${o(i.index)}:${i.index.version}:${Array.isArray(f[0].material)}:${JSON.stringify(i.groups)}:`+Object.entries(i.attributes).map(([u,d])=>`${u}:${o(d)}:${d.version}`).join(",")).join(";");if(r===this.signature)return;this.releaseCopies(),this.signature=r,this.unavailable=null;const a=[...n].filter(([,i])=>i.length>=3);a.reduce((i,[f,u])=>i+f.index.count*u.length,0)<6e6||(a.sort(([i,f],[u,d])=>u.index.count*d.length-i.index.count*f.length),this.queue=a.map(([i])=>i),this.next())}async next(){if(this.building||this.unavailable||this.bytes>=ae)return;const t=this.queue.shift();if(!t){this.worker?.terminate(),this.worker=null;return}this.building=!0;const n=this.generation,o=()=>{if(n!==this.generation)throw fo;if(this.unavailable)throw new Error(this.unavailable)},r=async()=>{await new Promise(a=>setTimeout(a,0)),o()};try{this.worker||(this.worker=new Worker(new URL("/assets/blender-motion-worker-CtT2cV3V.js",import.meta.url),{type:"module"}),this.worker.onmessage=x=>{if(this.pending?.id===x.data.id){const E=this.pending;this.pending=null,E.resolve(x.data)}},this.worker.onerror=x=>{this.unavailable=x.message||"Navigation geometry worker unavailable",this.worker?.terminate(),this.worker=null;const E=this.pending;this.pending=null,E?.resolve({id:E.id,refusal:this.unavailable})});const a=t.getAttribute("position"),i=this.groups.get(t),f=Array.isArray(i[0].material);if(i.some(x=>Array.isArray(x.material)!==f))return;const u=f?t.groups:[{start:0,count:t.index.count}],d=u.flatMap(x=>{const E=[];for(let A=x.start;A<x.start+x.count;A+=In)E.push({start:A,count:Math.min(In,x.start+x.count-A),materialIndex:x.materialIndex});return E}),l=t.getAttribute("blenderVertex"),s=new Uint32Array(a.count),c=new Uint8Array(a.count),m=x=>l?l.getX(x):x;for(let x=0;x<d.length;x++){const E=d[x];for(let A=E.start;A<E.start+E.count;A+=Pt){await r();for(let U=A;U<Math.min(A+Pt,E.start+E.count);U++){const k=m(t.index.getX(U));if(!Number.isInteger(k)||k<0||k>=s.length)return;s[k]?s[k]!==x+1&&(c[k]=1):s[k]=x+1}}}const _=Object.entries(t.attributes).filter(([x])=>x!=="position"&&x!=="blenderVertex"),h=_.reduce((x,[,E])=>x+E.itemSize,0);if(h>32)return;const g=[];let p=0;for(const[x,E]of _)for(let A=0;A<E.itemSize;A++,p++)x!=="normal"&&g.push(p);const v=_.flatMap(([x,E])=>Array(E.itemSize).fill(x==="normal"?.5:1)),y=t.boundingBox?.clone()??new ln;if(!t.boundingBox){const x=new b;for(let E=0;E<a.count;E+=Pt){await r();for(let A=E;A<Math.min(E+Pt,a.count);A++)y.expandByPoint(x.fromBufferAttribute(a,A))}}if(!t.boundingSphere)return;const w=Math.max(y.max.x-y.min.x,y.max.y-y.min.y,y.max.z-y.min.z)*.002,P=[],S=[];let T=0,O=0;for(const x of u){const E=T;for(let A=x.start;A<x.start+x.count;A+=In){await r();const U=Math.min(A+In,x.start+x.count),k=[],C=new Map,M=new Uint32Array(U-A);for(let K=A;K<U;K++){const mt=t.index.getX(K);let St=C.get(mt);St===void 0&&(St=k.length,k.push(mt),C.set(mt,St)),M[K-A]=St}const B=new Uint8Array(k.length),Q=new Float32Array(k.length*3),ot=new Float32Array(k.length*h);for(let K=0;K<k.length;K+=Pt){await r();for(let mt=K;mt<Math.min(K+Pt,k.length);mt++){const St=k[mt];B[mt]=c[m(St)];for(let Ft=0;Ft<3;Ft++)Q[mt*3+Ft]=a.getComponent(St,Ft);let Wt=0;for(const[,Ft]of _){for(let An=0;An<Ft.itemSize;An++)ot[mt*h+Wt+An]=Ft.getComponent(St,An);Wt+=Ft.itemSize}}}const ct=++this.nextId,nt=await new Promise(K=>{this.pending={id:ct,resolve:K};const mt={id:ct,positions:Q,indices:M,attributes:ot,stride:h,weights:v,absoluteError:w,protectedComponents:g,locks:B};this.worker.postMessage(mt,[Q.buffer,M.buffer,ot.buffer,B.buffer])});if(o(),nt.refusal)throw new Error(nt.refusal);if(!nt.indices||!Number.isFinite(nt.error))throw new Error("Invalid navigation geometry response");const rt=nt.indices;for(let K=0;K<rt.length;K++)rt[K]=k[rt[K]];if(T+=rt.length,T*4>ae-this.bytes)return;P.push(rt),O=Math.max(O,nt.error)}f&&S.push({start:E,count:T-E,materialIndex:x.materialIndex})}const R={vertices:a.count,fullTriangles:t.index.count/3,reducedTriangles:T/3,error:O,accepted:!1};if(this.reductions.length<32&&this.reductions.push(R),!T||T>=t.index.count*.75)return;const $=new Int32Array(a.count).fill(-1),j=[],H=new Uint32Array(T);let tt=0;for(const x of P){for(let E=0;E<x.length;E+=Pt){await r();for(let A=E;A<Math.min(E+Pt,x.length);A++){const U=x[A];let k=$[U];k<0&&(k=j.length,j.push(U),$[U]=k),H[tt+A]=k}}tt+=x.length}const Z=H.byteLength+Object.values(t.attributes).reduce((x,E)=>x+j.length*E.itemSize*E.array.BYTES_PER_ELEMENT,0);if(R.bytes=Z,this.bytes+Z>ae)return;const et=new un;et.setIndex(new ut(H,1));for(const[x,E]of Object.entries(t.attributes)){const A=E,U=A.array.constructor,k=new U(j.length*A.itemSize);for(let C=0;C<j.length;C+=Pt){await r();for(let M=C;M<Math.min(C+Pt,j.length);M++)for(let B=0;B<A.itemSize;B++)k[M*A.itemSize+B]=A.array[j[M]*A.itemSize+B]}et.setAttribute(x,new ut(k,A.itemSize,A.normalized))}et.boundingSphere=t.boundingSphere.clone(),et.boundingBox=y.clone();for(const x of S)et.addGroup(x.start,x.count,x.materialIndex);et.userData={...t.userData},R.accepted=!0,this.cache.set(t,{geometry:et,error:O,bytes:Z}),this.bytes+=Z}catch(a){if(a===fo)return;this.unavailable=String(a),this.worker?.terminate(),this.worker=null,this.pending=null,this.queue.length=0}finally{n===this.generation&&(this.building=!1,this.timer=setTimeout(()=>{this.timer=null,this.next()},0))}}prepare(t,n,o){if(this.finish(),this.drawnMeshes=this.fullTriangles=this.motionTriangles=0,!n||!(o>0))return!1;const r=performance.now(),a=this.cameraKnown&&(!t.matrixWorld.equals(this.cameraWorld)||!t.projectionMatrix.equals(this.cameraProjection));if(this.cameraKnown=!0,this.cameraWorld.copy(t.matrixWorld),this.cameraProjection.copy(t.projectionMatrix),a&&(this.movedAt=r,this.quietTimer&&clearTimeout(this.quietTimer),this.quietTimer=setTimeout(()=>{this.quietTimer=null,this.invalidate()},lo+1)),r-this.movedAt>lo)return!1;this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection);let i=0;for(const[f,u]of this.cache)for(const d of this.groups.get(f)??[]){if(!sn(d)||d.frustumCulled&&!this.frustum.intersectsObject(d))continue;const l=d.matrixWorld.elements,s=l[0]**2+l[1]**2+l[2]**2,c=l[4]**2+l[5]**2+l[6]**2,m=l[8]**2+l[9]**2+l[10]**2,_=Math.abs(l[0]*l[4]+l[1]*l[5]+l[2]*l[6]),h=Math.abs(l[0]*l[8]+l[1]*l[9]+l[2]*l[10]),g=Math.abs(l[4]*l[8]+l[5]*l[9]+l[6]*l[10]),p=Math.sqrt(Math.max(s+_+h,c+_+g,m+h+g)),v=f.boundingSphere;this.centre.copy(v.center).applyMatrix4(d.matrixWorld).applyMatrix4(t.matrixWorldInverse);const y=t.isPerspectiveCamera?-this.centre.z-v.radius*p:1,w=u.error*p*Math.abs(t.projectionMatrix.elements[5])*o/(2*y);if(!(y>0)||w>1){i++;continue}this.swapped.push({mesh:d,geometry:f}),d.geometry=u.geometry,this.drawnMeshes++,this.fullTriangles+=f.index.count/3,this.motionTriangles+=u.geometry.index.count/3}return this.lastNavigation={meshes:this.drawnMeshes,fullTriangles:this.fullTriangles,motionTriangles:this.motionTriangles,tooClose:i},this.swapped.length>0}finish(){for(const{mesh:t,geometry:n}of this.swapped)t.geometry=n;this.swapped.length=0}inspect(){return{copies:this.cache.size,bytes:this.bytes,queued:this.queue.length,pending:this.building,unavailable:this.unavailable,reductions:this.reductions.map(t=>({...t})),lastNavigation:{...this.lastNavigation}}}releaseCopies(){this.finish(),this.timer&&clearTimeout(this.timer),this.timer=null,this.generation++,this.worker?.terminate(),this.worker=null,this.pending?.resolve({id:this.pending.id,refusal:"Navigation geometry replaced"}),this.pending=null,this.building=!1,this.queue=[];for(const t of this.cache.values())t.geometry.dispose();this.cache.clear(),this.bytes=0,this.reductions=[]}clear(){this.releaseCopies(),this.quietTimer&&clearTimeout(this.quietTimer),this.quietTimer=null,this.groups.clear(),this.signature="",this.cameraKnown=!1,this.movedAt=-1/0}}const us={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},F=I().finite(),Go=W([F,F,F]),zn=W([I().int().nonnegative(),I().int().nonnegative()]),pt={name:z(),domain:Y(["POINT","EDGE","FACE","CORNER"])},ms=Ca("type",[N({...pt,type:X("FLOAT2"),data:L(W([F,F]))}).strict(),N({...pt,type:X("FLOAT_VECTOR"),data:L(Go)}).strict(),N({...pt,type:X("FLOAT_COLOR"),data:L(W([F,F,F,F]))}).strict(),N({...pt,type:X("BYTE_COLOR"),data:L(W([F,F,F,F]))}).strict(),N({...pt,type:X("QUATERNION"),data:L(W([F,F,F,F]))}).strict(),N({...pt,type:X("FLOAT4"),data:L(W([F,F,F,F]))}).strict(),N({...pt,type:X("FLOAT4X4"),data:L(L(F).length(16))}).strict(),N({...pt,type:X("INT16_2D"),data:L(W([I().int(),I().int()]))}).strict(),N({...pt,type:X("INT32_2D"),data:L(W([I().int(),I().int()]))}).strict(),N({...pt,type:X("FLOAT"),data:L(F)}).strict(),N({...pt,type:X("INT"),data:L(I().int())}).strict(),N({...pt,type:X("INT8"),data:L(I().int())}).strict(),N({...pt,type:X("BOOLEAN"),data:L(at())}).strict(),N({...pt,type:X("STRING"),data:L(z())}).strict()]),ds=N({positions:G(Float32Array),normals:G(Float32Array).nullable(),uv:G(Float32Array).nullable(),uvLayers:L(N({name:z(),data:G(Float32Array)}).strict()).optional(),attributeLayers:L(N({name:z(),data:G(Float32Array)}).strict()).optional(),orco:G(Float32Array).nullable().optional(),indices:G(Uint32Array),groups:L(N({start:I().int().nonnegative(),count:I().int().nonnegative(),materialIndex:I().int().nonnegative()}).strict()),hash:z()}).strict(),_s=N({v:L(Go),f:L(L(I().int().nonnegative())),e:L(zn).optional(),edge_order:L(zn).optional(),m:L(I().int().nonnegative()).optional(),s:L(at()).optional(),sharp:L(zn).optional(),seams:L(zn).optional(),creases:L(W([F,F,F])).optional(),attributes:L(ms).optional(),active_uv:z().nullable().optional(),render_uv:z().nullable().optional()}).strict(),hs=N({store:I().int().optional(),revision:I().int(),unchanged:X(!0)}).strict(),ps=N({co:Ut([G(Float32Array),G(Float64Array)]),cornerNormal:G(Float32Array).optional(),cornerTri:G(Uint32Array).optional(),orco:G(Float32Array).optional(),faceStart:G(Uint32Array),corner:G(Uint32Array),cornerEdge:G(Int32Array),edge:G(Uint32Array),edgeSharp:G(Uint8Array),edgeSeam:G(Uint8Array),edgeCrease:G(Float32Array),material:G(Uint32Array),smooth:G(Uint8Array),vertSelect:G(Uint8Array),vertHide:G(Uint8Array),edgeSelect:G(Uint8Array),edgeHide:G(Uint8Array),faceSelect:G(Uint8Array),faceHide:G(Uint8Array)}).strict(),gs=N({name:z(),domain:Y(["POINT","EDGE","FACE","CORNER"]),type:z(),data:ka(e=>ArrayBuffer.isView(e))}).strict(),Xo=N({columns:ps,attributes:L(gs),activeUv:z().nullable(),renderUv:z().nullable(),counts:N({verts:I().int().nonnegative(),edges:I().int().nonnegative(),faces:I().int().nonnegative(),corners:I().int().nonnegative()}).strict(),revision:I().int().nonnegative()}).strict(),vs=Ut([ds,Xo,_s,hs]),co=new Set;function xs(e,t){const n=new Blob([e],{type:t}),o=new Ta;let r=!1;o.addEventListener("dispose",()=>{r=!0,o.image?.close?.()});const a=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(i=>{if(r){i.close();return}o.image=i,o.needsUpdate=!0,gt()}).finally(()=>{co.delete(a)});return co.add(a),a.catch(()=>{}),{texture:o,ready:a}}function bs(e,t,n,o){const r=new Wn(e,t,n,qn,Aa);return r.flipY=!1,r.colorSpace=o==="data"?Ln:Bt,r.needsUpdate=!0,r}function ys(e,t,n){if(t.length===0)throw new Error(`Runtime image ${e} is tiled with no tiles`);const o=Math.max(...t.map(l=>l.width)),r=Math.max(...t.map(l=>l.height)),a=new Uint8Array(o*r*4*t.length),i=Math.max(...t.map(l=>l.number-1001))+1,f=new Float32Array(i*2*4);for(let l=0;l<i;l++)f[l*4]=-1;t.forEach((l,s)=>{const c=l.rgba??(l.rgbaBase64?ue(l.rgbaBase64):void 0);if(!c)throw new Error(`Runtime image ${e} tile ${l.number} carries no raster`);for(let _=0;_<l.height;_++)a.set(c.subarray(_*l.width*4,(_+1)*l.width*4),(s*r+_)*o*4);const m=l.number-1001;f[m*4]=s,f.set([0,0,l.width/o,l.height/r],(i+m)*4)});const u=new Oa(a,o,r,t.length);u.colorSpace=n==="data"?Ln:Bt,u.magFilter=Jt,u.minFilter=So,u.generateMipmaps=!0,u.needsUpdate=!0;const d=new Wn(f,i,2,qn,xo);return d.magFilter=d.minFilter=fe,d.needsUpdate=!0,{tiles:u,map:d,frame:t}}const ws=N({width:I().int().positive(),height:I().int().positive(),revision:I().int().nonnegative(),rgba:G(Uint8Array).optional(),rgbaBase64:z().optional(),colorspace:Y(["sRGB","data"]).optional(),tiles:L(N({number:I().int().min(1001),width:I().int().positive(),height:I().int().positive(),rgba:G(Uint8Array).optional(),rgbaBase64:z().optional()}).strict()).optional()}).strict(),Os=N({revision:I().int().nonnegative(),encoded:G(Uint8Array).optional(),encodedBase64:z().optional(),mime:Y(["image/png","image/jpeg"]),colorspace:Y(["sRGB","data"]).optional()}).strict(),Yo=Ut([ws,Os]),re=N({image:N({name:z(),revision:I().int().nonnegative()}).strict(),extension:Y(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:z(),tint:W([F,F,F]).optional()}).strict(),As=N({name:z(),color:W([F,F,F,F]),roughness:F,metallic:F,transmission:F,ior:F,physical:Mi.optional(),normal_texture:re.optional(),normal_strength:F.default(1),normal_space:Y(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:at().default(!1),texture:re.optional(),roughness_texture:re.optional(),emission:N({color:W([F,F,F]),strength:F}).strict().optional(),graph:ni.optional(),viewport:N({color:W([F,F,F,F]),roughness:F,metallic:F}).strict().optional()}).strict(),Ts=N({session:z(),revision:I().int().nonnegative(),volumes:Ot(z(),Lo).default({}),lights:Ot(z(),$r).default({}),world:Hr.nullable().default(null),meshes:Ot(z(),vs),materials:Ot(z(),As),images:Ot(z(),Yo).default({}),objects:L(N({id:z(),name:z(),type:Y(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:z().nullable(),volume:z().nullable().optional(),light:z().nullable().optional(),materials:L(z().nullable()),matrix:L(W([F,F,F,F])).length(4),visible:at(),render_visible:at().default(!0),selected:at(),parent:z().nullable(),texspace:W([W([F,F,F]),W([F,F,F])]).optional(),default_color:z().optional()}).strict()),active:z().nullable(),mode:z(),cameras:Ot(z(),Ot(z(),Po())).default({}),warnings:L(z()).default([]),updated:L(z()).default([]),frame:I().int().default(0),armatures:Ot(z(),ja).default({}),weights:zi.nullable().default(null),cursor:$i.optional(),camera_view:N({scene_camera:z().nullable(),view_layer_cameras:L(z()),aspect:I().finite().positive()}).optional(),light_distances:Ot(z(),W([I().finite(),I().finite()])).default({}),empties:Ot(z(),Wi).default({}),view:N({location:W([I(),I(),I()]),rotation:W([I(),I(),I(),I()]),distance:I().finite(),perspective:Y(["PERSP","ORTHO","CAMERA"]),lens:I().finite().positive().default(50),shading:Y(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:N({frame:I().int(),body:z(),markers:L(W([I().int(),z()]))}).optional(),units:N({system:Y(["NONE","METRIC","IMPERIAL"]),scale_length:I().finite()}).optional()}).strict();function Ss(e,t){for(let n=0,o=e.length-1;n<e.length&&o>=0;n++,o--){if(e[n][0]===t)return e[n][1];if(n===o)break;if(e[o][0]===t)return e[o][1]}return null}const Ms={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class Bn{constructor(){this.root=new ft,this.instances=new ls(this.root),this.transparentInstances=new fs(this.root),this.motionGeometry=new cs(gt),this.drawBatching=!0,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new qr,this.world=new Se,this.armatureOverlay=new Ka,this.weightOverlay=new ki,this.cursorOverlay=new Ui,this.extrasOverlay=new Gi,this.armatureRoot=new ft,this.weightRoot=new ft,this.cursorRoot=new ft,this.cameraExtrasRoot=new ft,this.lightExtrasRoot=new ft,this.emptyExtrasRoot=new ft,this.rendered=!1,this.heldRendered=null,this.worldApplied=null,this.worldKey="null",this.capturing=!1,this.workbench=!1,this.workbenchMaterials=new Map,this.fallback=new fn({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new Si,this.graphSamplers=new Map,this.photograph=!1,this.graphs=new Map,this.frame=null,this.retiredSessions=new Set,this.geometryBuilds=0,this.submittedMeshes=new Map,this.submitted=null,this.submittedSession=null,this.photographs=[],this.frameListeners=new Set,this.followers=new Set,this.leader=null,this.cameraViewZoom=Zi,this.cameraViewPan=Qi,this.mode=null,this.drawPreparation={last:null,navigation:null},this.awaitedImages=new Set,this.lookingThrough=null,this.staged=null;const t=this.root.updateMatrixWorld.bind(this.root);this.root.updateMatrixWorld=n=>{t(n),this.instances.sync()},this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[n,o]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group],[this.cursorRoot,this.cursorOverlay.group],[this.cameraExtrasRoot,this.extrasOverlay.cameras],[this.lightExtrasRoot,this.extrasOverlay.lights],[this.emptyExtrasRoot,this.extrasOverlay.empties]])n.matrixAutoUpdate=!1,n.matrix.copy(this.root.matrix),n.add(o),n.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const n of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])n.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let o=this.graphs.get(n);return o||(o=hi(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,o)),o}mirrorPose(t){let n=null;for(const[a,i]of this.objects)if(i===t){n=a;break}if(n===null)return;const o=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let r=!1;for(const a of o){if(a===this)continue;const i=a.objects.get(n);i!==void 0&&(i.matrix.copy(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),r=!0)}r&&gt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),o=La(t);return()=>{n(),o()}}blenderObjectName(t){for(const[n,o]of this.objects)if(o===t)return this.frame?.objects.find(r=>r.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,o,r,a]=t.rotation,i=new Mt(o,r,a,n),f=new b(...t.location).applyMatrix4(this.root.matrix),u=d=>d.applyQuaternion(i).applyMatrix4(this.root.matrix).normalize();return{target:f.toArray(),direction:u(new b(0,0,1)).toArray(),up:u(new b(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?us[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(o=>t.cameras[o])??null}blenderPose(t,n){const o=new q().copy(this.root.matrix).invert(),r=new q().compose(new b(...t),new Mt(...n),new b(1,1,1)).premultiply(o),a=new b,i=new Mt;return r.decompose(a,i,new b),{location:a.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,n,o,r){const a=this.frame,i=ro.safeParse(a?.cameras[t]);return!a?.camera_view||!i.success?null:Ki(i.data,this.root.matrix,n,o,r,a.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const o=t??n.frame,r=Ss(n.markers,o);return`(${o})${n.body}${r===null?"":` <${r}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const o=Ms[n.system],r=6*t,a=1/(n.scale_length||1);return(o.find(([f])=>f*a>r)??o[o.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(o=>o.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[o,r]of this.objects)if(r===t){const a=t.parent,i=[...t.children];t.removeFromParent();for(const f of i)n.add(f);a?.add(n),this.objects.set(o,n),this.rebuildInstances();return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,o){const r=new Set(this.objects.values()),a=this.cursorOverlay.placementAt(t,n,o,this.root,i=>r.has(i));return a!==null&&(this.cursorOverlay.show(a),gt()),a}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const o=t.isOrthographicCamera?t.getWorldDirection(new b).toArray().map(r=>r.toFixed(1)).join(","):"";return`${t.uuid}:${o}:${this.worldKey}`}report(t){t.then(gt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),gt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const o of this.frame?.objects??[]){if(o.mesh===null||o.volume)continue;const r=this.objects.get(o.id);if(!r?.isMesh)continue;const i=(o.materials.length?o.materials:[null]).map(f=>{const u=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,u.side,n):u});r.material=o.materials.length?i:i[0]}for(const[o,r]of this.workbenchMaterials)n.has(o)||(r.dispose(),this.workbenchMaterials.delete(o));this.rebuildInstances()}rebuildInstances(){this.transparentInstances.clear(),this.instances.rebuild(this.objects.values(),this.drawBatching&&!this.rendered),this.drawBatching&&!this.rendered&&this.transparentInstances.setObjects(this.objects.values()),this.motionGeometry.setObjects(this.objects.values())}setDrawBatching(t){t!==this.drawBatching&&(this.drawBatching=t,this.rebuildInstances(),gt())}prepareDraw(t,n){try{const o=performance.now();this.instances.prepareDraw(t),this.root.updateMatrixWorld(!0);const r=performance.now(),a=this.motionGeometry.prepare(t,!this.rendered&&(this.mode??this.frame?.mode)==="OBJECT"&&n?.interactive===!0,n?.height??0);a&&this.instances.sync();const i=performance.now();this.transparentInstances.prepare(t);const f={opaqueMs:r-o,motionMs:i-r,transparentMs:performance.now()-i};this.drawPreparation.last=f,a&&(this.drawPreparation.navigation=f)}catch(o){throw this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw(),o}return()=>{this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw()}}workbenchFor(t,n,o){const r=(t!==null?this.frame?.materials[t]?.viewport:void 0)??Ji,a=`${r.color.join(",")}|${r.roughness}|${r.metallic}|${n}`;o.add(a);let i=this.workbenchMaterials.get(a);return i||(i=rs(r,n),this.workbenchMaterials.set(a,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const o=(t?no(this.frame?.world)?.extinction:null)??new b;for(const a of[...this.materials.values(),this.fallback])Ei(a,o);this.rendered=t,this.lighting.setRendered(t);const r=t&&n?this.worldKeyFor(n):null;t?(this.capturing||r!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:r,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await Vr(),await Promise.all([...this.textures.values()].map(a=>a.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const o=[];for(const u of this.objects.values()){const d=u;if(d.isMesh&&(d.castShadow=t,d.receiveShadow=t,t&&d.visible)){const l=new ln().setFromObject(d);l.isEmpty()||o.push(l)}}if(!t||!o.length)return;const a=o.reduce((u,d)=>u.union(d),new ln).getBoundingSphere(new To),i=n?new Hn().setFromProjectionMatrix(new q().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=i?o.flatMap(u=>Yr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Zr(u,f,o):Ur(u,a.center,a.radius)}applyOverlays(t){const n=i=>{const f=t.objects.find(u=>u.name===i);return f===void 0?null:new q().set(...f.matrix.flat())},o=[...this.armatureOverlay.apply(t.armatures,n)],r=t.weights?this.objects.get(t.objects.find(i=>i.name===t.weights?.object)?.id??""):void 0,a=this.weightOverlay.apply(t.weights,r??null,t.weights?n(t.weights.object):null);return a!==null&&o.push(a),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),o}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),gt())}applyExtras(t){const n={};for(const[o,r]of Object.entries(t.cameras)){const a=ro.safeParse(r);a.success&&(n[o]=a.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(o=>o.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:o=>{const r=t.objects.find(a=>a.name===o);return r?this.objects.get(r.id)??null:null},image:o=>{const r=this.textures.get(o);if(!r)return null;const a=r.texture.image,i=r.width||a?.width||0,f=r.height||a?.height||0;return(i===0||f===0)&&r.ready&&!this.awaitedImages.has(o)&&(this.awaitedImages.add(o),r.ready.then(()=>{this.awaitedImages.delete(o),this.frame&&this.applyExtras(this.frame),gt()},()=>this.awaitedImages.delete(o))),{texture:r.texture,width:i,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const o=this.lights.get(t.light);o&&(o.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.capturing,this.weightOverlay.group.visible=!this.capturing,this.cursorOverlay.group.visible=!this.capturing;for(const t of[this.extrasOverlay.cameras,this.extrasOverlay.lights,this.extrasOverlay.empties])t.visible=!this.capturing}stageFrame(t){if(t.abort||!t.mesh&&!t.image){for(const o of this.staged?.meshes.values()??[])o.geometry.dispose();this.staged=t.abort?null:{session:t.session,revision:t.revision,meshes:new Map,images:new Map};return}const n=this.staged;if(!n||n.session!==t.session||n.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const o=Xo.parse(t.piece);if(n.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const r=`revision:${o.revision}`;n.meshes.set(t.mesh,{signature:r,geometry:Fn(Ve({...o.columns,attributes:o.attributes,activeUv:o.activeUv,renderUv:o.renderUv},r))})}else if(t.image!==void 0){if(n.images.has(t.image))throw new Error("Duplicate Blender image piece");n.images.set(t.image,Yo.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},o=Ts.parse(t),r=this.staged;if(r&&(r.session!==o.session||r.revision!==o.revision))throw new Error("Blender frame manifest does not match its staged revision");if(r)for(const[l,s]of r.images)o.images[l]=s;if(this.retiredSessions.has(o.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===o.session&&o.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const a=new Set(o.objects.map(l=>l.id));if(a.size!==o.objects.length)throw new Error("Runtime object IDs must be unique");const i=new Map(o.objects.map(l=>[l.id,l]));for(const l of o.objects){if(l.mesh!==null&&!o.meshes[l.mesh])throw new Error(`Missing runtime mesh ${l.mesh}`);if(l.volume&&(!o.volumes[l.volume]||l.mesh!==null))throw new Error(`Invalid runtime volume ${l.volume}`);if(l.light&&(!o.lights[l.light]||l.mesh!==null))throw new Error(`Invalid runtime light ${l.light}`);for(const m of l.materials)if(m!==null&&!o.materials[m])throw new Error(`Missing runtime material ${m}`);const s=new Set([l.id]);let c=l.parent;for(;c!==null;){if(s.has(c))throw new Error("Runtime parent cycle");s.add(c);const m=i.get(c);if(!m)throw new Error(`Missing runtime parent ${c}`);c=m.parent}}const f=new Map,u=new Map;try{for(const[l,s]of Object.entries(o.volumes)){const c=JSON.stringify(s);this.frame?.session===o.session&&this.volumes.get(l)?.signature===c||u.set(l,{signature:c,mesh:Qr(s)})}for(const[l,s]of Object.entries(o.meshes)){if("unchanged"in s){const h=r?.meshes.get(l);if(h){if(h.signature!==`revision:${s.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(l,h);continue}const g=this.meshes.get(l)?.signature;if(this.frame?.session===o.session&&g!==void 0&&(g===`revision:${s.revision}`||!g.startsWith("revision:")))continue;throw new Error(g===void 0?`${ke}: the presenter does not hold runtime mesh ${l} (store ${s.store}, revision ${s.revision})`:`${ke}: the presenter holds runtime mesh ${l} at ${g}, not revision ${s.revision}`)}const c="hash"in s,m="columns"in s,_=m?`revision:${s.revision}`:c?s.hash:JSON.stringify(s);this.frame?.session===o.session&&this.meshes.get(l)?.signature===_||f.set(l,{signature:_,geometry:m?Fn(Ve({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},_)):c?Fn(s):ur(s)})}}catch(l){for(const s of f.values())s.geometry.dispose();for(const{mesh:s}of u.values())s.geometry.dispose(),s.material.dispose();throw l}if(r){for(const[l,s]of r.meshes)f.has(l)||s.geometry.dispose();this.staged=null}this.frame?.session!==o.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[l,s]of u){const c=this.volumes.get(l)?.mesh;c&&(c.removeFromParent(),c.geometry.dispose(),c.material.dispose()),this.volumes.set(l,s)}for(const[l,s]of f)this.meshes.get(l)?.geometry.dispose(),this.meshes.set(l,s),this.geometryBuilds++;for(const[l,s]of Object.entries(o.images)){const c=this.textures.get(l);if("width"in s){const p=s.rgba??(s.rgbaBase64?ue(s.rgbaBase64):void 0);if(!p)throw new Error(`Runtime image ${l} carries no raster`);const v=s.tiles?ys(l,s.tiles,s.colorspace??"sRGB"):void 0;if(c?.udim&&(c.udim.tiles.dispose(),c.udim.map.dispose(),delete c.udim),c&&c.width===s.width&&c.height===s.height){const y=c.texture.image;if(y.data){y.data.set(p),c.texture.needsUpdate=!0,c.revision=s.revision,v&&(c.udim=v);continue}}c?.texture.dispose(),this.textures.set(l,{texture:bs(p,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...v?{udim:v}:{}});continue}const m=s.encoded??(s.encodedBase64?ue(s.encodedBase64):void 0);if(!m)throw new Error(`Runtime image ${l} carries no bytes`);c?.texture.dispose(),c?.udim?.tiles.dispose(),c?.udim?.map.dispose();const _=s.colorspace??"sRGB",{texture:h,ready:g}=xs(m,s.mime);h.colorSpace=_==="data"?Ln:Bt,this.textures.set(l,{texture:h,ready:g,width:0,height:0,revision:s.revision,encoded:{bytes:m.slice(),mime:s.mime,colorspace:_}})}for(const[l,s]of Object.entries(o.materials)){const c=this.materials.get(l)??new fn;c.name=s.name;const m=s.texture?.tint;s.texture!==void 0?c.color.setRGB(m?.[0]??1,m?.[1]??1,m?.[2]??1,bt):c.color.setRGB(s.color[0],s.color[1],s.color[2],bt),c.opacity=s.color[3];const _=c.opacity<1||s.graph!==void 0&&ei(s.graph);c.transparent!==_&&(c.transparent=_,c.needsUpdate=!0),c.roughness=s.roughness,c.metalness=s.metallic,c.transmission=s.transmission,c.ior=s.ior,Pe(c,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const h=s.normal_texture?.image.name;if(h===void 0)c.normalMap&&(this.textureSamplers.delete(`${l}:normal`),c.normalMap=null,c.needsUpdate=!0);else{const w=this.textures.get(h);if(!w)throw new Error(`${dn}: missing normal image ${h}`);const P=this.textureSamplers.get(`${l}:normal`,w.texture,s.normal_texture.extension,w.ready,s.normal_texture.uv);c.normalMap!==P&&(c.normalMap=P,c.needsUpdate=!0);const S=s.normal_space==="OBJECT"?ya:wa;c.normalMapType!==S&&(c.normalMapType=S,c.needsUpdate=!0),c.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(c.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],bt),c.emissiveIntensity=s.emission.strength):(c.emissive.setRGB(0,0,0),c.emissiveIntensity=1);const g=s.roughness_texture?.image.name??null;if(g===null)this.roughnessTextureNames.has(l)&&(this.textureSamplers.delete(`${l}:roughness`),c.roughnessMap=null,this.roughnessTextureNames.delete(l),c.needsUpdate=!0);else{const w=this.textures.get(g);if(!w)throw new Error(`${dn}: the presenter does not hold runtime image ${g} (revision ${s.roughness_texture.image.revision})`);const P=this.textureSamplers.get(`${l}:roughness`,w.texture,s.roughness_texture.extension,w.ready,s.roughness_texture.uv);c.roughnessMap!==P&&(c.roughnessMap=P,this.roughnessTextureNames.set(l,g),c.needsUpdate=!0)}const p=s.texture?.image.name??null;if(p===null)this.textureNames.has(l)&&(this.textureSamplers.delete(`${l}:color`),c.map=null,this.textureNames.delete(l),c.needsUpdate=!0);else{const w=this.textures.get(p);if(!w)throw new Error(`${dn}: the presenter does not hold runtime image ${p} (revision ${s.texture.image.revision})`);const P=this.textureSamplers.get(`${l}:color`,w.texture,s.texture.extension,w.ready,s.texture.uv);c.map!==P&&(c.map=P,this.textureNames.set(l,p),c.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,y=new Set;gi(c,v,w=>{const P=this.textures.get(w.name);if(!P)throw new Error(`${dn}: the presenter does not hold runtime image ${w.name} (revision ${w.revision})`);if(w.tiled){if(!P.udim)throw new Error(`${dn}: runtime image ${w.name} arrived without its UDIM tiles`);return P.udim}const S=`${l}:graph:${w.node}`;y.add(S);const T=this.textureSamplers.get(S,P.texture,w.extension,P.ready),O=w.closest?fe:Jt,R=w.closest?fe:w.mipmap?So:Jt;return(T.magFilter!==O||T.minFilter!==R)&&(T.magFilter=O,T.minFilter=R,T.needsUpdate=!0),T},this.photograph);for(const w of this.graphSamplers.get(l)??[])y.has(w)||this.textureSamplers.delete(w);this.graphSamplers.set(l,y),this.materials.set(l,c)}for(const l of o.objects){let s=this.objects.get(l.id);const c=l.volume?this.volumes.get(l.volume).mesh:null;if((!s||(c?s!==c:!!s.isMesh!=(l.mesh!==null)))&&(s?.removeFromParent(),s=c??(l.mesh!==null?new Dt(this.meshes.get(l.mesh).geometry,this.fallback):new go),this.objects.set(l.id,s)),s.name=l.name,l.type==="CAMERA"||l.type==="LIGHT"||l.type==="EMPTY"?s.userData.volterOwnOverlay=!0:delete s.userData.volterOwnOverlay,s.matrixAutoUpdate=!1,s.matrix.set(...l.matrix.flat()),l.parent){const m=new q().set(...i.get(l.parent).matrix.flat());s.matrix.premultiply(m.invert())}if(s.matrix.decompose(s.position,s.quaternion,s.scale),l.texspace?s.userData.blenderTexspace=l.texspace:delete s.userData.blenderTexspace,l.default_color!==void 0?s.userData.blenderDefaultColor=l.default_color:delete s.userData.blenderDefaultColor,l.mesh!==null){const m=s;m.geometry=this.meshes.get(l.mesh).geometry,m.material=l.materials.length?l.materials.map(_=>_===null?this.fallback:this.materials.get(_)):this.fallback,yi(m)}if(l.light){const m=this.lights.get(l.light)??null,_=Br(o.lights[l.light],m);m&&m!==_&&(m.removeFromParent(),m.dispose()),_.parent!==s&&s.add(_),_.userData.volterOwnOverlay=!0,Wr(_,s),this.lights.set(l.light,_)}}for(const l of o.objects){const s=this.objects.get(l.id),c=l.parent===null?this.root:this.objects.get(l.parent);s.parent!==c&&c.add(s)}for(const[l,s]of this.objects)a.has(l)||(s.removeFromParent(),this.objects.delete(l));for(const[l,s]of this.volumes)o.volumes[l]||(s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.volumes.delete(l));for(const[l,s]of this.meshes)o.meshes[l]||(s.geometry.dispose(),this.meshes.delete(l));for(const[l,s]of this.materials)if(!o.materials[l]){for(const c of["normal","roughness","color"])this.textureSamplers.delete(`${l}:${c}`);for(const c of this.graphSamplers.get(l)??[])this.textureSamplers.delete(c);this.graphSamplers.delete(l),s.dispose(),this.materials.delete(l)}for(const[l,s]of this.lights)o.lights[l]||(s.removeFromParent(),s.dispose(),this.lights.delete(l));this.root.updateMatrixWorld(!0),this.frame={...o,meshes:{},volumes:{},images:{}},this.worldKey=JSON.stringify(o.world??null);const d=this.applyOverlays(o);d.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...d]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const l of[...this.frameListeners])l();for(const l of this.followers)try{l.applyFrame(t)}catch{l.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,instancing:this.drawStatistics(),objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}drawStatistics(){return{enabled:this.drawBatching,preparation:{...this.drawPreparation},opaque:this.instances.inspect(),transparent:this.transparentInstances.inspect(),motion:this.motionGeometry.inspect()}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[r,{signature:a,geometry:i}]of this.meshes){const f=l=>{const s=i.getAttribute(l);if(!s)return null;if(!(s instanceof ut))throw new Error(`Blender capture cannot copy interleaved ${l}`);return new Float32Array(s.array)},u=f("position");if(!u)throw new Error(`Blender capture mesh ${r} has no positions`);const d=i.getIndex();n.meshes[r]={hash:a,positions:u,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(i.userData.blenderUvChannels??{}).map(([l,s])=>{const c=f(`uv${s}`);if(!c)throw new Error(`Blender capture mesh ${r} is missing UV layer ${l}`);return{name:l,data:c}}),orco:i.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(i.userData.blenderAttributes??[]).map(l=>{const s=f(jt(l));if(!s)throw new Error(`Blender capture mesh ${r} is missing attribute ${l}`);return{name:l,data:s}}),indices:d?new Uint32Array(d.array):Uint32Array.from({length:u.length/3},(l,s)=>s),groups:i.groups.map(l=>({start:l.start,count:l.count,materialIndex:l.materialIndex??0}))}}for(const[r,{signature:a}]of this.volumes)n.volumes[r]=Lo.parse(JSON.parse(a));const o=new Set(Object.values(n.materials).flatMap(r=>[r.texture?.image.name,r.roughness_texture?.image.name,r.normal_texture?.image.name,...Object.values(r.graph?.nodes??{}).map(a=>a.props.image?.name)].filter(a=>a!==void 0)));for(const r of o){const a=this.textures.get(r);if(!a)throw new Error(`Blender capture image ${r} is not resident`);if(a.encoded)n.images[r]={revision:a.revision,encoded:a.encoded.bytes.slice(),mime:a.encoded.mime,colorspace:a.encoded.colorspace};else{const i=a.texture.image?.data;if(!(i instanceof Uint8Array))throw new Error(`Blender capture image ${r} has no resident raster`);n.images[r]={revision:a.revision,width:a.width,height:a.height,rgba:i.slice(),colorspace:a.texture.colorSpace===Ln?"data":"sRGB",...a.udim?{tiles:a.udim.frame}:{}}}}return n}follow(){const t=new Bn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,o=this.createWorldVolumePass(),r=new Bn;r.photograph=!0;let a=!1;const i=()=>{a||(a=!0,o?.dispose(),r.dispose(),r.root.removeFromParent())};try{r.applyFrame(t),this.root.updateWorldMatrix(!0,!1),r.root.matrix.copy(this.root.matrixWorld),r.root.updateMatrixWorld(!0)}catch(f){throw i(),f}return{effect:o,root:r.root,session:n.session,revision:n.revision,prepare:f=>{if(a)throw new Error("Blender capture snapshot is disposed");return r.setRendered(!0,f)},dispose:i}}createWorldVolumePass(){const t=no(this.frame?.world);return t?new Ii(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,o=n.meshes;if(typeof o!="object"||o===null)return;const r=typeof n.session=="string"?n.session:null;r!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=r);const a=o;for(const[i,f]of Object.entries(a))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(i,f);for(const i of[...this.submittedMeshes.keys()])i in a||this.submittedMeshes.delete(i);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){this.motionGeometry.clear(),this.transparentInstances.clear(),this.instances.clear();for(const t of this.staged?.meshes.values()??[])t.geometry.dispose();this.staged=null;for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const Cs=new Bn;function Zo(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function ie(e){const t=Zo(e);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function Ps(e){const t=Zo(e);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function Es(e){return new q().set(...e.flat())}function uo(e,t){return[e.object,e.mesh,e.armature,e.vertexCount,e.bones.length,t].join("|")}class Ns{#n=new Map;#o=null;#a=null;#t=null;#r=null;#e=null;#s=null;#l=new Set;#u=0;#m=[];#i=0;get version(){return this.#u}get engineCalls(){return this.#i}subscribe(t){return this.#l.add(t),()=>this.#l.delete(t)}#f(){this.#u++;for(const t of[...this.#l])t()}state(){const t=this.#t,n=t?.frameStart??1,o=t?.frameEnd??250,r=t?.fps??24;return{frame:this.frame(),start:n,end:o,fps:r,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((a,i)=>a+i.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#m,engineCalls:this.#i,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return this.#r!==null?this.#r:!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:t.clipStart+this.#a.time*t.fps}get playable(){return this.#t!==null&&this.#e!==null}async bind(t,n){this.#i++;const o=await n.rig();if(!o)return;const r=[],a=new Set;let i=!1;for(const m of o.rigs){if(!m.object||!m.armature||!m.skinIndexBase64||!m.skinWeightBase64){m.reason&&r.push(m.reason);continue}a.add(m.object);const _=uo(m,o.frame);if(this.#n.get(m.object)?.signature===_)continue;const h=this.#_(t,m,o.frame,r);h&&(this.#n.get(m.object)?.skeleton.dispose(),this.#n.set(m.object,h),i=!0)}for(const[m,_]of[...this.#n])a.has(m)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(m),i=!0);this.#i++;const f=await n.clip(),u=this.#t,d=f?.frameStart!==u?.frameStart||f?.frameEnd!==u?.frameEnd||f?.fps!==u?.fps,l=f?.action!==u?.action||f?.tracks.length!==u?.tracks.length||f?.clipStart!==u?.clipStart||f?.clipEnd!==u?.clipEnd;this.#t=f??null,(!f||f.scene!==u?.scene)&&(this.#r=null),f?.reason&&r.push(f.reason),f&&(l||i)&&this.#h(t,f,r);const s=this.#e?.snapshot().activeSubject;d&&s&&this.#e?.setActiveSubject(s);const c=this.#e?.snapshot().playbackState==="playing";f&&!c&&(d||u?.frameCurrent!==f.frameCurrent)&&(this.#c(f.frameCurrent),this.#e&&f.fps>0&&this.#e.seek(f.frameCurrent/f.fps)),this.#m=r,this.#f()}#_(t,n,o,r){const a=t.objectForBlenderName(n.object??""),i=t.objectForBlenderName(n.armature??"");if(!a||!i)return null;const f=a,u=f.geometry;if(!u)return null;const d=u.getAttribute("blenderVertex");if(!d)return r.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let l=0;for(let S=0;S<d.count;S++)l=Math.max(l,d.getX(S));if(l>=n.vertexCount)return r.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${l} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const s=Ps(n.skinIndexBase64??""),c=ie(n.skinWeightBase64??""),m=d.count,_=new Uint16Array(m*4),h=new Float32Array(m*4);for(let S=0;S<m;S++){const T=d.getX(S);for(let O=0;O<4;O++)_[S*4+O]=s[T*4+O]??0,h[S*4+O]=c[T*4+O]??0}u.setAttribute("skinIndex",new Sa(_,4)),u.setAttribute("skinWeight",new Nt(h,4));const g=new ft;g.name=`${n.armature}:bones`;const p=[],v=n.bones.map(S=>Es(S.pose)),y=new Map(n.bones.map((S,T)=>[S.name,T]));n.bones.forEach((S,T)=>{const O=new Ma;O.name=S.name,p.push(O);const R=S.parent===null?void 0:y.get(S.parent);(R===void 0?v[T].clone():v[R].clone().invert().multiply(v[T])).decompose(O.position,O.quaternion,O.scale),(R===void 0?g:p[R]).add(O)}),i.add(g);const w=new Pa(u,f.material);w.name=f.name,w.matrixAutoUpdate=!1,w.matrix.copy(f.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=f.userData,w.frustumCulled=!1,t.replacePresentedObject(f,w),t.root.updateMatrixWorld(!0);const P=new Ea(p);return w.bind(P,w.matrixWorld.clone()),n.constrainedBones?.length&&r.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&r.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:w,boneRoot:g,bones:p,skeleton:P,frame:o,signature:uo(n,o)}}#h(t,n,o){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const r=n.armature?t.objectForBlenderName(n.armature):null;if(!r)return;const a=new Map;for(const s of this.#n.values())if(s.armature===n.armature)for(const c of s.bones)a.set(c.name,c);const i=[],f=new Set;for(const s of n.tracks){const c=a.get(s.bone);if(!c){f.add(s.bone);continue}const m=ie(s.timeBase64),_=ie(s.valueBase64),h=`${c.uuid}.${s.property}`;i.push(s.property==="quaternion"?new Na(h,Array.from(m),Array.from(_)):new Ra(h,Array.from(m),Array.from(_)))}if(f.size&&o.push(`${n.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!i.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,d=new Ia(r),l=d.clipAction(new za(n.action??"action",u,i));l.setLoop(Da,Number.POSITIVE_INFINITY),l.play(),this.#o=d,this.#a=l,this.#c(n.frameCurrent),this.#d()}#c(t){const n=this.#t;if(!n)return;const o=Math.min(n.frameEnd,Math.max(n.frameStart,t));if(this.#r=o,!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const r=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.max(0,Math.min(r-1e-4,(o-n.clipStart)/n.fps))),this.#d()}#d(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const o=n.scene;return!o||n.frameCurrent===t||(this.#i++,await $a(`bpy.data.scenes[${JSON.stringify(o)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#s?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const i=this.#t,f=i?.fps||24;return{start:(i?.frameStart??1)/f,end:(i?.frameEnd??250)/f,fps:f}},seek:i=>this.seekSeconds(i)}),o=t.onSettled(()=>{this.writeBookmark()}),r=()=>{o(),n(),this.#e===t&&(this.#e=null),this.#s=null};this.#s=r;const a=this.#t;return a&&a.fps>0&&t.seek(a.frameCurrent/a.fps),r}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#s?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null,this.#t=null,this.#r=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const Qo=new Ns;function ks(e){return Qo.subscribe(e)}function $s(){return Qo.version}export{Qo as a,$s as b,Cs as c,ks as s};