@volter/game-editor 0.5.143 → 0.5.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUNDLED_NOTICES +22 -22
- package/catalog/entries/blender.json +2 -2
- package/catalog/entries/music.json +2 -2
- package/dist/.vite/manifest.json +2154 -2154
- package/dist/assets/{AssetBudgetPanel-BdiVftGG.js → AssetBudgetPanel-8flhcwbD.js} +3 -3
- package/dist/assets/{AudioViewer-DjwTr_wg.js → AudioViewer-BYZn4DUK.js} +1 -1
- package/dist/assets/{CanvasBoardDocument-DK3MXhRp.js → CanvasBoardDocument-CoNJL2CI.js} +1 -1
- package/dist/assets/{CanvasSceneViewport-DOzblR0m.js → CanvasSceneViewport-Dq3V66EU.js} +1 -1
- package/dist/assets/{ColorInput-qITQn-_m.js → ColorInput-CZ9YSe5b.js} +1 -1
- package/dist/assets/{ColorPicker-DPs8654V.js → ColorPicker-DytPZaFB.js} +1 -1
- package/dist/assets/{EntityModelDocument-CNPGnGt3.js → EntityModelDocument-BkXCSQxA.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-oyIJfFdj.js → EnvironmentAssetDocument-DFZWx1WX.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-f2tPMu4I.js → GameplaySessionTimeline-B8wWEj5v.js} +1 -1
- package/dist/assets/{ImageViewer-DO5Ve_Ox.js → ImageViewer-CIM_I8nH.js} +1 -1
- package/dist/assets/InspectorObjectPreview-ec285ozq.js +1 -0
- package/dist/assets/{JsonAssetDocument-BuRyWHCE.js → JsonAssetDocument-gQuwiLdR.js} +1 -1
- package/dist/assets/{LiveModuleDocument-DSKvtvtv.js → LiveModuleDocument-DHCRcqhT.js} +1 -1
- package/dist/assets/{LutAssetDocument-DpQ27fBd.js → LutAssetDocument-B4RQTQCB.js} +1 -1
- package/dist/assets/{ModelAssetDocument-PpCxnR1j.js → ModelAssetDocument-DJnaaIHX.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-mIzPFTqE.js → NonThreeAuthoringBootstrap-CF7BPoB9.js} +1 -1
- package/dist/assets/{Object3DDocumentToolbar-BtPLixcu.js → Object3DDocumentToolbar-DsN2NUQv.js} +1 -1
- package/dist/assets/Object3DDocumentViewport-DGFR-qkU.js +2 -0
- package/dist/assets/{Object3DPreview-D3qGjLVE.js → Object3DPreview-BwZhzzAg.js} +1 -1
- package/dist/assets/{OnlineAssetDetail-p4AlihvW.js → OnlineAssetDetail-DB3yzRTz.js} +1 -1
- package/dist/assets/{PlayBar-CPfTu06h.js → PlayBar-CfImNQE-.js} +1 -1
- package/dist/assets/{QuarksAssetDocument-D6dGxxmU.js → QuarksAssetDocument-DJGQB4u7.js} +1 -1
- package/dist/assets/{ReactCanvasControls-DijwLcwS.js → ReactCanvasControls-BkR9VVE8.js} +1 -1
- package/dist/assets/{RootSelectionOverlay-CsD1aZs6.js → RootSelectionOverlay-CSfOoibk.js} +1 -1
- package/dist/assets/{ShaderAssetDocument-BEa81zNK.js → ShaderAssetDocument-CoiFAJWh.js} +1 -1
- package/dist/assets/{ShadowEditor-B7CJc6XL.js → ShadowEditor-DgBjRx-V.js} +1 -1
- package/dist/assets/{SourceAssetViewer-Bwvyvl7B.js → SourceAssetViewer-O0HH8IOS.js} +1 -1
- package/dist/assets/StageHost-CNkXkK_f.js +2 -0
- package/dist/assets/{StoryPreviewMount-CLfDAbBH.js → StoryPreviewMount-Bdx5zbNZ.js} +1 -1
- package/dist/assets/{ThreeBoardDocument-CBxxjARz.js → ThreeBoardDocument-CXv7KFP1.js} +2 -2
- package/dist/assets/{ThreeIsolationSceneContent-B7AvGnMj.js → ThreeIsolationSceneContent-D5WV80fA.js} +1 -1
- package/dist/assets/{ToolObject3DPreview-BgogY6xt.js → ToolObject3DPreview-BGrgHTE9.js} +1 -1
- package/dist/assets/{Toolbar-DcpfyyCi.js → Toolbar-SOKVz9Is.js} +1 -1
- package/dist/assets/{TransientHint-DzpkDjxN.js → TransientHint-C-aFB2Ox.js} +1 -1
- package/dist/assets/{VideoViewer-uaulCUB7.js → VideoViewer-B4I4Cbpl.js} +1 -1
- package/dist/assets/{ViewportShadingMenu-BNortpJP.js → ViewportShadingMenu-DBsoDPhe.js} +1 -1
- package/dist/assets/{active-ingest-D93pvHUb.js → active-ingest-DOoYv5lC.js} +2 -2
- package/dist/assets/{animation-clock-gP0Omdq0.js → animation-clock-TPDD3KgB.js} +1 -1
- package/dist/assets/{animation-mixers.service-BnC2sPxd.js → animation-mixers.service-fTlm79AY.js} +1 -1
- package/dist/assets/{animation-timeline.utility-_iveOjvf.js → animation-timeline.utility-CagyUWvy.js} +1 -1
- package/dist/assets/{asset-budget-asset.menu-BO6S6Clb.js → asset-budget-asset.menu-QnQQKyUV.js} +1 -1
- package/dist/assets/{asset-budget.action-BfPsEFA-.js → asset-budget.action-Denu9n8R.js} +1 -1
- package/dist/assets/{asset-budget.document-BPHPWfbm.js → asset-budget.document-DAQQudBF.js} +1 -1
- package/dist/assets/{asset-budget.menu-BMn3dsDS.js → asset-budget.menu-Dhqm1ACI.js} +1 -1
- package/dist/assets/{asset-editor-persistence-BE91v4hN.js → asset-editor-persistence-BPJ80IV2.js} +1 -1
- package/dist/assets/{asset-loaders-p2V4yWeG.js → asset-loaders-Dcnf7Bw6.js} +1 -1
- package/dist/assets/{asset-preview-BqIrR4Xy.js → asset-preview-BmprxTYE.js} +1 -1
- package/dist/assets/{audio-unlock.service-t0voeDQd.js → audio-unlock.service-CDSrqMlA.js} +1 -1
- package/dist/assets/{audio.utility-BtDV4l6L.js → audio.utility-Bk4p5xsL.js} +1 -1
- package/dist/assets/autoplay.service-B8dGBVjn.js +1 -0
- package/dist/assets/{babylon-authoring-adapter-ys1eX0ED.js → babylon-authoring-adapter-_KBkPwd9.js} +1 -1
- package/dist/assets/{binding-resolver-BWwofL-w.js → binding-resolver-ClWFzZwl.js} +2 -2
- package/dist/assets/{blender-node-editor.document-BHsl001G.js → blender-node-editor.document-BJs-svOJ.js} +1 -1
- package/dist/assets/{blender-properties-tab-uAaS_Exu.js → blender-properties-tab-Ca6GGoZA.js} +1 -1
- package/dist/assets/{blender-runtime-host-BYZufdkP.js → blender-runtime-host-BDbcC0Zg.js} +1 -1
- package/dist/assets/{blender-runtime-skin-DuLZEmCx.js → blender-runtime-skin-C-J3OdY_.js} +47 -47
- package/dist/assets/{blender-runtime.document-CfDUmwIa.js → blender-runtime.document-0fBzbVqg.js} +8 -8
- package/dist/assets/{blender-screenshot.menu-qJZV-LS0.js → blender-screenshot.menu-D3yZwxi6.js} +1 -1
- package/dist/assets/{blender-timeline.document-BwrXagJ6.js → blender-timeline.document-BOpLOn76.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-CSZoUDWM.js → blender-uv-editor.document-CNlwlNsR.js} +1 -1
- package/dist/assets/{blender-version.status-BWDUK2l7.js → blender-version.status-BrfCcN3A.js} +1 -1
- package/dist/assets/{blender.command-B0s3Af-m.js → blender.command-B-4gubQH.js} +1 -1
- package/dist/assets/{board-guides-5y4zeqX7.js → board-guides-CAd3Uwwe.js} +1 -1
- package/dist/assets/{bridge.command-DQfhUNFq.js → bridge.command-B_ZMM1Af.js} +3 -3
- package/dist/assets/{browserAll-Dbf4aGgB.js → browserAll-DJib4cRK.js} +1 -1
- package/dist/assets/{build-player.document-Bd0u1g-Y.js → build-player.document-Dkk9-Cxq.js} +1 -1
- package/dist/assets/{build-profiles.document-B7WkqaZ6.js → build-profiles.document-E4xigdal.js} +1 -1
- package/dist/assets/{build-progress.status-D2GyM7T5.js → build-progress.status-BmBmwXjj.js} +1 -1
- package/dist/assets/{build-session-urvplcJ_.js → build-session-DhHsQRks.js} +1 -1
- package/dist/assets/{build.action-CY_qJBby.js → build.action-CUifgV58.js} +1 -1
- package/dist/assets/{build.command-Bql81_76.js → build.command-BErZJdyz.js} +1 -1
- package/dist/assets/{build.header-BWEm5PxX.js → build.header-Bx2ejMEG.js} +1 -1
- package/dist/assets/{build.menu-Drj27927.js → build.menu-Dpl69Asc.js} +1 -1
- package/dist/assets/{build.service-UkGk8Uw_.js → build.service-BHf0-RtC.js} +1 -1
- package/dist/assets/{camera-DjlldTcH.js → camera-D2f8WceK.js} +1 -1
- package/dist/assets/{camera-runtime.inspector-Brr2VKtr.js → camera-runtime.inspector-Bed8jPeG.js} +1 -1
- package/dist/assets/{canvas-design-mount-qDZm4PWb.js → canvas-design-mount-s-hs4sM5.js} +3 -3
- package/dist/assets/{canvas-entry-runtime-C5mQcqUX.js → canvas-entry-runtime-DtH7NAl5.js} +2 -2
- package/dist/assets/{canvas-preview-frames-CKeTiNdf.js → canvas-preview-frames-BgBKQGAL.js} +1 -1
- package/dist/assets/{canvas-story-capture.service-DwdCXNcT.js → canvas-story-capture.service-Cqk4C8AX.js} +2 -2
- package/dist/assets/{capability-coverage-CNP_jAZY.js → capability-coverage-CRqjvzDo.js} +1 -1
- package/dist/assets/{collaboration-presence-DkEqt3Gz.js → collaboration-presence-D-oYewcY.js} +1 -1
- package/dist/assets/{collider-bbRSmral.js → collider-phxm70qk.js} +1 -1
- package/dist/assets/{component-board.service-BgVIeVii.js → component-board.service-CE8B8nHy.js} +2 -2
- package/dist/assets/{component-board.service-07TWRm-7.js → component-board.service-CLXsAGWX.js} +2 -2
- package/dist/assets/{component-board.service-BtSG5scd.js → component-board.service-D68yuC-G.js} +2 -2
- package/dist/assets/{component-contracts.service-DjLxfaIH.js → component-contracts.service-J0ThBCQb.js} +1 -1
- package/dist/assets/{component-instance-root-MaXT-9eH.js → component-instance-root-CTNzehmC.js} +1 -1
- package/dist/assets/{component-verbs.command-DAe5nFLA.js → component-verbs.command-D9Y2aSPT.js} +1 -1
- package/dist/assets/{component-verbs.service-DdkUX8_s.js → component-verbs.service-NmQpK7Cp.js} +1 -1
- package/dist/assets/{config-D6y2yi9i.js → config-DtFNLMre.js} +2 -2
- package/dist/assets/{configurations-B3CK604j.js → configurations-DizIsCtw.js} +1 -1
- package/dist/assets/{connection.status-BCz9SCph.js → connection.status-_545jhmC.js} +1 -1
- package/dist/assets/{constraints.inspector-ZPW1YgsY.js → constraints.inspector-Zg0371sI.js} +1 -1
- package/dist/assets/{content-bounds-CIrrm5u0.js → content-bounds-JcLbQeNM.js} +1 -1
- package/dist/assets/{contract-system-adapters-Da68ESRl.js → contract-system-adapters-CborQejG.js} +1 -1
- package/dist/assets/{coverage.service-DtjtcbGO.js → coverage.service-ZvzXk_RH.js} +1 -1
- package/dist/assets/{create-runtime-DYCcEzf_.js → create-runtime-BRhUNQFy.js} +1 -1
- package/dist/assets/{curve-XZVLp9Px.js → curve-ViOyXS6d.js} +1 -1
- package/dist/assets/{data-asset-C9QeMYQ6.js → data-asset-C4dKbRfK.js} +1 -1
- package/dist/assets/{data-ref-Dwd_nMTi.js → data-ref-B0raIwHa.js} +1 -1
- package/dist/assets/{debug-bridge-CmGhy30u.js → debug-bridge-DPTNskFv.js} +1 -1
- package/dist/assets/{debug-registry-7glJb2_c.js → debug-registry-Dc3W6vwO.js} +1 -1
- package/dist/assets/{deferred-ingest-play-CU5GjqVu.js → deferred-ingest-play-CIebXfgB.js} +2 -2
- package/dist/assets/{design-time-canvas-mount-DD8OYdJx.js → design-time-canvas-mount-BGOBVa9p.js} +2 -2
- package/dist/assets/{design-time-layers-C4EHX2H1.js → design-time-layers-BPYiK7VF.js} +1 -1
- package/dist/assets/{design-time-mount.service-C-E_So2G.js → design-time-mount.service-CBc4Am_-.js} +2 -2
- package/dist/assets/{design-time-mount.service-Bex5nxbX.js → design-time-mount.service-qJ2qfNGK.js} +2 -2
- package/dist/assets/{design-time-react-mount-BfS83T5B.js → design-time-react-mount-CV5Hd5Jd.js} +1 -1
- package/dist/assets/{document-preview-three-Br2Q34Dm.js → document-preview-three-C_6mBiiE.js} +1 -1
- package/dist/assets/{dom-authoring-adapter-uYyXOnRm.js → dom-authoring-adapter-CJzZxsuq.js} +1 -1
- package/dist/assets/{draco3d-DxNmfhHs.js → draco3d-CjtPWm52.js} +1 -1
- package/dist/assets/{edit-mode-audio.service-DE_pn_MR.js → edit-mode-audio.service-B-CjR9wW.js} +1 -1
- package/dist/assets/{edit-mode-authoring-8sn7p4nG.js → edit-mode-authoring-CCBUV6q2.js} +1 -1
- package/dist/assets/{edit-mode-networking.service-BXuBlovn.js → edit-mode-networking.service-Mx_poWhf.js} +1 -1
- package/dist/assets/{editor-api-BNcg9nJy.js → editor-api-DNxuq7oq.js} +1 -1
- package/dist/assets/{editor-layers-D3afd2Rj.js → editor-layers-DdJOFmu5.js} +1 -1
- package/dist/assets/{editor-shell-store-BNIOyldX.js → editor-shell-store-BXKwqCuM.js} +1 -1
- package/dist/assets/{entity-object-DC80r4hW.js → entity-object-dwaTJjul.js} +1 -1
- package/dist/assets/{extend-OjmwIbqx.js → extend-D_CXDVWD.js} +1 -1
- package/dist/assets/{fork-menu-CPdiffHY.js → fork-menu-DklvmtJS.js} +1 -1
- package/dist/assets/{frame-debugger-store-CYTSL3AX.js → frame-debugger-store-D2CIrmXD.js} +1 -1
- package/dist/assets/{game-contract-seams-WtNxnhc2.js → game-contract-seams-C1m_P4SS.js} +1 -1
- package/dist/assets/{game-css-scope-transform-C73qdewG.js → game-css-scope-transform-BA7ZbLSi.js} +1 -1
- package/dist/assets/{game-document.service-CF7EnKbN.js → game-document.service-Cce4QU61.js} +1 -1
- package/dist/assets/{game-eval.command-BcAACfLM.js → game-eval.command-BkWv-UfA.js} +1 -1
- package/dist/assets/{game-module-access-CTzw5tN5.js → game-module-access-XGEiv_PE.js} +1 -1
- package/dist/assets/{game-network-CbiXm5Hs.js → game-network-D8ug1x3w.js} +3 -3
- package/dist/assets/{gameplay-export-DSGl2k8q.js → gameplay-export-DoN38r9u.js} +1 -1
- package/dist/assets/{gameplay-replay-DCXlXrS2.js → gameplay-replay-DtHDmjp5.js} +1 -1
- package/dist/assets/{gameplay.command-YgXYsN_0.js → gameplay.command-DYnPT8Lo.js} +1 -1
- package/dist/assets/{generation-jobs-BEJk23Cn.js → generation-jobs-BXHZFlzo.js} +1 -1
- package/dist/assets/{generation.service-Dt9gsKXC.js → generation.service-CGSWxPf1.js} +1 -1
- package/dist/assets/{generations-CqmkgtNO.js → generations-DSXF1fKZ.js} +1 -1
- package/dist/assets/{generations.status-BULr7x14.js → generations.status-Cf_3wvkx.js} +1 -1
- package/dist/assets/{hierarchy-marks-Br83xItv.js → hierarchy-marks-D-538fQp.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-WupFrE9d.js → hosted-asset-materialization-DyuYIe1c.js} +1 -1
- package/dist/assets/{index-BliygjwA.js → index-8RtOnhOo.js} +1 -1
- package/dist/assets/{index-CEmW3p1F.js → index-9uCSEhwf.js} +1 -1
- package/dist/assets/{index-tJevWYyz.js → index-B6n4-N99.js} +1 -1
- package/dist/assets/{index-BVGC2p08.js → index-B_PxgVrX.js} +1 -1
- package/dist/assets/{index-D6Q6Xs1B.js → index-Bako454B.js} +1 -1
- package/dist/assets/{index-WZhfg_YR.js → index-BzRGSlHd.js} +1 -1
- package/dist/assets/{index-D6MeIqnu.js → index-CCKpGWll.js} +2 -2
- package/dist/assets/{index-DoeV0FPm.js → index-CqiPDGfq.js} +1 -1
- package/dist/assets/{index-C3IEVwzA.js → index-Crsbhlhy.js} +86 -86
- package/dist/assets/{inference-diagnostics-NkV5meYv.js → inference-diagnostics-JiGwiJUe.js} +1 -1
- package/dist/assets/{ingest-boot-viewport-BdEJB2uM.js → ingest-boot-viewport-BqIgHJiK.js} +1 -1
- package/dist/assets/{ingest-siblings-DG94tSnt.js → ingest-siblings-C3KBC2OL.js} +1 -1
- package/dist/assets/{ingest-source-persistence-COuafLsy.js → ingest-source-persistence-Bk9qLkTV.js} +1 -1
- package/dist/assets/{ingest.service-pguAbjpd.js → ingest.service-DdIqzdni.js} +1 -1
- package/dist/assets/{inspect-B9obej0m.js → inspect-DPJ1m-DR.js} +1 -1
- package/dist/assets/instances.command-BIwrjtVv.js +1 -0
- package/dist/assets/{json-history-resource-BZ-2HcB1.js → json-history-resource-BdE8EcB4.js} +1 -1
- package/dist/assets/{layered-pick-BOuHhOMD.js → layered-pick-CsPry26y.js} +1 -1
- package/dist/assets/{light-BhobQdgv.js → light-P3HQqMJN.js} +1 -1
- package/dist/assets/{live-project-verbs-BzcIAa92.js → live-project-verbs-l0iIsIQL.js} +1 -1
- package/dist/assets/{machine.document-C6KtiVU9.js → machine.document-Dz14QA8c.js} +1 -1
- package/dist/assets/{machines.finder-C4YZxgo1.js → machines.finder-d1uSMp3z.js} +1 -1
- package/dist/assets/{material-CGLOFkhv.js → material-D7yEfFFf.js} +1 -1
- package/dist/assets/{material-factory-B96Hx0uM.js → material-factory-DzsVJzgQ.js} +1 -1
- package/dist/assets/{mesh-CXz1SjeE.js → mesh-f9oWqYCD.js} +1 -1
- package/dist/assets/{model-asset-sections.service-ByQd6kq8.js → model-asset-sections.service-Yh4yCNss.js} +1 -1
- package/dist/assets/{model-inspection-vhAtpqOr.js → model-inspection-C5OZWNER.js} +1 -1
- package/dist/assets/{model-thumbnail-DKy7aBw4.js → model-thumbnail-DFht0Zea.js} +1 -1
- package/dist/assets/{models.finder-BQaOk9z2.js → models.finder-zG-WERDy.js} +1 -1
- package/dist/assets/{module-mode-Bvwyb8ON.js → module-mode-CIRC4PLv.js} +2 -2
- package/dist/assets/{mount-canvas-ingest-root-Q_xSSTn4.js → mount-canvas-ingest-root-WOBvBU2u.js} +2 -2
- package/dist/assets/{mount-dom-ingest-root-cTeFpCss.js → mount-dom-ingest-root-eYOFvDv6.js} +2 -2
- package/dist/assets/{mount-ingest-root-CzxqWdcJ.js → mount-ingest-root-BtlYDYMM.js} +2 -2
- package/dist/assets/{mount-manifest-DpGIVIqZ.js → mount-manifest-BLFE1lZT.js} +1 -1
- package/dist/assets/{mount-three-ingest-root-DkATi7dX.js → mount-three-ingest-root-Bp78LaZS.js} +1 -1
- package/dist/assets/{mounted-authoring-_iXvG_-y.js → mounted-authoring-C7-8VFjR.js} +1 -1
- package/dist/assets/{mounted-story-viewport-source-B3xRhvGK.js → mounted-story-viewport-source-DYFGQweE.js} +1 -1
- package/dist/assets/{native-debug-module-sgSgwV_6.js → native-debug-module-DZBcJZ3O.js} +1 -1
- package/dist/assets/{navigation-C7N4F7fm.js → navigation-CLNvQtYC.js} +1 -1
- package/dist/assets/{navmesh.menu-GjmPbNmN.js → navmesh.menu-VhuMK-B9.js} +1 -1
- package/dist/assets/{navmesh.service-C6OOgYOg.js → navmesh.service-9skC9KbW.js} +1 -1
- package/dist/assets/network-observer.service-ib7T4XSw.js +1 -0
- package/dist/assets/{network.utility-DFVzAD3R.js → network.utility-Cx6YQWiW.js} +1 -1
- package/dist/assets/{object3d-document-session-registry-yZYSi8a_.js → object3d-document-session-registry-DYtU0S61.js} +2 -2
- package/dist/assets/{oid-transform-B2rTU5dE.js → oid-transform--LwgkNr9.js} +1 -1
- package/dist/assets/{particles-WV7nuue8.js → particles-DCL9brKJ.js} +1 -1
- package/dist/assets/{pixi-authoring-adapter-DYxqfbtY.js → pixi-authoring-adapter-CJsDP9TC.js} +1 -1
- package/dist/assets/{pixi-live-write-target-BMM9gTYX.js → pixi-live-write-target-BkbfLPLj.js} +1 -1
- package/dist/assets/{play.command-Cw2b6MmY.js → play.command-D7U5ws3m.js} +2 -2
- package/dist/assets/{presentation-m9EXagyv.js → presentation-BlPdw2Jq.js} +1 -1
- package/dist/assets/{product-DY3NaL48.js → product-BjUMoNzc.js} +1 -1
- package/dist/assets/{profiler.action-AlWZaom2.js → profiler.action-BeMlKn0D.js} +1 -1
- package/dist/assets/{profiler.menu-C2HG4gW2.js → profiler.menu-ByNYDsb_.js} +1 -1
- package/dist/assets/{profiler.utility-xcXtWI8M.js → profiler.utility-QR-GTEWX.js} +1 -1
- package/dist/assets/{project-authoring-session-COpHfmqX.js → project-authoring-session-D5fR27Xf.js} +2 -2
- package/dist/assets/{properties-bone-constraints.inspector-CYTy1c6d.js → properties-bone-constraints.inspector-CQ1kzpeW.js} +1 -1
- package/dist/assets/{properties-bone.inspector-srx9O7Di.js → properties-bone.inspector-BmWvLtS5.js} +1 -1
- package/dist/assets/{properties-collection.inspector-Dz-z_Q4f.js → properties-collection.inspector-Bp4G6gAf.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-CU09Fq6P.js → properties-constraints.inspector-C5u2vHgr.js} +1 -1
- package/dist/assets/{properties-data.inspector-Cgt6CKvm.js → properties-data.inspector-DLuIeVjK.js} +1 -1
- package/dist/assets/{properties-material.inspector-jDhkNUDR.js → properties-material.inspector-BazVBacy.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-bcEjEW5a.js → properties-modifiers.inspector-BR_xxGgB.js} +1 -1
- package/dist/assets/{properties-object.inspector-C7u_OCfm.js → properties-object.inspector-BT8ErQ5C.js} +1 -1
- package/dist/assets/{properties-output.inspector-CRJOBoRT.js → properties-output.inspector-Db7k-X5n.js} +1 -1
- package/dist/assets/{properties-particles.inspector-BQRy6PnC.js → properties-particles.inspector-GHdgdRSV.js} +1 -1
- package/dist/assets/{properties-physics.inspector-kcBc7wis.js → properties-physics.inspector-CDa8fMg1.js} +1 -1
- package/dist/assets/{properties-render.inspector-w2VKl5a0.js → properties-render.inspector-ChRA2wF6.js} +1 -1
- package/dist/assets/{properties-scene.inspector-DDZCO3Og.js → properties-scene.inspector-wox_pPvs.js} +1 -1
- package/dist/assets/{properties-texture.inspector-Cz-imXaI.js → properties-texture.inspector-c5cYfvzG.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-Lnj3xdEk.js → properties-view-layer.inspector-KfYDdJ83.js} +1 -1
- package/dist/assets/{properties-world.inspector-DyeshJEW.js → properties-world.inspector-DO4TsCFa.js} +1 -1
- package/dist/assets/{r3f-design-session-b0R___Ze.js → r3f-design-session-huIajqIc.js} +2 -2
- package/dist/assets/{r3f-physics-binding-BeHcRXcx.js → r3f-physics-binding-YA43TdoL.js} +1 -1
- package/dist/assets/{r3f-source-authoring-adapter-DIKg1AbO.js → r3f-source-authoring-adapter-BlRstmGA.js} +1 -1
- package/dist/assets/{react-canvas-navigation-DBex6opA.js → react-canvas-navigation-M0ghQ3Pg.js} +1 -1
- package/dist/assets/{react-inspector.service--CnSg1fP.js → react-inspector.service-CStUUFdZ.js} +1 -1
- package/dist/assets/{react-story-board-Bfwrt56k.js → react-story-board-CJ2rY1vM.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-CWt9552l.js → react-three-rapier.esm-2PI2GKyc.js} +1 -1
- package/dist/assets/{react-world-authoring-adapter-Dh-F6SHg.js → react-world-authoring-adapter-tdk4Hqj1.js} +1 -1
- package/dist/assets/{realm-services-CSKI9wWm.js → realm-services-ZGsXIjKw.js} +1 -1
- package/dist/assets/{reflection-probe-capture.inspector-DTAmb51-.js → reflection-probe-capture.inspector-CacOiakh.js} +1 -1
- package/dist/assets/{registry-Djlt4lA_.js → registry-CCO8vgc4.js} +1 -1
- package/dist/assets/{relative-import-specifier-a5wd_Gs0.js → relative-import-specifier-CJ9epbC5.js} +1 -1
- package/dist/assets/{render-env-DgCta-cM.js → render-env-CcmQfcfh.js} +1 -1
- package/dist/assets/{render-features-D9IRNSOg.js → render-features-d6WsfyhR.js} +1 -1
- package/dist/assets/{render-settings-K5ykAjto.js → render-settings-2QiH0WvX.js} +1 -1
- package/dist/assets/{resolve-three-QtDpVk2v.js → resolve-three-DaW6J3do.js} +3 -3
- package/dist/assets/{root-seam-contract-BAJnkEp5.js → root-seam-contract-BaqTf_0m.js} +1 -1
- package/dist/assets/{run-selection-BmhnFN7A.js → run-selection-BmPqbXVv.js} +1 -1
- package/dist/assets/{scene-capture-CPjMfWPb.js → scene-capture-BPf9CksU.js} +1 -1
- package/dist/assets/{scene-document.service-lXXx86ZY.js → scene-document.service-BCJX2wYL.js} +2 -2
- package/dist/assets/{scene-framing-DAsS4rid.js → scene-framing-pfBwKlV1.js} +1 -1
- package/dist/assets/{seeded-random-BiOJCjoh.js → seeded-random-Cm0mJ9WK.js} +1 -1
- package/dist/assets/{setup-renderer-BLHf2o5h.js → setup-renderer-CDiOvS5v.js} +1 -1
- package/dist/assets/{source-object3d-authoring-adapter-DCTt6xT1.js → source-object3d-authoring-adapter-CmnO36sT.js} +1 -1
- package/dist/assets/{source-persistence-backend-BizSv5Yp.js → source-persistence-backend-ECfFZPdn.js} +1 -1
- package/dist/assets/{stage-keyboard-9hdCldtL.js → stage-keyboard-D9z07kMc.js} +1 -1
- package/dist/assets/{stage-overlay-set-DK8sGIBe.js → stage-overlay-set-BEcLelHE.js} +1 -1
- package/dist/assets/{stage-presence-markers-Bu19oyb3.js → stage-presence-markers-61iYjRz9.js} +1 -1
- package/dist/assets/{stage-transform-tools-BWs1sSub.js → stage-transform-tools-D_zntx7x.js} +1 -1
- package/dist/assets/{standard-viewport-dressing-3h78wiJH.js → standard-viewport-dressing-CvWc3TIo.js} +1 -1
- package/dist/assets/{state-watch.action-X_hXCJzX.js → state-watch.action-Dj33chqd.js} +1 -1
- package/dist/assets/{state-watch.menu-B33dSJ7V.js → state-watch.menu-BDbYVr9h.js} +1 -1
- package/dist/assets/{state-watch.utility-CS3p0R5B.js → state-watch.utility-YGDgFG4K.js} +1 -1
- package/dist/assets/{story-capture-BBg5pgKT.js → story-capture-DRH3UvNr.js} +1 -1
- package/dist/assets/{story-documents-q5m3c_wY.js → story-documents-DoLPg9Lx.js} +1 -1
- package/dist/assets/{story-documents.service-BtNfViZy.js → story-documents.service-Ll8_ATjf.js} +1 -1
- package/dist/assets/{story-documents.service-Dwsqu7bW.js → story-documents.service-Teg89FZc.js} +1 -1
- package/dist/assets/{story-media-presence-hCARiVUc.js → story-media-presence-Xlo427K1.js} +1 -1
- package/dist/assets/{story-pixi-preview-CMwSxREi.js → story-pixi-preview-BBP84uRR.js} +1 -1
- package/dist/assets/{story-presentation--uk_0JJX.js → story-presentation-Bqi53kq0.js} +1 -1
- package/dist/assets/{story-three-preview-lkPW7Mla.js → story-three-preview-BP4ILFDq.js} +2 -2
- package/dist/assets/{studio-environment-ByTLZM6a.js → studio-environment-BLFX45T5.js} +1 -1
- package/dist/assets/{surface-state-GPRTCWsc.js → surface-state-rZISD-ig.js} +1 -1
- package/dist/assets/{syntactic-prop-specs-BZ2T0Dju.js → syntactic-prop-specs-BVVxIxx3.js} +1 -1
- package/dist/assets/{team-playtest.service-COi4KAFM.js → team-playtest.service-DqP8zQMt.js} +1 -1
- package/dist/assets/{three-B95eDXwg.js → three-a5CVjo2i.js} +1 -1
- package/dist/assets/{three-authoring-adapter-mRgWq9dH.js → three-authoring-adapter-D9bJThN9.js} +1 -1
- package/dist/assets/three-authoring.service-C0WuXyLN.js +2 -0
- package/dist/assets/{three-ingest-runtime-CSUpmThV.js → three-ingest-runtime-CfjyePZf.js} +1 -1
- package/dist/assets/{three-integration-DPryzrWM.js → three-integration-Bq5NMTap.js} +2 -2
- package/dist/assets/three-integration.service-scS00K9w.js +1 -0
- package/dist/assets/{three-projection-core-C6Fuom2Z.js → three-projection-core-BTQ_M-Ho.js} +1 -1
- package/dist/assets/{three-state-BjGdd42C.js → three-state-DYl6KVhl.js} +1 -1
- package/dist/assets/{three-story-capture.service-BguWqBuW.js → three-story-capture.service-CkEnDiGX.js} +2 -2
- package/dist/assets/{three-story-model-BcQRzfG1.js → three-story-model-DR4JL0tj.js} +1 -1
- package/dist/assets/{three-viewport-presentation-PE5VLtVN.js → three-viewport-presentation-Bu3_3jY0.js} +1 -1
- package/dist/assets/{transform-mode-request-DrXkGR49.js → transform-mode-request-CQMVP3gI.js} +1 -1
- package/dist/assets/{transport-strip-B9M8lv_7.js → transport-strip-7xF6Xkx1.js} +1 -1
- package/dist/assets/transport.header-AqKlS4Ny.js +1 -0
- package/dist/assets/{tuples-B5xEbsBJ.js → tuples-Bi79tUJA.js} +1 -1
- package/dist/assets/{ui-board-document-Bp7xB2i3.js → ui-board-document-ByN-Igr_.js} +2 -2
- package/dist/assets/{user-data-BCzozK6p.js → user-data-BJje5VYV.js} +1 -1
- package/dist/assets/{utility-view-state-LNjKjbXt.js → utility-view-state-D_M1xdFg.js} +1 -1
- package/dist/assets/{viewport-door-876vvdh-.js → viewport-door-Bn_5UYAF.js} +1 -1
- package/dist/assets/{viewport-root-presentation-DjeK1HDN.js → viewport-root-presentation-CMku-eFg.js} +1 -1
- package/dist/assets/{viewport-surface-status-Cu-MsQ9Z.js → viewport-surface-status-Z2lECnRZ.js} +1 -1
- package/dist/assets/{webworkerAll-Cby9Al9A.js → webworkerAll-B66_oG9K.js} +1 -1
- package/dist/assets/{workspace-arrangement-DTpl9s7F.js → workspace-arrangement-BPsnvrOt.js} +1 -1
- package/dist/assets/{world-documents-DYaA8YwM.js → world-documents-CEI6Ult8.js} +1 -1
- package/dist/assets/{world-root-stage-binding-pOiqC5Pw.js → world-root-stage-binding-BtFetoJf.js} +1 -1
- package/dist/assets/{xstate-animation-binding-Dlgd2kK4.js → xstate-animation-binding-5ogRENtk.js} +1 -1
- package/dist/assets/{xstate-animation-meta-OTs0c50R.js → xstate-animation-meta-D3SfP75s.js} +1 -1
- package/dist-node/cli.js +16 -16
- package/package.json +16 -16
- package/dist/assets/InspectorObjectPreview-CunxnDvP.js +0 -1
- package/dist/assets/Object3DDocumentViewport-C1XieeeO.js +0 -2
- package/dist/assets/StageHost-CHeH7liy.js +0 -2
- package/dist/assets/autoplay.service-BTr6K5DJ.js +0 -1
- package/dist/assets/instances.command-C8fTOWWQ.js +0 -1
- package/dist/assets/network-observer.service-BYkKwX6g.js +0 -1
- package/dist/assets/three-authoring.service-DYHH4MQS.js +0 -2
- package/dist/assets/three-integration.service-Bxn19GhH.js +0 -1
- package/dist/assets/transport.header--skZwiFx.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
|
|
2
|
+
import{a as bo,b as yo,L as wo}from"./LineSegments2-DN9pUfWA.js";import{bh as ct,cl as Oo,fo as y,cm as q,N as oe,a$ as Nt,em as On,b4 as aa,co as Ft,ey as ra,cp as ke,_ as Mt,ej as Ut,fd as te,er as sa,M as ft,cj as wt,dp as St,aV as ia,cW as Ao,aE as Mo,c7 as bt,j as la,f6 as fa,fp as Ue,au as We,dw as qe,bi as An,aT as ca,c1 as ee,dd as fn,eC as cn,e7 as ze,aw as ge,da as Xt,I as ue,as as ua,e8 as da,b0 as To,K as ma,B as _a,b9 as ha,Y as So,cw as ne,ed as pa,cA as ga,fx as va,db as Po,el as xa,R as ba,e6 as ya,c0 as Eo,bX as wa,aI as $e,ao as Oa,eG as Aa,d3 as Ma,cs as Ta,b5 as He,bu as No,aM as Ro,a_ as Sa,E as we,ex as Mn,cO as Le,cY as Pa,eU as Ea,cE as un,c5 as Io,at as Na,ff as Ra,eW as Ia,f7 as Da,F as za,ev as Ca,et as Fa,dq as ka,fq as $a,n as La,l as ja,cf as Va}from"./three.core-3arARmh6.js";import{u as R,v as L,w as D,c5 as at,c4 as Y,c6 as I,e2 as W,_ as Ba,mB as Do,d_ as Wt,x as X,kE as Ot,e1 as zo,mC as G,dZ as Ua,mD as Wa}from"./index-Crsbhlhy.js";import{S as Yt}from"./three.module-BLhyNg0e.js";import{t as qa}from"./blender-runtime-host-BDbcC0Zg.js";const dn=new Set;function ht(){for(const n of[...dn])n()}function Ha(n){return dn.add(n),()=>{dn.delete(n)}}function mn(n){const t=atob(n),e=new Uint8Array(t.length);for(let o=0;o<t.length;o++)e[o]=t.charCodeAt(o);return e}const de=I().finite(),Ga=R({name:D(),parent:D().nullable(),connected:at(),hide:at(),length:de,matrix:L(W([de,de,de,de])).length(4),select:at(),active:at(),lockedWeight:at()}).strict(),Xa=R({object:D(),displayType:Y(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:at(),mode:D(),bones:L(Ga)}).strict(),Et={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function Ya(n){return new Mt(n.r*n.r*.1,n.g*n.g*.1,n.b*n.b*.1)}const Ge=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],Fn=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],$t=Math.SQRT1_2,Za=[[$t,-$t,0],[0,-$t,-$t],[-$t,-$t,0],[0,-$t,$t],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],Ka=[[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 kn(n){return n.select||n.active?2:1}const Ja=10,tr=4,er=`
|
|
3
3
|
attribute vec3 aSolid;
|
|
4
4
|
attribute vec3 aHint;
|
|
5
5
|
varying vec3 vColor;
|
|
@@ -10,13 +10,13 @@ import{a as wo,b as Oo,L as Ao}from"./LineSegments2-DN9pUfWA.js";import{bh as ct
|
|
|
10
10
|
vColor = mix(aHint, aSolid, fac * fac);
|
|
11
11
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`,nr=`
|
|
14
14
|
varying vec3 vColor;
|
|
15
15
|
void main() {
|
|
16
16
|
gl_FragColor = vec4(vColor, 1.0);
|
|
17
17
|
#include <colorspace_fragment>
|
|
18
18
|
}
|
|
19
|
-
`;function $t(n){return new Mt().setHex(n,Ut)}function Vn(n,t){const e=n.mode==="POSE";let o;return e?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),e&&t.lockedWeight&&o.lerp($t(Et.lockedWeight),Et.lockedWeightFactor),o}function Bn(n,t){const e=$t(Et.solid);return n.mode==="POSE"&&t.lockedWeight&&e.lerp($t(Et.lockedWeight),Et.lockedWeightFactor),e}const sr=new q,ir=new y,Un=new Mo;function Wn(n,t){return new q().set(...t.matrix.flat()).premultiply(n).scale(new y().setScalar(t.length))}class lr{constructor(){this.group=new ct,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,e){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=e(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 c=a.displayType==="STICK"?this.buildStick(a,f,i):this.buildOctahedral(a,f,i);a.showInFront&&c.traverse(d=>{const l=d.material;l&&"depthTest"in l&&(l.depthTest=!1),d.renderOrder=10}),this.group.add(c)}return o}buildOctahedral(t,e,o){const r=new ct;r.name=`${t.object}:bones`;const a=[],i=[],f=[],c=[],d=[],l=[],s=[],u=[],_=[],h=[];for(const m of e){const p=Wn(o,m),g=Bn(t,m),v=Ka(g),O=Vn(t,m);Un.setFromMatrix4(p).invert().transpose();for(let w=0;w<Ln.length;w++){const A=ir.set(...Ja[w]).applyMatrix3(Un).normalize().clone();for(const M of Ln[w]){const E=new y(...Qe[M]).applyMatrix4(p);a.push(E.x,E.y,E.z),i.push(A.x,A.y,A.z),f.push(g.r,g.g,g.b),c.push(v.r,v.g,v.b)}}const b=jn(m)===2?s:d,S=jn(m)===2?u:l;for(const[w,A]of tr){const M=new y(...Qe[w]).applyMatrix4(p),E=new y(...Qe[A]).applyMatrix4(p);b.push(M.x,M.y,M.z,E.x,E.y,E.z),S.push(O.r,O.g,O.b,O.r,O.g,O.b)}m.parent!==null&&m.connected||(_.push(p.clone()),h.push(g)),_.push(p.clone().multiply(sr.makeTranslation(0,1,0))),h.push(g)}r.add(this.solidMesh(a,i,f,c)),d.length&&r.add(this.lines(d,l,1)),s.length&&r.add(this.lines(s,u,2));for(let m=0;m<_.length;m++)r.add(this.point(_[m],h[m]));return r}buildStick(t,e,o){const r=new ct;r.name=`${t.object}:bones`;const a=[],i=[],f=[],c=[];for(const d of e){const l=Wn(o,d),s=new y().setFromMatrixPosition(l),u=new y(0,1,0).applyMatrix4(l),_=Vn(t,d),h=Bn(t,d);a.push(s.x,s.y,s.z,u.x,u.y,u.z),i.push(_.r,_.g,_.b,_.r,_.g,_.b),f.push(s.x,s.y,s.z,u.x,u.y,u.z),c.push(h.r,h.g,h.b,h.r,h.g,h.b)}return r.add(this.lines(a,i,nr)),r.add(this.lines(f,c,or)),r}solidMesh(t,e,o,r){const a=new ee;a.setAttribute("position",new Nt(t,3)),a.setAttribute("normal",new Nt(e,3)),a.setAttribute("aSolid",new Nt(o,3)),a.setAttribute("aHint",new Nt(r,3));const i=new Mn({vertexShader:ar,fragmentShader:rr,side:oa});this.disposables.push(a,i);const f=new zt(a,i);return f.frustumCulled=!1,f}lines(t,e,o){const r=new wo;r.setPositions(t),r.setColors(e);const a=new Oo({linewidth:o,vertexColors:!0});this.disposables.push(r,a);const i=new Ao(r,a);return i.frustumCulled=!1,i}point(t,e){const o=new aa(er,12,8),r=new $e({color:e});this.disposables.push(o,r);const a=new zt(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 qn="RUNTIME_FRAME_UNKNOWN_GEOMETRY",me="RUNTIME_FRAME_UNKNOWN_IMAGE";function fr(n){const t=Math.fround,e=t(t(t(n[0]*n[0])+t(n[1]*n[1]))+t(n[2]*n[2]));if(e>1e-35){const o=t(Math.sqrt(e)),r=t(1/o);return{unit:[t(n[0]*r),t(n[1]*r),t(n[2]*r)],length:o}}return{unit:[0,0,0],length:0}}const z=Math.fround,Ue=z(2*Math.PI),Ke=z(1-1e-4),Zt=(n,t)=>z(z(z(n[0]*t[0])+z(n[1]*t[1]))+z(n[2]*t[2])),ye=(n,t,e=1)=>n.map((o,r)=>z(o+z(t[r]*e))),cr=(n,t)=>n.map((e,o)=>z(e-t[o]));function _e(n){const t=z(Math.sqrt(Zt(n,n)));return t>0?n.map(e=>z(e/t)):[0,0,0]}function he(n){const t=Math.abs(n)<1?z(1-z(1-Math.abs(n))):1;let e=z(z(.077980478)+z(t*z(-.02164095)));e=z(z(-.213300989)+z(t*e)),e=z(z(1.5707963267)+z(t*e));const o=z(z(Math.sqrt(z(1-t)))*e);return n<0?z(z(Math.PI)-o):o}function ur(n){let t=n.at(-1);const e=[0,0,0];for(const o of n){for(let r=0;r<3;r++){const a=(r+1)%3,i=(r+2)%3;e[r]=z(e[r]+z(z(t[a]-o[a])*z(t[i]+o[i])))}t=o}return e}function dr(n){const t=[],e=[],o=(h,m)=>h<m?`${h}:${m}`:`${m}:${h}`,r=new Map((n.edge_order??[]).map(([h,m],p)=>[o(h,m),p])),a=new Set((n.sharp??[]).map(([h,m])=>o(h,m))),i=new Map;for(const[h,m]of n.f.entries()){const p=t.length,g=fr(ur(m.map(v=>n.v[v]))).unit;e.push(g.some(Boolean)?g:[0,0,1]);for(let v=0;v<m.length;v++){const O=o(m[v],m[(v+1)%m.length]);r.has(O)||r.set(O,r.size);const b=n.face_edges?.[h]?.[v]??r.get(O),S=t.length;t.push({vertex:m[v],face:h,edge:b,prev:p+(v+m.length-1)%m.length,next:p+(v+1)%m.length});const w=i.get(b)??[];w.push(S),i.set(b,w)}}const f=new Map,c=new Map;for(const[h,m]of i){if(m.length!==2||n.edge_sharp?.[h])continue;const[p,g]=m,v=t[p],O=t[g];!n.s?.[v.face]||!n.s?.[O.face]||v.vertex!==t[O.next].vertex||O.vertex!==t[v.next].vertex||!n.edge_sharp&&a.has(o(v.vertex,O.vertex))||(c.set(p,O.next),f.set(O.next,p),c.set(g,v.next),f.set(v.next,g))}const d=[],l=[],s=[],u=[],_=(h,m)=>_e(cr(n.v[t[t[h][m]].vertex],n.v[t[h].vertex]));for(let h=0;h<t.length;h++){if(l[h]!==void 0)continue;let m=h;const p=new Set([m]);for(;c.has(m)&&!p.has(c.get(m));)m=c.get(m),p.add(m);c.has(m)&&(m=Math.min(...p));const g=[m];for(;f.has(g.at(-1))&&f.get(g.at(-1))!==m;)g.push(f.get(g.at(-1)));let v=[0,0,0];if(g.length===1)v=e[t[m].face];else{for(const E of g)v=ye(v,e[t[E].face],he(Zt(_(E,"prev"),_(E,"next"))));v=_e(v)}const O=_(m,"next"),b=g.at(-1),S=_(b,"prev"),w=Zt(O,v),A=Zt(S,v),M={normal:v,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(w)<Ke&&Math.abs(A)<Ke){const E=g.length>1?g.map(nt=>_(nt,"next")):[];E.length&&t[t[b].prev].edge!==t[m].edge&&E.push(S),M.alpha=E.length?z(E.reduce((nt,x)=>z(nt+he(Zt(x,v))),0)/E.length):z(z(he(w)+he(A))/2),M.reference=_e(ye(O,v,-w));const C=v,V=M.reference;M.ortho=_e([z(z(C[1]*V[2])-z(C[2]*V[1])),z(z(C[2]*V[0])-z(C[0]*V[2])),z(z(C[0]*V[1])-z(C[1]*V[0]))]);const H=_e(ye(S,v,-A)),tt=Zt(M.reference,H),Z=he(tt);M.beta=tt<Ke?Zt(M.ortho,H)<0?z(Ue-Z):Z:Ue}M.alpha===0&&(M.normal=[0,0,0]);for(const E of g)l[E]=d.length;d.push(g),s.push(M),u.push(v)}return{corners:t,fans:d,fanOf:l,spaces:s,faceNormals:e,fanNormals:u}}function mr(n,t){if(!t[0]||n.alpha===0||n.beta===0)return n.normal;const e=z(t[0]/32767),o=z(t[1]/32767),r=z((e>0?n.alpha:z(Ue-n.alpha))*e),a=z((o>0?n.beta:z(Ue-n.beta))*o);let i=n.normal.map(f=>z(f*z(Math.cos(r))));return i=ye(i,n.reference,z(z(Math.sin(r))*z(Math.cos(a)))),o!==0&&(i=ye(i,n.ortho,z(z(Math.sin(r))*z(Math.sin(a))))),i}function zo(n,t){if(!t)return null;const{corners:e,fans:o,spaces:r}=dr(n);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(e.length);for(const[i,f]of o.entries()){const c=f.reduce((l,s)=>{const u=t.data[s];return[l[0]+u[0],l[1]+u[1]]},[0,0]),d=mr(r[i],c.map(l=>Math.trunc(l/f.length)));for(const l of f)a[l]=d}return a}if(t.type==="FLOAT_VECTOR")return e.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 Je={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}},_r=1e-6;function hr(n){const t=new y;for(let e=0;e<n.length;e++){const o=n[e],r=n[(e+1)%n.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 pr=(n,t,e)=>(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x),Hn=n=>Array.from({length:n-2},(t,e)=>[0,e+1,e+2]);function gr(n){let t=0;for(let e=0;e<n.length;e++){const o=n[e],r=n[(e+1)%n.length];t+=o.x*r.y-r.x*o.y}return t}function Gn(n,t,e){if(n.length!==t.length-2||!(Math.abs(e)>0))return!1;const o=Math.sign(e);let r=0;for(const[a,i,f]of n){const c=pr(t[a],t[i],t[f]);if(c*o<0)return!1;r+=Math.abs(c)}return Math.abs(r-Math.abs(e))<=_r*Math.abs(e)}function vr(n){const t=n.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const e=hr(n),o=e.length();if(!(o>0)||!Number.isFinite(o))return{triangles:Hn(t),sound:!1,method:"fan"};const r=e.clone().divideScalar(o),a=Math.abs(r.x)<.9?new y(1,0,0):new y(0,1,0),i=new y().crossVectors(a,r).normalize(),f=new y().crossVectors(r,i),c=n[0],d=n.map(_=>{const h=_.clone().sub(c);return new Jt(h.dot(i),h.dot(f))}),l=gr(d),s=Hn(t);if(Gn(s,d,l))return{triangles:s,sound:!0,method:"fan"};let u=[];try{u=ra.triangulateShape(d,[]).map(_=>[_[0],_[1],_[2]])}catch{return{triangles:s,sound:!1,method:"fan"}}return Gn(u,d,l)?{triangles:u,sound:!0,method:"earcut"}:{triangles:u.length>0?u:s,sound:!1,method:u.length>0?"earcut":"fan"}}const xr=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function tn(n){const t=n/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function en(n,t,e){switch(n){case"FLOAT":{const o=Number(t[e]);return[o,o,o,1]}case"FLOAT2":return[Number(t[e*2]),Number(t[e*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[e*3]),Number(t[e*3+1]),Number(t[e*3+2]),1];case"BYTE_COLOR":return[tn(Number(t[e*4])),tn(Number(t[e*4+1])),tn(Number(t[e*4+2])),Number(t[e*4+3])/255];default:return[Number(t[e*4]),Number(t[e*4+1]),Number(t[e*4+2]),Number(t[e*4+3])]}}function En(n,t){return n.filter(e=>xr.has(e.type)&&e.domain!=="EDGE"&&!e.name.startsWith(".")&&e.name!=="position"&&e.name!=="custom_normal"&&!(e.type==="FLOAT2"&&e.domain==="CORNER")).map(e=>{const o=t(e.data,e.type),r=[0,0,0,0];return{name:e.name,domain:e.domain,read:(a,i,f)=>e.domain==="POINT"?en(e.type,o,a):e.domain==="CORNER"?i===void 0?r:en(e.type,o,i):f===void 0?r:en(e.type,o,f)}})}function Fo(n){const t=n.vertexCount,e=n.starts.length-1,o=n.starts,r=n.cornerVerts,a=o[e];let i=t;for(let x=0;x<e;x++)i+=(o[x+1]-o[x]-2)*3;const f=new Uint32Array(a),c=new Uint8Array(a),d=new Uint8Array(t),l=new Uint32Array(a);let s=!1;for(let x=0;x<e;x++)if(n.smooth(x)){s=!0;break}const u=(x,N)=>t<94906265?Math.min(x,N)*t+Math.max(x,N):`${Math.min(x,N)}:${Math.max(x,N)}`,_=new Map,h=new Set;for(const[x,N]of n.sharp)h.add(u(x,N));if(n.edges)for(const[x,N]of n.edges){if(x===N)throw new Error("Runtime mesh edge needs distinct vertices");_.set(u(x,N),-1)}const m=x=>{for(;l[x]!==x;)l[x]=l[l[x]],x=l[x];return x},p=(x,N)=>{const T=m(x),U=m(N);l[Math.max(T,U)]=Math.min(T,U)};for(let x=0;x<e;x++){const N=o[x],T=o[x+1]-N,U=n.smooth(x)?1:0;for(let $=0;$<T;$++){const k=N+$;d[r[k]]=1,f[k]=N+($+1)%T,c[k]=U,l[k]=k}}for(let x=0;x<a;x++){const N=f[x],T=r[x],U=r[N],$=u(T,U),k=_.get($);if(k!==void 0&&k>=0&&c[x]&&c[k]&&!h.has($)){const P=f[k];p(x,r[k]===T?k:P),p(N,r[k]===T?P:k)}(k===void 0||k<0||!c[k]&&c[x])&&_.set($,x)}const g=n.uv,v=new Float32Array(i*3),O=new Float32Array(i*2),b=new Uint32Array(i),S=(n.uvLayers??[]).map(x=>({...x,data:new Float32Array(i*2)})),w=(n.attributeLayers??[]).map(x=>({...x,data:new Float32Array(i*4)})),A=n.orco?new Float32Array(i*3):null,M=new Uint32Array(i),E=new Map,C=[],V=n.normals||n.cornerNormal?new Float32Array(i*3):null;let H=0,tt=0;const Z=(x,N,T,U,$)=>{const k=H++;for(const P of w)P.data.set(P.read(x,U,$),k*4);if(A)for(let P=0;P<3;P++)A[k*3+P]=n.orco[x*3+P]*.5+.5;if(b[k]=x,n.co(x).toArray(v,k*3),N&&O.set(N,k*2),T&&V.set(T,k*3),U!==void 0)for(const P of S)P.data.set(P.read(U),k*2);return k},nt=(x,N)=>{const T=g?.(x),U=n.cornerNormal?[n.cornerNormal[x*3],n.cornerNormal[x*3+1],n.cornerNormal[x*3+2]]:n.normals?.[x];if(!s)return Z(r[x],T,U,x,N);const $=`${c[x]?m(x):x}${T?`:${T[0]}:${T[1]}`:""}${U?`:n${U.join(":")}`:""}${S.map(P=>":"+P.read(x).join(":")).join("")}${w.map(P=>P.domain==="POINT"?"":":"+Array.from(P.read(r[x],x,N)).join(":")).join("")}`;let k=E.get($);return k===void 0&&(k=Z(r[x],T,U,x,N),E.set($,k)),k};for(let x=0;x<e;x++){const N=tt,T=o[x],U=o[x+1]-T,$=[];for(let B=0;B<U;B++)$.push(n.co(r[T+B]));for(const B of vr($).triangles)for(const Q of B)M[tt++]=nt(T+Q,x);const k=n.material(x),P=C.at(-1);P?.materialIndex===k?P.count+=tt-N:C.push({start:N,count:tt-N,materialIndex:k})}for(let x=0;x<t;x++)d[x]||Z(x);return{positions:v.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:g?O.slice(0,H*2):null,uvLayers:S.map(x=>({name:x.name,data:x.data.slice(0,H*2)})),attributeLayers:w.map(x=>({name:x.name,data:x.data.slice(0,H*4)})),orco:A?A.slice(0,H*3):null,indices:M.slice(0,tt),sourceVertex:b.slice(0,H),groups:C}}function Bt(n){return`blenderA_${Array.from(new TextEncoder().encode(n),t=>t.toString(16).padStart(2,"0")).join("")}`}function Ce(n){const t=new ee;t.setAttribute("position",new ft(n.positions,3)),t.setAttribute("uv",new ft(n.uv??new Float32Array(n.positions.length/3*2),2)),t.setIndex(new ft(n.indices,1));const e=Object.create(null);for(const[o,r]of(n.uvLayers??[]).entries()){if(o>=8)throw new Error("A Blender mesh supports at most eight UV maps");e[r.name]=o+1,t.setAttribute(`uv${o+1}`,new ft(r.data,2))}t.userData.blenderUvChannels=e;for(const o of n.attributeLayers??[])t.setAttribute(Bt(o.name),new ft(o.data,4));t.userData.blenderAttributes=(n.attributeLayers??[]).map(o=>o.name),n.orco&&(t.setAttribute("blenderOrco",new ft(n.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const o of n.groups)t.addGroup(o.start,o.count,o.materialIndex);return n.normals?t.setAttribute("normal",new ft(n.normals,3)):t.computeVertexNormals(),n.sourceVertex&&t.setAttribute("blenderVertex",new ft(n.sourceVertex,1)),t}function br(n,t){const e=n.cornerTri,o=n.cornerNormal,r=n.co.length/3,a=n.corner.length,i=n.faceStart.length-1,f=n.attributes.filter(P=>P.type==="FLOAT2"&&P.domain==="CORNER"),c=n.renderUv??n.activeUv??f[0]?.name,d=f.findIndex(P=>P.name===c);if(c&&d<0)throw new Error(`Runtime UV map ${c} is missing`);const l=En(n.attributes,P=>P),s=3+f.length*2+l.length*4,u=new Float32Array(s),_=new Float32Array(s),h=new Uint32Array(u.buffer),m=new Uint32Array(_.buffer),p=new Uint32Array(a),g=new Uint32Array(a),v=new Uint32Array(a),O=new Uint32Array(a),b=new Uint8Array(r);let S=1;for(;S<Math.max(1,a*2);)S*=2;const w=new Uint32Array(S),A=(P,B,Q,ot)=>{let ut=0;for(let et=0;et<3;et++)ot[ut++]=o[P*3+et];for(const et of f)for(let rt=0;rt<2;rt++)ot[ut++]=Number(et.data[P*2+rt]);for(const et of l){const rt=et.read(Q,P,B);for(let K=0;K<4;K++)ot[ut++]=Number(rt[K])}};let M=0;for(let P=0;P<i;P++)for(let B=n.faceStart[P];B<n.faceStart[P+1];B++){const Q=n.corner[B];if(Q>=r)throw new Error("Native mesh corner references a missing vertex");p[B]=P,b[Q]=1,A(B,P,Q,u);let ot=Math.imul(Q^2166136261,16777619);for(const rt of h)ot=Math.imul(ot^rt,16777619);const ut=ot>>>0&S-1;let et=-1;for(let rt=w[ut];rt;rt=O[rt-1]){const K=rt-1,dt=v[K];if(n.corner[dt]!==Q)continue;A(dt,p[dt],Q,_);let Tt=!0;for(let qt=0;qt<s;qt++)if(h[qt]!==m[qt]){Tt=!1;break}if(Tt){et=K;break}}et<0&&(et=M++,v[et]=B,O[et]=w[ut],w[ut]=et+1),g[B]=et}let E=0;for(const P of b)P||E++;const C=M+E,V=new Float32Array(C*3),H=new Float32Array(C*3),tt=new Uint32Array(C),Z=f.map(P=>({name:P.name,data:new Float32Array(C*2)})),nt=l.map(P=>({name:P.name,data:new Float32Array(C*4)})),x=n.orco?new Float32Array(C*3):null,N=(P,B)=>{tt[P]=B;for(let Q=0;Q<3;Q++)V[P*3+Q]=n.co[B*3+Q],x&&(x[P*3+Q]=n.orco[B*3+Q]*.5+.5)};for(let P=0;P<M;P++){const B=v[P],Q=n.corner[B];N(P,Q),A(B,p[B],Q,u),H.set(u.subarray(0,3),P*3);let ot=3;for(const ut of Z)ut.data.set(u.subarray(ot,ot+2),P*2),ot+=2;for(const ut of nt)ut.data.set(u.subarray(ot,ot+4),P*4),ot+=4}let T=M;for(let P=0;P<r;P++)if(!b[P]){N(T,P);for(let B=0;B<l.length;B++)nt[B].data.set(l[B].read(P,void 0,void 0),T*4);T++}const U=new Uint32Array(e.length),$=[];let k=0;for(let P=0;P<i;P++){const B=n.faceStart[P],Q=n.faceStart[P+1],ot=Math.max(0,Q-B-2)*3;if(k+ot>e.length)throw new Error("Native mesh triangulation is incomplete");for(let rt=0;rt<ot;rt++){const K=e[k+rt];if(K<B||K>=Q)throw new Error("Native triangle references a different face");U[k+rt]=g[K]}const ut=n.material[P],et=$.at(-1);et?.materialIndex===ut?et.count+=ot:$.push({start:k,count:ot,materialIndex:ut}),k+=ot}if(k!==e.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:V,normals:H,sourceVertex:tt,uv:d<0?null:Z[d].data,uvLayers:Z,attributeLayers:nt,orco:x,indices:U,groups:$,hash:t}}function Xn(n,t){if(n.cornerTri&&n.cornerNormal)return br(n,t);const e=n.co.length/3,o=n.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),r=n.renderUv??n.activeUv??o[0]?.name,a=o.find(m=>m.name===r);if(r&&!a)throw new Error(`Runtime UV map ${r} is missing`);const i=a?a.data:null,f=n.edge.length/2,c=new Array(f);for(let m=0;m<f;m++)c[m]=[n.edge[m*2],n.edge[m*2+1]];const d=[];for(let m=0;m<f;m++)n.edgeSharp[m]===1&&d.push(c[m]);const l=n.cornerNormal?void 0:n.attributes.find(m=>m.name==="custom_normal"),s=l?{v:Array.from({length:e},(m,p)=>[n.co[p*3],n.co[p*3+1],n.co[p*3+2]]),f:Array.from({length:n.faceStart.length-1},(m,p)=>Array.from(n.corner.subarray(n.faceStart[p],n.faceStart[p+1]))),s:Array.from(n.smooth,Boolean),edge_order:c,sharp:d,face_edges:Array.from({length:n.faceStart.length-1},(m,p)=>Array.from(n.cornerEdge.subarray(n.faceStart[p],n.faceStart[p+1]))),edge_sharp:Array.from(n.edgeSharp,Boolean)}:null,u=l?{type:l.type,domain:l.domain,data:Array.from({length:l.data.length/Je[l.type].size},(m,p)=>Array.from({length:Je[l.type].size},(g,v)=>Number(l.data[p*Je[l.type].size+v])))}:void 0,_=new y,h={vertexCount:e,normals:s?zo(s,u):null,cornerNormal:n.cornerNormal,orco:n.orco,co:m=>_.set(n.co[m*3],n.co[m*3+1],n.co[m*3+2]).clone(),starts:n.faceStart,cornerVerts:n.corner,smooth:m=>n.smooth[m]===1,material:m=>n.material[m],edges:c,sharp:d,uv:i?m=>[i[m*2],i[m*2+1]]:null,uvLayers:o.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:En(n.attributes,m=>m)};return{...Fo(h),hash:t}}function yr(n){const t=n.v.map(s=>new y(...s)),e=s=>{const u=t[s];if(!u)throw new Error(`Runtime mesh vertex ${s} is missing`);return u},o=new Uint32Array(n.f.length+1);n.f.forEach((s,u)=>{if(s.length<3||new Set(s).size!==s.length)throw new Error("Runtime mesh face needs at least three distinct vertices");o[u+1]=o[u]+s.length});const r=new Uint32Array(o[n.f.length]);n.f.forEach((s,u)=>s.forEach((_,h)=>{e(_),r[o[u]+h]=_}));for(const[s,u]of n.edge_order??n.e??[])e(s),e(u);const a={POINT:t.length,EDGE:(n.edge_order??n.e??[]).length,FACE:n.f.length,CORNER:r.length};for(const s of n.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=(n.attributes??[]).filter(s=>s.type==="FLOAT2"&&s.domain==="CORNER"),f=n.render_uv??n.active_uv??i[0]?.name,c=i.find(s=>s.name===f);if(f&&!c)throw new Error(`Runtime UV map ${f} is missing`);const d=c?.data,l={vertexCount:t.length,normals:zo(n,n.attributes?.find(s=>s.name==="custom_normal")),co:e,starts:o,cornerVerts:r,smooth:s=>!!n.s?.[s],material:s=>n.m?.[s]??0,edges:n.edge_order??n.e??null,sharp:n.sharp??[],uv:d?s=>d[s]:null,uvLayers:i.map(s=>({name:s.name,read:u=>s.data[u]})),attributeLayers:En(n.attributes??[],s=>Array.from(s).flat())};return Ce(Fo(l))}const we=1.5707963267948966,Qt=6.283185307179586,Co=.3183098861837067,ko=.0795774715459476,wr=.3,Or=ko,Ar=3/16*Co,gn=.8,Yn=gn*gn,Kt=6371,$o=100,vn=Kt+$o,Zn=64,Qn=64,mt=256,Ht=64,Mr=[1.679,1.828,1.986,1.307],Tr=[.006605,.01067,.01842,.03156],Sr=[3472e-28,3914e-28,1349e-28,1103e-29],Pr=334.5,Er=[28722e-28,46168e-28,79706e-28,13578e-27],Nr=[15908e-26,17711e-26,20942e-26,24033e-26],Kn=13681e16,Rr=2e6,Ir=.73,nn=[[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]],We=n=>n*n,ve=n=>n<0?0:n>1?1:n,Dt=(n,t,e)=>n+e*(t-n),Dr=n=>Math.sqrt(Math.max(n,0)),Lo=n=>[-Math.sqrt(1-n*n),0,n];function xn(n,t,e,o,r,a,i){const f=n*o+t*r+e*a,c=n*n+t*t+e*e-i*i;if(c>0&&f>0)return-1;const d=f*f-c;return d<0?-1:d>=f*f?-f+Math.sqrt(d):-f-Math.sqrt(d)}const zr=n=>Ar*(1+We(n));function Fr(n){const t=1+Yn+2*gn*n;return ko*(1-Yn)/(t*Math.sqrt(t))}const Cr=n=>Kn*(Math.exp(-n/Ir)+Rr/Kn);function Nn(n,t){let e=n%Qt;Math.abs(e)>=Math.PI&&(e-=Math.sign(e)*2*Math.PI);let o=t;return(e>=we||e<=-we)&&(e=Math.sign(e)*Math.PI-e,o+=Math.PI),o=o%Qt,o<0&&(o+=Qt),o=Qt-o,[e,o]}class kr{constructor(t,e,o){this.air=t,this.aerosol=e,this.ozone=o,this.lut=new Float32Array(Ht*mt*4)}coefficients(t,e){const o=Cr(t)*this.aerosol,r=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-We(r-3.22261)*5.55555555-r),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)e[f]=Er[f]*o,e[4+f]=Nr[f]*o,e[8+f]=Sr[f]*Pr*a*this.ozone,e[12+f]=Tr[f]*i*this.air}transmittance(t,e,o){const[r,a,i]=Lo(t),f=Dt(Kt,vn,e),d=xn(0,0,f,r,a,i,vn)/Zn,l=[0,0,0,0],s=new Float64Array(16);for(let u=0;u<Zn;u++){const _=(u+.5)*d,h=r*_,m=a*_,p=f+i*_,g=Math.max(Math.hypot(h,m,p)-Kt,0);this.coefficients(g,s);for(let v=0;v<4;v++)l[v]+=(s[v]+s[4+v]+s[8+v]+s[12+v])*d}for(let u=0;u<4;u++)o[u]=Math.exp(-l[u])}precompute(){const t=new Float64Array(4);for(let e=0;e<Ht;e++)for(let o=0;o<mt;o++){const r=o/(mt-1),a=e/(Ht-1);this.transmittance(r*2-1,a,t);const i=(e*mt+o)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,e,o){const r=(mt-1)*ve(t*.5+.5),a=(Ht-1)*ve(e),i=Math.trunc(r),f=Math.trunc(a),c=Math.min(i+1,mt-1),d=Math.min(f+1,Ht-1),l=r-i,s=a-f,u=(f*mt+i)*4,_=(f*mt+c)*4,h=(d*mt+i)*4,m=(d*mt+c)*4;for(let p=0;p<4;p++)o[p]=Dt(Dt(this.lut[u+p],this.lut[_+p],l),Dt(this.lut[h+p],this.lut[m+p],l),s)}lookupAtGround(t,e){const o=(mt-1)*ve(t*.5+.5),r=Math.trunc(o),a=Math.min(r+1,mt-1),i=o-r;for(let f=0;f<4;f++)e[f]=Dt(this.lut[r*4+f],this.lut[a*4+f],i)}lookupToSun(t,e){const o=(Ht-1)*ve(t),r=Math.trunc(o),a=Math.min(r+1,Ht-1),i=o-r,f=mt-1;for(let c=0;c<4;c++)e[c]=Dt(this.lut[(r*mt+f)*4+c],this.lut[(a*mt+f)*4+c],i)}inscattering(t,e,o,r,a,i,f,c,d){const l=-(a*t[0]+i*t[1]+f*t[2]),s=zr(l),u=Fr(l),_=c/Qn,h=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),g=new Float64Array(4),v=new Float64Array(4),O=new Float64Array(4),b=[0,0,0,0],S=[1,1,1,1];for(let w=0;w<Qn;w++){const A=(w+.5)*_,M=e+a*A,E=o+i*A,C=r+f*A,V=Math.hypot(M,E,C),H=Math.max(V-Kt,0),tt=H/$o,Z=(M*t[0]+E*t[1]+C*t[2])/V;this.coefficients(H,h),this.lookup(Z,tt,m);const nt=Qt*(1-Dr(1-We(Kt/V)));this.lookupAtGround(Z,g),this.lookupToSun(0,v),this.lookupToSun(tt,O);const x=1/(1+5*Math.exp(-17.92*Z)),N=[.217,.347,.594,1];for(let T=0;T<4;T++){const U=v[T]/O[T],$=Or*nt*(wr*Co)*g[T]*U*Z;p[T]=.02*N[T]*x+$}for(let T=0;T<4;T++){const U=h[T]+h[4+T]+h[8+T]+h[12+T],$=Mr[T]*(h[12+T]*(s*m[T]+p[T])+h[4+T]*(u*m[T]+p[T])),k=Math.exp(-_*U),P=Math.max(U,1e-7);b[T]+=S[T]*(($-$*k)/P),S[T]*=k}}for(let w=0;w<4;w++)d[w]=b[w]}}const vt=512,ie=256;function jo(n,t){const e=new kr(n.airDensity,n.aerosolDensity,n.ozoneDensity);e.precompute();const o=Math.min(Math.max(n.altitude,1),99999)/1e3,r=Lo(Math.cos(we-t)),a=new Float32Array(vt*ie*3),i=vt/2,f=new Float64Array(4);for(let c=0;c<ie;c++)for(let d=0;d<i;d++){const l=(d+.5)/vt,s=(c+.5)/ie,u=Qt*l,_=s*2-1,h=Math.sign(_)*We(_)*we,m=Math.cos(h)*Math.cos(u),p=Math.cos(h)*Math.sin(u),g=Math.sin(h),v=Kt+o,O=xn(0,0,v,m,p,g,vn),b=xn(0,0,v,m,p,g,Kt),S=b<0?O:b;e.inscattering(r,0,0,v,m,p,g,S,f);let w=0,A=0,M=0;for(let V=0;V<4;V++)w+=nn[V][0]*f[V],A+=nn[V][1]*f[V],M+=nn[V][2]*f[V];const E=(c*vt+d)*3;a[E]=w,a[E+1]=A,a[E+2]=M;const C=(c*vt+(vt-d-1))*3;a[C]=w,a[C+1]=A,a[C+2]=M}return a}function $r(n){const[t]=Nn(n.sunElevation,n.sunRotation);return jo(n,t)}function Rn(n){const[t]=Nn(n.sunElevation,n.sunRotation);return JSON.stringify([t,n.altitude,n.airDensity,n.aerosolDensity,n.ozoneDensity])}const Lr=6,re=new Map;function jr(n){return re.has(Rn(n))}function Vo(n,t){re.set(Rn(n),t),re.size>Lr&&re.delete(re.keys().next().value)}function Vr(n){const[t,e]=Nn(n.sunElevation,n.sunRotation),o=Rn(n);let r=re.get(o);r===void 0&&(r=jo(n,t),Vo(n,r));const a=new y;return i=>{const f=Math.hypot(i.x,i.y),c=Math.atan2(i.z,f);let l=(Math.atan2(i.x,i.y)+Math.PI+e)/Qt;l-=Math.floor(l);const s=Math.abs(c),u=ve(Math.sqrt(s/we)*Math.sign(c)*.5+.5),_=l*vt-.5,h=u*ie-.5,m=Math.floor(_),p=Math.floor(h),g=_-m,v=h-p,O=C=>(C%vt+vt)%vt,b=C=>C<0?0:C>ie-1?ie-1:C,S=O(m),w=O(m+1),A=b(p),M=b(p+1),E=[0,0,0];for(let C=0;C<3;C++){const V=Dt(r[(A*vt+S)*3+C],r[(A*vt+w)*3+C],g),H=Dt(r[(M*vt+S)*3+C],r[(M*vt+w)*3+C],g);E[C]=Dt(V,H,v)}return a.set(Rt[0][0]*E[0]+Rt[0][1]*E[1]+Rt[0][2]*E[2],Rt[1][0]*E[0]+Rt[1][1]*E[1]+Rt[1][2]*E[2],Rt[2][0]*E[0]+Rt[2][1]*E[1]+Rt[2][2]*E[2])}}let kt=null,Me=!1,Br=0;const xe=new Map;function Ur(){if(kt||Me)return kt;if(typeof Worker>"u")return Me=!0,null;try{kt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return Me=!0,null}return kt.onmessage=n=>{const{id:t,pixels:e,error:o}=n.data,r=xe.get(t);r&&(xe.delete(t),e?r.resolve(e):r.reject(new Error(o??"sky worker returned nothing")))},kt.onerror=n=>{const t=new Error(`sky worker failed: ${n.message||"unknown error"}`);for(const e of xe.values())e.reject(t);xe.clear(),kt?.terminate(),kt=null,Me=!0},kt}function Wr(n){const t=Ur();if(!t)return Promise.resolve($r(n));const e=Br++,o={id:e,parameters:n};return new Promise((r,a)=>{xe.set(e,{resolve:r,reject:a}),t.postMessage(o)})}function qr(n,t,e,o={}){switch(o.type??"LINEAR"){case"QUADRATIC":{const r=Math.max(n,0);return r*r}case"EASING":{const r=Math.min(1,Math.max(0,n));return r*r*(3-2*r)}case"DIAGONAL":return(n+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(n,t,e),0);case"QUADRATIC_SPHERE":{const r=Math.max(.999999-Math.hypot(n,t,e),0);return r*r}case"RADIAL":return Math.atan2(t,n)/(2*Math.PI)+.5;default:return n}}const on=(n,t)=>t!==0?n/t:0,Jn=n=>Math.min(1,Math.max(-1,n)),to=(n,t,e)=>{const o=e!==0?Math.max(e-Math.abs(n-t),0)/e:0;return Math.min(n,t)-o*o*o*e/6},Bo={ADD:(n,t)=>n+t,SUBTRACT:(n,t)=>n-t,MULTIPLY:(n,t)=>n*t,DIVIDE:on,POWER:(n,t)=>t===0?1:n===0||n<0&&!Number.isInteger(t)?0:n**t,LOGARITHM:(n,t)=>n<=0||t<=0?0:on(Math.log(n),Math.log(t)),SQRT:n=>Math.sqrt(Math.max(n,0)),INVERSE_SQRT:n=>n>0?1/Math.sqrt(n):0,ABSOLUTE:Math.abs,RADIANS:n=>n*Math.PI/180,DEGREES:n=>n*180/Math.PI,MINIMUM:(n,t)=>Math.min(n,t),MAXIMUM:(n,t)=>Math.max(n,t),LESS_THAN:(n,t)=>+(n<t),GREATER_THAN:(n,t)=>+(n>t),ROUND:n=>Math.floor(n+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:n=>n-Math.floor(n),MODULO:(n,t)=>t!==0?n%t:0,FLOORED_MODULO:(n,t)=>t!==0?n-Math.floor(n/t)*t:0,TRUNC:Math.trunc,SNAP:(n,t)=>Math.floor(on(n,t))*t,WRAP:(n,t,e)=>t!==e?n-(t-e)*Math.floor((n-e)/(t-e)):e,PINGPONG:(n,t)=>{if(t===0)return 0;const e=(n-t)/(t*2);return Math.abs((e-Math.floor(e))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:n=>Math.asin(Jn(n)),ARCCOSINE:n=>Math.acos(Jn(n)),ARCTANGENT:Math.atan,ARCTAN2:(n,t)=>n===0&&t===0?0:Math.atan2(n,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(n,t,e)=>+(n===t||Math.abs(n-t)<=Math.max(e,2**-23)),MULTIPLY_ADD:(n,t,e)=>n*t+e,SMOOTH_MIN:to,SMOOTH_MAX:(n,t,e)=>-to(-n,-t,e)};function lt(n,t){if(typeof n=="number")return()=>n;if(Array.isArray(n)){const r=new y(...n);return()=>r}if(n.kind==="direction")return r=>r;if(n.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(n.kind==="gradient"){const r=lt(n.vector,t),a={type:n.gradient_type},i=new y;return f=>{const c=r(f),d=typeof c=="number"?c:c.x,l=typeof c=="number"?c:c.y,s=typeof c=="number"?c:c.z,u=wt.clamp(qr(d,l,s,a),0,1);return n.output==="Fac"?u:i.setScalar(u)}}if(n.kind==="to_float"){const r=lt(n.value,t);return a=>{const i=r(a);return typeof i=="number"?i:Math.fround(n.source_type==="RGBA"?i.x*.212639+i.y*.7151687+i.z*.0721923:(i.x+i.y+i.z)/3)}}if(n.kind==="math"){const r=n.inputs.map(f=>lt(f,t)),a=Bo[n.operation],i=(f,c)=>{const d=r[f]?.(c)??0;if(typeof d!="number")throw new Error("World Math needs scalar inputs");return Math.fround(d)};return f=>{const c=Math.fround(a(i(0,f),i(1,f),i(2,f)));return n.clamp?wt.clamp(c,0,1):c}}if(n.kind==="mix_color"){const r=lt(n.factor,t),a=lt(n.a,t),i=lt(n.b,t),f=new y,c=new y;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 u=i(d);return typeof u=="number"?c.setScalar(u):c.copy(u),f.lerp(c,n.clamp_factor?wt.clamp(l,0,1):l),n.clamp_result&&f.clampScalar(0,1),f}}if(n.kind==="sky"){const r=Vr({sunElevation:n.sun_elevation,sunRotation:n.sun_rotation,altitude:n.altitude,airDensity:n.air_density,aerosolDensity:n.aerosol_density,ozoneDensity:n.ozone_density});return a=>r(a)}if(n.kind==="mapping"){const r=lt(n.vector,t),a=new y(...n.location),i=new y(...n.scale),f=new St().setFromEuler(new sa(n.rotation[0],n.rotation[1],n.rotation[2],"ZYX")),c=f.clone().invert(),d=new y(...n.scale.map(s=>s===0?0:1/s)),l=new y;return s=>{const u=r(s);switch(typeof u=="number"?l.setScalar(u):l.copy(u),n.vector_type??"POINT"){case"TEXTURE":return l.sub(a).applyQuaternion(c).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(n.kind==="map_range"){const r=lt(n.value,t),a=lt(n.from_min,t),i=lt(n.from_max,t),f=lt(n.to_min,t),c=lt(n.to_max,t),d=lt(n.steps,t),l=(_,h)=>{const m=_(h);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},s=n.interpolation,u=n.clamp;return _=>{const h=l(r,_),m=l(a,_),p=l(i,_),g=l(f,_),v=l(c,_);if(m===p)return 0;let O;if(s==="STEPPED"){const S=l(d,_),w=(h-m)/(p-m);O=S>0?Math.floor(w*(S+1))/S:0}else if(s==="SMOOTHSTEP"||s==="SMOOTHERSTEP"){const S=wt.clamp((h-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),w=s==="SMOOTHSTEP"?S*S*(3-2*S):S*S*S*(S*(S*6-15)+10);O=m>p?1-w:w}else O=(h-m)/(p-m);const b=g+O*(v-g);return u?g>v?wt.clamp(b,v,g):wt.clamp(b,g,v):b}}if(n.kind==="separate"){const r=lt(n.vector,t);return a=>{const i=r(a);return typeof i=="number"?i:i.getComponent(n.axis)}}const e=lt(n.factor,t),o=new y;return r=>{const a=e(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),c=n.colors[f],d=n.colors[Math.min(f+1,256)],l=n.interpolate?i-f:0;return o.set(wt.lerp(c[0],d[0],l),wt.lerp(c[1],d[1],l),wt.lerp(c[2],d[2],l))}}function Hr(n,t,e,o){const r=new Float32Array(t*e*3),a=lt(n,o),i=new y;for(let f=0;f<e;f++){const c=((f+.5)/e-.5)*Math.PI;for(let d=0;d<t;d++){const l=((d+.5)/t-.5)*2*Math.PI;i.set(Math.cos(c)*Math.cos(l),-Math.cos(c)*Math.sin(l),Math.sin(c));const s=a(i),u=(f*t+d)*3;r[u]=typeof s=="number"?s:s.x,r[u+1]=typeof s=="number"?s:s.y,r[u+2]=typeof s=="number"?s:s.z}}return r}function eo(n){const t=[],e=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":e(o.vector);return;case"ramp":e(o.factor);return;case"mix_color":e(o.factor),e(o.a),e(o.b);return;case"math":o.inputs.forEach(e);return;case"to_float":e(o.value);return;case"map_range":e(o.value),e(o.from_min),e(o.from_max),e(o.to_min),e(o.to_max),e(o.steps);return;default:return}};return e(n),t}function Lt(n){if(typeof n=="number"||Array.isArray(n))return!1;switch(n.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Lt(n.vector);case"ramp":return Lt(n.factor);case"mix_color":return[n.factor,n.a,n.b].some(Lt);case"math":return n.inputs.some(Lt);case"to_float":return Lt(n.value);case"map_range":return[n.value,n.from_min,n.from_max,n.to_min,n.to_max,n.steps].some(Lt);default:return!1}}function Gr(n,t,e,o){o.updateMatrixWorld();const r=new Float32Array(t*e*3),a=new y,i=lt(n,()=>a),f=new y,c=o.getWorldPosition(new y),d=o.getWorldDirection(new y);for(let l=0;l<e;l++)for(let s=0;s<t;s++){const u=(s+.5)/t,_=(l+.5)/e;a.set(u,_,0),o.isOrthographicCamera?f.copy(d):f.set(u*2-1,_*2-1,.5).unproject(o).sub(c).normalize(),f.set(f.x,-f.z,f.y);const h=i(f),m=(l*t+s)*3;r[m]=typeof h=="number"?h:h.x,r[m+1]=typeof h=="number"?h:h.y,r[m+2]=typeof h=="number"?h:h.z}return r}const it=I().finite(),Xr=R({type:Y(["POINT","SUN","SPOT","AREA"]),color:W([it,it,it]),energy:it,use_shadow:at().default(!0),radius:it.optional(),spot_size:it.optional(),spot_blend:it.optional(),shape:Y(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:it.optional(),size_y:it.optional()}).strict();let bn;function Yr(){return bn??=qa(async()=>{const{RectAreaLightUniformsLib:n}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:n}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:n})=>{n.init(),_t()}),bn}function Zr(){return bn??Promise.resolve()}const Qr=n=>{const t=n.size??0,e=n.size_y??t;if(n.shape==="RECTANGLE")return[t,e];if(n.shape==="DISK"){const o=Math.sqrt(Math.PI*t*t/4);return[o,o]}if(n.shape==="ELLIPSE"){const o=Math.sqrt(Math.PI/4);return[t*o,e*o]}return[t,t]};function Kr(n,t){const e=(i,f)=>t&&f(t)?t:new i;if(n.type==="SUN"){const i=e(To,f=>f.isDirectionalLight);return i.intensity=n.energy,i.color.setRGB(n.color[0],n.color[1],n.color[2],bt),i.castShadow=n.use_shadow,i}if(n.type==="POINT"){const i=e(dn,f=>f.isPointLight);return i.intensity=n.energy/(4*Math.PI),i.distance=0,i.decay=2,i.color.setRGB(n.color[0],n.color[1],n.color[2],bt),i.castShadow=n.use_shadow,i}if(n.type==="SPOT"){const i=e(mn,f=>f.isSpotLight);return i.intensity=n.energy/(4*Math.PI),i.distance=0,i.decay=2,i.angle=(n.spot_size??0)/2,i.penumbra=n.spot_blend??0,i.color.setRGB(n.color[0],n.color[1],n.color[2],bt),i.castShadow=n.use_shadow,i}Yr();const o=e(Fe,i=>i.isRectAreaLight),[r,a]=Qr(n);return o.width=r,o.height=a,o.intensity=n.energy/(Math.max(r*a,Number.MIN_VALUE)*Math.PI),o.color.setRGB(n.color[0],n.color[1],n.color[2],bt),o}function Jr(n,t,e){if(!n.castShadow||e<=0)return;const r=n.getWorldPosition(new y).distanceTo(t),a=n.shadow;if(!a)return;const i=a.camera;i.near=Math.max(e*.001,r-e),i.far=r+e,n.isDirectionalLight&&(i.left=-e,i.right=e,i.top=e,i.bottom=-e),i.updateProjectionMatrix()}function ts(n,t){n.position.set(0,0,0);const e=n;n.isRectAreaLight||e.target&&e.target.parent!==t&&(e.target.position.set(0,0,-1),t.add(e.target))}const In=[{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}],no=.69;class es{constructor(){this.group=new ct,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Le;t.name="BlenderSolidStudioTarget",this.group.add(t);const e=new Mt(0,0,0);for(const[r,a]of In.entries()){const i=(1+a.smooth)**2,f=new To(16777215,Math.PI*no/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),e.r+=a.diffuse[0]*a.smooth/i,e.g+=a.diffuse[1]*a.smooth/i,e.b+=a.diffuse[2]*a.smooth/i}const o=new ia(16777215,Math.PI*no);o.name="BlenderSolidWrapFill",o.color.copy(e),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 ae=W([it,it,it]),J=Io(()=>Wt([it,ae,R({kind:X("direction")}).strict(),R({kind:X("window")}).strict(),R({kind:X("gradient"),gradient_type:Y(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:Y(["Fac","Color"]),vector:J}).strict(),R({kind:X("to_float"),source_type:Y(["RGBA","VECTOR"]),value:J}).strict(),R({kind:X("math"),operation:Y(Object.keys(Bo)),clamp:at(),inputs:L(J).min(1).max(3)}).strict(),R({kind:X("mix_color"),factor:J,a:J,b:J,clamp_factor:at(),clamp_result:at()}).strict(),R({kind:X("mapping"),vector_type:Y(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:J,location:ae,rotation:ae,scale:ae}).strict(),R({kind:X("separate"),vector:J,axis:I().int().min(0).max(2)}).strict(),R({kind:X("ramp"),factor:J,colors:L(ae).length(257),interpolate:at()}).strict(),R({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(),R({kind:X("sky"),sun_elevation:it,sun_rotation:it,altitude:it,air_density:it,aerosol_density:it,ozone_density:it}).strict()])),oo=R({color:ae,strength:it,shader:J.optional()}),ns=oo.extend({volume:L(R({kind:Y(["absorption","scatter","principled","emission"]),phase:D(),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:oo.strict().optional()}).strict(),os=4,pe=new Map,an=new Set;function ao(n,t,e){const a=Lt(n);if(a&&!e)throw new Error("World Window coordinates need a render camera");e?.updateMatrixWorld();const i=JSON.stringify([n,a?[e.matrixWorld.elements,e.projectionMatrix.elements]:null]),f=pe.get(i);if(f!==void 0)return yn(f,t,256,128);const c=new y,d=new Ge,l=e?new q().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse):null,s=e?.getWorldPosition(new y),_=Hr(n,256,128,a?h=>(c.set(h.x,h.z,-h.y),e.isPerspectiveCamera&&c.add(s),d.set(c.x,c.y,c.z,1).applyMatrix4(l),d.w===0?c.set(0,0,0):c.set(d.x/d.w*.5+.5,d.y/d.w*.5+.5,0)):void 0);return pe.set(i,_),pe.size>os&&pe.delete(pe.keys().next().value),yn(_,t,256,128)}function as(n,t,e,o){const r=ge.toHalfFloat(1);for(let a=0;a<o;a++)n[a*4]=ge.toHalfFloat(t[a*3]*e),n[a*4+1]=ge.toHalfFloat(t[a*3+1]*e),n[a*4+2]=ge.toHalfFloat(t[a*3+2]*e),n[a*4+3]=r}function yn(n,t,e,o){const r=new Uint16Array(e*o*4);as(r,n,t,e*o);const a=new Xe(r,e,o,Ye,Tn);return a.mapping=fa,a.colorSpace=bt,a.minFilter=te,a.magFilter=te,a.needsUpdate=!0,a}class Dn{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 e=t;for(;e;){if(e.isScene)return e;e=e.parent}return null}apply(t,e,o){if(this.clear(),this.pending=null,!e)return;const r=Dn.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=e.shader??e.color,i=this.generation,c=[...eo(a),...e.lighting?eo(e.lighting.shader??e.lighting.color):[]].filter(l=>!jr(l));if(c.length===0){this.compose(r,e,a,o);return}const d=(async()=>{const l=await Promise.all(c.map(Wr));c.forEach((s,u)=>{Vo(s,l[u])}),!(this.generation!==i||this.applied?.scene!==r)&&(this.compose(r,e,a,o),_t())})();this.pending=d,an.add(d),d.then(()=>an.delete(d),()=>an.delete(d))}compose(t,e,o,r){if(this.texture=ao(o,e.strength,r),Lt(o)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=yn(Gr(o,512,512,r),e.strength,512,512),this.screenTexture.mapping=la,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const i=r.getWorldDirection(new y);i.set(i.x,-i.z,i.y);const f=lt(e.shader??e.color)(i);t.background=typeof f=="number"?new Mt().setRGB(f,f,f).multiplyScalar(e.strength):new Mt().setRGB(f.x,f.y,f.z).multiplyScalar(e.strength)}else t.background=this.texture;const{lighting:a}=e;this.environmentTexture=a?ao(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 Uo(n){return[n.min.x,n.max.x].flatMap(t=>[n.min.y,n.max.y].flatMap(e=>[n.min.z,n.max.z].map(o=>new y(t,e,o))))}function rs(n,t){if(n.isEmpty()||!t.intersectsBox(n))return[];const e=Uo(n);if(e.every(l=>t.containsPoint(l)))return e;const o=[...t.planes,new Xt(new y(1,0,0),-n.min.x),new Xt(new y(-1,0,0),n.max.x),new Xt(new y(0,1,0),-n.min.y),new Xt(new y(0,-1,0),n.max.y),new Xt(new y(0,0,1),-n.min.z),new Xt(new y(0,0,-1),n.max.z)],r=[],a=new y,i=new y,f=new y,c=new y,d=Math.max(1,n.min.length(),n.max.length())*1e-8;for(let l=0;l<o.length;l++)for(let s=l+1;s<o.length;s++)for(let u=s+1;u<o.length;u++){const _=o[l],h=o[s],m=o[u];a.crossVectors(h.normal,m.normal);const p=_.normal.dot(a);Math.abs(p)<1e-12||(i.crossVectors(m.normal,_.normal),f.crossVectors(_.normal,h.normal),c.copy(a).multiplyScalar(-_.constant).addScaledVector(i,-h.constant).addScaledVector(f,-m.constant).divideScalar(p),o.every(g=>g.distanceToPoint(c)>=-d)&&r.push(c.clone()))}return r}function ss(n,t,e){if(!n.castShadow||!t.length)return;n.shadow.updateMatrices(n);const o=n.shadow.camera,r=o.matrixWorldInverse,a=new fe().setFromPoints(t.map(u=>u.clone().applyMatrix4(r))),i=a.getSize(new y),f=Math.max(i.length()*1e-6,Number.EPSILON),c=2+2*Math.SQRT2,d=Math.max(i.x,i.y,f)/Math.max(1,Math.min(n.shadow.mapSize.x,n.shadow.mapSize.y)-2*c),l=2*Math.SQRT2*d,s=c*d;a.min.x-=s,a.min.y-=s,a.max.x+=s,a.max.y+=s;for(const u of e){if(u.isEmpty())continue;const _=new fe().setFromPoints(Uo(u).map(h=>h.applyMatrix4(r)));_.max.x<a.min.x||_.min.x>a.max.x||_.max.y<a.min.y||_.min.y>a.max.y||(a.min.z=Math.min(a.min.z,_.min.z),a.max.z=Math.max(a.max.z,_.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(),n.shadow.normalBias=l}const le=I().finite(),ro=W([le,le,le]),Wo=R({min:W([I().int(),I().int(),I().int()]),max:W([I().int(),I().int(),I().int()]),density:L(le),voxelSize:le.positive(),color:ro,emission:ro,densityScale:le.nonnegative()}).strict();function is(n){const t=n.max.map((l,s)=>l-n.min[s]+1);if(t.some(l=>l<=0)||t.reduce((l,s)=>l*s,1)!==n.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const e=new ca(new Float32Array(n.density),t[0],t[1],t[2]);e.format=ua,e.type=So,e.minFilter=e.magFilter=te,e.unpackAlignment=1,e.needsUpdate=!0;const o=new y(...n.min).addScalar(-.5).multiplyScalar(n.voxelSize),r=new y(t[0],t[1],t[2]).multiplyScalar(n.voxelSize),a=new da(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 Mn({glslVersion:_a,side:ma,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:e},minimum:{value:o},extent:{value:r},voxelSize:{value:n.voxelSize},densityScale:{value:n.densityScale},volumeColor:{value:new y(...n.color)},emission:{value:new y(...n.emission)},cameraLocal:{value:new y},rayLocal:{value:new y},orthographic:{value:!1},worldScale:{value:new Mo}},vertexShader:`
|
|
19
|
+
`;function jt(n){return new Mt().setHex(n,Ut)}function $n(n,t){const e=n.mode==="POSE";let o;return e?t.active&&t.select?o=jt(Et.poseActive):t.active?o=jt(Et.poseActiveUnsel):t.select?o=jt(Et.pose):o=jt(Et.wire):o=jt(Et.vertex),e&&t.lockedWeight&&o.lerp(jt(Et.lockedWeight),Et.lockedWeightFactor),o}function Ln(n,t){const e=jt(Et.solid);return n.mode==="POSE"&&t.lockedWeight&&e.lerp(jt(Et.lockedWeight),Et.lockedWeightFactor),e}const or=new q,ar=new y,jn=new Oo;function Vn(n,t){return new q().set(...t.matrix.flat()).premultiply(n).scale(new y().setScalar(t.length))}class rr{constructor(){this.group=new ct,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,e){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 s=e(a.object);if(s===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 c=a.displayType==="STICK"?this.buildStick(a,f,s):this.buildOctahedral(a,f,s);a.showInFront&&c.traverse(d=>{const l=d.material;l&&"depthTest"in l&&(l.depthTest=!1),d.renderOrder=10}),this.group.add(c)}return o}buildOctahedral(t,e,o){const r=new ct;r.name=`${t.object}:bones`;const a=[],s=[],f=[],c=[],d=[],l=[],i=[],u=[],m=[],h=[];for(const _ of e){const p=Vn(o,_),g=Ln(t,_),v=Ya(g),O=$n(t,_);jn.setFromMatrix4(p).invert().transpose();for(let w=0;w<Fn.length;w++){const A=ar.set(...Za[w]).applyMatrix3(jn).normalize().clone();for(const M of Fn[w]){const E=new y(...Ge[M]).applyMatrix4(p);a.push(E.x,E.y,E.z),s.push(A.x,A.y,A.z),f.push(g.r,g.g,g.b),c.push(v.r,v.g,v.b)}}const b=kn(_)===2?i:d,S=kn(_)===2?u:l;for(const[w,A]of Ka){const M=new y(...Ge[w]).applyMatrix4(p),E=new y(...Ge[A]).applyMatrix4(p);b.push(M.x,M.y,M.z,E.x,E.y,E.z),S.push(O.r,O.g,O.b,O.r,O.g,O.b)}_.parent!==null&&_.connected||(m.push(p.clone()),h.push(g)),m.push(p.clone().multiply(or.makeTranslation(0,1,0))),h.push(g)}r.add(this.solidMesh(a,s,f,c)),d.length&&r.add(this.lines(d,l,1)),i.length&&r.add(this.lines(i,u,2));for(let _=0;_<m.length;_++)r.add(this.point(m[_],h[_]));return r}buildStick(t,e,o){const r=new ct;r.name=`${t.object}:bones`;const a=[],s=[],f=[],c=[];for(const d of e){const l=Vn(o,d),i=new y().setFromMatrixPosition(l),u=new y(0,1,0).applyMatrix4(l),m=$n(t,d),h=Ln(t,d);a.push(i.x,i.y,i.z,u.x,u.y,u.z),s.push(m.r,m.g,m.b,m.r,m.g,m.b),f.push(i.x,i.y,i.z,u.x,u.y,u.z),c.push(h.r,h.g,h.b,h.r,h.g,h.b)}return r.add(this.lines(a,s,Ja)),r.add(this.lines(f,c,tr)),r}solidMesh(t,e,o,r){const a=new oe;a.setAttribute("position",new Nt(t,3)),a.setAttribute("normal",new Nt(e,3)),a.setAttribute("aSolid",new Nt(o,3)),a.setAttribute("aHint",new Nt(r,3));const s=new On({vertexShader:er,fragmentShader:nr,side:aa});this.disposables.push(a,s);const f=new Ft(a,s);return f.frustumCulled=!1,f}lines(t,e,o){const r=new bo;r.setPositions(t),r.setColors(e);const a=new yo({linewidth:o,vertexColors:!0});this.disposables.push(r,a);const s=new wo(r,a);return s.frustumCulled=!1,s}point(t,e){const o=new ra(Qa,12,8),r=new ke({color:e});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 Bn="RUNTIME_FRAME_UNKNOWN_GEOMETRY",me="RUNTIME_FRAME_UNKNOWN_IMAGE";function sr(n){const t=Math.fround,e=t(t(t(n[0]*n[0])+t(n[1]*n[1]))+t(n[2]*n[2]));if(e>1e-35){const o=t(Math.sqrt(e)),r=t(1/o);return{unit:[t(n[0]*r),t(n[1]*r),t(n[2]*r)],length:o}}return{unit:[0,0,0],length:0}}const z=Math.fround,je=z(2*Math.PI),Xe=z(1-1e-4),Zt=(n,t)=>z(z(z(n[0]*t[0])+z(n[1]*t[1]))+z(n[2]*t[2])),ye=(n,t,e=1)=>n.map((o,r)=>z(o+z(t[r]*e))),ir=(n,t)=>n.map((e,o)=>z(e-t[o]));function _e(n){const t=z(Math.sqrt(Zt(n,n)));return t>0?n.map(e=>z(e/t)):[0,0,0]}function he(n){const t=Math.abs(n)<1?z(1-z(1-Math.abs(n))):1;let e=z(z(.077980478)+z(t*z(-.02164095)));e=z(z(-.213300989)+z(t*e)),e=z(z(1.5707963267)+z(t*e));const o=z(z(Math.sqrt(z(1-t)))*e);return n<0?z(z(Math.PI)-o):o}function lr(n){let t=n.at(-1);const e=[0,0,0];for(const o of n){for(let r=0;r<3;r++){const a=(r+1)%3,s=(r+2)%3;e[r]=z(e[r]+z(z(t[a]-o[a])*z(t[s]+o[s])))}t=o}return e}function fr(n){const t=[],e=[],o=(h,_)=>h<_?`${h}:${_}`:`${_}:${h}`,r=new Map((n.edge_order??[]).map(([h,_],p)=>[o(h,_),p])),a=new Set((n.sharp??[]).map(([h,_])=>o(h,_))),s=new Map;for(const[h,_]of n.f.entries()){const p=t.length,g=sr(lr(_.map(v=>n.v[v]))).unit;e.push(g.some(Boolean)?g:[0,0,1]);for(let v=0;v<_.length;v++){const O=o(_[v],_[(v+1)%_.length]);r.has(O)||r.set(O,r.size);const b=n.face_edges?.[h]?.[v]??r.get(O),S=t.length;t.push({vertex:_[v],face:h,edge:b,prev:p+(v+_.length-1)%_.length,next:p+(v+1)%_.length});const w=s.get(b)??[];w.push(S),s.set(b,w)}}const f=new Map,c=new Map;for(const[h,_]of s){if(_.length!==2||n.edge_sharp?.[h])continue;const[p,g]=_,v=t[p],O=t[g];!n.s?.[v.face]||!n.s?.[O.face]||v.vertex!==t[O.next].vertex||O.vertex!==t[v.next].vertex||!n.edge_sharp&&a.has(o(v.vertex,O.vertex))||(c.set(p,O.next),f.set(O.next,p),c.set(g,v.next),f.set(v.next,g))}const d=[],l=[],i=[],u=[],m=(h,_)=>_e(ir(n.v[t[t[h][_]].vertex],n.v[t[h].vertex]));for(let h=0;h<t.length;h++){if(l[h]!==void 0)continue;let _=h;const p=new Set([_]);for(;c.has(_)&&!p.has(c.get(_));)_=c.get(_),p.add(_);c.has(_)&&(_=Math.min(...p));const g=[_];for(;f.has(g.at(-1))&&f.get(g.at(-1))!==_;)g.push(f.get(g.at(-1)));let v=[0,0,0];if(g.length===1)v=e[t[_].face];else{for(const E of g)v=ye(v,e[t[E].face],he(Zt(m(E,"prev"),m(E,"next"))));v=_e(v)}const O=m(_,"next"),b=g.at(-1),S=m(b,"prev"),w=Zt(O,v),A=Zt(S,v),M={normal:v,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(w)<Xe&&Math.abs(A)<Xe){const E=g.length>1?g.map(nt=>m(nt,"next")):[];E.length&&t[t[b].prev].edge!==t[_].edge&&E.push(S),M.alpha=E.length?z(E.reduce((nt,x)=>z(nt+he(Zt(x,v))),0)/E.length):z(z(he(w)+he(A))/2),M.reference=_e(ye(O,v,-w));const F=v,V=M.reference;M.ortho=_e([z(z(F[1]*V[2])-z(F[2]*V[1])),z(z(F[2]*V[0])-z(F[0]*V[2])),z(z(F[0]*V[1])-z(F[1]*V[0]))]);const H=_e(ye(S,v,-A)),tt=Zt(M.reference,H),Z=he(tt);M.beta=tt<Xe?Zt(M.ortho,H)<0?z(je-Z):Z:je}M.alpha===0&&(M.normal=[0,0,0]);for(const E of g)l[E]=d.length;d.push(g),i.push(M),u.push(v)}return{corners:t,fans:d,fanOf:l,spaces:i,faceNormals:e,fanNormals:u}}function cr(n,t){if(!t[0]||n.alpha===0||n.beta===0)return n.normal;const e=z(t[0]/32767),o=z(t[1]/32767),r=z((e>0?n.alpha:z(je-n.alpha))*e),a=z((o>0?n.beta:z(je-n.beta))*o);let s=n.normal.map(f=>z(f*z(Math.cos(r))));return s=ye(s,n.reference,z(z(Math.sin(r))*z(Math.cos(a)))),o!==0&&(s=ye(s,n.ortho,z(z(Math.sin(r))*z(Math.sin(a))))),s}function Co(n,t){if(!t)return null;const{corners:e,fans:o,spaces:r}=fr(n);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(e.length);for(const[s,f]of o.entries()){const c=f.reduce((l,i)=>{const u=t.data[i];return[l[0]+u[0],l[1]+u[1]]},[0,0]),d=cr(r[s],c.map(l=>Math.trunc(l/f.length)));for(const l of f)a[l]=d}return a}if(t.type==="FLOAT_VECTOR")return e.map((a,s)=>{const f=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:s;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Ye={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}},ur=1e-6;function dr(n){const t=new y;for(let e=0;e<n.length;e++){const o=n[e],r=n[(e+1)%n.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 mr=(n,t,e)=>(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x),Un=n=>Array.from({length:n-2},(t,e)=>[0,e+1,e+2]);function _r(n){let t=0;for(let e=0;e<n.length;e++){const o=n[e],r=n[(e+1)%n.length];t+=o.x*r.y-r.x*o.y}return t}function Wn(n,t,e){if(n.length!==t.length-2||!(Math.abs(e)>0))return!1;const o=Math.sign(e);let r=0;for(const[a,s,f]of n){const c=mr(t[a],t[s],t[f]);if(c*o<0)return!1;r+=Math.abs(c)}return Math.abs(r-Math.abs(e))<=ur*Math.abs(e)}function hr(n){const t=n.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const e=dr(n),o=e.length();if(!(o>0)||!Number.isFinite(o))return{triangles:Un(t),sound:!1,method:"fan"};const r=e.clone().divideScalar(o),a=Math.abs(r.x)<.9?new y(1,0,0):new y(0,1,0),s=new y().crossVectors(a,r).normalize(),f=new y().crossVectors(r,s),c=n[0],d=n.map(m=>{const h=m.clone().sub(c);return new te(h.dot(s),h.dot(f))}),l=_r(d),i=Un(t);if(Wn(i,d,l))return{triangles:i,sound:!0,method:"fan"};let u=[];try{u=sa.triangulateShape(d,[]).map(m=>[m[0],m[1],m[2]])}catch{return{triangles:i,sound:!1,method:"fan"}}return Wn(u,d,l)?{triangles:u,sound:!0,method:"earcut"}:{triangles:u.length>0?u:i,sound:!1,method:u.length>0?"earcut":"fan"}}const pr=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Ze(n){const t=n/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Ke(n,t,e){switch(n){case"FLOAT":{const o=Number(t[e]);return[o,o,o,1]}case"FLOAT2":return[Number(t[e*2]),Number(t[e*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[e*3]),Number(t[e*3+1]),Number(t[e*3+2]),1];case"BYTE_COLOR":return[Ze(Number(t[e*4])),Ze(Number(t[e*4+1])),Ze(Number(t[e*4+2])),Number(t[e*4+3])/255];default:return[Number(t[e*4]),Number(t[e*4+1]),Number(t[e*4+2]),Number(t[e*4+3])]}}function Tn(n,t){return n.filter(e=>pr.has(e.type)&&e.domain!=="EDGE"&&!e.name.startsWith(".")&&e.name!=="position"&&e.name!=="custom_normal"&&!(e.type==="FLOAT2"&&e.domain==="CORNER")).map(e=>{const o=t(e.data,e.type),r=[0,0,0,0];return{name:e.name,domain:e.domain,read:(a,s,f)=>e.domain==="POINT"?Ke(e.type,o,a):e.domain==="CORNER"?s===void 0?r:Ke(e.type,o,s):f===void 0?r:Ke(e.type,o,f)}})}function Fo(n){const t=n.vertexCount,e=n.starts.length-1,o=n.starts,r=n.cornerVerts,a=o[e];let s=t;for(let x=0;x<e;x++)s+=(o[x+1]-o[x]-2)*3;const f=new Uint32Array(a),c=new Uint8Array(a),d=new Uint8Array(t),l=new Uint32Array(a);let i=!1;for(let x=0;x<e;x++)if(n.smooth(x)){i=!0;break}const u=(x,N)=>t<94906265?Math.min(x,N)*t+Math.max(x,N):`${Math.min(x,N)}:${Math.max(x,N)}`,m=new Map,h=new Set;for(const[x,N]of n.sharp)h.add(u(x,N));if(n.edges)for(const[x,N]of n.edges){if(x===N)throw new Error("Runtime mesh edge needs distinct vertices");m.set(u(x,N),-1)}const _=x=>{for(;l[x]!==x;)l[x]=l[l[x]],x=l[x];return x},p=(x,N)=>{const T=_(x),U=_(N);l[Math.max(T,U)]=Math.min(T,U)};for(let x=0;x<e;x++){const N=o[x],T=o[x+1]-N,U=n.smooth(x)?1:0;for(let $=0;$<T;$++){const k=N+$;d[r[k]]=1,f[k]=N+($+1)%T,c[k]=U,l[k]=k}}for(let x=0;x<a;x++){const N=f[x],T=r[x],U=r[N],$=u(T,U),k=m.get($);if(k!==void 0&&k>=0&&c[x]&&c[k]&&!h.has($)){const P=f[k];p(x,r[k]===T?k:P),p(N,r[k]===T?P:k)}(k===void 0||k<0||!c[k]&&c[x])&&m.set($,x)}const g=n.uv,v=new Float32Array(s*3),O=new Float32Array(s*2),b=new Uint32Array(s),S=(n.uvLayers??[]).map(x=>({...x,data:new Float32Array(s*2)})),w=(n.attributeLayers??[]).map(x=>({...x,data:new Float32Array(s*4)})),A=n.orco?new Float32Array(s*3):null,M=new Uint32Array(s),E=new Map,F=[],V=n.normals||n.cornerNormal?new Float32Array(s*3):null;let H=0,tt=0;const Z=(x,N,T,U,$)=>{const k=H++;for(const P of w)P.data.set(P.read(x,U,$),k*4);if(A)for(let P=0;P<3;P++)A[k*3+P]=n.orco[x*3+P]*.5+.5;if(b[k]=x,n.co(x).toArray(v,k*3),N&&O.set(N,k*2),T&&V.set(T,k*3),U!==void 0)for(const P of S)P.data.set(P.read(U),k*2);return k},nt=(x,N)=>{const T=g?.(x),U=n.cornerNormal?[n.cornerNormal[x*3],n.cornerNormal[x*3+1],n.cornerNormal[x*3+2]]:n.normals?.[x];if(!i)return Z(r[x],T,U,x,N);const $=`${c[x]?_(x):x}${T?`:${T[0]}:${T[1]}`:""}${U?`:n${U.join(":")}`:""}${S.map(P=>":"+P.read(x).join(":")).join("")}${w.map(P=>P.domain==="POINT"?"":":"+Array.from(P.read(r[x],x,N)).join(":")).join("")}`;let k=E.get($);return k===void 0&&(k=Z(r[x],T,U,x,N),E.set($,k)),k};for(let x=0;x<e;x++){const N=tt,T=o[x],U=o[x+1]-T,$=[];for(let B=0;B<U;B++)$.push(n.co(r[T+B]));for(const B of hr($).triangles)for(const K of B)M[tt++]=nt(T+K,x);const k=n.material(x),P=F.at(-1);P?.materialIndex===k?P.count+=tt-N:F.push({start:N,count:tt-N,materialIndex:k})}for(let x=0;x<t;x++)d[x]||Z(x);return{positions:v.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:g?O.slice(0,H*2):null,uvLayers:S.map(x=>({name:x.name,data:x.data.slice(0,H*2)})),attributeLayers:w.map(x=>({name:x.name,data:x.data.slice(0,H*4)})),orco:A?A.slice(0,H*3):null,indices:M.slice(0,tt),sourceVertex:b.slice(0,H),groups:F}}function Bt(n){return`blenderA_${Array.from(new TextEncoder().encode(n),t=>t.toString(16).padStart(2,"0")).join("")}`}function Ce(n){const t=new oe;t.setAttribute("position",new ft(n.positions,3)),t.setAttribute("uv",new ft(n.uv??new Float32Array(n.positions.length/3*2),2)),t.setIndex(new ft(n.indices,1));const e=Object.create(null);for(const[o,r]of(n.uvLayers??[]).entries()){if(o>=8)throw new Error("A Blender mesh supports at most eight UV maps");e[r.name]=o+1,t.setAttribute(`uv${o+1}`,new ft(r.data,2))}t.userData.blenderUvChannels=e;for(const o of n.attributeLayers??[])t.setAttribute(Bt(o.name),new ft(o.data,4));t.userData.blenderAttributes=(n.attributeLayers??[]).map(o=>o.name),n.orco&&(t.setAttribute("blenderOrco",new ft(n.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const o of n.groups)t.addGroup(o.start,o.count,o.materialIndex);return n.normals?t.setAttribute("normal",new ft(n.normals,3)):t.computeVertexNormals(),n.sourceVertex&&t.setAttribute("blenderVertex",new ft(n.sourceVertex,1)),t}function gr(n,t){const e=n.cornerTri,o=n.cornerNormal,r=n.co.length/3,a=n.corner.length,s=n.faceStart.length-1,f=n.attributes.filter(P=>P.type==="FLOAT2"&&P.domain==="CORNER"),c=n.renderUv??n.activeUv??f[0]?.name,d=f.findIndex(P=>P.name===c);if(c&&d<0)throw new Error(`Runtime UV map ${c} is missing`);const l=Tn(n.attributes,P=>P),i=3+f.length*2+l.length*4,u=new Float32Array(i),m=new Float32Array(i),h=new Uint32Array(u.buffer),_=new Uint32Array(m.buffer),p=new Uint32Array(a),g=new Uint32Array(a),v=new Uint32Array(a),O=new Uint32Array(a),b=new Uint8Array(r);let S=1;for(;S<Math.max(1,a*2);)S*=2;const w=new Uint32Array(S),A=(P,B,K,ot)=>{let dt=0;for(let et=0;et<3;et++)ot[dt++]=o[P*3+et];for(const et of f)for(let rt=0;rt<2;rt++)ot[dt++]=Number(et.data[P*2+rt]);for(const et of l){const rt=et.read(K,P,B);for(let Q=0;Q<4;Q++)ot[dt++]=Number(rt[Q])}};let M=0;for(let P=0;P<s;P++)for(let B=n.faceStart[P];B<n.faceStart[P+1];B++){const K=n.corner[B];if(K>=r)throw new Error("Native mesh corner references a missing vertex");p[B]=P,b[K]=1,A(B,P,K,u);let ot=Math.imul(K^2166136261,16777619);for(const rt of h)ot=Math.imul(ot^rt,16777619);const dt=ot>>>0&S-1;let et=-1;for(let rt=w[dt];rt;rt=O[rt-1]){const Q=rt-1,mt=v[Q];if(n.corner[mt]!==K)continue;A(mt,p[mt],K,m);let Tt=!0;for(let qt=0;qt<i;qt++)if(h[qt]!==_[qt]){Tt=!1;break}if(Tt){et=Q;break}}et<0&&(et=M++,v[et]=B,O[et]=w[dt],w[dt]=et+1),g[B]=et}let E=0;for(const P of b)P||E++;const F=M+E,V=new Float32Array(F*3),H=new Float32Array(F*3),tt=new Uint32Array(F),Z=f.map(P=>({name:P.name,data:new Float32Array(F*2)})),nt=l.map(P=>({name:P.name,data:new Float32Array(F*4)})),x=n.orco?new Float32Array(F*3):null,N=(P,B)=>{tt[P]=B;for(let K=0;K<3;K++)V[P*3+K]=n.co[B*3+K],x&&(x[P*3+K]=n.orco[B*3+K]*.5+.5)};for(let P=0;P<M;P++){const B=v[P],K=n.corner[B];N(P,K),A(B,p[B],K,u),H.set(u.subarray(0,3),P*3);let ot=3;for(const dt of Z)dt.data.set(u.subarray(ot,ot+2),P*2),ot+=2;for(const dt of nt)dt.data.set(u.subarray(ot,ot+4),P*4),ot+=4}let T=M;for(let P=0;P<r;P++)if(!b[P]){N(T,P);for(let B=0;B<l.length;B++)nt[B].data.set(l[B].read(P,void 0,void 0),T*4);T++}const U=new Uint32Array(e.length),$=[];let k=0;for(let P=0;P<s;P++){const B=n.faceStart[P],K=n.faceStart[P+1],ot=Math.max(0,K-B-2)*3;if(k+ot>e.length)throw new Error("Native mesh triangulation is incomplete");for(let rt=0;rt<ot;rt++){const Q=e[k+rt];if(Q<B||Q>=K)throw new Error("Native triangle references a different face");U[k+rt]=g[Q]}const dt=n.material[P],et=$.at(-1);et?.materialIndex===dt?et.count+=ot:$.push({start:k,count:ot,materialIndex:dt}),k+=ot}if(k!==e.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:V,normals:H,sourceVertex:tt,uv:d<0?null:Z[d].data,uvLayers:Z,attributeLayers:nt,orco:x,indices:U,groups:$,hash:t}}function qn(n,t){if(n.cornerTri&&n.cornerNormal)return gr(n,t);const e=n.co.length/3,o=n.attributes.filter(_=>_.type==="FLOAT2"&&_.domain==="CORNER"),r=n.renderUv??n.activeUv??o[0]?.name,a=o.find(_=>_.name===r);if(r&&!a)throw new Error(`Runtime UV map ${r} is missing`);const s=a?a.data:null,f=n.edge.length/2,c=new Array(f);for(let _=0;_<f;_++)c[_]=[n.edge[_*2],n.edge[_*2+1]];const d=[];for(let _=0;_<f;_++)n.edgeSharp[_]===1&&d.push(c[_]);const l=n.cornerNormal?void 0:n.attributes.find(_=>_.name==="custom_normal"),i=l?{v:Array.from({length:e},(_,p)=>[n.co[p*3],n.co[p*3+1],n.co[p*3+2]]),f:Array.from({length:n.faceStart.length-1},(_,p)=>Array.from(n.corner.subarray(n.faceStart[p],n.faceStart[p+1]))),s:Array.from(n.smooth,Boolean),edge_order:c,sharp:d,face_edges:Array.from({length:n.faceStart.length-1},(_,p)=>Array.from(n.cornerEdge.subarray(n.faceStart[p],n.faceStart[p+1]))),edge_sharp:Array.from(n.edgeSharp,Boolean)}:null,u=l?{type:l.type,domain:l.domain,data:Array.from({length:l.data.length/Ye[l.type].size},(_,p)=>Array.from({length:Ye[l.type].size},(g,v)=>Number(l.data[p*Ye[l.type].size+v])))}:void 0,m=new y,h={vertexCount:e,normals:i?Co(i,u):null,cornerNormal:n.cornerNormal,orco:n.orco,co:_=>m.set(n.co[_*3],n.co[_*3+1],n.co[_*3+2]).clone(),starts:n.faceStart,cornerVerts:n.corner,smooth:_=>n.smooth[_]===1,material:_=>n.material[_],edges:c,sharp:d,uv:s?_=>[s[_*2],s[_*2+1]]:null,uvLayers:o.map(_=>({name:_.name,read:p=>[Number(_.data[p*2]),Number(_.data[p*2+1])]})),attributeLayers:Tn(n.attributes,_=>_)};return{...Fo(h),hash:t}}function vr(n){const t=n.v.map(i=>new y(...i)),e=i=>{const u=t[i];if(!u)throw new Error(`Runtime mesh vertex ${i} is missing`);return u},o=new Uint32Array(n.f.length+1);n.f.forEach((i,u)=>{if(i.length<3||new Set(i).size!==i.length)throw new Error("Runtime mesh face needs at least three distinct vertices");o[u+1]=o[u]+i.length});const r=new Uint32Array(o[n.f.length]);n.f.forEach((i,u)=>i.forEach((m,h)=>{e(m),r[o[u]+h]=m}));for(const[i,u]of n.edge_order??n.e??[])e(i),e(u);const a={POINT:t.length,EDGE:(n.edge_order??n.e??[]).length,FACE:n.f.length,CORNER:r.length};for(const i of n.attributes??[])if(i.domain!=="EDGE"&&i.data.length!==a[i.domain])throw new Error(`Runtime attribute ${i.name} has ${i.data.length} values for ${a[i.domain]} ${i.domain} elements`);const s=(n.attributes??[]).filter(i=>i.type==="FLOAT2"&&i.domain==="CORNER"),f=n.render_uv??n.active_uv??s[0]?.name,c=s.find(i=>i.name===f);if(f&&!c)throw new Error(`Runtime UV map ${f} is missing`);const d=c?.data,l={vertexCount:t.length,normals:Co(n,n.attributes?.find(i=>i.name==="custom_normal")),co:e,starts:o,cornerVerts:r,smooth:i=>!!n.s?.[i],material:i=>n.m?.[i]??0,edges:n.edge_order??n.e??null,sharp:n.sharp??[],uv:d?i=>d[i]:null,uvLayers:s.map(i=>({name:i.name,read:u=>i.data[u]})),attributeLayers:Tn(n.attributes??[],i=>Array.from(i).flat())};return Ce(Fo(l))}const Oe=1.5707963267948966,Kt=6.283185307179586,ko=.3183098861837067,$o=.0795774715459476,xr=.3,br=$o,yr=3/16*ko,_n=.8,Hn=_n*_n,Qt=6371,Lo=100,hn=Qt+Lo,Gn=64,Xn=64,_t=256,Ht=64,wr=[1.679,1.828,1.986,1.307],Or=[.006605,.01067,.01842,.03156],Ar=[3472e-28,3914e-28,1349e-28,1103e-29],Mr=334.5,Tr=[28722e-28,46168e-28,79706e-28,13578e-27],Sr=[15908e-26,17711e-26,20942e-26,24033e-26],Yn=13681e16,Pr=2e6,Er=.73,Qe=[[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]],Ve=n=>n*n,ve=n=>n<0?0:n>1?1:n,Dt=(n,t,e)=>n+e*(t-n),Nr=n=>Math.sqrt(Math.max(n,0)),jo=n=>[-Math.sqrt(1-n*n),0,n];function pn(n,t,e,o,r,a,s){const f=n*o+t*r+e*a,c=n*n+t*t+e*e-s*s;if(c>0&&f>0)return-1;const d=f*f-c;return d<0?-1:d>=f*f?-f+Math.sqrt(d):-f-Math.sqrt(d)}const Rr=n=>yr*(1+Ve(n));function Ir(n){const t=1+Hn+2*_n*n;return $o*(1-Hn)/(t*Math.sqrt(t))}const Dr=n=>Yn*(Math.exp(-n/Er)+Pr/Yn);function Sn(n,t){let e=n%Kt;Math.abs(e)>=Math.PI&&(e-=Math.sign(e)*2*Math.PI);let o=t;return(e>=Oe||e<=-Oe)&&(e=Math.sign(e)*Math.PI-e,o+=Math.PI),o=o%Kt,o<0&&(o+=Kt),o=Kt-o,[e,o]}class zr{constructor(t,e,o){this.air=t,this.aerosol=e,this.ozone=o,this.lut=new Float32Array(Ht*_t*4)}coefficients(t,e){const o=Dr(t)*this.aerosol,r=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-Ve(r-3.22261)*5.55555555-r),s=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)e[f]=Tr[f]*o,e[4+f]=Sr[f]*o,e[8+f]=Ar[f]*Mr*a*this.ozone,e[12+f]=Or[f]*s*this.air}transmittance(t,e,o){const[r,a,s]=jo(t),f=Dt(Qt,hn,e),d=pn(0,0,f,r,a,s,hn)/Gn,l=[0,0,0,0],i=new Float64Array(16);for(let u=0;u<Gn;u++){const m=(u+.5)*d,h=r*m,_=a*m,p=f+s*m,g=Math.max(Math.hypot(h,_,p)-Qt,0);this.coefficients(g,i);for(let v=0;v<4;v++)l[v]+=(i[v]+i[4+v]+i[8+v]+i[12+v])*d}for(let u=0;u<4;u++)o[u]=Math.exp(-l[u])}precompute(){const t=new Float64Array(4);for(let e=0;e<Ht;e++)for(let o=0;o<_t;o++){const r=o/(_t-1),a=e/(Ht-1);this.transmittance(r*2-1,a,t);const s=(e*_t+o)*4;for(let f=0;f<4;f++)this.lut[s+f]=t[f]}}lookup(t,e,o){const r=(_t-1)*ve(t*.5+.5),a=(Ht-1)*ve(e),s=Math.trunc(r),f=Math.trunc(a),c=Math.min(s+1,_t-1),d=Math.min(f+1,Ht-1),l=r-s,i=a-f,u=(f*_t+s)*4,m=(f*_t+c)*4,h=(d*_t+s)*4,_=(d*_t+c)*4;for(let p=0;p<4;p++)o[p]=Dt(Dt(this.lut[u+p],this.lut[m+p],l),Dt(this.lut[h+p],this.lut[_+p],l),i)}lookupAtGround(t,e){const o=(_t-1)*ve(t*.5+.5),r=Math.trunc(o),a=Math.min(r+1,_t-1),s=o-r;for(let f=0;f<4;f++)e[f]=Dt(this.lut[r*4+f],this.lut[a*4+f],s)}lookupToSun(t,e){const o=(Ht-1)*ve(t),r=Math.trunc(o),a=Math.min(r+1,Ht-1),s=o-r,f=_t-1;for(let c=0;c<4;c++)e[c]=Dt(this.lut[(r*_t+f)*4+c],this.lut[(a*_t+f)*4+c],s)}inscattering(t,e,o,r,a,s,f,c,d){const l=-(a*t[0]+s*t[1]+f*t[2]),i=Rr(l),u=Ir(l),m=c/Xn,h=new Float64Array(16),_=new Float64Array(4),p=new Float64Array(4),g=new Float64Array(4),v=new Float64Array(4),O=new Float64Array(4),b=[0,0,0,0],S=[1,1,1,1];for(let w=0;w<Xn;w++){const A=(w+.5)*m,M=e+a*A,E=o+s*A,F=r+f*A,V=Math.hypot(M,E,F),H=Math.max(V-Qt,0),tt=H/Lo,Z=(M*t[0]+E*t[1]+F*t[2])/V;this.coefficients(H,h),this.lookup(Z,tt,_);const nt=Kt*(1-Nr(1-Ve(Qt/V)));this.lookupAtGround(Z,g),this.lookupToSun(0,v),this.lookupToSun(tt,O);const x=1/(1+5*Math.exp(-17.92*Z)),N=[.217,.347,.594,1];for(let T=0;T<4;T++){const U=v[T]/O[T],$=br*nt*(xr*ko)*g[T]*U*Z;p[T]=.02*N[T]*x+$}for(let T=0;T<4;T++){const U=h[T]+h[4+T]+h[8+T]+h[12+T],$=wr[T]*(h[12+T]*(i*_[T]+p[T])+h[4+T]*(u*_[T]+p[T])),k=Math.exp(-m*U),P=Math.max(U,1e-7);b[T]+=S[T]*(($-$*k)/P),S[T]*=k}}for(let w=0;w<4;w++)d[w]=b[w]}}const xt=512,fe=256;function Vo(n,t){const e=new zr(n.airDensity,n.aerosolDensity,n.ozoneDensity);e.precompute();const o=Math.min(Math.max(n.altitude,1),99999)/1e3,r=jo(Math.cos(Oe-t)),a=new Float32Array(xt*fe*3),s=xt/2,f=new Float64Array(4);for(let c=0;c<fe;c++)for(let d=0;d<s;d++){const l=(d+.5)/xt,i=(c+.5)/fe,u=Kt*l,m=i*2-1,h=Math.sign(m)*Ve(m)*Oe,_=Math.cos(h)*Math.cos(u),p=Math.cos(h)*Math.sin(u),g=Math.sin(h),v=Qt+o,O=pn(0,0,v,_,p,g,hn),b=pn(0,0,v,_,p,g,Qt),S=b<0?O:b;e.inscattering(r,0,0,v,_,p,g,S,f);let w=0,A=0,M=0;for(let V=0;V<4;V++)w+=Qe[V][0]*f[V],A+=Qe[V][1]*f[V],M+=Qe[V][2]*f[V];const E=(c*xt+d)*3;a[E]=w,a[E+1]=A,a[E+2]=M;const F=(c*xt+(xt-d-1))*3;a[F]=w,a[F+1]=A,a[F+2]=M}return a}function Cr(n){const[t]=Sn(n.sunElevation,n.sunRotation);return Vo(n,t)}function Pn(n){const[t]=Sn(n.sunElevation,n.sunRotation);return JSON.stringify([t,n.altitude,n.airDensity,n.aerosolDensity,n.ozoneDensity])}const Fr=6,ie=new Map;function kr(n){return ie.has(Pn(n))}function Bo(n,t){ie.set(Pn(n),t),ie.size>Fr&&ie.delete(ie.keys().next().value)}function $r(n){const[t,e]=Sn(n.sunElevation,n.sunRotation),o=Pn(n);let r=ie.get(o);r===void 0&&(r=Vo(n,t),Bo(n,r));const a=new y;return s=>{const f=Math.hypot(s.x,s.y),c=Math.atan2(s.z,f);let l=(Math.atan2(s.x,s.y)+Math.PI+e)/Kt;l-=Math.floor(l);const i=Math.abs(c),u=ve(Math.sqrt(i/Oe)*Math.sign(c)*.5+.5),m=l*xt-.5,h=u*fe-.5,_=Math.floor(m),p=Math.floor(h),g=m-_,v=h-p,O=F=>(F%xt+xt)%xt,b=F=>F<0?0:F>fe-1?fe-1:F,S=O(_),w=O(_+1),A=b(p),M=b(p+1),E=[0,0,0];for(let F=0;F<3;F++){const V=Dt(r[(A*xt+S)*3+F],r[(A*xt+w)*3+F],g),H=Dt(r[(M*xt+S)*3+F],r[(M*xt+w)*3+F],g);E[F]=Dt(V,H,v)}return a.set(Rt[0][0]*E[0]+Rt[0][1]*E[1]+Rt[0][2]*E[2],Rt[1][0]*E[0]+Rt[1][1]*E[1]+Rt[1][2]*E[2],Rt[2][0]*E[0]+Rt[2][1]*E[1]+Rt[2][2]*E[2])}}let Lt=null,Me=!1,Lr=0;const xe=new Map;function jr(){if(Lt||Me)return Lt;if(typeof Worker>"u")return Me=!0,null;try{Lt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return Me=!0,null}return Lt.onmessage=n=>{const{id:t,pixels:e,error:o}=n.data,r=xe.get(t);r&&(xe.delete(t),e?r.resolve(e):r.reject(new Error(o??"sky worker returned nothing")))},Lt.onerror=n=>{const t=new Error(`sky worker failed: ${n.message||"unknown error"}`);for(const e of xe.values())e.reject(t);xe.clear(),Lt?.terminate(),Lt=null,Me=!0},Lt}function Vr(n){const t=jr();if(!t)return Promise.resolve(Cr(n));const e=Lr++,o={id:e,parameters:n};return new Promise((r,a)=>{xe.set(e,{resolve:r,reject:a}),t.postMessage(o)})}function Br(n,t,e,o={}){switch(o.type??"LINEAR"){case"QUADRATIC":{const r=Math.max(n,0);return r*r}case"EASING":{const r=Math.min(1,Math.max(0,n));return r*r*(3-2*r)}case"DIAGONAL":return(n+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(n,t,e),0);case"QUADRATIC_SPHERE":{const r=Math.max(.999999-Math.hypot(n,t,e),0);return r*r}case"RADIAL":return Math.atan2(t,n)/(2*Math.PI)+.5;default:return n}}const Je=(n,t)=>t!==0?n/t:0,Zn=n=>Math.min(1,Math.max(-1,n)),Kn=(n,t,e)=>{const o=e!==0?Math.max(e-Math.abs(n-t),0)/e:0;return Math.min(n,t)-o*o*o*e/6},Uo={ADD:(n,t)=>n+t,SUBTRACT:(n,t)=>n-t,MULTIPLY:(n,t)=>n*t,DIVIDE:Je,POWER:(n,t)=>t===0?1:n===0||n<0&&!Number.isInteger(t)?0:n**t,LOGARITHM:(n,t)=>n<=0||t<=0?0:Je(Math.log(n),Math.log(t)),SQRT:n=>Math.sqrt(Math.max(n,0)),INVERSE_SQRT:n=>n>0?1/Math.sqrt(n):0,ABSOLUTE:Math.abs,RADIANS:n=>n*Math.PI/180,DEGREES:n=>n*180/Math.PI,MINIMUM:(n,t)=>Math.min(n,t),MAXIMUM:(n,t)=>Math.max(n,t),LESS_THAN:(n,t)=>+(n<t),GREATER_THAN:(n,t)=>+(n>t),ROUND:n=>Math.floor(n+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:n=>n-Math.floor(n),MODULO:(n,t)=>t!==0?n%t:0,FLOORED_MODULO:(n,t)=>t!==0?n-Math.floor(n/t)*t:0,TRUNC:Math.trunc,SNAP:(n,t)=>Math.floor(Je(n,t))*t,WRAP:(n,t,e)=>t!==e?n-(t-e)*Math.floor((n-e)/(t-e)):e,PINGPONG:(n,t)=>{if(t===0)return 0;const e=(n-t)/(t*2);return Math.abs((e-Math.floor(e))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:n=>Math.asin(Zn(n)),ARCCOSINE:n=>Math.acos(Zn(n)),ARCTANGENT:Math.atan,ARCTAN2:(n,t)=>n===0&&t===0?0:Math.atan2(n,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(n,t,e)=>+(n===t||Math.abs(n-t)<=Math.max(e,2**-23)),MULTIPLY_ADD:(n,t,e)=>n*t+e,SMOOTH_MIN:Kn,SMOOTH_MAX:(n,t,e)=>-Kn(-n,-t,e)};function lt(n,t){if(typeof n=="number")return()=>n;if(Array.isArray(n)){const r=new y(...n);return()=>r}if(n.kind==="direction")return r=>r;if(n.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(n.kind==="gradient"){const r=lt(n.vector,t),a={type:n.gradient_type},s=new y;return f=>{const c=r(f),d=typeof c=="number"?c:c.x,l=typeof c=="number"?c:c.y,i=typeof c=="number"?c:c.z,u=wt.clamp(Br(d,l,i,a),0,1);return n.output==="Fac"?u:s.setScalar(u)}}if(n.kind==="to_float"){const r=lt(n.value,t);return a=>{const s=r(a);return typeof s=="number"?s:Math.fround(n.source_type==="RGBA"?s.x*.212639+s.y*.7151687+s.z*.0721923:(s.x+s.y+s.z)/3)}}if(n.kind==="math"){const r=n.inputs.map(f=>lt(f,t)),a=Uo[n.operation],s=(f,c)=>{const d=r[f]?.(c)??0;if(typeof d!="number")throw new Error("World Math needs scalar inputs");return Math.fround(d)};return f=>{const c=Math.fround(a(s(0,f),s(1,f),s(2,f)));return n.clamp?wt.clamp(c,0,1):c}}if(n.kind==="mix_color"){const r=lt(n.factor,t),a=lt(n.a,t),s=lt(n.b,t),f=new y,c=new y;return d=>{const l=r(d);if(typeof l!="number")throw new Error("World color Mix needs a scalar factor");const i=a(d);typeof i=="number"?f.setScalar(i):f.copy(i);const u=s(d);return typeof u=="number"?c.setScalar(u):c.copy(u),f.lerp(c,n.clamp_factor?wt.clamp(l,0,1):l),n.clamp_result&&f.clampScalar(0,1),f}}if(n.kind==="sky"){const r=$r({sunElevation:n.sun_elevation,sunRotation:n.sun_rotation,altitude:n.altitude,airDensity:n.air_density,aerosolDensity:n.aerosol_density,ozoneDensity:n.ozone_density});return a=>r(a)}if(n.kind==="mapping"){const r=lt(n.vector,t),a=new y(...n.location),s=new y(...n.scale),f=new St().setFromEuler(new ia(n.rotation[0],n.rotation[1],n.rotation[2],"ZYX")),c=f.clone().invert(),d=new y(...n.scale.map(i=>i===0?0:1/i)),l=new y;return i=>{const u=r(i);switch(typeof u=="number"?l.setScalar(u):l.copy(u),n.vector_type??"POINT"){case"TEXTURE":return l.sub(a).applyQuaternion(c).multiply(d);case"VECTOR":return l.multiply(s).applyQuaternion(f);case"NORMAL":return l.multiply(d).applyQuaternion(f).normalize();case"POINT":return l.multiply(s).applyQuaternion(f).add(a)}}}if(n.kind==="map_range"){const r=lt(n.value,t),a=lt(n.from_min,t),s=lt(n.from_max,t),f=lt(n.to_min,t),c=lt(n.to_max,t),d=lt(n.steps,t),l=(m,h)=>{const _=m(h);if(typeof _!="number")throw new Error("World Map Range needs scalar inputs");return _},i=n.interpolation,u=n.clamp;return m=>{const h=l(r,m),_=l(a,m),p=l(s,m),g=l(f,m),v=l(c,m);if(_===p)return 0;let O;if(i==="STEPPED"){const S=l(d,m),w=(h-_)/(p-_);O=S>0?Math.floor(w*(S+1))/S:0}else if(i==="SMOOTHSTEP"||i==="SMOOTHERSTEP"){const S=wt.clamp((h-Math.min(_,p))/(Math.max(_,p)-Math.min(_,p)),0,1),w=i==="SMOOTHSTEP"?S*S*(3-2*S):S*S*S*(S*(S*6-15)+10);O=_>p?1-w:w}else O=(h-_)/(p-_);const b=g+O*(v-g);return u?g>v?wt.clamp(b,v,g):wt.clamp(b,g,v):b}}if(n.kind==="separate"){const r=lt(n.vector,t);return a=>{const s=r(a);return typeof s=="number"?s:s.getComponent(n.axis)}}const e=lt(n.factor,t),o=new y;return r=>{const a=e(r);if(typeof a!="number")throw new Error("World ColorRamp needs a scalar factor");const s=wt.clamp(a,0,1)*256,f=Math.floor(s),c=n.colors[f],d=n.colors[Math.min(f+1,256)],l=n.interpolate?s-f:0;return o.set(wt.lerp(c[0],d[0],l),wt.lerp(c[1],d[1],l),wt.lerp(c[2],d[2],l))}}function Ur(n,t,e,o){const r=new Float32Array(t*e*3),a=lt(n,o),s=new y;for(let f=0;f<e;f++){const c=((f+.5)/e-.5)*Math.PI;for(let d=0;d<t;d++){const l=((d+.5)/t-.5)*2*Math.PI;s.set(Math.cos(c)*Math.cos(l),-Math.cos(c)*Math.sin(l),Math.sin(c));const i=a(s),u=(f*t+d)*3;r[u]=typeof i=="number"?i:i.x,r[u+1]=typeof i=="number"?i:i.y,r[u+2]=typeof i=="number"?i:i.z}}return r}function Qn(n){const t=[],e=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":e(o.vector);return;case"ramp":e(o.factor);return;case"mix_color":e(o.factor),e(o.a),e(o.b);return;case"math":o.inputs.forEach(e);return;case"to_float":e(o.value);return;case"map_range":e(o.value),e(o.from_min),e(o.from_max),e(o.to_min),e(o.to_max),e(o.steps);return;default:return}};return e(n),t}function Vt(n){if(typeof n=="number"||Array.isArray(n))return!1;switch(n.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Vt(n.vector);case"ramp":return Vt(n.factor);case"mix_color":return[n.factor,n.a,n.b].some(Vt);case"math":return n.inputs.some(Vt);case"to_float":return Vt(n.value);case"map_range":return[n.value,n.from_min,n.from_max,n.to_min,n.to_max,n.steps].some(Vt);default:return!1}}function Wr(n,t,e,o){o.updateMatrixWorld();const r=new Float32Array(t*e*3),a=new y,s=lt(n,()=>a),f=new y,c=o.getWorldPosition(new y),d=o.getWorldDirection(new y);for(let l=0;l<e;l++)for(let i=0;i<t;i++){const u=(i+.5)/t,m=(l+.5)/e;a.set(u,m,0),o.isOrthographicCamera?f.copy(d):f.set(u*2-1,m*2-1,.5).unproject(o).sub(c).normalize(),f.set(f.x,-f.z,f.y);const h=s(f),_=(l*t+i)*3;r[_]=typeof h=="number"?h:h.x,r[_+1]=typeof h=="number"?h:h.y,r[_+2]=typeof h=="number"?h:h.z}return r}const it=I().finite(),qr=R({type:Y(["POINT","SUN","SPOT","AREA"]),color:W([it,it,it]),energy:it,use_shadow:at().default(!0),radius:it.optional(),spot_size:it.optional(),spot_blend:it.optional(),shape:Y(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:it.optional(),size_y:it.optional()}).strict();let gn;function Hr(){return gn??=Ba(async()=>{const{RectAreaLightUniformsLib:n}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:n}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:n})=>{n.init(),ht()}),gn}function Gr(){return gn??Promise.resolve()}const Xr=n=>{const t=n.size??0,e=n.size_y??t;if(n.shape==="RECTANGLE")return[t,e];if(n.shape==="DISK"){const o=Math.sqrt(Math.PI*t*t/4);return[o,o]}if(n.shape==="ELLIPSE"){const o=Math.sqrt(Math.PI/4);return[t*o,e*o]}return[t,t]};function Yr(n,t){const e=(s,f)=>t&&f(t)?t:new s;if(n.type==="SUN"){const s=e(Mo,f=>f.isDirectionalLight);return s.intensity=n.energy,s.color.setRGB(n.color[0],n.color[1],n.color[2],bt),s.castShadow=n.use_shadow,s}if(n.type==="POINT"){const s=e(fn,f=>f.isPointLight);return s.intensity=n.energy/(4*Math.PI),s.distance=0,s.decay=2,s.color.setRGB(n.color[0],n.color[1],n.color[2],bt),s.castShadow=n.use_shadow,s}if(n.type==="SPOT"){const s=e(cn,f=>f.isSpotLight);return s.intensity=n.energy/(4*Math.PI),s.distance=0,s.decay=2,s.angle=(n.spot_size??0)/2,s.penumbra=n.spot_blend??0,s.color.setRGB(n.color[0],n.color[1],n.color[2],bt),s.castShadow=n.use_shadow,s}Hr();const o=e(ze,s=>s.isRectAreaLight),[r,a]=Xr(n);return o.width=r,o.height=a,o.intensity=n.energy/(Math.max(r*a,Number.MIN_VALUE)*Math.PI),o.color.setRGB(n.color[0],n.color[1],n.color[2],bt),o}function Zr(n,t,e){if(!n.castShadow||e<=0)return;const r=n.getWorldPosition(new y).distanceTo(t),a=n.shadow;if(!a)return;const s=a.camera;s.near=Math.max(e*.001,r-e),s.far=r+e,n.isDirectionalLight&&(s.left=-e,s.right=e,s.top=e,s.bottom=-e),s.updateProjectionMatrix()}function Kr(n,t){n.position.set(0,0,0);const e=n;n.isRectAreaLight||e.target&&e.target.parent!==t&&(e.target.position.set(0,0,-1),t.add(e.target))}const En=[{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}],Jn=.69;class Qr{constructor(){this.group=new ct,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Ao;t.name="BlenderSolidStudioTarget",this.group.add(t);const e=new Mt(0,0,0);for(const[r,a]of En.entries()){const s=(1+a.smooth)**2,f=new Mo(16777215,Math.PI*Jn/s);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),e.r+=a.diffuse[0]*a.smooth/s,e.g+=a.diffuse[1]*a.smooth/s,e.b+=a.diffuse[2]*a.smooth/s}const o=new la(16777215,Math.PI*Jn);o.name="BlenderSolidWrapFill",o.color.copy(e),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 se=W([it,it,it]),J=Do(()=>Wt([it,se,R({kind:X("direction")}).strict(),R({kind:X("window")}).strict(),R({kind:X("gradient"),gradient_type:Y(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:Y(["Fac","Color"]),vector:J}).strict(),R({kind:X("to_float"),source_type:Y(["RGBA","VECTOR"]),value:J}).strict(),R({kind:X("math"),operation:Y(Object.keys(Uo)),clamp:at(),inputs:L(J).min(1).max(3)}).strict(),R({kind:X("mix_color"),factor:J,a:J,b:J,clamp_factor:at(),clamp_result:at()}).strict(),R({kind:X("mapping"),vector_type:Y(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:J,location:se,rotation:se,scale:se}).strict(),R({kind:X("separate"),vector:J,axis:I().int().min(0).max(2)}).strict(),R({kind:X("ramp"),factor:J,colors:L(se).length(257),interpolate:at()}).strict(),R({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(),R({kind:X("sky"),sun_elevation:it,sun_rotation:it,altitude:it,air_density:it,aerosol_density:it,ozone_density:it}).strict()])),to=R({color:se,strength:it,shader:J.optional()}),Jr=to.extend({volume:L(R({kind:Y(["absorption","scatter","principled","emission"]),phase:D(),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:to.strict().optional()}).strict(),ts=4,pe=new Map,tn=new Set;function eo(n,t,e){const a=Vt(n);if(a&&!e)throw new Error("World Window coordinates need a render camera");e?.updateMatrixWorld();const s=JSON.stringify([n,a?[e.matrixWorld.elements,e.projectionMatrix.elements]:null]),f=pe.get(s);if(f!==void 0)return vn(f,t,256,128);const c=new y,d=new Ue,l=e?new q().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse):null,i=e?.getWorldPosition(new y),m=Ur(n,256,128,a?h=>(c.set(h.x,h.z,-h.y),e.isPerspectiveCamera&&c.add(i),d.set(c.x,c.y,c.z,1).applyMatrix4(l),d.w===0?c.set(0,0,0):c.set(d.x/d.w*.5+.5,d.y/d.w*.5+.5,0)):void 0);return pe.set(s,m),pe.size>ts&&pe.delete(pe.keys().next().value),vn(m,t,256,128)}function es(n,t,e,o){const r=ge.toHalfFloat(1);for(let a=0;a<o;a++)n[a*4]=ge.toHalfFloat(t[a*3]*e),n[a*4+1]=ge.toHalfFloat(t[a*3+1]*e),n[a*4+2]=ge.toHalfFloat(t[a*3+2]*e),n[a*4+3]=r}function vn(n,t,e,o){const r=new Uint16Array(e*o*4);es(r,n,t,e*o);const a=new We(r,e,o,qe,An);return a.mapping=ca,a.colorSpace=bt,a.minFilter=ee,a.magFilter=ee,a.needsUpdate=!0,a}class Nn{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 e=t;for(;e;){if(e.isScene)return e;e=e.parent}return null}apply(t,e,o){if(this.clear(),this.pending=null,!e)return;const r=Nn.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=e.shader??e.color,s=this.generation,c=[...Qn(a),...e.lighting?Qn(e.lighting.shader??e.lighting.color):[]].filter(l=>!kr(l));if(c.length===0){this.compose(r,e,a,o);return}const d=(async()=>{const l=await Promise.all(c.map(Vr));c.forEach((i,u)=>{Bo(i,l[u])}),!(this.generation!==s||this.applied?.scene!==r)&&(this.compose(r,e,a,o),ht())})();this.pending=d,tn.add(d),d.then(()=>tn.delete(d),()=>tn.delete(d))}compose(t,e,o,r){if(this.texture=eo(o,e.strength,r),Vt(o)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=vn(Wr(o,512,512,r),e.strength,512,512),this.screenTexture.mapping=fa,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const s=r.getWorldDirection(new y);s.set(s.x,-s.z,s.y);const f=lt(e.shader??e.color)(s);t.background=typeof f=="number"?new Mt().setRGB(f,f,f).multiplyScalar(e.strength):new Mt().setRGB(f.x,f.y,f.z).multiplyScalar(e.strength)}else t.background=this.texture;const{lighting:a}=e;this.environmentTexture=a?eo(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 Wo(n){return[n.min.x,n.max.x].flatMap(t=>[n.min.y,n.max.y].flatMap(e=>[n.min.z,n.max.z].map(o=>new y(t,e,o))))}function ns(n,t){if(n.isEmpty()||!t.intersectsBox(n))return[];const e=Wo(n);if(e.every(l=>t.containsPoint(l)))return e;const o=[...t.planes,new Xt(new y(1,0,0),-n.min.x),new Xt(new y(-1,0,0),n.max.x),new Xt(new y(0,1,0),-n.min.y),new Xt(new y(0,-1,0),n.max.y),new Xt(new y(0,0,1),-n.min.z),new Xt(new y(0,0,-1),n.max.z)],r=[],a=new y,s=new y,f=new y,c=new y,d=Math.max(1,n.min.length(),n.max.length())*1e-8;for(let l=0;l<o.length;l++)for(let i=l+1;i<o.length;i++)for(let u=i+1;u<o.length;u++){const m=o[l],h=o[i],_=o[u];a.crossVectors(h.normal,_.normal);const p=m.normal.dot(a);Math.abs(p)<1e-12||(s.crossVectors(_.normal,m.normal),f.crossVectors(m.normal,h.normal),c.copy(a).multiplyScalar(-m.constant).addScaledVector(s,-h.constant).addScaledVector(f,-_.constant).divideScalar(p),o.every(g=>g.distanceToPoint(c)>=-d)&&r.push(c.clone()))}return r}function os(n,t,e){if(!n.castShadow||!t.length)return;n.shadow.updateMatrices(n);const o=n.shadow.camera,r=o.matrixWorldInverse,a=new ue().setFromPoints(t.map(u=>u.clone().applyMatrix4(r))),s=a.getSize(new y),f=Math.max(s.length()*1e-6,Number.EPSILON),c=2+2*Math.SQRT2,d=Math.max(s.x,s.y,f)/Math.max(1,Math.min(n.shadow.mapSize.x,n.shadow.mapSize.y)-2*c),l=2*Math.SQRT2*d,i=c*d;a.min.x-=i,a.min.y-=i,a.max.x+=i,a.max.y+=i;for(const u of e){if(u.isEmpty())continue;const m=new ue().setFromPoints(Wo(u).map(h=>h.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(),n.shadow.normalBias=l}const ce=I().finite(),no=W([ce,ce,ce]),qo=R({min:W([I().int(),I().int(),I().int()]),max:W([I().int(),I().int(),I().int()]),density:L(ce),voxelSize:ce.positive(),color:no,emission:no,densityScale:ce.nonnegative()}).strict();function as(n){const t=n.max.map((l,i)=>l-n.min[i]+1);if(t.some(l=>l<=0)||t.reduce((l,i)=>l*i,1)!==n.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const e=new ua(new Float32Array(n.density),t[0],t[1],t[2]);e.format=da,e.type=To,e.minFilter=e.magFilter=ee,e.unpackAlignment=1,e.needsUpdate=!0;const o=new y(...n.min).addScalar(-.5).multiplyScalar(n.voxelSize),r=new y(t[0],t[1],t[2]).multiplyScalar(n.voxelSize),a=new ma(r.x,r.y,r.z),s=a.getAttribute("position");for(let l=0;l<s.count;l++)s.setXYZ(l,o.x+(s.getX(l)>0?r.x:0),o.y+(s.getY(l)>0?r.y:0),o.z+(s.getZ(l)>0?r.z:0));s.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const f=new On({glslVersion:ha,side:_a,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:e},minimum:{value:o},extent:{value:r},voxelSize:{value:n.voxelSize},densityScale:{value:n.densityScale},volumeColor:{value:new y(...n.color)},emission:{value:new y(...n.emission)},cameraLocal:{value:new y},rayLocal:{value:new y},orthographic:{value:!1},worldScale:{value:new Oo}},vertexShader:`
|
|
20
20
|
out vec3 localPosition;
|
|
21
21
|
void main() {
|
|
22
22
|
localPosition = position;
|
|
@@ -58,7 +58,7 @@ import{a as wo,b as Oo,L as Ao}from"./LineSegments2-DN9pUfWA.js";import{bh as ct
|
|
|
58
58
|
outputColor = vec4(radiance, 1.0 - transmission);
|
|
59
59
|
#include <tonemapping_fragment>
|
|
60
60
|
#include <colorspace_fragment>
|
|
61
|
-
}`}),c=new
|
|
61
|
+
}`}),c=new Ft(a,f),d=new q;return c.onBeforeRender=(l,i,u)=>{d.copy(c.matrixWorld).invert(),f.uniforms.cameraLocal.value.setFromMatrixPosition(u.matrixWorld).applyMatrix4(d),u.getWorldDirection(f.uniforms.rayLocal.value).transformDirection(d),f.uniforms.orthographic.value=!!u.isOrthographicCamera,f.uniforms.worldScale.value.setFromMatrix4(c.matrixWorld)},f.addEventListener("dispose",()=>e.dispose()),c}const rs=`#define constexpr const
|
|
62
62
|
#define bool32_t bool
|
|
63
63
|
#define bool2 bvec2
|
|
64
64
|
#define bool3 bvec3
|
|
@@ -200,7 +200,7 @@ mat3x3 to_float3x3(mat3x4 m) { return mat3x3(m); }
|
|
|
200
200
|
#define float4_from_float(v) float4(float3(v), 1.0f)
|
|
201
201
|
#define gpu_dfdx(x) dFdx(x)
|
|
202
202
|
#define gpu_dfdy(x) dFdy(x)
|
|
203
|
-
#define gpu_fwidth(x) fwidth(x)`,
|
|
203
|
+
#define gpu_fwidth(x) fwidth(x)`,xn={"gpu_shader_common_math.glsl":{deps:["gpu_shader_math_constants_lib.glsl","gpu_shader_math_base_lib.glsl","gpu_shader_math_safe_lib.glsl"],code:`void math_add(float a, float b, float c, _ref(float ,result))
|
|
204
204
|
{
|
|
205
205
|
result = a + b;
|
|
206
206
|
}
|
|
@@ -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
|
-
}`}},
|
|
6882
|
+
}`}},oo=I().finite(),en=Y(["float","vec2","vec3","vec4"]),Ho=Wt([oo,L(oo)]),Go=W([D(),I().int().nonnegative()]),Fe=Wt([R({value:Ho}).strict(),R({link:Go}).strict()]),ss=["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"],is=R({type:Y(ss),props:Ot(D(),zo()),inputs:L(Wt([R({value:Ho,id:D(),gpu:en,enabled:at()}).strict(),R({link:Go,id:D(),gpu:en,enabled:at()}).strict()])),outputs:L(R({id:D(),gpu:en.or(X("closure")).nullable()}).strict())}).strict(),be=Do(()=>Wt([R({principled:X(!0)}).strict(),R({emission:W([Fe,Fe])}).strict(),R({transparent:I()}).strict(),R({none:X(!0)}).strict(),R({mix:W([Fe,be,be])}).strict(),R({add:W([be,be])}).strict()])),ls=R({surface:Y(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:Ot(D(),Fe),closure:be.optional(),nodes:Ot(D(),is)}).strict();function fs(n){const t=n.inputs.Alpha,e=o=>"transparent"in o||"mix"in o&&(e(o.mix[1])||e(o.mix[2]))||"add"in o&&(e(o.add[0])||e(o.add[1]));return t!==void 0&&"link"in t||n.closure!==void 0&&e(n.closure)}const Xo="vec3(0.2126729, 0.7151522, 0.0721750)",cs=n=>n==="float"?1:Number(n[3]);function us(n,t){const e=typeof t=="number"?[t]:t,o=cs(n);return Array.from({length:o},(r,a)=>e[a]??(a===3?1:0))}function ds(n,t,e){if(t===e)return n;const o=a=>a==="float"?"float":`float${a[3]}`,r=t==="vec4"&&e==="float"?`, ${Xo}`:"";return`${o(e)}_from_${o(t)}(${n}${r})`}const ms={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},_s={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},ao={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"},hs={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},ps={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},gs={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},vs=(()=>{const n=new Map;for(const[t,e]of Object.entries(xn))for(const o of e.code.matchAll(/^(?:void|float\d?)\s+([A-Za-z_]\w*)\s*\(/gm))n.has(o[1])||n.set(o[1],t);return n})();function j(n,t){if(!(t in n.props))throw new Error(`${n.type} arrived without its '${t}' property`);return n.props[t]}const xs=`
|
|
6883
6883
|
#define GPU_FRAGMENT_SHADER
|
|
6884
6884
|
#define FrontFacing gl_FrontFacing
|
|
6885
6885
|
#ifndef USE_TRANSMISSION
|
|
@@ -6936,7 +6936,7 @@ void blender_init_globals() {
|
|
|
6936
6936
|
g_data.curve_T = vec3(0.0);
|
|
6937
6937
|
g_data.barycentric_coords = vec2(0.0);
|
|
6938
6938
|
}
|
|
6939
|
-
`,
|
|
6939
|
+
`,bs=`
|
|
6940
6940
|
uniform vec2 blenderViewport;
|
|
6941
6941
|
vec3 blender_orco() {
|
|
6942
6942
|
// attr_load_orco: the orco attribute (\`orcoAttribute\`), interpolated.
|
|
@@ -7019,34 +7019,34 @@ vec3 blender_reflection() {
|
|
|
7019
7019
|
: normalize(cameraPosition - vBlenderWorldPosition);
|
|
7020
7020
|
return blender_from_three * -reflect(incident, normalize(vBlenderWorldNormal));
|
|
7021
7021
|
}
|
|
7022
|
-
`;class zn{constructor(t,e,o=!1,r="bgN"){this.graph=t,this.derivative=o,this.prefix=r,this.lines=[],this.emitted=new Map,this.s=e??{files:new Set,uniforms:new Map,uniformTypes:new Map,images:[],ramps:[],uvs:new Set,attributes:new Set,structure:[],functions:[]}}get uniforms(){return this.s.uniforms}get images(){return this.s.images}get ramps(){return this.s.ramps}d(t){return this.derivative?`(${t} + dF_impl(${t}))`:t}uniform(t,e){const o=`bgU${this.s.uniforms.size}`,r=_s(t,e);return this.s.uniforms.set(o,t==="float"?r[0]:r),this.s.uniformTypes.set(o,t),o}use(t){const e=ys.get(t);if(!e)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(e),t}source(t,e){if("value"in t)return this.s.structure.push("v"),this.uniform(e,t.value);const[o,r]=t.link,a=this.graph.nodes[o];if(!a)throw new Error(`The graph links to ${o}, which it does not carry`);const f=this.node(o,a)[r];if(!f)throw new Error(`${o} has no output ${r}`);return this.s.structure.push(["l",o,r]),hs(f.name,f.type,e)}input(t,e,o){const r=t.inputs.find(a=>a.id===e)??t.inputs.find(a=>a.id.replace(/_/g," ")===e);if(!r)throw new Error(`${t.type} arrived without its '${e}' input`);return this.source(r,o??r.gpu)}coordinate(t,e){const o=t.inputs[0];return"link"in o?this.source(o,"vec3"):(this.s.structure.push(["default",e]),e==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${se("")}, 0.0)`)))}node(t,e){const o=this.emitted.get(t);if(o)return o;const r=`${this.prefix}${this.emitted.size}`,a=e.outputs.map((s,u)=>({name:`${r}_${u}`,type:s.gpu==="closure"||s.gpu===null?"float":s.gpu}));this.emitted.set(t,a);const i=s=>`${a[s].type} ${a[s].name} = ${a[s].type}(0.0);`,f=a.map((s,u)=>i(u)).join(" "),c=s=>s.map(u=>a[u].name).join(", "),d=(s=[])=>[...e.inputs.map(_=>this.source(_,_.gpu)),...s,...a.map(_=>_.name)].join(", ");this.s.structure.push(["n",e.type,e.props.operation,e.props.blend_type,e.props.data_type,e.props.factor_mode,e.props.clamp_factor,e.props.clamp_result,e.props.use_clamp,e.props.noise_dimensions,e.props.noise_type,e.props.voronoi_dimensions,e.props.feature,e.props.distance,e.props.vector_type,e.props.uv_map,e.props.extension,e.props.interpolation,e.props.image_alpha_mode,e.props.image_is_data,e.props.color_ramp?.elements?.length,e.props.color_ramp?.interpolation]);const l=[f];switch(e.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const s=a[0].type;l.push(`${a[0].name} = ${this.uniform(s,j(e,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${se("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((u,_)=>{a[_]&&l.push(`${a[_].name} = ${this.d(u)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const s=j(e,e.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(s),this.s.structure.push(["a",s]);const u=e.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";l.push(`${this.use(u)}(${On(s)}, ${c(a.map((_,h)=>h))});`);for(const _ of a)l.push(`${_.name} = ${this.d(_.name)};`);break}case"ShaderNodeUVMap":{const s=j(e,"uv_map");this.s.uvs.add(s),l.push(`${a[0].name} = ${this.d(`vec3(${se(s)}, 0.0)`)};`);break}case"ShaderNodeMath":{const s=j(e,"operation"),u=this.use(ps[s]??`math_${s.toLowerCase()}`);l.push(`${u}(${d()});`),j(e,"use_clamp")&&l.push(`${this.use("clamp_value")}(${c([0])}, 0.0, 1.0, ${c([0])});`);break}case"ShaderNodeVectorMath":{const s=j(e,"operation");l.push(`${this.use(gs[s]??`vector_math_${s.toLowerCase()}`)}(${d()});`);break}case"ShaderNodeMapping":l.push(`${this.use(`mapping_${j(e,"vector_type").toLowerCase()}`)}(${d()});`);break;case"ShaderNodeInvert":l.push(`${this.use("invert")}(${d()});`);break;case"ShaderNodeSeparateXYZ":l.push(`${this.use("separate_xyz")}(${d()});`);break;case"ShaderNodeCombineXYZ":l.push(`${this.use("combine_xyz")}(${d()});`);break;case"ShaderNodeMix":{const s=j(e,"data_type"),u=j(e,"factor_mode")==="NON_UNIFORM",_={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[s];if(!_)throw new Error(`Mix has data type ${s}`);const h=s==="VECTOR"&&u;let m=this.input(e,h?"Factor_Vector":"Factor_Float");if(j(e,"clamp_factor")){const v=`${r}_fac`;l.push(h?`vec3 ${v}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${v});`:`float ${v}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${v});`),m=v}const p=s==="FLOAT"?"node_mix_float":s==="VECTOR"?u?"node_mix_vector_non_uniform":"node_mix_vector":s==="RGBA"?`node_mix_${io[j(e,"blend_type")]}`:"node_mix_rotation",g=e.outputs.findIndex(v=>v.id===`Result_${_}`);l.push(`${this.use(p)}(${m}, ${this.input(e,`A_${_}`)}, ${this.input(e,`B_${_}`)}, ${c([g])});`),s==="RGBA"&&j(e,"clamp_result")&&l.push(`${this.use("node_mix_clamp_color")}(${c([g])}, vec4(0.0), vec4(1.0), ${c([g])});`);break}case"ShaderNodeMixRGB":{const s=`${r}_fac`;l.push(`float ${s}; ${this.use("clamp_value")}(${this.input(e,"Fac")}, 0.0, 1.0, ${s});`);const u=e.inputs.slice(1).map(_=>this.source(_,_.gpu));l.push(`${this.use(`mix_${io[j(e,"blend_type")]}`)}(${[s,...u,c([0])].join(", ")});`),j(e,"use_clamp")&&l.push(`${this.use("clamp_color")}(${c([0])}, vec4(0.0), vec4(1.0), ${c([0])});`);break}case"ShaderNodeValToRGB":{const s=j(e,"color_ramp"),u=this.input(e,"Fac"),[_,h]=s.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(s.elements.length===1)l.push(`${c([0])} = ${m(_)}; ${c([1])} = ${c([0])}.a;`);else if(s.elements.length===2&&s.color_mode==="RGB"&&h&&s.interpolation!=="B_SPLINE"&&s.interpolation!=="CARDINAL")if(s.interpolation==="CONSTANT")l.push(`${this.use("valtorgb_opti_constant")}(${u}, ${this.uniform("float",Math.max(_[0],h[0]))}, ${m(_)}, ${m(h)}, ${c([0,1])});`);else{const p=1/(h[0]-_[0]),g=s.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";l.push(`${this.use(g)}(${u}, ${this.uniform("vec2",[p,-p*_[0]])}, ${m(_)}, ${m(h)}, ${c([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:s.table}),this.s.structure.push(["ramp",s.interpolation==="CONSTANT"]),l.push(s.interpolation==="CONSTANT"?`${c([0])} = texelFetch(${p}, ivec2(int(clamp(${u}, 0.0, 1.0) * 256.0), 0), 0);`:`${c([0])} = texture(${p}, vec2(clamp(${u}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),l.push(`${c([1])} = ${c([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const s=j(e,"curve_mapping"),u=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:u,table:s.table}),this.s.structure.push(["curve"]);const _=this.input(e,e.inputs.some(h=>h.id==="Factor")?"Factor":"Fac","float");e.type==="ShaderNodeRGBCurve"?l.push(`${this.use("curves_combined_rgb")}(${_}, ${this.input(e,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${u}, 0.5, ${this.uniform("vec4",s.minimums)}, ${this.uniform("vec4",s.dividers)}, ${this.uniform("vec4",s.starts)}, ${this.uniform("vec4",s.ends)}, ${c([0])});`):e.type==="ShaderNodeVectorCurve"?l.push(`${this.use("curves_vector_mixed")}(${_}, ${this.input(e,"Vector","vec3")}, ${u}, 0.5, ${this.uniform("vec3",s.minimums.slice(0,3))}, ${this.uniform("vec3",s.dividers.slice(0,3))}, ${this.uniform("vec3",s.starts.slice(0,3))}, ${this.uniform("vec3",s.ends.slice(0,3))}, ${c([0])});`):l.push(`${this.use("curves_float_mixed")}(${_}, ${this.input(e,"Value","float")}, ${u}, 0.5, ${this.uniform("float",s.minimums[0])}, ${this.uniform("float",s.dividers[0])}, ${this.uniform("float",s.starts[0])}, ${this.uniform("float",s.ends[0])}, ${c([0])});`);break}case"ShaderNodeTexNoise":{const s=Number(j(e,"noise_dimensions")[0]),u=this.use(`node_noise_tex_${vs[j(e,"noise_type")]}_${s}d`),_=this.coordinate(e,"orco"),h=e.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=j(e,"normalize")?"1.0":"0.0";l.push(`${u}(${[_,...h,m,"1.0",c(a.map((p,g)=>g))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const s=Number(j(e,"voronoi_dimensions")[0]),u=this.use(`node_tex_voronoi_${xs[j(e,"feature")]}_${s}d`),_=this.coordinate(e,"orco"),h=e.inputs.slice(1).map(g=>this.source(g,g.gpu)),m=`${bs[j(e,"distance")].toFixed(1)}`,p=j(e,"normalize")?"1.0":"0.0";l.push(`${u}(${[_,...h,m,p,c(a.map((g,v)=>v))].join(", ")});`);break}case"ShaderNodeTexChecker":{const s=this.coordinate(e,"orco"),u=e.inputs.slice(1).map(_=>this.source(_,_.gpu));l.push(`${this.use("node_tex_checker")}(${[s,...u,c(a.map((_,h)=>h))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const s=Number(j(e,"noise_dimensions")[0]);l.push(`${this.use(`node_white_noise_${s}d`)}(${d()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const s=this.coordinate(e,"orco"),u=e.inputs.slice(1).map(p=>this.source(p,p.gpu)),_=p=>j(e,`${p}#value`).toFixed(1),h=e.type==="ShaderNodeTexWave"?[_("wave_type"),_("bands_direction"),_("rings_direction"),_("wave_profile")]:e.type==="ShaderNodeTexGradient"?[_("gradient_type")]:e.type==="ShaderNodeTexMagic"?[j(e,"turbulence_depth").toFixed(1)]:[this.uniform("float",j(e,"offset")),j(e,"offset_frequency").toFixed(1),this.uniform("float",j(e,"squash")),j(e,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[e.type];l.push(`${this.use(m)}(${[s,...u,...h,c(a.map((p,g)=>g))].join(", ")});`);break}case"ShaderNodeMapRange":{const s=j(e,"data_type")==="FLOAT_VECTOR",u=j(e,"interpolation_type").toLowerCase(),_=j(e,"clamp");l.push(`${this.use(`${s?"vector_":""}map_range_${u}`)}(${d([_?"1.0":"0.0"])});`),_&&!s&&(u==="linear"||u==="stepped")&&l.push(`${this.use("clamp_range")}(${c([0])}, ${this.input(e,"To Min","float")}, ${this.input(e,"To Max","float")}, ${c([0])});`);break}case"ShaderNodeClamp":l.push(`${this.use(j(e,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${d()});`);break;case"ShaderNodeHueSaturation":l.push(`${this.use("hue_sat")}(${d()});`);break;case"ShaderNodeBrightContrast":l.push(`${this.use("brightness_contrast")}(${d()});`);break;case"ShaderNodeGamma":l.push(`${this.use("node_gamma")}(${d()});`);break;case"ShaderNodeRGBToBW":l.push(`${this.use("rgbtobw")}(${d([Go])});`);break;case"ShaderNodeSeparateColor":l.push(`${this.use(`separate_color_${j(e,"mode").toLowerCase()}`)}(${d()});`);break;case"ShaderNodeCombineColor":l.push(`${this.use(`combine_color_${j(e,"mode").toLowerCase()}`)}(${d()});`);break;case"ShaderNodeVectorRotate":{const s={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[j(e,"rotation_type")];l.push(`${this.use(`node_vector_rotate_${s}`)}(${d([j(e,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const s=e.inputs[1],u="link"in s?this.source(s,"vec3"):"g_data.N";"link"in s||this.s.structure.push("world-normal");const _=this.source(e.inputs[0],"float"),h=e.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";l.push(`${this.use(h)}(${[_,u,c(a.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const s=e.inputs.find(O=>O.id==="Height"),u=e.inputs.find(O=>O.id==="Normal"),_=u&&"link"in u?this.source(u,"vec3"):"g_data.N";if(!s||!("link"in s)){l.push(`${c([0])} = ${_};`);break}const h=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new zn(this.graph,this.s,!0,`${h}_`),p=m.source(s,"float");this.s.functions[Number(h.slice(8))]=`float ${h}() {
|
|
7023
|
-
${
|
|
7022
|
+
`;class Rn{constructor(t,e,o=!1,r="bgN"){this.graph=t,this.derivative=o,this.prefix=r,this.lines=[],this.emitted=new Map,this.s=e??{files:new Set,uniforms:new Map,uniformTypes:new Map,images:[],ramps:[],uvs:new Set,attributes:new Set,structure:[],functions:[]}}get uniforms(){return this.s.uniforms}get images(){return this.s.images}get ramps(){return this.s.ramps}d(t){return this.derivative?`(${t} + dF_impl(${t}))`:t}uniform(t,e){const o=`bgU${this.s.uniforms.size}`,r=us(t,e);return this.s.uniforms.set(o,t==="float"?r[0]:r),this.s.uniformTypes.set(o,t),o}use(t){const e=vs.get(t);if(!e)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(e),t}source(t,e){if("value"in t)return this.s.structure.push("v"),this.uniform(e,t.value);const[o,r]=t.link,a=this.graph.nodes[o];if(!a)throw new Error(`The graph links to ${o}, which it does not carry`);const f=this.node(o,a)[r];if(!f)throw new Error(`${o} has no output ${r}`);return this.s.structure.push(["l",o,r]),ds(f.name,f.type,e)}input(t,e,o){const r=t.inputs.find(a=>a.id===e)??t.inputs.find(a=>a.id.replace(/_/g," ")===e);if(!r)throw new Error(`${t.type} arrived without its '${e}' input`);return this.source(r,o??r.gpu)}coordinate(t,e){const o=t.inputs[0];return"link"in o?this.source(o,"vec3"):(this.s.structure.push(["default",e]),e==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${le("")}, 0.0)`)))}node(t,e){const o=this.emitted.get(t);if(o)return o;const r=`${this.prefix}${this.emitted.size}`,a=e.outputs.map((i,u)=>({name:`${r}_${u}`,type:i.gpu==="closure"||i.gpu===null?"float":i.gpu}));this.emitted.set(t,a);const s=i=>`${a[i].type} ${a[i].name} = ${a[i].type}(0.0);`,f=a.map((i,u)=>s(u)).join(" "),c=i=>i.map(u=>a[u].name).join(", "),d=(i=[])=>[...e.inputs.map(m=>this.source(m,m.gpu)),...i,...a.map(m=>m.name)].join(", ");this.s.structure.push(["n",e.type,e.props.operation,e.props.blend_type,e.props.data_type,e.props.factor_mode,e.props.clamp_factor,e.props.clamp_result,e.props.use_clamp,e.props.noise_dimensions,e.props.noise_type,e.props.voronoi_dimensions,e.props.feature,e.props.distance,e.props.vector_type,e.props.uv_map,e.props.extension,e.props.interpolation,e.props.image_alpha_mode,e.props.image_is_data,e.props.color_ramp?.elements?.length,e.props.color_ramp?.interpolation]);const l=[f];switch(e.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const i=a[0].type;l.push(`${a[0].name} = ${this.uniform(i,j(e,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${le("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((u,m)=>{a[m]&&l.push(`${a[m].name} = ${this.d(u)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const i=j(e,e.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(i),this.s.structure.push(["a",i]);const u=e.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";l.push(`${this.use(u)}(${bn(i)}, ${c(a.map((m,h)=>h))});`);for(const m of a)l.push(`${m.name} = ${this.d(m.name)};`);break}case"ShaderNodeUVMap":{const i=j(e,"uv_map");this.s.uvs.add(i),l.push(`${a[0].name} = ${this.d(`vec3(${le(i)}, 0.0)`)};`);break}case"ShaderNodeMath":{const i=j(e,"operation"),u=this.use(ms[i]??`math_${i.toLowerCase()}`);l.push(`${u}(${d()});`),j(e,"use_clamp")&&l.push(`${this.use("clamp_value")}(${c([0])}, 0.0, 1.0, ${c([0])});`);break}case"ShaderNodeVectorMath":{const i=j(e,"operation");l.push(`${this.use(_s[i]??`vector_math_${i.toLowerCase()}`)}(${d()});`);break}case"ShaderNodeMapping":l.push(`${this.use(`mapping_${j(e,"vector_type").toLowerCase()}`)}(${d()});`);break;case"ShaderNodeInvert":l.push(`${this.use("invert")}(${d()});`);break;case"ShaderNodeSeparateXYZ":l.push(`${this.use("separate_xyz")}(${d()});`);break;case"ShaderNodeCombineXYZ":l.push(`${this.use("combine_xyz")}(${d()});`);break;case"ShaderNodeMix":{const i=j(e,"data_type"),u=j(e,"factor_mode")==="NON_UNIFORM",m={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[i];if(!m)throw new Error(`Mix has data type ${i}`);const h=i==="VECTOR"&&u;let _=this.input(e,h?"Factor_Vector":"Factor_Float");if(j(e,"clamp_factor")){const v=`${r}_fac`;l.push(h?`vec3 ${v}; ${this.use("node_mix_clamp_vector")}(${_}, vec3(0.0), vec3(1.0), ${v});`:`float ${v}; ${this.use("node_mix_clamp_value")}(${_}, 0.0, 1.0, ${v});`),_=v}const p=i==="FLOAT"?"node_mix_float":i==="VECTOR"?u?"node_mix_vector_non_uniform":"node_mix_vector":i==="RGBA"?`node_mix_${ao[j(e,"blend_type")]}`:"node_mix_rotation",g=e.outputs.findIndex(v=>v.id===`Result_${m}`);l.push(`${this.use(p)}(${_}, ${this.input(e,`A_${m}`)}, ${this.input(e,`B_${m}`)}, ${c([g])});`),i==="RGBA"&&j(e,"clamp_result")&&l.push(`${this.use("node_mix_clamp_color")}(${c([g])}, vec4(0.0), vec4(1.0), ${c([g])});`);break}case"ShaderNodeMixRGB":{const i=`${r}_fac`;l.push(`float ${i}; ${this.use("clamp_value")}(${this.input(e,"Fac")}, 0.0, 1.0, ${i});`);const u=e.inputs.slice(1).map(m=>this.source(m,m.gpu));l.push(`${this.use(`mix_${ao[j(e,"blend_type")]}`)}(${[i,...u,c([0])].join(", ")});`),j(e,"use_clamp")&&l.push(`${this.use("clamp_color")}(${c([0])}, vec4(0.0), vec4(1.0), ${c([0])});`);break}case"ShaderNodeValToRGB":{const i=j(e,"color_ramp"),u=this.input(e,"Fac"),[m,h]=i.elements,_=p=>this.uniform("vec4",p.slice(1,5));if(i.elements.length===1)l.push(`${c([0])} = ${_(m)}; ${c([1])} = ${c([0])}.a;`);else if(i.elements.length===2&&i.color_mode==="RGB"&&h&&i.interpolation!=="B_SPLINE"&&i.interpolation!=="CARDINAL")if(i.interpolation==="CONSTANT")l.push(`${this.use("valtorgb_opti_constant")}(${u}, ${this.uniform("float",Math.max(m[0],h[0]))}, ${_(m)}, ${_(h)}, ${c([0,1])});`);else{const p=1/(h[0]-m[0]),g=i.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";l.push(`${this.use(g)}(${u}, ${this.uniform("vec2",[p,-p*m[0]])}, ${_(m)}, ${_(h)}, ${c([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:i.table}),this.s.structure.push(["ramp",i.interpolation==="CONSTANT"]),l.push(i.interpolation==="CONSTANT"?`${c([0])} = texelFetch(${p}, ivec2(int(clamp(${u}, 0.0, 1.0) * 256.0), 0), 0);`:`${c([0])} = texture(${p}, vec2(clamp(${u}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),l.push(`${c([1])} = ${c([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const i=j(e,"curve_mapping"),u=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:u,table:i.table}),this.s.structure.push(["curve"]);const m=this.input(e,e.inputs.some(h=>h.id==="Factor")?"Factor":"Fac","float");e.type==="ShaderNodeRGBCurve"?l.push(`${this.use("curves_combined_rgb")}(${m}, ${this.input(e,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${u}, 0.5, ${this.uniform("vec4",i.minimums)}, ${this.uniform("vec4",i.dividers)}, ${this.uniform("vec4",i.starts)}, ${this.uniform("vec4",i.ends)}, ${c([0])});`):e.type==="ShaderNodeVectorCurve"?l.push(`${this.use("curves_vector_mixed")}(${m}, ${this.input(e,"Vector","vec3")}, ${u}, 0.5, ${this.uniform("vec3",i.minimums.slice(0,3))}, ${this.uniform("vec3",i.dividers.slice(0,3))}, ${this.uniform("vec3",i.starts.slice(0,3))}, ${this.uniform("vec3",i.ends.slice(0,3))}, ${c([0])});`):l.push(`${this.use("curves_float_mixed")}(${m}, ${this.input(e,"Value","float")}, ${u}, 0.5, ${this.uniform("float",i.minimums[0])}, ${this.uniform("float",i.dividers[0])}, ${this.uniform("float",i.starts[0])}, ${this.uniform("float",i.ends[0])}, ${c([0])});`);break}case"ShaderNodeTexNoise":{const i=Number(j(e,"noise_dimensions")[0]),u=this.use(`node_noise_tex_${hs[j(e,"noise_type")]}_${i}d`),m=this.coordinate(e,"orco"),h=e.inputs.slice(1).map(p=>this.source(p,p.gpu)),_=j(e,"normalize")?"1.0":"0.0";l.push(`${u}(${[m,...h,_,"1.0",c(a.map((p,g)=>g))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const i=Number(j(e,"voronoi_dimensions")[0]),u=this.use(`node_tex_voronoi_${ps[j(e,"feature")]}_${i}d`),m=this.coordinate(e,"orco"),h=e.inputs.slice(1).map(g=>this.source(g,g.gpu)),_=`${gs[j(e,"distance")].toFixed(1)}`,p=j(e,"normalize")?"1.0":"0.0";l.push(`${u}(${[m,...h,_,p,c(a.map((g,v)=>v))].join(", ")});`);break}case"ShaderNodeTexChecker":{const i=this.coordinate(e,"orco"),u=e.inputs.slice(1).map(m=>this.source(m,m.gpu));l.push(`${this.use("node_tex_checker")}(${[i,...u,c(a.map((m,h)=>h))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const i=Number(j(e,"noise_dimensions")[0]);l.push(`${this.use(`node_white_noise_${i}d`)}(${d()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const i=this.coordinate(e,"orco"),u=e.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=p=>j(e,`${p}#value`).toFixed(1),h=e.type==="ShaderNodeTexWave"?[m("wave_type"),m("bands_direction"),m("rings_direction"),m("wave_profile")]:e.type==="ShaderNodeTexGradient"?[m("gradient_type")]:e.type==="ShaderNodeTexMagic"?[j(e,"turbulence_depth").toFixed(1)]:[this.uniform("float",j(e,"offset")),j(e,"offset_frequency").toFixed(1),this.uniform("float",j(e,"squash")),j(e,"squash_frequency").toFixed(1)],_={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[e.type];l.push(`${this.use(_)}(${[i,...u,...h,c(a.map((p,g)=>g))].join(", ")});`);break}case"ShaderNodeMapRange":{const i=j(e,"data_type")==="FLOAT_VECTOR",u=j(e,"interpolation_type").toLowerCase(),m=j(e,"clamp");l.push(`${this.use(`${i?"vector_":""}map_range_${u}`)}(${d([m?"1.0":"0.0"])});`),m&&!i&&(u==="linear"||u==="stepped")&&l.push(`${this.use("clamp_range")}(${c([0])}, ${this.input(e,"To Min","float")}, ${this.input(e,"To Max","float")}, ${c([0])});`);break}case"ShaderNodeClamp":l.push(`${this.use(j(e,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${d()});`);break;case"ShaderNodeHueSaturation":l.push(`${this.use("hue_sat")}(${d()});`);break;case"ShaderNodeBrightContrast":l.push(`${this.use("brightness_contrast")}(${d()});`);break;case"ShaderNodeGamma":l.push(`${this.use("node_gamma")}(${d()});`);break;case"ShaderNodeRGBToBW":l.push(`${this.use("rgbtobw")}(${d([Xo])});`);break;case"ShaderNodeSeparateColor":l.push(`${this.use(`separate_color_${j(e,"mode").toLowerCase()}`)}(${d()});`);break;case"ShaderNodeCombineColor":l.push(`${this.use(`combine_color_${j(e,"mode").toLowerCase()}`)}(${d()});`);break;case"ShaderNodeVectorRotate":{const i={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[j(e,"rotation_type")];l.push(`${this.use(`node_vector_rotate_${i}`)}(${d([j(e,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const i=e.inputs[1],u="link"in i?this.source(i,"vec3"):"g_data.N";"link"in i||this.s.structure.push("world-normal");const m=this.source(e.inputs[0],"float"),h=e.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";l.push(`${this.use(h)}(${[m,u,c(a.map((_,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const i=e.inputs.find(O=>O.id==="Height"),u=e.inputs.find(O=>O.id==="Normal"),m=u&&"link"in u?this.source(u,"vec3"):"g_data.N";if(!i||!("link"in i)){l.push(`${c([0])} = ${m};`);break}const h=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const _=new Rn(this.graph,this.s,!0,`${h}_`),p=_.source(i,"float");this.s.functions[Number(h.slice(8))]=`float ${h}() {
|
|
7023
|
+
${_.lines.join(`
|
|
7024
7024
|
`)}
|
|
7025
7025
|
return ${p};
|
|
7026
|
-
}`;const g=this.input(e,"Filter Width","float");l.push(`float ${r}_h = ${h}();`,`g_derivative_filter_width = ${g} * derivative_scale_get();`,`g_derivative_flag = 1; float ${r}_hx = ${h}();`,`g_derivative_flag = -1; float ${r}_hy = ${h}();`,"g_derivative_flag = 0;");const v=j(e,"invert")?"-1.0":"1.0";l.push(`${this.use("node_bump")}(${this.input(e,"Strength","float")}, ${this.input(e,"Distance","float")}, ${g}, ${r}_h, ${
|
|
7026
|
+
}`;const g=this.input(e,"Filter Width","float");l.push(`float ${r}_h = ${h}();`,`g_derivative_filter_width = ${g} * derivative_scale_get();`,`g_derivative_flag = 1; float ${r}_hx = ${h}();`,`g_derivative_flag = -1; float ${r}_hy = ${h}();`,"g_derivative_flag = 0;");const v=j(e,"invert")?"-1.0":"1.0";l.push(`${this.use("node_bump")}(${this.input(e,"Strength","float")}, ${this.input(e,"Distance","float")}, ${g}, ${r}_h, ${m}, vec2(${r}_hx, ${r}_hy), ${v}, ${c([0])});`);break}case"ShaderNodeNormalMap":{const i=j(e,"space"),u=this.input(e,"Strength","float"),m=this.input(e,"Color","vec3"),h=`${r}_n`;if(l.push(`vec3 ${h}; ${this.use(i.startsWith("BLENDER_")?"color_to_blender_normal_new_shading":"color_to_normal_new_shading")}(${m}, ${h});`),e.props.convention==="DIRECTX"&&l.push(`${this.use("color_invert_green_channel")}(${h}, ${h});`),i==="TANGENT"){const _=j(e,"uv_map");this.s.uvs.add(_),l.push(`${this.use("node_normal_map")}(blender_uv_tangent(${le(_)}), ${u}, ${h}, g_data.Ni, ${c([0])});`)}else(i==="OBJECT"||i==="BLENDER_OBJECT")&&l.push(`${this.use("normal_transform_object_to_world")}(${h}, ${h});`),l.push(`${this.use("node_normal_map_mix")}(${u}, ${h}, ${c([0])});`);break}case"ShaderNodeNewGeometry":{l.push(`${this.use("node_geometry")}(${["blender_orco()",c(a.map((i,u)=>u))].join(", ")});`),a[0]&&l.push(`${a[0].name} = ${this.d(a[0].name)};`);for(const i of[1,2,4])a[i]&&l.push(`${a[i].name} = normalize(${a[i].name});`);break}case"ShaderNodeTexImage":{const i=j(e,"image");if(i===null){l.push(e.props.image_missing===!0?`${c([0])} = vec4(1.0, 0.0, 1.0, 1.0); ${c([1])} = 1.0;`:`${c([0])} = vec4(0.0); ${c([1])} = 0.0;`);break}const u=j(e,"projection"),m=j(e,"interpolation"),h=m==="Cubic"||m==="Smart",_=j(e,"extension"),p=`bgImage${this.s.images.length}`;this.s.images.push({uniform:p,node:t,name:i.name,revision:i.revision,extension:_,closest:m==="Closest",mipmap:u!=="SPHERE"&&u!=="TUBE",tiled:u==="FLAT"&&e.props.image_tiled===!0});const g=this.s.images.at(-1).tiled;this.s.structure.push(["img",u,h,g]);let v=this.coordinate(e,"uv");const O=c([0]),b=c([1]);if(u==="BOX"){const M=`${r}_n`;l.push(`vec3 ${M}; ${this.use("world_normals_get")}(${M}); ${this.use("normal_transform_world_to_object")}(${M}, ${M});`,`vec4 ${r}_c1, ${r}_c2, ${r}_c3;`,`${this.use(h?"tex_box_sample_cubic":"tex_box_sample_linear")}(${v}, ${M}, ${p}, ${r}_c1, ${r}_c2, ${r}_c3);`,`${this.use("tex_box_blend")}(${M}, ${r}_c1, ${r}_c2, ${r}_c3, ${this.uniform("float",j(e,"projection_blend"))}, ${O}, ${b});`)}else if(g)h&&this.use("cubic_bspline_coefficients"),l.push(`${h?"blender_tex_tile_cubic":"blender_tex_tile_linear"}(${v}, ${p}, ${p}Map, ${O}, ${b});`);else{if(u==="SPHERE"||u==="TUBE"){const M=`${r}_co`;l.push(`vec3 ${M}; ${this.use("point_texco_remap_square")}(${v}, ${M});`,`${this.use(u==="SPHERE"?"point_map_to_sphere":"point_map_to_tube")}(${M}, ${M});`),v=M}l.push(`${this.use(h?"node_tex_image_cubic":"node_tex_image_linear")}(${v}, ${p}, ${O}, ${b});`),_==="CLIP"&&l.push(`if (any(lessThan(${v}.xy, vec2(0.0))) || any(greaterThan(${v}.xy, vec2(1.0)))) { ${O} = vec4(0.0); ${b} = 0.0; }`)}const S=j(e,"image_alpha_mode"),w=this.uses(t,1),A=c([0]);S==="NONE"||S==="CHANNEL_PACKED"||j(e,"image_is_data")?l.push(`${A}.a = 1.0;`):S==="PREMUL"?l.push(w?`if (${A}.a != 0.0 && ${A}.a != 1.0) ${A}.rgb /= ${A}.a;`:`${A}.a = 1.0;`):l.push(w?`${A}.a = 1.0;`:`${A}.rgb *= ${A}.a;`);break}}return this.lines.push(...l),a}uses(t,e){const o=a=>"link"in a&&a.link[0]===t&&a.link[1]===e,r=a=>a!==void 0&&("emission"in a?a.emission.some(o):"mix"in a?o(a.mix[0])||r(a.mix[1])||r(a.mix[2]):"add"in a?r(a.add[0])||r(a.add[1]):!1);return Object.values(this.graph.inputs).some(o)||Object.values(this.graph.nodes).some(a=>a.inputs.some(o))||r(this.graph.closure)}compile(){const t=this.graph.surface==="ShaderNodeEmission"?{Color:"vec4",Strength:"float"}:{"Base Color":"vec4",Metallic:"float",Roughness:"float",Alpha:"float","Emission Color":"vec4","Emission Strength":"float",Normal:"vec3"},e={},o=[];let r=0;for(const[i,u]of Object.entries(t)){const m=this.graph.inputs[i];if(!m||i==="Normal"&&!("link"in m))continue;const h=`bgOut${r++}`;e[i]={global:h,type:u},this.s.structure.push(["out",i]),o.push(`${h} = ${this.source(m,u)};`)}const a=this.graph.closure;if(a){let i=0;const u=(m,h)=>{if("principled"in m)this.s.structure.push("cP"),o.push(`bgClosureP += ${h};`);else if("emission"in m)this.s.structure.push("cE"),o.push(`bgClosureE += ${h} * ${this.source(m.emission[0],"vec4")}.rgb * ${this.source(m.emission[1],"float")};`);else if("transparent"in m)this.s.structure.push("cT"),o.push(`bgClosureT += ${h} * ${this.source({value:m.transparent},"float")};`);else if("mix"in m){this.s.structure.push("cM");const _=`bgClosureF${i++}`;o.push(`float ${_} = clamp(${this.source(m.mix[0],"float")}, 0.0, 1.0);`),u(m.mix[1],`${h} * (1.0 - ${_})`),u(m.mix[2],`${h} * ${_}`)}else"add"in m?(this.s.structure.push("cA"),u(m.add[0],h),u(m.add[1],h)):this.s.structure.push("c0")};o.push("bgClosureP = 0.0;","bgClosureE = vec3(0.0);","bgClosureT = 0.0;"),u(a,"1.0")}const s=[],f=new Set,c=i=>{if(!f.has(i)){f.add(i);for(const u of xn[i].deps)c(u);s.push(i)}};for(const i of this.s.files)c(i);const d=`void blenderGraph() {
|
|
7027
7027
|
blender_init_globals();
|
|
7028
7028
|
${[...this.lines,...o].join(`
|
|
7029
7029
|
`)}
|
|
7030
|
-
}`,l=[
|
|
7030
|
+
}`,l=[rs,ys(xs+s.map(i=>xn[i].code).join(`
|
|
7031
7031
|
`)+`
|
|
7032
|
-
`+
|
|
7033
|
-
`)),...[...this.s.uniformTypes].map(([
|
|
7034
|
-
uniform highp sampler2D ${
|
|
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:e,surface:this.graph.surface,closure:a!==void 0}}}function
|
|
7032
|
+
`+bs,[...this.s.functions,d].join(`
|
|
7033
|
+
`)),...[...this.s.uniformTypes].map(([i,u])=>`uniform ${u} ${i};`),...this.images.map(i=>i.tiled?`uniform highp sampler2DArray ${i.uniform};
|
|
7034
|
+
uniform highp sampler2D ${i.uniform}Map;`:`uniform sampler2D ${i.uniform};`),...this.ramps.map(i=>`uniform sampler2D ${i.uniform};`),...Object.values(e).map(i=>`${i.type} ${i.global};`),...a?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,d].join(`
|
|
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:e,surface:this.graph.surface,closure:a!==void 0}}}function ys(n,t){const e=[],o=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let r=0;for(let c;c=o.exec(n);){if(c.index<r)continue;let d=c.index+c[0].length;for(let m=1;d<n.length&&m>0;d++)m+=n[d]==="("?1:n[d]===")"?-1:0;const l=n.slice(d).match(/^\s*(\{|;)/);if(!l||/^\s*#/.test(n.slice(n.lastIndexOf(`
|
|
7036
7036
|
`,c.index)+1,c.index+1))||n.slice(Math.max(0,c.index-2),c.index).endsWith(`\\
|
|
7037
|
-
`))continue;let u=d+l[0].length;if(l[1]==="{")for(let
|
|
7038
|
-
`).find(
|
|
7037
|
+
`))continue;let u=d+l[0].length;if(l[1]==="{")for(let m=1;u<n.length&&m>0;u++)m+=n[u]==="{"?1:n[u]==="}"?-1:0;e.push({text:n.slice(r,c.index),name:null}),e.push({text:n.slice(c.index,u),name:c[1]}),r=u,o.lastIndex=u}e.push({text:n.slice(r),name:null});const a=new Set(e.filter(c=>c.name===null)),s=new Set,f=c=>{for(const d of c.matchAll(/[A-Za-z_]\w*/g))s.add(d[0])};f(t);for(const c of a)f(c.text);for(let c=!0;c;){c=!1;for(const d of e)a.has(d)||d.name===null||!s.has(d.name)||(a.add(d),f(d.text),c=!0)}return e.filter(c=>a.has(c)).map(c=>c.text).join("")}function bn(n){return`v${Bt(n)}`}function le(n){return n===""?"vBlenderUvRender":`vBlenderUv_${[...n].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function ws(n){return new Rn(n).compile()}function Os(n){const t=new Uint16Array(n.length*4);n.forEach((o,r)=>t.set([o[0]??0,o[1]??0,o[2]??0,o[3]??1].map(a=>ge.toHalfFloat(a)),r*4));const e=new We(t,n.length,1,qe,An);return e.minFilter=e.magFilter=ee,e.wrapS=e.wrapT=So,e.needsUpdate=!0,e}const ut=new WeakMap,In=new Set,zt=new WeakMap,Te=new WeakMap;function Se(n){const t=zt.get(n);if(t){zt.delete(n);for(const e of t.binding.ramps)e.dispose()}}function As(n,t,e,o=!1){const r=ut.get(n);if(t&&In.has(t.key)&&(t=null),!t){if(Se(n),r){for(const f of r.ramps)f.dispose();ut.delete(n),n.needsUpdate=!0}return}if(r&&r.compiled.key===t.key){Se(n),Pe(r,t,e);return}if(o){Se(n);for(const c of r?.ramps??[])c.dispose();const f={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};Pe(f,t,e),ut.set(n,f),n.needsUpdate=!0;return}const a=zt.get(n);if(a&&a.binding.compiled.key===t.key){Pe(a.binding,t,e);return}Se(n);const s={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};Pe(s,t,e),zt.set(n,{binding:s,started:!1})}function Ms(n,t){if(zt.has(n))return!1;const e=ut.get(n),o=e&&!In.has(e.compiled.key)?e:void 0,r=ut.get(t);return o?(!r||r.compiled.key!==o.compiled.key||r.uniforms!==o.uniforms)&&(ut.set(t,{compiled:o.compiled,uniforms:o.uniforms,ramps:[],channels:{}}),t.needsUpdate=!0):r&&(ut.delete(t),t.needsUpdate=!0),!0}function Pe(n,t,e){n.compiled=t;for(const[o,r]of t.uniforms){const a=typeof r=="number"?r:r.length===2?new te(...r):r.length===3?new y(...r):new Ue(...r),s=n.uniforms[o];s?s.value=a:n.uniforms[o]={value:a}}for(const o of n.ramps)o.dispose();n.ramps=t.ramps.map(o=>{const r=Os(o.table);return(n.uniforms[o.uniform]??={value:null}).value=r,r});for(const o of t.images){const r=e(o);if(o.tiled){const a=r!==null&&"tiles"in r?r:null;(n.uniforms[o.uniform]??={value:null}).value=a?.tiles??null,(n.uniforms[`${o.uniform}Map`]??={value:null}).value=a?.map??null}else(n.uniforms[o.uniform]??={value:null}).value=r!==null&&"tiles"in r?null:r}}function Ts(n){const t=ut.get(n);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function Ss(n){return Object.values(ut.get(n)?.channels??{})}function Yo(n,t){const e=new Set(["position","normal","uv"]);if(t.hasAttribute("tangent")&&e.add("tangent"),n.vertexColors&&e.add("color"),!(n instanceof ne))return e;const o=t.userData.blenderUvChannels,r=a=>{const s=a===""?0:o?.[a]??9;e.add(s===0?"uv":`uv${s}`)};for(const a of[n.map,n.roughnessMap,n.normalMap])a&&r(a.userData.blenderUvName??"");for(const a of[ut.get(n),zt.get(n)?.binding])if(a){e.add("blenderOrco");for(const s of a.compiled.uvs)r(s);for(const s of a.compiled.attributes)e.add(Bt(s))}return e}function ro(n,t){const e=t.userData.blenderUvChannels,o=t.getAttribute("position")?.count??0,r={};for(const a of n.uvs){let s=a===""?0:e?.[a];s===void 0&&(s=9,t.getAttribute("uv9")?.count!==o&&t.setAttribute("uv9",new ft(new Float32Array(o*2),2))),r[a]=s}return r}function Ps(n,t,e,o,r,a,s){const f=Te.get(n);f&&++f.draws>1&&(f.shadow.dispose(),Te.delete(n));const c=zt.get(n);if(c&&!c.started){c.started=!0,c.binding.channels=ro(c.binding.compiled,t);const u=s(n);ut.set(u,c.binding);const m=new Ft(t,u);m.castShadow=a.castShadow,m.receiveShadow=a.receiveShadow;const h=()=>{if(zt.get(n)!==c){u.dispose();return}zt.delete(n);for(const _ of ut.get(n)?.ramps??[])_.dispose();ut.set(n,c.binding),n.needsUpdate=!0,Te.get(n)?.shadow.dispose(),Te.set(n,{shadow:u,draws:0}),ht()};e.compileAsync(m,r,o).then(h,h)}const d=ut.get(n);if(!d)return;const l=e.properties.get(n).currentProgram;if(l?.diagnostics?.runnable===!1&&l.cacheKey?.includes(d.compiled.key)){In.add(d.compiled.key),ut.delete(n),n.needsUpdate=!0;const u=l.diagnostics.fragmentShader.log.split(`
|
|
7038
|
+
`).find(m=>m.startsWith("ERROR"))??"";console.warn(`Blender material "${n.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${u}`);return}const i=ro(d.compiled,t);JSON.stringify(i)!==JSON.stringify(d.channels)&&(d.channels=i,n.needsUpdate=!0)}function Es(n){const t=Array.isArray(n.material)?n.material:[n.material];if(!t.some(c=>c instanceof ne&&ut.has(c)))return;const e=n.geometry,o=n.userData.blenderTexspace??null,r=e.getAttribute("position"),a=JSON.stringify([o,r?.version??0,r?.count??0]);!e.userData.blenderOrcoFromDoor&&e.userData.blenderOrcoStamp!==a&&(e.setAttribute("blenderOrco",Ns(e,o)),e.userData.blenderOrcoStamp=a);const s=r?.count??0,f=n.userData.blenderDefaultColor;for(const c of t){const d=c instanceof ne?ut.get(c):void 0;for(const l of d?.compiled.attributes??[]){const i=Bt(l),u=l===""?f===void 0?void 0:e.getAttribute(Bt(f)):e.getAttribute(i);u&&u.count===s?e.getAttribute(i)!==u&&e.setAttribute(i,u):e.getAttribute(i)?.count!==s&&e.setAttribute(i,new ft(new Float32Array(s*4),4))}}}function Ns(n,t){const e=n.getAttribute("position");let o,r;if(t)o=[...t[0]],r=[...t[1]];else{n.computeBoundingBox();const s=n.boundingBox;o=[(s.min.x+s.max.x)/2,(s.min.y+s.max.y)/2,(s.min.z+s.max.z)/2],r=[(s.max.x-s.min.x)/2,(s.max.y-s.min.y)/2,(s.max.z-s.min.z)/2]}r=r.map(s=>s===0?1:s);const a=new Float32Array(e.count*3);for(let s=0;s<e.count;s++)a[s*3]=(e.getX(s)-o[0])/r[0]*.5+.5,a[s*3+1]=(e.getY(s)-o[1])/r[1]*.5+.5,a[s*3+2]=(e.getZ(s)-o[2])/r[2]*.5+.5;return new ft(a,3)}function Rs(n,t){const e=ut.get(n);if(!e)return;const{compiled:o,channels:r}=e;Object.assign(t.uniforms,e.uniforms,{blenderViewport:{value:Zo}});const a=g=>g===0?"uv":`uv${g}`,s=`varying vec3 vBlenderObjectPosition;
|
|
7039
7039
|
varying vec3 vBlenderObjectNormal;
|
|
7040
7040
|
varying vec3 vBlenderWorldPosition;
|
|
7041
7041
|
varying vec3 vBlenderWorldNormal;
|
|
7042
7042
|
varying vec3 vBlenderOrco;
|
|
7043
|
-
${o.attributes.map(g=>`varying vec4 ${
|
|
7043
|
+
${o.attributes.map(g=>`varying vec4 ${bn(g)};`).join(`
|
|
7044
7044
|
`)}
|
|
7045
|
-
${o.uvs.map(g=>`varying vec2 ${
|
|
7045
|
+
${o.uvs.map(g=>`varying vec2 ${le(g)};`).join(`
|
|
7046
7046
|
`)}`,f=o.attributes.map(g=>`attribute vec4 ${Bt(g)};`).join(`
|
|
7047
7047
|
`);t.vertexShader=`attribute vec3 blenderOrco;
|
|
7048
7048
|
${f}
|
|
7049
|
-
${
|
|
7049
|
+
${s}
|
|
7050
7050
|
${t.vertexShader}`.replace("#include <project_vertex>",`vBlenderObjectPosition = transformed;
|
|
7051
7051
|
vBlenderObjectNormal = objectNormal;
|
|
7052
7052
|
mat4 blenderWorldMatrix = modelMatrix;
|
|
@@ -7059,9 +7059,9 @@ blenderWorldMatrix = blenderWorldMatrix * instanceMatrix;
|
|
|
7059
7059
|
vBlenderWorldPosition = (blenderWorldMatrix * vec4(transformed, 1.0)).xyz;
|
|
7060
7060
|
vBlenderWorldNormal = normalize(transpose(inverse(mat3(blenderWorldMatrix))) * objectNormal);
|
|
7061
7061
|
vBlenderOrco = blenderOrco;
|
|
7062
|
-
${o.attributes.map(g=>`${
|
|
7062
|
+
${o.attributes.map(g=>`${bn(g)} = ${Bt(g)};`).join(`
|
|
7063
7063
|
`)}
|
|
7064
|
-
${o.uvs.map(g=>`${
|
|
7064
|
+
${o.uvs.map(g=>`${le(g)} = ${a(r[g]??0)};`).join(`
|
|
7065
7065
|
`)}
|
|
7066
7066
|
#include <project_vertex>`);const c=g=>o.outputs[g]?.global,d=[];o.surface==="ShaderNodeEmission"?(d.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),d.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${c("Color")}.rgb * ${c("Strength")};`,!1]),d.push(["#include <opaque_fragment>","outgoingLight = totalEmissiveRadiance;",!0])):o.surface==="closure"?(d.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),d.push(["#include <emissivemap_fragment>","totalEmissiveRadiance = vec3(0.0);",!1])):(d.push(["#include <color_fragment>",`diffuseColor.rgb = ${c("Base Color")}.rgb;`,!1]),d.push(["#include <alphamap_fragment>",`diffuseColor.a = ${c("Alpha")};`,!1]),d.push(["#include <metalnessmap_fragment>",`roughnessFactor = ${c("Roughness")};`,!0]),d.push(["#include <metalnessmap_fragment>",`metalnessFactor = ${c("Metallic")};`,!1]),d.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${c("Emission Color")}.rgb * ${c("Emission Strength")};`,!1]),c("Normal")&&d.push(["#include <clearcoat_normal_fragment_begin>",`normal = normalize((viewMatrix * vec4(transpose(blender_from_three) * ${c("Normal")}, 0.0)).xyz);`,!0])),o.closure&&d.push(["#include <opaque_fragment>",`{
|
|
7067
7067
|
float blenderCoverage = diffuseColor.a;
|
|
@@ -7073,17 +7073,17 @@ ${o.uvs.map(g=>`${se(g)} = ${a(r[g]??0)};`).join(`
|
|
|
7073
7073
|
outgoingLight = blenderRadiance / max(blenderAlpha, 1e-4);
|
|
7074
7074
|
#endif
|
|
7075
7075
|
diffuseColor.a = blenderAlpha;
|
|
7076
|
-
}`,!0]);const l=g=>g.replace(/^[ \t]*#include <(\w+)>/gm,(v,O)=>l(Yt[O]??"")),
|
|
7077
|
-
`);let p=t.fragmentShader.replace("void main() {",`${
|
|
7078
|
-
${
|
|
7076
|
+
}`,!0]);const l=g=>g.replace(/^[ \t]*#include <(\w+)>/gm,(v,O)=>l(Yt[O]??"")),i=l(t.fragmentShader.slice(0,t.fragmentShader.indexOf("void main() {"))),u=new Map([...i.matchAll(/^[ \t]*#define[ \t]+(\w+).*$/gm)].map(g=>[g[1],g[0].trim()])),h=[...new Set([...o.declarations.matchAll(/^[ \t]*#define[ \t]+(\w+)/gm)].map(g=>g[1]))].filter(g=>u.has(g)),_=[...h.map(g=>`#undef ${g}`),o.declarations,...h.flatMap(g=>[`#undef ${g}`,u.get(g)])].join(`
|
|
7077
|
+
`);let p=t.fragmentShader.replace("void main() {",`${s}
|
|
7078
|
+
${_}
|
|
7079
7079
|
void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
|
|
7080
7080
|
blenderGraph();`);for(const[g,v,O]of d){if(!p.includes(g))throw new Error(`three's physical shader has no ${g}`);p=p.replace(g,O?`${v}
|
|
7081
7081
|
${g}`:`${g}
|
|
7082
|
-
${v}`)}t.fragmentShader=p}const Zo=new
|
|
7082
|
+
${v}`)}t.fragmentShader=p}const Zo=new te(1,1);function Is(n){n.getDrawingBufferSize(Zo)}function Ds(n,t){const e=t.userData.blenderUvChannels;for(const o of[n.map,n.roughnessMap,n.normalMap]){if(!o)continue;const r=o.userData.blenderUvName;let a=r?e?.[r]:0;if(a===void 0){a=9;const s=t.getAttribute("position")?.count;if(s===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==s&&t.setAttribute("uv9",new ft(new Float32Array(s*2),2))}o.channel!==a&&(o.channel=a,n.needsUpdate=!0)}}class zs{constructor(){this.bindings=new Map}get(t,e,o,r,a=""){let s=this.bindings.get(t);if(!s||s.source!==e){this.delete(t),s={source:e,texture:e.clone(),version:-1,disposed:!1},this.bindings.set(t,s);const d=s;r&&r.then(()=>{d.disposed||(d.texture.needsUpdate=!0,d.version=e.version,ht())},()=>{})}const f=o==="REPEAT"?pa:o==="MIRROR"?ga:So,c=s.texture.wrapS!==f||s.texture.wrapT!==f;return s.texture.wrapS=s.texture.wrapT=f,s.texture.userData.blenderUvName=a,e.image&&(c||s.version!==e.version)&&(s.texture.needsUpdate=!0,s.version=e.version),s.texture}delete(t){const e=this.bindings.get(t);e&&(e.disposed=!0,e.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const At=I().finite(),nn=W([At,At,At]),Cs=R({coat:At,coat_roughness:At,coat_ior:At,coat_tint:nn,sheen:At,sheen_roughness:At,sheen_tint:nn,anisotropy:At,anisotropy_rotation:At,specular_level:At,specular_tint:nn,film_thickness:At,film_ior:At}).strict(),Fs={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},Ct=new WeakMap;function ks(n,t){Ct.has(n)||Dn(n),Ct.get(n).blenderWorldExtinction.value.copy(t)}function Ko(n){const t=new ne,e=Ct.get(n);Dn(t),t.copy(n);const o=Ct.get(t);return e&&(o.blenderCoatIor.value=e.blenderCoatIor.value,o.blenderCoatTint.value.copy(e.blenderCoatTint.value),o.blenderMapClip.value=e.blenderMapClip.value,o.blenderRoughnessClip.value=e.blenderRoughnessClip.value,o.blenderNormalClip.value=e.blenderNormalClip.value,o.blenderWorldExtinction.value.copy(e.blenderWorldExtinction.value)),t}function so(n,t){if(!(n instanceof ne)||!Ct.has(n))return null;const e=t??Ko(n);if(!Ms(n,e))return t||e.dispose(),null;e.copy(n);const o=Ct.get(n),r=Ct.get(e);return r.blenderCoatIor.value=o.blenderCoatIor.value,r.blenderCoatTint.value.copy(o.blenderCoatTint.value),r.blenderMapClip.value=o.blenderMapClip.value,r.blenderRoughnessClip.value=o.blenderRoughnessClip.value,r.blenderNormalClip.value=o.blenderNormalClip.value,r.blenderWorldExtinction.value.copy(o.blenderWorldExtinction.value),e}function Dn(n,t,e={}){const o=t??Fs;n.clearcoat=o.coat,n.clearcoatRoughness=o.coat_roughness,n.sheen=o.sheen,n.sheenRoughness=o.sheen_roughness,n.sheenColor.setRGB(...o.sheen_tint,bt),n.anisotropy=o.anisotropy,n.anisotropyRotation=o.anisotropy_rotation*Math.PI*2,n.specularIntensity=o.specular_level*2,n.specularColor.setRGB(...o.specular_tint,bt),n.iridescence=o.film_thickness>0?1:0,n.iridescenceIOR=o.film_ior,n.iridescenceThicknessRange=[o.film_thickness,o.film_thickness];let r=Ct.get(n);if(!r){r={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new Mt(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new y}},Ct.set(n,r);const a=r;n.customProgramCacheKey=()=>`blender-principled-physical-v5${Ts(n)}`,n.onBeforeRender=(s,f,c,d,l)=>{Ds(n,d),Ps(n,d,s,f,c,l,Ko),Is(s)},n.onBeforeCompile=s=>{const f=new Set([n.map,n.roughnessMap,n.normalMap].flatMap(h=>h?[h.channel]:[]).concat(Ss(n)));s.vertexShader=[...f].filter(h=>h>0).sort((h,_)=>h-_).map(h=>h<=3?`#ifndef USE_UV${h}
|
|
7083
7083
|
attribute vec2 uv${h};
|
|
7084
7084
|
#endif`:`attribute vec2 uv${h};`).join(`
|
|
7085
7085
|
`)+`
|
|
7086
|
-
`+
|
|
7086
|
+
`+s.vertexShader,Object.assign(s.uniforms,a),s.fragmentShader=`uniform float blenderCoatIor;
|
|
7087
7087
|
uniform vec3 blenderWorldExtinction;
|
|
7088
7088
|
vec3 blenderInfiniteTransmission() { return vec3(
|
|
7089
7089
|
blenderWorldExtinction.x>0.?0.:1., blenderWorldExtinction.y>0.?0.:1., blenderWorldExtinction.z>0.?0.:1.); }
|
|
@@ -7094,34 +7094,34 @@ attribute vec2 uv${h};
|
|
|
7094
7094
|
if (clipImage && (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0))))) pixel = vec4(0.0);
|
|
7095
7095
|
return pixel;
|
|
7096
7096
|
}
|
|
7097
|
-
`+
|
|
7097
|
+
`+s.fragmentShader;const c=Yt.lights_physical_fragment.replace("material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );","material.specularF90 = 1.0;").replace("material.clearcoatF0 = vec3( 0.04 );","material.clearcoatF0 = vec3( pow2( ( blenderCoatIor - 1.0 ) / ( blenderCoatIor + 1.0 ) ) );"),d=Yt.normal_fragment_maps.replace("normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;","vec3 blenderBaseNormal = normal; normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; normal.y *= normalScale.y < 0.0 ? -1.0 : 1.0;").replace("normal = normalize( normalMatrix * normal );","normal = normalize(mix(blenderBaseNormal, normalize(normalMatrix * normal), max(0.0, normalScale.x)));").replace("mapN.xy *= normalScale;","mapN.xy *= normalScale; mapN.z = mix(1.0, mapN.z, clamp(normalScale.x, 0.0, 1.0));").replaceAll("texture2D( normalMap, vNormalMapUv )","blenderImageSample(normalMap, vNormalMapUv, blenderNormalClip)"),l=Yt.map_fragment.replace("texture2D( map, vMapUv )","blenderImageSample(map, vMapUv, blenderMapClip)").replace("diffuseColor *= sampledDiffuseColor;","diffuseColor.rgb *= sampledDiffuseColor.rgb;"),i=Yt.roughnessmap_fragment.replace("texture2D( roughnessMap, vRoughnessMapUv )","blenderImageSample(roughnessMap, vRoughnessMapUv, blenderRoughnessClip)"),u=Yt.lights_fragment_begin.replace("getPointLightInfo( pointLight, geometryPosition, directLight );","getPointLightInfo( pointLight, geometryPosition, directLight ); directLight.color *= exp(-blenderWorldExtinction * length(pointLight.position-geometryPosition));").replace("getSpotLightInfo( spotLight, geometryPosition, directLight );","getSpotLightInfo( spotLight, geometryPosition, directLight ); directLight.color *= exp(-blenderWorldExtinction * length(spotLight.position-geometryPosition));").replace("getDirectionalLightInfo( directionalLight, directLight );","getDirectionalLightInfo( directionalLight, directLight ); directLight.color *= blenderInfiniteTransmission();").replace("rectAreaLight = rectAreaLights[ i ];","rectAreaLight = rectAreaLights[ i ]; rectAreaLight.color *= exp(-blenderWorldExtinction * length(rectAreaLight.position-geometryPosition));").replace("getAmbientLightIrradiance( ambientLightColor )","getAmbientLightIrradiance( ambientLightColor ) * blenderInfiniteTransmission()"),m=Yt.lights_fragment_maps.replaceAll(/(getIBL(?:Irradiance|Radiance|AnisotropyRadiance)\([^;]+\))/g,"$1 * blenderInfiniteTransmission()");s.fragmentShader=s.fragmentShader.replace("#include <lights_physical_fragment>",c).replace("#include <lights_fragment_begin>",u).replace("#include <lights_fragment_maps>",m).replace("#include <normal_fragment_maps>",d).replace("#include <map_fragment>",l).replace("#include <roughnessmap_fragment>",i).replace("vec3 Fcc = F_Schlick",`
|
|
7098
7098
|
// Blender's slab_transmittance_at_angle (gpu_shader_material_principled.glsl):
|
|
7099
7099
|
// Beer-Lambert attenuation through a refracting coat at this view angle.
|
|
7100
7100
|
float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
|
|
7101
7101
|
blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
|
|
7102
7102
|
outgoingLight *= mix(vec3(1.0), pow(max(blenderCoatTint, vec3(0.0)), vec3(coatPath)), material.clearcoat);
|
|
7103
|
-
vec3 Fcc = F_Schlick`),
|
|
7104
|
-
`;let g="1.0",v="1.0";if(h instanceof
|
|
7105
|
-
`,v=`smoothstep(cone${
|
|
7106
|
-
`,g=h instanceof
|
|
7103
|
+
vec3 Fcc = F_Schlick`),Rs(n,s)},n.needsUpdate=!0}r.blenderCoatIor.value=Math.max(1,o.coat_ior),r.blenderCoatTint.value.setRGB(...o.coat_tint,bt),r.blenderMapClip.value=e.map===!0,r.blenderRoughnessClip.value=e.roughness===!0,r.blenderNormalClip.value=e.normal===!0}function zn(n){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(n);const e=lt(n)(new y);if(!(typeof e=="number"?[e]:e.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return e}function ae(n){const t=zn(n);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function Ee(n){const t=zn(n);return(typeof t=="number"?new y().setScalar(t):t.clone()).max(new y)}function $s(n){if(n<800)return new y(5.413294490189271,0,0);if(n>=12e3)return new y(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(a=>n>=a).length,e=[[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 y(e[0]/n+e[1]*n+e[2],o[0]/n+o[1]*n+o[2],((r[0]*n+r[1])*n+r[2])*n+r[3]).max(new y)}function io(n){if(!n?.volume?.length)return null;const t={extinction:new y,emission:new y,lobes:[]};for(const e of n.volume){const o=ae(e.weight);if(o===0)continue;const r=Ee(e.color),a=ae(e.density),s=new y,f=new y;if(e.kind==="absorption"&&s.set(1-r.x,1-r.y,1-r.z).max(new y).multiplyScalar(a),e.kind==="scatter"||e.kind==="principled"){f.copy(r).multiplyScalar(a);const c=e.kind==="principled"?"HENYEY_GREENSTEIN":e.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(c))throw new Error(`World volume ${c} phase is not implemented`);const d=zn(e.anisotropy);if(typeof d!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:f.clone().multiplyScalar(o),g:c==="RAYLEIGH"?0:wt.clamp(d,-.999,.999),alpha:c==="RAYLEIGH"?1:c==="DRAINE"?ae(e.alpha):0})}if(e.kind==="principled"){const c=Ee(e.absorption_color);s.set(Math.max(1-r.x,0)*Math.max(1-Math.sqrt(c.x),0),Math.max(1-r.y,0)*Math.max(1-Math.sqrt(c.y),0),Math.max(1-r.z,0)*Math.max(1-Math.sqrt(c.z),0)).multiplyScalar(a);const d=ae(e.blackbody_intensity);if(d>.001){const l=ae(e.temperature),i=5670373e-20/Math.PI*(1+d*(l**4-1));t.emission.add($s(l).multiply(Ee(e.blackbody_tint)).multiplyScalar(i*o))}}(e.kind==="principled"||e.kind==="emission")&&t.emission.add((e.kind==="emission"?r:Ee(e.emission_color)).multiplyScalar(ae(e.emission_strength)*o)),t.extinction.add(s.add(f).multiplyScalar(o))}for(const e of["x","y","z"])if(t.extinction[e]===0&&t.emission[e]>0)throw new Error("Unbounded emissive World volume with zero extinction has divergent radiance");return t}class Ls{constructor(t){this.medium=t,this.target=new va(1,1,{type:An,depthBuffer:!1}),this.geometry=new Po(2,2),this.scene=new xa,this.camera=new ba}render(t,e,o,r){if(!e.depthTexture)throw new Error("World volume render requires surface depth");const a={surface:{value:e.texture},depth:{value:e.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 s="",f="",c=0,d=2;o.traverseVisible(m=>{if(!(m instanceof fn||m instanceof cn||m instanceof ze))return;const h=m,_=c++,p=h.getWorldPosition(new y);a[`lp${_}`]={value:p},a[`lc${_}`]={value:h.color.clone().multiplyScalar(h.intensity)},s+=`uniform vec3 lp${_}, lc${_};
|
|
7104
|
+
`;let g="1.0",v="1.0";if(h instanceof cn&&(a[`ld${_}`]={value:h.target.getWorldPosition(new y).sub(p).normalize()},a[`cone${_}`]={value:new te(Math.cos(h.angle),Math.cos(h.angle*(1-h.penumbra)))},s+=`uniform vec3 ld${_}; uniform vec2 cone${_};
|
|
7105
|
+
`,v=`smoothstep(cone${_}.x, max(cone${_}.x+1e-6,cone${_}.y),dot(-L,ld${_}))`),!(h instanceof ze)&&h.castShadow&&h.shadow.map){if(++d>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");a[`sm${_}`]={value:h.shadow.map.texture},a[`sx${_}`]={value:h.shadow.matrix},a[`ss${_}`]={value:h.shadow.mapSize},a[`sb${_}`]={value:h.shadow.bias},a[`sn${_}`]={value:h.shadow.camera.near},a[`sf${_}`]={value:h.shadow.camera.far},s+=`uniform sampler2D sm${_}; uniform mat4 sx${_}; uniform vec2 ss${_}; uniform float sb${_},sn${_},sf${_};
|
|
7106
|
+
`,g=h instanceof fn?`getPointShadow(sm${_},ss${_},1.0,sb${_},1.0,sx${_}*vec4(p,1.0),sn${_},sf${_})`:`getShadow(sm${_},ss${_},1.0,sb${_},1.0,sx${_}*vec4(p,1.0))`}if(h instanceof ze){const O=new q().extractRotation(h.matrixWorld);a[`lx${_}`]={value:new y(h.width,0,0).applyMatrix4(O)},a[`ly${_}`]={value:new y(0,h.height,0).applyMatrix4(O)},a[`ln${_}`]={value:new y(0,0,-1).transformDirection(O)},s+=`uniform vec3 lx${_},ly${_},ln${_};
|
|
7107
7107
|
`,f+=`for(int ax=0;ax<4;ax++) for(int ay=0;ay<4;ay++) {
|
|
7108
|
-
vec3 delta=lp${
|
|
7108
|
+
vec3 delta=lp${_}+lx${_}*((float(ax)+.5)/4.-.5)+ly${_}*((float(ay)+.5)/4.-.5)-p;
|
|
7109
7109
|
float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7110
|
-
sum+=lc${
|
|
7111
|
-
length(lx${
|
|
7112
|
-
`}else a[`cut${
|
|
7113
|
-
`,f+=`{ vec3 delta=lp${
|
|
7114
|
-
float cutoff=cut${
|
|
7115
|
-
sum+=lc${
|
|
7116
|
-
`});let l="vec3 result=vec3(0.);";this.medium.lobes.forEach((
|
|
7117
|
-
`,l+=`result+=scatter${h}*(1.-g${h}*g${h})*(1.+a${h}*c*c)/(12.56637061436*(1.+a${h}*(1.+2.*g${h}*g${h})/3.)*pow(1.+g${h}*g${h}-2.*g${h}*c,1.5));`});const
|
|
7110
|
+
sum+=lc${_}*exp(-sigma*d)*phase(dot(L,ray))*max(dot(-L,ln${_}),0.)*
|
|
7111
|
+
length(lx${_})*length(ly${_})/(16.*max(d*d,1e-4)); }
|
|
7112
|
+
`}else a[`cut${_}`]={value:h.distance},a[`decay${_}`]={value:h.decay},s+=`uniform float cut${_},decay${_};
|
|
7113
|
+
`,f+=`{ vec3 delta=lp${_}-p; float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7114
|
+
float cutoff=cut${_}>0.?pow(clamp(1.-pow(d/cut${_},4.),0.,1.),2.):1.;
|
|
7115
|
+
sum+=lc${_}*exp(-sigma*d)*phase(dot(L,ray))*${v}*${g}*cutoff/max(pow(d,decay${_}),.01); }
|
|
7116
|
+
`});let l="vec3 result=vec3(0.);";this.medium.lobes.forEach((m,h)=>{a[`scatter${h}`]={value:m.coefficient},a[`g${h}`]={value:m.g},a[`a${h}`]={value:m.alpha},s+=`uniform vec3 scatter${h}; uniform float g${h},a${h};
|
|
7117
|
+
`,l+=`result+=scatter${h}*(1.-g${h}*g${h})*(1.+a${h}*c*c)/(12.56637061436*(1.+a${h}*(1.+2.*g${h}*g${h})/3.)*pow(1.+g${h}*g${h}-2.*g${h}*c,1.5));`});const i=this.medium.extinction.toArray().filter(m=>m>0);a.range={value:i.length?20/Math.min(...i):1},this.material?.dispose(),this.material=new On({uniforms:a,depthTest:!1,depthWrite:!1,toneMapped:!1,defines:{USE_SHADOWMAP:"",NUM_DIR_LIGHT_SHADOWS:0,NUM_SPOT_LIGHT_SHADOWS:0,NUM_POINT_LIGHT_SHADOWS:0,NUM_SPOT_LIGHT_COORDS:0},vertexShader:"varying vec2 vUv; void main(){vUv=uv;gl_Position=vec4(position.xy,0.,1.);}",fragmentShader:`
|
|
7118
7118
|
#include <common>
|
|
7119
7119
|
#include <packing>
|
|
7120
7120
|
#include <shadowmap_pars_fragment>
|
|
7121
7121
|
varying vec2 vUv; uniform sampler2D surface,depth;
|
|
7122
7122
|
uniform mat4 inverseProjection,cameraWorld; uniform bool orthographic;
|
|
7123
7123
|
uniform vec3 sigma,emission; uniform float range;
|
|
7124
|
-
${
|
|
7124
|
+
${s}
|
|
7125
7125
|
vec3 phase(float c){${l} return result;}
|
|
7126
7126
|
vec3 incident(vec3 p,vec3 ray){vec3 sum=vec3(0.);${f}return sum;}
|
|
7127
7127
|
float integral(float s,float d){float x=s*d;return x<.001 ? d*(1.-x*.5+x*x/6.) : (1.-exp(-x))/s;}
|
|
@@ -7144,10 +7144,10 @@ attribute vec2 uv${h};
|
|
|
7144
7144
|
radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
|
|
7145
7145
|
}
|
|
7146
7146
|
gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
|
|
7147
|
-
}`}),this.scene.clear(),this.scene.add(new zt(this.geometry,this.material)),this.target.setSize(e.width,e.height);const u=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(u)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const Us=R({object:D(),group:D(),groupIndex:I().int().nonnegative(),count:I().int().nonnegative(),digest:D(),alertMode:Y(["NONE","ACTIVE","ALL"]),unchanged:X(!0).optional(),weightsBase64:D().optional(),alertBase64:D().optional()}).strict();function Ws(n){const e=n<0?0:n>1?1:n,o=(.5+.5*e)**1.5,[r,a,i]=qs(2/3*(1-e)),f=new Mt;return f.setRGB((r*o)**(1/1.5),(a*o)**(1/1.5),(i*o)**(1/1.5),Ut),f}function qs(n){const t=(n%1+1)%1,e=Math.floor(t*6),o=t*6-e;switch(e%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 Hs=0;function co(n){const t=atob(n),e=new Uint8Array(t.length);for(let o=0;o<t.length;o++)e[o]=t.charCodeAt(o);return e}class Gs{constructor(){this.group=new ct,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,e,o){if(t===null||e===null||!e.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 h=co(t.weightsBase64);this.held={key:r,weights:new Float32Array(h.buffer,h.byteOffset,t.count),alerts:co(t.alertBase64)}}const a=this.held;if(a===null)return null;const i=`${r}:${t.digest}:${e.geometry.uuid}:${t.alertMode}:${o.elements.join(",")}`;if(i===this.signature&&this.mesh!==null)return null;this.signature=i,this.clear();const f=e.geometry.clone(),c=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(c.count*3),s=new Mt().setHex(Hs,Ut);for(let h=0;h<c.count;h++){const m=d.getX(h),g=t.alertMode!=="NONE"&&a.alerts[m]===1?s:Ws(a.weights[m]??0);l[h*3]=g.r,l[h*3+1]=g.g,l[h*3+2]=g.b}f.setAttribute("color",new ft(l,3)),f.deleteAttribute("blenderVertex");const u=new $e({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),_=new zt(f,u);return _.name=`${t.object}:weights`,_.frustumCulled=!1,_.matrixAutoUpdate=!1,_.matrix.copy(o),_.matrix.decompose(_.position,_.quaternion,_.scale),this.geometry=f,this.material=u,this.mesh=_,this.group.add(_),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 Ne=I().finite(),Xs=L(W([Ne,Ne,Ne,Ne])).length(4),Ys=20,uo=[16724818,9165824,2658559];function Zs(n){const t=e=>Math.min(255,Math.max(0,Math.floor(.75*e+63.75)-60))/255;return new Mt().setRGB(t(n>>16&255),t(n>>8&255),t(n&255),Ut)}function Qo(){return new ya({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function Qs(){const n=[],t=[],e=new Mt(0,0,0),o=(a,i,f,c,d)=>{for(const l of[a,i]){const s=[0,0,0];s[f]=l*c,n.push(...s),t.push(d.r,d.g,d.b)}};for(let a=0;a<3;a++){const i=new Mt().setHex(uo[a],Ut);o(1,.85,a,1,i),o(.85,.25,a,1,e),o(1,.85,a,-1,Zs(uo[a])),o(.85,.25,a,-1,e)}const r=new ee;return r.setAttribute("position",new Nt(n,3)),r.setAttribute("color",new Nt(t,3)),new No(r,Qo())}function Ks(){const t=[],e=[],o=new Mt(1,0,0),r=new Mt(1,1,1);for(let i=0;i<12;i++){const f=(i+1)%2===0?r:o;for(const c of[i,i+1]){const d=2*Math.PI*c/12;t.push(.5*Math.cos(d),.5*Math.sin(d),0),e.push(f.r,f.g,f.b)}}const a=new ee;return a.setAttribute("position",new Nt(t,3)),a.setAttribute("color",new Nt(e,3)),new No(a,Qo())}class Js{constructor(){this.group=new ct,this.anchor=new ct,this.lines=Qs(),this.circle=Ks(),this.seen=null,this.size=new Jt,this.scratch=new y,this.parentQuat=new St,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,e,o)=>this.fit(t,o),this.circle.onBeforeRender=(t,e,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[e,o,r,a]=t.rotation;this.anchor.matrix.compose(new y(...t.location),new St(o,r,a,e),new y(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,e){this.seen={camera:e,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(e.isOrthographicCamera){const f=e;a=(f.top-f.bottom)/f.zoom/o}else{const f=e;a=2*Math.max(-r.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(f.fov)/2)/f.zoom/o}const i=a*Ys;this.lines.scale.setScalar(i),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(i),this.circle.updateMatrixWorld(!0)}placementAt(t,e,o,r,a){const i=this.seen;if(i===null||o!==i.canvas)return null;const f=i.canvas.getBoundingClientRect(),c=new Jt((t-f.left)/Math.max(f.width,1)*2-1,-((e-f.top)/Math.max(f.height,1))*2+1),d=new ba;d.setFromCamera(c,i.camera);const l=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},s=d.intersectObject(r,!0).find(m=>m.object.isMesh&&a(m.object)&&l(m.object));let u=s?s.point.clone():null;if(u===null){const m=new y().setFromMatrixPosition(this.anchor.matrixWorld),p=i.camera.getWorldDirection(new y),g=i.camera.getWorldPosition(new y),v=m.clone().sub(g).dot(p);v<=0&&m.addScaledVector(p,-2*v+(v===0?1:0)),u=d.ray.intersectPlane(new Xt().setFromNormalAndCoplanarPoint(p,m),new y)}if(u===null)return null;r.updateWorldMatrix(!0,!1);const _=r.worldToLocal(u),h=r.getWorldQuaternion(new St).invert().multiply(i.camera.getWorldQuaternion(new St));return{location:[_.x,_.y,_.z],rotation:[h.w,h.x,h.y,h.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Gt=I().finite(),ti=R({display:Y(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Gt,image:R({name:D().nullable(),offset:W([Gt,Gt]),depth:Y(["DEFAULT","FRONT","BACK"]),side:Y(["DOUBLE_SIDED","FRONT","BACK"]),perspective:at(),orthographic:at(),axis_aligned:at(),opacity:Gt.nullable(),tint:W([Gt,Gt,Gt]).default([1,1,1]),premultiplied:at().default(!1)}).optional()}),It={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},ei=1,st=(n,t,e)=>n.push(t[0],t[1],t[2],e[0],e[1],e[2]);function ht(n,t){return Array.from({length:t},(e,o)=>{const r=2*Math.PI*o/t;return[n*Math.cos(r),n*Math.sin(r)]})}function yt(n,t,e=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];st(n,[i[0],i[1],e],[f[0],f[1],e])}}function ni(n){if(!n.isMesh||n.userData.volterOverrideStandDown)return;n.userData.volterOverrideStandDown=!0;const t=n.onBeforeRender.bind(n),e=n.onAfterRender.bind(n),o=new q;let r=!1;n.onBeforeRender=(a,i,f,c,d,l)=>{t(a,i,f,c,d,l),i.overrideMaterial&&(o.copy(n.matrixWorld),n.matrixWorld.makeScale(0,0,0),r=!0)},n.onAfterRender=(a,i,f,c,d,l)=>{r&&(n.matrixWorld.copy(o),r=!1),e(a,i,f,c,d,l)}}class oi{constructor(){this.cameras=new ct,this.lights=new ct,this.empties=new ct,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new y,this.size=new Jt,this.parentQuat=new St,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const e=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;e.add(o.name);const c=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,c,f,a?[o.name===t.sceneCamera,t.renderAspect]:null]),s=this.drawn.get(o.name),u=t.presented(o.name);if(s?.key===l){for(const g of s.parts)g.userData.volterPicksAs=u;continue}s&&this.remove(s.parts);const _=new q().set(...o.matrix.flat()),h=a?this.cameras:i?this.lights:this.empties,m=new Set(h.children);a?this.camera(a,_,r,o.name===t.sceneCamera,t.renderAspect):i?this.light(i,_,r,c):f&&this.empty(f,_,r,d);const p=h.children.filter(g=>!m.has(g));for(const g of p)g.userData.volterPicksAs=u,g.traverse(ni);this.drawn.set(o.name,{key:l,parts:p})}for(const[o,r]of this.drawn)e.has(o)||(this.remove(r.parts),this.drawn.delete(o))}remove(t){for(const e of t)e.removeFromParent(),e.geometry?.dispose(),e.userData.volterOwnMaterial&&e.material.dispose()}camera(t,e,o,r,a){const i=t.display_size,c=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let d,l,s,u;if(t.type==="ORTHO")s=[.5*t.ortho_scale*c[0],.5*t.ortho_scale*c[1]],u=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],l=-i,d=.5*t.ortho_scale;else{const A=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),M=new y().setFromMatrixScale(e);if(M.x===0||M.y===0||M.z===0)return;d=i/2/((1/M.x+1/M.y+1/M.z)/3),l=d*t.lens/-A,s=[d*c[0],d*c[1]],u=[t.shift_x*d*2,t.shift_y*d*2]}const _=[[u[0]+s[0],u[1]+s[1],l],[u[0]+s[0],u[1]-s[1],l],[u[0]-s[0],u[1]-s[1],l],[u[0]-s[0],u[1]+s[1],l]],h=[];for(let A=0;A<4;A++)st(h,_[A],_[(A+1)%4]),st(h,_[A],[0,0,0]);const m=.7*d,p=.1*d,g=u[1]+s[1]+p,v=[[u[0]-m,g,l],[u[0]+m,g,l],[u[0],g+m,l]],O=ln(e);this.cameras.add(this.lines(h,o,1,O));let b;if(r){const A=new ee;A.setAttribute("position",new Nt(v.flat(),3)),b=new zt(A,this.fill(o)),b.matrixAutoUpdate=!1,b.matrix.copy(O)}else{const A=[];for(let M=0;M<3;M++)st(A,v[M],v[(M+1)%3]);b=this.lines(A,o,1,O)}const S=new y,w=b.onBeforeRender.bind(b);b.onBeforeRender=(A,M,E,C,V,H)=>{S.setFromMatrixPosition(O).applyMatrix4(this.cameras.matrixWorld);const tt=E.getWorldPosition(this.scratch).distanceToSquared(S)>1e-8;b.matrix.copy(O),tt||b.matrix.scale(new y(0,0,0)),b.updateMatrixWorld(!0),w(A,M,E,C,V,H)},this.cameras.add(b)}light(t,e,o,r){const a=new y().setFromMatrixPosition(e),i=[];st(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,ht(1.35,4)),this.lights.add(this.screen(f,It.light,It.lightAlpha,new y(a.x,a.y,0)));const c=[],d=9;if(yt(c,ht(d*.3,4)),yt(c,ht(d,16),0,!0),yt(c,ht(d*1.33,20),0,!0),t.type==="SUN")for(const[u,_]of ht(d,8))st(c,[u*1.6,_*1.6,0],[u*1.9,_*1.9,0]),st(c,[u*2.2,_*2.2,0],[u*2.5,_*2.5,0]);this.lights.add(this.screen(c,o,1,a));const l=ln(e),s=[];if(t.type==="SUN")st(s,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const u=(t.size??1)/2,_=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?yt(s,ht(1,32).map(([h,m])=>[h*u,m*_])):yt(s,[[u,_],[-u,_],[-u,-_],[u,-_]])}if(s.length>0&&this.lights.add(this.lines(s,o,1,e.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const u=new y(0,0,-1).transformDirection(e),_=g=>a.clone().addScaledVector(u,g),[h,m]=r,p=[];st(p,_(h).toArray(),_(m).toArray()),this.lights.add(this.lines(p,o,1,new q));for(const g of[h,m]){const v=[];yt(v,ht(1.2,4)),this.lights.add(this.screen(v,o,1,_(g)))}}if(t.type==="SPOT"){const u=(t.spot_size??Math.PI/4)/2,_=Math.cos(u),h=t.spot_blend??.15,m=_*h-_-h,p=Math.sqrt((_*_-_*_*m*m)/(m*m-_*_*m*m)),g=Math.sqrt(1-_*_),v=ln(e).multiply(new q().makeScale(10,10,10)),O=[];yt(O,ht(g,32),-_),yt(O,ht(g*p,32),-_),this.lights.add(this.lines(O,o,1,v.clone())),this.lights.add(this.silhouette(g,_,o,v))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const u=[];yt(u,ht(t.radius,32)),this.lights.add(this.facing(u,o,new y().setFromMatrixPosition(l)))}}empty(t,e,o,r){const a=t.size,i=[],f=(d,l)=>{const s=ht(1,l);for(let u=0;u<l;u++){const[_,h]=s[u],[m,p]=s[(u+1)%l],g=(v,O)=>d==="xy"?[v,O,0]:d==="xz"?[v,0,O]:[0,v,O];st(i,g(_,h),g(m,p))}};switch(t.display){case"PLAIN_AXES":st(i,[0,-1,0],[0,1,0]),st(i,[-1,0,0],[1,0,0]),st(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{st(i,[0,0,0],[0,0,.75]);for(const[d,l]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])st(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 ai)st(i,mo[d],mo[l]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const d=ht(1,8);for(let l=0;l<8;l++){const[s,u]=d[l],[_,h]=d[(l+1)%8];st(i,[s,0,u],[0,2,0]),st(i,[s,0,u],[_,0,h])}break}case"ARROWS":for(let d=0;d<3;d++){const l=[0,0,0];l[d]=1,st(i,[0,0,0],l)}break;case"IMAGE":this.imageEmpty(t,e,o,r);return}const c=e.clone().multiply(new q().makeScale(a,a,a));this.empties.add(this.lines(i,o,1,c)),t.display==="ARROWS"&&this.axisNames(e,a,o)}silhouette(t,e,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=ht(1,32).map(([_,h])=>new y(_*t,h*t,-e)),c=new y,d=new q,l=new y,s=new y,u=new y;return this.onDraw(a,(_,h)=>{d.copy(a.matrixWorld).invert();const m=h.isOrthographicCamera;m?h.getWorldDirection(c).negate().transformDirection(d):c.setFromMatrixPosition(h.matrixWorld).applyMatrix4(d);const p=i.array;let g=!1;for(let v=0;v<32;v++){const O=f[v];l.crossVectors(O,f[(v+31)%32]),s.crossVectors(f[(v+1)%32],O),m?u.copy(c):u.copy(c).sub(O);const b=l.dot(u)>0!=s.dot(u)>0;(p[v*6+3]!==0||p[v*6+5]!==0)!==b&&(g=!0),p.set([0,0,0,b?O.x:0,b?O.y:0,b?O.z:0],v*6)}g&&(i.needsUpdate=!0,_t())}),a}imageEmpty(t,e,o,r){const a=t.image;if(!a)return;const i=r?.width??0,f=r?.height??0,c=i>0&&f>0?i>=f?[1,f/i]:[i/f,1]:[1,1],d=new y,l=new y,s=new y;e.extractBasis(d,l,s),d.multiplyScalar(c[0]*.5*t.size),l.multiplyScalar(c[1]*.5*t.size);const u=new y().setFromMatrixPosition(e).addScaledVector(d,a.offset[0]*2+1).addScaledVector(l,a.offset[1]*2+1),_=new q().makeBasis(d,l,s.clone()).setPosition(u),h=[];yt(h,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(h,o,1,_),p=s.clone().normalize(),g=new y,v=new y,O=(E,C)=>{const V=E.isOrthographicCamera===!0;if(V?!a.orthographic:!a.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);E.getWorldDirection(v);let tt,Z;if(V)tt=H.dot(v.clone().negate()),Z=1e-5;else{const nt=u.clone().applyMatrix4(this.empties.matrixWorld);tt=H.dot(g.setFromMatrixPosition(E.matrixWorld).sub(nt)),Z=0}return!(a.side==="FRONT"&&tt<Z||a.side==="BACK"&&tt>-Z||a.axis_aligned&&H.clone().projectOnPlane(v).lengthSq()>1e-5)},b=(E,C)=>{const V=E.onBeforeRender.bind(E);E.onBeforeRender=(H,tt,Z,nt,x,N)=>{E.matrix.copy(_),O(Z,C)||E.matrix.scale(new y(0,0,0)),E.updateMatrixWorld(!0),V(H,tt,Z,nt,x,N)}};if(b(m,!1),this.empties.add(m),!r||a.opacity!==null&&a.opacity<=0)return;const S=a.opacity!==null,w=a.depth==="BACK",A=new $e({map:r.texture,side:je,transparent:S&&!w,opacity:a.opacity??1,alphaTest:S?0:.05,toneMapped:!1,depthTest:a.depth==="DEFAULT",depthWrite:a.depth==="DEFAULT"&&!S});A.color.setRGB(...a.tint,bt),S&&w&&(A.blending=wa,A.blendSrc=Oa,A.blendDst=Aa),A.onBeforeCompile=E=>{const C=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7147
|
+
}`}),this.scene.clear(),this.scene.add(new Ft(this.geometry,this.material)),this.target.setSize(e.width,e.height);const u=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(u)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const js=R({object:D(),group:D(),groupIndex:I().int().nonnegative(),count:I().int().nonnegative(),digest:D(),alertMode:Y(["NONE","ACTIVE","ALL"]),unchanged:X(!0).optional(),weightsBase64:D().optional(),alertBase64:D().optional()}).strict();function Vs(n){const e=n<0?0:n>1?1:n,o=(.5+.5*e)**1.5,[r,a,s]=Bs(2/3*(1-e)),f=new Mt;return f.setRGB((r*o)**(1/1.5),(a*o)**(1/1.5),(s*o)**(1/1.5),Ut),f}function Bs(n){const t=(n%1+1)%1,e=Math.floor(t*6),o=t*6-e;switch(e%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 Us=0;function lo(n){const t=atob(n),e=new Uint8Array(t.length);for(let o=0;o<t.length;o++)e[o]=t.charCodeAt(o);return e}class Ws{constructor(){this.group=new ct,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,e,o){if(t===null||e===null||!e.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 h=lo(t.weightsBase64);this.held={key:r,weights:new Float32Array(h.buffer,h.byteOffset,t.count),alerts:lo(t.alertBase64)}}const a=this.held;if(a===null)return null;const s=`${r}:${t.digest}:${e.geometry.uuid}:${t.alertMode}:${o.elements.join(",")}`;if(s===this.signature&&this.mesh!==null)return null;this.signature=s,this.clear();const f=e.geometry.clone(),c=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(c.count*3),i=new Mt().setHex(Us,Ut);for(let h=0;h<c.count;h++){const _=d.getX(h),g=t.alertMode!=="NONE"&&a.alerts[_]===1?i:Vs(a.weights[_]??0);l[h*3]=g.r,l[h*3+1]=g.g,l[h*3+2]=g.b}f.setAttribute("color",new ft(l,3)),f.deleteAttribute("blenderVertex");const u=new ke({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),m=new Ft(f,u);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=u,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 Ne=I().finite(),qs=L(W([Ne,Ne,Ne,Ne])).length(4),Hs=20,fo=[16724818,9165824,2658559];function Gs(n){const t=e=>Math.min(255,Math.max(0,Math.floor(.75*e+63.75)-60))/255;return new Mt().setRGB(t(n>>16&255),t(n>>8&255),t(n&255),Ut)}function Qo(){return new wa({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function Xs(){const n=[],t=[],e=new Mt(0,0,0),o=(a,s,f,c,d)=>{for(const l of[a,s]){const i=[0,0,0];i[f]=l*c,n.push(...i),t.push(d.r,d.g,d.b)}};for(let a=0;a<3;a++){const s=new Mt().setHex(fo[a],Ut);o(1,.85,a,1,s),o(.85,.25,a,1,e),o(1,.85,a,-1,Gs(fo[a])),o(.85,.25,a,-1,e)}const r=new oe;return r.setAttribute("position",new Nt(n,3)),r.setAttribute("color",new Nt(t,3)),new Eo(r,Qo())}function Ys(){const t=[],e=[],o=new Mt(1,0,0),r=new Mt(1,1,1);for(let s=0;s<12;s++){const f=(s+1)%2===0?r:o;for(const c of[s,s+1]){const d=2*Math.PI*c/12;t.push(.5*Math.cos(d),.5*Math.sin(d),0),e.push(f.r,f.g,f.b)}}const a=new oe;return a.setAttribute("position",new Nt(t,3)),a.setAttribute("color",new Nt(e,3)),new Eo(a,Qo())}class Zs{constructor(){this.group=new ct,this.anchor=new ct,this.lines=Xs(),this.circle=Ys(),this.seen=null,this.size=new te,this.scratch=new y,this.parentQuat=new St,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,e,o)=>this.fit(t,o),this.circle.onBeforeRender=(t,e,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[e,o,r,a]=t.rotation;this.anchor.matrix.compose(new y(...t.location),new St(o,r,a,e),new y(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,e){this.seen={camera:e,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(e.isOrthographicCamera){const f=e;a=(f.top-f.bottom)/f.zoom/o}else{const f=e;a=2*Math.max(-r.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(f.fov)/2)/f.zoom/o}const s=a*Hs;this.lines.scale.setScalar(s),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(s),this.circle.updateMatrixWorld(!0)}placementAt(t,e,o,r,a){const s=this.seen;if(s===null||o!==s.canvas)return null;const f=s.canvas.getBoundingClientRect(),c=new te((t-f.left)/Math.max(f.width,1)*2-1,-((e-f.top)/Math.max(f.height,1))*2+1),d=new ya;d.setFromCamera(c,s.camera);const l=_=>{for(let p=_;p!==null;p=p.parent)if(!p.visible)return!1;return!0},i=d.intersectObject(r,!0).find(_=>_.object.isMesh&&a(_.object)&&l(_.object));let u=i?i.point.clone():null;if(u===null){const _=new y().setFromMatrixPosition(this.anchor.matrixWorld),p=s.camera.getWorldDirection(new y),g=s.camera.getWorldPosition(new y),v=_.clone().sub(g).dot(p);v<=0&&_.addScaledVector(p,-2*v+(v===0?1:0)),u=d.ray.intersectPlane(new Xt().setFromNormalAndCoplanarPoint(p,_),new y)}if(u===null)return null;r.updateWorldMatrix(!0,!1);const m=r.worldToLocal(u),h=r.getWorldQuaternion(new St).invert().multiply(s.camera.getWorldQuaternion(new St));return{location:[m.x,m.y,m.z],rotation:[h.w,h.x,h.y,h.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Gt=I().finite(),Ks=R({display:Y(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Gt,image:R({name:D().nullable(),offset:W([Gt,Gt]),depth:Y(["DEFAULT","FRONT","BACK"]),side:Y(["DOUBLE_SIDED","FRONT","BACK"]),perspective:at(),orthographic:at(),axis_aligned:at(),opacity:Gt.nullable(),tint:W([Gt,Gt,Gt]).default([1,1,1]),premultiplied:at().default(!1)}).optional()}),It={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},Qs=1,st=(n,t,e)=>n.push(t[0],t[1],t[2],e[0],e[1],e[2]);function pt(n,t){return Array.from({length:t},(e,o)=>{const r=2*Math.PI*o/t;return[n*Math.cos(r),n*Math.sin(r)]})}function yt(n,t,e=0,o=!1){const r=o?2:1;for(let a=0;a<Math.floor(t.length/r);a++){const s=t[a*r%t.length],f=t[(a*r+1)%t.length];st(n,[s[0],s[1],e],[f[0],f[1],e])}}function Js(n){if(!n.isMesh||n.userData.volterOverrideStandDown)return;n.userData.volterOverrideStandDown=!0;const t=n.onBeforeRender.bind(n),e=n.onAfterRender.bind(n),o=new q;let r=!1;n.onBeforeRender=(a,s,f,c,d,l)=>{t(a,s,f,c,d,l),s.overrideMaterial&&(o.copy(n.matrixWorld),n.matrixWorld.makeScale(0,0,0),r=!0)},n.onAfterRender=(a,s,f,c,d,l)=>{r&&(n.matrixWorld.copy(o),r=!1),e(a,s,f,c,d,l)}}class ti{constructor(){this.cameras=new ct,this.lights=new ct,this.empties=new ct,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new y,this.size=new te,this.parentQuat=new St,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const e=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,s=o.type==="LIGHT"&&o.light?t.lights[o.light]:void 0,f=o.type==="EMPTY"?t.empties[o.name]:void 0;if(!a&&!s&&!f)continue;e.add(o.name);const c=s&&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,s,c,f,a?[o.name===t.sceneCamera,t.renderAspect]:null]),i=this.drawn.get(o.name),u=t.presented(o.name);if(i?.key===l){for(const g of i.parts)g.userData.volterPicksAs=u;continue}i&&this.remove(i.parts);const m=new q().set(...o.matrix.flat()),h=a?this.cameras:s?this.lights:this.empties,_=new Set(h.children);a?this.camera(a,m,r,o.name===t.sceneCamera,t.renderAspect):s?this.light(s,m,r,c):f&&this.empty(f,m,r,d);const p=h.children.filter(g=>!_.has(g));for(const g of p)g.userData.volterPicksAs=u,g.traverse(Js);this.drawn.set(o.name,{key:l,parts:p})}for(const[o,r]of this.drawn)e.has(o)||(this.remove(r.parts),this.drawn.delete(o))}remove(t){for(const e of t)e.removeFromParent(),e.geometry?.dispose(),e.userData.volterOwnMaterial&&e.material.dispose()}camera(t,e,o,r,a){const s=t.display_size,c=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let d,l,i,u;if(t.type==="ORTHO")i=[.5*t.ortho_scale*c[0],.5*t.ortho_scale*c[1]],u=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],l=-s,d=.5*t.ortho_scale;else{const A=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),M=new y().setFromMatrixScale(e);if(M.x===0||M.y===0||M.z===0)return;d=s/2/((1/M.x+1/M.y+1/M.z)/3),l=d*t.lens/-A,i=[d*c[0],d*c[1]],u=[t.shift_x*d*2,t.shift_y*d*2]}const m=[[u[0]+i[0],u[1]+i[1],l],[u[0]+i[0],u[1]-i[1],l],[u[0]-i[0],u[1]-i[1],l],[u[0]-i[0],u[1]+i[1],l]],h=[];for(let A=0;A<4;A++)st(h,m[A],m[(A+1)%4]),st(h,m[A],[0,0,0]);const _=.7*d,p=.1*d,g=u[1]+i[1]+p,v=[[u[0]-_,g,l],[u[0]+_,g,l],[u[0],g+_,l]],O=on(e);this.cameras.add(this.lines(h,o,1,O));let b;if(r){const A=new oe;A.setAttribute("position",new Nt(v.flat(),3)),b=new Ft(A,this.fill(o)),b.matrixAutoUpdate=!1,b.matrix.copy(O)}else{const A=[];for(let M=0;M<3;M++)st(A,v[M],v[(M+1)%3]);b=this.lines(A,o,1,O)}const S=new y,w=b.onBeforeRender.bind(b);b.onBeforeRender=(A,M,E,F,V,H)=>{S.setFromMatrixPosition(O).applyMatrix4(this.cameras.matrixWorld);const tt=E.getWorldPosition(this.scratch).distanceToSquared(S)>1e-8;b.matrix.copy(O),tt||b.matrix.scale(new y(0,0,0)),b.updateMatrixWorld(!0),w(A,M,E,F,V,H)},this.cameras.add(b)}light(t,e,o,r){const a=new y().setFromMatrixPosition(e),s=[];st(s,[a.x,a.y,a.z],[a.x,a.y,0]),this.lights.add(this.lines(s,It.light,It.lightAlpha,new q));const f=[];yt(f,pt(1.35,4)),this.lights.add(this.screen(f,It.light,It.lightAlpha,new y(a.x,a.y,0)));const c=[],d=9;if(yt(c,pt(d*.3,4)),yt(c,pt(d,16),0,!0),yt(c,pt(d*1.33,20),0,!0),t.type==="SUN")for(const[u,m]of pt(d,8))st(c,[u*1.6,m*1.6,0],[u*1.9,m*1.9,0]),st(c,[u*2.2,m*2.2,0],[u*2.5,m*2.5,0]);this.lights.add(this.screen(c,o,1,a));const l=on(e),i=[];if(t.type==="SUN")st(i,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const u=(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(i,pt(1,32).map(([h,_])=>[h*u,_*m])):yt(i,[[u,m],[-u,m],[-u,-m],[u,-m]])}if(i.length>0&&this.lights.add(this.lines(i,o,1,e.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const u=new y(0,0,-1).transformDirection(e),m=g=>a.clone().addScaledVector(u,g),[h,_]=r,p=[];st(p,m(h).toArray(),m(_).toArray()),this.lights.add(this.lines(p,o,1,new q));for(const g of[h,_]){const v=[];yt(v,pt(1.2,4)),this.lights.add(this.screen(v,o,1,m(g)))}}if(t.type==="SPOT"){const u=(t.spot_size??Math.PI/4)/2,m=Math.cos(u),h=t.spot_blend??.15,_=m*h-m-h,p=Math.sqrt((m*m-m*m*_*_)/(_*_-m*m*_*_)),g=Math.sqrt(1-m*m),v=on(e).multiply(new q().makeScale(10,10,10)),O=[];yt(O,pt(g,32),-m),yt(O,pt(g*p,32),-m),this.lights.add(this.lines(O,o,1,v.clone())),this.lights.add(this.silhouette(g,m,o,v))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const u=[];yt(u,pt(t.radius,32)),this.lights.add(this.facing(u,o,new y().setFromMatrixPosition(l)))}}empty(t,e,o,r){const a=t.size,s=[],f=(d,l)=>{const i=pt(1,l);for(let u=0;u<l;u++){const[m,h]=i[u],[_,p]=i[(u+1)%l],g=(v,O)=>d==="xy"?[v,O,0]:d==="xz"?[v,0,O]:[0,v,O];st(s,g(m,h),g(_,p))}};switch(t.display){case"PLAIN_AXES":st(s,[0,-1,0],[0,1,0]),st(s,[-1,0,0],[1,0,0]),st(s,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{st(s,[0,0,0],[0,0,.75]);for(const[d,l]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])st(s,[0,0,1],[d,l,.75]);yt(s,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[d,l]of ei)st(s,co[d],co[l]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const d=pt(1,8);for(let l=0;l<8;l++){const[i,u]=d[l],[m,h]=d[(l+1)%8];st(s,[i,0,u],[0,2,0]),st(s,[i,0,u],[m,0,h])}break}case"ARROWS":for(let d=0;d<3;d++){const l=[0,0,0];l[d]=1,st(s,[0,0,0],l)}break;case"IMAGE":this.imageEmpty(t,e,o,r);return}const c=e.clone().multiply(new q().makeScale(a,a,a));this.empties.add(this.lines(s,o,1,c)),t.display==="ARROWS"&&this.axisNames(e,a,o)}silhouette(t,e,o,r){const a=this.lines(new Array(192).fill(0),o,1,r);a.frustumCulled=!1;const s=a.geometry.getAttribute("instanceStart").data,f=pt(1,32).map(([m,h])=>new y(m*t,h*t,-e)),c=new y,d=new q,l=new y,i=new y,u=new y;return this.onDraw(a,(m,h)=>{d.copy(a.matrixWorld).invert();const _=h.isOrthographicCamera;_?h.getWorldDirection(c).negate().transformDirection(d):c.setFromMatrixPosition(h.matrixWorld).applyMatrix4(d);const p=s.array;let g=!1;for(let v=0;v<32;v++){const O=f[v];l.crossVectors(O,f[(v+31)%32]),i.crossVectors(f[(v+1)%32],O),_?u.copy(c):u.copy(c).sub(O);const b=l.dot(u)>0!=i.dot(u)>0;(p[v*6+3]!==0||p[v*6+5]!==0)!==b&&(g=!0),p.set([0,0,0,b?O.x:0,b?O.y:0,b?O.z:0],v*6)}g&&(s.needsUpdate=!0,ht())}),a}imageEmpty(t,e,o,r){const a=t.image;if(!a)return;const s=r?.width??0,f=r?.height??0,c=s>0&&f>0?s>=f?[1,f/s]:[s/f,1]:[1,1],d=new y,l=new y,i=new y;e.extractBasis(d,l,i),d.multiplyScalar(c[0]*.5*t.size),l.multiplyScalar(c[1]*.5*t.size);const u=new y().setFromMatrixPosition(e).addScaledVector(d,a.offset[0]*2+1).addScaledVector(l,a.offset[1]*2+1),m=new q().makeBasis(d,l,i.clone()).setPosition(u),h=[];yt(h,[[-1,-1],[1,-1],[1,1],[-1,1]]);const _=this.lines(h,o,1,m),p=i.clone().normalize(),g=new y,v=new y,O=(E,F)=>{const V=E.isOrthographicCamera===!0;if(V?!a.orthographic:!a.perspective)return!1;if(!F)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);E.getWorldDirection(v);let tt,Z;if(V)tt=H.dot(v.clone().negate()),Z=1e-5;else{const nt=u.clone().applyMatrix4(this.empties.matrixWorld);tt=H.dot(g.setFromMatrixPosition(E.matrixWorld).sub(nt)),Z=0}return!(a.side==="FRONT"&&tt<Z||a.side==="BACK"&&tt>-Z||a.axis_aligned&&H.clone().projectOnPlane(v).lengthSq()>1e-5)},b=(E,F)=>{const V=E.onBeforeRender.bind(E);E.onBeforeRender=(H,tt,Z,nt,x,N)=>{E.matrix.copy(m),O(Z,F)||E.matrix.scale(new y(0,0,0)),E.updateMatrixWorld(!0),V(H,tt,Z,nt,x,N)}};if(b(_,!1),this.empties.add(_),!r||a.opacity!==null&&a.opacity<=0)return;const S=a.opacity!==null,w=a.depth==="BACK",A=new ke({map:r.texture,side:$e,transparent:S&&!w,opacity:a.opacity??1,alphaTest:S?0:.05,toneMapped:!1,depthTest:a.depth==="DEFAULT",depthWrite:a.depth==="DEFAULT"&&!S});A.color.setRGB(...a.tint,bt),S&&w&&(A.blending=Oa,A.blendSrc=Aa,A.blendDst=Ma),A.onBeforeCompile=E=>{const F=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7148
7148
|
`:"";E.fragmentShader=E.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
7149
|
-
${
|
|
7150
|
-
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${a.premultiplied}:${S}`;const M=new
|
|
7149
|
+
${F}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",S?"#include <alphatest_fragment>":`#include <alphatest_fragment>
|
|
7150
|
+
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${a.premultiplied}:${S}`;const M=new Ft(new Po(2,2),A);M.matrixAutoUpdate=!1,M.matrix.copy(m),M.renderOrder=a.depth==="FRONT"?1e3:a.depth==="BACK"?-1e3:0,M.userData.volterOwnMaterial=!0,b(M,!0),this.empties.add(M)}axisNames(t,e,o){const r=[new y,new y,new y];t.extractBasis(r[0],r[1],r[2]);for(let a=0;a<3;a++){const s=r[a].length()*e,f=new y(0,0,0);f.setComponent(a,1.25*e),f.applyMatrix4(t);const c=new y(0,0,0);c.setComponent(a,e),c.applyMatrix4(t);const d=[];for(let u=1;u<=6;u++)yt(d,pt(.007*(4*u/6)*s,4));this.empties.add(this.facing(d,o,c));const l=ni[a],i=[];for(let u=0;u+1<l.length;u+=2){const[m,h]=l[u],[_,p]=l[u+1];st(i,[m*4*s,h*4*s,0],[_*4*s,p*4*s,0])}this.empties.add(this.facing(i,o,f))}}material(t,e){const o=`${t}:${e}`;let r=this.lineMaterials.get(o);return r||(r=new yo({color:t,linewidth:Qs,transparent:e<1,opacity:e,depthTest:!0,depthWrite:e>=1,toneMapped:!1}),this.lineMaterials.set(o,r)),r}fill(t){let e=this.fillMaterials.get(t);return e||(e=new ke({color:t,side:$e,toneMapped:!1}),this.fillMaterials.set(t,e)),e}lines(t,e,o,r){const a=new bo().setPositions(t),s=new wo(a,this.material(e,o));return s.matrixAutoUpdate=!1,s.matrix.copy(r),s.computeLineDistances(),s}screen(t,e,o,r){const a=this.lines(t,e,o,new q);return a.matrixAutoUpdate=!0,a.position.copy(r),a.scale.setScalar(0),a.frustumCulled=!1,this.onDraw(a,(s,f)=>this.face(a,s,f,!0)),a}facing(t,e,o){const r=this.lines(t,e,1,new q);return r.matrixAutoUpdate=!0,r.position.copy(o),this.onDraw(r,(a,s)=>this.face(r,a,s,!1)),r}onDraw(t,e){const o=t,r=o.onBeforeRender.bind(o);o.onBeforeRender=(a,s,f,c,d,l)=>{e(a,f),r(a,s,f,c,d,l)}}face(t,e,o,r){t.parent?.getWorldQuaternion(this.parentQuat).invert(),o.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let a=1;if(r){e.getSize(this.size);const s=Math.max(this.size.y,1),f=this.scratch.setFromMatrixPosition(t.matrixWorld);if(o.isOrthographicCamera){const c=o;a=(c.top-c.bottom)/c.zoom/s}else{const c=o;a=2*Math.max(-f.applyMatrix4(o.matrixWorldInverse).z,1e-6)*Math.tan(wt.degToRad(c.fov)/2)/c.zoom/s}}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 on(n){const t=new y,e=new St;return n.decompose(t,e,new y),new q().compose(t,e,new y(1,1,1))}const co=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],ei=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],ni=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([n,t])=>[n*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([n,t])=>[n*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([n,t])=>[n*.02,t*.025])],gt=I().finite(),uo=R({name:D(),type:D(),lens:gt,sensor_width:gt,sensor_height:gt,sensor_fit:Y(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:gt,clip_start:gt,clip_end:gt,shift_x:gt,shift_y:gt,matrix:L(W([gt,gt,gt,gt])).length(4),passepartout:gt.default(0),display_size:gt.default(1)}),oi={opening:.5,min:.1657359312880715,max:44.98528137423857},Re={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function ai(n,t,e,o){const r=a=>Math.min(1,Math.max(-1,a));return[r(n[0]-e/(2*t)),r(n[1]+o/(2*t))]}function mo(n,t,e,o){const r=n.type==="ORTHO",a=n.sensor_fit==="VERTICAL"?n.sensor_height:n.sensor_width,s=n.sensor_fit==="AUTO"?t>=e:n.sensor_fit==="HORIZONTAL",f=(r?n.ortho_scale:a/n.lens)/2*o;return s?[f,f*e/t]:[f*t/e,f]}function ri(n,t,e,o,r,a){const s=Math.max(e.width,1),f=Math.max(e.height,1),[c,d]=mo(n,s,f,1/o),[l,i]=mo(n,a,1,1),m=2*((n.sensor_fit==="AUTO"?a>=1:n.sensor_fit==="HORIZONTAL")?l:i),h=l/c,_=i/d,p=-2*r[0]*o,g=2*r[1]*o,v=n.shift_x*m-p*2*c,O=n.shift_y*m+g*2*d,b=new q().set(...n.matrix.flat()).premultiply(t),S=new y,w=new St;return b.decompose(S,w,new y),{name:n.name,position:S.toArray(),quaternion:[w.x,w.y,w.z,w.w],projection:n.type==="ORTHO"?"orthographic":"perspective",window:{left:v-c,right:v+c,top:O+d,bottom:O-d},near:n.clip_start,far:n.clip_end,frame:{left:.5-h/2+p,top:.5-_/2+g,width:h,height:_},passepartout:{color:Re.passepartout,opacity:n.passepartout},border:{solid:Re.back,dashed:Re.overlay,locked:Re.redalert}}}const si={color:[.8,.8,.8,1],roughness:.5,metallic:0},ii=`
|
|
7151
7151
|
uniform vec3 wbDir[4];
|
|
7152
7152
|
uniform vec3 wbDiffuse[4];
|
|
7153
7153
|
uniform vec3 wbSpecular[4];
|
|
@@ -7189,6 +7189,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
|
|
|
7189
7189
|
diffuseLight *= diffuseColor * (1.0 - specEnergy);
|
|
7190
7190
|
return diffuseLight + specularLight;
|
|
7191
7191
|
}
|
|
7192
|
-
`,
|
|
7192
|
+
`,Cn=n=>En.map(t=>{const[e=0,o=0,r=0]=n(t);return new y(e,o,r)}),li=Cn(n=>n.direction).map(n=>n.normalize()),fi=Cn(n=>n.diffuse),ci=Cn(n=>n.specular),ui=new Ue(...En.map(n=>n.smooth));function di(n,t){const[e,o,r]=n.color,a=new Ta({side:t});return a.color.setRGB(e,o,r,bt),a.name="volter:blender-solid",a.onBeforeCompile=s=>{s.uniforms.wbDir={value:li},s.uniforms.wbDiffuse={value:fi},s.uniforms.wbSpecular={value:ci},s.uniforms.wbWrap={value:ui},s.uniforms.wbRoughness={value:n.roughness},s.uniforms.wbMetallic={value:n.metallic},s.fragmentShader=s.fragmentShader.replace("void main() {",`${ii}
|
|
7193
7193
|
void main() {`).replace("#include <opaque_fragment>",`outgoingLight = volterWorkbenchLighting(diffuseColor.rgb, normal, isOrthographic ? vec3(0.0, 0.0, 1.0) : normalize(vViewPosition));
|
|
7194
|
-
#include <opaque_fragment>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const pi=64;function gi(n,t){return Array.isArray(n)&&Array.isArray(t)?n.length===t.length&&n.every((e,o)=>e===t[o]):n===t}function jt(n){for(let t=n;t;t=t.parent)if(!t.visible)return!1;return!0}function qe(n){if(n.determinant()<=0)return!1;const t=n.elements,e=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(e+o+r)&&Math.min(e,o,r)>0&&Math.abs(a(0,4))<=1e-7*e*o&&Math.abs(a(0,8))<=1e-7*e*r&&Math.abs(a(4,8))<=1e-7*o*r}class vi{constructor(t){this.root=t,this.batches=[],this.inverse=new q,this.matrix=new q,this.box=new fe,this.projection=new q,this.frustum=new Oe,this.camera=null,this.eligible=0,this.excluded={}}rebuild(t,e){if(this.clear(),!e)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=>Yo(l,i.geometry).size>12)){r("attributeBudget");continue}if(this.matrix.multiplyMatrices(this.inverse,i.matrixWorld),!qe(this.matrix)){r("transform");continue}this.eligible++;const c=`${i.geometry.id}:${Array.isArray(i.material)?"slots":"single"}:`+f.map(l=>l.uuid).join(",")+`:${i.renderOrder}`,d=o.get(c);d?d.push(i):o.set(c,[i])}for(const a of o.values()){if(a.length<2)continue;const i=f=>{if(f.length>pi){this.box.makeEmpty();for(const h of f)this.box.expandByPoint(new y().setFromMatrixPosition(h.matrixWorld));const s=this.box.getSize(new y),u=s.x>=s.y&&s.x>=s.z?12:s.y>=s.z?13:14;f.sort((h,m)=>h.matrixWorld.elements[u]-m.matrixWorld.elements[u]);const _=Math.floor(f.length/2);i(f.slice(0,_)),i(f.slice(_));return}if(f.length<2)return;const c=f[0],d=new Sn(c.geometry,c.material,f.length);d.name="Blender repeated geometry",d.userData.engineInternal=!0,d.matrixAutoUpdate=!1,d.renderOrder=c.renderOrder,d.instanceMatrix.setUsage(Pn);const l={draw:d,members:f.map(s=>({mesh:s,layers:s.layers.mask}))};d.raycast=(s,u)=>{for(const{mesh:_}of l.members)_.layers.mask===0&&jt(_)&&_.raycast(s,u)},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:e}of this.batches){let o=0,r=!1;for(const a of e){const{mesh:i}=a;if(this.matrix.multiplyMatrices(this.inverse,i.matrixWorld),!(i.parent!==null&&i.geometry===t.geometry&&gi(i.material,t.material)&&qe(this.matrix))){i.layers.mask|=a.layers;continue}if(i.layers.mask&=~a.layers,!jt(i)||this.camera&&(!this.camera.layers.isEnabled(0)||i.frustumCulled&&!this.frustum.intersectsObject(i)))continue;const c=o*16;this.matrix.elements.some((d,l)=>Math.fround(d)!==t.instanceMatrix.array[c+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:e}of this.batches){for(const{mesh:o,layers:r}of e)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:e})=>t+e.count,0),eligible:this.eligible,excluded:{...this.excluded}}}}const Ie=64,xi=1024;class bi{constructor(t){this.root=t,this.objects=[],this.pools=new Map,this.hidden=[],this.active=[],this.inverse=new q,this.matrix=new q,this.projection=new q,this.frustum=new Oe,this.allocated=0,this.statistics={batches:0,instances:0,preparationMs:0}}supports(t){return t.isMeshDepthMaterial&&t.visible&&!t.transparent&&!t.map&&!t.alphaMap&&!t.displacementMap&&!t.alphaHash&&t.alphaTest===0&&!t.wireframe&&!t.stencilWrite&&t.depthWrite&&t.depthTest&&!t.clippingPlanes?.length&&!t.polygonOffset&&(t.depthFunc===Ta||t.depthFunc===Sa)&&(t.blending===Pa||t.blending===Ea)&&t.onBeforeCompile===$n.prototype.onBeforeCompile&&t.onBeforeRender===$n.prototype.onBeforeRender}setObjects(t){this.clear(),this.objects=[...t].filter(e=>e.isMesh===!0)}prepare(t,e){this.finish();const o=performance.now();if(this.statistics={batches:0,instances:0,preparationMs:0},!t.layers.isEnabled(0))return;this.inverse.copy(this.root.matrixWorld).invert(),this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection);const r=new Map;for(const a of this.objects){if(a.layers.mask!==1||!jt(a)||a.isSkinnedMesh||a.isInstancedMesh||a.isBatchedMesh||a.morphTargetInfluences||a.onBeforeRender!==Le.prototype.onBeforeRender||a.onAfterRender!==Le.prototype.onAfterRender)continue;const i=Array.isArray(a.material)?a.material:[a.material];if(i.length!==1||!i[0]?.visible)continue;const f=a.geometry,c=f.index?.count??f.getAttribute("position")?.count??0;if(!c||Array.isArray(a.material)&&!(f.groups.length===1&&f.groups[0].start===0&&f.groups[0].count===c&&f.groups[0].materialIndex===0)||a.frustumCulled&&!this.frustum.intersectsObject(a)||(this.matrix.multiplyMatrices(this.inverse,a.matrixWorld),!qe(this.matrix)))continue;const d=r.get(f);d?d.push(a):r.set(f,[a])}for(const[a,i]of this.pools)if(!r.has(a)){for(const f of i)f.removeFromParent(),f.dispose(),this.allocated--;this.pools.delete(a)}for(const[a,i]of r){if(i.length<2)continue;let f=this.pools.get(a);f||(f=[],this.pools.set(a,f));for(let c=0;c<i.length;c+=Ie){const d=Math.min(Ie,i.length-c);if(d<2)continue;const l=c/Ie;let s=f[l];if(!s){if(this.allocated>=xi)continue;s=new Sn(a,e,Ie),s.name="Blender depth instances",s.userData.engineInternal=!0,s.matrixAutoUpdate=!1,s.frustumCulled=!1,s.boundingSphere=new Ze,s.instanceMatrix.setUsage(Pn),s.raycast=()=>{},this.root.add(s),f.push(s),this.allocated++}s.material=e,s.matrixWorld.copy(this.root.matrixWorld),s.count=d,s.visible=!0,this.active.push(s);for(let u=0;u<d;u++){const _=i[c+u];this.matrix.multiplyMatrices(this.inverse,_.matrixWorld),s.setMatrixAt(u,this.matrix),this.hidden.push({mesh:_,mask:_.layers.mask}),_.layers.disable(0)}s.instanceMatrix.needsUpdate=!0,this.statistics.batches++,this.statistics.instances+=d}}this.statistics.preparationMs=performance.now()-o}finish(){for(const{mesh:t,mask:e}of this.hidden)t.layers.mask=e;this.hidden.length=0;for(const t of this.active)t.visible=!1;this.active.length=0}clear(){this.finish();for(const t of this.pools.values())for(const e of t)e.removeFromParent(),e.dispose();this.pools.clear(),this.objects=[],this.allocated=0}inspect(){return{...this.statistics,allocated:this.allocated}}}const An=64,po=4*1024*1024,yi=32*1024*1024,wi=1024;class Oi{constructor(){this.families=new Map,this.registrations=new Map,this.bytes=0,this.drawCount=0,this.created=0,this.pending=!1}begin(){this.created=0,this.pending=!1,this.registrations.clear()}register(t,e,o){const r=`${t.id}:${e.uuid}:${o}`;if(this.registrations.has(r))return this.registrations.get(r);this.registrations.set(r,null);const a=t.getAttribute("position"),i=t.index?.count??a?.count??0;if(!a||t.drawRange.start!==0||t.drawRange.count<i||Object.keys(t.morphAttributes).length)return null;const f=[!!t.index,t.userData.blenderUvChannels??null],c=[t.index?.id,t.index?.version];let d=(t.index?.count??0)*4;for(const h of Object.keys(t.attributes).sort()){const m=t.getAttribute(h);if(!(m instanceof ft)||m.isInstancedBufferAttribute||m instanceof Na||m.count!==a.count)return null;f.push([h,m.array.constructor.name,m.itemSize,m.normalized,m.gpuType]),c.push(h,m.id,m.version),d+=m.array.byteLength}if(d>po)return null;const l=`multi:${e.uuid}:${o}:${JSON.stringify(f)}`;let s=this.families.get(l);s||(s={material:e,shapes:new Map,template:null,ids:new Map,draws:[],dirty:!0,bytes:0,refused:!1},this.families.set(l,s));const u=JSON.stringify(c),_=s.shapes.get(t.id);return(!_||_.stamp!==u)&&(s.shapes.set(t.id,{geometry:t,stamp:u}),s.dirty=!0),this.registrations.set(r,l),l}pack(){for(const t of this.families.values()){if(!t.dirty)continue;this.release(t),t.dirty=!1;let e=0,o=0,r=0;for(const{geometry:f}of t.shapes.values()){e+=f.getAttribute("position").count,o+=f.index?.count??0;for(const c of Object.values(f.attributes))r+=c.array.byteLength}if(r+=o*(e>65535?4:2),t.refused=r>po||this.bytes+r>yi,t.refused)continue;const a=new Ve(An,e,o,t.material);a.sortObjects=!1,a.perObjectFrustumCulled=!1,a.frustumCulled=!1,a.matrixAutoUpdate=!1,a.boundingSphere=new Ze,a.name="Blender ordered multi-draw",a.userData.engineInternal=!0;for(const{geometry:f}of t.shapes.values())t.ids.set(f.id,a.addGeometry(f));const i=t.shapes.values().next().value.geometry;a.geometry.userData.blenderUvChannels=i.userData.blenderUvChannels;for(const f of Object.keys(i.attributes))a.geometry.getAttribute(f).gpuType=i.getAttribute(f).gpuType;t.template=a,t.bytes=r,this.bytes+=r}}available(t){return!!this.families.get(t)?.template}get(t,e){const o=this.families.get(t),r=o.template;if(!r)return null;let a=o.draws[e];if(!a){if(this.drawCount>=wi)return null;if(this.created>=4)return this.pending=!0,null;a=new Ve(1,0,0,o.material),a.dispose(),a.copy(r);for(const f of Object.keys(r.geometry.attributes))a.geometry.setAttribute(f,r.geometry.getAttribute(f));a.geometry.setIndex(r.geometry.index);const i=o.ids.values().next().value;for(let f=0;f<An;f++)a.addInstance(i),a.setVisibleAt(f,!1);o.draws.push(a),this.created++,this.drawCount++}return a}geometryId(t,e){return this.families.get(t).ids.get(e.id)}inspect(){return{bytes:this.bytes,draws:this.drawCount,pending:this.pending,refusedFamilies:[...this.families.values()].filter(t=>t.refused).length}}release(t){for(const e of t.draws){e.removeFromParent();for(const o of Object.keys(e.geometry.attributes))e.geometry.deleteAttribute(o);e.geometry.setIndex(null),e.dispose(),this.drawCount--}t.draws.length=0,t.template?.dispose(),t.template=null,t.ids.clear(),this.bytes-=t.bytes,t.bytes=0}clear(){for(const t of this.families.values())this.release(t);this.families.clear(),this.registrations.clear(),this.pending=!1}}const oe=An;function go(n){for(let t=n.parent;t;t=t.parent)if(t.isGroup)return t.renderOrder;return 0}class Ai{constructor(t){this.root=t,this.objects=[],this.ordered=new Oi,this.mixedDraws=new Map,this.multiDraw=!1,this.pools=new Map,this.hidden=[],this.inverse=new q,this.matrix=new q,this.projection=new q,this.frustum=new Oe,this.centre=new y,this.depth=new Ge,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(e=>e.isMesh===!0)}prepare(t,e=!1){if(this.finishDraw(),!this.objects.length)return;t.updateMatrixWorld(),this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const o=this.multiDraw!==e;if(this.multiDraw=e,!this.planChanged(t)&&!o&&!this.ordered.pending){for(const c of this.planned){c.mesh.visible=!0;for(const d of c.members)d.layers.disable(0),this.hidden.push(d)}return}this.planned.length=0;for(const c of this.mixedDraws.values())c.members.length=0;this.ordered.begin();for(const c of this.pools.values())for(const d of c)d.mesh.visible=!1,d.members.length=0;this.batches=this.instances=0,this.excluded={},this.frustum.setFromProjectionMatrix(this.projection),this.inverse.copy(this.root.matrixWorld).invert();const a=[],i=new Map;for(const c of this.objects){const d=Array.isArray(c.material)?c.material:[c.material];if(!d.some(v=>v.visible&&v.transparent)||!jt(c)||!c.layers.test(t.layers)||c.frustumCulled&&!this.frustum.intersectsObject(c))continue;const l=c;l.boundingSphere!==void 0?(l.boundingSphere===null&&l.computeBoundingSphere?.(),this.centre.copy(l.boundingSphere.center)):(c.geometry.boundingSphere||c.geometry.computeBoundingSphere(),this.centre.copy(c.geometry.boundingSphere.center)),this.centre.applyMatrix4(c.matrixWorld);const s=this.centre.clone(),u=this.depth.set(s.x,s.y,s.z,1).applyMatrix4(this.projection).z;let _=null,h=null;const m=d.length===1?d[0]:null,p=go(c);if(m&&m.visible&&m.transparent&&!m.isShaderMaterial&&!(m.transmission>0)&&(m.side!==je||m.forceSinglePass)&&!c.isSkinnedMesh&&!c.morphTargetInfluences&&!c.isInstancedMesh&&c.layers.mask===1&&p===this.root.renderOrder){const v=c.geometry,O=v.index?.count??v.getAttribute("position").count,b=!Array.isArray(c.material)||v.groups.length===1&&v.groups[0].start===0&&v.groups[0].count===O&&v.groups[0].materialIndex===0,S=`${v.id}:${m.uuid}:${c.renderOrder}`;let w=i.get(S);w===void 0&&(w=Yo(m,v).size<=12,i.set(S,w)),this.matrix.multiplyMatrices(this.inverse,c.matrixWorld),b&&w&&qe(this.matrix)&&(_=m,h=S)}if(h===null){const v=m?m.isShaderMaterial?"customShader":m.transmission>0?"transmission":m.side===je&&!m.forceSinglePass?"twoPass":"geometryLayersOrTransform":"multipleMaterials";this.excluded[v]=(this.excluded[v]??0)+1}const g=e&&h&&_?this.ordered.register(c.geometry,_,c.renderOrder):null;a.push({mesh:c,material:_,key:h,batchKey:g,groupOrder:p,z:u,centre:s})}this.ordered.pack();for(const c of a)c.batchKey&&this.ordered.available(c.batchKey)&&(c.key=c.batchKey);for(const[c]of this.mixedDraws)c.parent||this.mixedDraws.delete(c);a.sort((c,d)=>c.groupOrder-d.groupOrder||c.mesh.renderOrder-d.mesh.renderOrder||d.z-c.z||c.mesh.id-d.mesh.id);const f=new Map;for(let c=0;c<a.length;){const d=a[c];let l=c+1;if(d.key!==null)for(;l<a.length&&a[l].key===d.key;)l++;const s=a[c-1],u=a[l],_=s?.z===d.z&&s.mesh.renderOrder===d.mesh.renderOrder||u?.z===a[l-1].z&&u.mesh.renderOrder===d.mesh.renderOrder;if(d.key!==null&&l-c>=2&&!_){let h=!0;for(let m=c+oe;m<l;m+=oe)a[m-1].z===a[m].z&&(h=!1);if(h)for(let m=c;m<l;m+=oe){const p=Math.min(oe,l-m);if(p<2)continue;const g=a[m],v=f.get(d.key)??0;f.set(d.key,v+1);const O=d.key.startsWith("multi:");let b;if(O){const w=this.ordered.get(d.key,v);if(!w)continue;if(b=this.mixedDraws.get(w),!b){b={mesh:w,members:[]},this.mixedDraws.set(w,b);const A=b;w.raycast=(M,E)=>{if(w.visible)for(const C of A.members)jt(C)&&C.raycast(M,E)},this.root.add(w)}}let S=this.pools.get(d.key);if(S||(S=[],this.pools.set(d.key,S)),O||(b=S[v]),!b){const w=new Sn(d.mesh.geometry,d.material,oe);w.name="Blender ordered transparency",w.userData.engineInternal=!0,w.matrixAutoUpdate=!1,w.frustumCulled=!1,w.boundingSphere=new Ze,w.instanceMatrix.setUsage(Pn),b={mesh:w,members:[]};const A=b;w.raycast=(M,E)=>{if(w.visible)for(const C of A.members)jt(C)&&C.raycast(M,E)},S.push(b),this.root.add(w)}b.mesh.visible=!0,b.mesh.renderOrder=g.mesh.renderOrder,b.mesh.boundingSphere.center.copy(g.centre).applyMatrix4(this.inverse),b.mesh.updateMatrixWorld(!0);for(let w=0;w<p;w++){const A=a[m+w].mesh;this.matrix.multiplyMatrices(this.inverse,A.matrixWorld),b.mesh.setMatrixAt(w,this.matrix),b.mesh instanceof Ve&&(b.mesh.setGeometryIdAt(w,this.ordered.geometryId(d.key,A.geometry)),b.mesh.setVisibleAt(w,!0)),b.members.push(A),A.layers.disable(0),this.hidden.push(A)}if(b.mesh instanceof Ve)for(let w=p;w<oe;w++)b.mesh.setVisibleAt(w,!1);else b.mesh.count=p,b.mesh.instanceMatrix.needsUpdate=!0;this.planned.push(b),this.batches++,this.instances+=p}}c=l}this.ordered.pending&&queueMicrotask(_t)}inspect(){return{batches:this.batches,instances:this.instances,excluded:{...this.excluded},multiDraw:this.ordered.inspect()}}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 o of this.projection.elements)this.observe(o);for(const o of this.root.matrixWorld.elements)this.observe(o);const e=new Set;for(const o of this.objects){if(!(Array.isArray(o.material)?o.material:[o.material]).some(c=>c.visible&&c.transparent))continue;this.observe(o.parent?.id??-1),this.observe(jt(o)?1:0),this.observe(o.layers.mask),this.observe(o.renderOrder),this.observe(go(o)),this.observe(o.frustumCulled?1:0),this.observe(o.morphTargetInfluences?1:0);for(const c of o.matrixWorld.elements)this.observe(c);const a=o.geometry;if(this.observe(a.id),!e.has(a)){e.add(a),this.observe(a.index?.id??-1),this.observe(a.index?.version??-1),this.observe(JSON.stringify(a.userData.blenderUvChannels??null));for(const c of Object.keys(a.attributes).sort()){const d=a.getAttribute(c);this.observe(c),d instanceof ft&&(this.observe(d.id),this.observe(d.version))}}this.observe(a.drawRange.start),this.observe(a.drawRange.count),this.observe(a.index?.count??a.getAttribute("position").count),this.observe(a.groups.length);for(const c of a.groups)this.observe(c.start),this.observe(c.count),this.observe(c.materialIndex??0);const i=o.boundingSphere??a.boundingSphere;this.observe(i?.center.x??0),this.observe(i?.center.y??0),this.observe(i?.center.z??0),this.observe(i?.radius??-1);const f=Array.isArray(o.material)?o.material:null;if(this.observe(f?.length??-1),f)for(const c of f)this.observeMaterial(c);else this.observeMaterial(o.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)}suspendDraw(){const t=this.hidden.map(o=>({mesh:o,mask:o.layers.mask})),e=this.planned.map(({mesh:o})=>({mesh:o,visible:o.visible}));for(const{mesh:o}of t)o.layers.enable(0);for(const{mesh:o}of e)o.visible=!1;return()=>{for(const{mesh:o,mask:r}of t)o.layers.mask=r;for(const{mesh:o,visible:r}of e)o.visible=r}}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:e}of t)e.visible=!1;for(const{mesh:t}of this.mixedDraws.values())t.visible=!1}clear(){this.finishDraw();for(const t of this.pools.values())for(const{mesh:e}of t)e.removeFromParent(),e.dispose();this.pools.clear(),this.ordered.clear(),this.mixedDraws.clear(),this.planned.length=0,this.planState.length=0,this.objects=[],this.batches=this.instances=0}}const Mi=8*1024*1024;class Ti{constructor(){this.objects=[],this.copies=new Map,this.swapped=[],this.bytes=0,this.savedDraws=0}setObjects(t){this.clear(),this.objects=[...t].filter(e=>e.isMesh===!0)}prepare(){this.savedDraws=0;for(const t of this.objects){const e=t.geometry,o=t.material;if(t.layers.mask===0||!Array.isArray(o)||e.groups.length<8||!e.index||t.isSkinnedMesh||t.isInstancedMesh||t.morphTargetInfluences||Object.keys(e.morphAttributes).length||e.drawRange.start!==0||e.drawRange.count<e.index.count||o.some(i=>i.transparent||i.transmission>0||i.isShaderMaterial))continue;const r=JSON.stringify([e.id,e.index.id,e.index.version,o.map(i=>i.uuid),e.groups,Object.entries(e.attributes).map(([i,f])=>[i,f.id])]);let a=this.copies.get(r);if(!a){let i=0,f=!0;const c=new Map;for(const _ of e.groups){const h=_.materialIndex??0,m=o[h];if(!m||_.start!==i||_.count<=0||_.count%3!==0){f=!1;break}i+=_.count;const p=c.get(m.uuid);p?p.groups.push(_):c.set(m.uuid,{slot:h,groups:[_]})}if(!f||i!==e.index.count||c.size>=e.groups.length)continue;const d=e.index.array.byteLength;if(this.bytes+d>Mi)continue;const l=new ee;for(const[_,h]of Object.entries(e.attributes))l.setAttribute(_,h);const s=e.index.clone();let u=0;for(const _ of c.values()){const h=u;for(const m of _.groups)s.array.set(e.index.array.subarray(m.start,m.start+m.count),u),u+=m.count;l.addGroup(h,u-h,_.slot)}l.setIndex(s),l.boundingBox=e.boundingBox?.clone()??null,l.boundingSphere=e.boundingSphere?.clone()??null,l.userData={...e.userData},a={geometry:l,signature:r,bytes:d,before:e.groups.length,after:c.size},this.copies.set(r,a),this.bytes+=d}this.swapped.push({mesh:t,geometry:e}),t.geometry=a.geometry,this.savedDraws+=a.before-a.after}}finish(){for(const{mesh:t,geometry:e}of this.swapped)t.geometry=e;this.swapped.length=0}inspect(){return{copies:this.copies.size,bytes:this.bytes,savedRanges:this.savedDraws}}release(t){for(const e of Object.keys(t.geometry.attributes))t.geometry.deleteAttribute(e);t.geometry.dispose(),this.bytes-=t.bytes}clear(){this.finish();for(const t of this.copies.values())this.release(t);this.copies.clear(),this.objects=[],this.savedDraws=0}}const fn=64*1024*1024,vo=150,De=49152,Pt=8192,xo=Symbol("navigation geometry replaced");class Si{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 Oe,this.centre=new y,this.boxCentre=new y,this.halfExtent=new y,this.viewWorld=new q,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 e=new Map;for(const i of t){const f=i;if(!f.isMesh||f.isSkinnedMesh||f.isInstancedMesh||f.morphTargetInfluences)continue;const c=f.geometry,d=c.getAttribute("position");if(!c.index||c.index.count<6144||!d||d.count>8e6||Object.values(c.attributes).some(s=>!(s instanceof ft)||s.isFloat16BufferAttribute||s.isInstancedBufferAttribute)||Object.keys(c.morphAttributes).length||c.drawRange.start!==0||c.drawRange.count<c.index.count)continue;if(Array.isArray(f.material)){let s=0;if(!c.groups.length||c.groups.some(u=>{const _=u.start===s&&u.count>0&&u.count%3===0&&Number.isInteger(u.materialIndex)&&u.materialIndex>=0&&u.materialIndex<f.material.length;return s=u.start+u.count,!_})||s!==c.index.count)continue}const l=e.get(c);l?l.push(f):e.set(c,[f])}this.groups=e;const o=i=>{let f=this.identities.get(i);return f===void 0&&(f=++this.nextIdentity,this.identities.set(i,f)),f},r=[...e].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(([c,d])=>`${c}:${o(d)}:${d.version}`).join(",")).join(";");if(r===this.signature)return;this.releaseCopies(),this.signature=r,this.unavailable=null;const a=[...e].filter(([,i])=>i.length>=3);a.reduce((i,[f,c])=>i+f.index.count*c.length,0)<6e6||(a.sort(([i,f],[c,d])=>c.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>=fn)return;const t=this.queue.shift();if(!t){this.worker?.terminate(),this.worker=null;return}this.building=!0;const e=this.generation,o=()=>{if(e!==this.generation)throw xo;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 N=this.pending;this.pending=null,N.resolve(x.data)}},this.worker.onerror=x=>{this.unavailable=x.message||"Navigation geometry worker unavailable",this.worker?.terminate(),this.worker=null;const N=this.pending;this.pending=null,N?.resolve({id:N.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 c=f?t.groups:[{start:0,count:t.index.count}],d=c.flatMap(x=>{const N=[];for(let T=x.start;T<x.start+x.count;T+=De)N.push({start:T,count:Math.min(De,x.start+x.count-T),materialIndex:x.materialIndex});return N}),l=t.getAttribute("blenderVertex"),s=new Uint32Array(a.count),u=new Uint8Array(a.count),_=x=>l?l.getX(x):x;for(let x=0;x<d.length;x++){const N=d[x];for(let T=N.start;T<N.start+N.count;T+=Pt){await r();for(let U=T;U<Math.min(T+Pt,N.start+N.count);U++){const $=_(t.index.getX(U));if(!Number.isInteger($)||$<0||$>=s.length)return;s[$]?s[$]!==x+1&&(u[$]=1):s[$]=x+1}}}const h=Object.entries(t.attributes).filter(([x])=>x!=="position"&&x!=="blenderVertex"),m=h.reduce((x,[,N])=>x+N.itemSize,0);if(m>32)return;const p=[];let g=0;for(const[x,N]of h)for(let T=0;T<N.itemSize;T++,g++)x!=="normal"&&p.push(g);const v=h.flatMap(([x,N])=>Array(N.itemSize).fill(x==="normal"?.5:1)),O=t.boundingBox?.clone()??new fe;if(!t.boundingBox){const x=new y;for(let N=0;N<a.count;N+=Pt){await r();for(let T=N;T<Math.min(N+Pt,a.count);T++)O.expandByPoint(x.fromBufferAttribute(a,T))}}if(!t.boundingSphere)return;const b=Math.max(O.max.x-O.min.x,O.max.y-O.min.y,O.max.z-O.min.z)*.002,S=[],w=[];let A=0,M=0;for(const x of c){const N=A;for(let T=x.start;T<x.start+x.count;T+=De){await r();const U=Math.min(T+De,x.start+x.count),$=[],k=new Map,P=new Uint32Array(U-T);for(let K=T;K<U;K++){const dt=t.index.getX(K);let Tt=k.get(dt);Tt===void 0&&(Tt=$.length,$.push(dt),k.set(dt,Tt)),P[K-T]=Tt}const B=new Uint8Array($.length),Q=new Float32Array($.length*3),ot=new Float32Array($.length*m);for(let K=0;K<$.length;K+=Pt){await r();for(let dt=K;dt<Math.min(K+Pt,$.length);dt++){const Tt=$[dt];B[dt]=u[_(Tt)];for(let Ft=0;Ft<3;Ft++)Q[dt*3+Ft]=a.getComponent(Tt,Ft);let qt=0;for(const[,Ft]of h){for(let Ae=0;Ae<Ft.itemSize;Ae++)ot[dt*m+qt+Ae]=Ft.getComponent(Tt,Ae);qt+=Ft.itemSize}}}const ut=++this.nextId,et=await new Promise(K=>{this.pending={id:ut,resolve:K};const dt={id:ut,positions:Q,indices:P,attributes:ot,stride:m,weights:v,absoluteError:b,protectedComponents:p,locks:B};this.worker.postMessage(dt,[Q.buffer,P.buffer,ot.buffer,B.buffer])});if(o(),et.refusal)throw new Error(et.refusal);if(!et.indices||!Number.isFinite(et.error))throw new Error("Invalid navigation geometry response");const rt=et.indices;for(let K=0;K<rt.length;K++)rt[K]=$[rt[K]];if(A+=rt.length,A*4>fn-this.bytes)return;S.push(rt),M=Math.max(M,et.error)}f&&w.push({start:N,count:A-N,materialIndex:x.materialIndex})}const E={vertices:a.count,fullTriangles:t.index.count/3,reducedTriangles:A/3,error:M,accepted:!1};if(this.reductions.length<32&&this.reductions.push(E),!A||A>=t.index.count*.75)return;const C=new Int32Array(a.count).fill(-1),V=[],H=new Uint32Array(A);let tt=0;for(const x of S){for(let N=0;N<x.length;N+=Pt){await r();for(let T=N;T<Math.min(N+Pt,x.length);T++){const U=x[T];let $=C[U];$<0&&($=V.length,V.push(U),C[U]=$),H[tt+T]=$}}tt+=x.length}const Z=H.byteLength+Object.values(t.attributes).reduce((x,N)=>x+V.length*N.itemSize*N.array.BYTES_PER_ELEMENT,0);if(E.bytes=Z,this.bytes+Z>fn)return;const nt=new ee;nt.setIndex(new ft(H,1));for(const[x,N]of Object.entries(t.attributes)){const T=N,U=T.array.constructor,$=new U(V.length*T.itemSize);for(let k=0;k<V.length;k+=Pt){await r();for(let P=k;P<Math.min(k+Pt,V.length);P++)for(let B=0;B<T.itemSize;B++)$[P*T.itemSize+B]=T.array[V[P]*T.itemSize+B]}nt.setAttribute(x,new ft($,T.itemSize,T.normalized))}nt.boundingSphere=t.boundingSphere.clone(),nt.boundingBox=O.clone();for(const x of w)nt.addGroup(x.start,x.count,x.materialIndex);nt.userData={...t.userData},E.accepted=!0,this.cache.set(t,{geometry:nt,error:M,bytes:Z}),this.bytes+=Z}catch(a){if(a===xo)return;this.unavailable=String(a),this.worker?.terminate(),this.worker=null,this.pending=null,this.queue.length=0}finally{e===this.generation&&(this.building=!1,this.timer=setTimeout(()=>{this.timer=null,this.next()},0))}}prepare(t,e,o){if(this.finish(),this.drawnMeshes=this.fullTriangles=this.motionTriangles=0,!e||!(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()},vo+1)),r-this.movedAt>vo)return!1;this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection);let i=0;for(const[f,c]of this.cache){const d=c.geometry.boundingBox;d.getSize(this.halfExtent).multiplyScalar(.5);for(const l of this.groups.get(f)??[]){if(!jt(l)||l.frustumCulled&&!this.frustum.intersectsObject(l))continue;this.viewWorld.multiplyMatrices(t.matrixWorldInverse,l.matrixWorld);const s=this.viewWorld.elements,u=s[0]**2+s[1]**2+s[2]**2,_=s[4]**2+s[5]**2+s[6]**2,h=s[8]**2+s[9]**2+s[10]**2,m=Math.abs(s[0]*s[4]+s[1]*s[5]+s[2]*s[6]),p=Math.abs(s[0]*s[8]+s[1]*s[9]+s[2]*s[10]),g=Math.abs(s[4]*s[8]+s[5]*s[9]+s[6]*s[10]),v=Math.sqrt(Math.max(u+m+p,_+m+g,h+p+g)),O=f.boundingSphere;this.centre.copy(O.center).applyMatrix4(this.viewWorld);let b=1;if(t.isPerspectiveCamera){const w=-this.centre.z-O.radius*v;d.getCenter(this.boxCentre).applyMatrix4(this.viewWorld);const A=this.viewWorld.elements,M=Math.abs(A[2])*this.halfExtent.x+Math.abs(A[6])*this.halfExtent.y+Math.abs(A[10])*this.halfExtent.z;b=Math.max(w,-this.boxCentre.z-M)}const S=c.error*v*Math.abs(t.projectionMatrix.elements[5])*o/(2*b);if(!(b>0)||S>1){i++;continue}this.swapped.push({mesh:l,geometry:f}),l.geometry=c.geometry,this.drawnMeshes++,this.fullTriangles+=f.index.count/3,this.motionTriangles+=c.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:e}of this.swapped)t.geometry=e;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 Pi={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},F=I().finite(),Ko=W([F,F,F]),ze=W([I().int().nonnegative(),I().int().nonnegative()]),gt={name:D(),domain:Y(["POINT","EDGE","FACE","CORNER"])},Ei=Ha("type",[R({...gt,type:X("FLOAT2"),data:L(W([F,F]))}).strict(),R({...gt,type:X("FLOAT_VECTOR"),data:L(Ko)}).strict(),R({...gt,type:X("FLOAT_COLOR"),data:L(W([F,F,F,F]))}).strict(),R({...gt,type:X("BYTE_COLOR"),data:L(W([F,F,F,F]))}).strict(),R({...gt,type:X("QUATERNION"),data:L(W([F,F,F,F]))}).strict(),R({...gt,type:X("FLOAT4"),data:L(W([F,F,F,F]))}).strict(),R({...gt,type:X("FLOAT4X4"),data:L(L(F).length(16))}).strict(),R({...gt,type:X("INT16_2D"),data:L(W([I().int(),I().int()]))}).strict(),R({...gt,type:X("INT32_2D"),data:L(W([I().int(),I().int()]))}).strict(),R({...gt,type:X("FLOAT"),data:L(F)}).strict(),R({...gt,type:X("INT"),data:L(I().int())}).strict(),R({...gt,type:X("INT8"),data:L(I().int())}).strict(),R({...gt,type:X("BOOLEAN"),data:L(at())}).strict(),R({...gt,type:X("STRING"),data:L(D())}).strict()]),Ni=R({positions:G(Float32Array),normals:G(Float32Array).nullable(),uv:G(Float32Array).nullable(),uvLayers:L(R({name:D(),data:G(Float32Array)}).strict()).optional(),attributeLayers:L(R({name:D(),data:G(Float32Array)}).strict()).optional(),orco:G(Float32Array).nullable().optional(),indices:G(Uint32Array),groups:L(R({start:I().int().nonnegative(),count:I().int().nonnegative(),materialIndex:I().int().nonnegative()}).strict()),hash:D()}).strict(),Ri=R({v:L(Ko),f:L(L(I().int().nonnegative())),e:L(ze).optional(),edge_order:L(ze).optional(),m:L(I().int().nonnegative()).optional(),s:L(at()).optional(),sharp:L(ze).optional(),seams:L(ze).optional(),creases:L(W([F,F,F])).optional(),attributes:L(Ei).optional(),active_uv:D().nullable().optional(),render_uv:D().nullable().optional()}).strict(),Ii=R({store:I().int().optional(),revision:I().int(),unchanged:X(!0)}).strict(),Di=R({co:Wt([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(),zi=R({name:D(),domain:Y(["POINT","EDGE","FACE","CORNER"]),type:D(),data:Ga(n=>ArrayBuffer.isView(n))}).strict(),Jo=R({columns:Di,attributes:L(zi),activeUv:D().nullable(),renderUv:D().nullable(),counts:R({verts:I().int().nonnegative(),edges:I().int().nonnegative(),faces:I().int().nonnegative(),corners:I().int().nonnegative()}).strict(),revision:I().int().nonnegative()}).strict(),Fi=Wt([Ni,Jo,Ri,Ii]),bo=new Set;function Ci(n,t){const e=new Blob([n],{type:t}),o=new Fa;let r=!1;o.addEventListener("dispose",()=>{r=!0,o.image?.close?.()});const a=createImageBitmap(e,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(i=>{if(r){i.close();return}o.image=i,o.needsUpdate=!0,_t()}).finally(()=>{bo.delete(a)});return bo.add(a),a.catch(()=>{}),{texture:o,ready:a}}function ki(n,t,e,o){const r=new Xe(n,t,e,Ye,za);return r.flipY=!1,r.colorSpace=o==="data"?Be:Ut,r.needsUpdate=!0,r}function $i(n,t,e){if(t.length===0)throw new Error(`Runtime image ${n} 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 u=l.rgba??(l.rgbaBase64?pn(l.rgbaBase64):void 0);if(!u)throw new Error(`Runtime image ${n} tile ${l.number} carries no raster`);for(let h=0;h<l.height;h++)a.set(u.subarray(h*l.width*4,(h+1)*l.width*4),(s*r+h)*o*4);const _=l.number-1001;f[_*4]=s,f.set([0,0,l.width/o,l.height/r],(i+_)*4)});const c=new Da(a,o,r,t.length);c.colorSpace=e==="data"?Be:Ut,c.magFilter=te,c.minFilter=Ro,c.generateMipmaps=!0,c.needsUpdate=!0;const d=new Xe(f,i,2,Ye,So);return d.magFilter=d.minFilter=_n,d.needsUpdate=!0,{tiles:c,map:d,frame:t}}const Li=R({width:I().int().positive(),height:I().int().positive(),revision:I().int().nonnegative(),rgba:G(Uint8Array).optional(),rgbaBase64:D().optional(),colorspace:Y(["sRGB","data"]).optional(),tiles:L(R({number:I().int().min(1001),width:I().int().positive(),height:I().int().positive(),rgba:G(Uint8Array).optional(),rgbaBase64:D().optional()}).strict()).optional()}).strict(),ji=R({revision:I().int().nonnegative(),encoded:G(Uint8Array).optional(),encodedBase64:D().optional(),mime:Y(["image/png","image/jpeg"]),colorspace:Y(["sRGB","data"]).optional()}).strict(),ta=Wt([Li,ji]),cn=R({image:R({name:D(),revision:I().int().nonnegative()}).strict(),extension:Y(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:D(),tint:W([F,F,F]).optional()}).strict(),Vi=R({name:D(),color:W([F,F,F,F]),roughness:F,metallic:F,transmission:F,ior:F,physical:ks.optional(),normal_texture:cn.optional(),normal_strength:F.default(1),normal_space:Y(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:at().default(!1),texture:cn.optional(),roughness_texture:cn.optional(),emission:R({color:W([F,F,F]),strength:F}).strict().optional(),graph:us.optional(),viewport:R({color:W([F,F,F,F]),roughness:F,metallic:F}).strict().optional()}).strict(),Bi=R({session:D(),revision:I().int().nonnegative(),volumes:Ot(D(),Wo).default({}),lights:Ot(D(),Xr).default({}),world:ns.nullable().default(null),meshes:Ot(D(),Fi),materials:Ot(D(),Vi),images:Ot(D(),ta).default({}),objects:L(R({id:D(),name:D(),type:Y(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:D().nullable(),volume:D().nullable().optional(),light:D().nullable().optional(),materials:L(D().nullable()),matrix:L(W([F,F,F,F])).length(4),visible:at(),render_visible:at().default(!0),selected:at(),parent:D().nullable(),texspace:W([W([F,F,F]),W([F,F,F])]).optional(),default_color:D().optional()}).strict()),active:D().nullable(),mode:D(),cameras:Ot(D(),Ot(D(),Do())).default({}),warnings:L(D()).default([]),updated:L(D()).default([]),frame:I().int().default(0),armatures:Ot(D(),Qa).default({}),weights:Us.nullable().default(null),cursor:Xs.optional(),camera_view:R({scene_camera:D().nullable(),view_layer_cameras:L(D()),aspect:I().finite().positive()}).optional(),light_distances:Ot(D(),W([I().finite(),I().finite()])).default({}),empties:Ot(D(),ti).default({}),view:R({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:R({frame:I().int(),body:D(),markers:L(W([I().int(),D()]))}).optional(),units:R({system:Y(["NONE","METRIC","IMPERIAL"]),scale_length:I().finite()}).optional()}).strict();function Ui(n,t){for(let e=0,o=n.length-1;e<n.length&&o>=0;e++,o--){if(n[e][0]===t)return n[e][1];if(e===o)break;if(n[o][0]===t)return n[o][1]}return null}const Wi={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 He{constructor(){this.root=new ct,this.instances=new vi(this.root),this.depthInstances=new bi(this.root),this.materialRanges=new Ti,this.transparentInstances=new Ai(this.root),this.motionGeometry=new Si(_t),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 es,this.world=new Dn,this.armatureOverlay=new lr,this.weightOverlay=new Gs,this.cursorOverlay=new Js,this.extrasOverlay=new oi,this.armatureRoot=new ct,this.weightRoot=new ct,this.cursorRoot=new ct,this.cameraExtrasRoot=new ct,this.lightExtrasRoot=new ct,this.emptyExtrasRoot=new ct,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 ce({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new Cs,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=si,this.cameraViewPan=ii,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=e=>{t(e),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[e,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]])e.matrixAutoUpdate=!1,e.matrix.copy(this.root.matrix),e.add(o),e.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const e of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])e.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const e=JSON.stringify(t);let o=this.graphs.get(e);return o||(o=Ms(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(e,o)),o}mirrorPose(t){let e=null;for(const[a,i]of this.objects)if(i===t){e=a;break}if(e===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(e);i!==void 0&&(i.matrix.copy(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),r=!0)}r&&_t()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const e=this.subscribeFrames(t),o=Ya(t);return()=>{e(),o()}}blenderObjectName(t){for(const[e,o]of this.objects)if(o===t)return this.frame?.objects.find(r=>r.id===e)?.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[e,o,r,a]=t.rotation,i=new St(o,r,a,e),f=new y(...t.location).applyMatrix4(this.root.matrix),c=d=>d.applyQuaternion(i).applyMatrix4(this.root.matrix).normalize();return{target:f.toArray(),direction:c(new y(0,0,1)).toArray(),up:c(new y(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?Pi[t.shading]:null}}cameraViewCamera(){const t=this.frame,e=t?.camera_view;return!t||!e?null:e.scene_camera!==null&&t.cameras[e.scene_camera]?e.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:e.view_layer_cameras.find(o=>t.cameras[o])??null}blenderPose(t,e){const o=new q().copy(this.root.matrix).invert(),r=new q().compose(new y(...t),new St(...e),new y(1,1,1)).premultiply(o),a=new y,i=new St;return r.decompose(a,i,new y),{location:a.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,e,o,r){const a=this.frame,i=_o.safeParse(a?.cameras[t]);return!a?.camera_view||!i.success?null:li(i.data,this.root.matrix,e,o,r,a.camera_view.aspect)}subjectLine(t){const e=this.frame?.subject;if(e===void 0)return null;const o=t??e.frame,r=Ui(e.markers,o);return`(${o})${e.body}${r===null?"":` <${r}>`}`}gridUnitName(t){const e=this.frame?.units;if(e===void 0||e.system==="NONE")return null;const o=Wi[e.system],r=6*t,a=1/(e.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(e=>e.selected).map(e=>e.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const e=this.frame?.objects.find(o=>o.name===t);return e===void 0?null:this.objects.get(e.id)??null}replacePresentedObject(t,e){for(const[o,r]of this.objects)if(r===t){const a=t.parent,i=[...t.children];t.removeFromParent();for(const f of i)e.add(f);a?.add(e),this.objects.set(o,e),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,e,o){const r=new Set(this.objects.values()),a=this.cursorOverlay.placementAt(t,e,o,this.root,i=>r.has(i));return a!==null&&(this.cursorOverlay.show(a),_t()),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 y).toArray().map(r=>r.toFixed(1)).join(","):"";return`${t.uuid}:${o}:${this.worldKey}`}report(t){t.then(_t,e=>console.error(`Rendered shading could not be applied: ${e instanceof Error?e.message:String(e)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),_t())}applyWorkbench(){const t=this.workbench&&!this.rendered,e=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 c=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,c.side,e):c});r.material=o.materials.length?i:i[0]}for(const[o,r]of this.workbenchMaterials)e.has(o)||(r.dispose(),this.workbenchMaterials.delete(o));this.rebuildInstances()}rebuildInstances(){this.depthInstances.setObjects(this.drawBatching&&!this.rendered?this.objects.values():[]),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()),this.materialRanges.setObjects(this.drawBatching&&!this.rendered?this.objects.values():[])}setDrawBatching(t){t!==this.drawBatching&&(this.drawBatching=t,this.rebuildInstances(),_t())}prepareDraw(t,e){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"&&e?.interactive===!0,e?.height??0);a&&this.instances.sync();const i=performance.now();this.materialRanges.prepare();const f=performance.now();this.transparentInstances.prepare(t,e?.multiDraw===!0);const c={opaqueMs:r-o,motionMs:i-r,rangesMs:f-i,transparentMs:performance.now()-f};this.drawPreparation.last=c,a&&(this.drawPreparation.navigation=c)}catch(o){throw this.materialRanges.finish(),this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw(),o}return()=>{this.materialRanges.finish(),this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw()}}prepareDepthDraw(t,e){if(!this.drawBatching||this.rendered||!this.depthInstances.supports(e))return;const o=this.transparentInstances.suspendDraw(),r=()=>{try{this.depthInstances.finish()}finally{o()}};try{this.depthInstances.prepare(t,e)}catch(a){throw r(),a}return r}workbenchFor(t,e,o){const r=(t!==null?this.frame?.materials[t]?.viewport:void 0)??fi,a=`${r.color.join(",")}|${r.roughness}|${r.metallic}|${e}`;o.add(a);let i=this.workbenchMaterials.get(a);return i||(i=hi(r,e),this.workbenchMaterials.set(a,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,e){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,e)}async applyRendered(t,e){const o=(t?fo(this.frame?.world)?.extinction:null)??new y;for(const a of[...this.materials.values(),this.fallback])Ls(a,o);this.rendered=t,this.lighting.setRendered(t);const r=t&&e?this.worldKeyFor(e):null;t?(this.capturing||r!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,e):this.world.clear(),this.worldApplied=this.capturing?null:r,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,e),t&&(await Zr(),await Promise.all([...this.textures.values()].map(a=>a.ready)),await this.world.ready())}applyShadows(t,e){this.root.updateMatrixWorld(!0);const o=[];for(const c of this.objects.values()){const d=c;if(d.isMesh&&(d.castShadow=t,d.receiveShadow=t,t&&d.visible)){const l=new fe().setFromObject(d);l.isEmpty()||o.push(l)}}if(!t||!o.length)return;const a=o.reduce((c,d)=>c.union(d),new fe).getBoundingSphere(new Ze),i=e?new Oe().setFromProjectionMatrix(new q().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)):null,f=i?o.flatMap(c=>rs(c,i)):[];for(const c of this.lights.values())c.isDirectionalLight&&e?ss(c,f,o):Jr(c,a.center,a.radius)}applyOverlays(t){const e=i=>{const f=t.objects.find(c=>c.name===i);return f===void 0?null:new q().set(...f.matrix.flat())},o=[...this.armatureOverlay.apply(t.armatures,e)],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?e(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),_t())}applyExtras(t){const e={};for(const[o,r]of Object.entries(t.cameras)){const a=_o.safeParse(r);a.success&&(e[o]=a.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(o=>o.visible),active:t.active,cameras:e,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),_t()},()=>this.awaitedImages.delete(o))),{texture:r.texture,width:i,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const e=this.objects.get(t.id);if(e&&(e.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 e=this.staged;if(!e||e.session!==t.session||e.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const o=Jo.parse(t.piece);if(e.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const r=`revision:${o.revision}`;e.meshes.set(t.mesh,{signature:r,geometry:Ce(Xn({...o.columns,attributes:o.attributes,activeUv:o.activeUv,renderUv:o.renderUv},r))})}else if(t.image!==void 0){if(e.images.has(t.image))throw new Error("Duplicate Blender image piece");e.images.set(t.image,ta.parse(t.piece))}}applyFrame(t){const e=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},o=Bi.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 _ of l.materials)if(_!==null&&!o.materials[_])throw new Error(`Missing runtime material ${_}`);const s=new Set([l.id]);let u=l.parent;for(;u!==null;){if(s.has(u))throw new Error("Runtime parent cycle");s.add(u);const _=i.get(u);if(!_)throw new Error(`Missing runtime parent ${u}`);u=_.parent}}const f=new Map,c=new Map;try{for(const[l,s]of Object.entries(o.volumes)){const u=JSON.stringify(s);this.frame?.session===o.session&&this.volumes.get(l)?.signature===u||c.set(l,{signature:u,mesh:is(s)})}for(const[l,s]of Object.entries(o.meshes)){if("unchanged"in s){const m=r?.meshes.get(l);if(m){if(m.signature!==`revision:${s.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(l,m);continue}const p=this.meshes.get(l)?.signature;if(this.frame?.session===o.session&&p!==void 0&&(p===`revision:${s.revision}`||!p.startsWith("revision:")))continue;throw new Error(p===void 0?`${qn}: the presenter does not hold runtime mesh ${l} (store ${s.store}, revision ${s.revision})`:`${qn}: the presenter holds runtime mesh ${l} at ${p}, not revision ${s.revision}`)}const u="hash"in s,_="columns"in s,h=_?`revision:${s.revision}`:u?s.hash:JSON.stringify(s);this.frame?.session===o.session&&this.meshes.get(l)?.signature===h||f.set(l,{signature:h,geometry:_?Ce(Xn({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},h)):u?Ce(s):yr(s)})}}catch(l){for(const s of f.values())s.geometry.dispose();for(const{mesh:s}of c.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 c){const u=this.volumes.get(l)?.mesh;u&&(u.removeFromParent(),u.geometry.dispose(),u.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 u=this.textures.get(l);if("width"in s){const g=s.rgba??(s.rgbaBase64?pn(s.rgbaBase64):void 0);if(!g)throw new Error(`Runtime image ${l} carries no raster`);const v=s.tiles?$i(l,s.tiles,s.colorspace??"sRGB"):void 0;if(u?.udim&&(u.udim.tiles.dispose(),u.udim.map.dispose(),delete u.udim),u&&u.width===s.width&&u.height===s.height){const O=u.texture.image;if(O.data){O.data.set(g),u.texture.needsUpdate=!0,u.revision=s.revision,v&&(u.udim=v);continue}}u?.texture.dispose(),this.textures.set(l,{texture:ki(g,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...v?{udim:v}:{}});continue}const _=s.encoded??(s.encodedBase64?pn(s.encodedBase64):void 0);if(!_)throw new Error(`Runtime image ${l} carries no bytes`);u?.texture.dispose(),u?.udim?.tiles.dispose(),u?.udim?.map.dispose();const h=s.colorspace??"sRGB",{texture:m,ready:p}=Ci(_,s.mime);m.colorSpace=h==="data"?Be:Ut,this.textures.set(l,{texture:m,ready:p,width:0,height:0,revision:s.revision,encoded:{bytes:_.slice(),mime:s.mime,colorspace:h}})}for(const[l,s]of Object.entries(o.materials)){const u=this.materials.get(l)??new ce;u.name=s.name;const _=s.texture?.tint;s.texture!==void 0?u.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,bt):u.color.setRGB(s.color[0],s.color[1],s.color[2],bt),u.opacity=s.color[3];const h=u.opacity<1||s.graph!==void 0&&ds(s.graph);u.transparent!==h&&(u.transparent=h,u.needsUpdate=!0),u.roughness=s.roughness,u.metalness=s.metallic,u.transmission=s.transmission,u.ior=s.ior,Fn(u,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const m=s.normal_texture?.image.name;if(m===void 0)u.normalMap&&(this.textureSamplers.delete(`${l}:normal`),u.normalMap=null,u.needsUpdate=!0);else{const b=this.textures.get(m);if(!b)throw new Error(`${me}: missing normal image ${m}`);const S=this.textureSamplers.get(`${l}:normal`,b.texture,s.normal_texture.extension,b.ready,s.normal_texture.uv);u.normalMap!==S&&(u.normalMap=S,u.needsUpdate=!0);const w=s.normal_space==="OBJECT"?Ra:Ia;u.normalMapType!==w&&(u.normalMapType=w,u.needsUpdate=!0),u.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(u.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],bt),u.emissiveIntensity=s.emission.strength):(u.emissive.setRGB(0,0,0),u.emissiveIntensity=1);const p=s.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(l)&&(this.textureSamplers.delete(`${l}:roughness`),u.roughnessMap=null,this.roughnessTextureNames.delete(l),u.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${me}: the presenter does not hold runtime image ${p} (revision ${s.roughness_texture.image.revision})`);const S=this.textureSamplers.get(`${l}:roughness`,b.texture,s.roughness_texture.extension,b.ready,s.roughness_texture.uv);u.roughnessMap!==S&&(u.roughnessMap=S,this.roughnessTextureNames.set(l,p),u.needsUpdate=!0)}const g=s.texture?.image.name??null;if(g===null)this.textureNames.has(l)&&(this.textureSamplers.delete(`${l}:color`),u.map=null,this.textureNames.delete(l),u.needsUpdate=!0);else{const b=this.textures.get(g);if(!b)throw new Error(`${me}: the presenter does not hold runtime image ${g} (revision ${s.texture.image.revision})`);const S=this.textureSamplers.get(`${l}:color`,b.texture,s.texture.extension,b.ready,s.texture.uv);u.map!==S&&(u.map=S,this.textureNames.set(l,g),u.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,O=new Set;Ss(u,v,b=>{const S=this.textures.get(b.name);if(!S)throw new Error(`${me}: the presenter does not hold runtime image ${b.name} (revision ${b.revision})`);if(b.tiled){if(!S.udim)throw new Error(`${me}: runtime image ${b.name} arrived without its UDIM tiles`);return S.udim}const w=`${l}:graph:${b.node}`;O.add(w);const A=this.textureSamplers.get(w,S.texture,b.extension,S.ready),M=b.closest?_n:te,E=b.closest?_n:b.mipmap?Ro:te;return(A.magFilter!==M||A.minFilter!==E)&&(A.magFilter=M,A.minFilter=E,A.needsUpdate=!0),A},this.photograph);for(const b of this.graphSamplers.get(l)??[])O.has(b)||this.textureSamplers.delete(b);this.graphSamplers.set(l,O),this.materials.set(l,u)}for(const l of o.objects){let s=this.objects.get(l.id);const u=l.volume?this.volumes.get(l.volume).mesh:null;if((!s||(u?s!==u:!!s.isMesh!=(l.mesh!==null)))&&(s?.removeFromParent(),s=u??(l.mesh!==null?new zt(this.meshes.get(l.mesh).geometry,this.fallback):new Le),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 _=new q().set(...i.get(l.parent).matrix.flat());s.matrix.premultiply(_.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 _=s;_.geometry=this.meshes.get(l.mesh).geometry,_.material=l.materials.length?l.materials.map(h=>h===null?this.fallback:this.materials.get(h)):this.fallback,Rs(_)}if(l.light){const _=this.lights.get(l.light)??null,h=Kr(o.lights[l.light],_);_&&_!==h&&(_.removeFromParent(),_.dispose()),h.parent!==s&&s.add(h),h.userData.volterOwnOverlay=!0,ts(h,s),this.lights.set(l.light,h)}}for(const l of o.objects){const s=this.objects.get(l.id),u=l.parent===null?this.root:this.objects.get(l.parent);s.parent!==u&&u.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 u of["normal","roughness","color"])this.textureSamplers.delete(`${l}:${u}`);for(const u of this.graphSamplers.get(l)??[])this.textureSamplers.delete(u);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:e}}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,e])=>({id:t,name:e.name,uuid:e.uuid,geometry:e.geometry?.uuid,visible:e.visible}))}}drawStatistics(){return{enabled:this.drawBatching,preparation:{...this.drawPreparation},depth:this.depthInstances.inspect(),materialRanges:this.materialRanges.inspect(),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 e=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 ft))throw new Error(`Blender capture cannot copy interleaved ${l}`);return new Float32Array(s.array)},c=f("position");if(!c)throw new Error(`Blender capture mesh ${r} has no positions`);const d=i.getIndex();e.meshes[r]={hash:a,positions:c,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(i.userData.blenderUvChannels??{}).map(([l,s])=>{const u=f(`uv${s}`);if(!u)throw new Error(`Blender capture mesh ${r} is missing UV layer ${l}`);return{name:l,data:u}}),orco:i.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(i.userData.blenderAttributes??[]).map(l=>{const s=f(Bt(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:c.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)e.volumes[r]=Wo.parse(JSON.parse(a));const o=new Set(Object.values(e.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)e.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`);e.images[r]={revision:a.revision,width:a.width,height:a.height,rgba:i.slice(),colorspace:a.texture.colorSpace===Be?"data":"sRGB",...a.udim?{tiles:a.udim.frame}:{}}}}return e}follow(){const t=new He;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let e=!1;return{view:t,dispose:()=>{e||(e=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),e=this.frame,o=this.createWorldVolumePass(),r=new He;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:e.session,revision:e.revision,prepare:f=>{if(a)throw new Error("Blender capture snapshot is disposed");return r.setRendered(!0,f)},dispose:i}}createWorldVolumePass(){const t=fo(this.frame?.world);return t?new Bs(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const e=t,o=e.meshes;if(typeof o!="object"||o===null)return;const r=typeof e.session=="string"?e.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={...e,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){this.depthInstances.clear(),this.materialRanges.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:e}of this.textures.values())t.dispose(),e?.tiles.dispose(),e?.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 Ji=new He;function ea(n){const t=atob(n),e=new Uint8Array(t.length);for(let o=0;o<t.length;o++)e[o]=t.charCodeAt(o);return e}function un(n){const t=ea(n);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function qi(n){const t=ea(n);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function Hi(n){return new q().set(...n.flat())}function yo(n,t){return[n.object,n.mesh,n.armature,n.vertexCount,n.bones.length,t].join("|")}class Gi{#e=new Map;#o=null;#a=null;#t=null;#r=null;#n=null;#i=null;#l=new Set;#u=0;#d=[];#s=0;get version(){return this.#u}get engineCalls(){return this.#s}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,e=t?.frameStart??1,o=t?.frameEnd??250,r=t?.fps??24;return{frame:this.frame(),start:e,end:o,fps:r,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#e.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.#e.keys()],warnings:this.#d,engineCalls:this.#s,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.#n!==null}async bind(t,e){this.#s++;const o=await e.rig();if(!o)return;const r=[],a=new Set;let i=!1;for(const _ of o.rigs){if(!_.object||!_.armature||!_.skinIndexBase64||!_.skinWeightBase64){_.reason&&r.push(_.reason);continue}a.add(_.object);const h=yo(_,o.frame);if(this.#e.get(_.object)?.signature===h)continue;const m=this.#_(t,_,o.frame,r);m&&(this.#e.get(_.object)?.skeleton.dispose(),this.#e.set(_.object,m),i=!0)}for(const[_,h]of[...this.#e])a.has(_)||(h.skeleton.dispose(),h.boneRoot.removeFromParent(),this.#e.delete(_),i=!0);this.#s++;const f=await e.clip(),c=this.#t,d=f?.frameStart!==c?.frameStart||f?.frameEnd!==c?.frameEnd||f?.fps!==c?.fps,l=f?.action!==c?.action||f?.tracks.length!==c?.tracks.length||f?.clipStart!==c?.clipStart||f?.clipEnd!==c?.clipEnd;this.#t=f??null,(!f||f.scene!==c?.scene)&&(this.#r=null),f?.reason&&r.push(f.reason),f&&(l||i)&&this.#h(t,f,r);const s=this.#n?.snapshot().activeSubject;d&&s&&this.#n?.setActiveSubject(s);const u=this.#n?.snapshot().playbackState==="playing";f&&!u&&(d||c?.frameCurrent!==f.frameCurrent)&&(this.#c(f.frameCurrent),this.#n&&f.fps>0&&this.#n.seek(f.frameCurrent/f.fps)),this.#d=r,this.#f()}#_(t,e,o,r){const a=t.objectForBlenderName(e.object??""),i=t.objectForBlenderName(e.armature??"");if(!a||!i)return null;const f=a,c=f.geometry;if(!c)return null;const d=c.getAttribute("blenderVertex");if(!d)return r.push(`"${e.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(e.vertexCount===0)return null;let l=0;for(let w=0;w<d.count;w++)l=Math.max(l,d.getX(w));if(l>=e.vertexCount)return r.push(`"${e.object}" is not skinned here: its presented geometry references Blender vertex ${l} while the mesh declares ${e.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=qi(e.skinIndexBase64??""),u=un(e.skinWeightBase64??""),_=d.count,h=new Uint16Array(_*4),m=new Float32Array(_*4);for(let w=0;w<_;w++){const A=d.getX(w);for(let M=0;M<4;M++)h[w*4+M]=s[A*4+M]??0,m[w*4+M]=u[A*4+M]??0}c.setAttribute("skinIndex",new Ca(h,4)),c.setAttribute("skinWeight",new Nt(m,4));const p=new ct;p.name=`${e.armature}:bones`;const g=[],v=e.bones.map(w=>Hi(w.pose)),O=new Map(e.bones.map((w,A)=>[w.name,A]));e.bones.forEach((w,A)=>{const M=new ka;M.name=w.name,g.push(M);const E=w.parent===null?void 0:O.get(w.parent);(E===void 0?v[A].clone():v[E].clone().invert().multiply(v[A])).decompose(M.position,M.quaternion,M.scale),(E===void 0?p:g[E]).add(M)}),i.add(p);const b=new $a(c,f.material);b.name=f.name,b.matrixAutoUpdate=!1,b.matrix.copy(f.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale),b.userData=f.userData,b.frustumCulled=!1,t.replacePresentedObject(f,b),t.root.updateMatrixWorld(!0);const S=new La(g);return b.bind(S,b.matrixWorld.clone()),e.constrainedBones?.length&&r.push(`Bone constraints on ${e.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),e.unmappedGroups?.length&&r.push(`${e.object} carries vertex groups no bone is named for (${e.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:e.object??"",armature:e.armature??"",mesh:b,boneRoot:p,bones:g,skeleton:S,frame:o,signature:yo(e,o)}}#h(t,e,o){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!e.tracks.length||e.clipStart===void 0||e.clipEnd===void 0)return;const r=e.armature?t.objectForBlenderName(e.armature):null;if(!r)return;const a=new Map;for(const s of this.#e.values())if(s.armature===e.armature)for(const u of s.bones)a.set(u.name,u);const i=[],f=new Set;for(const s of e.tracks){const u=a.get(s.bone);if(!u){f.add(s.bone);continue}const _=un(s.timeBase64),h=un(s.valueBase64),m=`${u.uuid}.${s.property}`;i.push(s.property==="quaternion"?new ja(m,Array.from(_),Array.from(h)):new Va(m,Array.from(_),Array.from(h)))}if(f.size&&o.push(`${e.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!i.length)return;const c=e.duration??(e.clipEnd-e.clipStart)/e.fps,d=new Ba(r),l=d.clipAction(new Ua(e.action??"action",c,i));l.setLoop(Wa,Number.POSITIVE_INFINITY),l.play(),this.#o=d,this.#a=l,this.#c(e.frameCurrent),this.#m()}#c(t){const e=this.#t;if(!e)return;const o=Math.min(e.frameEnd,Math.max(e.frameStart,t));if(this.#r=o,!this.#o||e.clipStart===void 0||e.clipEnd===void 0)return;const r=(e.clipEnd-e.clipStart)/e.fps;this.#o.setTime(Math.max(0,Math.min(r-1e-4,(o-e.clipStart)/e.fps))),this.#m()}#m(){for(const t of this.#e.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),e=this.#t;if(!e)return t;const o=e.scene;return!o||e.frameCurrent===t||(this.#s++,await Xa(`bpy.data.scenes[${JSON.stringify(o)}]`,"frame_current",t,void 0,!1),this.#t={...e,frameCurrent:t},this.#f()),t}get transport(){return this.#n}attachTo(t){this.#i?.(),this.#n=t;const e=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(),e(),this.#n===t&&(this.#n=null),this.#i=null};this.#i=r;const a=this.#t;return a&&a.fps>0&&t.seek(a.frameCurrent/a.fps),r}seekSeconds(t){const e=this.#t?.fps||24;this.#c(Math.round(t*e)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#i?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null,this.#t=null,this.#r=null;for(const t of this.#e.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#e.clear()}}const na=new Gi;function tl(n){return na.subscribe(n)}function el(){return na.version}export{na as a,el as b,Ji as c,tl as s};
|
|
7194
|
+
#include <opaque_fragment>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const mi=64;function _i(n,t){return Array.isArray(n)&&Array.isArray(t)?n.length===t.length&&n.every((e,o)=>e===t[o]):n===t}function Jt(n){for(let t=n;t;t=t.parent)if(!t.visible)return!1;return!0}function yn(n){if(n.determinant()<=0)return!1;const t=n.elements,e=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=(s,f)=>t[s]*t[f]+t[s+1]*t[f+1]+t[s+2]*t[f+2];return Number.isFinite(e+o+r)&&Math.min(e,o,r)>0&&Math.abs(a(0,4))<=1e-7*e*o&&Math.abs(a(0,8))<=1e-7*e*r&&Math.abs(a(4,8))<=1e-7*o*r}class hi{constructor(t){this.root=t,this.batches=[],this.inverse=new q,this.matrix=new q,this.box=new ue,this.projection=new q,this.frustum=new He,this.camera=null,this.eligible=0,this.excluded={}}rebuild(t,e){if(this.clear(),!e)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 s=a;if(!s.isMesh)continue;if(s.isSkinnedMesh||s.isInstancedMesh||s.morphTargetInfluences||s.layers.mask!==1){r("deformationOrLayers");continue}const f=Array.isArray(s.material)?s.material:[s.material];if(f.some(l=>l.transparent||l.transmission>0||l.isShaderMaterial)){r("material");continue}if(f.some(l=>Yo(l,s.geometry).size>12)){r("attributeBudget");continue}if(this.matrix.multiplyMatrices(this.inverse,s.matrixWorld),!yn(this.matrix)){r("transform");continue}this.eligible++;const c=`${s.geometry.id}:${Array.isArray(s.material)?"slots":"single"}:`+f.map(l=>l.uuid).join(",")+`:${s.renderOrder}`,d=o.get(c);d?d.push(s):o.set(c,[s])}for(const a of o.values()){if(a.length<2)continue;const s=f=>{if(f.length>mi){this.box.makeEmpty();for(const h of f)this.box.expandByPoint(new y().setFromMatrixPosition(h.matrixWorld));const i=this.box.getSize(new y),u=i.x>=i.y&&i.x>=i.z?12:i.y>=i.z?13:14;f.sort((h,_)=>h.matrixWorld.elements[u]-_.matrixWorld.elements[u]);const m=Math.floor(f.length/2);s(f.slice(0,m)),s(f.slice(m));return}if(f.length<2)return;const c=f[0],d=new No(c.geometry,c.material,f.length);d.name="Blender repeated geometry",d.userData.engineInternal=!0,d.matrixAutoUpdate=!1,d.renderOrder=c.renderOrder,d.instanceMatrix.setUsage(Ro);const l={draw:d,members:f.map(i=>({mesh:i,layers:i.layers.mask}))};d.raycast=(i,u)=>{for(const{mesh:m}of l.members)m.layers.mask===0&&Jt(m)&&m.raycast(i,u)},this.root.add(d),d.updateMatrixWorld(!0),this.batches.push(l)};s(a)}this.sync()}sync(){if(this.batches.length){this.inverse.copy(this.root.matrixWorld).invert();for(const{draw:t,members:e}of this.batches){let o=0,r=!1;for(const a of e){const{mesh:s}=a;if(this.matrix.multiplyMatrices(this.inverse,s.matrixWorld),!(s.parent!==null&&s.geometry===t.geometry&&_i(s.material,t.material)&&yn(this.matrix))){s.layers.mask|=a.layers;continue}if(s.layers.mask&=~a.layers,!Jt(s)||this.camera&&(!this.camera.layers.isEnabled(0)||s.frustumCulled&&!this.frustum.intersectsObject(s)))continue;const c=o*16;this.matrix.elements.some((d,l)=>Math.fround(d)!==t.instanceMatrix.array[c+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:e}of this.batches){for(const{mesh:o,layers:r}of e)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:e})=>t+e.count,0),eligible:this.eligible,excluded:{...this.excluded}}}}const wn=64,an=4*1024*1024,pi=32*1024*1024,gi=1024;class vi{constructor(){this.families=new Map,this.partitions=new Map,this.registrations=new Map,this.bytes=0,this.drawCount=0,this.created=0,this.pending=!1}begin(){this.created=0,this.pending=!1,this.registrations.clear()}register(t,e,o){const r=`${t.id}:${e.uuid}:${o}`;if(this.registrations.has(r))return this.registrations.get(r);this.registrations.set(r,null);const a=t.getAttribute("position"),s=t.index?.count??a?.count??0;if(!a||t.drawRange.start!==0||t.drawRange.count<s||Object.keys(t.morphAttributes).length)return null;const f=[!!t.index,t.userData.blenderUvChannels??null],c=[t.index?.id,t.index?.version];let d=(t.index?.count??0)*4;for(const p of Object.keys(t.attributes).sort()){const g=t.getAttribute(p);if(!(g instanceof ft)||g.isInstancedBufferAttribute||g instanceof Sa||g.count!==a.count)return null;f.push([p,g.array.constructor.name,g.itemSize,g.normalized,g.gpuType]),c.push(p,g.id,g.version),d+=g.array.byteLength}if(d>an)return null;const l=`multi:${e.uuid}:${o}:${JSON.stringify(f)}`;let i=this.partitions.get(l);i||(i=[],this.partitions.set(l,i));let u=i.find(p=>this.families.get(p).shapes.has(t.id));u??=i.find(p=>this.families.get(p).reservedBytes+d<=an),u||(u=`${l}:${i.length}`,i.push(u));let m=this.families.get(u);m||(m={material:e,shapes:new Map,template:null,ids:new Map,draws:[],dirty:!0,bytes:0,reservedBytes:0,refused:!1},this.families.set(u,m));const h=JSON.stringify(c),_=m.shapes.get(t.id);return(!_||_.stamp!==h)&&(m.reservedBytes+=d-(_?.bytes??0),m.shapes.set(t.id,{geometry:t,stamp:h,bytes:d}),m.dirty=!0),this.registrations.set(r,u),u}pack(){for(const t of this.families.values()){if(!t.dirty)continue;this.release(t),t.dirty=!1;let e=0,o=0,r=0;for(const{geometry:f}of t.shapes.values()){e+=f.getAttribute("position").count,o+=f.index?.count??0;for(const c of Object.values(f.attributes))r+=c.array.byteLength}if(r+=o*(e>65535?4:2),t.refused=r>an||this.bytes+r>pi,t.refused)continue;const a=new we(wn,e,o,t.material);a.sortObjects=!1,a.perObjectFrustumCulled=!1,a.frustumCulled=!1,a.matrixAutoUpdate=!1,a.boundingSphere=new Mn,a.name="Blender ordered multi-draw",a.userData.engineInternal=!0;for(const{geometry:f}of t.shapes.values())t.ids.set(f.id,a.addGeometry(f));const s=t.shapes.values().next().value.geometry;a.geometry.userData.blenderUvChannels=s.userData.blenderUvChannels;for(const f of Object.keys(s.attributes))a.geometry.getAttribute(f).gpuType=s.getAttribute(f).gpuType;t.template=a,t.bytes=r,this.bytes+=r}}available(t){return!!this.families.get(t)?.template}get(t,e){const o=this.families.get(t),r=o.template;if(!r)return null;let a=o.draws[e];if(!a){if(this.drawCount>=gi)return null;if(this.created>=4)return this.pending=!0,null;a=new we(1,0,0,o.material),a.dispose(),a.copy(r);for(const f of Object.keys(r.geometry.attributes))a.geometry.setAttribute(f,r.geometry.getAttribute(f));a.geometry.setIndex(r.geometry.index);const s=o.ids.values().next().value;for(let f=0;f<wn;f++)a.addInstance(s),a.setVisibleAt(f,!1);o.draws.push(a),this.created++,this.drawCount++}return a}geometryId(t,e){return this.families.get(t).ids.get(e.id)}inspect(){return{bytes:this.bytes,draws:this.drawCount,pending:this.pending,refusedFamilies:[...this.families.values()].filter(t=>t.refused).length}}release(t){for(const e of t.draws){e.removeFromParent();for(const o of Object.keys(e.geometry.attributes))e.geometry.deleteAttribute(o);e.geometry.setIndex(null),e.dispose(),this.drawCount--}t.draws.length=0,t.template?.dispose(),t.template=null,t.ids.clear(),this.bytes-=t.bytes,t.bytes=0}clear(){for(const t of this.families.values())this.release(t);this.families.clear(),this.partitions.clear(),this.registrations.clear(),this.pending=!1}}const _o=128;class xi{constructor(){this.sources=new Map,this.geometryKeys=new Map,this.frame=0,this.count=0}begin(){this.frame++,this.geometryKeys.clear()}get(t,e){let o=this.geometryKeys.get(e.geometry);o===void 0&&(o=JSON.stringify([e.geometry.userData.blenderUvChannels??null,Object.keys(e.geometry.attributes).sort().map(f=>[f,e.geometry.getAttribute(f).itemSize])]),this.geometryKeys.set(e.geometry,o));const r=`${e instanceof we?"batch":"instance"}:${o}`;let a=this.sources.get(t);a||(a=new Map,this.sources.set(t,a));let s=a.get(r);if(s)s.frame!==this.frame&&(s.ready=so(t,s.material)!==null,s.sourceVersion!==t.version&&(s.material.needsUpdate=!0),s.sourceVersion=t.version,s.frame=this.frame);else{if(this.count>=_o)return t;const f=so(t);if(!f)return t;s={material:f,sourceVersion:t.version,frame:this.frame,ready:!0},a.set(r,s),this.count++}return s.ready?s.material:t}clear(){for(const t of this.sources.values())for(const{material:e}of t.values())e.dispose();this.sources.clear(),this.geometryKeys.clear(),this.count=0}inspect(){return{variants:this.count,limit:_o}}}const re=wn;function ho(n){for(let t=n.parent;t;t=t.parent)if(t.isGroup)return t.renderOrder;return 0}class bi{constructor(t){this.root=t,this.objects=[],this.drawMaterials=new xi,this.ordered=new vi,this.mixedDraws=new Map,this.multiDraw=!1,this.pools=new Map,this.hidden=[],this.inverse=new q,this.matrix=new q,this.projection=new q,this.frustum=new He,this.centre=new y,this.depth=new Ue,this.batches=0,this.instances=0,this.excluded={},this.plannedProjection=new q,this.projectionKnown=!1,this.planState=[],this.planned=[],this.stateIndex=0,this.stateChanged=!1}setObjects(t){this.clear(),this.objects=[...t].filter(e=>e.isMesh===!0)}prepare(t,e=!1){if(this.finishDraw(),this.drawMaterials.begin(),!this.objects.length)return;t.updateMatrixWorld(),this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);const o=this.multiDraw!==e;if(this.multiDraw=e,!this.planChanged(t)&&!o&&!this.ordered.pending){for(const c of this.planned){c.mesh.visible=!0;const d=c.members[0].material;c.mesh.material=this.drawMaterials.get(Array.isArray(d)?d[0]:d,c.mesh);for(const l of c.members)l.layers.disable(0),this.hidden.push(l)}return}this.planned.length=0;for(const c of this.mixedDraws.values())c.members.length=0;this.ordered.begin();for(const c of this.pools.values())for(const d of c)d.mesh.visible=!1,d.members.length=0;this.batches=this.instances=0,this.excluded={},this.frustum.setFromProjectionMatrix(this.projection),this.inverse.copy(this.root.matrixWorld).invert();const a=[],s=new Map;for(const c of this.objects){const d=Array.isArray(c.material)?c.material:[c.material];if(!d.some(v=>v.visible&&v.transparent)||!Jt(c)||!c.layers.test(t.layers)||c.frustumCulled&&!this.frustum.intersectsObject(c))continue;const l=c;l.boundingSphere!==void 0?(l.boundingSphere===null&&l.computeBoundingSphere?.(),this.centre.copy(l.boundingSphere.center)):(c.geometry.boundingSphere||c.geometry.computeBoundingSphere(),this.centre.copy(c.geometry.boundingSphere.center)),this.centre.applyMatrix4(c.matrixWorld);const i=this.centre.clone(),u=this.depth.set(i.x,i.y,i.z,1).applyMatrix4(this.projection).z;let m=null,h=null;const _=d.length===1?d[0]:null,p=ho(c);if(_&&_.visible&&_.transparent&&!_.isShaderMaterial&&!(_.transmission>0)&&(_.side!==$e||_.forceSinglePass)&&!c.isSkinnedMesh&&!c.morphTargetInfluences&&!c.isInstancedMesh&&c.layers.mask===1&&p===this.root.renderOrder){const v=c.geometry,O=v.index?.count??v.getAttribute("position").count,b=!Array.isArray(c.material)||v.groups.length===1&&v.groups[0].start===0&&v.groups[0].count===O&&v.groups[0].materialIndex===0,S=`${v.id}:${_.uuid}:${c.renderOrder}`;let w=s.get(S);w===void 0&&(w=Yo(_,v).size<=12,s.set(S,w)),this.matrix.multiplyMatrices(this.inverse,c.matrixWorld),b&&w&&yn(this.matrix)&&(m=_,h=S)}if(h===null){const v=_?_.isShaderMaterial?"customShader":_.transmission>0?"transmission":_.side===$e&&!_.forceSinglePass?"twoPass":"geometryLayersOrTransform":"multipleMaterials";this.excluded[v]=(this.excluded[v]??0)+1}const g=e&&h&&m?this.ordered.register(c.geometry,m,c.renderOrder):null;a.push({mesh:c,material:m,key:h,batchKey:g,groupOrder:p,z:u,centre:i})}this.ordered.pack();for(const c of a)c.batchKey&&this.ordered.available(c.batchKey)&&(c.key=c.batchKey);for(const[c]of this.mixedDraws)c.parent||this.mixedDraws.delete(c);a.sort((c,d)=>c.groupOrder-d.groupOrder||c.mesh.renderOrder-d.mesh.renderOrder||d.z-c.z||c.mesh.id-d.mesh.id);const f=new Map;for(let c=0;c<a.length;){const d=a[c];let l=c+1;if(d.key!==null)for(;l<a.length&&a[l].key===d.key;)l++;const i=a[c-1],u=a[l],m=i?.z===d.z&&i.mesh.renderOrder===d.mesh.renderOrder||u?.z===a[l-1].z&&u.mesh.renderOrder===d.mesh.renderOrder;if(d.key!==null&&l-c>=2&&!m){let h=!0;for(let _=c+re;_<l;_+=re)a[_-1].z===a[_].z&&(h=!1);if(h)for(let _=c;_<l;_+=re){const p=Math.min(re,l-_);if(p<2)continue;const g=a[_],v=f.get(d.key)??0;f.set(d.key,v+1);const O=d.key.startsWith("multi:");let b;if(O){const w=this.ordered.get(d.key,v);if(!w)continue;if(b=this.mixedDraws.get(w),!b){b={mesh:w,members:[]},this.mixedDraws.set(w,b);const A=b;w.raycast=(M,E)=>{if(w.visible)for(const F of A.members)Jt(F)&&F.raycast(M,E)},this.root.add(w)}}let S=this.pools.get(d.key);if(S||(S=[],this.pools.set(d.key,S)),O||(b=S[v]),!b){const w=new No(d.mesh.geometry,d.material,re);w.name="Blender ordered transparency",w.userData.engineInternal=!0,w.matrixAutoUpdate=!1,w.frustumCulled=!1,w.boundingSphere=new Mn,w.instanceMatrix.setUsage(Ro),b={mesh:w,members:[]};const A=b;w.raycast=(M,E)=>{if(w.visible)for(const F of A.members)Jt(F)&&F.raycast(M,E)},S.push(b),this.root.add(w)}b.mesh.material=this.drawMaterials.get(d.material,b.mesh),b.mesh.visible=!0,b.mesh.renderOrder=g.mesh.renderOrder,b.mesh.boundingSphere.center.copy(g.centre).applyMatrix4(this.inverse),b.mesh.updateMatrixWorld(!0);for(let w=0;w<p;w++){const A=a[_+w].mesh;this.matrix.multiplyMatrices(this.inverse,A.matrixWorld),b.mesh.setMatrixAt(w,this.matrix),b.mesh instanceof we&&(b.mesh.setGeometryIdAt(w,this.ordered.geometryId(d.key,A.geometry)),b.mesh.setVisibleAt(w,!0)),b.members.push(A),A.layers.disable(0),this.hidden.push(A)}if(b.mesh instanceof we)for(let w=p;w<re;w++)b.mesh.setVisibleAt(w,!1);else b.mesh.count=p,b.mesh.instanceMatrix.needsUpdate=!0;this.planned.push(b),this.batches++,this.instances+=p}}c=l}this.ordered.pending&&queueMicrotask(ht)}inspect(){return{batches:this.batches,instances:this.instances,excluded:{...this.excluded},multiDraw:this.ordered.inspect(),materials:this.drawMaterials.inspect()}}observe(t){this.planState[this.stateIndex]!==t&&(this.planState[this.stateIndex]=t,this.stateChanged=!0),this.stateIndex++}planChanged(t){if(!this.projectionKnown||!this.plannedProjection.equals(this.projection))return this.plannedProjection.copy(this.projection),this.projectionKnown=!0,this.planState.length=0,!0;this.stateIndex=0,this.stateChanged=this.planState.length===0,this.observe(t.layers.mask);for(const o of this.projection.elements)this.observe(o);for(const o of this.root.matrixWorld.elements)this.observe(o);const e=new Set;for(const o of this.objects){if(!(Array.isArray(o.material)?o.material:[o.material]).some(c=>c.visible&&c.transparent))continue;this.observe(o.parent?.id??-1),this.observe(Jt(o)?1:0),this.observe(o.layers.mask),this.observe(o.renderOrder),this.observe(ho(o)),this.observe(o.frustumCulled?1:0),this.observe(o.morphTargetInfluences?1:0);for(const c of o.matrixWorld.elements)this.observe(c);const a=o.geometry;if(this.observe(a.id),!e.has(a)){e.add(a),this.observe(a.index?.id??-1),this.observe(a.index?.version??-1),this.observe(JSON.stringify(a.userData.blenderUvChannels??null));for(const c of Object.keys(a.attributes).sort()){const d=a.getAttribute(c);this.observe(c),d instanceof ft&&(this.observe(d.id),this.observe(d.version))}}this.observe(a.drawRange.start),this.observe(a.drawRange.count),this.observe(a.index?.count??a.getAttribute("position").count),this.observe(a.groups.length);for(const c of a.groups)this.observe(c.start),this.observe(c.count),this.observe(c.materialIndex??0);const s=o.boundingSphere??a.boundingSphere;this.observe(s?.center.x??0),this.observe(s?.center.y??0),this.observe(s?.center.z??0),this.observe(s?.radius??-1);const f=Array.isArray(o.material)?o.material:null;if(this.observe(f?.length??-1),f)for(const c of f)this.observeMaterial(c);else this.observeMaterial(o.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:e}of t)e.visible=!1;for(const{mesh:t}of this.mixedDraws.values())t.visible=!1}clear(){this.finishDraw();for(const t of this.pools.values())for(const{mesh:e}of t)e.removeFromParent(),e.dispose();this.pools.clear(),this.ordered.clear(),this.drawMaterials.clear(),this.mixedDraws.clear(),this.planned.length=0,this.planState.length=0,this.projectionKnown=!1,this.objects=[],this.batches=this.instances=0}}const yi=8*1024*1024;class wi{constructor(){this.objects=[],this.copies=new Map,this.swapped=[],this.bytes=0,this.savedDraws=0}setObjects(t){this.clear(),this.objects=[...t].filter(e=>e.isMesh===!0)}prepare(){this.savedDraws=0;for(const t of this.objects){const e=t.geometry,o=t.material;if(t.layers.mask===0||!Array.isArray(o)||e.groups.length<8||!e.index||t.isSkinnedMesh||t.isInstancedMesh||t.morphTargetInfluences||Object.keys(e.morphAttributes).length||e.drawRange.start!==0||e.drawRange.count<e.index.count||o.some(s=>s.transparent||s.transmission>0||s.isShaderMaterial))continue;const r=JSON.stringify([e.id,e.index.id,e.index.version,o.map(s=>s.uuid),e.groups,Object.entries(e.attributes).map(([s,f])=>[s,f.id])]);let a=this.copies.get(r);if(!a){let s=0,f=!0;const c=new Map;for(const m of e.groups){const h=m.materialIndex??0,_=o[h];if(!_||m.start!==s||m.count<=0||m.count%3!==0){f=!1;break}s+=m.count;const p=c.get(_.uuid);p?p.groups.push(m):c.set(_.uuid,{slot:h,groups:[m]})}if(!f||s!==e.index.count||c.size>=e.groups.length)continue;const d=e.index.array.byteLength;if(this.bytes+d>yi)continue;const l=new oe;for(const[m,h]of Object.entries(e.attributes))l.setAttribute(m,h);const i=e.index.clone();let u=0;for(const m of c.values()){const h=u;for(const _ of m.groups)i.array.set(e.index.array.subarray(_.start,_.start+_.count),u),u+=_.count;l.addGroup(h,u-h,m.slot)}l.setIndex(i),l.boundingBox=e.boundingBox?.clone()??null,l.boundingSphere=e.boundingSphere?.clone()??null,l.userData={...e.userData},a={geometry:l,signature:r,bytes:d,before:e.groups.length,after:c.size},this.copies.set(r,a),this.bytes+=d}this.swapped.push({mesh:t,geometry:e}),t.geometry=a.geometry,this.savedDraws+=a.before-a.after}}finish(){for(const{mesh:t,geometry:e}of this.swapped)t.geometry=e;this.swapped.length=0}inspect(){return{copies:this.copies.size,bytes:this.bytes,savedRanges:this.savedDraws}}release(t){for(const e of Object.keys(t.geometry.attributes))t.geometry.deleteAttribute(e);t.geometry.dispose(),this.bytes-=t.bytes}clear(){this.finish();for(const t of this.copies.values())this.release(t);this.copies.clear(),this.objects=[],this.savedDraws=0}}const rn=64*1024*1024,po=150,Ie=49152,Pt=8192,go=Symbol("navigation geometry replaced");class Oi{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 He,this.centre=new y,this.boxCentre=new y,this.halfExtent=new y,this.viewWorld=new q,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 e=new Map;for(const s of t){const f=s;if(!f.isMesh||f.isSkinnedMesh||f.isInstancedMesh||f.morphTargetInfluences)continue;const c=f.geometry,d=c.getAttribute("position");if(!c.index||c.index.count<6144||!d||d.count>8e6||Object.values(c.attributes).some(i=>!(i instanceof ft)||i.isFloat16BufferAttribute||i.isInstancedBufferAttribute)||Object.keys(c.morphAttributes).length||c.drawRange.start!==0||c.drawRange.count<c.index.count)continue;if(Array.isArray(f.material)){let i=0;if(!c.groups.length||c.groups.some(u=>{const m=u.start===i&&u.count>0&&u.count%3===0&&Number.isInteger(u.materialIndex)&&u.materialIndex>=0&&u.materialIndex<f.material.length;return i=u.start+u.count,!m})||i!==c.index.count)continue}const l=e.get(c);l?l.push(f):e.set(c,[f])}this.groups=e;const o=s=>{let f=this.identities.get(s);return f===void 0&&(f=++this.nextIdentity,this.identities.set(s,f)),f},r=[...e].map(([s,f])=>`${s.id}:${o(s.index)}:${s.index.version}:${Array.isArray(f[0].material)}:${JSON.stringify(s.groups)}:`+Object.entries(s.attributes).map(([c,d])=>`${c}:${o(d)}:${d.version}`).join(",")).join(";");if(r===this.signature)return;this.releaseCopies(),this.signature=r,this.unavailable=null;const a=[...e].filter(([,s])=>s.length>=3);a.reduce((s,[f,c])=>s+f.index.count*c.length,0)<6e6||(a.sort(([s,f],[c,d])=>c.index.count*d.length-s.index.count*f.length),this.queue=a.map(([s])=>s),this.next())}async next(){if(this.building||this.unavailable||this.bytes>=rn)return;const t=this.queue.shift();if(!t){this.worker?.terminate(),this.worker=null;return}this.building=!0;const e=this.generation,o=()=>{if(e!==this.generation)throw go;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 N=this.pending;this.pending=null,N.resolve(x.data)}},this.worker.onerror=x=>{this.unavailable=x.message||"Navigation geometry worker unavailable",this.worker?.terminate(),this.worker=null;const N=this.pending;this.pending=null,N?.resolve({id:N.id,refusal:this.unavailable})});const a=t.getAttribute("position"),s=this.groups.get(t),f=Array.isArray(s[0].material);if(s.some(x=>Array.isArray(x.material)!==f))return;const c=f?t.groups:[{start:0,count:t.index.count}],d=c.flatMap(x=>{const N=[];for(let T=x.start;T<x.start+x.count;T+=Ie)N.push({start:T,count:Math.min(Ie,x.start+x.count-T),materialIndex:x.materialIndex});return N}),l=t.getAttribute("blenderVertex"),i=new Uint32Array(a.count),u=new Uint8Array(a.count),m=x=>l?l.getX(x):x;for(let x=0;x<d.length;x++){const N=d[x];for(let T=N.start;T<N.start+N.count;T+=Pt){await r();for(let U=T;U<Math.min(T+Pt,N.start+N.count);U++){const $=m(t.index.getX(U));if(!Number.isInteger($)||$<0||$>=i.length)return;i[$]?i[$]!==x+1&&(u[$]=1):i[$]=x+1}}}const h=Object.entries(t.attributes).filter(([x])=>x!=="position"&&x!=="blenderVertex"),_=h.reduce((x,[,N])=>x+N.itemSize,0);if(_>32)return;const p=[];let g=0;for(const[x,N]of h)for(let T=0;T<N.itemSize;T++,g++)x!=="normal"&&p.push(g);const v=h.flatMap(([x,N])=>Array(N.itemSize).fill(x==="normal"?.5:1)),O=t.boundingBox?.clone()??new ue;if(!t.boundingBox){const x=new y;for(let N=0;N<a.count;N+=Pt){await r();for(let T=N;T<Math.min(N+Pt,a.count);T++)O.expandByPoint(x.fromBufferAttribute(a,T))}}if(!t.boundingSphere)return;const b=Math.max(O.max.x-O.min.x,O.max.y-O.min.y,O.max.z-O.min.z)*.002,S=[],w=[];let A=0,M=0;for(const x of c){const N=A;for(let T=x.start;T<x.start+x.count;T+=Ie){await r();const U=Math.min(T+Ie,x.start+x.count),$=[],k=new Map,P=new Uint32Array(U-T);for(let Q=T;Q<U;Q++){const mt=t.index.getX(Q);let Tt=k.get(mt);Tt===void 0&&(Tt=$.length,$.push(mt),k.set(mt,Tt)),P[Q-T]=Tt}const B=new Uint8Array($.length),K=new Float32Array($.length*3),ot=new Float32Array($.length*_);for(let Q=0;Q<$.length;Q+=Pt){await r();for(let mt=Q;mt<Math.min(Q+Pt,$.length);mt++){const Tt=$[mt];B[mt]=u[m(Tt)];for(let kt=0;kt<3;kt++)K[mt*3+kt]=a.getComponent(Tt,kt);let qt=0;for(const[,kt]of h){for(let Ae=0;Ae<kt.itemSize;Ae++)ot[mt*_+qt+Ae]=kt.getComponent(Tt,Ae);qt+=kt.itemSize}}}const dt=++this.nextId,et=await new Promise(Q=>{this.pending={id:dt,resolve:Q};const mt={id:dt,positions:K,indices:P,attributes:ot,stride:_,weights:v,absoluteError:b,protectedComponents:p,locks:B};this.worker.postMessage(mt,[K.buffer,P.buffer,ot.buffer,B.buffer])});if(o(),et.refusal)throw new Error(et.refusal);if(!et.indices||!Number.isFinite(et.error))throw new Error("Invalid navigation geometry response");const rt=et.indices;for(let Q=0;Q<rt.length;Q++)rt[Q]=$[rt[Q]];if(A+=rt.length,A*4>rn-this.bytes)return;S.push(rt),M=Math.max(M,et.error)}f&&w.push({start:N,count:A-N,materialIndex:x.materialIndex})}const E={vertices:a.count,fullTriangles:t.index.count/3,reducedTriangles:A/3,error:M,accepted:!1};if(this.reductions.length<32&&this.reductions.push(E),!A||A>=t.index.count*.75)return;const F=new Int32Array(a.count).fill(-1),V=[],H=new Uint32Array(A);let tt=0;for(const x of S){for(let N=0;N<x.length;N+=Pt){await r();for(let T=N;T<Math.min(N+Pt,x.length);T++){const U=x[T];let $=F[U];$<0&&($=V.length,V.push(U),F[U]=$),H[tt+T]=$}}tt+=x.length}const Z=H.byteLength+Object.values(t.attributes).reduce((x,N)=>x+V.length*N.itemSize*N.array.BYTES_PER_ELEMENT,0);if(E.bytes=Z,this.bytes+Z>rn)return;const nt=new oe;nt.setIndex(new ft(H,1));for(const[x,N]of Object.entries(t.attributes)){const T=N,U=T.array.constructor,$=new U(V.length*T.itemSize);for(let k=0;k<V.length;k+=Pt){await r();for(let P=k;P<Math.min(k+Pt,V.length);P++)for(let B=0;B<T.itemSize;B++)$[P*T.itemSize+B]=T.array[V[P]*T.itemSize+B]}nt.setAttribute(x,new ft($,T.itemSize,T.normalized))}nt.boundingSphere=t.boundingSphere.clone(),nt.boundingBox=O.clone();for(const x of w)nt.addGroup(x.start,x.count,x.materialIndex);nt.userData={...t.userData},E.accepted=!0,this.cache.set(t,{geometry:nt,error:M,bytes:Z}),this.bytes+=Z}catch(a){if(a===go)return;this.unavailable=String(a),this.worker?.terminate(),this.worker=null,this.pending=null,this.queue.length=0}finally{e===this.generation&&(this.building=!1,this.timer=setTimeout(()=>{this.timer=null,this.next()},0))}}prepare(t,e,o){if(this.finish(),this.drawnMeshes=this.fullTriangles=this.motionTriangles=0,!e||!(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()},po+1)),r-this.movedAt>po)return!1;this.projection.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projection);let s=0;for(const[f,c]of this.cache){const d=c.geometry.boundingBox;d.getSize(this.halfExtent).multiplyScalar(.5);for(const l of this.groups.get(f)??[]){if(!Jt(l)||l.frustumCulled&&!this.frustum.intersectsObject(l))continue;this.viewWorld.multiplyMatrices(t.matrixWorldInverse,l.matrixWorld);const i=this.viewWorld.elements,u=i[0]**2+i[1]**2+i[2]**2,m=i[4]**2+i[5]**2+i[6]**2,h=i[8]**2+i[9]**2+i[10]**2,_=Math.abs(i[0]*i[4]+i[1]*i[5]+i[2]*i[6]),p=Math.abs(i[0]*i[8]+i[1]*i[9]+i[2]*i[10]),g=Math.abs(i[4]*i[8]+i[5]*i[9]+i[6]*i[10]),v=Math.sqrt(Math.max(u+_+p,m+_+g,h+p+g)),O=f.boundingSphere;this.centre.copy(O.center).applyMatrix4(this.viewWorld);let b=1;if(t.isPerspectiveCamera){const w=-this.centre.z-O.radius*v;d.getCenter(this.boxCentre).applyMatrix4(this.viewWorld);const A=this.viewWorld.elements,M=Math.abs(A[2])*this.halfExtent.x+Math.abs(A[6])*this.halfExtent.y+Math.abs(A[10])*this.halfExtent.z;b=Math.max(w,-this.boxCentre.z-M)}const S=c.error*v*Math.abs(t.projectionMatrix.elements[5])*o/(2*b);if(!(b>0)||S>1){s++;continue}this.swapped.push({mesh:l,geometry:f}),l.geometry=c.geometry,this.drawnMeshes++,this.fullTriangles+=f.index.count/3,this.motionTriangles+=c.geometry.index.count/3}}return this.lastNavigation={meshes:this.drawnMeshes,fullTriangles:this.fullTriangles,motionTriangles:this.motionTriangles,tooClose:s},this.swapped.length>0}finish(){for(const{mesh:t,geometry:e}of this.swapped)t.geometry=e;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 Ai={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},C=I().finite(),Jo=W([C,C,C]),De=W([I().int().nonnegative(),I().int().nonnegative()]),vt={name:D(),domain:Y(["POINT","EDGE","FACE","CORNER"])},Mi=Ua("type",[R({...vt,type:X("FLOAT2"),data:L(W([C,C]))}).strict(),R({...vt,type:X("FLOAT_VECTOR"),data:L(Jo)}).strict(),R({...vt,type:X("FLOAT_COLOR"),data:L(W([C,C,C,C]))}).strict(),R({...vt,type:X("BYTE_COLOR"),data:L(W([C,C,C,C]))}).strict(),R({...vt,type:X("QUATERNION"),data:L(W([C,C,C,C]))}).strict(),R({...vt,type:X("FLOAT4"),data:L(W([C,C,C,C]))}).strict(),R({...vt,type:X("FLOAT4X4"),data:L(L(C).length(16))}).strict(),R({...vt,type:X("INT16_2D"),data:L(W([I().int(),I().int()]))}).strict(),R({...vt,type:X("INT32_2D"),data:L(W([I().int(),I().int()]))}).strict(),R({...vt,type:X("FLOAT"),data:L(C)}).strict(),R({...vt,type:X("INT"),data:L(I().int())}).strict(),R({...vt,type:X("INT8"),data:L(I().int())}).strict(),R({...vt,type:X("BOOLEAN"),data:L(at())}).strict(),R({...vt,type:X("STRING"),data:L(D())}).strict()]),Ti=R({positions:G(Float32Array),normals:G(Float32Array).nullable(),uv:G(Float32Array).nullable(),uvLayers:L(R({name:D(),data:G(Float32Array)}).strict()).optional(),attributeLayers:L(R({name:D(),data:G(Float32Array)}).strict()).optional(),orco:G(Float32Array).nullable().optional(),indices:G(Uint32Array),groups:L(R({start:I().int().nonnegative(),count:I().int().nonnegative(),materialIndex:I().int().nonnegative()}).strict()),hash:D()}).strict(),Si=R({v:L(Jo),f:L(L(I().int().nonnegative())),e:L(De).optional(),edge_order:L(De).optional(),m:L(I().int().nonnegative()).optional(),s:L(at()).optional(),sharp:L(De).optional(),seams:L(De).optional(),creases:L(W([C,C,C])).optional(),attributes:L(Mi).optional(),active_uv:D().nullable().optional(),render_uv:D().nullable().optional()}).strict(),Pi=R({store:I().int().optional(),revision:I().int(),unchanged:X(!0)}).strict(),Ei=R({co:Wt([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(),Ni=R({name:D(),domain:Y(["POINT","EDGE","FACE","CORNER"]),type:D(),data:Wa(n=>ArrayBuffer.isView(n))}).strict(),ta=R({columns:Ei,attributes:L(Ni),activeUv:D().nullable(),renderUv:D().nullable(),counts:R({verts:I().int().nonnegative(),edges:I().int().nonnegative(),faces:I().int().nonnegative(),corners:I().int().nonnegative()}).strict(),revision:I().int().nonnegative()}).strict(),Ri=Wt([Ti,ta,Si,Pi]),vo=new Set;function Ii(n,t){const e=new Blob([n],{type:t}),o=new Ia;let r=!1;o.addEventListener("dispose",()=>{r=!0,o.image?.close?.()});const a=createImageBitmap(e,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(s=>{if(r){s.close();return}o.image=s,o.needsUpdate=!0,ht()}).finally(()=>{vo.delete(a)});return vo.add(a),a.catch(()=>{}),{texture:o,ready:a}}function Di(n,t,e,o){const r=new We(n,t,e,qe,Ra);return r.flipY=!1,r.colorSpace=o==="data"?Le:Ut,r.needsUpdate=!0,r}function zi(n,t,e){if(t.length===0)throw new Error(`Runtime image ${n} 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),s=Math.max(...t.map(l=>l.number-1001))+1,f=new Float32Array(s*2*4);for(let l=0;l<s;l++)f[l*4]=-1;t.forEach((l,i)=>{const u=l.rgba??(l.rgbaBase64?mn(l.rgbaBase64):void 0);if(!u)throw new Error(`Runtime image ${n} tile ${l.number} carries no raster`);for(let h=0;h<l.height;h++)a.set(u.subarray(h*l.width*4,(h+1)*l.width*4),(i*r+h)*o*4);const m=l.number-1001;f[m*4]=i,f.set([0,0,l.width/o,l.height/r],(s+m)*4)});const c=new Na(a,o,r,t.length);c.colorSpace=e==="data"?Le:Ut,c.magFilter=ee,c.minFilter=Io,c.generateMipmaps=!0,c.needsUpdate=!0;const d=new We(f,s,2,qe,To);return d.magFilter=d.minFilter=un,d.needsUpdate=!0,{tiles:c,map:d,frame:t}}const Ci=R({width:I().int().positive(),height:I().int().positive(),revision:I().int().nonnegative(),rgba:G(Uint8Array).optional(),rgbaBase64:D().optional(),colorspace:Y(["sRGB","data"]).optional(),tiles:L(R({number:I().int().min(1001),width:I().int().positive(),height:I().int().positive(),rgba:G(Uint8Array).optional(),rgbaBase64:D().optional()}).strict()).optional()}).strict(),Fi=R({revision:I().int().nonnegative(),encoded:G(Uint8Array).optional(),encodedBase64:D().optional(),mime:Y(["image/png","image/jpeg"]),colorspace:Y(["sRGB","data"]).optional()}).strict(),ea=Wt([Ci,Fi]),sn=R({image:R({name:D(),revision:I().int().nonnegative()}).strict(),extension:Y(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:D(),tint:W([C,C,C]).optional()}).strict(),ki=R({name:D(),color:W([C,C,C,C]),roughness:C,metallic:C,transmission:C,ior:C,physical:Cs.optional(),normal_texture:sn.optional(),normal_strength:C.default(1),normal_space:Y(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:at().default(!1),texture:sn.optional(),roughness_texture:sn.optional(),emission:R({color:W([C,C,C]),strength:C}).strict().optional(),graph:ls.optional(),viewport:R({color:W([C,C,C,C]),roughness:C,metallic:C}).strict().optional()}).strict(),$i=R({session:D(),revision:I().int().nonnegative(),volumes:Ot(D(),qo).default({}),lights:Ot(D(),qr).default({}),world:Jr.nullable().default(null),meshes:Ot(D(),Ri),materials:Ot(D(),ki),images:Ot(D(),ea).default({}),objects:L(R({id:D(),name:D(),type:Y(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:D().nullable(),volume:D().nullable().optional(),light:D().nullable().optional(),materials:L(D().nullable()),matrix:L(W([C,C,C,C])).length(4),visible:at(),render_visible:at().default(!0),selected:at(),parent:D().nullable(),texspace:W([W([C,C,C]),W([C,C,C])]).optional(),default_color:D().optional()}).strict()),active:D().nullable(),mode:D(),cameras:Ot(D(),Ot(D(),zo())).default({}),warnings:L(D()).default([]),updated:L(D()).default([]),frame:I().int().default(0),armatures:Ot(D(),Xa).default({}),weights:js.nullable().default(null),cursor:qs.optional(),camera_view:R({scene_camera:D().nullable(),view_layer_cameras:L(D()),aspect:I().finite().positive()}).optional(),light_distances:Ot(D(),W([I().finite(),I().finite()])).default({}),empties:Ot(D(),Ks).default({}),view:R({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:R({frame:I().int(),body:D(),markers:L(W([I().int(),D()]))}).optional(),units:R({system:Y(["NONE","METRIC","IMPERIAL"]),scale_length:I().finite()}).optional()}).strict();function Li(n,t){for(let e=0,o=n.length-1;e<n.length&&o>=0;e++,o--){if(n[e][0]===t)return n[e][1];if(e===o)break;if(n[o][0]===t)return n[o][1]}return null}const ji={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 Be{constructor(){this.root=new ct,this.instances=new hi(this.root),this.materialRanges=new wi,this.transparentInstances=new bi(this.root),this.motionGeometry=new Oi(ht),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 Nn,this.armatureOverlay=new rr,this.weightOverlay=new Ws,this.cursorOverlay=new Zs,this.extrasOverlay=new ti,this.armatureRoot=new ct,this.weightRoot=new ct,this.cursorRoot=new ct,this.cameraExtrasRoot=new ct,this.lightExtrasRoot=new ct,this.emptyExtrasRoot=new ct,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 ne({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new zs,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=oi,this.cameraViewPan=ai,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=e=>{t(e),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[e,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]])e.matrixAutoUpdate=!1,e.matrix.copy(this.root.matrix),e.add(o),e.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const e of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])e.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const e=JSON.stringify(t);let o=this.graphs.get(e);return o||(o=ws(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(e,o)),o}mirrorPose(t){let e=null;for(const[a,s]of this.objects)if(s===t){e=a;break}if(e===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 s=a.objects.get(e);s!==void 0&&(s.matrix.copy(t.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.updateMatrixWorld(!0),r=!0)}r&&ht()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const e=this.subscribeFrames(t),o=Ha(t);return()=>{e(),o()}}blenderObjectName(t){for(const[e,o]of this.objects)if(o===t)return this.frame?.objects.find(r=>r.id===e)?.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[e,o,r,a]=t.rotation,s=new St(o,r,a,e),f=new y(...t.location).applyMatrix4(this.root.matrix),c=d=>d.applyQuaternion(s).applyMatrix4(this.root.matrix).normalize();return{target:f.toArray(),direction:c(new y(0,0,1)).toArray(),up:c(new y(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?Ai[t.shading]:null}}cameraViewCamera(){const t=this.frame,e=t?.camera_view;return!t||!e?null:e.scene_camera!==null&&t.cameras[e.scene_camera]?e.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:e.view_layer_cameras.find(o=>t.cameras[o])??null}blenderPose(t,e){const o=new q().copy(this.root.matrix).invert(),r=new q().compose(new y(...t),new St(...e),new y(1,1,1)).premultiply(o),a=new y,s=new St;return r.decompose(a,s,new y),{location:a.toArray(),rotation:[s.w,s.x,s.y,s.z]}}cameraView(t,e,o,r){const a=this.frame,s=uo.safeParse(a?.cameras[t]);return!a?.camera_view||!s.success?null:ri(s.data,this.root.matrix,e,o,r,a.camera_view.aspect)}subjectLine(t){const e=this.frame?.subject;if(e===void 0)return null;const o=t??e.frame,r=Li(e.markers,o);return`(${o})${e.body}${r===null?"":` <${r}>`}`}gridUnitName(t){const e=this.frame?.units;if(e===void 0||e.system==="NONE")return null;const o=ji[e.system],r=6*t,a=1/(e.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(e=>e.selected).map(e=>e.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const e=this.frame?.objects.find(o=>o.name===t);return e===void 0?null:this.objects.get(e.id)??null}replacePresentedObject(t,e){for(const[o,r]of this.objects)if(r===t){const a=t.parent,s=[...t.children];t.removeFromParent();for(const f of s)e.add(f);a?.add(e),this.objects.set(o,e),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,e,o){const r=new Set(this.objects.values()),a=this.cursorOverlay.placementAt(t,e,o,this.root,s=>r.has(s));return a!==null&&(this.cursorOverlay.show(a),ht()),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 y).toArray().map(r=>r.toFixed(1)).join(","):"";return`${t.uuid}:${o}:${this.worldKey}`}report(t){t.then(ht,e=>console.error(`Rendered shading could not be applied: ${e instanceof Error?e.message:String(e)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),ht())}applyWorkbench(){const t=this.workbench&&!this.rendered,e=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 s=(o.materials.length?o.materials:[null]).map(f=>{const c=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,c.side,e):c});r.material=o.materials.length?s:s[0]}for(const[o,r]of this.workbenchMaterials)e.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()),this.materialRanges.setObjects(this.drawBatching&&!this.rendered?this.objects.values():[])}setDrawBatching(t){t!==this.drawBatching&&(this.drawBatching=t,this.rebuildInstances(),ht())}prepareDraw(t,e){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"&&e?.interactive===!0,e?.height??0);a&&this.instances.sync();const s=performance.now();this.materialRanges.prepare();const f=performance.now();this.transparentInstances.prepare(t,e?.multiDraw===!0);const c={opaqueMs:r-o,motionMs:s-r,rangesMs:f-s,transparentMs:performance.now()-f};this.drawPreparation.last=c,a&&(this.drawPreparation.navigation=c)}catch(o){throw this.materialRanges.finish(),this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw(),o}return()=>{this.materialRanges.finish(),this.motionGeometry.finish(),this.instances.finishDraw(),this.transparentInstances.finishDraw()}}workbenchFor(t,e,o){const r=(t!==null?this.frame?.materials[t]?.viewport:void 0)??si,a=`${r.color.join(",")}|${r.roughness}|${r.metallic}|${e}`;o.add(a);let s=this.workbenchMaterials.get(a);return s||(s=di(r,e),this.workbenchMaterials.set(a,s)),s}renderedHeld(){return this.heldRendered!==null}async setRendered(t,e){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,e)}async applyRendered(t,e){const o=(t?io(this.frame?.world)?.extinction:null)??new y;for(const a of[...this.materials.values(),this.fallback])ks(a,o);this.rendered=t,this.lighting.setRendered(t);const r=t&&e?this.worldKeyFor(e):null;t?(this.capturing||r!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,e):this.world.clear(),this.worldApplied=this.capturing?null:r,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,e),t&&(await Gr(),await Promise.all([...this.textures.values()].map(a=>a.ready)),await this.world.ready())}applyShadows(t,e){this.root.updateMatrixWorld(!0);const o=[];for(const c of this.objects.values()){const d=c;if(d.isMesh&&(d.castShadow=t,d.receiveShadow=t,t&&d.visible)){const l=new ue().setFromObject(d);l.isEmpty()||o.push(l)}}if(!t||!o.length)return;const a=o.reduce((c,d)=>c.union(d),new ue).getBoundingSphere(new Mn),s=e?new He().setFromProjectionMatrix(new q().multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)):null,f=s?o.flatMap(c=>ns(c,s)):[];for(const c of this.lights.values())c.isDirectionalLight&&e?os(c,f,o):Zr(c,a.center,a.radius)}applyOverlays(t){const e=s=>{const f=t.objects.find(c=>c.name===s);return f===void 0?null:new q().set(...f.matrix.flat())},o=[...this.armatureOverlay.apply(t.armatures,e)],r=t.weights?this.objects.get(t.objects.find(s=>s.name===t.weights?.object)?.id??""):void 0,a=this.weightOverlay.apply(t.weights,r??null,t.weights?e(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),ht())}applyExtras(t){const e={};for(const[o,r]of Object.entries(t.cameras)){const a=uo.safeParse(r);a.success&&(e[o]=a.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(o=>o.visible),active:t.active,cameras:e,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,s=r.width||a?.width||0,f=r.height||a?.height||0;return(s===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),ht()},()=>this.awaitedImages.delete(o))),{texture:r.texture,width:s,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const e=this.objects.get(t.id);if(e&&(e.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 e=this.staged;if(!e||e.session!==t.session||e.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const o=ta.parse(t.piece);if(e.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const r=`revision:${o.revision}`;e.meshes.set(t.mesh,{signature:r,geometry:Ce(qn({...o.columns,attributes:o.attributes,activeUv:o.activeUv,renderUv:o.renderUv},r))})}else if(t.image!==void 0){if(e.images.has(t.image))throw new Error("Duplicate Blender image piece");e.images.set(t.image,ea.parse(t.piece))}}applyFrame(t){const e=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},o=$i.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,i]of r.images)o.images[l]=i;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 s=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 i=new Set([l.id]);let u=l.parent;for(;u!==null;){if(i.has(u))throw new Error("Runtime parent cycle");i.add(u);const m=s.get(u);if(!m)throw new Error(`Missing runtime parent ${u}`);u=m.parent}}const f=new Map,c=new Map;try{for(const[l,i]of Object.entries(o.volumes)){const u=JSON.stringify(i);this.frame?.session===o.session&&this.volumes.get(l)?.signature===u||c.set(l,{signature:u,mesh:as(i)})}for(const[l,i]of Object.entries(o.meshes)){if("unchanged"in i){const _=r?.meshes.get(l);if(_){if(_.signature!==`revision:${i.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(l,_);continue}const p=this.meshes.get(l)?.signature;if(this.frame?.session===o.session&&p!==void 0&&(p===`revision:${i.revision}`||!p.startsWith("revision:")))continue;throw new Error(p===void 0?`${Bn}: the presenter does not hold runtime mesh ${l} (store ${i.store}, revision ${i.revision})`:`${Bn}: the presenter holds runtime mesh ${l} at ${p}, not revision ${i.revision}`)}const u="hash"in i,m="columns"in i,h=m?`revision:${i.revision}`:u?i.hash:JSON.stringify(i);this.frame?.session===o.session&&this.meshes.get(l)?.signature===h||f.set(l,{signature:h,geometry:m?Ce(qn({...i.columns,attributes:i.attributes,activeUv:i.activeUv,renderUv:i.renderUv},h)):u?Ce(i):vr(i)})}}catch(l){for(const i of f.values())i.geometry.dispose();for(const{mesh:i}of c.values())i.geometry.dispose(),i.material.dispose();throw l}if(r){for(const[l,i]of r.meshes)f.has(l)||i.geometry.dispose();this.staged=null}this.frame?.session!==o.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[l,i]of c){const u=this.volumes.get(l)?.mesh;u&&(u.removeFromParent(),u.geometry.dispose(),u.material.dispose()),this.volumes.set(l,i)}for(const[l,i]of f)this.meshes.get(l)?.geometry.dispose(),this.meshes.set(l,i),this.geometryBuilds++;for(const[l,i]of Object.entries(o.images)){const u=this.textures.get(l);if("width"in i){const g=i.rgba??(i.rgbaBase64?mn(i.rgbaBase64):void 0);if(!g)throw new Error(`Runtime image ${l} carries no raster`);const v=i.tiles?zi(l,i.tiles,i.colorspace??"sRGB"):void 0;if(u?.udim&&(u.udim.tiles.dispose(),u.udim.map.dispose(),delete u.udim),u&&u.width===i.width&&u.height===i.height){const O=u.texture.image;if(O.data){O.data.set(g),u.texture.needsUpdate=!0,u.revision=i.revision,v&&(u.udim=v);continue}}u?.texture.dispose(),this.textures.set(l,{texture:Di(g,i.width,i.height,i.colorspace??"sRGB"),width:i.width,height:i.height,revision:i.revision,...v?{udim:v}:{}});continue}const m=i.encoded??(i.encodedBase64?mn(i.encodedBase64):void 0);if(!m)throw new Error(`Runtime image ${l} carries no bytes`);u?.texture.dispose(),u?.udim?.tiles.dispose(),u?.udim?.map.dispose();const h=i.colorspace??"sRGB",{texture:_,ready:p}=Ii(m,i.mime);_.colorSpace=h==="data"?Le:Ut,this.textures.set(l,{texture:_,ready:p,width:0,height:0,revision:i.revision,encoded:{bytes:m.slice(),mime:i.mime,colorspace:h}})}for(const[l,i]of Object.entries(o.materials)){const u=this.materials.get(l)??new ne;u.name=i.name;const m=i.texture?.tint;i.texture!==void 0?u.color.setRGB(m?.[0]??1,m?.[1]??1,m?.[2]??1,bt):u.color.setRGB(i.color[0],i.color[1],i.color[2],bt),u.opacity=i.color[3];const h=u.opacity<1||i.graph!==void 0&&fs(i.graph);u.transparent!==h&&(u.transparent=h,u.needsUpdate=!0),u.roughness=i.roughness,u.metalness=i.metallic,u.transmission=i.transmission,u.ior=i.ior,Dn(u,i.physical,{map:i.texture?.extension==="CLIP",roughness:i.roughness_texture?.extension==="CLIP",normal:i.normal_texture?.extension==="CLIP"});const _=i.normal_texture?.image.name;if(_===void 0)u.normalMap&&(this.textureSamplers.delete(`${l}:normal`),u.normalMap=null,u.needsUpdate=!0);else{const b=this.textures.get(_);if(!b)throw new Error(`${me}: missing normal image ${_}`);const S=this.textureSamplers.get(`${l}:normal`,b.texture,i.normal_texture.extension,b.ready,i.normal_texture.uv);u.normalMap!==S&&(u.normalMap=S,u.needsUpdate=!0);const w=i.normal_space==="OBJECT"?Pa:Ea;u.normalMapType!==w&&(u.normalMapType=w,u.needsUpdate=!0),u.normalScale.set(i.normal_strength,i.normal_strength*(i.normal_directx?-1:1))}i.emission?(u.emissive.setRGB(i.emission.color[0],i.emission.color[1],i.emission.color[2],bt),u.emissiveIntensity=i.emission.strength):(u.emissive.setRGB(0,0,0),u.emissiveIntensity=1);const p=i.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(l)&&(this.textureSamplers.delete(`${l}:roughness`),u.roughnessMap=null,this.roughnessTextureNames.delete(l),u.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${me}: the presenter does not hold runtime image ${p} (revision ${i.roughness_texture.image.revision})`);const S=this.textureSamplers.get(`${l}:roughness`,b.texture,i.roughness_texture.extension,b.ready,i.roughness_texture.uv);u.roughnessMap!==S&&(u.roughnessMap=S,this.roughnessTextureNames.set(l,p),u.needsUpdate=!0)}const g=i.texture?.image.name??null;if(g===null)this.textureNames.has(l)&&(this.textureSamplers.delete(`${l}:color`),u.map=null,this.textureNames.delete(l),u.needsUpdate=!0);else{const b=this.textures.get(g);if(!b)throw new Error(`${me}: the presenter does not hold runtime image ${g} (revision ${i.texture.image.revision})`);const S=this.textureSamplers.get(`${l}:color`,b.texture,i.texture.extension,b.ready,i.texture.uv);u.map!==S&&(u.map=S,this.textureNames.set(l,g),u.needsUpdate=!0)}const v=i.graph?this.compiledGraph(i.graph):null,O=new Set;As(u,v,b=>{const S=this.textures.get(b.name);if(!S)throw new Error(`${me}: the presenter does not hold runtime image ${b.name} (revision ${b.revision})`);if(b.tiled){if(!S.udim)throw new Error(`${me}: runtime image ${b.name} arrived without its UDIM tiles`);return S.udim}const w=`${l}:graph:${b.node}`;O.add(w);const A=this.textureSamplers.get(w,S.texture,b.extension,S.ready),M=b.closest?un:ee,E=b.closest?un:b.mipmap?Io:ee;return(A.magFilter!==M||A.minFilter!==E)&&(A.magFilter=M,A.minFilter=E,A.needsUpdate=!0),A},this.photograph);for(const b of this.graphSamplers.get(l)??[])O.has(b)||this.textureSamplers.delete(b);this.graphSamplers.set(l,O),this.materials.set(l,u)}for(const l of o.objects){let i=this.objects.get(l.id);const u=l.volume?this.volumes.get(l.volume).mesh:null;if((!i||(u?i!==u:!!i.isMesh!=(l.mesh!==null)))&&(i?.removeFromParent(),i=u??(l.mesh!==null?new Ft(this.meshes.get(l.mesh).geometry,this.fallback):new Ao),this.objects.set(l.id,i)),i.name=l.name,l.type==="CAMERA"||l.type==="LIGHT"||l.type==="EMPTY"?i.userData.volterOwnOverlay=!0:delete i.userData.volterOwnOverlay,i.matrixAutoUpdate=!1,i.matrix.set(...l.matrix.flat()),l.parent){const m=new q().set(...s.get(l.parent).matrix.flat());i.matrix.premultiply(m.invert())}if(i.matrix.decompose(i.position,i.quaternion,i.scale),l.texspace?i.userData.blenderTexspace=l.texspace:delete i.userData.blenderTexspace,l.default_color!==void 0?i.userData.blenderDefaultColor=l.default_color:delete i.userData.blenderDefaultColor,l.mesh!==null){const m=i;m.geometry=this.meshes.get(l.mesh).geometry,m.material=l.materials.length?l.materials.map(h=>h===null?this.fallback:this.materials.get(h)):this.fallback,Es(m)}if(l.light){const m=this.lights.get(l.light)??null,h=Yr(o.lights[l.light],m);m&&m!==h&&(m.removeFromParent(),m.dispose()),h.parent!==i&&i.add(h),h.userData.volterOwnOverlay=!0,Kr(h,i),this.lights.set(l.light,h)}}for(const l of o.objects){const i=this.objects.get(l.id),u=l.parent===null?this.root:this.objects.get(l.parent);i.parent!==u&&u.add(i)}for(const[l,i]of this.objects)a.has(l)||(i.removeFromParent(),this.objects.delete(l));for(const[l,i]of this.volumes)o.volumes[l]||(i.mesh.geometry.dispose(),i.mesh.material.dispose(),this.volumes.delete(l));for(const[l,i]of this.meshes)o.meshes[l]||(i.geometry.dispose(),this.meshes.delete(l));for(const[l,i]of this.materials)if(!o.materials[l]){for(const u of["normal","roughness","color"])this.textureSamplers.delete(`${l}:${u}`);for(const u of this.graphSamplers.get(l)??[])this.textureSamplers.delete(u);this.graphSamplers.delete(l),i.dispose(),this.materials.delete(l)}for(const[l,i]of this.lights)o.lights[l]||(i.removeFromParent(),i.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:e}}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,e])=>({id:t,name:e.name,uuid:e.uuid,geometry:e.geometry?.uuid,visible:e.visible}))}}drawStatistics(){return{enabled:this.drawBatching,preparation:{...this.drawPreparation},materialRanges:this.materialRanges.inspect(),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 e=structuredClone({...t,images:{},armatures:{},weights:null});for(const[r,{signature:a,geometry:s}]of this.meshes){const f=l=>{const i=s.getAttribute(l);if(!i)return null;if(!(i instanceof ft))throw new Error(`Blender capture cannot copy interleaved ${l}`);return new Float32Array(i.array)},c=f("position");if(!c)throw new Error(`Blender capture mesh ${r} has no positions`);const d=s.getIndex();e.meshes[r]={hash:a,positions:c,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(s.userData.blenderUvChannels??{}).map(([l,i])=>{const u=f(`uv${i}`);if(!u)throw new Error(`Blender capture mesh ${r} is missing UV layer ${l}`);return{name:l,data:u}}),orco:s.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(s.userData.blenderAttributes??[]).map(l=>{const i=f(Bt(l));if(!i)throw new Error(`Blender capture mesh ${r} is missing attribute ${l}`);return{name:l,data:i}}),indices:d?new Uint32Array(d.array):Uint32Array.from({length:c.length/3},(l,i)=>i),groups:s.groups.map(l=>({start:l.start,count:l.count,materialIndex:l.materialIndex??0}))}}for(const[r,{signature:a}]of this.volumes)e.volumes[r]=qo.parse(JSON.parse(a));const o=new Set(Object.values(e.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)e.images[r]={revision:a.revision,encoded:a.encoded.bytes.slice(),mime:a.encoded.mime,colorspace:a.encoded.colorspace};else{const s=a.texture.image?.data;if(!(s instanceof Uint8Array))throw new Error(`Blender capture image ${r} has no resident raster`);e.images[r]={revision:a.revision,width:a.width,height:a.height,rgba:s.slice(),colorspace:a.texture.colorSpace===Le?"data":"sRGB",...a.udim?{tiles:a.udim.frame}:{}}}}return e}follow(){const t=new Be;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let e=!1;return{view:t,dispose:()=>{e||(e=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),e=this.frame,o=this.createWorldVolumePass(),r=new Be;r.photograph=!0;let a=!1;const s=()=>{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 s(),f}return{effect:o,root:r.root,session:e.session,revision:e.revision,prepare:f=>{if(a)throw new Error("Blender capture snapshot is disposed");return r.setRendered(!0,f)},dispose:s}}createWorldVolumePass(){const t=io(this.frame?.world);return t?new Ls(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const e=t,o=e.meshes;if(typeof o!="object"||o===null)return;const r=typeof e.session=="string"?e.session:null;r!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=r);const a=o;for(const[s,f]of Object.entries(a))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(s,f);for(const s of[...this.submittedMeshes.keys()])s in a||this.submittedMeshes.delete(s);this.submitted={...e,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){this.materialRanges.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:e}of this.textures.values())t.dispose(),e?.tiles.dispose(),e?.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 Yi=new Be;function na(n){const t=atob(n),e=new Uint8Array(t.length);for(let o=0;o<t.length;o++)e[o]=t.charCodeAt(o);return e}function ln(n){const t=na(n);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function Vi(n){const t=na(n);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function Bi(n){return new q().set(...n.flat())}function xo(n,t){return[n.object,n.mesh,n.armature,n.vertexCount,n.bones.length,t].join("|")}class Ui{#e=new Map;#o=null;#a=null;#t=null;#r=null;#n=null;#i=null;#l=new Set;#u=0;#d=[];#s=0;get version(){return this.#u}get engineCalls(){return this.#s}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,e=t?.frameStart??1,o=t?.frameEnd??250,r=t?.fps??24;return{frame:this.frame(),start:e,end:o,fps:r,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#e.values()].reduce((a,s)=>a+s.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#e.keys()],warnings:this.#d,engineCalls:this.#s,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.#n!==null}async bind(t,e){this.#s++;const o=await e.rig();if(!o)return;const r=[],a=new Set;let s=!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 h=xo(m,o.frame);if(this.#e.get(m.object)?.signature===h)continue;const _=this.#_(t,m,o.frame,r);_&&(this.#e.get(m.object)?.skeleton.dispose(),this.#e.set(m.object,_),s=!0)}for(const[m,h]of[...this.#e])a.has(m)||(h.skeleton.dispose(),h.boneRoot.removeFromParent(),this.#e.delete(m),s=!0);this.#s++;const f=await e.clip(),c=this.#t,d=f?.frameStart!==c?.frameStart||f?.frameEnd!==c?.frameEnd||f?.fps!==c?.fps,l=f?.action!==c?.action||f?.tracks.length!==c?.tracks.length||f?.clipStart!==c?.clipStart||f?.clipEnd!==c?.clipEnd;this.#t=f??null,(!f||f.scene!==c?.scene)&&(this.#r=null),f?.reason&&r.push(f.reason),f&&(l||s)&&this.#h(t,f,r);const i=this.#n?.snapshot().activeSubject;d&&i&&this.#n?.setActiveSubject(i);const u=this.#n?.snapshot().playbackState==="playing";f&&!u&&(d||c?.frameCurrent!==f.frameCurrent)&&(this.#c(f.frameCurrent),this.#n&&f.fps>0&&this.#n.seek(f.frameCurrent/f.fps)),this.#d=r,this.#f()}#_(t,e,o,r){const a=t.objectForBlenderName(e.object??""),s=t.objectForBlenderName(e.armature??"");if(!a||!s)return null;const f=a,c=f.geometry;if(!c)return null;const d=c.getAttribute("blenderVertex");if(!d)return r.push(`"${e.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(e.vertexCount===0)return null;let l=0;for(let w=0;w<d.count;w++)l=Math.max(l,d.getX(w));if(l>=e.vertexCount)return r.push(`"${e.object}" is not skinned here: its presented geometry references Blender vertex ${l} while the mesh declares ${e.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 i=Vi(e.skinIndexBase64??""),u=ln(e.skinWeightBase64??""),m=d.count,h=new Uint16Array(m*4),_=new Float32Array(m*4);for(let w=0;w<m;w++){const A=d.getX(w);for(let M=0;M<4;M++)h[w*4+M]=i[A*4+M]??0,_[w*4+M]=u[A*4+M]??0}c.setAttribute("skinIndex",new Da(h,4)),c.setAttribute("skinWeight",new Nt(_,4));const p=new ct;p.name=`${e.armature}:bones`;const g=[],v=e.bones.map(w=>Bi(w.pose)),O=new Map(e.bones.map((w,A)=>[w.name,A]));e.bones.forEach((w,A)=>{const M=new za;M.name=w.name,g.push(M);const E=w.parent===null?void 0:O.get(w.parent);(E===void 0?v[A].clone():v[E].clone().invert().multiply(v[A])).decompose(M.position,M.quaternion,M.scale),(E===void 0?p:g[E]).add(M)}),s.add(p);const b=new Ca(c,f.material);b.name=f.name,b.matrixAutoUpdate=!1,b.matrix.copy(f.matrix),b.matrix.decompose(b.position,b.quaternion,b.scale),b.userData=f.userData,b.frustumCulled=!1,t.replacePresentedObject(f,b),t.root.updateMatrixWorld(!0);const S=new Fa(g);return b.bind(S,b.matrixWorld.clone()),e.constrainedBones?.length&&r.push(`Bone constraints on ${e.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),e.unmappedGroups?.length&&r.push(`${e.object} carries vertex groups no bone is named for (${e.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:e.object??"",armature:e.armature??"",mesh:b,boneRoot:p,bones:g,skeleton:S,frame:o,signature:xo(e,o)}}#h(t,e,o){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!e.tracks.length||e.clipStart===void 0||e.clipEnd===void 0)return;const r=e.armature?t.objectForBlenderName(e.armature):null;if(!r)return;const a=new Map;for(const i of this.#e.values())if(i.armature===e.armature)for(const u of i.bones)a.set(u.name,u);const s=[],f=new Set;for(const i of e.tracks){const u=a.get(i.bone);if(!u){f.add(i.bone);continue}const m=ln(i.timeBase64),h=ln(i.valueBase64),_=`${u.uuid}.${i.property}`;s.push(i.property==="quaternion"?new ka(_,Array.from(m),Array.from(h)):new $a(_,Array.from(m),Array.from(h)))}if(f.size&&o.push(`${e.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!s.length)return;const c=e.duration??(e.clipEnd-e.clipStart)/e.fps,d=new La(r),l=d.clipAction(new ja(e.action??"action",c,s));l.setLoop(Va,Number.POSITIVE_INFINITY),l.play(),this.#o=d,this.#a=l,this.#c(e.frameCurrent),this.#m()}#c(t){const e=this.#t;if(!e)return;const o=Math.min(e.frameEnd,Math.max(e.frameStart,t));if(this.#r=o,!this.#o||e.clipStart===void 0||e.clipEnd===void 0)return;const r=(e.clipEnd-e.clipStart)/e.fps;this.#o.setTime(Math.max(0,Math.min(r-1e-4,(o-e.clipStart)/e.fps))),this.#m()}#m(){for(const t of this.#e.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),e=this.#t;if(!e)return t;const o=e.scene;return!o||e.frameCurrent===t||(this.#s++,await qa(`bpy.data.scenes[${JSON.stringify(o)}]`,"frame_current",t,void 0,!1),this.#t={...e,frameCurrent:t},this.#f()),t}get transport(){return this.#n}attachTo(t){this.#i?.(),this.#n=t;const e=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const s=this.#t,f=s?.fps||24;return{start:(s?.frameStart??1)/f,end:(s?.frameEnd??250)/f,fps:f}},seek:s=>this.seekSeconds(s)}),o=t.onSettled(()=>{this.writeBookmark()}),r=()=>{o(),e(),this.#n===t&&(this.#n=null),this.#i=null};this.#i=r;const a=this.#t;return a&&a.fps>0&&t.seek(a.frameCurrent/a.fps),r}seekSeconds(t){const e=this.#t?.fps||24;this.#c(Math.round(t*e)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#i?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null,this.#t=null,this.#r=null;for(const t of this.#e.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#e.clear()}}const oa=new Ui;function Zi(n){return oa.subscribe(n)}function Ki(){return oa.version}export{oa as a,Ki as b,Yi as c,Zi as s};
|