@volter/game-editor 0.5.103 → 0.5.104
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 +2129 -2129
- package/dist/assets/{AssetBudgetPanel-Oh8dSTUh.js → AssetBudgetPanel-Do9svi7u.js} +3 -3
- package/dist/assets/{AudioViewer-CzZFhC-x.js → AudioViewer-B3j4T9Xx.js} +1 -1
- package/dist/assets/{CanvasBoardDocument-3N_K0_wP.js → CanvasBoardDocument-DqFgSPkp.js} +1 -1
- package/dist/assets/{CanvasSceneViewport-B2sPcQAE.js → CanvasSceneViewport-C8qYP3av.js} +1 -1
- package/dist/assets/{ColorInput-EcsC3oGq.js → ColorInput-hD_XvN8_.js} +1 -1
- package/dist/assets/{ColorPicker-Z9Q4TZPe.js → ColorPicker-DtupCHAc.js} +1 -1
- package/dist/assets/{EntityModelDocument-CWH9ZbnJ.js → EntityModelDocument-HexOIL-w.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-Ctj7W1nz.js → EnvironmentAssetDocument-Ctq9udwE.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-C6fE603u.js → GameplaySessionTimeline-WZDnZuXZ.js} +1 -1
- package/dist/assets/{ImageViewer-DzjRPdhJ.js → ImageViewer-C5aOkmHd.js} +1 -1
- package/dist/assets/InspectorObjectPreview-K5o2CVA_.js +1 -0
- package/dist/assets/{JsonAssetDocument-DmiBAq6c.js → JsonAssetDocument-CC48TUs4.js} +1 -1
- package/dist/assets/{LiveModuleDocument-Cst-vDAF.js → LiveModuleDocument-DFmGUxCz.js} +1 -1
- package/dist/assets/{LutAssetDocument-Ca6Yb4KG.js → LutAssetDocument-CJ-zAhKf.js} +1 -1
- package/dist/assets/{ModelAssetDocument-AhY3MxeF.js → ModelAssetDocument-8oCMA6n_.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-BdwPZRKI.js → NonThreeAuthoringBootstrap-vFanE6YO.js} +1 -1
- package/dist/assets/{Object3DDocumentToolbar-BBUOMs7G.js → Object3DDocumentToolbar-F8V7ujRJ.js} +1 -1
- package/dist/assets/Object3DDocumentViewport-BoM02bUy.js +2 -0
- package/dist/assets/{Object3DPreview-Bds4Guxp.js → Object3DPreview-D3aWEGHf.js} +1 -1
- package/dist/assets/{OnlineAssetDetail-BJvtU4kq.js → OnlineAssetDetail-BhgtTgaO.js} +1 -1
- package/dist/assets/{PlayBar-D14ef9GU.js → PlayBar-CEg9I-qt.js} +1 -1
- package/dist/assets/{QuarksAssetDocument-BfWDJh1Y.js → QuarksAssetDocument-DOUgV4IW.js} +1 -1
- package/dist/assets/{ReactCanvasControls-CSI2M3mS.js → ReactCanvasControls-DU6XgfiE.js} +1 -1
- package/dist/assets/{RootSelectionOverlay-bLaHqzdL.js → RootSelectionOverlay-DVar-Q0H.js} +1 -1
- package/dist/assets/{ShaderAssetDocument-uK7PUVKl.js → ShaderAssetDocument-CBnyOGOt.js} +1 -1
- package/dist/assets/{ShadowEditor-D5KtXjkp.js → ShadowEditor-DuEbmjJY.js} +1 -1
- package/dist/assets/{SourceAssetViewer-D3oxYm70.js → SourceAssetViewer-DmIT8Ddb.js} +1 -1
- package/dist/assets/{StageHost-3lASGojO.js → StageHost-D1qeIVJG.js} +2 -2
- package/dist/assets/{StoryPreviewMount-Q9XdRdkT.js → StoryPreviewMount-B5fxqIzC.js} +1 -1
- package/dist/assets/{ThreeBoardDocument-C3LmHh0f.js → ThreeBoardDocument-CgwkIFQd.js} +2 -2
- package/dist/assets/{ThreeIsolationSceneContent-Bd3c_wyZ.js → ThreeIsolationSceneContent--ive7R-h.js} +1 -1
- package/dist/assets/{ToolObject3DPreview-BzZwqWmT.js → ToolObject3DPreview-B7hw0hWZ.js} +1 -1
- package/dist/assets/{Toolbar-D1ffVclt.js → Toolbar-D0dXFDbq.js} +1 -1
- package/dist/assets/{TransientHint-BrOTvPr3.js → TransientHint-dxvNNOXu.js} +1 -1
- package/dist/assets/{VideoViewer-BhhQo5Jp.js → VideoViewer-DrgTt54f.js} +1 -1
- package/dist/assets/{ViewportShadingMenu-D4YPGPke.js → ViewportShadingMenu-CyiQQPIc.js} +1 -1
- package/dist/assets/{active-ingest-CPKqxKv3.js → active-ingest-DAkHIJE8.js} +2 -2
- package/dist/assets/{animation-clock-Cy0DIkjQ.js → animation-clock-B9MhZHPo.js} +1 -1
- package/dist/assets/{animation-mixers.service-DOssqDVN.js → animation-mixers.service-CwVE7Gsz.js} +1 -1
- package/dist/assets/{animation-timeline.utility-CqfSqHJS.js → animation-timeline.utility-6b29yrIZ.js} +1 -1
- package/dist/assets/{asset-budget-asset.menu-y3y7g_7E.js → asset-budget-asset.menu-CH7aDPrI.js} +1 -1
- package/dist/assets/{asset-budget.action-CNQO9N1B.js → asset-budget.action-DjrPFww4.js} +1 -1
- package/dist/assets/{asset-budget.document-BCsC5KF8.js → asset-budget.document-BIXOBUfr.js} +1 -1
- package/dist/assets/{asset-budget.menu-D-4cW9Se.js → asset-budget.menu-CAF-JhVx.js} +1 -1
- package/dist/assets/{asset-editor-persistence-CRDFEzVW.js → asset-editor-persistence-DERr6Ar0.js} +1 -1
- package/dist/assets/{asset-loaders-qncuupm2.js → asset-loaders-8UD0PeWB.js} +1 -1
- package/dist/assets/{asset-preview-DobyqQsr.js → asset-preview-BPHva-nJ.js} +1 -1
- package/dist/assets/{audio-unlock.service-CkQY_0tF.js → audio-unlock.service-CviQ89Ai.js} +1 -1
- package/dist/assets/{audio.utility-cMwOFQG0.js → audio.utility-C8zXrVmH.js} +1 -1
- package/dist/assets/autoplay.service-C7V2RiPk.js +1 -0
- package/dist/assets/{babylon-authoring-adapter-CqTM1i9K.js → babylon-authoring-adapter-CxxRmuek.js} +1 -1
- package/dist/assets/{binding-resolver-B-stpSB4.js → binding-resolver-1kr52CX9.js} +2 -2
- package/dist/assets/{blender-emscripten-engine-BguP_IVu.js → blender-emscripten-engine-29p9HI1F.js} +1 -1
- package/dist/assets/{blender-node-editor.document-D7eEoAQB.js → blender-node-editor.document-DjIzAu0e.js} +1 -1
- package/dist/assets/{blender-properties-tab-BoY1rcMd.js → blender-properties-tab-C2VBypv-.js} +1 -1
- package/dist/assets/{blender-runtime-host-Cd0cWqhE.js → blender-runtime-host-DTZFV6jk.js} +1 -1
- package/dist/assets/{blender-runtime-skin-B9nNj3mV.js → blender-runtime-skin-Byu1GMlY.js} +13 -13
- package/dist/assets/{blender-runtime.document-D3ik5bRD.js → blender-runtime.document-Ds-rszgc.js} +1 -1
- package/dist/assets/{blender-screenshot.menu-1KBznhC3.js → blender-screenshot.menu-BvIMt3OB.js} +1 -1
- package/dist/assets/{blender-timeline.document-WNG1V_R8.js → blender-timeline.document-B5MIMyIK.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-jNQhsTx6.js → blender-uv-editor.document-DG593dNW.js} +1 -1
- package/dist/assets/{blender-version.status-B-Y4bbxi.js → blender-version.status-B4CHyb7P.js} +1 -1
- package/dist/assets/{blender-wali-engine-C6wu-1A7.js → blender-wali-engine-hS46jHiy.js} +1 -1
- package/dist/assets/{blender.command-CcdN9tDE.js → blender.command-CAl-K2V1.js} +1 -1
- package/dist/assets/{board-guides-BYUO_sY5.js → board-guides-DaJmf1iE.js} +1 -1
- package/dist/assets/{bridge.command-CnBEU8Uk.js → bridge.command-1KUhwxuW.js} +3 -3
- package/dist/assets/{browserAll-Cp0xR1kQ.js → browserAll-gxhQAT8w.js} +1 -1
- package/dist/assets/{build-player.document-B-jVxxCv.js → build-player.document-CMYix_wf.js} +1 -1
- package/dist/assets/{build-profiles.document-BYmgd5bj.js → build-profiles.document-BwT0QjUg.js} +1 -1
- package/dist/assets/{build-progress.status-Dvtxz1bh.js → build-progress.status-CfuqYUwe.js} +1 -1
- package/dist/assets/{build-session-BAeG-1X-.js → build-session-Wnc89PeB.js} +1 -1
- package/dist/assets/{build.action-CkE5zDTc.js → build.action-DiZ0x5g2.js} +1 -1
- package/dist/assets/{build.command-Cu_orUKE.js → build.command-CXtymnIH.js} +1 -1
- package/dist/assets/{build.header-C_leUByi.js → build.header-D2CPBZIn.js} +1 -1
- package/dist/assets/{build.menu-CJUci9Xn.js → build.menu-QtZP3RL_.js} +1 -1
- package/dist/assets/{build.service-DiwvVIIw.js → build.service-BUh12p2S.js} +1 -1
- package/dist/assets/{camera-CTjnYWuJ.js → camera-Dwt7UMVl.js} +1 -1
- package/dist/assets/{camera-runtime.inspector-BNs6n4wK.js → camera-runtime.inspector-Cx8UV27Z.js} +1 -1
- package/dist/assets/{canvas-design-mount-DH1Hqxcg.js → canvas-design-mount-eLuY7Zwc.js} +3 -3
- package/dist/assets/{canvas-entry-runtime-DYulUxXs.js → canvas-entry-runtime-B1Ra5F2C.js} +2 -2
- package/dist/assets/{canvas-preview-frames-EerVSkU7.js → canvas-preview-frames-CgpipMi6.js} +1 -1
- package/dist/assets/{canvas-story-capture.service-CSTKXcDI.js → canvas-story-capture.service-DOuqbkFo.js} +2 -2
- package/dist/assets/{capability-coverage-v7kdcgtL.js → capability-coverage-DGbP8duM.js} +1 -1
- package/dist/assets/{collaboration-presence-VM3x8Io1.js → collaboration-presence-CwlafSSH.js} +1 -1
- package/dist/assets/{collider-_D5Fw1td.js → collider-D5LrXyd_.js} +1 -1
- package/dist/assets/{component-board.service-0BOaOIXr.js → component-board.service-Bm9OMP0z.js} +2 -2
- package/dist/assets/{component-board.service-Cg6-k_hM.js → component-board.service-fN0yWS4M.js} +2 -2
- package/dist/assets/{component-board.service-ClU3qTWE.js → component-board.service-hp8X2t-n.js} +2 -2
- package/dist/assets/{component-contracts.service-BbEl3P1k.js → component-contracts.service-CGk1bQ3O.js} +1 -1
- package/dist/assets/{component-instance-root-Z6etJiYM.js → component-instance-root-csIXzOWO.js} +1 -1
- package/dist/assets/{component-verbs.command-C1GMNIl8.js → component-verbs.command-Qm8BLZw4.js} +1 -1
- package/dist/assets/{component-verbs.service-ClYnt87p.js → component-verbs.service-D_yeU2PT.js} +1 -1
- package/dist/assets/{config-DTRj4sjY.js → config-C43bOr7x.js} +2 -2
- package/dist/assets/{configurations-BsYZ8oXM.js → configurations-CloEhwu6.js} +1 -1
- package/dist/assets/{connection.status-DHHHD1M-.js → connection.status-D9itISdU.js} +1 -1
- package/dist/assets/{constraints.inspector-BWpbIYJ1.js → constraints.inspector-BDyTxI1m.js} +1 -1
- package/dist/assets/{content-bounds-BHATh6xy.js → content-bounds-BbKUBrZF.js} +1 -1
- package/dist/assets/{contract-system-adapters-Br_gPPDd.js → contract-system-adapters-C27z1XVm.js} +1 -1
- package/dist/assets/{coverage.service-BkBV75zS.js → coverage.service-LjeHdxxC.js} +1 -1
- package/dist/assets/{create-runtime-BBGuKu3c.js → create-runtime-C8x1YP-D.js} +1 -1
- package/dist/assets/{curve-CcJNQKa1.js → curve-C_2BEurv.js} +1 -1
- package/dist/assets/{data-asset-RZyQLLbI.js → data-asset-CdMrskXw.js} +1 -1
- package/dist/assets/{data-ref-CtJnDYCQ.js → data-ref-CTkU7ZLz.js} +1 -1
- package/dist/assets/{debug-bridge-Cwws7lJ5.js → debug-bridge-Jj4hyuEm.js} +1 -1
- package/dist/assets/{debug-registry-cnzYoRGC.js → debug-registry-D1_IjiN8.js} +1 -1
- package/dist/assets/{deferred-ingest-play-aljbz0kJ.js → deferred-ingest-play-BWP7-5Y3.js} +2 -2
- package/dist/assets/{design-time-canvas-mount-sAZlE75n.js → design-time-canvas-mount-CznhiyJ-.js} +2 -2
- package/dist/assets/{design-time-layers-D9iqNyOP.js → design-time-layers-fEiUhX7O.js} +1 -1
- package/dist/assets/{design-time-mount.service-DL2UaFnQ.js → design-time-mount.service-B-Nzrp2D.js} +2 -2
- package/dist/assets/{design-time-mount.service-BveLMB2j.js → design-time-mount.service-Clr-26oh.js} +2 -2
- package/dist/assets/{design-time-react-mount-DH8ZKAOv.js → design-time-react-mount-kB1PuKHR.js} +1 -1
- package/dist/assets/{document-preview-three-BwIoi1Yg.js → document-preview-three-OZGa9ZSz.js} +1 -1
- package/dist/assets/{dom-authoring-adapter-Bf6uO4ug.js → dom-authoring-adapter-d4tEG2iC.js} +1 -1
- package/dist/assets/{draco3d-BEGBkOQ_.js → draco3d-C-48Vw5O.js} +1 -1
- package/dist/assets/{edit-mode-audio.service-OUc4WDmV.js → edit-mode-audio.service-D1YYFUHS.js} +1 -1
- package/dist/assets/{edit-mode-authoring-BkAXj1Dl.js → edit-mode-authoring-k8qAGSe_.js} +1 -1
- package/dist/assets/{edit-mode-networking.service-XSzRkTdl.js → edit-mode-networking.service-Cu0ueG8q.js} +1 -1
- package/dist/assets/{editor-api-DHXbg7gx.js → editor-api-DmN8SYsv.js} +1 -1
- package/dist/assets/{editor-layers-CeA87FKx.js → editor-layers-B841PVwv.js} +1 -1
- package/dist/assets/{editor-shell-store-DLjzC_JN.js → editor-shell-store-CydeK2Qp.js} +1 -1
- package/dist/assets/{entity-object-CvgTS5qG.js → entity-object-CX3tOK_s.js} +1 -1
- package/dist/assets/{extend-o3zluXRG.js → extend-CRh797pm.js} +1 -1
- package/dist/assets/{fork-menu-ChRyTypr.js → fork-menu-8dPAdLNl.js} +1 -1
- package/dist/assets/{frame-debugger-store-C0fcC1PZ.js → frame-debugger-store-TrKmXRVy.js} +1 -1
- package/dist/assets/{game-contract-seams-Dnnllvq-.js → game-contract-seams-3fieQD1E.js} +1 -1
- package/dist/assets/{game-css-scope-transform-B01yy90a.js → game-css-scope-transform-bFewAv8o.js} +1 -1
- package/dist/assets/{game-document.service-Dh-bHort.js → game-document.service-D3gHy4BE.js} +1 -1
- package/dist/assets/{game-eval.command-DEyt0caP.js → game-eval.command-Cv7DgXSQ.js} +1 -1
- package/dist/assets/{game-module-access-CFQvyc4D.js → game-module-access-DxAqErba.js} +1 -1
- package/dist/assets/{game-network-D0zeBzXU.js → game-network-B6pMFRsp.js} +3 -3
- package/dist/assets/{gameplay-export-DeDFfShC.js → gameplay-export-C1Cj1E4O.js} +1 -1
- package/dist/assets/{gameplay-replay-hzjmIuOc.js → gameplay-replay-DQ8EZCzi.js} +1 -1
- package/dist/assets/{gameplay.command-RA0eSndq.js → gameplay.command-DQKxBa3s.js} +1 -1
- package/dist/assets/{generation-jobs-Hpj1-QQB.js → generation-jobs-DY8nsFXo.js} +1 -1
- package/dist/assets/{generation.service-Sjw7IpNp.js → generation.service-CCwesOGp.js} +1 -1
- package/dist/assets/{generations-BiOaNP69.js → generations-BOOE3ap0.js} +1 -1
- package/dist/assets/{generations.status-BhsDtMDJ.js → generations.status--ac1DpiA.js} +1 -1
- package/dist/assets/{hierarchy-marks-CmpbokYk.js → hierarchy-marks-Co6v1FlC.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-CAH8Nv4-.js → hosted-asset-materialization-DzNmisaP.js} +1 -1
- package/dist/assets/{index-DwzxylBO.js → index-B2vZf_A3.js} +2 -2
- package/dist/assets/{index-CRnjSzpg.js → index-BttGnYIO.js} +1 -1
- package/dist/assets/{index-Dhtjk2tL.js → index-CRHaR2RX.js} +1 -1
- package/dist/assets/{index-Ceug5YS-.js → index-C_lexbzO.js} +1 -1
- package/dist/assets/{index-0aVAlM5L.js → index-D5Nb7eV_.js} +1 -1
- package/dist/assets/{index-DD7bV3s_.js → index-DJIpSdra.js} +1 -1
- package/dist/assets/{index-DtHn6CWv.js → index-Dkutnr2n.js} +7 -7
- package/dist/assets/{index-BMcG_Vwm.js → index-DozSymkj.js} +1 -1
- package/dist/assets/{index-OngQ0p8C.js → index-cLUT2nM7.js} +1 -1
- package/dist/assets/{inference-diagnostics-BPOVzMs8.js → inference-diagnostics-2wdckZWv.js} +1 -1
- package/dist/assets/{ingest-boot-viewport-D0v7-mdP.js → ingest-boot-viewport-65jcuyCM.js} +1 -1
- package/dist/assets/{ingest-siblings-BBwe66Qe.js → ingest-siblings-wM1aoHRr.js} +1 -1
- package/dist/assets/{ingest-source-persistence-Ds9wT6hB.js → ingest-source-persistence-DuOq59jI.js} +1 -1
- package/dist/assets/{ingest.service-B5kDVmk9.js → ingest.service-5BSD2D1w.js} +1 -1
- package/dist/assets/{inspect-C8I8uV_8.js → inspect-foumRNDE.js} +1 -1
- package/dist/assets/instances.command-v_AywTSQ.js +1 -0
- package/dist/assets/{json-history-resource-BrWqLafx.js → json-history-resource-BQE6z5mQ.js} +1 -1
- package/dist/assets/{layered-pick-B_JEIiQ2.js → layered-pick--Y_0pY3G.js} +1 -1
- package/dist/assets/{light-BflLnrIy.js → light-DvaH7BLf.js} +1 -1
- package/dist/assets/{live-project-verbs-BM34rdCZ.js → live-project-verbs-CX39gLxb.js} +1 -1
- package/dist/assets/{machine.document-C6zdrUDT.js → machine.document-BMR-3csM.js} +1 -1
- package/dist/assets/{machines.finder-DMFaienC.js → machines.finder-CxJ7iX7M.js} +1 -1
- package/dist/assets/{material-DI_qXque.js → material-Cv9XDc-u.js} +1 -1
- package/dist/assets/{material-factory-DKIpXJa3.js → material-factory-C5yRmeCS.js} +1 -1
- package/dist/assets/{mesh-DwA8mZpj.js → mesh-DEAFmgsb.js} +1 -1
- package/dist/assets/{model-asset-sections.service-BVq6IO9C.js → model-asset-sections.service-wS4lIaLN.js} +1 -1
- package/dist/assets/{model-inspection-BysrUCzz.js → model-inspection-CaolaLiG.js} +1 -1
- package/dist/assets/{model-thumbnail-BPU00Egp.js → model-thumbnail-CSptOAUa.js} +1 -1
- package/dist/assets/{models.finder-Bqzx4DeL.js → models.finder-Cy4h2OKx.js} +1 -1
- package/dist/assets/{module-mode-C3GDPuN-.js → module-mode-BvWTPH2M.js} +2 -2
- package/dist/assets/{mount-canvas-ingest-root-DB72hp21.js → mount-canvas-ingest-root-BHSJW9sH.js} +2 -2
- package/dist/assets/{mount-dom-ingest-root-ByBUNP8m.js → mount-dom-ingest-root-Cpph1FEo.js} +2 -2
- package/dist/assets/{mount-ingest-root-Bs2BR4zB.js → mount-ingest-root-DVe374zc.js} +2 -2
- package/dist/assets/{mount-manifest-DY94FCrN.js → mount-manifest-CzruKjkg.js} +1 -1
- package/dist/assets/{mount-three-ingest-root-DDxgTpLk.js → mount-three-ingest-root-DwJmgS0_.js} +1 -1
- package/dist/assets/{mounted-authoring-De2kvgdv.js → mounted-authoring-AzTovhQG.js} +1 -1
- package/dist/assets/{mounted-story-viewport-source-CMU6N81Y.js → mounted-story-viewport-source-BLF4IS3t.js} +1 -1
- package/dist/assets/{native-debug-module-CLUcQYEd.js → native-debug-module-DUQF_Avf.js} +1 -1
- package/dist/assets/{navigation-B1sKNjXx.js → navigation-BxnMKYpS.js} +1 -1
- package/dist/assets/{navmesh.menu-BxKB9XSM.js → navmesh.menu-CiZxrZFn.js} +1 -1
- package/dist/assets/{navmesh.service-C6JsnfxA.js → navmesh.service-vLdZaQ9g.js} +1 -1
- package/dist/assets/network-observer.service-D5vaf09-.js +1 -0
- package/dist/assets/{network.utility-ChWMnMX6.js → network.utility-By1RrXJY.js} +1 -1
- package/dist/assets/{object3d-document-session-registry-C6f1B5Gv.js → object3d-document-session-registry-BgGXd9AB.js} +2 -2
- package/dist/assets/{oid-transform-acF0qC1h.js → oid-transform-C6MnAzl-.js} +1 -1
- package/dist/assets/{particles-B-vZkrKh.js → particles-ZQGD1wbK.js} +1 -1
- package/dist/assets/{pixi-authoring-adapter-DiliqUpX.js → pixi-authoring-adapter-CJC8ONFB.js} +1 -1
- package/dist/assets/{pixi-live-write-target-DL9gLned.js → pixi-live-write-target-Xl9D9Qlr.js} +1 -1
- package/dist/assets/{play.command-CaiE-Dna.js → play.command-DgflesEv.js} +2 -2
- package/dist/assets/{presentation-BI8ewAdl.js → presentation-C93VwRg4.js} +1 -1
- package/dist/assets/{product-C_Y63e3d.js → product-CAvD_8Hm.js} +1 -1
- package/dist/assets/{profiler.action-A36QsSu2.js → profiler.action-BZ-xvMb2.js} +1 -1
- package/dist/assets/{profiler.menu-Cr_HMI3m.js → profiler.menu-CA3to9pj.js} +1 -1
- package/dist/assets/{profiler.utility-eYZ8EVmA.js → profiler.utility-EmPtpp7i.js} +1 -1
- package/dist/assets/{project-authoring-session-DUN1thD_.js → project-authoring-session-CFAPQD4g.js} +2 -2
- package/dist/assets/{properties-bone-constraints.inspector-C-LAvCiN.js → properties-bone-constraints.inspector-BTFsSjN7.js} +1 -1
- package/dist/assets/{properties-bone.inspector-dIT0bo62.js → properties-bone.inspector-CpIBy2J6.js} +1 -1
- package/dist/assets/{properties-collection.inspector-Bu_QSYWG.js → properties-collection.inspector-C3ZDW54c.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-CRaxpsmC.js → properties-constraints.inspector-6whJ1tNf.js} +1 -1
- package/dist/assets/{properties-data.inspector-BRK-rAkt.js → properties-data.inspector-DS-dM6gE.js} +1 -1
- package/dist/assets/{properties-material.inspector-D1hapD87.js → properties-material.inspector-DMegXBqW.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-e_Jnge7Q.js → properties-modifiers.inspector-B9vdwiAl.js} +1 -1
- package/dist/assets/{properties-object.inspector-Dba3Nsvx.js → properties-object.inspector-CwJB4LGe.js} +1 -1
- package/dist/assets/{properties-output.inspector-Bzazy4ep.js → properties-output.inspector-Ls8nM482.js} +1 -1
- package/dist/assets/{properties-particles.inspector-_wcU6XaI.js → properties-particles.inspector-BIHayKBw.js} +1 -1
- package/dist/assets/{properties-physics.inspector-CGhhBda1.js → properties-physics.inspector-DEHm2-Ki.js} +1 -1
- package/dist/assets/{properties-render.inspector-2bN9MTRJ.js → properties-render.inspector-CyR-YKAg.js} +1 -1
- package/dist/assets/{properties-scene.inspector-KhDUiCEF.js → properties-scene.inspector-BJwrGRWh.js} +1 -1
- package/dist/assets/{properties-texture.inspector-CsjihRWz.js → properties-texture.inspector-D6kEaabn.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-D88S8-dD.js → properties-view-layer.inspector-CKyTU9E7.js} +1 -1
- package/dist/assets/{properties-world.inspector-DBiBNfBo.js → properties-world.inspector-BDEyew7v.js} +1 -1
- package/dist/assets/{r3f-design-session-BP4wF7Pu.js → r3f-design-session-Cew1mEz_.js} +2 -2
- package/dist/assets/{r3f-physics-binding-D_pscHZg.js → r3f-physics-binding-B_FkOhal.js} +1 -1
- package/dist/assets/{r3f-source-authoring-adapter-Dp-yo9H4.js → r3f-source-authoring-adapter-CPSvJLuN.js} +1 -1
- package/dist/assets/{react-canvas-navigation-BelC0re4.js → react-canvas-navigation-BFYoVJe-.js} +1 -1
- package/dist/assets/{react-inspector.service-CDcHpCda.js → react-inspector.service-DcNAmwRW.js} +1 -1
- package/dist/assets/{react-story-board-DricHxUL.js → react-story-board-Cx1hWCYx.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-fPvqur2F.js → react-three-rapier.esm-B7nE1BrR.js} +1 -1
- package/dist/assets/{react-world-authoring-adapter-DtEQuR6s.js → react-world-authoring-adapter-yE4jwFl-.js} +1 -1
- package/dist/assets/{realm-services-LKVyh1B_.js → realm-services-D3p2zH9K.js} +1 -1
- package/dist/assets/{reflection-probe-capture.inspector-BHOptXQX.js → reflection-probe-capture.inspector-HjyAHGjr.js} +1 -1
- package/dist/assets/{registry-CXpgn9QF.js → registry-CLxkJZOC.js} +1 -1
- package/dist/assets/{relative-import-specifier-CAj4A_JI.js → relative-import-specifier-CclIYaer.js} +1 -1
- package/dist/assets/{render-env-DVT8ojGr.js → render-env-1Vekcinw.js} +1 -1
- package/dist/assets/{render-features-Dc8a_LwL.js → render-features-Bdq4iE76.js} +1 -1
- package/dist/assets/{render-settings-BkYr5Zc4.js → render-settings-BJeizVxT.js} +1 -1
- package/dist/assets/{resolve-three-Bqlem5kW.js → resolve-three-DfNuOT9M.js} +3 -3
- package/dist/assets/{root-seam-contract-VGetLzIA.js → root-seam-contract-A5jfbopr.js} +1 -1
- package/dist/assets/{run-selection-Dk6Yk5yq.js → run-selection-Cm94E92a.js} +1 -1
- package/dist/assets/{scene-capture-BLgs1pyt.js → scene-capture-DrvZjY1n.js} +1 -1
- package/dist/assets/{scene-document.service-D0qlTC3S.js → scene-document.service-IOsJPO6v.js} +2 -2
- package/dist/assets/{scene-framing-BFIxUrLj.js → scene-framing-DrWwVW3r.js} +1 -1
- package/dist/assets/{seeded-random-DJMagyLX.js → seeded-random-pvWLzR79.js} +1 -1
- package/dist/assets/{session-Bz2cBNDy.js → session-D32o2Hbx.js} +9 -1
- package/dist/assets/{setup-renderer-Cjxicsi1.js → setup-renderer-DChUMGBJ.js} +1 -1
- package/dist/assets/{source-object3d-authoring-adapter-DgVXfO6h.js → source-object3d-authoring-adapter-C_p9t9C7.js} +1 -1
- package/dist/assets/{source-persistence-backend-BBT8JHNa.js → source-persistence-backend-B8umrq16.js} +1 -1
- package/dist/assets/{stage-keyboard-CHgnzHXv.js → stage-keyboard-DzMX8374.js} +1 -1
- package/dist/assets/{stage-overlay-set-mrmRsRtX.js → stage-overlay-set-Bqd7XZV-.js} +1 -1
- package/dist/assets/{stage-presence-markers-Bay58Uyg.js → stage-presence-markers-DHO9H3mp.js} +1 -1
- package/dist/assets/{stage-transform-tools-DIVrM68Z.js → stage-transform-tools-cU0fgHwZ.js} +1 -1
- package/dist/assets/{standard-viewport-dressing-DGKodRuY.js → standard-viewport-dressing-NWfy8Hso.js} +1 -1
- package/dist/assets/{state-watch.action-B6OMfprF.js → state-watch.action-D89N9CtV.js} +1 -1
- package/dist/assets/{state-watch.menu-DHLSWW8b.js → state-watch.menu-CZ-2NTku.js} +1 -1
- package/dist/assets/{state-watch.utility-DrQ2ncIQ.js → state-watch.utility-Dc8MRaLQ.js} +1 -1
- package/dist/assets/{story-capture-D7VKp0Uu.js → story-capture-D-Bfhd-N.js} +1 -1
- package/dist/assets/{story-documents-DqVhPp7Q.js → story-documents-B4eqKV9Q.js} +1 -1
- package/dist/assets/{story-documents.service-BGVSWonW.js → story-documents.service-BzgLOK5s.js} +1 -1
- package/dist/assets/{story-documents.service-B7YLSGGl.js → story-documents.service-Kbq0L_qc.js} +1 -1
- package/dist/assets/{story-media-presence-DtHxlfLm.js → story-media-presence-DylsyDkr.js} +1 -1
- package/dist/assets/{story-pixi-preview-4UdwWiBu.js → story-pixi-preview-D2IVMDNn.js} +1 -1
- package/dist/assets/{story-presentation-D1TZsV0C.js → story-presentation-Cp6l325C.js} +1 -1
- package/dist/assets/{story-three-preview-D_g4a4Le.js → story-three-preview-DepXfNP0.js} +2 -2
- package/dist/assets/{studio-environment-1cwp_5d7.js → studio-environment-IgmQFWyd.js} +1 -1
- package/dist/assets/{surface-state-DjrYVebs.js → surface-state-CmM-3m-Q.js} +1 -1
- package/dist/assets/{syntactic-prop-specs-fgViRyRh.js → syntactic-prop-specs-BkXxTFOh.js} +1 -1
- package/dist/assets/{team-playtest.service-DgbHBLBb.js → team-playtest.service-COL0BN3l.js} +1 -1
- package/dist/assets/{three-D6jqjBEb.js → three-DI0IcOPh.js} +1 -1
- package/dist/assets/{three-authoring-adapter-CVuyHVoy.js → three-authoring-adapter-CP2YpLQI.js} +1 -1
- package/dist/assets/three-authoring.service-DpTIEmH3.js +2 -0
- package/dist/assets/{three-ingest-runtime-BZE8pNFB.js → three-ingest-runtime-C1rkxRcA.js} +1 -1
- package/dist/assets/{three-integration-C_2R9M16.js → three-integration-CjYs621O.js} +2 -2
- package/dist/assets/three-integration.service-BDfK-f7C.js +1 -0
- package/dist/assets/{three-projection-core-BBkEtoFl.js → three-projection-core-B5Rz6wb-.js} +1 -1
- package/dist/assets/{three-state-B43Tj_yx.js → three-state-Ch6FmIWu.js} +1 -1
- package/dist/assets/{three-story-capture.service-DWRAJSS3.js → three-story-capture.service-BfYfB1a_.js} +2 -2
- package/dist/assets/{three-story-model-Lz1xTUC3.js → three-story-model-BZmswPjX.js} +1 -1
- package/dist/assets/{three-viewport-presentation-DzvBa-nS.js → three-viewport-presentation-CP6onmQU.js} +1 -1
- package/dist/assets/{transform-mode-request-BSNy9wSI.js → transform-mode-request-DZs7R1cg.js} +1 -1
- package/dist/assets/{transport-strip-Br5I88s-.js → transport-strip-CCBtfQCz.js} +1 -1
- package/dist/assets/transport.header-DwdZ6rHJ.js +1 -0
- package/dist/assets/{tuples-CjnRO1dB.js → tuples-oiYOza0c.js} +1 -1
- package/dist/assets/{ui-board-document-B9JCWtmC.js → ui-board-document-BL0NGODT.js} +2 -2
- package/dist/assets/{user-data-BvAeRvCw.js → user-data-CSGKecHj.js} +1 -1
- package/dist/assets/{utility-view-state-D6D8DRjj.js → utility-view-state-BrzKuLRA.js} +1 -1
- package/dist/assets/{viewport-door-Cu2zHjqE.js → viewport-door-BKMhSHwk.js} +1 -1
- package/dist/assets/{viewport-root-presentation-DhvzyJF4.js → viewport-root-presentation-RDTf_Vif.js} +1 -1
- package/dist/assets/{viewport-surface-status-C8ao1kYM.js → viewport-surface-status-Ja_qK6uL.js} +1 -1
- package/dist/assets/{webworkerAll-PA819hf4.js → webworkerAll-pgZ6mwSX.js} +1 -1
- package/dist/assets/{worker-Bt4ZMKO2.js → worker-DT2ulpB8.js} +1 -1
- package/dist/assets/{workspace-arrangement-B71RawgR.js → workspace-arrangement-DIFR8bvv.js} +1 -1
- package/dist/assets/{world-documents-Daj6b58N.js → world-documents-C1DKxk9C.js} +1 -1
- package/dist/assets/{world-root-stage-binding-C5Hsg9CI.js → world-root-stage-binding-D7ZBdu5J.js} +1 -1
- package/dist/assets/{xstate-animation-binding-CRIHTEdx.js → xstate-animation-binding-_1Xyj_VP.js} +1 -1
- package/dist/assets/{xstate-animation-meta-CJ7CHG3p.js → xstate-animation-meta-4eFVmyGH.js} +1 -1
- package/dist-node/cli.js +16 -16
- package/package.json +16 -16
- package/dist/assets/InspectorObjectPreview-C8VwzHo1.js +0 -1
- package/dist/assets/Object3DDocumentViewport-BaTPsMaW.js +0 -2
- package/dist/assets/autoplay.service-CjSb7Lwk.js +0 -1
- package/dist/assets/instances.command-C3Db8kDA.js +0 -1
- package/dist/assets/network-observer.service-CatF04sX.js +0 -1
- package/dist/assets/three-authoring.service-CfLqPazd.js +0 -2
- package/dist/assets/three-integration.service-DqtQ7xhR.js +0 -1
- package/dist/assets/transport.header-CvF5KcFb.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 Wo,b as Ho,L as qo}from"./LineSegments2-DN9pUfWA.js";import{bh as ot,cl as Go,fo as x,cm as X,N as fn,a$ as bt,em as Jn,b4 as Ae,co as Tt,ey as Pe,cp as bn,_ as ht,ej as Mt,fd as $t,er as Se,M as it,cj as ut,dp as gt,aV as Ee,cW as Xo,aE as Yo,c7 as ft,j as Me,f6 as Ne,fp as to,au as An,dw as Pn,bi as no,aT as Re,c1 as Lt,dd as Vn,eC as jn,e7 as gn,aw as nn,da as It,I as yn,as as Ie,e8 as Fe,b0 as Zo,K as ze,B as De,b9 as Ce,Y as Qo,cw as ln,ed as ke,cA as $e,fx as Le,db as Ko,el as Ve,R as je,e6 as Be,c0 as Jo,bX as Ue,aI as uo,ao as We,eG as He,d3 as qe,cs as Ge,ex as Xe,b5 as Ye,cY as Ze,eU as Qe,cE as Bn,c5 as te,cO as oo,at as Ke,ff as Je,eW as ta,f7 as na,F as oa,ev as ea,et as aa,dq as ra,fq as la,n as ia,l as sa,cf as fa}from"./three.core-3arARmh6.js";import{u as A,v as F,w as E,c5 as q,c4 as W,c6 as S,e2 as $,_ as ca,mB as ne,d_ as jt,x as j,kE as _t,e1 as oe,mC as B,dZ as ua,mD as _a}from"./index-Dkutnr2n.js";import{S as Ft}from"./three.module-BLhyNg0e.js";import{t as ma}from"./blender-runtime-host-DTZFV6jk.js";const Un=new Set;function vt(){for(const o of[...Un])o()}function da(o){return Un.add(o),()=>{Un.delete(o)}}function Wn(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const Zt=S().finite(),ha=A({name:E(),parent:E().nullable(),connected:q(),hide:q(),length:Zt,matrix:F($([Zt,Zt,Zt,Zt])).length(4),select:q(),active:q(),lockedWeight:q()}).strict(),pa=A({object:E(),displayType:W(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:q(),mode:E(),bones:F(ha)}).strict(),xt={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function va(o){return new ht(o.r*o.r*.1,o.g*o.g*.1,o.b*o.b*.1)}const Sn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],_o=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],At=Math.SQRT1_2,ga=[[At,-At,0],[0,-At,-At],[-At,-At,0],[0,-At,At],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],xa=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],ba=.05;function mo(o){return o.select||o.active?2:1}const ya=10,wa=4,Oa=`
|
|
3
3
|
attribute vec3 aSolid;
|
|
4
4
|
attribute vec3 aHint;
|
|
5
5
|
varying vec3 vColor;
|
|
@@ -10,13 +10,13 @@ import{a as Uo,b as Wo,L as Ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ot
|
|
|
10
10
|
vColor = mix(aHint, aSolid, fac * fac);
|
|
11
11
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`,Ta=`
|
|
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 St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Ta=new X,Aa=new x,vo=new qo;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Pa{constructor(){this.group=new ot,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],a=JSON.stringify(t);if(a===this.signature)return e;this.signature=a,this.clear();for(const r of Object.values(t)){const l=n(r.object);if(l===null)continue;r.displayType!=="OCTAHEDRAL"&&r.displayType!=="STICK"&&e.push(`armature ${r.object}: Blender's ${r.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),r.mode==="EDIT"&&e.push(`armature ${r.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 c=r.bones.filter(f=>!f.hide);if(c.length===0)continue;const u=r.displayType==="STICK"?this.buildStick(r,c,l):this.buildOctahedral(r,c,l);r.showInFront&&u.traverse(f=>{const s=f.material;s&&"depthTest"in s&&(s.depthTest=!1),f.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],l=[],c=[],u=[],f=[],s=[],i=[],_=[],d=[],h=[];for(const m of n){const p=go(e,m),v=po(t,m),g=pa(v),b=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const P=Aa.set(...va[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const M=new x(...Sn[O]).applyMatrix4(p);r.push(M.x,M.y,M.z),l.push(P.x,P.y,P.z),c.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const w=mo(m)===2?i:f,R=mo(m)===2?_:s;for(const[T,P]of ga){const O=new x(...Sn[T]).applyMatrix4(p),M=new x(...Sn[P]).applyMatrix4(p);w.push(O.x,O.y,O.z,M.x,M.y,M.z),R.push(b.r,b.g,b.b,b.r,b.g,b.b)}m.parent!==null&&m.connected||(d.push(p.clone()),h.push(v)),d.push(p.clone().multiply(Ta.makeTranslation(0,1,0))),h.push(v)}a.add(this.solidMesh(r,l,c,u)),f.length&&a.add(this.lines(f,s,1)),i.length&&a.add(this.lines(i,_,2));for(let m=0;m<d.length;m++)a.add(this.point(d[m],h[m]));return a}buildStick(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],l=[],c=[],u=[];for(const f of n){const s=go(e,f),i=new x().setFromMatrixPosition(s),_=new x(0,1,0).applyMatrix4(s),d=ho(t,f),h=po(t,f);r.push(i.x,i.y,i.z,_.x,_.y,_.z),l.push(d.r,d.g,d.b,d.r,d.g,d.b),c.push(i.x,i.y,i.z,_.x,_.y,_.z),u.push(h.r,h.g,h.b,h.r,h.g,h.b)}return a.add(this.lines(r,l,ba)),a.add(this.lines(c,u,ya)),a}solidMesh(t,n,e,a){const r=new fn;r.setAttribute("position",new bt(t,3)),r.setAttribute("normal",new bt(n,3)),r.setAttribute("aSolid",new bt(e,3)),r.setAttribute("aHint",new bt(a,3));const l=new Jn({vertexShader:wa,fragmentShader:Oa,side:Te});this.disposables.push(r,l);const c=new Tt(r,l);return c.frustumCulled=!1,c}lines(t,n,e){const a=new Uo;a.setPositions(t),a.setColors(n);const r=new Wo({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const l=new Ho(a,r);return l.frustumCulled=!1,l}point(t,n){const e=new Ae(xa,12,8),a=new bn({color:n});this.disposables.push(e,a);const r=new Tt(e,a);return r.applyMatrix4(t),r.frustumCulled=!1,r}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 Sa="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ea(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),a=t(1/e);return{unit:[t(o[0]*a),t(o[1]*a),t(o[2]*a)],length:e}}return{unit:[0,0,0],length:0}}const N=Math.fround,wn=N(2*Math.PI),En=N(1-1e-4),zt=(o,t)=>N(N(N(o[0]*t[0])+N(o[1]*t[1]))+N(o[2]*t[2])),rn=(o,t,n=1)=>o.map((e,a)=>N(e+N(t[a]*n))),Ma=(o,t)=>o.map((n,e)=>N(n-t[e]));function Kt(o){const t=N(Math.sqrt(zt(o,o)));return t>0?o.map(n=>N(n/t)):[0,0,0]}function Jt(o){const t=Math.abs(o)<1?N(1-N(1-Math.abs(o))):1;let n=N(N(.077980478)+N(t*N(-.02164095)));n=N(N(-.213300989)+N(t*n)),n=N(N(1.5707963267)+N(t*n));const e=N(N(Math.sqrt(N(1-t)))*n);return o<0?N(N(Math.PI)-e):e}function Na(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let a=0;a<3;a++){const r=(a+1)%3,l=(a+2)%3;n[a]=N(n[a]+N(N(t[r]-e[r])*N(t[l]+e[l])))}t=e}return n}function Ra(o){const t=[],n=[],e=(h,m)=>h<m?`${h}:${m}`:`${m}:${h}`,a=new Map((o.edge_order??[]).map(([h,m],p)=>[e(h,m),p])),r=new Set((o.sharp??[]).map(([h,m])=>e(h,m))),l=new Map;for(const[h,m]of o.f.entries()){const p=t.length,v=Ea(Na(m.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<m.length;g++){const b=e(m[g],m[(g+1)%m.length]);a.has(b)||a.set(b,a.size);const w=o.face_edges?.[h]?.[g]??a.get(b),R=t.length;t.push({vertex:m[g],face:h,edge:w,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=l.get(w)??[];T.push(R),l.set(w,T)}}const c=new Map,u=new Map;for(const[h,m]of l){if(m.length!==2||o.edge_sharp?.[h])continue;const[p,v]=m,g=t[p],b=t[v];!o.s?.[g.face]||!o.s?.[b.face]||g.vertex!==t[b.next].vertex||b.vertex!==t[g.next].vertex||!o.edge_sharp&&r.has(e(g.vertex,b.vertex))||(u.set(p,b.next),c.set(b.next,p),u.set(v,g.next),c.set(g.next,v))}const f=[],s=[],i=[],_=[],d=(h,m)=>Kt(Ma(o.v[t[t[h][m]].vertex],o.v[t[h].vertex]));for(let h=0;h<t.length;h++){if(s[h]!==void 0)continue;let m=h;const p=new Set([m]);for(;u.has(m)&&!p.has(u.get(m));)m=u.get(m),p.add(m);u.has(m)&&(m=Math.min(...p));const v=[m];for(;c.has(v.at(-1))&&c.get(v.at(-1))!==m;)v.push(c.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[m].face];else{for(const M of v)g=rn(g,n[t[M].face],Jt(zt(d(M,"prev"),d(M,"next"))));g=Kt(g)}const b=d(m,"next"),w=v.at(-1),R=d(w,"prev"),T=zt(b,g),P=zt(R,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<En&&Math.abs(P)<En){const M=v.length>1?v.map(pt=>d(pt,"next")):[];M.length&&t[t[w].prev].edge!==t[m].edge&&M.push(R),O.alpha=M.length?N(M.reduce((pt,y)=>N(pt+Jt(zt(y,g))),0)/M.length):N(N(Jt(T)+Jt(P))/2),O.reference=Kt(rn(b,g,-T));const C=g,V=O.reference;O.ortho=Kt([N(N(C[1]*V[2])-N(C[2]*V[1])),N(N(C[2]*V[0])-N(C[0]*V[2])),N(N(C[0]*V[1])-N(C[1]*V[0]))]);const H=Kt(rn(R,g,-P)),Q=zt(O.reference,H),tt=Jt(Q);O.beta=Q<En?zt(O.ortho,H)<0?N(wn-tt):tt:wn}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)s[M]=f.length;f.push(v),i.push(O),_.push(g)}return{corners:t,fans:f,fanOf:s,spaces:i,faceNormals:n,fanNormals:_}}function Ia(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=N(t[0]/32767),e=N(t[1]/32767),a=N((n>0?o.alpha:N(wn-o.alpha))*n),r=N((e>0?o.beta:N(wn-o.beta))*e);let l=o.normal.map(c=>N(c*N(Math.cos(a))));return l=rn(l,o.reference,N(N(Math.sin(a))*N(Math.cos(r)))),e!==0&&(l=rn(l,o.ortho,N(N(Math.sin(a))*N(Math.sin(r))))),l}function oe(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Ra(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const r=new Array(n.length);for(const[l,c]of e.entries()){const u=c.reduce((s,i)=>{const _=t.data[i];return[s[0]+_[0],s[1]+_[1]]},[0,0]),f=Ia(a[l],u.map(s=>Math.trunc(s/c.length)));for(const s of c)r[s]=f}return r}if(t.type==="FLOAT_VECTOR")return n.map((r,l)=>{const c=t.domain==="POINT"?r.vertex:t.domain==="FACE"?r.face:l;return t.data[c]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Mn={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}},Fa=1e-6;function za(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t.x+=(e.y-a.y)*(e.z+a.z),t.y+=(e.z-a.z)*(e.x+a.x),t.z+=(e.x-a.x)*(e.y+a.y)}return t.multiplyScalar(.5)}const Da=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),xo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ca(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t+=e.x*a.y-a.x*e.y}return t}function bo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let a=0;for(const[r,l,c]of o){const u=Da(t[r],t[l],t[c]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Fa*Math.abs(n)}function ka(o){const t=o.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=za(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:xo(t),sound:!1,method:"fan"};const a=n.clone().divideScalar(e),r=Math.abs(a.x)<.9?new x(1,0,0):new x(0,1,0),l=new x().crossVectors(r,a).normalize(),c=new x().crossVectors(a,l),u=o[0],f=o.map(d=>{const h=d.clone().sub(u);return new $t(h.dot(l),h.dot(c))}),s=Ca(f),i=xo(t);if(bo(i,f,s))return{triangles:i,sound:!0,method:"fan"};let _=[];try{_=Pe.triangulateShape(f,[]).map(d=>[d[0],d[1],d[2]])}catch{return{triangles:i,sound:!1,method:"fan"}}return bo(_,f,s)?{triangles:_,sound:!0,method:"earcut"}:{triangles:_.length>0?_:i,sound:!1,method:_.length>0?"earcut":"fan"}}const $a=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Nn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Rn(o,t,n){switch(o){case"FLOAT":{const e=Number(t[n]);return[e,e,e,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[Nn(Number(t[n*4])),Nn(Number(t[n*4+1])),Nn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function ee(o,t){return o.filter(n=>$a.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),a=[0,0,0,0];return{name:n.name,domain:n.domain,read:(r,l,c)=>n.domain==="POINT"?Rn(n.type,e,r):n.domain==="CORNER"?l===void 0?a:Rn(n.type,e,l):c===void 0?a:Rn(n.type,e,c)}})}function ae(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,a=o.cornerVerts,r=e[n];let l=t;for(let y=0;y<n;y++)l+=(e[y+1]-e[y]-2)*3;const c=new Uint32Array(r),u=new Uint8Array(r),f=new Uint8Array(t),s=new Uint32Array(r);let i=!1;for(let y=0;y<n;y++)if(o.smooth(y)){i=!0;break}const _=(y,L)=>t<94906265?Math.min(y,L)*t+Math.max(y,L):`${Math.min(y,L)}:${Math.max(y,L)}`,d=new Map,h=new Set;for(const[y,L]of o.sharp)h.add(_(y,L));if(o.edges)for(const[y,L]of o.edges){if(y===L)throw new Error("Runtime mesh edge needs distinct vertices");d.set(_(y,L),-1)}const m=y=>{for(;s[y]!==y;)s[y]=s[s[y]],y=s[y];return y},p=(y,L)=>{const D=m(y),Y=m(L);s[Math.max(D,Y)]=Math.min(D,Y)};for(let y=0;y<n;y++){const L=e[y],D=e[y+1]-L,Y=o.smooth(y)?1:0;for(let Z=0;Z<D;Z++){const k=L+Z;f[a[k]]=1,c[k]=L+(Z+1)%D,u[k]=Y,s[k]=k}}for(let y=0;y<r;y++){const L=c[y],D=a[y],Y=a[L],Z=_(D,Y),k=d.get(Z);if(k!==void 0&&k>=0&&u[y]&&u[k]&&!h.has(Z)){const G=c[k];p(y,a[k]===D?k:G),p(L,a[k]===D?G:k)}(k===void 0||k<0||!u[k]&&u[y])&&d.set(Z,y)}const v=o.uv,g=new Float32Array(l*3),b=new Float32Array(l*2),w=new Uint32Array(l),R=(o.uvLayers??[]).map(y=>({...y,data:new Float32Array(l*2)})),T=(o.attributeLayers??[]).map(y=>({...y,data:new Float32Array(l*4)})),P=o.orco?new Float32Array(l*3):null,O=new Uint32Array(l),M=new Map,C=[],V=o.normals||o.cornerNormal?new Float32Array(l*3):null;let H=0,Q=0;const tt=(y,L,D,Y,Z)=>{const k=H++;for(const G of T)G.data.set(G.read(y,Y,Z),k*4);if(P)for(let G=0;G<3;G++)P[k*3+G]=o.orco[y*3+G]*.5+.5;if(w[k]=y,o.co(y).toArray(g,k*3),L&&b.set(L,k*2),D&&V.set(D,k*3),Y!==void 0)for(const G of R)G.data.set(G.read(Y),k*2);return k},pt=(y,L)=>{const D=v?.(y),Y=o.cornerNormal?[o.cornerNormal[y*3],o.cornerNormal[y*3+1],o.cornerNormal[y*3+2]]:o.normals?.[y];if(!i)return tt(a[y],D,Y,y,L);const Z=`${u[y]?m(y):y}${D?`:${D[0]}:${D[1]}`:""}${Y?`:n${Y.join(":")}`:""}${R.map(G=>":"+G.read(y).join(":")).join("")}${T.map(G=>G.domain==="POINT"?"":":"+Array.from(G.read(a[y],y,L)).join(":")).join("")}`;let k=M.get(Z);return k===void 0&&(k=tt(a[y],D,Y,y,L),M.set(Z,k)),k};for(let y=0;y<n;y++){const L=Q,D=e[y],Y=e[y+1]-D,Z=[];for(let Yt=0;Yt<Y;Yt++)Z.push(o.co(a[D+Yt]));for(const Yt of ka(Z).triangles)for(const Oe of Yt)O[Q++]=pt(D+Oe,y);const k=o.material(y),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let y=0;y<t;y++)f[y]||tt(y);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?b.slice(0,H*2):null,uvLayers:R.map(y=>({name:y.name,data:y.data.slice(0,H*2)})),attributeLayers:T.map(y=>({name:y.name,data:y.data.slice(0,H*4)})),orco:P?P.slice(0,H*3):null,indices:O.slice(0,Q),sourceVertex:w.slice(0,H),groups:C}}function Vt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function Hn(o){const t=new fn;t.setAttribute("position",new it(o.positions,3)),t.setAttribute("uv",new it(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new it(o.indices,1));const n=Object.create(null);for(const[e,a]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[a.name]=e+1,t.setAttribute(`uv${e+1}`,new it(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(Vt(e.name),new it(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new it(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new it(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new it(o.sourceVertex,1)),t}function La(o,t){const n=o.co.length/3,e=o.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),a=o.renderUv??o.activeUv??e[0]?.name,r=e.find(m=>m.name===a);if(a&&!r)throw new Error(`Runtime UV map ${a} is missing`);const l=r?r.data:null,c=o.edge.length/2,u=new Array(c);for(let m=0;m<c;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const f=[];for(let m=0;m<c;m++)o.edgeSharp[m]===1&&f.push(u[m]);const s=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),i=s?{v:Array.from({length:n},(m,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:f,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,_=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/Mn[s.type].size},(m,p)=>Array.from({length:Mn[s.type].size},(v,g)=>Number(s.data[p*Mn[s.type].size+g])))}:void 0,d=new x,h={vertexCount:n,normals:i?oe(i,_):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>d.set(o.co[m*3],o.co[m*3+1],o.co[m*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:m=>o.smooth[m]===1,material:m=>o.material[m],edges:u,sharp:f,uv:l?m=>[l[m*2],l[m*2+1]]:null,uvLayers:e.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:ee(o.attributes,m=>m)};return{...ae(h),hash:t}}function Va(o){const t=o.v.map(i=>new x(...i)),n=i=>{const _=t[i];if(!_)throw new Error(`Runtime mesh vertex ${i} is missing`);return _},e=new Uint32Array(o.f.length+1);o.f.forEach((i,_)=>{if(i.length<3||new Set(i).size!==i.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[_+1]=e[_]+i.length});const a=new Uint32Array(e[o.f.length]);o.f.forEach((i,_)=>i.forEach((d,h)=>{n(d),a[e[_]+h]=d}));for(const[i,_]of o.edge_order??o.e??[])n(i),n(_);const r={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:a.length};for(const i of o.attributes??[])if(i.domain!=="EDGE"&&i.data.length!==r[i.domain])throw new Error(`Runtime attribute ${i.name} has ${i.data.length} values for ${r[i.domain]} ${i.domain} elements`);const l=(o.attributes??[]).filter(i=>i.type==="FLOAT2"&&i.domain==="CORNER"),c=o.render_uv??o.active_uv??l[0]?.name,u=l.find(i=>i.name===c);if(c&&!u)throw new Error(`Runtime UV map ${c} is missing`);const f=u?.data,s={vertexCount:t.length,normals:oe(o,o.attributes?.find(i=>i.name==="custom_normal")),co:n,starts:e,cornerVerts:a,smooth:i=>!!o.s?.[i],material:i=>o.m?.[i]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:f?i=>f[i]:null,uvLayers:l.map(i=>({name:i.name,read:_=>i.data[_]})),attributeLayers:ee(o.attributes??[],i=>Array.from(i).flat())};return Hn(ae(s))}const sn=1.5707963267948966,Dt=6.283185307179586,re=.3183098861837067,le=.0795774715459476,ja=.3,Ba=le,Ua=3/16*re,qn=.8,yo=qn*qn,Ct=6371,ie=100,Gn=Ct+ie,wo=64,Oo=64,et=256,Nt=64,Wa=[1.679,1.828,1.986,1.307],Ha=[.006605,.01067,.01842,.03156],qa=[3472e-28,3914e-28,1349e-28,1103e-29],Ga=334.5,Xa=[28722e-28,46168e-28,79706e-28,13578e-27],Ya=[15908e-26,17711e-26,20942e-26,24033e-26],To=13681e16,Za=2e6,Qa=.73,In=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],On=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),Ka=o=>Math.sqrt(Math.max(o,0)),se=o=>[-Math.sqrt(1-o*o),0,o];function Xn(o,t,n,e,a,r,l){const c=o*e+t*a+n*r,u=o*o+t*t+n*n-l*l;if(u>0&&c>0)return-1;const f=c*c-u;return f<0?-1:f>=c*c?-c+Math.sqrt(f):-c-Math.sqrt(f)}const Ja=o=>Ua*(1+On(o));function tr(o){const t=1+yo+2*qn*o;return le*(1-yo)/(t*Math.sqrt(t))}const nr=o=>To*(Math.exp(-o/Qa)+Za/To);function eo(o,t){let n=o%Dt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=sn||n<=-sn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Dt,e<0&&(e+=Dt),e=Dt-e,[n,e]}class or{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Nt*et*4)}coefficients(t,n){const e=nr(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-On(a-3.22261)*5.55555555-a),l=Math.exp(-.07771971*t**1.16364243);for(let c=0;c<4;c++)n[c]=Xa[c]*e,n[4+c]=Ya[c]*e,n[8+c]=qa[c]*Ga*r*this.ozone,n[12+c]=Ha[c]*l*this.air}transmittance(t,n,e){const[a,r,l]=se(t),c=Ot(Ct,Gn,n),f=Xn(0,0,c,a,r,l,Gn)/wo,s=[0,0,0,0],i=new Float64Array(16);for(let _=0;_<wo;_++){const d=(_+.5)*f,h=a*d,m=r*d,p=c+l*d,v=Math.max(Math.hypot(h,m,p)-Ct,0);this.coefficients(v,i);for(let g=0;g<4;g++)s[g]+=(i[g]+i[4+g]+i[8+g]+i[12+g])*f}for(let _=0;_<4;_++)e[_]=Math.exp(-s[_])}precompute(){const t=new Float64Array(4);for(let n=0;n<Nt;n++)for(let e=0;e<et;e++){const a=e/(et-1),r=n/(Nt-1);this.transmittance(a*2-1,r,t);const l=(n*et+e)*4;for(let c=0;c<4;c++)this.lut[l+c]=t[c]}}lookup(t,n,e){const a=(et-1)*on(t*.5+.5),r=(Nt-1)*on(n),l=Math.trunc(a),c=Math.trunc(r),u=Math.min(l+1,et-1),f=Math.min(c+1,Nt-1),s=a-l,i=r-c,_=(c*et+l)*4,d=(c*et+u)*4,h=(f*et+l)*4,m=(f*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[_+p],this.lut[d+p],s),Ot(this.lut[h+p],this.lut[m+p],s),i)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,et-1),l=e-a;for(let c=0;c<4;c++)n[c]=Ot(this.lut[a*4+c],this.lut[r*4+c],l)}lookupToSun(t,n){const e=(Nt-1)*on(t),a=Math.trunc(e),r=Math.min(a+1,Nt-1),l=e-a,c=et-1;for(let u=0;u<4;u++)n[u]=Ot(this.lut[(a*et+c)*4+u],this.lut[(r*et+c)*4+u],l)}inscattering(t,n,e,a,r,l,c,u,f){const s=-(r*t[0]+l*t[1]+c*t[2]),i=Ja(s),_=tr(s),d=u/Oo,h=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),b=new Float64Array(4),w=[0,0,0,0],R=[1,1,1,1];for(let T=0;T<Oo;T++){const P=(T+.5)*d,O=n+r*P,M=e+l*P,C=a+c*P,V=Math.hypot(O,M,C),H=Math.max(V-Ct,0),Q=H/ie,tt=(O*t[0]+M*t[1]+C*t[2])/V;this.coefficients(H,h),this.lookup(tt,Q,m);const pt=Dt*(1-Ka(1-On(Ct/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,b);const y=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let D=0;D<4;D++){const Y=g[D]/b[D],Z=Ba*pt*(ja*re)*v[D]*Y*tt;p[D]=.02*L[D]*y+Z}for(let D=0;D<4;D++){const Y=h[D]+h[4+D]+h[8+D]+h[12+D],Z=Wa[D]*(h[12+D]*(i*m[D]+p[D])+h[4+D]*(_*m[D]+p[D])),k=Math.exp(-d*Y),G=Math.max(Y,1e-7);w[D]+=R[D]*((Z-Z*k)/G),R[D]*=k}}for(let T=0;T<4;T++)f[T]=w[T]}}const st=512,qt=256;function fe(o,t){const n=new or(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=se(Math.cos(sn-t)),r=new Float32Array(st*qt*3),l=st/2,c=new Float64Array(4);for(let u=0;u<qt;u++)for(let f=0;f<l;f++){const s=(f+.5)/st,i=(u+.5)/qt,_=Dt*s,d=i*2-1,h=Math.sign(d)*On(d)*sn,m=Math.cos(h)*Math.cos(_),p=Math.cos(h)*Math.sin(_),v=Math.sin(h),g=Ct+e,b=Xn(0,0,g,m,p,v,Gn),w=Xn(0,0,g,m,p,v,Ct),R=w<0?b:w;n.inscattering(a,0,0,g,m,p,v,R,c);let T=0,P=0,O=0;for(let V=0;V<4;V++)T+=In[V][0]*c[V],P+=In[V][1]*c[V],O+=In[V][2]*c[V];const M=(u*st+f)*3;r[M]=T,r[M+1]=P,r[M+2]=O;const C=(u*st+(st-f-1))*3;r[C]=T,r[C+1]=P,r[C+2]=O}return r}function er(o){const[t]=eo(o.sunElevation,o.sunRotation);return fe(o,t)}function ao(o){const[t]=eo(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const ar=6,Wt=new Map;function rr(o){return Wt.has(ao(o))}function ce(o,t){Wt.set(ao(o),t),Wt.size>ar&&Wt.delete(Wt.keys().next().value)}function lr(o){const[t,n]=eo(o.sunElevation,o.sunRotation),e=ao(o);let a=Wt.get(e);a===void 0&&(a=fe(o,t),ce(o,a));const r=new x;return l=>{const c=Math.hypot(l.x,l.y),u=Math.atan2(l.z,c);let s=(Math.atan2(l.x,l.y)+Math.PI+n)/Dt;s-=Math.floor(s);const i=Math.abs(u),_=on(Math.sqrt(i/sn)*Math.sign(u)*.5+.5),d=s*st-.5,h=_*qt-.5,m=Math.floor(d),p=Math.floor(h),v=d-m,g=h-p,b=C=>(C%st+st)%st,w=C=>C<0?0:C>qt-1?qt-1:C,R=b(m),T=b(m+1),P=w(p),O=w(p+1),M=[0,0,0];for(let C=0;C<3;C++){const V=Ot(a[(P*st+R)*3+C],a[(P*st+T)*3+C],v),H=Ot(a[(O*st+R)*3+C],a[(O*st+T)*3+C],v);M[C]=Ot(V,H,g)}return r.set(yt[0][0]*M[0]+yt[0][1]*M[1]+yt[0][2]*M[2],yt[1][0]*M[0]+yt[1][1]*M[1]+yt[1][2]*M[2],yt[2][0]*M[0]+yt[2][1]*M[1]+yt[2][2]*M[2])}}let Pt=null,cn=!1,ir=0;const en=new Map;function sr(){if(Pt||cn)return Pt;if(typeof Worker>"u")return cn=!0,null;try{Pt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return Pt.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,a=en.get(t);a&&(en.delete(t),n?a.resolve(n):a.reject(new Error(e??"sky worker returned nothing")))},Pt.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),Pt?.terminate(),Pt=null,cn=!0},Pt}function fr(o){const t=sr();if(!t)return Promise.resolve(er(o));const n=ir++,e={id:n,parameters:o};return new Promise((a,r)=>{en.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function cr(o,t,n,e={}){switch(e.type??"LINEAR"){case"QUADRATIC":{const a=Math.max(o,0);return a*a}case"EASING":{const a=Math.min(1,Math.max(0,o));return a*a*(3-2*a)}case"DIAGONAL":return(o+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(o,t,n),0);case"QUADRATIC_SPHERE":{const a=Math.max(.999999-Math.hypot(o,t,n),0);return a*a}case"RADIAL":return Math.atan2(t,o)/(2*Math.PI)+.5;default:return o}}const Fn=(o,t)=>t!==0?o/t:0,Ao=o=>Math.min(1,Math.max(-1,o)),Po=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},ue={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:Fn,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:Fn(Math.log(o),Math.log(t)),SQRT:o=>Math.sqrt(Math.max(o,0)),INVERSE_SQRT:o=>o>0?1/Math.sqrt(o):0,ABSOLUTE:Math.abs,RADIANS:o=>o*Math.PI/180,DEGREES:o=>o*180/Math.PI,MINIMUM:(o,t)=>Math.min(o,t),MAXIMUM:(o,t)=>Math.max(o,t),LESS_THAN:(o,t)=>+(o<t),GREATER_THAN:(o,t)=>+(o>t),ROUND:o=>Math.floor(o+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:o=>o-Math.floor(o),MODULO:(o,t)=>t!==0?o%t:0,FLOORED_MODULO:(o,t)=>t!==0?o-Math.floor(o/t)*t:0,TRUNC:Math.trunc,SNAP:(o,t)=>Math.floor(Fn(o,t))*t,WRAP:(o,t,n)=>t!==n?o-(t-n)*Math.floor((o-n)/(t-n)):n,PINGPONG:(o,t)=>{if(t===0)return 0;const n=(o-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:o=>Math.asin(Ao(o)),ARCCOSINE:o=>Math.acos(Ao(o)),ARCTANGENT:Math.atan,ARCTAN2:(o,t)=>o===0&&t===0?0:Math.atan2(o,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(o,t,n)=>+(o===t||Math.abs(o-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(o,t,n)=>o*t+n,SMOOTH_MIN:Po,SMOOTH_MAX:(o,t,n)=>-Po(-o,-t,n)};function nt(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const a=new x(...o);return()=>a}if(o.kind==="direction")return a=>a;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const a=nt(o.vector,t),r={type:o.gradient_type},l=new x;return c=>{const u=a(c),f=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,i=typeof u=="number"?u:u.z,_=ut.clamp(cr(f,s,i,r),0,1);return o.output==="Fac"?_:l.setScalar(_)}}if(o.kind==="to_float"){const a=nt(o.value,t);return r=>{const l=a(r);return typeof l=="number"?l:Math.fround(o.source_type==="RGBA"?l.x*.212639+l.y*.7151687+l.z*.0721923:(l.x+l.y+l.z)/3)}}if(o.kind==="math"){const a=o.inputs.map(c=>nt(c,t)),r=ue[o.operation],l=(c,u)=>{const f=a[c]?.(u)??0;if(typeof f!="number")throw new Error("World Math needs scalar inputs");return Math.fround(f)};return c=>{const u=Math.fround(r(l(0,c),l(1,c),l(2,c)));return o.clamp?ut.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=nt(o.factor,t),r=nt(o.a,t),l=nt(o.b,t),c=new x,u=new x;return f=>{const s=a(f);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const i=r(f);typeof i=="number"?c.setScalar(i):c.copy(i);const _=l(f);return typeof _=="number"?u.setScalar(_):u.copy(_),c.lerp(u,o.clamp_factor?ut.clamp(s,0,1):s),o.clamp_result&&c.clampScalar(0,1),c}}if(o.kind==="sky"){const a=lr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return r=>a(r)}if(o.kind==="mapping"){const a=nt(o.vector,t),r=new x(...o.location),l=new x(...o.scale),c=new gt().setFromEuler(new Se(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=c.clone().invert(),f=new x(...o.scale.map(i=>i===0?0:1/i)),s=new x;return i=>{const _=a(i);switch(typeof _=="number"?s.setScalar(_):s.copy(_),o.vector_type??"POINT"){case"TEXTURE":return s.sub(r).applyQuaternion(u).multiply(f);case"VECTOR":return s.multiply(l).applyQuaternion(c);case"NORMAL":return s.multiply(f).applyQuaternion(c).normalize();case"POINT":return s.multiply(l).applyQuaternion(c).add(r)}}}if(o.kind==="map_range"){const a=nt(o.value,t),r=nt(o.from_min,t),l=nt(o.from_max,t),c=nt(o.to_min,t),u=nt(o.to_max,t),f=nt(o.steps,t),s=(d,h)=>{const m=d(h);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},i=o.interpolation,_=o.clamp;return d=>{const h=s(a,d),m=s(r,d),p=s(l,d),v=s(c,d),g=s(u,d);if(m===p)return 0;let b;if(i==="STEPPED"){const R=s(f,d),T=(h-m)/(p-m);b=R>0?Math.floor(T*(R+1))/R:0}else if(i==="SMOOTHSTEP"||i==="SMOOTHERSTEP"){const R=ut.clamp((h-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=i==="SMOOTHSTEP"?R*R*(3-2*R):R*R*R*(R*(R*6-15)+10);b=m>p?1-T:T}else b=(h-m)/(p-m);const w=v+b*(g-v);return _?v>g?ut.clamp(w,g,v):ut.clamp(w,v,g):w}}if(o.kind==="separate"){const a=nt(o.vector,t);return r=>{const l=a(r);return typeof l=="number"?l:l.getComponent(o.axis)}}const n=nt(o.factor,t),e=new x;return a=>{const r=n(a);if(typeof r!="number")throw new Error("World ColorRamp needs a scalar factor");const l=ut.clamp(r,0,1)*256,c=Math.floor(l),u=o.colors[c],f=o.colors[Math.min(c+1,256)],s=o.interpolate?l-c:0;return e.set(ut.lerp(u[0],f[0],s),ut.lerp(u[1],f[1],s),ut.lerp(u[2],f[2],s))}}function ur(o,t,n,e){const a=new Float32Array(t*n*3),r=nt(o,e),l=new x;for(let c=0;c<n;c++){const u=((c+.5)/n-.5)*Math.PI;for(let f=0;f<t;f++){const s=((f+.5)/t-.5)*2*Math.PI;l.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const i=r(l),_=(c*t+f)*3;a[_]=typeof i=="number"?i:i.x,a[_+1]=typeof i=="number"?i:i.y,a[_+2]=typeof i=="number"?i:i.z}}return a}function So(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function _r(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,l=nt(o,()=>r),c=new x,u=e.getWorldPosition(new x),f=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let i=0;i<t;i++){const _=(i+.5)/t,d=(s+.5)/n;r.set(_,d,0),e.isOrthographicCamera?c.copy(f):c.set(_*2-1,d*2-1,.5).unproject(e).sub(u).normalize(),c.set(c.x,-c.z,c.y);const h=l(c),m=(s*t+i)*3;a[m]=typeof h=="number"?h:h.x,a[m+1]=typeof h=="number"?h:h.y,a[m+2]=typeof h=="number"?h:h.z}return a}const J=S().finite(),mr=A({type:W(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:W(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Yn;function dr(){return Yn??=fa(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Yn}function hr(){return Yn??Promise.resolve()}const pr=o=>{const t=o.size??0,n=o.size_y??t;if(o.shape==="RECTANGLE")return[t,n];if(o.shape==="DISK"){const e=Math.sqrt(Math.PI*t*t/4);return[e,e]}if(o.shape==="ELLIPSE"){const e=Math.sqrt(Math.PI/4);return[t*e,n*e]}return[t,t]};function vr(o,t){const n=(l,c)=>t&&c(t)?t:new l;if(o.type==="SUN"){const l=n(Xo,c=>c.isDirectionalLight);return l.intensity=o.energy,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="POINT"){const l=n(Vn,c=>c.isPointLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="SPOT"){const l=n(jn,c=>c.isSpotLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.angle=(o.spot_size??0)/2,l.penumbra=o.spot_blend??0,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}dr();const e=n(gn,l=>l.isRectAreaLight),[a,r]=pr(o);return e.width=a,e.height=r,e.intensity=o.energy/(Math.max(a*r,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],ft),e}function gr(o,t,n){if(!o.castShadow||n<=0)return;const a=o.getWorldPosition(new x).distanceTo(t),r=o.shadow;if(!r)return;const l=r.camera;l.near=Math.max(n*.001,a-n),l.far=a+n,o.isDirectionalLight&&(l.left=-n,l.right=n,l.top=n,l.bottom=-n),l.updateProjectionMatrix()}function xr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ro=[{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}],Eo=.69;class br{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Go;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[a,r]of ro.entries()){const l=(1+r.smooth)**2,c=new Xo(16777215,Math.PI*Eo/l);c.name=`BlenderSolidLight${a}`,c.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],ft),c.position.set(r.direction[0],r.direction[1],r.direction[2]),c.target=t,this.group.add(c),this.lights.push(c),n.r+=r.diffuse[0]*r.smooth/l,n.g+=r.diffuse[1]*r.smooth/l,n.b+=r.diffuse[2]*r.smooth/l}const e=new Ee(16777215,Math.PI*Eo);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),U=te(()=>jt([J,Ut,A({kind:j("direction")}).strict(),A({kind:j("window")}).strict(),A({kind:j("gradient"),gradient_type:W(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:W(["Fac","Color"]),vector:U}).strict(),A({kind:j("to_float"),source_type:W(["RGBA","VECTOR"]),value:U}).strict(),A({kind:j("math"),operation:W(Object.keys(ue)),clamp:q(),inputs:F(U).min(1).max(3)}).strict(),A({kind:j("mix_color"),factor:U,a:U,b:U,clamp_factor:q(),clamp_result:q()}).strict(),A({kind:j("mapping"),vector_type:W(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:U,location:Ut,rotation:Ut,scale:Ut}).strict(),A({kind:j("separate"),vector:U,axis:S().int().min(0).max(2)}).strict(),A({kind:j("ramp"),factor:U,colors:F(Ut).length(257),interpolate:q()}).strict(),A({kind:j("map_range"),interpolation:W(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:U,from_min:U,from_max:U,to_min:U,to_max:U,steps:U}).strict(),A({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),Mo=A({color:Ut,strength:J,shader:U.optional()}),yr=Mo.extend({volume:F(A({kind:W(["absorption","scatter","principled","emission"]),phase:E(),alpha:U,weight:U,color:U,density:U,anisotropy:U,absorption_color:U,emission_color:U,emission_strength:U,blackbody_intensity:U,temperature:U,blackbody_tint:U}).strict()).optional(),lighting:Mo.strict().optional()}).strict(),wr=4,tn=new Map,zn=new Set;function No(o,t,n){const r=Et(o);if(r&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const l=JSON.stringify([o,r?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),c=tn.get(l);if(c!==void 0)return Zn(c,t,256,128);const u=new x,f=new to,s=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,i=n?.getWorldPosition(new x),d=ur(o,256,128,r?h=>(u.set(h.x,h.z,-h.y),n.isPerspectiveCamera&&u.add(i),f.set(u.x,u.y,u.z,1).applyMatrix4(s),f.w===0?u.set(0,0,0):u.set(f.x/f.w*.5+.5,f.y/f.w*.5+.5,0)):void 0);return tn.set(l,d),tn.size>wr&&tn.delete(tn.keys().next().value),Zn(d,t,256,128)}function Or(o,t,n,e){const a=nn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=nn.toHalfFloat(t[r*3]*n),o[r*4+1]=nn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=nn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function Zn(o,t,n,e){const a=new Uint16Array(n*e*4);Or(a,o,t,n*e);const r=new An(a,n,e,Pn,no);return r.mapping=Ne,r.colorSpace=ft,r.minFilter=Lt,r.magFilter=Lt,r.needsUpdate=!0,r}class lo{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const a=lo.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,l=this.generation,u=[...So(r),...n.lighting?So(n.lighting.shader??n.lighting.color):[]].filter(s=>!rr(s));if(u.length===0){this.compose(a,n,r,e);return}const f=(async()=>{const s=await Promise.all(u.map(fr));u.forEach((i,_)=>{ce(i,s[_])}),!(this.generation!==l||this.applied?.scene!==a)&&(this.compose(a,n,r,e),vt())})();this.pending=f,zn.add(f),f.then(()=>zn.delete(f),()=>zn.delete(f))}compose(t,n,e,a){if(this.texture=No(e,n.strength,a),Et(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=Zn(_r(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=Me,t.background=this.screenTexture}else if(a&&a.isOrthographicCamera){const l=a.getWorldDirection(new x);l.set(l.x,-l.z,l.y);const c=nt(n.shader??n.color)(l);t.background=typeof c=="number"?new ht().setRGB(c,c,c).multiplyScalar(n.strength):new ht().setRGB(c.x,c.y,c.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?No(r.shader??r.color,r.strength,a):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 _e(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Tr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=_e(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new It(new x(1,0,0),-o.min.x),new It(new x(-1,0,0),o.max.x),new It(new x(0,1,0),-o.min.y),new It(new x(0,-1,0),o.max.y),new It(new x(0,0,1),-o.min.z),new It(new x(0,0,-1),o.max.z)],a=[],r=new x,l=new x,c=new x,u=new x,f=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let i=s+1;i<e.length;i++)for(let _=i+1;_<e.length;_++){const d=e[s],h=e[i],m=e[_];r.crossVectors(h.normal,m.normal);const p=d.normal.dot(r);Math.abs(p)<1e-12||(l.crossVectors(m.normal,d.normal),c.crossVectors(d.normal,h.normal),u.copy(r).multiplyScalar(-d.constant).addScaledVector(l,-h.constant).addScaledVector(c,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-f)&&a.push(u.clone()))}return a}function Ar(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new yn().setFromPoints(t.map(_=>_.clone().applyMatrix4(a))),l=r.getSize(new x),c=Math.max(l.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,f=Math.max(l.x,l.y,c)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*f,i=u*f;r.min.x-=i,r.min.y-=i,r.max.x+=i,r.max.y+=i;for(const _ of n){if(_.isEmpty())continue;const d=new yn().setFromPoints(_e(_).map(h=>h.applyMatrix4(a)));d.max.x<r.min.x||d.min.x>r.max.x||d.max.y<r.min.y||d.min.y>r.max.y||(r.min.z=Math.min(r.min.z,d.min.z),r.max.z=Math.max(r.max.z,d.max.z))}e.left=r.min.x,e.right=r.max.x,e.bottom=r.min.y,e.top=r.max.y,e.near=-r.max.z-s-c,e.far=-r.min.z+s+c,e.updateProjectionMatrix(),o.shadow.normalBias=s}const Gt=S().finite(),Ro=$([Gt,Gt,Gt]),me=A({min:$([S().int(),S().int(),S().int()]),max:$([S().int(),S().int(),S().int()]),density:F(Gt),voxelSize:Gt.positive(),color:Ro,emission:Ro,densityScale:Gt.nonnegative()}).strict();function Pr(o){const t=o.max.map((s,i)=>s-o.min[i]+1);if(t.some(s=>s<=0)||t.reduce((s,i)=>s*i,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Re(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Ie,n.type=Yo,n.minFilter=n.magFilter=Lt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),a=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),r=new Fe(a.x,a.y,a.z),l=r.getAttribute("position");for(let s=0;s<l.count;s++)l.setXYZ(s,e.x+(l.getX(s)>0?a.x:0),e.y+(l.getY(s)>0?a.y:0),e.z+(l.getZ(s)>0?a.z:0));l.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere();const c=new Jn({glslVersion:De,side:ze,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:e},extent:{value:a},voxelSize:{value:o.voxelSize},densityScale:{value:o.densityScale},volumeColor:{value:new x(...o.color)},emission:{value:new x(...o.emission)},cameraLocal:{value:new x},rayLocal:{value:new x},orthographic:{value:!1},worldScale:{value:new qo}},vertexShader:`
|
|
19
|
+
`;function St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Aa=new X,Pa=new x,vo=new Go;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Sa{constructor(){this.group=new ot,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],a=JSON.stringify(t);if(a===this.signature)return e;this.signature=a,this.clear();for(const r of Object.values(t)){const l=n(r.object);if(l===null)continue;r.displayType!=="OCTAHEDRAL"&&r.displayType!=="STICK"&&e.push(`armature ${r.object}: Blender's ${r.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),r.mode==="EDIT"&&e.push(`armature ${r.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 c=r.bones.filter(f=>!f.hide);if(c.length===0)continue;const u=r.displayType==="STICK"?this.buildStick(r,c,l):this.buildOctahedral(r,c,l);r.showInFront&&u.traverse(f=>{const s=f.material;s&&"depthTest"in s&&(s.depthTest=!1),f.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],l=[],c=[],u=[],f=[],s=[],i=[],_=[],d=[],h=[];for(const m of n){const p=go(e,m),v=po(t,m),g=va(v),b=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const P=Pa.set(...ga[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const M=new x(...Sn[O]).applyMatrix4(p);r.push(M.x,M.y,M.z),l.push(P.x,P.y,P.z),c.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const w=mo(m)===2?i:f,R=mo(m)===2?_:s;for(const[T,P]of xa){const O=new x(...Sn[T]).applyMatrix4(p),M=new x(...Sn[P]).applyMatrix4(p);w.push(O.x,O.y,O.z,M.x,M.y,M.z),R.push(b.r,b.g,b.b,b.r,b.g,b.b)}m.parent!==null&&m.connected||(d.push(p.clone()),h.push(v)),d.push(p.clone().multiply(Aa.makeTranslation(0,1,0))),h.push(v)}a.add(this.solidMesh(r,l,c,u)),f.length&&a.add(this.lines(f,s,1)),i.length&&a.add(this.lines(i,_,2));for(let m=0;m<d.length;m++)a.add(this.point(d[m],h[m]));return a}buildStick(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],l=[],c=[],u=[];for(const f of n){const s=go(e,f),i=new x().setFromMatrixPosition(s),_=new x(0,1,0).applyMatrix4(s),d=ho(t,f),h=po(t,f);r.push(i.x,i.y,i.z,_.x,_.y,_.z),l.push(d.r,d.g,d.b,d.r,d.g,d.b),c.push(i.x,i.y,i.z,_.x,_.y,_.z),u.push(h.r,h.g,h.b,h.r,h.g,h.b)}return a.add(this.lines(r,l,ya)),a.add(this.lines(c,u,wa)),a}solidMesh(t,n,e,a){const r=new fn;r.setAttribute("position",new bt(t,3)),r.setAttribute("normal",new bt(n,3)),r.setAttribute("aSolid",new bt(e,3)),r.setAttribute("aHint",new bt(a,3));const l=new Jn({vertexShader:Oa,fragmentShader:Ta,side:Ae});this.disposables.push(r,l);const c=new Tt(r,l);return c.frustumCulled=!1,c}lines(t,n,e){const a=new Wo;a.setPositions(t),a.setColors(n);const r=new Ho({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const l=new qo(a,r);return l.frustumCulled=!1,l}point(t,n){const e=new Pe(ba,12,8),a=new bn({color:n});this.disposables.push(e,a);const r=new Tt(e,a);return r.applyMatrix4(t),r.frustumCulled=!1,r}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 xo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ea(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),a=t(1/e);return{unit:[t(o[0]*a),t(o[1]*a),t(o[2]*a)],length:e}}return{unit:[0,0,0],length:0}}const N=Math.fround,wn=N(2*Math.PI),En=N(1-1e-4),zt=(o,t)=>N(N(N(o[0]*t[0])+N(o[1]*t[1]))+N(o[2]*t[2])),rn=(o,t,n=1)=>o.map((e,a)=>N(e+N(t[a]*n))),Ma=(o,t)=>o.map((n,e)=>N(n-t[e]));function Kt(o){const t=N(Math.sqrt(zt(o,o)));return t>0?o.map(n=>N(n/t)):[0,0,0]}function Jt(o){const t=Math.abs(o)<1?N(1-N(1-Math.abs(o))):1;let n=N(N(.077980478)+N(t*N(-.02164095)));n=N(N(-.213300989)+N(t*n)),n=N(N(1.5707963267)+N(t*n));const e=N(N(Math.sqrt(N(1-t)))*n);return o<0?N(N(Math.PI)-e):e}function Na(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let a=0;a<3;a++){const r=(a+1)%3,l=(a+2)%3;n[a]=N(n[a]+N(N(t[r]-e[r])*N(t[l]+e[l])))}t=e}return n}function Ra(o){const t=[],n=[],e=(h,m)=>h<m?`${h}:${m}`:`${m}:${h}`,a=new Map((o.edge_order??[]).map(([h,m],p)=>[e(h,m),p])),r=new Set((o.sharp??[]).map(([h,m])=>e(h,m))),l=new Map;for(const[h,m]of o.f.entries()){const p=t.length,v=Ea(Na(m.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<m.length;g++){const b=e(m[g],m[(g+1)%m.length]);a.has(b)||a.set(b,a.size);const w=o.face_edges?.[h]?.[g]??a.get(b),R=t.length;t.push({vertex:m[g],face:h,edge:w,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=l.get(w)??[];T.push(R),l.set(w,T)}}const c=new Map,u=new Map;for(const[h,m]of l){if(m.length!==2||o.edge_sharp?.[h])continue;const[p,v]=m,g=t[p],b=t[v];!o.s?.[g.face]||!o.s?.[b.face]||g.vertex!==t[b.next].vertex||b.vertex!==t[g.next].vertex||!o.edge_sharp&&r.has(e(g.vertex,b.vertex))||(u.set(p,b.next),c.set(b.next,p),u.set(v,g.next),c.set(g.next,v))}const f=[],s=[],i=[],_=[],d=(h,m)=>Kt(Ma(o.v[t[t[h][m]].vertex],o.v[t[h].vertex]));for(let h=0;h<t.length;h++){if(s[h]!==void 0)continue;let m=h;const p=new Set([m]);for(;u.has(m)&&!p.has(u.get(m));)m=u.get(m),p.add(m);u.has(m)&&(m=Math.min(...p));const v=[m];for(;c.has(v.at(-1))&&c.get(v.at(-1))!==m;)v.push(c.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[m].face];else{for(const M of v)g=rn(g,n[t[M].face],Jt(zt(d(M,"prev"),d(M,"next"))));g=Kt(g)}const b=d(m,"next"),w=v.at(-1),R=d(w,"prev"),T=zt(b,g),P=zt(R,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<En&&Math.abs(P)<En){const M=v.length>1?v.map(pt=>d(pt,"next")):[];M.length&&t[t[w].prev].edge!==t[m].edge&&M.push(R),O.alpha=M.length?N(M.reduce((pt,y)=>N(pt+Jt(zt(y,g))),0)/M.length):N(N(Jt(T)+Jt(P))/2),O.reference=Kt(rn(b,g,-T));const C=g,V=O.reference;O.ortho=Kt([N(N(C[1]*V[2])-N(C[2]*V[1])),N(N(C[2]*V[0])-N(C[0]*V[2])),N(N(C[0]*V[1])-N(C[1]*V[0]))]);const H=Kt(rn(R,g,-P)),Q=zt(O.reference,H),tt=Jt(Q);O.beta=Q<En?zt(O.ortho,H)<0?N(wn-tt):tt:wn}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)s[M]=f.length;f.push(v),i.push(O),_.push(g)}return{corners:t,fans:f,fanOf:s,spaces:i,faceNormals:n,fanNormals:_}}function Ia(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=N(t[0]/32767),e=N(t[1]/32767),a=N((n>0?o.alpha:N(wn-o.alpha))*n),r=N((e>0?o.beta:N(wn-o.beta))*e);let l=o.normal.map(c=>N(c*N(Math.cos(a))));return l=rn(l,o.reference,N(N(Math.sin(a))*N(Math.cos(r)))),e!==0&&(l=rn(l,o.ortho,N(N(Math.sin(a))*N(Math.sin(r))))),l}function ee(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Ra(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const r=new Array(n.length);for(const[l,c]of e.entries()){const u=c.reduce((s,i)=>{const _=t.data[i];return[s[0]+_[0],s[1]+_[1]]},[0,0]),f=Ia(a[l],u.map(s=>Math.trunc(s/c.length)));for(const s of c)r[s]=f}return r}if(t.type==="FLOAT_VECTOR")return n.map((r,l)=>{const c=t.domain==="POINT"?r.vertex:t.domain==="FACE"?r.face:l;return t.data[c]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Mn={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}},Fa=1e-6;function za(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t.x+=(e.y-a.y)*(e.z+a.z),t.y+=(e.z-a.z)*(e.x+a.x),t.z+=(e.x-a.x)*(e.y+a.y)}return t.multiplyScalar(.5)}const Da=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),bo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ca(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t+=e.x*a.y-a.x*e.y}return t}function yo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let a=0;for(const[r,l,c]of o){const u=Da(t[r],t[l],t[c]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Fa*Math.abs(n)}function ka(o){const t=o.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=za(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:bo(t),sound:!1,method:"fan"};const a=n.clone().divideScalar(e),r=Math.abs(a.x)<.9?new x(1,0,0):new x(0,1,0),l=new x().crossVectors(r,a).normalize(),c=new x().crossVectors(a,l),u=o[0],f=o.map(d=>{const h=d.clone().sub(u);return new $t(h.dot(l),h.dot(c))}),s=Ca(f),i=bo(t);if(yo(i,f,s))return{triangles:i,sound:!0,method:"fan"};let _=[];try{_=Se.triangulateShape(f,[]).map(d=>[d[0],d[1],d[2]])}catch{return{triangles:i,sound:!1,method:"fan"}}return yo(_,f,s)?{triangles:_,sound:!0,method:"earcut"}:{triangles:_.length>0?_:i,sound:!1,method:_.length>0?"earcut":"fan"}}const $a=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Nn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Rn(o,t,n){switch(o){case"FLOAT":{const e=Number(t[n]);return[e,e,e,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[Nn(Number(t[n*4])),Nn(Number(t[n*4+1])),Nn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function ae(o,t){return o.filter(n=>$a.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),a=[0,0,0,0];return{name:n.name,domain:n.domain,read:(r,l,c)=>n.domain==="POINT"?Rn(n.type,e,r):n.domain==="CORNER"?l===void 0?a:Rn(n.type,e,l):c===void 0?a:Rn(n.type,e,c)}})}function re(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,a=o.cornerVerts,r=e[n];let l=t;for(let y=0;y<n;y++)l+=(e[y+1]-e[y]-2)*3;const c=new Uint32Array(r),u=new Uint8Array(r),f=new Uint8Array(t),s=new Uint32Array(r);let i=!1;for(let y=0;y<n;y++)if(o.smooth(y)){i=!0;break}const _=(y,L)=>t<94906265?Math.min(y,L)*t+Math.max(y,L):`${Math.min(y,L)}:${Math.max(y,L)}`,d=new Map,h=new Set;for(const[y,L]of o.sharp)h.add(_(y,L));if(o.edges)for(const[y,L]of o.edges){if(y===L)throw new Error("Runtime mesh edge needs distinct vertices");d.set(_(y,L),-1)}const m=y=>{for(;s[y]!==y;)s[y]=s[s[y]],y=s[y];return y},p=(y,L)=>{const D=m(y),Y=m(L);s[Math.max(D,Y)]=Math.min(D,Y)};for(let y=0;y<n;y++){const L=e[y],D=e[y+1]-L,Y=o.smooth(y)?1:0;for(let Z=0;Z<D;Z++){const k=L+Z;f[a[k]]=1,c[k]=L+(Z+1)%D,u[k]=Y,s[k]=k}}for(let y=0;y<r;y++){const L=c[y],D=a[y],Y=a[L],Z=_(D,Y),k=d.get(Z);if(k!==void 0&&k>=0&&u[y]&&u[k]&&!h.has(Z)){const G=c[k];p(y,a[k]===D?k:G),p(L,a[k]===D?G:k)}(k===void 0||k<0||!u[k]&&u[y])&&d.set(Z,y)}const v=o.uv,g=new Float32Array(l*3),b=new Float32Array(l*2),w=new Uint32Array(l),R=(o.uvLayers??[]).map(y=>({...y,data:new Float32Array(l*2)})),T=(o.attributeLayers??[]).map(y=>({...y,data:new Float32Array(l*4)})),P=o.orco?new Float32Array(l*3):null,O=new Uint32Array(l),M=new Map,C=[],V=o.normals||o.cornerNormal?new Float32Array(l*3):null;let H=0,Q=0;const tt=(y,L,D,Y,Z)=>{const k=H++;for(const G of T)G.data.set(G.read(y,Y,Z),k*4);if(P)for(let G=0;G<3;G++)P[k*3+G]=o.orco[y*3+G]*.5+.5;if(w[k]=y,o.co(y).toArray(g,k*3),L&&b.set(L,k*2),D&&V.set(D,k*3),Y!==void 0)for(const G of R)G.data.set(G.read(Y),k*2);return k},pt=(y,L)=>{const D=v?.(y),Y=o.cornerNormal?[o.cornerNormal[y*3],o.cornerNormal[y*3+1],o.cornerNormal[y*3+2]]:o.normals?.[y];if(!i)return tt(a[y],D,Y,y,L);const Z=`${u[y]?m(y):y}${D?`:${D[0]}:${D[1]}`:""}${Y?`:n${Y.join(":")}`:""}${R.map(G=>":"+G.read(y).join(":")).join("")}${T.map(G=>G.domain==="POINT"?"":":"+Array.from(G.read(a[y],y,L)).join(":")).join("")}`;let k=M.get(Z);return k===void 0&&(k=tt(a[y],D,Y,y,L),M.set(Z,k)),k};for(let y=0;y<n;y++){const L=Q,D=e[y],Y=e[y+1]-D,Z=[];for(let Yt=0;Yt<Y;Yt++)Z.push(o.co(a[D+Yt]));for(const Yt of ka(Z).triangles)for(const Te of Yt)O[Q++]=pt(D+Te,y);const k=o.material(y),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let y=0;y<t;y++)f[y]||tt(y);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?b.slice(0,H*2):null,uvLayers:R.map(y=>({name:y.name,data:y.data.slice(0,H*2)})),attributeLayers:T.map(y=>({name:y.name,data:y.data.slice(0,H*4)})),orco:P?P.slice(0,H*3):null,indices:O.slice(0,Q),sourceVertex:w.slice(0,H),groups:C}}function Vt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function Hn(o){const t=new fn;t.setAttribute("position",new it(o.positions,3)),t.setAttribute("uv",new it(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new it(o.indices,1));const n=Object.create(null);for(const[e,a]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[a.name]=e+1,t.setAttribute(`uv${e+1}`,new it(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(Vt(e.name),new it(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new it(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new it(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new it(o.sourceVertex,1)),t}function La(o,t){const n=o.co.length/3,e=o.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),a=o.renderUv??o.activeUv??e[0]?.name,r=e.find(m=>m.name===a);if(a&&!r)throw new Error(`Runtime UV map ${a} is missing`);const l=r?r.data:null,c=o.edge.length/2,u=new Array(c);for(let m=0;m<c;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const f=[];for(let m=0;m<c;m++)o.edgeSharp[m]===1&&f.push(u[m]);const s=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),i=s?{v:Array.from({length:n},(m,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:f,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,_=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/Mn[s.type].size},(m,p)=>Array.from({length:Mn[s.type].size},(v,g)=>Number(s.data[p*Mn[s.type].size+g])))}:void 0,d=new x,h={vertexCount:n,normals:i?ee(i,_):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>d.set(o.co[m*3],o.co[m*3+1],o.co[m*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:m=>o.smooth[m]===1,material:m=>o.material[m],edges:u,sharp:f,uv:l?m=>[l[m*2],l[m*2+1]]:null,uvLayers:e.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:ae(o.attributes,m=>m)};return{...re(h),hash:t}}function Va(o){const t=o.v.map(i=>new x(...i)),n=i=>{const _=t[i];if(!_)throw new Error(`Runtime mesh vertex ${i} is missing`);return _},e=new Uint32Array(o.f.length+1);o.f.forEach((i,_)=>{if(i.length<3||new Set(i).size!==i.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[_+1]=e[_]+i.length});const a=new Uint32Array(e[o.f.length]);o.f.forEach((i,_)=>i.forEach((d,h)=>{n(d),a[e[_]+h]=d}));for(const[i,_]of o.edge_order??o.e??[])n(i),n(_);const r={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:a.length};for(const i of o.attributes??[])if(i.domain!=="EDGE"&&i.data.length!==r[i.domain])throw new Error(`Runtime attribute ${i.name} has ${i.data.length} values for ${r[i.domain]} ${i.domain} elements`);const l=(o.attributes??[]).filter(i=>i.type==="FLOAT2"&&i.domain==="CORNER"),c=o.render_uv??o.active_uv??l[0]?.name,u=l.find(i=>i.name===c);if(c&&!u)throw new Error(`Runtime UV map ${c} is missing`);const f=u?.data,s={vertexCount:t.length,normals:ee(o,o.attributes?.find(i=>i.name==="custom_normal")),co:n,starts:e,cornerVerts:a,smooth:i=>!!o.s?.[i],material:i=>o.m?.[i]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:f?i=>f[i]:null,uvLayers:l.map(i=>({name:i.name,read:_=>i.data[_]})),attributeLayers:ae(o.attributes??[],i=>Array.from(i).flat())};return Hn(re(s))}const sn=1.5707963267948966,Dt=6.283185307179586,le=.3183098861837067,ie=.0795774715459476,ja=.3,Ba=ie,Ua=3/16*le,qn=.8,wo=qn*qn,Ct=6371,se=100,Gn=Ct+se,Oo=64,To=64,et=256,Nt=64,Wa=[1.679,1.828,1.986,1.307],Ha=[.006605,.01067,.01842,.03156],qa=[3472e-28,3914e-28,1349e-28,1103e-29],Ga=334.5,Xa=[28722e-28,46168e-28,79706e-28,13578e-27],Ya=[15908e-26,17711e-26,20942e-26,24033e-26],Ao=13681e16,Za=2e6,Qa=.73,In=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],On=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),Ka=o=>Math.sqrt(Math.max(o,0)),fe=o=>[-Math.sqrt(1-o*o),0,o];function Xn(o,t,n,e,a,r,l){const c=o*e+t*a+n*r,u=o*o+t*t+n*n-l*l;if(u>0&&c>0)return-1;const f=c*c-u;return f<0?-1:f>=c*c?-c+Math.sqrt(f):-c-Math.sqrt(f)}const Ja=o=>Ua*(1+On(o));function tr(o){const t=1+wo+2*qn*o;return ie*(1-wo)/(t*Math.sqrt(t))}const nr=o=>Ao*(Math.exp(-o/Qa)+Za/Ao);function eo(o,t){let n=o%Dt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=sn||n<=-sn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Dt,e<0&&(e+=Dt),e=Dt-e,[n,e]}class or{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Nt*et*4)}coefficients(t,n){const e=nr(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-On(a-3.22261)*5.55555555-a),l=Math.exp(-.07771971*t**1.16364243);for(let c=0;c<4;c++)n[c]=Xa[c]*e,n[4+c]=Ya[c]*e,n[8+c]=qa[c]*Ga*r*this.ozone,n[12+c]=Ha[c]*l*this.air}transmittance(t,n,e){const[a,r,l]=fe(t),c=Ot(Ct,Gn,n),f=Xn(0,0,c,a,r,l,Gn)/Oo,s=[0,0,0,0],i=new Float64Array(16);for(let _=0;_<Oo;_++){const d=(_+.5)*f,h=a*d,m=r*d,p=c+l*d,v=Math.max(Math.hypot(h,m,p)-Ct,0);this.coefficients(v,i);for(let g=0;g<4;g++)s[g]+=(i[g]+i[4+g]+i[8+g]+i[12+g])*f}for(let _=0;_<4;_++)e[_]=Math.exp(-s[_])}precompute(){const t=new Float64Array(4);for(let n=0;n<Nt;n++)for(let e=0;e<et;e++){const a=e/(et-1),r=n/(Nt-1);this.transmittance(a*2-1,r,t);const l=(n*et+e)*4;for(let c=0;c<4;c++)this.lut[l+c]=t[c]}}lookup(t,n,e){const a=(et-1)*on(t*.5+.5),r=(Nt-1)*on(n),l=Math.trunc(a),c=Math.trunc(r),u=Math.min(l+1,et-1),f=Math.min(c+1,Nt-1),s=a-l,i=r-c,_=(c*et+l)*4,d=(c*et+u)*4,h=(f*et+l)*4,m=(f*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[_+p],this.lut[d+p],s),Ot(this.lut[h+p],this.lut[m+p],s),i)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,et-1),l=e-a;for(let c=0;c<4;c++)n[c]=Ot(this.lut[a*4+c],this.lut[r*4+c],l)}lookupToSun(t,n){const e=(Nt-1)*on(t),a=Math.trunc(e),r=Math.min(a+1,Nt-1),l=e-a,c=et-1;for(let u=0;u<4;u++)n[u]=Ot(this.lut[(a*et+c)*4+u],this.lut[(r*et+c)*4+u],l)}inscattering(t,n,e,a,r,l,c,u,f){const s=-(r*t[0]+l*t[1]+c*t[2]),i=Ja(s),_=tr(s),d=u/To,h=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),b=new Float64Array(4),w=[0,0,0,0],R=[1,1,1,1];for(let T=0;T<To;T++){const P=(T+.5)*d,O=n+r*P,M=e+l*P,C=a+c*P,V=Math.hypot(O,M,C),H=Math.max(V-Ct,0),Q=H/se,tt=(O*t[0]+M*t[1]+C*t[2])/V;this.coefficients(H,h),this.lookup(tt,Q,m);const pt=Dt*(1-Ka(1-On(Ct/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,b);const y=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let D=0;D<4;D++){const Y=g[D]/b[D],Z=Ba*pt*(ja*le)*v[D]*Y*tt;p[D]=.02*L[D]*y+Z}for(let D=0;D<4;D++){const Y=h[D]+h[4+D]+h[8+D]+h[12+D],Z=Wa[D]*(h[12+D]*(i*m[D]+p[D])+h[4+D]*(_*m[D]+p[D])),k=Math.exp(-d*Y),G=Math.max(Y,1e-7);w[D]+=R[D]*((Z-Z*k)/G),R[D]*=k}}for(let T=0;T<4;T++)f[T]=w[T]}}const st=512,qt=256;function ce(o,t){const n=new or(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=fe(Math.cos(sn-t)),r=new Float32Array(st*qt*3),l=st/2,c=new Float64Array(4);for(let u=0;u<qt;u++)for(let f=0;f<l;f++){const s=(f+.5)/st,i=(u+.5)/qt,_=Dt*s,d=i*2-1,h=Math.sign(d)*On(d)*sn,m=Math.cos(h)*Math.cos(_),p=Math.cos(h)*Math.sin(_),v=Math.sin(h),g=Ct+e,b=Xn(0,0,g,m,p,v,Gn),w=Xn(0,0,g,m,p,v,Ct),R=w<0?b:w;n.inscattering(a,0,0,g,m,p,v,R,c);let T=0,P=0,O=0;for(let V=0;V<4;V++)T+=In[V][0]*c[V],P+=In[V][1]*c[V],O+=In[V][2]*c[V];const M=(u*st+f)*3;r[M]=T,r[M+1]=P,r[M+2]=O;const C=(u*st+(st-f-1))*3;r[C]=T,r[C+1]=P,r[C+2]=O}return r}function er(o){const[t]=eo(o.sunElevation,o.sunRotation);return ce(o,t)}function ao(o){const[t]=eo(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const ar=6,Wt=new Map;function rr(o){return Wt.has(ao(o))}function ue(o,t){Wt.set(ao(o),t),Wt.size>ar&&Wt.delete(Wt.keys().next().value)}function lr(o){const[t,n]=eo(o.sunElevation,o.sunRotation),e=ao(o);let a=Wt.get(e);a===void 0&&(a=ce(o,t),ue(o,a));const r=new x;return l=>{const c=Math.hypot(l.x,l.y),u=Math.atan2(l.z,c);let s=(Math.atan2(l.x,l.y)+Math.PI+n)/Dt;s-=Math.floor(s);const i=Math.abs(u),_=on(Math.sqrt(i/sn)*Math.sign(u)*.5+.5),d=s*st-.5,h=_*qt-.5,m=Math.floor(d),p=Math.floor(h),v=d-m,g=h-p,b=C=>(C%st+st)%st,w=C=>C<0?0:C>qt-1?qt-1:C,R=b(m),T=b(m+1),P=w(p),O=w(p+1),M=[0,0,0];for(let C=0;C<3;C++){const V=Ot(a[(P*st+R)*3+C],a[(P*st+T)*3+C],v),H=Ot(a[(O*st+R)*3+C],a[(O*st+T)*3+C],v);M[C]=Ot(V,H,g)}return r.set(yt[0][0]*M[0]+yt[0][1]*M[1]+yt[0][2]*M[2],yt[1][0]*M[0]+yt[1][1]*M[1]+yt[1][2]*M[2],yt[2][0]*M[0]+yt[2][1]*M[1]+yt[2][2]*M[2])}}let Pt=null,cn=!1,ir=0;const en=new Map;function sr(){if(Pt||cn)return Pt;if(typeof Worker>"u")return cn=!0,null;try{Pt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return Pt.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,a=en.get(t);a&&(en.delete(t),n?a.resolve(n):a.reject(new Error(e??"sky worker returned nothing")))},Pt.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),Pt?.terminate(),Pt=null,cn=!0},Pt}function fr(o){const t=sr();if(!t)return Promise.resolve(er(o));const n=ir++,e={id:n,parameters:o};return new Promise((a,r)=>{en.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function cr(o,t,n,e={}){switch(e.type??"LINEAR"){case"QUADRATIC":{const a=Math.max(o,0);return a*a}case"EASING":{const a=Math.min(1,Math.max(0,o));return a*a*(3-2*a)}case"DIAGONAL":return(o+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(o,t,n),0);case"QUADRATIC_SPHERE":{const a=Math.max(.999999-Math.hypot(o,t,n),0);return a*a}case"RADIAL":return Math.atan2(t,o)/(2*Math.PI)+.5;default:return o}}const Fn=(o,t)=>t!==0?o/t:0,Po=o=>Math.min(1,Math.max(-1,o)),So=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},_e={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:Fn,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:Fn(Math.log(o),Math.log(t)),SQRT:o=>Math.sqrt(Math.max(o,0)),INVERSE_SQRT:o=>o>0?1/Math.sqrt(o):0,ABSOLUTE:Math.abs,RADIANS:o=>o*Math.PI/180,DEGREES:o=>o*180/Math.PI,MINIMUM:(o,t)=>Math.min(o,t),MAXIMUM:(o,t)=>Math.max(o,t),LESS_THAN:(o,t)=>+(o<t),GREATER_THAN:(o,t)=>+(o>t),ROUND:o=>Math.floor(o+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:o=>o-Math.floor(o),MODULO:(o,t)=>t!==0?o%t:0,FLOORED_MODULO:(o,t)=>t!==0?o-Math.floor(o/t)*t:0,TRUNC:Math.trunc,SNAP:(o,t)=>Math.floor(Fn(o,t))*t,WRAP:(o,t,n)=>t!==n?o-(t-n)*Math.floor((o-n)/(t-n)):n,PINGPONG:(o,t)=>{if(t===0)return 0;const n=(o-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:o=>Math.asin(Po(o)),ARCCOSINE:o=>Math.acos(Po(o)),ARCTANGENT:Math.atan,ARCTAN2:(o,t)=>o===0&&t===0?0:Math.atan2(o,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(o,t,n)=>+(o===t||Math.abs(o-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(o,t,n)=>o*t+n,SMOOTH_MIN:So,SMOOTH_MAX:(o,t,n)=>-So(-o,-t,n)};function nt(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const a=new x(...o);return()=>a}if(o.kind==="direction")return a=>a;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const a=nt(o.vector,t),r={type:o.gradient_type},l=new x;return c=>{const u=a(c),f=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,i=typeof u=="number"?u:u.z,_=ut.clamp(cr(f,s,i,r),0,1);return o.output==="Fac"?_:l.setScalar(_)}}if(o.kind==="to_float"){const a=nt(o.value,t);return r=>{const l=a(r);return typeof l=="number"?l:Math.fround(o.source_type==="RGBA"?l.x*.212639+l.y*.7151687+l.z*.0721923:(l.x+l.y+l.z)/3)}}if(o.kind==="math"){const a=o.inputs.map(c=>nt(c,t)),r=_e[o.operation],l=(c,u)=>{const f=a[c]?.(u)??0;if(typeof f!="number")throw new Error("World Math needs scalar inputs");return Math.fround(f)};return c=>{const u=Math.fround(r(l(0,c),l(1,c),l(2,c)));return o.clamp?ut.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=nt(o.factor,t),r=nt(o.a,t),l=nt(o.b,t),c=new x,u=new x;return f=>{const s=a(f);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const i=r(f);typeof i=="number"?c.setScalar(i):c.copy(i);const _=l(f);return typeof _=="number"?u.setScalar(_):u.copy(_),c.lerp(u,o.clamp_factor?ut.clamp(s,0,1):s),o.clamp_result&&c.clampScalar(0,1),c}}if(o.kind==="sky"){const a=lr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return r=>a(r)}if(o.kind==="mapping"){const a=nt(o.vector,t),r=new x(...o.location),l=new x(...o.scale),c=new gt().setFromEuler(new Ee(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=c.clone().invert(),f=new x(...o.scale.map(i=>i===0?0:1/i)),s=new x;return i=>{const _=a(i);switch(typeof _=="number"?s.setScalar(_):s.copy(_),o.vector_type??"POINT"){case"TEXTURE":return s.sub(r).applyQuaternion(u).multiply(f);case"VECTOR":return s.multiply(l).applyQuaternion(c);case"NORMAL":return s.multiply(f).applyQuaternion(c).normalize();case"POINT":return s.multiply(l).applyQuaternion(c).add(r)}}}if(o.kind==="map_range"){const a=nt(o.value,t),r=nt(o.from_min,t),l=nt(o.from_max,t),c=nt(o.to_min,t),u=nt(o.to_max,t),f=nt(o.steps,t),s=(d,h)=>{const m=d(h);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},i=o.interpolation,_=o.clamp;return d=>{const h=s(a,d),m=s(r,d),p=s(l,d),v=s(c,d),g=s(u,d);if(m===p)return 0;let b;if(i==="STEPPED"){const R=s(f,d),T=(h-m)/(p-m);b=R>0?Math.floor(T*(R+1))/R:0}else if(i==="SMOOTHSTEP"||i==="SMOOTHERSTEP"){const R=ut.clamp((h-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=i==="SMOOTHSTEP"?R*R*(3-2*R):R*R*R*(R*(R*6-15)+10);b=m>p?1-T:T}else b=(h-m)/(p-m);const w=v+b*(g-v);return _?v>g?ut.clamp(w,g,v):ut.clamp(w,v,g):w}}if(o.kind==="separate"){const a=nt(o.vector,t);return r=>{const l=a(r);return typeof l=="number"?l:l.getComponent(o.axis)}}const n=nt(o.factor,t),e=new x;return a=>{const r=n(a);if(typeof r!="number")throw new Error("World ColorRamp needs a scalar factor");const l=ut.clamp(r,0,1)*256,c=Math.floor(l),u=o.colors[c],f=o.colors[Math.min(c+1,256)],s=o.interpolate?l-c:0;return e.set(ut.lerp(u[0],f[0],s),ut.lerp(u[1],f[1],s),ut.lerp(u[2],f[2],s))}}function ur(o,t,n,e){const a=new Float32Array(t*n*3),r=nt(o,e),l=new x;for(let c=0;c<n;c++){const u=((c+.5)/n-.5)*Math.PI;for(let f=0;f<t;f++){const s=((f+.5)/t-.5)*2*Math.PI;l.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const i=r(l),_=(c*t+f)*3;a[_]=typeof i=="number"?i:i.x,a[_+1]=typeof i=="number"?i:i.y,a[_+2]=typeof i=="number"?i:i.z}}return a}function Eo(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function _r(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,l=nt(o,()=>r),c=new x,u=e.getWorldPosition(new x),f=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let i=0;i<t;i++){const _=(i+.5)/t,d=(s+.5)/n;r.set(_,d,0),e.isOrthographicCamera?c.copy(f):c.set(_*2-1,d*2-1,.5).unproject(e).sub(u).normalize(),c.set(c.x,-c.z,c.y);const h=l(c),m=(s*t+i)*3;a[m]=typeof h=="number"?h:h.x,a[m+1]=typeof h=="number"?h:h.y,a[m+2]=typeof h=="number"?h:h.z}return a}const J=S().finite(),mr=A({type:W(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:W(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Yn;function dr(){return Yn??=ca(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Yn}function hr(){return Yn??Promise.resolve()}const pr=o=>{const t=o.size??0,n=o.size_y??t;if(o.shape==="RECTANGLE")return[t,n];if(o.shape==="DISK"){const e=Math.sqrt(Math.PI*t*t/4);return[e,e]}if(o.shape==="ELLIPSE"){const e=Math.sqrt(Math.PI/4);return[t*e,n*e]}return[t,t]};function vr(o,t){const n=(l,c)=>t&&c(t)?t:new l;if(o.type==="SUN"){const l=n(Yo,c=>c.isDirectionalLight);return l.intensity=o.energy,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="POINT"){const l=n(Vn,c=>c.isPointLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="SPOT"){const l=n(jn,c=>c.isSpotLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.angle=(o.spot_size??0)/2,l.penumbra=o.spot_blend??0,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}dr();const e=n(gn,l=>l.isRectAreaLight),[a,r]=pr(o);return e.width=a,e.height=r,e.intensity=o.energy/(Math.max(a*r,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],ft),e}function gr(o,t,n){if(!o.castShadow||n<=0)return;const a=o.getWorldPosition(new x).distanceTo(t),r=o.shadow;if(!r)return;const l=r.camera;l.near=Math.max(n*.001,a-n),l.far=a+n,o.isDirectionalLight&&(l.left=-n,l.right=n,l.top=n,l.bottom=-n),l.updateProjectionMatrix()}function xr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ro=[{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}],Mo=.69;class br{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Xo;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[a,r]of ro.entries()){const l=(1+r.smooth)**2,c=new Yo(16777215,Math.PI*Mo/l);c.name=`BlenderSolidLight${a}`,c.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],ft),c.position.set(r.direction[0],r.direction[1],r.direction[2]),c.target=t,this.group.add(c),this.lights.push(c),n.r+=r.diffuse[0]*r.smooth/l,n.g+=r.diffuse[1]*r.smooth/l,n.b+=r.diffuse[2]*r.smooth/l}const e=new Me(16777215,Math.PI*Mo);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),U=ne(()=>jt([J,Ut,A({kind:j("direction")}).strict(),A({kind:j("window")}).strict(),A({kind:j("gradient"),gradient_type:W(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:W(["Fac","Color"]),vector:U}).strict(),A({kind:j("to_float"),source_type:W(["RGBA","VECTOR"]),value:U}).strict(),A({kind:j("math"),operation:W(Object.keys(_e)),clamp:q(),inputs:F(U).min(1).max(3)}).strict(),A({kind:j("mix_color"),factor:U,a:U,b:U,clamp_factor:q(),clamp_result:q()}).strict(),A({kind:j("mapping"),vector_type:W(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:U,location:Ut,rotation:Ut,scale:Ut}).strict(),A({kind:j("separate"),vector:U,axis:S().int().min(0).max(2)}).strict(),A({kind:j("ramp"),factor:U,colors:F(Ut).length(257),interpolate:q()}).strict(),A({kind:j("map_range"),interpolation:W(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:U,from_min:U,from_max:U,to_min:U,to_max:U,steps:U}).strict(),A({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),No=A({color:Ut,strength:J,shader:U.optional()}),yr=No.extend({volume:F(A({kind:W(["absorption","scatter","principled","emission"]),phase:E(),alpha:U,weight:U,color:U,density:U,anisotropy:U,absorption_color:U,emission_color:U,emission_strength:U,blackbody_intensity:U,temperature:U,blackbody_tint:U}).strict()).optional(),lighting:No.strict().optional()}).strict(),wr=4,tn=new Map,zn=new Set;function Ro(o,t,n){const r=Et(o);if(r&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const l=JSON.stringify([o,r?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),c=tn.get(l);if(c!==void 0)return Zn(c,t,256,128);const u=new x,f=new to,s=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,i=n?.getWorldPosition(new x),d=ur(o,256,128,r?h=>(u.set(h.x,h.z,-h.y),n.isPerspectiveCamera&&u.add(i),f.set(u.x,u.y,u.z,1).applyMatrix4(s),f.w===0?u.set(0,0,0):u.set(f.x/f.w*.5+.5,f.y/f.w*.5+.5,0)):void 0);return tn.set(l,d),tn.size>wr&&tn.delete(tn.keys().next().value),Zn(d,t,256,128)}function Or(o,t,n,e){const a=nn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=nn.toHalfFloat(t[r*3]*n),o[r*4+1]=nn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=nn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function Zn(o,t,n,e){const a=new Uint16Array(n*e*4);Or(a,o,t,n*e);const r=new An(a,n,e,Pn,no);return r.mapping=Re,r.colorSpace=ft,r.minFilter=Lt,r.magFilter=Lt,r.needsUpdate=!0,r}class lo{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const a=lo.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,l=this.generation,u=[...Eo(r),...n.lighting?Eo(n.lighting.shader??n.lighting.color):[]].filter(s=>!rr(s));if(u.length===0){this.compose(a,n,r,e);return}const f=(async()=>{const s=await Promise.all(u.map(fr));u.forEach((i,_)=>{ue(i,s[_])}),!(this.generation!==l||this.applied?.scene!==a)&&(this.compose(a,n,r,e),vt())})();this.pending=f,zn.add(f),f.then(()=>zn.delete(f),()=>zn.delete(f))}compose(t,n,e,a){if(this.texture=Ro(e,n.strength,a),Et(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=Zn(_r(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=Ne,t.background=this.screenTexture}else if(a&&a.isOrthographicCamera){const l=a.getWorldDirection(new x);l.set(l.x,-l.z,l.y);const c=nt(n.shader??n.color)(l);t.background=typeof c=="number"?new ht().setRGB(c,c,c).multiplyScalar(n.strength):new ht().setRGB(c.x,c.y,c.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?Ro(r.shader??r.color,r.strength,a):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 me(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Tr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=me(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new It(new x(1,0,0),-o.min.x),new It(new x(-1,0,0),o.max.x),new It(new x(0,1,0),-o.min.y),new It(new x(0,-1,0),o.max.y),new It(new x(0,0,1),-o.min.z),new It(new x(0,0,-1),o.max.z)],a=[],r=new x,l=new x,c=new x,u=new x,f=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let i=s+1;i<e.length;i++)for(let _=i+1;_<e.length;_++){const d=e[s],h=e[i],m=e[_];r.crossVectors(h.normal,m.normal);const p=d.normal.dot(r);Math.abs(p)<1e-12||(l.crossVectors(m.normal,d.normal),c.crossVectors(d.normal,h.normal),u.copy(r).multiplyScalar(-d.constant).addScaledVector(l,-h.constant).addScaledVector(c,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-f)&&a.push(u.clone()))}return a}function Ar(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new yn().setFromPoints(t.map(_=>_.clone().applyMatrix4(a))),l=r.getSize(new x),c=Math.max(l.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,f=Math.max(l.x,l.y,c)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*f,i=u*f;r.min.x-=i,r.min.y-=i,r.max.x+=i,r.max.y+=i;for(const _ of n){if(_.isEmpty())continue;const d=new yn().setFromPoints(me(_).map(h=>h.applyMatrix4(a)));d.max.x<r.min.x||d.min.x>r.max.x||d.max.y<r.min.y||d.min.y>r.max.y||(r.min.z=Math.min(r.min.z,d.min.z),r.max.z=Math.max(r.max.z,d.max.z))}e.left=r.min.x,e.right=r.max.x,e.bottom=r.min.y,e.top=r.max.y,e.near=-r.max.z-s-c,e.far=-r.min.z+s+c,e.updateProjectionMatrix(),o.shadow.normalBias=s}const Gt=S().finite(),Io=$([Gt,Gt,Gt]),de=A({min:$([S().int(),S().int(),S().int()]),max:$([S().int(),S().int(),S().int()]),density:F(Gt),voxelSize:Gt.positive(),color:Io,emission:Io,densityScale:Gt.nonnegative()}).strict();function Pr(o){const t=o.max.map((s,i)=>s-o.min[i]+1);if(t.some(s=>s<=0)||t.reduce((s,i)=>s*i,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Ie(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Fe,n.type=Zo,n.minFilter=n.magFilter=Lt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),a=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),r=new ze(a.x,a.y,a.z),l=r.getAttribute("position");for(let s=0;s<l.count;s++)l.setXYZ(s,e.x+(l.getX(s)>0?a.x:0),e.y+(l.getY(s)>0?a.y:0),e.z+(l.getZ(s)>0?a.z:0));l.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere();const c=new Jn({glslVersion:Ce,side:De,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:e},extent:{value:a},voxelSize:{value:o.voxelSize},densityScale:{value:o.densityScale},volumeColor:{value:new x(...o.color)},emission:{value:new x(...o.emission)},cameraLocal:{value:new x},rayLocal:{value:new x},orthographic:{value:!1},worldScale:{value:new Go}},vertexShader:`
|
|
20
20
|
out vec3 localPosition;
|
|
21
21
|
void main() {
|
|
22
22
|
localPosition = position;
|
|
@@ -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
|
+
}`}},Fo=S().finite(),Dn=W(["float","vec2","vec3","vec4"]),he=jt([Fo,F(Fo)]),pe=$([E(),S().int().nonnegative()]),xn=jt([A({value:he}).strict(),A({link:pe}).strict()]),Er=["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"],Mr=A({type:W(Er),props:_t(E(),oe()),inputs:F(jt([A({value:he,id:E(),gpu:Dn,enabled:q()}).strict(),A({link:pe,id:E(),gpu:Dn,enabled:q()}).strict()])),outputs:F(A({id:E(),gpu:Dn.or(j("closure")).nullable()}).strict())}).strict(),an=ne(()=>jt([A({principled:j(!0)}).strict(),A({emission:$([xn,xn])}).strict(),A({transparent:S()}).strict(),A({none:j(!0)}).strict(),A({mix:$([xn,an,an])}).strict(),A({add:$([an,an])}).strict()])),Nr=A({surface:W(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:_t(E(),xn),closure:an.optional(),nodes:_t(E(),Mr)}).strict();function Rr(o){const t=o.inputs.Alpha,n=e=>"transparent"in e||"mix"in e&&(n(e.mix[1])||n(e.mix[2]))||"add"in e&&(n(e.add[0])||n(e.add[1]));return t!==void 0&&"link"in t||o.closure!==void 0&&n(o.closure)}const ve="vec3(0.2126729, 0.7151522, 0.0721750)",Ir=o=>o==="float"?1:Number(o[3]);function Fr(o,t){const n=typeof t=="number"?[t]:t,e=Ir(o);return Array.from({length:e},(a,r)=>n[r]??(r===3?1:0))}function zr(o,t,n){if(t===n)return o;const e=r=>r==="float"?"float":`float${r[3]}`,a=t==="vec4"&&n==="float"?`, ${ve}`:"";return`${e(n)}_from_${e(t)}(${o}${a})`}const Dr={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},Cr={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},zo={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"},kr={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},$r={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},Lr={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},Vr=(()=>{const o=new Map;for(const[t,n]of Object.entries(Qn))for(const e of n.code.matchAll(/^(?:void|float\d?)\s+([A-Za-z_]\w*)\s*\(/gm))o.has(e[1])||o.set(e[1],t);return o})();function z(o,t){if(!(t in o.props))throw new Error(`${o.type} arrived without its '${t}' property`);return o.props[t]}const jr=`
|
|
6883
6883
|
#define GPU_FRAGMENT_SHADER
|
|
6884
6884
|
#define FrontFacing gl_FrontFacing
|
|
6885
6885
|
uniform mat4 modelMatrix;
|
|
@@ -7017,7 +7017,7 @@ vec3 blender_reflection() {
|
|
|
7017
7017
|
: normalize(cameraPosition - vBlenderWorldPosition);
|
|
7018
7018
|
return blender_from_three * -reflect(incident, normalize(vBlenderWorldNormal));
|
|
7019
7019
|
}
|
|
7020
|
-
`;class io{constructor(t,n,e=!1,a="bgN"){this.graph=t,this.derivative=e,this.prefix=a,this.lines=[],this.emitted=new Map,this.s=n??{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,n){const e=`bgU${this.s.uniforms.size}`,a=Fr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Vr.get(t);if(!n)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(n),t}source(t,n){if("value"in t)return this.s.structure.push("v"),this.uniform(n,t.value);const[e,a]=t.link,r=this.graph.nodes[e];if(!r)throw new Error(`The graph links to ${e}, which it does not carry`);const c=this.node(e,r)[a];if(!c)throw new Error(`${e} has no output ${a}`);return this.s.structure.push(["l",e,a]),zr(c.name,c.type,n)}input(t,n,e){const a=t.inputs.find(r=>r.id===n)??t.inputs.find(r=>r.id.replace(/_/g," ")===n);if(!a)throw new Error(`${t.type} arrived without its '${n}' input`);return this.source(a,e??a.gpu)}coordinate(t,n){const e=t.inputs[0];return"link"in e?this.source(e,"vec3"):(this.s.structure.push(["default",n]),n==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${Ht("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const a=`${this.prefix}${this.emitted.size}`,r=n.outputs.map((i,_)=>({name:`${a}_${_}`,type:i.gpu==="closure"||i.gpu===null?"float":i.gpu}));this.emitted.set(t,r);const l=i=>`${r[i].type} ${r[i].name} = ${r[i].type}(0.0);`,c=r.map((i,_)=>l(_)).join(" "),u=i=>i.map(_=>r[_].name).join(", "),f=(i=[])=>[...n.inputs.map(d=>this.source(d,d.gpu)),...i,...r.map(d=>d.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const s=[c];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const i=r[0].type;s.push(`${r[0].name} = ${this.uniform(i,z(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Ht("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((_,d)=>{r[d]&&s.push(`${r[d].name} = ${this.d(_)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const i=z(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(i),this.s.structure.push(["a",i]);const _=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(_)}(${Kn(i)}, ${u(r.map((d,h)=>h))});`);for(const d of r)s.push(`${d.name} = ${this.d(d.name)};`);break}case"ShaderNodeUVMap":{const i=z(n,"uv_map");this.s.uvs.add(i),s.push(`${r[0].name} = ${this.d(`vec3(${Ht(i)}, 0.0)`)};`);break}case"ShaderNodeMath":{const i=z(n,"operation"),_=this.use(Dr[i]??`math_${i.toLowerCase()}`);s.push(`${_}(${f()});`),z(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const i=z(n,"operation");s.push(`${this.use(Cr[i]??`vector_math_${i.toLowerCase()}`)}(${f()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${z(n,"vector_type").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${f()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${f()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${f()});`);break;case"ShaderNodeMix":{const i=z(n,"data_type"),_=z(n,"factor_mode")==="NON_UNIFORM",d={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[i];if(!d)throw new Error(`Mix has data type ${i}`);const h=i==="VECTOR"&&_;let m=this.input(n,h?"Factor_Vector":"Factor_Float");if(z(n,"clamp_factor")){const g=`${a}_fac`;s.push(h?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${g});`),m=g}const p=i==="FLOAT"?"node_mix_float":i==="VECTOR"?_?"node_mix_vector_non_uniform":"node_mix_vector":i==="RGBA"?`node_mix_${Fo[z(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${d}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${d}`)}, ${this.input(n,`B_${d}`)}, ${u([v])});`),i==="RGBA"&&z(n,"clamp_result")&&s.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const i=`${a}_fac`;s.push(`float ${i}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${i});`);const _=n.inputs.slice(1).map(d=>this.source(d,d.gpu));s.push(`${this.use(`mix_${Fo[z(n,"blend_type")]}`)}(${[i,..._,u([0])].join(", ")});`),z(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const i=z(n,"color_ramp"),_=this.input(n,"Fac"),[d,h]=i.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(i.elements.length===1)s.push(`${u([0])} = ${m(d)}; ${u([1])} = ${u([0])}.a;`);else if(i.elements.length===2&&i.color_mode==="RGB"&&h&&i.interpolation!=="B_SPLINE"&&i.interpolation!=="CARDINAL")if(i.interpolation==="CONSTANT")s.push(`${this.use("valtorgb_opti_constant")}(${_}, ${this.uniform("float",Math.max(d[0],h[0]))}, ${m(d)}, ${m(h)}, ${u([0,1])});`);else{const p=1/(h[0]-d[0]),v=i.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${_}, ${this.uniform("vec2",[p,-p*d[0]])}, ${m(d)}, ${m(h)}, ${u([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"]),s.push(i.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${_}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${_}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),s.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const i=z(n,"curve_mapping"),_=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:_,table:i.table}),this.s.structure.push(["curve"]);const d=this.input(n,n.inputs.some(h=>h.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${d}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${_}, 0.5, ${this.uniform("vec4",i.minimums)}, ${this.uniform("vec4",i.dividers)}, ${this.uniform("vec4",i.starts)}, ${this.uniform("vec4",i.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?s.push(`${this.use("curves_vector_mixed")}(${d}, ${this.input(n,"Vector","vec3")}, ${_}, 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))}, ${u([0])});`):s.push(`${this.use("curves_float_mixed")}(${d}, ${this.input(n,"Value","float")}, ${_}, 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])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const i=Number(z(n,"noise_dimensions")[0]),_=this.use(`node_noise_tex_${kr[z(n,"noise_type")]}_${i}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=z(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[d,...h,m,"1.0",u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const i=Number(z(n,"voronoi_dimensions")[0]),_=this.use(`node_tex_voronoi_${$r[z(n,"feature")]}_${i}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Lr[z(n,"distance")].toFixed(1)}`,p=z(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[d,...h,m,p,u(r.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const i=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(d=>this.source(d,d.gpu));s.push(`${this.use("node_tex_checker")}(${[i,..._,u(r.map((d,h)=>h))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const i=Number(z(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${i}d`)}(${f()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const i=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),d=p=>z(n,`${p}#value`).toFixed(1),h=n.type==="ShaderNodeTexWave"?[d("wave_type"),d("bands_direction"),d("rings_direction"),d("wave_profile")]:n.type==="ShaderNodeTexGradient"?[d("gradient_type")]:n.type==="ShaderNodeTexMagic"?[z(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",z(n,"offset")),z(n,"offset_frequency").toFixed(1),this.uniform("float",z(n,"squash")),z(n,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];s.push(`${this.use(m)}(${[i,..._,...h,u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const i=z(n,"data_type")==="FLOAT_VECTOR",_=z(n,"interpolation_type").toLowerCase(),d=z(n,"clamp");s.push(`${this.use(`${i?"vector_":""}map_range_${_}`)}(${f([d?"1.0":"0.0"])});`),d&&!i&&(_==="linear"||_==="stepped")&&s.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":s.push(`${this.use(z(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${f()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${f()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${f()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${f()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${f([pe])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);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"}[z(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${i}`)}(${f([z(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const i=n.inputs[1],_="link"in i?this.source(i,"vec3"):"g_data.N";"link"in i||this.s.structure.push("world-normal");const d=this.source(n.inputs[0],"float"),h=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(h)}(${[d,_,u(r.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const i=n.inputs.find(b=>b.id==="Height"),_=n.inputs.find(b=>b.id==="Normal"),d=_&&"link"in _?this.source(_,"vec3"):"g_data.N";if(!i||!("link"in i)){s.push(`${u([0])} = ${d};`);break}const h=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new io(this.graph,this.s,!0,`${h}_`),p=m.source(i,"float");this.s.functions[Number(h.slice(8))]=`float ${h}() {
|
|
7020
|
+
`;class io{constructor(t,n,e=!1,a="bgN"){this.graph=t,this.derivative=e,this.prefix=a,this.lines=[],this.emitted=new Map,this.s=n??{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,n){const e=`bgU${this.s.uniforms.size}`,a=Fr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Vr.get(t);if(!n)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(n),t}source(t,n){if("value"in t)return this.s.structure.push("v"),this.uniform(n,t.value);const[e,a]=t.link,r=this.graph.nodes[e];if(!r)throw new Error(`The graph links to ${e}, which it does not carry`);const c=this.node(e,r)[a];if(!c)throw new Error(`${e} has no output ${a}`);return this.s.structure.push(["l",e,a]),zr(c.name,c.type,n)}input(t,n,e){const a=t.inputs.find(r=>r.id===n)??t.inputs.find(r=>r.id.replace(/_/g," ")===n);if(!a)throw new Error(`${t.type} arrived without its '${n}' input`);return this.source(a,e??a.gpu)}coordinate(t,n){const e=t.inputs[0];return"link"in e?this.source(e,"vec3"):(this.s.structure.push(["default",n]),n==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${Ht("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const a=`${this.prefix}${this.emitted.size}`,r=n.outputs.map((i,_)=>({name:`${a}_${_}`,type:i.gpu==="closure"||i.gpu===null?"float":i.gpu}));this.emitted.set(t,r);const l=i=>`${r[i].type} ${r[i].name} = ${r[i].type}(0.0);`,c=r.map((i,_)=>l(_)).join(" "),u=i=>i.map(_=>r[_].name).join(", "),f=(i=[])=>[...n.inputs.map(d=>this.source(d,d.gpu)),...i,...r.map(d=>d.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const s=[c];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const i=r[0].type;s.push(`${r[0].name} = ${this.uniform(i,z(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Ht("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((_,d)=>{r[d]&&s.push(`${r[d].name} = ${this.d(_)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const i=z(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(i),this.s.structure.push(["a",i]);const _=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(_)}(${Kn(i)}, ${u(r.map((d,h)=>h))});`);for(const d of r)s.push(`${d.name} = ${this.d(d.name)};`);break}case"ShaderNodeUVMap":{const i=z(n,"uv_map");this.s.uvs.add(i),s.push(`${r[0].name} = ${this.d(`vec3(${Ht(i)}, 0.0)`)};`);break}case"ShaderNodeMath":{const i=z(n,"operation"),_=this.use(Dr[i]??`math_${i.toLowerCase()}`);s.push(`${_}(${f()});`),z(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const i=z(n,"operation");s.push(`${this.use(Cr[i]??`vector_math_${i.toLowerCase()}`)}(${f()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${z(n,"vector_type").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${f()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${f()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${f()});`);break;case"ShaderNodeMix":{const i=z(n,"data_type"),_=z(n,"factor_mode")==="NON_UNIFORM",d={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[i];if(!d)throw new Error(`Mix has data type ${i}`);const h=i==="VECTOR"&&_;let m=this.input(n,h?"Factor_Vector":"Factor_Float");if(z(n,"clamp_factor")){const g=`${a}_fac`;s.push(h?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${g});`),m=g}const p=i==="FLOAT"?"node_mix_float":i==="VECTOR"?_?"node_mix_vector_non_uniform":"node_mix_vector":i==="RGBA"?`node_mix_${zo[z(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${d}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${d}`)}, ${this.input(n,`B_${d}`)}, ${u([v])});`),i==="RGBA"&&z(n,"clamp_result")&&s.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const i=`${a}_fac`;s.push(`float ${i}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${i});`);const _=n.inputs.slice(1).map(d=>this.source(d,d.gpu));s.push(`${this.use(`mix_${zo[z(n,"blend_type")]}`)}(${[i,..._,u([0])].join(", ")});`),z(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const i=z(n,"color_ramp"),_=this.input(n,"Fac"),[d,h]=i.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(i.elements.length===1)s.push(`${u([0])} = ${m(d)}; ${u([1])} = ${u([0])}.a;`);else if(i.elements.length===2&&i.color_mode==="RGB"&&h&&i.interpolation!=="B_SPLINE"&&i.interpolation!=="CARDINAL")if(i.interpolation==="CONSTANT")s.push(`${this.use("valtorgb_opti_constant")}(${_}, ${this.uniform("float",Math.max(d[0],h[0]))}, ${m(d)}, ${m(h)}, ${u([0,1])});`);else{const p=1/(h[0]-d[0]),v=i.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${_}, ${this.uniform("vec2",[p,-p*d[0]])}, ${m(d)}, ${m(h)}, ${u([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"]),s.push(i.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${_}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${_}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),s.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const i=z(n,"curve_mapping"),_=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:_,table:i.table}),this.s.structure.push(["curve"]);const d=this.input(n,n.inputs.some(h=>h.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${d}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${_}, 0.5, ${this.uniform("vec4",i.minimums)}, ${this.uniform("vec4",i.dividers)}, ${this.uniform("vec4",i.starts)}, ${this.uniform("vec4",i.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?s.push(`${this.use("curves_vector_mixed")}(${d}, ${this.input(n,"Vector","vec3")}, ${_}, 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))}, ${u([0])});`):s.push(`${this.use("curves_float_mixed")}(${d}, ${this.input(n,"Value","float")}, ${_}, 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])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const i=Number(z(n,"noise_dimensions")[0]),_=this.use(`node_noise_tex_${kr[z(n,"noise_type")]}_${i}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=z(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[d,...h,m,"1.0",u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const i=Number(z(n,"voronoi_dimensions")[0]),_=this.use(`node_tex_voronoi_${$r[z(n,"feature")]}_${i}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Lr[z(n,"distance")].toFixed(1)}`,p=z(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[d,...h,m,p,u(r.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const i=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(d=>this.source(d,d.gpu));s.push(`${this.use("node_tex_checker")}(${[i,..._,u(r.map((d,h)=>h))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const i=Number(z(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${i}d`)}(${f()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const i=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),d=p=>z(n,`${p}#value`).toFixed(1),h=n.type==="ShaderNodeTexWave"?[d("wave_type"),d("bands_direction"),d("rings_direction"),d("wave_profile")]:n.type==="ShaderNodeTexGradient"?[d("gradient_type")]:n.type==="ShaderNodeTexMagic"?[z(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",z(n,"offset")),z(n,"offset_frequency").toFixed(1),this.uniform("float",z(n,"squash")),z(n,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];s.push(`${this.use(m)}(${[i,..._,...h,u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const i=z(n,"data_type")==="FLOAT_VECTOR",_=z(n,"interpolation_type").toLowerCase(),d=z(n,"clamp");s.push(`${this.use(`${i?"vector_":""}map_range_${_}`)}(${f([d?"1.0":"0.0"])});`),d&&!i&&(_==="linear"||_==="stepped")&&s.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":s.push(`${this.use(z(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${f()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${f()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${f()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${f()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${f([ve])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);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"}[z(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${i}`)}(${f([z(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const i=n.inputs[1],_="link"in i?this.source(i,"vec3"):"g_data.N";"link"in i||this.s.structure.push("world-normal");const d=this.source(n.inputs[0],"float"),h=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(h)}(${[d,_,u(r.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const i=n.inputs.find(b=>b.id==="Height"),_=n.inputs.find(b=>b.id==="Normal"),d=_&&"link"in _?this.source(_,"vec3"):"g_data.N";if(!i||!("link"in i)){s.push(`${u([0])} = ${d};`);break}const h=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new io(this.graph,this.s,!0,`${h}_`),p=m.source(i,"float");this.s.functions[Number(h.slice(8))]=`float ${h}() {
|
|
7021
7021
|
${m.lines.join(`
|
|
7022
7022
|
`)}
|
|
7023
7023
|
return ${p};
|
|
@@ -7032,8 +7032,8 @@ vec3 blender_reflection() {
|
|
|
7032
7032
|
uniform highp sampler2D ${i.uniform}Map;`:`uniform sampler2D ${i.uniform};`),...this.ramps.map(i=>`uniform sampler2D ${i.uniform};`),...Object.values(n).map(i=>`${i.type} ${i.global};`),...r?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,f].join(`
|
|
7033
7033
|
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:s,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:r!==void 0}}}function Ur(o,t){const n=[],e=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let a=0;for(let u;u=e.exec(o);){if(u.index<a)continue;let f=u.index+u[0].length;for(let d=1;f<o.length&&d>0;f++)d+=o[f]==="("?1:o[f]===")"?-1:0;const s=o.slice(f).match(/^\s*(\{|;)/);if(!s||/^\s*#/.test(o.slice(o.lastIndexOf(`
|
|
7034
7034
|
`,u.index)+1,u.index+1))||o.slice(Math.max(0,u.index-2),u.index).endsWith(`\\
|
|
7035
|
-
`))continue;let _=f+s[0].length;if(s[1]==="{")for(let d=1;_<o.length&&d>0;_++)d+=o[_]==="{"?1:o[_]==="}"?-1:0;n.push({text:o.slice(a,u.index),name:null}),n.push({text:o.slice(u.index,_),name:u[1]}),a=_,e.lastIndex=_}n.push({text:o.slice(a),name:null});const r=new Set(n.filter(u=>u.name===null)),l=new Set,c=u=>{for(const f of u.matchAll(/[A-Za-z_]\w*/g))l.add(f[0])};c(t);for(const u of r)c(u.text);for(let u=!0;u;){u=!1;for(const f of n)r.has(f)||f.name===null||!l.has(f.name)||(r.add(f),c(f.text),u=!0)}return n.filter(u=>r.has(u)).map(u=>u.text).join("")}function Kn(o){return`v${Vt(o)}`}function Ht(o){return o===""?"vBlenderUvRender":`vBlenderUv_${[...o].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function Wr(o){return new io(o).compile()}function Hr(o){const t=new Uint16Array(o.length*4);o.forEach((e,a)=>t.set([e[0]??0,e[1]??0,e[2]??0,e[3]??1].map(r=>nn.toHalfFloat(r)),a*4));const n=new An(t,o.length,1,Pn,no);return n.minFilter=n.magFilter=Lt,n.wrapS=n.wrapT=
|
|
7036
|
-
`).find(d=>d.startsWith("ERROR"))??"";console.warn(`Blender material "${o.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${_}`);return}const i=
|
|
7035
|
+
`))continue;let _=f+s[0].length;if(s[1]==="{")for(let d=1;_<o.length&&d>0;_++)d+=o[_]==="{"?1:o[_]==="}"?-1:0;n.push({text:o.slice(a,u.index),name:null}),n.push({text:o.slice(u.index,_),name:u[1]}),a=_,e.lastIndex=_}n.push({text:o.slice(a),name:null});const r=new Set(n.filter(u=>u.name===null)),l=new Set,c=u=>{for(const f of u.matchAll(/[A-Za-z_]\w*/g))l.add(f[0])};c(t);for(const u of r)c(u.text);for(let u=!0;u;){u=!1;for(const f of n)r.has(f)||f.name===null||!l.has(f.name)||(r.add(f),c(f.text),u=!0)}return n.filter(u=>r.has(u)).map(u=>u.text).join("")}function Kn(o){return`v${Vt(o)}`}function Ht(o){return o===""?"vBlenderUvRender":`vBlenderUv_${[...o].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function Wr(o){return new io(o).compile()}function Hr(o){const t=new Uint16Array(o.length*4);o.forEach((e,a)=>t.set([e[0]??0,e[1]??0,e[2]??0,e[3]??1].map(r=>nn.toHalfFloat(r)),a*4));const n=new An(t,o.length,1,Pn,no);return n.minFilter=n.magFilter=Lt,n.wrapS=n.wrapT=Qo,n.needsUpdate=!0,n}const dt=new WeakMap,ge=new Set,kt=new WeakMap,un=new WeakMap;function _n(o){const t=kt.get(o);if(t){kt.delete(o);for(const n of t.binding.ramps)n.dispose()}}function qr(o,t,n,e=!1){const a=dt.get(o);if(t&&ge.has(t.key)&&(t=null),!t){if(_n(o),a){for(const c of a.ramps)c.dispose();dt.delete(o),o.needsUpdate=!0}return}if(a&&a.compiled.key===t.key){_n(o),mn(a,t,n);return}if(e){_n(o);for(const u of a?.ramps??[])u.dispose();const c={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};mn(c,t,n),dt.set(o,c),o.needsUpdate=!0;return}const r=kt.get(o);if(r&&r.binding.compiled.key===t.key){mn(r.binding,t,n);return}_n(o);const l={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};mn(l,t,n),kt.set(o,{binding:l,started:!1})}function mn(o,t,n){o.compiled=t;for(const[e,a]of t.uniforms){const r=typeof a=="number"?a:a.length===2?new $t(...a):a.length===3?new x(...a):new to(...a),l=o.uniforms[e];l?l.value=r:o.uniforms[e]={value:r}}for(const e of o.ramps)e.dispose();o.ramps=t.ramps.map(e=>{const a=Hr(e.table);return(o.uniforms[e.uniform]??={value:null}).value=a,a});for(const e of t.images){const a=n(e);if(e.tiled){const r=a!==null&&"tiles"in a?a:null;(o.uniforms[e.uniform]??={value:null}).value=r?.tiles??null,(o.uniforms[`${e.uniform}Map`]??={value:null}).value=r?.map??null}else(o.uniforms[e.uniform]??={value:null}).value=a!==null&&"tiles"in a?null:a}}function Gr(o){const t=dt.get(o);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function Xr(o){return Object.values(dt.get(o)?.channels??{})}function Do(o,t){const n=t.userData.blenderUvChannels,e=t.getAttribute("position")?.count??0,a={};for(const r of o.uvs){let l=r===""?0:n?.[r];l===void 0&&(l=9,t.getAttribute("uv9")?.count!==e&&t.setAttribute("uv9",new it(new Float32Array(e*2),2))),a[r]=l}return a}function Yr(o,t,n,e,a,r,l){const c=un.get(o);c&&++c.draws>1&&(c.shadow.dispose(),un.delete(o));const u=kt.get(o);if(u&&!u.started){u.started=!0,u.binding.channels=Do(u.binding.compiled,t);const _=l(o);dt.set(_,u.binding);const d=new Tt(t,_);d.castShadow=r.castShadow,d.receiveShadow=r.receiveShadow;const h=()=>{if(kt.get(o)!==u){_.dispose();return}kt.delete(o);for(const m of dt.get(o)?.ramps??[])m.dispose();dt.set(o,u.binding),o.needsUpdate=!0,un.get(o)?.shadow.dispose(),un.set(o,{shadow:_,draws:0}),vt()};n.compileAsync(d,a,e).then(h,h)}const f=dt.get(o);if(!f)return;const s=n.properties.get(o).currentProgram;if(s?.diagnostics?.runnable===!1&&s.cacheKey?.includes(f.compiled.key)){ge.add(f.compiled.key),dt.delete(o),o.needsUpdate=!0;const _=s.diagnostics.fragmentShader.log.split(`
|
|
7036
|
+
`).find(d=>d.startsWith("ERROR"))??"";console.warn(`Blender material "${o.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${_}`);return}const i=Do(f.compiled,t);JSON.stringify(i)!==JSON.stringify(f.channels)&&(f.channels=i,o.needsUpdate=!0)}function Zr(o){const t=Array.isArray(o.material)?o.material:[o.material];if(!t.some(u=>u instanceof ln&&dt.has(u)))return;const n=o.geometry,e=o.userData.blenderTexspace??null,a=n.getAttribute("position"),r=JSON.stringify([e,a?.version??0,a?.count??0]);!n.userData.blenderOrcoFromDoor&&n.userData.blenderOrcoStamp!==r&&(n.setAttribute("blenderOrco",Qr(n,e)),n.userData.blenderOrcoStamp=r);const l=a?.count??0,c=o.userData.blenderDefaultColor;for(const u of t){const f=u instanceof ln?dt.get(u):void 0;for(const s of f?.compiled.attributes??[]){const i=Vt(s),_=s===""?c===void 0?void 0:n.getAttribute(Vt(c)):n.getAttribute(i);_&&_.count===l?n.getAttribute(i)!==_&&n.setAttribute(i,_):n.getAttribute(i)?.count!==l&&n.setAttribute(i,new it(new Float32Array(l*4),4))}}}function Qr(o,t){const n=o.getAttribute("position");let e,a;if(t)e=[...t[0]],a=[...t[1]];else{o.computeBoundingBox();const l=o.boundingBox;e=[(l.min.x+l.max.x)/2,(l.min.y+l.max.y)/2,(l.min.z+l.max.z)/2],a=[(l.max.x-l.min.x)/2,(l.max.y-l.min.y)/2,(l.max.z-l.min.z)/2]}a=a.map(l=>l===0?1:l);const r=new Float32Array(n.count*3);for(let l=0;l<n.count;l++)r[l*3]=(n.getX(l)-e[0])/a[0]*.5+.5,r[l*3+1]=(n.getY(l)-e[1])/a[1]*.5+.5,r[l*3+2]=(n.getZ(l)-e[2])/a[2]*.5+.5;return new it(r,3)}function Kr(o,t){const n=dt.get(o);if(!n)return;const{compiled:e,channels:a}=n;Object.assign(t.uniforms,n.uniforms,{blenderViewport:{value:xe}});const r=v=>v===0?"uv":`uv${v}`,l=`varying vec3 vBlenderObjectPosition;
|
|
7037
7037
|
varying vec3 vBlenderObjectNormal;
|
|
7038
7038
|
varying vec3 vBlenderWorldPosition;
|
|
7039
7039
|
varying vec3 vBlenderWorldNormal;
|
|
@@ -7070,7 +7070,7 @@ ${m}
|
|
|
7070
7070
|
void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
|
|
7071
7071
|
blenderGraph();`);for(const[v,g,b]of f){if(!p.includes(v))throw new Error(`three's physical shader has no ${v}`);p=p.replace(v,b?`${g}
|
|
7072
7072
|
${v}`:`${v}
|
|
7073
|
-
${g}`)}t.fragmentShader=p}const
|
|
7073
|
+
${g}`)}t.fragmentShader=p}const xe=new $t(1,1);function Jr(o){o.getDrawingBufferSize(xe)}function tl(o,t){const n=t.userData.blenderUvChannels;for(const e of[o.map,o.roughnessMap,o.normalMap]){if(!e)continue;const a=e.userData.blenderUvName;let r=a?n?.[a]:0;if(r===void 0){r=9;const l=t.getAttribute("position")?.count;if(l===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==l&&t.setAttribute("uv9",new it(new Float32Array(l*2),2))}e.channel!==r&&(e.channel=r,o.needsUpdate=!0)}}class nl{constructor(){this.bindings=new Map}get(t,n,e,a,r=""){let l=this.bindings.get(t);if(!l||l.source!==n){this.delete(t),l={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,l);const f=l;a&&a.then(()=>{f.disposed||(f.texture.needsUpdate=!0,f.version=n.version,vt())},()=>{})}const c=e==="REPEAT"?ke:e==="MIRROR"?$e:Qo,u=l.texture.wrapS!==c||l.texture.wrapT!==c;return l.texture.wrapS=l.texture.wrapT=c,l.texture.userData.blenderUvName=r,n.image&&(u||l.version!==n.version)&&(l.texture.needsUpdate=!0,l.version=n.version),l.texture}delete(t){const n=this.bindings.get(t);n&&(n.disposed=!0,n.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const mt=S().finite(),Cn=$([mt,mt,mt]),ol=A({coat:mt,coat_roughness:mt,coat_ior:mt,coat_tint:Cn,sheen:mt,sheen_roughness:mt,sheen_tint:Cn,anisotropy:mt,anisotropy_rotation:mt,specular_level:mt,specular_tint:Cn,film_thickness:mt,film_ior:mt}).strict(),el={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},Xt=new WeakMap;function al(o,t){Xt.has(o)||so(o),Xt.get(o).blenderWorldExtinction.value.copy(t)}function rl(o){const t=new ln,n=Xt.get(o);so(t),t.copy(o);const e=Xt.get(t);return n&&(e.blenderCoatIor.value=n.blenderCoatIor.value,e.blenderCoatTint.value.copy(n.blenderCoatTint.value),e.blenderMapClip.value=n.blenderMapClip.value,e.blenderRoughnessClip.value=n.blenderRoughnessClip.value,e.blenderNormalClip.value=n.blenderNormalClip.value,e.blenderWorldExtinction.value.copy(n.blenderWorldExtinction.value)),t}function so(o,t,n={}){const e=t??el;o.clearcoat=e.coat,o.clearcoatRoughness=e.coat_roughness,o.sheen=e.sheen,o.sheenRoughness=e.sheen_roughness,o.sheenColor.setRGB(...e.sheen_tint,ft),o.anisotropy=e.anisotropy,o.anisotropyRotation=e.anisotropy_rotation*Math.PI*2,o.specularIntensity=e.specular_level*2,o.specularColor.setRGB(...e.specular_tint,ft),o.iridescence=e.film_thickness>0?1:0,o.iridescenceIOR=e.film_ior,o.iridescenceThicknessRange=[e.film_thickness,e.film_thickness];let a=Xt.get(o);if(!a){a={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new ht(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new x}},Xt.set(o,a);const r=a;o.customProgramCacheKey=()=>`blender-principled-physical-v5${Gr(o)}`,o.onBeforeRender=(l,c,u,f,s)=>{tl(o,f),Yr(o,f,l,c,u,s,rl),Jr(l)},o.onBeforeCompile=l=>{const c=new Set([o.map,o.roughnessMap,o.normalMap].flatMap(h=>h?[h.channel]:[]).concat(Xr(o)));l.vertexShader=[...c].filter(h=>h>0).sort((h,m)=>h-m).map(h=>h<=3?`#ifndef USE_UV${h}
|
|
7074
7074
|
attribute vec2 uv${h};
|
|
7075
7075
|
#endif`:`attribute vec2 uv${h};`).join(`
|
|
7076
7076
|
`)+`
|
|
@@ -7091,7 +7091,7 @@ attribute vec2 uv${h};
|
|
|
7091
7091
|
float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
|
|
7092
7092
|
blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
|
|
7093
7093
|
outgoingLight *= mix(vec3(1.0), pow(max(blenderCoatTint, vec3(0.0)), vec3(coatPath)), material.clearcoat);
|
|
7094
|
-
vec3 Fcc = F_Schlick`),Kr(o,l)},o.needsUpdate=!0}a.blenderCoatIor.value=Math.max(1,e.coat_ior),a.blenderCoatTint.value.setRGB(...e.coat_tint,ft),a.blenderMapClip.value=n.map===!0,a.blenderRoughnessClip.value=n.roughness===!0,a.blenderNormalClip.value=n.normal===!0}function fo(o){const t=a=>{if(!(!a||typeof a!="object")){if("kind"in a&&["direction","window","sky"].includes(String(a.kind)))throw new Error(`World volume spatial input ${a.kind} is not implemented`);for(const r of Object.values(a))t(r)}};t(o);const n=nt(o)(new x);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function Bt(o){const t=fo(o);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function dn(o){const t=fo(o);return(typeof t=="number"?new x().setScalar(t):t.clone()).max(new x)}function ll(o){if(o<800)return new x(5.413294490189271,0,0);if(o>=12e3)return new x(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(r=>o>=r).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],e=[[-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],a=[[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 x(n[0]/o+n[1]*o+n[2],e[0]/o+e[1]*o+e[2],((a[0]*o+a[1])*o+a[2])*o+a[3]).max(new x)}function
|
|
7094
|
+
vec3 Fcc = F_Schlick`),Kr(o,l)},o.needsUpdate=!0}a.blenderCoatIor.value=Math.max(1,e.coat_ior),a.blenderCoatTint.value.setRGB(...e.coat_tint,ft),a.blenderMapClip.value=n.map===!0,a.blenderRoughnessClip.value=n.roughness===!0,a.blenderNormalClip.value=n.normal===!0}function fo(o){const t=a=>{if(!(!a||typeof a!="object")){if("kind"in a&&["direction","window","sky"].includes(String(a.kind)))throw new Error(`World volume spatial input ${a.kind} is not implemented`);for(const r of Object.values(a))t(r)}};t(o);const n=nt(o)(new x);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function Bt(o){const t=fo(o);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function dn(o){const t=fo(o);return(typeof t=="number"?new x().setScalar(t):t.clone()).max(new x)}function ll(o){if(o<800)return new x(5.413294490189271,0,0);if(o>=12e3)return new x(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(r=>o>=r).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],e=[[-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],a=[[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 x(n[0]/o+n[1]*o+n[2],e[0]/o+e[1]*o+e[2],((a[0]*o+a[1])*o+a[2])*o+a[3]).max(new x)}function Co(o){if(!o?.volume?.length)return null;const t={extinction:new x,emission:new x,lobes:[]};for(const n of o.volume){const e=Bt(n.weight);if(e===0)continue;const a=dn(n.color),r=Bt(n.density),l=new x,c=new x;if(n.kind==="absorption"&&l.set(1-a.x,1-a.y,1-a.z).max(new x).multiplyScalar(r),n.kind==="scatter"||n.kind==="principled"){c.copy(a).multiplyScalar(r);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const f=fo(n.anisotropy);if(typeof f!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:c.clone().multiplyScalar(e),g:u==="RAYLEIGH"?0:ut.clamp(f,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?Bt(n.alpha):0})}if(n.kind==="principled"){const u=dn(n.absorption_color);l.set(Math.max(1-a.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-a.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-a.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(r);const f=Bt(n.blackbody_intensity);if(f>.001){const s=Bt(n.temperature),i=5670373e-20/Math.PI*(1+f*(s**4-1));t.emission.add(ll(s).multiply(dn(n.blackbody_tint)).multiplyScalar(i*e))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?a:dn(n.emission_color)).multiplyScalar(Bt(n.emission_strength)*e)),t.extinction.add(l.add(c).multiplyScalar(e))}for(const n of["x","y","z"])if(t.extinction[n]===0&&t.emission[n]>0)throw new Error("Unbounded emissive World volume with zero extinction has divergent radiance");return t}class il{constructor(t){this.medium=t,this.target=new Le(1,1,{type:no,depthBuffer:!1}),this.geometry=new Ko(2,2),this.scene=new Ve,this.camera=new je}render(t,n,e,a){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const r={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:a.projectionMatrixInverse},cameraWorld:{value:a.matrixWorld},orthographic:{value:a.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let l="",c="",u=0,f=2;e.traverseVisible(d=>{if(!(d instanceof Vn||d instanceof jn||d instanceof gn))return;const h=d,m=u++,p=h.getWorldPosition(new x);r[`lp${m}`]={value:p},r[`lc${m}`]={value:h.color.clone().multiplyScalar(h.intensity)},l+=`uniform vec3 lp${m}, lc${m};
|
|
7095
7095
|
`;let v="1.0",g="1.0";if(h instanceof jn&&(r[`ld${m}`]={value:h.target.getWorldPosition(new x).sub(p).normalize()},r[`cone${m}`]={value:new $t(Math.cos(h.angle),Math.cos(h.angle*(1-h.penumbra)))},l+=`uniform vec3 ld${m}; uniform vec2 cone${m};
|
|
7096
7096
|
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(h instanceof gn)&&h.castShadow&&h.shadow.map){if(++f>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");r[`sm${m}`]={value:h.shadow.map.texture},r[`sx${m}`]={value:h.shadow.matrix},r[`ss${m}`]={value:h.shadow.mapSize},r[`sb${m}`]={value:h.shadow.bias},r[`sn${m}`]={value:h.shadow.camera.near},r[`sf${m}`]={value:h.shadow.camera.far},l+=`uniform sampler2D sm${m}; uniform mat4 sx${m}; uniform vec2 ss${m}; uniform float sb${m},sn${m},sf${m};
|
|
7097
7097
|
`,v=h instanceof Vn?`getPointShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0),sn${m},sf${m})`:`getShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0))`}if(h instanceof gn){const b=new X().extractRotation(h.matrixWorld);r[`lx${m}`]={value:new x(h.width,0,0).applyMatrix4(b)},r[`ly${m}`]={value:new x(0,h.height,0).applyMatrix4(b)},r[`ln${m}`]={value:new x(0,0,-1).transformDirection(b)},l+=`uniform vec3 lx${m},ly${m},ln${m};
|
|
@@ -7135,10 +7135,10 @@ attribute vec2 uv${h};
|
|
|
7135
7135
|
radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
|
|
7136
7136
|
}
|
|
7137
7137
|
gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
|
|
7138
|
-
}`}),this.scene.clear(),this.scene.add(new Tt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const _=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(_)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const sl=A({object:E(),group:E(),groupIndex:S().int().nonnegative(),count:S().int().nonnegative(),digest:E(),alertMode:W(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:E().optional(),alertBase64:E().optional()}).strict();function fl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,l]=cl(2/3*(1-n)),c=new ht;return c.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(l*e)**(1/1.5),Mt),c}function cl(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const ul=0;function Co(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class _l{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const a=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==a)return this.clear(),`weights: the session sent a reference to ${a} 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: ${a} carried neither an array nor a reference`;const h=Co(t.weightsBase64);this.held={key:a,weights:new Float32Array(h.buffer,h.byteOffset,t.count),alerts:Co(t.alertBase64)}}const r=this.held;if(r===null)return null;const l=`${a}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(l===this.signature&&this.mesh!==null)return null;this.signature=l,this.clear();const c=n.geometry.clone(),u=c.getAttribute("position"),f=c.getAttribute("blenderVertex");if(f===void 0)return c.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),i=new ht().setHex(ul,Mt);for(let h=0;h<u.count;h++){const m=f.getX(h),v=t.alertMode!=="NONE"&&r.alerts[m]===1?i:fl(r.weights[m]??0);s[h*3]=v.r,s[h*3+1]=v.g,s[h*3+2]=v.b}c.setAttribute("color",new it(s,3)),c.deleteAttribute("blenderVertex");const _=new bn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),d=new Tt(c,_);return d.name=`${t.object}:weights`,d.frustumCulled=!1,d.matrixAutoUpdate=!1,d.matrix.copy(e),d.matrix.decompose(d.position,d.quaternion,d.scale),this.geometry=c,this.material=_,this.mesh=d,this.group.add(d),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 hn=S().finite(),ml=F($([hn,hn,hn,hn])).length(4),dl=20,ko=[16724818,9165824,2658559];function hl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function xe(){return new Be({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function pl(){const o=[],t=[],n=new ht(0,0,0),e=(r,l,c,u,f)=>{for(const s of[r,l]){const i=[0,0,0];i[c]=s*u,o.push(...i),t.push(f.r,f.g,f.b)}};for(let r=0;r<3;r++){const l=new ht().setHex(ko[r],Mt);e(1,.85,r,1,l),e(.85,.25,r,1,n),e(1,.85,r,-1,hl(ko[r])),e(.85,.25,r,-1,n)}const a=new fn;return a.setAttribute("position",new bt(o,3)),a.setAttribute("color",new bt(t,3)),new Ko(a,xe())}function vl(){const t=[],n=[],e=new ht(1,0,0),a=new ht(1,1,1);for(let l=0;l<12;l++){const c=(l+1)%2===0?a:e;for(const u of[l,l+1]){const f=2*Math.PI*u/12;t.push(.5*Math.cos(f),.5*Math.sin(f),0),n.push(c.r,c.g,c.b)}}const r=new fn;return r.setAttribute("position",new bt(t,3)),r.setAttribute("color",new bt(n,3)),new Ko(r,xe())}class gl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=pl(),this.circle=vl(),this.seen=null,this.size=new $t,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,a,r]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new gt(e,a,r,n),new x(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const e=Math.max(this.size.y,1),a=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let r;if(n.isOrthographicCamera){const c=n;r=(c.top-c.bottom)/c.zoom/e}else{const c=n;r=2*Math.max(-a.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(c.fov)/2)/c.zoom/e}const l=r*dl;this.lines.scale.setScalar(l),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(l),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,a,r){const l=this.seen;if(l===null||e!==l.canvas)return null;const c=l.canvas.getBoundingClientRect(),u=new $t((t-c.left)/Math.max(c.width,1)*2-1,-((n-c.top)/Math.max(c.height,1))*2+1),f=new je;f.setFromCamera(u,l.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},i=f.intersectObject(a,!0).find(m=>m.object.isMesh&&r(m.object)&&s(m.object));let _=i?i.point.clone():null;if(_===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=l.camera.getWorldDirection(new x),v=l.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),_=f.ray.intersectPlane(new It().setFromNormalAndCoplanarPoint(p,m),new x)}if(_===null)return null;a.updateWorldMatrix(!0,!1);const d=a.worldToLocal(_),h=a.getWorldQuaternion(new gt).invert().multiply(l.camera.getWorldQuaternion(new gt));return{location:[d.x,d.y,d.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 Rt=S().finite(),xl=A({display:W(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Rt,image:A({name:E().nullable(),offset:$([Rt,Rt]),depth:W(["DEFAULT","FRONT","BACK"]),side:W(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:Rt.nullable(),tint:$([Rt,Rt,Rt]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},bl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const a=2*Math.PI*e/t;return[o*Math.cos(a),o*Math.sin(a)]})}function ct(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const l=t[r*a%t.length],c=t[(r*a+1)%t.length];K(o,[l[0],l[1],n],[c[0],c[1],n])}}function yl(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new X;let a=!1;o.onBeforeRender=(r,l,c,u,f,s)=>{t(r,l,c,u,f,s),l.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),a=!0)},o.onAfterRender=(r,l,c,u,f,s)=>{a&&(o.matrixWorld.copy(e),a=!1),n(r,l,c,u,f,s)}}class wl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new $t,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const a=e.selected?e.name===t.active?wt.active:wt.selected:e.type==="CAMERA"?wt.camera:e.type==="LIGHT"?wt.light:wt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,l=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,c=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!r&&!l&&!c)continue;n.add(e.name);const u=l&&e.light?t.lightDistances[e.light]??null:null,f=c?.image?.name?t.image(c.image.name):null,s=JSON.stringify([f?[f.texture.uuid,f.width,f.height]:null,e.matrix,a,r,l,u,c,r?[e.name===t.sceneCamera,t.renderAspect]:null]),i=this.drawn.get(e.name),_=t.presented(e.name);if(i?.key===s){for(const v of i.parts)v.userData.volterPicksAs=_;continue}i&&this.remove(i.parts);const d=new X().set(...e.matrix.flat()),h=r?this.cameras:l?this.lights:this.empties,m=new Set(h.children);r?this.camera(r,d,a,e.name===t.sceneCamera,t.renderAspect):l?this.light(l,d,a,u):c&&this.empty(c,d,a,f);const p=h.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=_,v.traverse(yl);this.drawn.set(e.name,{key:s,parts:p})}for(const[e,a]of this.drawn)n.has(e)||(this.remove(a.parts),this.drawn.delete(e))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,e,a,r){const l=t.display_size,u=(t.sensor_fit==="AUTO"?r>=1:t.sensor_fit==="HORIZONTAL")?[1,1/r]:[r,1];let f,s,i,_;if(t.type==="ORTHO")i=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],_=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-l,f=.5*t.ortho_scale;else{const P=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new x().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;f=l/2/((1/O.x+1/O.y+1/O.z)/3),s=f*t.lens/-P,i=[f*u[0],f*u[1]],_=[t.shift_x*f*2,t.shift_y*f*2]}const d=[[_[0]+i[0],_[1]+i[1],s],[_[0]+i[0],_[1]-i[1],s],[_[0]-i[0],_[1]-i[1],s],[_[0]-i[0],_[1]+i[1],s]],h=[];for(let P=0;P<4;P++)K(h,d[P],d[(P+1)%4]),K(h,d[P],[0,0,0]);const m=.7*f,p=.1*f,v=_[1]+i[1]+p,g=[[_[0]-m,v,s],[_[0]+m,v,s],[_[0],v+m,s]],b=kn(n);this.cameras.add(this.lines(h,e,1,b));let w;if(a){const P=new fn;P.setAttribute("position",new bt(g.flat(),3)),w=new Tt(P,this.fill(e)),w.matrixAutoUpdate=!1,w.matrix.copy(b)}else{const P=[];for(let O=0;O<3;O++)K(P,g[O],g[(O+1)%3]);w=this.lines(P,e,1,b)}const R=new x,T=w.onBeforeRender.bind(w);w.onBeforeRender=(P,O,M,C,V,H)=>{R.setFromMatrixPosition(b).applyMatrix4(this.cameras.matrixWorld);const Q=M.getWorldPosition(this.scratch).distanceToSquared(R)>1e-8;w.matrix.copy(b),Q||w.matrix.scale(new x(0,0,0)),w.updateMatrixWorld(!0),T(P,O,M,C,V,H)},this.cameras.add(w)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),l=[];K(l,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(l,wt.light,wt.lightAlpha,new X));const c=[];ct(c,at(1.35,4)),this.lights.add(this.screen(c,wt.light,wt.lightAlpha,new x(r.x,r.y,0)));const u=[],f=9;if(ct(u,at(f*.3,4)),ct(u,at(f,16),0,!0),ct(u,at(f*1.33,20),0,!0),t.type==="SUN")for(const[_,d]of at(f,8))K(u,[_*1.6,d*1.6,0],[_*1.9,d*1.9,0]),K(u,[_*2.2,d*2.2,0],[_*2.5,d*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=kn(n),i=[];if(t.type==="SUN")K(i,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const _=(t.size??1)/2,d=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?ct(i,at(1,32).map(([h,m])=>[h*_,m*d])):ct(i,[[_,d],[-_,d],[-_,-d],[_,-d]])}if(i.length>0&&this.lights.add(this.lines(i,e,1,n.clone())),a&&(t.type==="SPOT"||t.type==="AREA")){const _=new x(0,0,-1).transformDirection(n),d=v=>r.clone().addScaledVector(_,v),[h,m]=a,p=[];K(p,d(h).toArray(),d(m).toArray()),this.lights.add(this.lines(p,e,1,new X));for(const v of[h,m]){const g=[];ct(g,at(1.2,4)),this.lights.add(this.screen(g,e,1,d(v)))}}if(t.type==="SPOT"){const _=(t.spot_size??Math.PI/4)/2,d=Math.cos(_),h=t.spot_blend??.15,m=d*h-d-h,p=Math.sqrt((d*d-d*d*m*m)/(m*m-d*d*m*m)),v=Math.sqrt(1-d*d),g=kn(n).multiply(new X().makeScale(10,10,10)),b=[];ct(b,at(v,32),-d),ct(b,at(v*p,32),-d),this.lights.add(this.lines(b,e,1,g.clone())),this.lights.add(this.silhouette(v,d,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const _=[];ct(_,at(t.radius,32)),this.lights.add(this.facing(_,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,a){const r=t.size,l=[],c=(f,s)=>{const i=at(1,s);for(let _=0;_<s;_++){const[d,h]=i[_],[m,p]=i[(_+1)%s],v=(g,b)=>f==="xy"?[g,b,0]:f==="xz"?[g,0,b]:[0,g,b];K(l,v(d,h),v(m,p))}};switch(t.display){case"PLAIN_AXES":K(l,[0,-1,0],[0,1,0]),K(l,[-1,0,0],[1,0,0]),K(l,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{K(l,[0,0,0],[0,0,.75]);for(const[f,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(l,[0,0,1],[f,s,.75]);ct(l,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[f,s]of Ol)K(l,$o[f],$o[s]);break;case"CIRCLE":c("xz",64);break;case"SPHERE":c("xy",32),c("xz",32),c("yz",32);break;case"CONE":{const f=at(1,8);for(let s=0;s<8;s++){const[i,_]=f[s],[d,h]=f[(s+1)%8];K(l,[i,0,_],[0,2,0]),K(l,[i,0,_],[d,0,h])}break}case"ARROWS":for(let f=0;f<3;f++){const s=[0,0,0];s[f]=1,K(l,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new X().makeScale(r,r,r));this.empties.add(this.lines(l,e,1,u)),t.display==="ARROWS"&&this.axisNames(n,r,e)}silhouette(t,n,e,a){const r=this.lines(new Array(192).fill(0),e,1,a);r.frustumCulled=!1;const l=r.geometry.getAttribute("instanceStart").data,c=at(1,32).map(([d,h])=>new x(d*t,h*t,-n)),u=new x,f=new X,s=new x,i=new x,_=new x;return this.onDraw(r,(d,h)=>{f.copy(r.matrixWorld).invert();const m=h.isOrthographicCamera;m?h.getWorldDirection(u).negate().transformDirection(f):u.setFromMatrixPosition(h.matrixWorld).applyMatrix4(f);const p=l.array;let v=!1;for(let g=0;g<32;g++){const b=c[g];s.crossVectors(b,c[(g+31)%32]),i.crossVectors(c[(g+1)%32],b),m?_.copy(u):_.copy(u).sub(b);const w=s.dot(_)>0!=i.dot(_)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==w&&(v=!0),p.set([0,0,0,w?b.x:0,w?b.y:0,w?b.z:0],g*6)}v&&(l.needsUpdate=!0,vt())}),r}imageEmpty(t,n,e,a){const r=t.image;if(!r)return;const l=a?.width??0,c=a?.height??0,u=l>0&&c>0?l>=c?[1,c/l]:[l/c,1]:[1,1],f=new x,s=new x,i=new x;n.extractBasis(f,s,i),f.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const _=new x().setFromMatrixPosition(n).addScaledVector(f,r.offset[0]*2+1).addScaledVector(s,r.offset[1]*2+1),d=new X().makeBasis(f,s,i.clone()).setPosition(_),h=[];ct(h,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(h,e,1,d),p=i.clone().normalize(),v=new x,g=new x,b=(M,C)=>{const V=M.isOrthographicCamera===!0;if(V?!r.orthographic:!r.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);M.getWorldDirection(g);let Q,tt;if(V)Q=H.dot(g.clone().negate()),tt=1e-5;else{const pt=_.clone().applyMatrix4(this.empties.matrixWorld);Q=H.dot(v.setFromMatrixPosition(M.matrixWorld).sub(pt)),tt=0}return!(r.side==="FRONT"&&Q<tt||r.side==="BACK"&&Q>-tt||r.axis_aligned&&H.clone().projectOnPlane(g).lengthSq()>1e-5)},w=(M,C)=>{const V=M.onBeforeRender.bind(M);M.onBeforeRender=(H,Q,tt,pt,y,L)=>{M.matrix.copy(d),b(tt,C)||M.matrix.scale(new x(0,0,0)),M.updateMatrixWorld(!0),V(H,Q,tt,pt,y,L)}};if(w(m,!1),this.empties.add(m),!a||r.opacity!==null&&r.opacity<=0)return;const R=r.opacity!==null,T=r.depth==="BACK",P=new bn({map:a.texture,side:uo,transparent:R&&!T,opacity:r.opacity??1,alphaTest:R?0:.05,toneMapped:!1,depthTest:r.depth==="DEFAULT",depthWrite:r.depth==="DEFAULT"&&!R});P.color.setRGB(...r.tint,ft),R&&T&&(P.blending=Ue,P.blendSrc=We,P.blendDst=He),P.onBeforeCompile=M=>{const C=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7138
|
+
}`}),this.scene.clear(),this.scene.add(new Tt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const _=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(_)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const sl=A({object:E(),group:E(),groupIndex:S().int().nonnegative(),count:S().int().nonnegative(),digest:E(),alertMode:W(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:E().optional(),alertBase64:E().optional()}).strict();function fl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,l]=cl(2/3*(1-n)),c=new ht;return c.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(l*e)**(1/1.5),Mt),c}function cl(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const ul=0;function ko(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class _l{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const a=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==a)return this.clear(),`weights: the session sent a reference to ${a} 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: ${a} carried neither an array nor a reference`;const h=ko(t.weightsBase64);this.held={key:a,weights:new Float32Array(h.buffer,h.byteOffset,t.count),alerts:ko(t.alertBase64)}}const r=this.held;if(r===null)return null;const l=`${a}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(l===this.signature&&this.mesh!==null)return null;this.signature=l,this.clear();const c=n.geometry.clone(),u=c.getAttribute("position"),f=c.getAttribute("blenderVertex");if(f===void 0)return c.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),i=new ht().setHex(ul,Mt);for(let h=0;h<u.count;h++){const m=f.getX(h),v=t.alertMode!=="NONE"&&r.alerts[m]===1?i:fl(r.weights[m]??0);s[h*3]=v.r,s[h*3+1]=v.g,s[h*3+2]=v.b}c.setAttribute("color",new it(s,3)),c.deleteAttribute("blenderVertex");const _=new bn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),d=new Tt(c,_);return d.name=`${t.object}:weights`,d.frustumCulled=!1,d.matrixAutoUpdate=!1,d.matrix.copy(e),d.matrix.decompose(d.position,d.quaternion,d.scale),this.geometry=c,this.material=_,this.mesh=d,this.group.add(d),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 hn=S().finite(),ml=F($([hn,hn,hn,hn])).length(4),dl=20,$o=[16724818,9165824,2658559];function hl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function be(){return new Ue({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function pl(){const o=[],t=[],n=new ht(0,0,0),e=(r,l,c,u,f)=>{for(const s of[r,l]){const i=[0,0,0];i[c]=s*u,o.push(...i),t.push(f.r,f.g,f.b)}};for(let r=0;r<3;r++){const l=new ht().setHex($o[r],Mt);e(1,.85,r,1,l),e(.85,.25,r,1,n),e(1,.85,r,-1,hl($o[r])),e(.85,.25,r,-1,n)}const a=new fn;return a.setAttribute("position",new bt(o,3)),a.setAttribute("color",new bt(t,3)),new Jo(a,be())}function vl(){const t=[],n=[],e=new ht(1,0,0),a=new ht(1,1,1);for(let l=0;l<12;l++){const c=(l+1)%2===0?a:e;for(const u of[l,l+1]){const f=2*Math.PI*u/12;t.push(.5*Math.cos(f),.5*Math.sin(f),0),n.push(c.r,c.g,c.b)}}const r=new fn;return r.setAttribute("position",new bt(t,3)),r.setAttribute("color",new bt(n,3)),new Jo(r,be())}class gl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=pl(),this.circle=vl(),this.seen=null,this.size=new $t,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,a,r]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new gt(e,a,r,n),new x(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const e=Math.max(this.size.y,1),a=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let r;if(n.isOrthographicCamera){const c=n;r=(c.top-c.bottom)/c.zoom/e}else{const c=n;r=2*Math.max(-a.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(c.fov)/2)/c.zoom/e}const l=r*dl;this.lines.scale.setScalar(l),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(l),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,a,r){const l=this.seen;if(l===null||e!==l.canvas)return null;const c=l.canvas.getBoundingClientRect(),u=new $t((t-c.left)/Math.max(c.width,1)*2-1,-((n-c.top)/Math.max(c.height,1))*2+1),f=new Be;f.setFromCamera(u,l.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},i=f.intersectObject(a,!0).find(m=>m.object.isMesh&&r(m.object)&&s(m.object));let _=i?i.point.clone():null;if(_===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=l.camera.getWorldDirection(new x),v=l.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),_=f.ray.intersectPlane(new It().setFromNormalAndCoplanarPoint(p,m),new x)}if(_===null)return null;a.updateWorldMatrix(!0,!1);const d=a.worldToLocal(_),h=a.getWorldQuaternion(new gt).invert().multiply(l.camera.getWorldQuaternion(new gt));return{location:[d.x,d.y,d.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 Rt=S().finite(),xl=A({display:W(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Rt,image:A({name:E().nullable(),offset:$([Rt,Rt]),depth:W(["DEFAULT","FRONT","BACK"]),side:W(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:Rt.nullable(),tint:$([Rt,Rt,Rt]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},bl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const a=2*Math.PI*e/t;return[o*Math.cos(a),o*Math.sin(a)]})}function ct(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const l=t[r*a%t.length],c=t[(r*a+1)%t.length];K(o,[l[0],l[1],n],[c[0],c[1],n])}}function yl(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new X;let a=!1;o.onBeforeRender=(r,l,c,u,f,s)=>{t(r,l,c,u,f,s),l.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),a=!0)},o.onAfterRender=(r,l,c,u,f,s)=>{a&&(o.matrixWorld.copy(e),a=!1),n(r,l,c,u,f,s)}}class wl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new $t,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const a=e.selected?e.name===t.active?wt.active:wt.selected:e.type==="CAMERA"?wt.camera:e.type==="LIGHT"?wt.light:wt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,l=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,c=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!r&&!l&&!c)continue;n.add(e.name);const u=l&&e.light?t.lightDistances[e.light]??null:null,f=c?.image?.name?t.image(c.image.name):null,s=JSON.stringify([f?[f.texture.uuid,f.width,f.height]:null,e.matrix,a,r,l,u,c,r?[e.name===t.sceneCamera,t.renderAspect]:null]),i=this.drawn.get(e.name),_=t.presented(e.name);if(i?.key===s){for(const v of i.parts)v.userData.volterPicksAs=_;continue}i&&this.remove(i.parts);const d=new X().set(...e.matrix.flat()),h=r?this.cameras:l?this.lights:this.empties,m=new Set(h.children);r?this.camera(r,d,a,e.name===t.sceneCamera,t.renderAspect):l?this.light(l,d,a,u):c&&this.empty(c,d,a,f);const p=h.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=_,v.traverse(yl);this.drawn.set(e.name,{key:s,parts:p})}for(const[e,a]of this.drawn)n.has(e)||(this.remove(a.parts),this.drawn.delete(e))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,e,a,r){const l=t.display_size,u=(t.sensor_fit==="AUTO"?r>=1:t.sensor_fit==="HORIZONTAL")?[1,1/r]:[r,1];let f,s,i,_;if(t.type==="ORTHO")i=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],_=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-l,f=.5*t.ortho_scale;else{const P=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new x().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;f=l/2/((1/O.x+1/O.y+1/O.z)/3),s=f*t.lens/-P,i=[f*u[0],f*u[1]],_=[t.shift_x*f*2,t.shift_y*f*2]}const d=[[_[0]+i[0],_[1]+i[1],s],[_[0]+i[0],_[1]-i[1],s],[_[0]-i[0],_[1]-i[1],s],[_[0]-i[0],_[1]+i[1],s]],h=[];for(let P=0;P<4;P++)K(h,d[P],d[(P+1)%4]),K(h,d[P],[0,0,0]);const m=.7*f,p=.1*f,v=_[1]+i[1]+p,g=[[_[0]-m,v,s],[_[0]+m,v,s],[_[0],v+m,s]],b=kn(n);this.cameras.add(this.lines(h,e,1,b));let w;if(a){const P=new fn;P.setAttribute("position",new bt(g.flat(),3)),w=new Tt(P,this.fill(e)),w.matrixAutoUpdate=!1,w.matrix.copy(b)}else{const P=[];for(let O=0;O<3;O++)K(P,g[O],g[(O+1)%3]);w=this.lines(P,e,1,b)}const R=new x,T=w.onBeforeRender.bind(w);w.onBeforeRender=(P,O,M,C,V,H)=>{R.setFromMatrixPosition(b).applyMatrix4(this.cameras.matrixWorld);const Q=M.getWorldPosition(this.scratch).distanceToSquared(R)>1e-8;w.matrix.copy(b),Q||w.matrix.scale(new x(0,0,0)),w.updateMatrixWorld(!0),T(P,O,M,C,V,H)},this.cameras.add(w)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),l=[];K(l,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(l,wt.light,wt.lightAlpha,new X));const c=[];ct(c,at(1.35,4)),this.lights.add(this.screen(c,wt.light,wt.lightAlpha,new x(r.x,r.y,0)));const u=[],f=9;if(ct(u,at(f*.3,4)),ct(u,at(f,16),0,!0),ct(u,at(f*1.33,20),0,!0),t.type==="SUN")for(const[_,d]of at(f,8))K(u,[_*1.6,d*1.6,0],[_*1.9,d*1.9,0]),K(u,[_*2.2,d*2.2,0],[_*2.5,d*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=kn(n),i=[];if(t.type==="SUN")K(i,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const _=(t.size??1)/2,d=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?ct(i,at(1,32).map(([h,m])=>[h*_,m*d])):ct(i,[[_,d],[-_,d],[-_,-d],[_,-d]])}if(i.length>0&&this.lights.add(this.lines(i,e,1,n.clone())),a&&(t.type==="SPOT"||t.type==="AREA")){const _=new x(0,0,-1).transformDirection(n),d=v=>r.clone().addScaledVector(_,v),[h,m]=a,p=[];K(p,d(h).toArray(),d(m).toArray()),this.lights.add(this.lines(p,e,1,new X));for(const v of[h,m]){const g=[];ct(g,at(1.2,4)),this.lights.add(this.screen(g,e,1,d(v)))}}if(t.type==="SPOT"){const _=(t.spot_size??Math.PI/4)/2,d=Math.cos(_),h=t.spot_blend??.15,m=d*h-d-h,p=Math.sqrt((d*d-d*d*m*m)/(m*m-d*d*m*m)),v=Math.sqrt(1-d*d),g=kn(n).multiply(new X().makeScale(10,10,10)),b=[];ct(b,at(v,32),-d),ct(b,at(v*p,32),-d),this.lights.add(this.lines(b,e,1,g.clone())),this.lights.add(this.silhouette(v,d,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const _=[];ct(_,at(t.radius,32)),this.lights.add(this.facing(_,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,a){const r=t.size,l=[],c=(f,s)=>{const i=at(1,s);for(let _=0;_<s;_++){const[d,h]=i[_],[m,p]=i[(_+1)%s],v=(g,b)=>f==="xy"?[g,b,0]:f==="xz"?[g,0,b]:[0,g,b];K(l,v(d,h),v(m,p))}};switch(t.display){case"PLAIN_AXES":K(l,[0,-1,0],[0,1,0]),K(l,[-1,0,0],[1,0,0]),K(l,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{K(l,[0,0,0],[0,0,.75]);for(const[f,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(l,[0,0,1],[f,s,.75]);ct(l,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[f,s]of Ol)K(l,Lo[f],Lo[s]);break;case"CIRCLE":c("xz",64);break;case"SPHERE":c("xy",32),c("xz",32),c("yz",32);break;case"CONE":{const f=at(1,8);for(let s=0;s<8;s++){const[i,_]=f[s],[d,h]=f[(s+1)%8];K(l,[i,0,_],[0,2,0]),K(l,[i,0,_],[d,0,h])}break}case"ARROWS":for(let f=0;f<3;f++){const s=[0,0,0];s[f]=1,K(l,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new X().makeScale(r,r,r));this.empties.add(this.lines(l,e,1,u)),t.display==="ARROWS"&&this.axisNames(n,r,e)}silhouette(t,n,e,a){const r=this.lines(new Array(192).fill(0),e,1,a);r.frustumCulled=!1;const l=r.geometry.getAttribute("instanceStart").data,c=at(1,32).map(([d,h])=>new x(d*t,h*t,-n)),u=new x,f=new X,s=new x,i=new x,_=new x;return this.onDraw(r,(d,h)=>{f.copy(r.matrixWorld).invert();const m=h.isOrthographicCamera;m?h.getWorldDirection(u).negate().transformDirection(f):u.setFromMatrixPosition(h.matrixWorld).applyMatrix4(f);const p=l.array;let v=!1;for(let g=0;g<32;g++){const b=c[g];s.crossVectors(b,c[(g+31)%32]),i.crossVectors(c[(g+1)%32],b),m?_.copy(u):_.copy(u).sub(b);const w=s.dot(_)>0!=i.dot(_)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==w&&(v=!0),p.set([0,0,0,w?b.x:0,w?b.y:0,w?b.z:0],g*6)}v&&(l.needsUpdate=!0,vt())}),r}imageEmpty(t,n,e,a){const r=t.image;if(!r)return;const l=a?.width??0,c=a?.height??0,u=l>0&&c>0?l>=c?[1,c/l]:[l/c,1]:[1,1],f=new x,s=new x,i=new x;n.extractBasis(f,s,i),f.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const _=new x().setFromMatrixPosition(n).addScaledVector(f,r.offset[0]*2+1).addScaledVector(s,r.offset[1]*2+1),d=new X().makeBasis(f,s,i.clone()).setPosition(_),h=[];ct(h,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(h,e,1,d),p=i.clone().normalize(),v=new x,g=new x,b=(M,C)=>{const V=M.isOrthographicCamera===!0;if(V?!r.orthographic:!r.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);M.getWorldDirection(g);let Q,tt;if(V)Q=H.dot(g.clone().negate()),tt=1e-5;else{const pt=_.clone().applyMatrix4(this.empties.matrixWorld);Q=H.dot(v.setFromMatrixPosition(M.matrixWorld).sub(pt)),tt=0}return!(r.side==="FRONT"&&Q<tt||r.side==="BACK"&&Q>-tt||r.axis_aligned&&H.clone().projectOnPlane(g).lengthSq()>1e-5)},w=(M,C)=>{const V=M.onBeforeRender.bind(M);M.onBeforeRender=(H,Q,tt,pt,y,L)=>{M.matrix.copy(d),b(tt,C)||M.matrix.scale(new x(0,0,0)),M.updateMatrixWorld(!0),V(H,Q,tt,pt,y,L)}};if(w(m,!1),this.empties.add(m),!a||r.opacity!==null&&r.opacity<=0)return;const R=r.opacity!==null,T=r.depth==="BACK",P=new bn({map:a.texture,side:uo,transparent:R&&!T,opacity:r.opacity??1,alphaTest:R?0:.05,toneMapped:!1,depthTest:r.depth==="DEFAULT",depthWrite:r.depth==="DEFAULT"&&!R});P.color.setRGB(...r.tint,ft),R&&T&&(P.blending=We,P.blendSrc=He,P.blendDst=qe),P.onBeforeCompile=M=>{const C=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7139
7139
|
`:"";M.fragmentShader=M.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
7140
7140
|
${C}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",R?"#include <alphatest_fragment>":`#include <alphatest_fragment>
|
|
7141
|
-
diffuseColor.a = 1.0;`)},P.customProgramCacheKey=()=>`volter-blender-image:${r.premultiplied}:${R}`;const O=new Tt(new
|
|
7141
|
+
diffuseColor.a = 1.0;`)},P.customProgramCacheKey=()=>`volter-blender-image:${r.premultiplied}:${R}`;const O=new Tt(new Ko(2,2),P);O.matrixAutoUpdate=!1,O.matrix.copy(d),O.renderOrder=r.depth==="FRONT"?1e3:r.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,w(O,!0),this.empties.add(O)}axisNames(t,n,e){const a=[new x,new x,new x];t.extractBasis(a[0],a[1],a[2]);for(let r=0;r<3;r++){const l=a[r].length()*n,c=new x(0,0,0);c.setComponent(r,1.25*n),c.applyMatrix4(t);const u=new x(0,0,0);u.setComponent(r,n),u.applyMatrix4(t);const f=[];for(let _=1;_<=6;_++)ct(f,at(.007*(4*_/6)*l,4));this.empties.add(this.facing(f,e,u));const s=Tl[r],i=[];for(let _=0;_+1<s.length;_+=2){const[d,h]=s[_],[m,p]=s[_+1];K(i,[d*4*l,h*4*l,0],[m*4*l,p*4*l,0])}this.empties.add(this.facing(i,e,c))}}material(t,n){const e=`${t}:${n}`;let a=this.lineMaterials.get(e);return a||(a=new Ho({color:t,linewidth:bl,transparent:n<1,opacity:n,depthTest:!0,depthWrite:n>=1,toneMapped:!1}),this.lineMaterials.set(e,a)),a}fill(t){let n=this.fillMaterials.get(t);return n||(n=new bn({color:t,side:uo,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,e,a){const r=new Wo().setPositions(t),l=new qo(r,this.material(n,e));return l.matrixAutoUpdate=!1,l.matrix.copy(a),l.computeLineDistances(),l}screen(t,n,e,a){const r=this.lines(t,n,e,new X);return r.matrixAutoUpdate=!0,r.position.copy(a),r.scale.setScalar(0),r.frustumCulled=!1,this.onDraw(r,(l,c)=>this.face(r,l,c,!0)),r}facing(t,n,e){const a=this.lines(t,n,1,new X);return a.matrixAutoUpdate=!0,a.position.copy(e),this.onDraw(a,(r,l)=>this.face(a,r,l,!1)),a}onDraw(t,n){const e=t,a=e.onBeforeRender.bind(e);e.onBeforeRender=(r,l,c,u,f,s)=>{n(r,c),a(r,l,c,u,f,s)}}face(t,n,e,a){t.parent?.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let r=1;if(a){n.getSize(this.size);const l=Math.max(this.size.y,1),c=this.scratch.setFromMatrixPosition(t.matrixWorld);if(e.isOrthographicCamera){const u=e;r=(u.top-u.bottom)/u.zoom/l}else{const u=e;r=2*Math.max(-c.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(u.fov)/2)/u.zoom/l}}t.scale.setScalar(r),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 kn(o){const t=new x,n=new gt;return o.decompose(t,n,new x),new X().compose(t,n,new x(1,1,1))}const Lo=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],Ol=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Tl=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([o,t])=>[o*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([o,t])=>[o*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([o,t])=>[o*.02,t*.025])],rt=S().finite(),Vo=A({name:E(),type:E(),lens:rt,sensor_width:rt,sensor_height:rt,sensor_fit:W(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:rt,clip_start:rt,clip_end:rt,shift_x:rt,shift_y:rt,matrix:F($([rt,rt,rt,rt])).length(4),passepartout:rt.default(0),display_size:rt.default(1)}),Al={opening:.5,min:.1657359312880715,max:44.98528137423857},pn={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function Pl(o,t,n,e){const a=r=>Math.min(1,Math.max(-1,r));return[a(o[0]-n/(2*t)),a(o[1]+e/(2*t))]}function jo(o,t,n,e){const a=o.type==="ORTHO",r=o.sensor_fit==="VERTICAL"?o.sensor_height:o.sensor_width,l=o.sensor_fit==="AUTO"?t>=n:o.sensor_fit==="HORIZONTAL",c=(a?o.ortho_scale:r/o.lens)/2*e;return l?[c,c*n/t]:[c*t/n,c]}function Sl(o,t,n,e,a,r){const l=Math.max(n.width,1),c=Math.max(n.height,1),[u,f]=jo(o,l,c,1/e),[s,i]=jo(o,r,1,1),d=2*((o.sensor_fit==="AUTO"?r>=1:o.sensor_fit==="HORIZONTAL")?s:i),h=s/u,m=i/f,p=-2*a[0]*e,v=2*a[1]*e,g=o.shift_x*d-p*2*u,b=o.shift_y*d+v*2*f,w=new X().set(...o.matrix.flat()).premultiply(t),R=new x,T=new gt;return w.decompose(R,T,new x),{name:o.name,position:R.toArray(),quaternion:[T.x,T.y,T.z,T.w],projection:o.type==="ORTHO"?"orthographic":"perspective",window:{left:g-u,right:g+u,top:b+f,bottom:b-f},near:o.clip_start,far:o.clip_end,frame:{left:.5-h/2+p,top:.5-m/2+v,width:h,height:m},passepartout:{color:pn.passepartout,opacity:o.passepartout},border:{solid:pn.back,dashed:pn.overlay,locked:pn.redalert}}}const El={color:[.8,.8,.8,1],roughness:.5,metallic:0},Ml=`
|
|
7142
7142
|
uniform vec3 wbDir[4];
|
|
7143
7143
|
uniform vec3 wbDiffuse[4];
|
|
7144
7144
|
uniform vec3 wbSpecular[4];
|
|
@@ -7180,6 +7180,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
|
|
|
7180
7180
|
diffuseLight *= diffuseColor * (1.0 - specEnergy);
|
|
7181
7181
|
return diffuseLight + specularLight;
|
|
7182
7182
|
}
|
|
7183
|
-
`,co=o=>ro.map(t=>{const[n=0,e=0,a=0]=o(t);return new x(n,e,a)}),Nl=co(o=>o.direction).map(o=>o.normalize()),Rl=co(o=>o.diffuse),Il=co(o=>o.specular),Fl=new to(...ro.map(o=>o.smooth));function zl(o,t){const[n,e,a]=o.color,r=new
|
|
7183
|
+
`,co=o=>ro.map(t=>{const[n=0,e=0,a=0]=o(t);return new x(n,e,a)}),Nl=co(o=>o.direction).map(o=>o.normalize()),Rl=co(o=>o.diffuse),Il=co(o=>o.specular),Fl=new to(...ro.map(o=>o.smooth));function zl(o,t){const[n,e,a]=o.color,r=new Ge({side:t});return r.color.setRGB(n,e,a,ft),r.name="volter:blender-solid",r.onBeforeCompile=l=>{l.uniforms.wbDir={value:Nl},l.uniforms.wbDiffuse={value:Rl},l.uniforms.wbSpecular={value:Il},l.uniforms.wbWrap={value:Fl},l.uniforms.wbRoughness={value:o.roughness},l.uniforms.wbMetallic={value:o.metallic},l.fragmentShader=l.fragmentShader.replace("void main() {",`${Ml}
|
|
7184
7184
|
void main() {`).replace("#include <opaque_fragment>",`outgoingLight = volterWorkbenchLighting(diffuseColor.rgb, normal, isOrthographic ? vec3(0.0, 0.0, 1.0) : normalize(vViewPosition));
|
|
7185
|
-
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const Dl={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},I=S().finite(),be=$([I,I,I]),vn=$([S().int().nonnegative(),S().int().nonnegative()]),lt={name:E(),domain:W(["POINT","EDGE","FACE","CORNER"])},Cl=ca("type",[A({...lt,type:j("FLOAT2"),data:F($([I,I]))}).strict(),A({...lt,type:j("FLOAT_VECTOR"),data:F(be)}).strict(),A({...lt,type:j("FLOAT_COLOR"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("BYTE_COLOR"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("QUATERNION"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("FLOAT4"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("FLOAT4X4"),data:F(F(I).length(16))}).strict(),A({...lt,type:j("INT16_2D"),data:F($([S().int(),S().int()]))}).strict(),A({...lt,type:j("INT32_2D"),data:F($([S().int(),S().int()]))}).strict(),A({...lt,type:j("FLOAT"),data:F(I)}).strict(),A({...lt,type:j("INT"),data:F(S().int())}).strict(),A({...lt,type:j("INT8"),data:F(S().int())}).strict(),A({...lt,type:j("BOOLEAN"),data:F(q())}).strict(),A({...lt,type:j("STRING"),data:F(E())}).strict()]),kl=A({positions:B(Float32Array),normals:B(Float32Array).nullable(),uv:B(Float32Array).nullable(),uvLayers:F(A({name:E(),data:B(Float32Array)}).strict()).optional(),attributeLayers:F(A({name:E(),data:B(Float32Array)}).strict()).optional(),orco:B(Float32Array).nullable().optional(),indices:B(Uint32Array),groups:F(A({start:S().int().nonnegative(),count:S().int().nonnegative(),materialIndex:S().int().nonnegative()}).strict()),hash:E()}).strict(),$l=A({v:F(be),f:F(F(S().int().nonnegative())),e:F(vn).optional(),edge_order:F(vn).optional(),m:F(S().int().nonnegative()).optional(),s:F(q()).optional(),sharp:F(vn).optional(),seams:F(vn).optional(),creases:F($([I,I,I])).optional(),attributes:F(Cl).optional(),active_uv:E().nullable().optional(),render_uv:E().nullable().optional()}).strict(),Ll=A({store:S().int().optional(),revision:S().int(),unchanged:j(!0)}).strict(),Vl=A({co:B(Float64Array),cornerNormal:B(Float32Array).optional(),orco:B(Float32Array).optional(),faceStart:B(Uint32Array),corner:B(Uint32Array),cornerEdge:B(Int32Array),edge:B(Uint32Array),edgeSharp:B(Uint8Array),edgeSeam:B(Uint8Array),edgeCrease:B(Float32Array),material:B(Uint32Array),smooth:B(Uint8Array),vertSelect:B(Uint8Array),vertHide:B(Uint8Array),edgeSelect:B(Uint8Array),edgeHide:B(Uint8Array),faceSelect:B(Uint8Array),faceHide:B(Uint8Array)}).strict(),jl=A({name:E(),domain:W(["POINT","EDGE","FACE","CORNER"]),type:E(),data:ua(o=>ArrayBuffer.isView(o))}).strict(),Bl=A({columns:Vl,attributes:F(jl),activeUv:E().nullable(),renderUv:E().nullable(),counts:A({verts:S().int().nonnegative(),edges:S().int().nonnegative(),faces:S().int().nonnegative(),corners:S().int().nonnegative()}).strict(),revision:S().int().nonnegative()}).strict(),Ul=jt([kl,Bl,$l,Ll]),jo=new Set;function Wl(o){const t=new Blob([o],{type:"image/png"}),n=new Je;let e=!1;n.addEventListener("dispose",()=>{e=!0,n.image?.close?.()});const a=createImageBitmap(t,{imageOrientation:"flipY",premultiplyAlpha:"none"}).then(r=>{if(e){r.close();return}n.image=r,n.needsUpdate=!0,vt()}).finally(()=>{jo.delete(a)});return jo.add(a),a.catch(()=>{}),{texture:n,ready:a}}function Hl(o,t,n,e){const a=new An(o,t,n,Pn,Ke);return a.flipY=!1,a.colorSpace=e==="data"?oo:Mt,a.needsUpdate=!0,a}function ql(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(s=>s.width)),a=Math.max(...t.map(s=>s.height)),r=new Uint8Array(e*a*4*t.length),l=Math.max(...t.map(s=>s.number-1001))+1,c=new Float32Array(l*2*4);for(let s=0;s<l;s++)c[s*4]=-1;t.forEach((s,i)=>{const _=s.rgba??(s.rgbaBase64?Wn(s.rgbaBase64):void 0);if(!_)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let h=0;h<s.height;h++)r.set(_.subarray(h*s.width*4,(h+1)*s.width*4),(i*a+h)*e*4);const d=s.number-1001;c[d*4]=i,c.set([0,0,s.width/e,s.height/a],(l+d)*4)});const u=new Qe(r,e,a,t.length);u.colorSpace=n==="data"?oo:Mt,u.magFilter=Lt,u.minFilter=Jo,u.generateMipmaps=!0,u.needsUpdate=!0;const f=new An(c,l,2,Pn,Yo);return f.magFilter=f.minFilter=Bn,f.needsUpdate=!0,{tiles:u,map:f,frame:t}}const Gl=A({width:S().int().positive(),height:S().int().positive(),revision:S().int().nonnegative(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional(),colorspace:W(["sRGB","data"]).optional(),tiles:F(A({number:S().int().min(1001),width:S().int().positive(),height:S().int().positive(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional()}).strict()).optional()}).strict(),Xl=A({revision:S().int().nonnegative(),png:B(Uint8Array).optional(),pngBase64:E().optional()}).strict(),Yl=jt([Gl,Xl]),$n=A({image:A({name:E(),revision:S().int().nonnegative()}).strict(),extension:W(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:E(),tint:$([I,I,I]).optional()}).strict(),Zl=A({name:E(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:ol.optional(),normal_texture:$n.optional(),normal_strength:I.default(1),normal_space:W(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:$n.optional(),roughness_texture:$n.optional(),emission:A({color:$([I,I,I]),strength:I}).strict().optional(),graph:Nr.optional(),viewport:A({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Ql=A({session:E(),revision:S().int().nonnegative(),volumes:_t(E(),me).default({}),lights:_t(E(),mr).default({}),world:yr.nullable().default(null),meshes:_t(E(),Ul),materials:_t(E(),Zl),images:_t(E(),Yl).default({}),objects:F(A({id:E(),name:E(),type:W(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:E().nullable(),volume:E().nullable().optional(),light:E().nullable().optional(),materials:F(E().nullable()),matrix:F($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:E().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:E().optional()}).strict()),active:E().nullable(),mode:E(),cameras:_t(E(),_t(E(),ne())).default({}),warnings:F(E()).default([]),updated:F(E()).default([]),frame:S().int().default(0),armatures:_t(E(),ha).default({}),weights:sl.nullable().default(null),cursor:ml.optional(),camera_view:A({scene_camera:E().nullable(),view_layer_cameras:F(E()),aspect:S().finite().positive()}).optional(),light_distances:_t(E(),$([S().finite(),S().finite()])).default({}),empties:_t(E(),xl).default({}),view:A({location:$([S(),S(),S()]),rotation:$([S(),S(),S(),S()]),distance:S().finite(),perspective:W(["PERSP","ORTHO","CAMERA"]),lens:S().finite().positive().default(50),shading:W(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:A({frame:S().int(),body:E(),markers:F($([S().int(),E()]))}).optional(),units:A({system:W(["NONE","METRIC","IMPERIAL"]),scale_length:S().finite()}).optional()}).strict();function Kl(o,t){for(let n=0,e=o.length-1;n<o.length&&e>=0;n++,e--){if(o[n][0]===t)return o[n][1];if(n===e)break;if(o[e][0]===t)return o[e][1]}return null}const Jl={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 Tn{constructor(){this.root=new ot,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new br,this.world=new lo,this.armatureOverlay=new Pa,this.weightOverlay=new _l,this.cursorOverlay=new gl,this.extrasOverlay=new wl,this.armatureRoot=new ot,this.weightRoot=new ot,this.cursorRoot=new ot,this.cameraExtrasRoot=new ot,this.lightExtrasRoot=new ot,this.emptyExtrasRoot=new ot,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 ln({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new nl,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=Al,this.cameraViewPan=Pl,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,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[t,n]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]])t.matrixAutoUpdate=!1,t.matrix.copy(this.root.matrix),t.add(n),t.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const t of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])t.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let e=this.graphs.get(n);return e||(e=Wr(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[r,l]of this.objects)if(l===t){n=r;break}if(n===null)return;const e=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let a=!1;for(const r of e){if(r===this)continue;const l=r.objects.get(n);l!==void 0&&(l.matrix.copy(t.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.updateMatrixWorld(!0),a=!0)}a&&vt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=ma(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(a=>a.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,a,r]=t.rotation,l=new gt(e,a,r,n),c=new x(...t.location).applyMatrix4(this.root.matrix),u=f=>f.applyQuaternion(l).applyMatrix4(this.root.matrix).normalize();return{target:c.toArray(),direction:u(new x(0,0,1)).toArray(),up:u(new x(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?Dl[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new X().copy(this.root.matrix).invert(),a=new X().compose(new x(...t),new gt(...n),new x(1,1,1)).premultiply(e),r=new x,l=new gt;return a.decompose(r,l,new x),{location:r.toArray(),rotation:[l.w,l.x,l.y,l.z]}}cameraView(t,n,e,a){const r=this.frame,l=Lo.safeParse(r?.cameras[t]);return!r?.camera_view||!l.success?null:Sl(l.data,this.root.matrix,n,e,a,r.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const e=t??n.frame,a=Kl(n.markers,e);return`(${e})${n.body}${a===null?"":` <${a}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const e=Jl[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([c])=>c*r>a)??e[e.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(e=>e.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[e,a]of this.objects)if(a===t){const r=t.parent,l=[...t.children];t.removeFromParent();for(const c of l)n.add(c);r?.add(n),this.objects.set(e,n);return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,e){const a=new Set(this.objects.values()),r=this.cursorOverlay.placementAt(t,n,e,this.root,l=>a.has(l));return r!==null&&(this.cursorOverlay.show(r),vt()),r}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 e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(a=>a.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(vt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),vt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const a=this.objects.get(e.id);if(!a?.isMesh)continue;const l=(e.materials.length?e.materials:[null]).map(c=>{const u=c===null?this.fallback:this.materials.get(c)??this.fallback;return t?this.workbenchFor(c,u.side,n):u});a.material=e.materials.length?l:l[0]}for(const[e,a]of this.workbenchMaterials)n.has(e)||(a.dispose(),this.workbenchMaterials.delete(e))}workbenchFor(t,n,e){const a=(t!==null?this.frame?.materials[t]?.viewport:void 0)??El,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let l=this.workbenchMaterials.get(r);return l||(l=zl(a,n),this.workbenchMaterials.set(r,l)),l}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Do(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])al(r,e);this.rendered=t,this.lighting.setRendered(t);const a=t&&n?this.worldKeyFor(n):null;t?(this.capturing||a!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:a,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await hr(),await Promise.all([...this.textures.values()].map(r=>r.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const e=[];for(const u of this.objects.values()){const f=u;if(f.isMesh&&(f.castShadow=t,f.receiveShadow=t,t&&f.visible)){const s=new yn().setFromObject(f);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,f)=>u.union(f),new yn).getBoundingSphere(new Ge),l=n?new Xe().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,c=l?e.flatMap(u=>Tr(u,l)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Ar(u,c,e):gr(u,r.center,r.radius)}applyOverlays(t){const n=l=>{const c=t.objects.find(u=>u.name===l);return c===void 0?null:new X().set(...c.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],a=t.weights?this.objects.get(t.objects.find(l=>l.name===t.weights?.object)?.id??""):void 0,r=this.weightOverlay.apply(t.weights,a??null,t.weights?n(t.weights.object):null);return r!==null&&e.push(r),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),e}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),vt())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=Lo.safeParse(a);r.success&&(n[e]=r.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(e=>e.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:e=>{const a=t.objects.find(r=>r.name===e);return a?this.objects.get(a.id)??null:null},image:e=>{const a=this.textures.get(e);if(!a)return null;const r=a.texture.image,l=a.width||r?.width||0,c=a.height||r?.height||0;return(l===0||c===0)&&a.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),a.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),vt()},()=>this.awaitedImages.delete(e))),{texture:a.texture,width:l,height:c}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const e=this.lights.get(t.light);e&&(e.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}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=Ql.parse(t);if(this.retiredSessions.has(e.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===e.session&&e.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const a=new Set(e.objects.map(f=>f.id));if(a.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const r=new Map(e.objects.map(f=>[f.id,f]));for(const f of e.objects){if(f.mesh!==null&&!e.meshes[f.mesh])throw new Error(`Missing runtime mesh ${f.mesh}`);if(f.volume&&(!e.volumes[f.volume]||f.mesh!==null))throw new Error(`Invalid runtime volume ${f.volume}`);if(f.light&&(!e.lights[f.light]||f.mesh!==null))throw new Error(`Invalid runtime light ${f.light}`);for(const _ of f.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const s=new Set([f.id]);let i=f.parent;for(;i!==null;){if(s.has(i))throw new Error("Runtime parent cycle");s.add(i);const _=r.get(i);if(!_)throw new Error(`Missing runtime parent ${i}`);i=_.parent}}const l=new Map,c=new Map;try{for(const[f,s]of Object.entries(e.volumes)){const i=JSON.stringify(s);this.frame?.session===e.session&&this.volumes.get(f)?.signature===i||c.set(f,{signature:i,mesh:Pr(s)})}for(const[f,s]of Object.entries(e.meshes)){if("unchanged"in s){if(this.frame?.session===e.session&&this.meshes.has(f))continue;throw new Error(`${Sa}: the presenter does not hold runtime mesh ${f} (store ${s.store}, revision ${s.revision})`)}const i="hash"in s,_="columns"in s,d=_?`revision:${s.revision}`:i?s.hash:JSON.stringify(s);this.frame?.session===e.session&&this.meshes.get(f)?.signature===d||l.set(f,{signature:d,geometry:_?Hn(La({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},d)):i?Hn(s):Va(s)})}}catch(f){for(const s of l.values())s.geometry.dispose();for(const{mesh:s}of c.values())s.geometry.dispose(),s.material.dispose();throw f}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[f,s]of c){const i=this.volumes.get(f)?.mesh;i&&(i.removeFromParent(),i.geometry.dispose(),i.material.dispose()),this.volumes.set(f,s)}for(const[f,s]of l)this.meshes.get(f)?.geometry.dispose(),this.meshes.set(f,s),this.geometryBuilds++;for(const[f,s]of Object.entries(e.images)){const i=this.textures.get(f);if("width"in s){const m=s.rgba??(s.rgbaBase64?Wn(s.rgbaBase64):void 0);if(!m)throw new Error(`Runtime image ${f} carries no raster`);const p=s.tiles?ql(f,s.tiles,s.colorspace??"sRGB"):void 0;if(i?.udim&&(i.udim.tiles.dispose(),i.udim.map.dispose(),delete i.udim),i&&i.width===s.width&&i.height===s.height){const v=i.texture.image;if(v.data){v.data.set(m),i.texture.needsUpdate=!0,i.revision=s.revision,p&&(i.udim=p);continue}}i?.texture.dispose(),this.textures.set(f,{texture:Hl(m,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...p?{udim:p}:{}});continue}const _=s.png??(s.pngBase64?Wn(s.pngBase64):void 0);if(!_)throw new Error(`Runtime image ${f} carries no bytes`);i?.texture.dispose(),i?.udim?.tiles.dispose(),i?.udim?.map.dispose();const{texture:d,ready:h}=Wl(_);d.colorSpace=Mt,this.textures.set(f,{texture:d,ready:h,width:0,height:0,revision:s.revision,png:_.slice()})}for(const[f,s]of Object.entries(e.materials)){const i=this.materials.get(f)??new ln;i.name=s.name;const _=s.texture?.tint;s.texture!==void 0?i.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):i.color.setRGB(s.color[0],s.color[1],s.color[2],ft),i.opacity=s.color[3];const d=i.opacity<1||s.graph!==void 0&&Rr(s.graph);i.transparent!==d&&(i.transparent=d,i.needsUpdate=!0),i.roughness=s.roughness,i.metalness=s.metallic,i.transmission=s.transmission,i.ior=s.ior,so(i,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const h=s.normal_texture?.image.name;if(h===void 0)i.normalMap&&(this.textureSamplers.delete(`${f}:normal`),i.normalMap=null,i.needsUpdate=!0);else{const b=this.textures.get(h);if(!b)throw new Error(`${Qt}: missing normal image ${h}`);const w=this.textureSamplers.get(`${f}:normal`,b.texture,s.normal_texture.extension,b.ready,s.normal_texture.uv);i.normalMap!==w&&(i.normalMap=w,i.needsUpdate=!0);const R=s.normal_space==="OBJECT"?Ye:Ze;i.normalMapType!==R&&(i.normalMapType=R,i.needsUpdate=!0),i.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(i.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],ft),i.emissiveIntensity=s.emission.strength):(i.emissive.setRGB(0,0,0),i.emissiveIntensity=1);const m=s.roughness_texture?.image.name??null;if(m===null)this.roughnessTextureNames.has(f)&&(this.textureSamplers.delete(`${f}:roughness`),i.roughnessMap=null,this.roughnessTextureNames.delete(f),i.needsUpdate=!0);else{const b=this.textures.get(m);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${m} (revision ${s.roughness_texture.image.revision})`);const w=this.textureSamplers.get(`${f}:roughness`,b.texture,s.roughness_texture.extension,b.ready,s.roughness_texture.uv);i.roughnessMap!==w&&(i.roughnessMap=w,this.roughnessTextureNames.set(f,m),i.needsUpdate=!0)}const p=s.texture?.image.name??null;if(p===null)this.textureNames.has(f)&&(this.textureSamplers.delete(`${f}:color`),i.map=null,this.textureNames.delete(f),i.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${p} (revision ${s.texture.image.revision})`);const w=this.textureSamplers.get(`${f}:color`,b.texture,s.texture.extension,b.ready,s.texture.uv);i.map!==w&&(i.map=w,this.textureNames.set(f,p),i.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,g=new Set;qr(i,v,b=>{const w=this.textures.get(b.name);if(!w)throw new Error(`${Qt}: the presenter does not hold runtime image ${b.name} (revision ${b.revision})`);if(b.tiled){if(!w.udim)throw new Error(`${Qt}: runtime image ${b.name} arrived without its UDIM tiles`);return w.udim}const R=`${f}:graph:${b.node}`;g.add(R);const T=this.textureSamplers.get(R,w.texture,b.extension,w.ready),P=b.closest?Bn:Lt,O=b.closest?Bn:b.mipmap?Jo:Lt;return(T.magFilter!==P||T.minFilter!==O)&&(T.magFilter=P,T.minFilter=O,T.needsUpdate=!0),T},this.photograph);for(const b of this.graphSamplers.get(f)??[])g.has(b)||this.textureSamplers.delete(b);this.graphSamplers.set(f,g),this.materials.set(f,i)}for(const f of e.objects){let s=this.objects.get(f.id);const i=f.volume?this.volumes.get(f.volume).mesh:null;if((!s||(i?s!==i:!!s.isMesh!=(f.mesh!==null)))&&(s?.removeFromParent(),s=i??(f.mesh!==null?new Tt(this.meshes.get(f.mesh).geometry,this.fallback):new Go),this.objects.set(f.id,s)),s.name=f.name,f.type==="CAMERA"||f.type==="LIGHT"||f.type==="EMPTY"?s.userData.volterOwnOverlay=!0:delete s.userData.volterOwnOverlay,s.matrixAutoUpdate=!1,s.matrix.set(...f.matrix.flat()),f.parent){const _=new X().set(...r.get(f.parent).matrix.flat());s.matrix.premultiply(_.invert())}if(s.matrix.decompose(s.position,s.quaternion,s.scale),f.texspace?s.userData.blenderTexspace=f.texspace:delete s.userData.blenderTexspace,f.default_color!==void 0?s.userData.blenderDefaultColor=f.default_color:delete s.userData.blenderDefaultColor,f.mesh!==null){const _=s;_.geometry=this.meshes.get(f.mesh).geometry,_.material=f.materials.length?f.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,Zr(_)}if(f.light){const _=this.lights.get(f.light)??null,d=vr(e.lights[f.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==s&&s.add(d),d.userData.volterOwnOverlay=!0,xr(d,s),this.lights.set(f.light,d)}}for(const f of e.objects){const s=this.objects.get(f.id),i=f.parent===null?this.root:this.objects.get(f.parent);s.parent!==i&&i.add(s)}for(const[f,s]of this.objects)a.has(f)||(s.removeFromParent(),this.objects.delete(f));for(const[f,s]of this.volumes)e.volumes[f]||(s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.volumes.delete(f));for(const[f,s]of this.meshes)e.meshes[f]||(s.geometry.dispose(),this.meshes.delete(f));for(const[f,s]of this.materials)if(!e.materials[f]){for(const i of["normal","roughness","color"])this.textureSamplers.delete(`${f}:${i}`);for(const i of this.graphSamplers.get(f)??[])this.textureSamplers.delete(i);this.graphSamplers.delete(f),s.dispose(),this.materials.delete(f)}for(const[f,s]of this.lights)e.lights[f]||(s.removeFromParent(),s.dispose(),this.lights.delete(f));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{}},this.worldKey=JSON.stringify(e.world??null);const u=this.applyOverlays(e);u.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...u]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const f of[...this.frameListeners])f();for(const f of this.followers)try{f.applyFrame(t)}catch{f.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[a,{signature:r,geometry:l}]of this.meshes){const c=s=>{const i=l.getAttribute(s);if(!i)return null;if(!(i instanceof it))throw new Error(`Blender capture cannot copy interleaved ${s}`);return new Float32Array(i.array)},u=c("position");if(!u)throw new Error(`Blender capture mesh ${a} has no positions`);const f=l.getIndex();n.meshes[a]={hash:r,positions:u,normals:c("normal"),uv:c("uv"),uvLayers:Object.entries(l.userData.blenderUvChannels??{}).map(([s,i])=>{const _=c(`uv${i}`);if(!_)throw new Error(`Blender capture mesh ${a} is missing UV layer ${s}`);return{name:s,data:_}}),orco:l.userData.blenderOrcoFromDoor?c("blenderOrco"):null,attributeLayers:(l.userData.blenderAttributes??[]).map(s=>{const i=c(Vt(s));if(!i)throw new Error(`Blender capture mesh ${a} is missing attribute ${s}`);return{name:s,data:i}}),indices:f?new Uint32Array(f.array):Uint32Array.from({length:u.length/3},(s,i)=>i),groups:l.groups.map(s=>({start:s.start,count:s.count,materialIndex:s.materialIndex??0}))}}for(const[a,{signature:r}]of this.volumes)n.volumes[a]=me.parse(JSON.parse(r));const e=new Set(Object.values(n.materials).flatMap(a=>[a.texture?.image.name,a.roughness_texture?.image.name,a.normal_texture?.image.name,...Object.values(a.graph?.nodes??{}).map(r=>r.props.image?.name)].filter(r=>r!==void 0)));for(const a of e){const r=this.textures.get(a);if(!r)throw new Error(`Blender capture image ${a} is not resident`);if(r.png)n.images[a]={revision:r.revision,png:r.png.slice()};else{const l=r.texture.image?.data;if(!(l instanceof Uint8Array))throw new Error(`Blender capture image ${a} has no resident raster`);n.images[a]={revision:r.revision,width:r.width,height:r.height,rgba:l.slice(),colorspace:r.texture.colorSpace===oo?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Tn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,e=this.createWorldVolumePass(),a=new Tn;a.photograph=!0;let r=!1;const l=()=>{r||(r=!0,e?.dispose(),a.dispose(),a.root.removeFromParent())};try{a.applyFrame(t),this.root.updateWorldMatrix(!0,!1),a.root.matrix.copy(this.root.matrixWorld),a.root.updateMatrixWorld(!0)}catch(c){throw l(),c}return{effect:e,root:a.root,session:n.session,revision:n.revision,prepare:c=>{if(r)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,c)},dispose:l}}createWorldVolumePass(){const t=Do(this.frame?.world);return t?new il(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const a=typeof n.session=="string"?n.session:null;a!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=a);const r=e;for(const[l,c]of Object.entries(r))typeof c=="object"&&c!==null&&!("unchanged"in c)&&this.submittedMeshes.set(l,c);for(const l of[...this.submittedMeshes.keys()])l in r||this.submittedMeshes.delete(l);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const si=new Tn;function ye(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Ln(o){const t=ye(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function ti(o){const t=ye(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ni(o){return new X().set(...o.flat())}function Bo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class oi{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,a=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:a,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((r,l)=>r+l.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:this.#i!==null?this.#i:t.clipStart+this.#a.time*t.fps}get playable(){return this.#a!==null}async bind(t,n){this.#r++;const e=await n.rig();if(!e)return;const a=[],r=new Set;let l=!1;for(const i of e.rigs){if(!i.object||!i.armature||!i.skinIndexBase64||!i.skinWeightBase64){i.reason&&a.push(i.reason);continue}r.add(i.object);const _=Bo(i,e.frame);if(this.#n.get(i.object)?.signature===_)continue;const d=this.#d(t,i,e.frame,a);d&&(this.#n.get(i.object)?.skeleton.dispose(),this.#n.set(i.object,d),l=!0)}for(const[i,_]of[...this.#n])r.has(i)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(i),l=!0);this.#r++;const c=await n.clip(),u=this.#t,f=c?.action!==u?.action||c?.tracks.length!==u?.tracks.length||c?.clipStart!==u?.clipStart||c?.clipEnd!==u?.clipEnd;this.#t=c??null,c?.reason&&a.push(c.reason),c&&(f||l)&&this.#h(t,c,a);const s=this.#e?.snapshot().playbackState==="playing";c&&!s&&u?.frameCurrent!==c.frameCurrent&&(this.#c(c.frameCurrent),this.#e&&c.fps>0&&this.#e.seek(c.frameCurrent/c.fps)),this.#_=a,this.#f()}#d(t,n,e,a){const r=t.objectForBlenderName(n.object??""),l=t.objectForBlenderName(n.armature??"");if(!r||!l)return null;const c=r,u=c.geometry;if(!u)return null;const f=u.getAttribute("blenderVertex");if(!f)return a.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let s=0;for(let T=0;T<f.count;T++)s=Math.max(s,f.getX(T));if(s>=n.vertexCount)return a.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${s} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const i=ti(n.skinIndexBase64??""),_=Ln(n.skinWeightBase64??""),d=f.count,h=new Uint16Array(d*4),m=new Float32Array(d*4);for(let T=0;T<d;T++){const P=f.getX(T);for(let O=0;O<4;O++)h[T*4+O]=i[P*4+O]??0,m[T*4+O]=_[P*4+O]??0}u.setAttribute("skinIndex",new ta(h,4)),u.setAttribute("skinWeight",new bt(m,4));const p=new ot;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ni(T.pose)),b=new Map(n.bones.map((T,P)=>[T.name,P]));n.bones.forEach((T,P)=>{const O=new na;O.name=T.name,v.push(O);const M=T.parent===null?void 0:b.get(T.parent);(M===void 0?g[P].clone():g[M].clone().invert().multiply(g[P])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),l.add(p);const w=new oa(u,c.material);w.name=c.name,w.matrixAutoUpdate=!1,w.matrix.copy(c.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=c.userData,w.frustumCulled=!1,t.replacePresentedObject(c,w),t.root.updateMatrixWorld(!0);const R=new ea(v);return w.bind(R,w.matrixWorld.clone()),n.constrainedBones?.length&&a.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&a.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:w,boneRoot:p,bones:v,skeleton:R,frame:e,signature:Bo(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const a=n.armature?t.objectForBlenderName(n.armature):null;if(!a)return;const r=new Map;for(const i of this.#n.values())if(i.armature===n.armature)for(const _ of i.bones)r.set(_.name,_);const l=[],c=new Set;for(const i of n.tracks){const _=r.get(i.bone);if(!_){c.add(i.bone);continue}const d=Ln(i.timeBase64),h=Ln(i.valueBase64),m=`${_.uuid}.${i.property}`;l.push(i.property==="quaternion"?new aa(m,Array.from(d),Array.from(h)):new ra(m,Array.from(d),Array.from(h)))}if(c.size&&e.push(`${n.action} animates ${[...c].join(", ")}, which this binding has no bone for.`),!l.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,f=new la(a),s=f.clipAction(new ia(n.action??"action",u,l));s.setLoop(sa,Number.POSITIVE_INFINITY),s.play(),this.#o=f,this.#a=s,this.#c(n.frameCurrent),this.#m()}#c(t){const n=this.#t;if(!n||!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const e=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#i=e;const a=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.min(a-1e-4,(e-n.clipStart)/n.fps)),this.#m()}#m(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const e=n.scene;return!e||n.frameCurrent===t||(this.#r++,await _a(`bpy.data.scenes[${JSON.stringify(e)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const l=this.#t,c=l?.fps||24;return{start:(l?.frameStart??1)/c,end:(l?.frameEnd??250)/c,fps:c}},seek:l=>this.seekSeconds(l)}),e=t.onSettled(()=>{this.writeBookmark()}),a=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#l=null};this.#l=a;const r=this.#t;return r&&r.fps>0&&t.seek(r.frameCurrent/r.fps),a}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#l?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const we=new oi;function fi(o){return we.subscribe(o)}function ci(){return we.version}export{we as a,ci as b,si as c,fi as s};
|
|
7185
|
+
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const Dl={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},I=S().finite(),ye=$([I,I,I]),vn=$([S().int().nonnegative(),S().int().nonnegative()]),lt={name:E(),domain:W(["POINT","EDGE","FACE","CORNER"])},Cl=ua("type",[A({...lt,type:j("FLOAT2"),data:F($([I,I]))}).strict(),A({...lt,type:j("FLOAT_VECTOR"),data:F(ye)}).strict(),A({...lt,type:j("FLOAT_COLOR"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("BYTE_COLOR"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("QUATERNION"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("FLOAT4"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("FLOAT4X4"),data:F(F(I).length(16))}).strict(),A({...lt,type:j("INT16_2D"),data:F($([S().int(),S().int()]))}).strict(),A({...lt,type:j("INT32_2D"),data:F($([S().int(),S().int()]))}).strict(),A({...lt,type:j("FLOAT"),data:F(I)}).strict(),A({...lt,type:j("INT"),data:F(S().int())}).strict(),A({...lt,type:j("INT8"),data:F(S().int())}).strict(),A({...lt,type:j("BOOLEAN"),data:F(q())}).strict(),A({...lt,type:j("STRING"),data:F(E())}).strict()]),kl=A({positions:B(Float32Array),normals:B(Float32Array).nullable(),uv:B(Float32Array).nullable(),uvLayers:F(A({name:E(),data:B(Float32Array)}).strict()).optional(),attributeLayers:F(A({name:E(),data:B(Float32Array)}).strict()).optional(),orco:B(Float32Array).nullable().optional(),indices:B(Uint32Array),groups:F(A({start:S().int().nonnegative(),count:S().int().nonnegative(),materialIndex:S().int().nonnegative()}).strict()),hash:E()}).strict(),$l=A({v:F(ye),f:F(F(S().int().nonnegative())),e:F(vn).optional(),edge_order:F(vn).optional(),m:F(S().int().nonnegative()).optional(),s:F(q()).optional(),sharp:F(vn).optional(),seams:F(vn).optional(),creases:F($([I,I,I])).optional(),attributes:F(Cl).optional(),active_uv:E().nullable().optional(),render_uv:E().nullable().optional()}).strict(),Ll=A({store:S().int().optional(),revision:S().int(),unchanged:j(!0)}).strict(),Vl=A({co:B(Float64Array),cornerNormal:B(Float32Array).optional(),orco:B(Float32Array).optional(),faceStart:B(Uint32Array),corner:B(Uint32Array),cornerEdge:B(Int32Array),edge:B(Uint32Array),edgeSharp:B(Uint8Array),edgeSeam:B(Uint8Array),edgeCrease:B(Float32Array),material:B(Uint32Array),smooth:B(Uint8Array),vertSelect:B(Uint8Array),vertHide:B(Uint8Array),edgeSelect:B(Uint8Array),edgeHide:B(Uint8Array),faceSelect:B(Uint8Array),faceHide:B(Uint8Array)}).strict(),jl=A({name:E(),domain:W(["POINT","EDGE","FACE","CORNER"]),type:E(),data:_a(o=>ArrayBuffer.isView(o))}).strict(),Bl=A({columns:Vl,attributes:F(jl),activeUv:E().nullable(),renderUv:E().nullable(),counts:A({verts:S().int().nonnegative(),edges:S().int().nonnegative(),faces:S().int().nonnegative(),corners:S().int().nonnegative()}).strict(),revision:S().int().nonnegative()}).strict(),Ul=jt([kl,Bl,$l,Ll]),Bo=new Set;function Wl(o){const t=new Blob([o],{type:"image/png"}),n=new ta;let e=!1;n.addEventListener("dispose",()=>{e=!0,n.image?.close?.()});const a=createImageBitmap(t,{imageOrientation:"flipY",premultiplyAlpha:"none"}).then(r=>{if(e){r.close();return}n.image=r,n.needsUpdate=!0,vt()}).finally(()=>{Bo.delete(a)});return Bo.add(a),a.catch(()=>{}),{texture:n,ready:a}}function Hl(o,t,n,e){const a=new An(o,t,n,Pn,Je);return a.flipY=!1,a.colorSpace=e==="data"?oo:Mt,a.needsUpdate=!0,a}function ql(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(s=>s.width)),a=Math.max(...t.map(s=>s.height)),r=new Uint8Array(e*a*4*t.length),l=Math.max(...t.map(s=>s.number-1001))+1,c=new Float32Array(l*2*4);for(let s=0;s<l;s++)c[s*4]=-1;t.forEach((s,i)=>{const _=s.rgba??(s.rgbaBase64?Wn(s.rgbaBase64):void 0);if(!_)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let h=0;h<s.height;h++)r.set(_.subarray(h*s.width*4,(h+1)*s.width*4),(i*a+h)*e*4);const d=s.number-1001;c[d*4]=i,c.set([0,0,s.width/e,s.height/a],(l+d)*4)});const u=new Ke(r,e,a,t.length);u.colorSpace=n==="data"?oo:Mt,u.magFilter=Lt,u.minFilter=te,u.generateMipmaps=!0,u.needsUpdate=!0;const f=new An(c,l,2,Pn,Zo);return f.magFilter=f.minFilter=Bn,f.needsUpdate=!0,{tiles:u,map:f,frame:t}}const Gl=A({width:S().int().positive(),height:S().int().positive(),revision:S().int().nonnegative(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional(),colorspace:W(["sRGB","data"]).optional(),tiles:F(A({number:S().int().min(1001),width:S().int().positive(),height:S().int().positive(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional()}).strict()).optional()}).strict(),Xl=A({revision:S().int().nonnegative(),png:B(Uint8Array).optional(),pngBase64:E().optional()}).strict(),Yl=jt([Gl,Xl]),$n=A({image:A({name:E(),revision:S().int().nonnegative()}).strict(),extension:W(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:E(),tint:$([I,I,I]).optional()}).strict(),Zl=A({name:E(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:ol.optional(),normal_texture:$n.optional(),normal_strength:I.default(1),normal_space:W(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:$n.optional(),roughness_texture:$n.optional(),emission:A({color:$([I,I,I]),strength:I}).strict().optional(),graph:Nr.optional(),viewport:A({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Ql=A({session:E(),revision:S().int().nonnegative(),volumes:_t(E(),de).default({}),lights:_t(E(),mr).default({}),world:yr.nullable().default(null),meshes:_t(E(),Ul),materials:_t(E(),Zl),images:_t(E(),Yl).default({}),objects:F(A({id:E(),name:E(),type:W(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:E().nullable(),volume:E().nullable().optional(),light:E().nullable().optional(),materials:F(E().nullable()),matrix:F($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:E().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:E().optional()}).strict()),active:E().nullable(),mode:E(),cameras:_t(E(),_t(E(),oe())).default({}),warnings:F(E()).default([]),updated:F(E()).default([]),frame:S().int().default(0),armatures:_t(E(),pa).default({}),weights:sl.nullable().default(null),cursor:ml.optional(),camera_view:A({scene_camera:E().nullable(),view_layer_cameras:F(E()),aspect:S().finite().positive()}).optional(),light_distances:_t(E(),$([S().finite(),S().finite()])).default({}),empties:_t(E(),xl).default({}),view:A({location:$([S(),S(),S()]),rotation:$([S(),S(),S(),S()]),distance:S().finite(),perspective:W(["PERSP","ORTHO","CAMERA"]),lens:S().finite().positive().default(50),shading:W(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:A({frame:S().int(),body:E(),markers:F($([S().int(),E()]))}).optional(),units:A({system:W(["NONE","METRIC","IMPERIAL"]),scale_length:S().finite()}).optional()}).strict();function Kl(o,t){for(let n=0,e=o.length-1;n<o.length&&e>=0;n++,e--){if(o[n][0]===t)return o[n][1];if(n===e)break;if(o[e][0]===t)return o[e][1]}return null}const Jl={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 Tn{constructor(){this.root=new ot,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new br,this.world=new lo,this.armatureOverlay=new Sa,this.weightOverlay=new _l,this.cursorOverlay=new gl,this.extrasOverlay=new wl,this.armatureRoot=new ot,this.weightRoot=new ot,this.cursorRoot=new ot,this.cameraExtrasRoot=new ot,this.lightExtrasRoot=new ot,this.emptyExtrasRoot=new ot,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 ln({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new nl,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=Al,this.cameraViewPan=Pl,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,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[t,n]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]])t.matrixAutoUpdate=!1,t.matrix.copy(this.root.matrix),t.add(n),t.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const t of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])t.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let e=this.graphs.get(n);return e||(e=Wr(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[r,l]of this.objects)if(l===t){n=r;break}if(n===null)return;const e=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let a=!1;for(const r of e){if(r===this)continue;const l=r.objects.get(n);l!==void 0&&(l.matrix.copy(t.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.updateMatrixWorld(!0),a=!0)}a&&vt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=da(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(a=>a.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,a,r]=t.rotation,l=new gt(e,a,r,n),c=new x(...t.location).applyMatrix4(this.root.matrix),u=f=>f.applyQuaternion(l).applyMatrix4(this.root.matrix).normalize();return{target:c.toArray(),direction:u(new x(0,0,1)).toArray(),up:u(new x(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?Dl[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new X().copy(this.root.matrix).invert(),a=new X().compose(new x(...t),new gt(...n),new x(1,1,1)).premultiply(e),r=new x,l=new gt;return a.decompose(r,l,new x),{location:r.toArray(),rotation:[l.w,l.x,l.y,l.z]}}cameraView(t,n,e,a){const r=this.frame,l=Vo.safeParse(r?.cameras[t]);return!r?.camera_view||!l.success?null:Sl(l.data,this.root.matrix,n,e,a,r.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const e=t??n.frame,a=Kl(n.markers,e);return`(${e})${n.body}${a===null?"":` <${a}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const e=Jl[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([c])=>c*r>a)??e[e.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(e=>e.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[e,a]of this.objects)if(a===t){const r=t.parent,l=[...t.children];t.removeFromParent();for(const c of l)n.add(c);r?.add(n),this.objects.set(e,n);return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,e){const a=new Set(this.objects.values()),r=this.cursorOverlay.placementAt(t,n,e,this.root,l=>a.has(l));return r!==null&&(this.cursorOverlay.show(r),vt()),r}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 e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(a=>a.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(vt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),vt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const a=this.objects.get(e.id);if(!a?.isMesh)continue;const l=(e.materials.length?e.materials:[null]).map(c=>{const u=c===null?this.fallback:this.materials.get(c)??this.fallback;return t?this.workbenchFor(c,u.side,n):u});a.material=e.materials.length?l:l[0]}for(const[e,a]of this.workbenchMaterials)n.has(e)||(a.dispose(),this.workbenchMaterials.delete(e))}workbenchFor(t,n,e){const a=(t!==null?this.frame?.materials[t]?.viewport:void 0)??El,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let l=this.workbenchMaterials.get(r);return l||(l=zl(a,n),this.workbenchMaterials.set(r,l)),l}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Co(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])al(r,e);this.rendered=t,this.lighting.setRendered(t);const a=t&&n?this.worldKeyFor(n):null;t?(this.capturing||a!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:a,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await hr(),await Promise.all([...this.textures.values()].map(r=>r.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const e=[];for(const u of this.objects.values()){const f=u;if(f.isMesh&&(f.castShadow=t,f.receiveShadow=t,t&&f.visible)){const s=new yn().setFromObject(f);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,f)=>u.union(f),new yn).getBoundingSphere(new Xe),l=n?new Ye().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,c=l?e.flatMap(u=>Tr(u,l)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Ar(u,c,e):gr(u,r.center,r.radius)}applyOverlays(t){const n=l=>{const c=t.objects.find(u=>u.name===l);return c===void 0?null:new X().set(...c.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],a=t.weights?this.objects.get(t.objects.find(l=>l.name===t.weights?.object)?.id??""):void 0,r=this.weightOverlay.apply(t.weights,a??null,t.weights?n(t.weights.object):null);return r!==null&&e.push(r),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),e}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),vt())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=Vo.safeParse(a);r.success&&(n[e]=r.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(e=>e.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:e=>{const a=t.objects.find(r=>r.name===e);return a?this.objects.get(a.id)??null:null},image:e=>{const a=this.textures.get(e);if(!a)return null;const r=a.texture.image,l=a.width||r?.width||0,c=a.height||r?.height||0;return(l===0||c===0)&&a.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),a.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),vt()},()=>this.awaitedImages.delete(e))),{texture:a.texture,width:l,height:c}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const e=this.lights.get(t.light);e&&(e.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}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=Ql.parse(t);if(this.retiredSessions.has(e.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===e.session&&e.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const a=new Set(e.objects.map(f=>f.id));if(a.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const r=new Map(e.objects.map(f=>[f.id,f]));for(const f of e.objects){if(f.mesh!==null&&!e.meshes[f.mesh])throw new Error(`Missing runtime mesh ${f.mesh}`);if(f.volume&&(!e.volumes[f.volume]||f.mesh!==null))throw new Error(`Invalid runtime volume ${f.volume}`);if(f.light&&(!e.lights[f.light]||f.mesh!==null))throw new Error(`Invalid runtime light ${f.light}`);for(const _ of f.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const s=new Set([f.id]);let i=f.parent;for(;i!==null;){if(s.has(i))throw new Error("Runtime parent cycle");s.add(i);const _=r.get(i);if(!_)throw new Error(`Missing runtime parent ${i}`);i=_.parent}}const l=new Map,c=new Map;try{for(const[f,s]of Object.entries(e.volumes)){const i=JSON.stringify(s);this.frame?.session===e.session&&this.volumes.get(f)?.signature===i||c.set(f,{signature:i,mesh:Pr(s)})}for(const[f,s]of Object.entries(e.meshes)){if("unchanged"in s){const h=this.meshes.get(f)?.signature;if(this.frame?.session===e.session&&h!==void 0&&(h===`revision:${s.revision}`||!h.startsWith("revision:")))continue;throw new Error(h===void 0?`${xo}: the presenter does not hold runtime mesh ${f} (store ${s.store}, revision ${s.revision})`:`${xo}: the presenter holds runtime mesh ${f} at ${h}, not revision ${s.revision}`)}const i="hash"in s,_="columns"in s,d=_?`revision:${s.revision}`:i?s.hash:JSON.stringify(s);this.frame?.session===e.session&&this.meshes.get(f)?.signature===d||l.set(f,{signature:d,geometry:_?Hn(La({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},d)):i?Hn(s):Va(s)})}}catch(f){for(const s of l.values())s.geometry.dispose();for(const{mesh:s}of c.values())s.geometry.dispose(),s.material.dispose();throw f}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[f,s]of c){const i=this.volumes.get(f)?.mesh;i&&(i.removeFromParent(),i.geometry.dispose(),i.material.dispose()),this.volumes.set(f,s)}for(const[f,s]of l)this.meshes.get(f)?.geometry.dispose(),this.meshes.set(f,s),this.geometryBuilds++;for(const[f,s]of Object.entries(e.images)){const i=this.textures.get(f);if("width"in s){const m=s.rgba??(s.rgbaBase64?Wn(s.rgbaBase64):void 0);if(!m)throw new Error(`Runtime image ${f} carries no raster`);const p=s.tiles?ql(f,s.tiles,s.colorspace??"sRGB"):void 0;if(i?.udim&&(i.udim.tiles.dispose(),i.udim.map.dispose(),delete i.udim),i&&i.width===s.width&&i.height===s.height){const v=i.texture.image;if(v.data){v.data.set(m),i.texture.needsUpdate=!0,i.revision=s.revision,p&&(i.udim=p);continue}}i?.texture.dispose(),this.textures.set(f,{texture:Hl(m,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...p?{udim:p}:{}});continue}const _=s.png??(s.pngBase64?Wn(s.pngBase64):void 0);if(!_)throw new Error(`Runtime image ${f} carries no bytes`);i?.texture.dispose(),i?.udim?.tiles.dispose(),i?.udim?.map.dispose();const{texture:d,ready:h}=Wl(_);d.colorSpace=Mt,this.textures.set(f,{texture:d,ready:h,width:0,height:0,revision:s.revision,png:_.slice()})}for(const[f,s]of Object.entries(e.materials)){const i=this.materials.get(f)??new ln;i.name=s.name;const _=s.texture?.tint;s.texture!==void 0?i.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):i.color.setRGB(s.color[0],s.color[1],s.color[2],ft),i.opacity=s.color[3];const d=i.opacity<1||s.graph!==void 0&&Rr(s.graph);i.transparent!==d&&(i.transparent=d,i.needsUpdate=!0),i.roughness=s.roughness,i.metalness=s.metallic,i.transmission=s.transmission,i.ior=s.ior,so(i,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const h=s.normal_texture?.image.name;if(h===void 0)i.normalMap&&(this.textureSamplers.delete(`${f}:normal`),i.normalMap=null,i.needsUpdate=!0);else{const b=this.textures.get(h);if(!b)throw new Error(`${Qt}: missing normal image ${h}`);const w=this.textureSamplers.get(`${f}:normal`,b.texture,s.normal_texture.extension,b.ready,s.normal_texture.uv);i.normalMap!==w&&(i.normalMap=w,i.needsUpdate=!0);const R=s.normal_space==="OBJECT"?Ze:Qe;i.normalMapType!==R&&(i.normalMapType=R,i.needsUpdate=!0),i.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(i.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],ft),i.emissiveIntensity=s.emission.strength):(i.emissive.setRGB(0,0,0),i.emissiveIntensity=1);const m=s.roughness_texture?.image.name??null;if(m===null)this.roughnessTextureNames.has(f)&&(this.textureSamplers.delete(`${f}:roughness`),i.roughnessMap=null,this.roughnessTextureNames.delete(f),i.needsUpdate=!0);else{const b=this.textures.get(m);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${m} (revision ${s.roughness_texture.image.revision})`);const w=this.textureSamplers.get(`${f}:roughness`,b.texture,s.roughness_texture.extension,b.ready,s.roughness_texture.uv);i.roughnessMap!==w&&(i.roughnessMap=w,this.roughnessTextureNames.set(f,m),i.needsUpdate=!0)}const p=s.texture?.image.name??null;if(p===null)this.textureNames.has(f)&&(this.textureSamplers.delete(`${f}:color`),i.map=null,this.textureNames.delete(f),i.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${p} (revision ${s.texture.image.revision})`);const w=this.textureSamplers.get(`${f}:color`,b.texture,s.texture.extension,b.ready,s.texture.uv);i.map!==w&&(i.map=w,this.textureNames.set(f,p),i.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,g=new Set;qr(i,v,b=>{const w=this.textures.get(b.name);if(!w)throw new Error(`${Qt}: the presenter does not hold runtime image ${b.name} (revision ${b.revision})`);if(b.tiled){if(!w.udim)throw new Error(`${Qt}: runtime image ${b.name} arrived without its UDIM tiles`);return w.udim}const R=`${f}:graph:${b.node}`;g.add(R);const T=this.textureSamplers.get(R,w.texture,b.extension,w.ready),P=b.closest?Bn:Lt,O=b.closest?Bn:b.mipmap?te:Lt;return(T.magFilter!==P||T.minFilter!==O)&&(T.magFilter=P,T.minFilter=O,T.needsUpdate=!0),T},this.photograph);for(const b of this.graphSamplers.get(f)??[])g.has(b)||this.textureSamplers.delete(b);this.graphSamplers.set(f,g),this.materials.set(f,i)}for(const f of e.objects){let s=this.objects.get(f.id);const i=f.volume?this.volumes.get(f.volume).mesh:null;if((!s||(i?s!==i:!!s.isMesh!=(f.mesh!==null)))&&(s?.removeFromParent(),s=i??(f.mesh!==null?new Tt(this.meshes.get(f.mesh).geometry,this.fallback):new Xo),this.objects.set(f.id,s)),s.name=f.name,f.type==="CAMERA"||f.type==="LIGHT"||f.type==="EMPTY"?s.userData.volterOwnOverlay=!0:delete s.userData.volterOwnOverlay,s.matrixAutoUpdate=!1,s.matrix.set(...f.matrix.flat()),f.parent){const _=new X().set(...r.get(f.parent).matrix.flat());s.matrix.premultiply(_.invert())}if(s.matrix.decompose(s.position,s.quaternion,s.scale),f.texspace?s.userData.blenderTexspace=f.texspace:delete s.userData.blenderTexspace,f.default_color!==void 0?s.userData.blenderDefaultColor=f.default_color:delete s.userData.blenderDefaultColor,f.mesh!==null){const _=s;_.geometry=this.meshes.get(f.mesh).geometry,_.material=f.materials.length?f.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,Zr(_)}if(f.light){const _=this.lights.get(f.light)??null,d=vr(e.lights[f.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==s&&s.add(d),d.userData.volterOwnOverlay=!0,xr(d,s),this.lights.set(f.light,d)}}for(const f of e.objects){const s=this.objects.get(f.id),i=f.parent===null?this.root:this.objects.get(f.parent);s.parent!==i&&i.add(s)}for(const[f,s]of this.objects)a.has(f)||(s.removeFromParent(),this.objects.delete(f));for(const[f,s]of this.volumes)e.volumes[f]||(s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.volumes.delete(f));for(const[f,s]of this.meshes)e.meshes[f]||(s.geometry.dispose(),this.meshes.delete(f));for(const[f,s]of this.materials)if(!e.materials[f]){for(const i of["normal","roughness","color"])this.textureSamplers.delete(`${f}:${i}`);for(const i of this.graphSamplers.get(f)??[])this.textureSamplers.delete(i);this.graphSamplers.delete(f),s.dispose(),this.materials.delete(f)}for(const[f,s]of this.lights)e.lights[f]||(s.removeFromParent(),s.dispose(),this.lights.delete(f));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{}},this.worldKey=JSON.stringify(e.world??null);const u=this.applyOverlays(e);u.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...u]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const f of[...this.frameListeners])f();for(const f of this.followers)try{f.applyFrame(t)}catch{f.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[a,{signature:r,geometry:l}]of this.meshes){const c=s=>{const i=l.getAttribute(s);if(!i)return null;if(!(i instanceof it))throw new Error(`Blender capture cannot copy interleaved ${s}`);return new Float32Array(i.array)},u=c("position");if(!u)throw new Error(`Blender capture mesh ${a} has no positions`);const f=l.getIndex();n.meshes[a]={hash:r,positions:u,normals:c("normal"),uv:c("uv"),uvLayers:Object.entries(l.userData.blenderUvChannels??{}).map(([s,i])=>{const _=c(`uv${i}`);if(!_)throw new Error(`Blender capture mesh ${a} is missing UV layer ${s}`);return{name:s,data:_}}),orco:l.userData.blenderOrcoFromDoor?c("blenderOrco"):null,attributeLayers:(l.userData.blenderAttributes??[]).map(s=>{const i=c(Vt(s));if(!i)throw new Error(`Blender capture mesh ${a} is missing attribute ${s}`);return{name:s,data:i}}),indices:f?new Uint32Array(f.array):Uint32Array.from({length:u.length/3},(s,i)=>i),groups:l.groups.map(s=>({start:s.start,count:s.count,materialIndex:s.materialIndex??0}))}}for(const[a,{signature:r}]of this.volumes)n.volumes[a]=de.parse(JSON.parse(r));const e=new Set(Object.values(n.materials).flatMap(a=>[a.texture?.image.name,a.roughness_texture?.image.name,a.normal_texture?.image.name,...Object.values(a.graph?.nodes??{}).map(r=>r.props.image?.name)].filter(r=>r!==void 0)));for(const a of e){const r=this.textures.get(a);if(!r)throw new Error(`Blender capture image ${a} is not resident`);if(r.png)n.images[a]={revision:r.revision,png:r.png.slice()};else{const l=r.texture.image?.data;if(!(l instanceof Uint8Array))throw new Error(`Blender capture image ${a} has no resident raster`);n.images[a]={revision:r.revision,width:r.width,height:r.height,rgba:l.slice(),colorspace:r.texture.colorSpace===oo?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Tn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,e=this.createWorldVolumePass(),a=new Tn;a.photograph=!0;let r=!1;const l=()=>{r||(r=!0,e?.dispose(),a.dispose(),a.root.removeFromParent())};try{a.applyFrame(t),this.root.updateWorldMatrix(!0,!1),a.root.matrix.copy(this.root.matrixWorld),a.root.updateMatrixWorld(!0)}catch(c){throw l(),c}return{effect:e,root:a.root,session:n.session,revision:n.revision,prepare:c=>{if(r)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,c)},dispose:l}}createWorldVolumePass(){const t=Co(this.frame?.world);return t?new il(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const a=typeof n.session=="string"?n.session:null;a!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=a);const r=e;for(const[l,c]of Object.entries(r))typeof c=="object"&&c!==null&&!("unchanged"in c)&&this.submittedMeshes.set(l,c);for(const l of[...this.submittedMeshes.keys()])l in r||this.submittedMeshes.delete(l);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const si=new Tn;function we(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Ln(o){const t=we(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function ti(o){const t=we(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ni(o){return new X().set(...o.flat())}function Uo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class oi{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,a=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:a,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((r,l)=>r+l.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:this.#i!==null?this.#i:t.clipStart+this.#a.time*t.fps}get playable(){return this.#a!==null}async bind(t,n){this.#r++;const e=await n.rig();if(!e)return;const a=[],r=new Set;let l=!1;for(const i of e.rigs){if(!i.object||!i.armature||!i.skinIndexBase64||!i.skinWeightBase64){i.reason&&a.push(i.reason);continue}r.add(i.object);const _=Uo(i,e.frame);if(this.#n.get(i.object)?.signature===_)continue;const d=this.#d(t,i,e.frame,a);d&&(this.#n.get(i.object)?.skeleton.dispose(),this.#n.set(i.object,d),l=!0)}for(const[i,_]of[...this.#n])r.has(i)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(i),l=!0);this.#r++;const c=await n.clip(),u=this.#t,f=c?.action!==u?.action||c?.tracks.length!==u?.tracks.length||c?.clipStart!==u?.clipStart||c?.clipEnd!==u?.clipEnd;this.#t=c??null,c?.reason&&a.push(c.reason),c&&(f||l)&&this.#h(t,c,a);const s=this.#e?.snapshot().playbackState==="playing";c&&!s&&u?.frameCurrent!==c.frameCurrent&&(this.#c(c.frameCurrent),this.#e&&c.fps>0&&this.#e.seek(c.frameCurrent/c.fps)),this.#_=a,this.#f()}#d(t,n,e,a){const r=t.objectForBlenderName(n.object??""),l=t.objectForBlenderName(n.armature??"");if(!r||!l)return null;const c=r,u=c.geometry;if(!u)return null;const f=u.getAttribute("blenderVertex");if(!f)return a.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let s=0;for(let T=0;T<f.count;T++)s=Math.max(s,f.getX(T));if(s>=n.vertexCount)return a.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${s} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const i=ti(n.skinIndexBase64??""),_=Ln(n.skinWeightBase64??""),d=f.count,h=new Uint16Array(d*4),m=new Float32Array(d*4);for(let T=0;T<d;T++){const P=f.getX(T);for(let O=0;O<4;O++)h[T*4+O]=i[P*4+O]??0,m[T*4+O]=_[P*4+O]??0}u.setAttribute("skinIndex",new na(h,4)),u.setAttribute("skinWeight",new bt(m,4));const p=new ot;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ni(T.pose)),b=new Map(n.bones.map((T,P)=>[T.name,P]));n.bones.forEach((T,P)=>{const O=new oa;O.name=T.name,v.push(O);const M=T.parent===null?void 0:b.get(T.parent);(M===void 0?g[P].clone():g[M].clone().invert().multiply(g[P])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),l.add(p);const w=new ea(u,c.material);w.name=c.name,w.matrixAutoUpdate=!1,w.matrix.copy(c.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=c.userData,w.frustumCulled=!1,t.replacePresentedObject(c,w),t.root.updateMatrixWorld(!0);const R=new aa(v);return w.bind(R,w.matrixWorld.clone()),n.constrainedBones?.length&&a.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&a.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:w,boneRoot:p,bones:v,skeleton:R,frame:e,signature:Uo(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const a=n.armature?t.objectForBlenderName(n.armature):null;if(!a)return;const r=new Map;for(const i of this.#n.values())if(i.armature===n.armature)for(const _ of i.bones)r.set(_.name,_);const l=[],c=new Set;for(const i of n.tracks){const _=r.get(i.bone);if(!_){c.add(i.bone);continue}const d=Ln(i.timeBase64),h=Ln(i.valueBase64),m=`${_.uuid}.${i.property}`;l.push(i.property==="quaternion"?new ra(m,Array.from(d),Array.from(h)):new la(m,Array.from(d),Array.from(h)))}if(c.size&&e.push(`${n.action} animates ${[...c].join(", ")}, which this binding has no bone for.`),!l.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,f=new ia(a),s=f.clipAction(new sa(n.action??"action",u,l));s.setLoop(fa,Number.POSITIVE_INFINITY),s.play(),this.#o=f,this.#a=s,this.#c(n.frameCurrent),this.#m()}#c(t){const n=this.#t;if(!n||!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const e=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#i=e;const a=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.min(a-1e-4,(e-n.clipStart)/n.fps)),this.#m()}#m(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const e=n.scene;return!e||n.frameCurrent===t||(this.#r++,await ma(`bpy.data.scenes[${JSON.stringify(e)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const l=this.#t,c=l?.fps||24;return{start:(l?.frameStart??1)/c,end:(l?.frameEnd??250)/c,fps:c}},seek:l=>this.seekSeconds(l)}),e=t.onSettled(()=>{this.writeBookmark()}),a=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#l=null};this.#l=a;const r=this.#t;return r&&r.fps>0&&t.seek(r.frameCurrent/r.fps),a}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#l?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const Oe=new oi;function fi(o){return Oe.subscribe(o)}function ci(){return Oe.version}export{Oe as a,ci as b,si as c,fi as s};
|