@volter/game-editor 0.5.127 → 0.5.129
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 +2206 -2206
- package/dist/assets/{AssetBudgetPanel-PD5Ly9CT.js → AssetBudgetPanel-zU9LQz7t.js} +3 -3
- package/dist/assets/{AudioViewer-Q40_cmYq.js → AudioViewer-BuIumvS8.js} +1 -1
- package/dist/assets/{CanvasBoardDocument-BBdEdhFm.js → CanvasBoardDocument-C_hhKnYC.js} +1 -1
- package/dist/assets/{CanvasSceneViewport-BJeFlMuc.js → CanvasSceneViewport-ksSPZOlc.js} +1 -1
- package/dist/assets/{ColorInput-Cad8L0Ed.js → ColorInput-CHpAb52O.js} +1 -1
- package/dist/assets/{ColorPicker-DFs5jze4.js → ColorPicker-Cj7n9Kxl.js} +1 -1
- package/dist/assets/{EntityModelDocument-CayVoiiM.js → EntityModelDocument-B7Ud_279.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-CV3BXxtQ.js → EnvironmentAssetDocument-yGom_45-.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-DIJVApAB.js → GameplaySessionTimeline-Cd0MV73-.js} +1 -1
- package/dist/assets/{ImageViewer-gSGJ3OMb.js → ImageViewer-CcUUUXNJ.js} +1 -1
- package/dist/assets/InspectorObjectPreview-B90Vut8e.js +1 -0
- package/dist/assets/{JsonAssetDocument-P6W4QFdq.js → JsonAssetDocument-Cyahk092.js} +1 -1
- package/dist/assets/{LiveModuleDocument-Df4fCKjJ.js → LiveModuleDocument-CZgNwvQy.js} +1 -1
- package/dist/assets/{LutAssetDocument-BxMT39rJ.js → LutAssetDocument-BCbAd-Z6.js} +1 -1
- package/dist/assets/{ModelAssetDocument-iydZwJm6.js → ModelAssetDocument-DCPMNFPS.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-n7HSxNdt.js → NonThreeAuthoringBootstrap-Bj2wN899.js} +1 -1
- package/dist/assets/{Object3DDocumentToolbar-DPt8h35L.js → Object3DDocumentToolbar-CVPoo7Ba.js} +1 -1
- package/dist/assets/Object3DDocumentViewport-S-eokiOr.js +2 -0
- package/dist/assets/{Object3DPreview-BxyRQ29F.js → Object3DPreview-BVbUxKmH.js} +1 -1
- package/dist/assets/{OnlineAssetDetail-CqwqPoIr.js → OnlineAssetDetail-7a6_tNJk.js} +1 -1
- package/dist/assets/{PlayBar-BZ7mY6yG.js → PlayBar-Cmml9m77.js} +1 -1
- package/dist/assets/{QuarksAssetDocument-CGvZL9FT.js → QuarksAssetDocument-Cf6ov1uz.js} +1 -1
- package/dist/assets/{ReactCanvasControls-DAiX7h2-.js → ReactCanvasControls-DlFa-ACA.js} +1 -1
- package/dist/assets/{RootSelectionOverlay-CXVw9xAS.js → RootSelectionOverlay-BzYz2ob2.js} +1 -1
- package/dist/assets/{ShaderAssetDocument-CMrEhzOn.js → ShaderAssetDocument-BHIygP3B.js} +1 -1
- package/dist/assets/{ShadowEditor-5kAPELQ2.js → ShadowEditor-D19zHDYi.js} +1 -1
- package/dist/assets/{SourceAssetViewer-BNMvYZgb.js → SourceAssetViewer-IiFeRSfU.js} +1 -1
- package/dist/assets/{StageHost-Bg2tw0U7.js → StageHost-A77nKogt.js} +2 -2
- package/dist/assets/{StoryPreviewMount-D3R8uVtn.js → StoryPreviewMount-BznKUCNI.js} +1 -1
- package/dist/assets/{ThreeBoardDocument-B6eFjrJd.js → ThreeBoardDocument-CKCPXwDq.js} +2 -2
- package/dist/assets/{ThreeIsolationSceneContent-ChDzjYPl.js → ThreeIsolationSceneContent-C1beSjX3.js} +1 -1
- package/dist/assets/{ToolObject3DPreview-CHgTtmL3.js → ToolObject3DPreview-CwbFFjfw.js} +1 -1
- package/dist/assets/{Toolbar-DkvknKyY.js → Toolbar-9O701nY-.js} +1 -1
- package/dist/assets/{TransientHint-BfLb1fyi.js → TransientHint-0ES3rCAi.js} +1 -1
- package/dist/assets/{VideoViewer-B8RaJOtF.js → VideoViewer-mF9y5CJx.js} +1 -1
- package/dist/assets/{ViewportShadingMenu-B5j1MDef.js → ViewportShadingMenu-Bl09DInq.js} +1 -1
- package/dist/assets/{active-ingest-R_div-Oj.js → active-ingest-Lfx46SVT.js} +2 -2
- package/dist/assets/{animation-clock-OkUiSD6M.js → animation-clock-Bx0PQrFI.js} +1 -1
- package/dist/assets/{animation-mixers.service-DR98WDHt.js → animation-mixers.service-DBwnNdey.js} +1 -1
- package/dist/assets/{animation-timeline.utility-De6MGXwn.js → animation-timeline.utility-5scbZH3A.js} +1 -1
- package/dist/assets/{asset-budget-asset.menu-Kt7mAPah.js → asset-budget-asset.menu-BAsodLrT.js} +1 -1
- package/dist/assets/{asset-budget.action-gtj2M3e4.js → asset-budget.action-BxLOHl6M.js} +1 -1
- package/dist/assets/{asset-budget.document-DE_v7Mpa.js → asset-budget.document-gEs0TFUI.js} +1 -1
- package/dist/assets/{asset-budget.menu-C1PtQGYz.js → asset-budget.menu-DLKtNhbo.js} +1 -1
- package/dist/assets/{asset-editor-persistence-BrrBFKn0.js → asset-editor-persistence-DMRNecs7.js} +1 -1
- package/dist/assets/{asset-loaders-CUe2eH9D.js → asset-loaders-D6LJNA5m.js} +1 -1
- package/dist/assets/{asset-preview-BlwxJaQK.js → asset-preview-DPWGMtoN.js} +1 -1
- package/dist/assets/{audio-unlock.service-DTn3KONa.js → audio-unlock.service-zZPU9-cJ.js} +1 -1
- package/dist/assets/{audio.utility-BJnmxTTI.js → audio.utility-1ayYQ4bt.js} +1 -1
- package/dist/assets/autoplay.service-DWi0mQ06.js +1 -0
- package/dist/assets/{babylon-authoring-adapter-D1NipHtB.js → babylon-authoring-adapter-z6KoQamT.js} +1 -1
- package/dist/assets/{binding-resolver-Bpe3oTrY.js → binding-resolver--K9B2aXQ.js} +2 -2
- package/dist/assets/{blender-node-editor.document-MfNbaeLR.js → blender-node-editor.document-Cbl3oe-Y.js} +1 -1
- package/dist/assets/{blender-properties-tab-B779fz1Q.js → blender-properties-tab-BjcUgPFK.js} +1 -1
- package/dist/assets/{blender-runtime-host-CtCtgqOL.js → blender-runtime-host-BnaYnPbE.js} +3 -3
- package/dist/assets/{blender-runtime-skin-CKHCTsry.js → blender-runtime-skin-i6pRHo_x.js} +57 -53
- package/dist/assets/{blender-runtime.document-Ckdh3HKB.js → blender-runtime.document-iznL9OIR.js} +1 -1
- package/dist/assets/{blender-screenshot.menu-ChP92jI-.js → blender-screenshot.menu-DY45gH2v.js} +1 -1
- package/dist/assets/{blender-timeline.document-DdyfjgSk.js → blender-timeline.document-DzI6KOwi.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-DU_1bKdH.js → blender-uv-editor.document-CQGNL-em.js} +1 -1
- package/dist/assets/{blender-version.status-BJq9fepS.js → blender-version.status-B-cFkEmZ.js} +1 -1
- package/dist/assets/{blender.command-6IlfjjJi.js → blender.command-DYVT6Brx.js} +1 -1
- package/dist/assets/{board-guides-DiAs0DMA.js → board-guides-BRZrEdtv.js} +1 -1
- package/dist/assets/{bridge.command-B9N3cMbg.js → bridge.command-BJz6FKqT.js} +3 -3
- package/dist/assets/{browserAll-D7Kd6srk.js → browserAll-Xq6kMmyy.js} +1 -1
- package/dist/assets/{build-player.document-Bl_0T2uA.js → build-player.document-G0EP4-cV.js} +1 -1
- package/dist/assets/{build-profiles.document-DNDwF9_Y.js → build-profiles.document-C0z4JBId.js} +1 -1
- package/dist/assets/{build-progress.status-Boink4g8.js → build-progress.status-ZvaZuR-0.js} +1 -1
- package/dist/assets/{build-session-CuhlmGcx.js → build-session-CymiRvjZ.js} +1 -1
- package/dist/assets/{build.action-CsMtOkDc.js → build.action-BBxTsXfE.js} +1 -1
- package/dist/assets/{build.command-bhhxJk4Q.js → build.command-DT_Zjx0J.js} +1 -1
- package/dist/assets/{build.header-xDNZZU34.js → build.header-CIpUEYXT.js} +1 -1
- package/dist/assets/{build.menu-BpjSystA.js → build.menu-BlTGELsH.js} +1 -1
- package/dist/assets/{build.service-BwluoAjv.js → build.service-AUScoZYu.js} +1 -1
- package/dist/assets/{camera-hh5_JQfV.js → camera-_xYhs96x.js} +1 -1
- package/dist/assets/{camera-runtime.inspector-CUI-ssDo.js → camera-runtime.inspector-CfU1WRe7.js} +1 -1
- package/dist/assets/{canvas-design-mount-CLCR9y6J.js → canvas-design-mount-B1zBhn_J.js} +3 -3
- package/dist/assets/{canvas-entry-runtime-hVYG6wMW.js → canvas-entry-runtime-Cg364i6A.js} +2 -2
- package/dist/assets/{canvas-preview-frames-DLO3eNyZ.js → canvas-preview-frames-BFU7tNhh.js} +1 -1
- package/dist/assets/{canvas-story-capture.service-B0_KeCoB.js → canvas-story-capture.service-5kd3Krkr.js} +2 -2
- package/dist/assets/{capability-coverage-Cchr0mQ3.js → capability-coverage-rUUpSzOn.js} +1 -1
- package/dist/assets/{collaboration-presence-Z5klZlI7.js → collaboration-presence-DVqUskAb.js} +1 -1
- package/dist/assets/{collider-D1_IIE-F.js → collider-BF-ZbxHV.js} +1 -1
- package/dist/assets/{component-board.service-LdfAanpB.js → component-board.service-BcwBF-zp.js} +2 -2
- package/dist/assets/{component-board.service-DRc9tSvn.js → component-board.service-Bd1jmbus.js} +2 -2
- package/dist/assets/{component-board.service-Jx7a2Yr-.js → component-board.service-C4T_W5t7.js} +2 -2
- package/dist/assets/{component-contracts.service-B_JKJT9K.js → component-contracts.service-Cft1sJ-Z.js} +1 -1
- package/dist/assets/{component-instance-root-0OmhquKK.js → component-instance-root-DktYaTot.js} +1 -1
- package/dist/assets/{component-verbs.command-BAVS6__0.js → component-verbs.command-DvuK_xvY.js} +1 -1
- package/dist/assets/{component-verbs.service-LM9zY1kI.js → component-verbs.service-DjMcC9H_.js} +1 -1
- package/dist/assets/{config-BUK1VABW.js → config-DlwXFlyt.js} +2 -2
- package/dist/assets/{configurations-N2mNw-tg.js → configurations-CNjdXyJJ.js} +1 -1
- package/dist/assets/{connection.status-BzJ3fGF_.js → connection.status-Cew-NIBU.js} +1 -1
- package/dist/assets/{constraints.inspector-DxF0WKoV.js → constraints.inspector-COs-kZwV.js} +1 -1
- package/dist/assets/{content-bounds-BZfH5RtN.js → content-bounds-CY_M6Fwr.js} +1 -1
- package/dist/assets/{contract-system-adapters-BN9ohs9e.js → contract-system-adapters-C1bKdaVk.js} +1 -1
- package/dist/assets/{coverage.service-CKeNuy0m.js → coverage.service-DyHGtZYc.js} +1 -1
- package/dist/assets/{create-runtime-DIhNSHgr.js → create-runtime-CYU9IW7x.js} +1 -1
- package/dist/assets/{curve-DqPAAyLA.js → curve-BF_LI3jO.js} +1 -1
- package/dist/assets/{data-asset-CUXIvdhH.js → data-asset-D71yCsQc.js} +1 -1
- package/dist/assets/{data-ref-u6lwt2bh.js → data-ref-DlKbKxgc.js} +1 -1
- package/dist/assets/{debug-bridge-0Ch5pR4P.js → debug-bridge-D1LqwyHH.js} +1 -1
- package/dist/assets/{debug-registry-D9oD7FHT.js → debug-registry-BFq6QR4G.js} +1 -1
- package/dist/assets/{deferred-ingest-play-DObJUzph.js → deferred-ingest-play-sqaLv2U9.js} +2 -2
- package/dist/assets/{design-time-canvas-mount-kTm3g37R.js → design-time-canvas-mount-Cyaec5o_.js} +2 -2
- package/dist/assets/{design-time-layers-Bf9v4K6S.js → design-time-layers-BmljBngv.js} +1 -1
- package/dist/assets/{design-time-mount.service-DnfuDkLV.js → design-time-mount.service-DaEQZipp.js} +2 -2
- package/dist/assets/{design-time-mount.service-DdoDO9db.js → design-time-mount.service-DkXbIUSV.js} +2 -2
- package/dist/assets/{design-time-react-mount-BKngZyGo.js → design-time-react-mount-DiJOqmix.js} +1 -1
- package/dist/assets/{document-preview-three-Bfn5CPiD.js → document-preview-three-BGSnBaa1.js} +1 -1
- package/dist/assets/{dom-authoring-adapter-CKolNcI_.js → dom-authoring-adapter-DeA4Bi4o.js} +1 -1
- package/dist/assets/{draco3d-BkMn9cW2.js → draco3d-Dt3Ei-m7.js} +1 -1
- package/dist/assets/{edit-mode-audio.service-BXgbsw-L.js → edit-mode-audio.service-CwOaP-3u.js} +1 -1
- package/dist/assets/{edit-mode-authoring-Bx6SGIjL.js → edit-mode-authoring-Cm2rEFlJ.js} +1 -1
- package/dist/assets/{edit-mode-networking.service-ZZETnS-m.js → edit-mode-networking.service-BC5B83fD.js} +1 -1
- package/dist/assets/{editor-api-MYo_NhPG.js → editor-api-B0Z7yvj8.js} +1 -1
- package/dist/assets/{editor-layers-BDej9Ofa.js → editor-layers-kBpG49pG.js} +1 -1
- package/dist/assets/{editor-shell-store-DmIN_bZc.js → editor-shell-store-C6VYP6ve.js} +1 -1
- package/dist/assets/{entity-object-sI9MDwQJ.js → entity-object-DiC6cpEd.js} +1 -1
- package/dist/assets/{extend-Ci0OsrQT.js → extend-DXDb7AYu.js} +1 -1
- package/dist/assets/{fork-menu-DBSCmy4Q.js → fork-menu-Cleuze1z.js} +1 -1
- package/dist/assets/{frame-debugger-store-BgELTeli.js → frame-debugger-store-B3YeiIrp.js} +1 -1
- package/dist/assets/{game-contract-seams-lha_cX4J.js → game-contract-seams-Cfyg896y.js} +1 -1
- package/dist/assets/{game-css-scope-transform-BsQrnJad.js → game-css-scope-transform-CWJpcOFq.js} +1 -1
- package/dist/assets/{game-document.service-CRVaHjov.js → game-document.service-Dhy_L2WU.js} +1 -1
- package/dist/assets/{game-eval.command-KKR6bdMi.js → game-eval.command-C14hkRIz.js} +1 -1
- package/dist/assets/{game-module-access-DYES1F1a.js → game-module-access-Cb0rgQXR.js} +1 -1
- package/dist/assets/{game-network-BtZZImhM.js → game-network-BuhrtQlJ.js} +3 -3
- package/dist/assets/{gameplay-export-NxNgfvAW.js → gameplay-export-BMmWR4qO.js} +1 -1
- package/dist/assets/{gameplay-replay-D4vTBXtR.js → gameplay-replay-Cgxltc0I.js} +1 -1
- package/dist/assets/{gameplay.command-C3NnXZz5.js → gameplay.command-BXkiGrY3.js} +1 -1
- package/dist/assets/{generation-jobs-B487f_2Z.js → generation-jobs-Dti-NsGT.js} +1 -1
- package/dist/assets/{generation.service--yjaC5qx.js → generation.service-CUqMO_sv.js} +1 -1
- package/dist/assets/{generations-B76X3pOw.js → generations-CEMzKgsY.js} +1 -1
- package/dist/assets/{generations.status-iHwft6E7.js → generations.status-ClObpAPX.js} +1 -1
- package/dist/assets/{hierarchy-marks-Bv3lFwvr.js → hierarchy-marks-BTgoMhKJ.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-CI3cdlhz.js → hosted-asset-materialization-B1rqU0R3.js} +1 -1
- package/dist/assets/{index-jhDTJrJJ.js → index-9nYTVIws.js} +7 -7
- package/dist/assets/{index-CQ4zsFnG.js → index-BQhQTNuj.js} +2 -2
- package/dist/assets/{index-DmZJfzXE.js → index-BTj5ZDs3.js} +1 -1
- package/dist/assets/{index-p9CDkug5.js → index-BZ9SChD2.js} +1 -1
- package/dist/assets/{index-CECK_ODc.js → index-Bir3FN9S.js} +1 -1
- package/dist/assets/{index-hDH0MQtY.js → index-CfVh4Js-.js} +1 -1
- package/dist/assets/{index-jbVAkbCC.js → index-D8ZZhAux.js} +1 -1
- package/dist/assets/{index-CxM9SCDb.js → index-DmRQLG00.js} +1 -1
- package/dist/assets/{index-DM6wGhg6.js → index-L-eheuNN.js} +1 -1
- package/dist/assets/{inference-diagnostics-GzO30GlV.js → inference-diagnostics-71A-NHW0.js} +1 -1
- package/dist/assets/{ingest-boot-viewport-eEXoWb4H.js → ingest-boot-viewport-R_sgEesV.js} +1 -1
- package/dist/assets/{ingest-siblings-DFv3-ybn.js → ingest-siblings-Cw0Uh18c.js} +1 -1
- package/dist/assets/{ingest-source-persistence-DrtMONfa.js → ingest-source-persistence-DbuTxtMu.js} +1 -1
- package/dist/assets/{ingest.service-Aqr5ECGV.js → ingest.service-DLFH4vr0.js} +1 -1
- package/dist/assets/{inspect-CkG2Z66I.js → inspect-3o2qSIRq.js} +1 -1
- package/dist/assets/instances.command-BCLwTYAu.js +1 -0
- package/dist/assets/{json-history-resource-sg0Vzf4w.js → json-history-resource-C818aJwj.js} +1 -1
- package/dist/assets/{layered-pick-CEWefTxe.js → layered-pick-D9xs5s8q.js} +1 -1
- package/dist/assets/{light-BPEv67Pc.js → light-DmAkSp8r.js} +1 -1
- package/dist/assets/{live-project-verbs-CvPNGB8N.js → live-project-verbs-E-s8WH5m.js} +1 -1
- package/dist/assets/{machine.document-Byg4Akxw.js → machine.document-WaAig10j.js} +1 -1
- package/dist/assets/{machines.finder-Cu6MQ5CX.js → machines.finder-DOuT11sq.js} +1 -1
- package/dist/assets/{material-CCaJzzZ3.js → material-Dmhe3uX6.js} +1 -1
- package/dist/assets/{material-factory-BUMkjoYi.js → material-factory-D2dS8Frx.js} +1 -1
- package/dist/assets/{mesh-CK1UuqDd.js → mesh-C0P0KD9j.js} +1 -1
- package/dist/assets/{model-asset-sections.service-iifouDM7.js → model-asset-sections.service-DuN8nZyK.js} +1 -1
- package/dist/assets/{model-inspection-DYuFlISa.js → model-inspection-Dys9s7L6.js} +1 -1
- package/dist/assets/{model-thumbnail-DQh5eEm6.js → model-thumbnail-DXupO6bI.js} +1 -1
- package/dist/assets/{models.finder-DK7FBN-1.js → models.finder-DVEKCOHk.js} +1 -1
- package/dist/assets/{module-mode-IVU14VtJ.js → module-mode-BygBdatu.js} +2 -2
- package/dist/assets/{mount-canvas-ingest-root-CxkwEZ3U.js → mount-canvas-ingest-root-Cbgn79dS.js} +2 -2
- package/dist/assets/{mount-dom-ingest-root-CIxtLQlq.js → mount-dom-ingest-root-CXQpetbD.js} +2 -2
- package/dist/assets/{mount-ingest-root-0tfZf15A.js → mount-ingest-root-DUX3GfHM.js} +2 -2
- package/dist/assets/{mount-manifest-BjOZvESY.js → mount-manifest-CD7uLAam.js} +1 -1
- package/dist/assets/{mount-three-ingest-root-DohUuewD.js → mount-three-ingest-root-D5BUSuP1.js} +1 -1
- package/dist/assets/{mounted-authoring-MD8wY1MJ.js → mounted-authoring-CHg17ilK.js} +1 -1
- package/dist/assets/{mounted-story-viewport-source-CXQknMtQ.js → mounted-story-viewport-source-DWvv2V1k.js} +1 -1
- package/dist/assets/{native-debug-module-B7pExEZQ.js → native-debug-module-lQJX-160.js} +1 -1
- package/dist/assets/{navigation-oRKxBmNV.js → navigation-BVBawG9W.js} +1 -1
- package/dist/assets/{navmesh.menu-B9VhK5IV.js → navmesh.menu-CJDd0N9U.js} +1 -1
- package/dist/assets/{navmesh.service-CyG9vb7p.js → navmesh.service-3H_AsM8V.js} +1 -1
- package/dist/assets/network-observer.service-BgHgylkf.js +1 -0
- package/dist/assets/{network.utility-fKCL0zrN.js → network.utility-CFfOHPIO.js} +1 -1
- package/dist/assets/{object3d-document-session-registry-BGN2Zn49.js → object3d-document-session-registry-D6-Tfc82.js} +2 -2
- package/dist/assets/{oid-transform-CGuM6vZg.js → oid-transform-CS4vS_7K.js} +1 -1
- package/dist/assets/{particles-CZSrHj3_.js → particles-5E9qI-gh.js} +1 -1
- package/dist/assets/{pixi-authoring-adapter-BGdlVTc3.js → pixi-authoring-adapter-B7lzpOiN.js} +1 -1
- package/dist/assets/{pixi-live-write-target-Bwu1bYXf.js → pixi-live-write-target-B_0mlJ-W.js} +1 -1
- package/dist/assets/{play.command-DOGPaB4C.js → play.command-DXwe-naC.js} +2 -2
- package/dist/assets/{presentation-BaYyBBj2.js → presentation-CNsPSm6R.js} +1 -1
- package/dist/assets/{product-nDWAhddV.js → product-CGnkd6iD.js} +1 -1
- package/dist/assets/{profiler.action-BJHf2xQo.js → profiler.action-CJgUgLVa.js} +1 -1
- package/dist/assets/{profiler.menu-BNIQRpMB.js → profiler.menu-r7vS6Yo1.js} +1 -1
- package/dist/assets/{profiler.utility-SN9V1vO1.js → profiler.utility-CoHWXo_c.js} +1 -1
- package/dist/assets/{project-authoring-session-BTy053IX.js → project-authoring-session-CRVFBRc-.js} +2 -2
- package/dist/assets/{properties-bone-constraints.inspector-CYpu4a1I.js → properties-bone-constraints.inspector-CzmVcM5s.js} +1 -1
- package/dist/assets/{properties-bone.inspector-CoRR1NRF.js → properties-bone.inspector-BZmU33Jq.js} +1 -1
- package/dist/assets/{properties-collection.inspector-DbmGF5HE.js → properties-collection.inspector-D5E8xv7R.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-DhDu-8JO.js → properties-constraints.inspector-m1I_6ZEe.js} +1 -1
- package/dist/assets/{properties-data.inspector-C9hizZ5U.js → properties-data.inspector-CHYtOay1.js} +1 -1
- package/dist/assets/{properties-material.inspector-xw768wuX.js → properties-material.inspector-DD3Id-bK.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-CunyZ4p0.js → properties-modifiers.inspector-DgFoyJ9g.js} +1 -1
- package/dist/assets/{properties-object.inspector-DhR_ipG7.js → properties-object.inspector-ZKMUDqDb.js} +1 -1
- package/dist/assets/{properties-output.inspector-DiR-D4kZ.js → properties-output.inspector-B_EiV17y.js} +1 -1
- package/dist/assets/{properties-particles.inspector-B3Wptqjp.js → properties-particles.inspector-Bp5t3sG5.js} +1 -1
- package/dist/assets/{properties-physics.inspector-DczZfTN-.js → properties-physics.inspector-BvJ6FjLW.js} +1 -1
- package/dist/assets/{properties-render.inspector-qjHCxhXs.js → properties-render.inspector-C0HhUqJV.js} +1 -1
- package/dist/assets/{properties-scene.inspector-B-5goJJ1.js → properties-scene.inspector-DvxB8SBY.js} +1 -1
- package/dist/assets/{properties-texture.inspector-xNjlzod3.js → properties-texture.inspector-DQK_N2p0.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-6onYZnR0.js → properties-view-layer.inspector-CQimDF5e.js} +1 -1
- package/dist/assets/{properties-world.inspector-CJzAraZh.js → properties-world.inspector-Cbyj1FX6.js} +1 -1
- package/dist/assets/{r3f-design-session-JBU21CBT.js → r3f-design-session-BSfF6B87.js} +2 -2
- package/dist/assets/{r3f-physics-binding-BQKS3eos.js → r3f-physics-binding-BNfJcrsE.js} +1 -1
- package/dist/assets/{r3f-source-authoring-adapter-CaPTplr2.js → r3f-source-authoring-adapter-CN3frg1s.js} +1 -1
- package/dist/assets/{react-canvas-navigation-CuOqbCmx.js → react-canvas-navigation-DdSNr1eV.js} +1 -1
- package/dist/assets/{react-inspector.service-Biw-7Aph.js → react-inspector.service-BbtT2HsV.js} +1 -1
- package/dist/assets/{react-story-board-BS4wtpbe.js → react-story-board-BT9vj0hE.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-BPcU5vTr.js → react-three-rapier.esm-DE67kTw9.js} +1 -1
- package/dist/assets/{react-world-authoring-adapter-MA_K7IzV.js → react-world-authoring-adapter-CW_LKdTk.js} +1 -1
- package/dist/assets/{realm-services-Dir-FaGM.js → realm-services-NnoNrbsM.js} +1 -1
- package/dist/assets/{reflection-probe-capture.inspector-BzVk5nbq.js → reflection-probe-capture.inspector-DRvTQC2t.js} +1 -1
- package/dist/assets/{registry-BRpQODGg.js → registry-BYs8gLgr.js} +1 -1
- package/dist/assets/{relative-import-specifier-BFDgw6rr.js → relative-import-specifier-CAVq9YAo.js} +1 -1
- package/dist/assets/{render-env-g0xcT2gf.js → render-env-B5aBdPRW.js} +1 -1
- package/dist/assets/{render-features-ipsYrx5W.js → render-features-Dro8D2hp.js} +1 -1
- package/dist/assets/{render-settings-Blt3RlHC.js → render-settings-GZy83cAX.js} +1 -1
- package/dist/assets/{resolve-three-D7kJDkec.js → resolve-three-D2L9I0Oc.js} +3 -3
- package/dist/assets/{root-seam-contract-TccLSDcM.js → root-seam-contract-DhJmeQCY.js} +1 -1
- package/dist/assets/{run-selection-BwneJGDD.js → run-selection-BkQCgqx8.js} +1 -1
- package/dist/assets/{scene-capture-BbPvTNLW.js → scene-capture-D1HDHgUb.js} +1 -1
- package/dist/assets/{scene-document.service-EWLuGMAY.js → scene-document.service-CDkhd8nL.js} +2 -2
- package/dist/assets/{scene-framing-CXQ4WFCe.js → scene-framing-Bib_NZz8.js} +1 -1
- package/dist/assets/{seeded-random-CLC2hMDL.js → seeded-random-DfGQ6n66.js} +1 -1
- package/dist/assets/{setup-renderer-CwZuhttK.js → setup-renderer-ayLSJRHD.js} +1 -1
- package/dist/assets/{source-object3d-authoring-adapter-BRXDkWd8.js → source-object3d-authoring-adapter-B_kkT_oM.js} +1 -1
- package/dist/assets/{source-persistence-backend-BMcrOXF8.js → source-persistence-backend-CTvhQwDl.js} +1 -1
- package/dist/assets/{stage-keyboard-BoOvqz6F.js → stage-keyboard-BiNmyrcC.js} +1 -1
- package/dist/assets/{stage-overlay-set-9gaaWRc5.js → stage-overlay-set-DQLl2s9p.js} +1 -1
- package/dist/assets/{stage-presence-markers-B5tMBPb2.js → stage-presence-markers-DfVJAOvz.js} +1 -1
- package/dist/assets/{stage-transform-tools-CCzvYtKw.js → stage-transform-tools-D31L_IPe.js} +1 -1
- package/dist/assets/{standard-viewport-dressing-BVHhIJE1.js → standard-viewport-dressing-KeudiGw3.js} +1 -1
- package/dist/assets/{state-watch.action-BbRdD-Bw.js → state-watch.action-CPN044HT.js} +1 -1
- package/dist/assets/{state-watch.menu-D_JIVIMe.js → state-watch.menu-BflRXjsh.js} +1 -1
- package/dist/assets/{state-watch.utility-BE-P2r3A.js → state-watch.utility-Bqey3wQF.js} +1 -1
- package/dist/assets/{story-capture-BLl-A22X.js → story-capture-BzPUoVSA.js} +1 -1
- package/dist/assets/{story-documents-C441czJk.js → story-documents-B3tO-W0D.js} +1 -1
- package/dist/assets/{story-documents.service-CcG3J9jn.js → story-documents.service-BT7uy424.js} +1 -1
- package/dist/assets/{story-documents.service-DAAUrl6I.js → story-documents.service-ChxLJ279.js} +1 -1
- package/dist/assets/{story-media-presence-BR_BcVt0.js → story-media-presence-D_0fuO18.js} +1 -1
- package/dist/assets/{story-pixi-preview-CM_XAwSW.js → story-pixi-preview-DwHwBn93.js} +1 -1
- package/dist/assets/{story-presentation-CjP2otRK.js → story-presentation-CSAikKBj.js} +1 -1
- package/dist/assets/{story-three-preview-DUvRTcZc.js → story-three-preview-3zJJUEeK.js} +2 -2
- package/dist/assets/{studio-environment-D05pL7iQ.js → studio-environment-8rNw9hGx.js} +1 -1
- package/dist/assets/{surface-state-0xXAxq6X.js → surface-state-bfly5eRp.js} +1 -1
- package/dist/assets/{syntactic-prop-specs-wO7dY0s8.js → syntactic-prop-specs-mk2vEFn1.js} +1 -1
- package/dist/assets/{team-playtest.service-BPinahrE.js → team-playtest.service-BsPtBJdT.js} +1 -1
- package/dist/assets/{three-B_zMk3VF.js → three-Cq9i0Lo_.js} +1 -1
- package/dist/assets/{three-authoring-adapter-zwGjYwL0.js → three-authoring-adapter--CDtc-SE.js} +1 -1
- package/dist/assets/three-authoring.service-Ckj4Lbbp.js +2 -0
- package/dist/assets/{three-ingest-runtime-CSsXqTWC.js → three-ingest-runtime-CDzGhpUC.js} +1 -1
- package/dist/assets/{three-integration-CXNucx1z.js → three-integration-w-zCKW8J.js} +2 -2
- package/dist/assets/three-integration.service-CKxTNTnz.js +1 -0
- package/dist/assets/{three-projection-core-BPR7YFcJ.js → three-projection-core-CxFDvqEe.js} +1 -1
- package/dist/assets/{three-state-C_HLiIZD.js → three-state-BHy0drOJ.js} +1 -1
- package/dist/assets/{three-story-capture.service-735_vEsy.js → three-story-capture.service-D8JgsxaP.js} +2 -2
- package/dist/assets/{three-story-model-BEisRrzq.js → three-story-model-uufCdHEL.js} +1 -1
- package/dist/assets/{three-viewport-presentation-Cfs5MJTy.js → three-viewport-presentation-ChXzMJQZ.js} +1 -1
- package/dist/assets/{transform-mode-request-DsaxVuwS.js → transform-mode-request-BUc943em.js} +1 -1
- package/dist/assets/{transport-strip-BEEkMmqy.js → transport-strip-Q1C-g9BA.js} +1 -1
- package/dist/assets/transport.header-DMkwWnDF.js +1 -0
- package/dist/assets/{tuples-CeiD4z2j.js → tuples-DKGWjTy0.js} +1 -1
- package/dist/assets/{ui-board-document-DcTv9Oo_.js → ui-board-document-D-VnJE6m.js} +2 -2
- package/dist/assets/{user-data-W3aDNol1.js → user-data-BQR8TLTV.js} +1 -1
- package/dist/assets/{utility-view-state-IlWKtSFw.js → utility-view-state-CI8DUyub.js} +1 -1
- package/dist/assets/{viewport-door-C7l0uUHo.js → viewport-door-3sS8tuxh.js} +1 -1
- package/dist/assets/{viewport-root-presentation-DAw5nyWp.js → viewport-root-presentation-D1HAou7A.js} +1 -1
- package/dist/assets/{viewport-surface-status-gSFti1Lv.js → viewport-surface-status-QAiH2FdR.js} +1 -1
- package/dist/assets/{webworkerAll-Cf8x3KX0.js → webworkerAll-BsJisO83.js} +1 -1
- package/dist/assets/{workspace-arrangement-MmNy_T4o.js → workspace-arrangement-8FYR3_fQ.js} +1 -1
- package/dist/assets/{world-documents-BNdPRrgb.js → world-documents-BIjTeJpy.js} +1 -1
- package/dist/assets/{world-root-stage-binding-BMAxQSOR.js → world-root-stage-binding-dtFvIiVe.js} +1 -1
- package/dist/assets/{xstate-animation-binding-DZNqaKO9.js → xstate-animation-binding-DCEYnnM_.js} +1 -1
- package/dist/assets/{xstate-animation-meta-KfEE-v3f.js → xstate-animation-meta-SX2VmhFE.js} +1 -1
- package/dist-node/cli.js +16 -16
- package/package.json +16 -16
- package/dist/assets/InspectorObjectPreview-DpCK9AEo.js +0 -1
- package/dist/assets/Object3DDocumentViewport-DyqXdp2F.js +0 -2
- package/dist/assets/autoplay.service-D8gOha8F.js +0 -1
- package/dist/assets/instances.command-CnDpU3nG.js +0 -1
- package/dist/assets/network-observer.service-BN1u0-oM.js +0 -1
- package/dist/assets/three-authoring.service-D7a7tS8M.js +0 -2
- package/dist/assets/three-integration.service-_6xudYSC.js +0 -1
- package/dist/assets/transport.header-Ds1930r5.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 ee,b as ae,L as re}from"./LineSegments2-DN9pUfWA.js";import{bh as it,cl as ie,fo as x,cm as Z,N as pn,a$ as Pt,em as lo,b4 as $e,co as Rt,ey as Le,cp as En,_ as wt,ej as $t,fd as Gt,er as Ve,M as dt,cj as xt,dp as At,aV as je,cW as se,aE as le,c7 as vt,j as Be,f6 as Ue,fp as fo,au as zn,dw as Dn,bi as co,aT as We,c1 as Xt,dd as Zn,eC as Qn,e7 as Sn,aw as fn,da as Bt,I as dn,as as He,e8 as qe,b0 as fe,K as Ge,B as Xe,b9 as Ye,Y as ce,cw as nn,ed as Ze,cA as Qe,fx as Ke,db as ue,el as Je,R as ta,e6 as na,c0 as _e,bX as oa,aI as wo,ao as ea,eG as aa,d3 as ra,cs as ia,bu as sa,aM as la,ex as fa,b5 as ca,cO as Nn,cY as ua,eU as _a,cE as Kn,c5 as me,at as ma,ff as da,eW as ha,f7 as pa,F as va,ev as ga,et as xa,dq as ba,fq as ya,n as wa,l as Oa,cf as Aa}from"./three.core-3arARmh6.js";import{u as S,v as D,w as R,c5 as Q,c4 as H,c6 as N,e2 as L,_ as Ta,mB as de,d_ as Lt,x as W,kE as bt,e1 as he,mC as U,dZ as Sa,mD as Pa}from"./index-9nYTVIws.js";import{S as Ut}from"./three.module-BLhyNg0e.js";import{t as Ma}from"./blender-runtime-host-BnaYnPbE.js";const Jn=new Set;function Ot(){for(const o of[...Jn])o()}function Ea(o){return Jn.add(o),()=>{Jn.delete(o)}}function to(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 en=N().finite(),Na=S({name:R(),parent:R().nullable(),connected:Q(),hide:Q(),length:en,matrix:D(L([en,en,en,en])).length(4),select:Q(),active:Q(),lockedWeight:Q()}).strict(),Ra=S({object:R(),displayType:H(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:Q(),mode:R(),bones:D(Na)}).strict(),St={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function Ia(o){return new wt(o.r*o.r*.1,o.g*o.g*.1,o.b*o.b*.1)}const kn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],Oo=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],It=Math.SQRT1_2,Fa=[[It,-It,0],[0,-It,-It],[-It,-It,0],[0,-It,It],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],za=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],Da=.05;function Ao(o){return o.select||o.active?2:1}const Ca=10,ka=4,$a=`
|
|
3
3
|
attribute vec3 aSolid;
|
|
4
4
|
attribute vec3 aHint;
|
|
5
5
|
varying vec3 vColor;
|
|
@@ -10,13 +10,13 @@ import{a as ne,b as oe,L as ee}from"./LineSegments2-DN9pUfWA.js";import{bh as lt
|
|
|
10
10
|
vColor = mix(aHint, aSolid, fac * fac);
|
|
11
11
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`,La=`
|
|
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 zt(o){return new wt().setHex(o,Ct)}function Ao(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=zt(Pt.poseActive):t.active?e=zt(Pt.poseActiveUnsel):t.select?e=zt(Pt.pose):e=zt(Pt.wire):e=zt(Pt.vertex),n&&t.lockedWeight&&e.lerp(zt(Pt.lockedWeight),Pt.lockedWeightFactor),e}function Po(o,t){const n=zt(Pt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(zt(Pt.lockedWeight),Pt.lockedWeightFactor),n}const Ca=new tt,ka=new x,So=new ae;function Eo(o,t){return new tt().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class $a{constructor(){this.group=new lt,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 i=n(r.object);if(i===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 f=r.bones.filter(h=>!h.hide);if(f.length===0)continue;const u=r.displayType==="STICK"?this.buildStick(r,f,i):this.buildOctahedral(r,f,i);r.showInFront&&u.traverse(h=>{const s=h.material;s&&"depthTest"in s&&(s.depthTest=!1),h.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const a=new lt;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[],h=[],s=[],l=[],c=[],_=[],d=[];for(const m of n){const p=Eo(e,m),v=Po(t,m),g=Ea(v),w=Ao(t,m);So.setFromMatrix4(p).invert().transpose();for(let T=0;T<Oo.length;T++){const A=ka.set(...Ma[T]).applyMatrix3(So).normalize().clone();for(const O of Oo[T]){const M=new x(...kn[O]).applyMatrix4(p);r.push(M.x,M.y,M.z),i.push(A.x,A.y,A.z),f.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const y=To(m)===2?l:h,S=To(m)===2?c:s;for(const[T,A]of Na){const O=new x(...kn[T]).applyMatrix4(p),M=new x(...kn[A]).applyMatrix4(p);y.push(O.x,O.y,O.z,M.x,M.y,M.z),S.push(w.r,w.g,w.b,w.r,w.g,w.b)}m.parent!==null&&m.connected||(_.push(p.clone()),d.push(v)),_.push(p.clone().multiply(Ca.makeTranslation(0,1,0))),d.push(v)}a.add(this.solidMesh(r,i,f,u)),h.length&&a.add(this.lines(h,s,1)),l.length&&a.add(this.lines(l,c,2));for(let m=0;m<_.length;m++)a.add(this.point(_[m],d[m]));return a}buildStick(t,n,e){const a=new lt;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[];for(const h of n){const s=Eo(e,h),l=new x().setFromMatrixPosition(s),c=new x(0,1,0).applyMatrix4(s),_=Ao(t,h),d=Po(t,h);r.push(l.x,l.y,l.z,c.x,c.y,c.z),i.push(_.r,_.g,_.b,_.r,_.g,_.b),f.push(l.x,l.y,l.z,c.x,c.y,c.z),u.push(d.r,d.g,d.b,d.r,d.g,d.b)}return a.add(this.lines(r,i,Ia)),a.add(this.lines(f,u,Fa)),a}solidMesh(t,n,e,a){const r=new hn;r.setAttribute("position",new St(t,3)),r.setAttribute("normal",new St(n,3)),r.setAttribute("aSolid",new St(e,3)),r.setAttribute("aHint",new St(a,3));const i=new so({vertexShader:za,fragmentShader:Da,side:Ce});this.disposables.push(r,i);const f=new Rt(r,i);return f.frustumCulled=!1,f}lines(t,n,e){const a=new ne;a.setPositions(t),a.setColors(n);const r=new oe({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const i=new ee(a,r);return i.frustumCulled=!1,i}point(t,n){const e=new ke(Ra,12,8),a=new En({color:n});this.disposables.push(e,a);const r=new Rt(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 Mo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",en="RUNTIME_FRAME_UNKNOWN_IMAGE";function La(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 I=Math.fround,Rn=I(2*Math.PI),$n=I(1-1e-4),Bt=(o,t)=>I(I(I(o[0]*t[0])+I(o[1]*t[1]))+I(o[2]*t[2])),_n=(o,t,n=1)=>o.map((e,a)=>I(e+I(t[a]*n))),Va=(o,t)=>o.map((n,e)=>I(n-t[e]));function an(o){const t=I(Math.sqrt(Bt(o,o)));return t>0?o.map(n=>I(n/t)):[0,0,0]}function rn(o){const t=Math.abs(o)<1?I(1-I(1-Math.abs(o))):1;let n=I(I(.077980478)+I(t*I(-.02164095)));n=I(I(-.213300989)+I(t*n)),n=I(I(1.5707963267)+I(t*n));const e=I(I(Math.sqrt(I(1-t)))*n);return o<0?I(I(Math.PI)-e):e}function ja(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,i=(a+2)%3;n[a]=I(n[a]+I(I(t[r]-e[r])*I(t[i]+e[i])))}t=e}return n}function Ba(o){const t=[],n=[],e=(d,m)=>d<m?`${d}:${m}`:`${m}:${d}`,a=new Map((o.edge_order??[]).map(([d,m],p)=>[e(d,m),p])),r=new Set((o.sharp??[]).map(([d,m])=>e(d,m))),i=new Map;for(const[d,m]of o.f.entries()){const p=t.length,v=La(ja(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 w=e(m[g],m[(g+1)%m.length]);a.has(w)||a.set(w,a.size);const y=o.face_edges?.[d]?.[g]??a.get(w),S=t.length;t.push({vertex:m[g],face:d,edge:y,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=i.get(y)??[];T.push(S),i.set(y,T)}}const f=new Map,u=new Map;for(const[d,m]of i){if(m.length!==2||o.edge_sharp?.[d])continue;const[p,v]=m,g=t[p],w=t[v];!o.s?.[g.face]||!o.s?.[w.face]||g.vertex!==t[w.next].vertex||w.vertex!==t[g.next].vertex||!o.edge_sharp&&r.has(e(g.vertex,w.vertex))||(u.set(p,w.next),f.set(w.next,p),u.set(v,g.next),f.set(g.next,v))}const h=[],s=[],l=[],c=[],_=(d,m)=>an(Va(o.v[t[t[d][m]].vertex],o.v[t[d].vertex]));for(let d=0;d<t.length;d++){if(s[d]!==void 0)continue;let m=d;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(;f.has(v.at(-1))&&f.get(v.at(-1))!==m;)v.push(f.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=_n(g,n[t[M].face],rn(Bt(_(M,"prev"),_(M,"next"))));g=an(g)}const w=_(m,"next"),y=v.at(-1),S=_(y,"prev"),T=Bt(w,g),A=Bt(S,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<$n&&Math.abs(A)<$n){const M=v.length>1?v.map(st=>_(st,"next")):[];M.length&&t[t[y].prev].edge!==t[m].edge&&M.push(S),O.alpha=M.length?I(M.reduce((st,b)=>I(st+rn(Bt(b,g))),0)/M.length):I(I(rn(T)+rn(A))/2),O.reference=an(_n(w,g,-T));const k=g,j=O.reference;O.ortho=an([I(I(k[1]*j[2])-I(k[2]*j[1])),I(I(k[2]*j[0])-I(k[0]*j[2])),I(I(k[0]*j[1])-I(k[1]*j[0]))]);const q=an(_n(S,g,-A)),Q=Bt(O.reference,q),K=rn(Q);O.beta=Q<$n?Bt(O.ortho,q)<0?I(Rn-K):K:Rn}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)s[M]=h.length;h.push(v),l.push(O),c.push(g)}return{corners:t,fans:h,fanOf:s,spaces:l,faceNormals:n,fanNormals:c}}function Ua(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=I(t[0]/32767),e=I(t[1]/32767),a=I((n>0?o.alpha:I(Rn-o.alpha))*n),r=I((e>0?o.beta:I(Rn-o.beta))*e);let i=o.normal.map(f=>I(f*I(Math.cos(a))));return i=_n(i,o.reference,I(I(Math.sin(a))*I(Math.cos(r)))),e!==0&&(i=_n(i,o.ortho,I(I(Math.sin(a))*I(Math.sin(r))))),i}function de(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Ba(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const r=new Array(n.length);for(const[i,f]of e.entries()){const u=f.reduce((s,l)=>{const c=t.data[l];return[s[0]+c[0],s[1]+c[1]]},[0,0]),h=Ua(a[i],u.map(s=>Math.trunc(s/f.length)));for(const s of f)r[s]=h}return r}if(t.type==="FLOAT_VECTOR")return n.map((r,i)=>{const f=t.domain==="POINT"?r.vertex:t.domain==="FACE"?r.face:i;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Ln={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}},Wa=1e-6;function Ha(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 qa=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),No=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ga(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 Ro(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,i,f]of o){const u=qa(t[r],t[i],t[f]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Wa*Math.abs(n)}function Xa(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=Ha(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:No(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),i=new x().crossVectors(r,a).normalize(),f=new x().crossVectors(a,i),u=o[0],h=o.map(_=>{const d=_.clone().sub(u);return new qt(d.dot(i),d.dot(f))}),s=Ga(h),l=No(t);if(Ro(l,h,s))return{triangles:l,sound:!0,method:"fan"};let c=[];try{c=$e.triangulateShape(h,[]).map(_=>[_[0],_[1],_[2]])}catch{return{triangles:l,sound:!1,method:"fan"}}return Ro(c,h,s)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:l,sound:!1,method:c.length>0?"earcut":"fan"}}const Ya=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Vn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function jn(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[Vn(Number(t[n*4])),Vn(Number(t[n*4+1])),Vn(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 uo(o,t){return o.filter(n=>Ya.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,i,f)=>n.domain==="POINT"?jn(n.type,e,r):n.domain==="CORNER"?i===void 0?a:jn(n.type,e,i):f===void 0?a:jn(n.type,e,f)}})}function he(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,a=o.cornerVerts,r=e[n];let i=t;for(let b=0;b<n;b++)i+=(e[b+1]-e[b]-2)*3;const f=new Uint32Array(r),u=new Uint8Array(r),h=new Uint8Array(t),s=new Uint32Array(r);let l=!1;for(let b=0;b<n;b++)if(o.smooth(b)){l=!0;break}const c=(b,V)=>t<94906265?Math.min(b,V)*t+Math.max(b,V):`${Math.min(b,V)}:${Math.max(b,V)}`,_=new Map,d=new Set;for(const[b,V]of o.sharp)d.add(c(b,V));if(o.edges)for(const[b,V]of o.edges){if(b===V)throw new Error("Runtime mesh edge needs distinct vertices");_.set(c(b,V),-1)}const m=b=>{for(;s[b]!==b;)s[b]=s[s[b]],b=s[b];return b},p=(b,V)=>{const z=m(b),X=m(V);s[Math.max(z,X)]=Math.min(z,X)};for(let b=0;b<n;b++){const V=e[b],z=e[b+1]-V,X=o.smooth(b)?1:0;for(let Y=0;Y<z;Y++){const $=V+Y;h[a[$]]=1,f[$]=V+(Y+1)%z,u[$]=X,s[$]=$}}for(let b=0;b<r;b++){const V=f[b],z=a[b],X=a[V],Y=c(z,X),$=_.get(Y);if($!==void 0&&$>=0&&u[b]&&u[$]&&!d.has(Y)){const E=f[$];p(b,a[$]===z?$:E),p(V,a[$]===z?E:$)}($===void 0||$<0||!u[$]&&u[b])&&_.set(Y,b)}const v=o.uv,g=new Float32Array(i*3),w=new Float32Array(i*2),y=new Uint32Array(i),S=(o.uvLayers??[]).map(b=>({...b,data:new Float32Array(i*2)})),T=(o.attributeLayers??[]).map(b=>({...b,data:new Float32Array(i*4)})),A=o.orco?new Float32Array(i*3):null,O=new Uint32Array(i),M=new Map,k=[],j=o.normals||o.cornerNormal?new Float32Array(i*3):null;let q=0,Q=0;const K=(b,V,z,X,Y)=>{const $=q++;for(const E of T)E.data.set(E.read(b,X,Y),$*4);if(A)for(let E=0;E<3;E++)A[$*3+E]=o.orco[b*3+E]*.5+.5;if(y[$]=b,o.co(b).toArray(g,$*3),V&&w.set(V,$*2),z&&j.set(z,$*3),X!==void 0)for(const E of S)E.data.set(E.read(X),$*2);return $},st=(b,V)=>{const z=v?.(b),X=o.cornerNormal?[o.cornerNormal[b*3],o.cornerNormal[b*3+1],o.cornerNormal[b*3+2]]:o.normals?.[b];if(!l)return K(a[b],z,X,b,V);const Y=`${u[b]?m(b):b}${z?`:${z[0]}:${z[1]}`:""}${X?`:n${X.join(":")}`:""}${S.map(E=>":"+E.read(b).join(":")).join("")}${T.map(E=>E.domain==="POINT"?"":":"+Array.from(E.read(a[b],b,V)).join(":")).join("")}`;let $=M.get(Y);return $===void 0&&($=K(a[b],z,X,b,V),M.set(Y,$)),$};for(let b=0;b<n;b++){const V=Q,z=e[b],X=e[b+1]-z,Y=[];for(let B=0;B<X;B++)Y.push(o.co(a[z+B]));for(const B of Xa(Y).triangles)for(const J of B)O[Q++]=st(z+J,b);const $=o.material(b),E=k.at(-1);E?.materialIndex===$?E.count+=Q-V:k.push({start:V,count:Q-V,materialIndex:$})}for(let b=0;b<t;b++)h[b]||K(b);return{positions:g.slice(0,q*3),normals:j?.slice(0,q*3)??null,uv:v?w.slice(0,q*2):null,uvLayers:S.map(b=>({name:b.name,data:b.data.slice(0,q*2)})),attributeLayers:T.map(b=>({name:b.name,data:b.data.slice(0,q*4)})),orco:A?A.slice(0,q*3):null,indices:O.slice(0,Q),sourceVertex:y.slice(0,q),groups:k}}function Xt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function Pn(o){const t=new hn;t.setAttribute("position",new dt(o.positions,3)),t.setAttribute("uv",new dt(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new dt(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 dt(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(Xt(e.name),new dt(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new dt(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 dt(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new dt(o.sourceVertex,1)),t}function Za(o,t){const n=o.cornerTri,e=o.cornerNormal,a=o.co.length/3,r=o.corner.length,i=o.faceStart.length-1,f=o.attributes.filter(E=>E.type==="FLOAT2"&&E.domain==="CORNER"),u=o.renderUv??o.activeUv??f[0]?.name,h=f.findIndex(E=>E.name===u);if(u&&h<0)throw new Error(`Runtime UV map ${u} is missing`);const s=uo(o.attributes,E=>E),l=3+f.length*2+s.length*4,c=new Float32Array(l),_=new Float32Array(l),d=new Uint32Array(c.buffer),m=new Uint32Array(_.buffer),p=new Uint32Array(r),v=new Uint32Array(r),g=new Uint32Array(r),w=new Uint32Array(r),y=new Uint8Array(a);let S=1;for(;S<Math.max(1,r*2);)S*=2;const T=new Uint32Array(S),A=(E,B,J,nt)=>{let ct=0;for(let rt=0;rt<3;rt++)nt[ct++]=e[E*3+rt];for(const rt of f)for(let it=0;it<2;it++)nt[ct++]=Number(rt.data[E*2+it]);for(const rt of s){const it=rt.read(J,E,B);for(let At=0;At<4;At++)nt[ct++]=Number(it[At])}};let O=0;for(let E=0;E<i;E++)for(let B=o.faceStart[E];B<o.faceStart[E+1];B++){const J=o.corner[B];if(J>=a)throw new Error("Native mesh corner references a missing vertex");p[B]=E,y[J]=1,A(B,E,J,c);let nt=Math.imul(J^2166136261,16777619);for(const it of d)nt=Math.imul(nt^it,16777619);const ct=nt>>>0&S-1;let rt=-1;for(let it=T[ct];it;it=w[it-1]){const At=it-1,Cn=g[At];if(o.corner[Cn]!==J)continue;A(Cn,p[Cn],J,_);let yo=!0;for(let pn=0;pn<l;pn++)if(d[pn]!==m[pn]){yo=!1;break}if(yo){rt=At;break}}rt<0&&(rt=O++,g[rt]=B,w[rt]=T[ct],T[ct]=rt+1),v[B]=rt}let M=0;for(const E of y)E||M++;const k=O+M,j=new Float32Array(k*3),q=new Float32Array(k*3),Q=new Uint32Array(k),K=f.map(E=>({name:E.name,data:new Float32Array(k*2)})),st=s.map(E=>({name:E.name,data:new Float32Array(k*4)})),b=o.orco?new Float32Array(k*3):null,V=(E,B)=>{Q[E]=B;for(let J=0;J<3;J++)j[E*3+J]=o.co[B*3+J],b&&(b[E*3+J]=o.orco[B*3+J]*.5+.5)};for(let E=0;E<O;E++){const B=g[E],J=o.corner[B];V(E,J),A(B,p[B],J,c),q.set(c.subarray(0,3),E*3);let nt=3;for(const ct of K)ct.data.set(c.subarray(nt,nt+2),E*2),nt+=2;for(const ct of st)ct.data.set(c.subarray(nt,nt+4),E*4),nt+=4}let z=O;for(let E=0;E<a;E++)if(!y[E]){V(z,E);for(let B=0;B<s.length;B++)st[B].data.set(s[B].read(E,void 0,void 0),z*4);z++}const X=new Uint32Array(n.length),Y=[];let $=0;for(let E=0;E<i;E++){const B=o.faceStart[E],J=o.faceStart[E+1],nt=Math.max(0,J-B-2)*3;if($+nt>n.length)throw new Error("Native mesh triangulation is incomplete");for(let it=0;it<nt;it++){const At=n[$+it];if(At<B||At>=J)throw new Error("Native triangle references a different face");X[$+it]=v[At]}const ct=o.material[E],rt=Y.at(-1);rt?.materialIndex===ct?rt.count+=nt:Y.push({start:$,count:nt,materialIndex:ct}),$+=nt}if($!==n.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:j,normals:q,sourceVertex:Q,uv:h<0?null:K[h].data,uvLayers:K,attributeLayers:st,orco:b,indices:X,groups:Y,hash:t}}function Io(o,t){if(o.cornerTri&&o.cornerNormal)return Za(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 i=r?r.data:null,f=o.edge.length/2,u=new Array(f);for(let m=0;m<f;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const h=[];for(let m=0;m<f;m++)o.edgeSharp[m]===1&&h.push(u[m]);const s=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),l=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:h,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,c=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/Ln[s.type].size},(m,p)=>Array.from({length:Ln[s.type].size},(v,g)=>Number(s.data[p*Ln[s.type].size+g])))}:void 0,_=new x,d={vertexCount:n,normals:l?de(l,c):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>_.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:h,uv:i?m=>[i[m*2],i[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:uo(o.attributes,m=>m)};return{...he(d),hash:t}}function Qa(o){const t=o.v.map(l=>new x(...l)),n=l=>{const c=t[l];if(!c)throw new Error(`Runtime mesh vertex ${l} is missing`);return c},e=new Uint32Array(o.f.length+1);o.f.forEach((l,c)=>{if(l.length<3||new Set(l).size!==l.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[c+1]=e[c]+l.length});const a=new Uint32Array(e[o.f.length]);o.f.forEach((l,c)=>l.forEach((_,d)=>{n(_),a[e[c]+d]=_}));for(const[l,c]of o.edge_order??o.e??[])n(l),n(c);const r={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:a.length};for(const l of o.attributes??[])if(l.domain!=="EDGE"&&l.data.length!==r[l.domain])throw new Error(`Runtime attribute ${l.name} has ${l.data.length} values for ${r[l.domain]} ${l.domain} elements`);const i=(o.attributes??[]).filter(l=>l.type==="FLOAT2"&&l.domain==="CORNER"),f=o.render_uv??o.active_uv??i[0]?.name,u=i.find(l=>l.name===f);if(f&&!u)throw new Error(`Runtime UV map ${f} is missing`);const h=u?.data,s={vertexCount:t.length,normals:de(o,o.attributes?.find(l=>l.name==="custom_normal")),co:n,starts:e,cornerVerts:a,smooth:l=>!!o.s?.[l],material:l=>o.m?.[l]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:h?l=>h[l]:null,uvLayers:i.map(l=>({name:l.name,read:c=>l.data[c]})),attributeLayers:uo(o.attributes??[],l=>Array.from(l).flat())};return Pn(he(s))}const dn=1.5707963267948966,Ut=6.283185307179586,pe=.3183098861837067,ve=.0795774715459476,Ka=.3,Ja=ve,tr=3/16*pe,no=.8,Fo=no*no,Wt=6371,ge=100,oo=Wt+ge,zo=64,Do=64,ft=256,$t=64,nr=[1.679,1.828,1.986,1.307],or=[.006605,.01067,.01842,.03156],er=[3472e-28,3914e-28,1349e-28,1103e-29],ar=334.5,rr=[28722e-28,46168e-28,79706e-28,13578e-27],lr=[15908e-26,17711e-26,20942e-26,24033e-26],Co=13681e16,ir=2e6,sr=.73,Bn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],Et=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],In=o=>o*o,fn=o=>o<0?0:o>1?1:o,Nt=(o,t,n)=>o+n*(t-o),fr=o=>Math.sqrt(Math.max(o,0)),xe=o=>[-Math.sqrt(1-o*o),0,o];function eo(o,t,n,e,a,r,i){const f=o*e+t*a+n*r,u=o*o+t*t+n*n-i*i;if(u>0&&f>0)return-1;const h=f*f-u;return h<0?-1:h>=f*f?-f+Math.sqrt(h):-f-Math.sqrt(h)}const cr=o=>tr*(1+In(o));function ur(o){const t=1+Fo+2*no*o;return ve*(1-Fo)/(t*Math.sqrt(t))}const _r=o=>Co*(Math.exp(-o/sr)+ir/Co);function _o(o,t){let n=o%Ut;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=dn||n<=-dn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Ut,e<0&&(e+=Ut),e=Ut-e,[n,e]}class mr{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array($t*ft*4)}coefficients(t,n){const e=_r(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-In(a-3.22261)*5.55555555-a),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=rr[f]*e,n[4+f]=lr[f]*e,n[8+f]=er[f]*ar*r*this.ozone,n[12+f]=or[f]*i*this.air}transmittance(t,n,e){const[a,r,i]=xe(t),f=Nt(Wt,oo,n),h=eo(0,0,f,a,r,i,oo)/zo,s=[0,0,0,0],l=new Float64Array(16);for(let c=0;c<zo;c++){const _=(c+.5)*h,d=a*_,m=r*_,p=f+i*_,v=Math.max(Math.hypot(d,m,p)-Wt,0);this.coefficients(v,l);for(let g=0;g<4;g++)s[g]+=(l[g]+l[4+g]+l[8+g]+l[12+g])*h}for(let c=0;c<4;c++)e[c]=Math.exp(-s[c])}precompute(){const t=new Float64Array(4);for(let n=0;n<$t;n++)for(let e=0;e<ft;e++){const a=e/(ft-1),r=n/($t-1);this.transmittance(a*2-1,r,t);const i=(n*ft+e)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,n,e){const a=(ft-1)*fn(t*.5+.5),r=($t-1)*fn(n),i=Math.trunc(a),f=Math.trunc(r),u=Math.min(i+1,ft-1),h=Math.min(f+1,$t-1),s=a-i,l=r-f,c=(f*ft+i)*4,_=(f*ft+u)*4,d=(h*ft+i)*4,m=(h*ft+u)*4;for(let p=0;p<4;p++)e[p]=Nt(Nt(this.lut[c+p],this.lut[_+p],s),Nt(this.lut[d+p],this.lut[m+p],s),l)}lookupAtGround(t,n){const e=(ft-1)*fn(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,ft-1),i=e-a;for(let f=0;f<4;f++)n[f]=Nt(this.lut[a*4+f],this.lut[r*4+f],i)}lookupToSun(t,n){const e=($t-1)*fn(t),a=Math.trunc(e),r=Math.min(a+1,$t-1),i=e-a,f=ft-1;for(let u=0;u<4;u++)n[u]=Nt(this.lut[(a*ft+f)*4+u],this.lut[(r*ft+f)*4+u],i)}inscattering(t,n,e,a,r,i,f,u,h){const s=-(r*t[0]+i*t[1]+f*t[2]),l=cr(s),c=ur(s),_=u/Do,d=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),w=new Float64Array(4),y=[0,0,0,0],S=[1,1,1,1];for(let T=0;T<Do;T++){const A=(T+.5)*_,O=n+r*A,M=e+i*A,k=a+f*A,j=Math.hypot(O,M,k),q=Math.max(j-Wt,0),Q=q/ge,K=(O*t[0]+M*t[1]+k*t[2])/j;this.coefficients(q,d),this.lookup(K,Q,m);const st=Ut*(1-fr(1-In(Wt/j)));this.lookupAtGround(K,v),this.lookupToSun(0,g),this.lookupToSun(Q,w);const b=1/(1+5*Math.exp(-17.92*K)),V=[.217,.347,.594,1];for(let z=0;z<4;z++){const X=g[z]/w[z],Y=Ja*st*(Ka*pe)*v[z]*X*K;p[z]=.02*V[z]*b+Y}for(let z=0;z<4;z++){const X=d[z]+d[4+z]+d[8+z]+d[12+z],Y=nr[z]*(d[12+z]*(l*m[z]+p[z])+d[4+z]*(c*m[z]+p[z])),$=Math.exp(-_*X),E=Math.max(X,1e-7);y[z]+=S[z]*((Y-Y*$)/E),S[z]*=$}}for(let T=0;T<4;T++)h[T]=y[T]}}const ht=512,Jt=256;function be(o,t){const n=new mr(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=xe(Math.cos(dn-t)),r=new Float32Array(ht*Jt*3),i=ht/2,f=new Float64Array(4);for(let u=0;u<Jt;u++)for(let h=0;h<i;h++){const s=(h+.5)/ht,l=(u+.5)/Jt,c=Ut*s,_=l*2-1,d=Math.sign(_)*In(_)*dn,m=Math.cos(d)*Math.cos(c),p=Math.cos(d)*Math.sin(c),v=Math.sin(d),g=Wt+e,w=eo(0,0,g,m,p,v,oo),y=eo(0,0,g,m,p,v,Wt),S=y<0?w:y;n.inscattering(a,0,0,g,m,p,v,S,f);let T=0,A=0,O=0;for(let j=0;j<4;j++)T+=Bn[j][0]*f[j],A+=Bn[j][1]*f[j],O+=Bn[j][2]*f[j];const M=(u*ht+h)*3;r[M]=T,r[M+1]=A,r[M+2]=O;const k=(u*ht+(ht-h-1))*3;r[k]=T,r[k+1]=A,r[k+2]=O}return r}function dr(o){const[t]=_o(o.sunElevation,o.sunRotation);return be(o,t)}function mo(o){const[t]=_o(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const hr=6,Qt=new Map;function pr(o){return Qt.has(mo(o))}function ye(o,t){Qt.set(mo(o),t),Qt.size>hr&&Qt.delete(Qt.keys().next().value)}function vr(o){const[t,n]=_o(o.sunElevation,o.sunRotation),e=mo(o);let a=Qt.get(e);a===void 0&&(a=be(o,t),ye(o,a));const r=new x;return i=>{const f=Math.hypot(i.x,i.y),u=Math.atan2(i.z,f);let s=(Math.atan2(i.x,i.y)+Math.PI+n)/Ut;s-=Math.floor(s);const l=Math.abs(u),c=fn(Math.sqrt(l/dn)*Math.sign(u)*.5+.5),_=s*ht-.5,d=c*Jt-.5,m=Math.floor(_),p=Math.floor(d),v=_-m,g=d-p,w=k=>(k%ht+ht)%ht,y=k=>k<0?0:k>Jt-1?Jt-1:k,S=w(m),T=w(m+1),A=y(p),O=y(p+1),M=[0,0,0];for(let k=0;k<3;k++){const j=Nt(a[(A*ht+S)*3+k],a[(A*ht+T)*3+k],v),q=Nt(a[(O*ht+S)*3+k],a[(O*ht+T)*3+k],v);M[k]=Nt(j,q,g)}return r.set(Et[0][0]*M[0]+Et[0][1]*M[1]+Et[0][2]*M[2],Et[1][0]*M[0]+Et[1][1]*M[1]+Et[1][2]*M[2],Et[2][0]*M[0]+Et[2][1]*M[1]+Et[2][2]*M[2])}}let Ft=null,vn=!1,gr=0;const cn=new Map;function xr(){if(Ft||vn)return Ft;if(typeof Worker>"u")return vn=!0,null;try{Ft=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return vn=!0,null}return Ft.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,a=cn.get(t);a&&(cn.delete(t),n?a.resolve(n):a.reject(new Error(e??"sky worker returned nothing")))},Ft.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of cn.values())n.reject(t);cn.clear(),Ft?.terminate(),Ft=null,vn=!0},Ft}function br(o){const t=xr();if(!t)return Promise.resolve(dr(o));const n=gr++,e={id:n,parameters:o};return new Promise((a,r)=>{cn.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function yr(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 Un=(o,t)=>t!==0?o/t:0,ko=o=>Math.min(1,Math.max(-1,o)),$o=(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},we={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:Un,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:Un(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(Un(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(ko(o)),ARCCOSINE:o=>Math.acos(ko(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:$o,SMOOTH_MAX:(o,t,n)=>-$o(-o,-t,n)};function at(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=at(o.vector,t),r={type:o.gradient_type},i=new x;return f=>{const u=a(f),h=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,l=typeof u=="number"?u:u.z,c=gt.clamp(yr(h,s,l,r),0,1);return o.output==="Fac"?c:i.setScalar(c)}}if(o.kind==="to_float"){const a=at(o.value,t);return r=>{const i=a(r);return typeof i=="number"?i:Math.fround(o.source_type==="RGBA"?i.x*.212639+i.y*.7151687+i.z*.0721923:(i.x+i.y+i.z)/3)}}if(o.kind==="math"){const a=o.inputs.map(f=>at(f,t)),r=we[o.operation],i=(f,u)=>{const h=a[f]?.(u)??0;if(typeof h!="number")throw new Error("World Math needs scalar inputs");return Math.fround(h)};return f=>{const u=Math.fround(r(i(0,f),i(1,f),i(2,f)));return o.clamp?gt.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=at(o.factor,t),r=at(o.a,t),i=at(o.b,t),f=new x,u=new x;return h=>{const s=a(h);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const l=r(h);typeof l=="number"?f.setScalar(l):f.copy(l);const c=i(h);return typeof c=="number"?u.setScalar(c):u.copy(c),f.lerp(u,o.clamp_factor?gt.clamp(s,0,1):s),o.clamp_result&&f.clampScalar(0,1),f}}if(o.kind==="sky"){const a=vr({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=at(o.vector,t),r=new x(...o.location),i=new x(...o.scale),f=new Tt().setFromEuler(new Le(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=f.clone().invert(),h=new x(...o.scale.map(l=>l===0?0:1/l)),s=new x;return l=>{const c=a(l);switch(typeof c=="number"?s.setScalar(c):s.copy(c),o.vector_type??"POINT"){case"TEXTURE":return s.sub(r).applyQuaternion(u).multiply(h);case"VECTOR":return s.multiply(i).applyQuaternion(f);case"NORMAL":return s.multiply(h).applyQuaternion(f).normalize();case"POINT":return s.multiply(i).applyQuaternion(f).add(r)}}}if(o.kind==="map_range"){const a=at(o.value,t),r=at(o.from_min,t),i=at(o.from_max,t),f=at(o.to_min,t),u=at(o.to_max,t),h=at(o.steps,t),s=(_,d)=>{const m=_(d);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},l=o.interpolation,c=o.clamp;return _=>{const d=s(a,_),m=s(r,_),p=s(i,_),v=s(f,_),g=s(u,_);if(m===p)return 0;let w;if(l==="STEPPED"){const S=s(h,_),T=(d-m)/(p-m);w=S>0?Math.floor(T*(S+1))/S:0}else if(l==="SMOOTHSTEP"||l==="SMOOTHERSTEP"){const S=gt.clamp((d-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=l==="SMOOTHSTEP"?S*S*(3-2*S):S*S*S*(S*(S*6-15)+10);w=m>p?1-T:T}else w=(d-m)/(p-m);const y=v+w*(g-v);return c?v>g?gt.clamp(y,g,v):gt.clamp(y,v,g):y}}if(o.kind==="separate"){const a=at(o.vector,t);return r=>{const i=a(r);return typeof i=="number"?i:i.getComponent(o.axis)}}const n=at(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 i=gt.clamp(r,0,1)*256,f=Math.floor(i),u=o.colors[f],h=o.colors[Math.min(f+1,256)],s=o.interpolate?i-f:0;return e.set(gt.lerp(u[0],h[0],s),gt.lerp(u[1],h[1],s),gt.lerp(u[2],h[2],s))}}function wr(o,t,n,e){const a=new Float32Array(t*n*3),r=at(o,e),i=new x;for(let f=0;f<n;f++){const u=((f+.5)/n-.5)*Math.PI;for(let h=0;h<t;h++){const s=((h+.5)/t-.5)*2*Math.PI;i.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const l=r(i),c=(f*t+h)*3;a[c]=typeof l=="number"?l:l.x,a[c+1]=typeof l=="number"?l:l.y,a[c+2]=typeof l=="number"?l:l.z}}return a}function Lo(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 Dt(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Dt(o.vector);case"ramp":return Dt(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Dt);case"math":return o.inputs.some(Dt);case"to_float":return Dt(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Dt);default:return!1}}function Or(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,i=at(o,()=>r),f=new x,u=e.getWorldPosition(new x),h=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let l=0;l<t;l++){const c=(l+.5)/t,_=(s+.5)/n;r.set(c,_,0),e.isOrthographicCamera?f.copy(h):f.set(c*2-1,_*2-1,.5).unproject(e).sub(u).normalize(),f.set(f.x,-f.z,f.y);const d=i(f),m=(s*t+l)*3;a[m]=typeof d=="number"?d:d.x,a[m+1]=typeof d=="number"?d:d.y,a[m+2]=typeof d=="number"?d:d.z}return a}const et=N().finite(),Tr=P({type:H(["POINT","SUN","SPOT","AREA"]),color:L([et,et,et]),energy:et,use_shadow:Z().default(!0),radius:et.optional(),spot_size:et.optional(),spot_blend:et.optional(),shape:H(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:et.optional(),size_y:et.optional()}).strict();let ao;function Ar(){return ao??=ya(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),Ot()}),ao}function Pr(){return ao??Promise.resolve()}const Sr=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 Er(o,t){const n=(i,f)=>t&&f(t)?t:new i;if(o.type==="SUN"){const i=n(le,f=>f.isDirectionalLight);return i.intensity=o.energy,i.color.setRGB(o.color[0],o.color[1],o.color[2],pt),i.castShadow=o.use_shadow,i}if(o.type==="POINT"){const i=n(Zn,f=>f.isPointLight);return i.intensity=o.energy/(4*Math.PI),i.distance=0,i.decay=2,i.color.setRGB(o.color[0],o.color[1],o.color[2],pt),i.castShadow=o.use_shadow,i}if(o.type==="SPOT"){const i=n(Qn,f=>f.isSpotLight);return i.intensity=o.energy/(4*Math.PI),i.distance=0,i.decay=2,i.angle=(o.spot_size??0)/2,i.penumbra=o.spot_blend??0,i.color.setRGB(o.color[0],o.color[1],o.color[2],pt),i.castShadow=o.use_shadow,i}Ar();const e=n(An,i=>i.isRectAreaLight),[a,r]=Sr(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],pt),e}function Mr(o,t,n){if(!o.castShadow||n<=0)return;const a=o.getWorldPosition(new x).distanceTo(t),r=o.shadow;if(!r)return;const i=r.camera;i.near=Math.max(n*.001,a-n),i.far=a+n,o.isDirectionalLight&&(i.left=-n,i.right=n,i.top=n,i.bottom=-n),i.updateProjectionMatrix()}function Nr(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 ho=[{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}],Vo=.69;class Rr{constructor(){this.group=new lt,this.lights=[],this.group.name="BlenderSolidStudio";const t=new re;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new wt(0,0,0);for(const[a,r]of ho.entries()){const i=(1+r.smooth)**2,f=new le(16777215,Math.PI*Vo/i);f.name=`BlenderSolidLight${a}`,f.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],pt),f.position.set(r.direction[0],r.direction[1],r.direction[2]),f.target=t,this.group.add(f),this.lights.push(f),n.r+=r.diffuse[0]*r.smooth/i,n.g+=r.diffuse[1]*r.smooth/i,n.b+=r.diffuse[2]*r.smooth/i}const e=new Ve(16777215,Math.PI*Vo);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 Zt=L([et,et,et]),G=_e(()=>kt([et,Zt,P({kind:W("direction")}).strict(),P({kind:W("window")}).strict(),P({kind:W("gradient"),gradient_type:H(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:H(["Fac","Color"]),vector:G}).strict(),P({kind:W("to_float"),source_type:H(["RGBA","VECTOR"]),value:G}).strict(),P({kind:W("math"),operation:H(Object.keys(we)),clamp:Z(),inputs:D(G).min(1).max(3)}).strict(),P({kind:W("mix_color"),factor:G,a:G,b:G,clamp_factor:Z(),clamp_result:Z()}).strict(),P({kind:W("mapping"),vector_type:H(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:G,location:Zt,rotation:Zt,scale:Zt}).strict(),P({kind:W("separate"),vector:G,axis:N().int().min(0).max(2)}).strict(),P({kind:W("ramp"),factor:G,colors:D(Zt).length(257),interpolate:Z()}).strict(),P({kind:W("map_range"),interpolation:H(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:Z(),value:G,from_min:G,from_max:G,to_min:G,to_max:G,steps:G}).strict(),P({kind:W("sky"),sun_elevation:et,sun_rotation:et,altitude:et,air_density:et,aerosol_density:et,ozone_density:et}).strict()])),jo=P({color:Zt,strength:et,shader:G.optional()}),Ir=jo.extend({volume:D(P({kind:H(["absorption","scatter","principled","emission"]),phase:R(),alpha:G,weight:G,color:G,density:G,anisotropy:G,absorption_color:G,emission_color:G,emission_strength:G,blackbody_intensity:G,temperature:G,blackbody_tint:G}).strict()).optional(),lighting:jo.strict().optional()}).strict(),Fr=4,ln=new Map,Wn=new Set;function Bo(o,t,n){const r=Dt(o);if(r&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const i=JSON.stringify([o,r?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),f=ln.get(i);if(f!==void 0)return ro(f,t,256,128);const u=new x,h=new fo,s=n?new tt().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,l=n?.getWorldPosition(new x),_=wr(o,256,128,r?d=>(u.set(d.x,d.z,-d.y),n.isPerspectiveCamera&&u.add(l),h.set(u.x,u.y,u.z,1).applyMatrix4(s),h.w===0?u.set(0,0,0):u.set(h.x/h.w*.5+.5,h.y/h.w*.5+.5,0)):void 0);return ln.set(i,_),ln.size>Fr&&ln.delete(ln.keys().next().value),ro(_,t,256,128)}function zr(o,t,n,e){const a=sn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=sn.toHalfFloat(t[r*3]*n),o[r*4+1]=sn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=sn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function ro(o,t,n,e){const a=new Uint16Array(n*e*4);zr(a,o,t,n*e);const r=new zn(a,n,e,Dn,co);return r.mapping=Be,r.colorSpace=pt,r.minFilter=Gt,r.magFilter=Gt,r.needsUpdate=!0,r}class po{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=po.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,i=this.generation,u=[...Lo(r),...n.lighting?Lo(n.lighting.shader??n.lighting.color):[]].filter(s=>!pr(s));if(u.length===0){this.compose(a,n,r,e);return}const h=(async()=>{const s=await Promise.all(u.map(br));u.forEach((l,c)=>{ye(l,s[c])}),!(this.generation!==i||this.applied?.scene!==a)&&(this.compose(a,n,r,e),Ot())})();this.pending=h,Wn.add(h),h.then(()=>Wn.delete(h),()=>Wn.delete(h))}compose(t,n,e,a){if(this.texture=Bo(e,n.strength,a),Dt(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=ro(Or(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=je,t.background=this.screenTexture}else if(a&&a.isOrthographicCamera){const i=a.getWorldDirection(new x);i.set(i.x,-i.z,i.y);const f=at(n.shader??n.color)(i);t.background=typeof f=="number"?new wt().setRGB(f,f,f).multiplyScalar(n.strength):new wt().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?Bo(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 Oe(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 Dr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=Oe(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new Vt(new x(1,0,0),-o.min.x),new Vt(new x(-1,0,0),o.max.x),new Vt(new x(0,1,0),-o.min.y),new Vt(new x(0,-1,0),o.max.y),new Vt(new x(0,0,1),-o.min.z),new Vt(new x(0,0,-1),o.max.z)],a=[],r=new x,i=new x,f=new x,u=new x,h=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let l=s+1;l<e.length;l++)for(let c=l+1;c<e.length;c++){const _=e[s],d=e[l],m=e[c];r.crossVectors(d.normal,m.normal);const p=_.normal.dot(r);Math.abs(p)<1e-12||(i.crossVectors(m.normal,_.normal),f.crossVectors(_.normal,d.normal),u.copy(r).multiplyScalar(-_.constant).addScaledVector(i,-d.constant).addScaledVector(f,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-h)&&a.push(u.clone()))}return a}function Cr(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new Mn().setFromPoints(t.map(c=>c.clone().applyMatrix4(a))),i=r.getSize(new x),f=Math.max(i.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,h=Math.max(i.x,i.y,f)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*h,l=u*h;r.min.x-=l,r.min.y-=l,r.max.x+=l,r.max.y+=l;for(const c of n){if(c.isEmpty())continue;const _=new Mn().setFromPoints(Oe(c).map(d=>d.applyMatrix4(a)));_.max.x<r.min.x||_.min.x>r.max.x||_.max.y<r.min.y||_.min.y>r.max.y||(r.min.z=Math.min(r.min.z,_.min.z),r.max.z=Math.max(r.max.z,_.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-f,e.far=-r.min.z+s+f,e.updateProjectionMatrix(),o.shadow.normalBias=s}const tn=N().finite(),Uo=L([tn,tn,tn]),Te=P({min:L([N().int(),N().int(),N().int()]),max:L([N().int(),N().int(),N().int()]),density:D(tn),voxelSize:tn.positive(),color:Uo,emission:Uo,densityScale:tn.nonnegative()}).strict();function kr(o){const t=o.max.map((s,l)=>s-o.min[l]+1);if(t.some(s=>s<=0)||t.reduce((s,l)=>s*l,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Ue(new Float32Array(o.density),t[0],t[1],t[2]);n.format=We,n.type=ie,n.minFilter=n.magFilter=Gt,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 He(a.x,a.y,a.z),i=r.getAttribute("position");for(let s=0;s<i.count;s++)i.setXYZ(s,e.x+(i.getX(s)>0?a.x:0),e.y+(i.getY(s)>0?a.y:0),e.z+(i.getZ(s)>0?a.z:0));i.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere();const f=new so({glslVersion:Ge,side:qe,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 ae}},vertexShader:`
|
|
19
|
+
`;function zt(o){return new wt().setHex(o,$t)}function To(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=zt(St.poseActive):t.active?e=zt(St.poseActiveUnsel):t.select?e=zt(St.pose):e=zt(St.wire):e=zt(St.vertex),n&&t.lockedWeight&&e.lerp(zt(St.lockedWeight),St.lockedWeightFactor),e}function So(o,t){const n=zt(St.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(zt(St.lockedWeight),St.lockedWeightFactor),n}const Va=new Z,ja=new x,Po=new ie;function Mo(o,t){return new Z().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Ba{constructor(){this.group=new it,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],r=JSON.stringify(t);if(r===this.signature)return e;this.signature=r,this.clear();for(const a of Object.values(t)){const s=n(a.object);if(s===null)continue;a.displayType!=="OCTAHEDRAL"&&a.displayType!=="STICK"&&e.push(`armature ${a.object}: Blender's ${a.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),a.mode==="EDIT"&&e.push(`armature ${a.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const f=a.bones.filter(_=>!_.hide);if(f.length===0)continue;const u=a.displayType==="STICK"?this.buildStick(a,f,s):this.buildOctahedral(a,f,s);a.showInFront&&u.traverse(_=>{const l=_.material;l&&"depthTest"in l&&(l.depthTest=!1),_.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const r=new it;r.name=`${t.object}:bones`;const a=[],s=[],f=[],u=[],_=[],l=[],i=[],c=[],m=[],d=[];for(const h of n){const p=Mo(e,h),v=So(t,h),g=Ia(v),w=To(t,h);Po.setFromMatrix4(p).invert().transpose();for(let A=0;A<Oo.length;A++){const T=ja.set(...Fa[A]).applyMatrix3(Po).normalize().clone();for(const O of Oo[A]){const E=new x(...kn[O]).applyMatrix4(p);a.push(E.x,E.y,E.z),s.push(T.x,T.y,T.z),f.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const y=Ao(h)===2?i:_,P=Ao(h)===2?c:l;for(const[A,T]of za){const O=new x(...kn[A]).applyMatrix4(p),E=new x(...kn[T]).applyMatrix4(p);y.push(O.x,O.y,O.z,E.x,E.y,E.z),P.push(w.r,w.g,w.b,w.r,w.g,w.b)}h.parent!==null&&h.connected||(m.push(p.clone()),d.push(v)),m.push(p.clone().multiply(Va.makeTranslation(0,1,0))),d.push(v)}r.add(this.solidMesh(a,s,f,u)),_.length&&r.add(this.lines(_,l,1)),i.length&&r.add(this.lines(i,c,2));for(let h=0;h<m.length;h++)r.add(this.point(m[h],d[h]));return r}buildStick(t,n,e){const r=new it;r.name=`${t.object}:bones`;const a=[],s=[],f=[],u=[];for(const _ of n){const l=Mo(e,_),i=new x().setFromMatrixPosition(l),c=new x(0,1,0).applyMatrix4(l),m=To(t,_),d=So(t,_);a.push(i.x,i.y,i.z,c.x,c.y,c.z),s.push(m.r,m.g,m.b,m.r,m.g,m.b),f.push(i.x,i.y,i.z,c.x,c.y,c.z),u.push(d.r,d.g,d.b,d.r,d.g,d.b)}return r.add(this.lines(a,s,Ca)),r.add(this.lines(f,u,ka)),r}solidMesh(t,n,e,r){const a=new pn;a.setAttribute("position",new Pt(t,3)),a.setAttribute("normal",new Pt(n,3)),a.setAttribute("aSolid",new Pt(e,3)),a.setAttribute("aHint",new Pt(r,3));const s=new lo({vertexShader:$a,fragmentShader:La,side:$e});this.disposables.push(a,s);const f=new Rt(a,s);return f.frustumCulled=!1,f}lines(t,n,e){const r=new ee;r.setPositions(t),r.setColors(n);const a=new ae({linewidth:e,vertexColors:!0});this.disposables.push(r,a);const s=new re(r,a);return s.frustumCulled=!1,s}point(t,n){const e=new Le(Da,12,8),r=new En({color:n});this.disposables.push(e,r);const a=new Rt(e,r);return a.applyMatrix4(t),a.frustumCulled=!1,a}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const Eo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",an="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ua(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)),r=t(1/e);return{unit:[t(o[0]*r),t(o[1]*r),t(o[2]*r)],length:e}}return{unit:[0,0,0],length:0}}const I=Math.fround,Rn=I(2*Math.PI),$n=I(1-1e-4),Wt=(o,t)=>I(I(I(o[0]*t[0])+I(o[1]*t[1]))+I(o[2]*t[2])),mn=(o,t,n=1)=>o.map((e,r)=>I(e+I(t[r]*n))),Wa=(o,t)=>o.map((n,e)=>I(n-t[e]));function rn(o){const t=I(Math.sqrt(Wt(o,o)));return t>0?o.map(n=>I(n/t)):[0,0,0]}function sn(o){const t=Math.abs(o)<1?I(1-I(1-Math.abs(o))):1;let n=I(I(.077980478)+I(t*I(-.02164095)));n=I(I(-.213300989)+I(t*n)),n=I(I(1.5707963267)+I(t*n));const e=I(I(Math.sqrt(I(1-t)))*n);return o<0?I(I(Math.PI)-e):e}function Ha(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let r=0;r<3;r++){const a=(r+1)%3,s=(r+2)%3;n[r]=I(n[r]+I(I(t[a]-e[a])*I(t[s]+e[s])))}t=e}return n}function qa(o){const t=[],n=[],e=(d,h)=>d<h?`${d}:${h}`:`${h}:${d}`,r=new Map((o.edge_order??[]).map(([d,h],p)=>[e(d,h),p])),a=new Set((o.sharp??[]).map(([d,h])=>e(d,h))),s=new Map;for(const[d,h]of o.f.entries()){const p=t.length,v=Ua(Ha(h.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<h.length;g++){const w=e(h[g],h[(g+1)%h.length]);r.has(w)||r.set(w,r.size);const y=o.face_edges?.[d]?.[g]??r.get(w),P=t.length;t.push({vertex:h[g],face:d,edge:y,prev:p+(g+h.length-1)%h.length,next:p+(g+1)%h.length});const A=s.get(y)??[];A.push(P),s.set(y,A)}}const f=new Map,u=new Map;for(const[d,h]of s){if(h.length!==2||o.edge_sharp?.[d])continue;const[p,v]=h,g=t[p],w=t[v];!o.s?.[g.face]||!o.s?.[w.face]||g.vertex!==t[w.next].vertex||w.vertex!==t[g.next].vertex||!o.edge_sharp&&a.has(e(g.vertex,w.vertex))||(u.set(p,w.next),f.set(w.next,p),u.set(v,g.next),f.set(g.next,v))}const _=[],l=[],i=[],c=[],m=(d,h)=>rn(Wa(o.v[t[t[d][h]].vertex],o.v[t[d].vertex]));for(let d=0;d<t.length;d++){if(l[d]!==void 0)continue;let h=d;const p=new Set([h]);for(;u.has(h)&&!p.has(u.get(h));)h=u.get(h),p.add(h);u.has(h)&&(h=Math.min(...p));const v=[h];for(;f.has(v.at(-1))&&f.get(v.at(-1))!==h;)v.push(f.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[h].face];else{for(const E of v)g=mn(g,n[t[E].face],sn(Wt(m(E,"prev"),m(E,"next"))));g=rn(g)}const w=m(h,"next"),y=v.at(-1),P=m(y,"prev"),A=Wt(w,g),T=Wt(P,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(A)<$n&&Math.abs(T)<$n){const E=v.length>1?v.map(lt=>m(lt,"next")):[];E.length&&t[t[y].prev].edge!==t[h].edge&&E.push(P),O.alpha=E.length?I(E.reduce((lt,b)=>I(lt+sn(Wt(b,g))),0)/E.length):I(I(sn(A)+sn(T))/2),O.reference=rn(mn(w,g,-A));const k=g,j=O.reference;O.ortho=rn([I(I(k[1]*j[2])-I(k[2]*j[1])),I(I(k[2]*j[0])-I(k[0]*j[2])),I(I(k[0]*j[1])-I(k[1]*j[0]))]);const q=rn(mn(P,g,-T)),K=Wt(O.reference,q),J=sn(K);O.beta=K<$n?Wt(O.ortho,q)<0?I(Rn-J):J:Rn}O.alpha===0&&(O.normal=[0,0,0]);for(const E of v)l[E]=_.length;_.push(v),i.push(O),c.push(g)}return{corners:t,fans:_,fanOf:l,spaces:i,faceNormals:n,fanNormals:c}}function Ga(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=I(t[0]/32767),e=I(t[1]/32767),r=I((n>0?o.alpha:I(Rn-o.alpha))*n),a=I((e>0?o.beta:I(Rn-o.beta))*e);let s=o.normal.map(f=>I(f*I(Math.cos(r))));return s=mn(s,o.reference,I(I(Math.sin(r))*I(Math.cos(a)))),e!==0&&(s=mn(s,o.ortho,I(I(Math.sin(r))*I(Math.sin(a))))),s}function pe(o,t){if(!t)return null;const{corners:n,fans:e,spaces:r}=qa(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(n.length);for(const[s,f]of e.entries()){const u=f.reduce((l,i)=>{const c=t.data[i];return[l[0]+c[0],l[1]+c[1]]},[0,0]),_=Ga(r[s],u.map(l=>Math.trunc(l/f.length)));for(const l of f)a[l]=_}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,s)=>{const f=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:s;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Ln={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}},Xa=1e-6;function Ya(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],r=o[(n+1)%o.length];t.x+=(e.y-r.y)*(e.z+r.z),t.y+=(e.z-r.z)*(e.x+r.x),t.z+=(e.x-r.x)*(e.y+r.y)}return t.multiplyScalar(.5)}const Za=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),No=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Qa(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],r=o[(n+1)%o.length];t+=e.x*r.y-r.x*e.y}return t}function Ro(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let r=0;for(const[a,s,f]of o){const u=Za(t[a],t[s],t[f]);if(u*e<0)return!1;r+=Math.abs(u)}return Math.abs(r-Math.abs(n))<=Xa*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=Ya(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:No(t),sound:!1,method:"fan"};const r=n.clone().divideScalar(e),a=Math.abs(r.x)<.9?new x(1,0,0):new x(0,1,0),s=new x().crossVectors(a,r).normalize(),f=new x().crossVectors(r,s),u=o[0],_=o.map(m=>{const d=m.clone().sub(u);return new Gt(d.dot(s),d.dot(f))}),l=Qa(_),i=No(t);if(Ro(i,_,l))return{triangles:i,sound:!0,method:"fan"};let c=[];try{c=Ve.triangulateShape(_,[]).map(m=>[m[0],m[1],m[2]])}catch{return{triangles:i,sound:!1,method:"fan"}}return Ro(c,_,l)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:i,sound:!1,method:c.length>0?"earcut":"fan"}}const Ja=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Vn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function jn(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[Vn(Number(t[n*4])),Vn(Number(t[n*4+1])),Vn(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 uo(o,t){return o.filter(n=>Ja.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),r=[0,0,0,0];return{name:n.name,domain:n.domain,read:(a,s,f)=>n.domain==="POINT"?jn(n.type,e,a):n.domain==="CORNER"?s===void 0?r:jn(n.type,e,s):f===void 0?r:jn(n.type,e,f)}})}function ve(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,r=o.cornerVerts,a=e[n];let s=t;for(let b=0;b<n;b++)s+=(e[b+1]-e[b]-2)*3;const f=new Uint32Array(a),u=new Uint8Array(a),_=new Uint8Array(t),l=new Uint32Array(a);let i=!1;for(let b=0;b<n;b++)if(o.smooth(b)){i=!0;break}const c=(b,V)=>t<94906265?Math.min(b,V)*t+Math.max(b,V):`${Math.min(b,V)}:${Math.max(b,V)}`,m=new Map,d=new Set;for(const[b,V]of o.sharp)d.add(c(b,V));if(o.edges)for(const[b,V]of o.edges){if(b===V)throw new Error("Runtime mesh edge needs distinct vertices");m.set(c(b,V),-1)}const h=b=>{for(;l[b]!==b;)l[b]=l[l[b]],b=l[b];return b},p=(b,V)=>{const z=h(b),X=h(V);l[Math.max(z,X)]=Math.min(z,X)};for(let b=0;b<n;b++){const V=e[b],z=e[b+1]-V,X=o.smooth(b)?1:0;for(let Y=0;Y<z;Y++){const $=V+Y;_[r[$]]=1,f[$]=V+(Y+1)%z,u[$]=X,l[$]=$}}for(let b=0;b<a;b++){const V=f[b],z=r[b],X=r[V],Y=c(z,X),$=m.get(Y);if($!==void 0&&$>=0&&u[b]&&u[$]&&!d.has(Y)){const M=f[$];p(b,r[$]===z?$:M),p(V,r[$]===z?M:$)}($===void 0||$<0||!u[$]&&u[b])&&m.set(Y,b)}const v=o.uv,g=new Float32Array(s*3),w=new Float32Array(s*2),y=new Uint32Array(s),P=(o.uvLayers??[]).map(b=>({...b,data:new Float32Array(s*2)})),A=(o.attributeLayers??[]).map(b=>({...b,data:new Float32Array(s*4)})),T=o.orco?new Float32Array(s*3):null,O=new Uint32Array(s),E=new Map,k=[],j=o.normals||o.cornerNormal?new Float32Array(s*3):null;let q=0,K=0;const J=(b,V,z,X,Y)=>{const $=q++;for(const M of A)M.data.set(M.read(b,X,Y),$*4);if(T)for(let M=0;M<3;M++)T[$*3+M]=o.orco[b*3+M]*.5+.5;if(y[$]=b,o.co(b).toArray(g,$*3),V&&w.set(V,$*2),z&&j.set(z,$*3),X!==void 0)for(const M of P)M.data.set(M.read(X),$*2);return $},lt=(b,V)=>{const z=v?.(b),X=o.cornerNormal?[o.cornerNormal[b*3],o.cornerNormal[b*3+1],o.cornerNormal[b*3+2]]:o.normals?.[b];if(!i)return J(r[b],z,X,b,V);const Y=`${u[b]?h(b):b}${z?`:${z[0]}:${z[1]}`:""}${X?`:n${X.join(":")}`:""}${P.map(M=>":"+M.read(b).join(":")).join("")}${A.map(M=>M.domain==="POINT"?"":":"+Array.from(M.read(r[b],b,V)).join(":")).join("")}`;let $=E.get(Y);return $===void 0&&($=J(r[b],z,X,b,V),E.set(Y,$)),$};for(let b=0;b<n;b++){const V=K,z=e[b],X=e[b+1]-z,Y=[];for(let B=0;B<X;B++)Y.push(o.co(r[z+B]));for(const B of Ka(Y).triangles)for(const tt of B)O[K++]=lt(z+tt,b);const $=o.material(b),M=k.at(-1);M?.materialIndex===$?M.count+=K-V:k.push({start:V,count:K-V,materialIndex:$})}for(let b=0;b<t;b++)_[b]||J(b);return{positions:g.slice(0,q*3),normals:j?.slice(0,q*3)??null,uv:v?w.slice(0,q*2):null,uvLayers:P.map(b=>({name:b.name,data:b.data.slice(0,q*2)})),attributeLayers:A.map(b=>({name:b.name,data:b.data.slice(0,q*4)})),orco:T?T.slice(0,q*3):null,indices:O.slice(0,K),sourceVertex:y.slice(0,q),groups:k}}function kt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function Pn(o){const t=new pn;t.setAttribute("position",new dt(o.positions,3)),t.setAttribute("uv",new dt(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new dt(o.indices,1));const n=Object.create(null);for(const[e,r]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[r.name]=e+1,t.setAttribute(`uv${e+1}`,new dt(r.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(kt(e.name),new dt(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new dt(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 dt(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new dt(o.sourceVertex,1)),t}function tr(o,t){const n=o.cornerTri,e=o.cornerNormal,r=o.co.length/3,a=o.corner.length,s=o.faceStart.length-1,f=o.attributes.filter(M=>M.type==="FLOAT2"&&M.domain==="CORNER"),u=o.renderUv??o.activeUv??f[0]?.name,_=f.findIndex(M=>M.name===u);if(u&&_<0)throw new Error(`Runtime UV map ${u} is missing`);const l=uo(o.attributes,M=>M),i=3+f.length*2+l.length*4,c=new Float32Array(i),m=new Float32Array(i),d=new Uint32Array(c.buffer),h=new Uint32Array(m.buffer),p=new Uint32Array(a),v=new Uint32Array(a),g=new Uint32Array(a),w=new Uint32Array(a),y=new Uint8Array(r);let P=1;for(;P<Math.max(1,a*2);)P*=2;const A=new Uint32Array(P),T=(M,B,tt,nt)=>{let ct=0;for(let rt=0;rt<3;rt++)nt[ct++]=e[M*3+rt];for(const rt of f)for(let st=0;st<2;st++)nt[ct++]=Number(rt.data[M*2+st]);for(const rt of l){const st=rt.read(tt,M,B);for(let Tt=0;Tt<4;Tt++)nt[ct++]=Number(st[Tt])}};let O=0;for(let M=0;M<s;M++)for(let B=o.faceStart[M];B<o.faceStart[M+1];B++){const tt=o.corner[B];if(tt>=r)throw new Error("Native mesh corner references a missing vertex");p[B]=M,y[tt]=1,T(B,M,tt,c);let nt=Math.imul(tt^2166136261,16777619);for(const st of d)nt=Math.imul(nt^st,16777619);const ct=nt>>>0&P-1;let rt=-1;for(let st=A[ct];st;st=w[st-1]){const Tt=st-1,Cn=g[Tt];if(o.corner[Cn]!==tt)continue;T(Cn,p[Cn],tt,m);let yo=!0;for(let vn=0;vn<i;vn++)if(d[vn]!==h[vn]){yo=!1;break}if(yo){rt=Tt;break}}rt<0&&(rt=O++,g[rt]=B,w[rt]=A[ct],A[ct]=rt+1),v[B]=rt}let E=0;for(const M of y)M||E++;const k=O+E,j=new Float32Array(k*3),q=new Float32Array(k*3),K=new Uint32Array(k),J=f.map(M=>({name:M.name,data:new Float32Array(k*2)})),lt=l.map(M=>({name:M.name,data:new Float32Array(k*4)})),b=o.orco?new Float32Array(k*3):null,V=(M,B)=>{K[M]=B;for(let tt=0;tt<3;tt++)j[M*3+tt]=o.co[B*3+tt],b&&(b[M*3+tt]=o.orco[B*3+tt]*.5+.5)};for(let M=0;M<O;M++){const B=g[M],tt=o.corner[B];V(M,tt),T(B,p[B],tt,c),q.set(c.subarray(0,3),M*3);let nt=3;for(const ct of J)ct.data.set(c.subarray(nt,nt+2),M*2),nt+=2;for(const ct of lt)ct.data.set(c.subarray(nt,nt+4),M*4),nt+=4}let z=O;for(let M=0;M<r;M++)if(!y[M]){V(z,M);for(let B=0;B<l.length;B++)lt[B].data.set(l[B].read(M,void 0,void 0),z*4);z++}const X=new Uint32Array(n.length),Y=[];let $=0;for(let M=0;M<s;M++){const B=o.faceStart[M],tt=o.faceStart[M+1],nt=Math.max(0,tt-B-2)*3;if($+nt>n.length)throw new Error("Native mesh triangulation is incomplete");for(let st=0;st<nt;st++){const Tt=n[$+st];if(Tt<B||Tt>=tt)throw new Error("Native triangle references a different face");X[$+st]=v[Tt]}const ct=o.material[M],rt=Y.at(-1);rt?.materialIndex===ct?rt.count+=nt:Y.push({start:$,count:nt,materialIndex:ct}),$+=nt}if($!==n.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:j,normals:q,sourceVertex:K,uv:_<0?null:J[_].data,uvLayers:J,attributeLayers:lt,orco:b,indices:X,groups:Y,hash:t}}function Io(o,t){if(o.cornerTri&&o.cornerNormal)return tr(o,t);const n=o.co.length/3,e=o.attributes.filter(h=>h.type==="FLOAT2"&&h.domain==="CORNER"),r=o.renderUv??o.activeUv??e[0]?.name,a=e.find(h=>h.name===r);if(r&&!a)throw new Error(`Runtime UV map ${r} is missing`);const s=a?a.data:null,f=o.edge.length/2,u=new Array(f);for(let h=0;h<f;h++)u[h]=[o.edge[h*2],o.edge[h*2+1]];const _=[];for(let h=0;h<f;h++)o.edgeSharp[h]===1&&_.push(u[h]);const l=o.cornerNormal?void 0:o.attributes.find(h=>h.name==="custom_normal"),i=l?{v:Array.from({length:n},(h,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(h,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:_,face_edges:Array.from({length:o.faceStart.length-1},(h,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,c=l?{type:l.type,domain:l.domain,data:Array.from({length:l.data.length/Ln[l.type].size},(h,p)=>Array.from({length:Ln[l.type].size},(v,g)=>Number(l.data[p*Ln[l.type].size+g])))}:void 0,m=new x,d={vertexCount:n,normals:i?pe(i,c):null,cornerNormal:o.cornerNormal,orco:o.orco,co:h=>m.set(o.co[h*3],o.co[h*3+1],o.co[h*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:h=>o.smooth[h]===1,material:h=>o.material[h],edges:u,sharp:_,uv:s?h=>[s[h*2],s[h*2+1]]:null,uvLayers:e.map(h=>({name:h.name,read:p=>[Number(h.data[p*2]),Number(h.data[p*2+1])]})),attributeLayers:uo(o.attributes,h=>h)};return{...ve(d),hash:t}}function nr(o){const t=o.v.map(i=>new x(...i)),n=i=>{const c=t[i];if(!c)throw new Error(`Runtime mesh vertex ${i} is missing`);return c},e=new Uint32Array(o.f.length+1);o.f.forEach((i,c)=>{if(i.length<3||new Set(i).size!==i.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[c+1]=e[c]+i.length});const r=new Uint32Array(e[o.f.length]);o.f.forEach((i,c)=>i.forEach((m,d)=>{n(m),r[e[c]+d]=m}));for(const[i,c]of o.edge_order??o.e??[])n(i),n(c);const a={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:r.length};for(const i of o.attributes??[])if(i.domain!=="EDGE"&&i.data.length!==a[i.domain])throw new Error(`Runtime attribute ${i.name} has ${i.data.length} values for ${a[i.domain]} ${i.domain} elements`);const s=(o.attributes??[]).filter(i=>i.type==="FLOAT2"&&i.domain==="CORNER"),f=o.render_uv??o.active_uv??s[0]?.name,u=s.find(i=>i.name===f);if(f&&!u)throw new Error(`Runtime UV map ${f} is missing`);const _=u?.data,l={vertexCount:t.length,normals:pe(o,o.attributes?.find(i=>i.name==="custom_normal")),co:n,starts:e,cornerVerts:r,smooth:i=>!!o.s?.[i],material:i=>o.m?.[i]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:_?i=>_[i]:null,uvLayers:s.map(i=>({name:i.name,read:c=>i.data[c]})),attributeLayers:uo(o.attributes??[],i=>Array.from(i).flat())};return Pn(ve(l))}const hn=1.5707963267948966,Ht=6.283185307179586,ge=.3183098861837067,xe=.0795774715459476,or=.3,er=xe,ar=3/16*ge,no=.8,Fo=no*no,qt=6371,be=100,oo=qt+be,zo=64,Do=64,ft=256,Vt=64,rr=[1.679,1.828,1.986,1.307],ir=[.006605,.01067,.01842,.03156],sr=[3472e-28,3914e-28,1349e-28,1103e-29],lr=334.5,fr=[28722e-28,46168e-28,79706e-28,13578e-27],cr=[15908e-26,17711e-26,20942e-26,24033e-26],Co=13681e16,ur=2e6,_r=.73,Bn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],Mt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],In=o=>o*o,cn=o=>o<0?0:o>1?1:o,Nt=(o,t,n)=>o+n*(t-o),mr=o=>Math.sqrt(Math.max(o,0)),ye=o=>[-Math.sqrt(1-o*o),0,o];function eo(o,t,n,e,r,a,s){const f=o*e+t*r+n*a,u=o*o+t*t+n*n-s*s;if(u>0&&f>0)return-1;const _=f*f-u;return _<0?-1:_>=f*f?-f+Math.sqrt(_):-f-Math.sqrt(_)}const dr=o=>ar*(1+In(o));function hr(o){const t=1+Fo+2*no*o;return xe*(1-Fo)/(t*Math.sqrt(t))}const pr=o=>Co*(Math.exp(-o/_r)+ur/Co);function _o(o,t){let n=o%Ht;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=hn||n<=-hn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Ht,e<0&&(e+=Ht),e=Ht-e,[n,e]}class vr{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Vt*ft*4)}coefficients(t,n){const e=pr(t)*this.aerosol,r=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-In(r-3.22261)*5.55555555-r),s=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=fr[f]*e,n[4+f]=cr[f]*e,n[8+f]=sr[f]*lr*a*this.ozone,n[12+f]=ir[f]*s*this.air}transmittance(t,n,e){const[r,a,s]=ye(t),f=Nt(qt,oo,n),_=eo(0,0,f,r,a,s,oo)/zo,l=[0,0,0,0],i=new Float64Array(16);for(let c=0;c<zo;c++){const m=(c+.5)*_,d=r*m,h=a*m,p=f+s*m,v=Math.max(Math.hypot(d,h,p)-qt,0);this.coefficients(v,i);for(let g=0;g<4;g++)l[g]+=(i[g]+i[4+g]+i[8+g]+i[12+g])*_}for(let c=0;c<4;c++)e[c]=Math.exp(-l[c])}precompute(){const t=new Float64Array(4);for(let n=0;n<Vt;n++)for(let e=0;e<ft;e++){const r=e/(ft-1),a=n/(Vt-1);this.transmittance(r*2-1,a,t);const s=(n*ft+e)*4;for(let f=0;f<4;f++)this.lut[s+f]=t[f]}}lookup(t,n,e){const r=(ft-1)*cn(t*.5+.5),a=(Vt-1)*cn(n),s=Math.trunc(r),f=Math.trunc(a),u=Math.min(s+1,ft-1),_=Math.min(f+1,Vt-1),l=r-s,i=a-f,c=(f*ft+s)*4,m=(f*ft+u)*4,d=(_*ft+s)*4,h=(_*ft+u)*4;for(let p=0;p<4;p++)e[p]=Nt(Nt(this.lut[c+p],this.lut[m+p],l),Nt(this.lut[d+p],this.lut[h+p],l),i)}lookupAtGround(t,n){const e=(ft-1)*cn(t*.5+.5),r=Math.trunc(e),a=Math.min(r+1,ft-1),s=e-r;for(let f=0;f<4;f++)n[f]=Nt(this.lut[r*4+f],this.lut[a*4+f],s)}lookupToSun(t,n){const e=(Vt-1)*cn(t),r=Math.trunc(e),a=Math.min(r+1,Vt-1),s=e-r,f=ft-1;for(let u=0;u<4;u++)n[u]=Nt(this.lut[(r*ft+f)*4+u],this.lut[(a*ft+f)*4+u],s)}inscattering(t,n,e,r,a,s,f,u,_){const l=-(a*t[0]+s*t[1]+f*t[2]),i=dr(l),c=hr(l),m=u/Do,d=new Float64Array(16),h=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),w=new Float64Array(4),y=[0,0,0,0],P=[1,1,1,1];for(let A=0;A<Do;A++){const T=(A+.5)*m,O=n+a*T,E=e+s*T,k=r+f*T,j=Math.hypot(O,E,k),q=Math.max(j-qt,0),K=q/be,J=(O*t[0]+E*t[1]+k*t[2])/j;this.coefficients(q,d),this.lookup(J,K,h);const lt=Ht*(1-mr(1-In(qt/j)));this.lookupAtGround(J,v),this.lookupToSun(0,g),this.lookupToSun(K,w);const b=1/(1+5*Math.exp(-17.92*J)),V=[.217,.347,.594,1];for(let z=0;z<4;z++){const X=g[z]/w[z],Y=er*lt*(or*ge)*v[z]*X*J;p[z]=.02*V[z]*b+Y}for(let z=0;z<4;z++){const X=d[z]+d[4+z]+d[8+z]+d[12+z],Y=rr[z]*(d[12+z]*(i*h[z]+p[z])+d[4+z]*(c*h[z]+p[z])),$=Math.exp(-m*X),M=Math.max(X,1e-7);y[z]+=P[z]*((Y-Y*$)/M),P[z]*=$}}for(let A=0;A<4;A++)_[A]=y[A]}}const ht=512,Jt=256;function we(o,t){const n=new vr(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,r=ye(Math.cos(hn-t)),a=new Float32Array(ht*Jt*3),s=ht/2,f=new Float64Array(4);for(let u=0;u<Jt;u++)for(let _=0;_<s;_++){const l=(_+.5)/ht,i=(u+.5)/Jt,c=Ht*l,m=i*2-1,d=Math.sign(m)*In(m)*hn,h=Math.cos(d)*Math.cos(c),p=Math.cos(d)*Math.sin(c),v=Math.sin(d),g=qt+e,w=eo(0,0,g,h,p,v,oo),y=eo(0,0,g,h,p,v,qt),P=y<0?w:y;n.inscattering(r,0,0,g,h,p,v,P,f);let A=0,T=0,O=0;for(let j=0;j<4;j++)A+=Bn[j][0]*f[j],T+=Bn[j][1]*f[j],O+=Bn[j][2]*f[j];const E=(u*ht+_)*3;a[E]=A,a[E+1]=T,a[E+2]=O;const k=(u*ht+(ht-_-1))*3;a[k]=A,a[k+1]=T,a[k+2]=O}return a}function gr(o){const[t]=_o(o.sunElevation,o.sunRotation);return we(o,t)}function mo(o){const[t]=_o(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const xr=6,Qt=new Map;function br(o){return Qt.has(mo(o))}function Oe(o,t){Qt.set(mo(o),t),Qt.size>xr&&Qt.delete(Qt.keys().next().value)}function yr(o){const[t,n]=_o(o.sunElevation,o.sunRotation),e=mo(o);let r=Qt.get(e);r===void 0&&(r=we(o,t),Oe(o,r));const a=new x;return s=>{const f=Math.hypot(s.x,s.y),u=Math.atan2(s.z,f);let l=(Math.atan2(s.x,s.y)+Math.PI+n)/Ht;l-=Math.floor(l);const i=Math.abs(u),c=cn(Math.sqrt(i/hn)*Math.sign(u)*.5+.5),m=l*ht-.5,d=c*Jt-.5,h=Math.floor(m),p=Math.floor(d),v=m-h,g=d-p,w=k=>(k%ht+ht)%ht,y=k=>k<0?0:k>Jt-1?Jt-1:k,P=w(h),A=w(h+1),T=y(p),O=y(p+1),E=[0,0,0];for(let k=0;k<3;k++){const j=Nt(r[(T*ht+P)*3+k],r[(T*ht+A)*3+k],v),q=Nt(r[(O*ht+P)*3+k],r[(O*ht+A)*3+k],v);E[k]=Nt(j,q,g)}return a.set(Mt[0][0]*E[0]+Mt[0][1]*E[1]+Mt[0][2]*E[2],Mt[1][0]*E[0]+Mt[1][1]*E[1]+Mt[1][2]*E[2],Mt[2][0]*E[0]+Mt[2][1]*E[1]+Mt[2][2]*E[2])}}let Ft=null,gn=!1,wr=0;const un=new Map;function Or(){if(Ft||gn)return Ft;if(typeof Worker>"u")return gn=!0,null;try{Ft=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return gn=!0,null}return Ft.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,r=un.get(t);r&&(un.delete(t),n?r.resolve(n):r.reject(new Error(e??"sky worker returned nothing")))},Ft.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of un.values())n.reject(t);un.clear(),Ft?.terminate(),Ft=null,gn=!0},Ft}function Ar(o){const t=Or();if(!t)return Promise.resolve(gr(o));const n=wr++,e={id:n,parameters:o};return new Promise((r,a)=>{un.set(n,{resolve:r,reject:a}),t.postMessage(e)})}function Tr(o,t,n,e={}){switch(e.type??"LINEAR"){case"QUADRATIC":{const r=Math.max(o,0);return r*r}case"EASING":{const r=Math.min(1,Math.max(0,o));return r*r*(3-2*r)}case"DIAGONAL":return(o+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(o,t,n),0);case"QUADRATIC_SPHERE":{const r=Math.max(.999999-Math.hypot(o,t,n),0);return r*r}case"RADIAL":return Math.atan2(t,o)/(2*Math.PI)+.5;default:return o}}const Un=(o,t)=>t!==0?o/t:0,ko=o=>Math.min(1,Math.max(-1,o)),$o=(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},Ae={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:Un,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:Un(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(Un(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(ko(o)),ARCCOSINE:o=>Math.acos(ko(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:$o,SMOOTH_MAX:(o,t,n)=>-$o(-o,-t,n)};function at(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const r=new x(...o);return()=>r}if(o.kind==="direction")return r=>r;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const r=at(o.vector,t),a={type:o.gradient_type},s=new x;return f=>{const u=r(f),_=typeof u=="number"?u:u.x,l=typeof u=="number"?u:u.y,i=typeof u=="number"?u:u.z,c=xt.clamp(Tr(_,l,i,a),0,1);return o.output==="Fac"?c:s.setScalar(c)}}if(o.kind==="to_float"){const r=at(o.value,t);return a=>{const s=r(a);return typeof s=="number"?s:Math.fround(o.source_type==="RGBA"?s.x*.212639+s.y*.7151687+s.z*.0721923:(s.x+s.y+s.z)/3)}}if(o.kind==="math"){const r=o.inputs.map(f=>at(f,t)),a=Ae[o.operation],s=(f,u)=>{const _=r[f]?.(u)??0;if(typeof _!="number")throw new Error("World Math needs scalar inputs");return Math.fround(_)};return f=>{const u=Math.fround(a(s(0,f),s(1,f),s(2,f)));return o.clamp?xt.clamp(u,0,1):u}}if(o.kind==="mix_color"){const r=at(o.factor,t),a=at(o.a,t),s=at(o.b,t),f=new x,u=new x;return _=>{const l=r(_);if(typeof l!="number")throw new Error("World color Mix needs a scalar factor");const i=a(_);typeof i=="number"?f.setScalar(i):f.copy(i);const c=s(_);return typeof c=="number"?u.setScalar(c):u.copy(c),f.lerp(u,o.clamp_factor?xt.clamp(l,0,1):l),o.clamp_result&&f.clampScalar(0,1),f}}if(o.kind==="sky"){const r=yr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return a=>r(a)}if(o.kind==="mapping"){const r=at(o.vector,t),a=new x(...o.location),s=new x(...o.scale),f=new At().setFromEuler(new je(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=f.clone().invert(),_=new x(...o.scale.map(i=>i===0?0:1/i)),l=new x;return i=>{const c=r(i);switch(typeof c=="number"?l.setScalar(c):l.copy(c),o.vector_type??"POINT"){case"TEXTURE":return l.sub(a).applyQuaternion(u).multiply(_);case"VECTOR":return l.multiply(s).applyQuaternion(f);case"NORMAL":return l.multiply(_).applyQuaternion(f).normalize();case"POINT":return l.multiply(s).applyQuaternion(f).add(a)}}}if(o.kind==="map_range"){const r=at(o.value,t),a=at(o.from_min,t),s=at(o.from_max,t),f=at(o.to_min,t),u=at(o.to_max,t),_=at(o.steps,t),l=(m,d)=>{const h=m(d);if(typeof h!="number")throw new Error("World Map Range needs scalar inputs");return h},i=o.interpolation,c=o.clamp;return m=>{const d=l(r,m),h=l(a,m),p=l(s,m),v=l(f,m),g=l(u,m);if(h===p)return 0;let w;if(i==="STEPPED"){const P=l(_,m),A=(d-h)/(p-h);w=P>0?Math.floor(A*(P+1))/P:0}else if(i==="SMOOTHSTEP"||i==="SMOOTHERSTEP"){const P=xt.clamp((d-Math.min(h,p))/(Math.max(h,p)-Math.min(h,p)),0,1),A=i==="SMOOTHSTEP"?P*P*(3-2*P):P*P*P*(P*(P*6-15)+10);w=h>p?1-A:A}else w=(d-h)/(p-h);const y=v+w*(g-v);return c?v>g?xt.clamp(y,g,v):xt.clamp(y,v,g):y}}if(o.kind==="separate"){const r=at(o.vector,t);return a=>{const s=r(a);return typeof s=="number"?s:s.getComponent(o.axis)}}const n=at(o.factor,t),e=new x;return r=>{const a=n(r);if(typeof a!="number")throw new Error("World ColorRamp needs a scalar factor");const s=xt.clamp(a,0,1)*256,f=Math.floor(s),u=o.colors[f],_=o.colors[Math.min(f+1,256)],l=o.interpolate?s-f:0;return e.set(xt.lerp(u[0],_[0],l),xt.lerp(u[1],_[1],l),xt.lerp(u[2],_[2],l))}}function Sr(o,t,n,e){const r=new Float32Array(t*n*3),a=at(o,e),s=new x;for(let f=0;f<n;f++){const u=((f+.5)/n-.5)*Math.PI;for(let _=0;_<t;_++){const l=((_+.5)/t-.5)*2*Math.PI;s.set(Math.cos(u)*Math.cos(l),-Math.cos(u)*Math.sin(l),Math.sin(u));const i=a(s),c=(f*t+_)*3;r[c]=typeof i=="number"?i:i.x,r[c+1]=typeof i=="number"?i:i.y,r[c+2]=typeof i=="number"?i:i.z}}return r}function Lo(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 Dt(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Dt(o.vector);case"ramp":return Dt(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Dt);case"math":return o.inputs.some(Dt);case"to_float":return Dt(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Dt);default:return!1}}function Pr(o,t,n,e){e.updateMatrixWorld();const r=new Float32Array(t*n*3),a=new x,s=at(o,()=>a),f=new x,u=e.getWorldPosition(new x),_=e.getWorldDirection(new x);for(let l=0;l<n;l++)for(let i=0;i<t;i++){const c=(i+.5)/t,m=(l+.5)/n;a.set(c,m,0),e.isOrthographicCamera?f.copy(_):f.set(c*2-1,m*2-1,.5).unproject(e).sub(u).normalize(),f.set(f.x,-f.z,f.y);const d=s(f),h=(l*t+i)*3;r[h]=typeof d=="number"?d:d.x,r[h+1]=typeof d=="number"?d:d.y,r[h+2]=typeof d=="number"?d:d.z}return r}const et=N().finite(),Mr=S({type:H(["POINT","SUN","SPOT","AREA"]),color:L([et,et,et]),energy:et,use_shadow:Q().default(!0),radius:et.optional(),spot_size:et.optional(),spot_blend:et.optional(),shape:H(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:et.optional(),size_y:et.optional()}).strict();let ao;function Er(){return ao??=Ta(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),Ot()}),ao}function Nr(){return ao??Promise.resolve()}const Rr=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 Ir(o,t){const n=(s,f)=>t&&f(t)?t:new s;if(o.type==="SUN"){const s=n(le,f=>f.isDirectionalLight);return s.intensity=o.energy,s.color.setRGB(o.color[0],o.color[1],o.color[2],vt),s.castShadow=o.use_shadow,s}if(o.type==="POINT"){const s=n(Zn,f=>f.isPointLight);return s.intensity=o.energy/(4*Math.PI),s.distance=0,s.decay=2,s.color.setRGB(o.color[0],o.color[1],o.color[2],vt),s.castShadow=o.use_shadow,s}if(o.type==="SPOT"){const s=n(Qn,f=>f.isSpotLight);return s.intensity=o.energy/(4*Math.PI),s.distance=0,s.decay=2,s.angle=(o.spot_size??0)/2,s.penumbra=o.spot_blend??0,s.color.setRGB(o.color[0],o.color[1],o.color[2],vt),s.castShadow=o.use_shadow,s}Er();const e=n(Sn,s=>s.isRectAreaLight),[r,a]=Rr(o);return e.width=r,e.height=a,e.intensity=o.energy/(Math.max(r*a,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],vt),e}function Fr(o,t,n){if(!o.castShadow||n<=0)return;const r=o.getWorldPosition(new x).distanceTo(t),a=o.shadow;if(!a)return;const s=a.camera;s.near=Math.max(n*.001,r-n),s.far=r+n,o.isDirectionalLight&&(s.left=-n,s.right=n,s.top=n,s.bottom=-n),s.updateProjectionMatrix()}function zr(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 ho=[{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}],Vo=.69;class Dr{constructor(){this.group=new it,this.lights=[],this.group.name="BlenderSolidStudio";const t=new se;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new wt(0,0,0);for(const[r,a]of ho.entries()){const s=(1+a.smooth)**2,f=new le(16777215,Math.PI*Vo/s);f.name=`BlenderSolidLight${r}`,f.color.setRGB(a.diffuse[0],a.diffuse[1],a.diffuse[2],vt),f.position.set(a.direction[0],a.direction[1],a.direction[2]),f.target=t,this.group.add(f),this.lights.push(f),n.r+=a.diffuse[0]*a.smooth/s,n.g+=a.diffuse[1]*a.smooth/s,n.b+=a.diffuse[2]*a.smooth/s}const e=new Be(16777215,Math.PI*Vo);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 Zt=L([et,et,et]),G=de(()=>Lt([et,Zt,S({kind:W("direction")}).strict(),S({kind:W("window")}).strict(),S({kind:W("gradient"),gradient_type:H(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:H(["Fac","Color"]),vector:G}).strict(),S({kind:W("to_float"),source_type:H(["RGBA","VECTOR"]),value:G}).strict(),S({kind:W("math"),operation:H(Object.keys(Ae)),clamp:Q(),inputs:D(G).min(1).max(3)}).strict(),S({kind:W("mix_color"),factor:G,a:G,b:G,clamp_factor:Q(),clamp_result:Q()}).strict(),S({kind:W("mapping"),vector_type:H(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:G,location:Zt,rotation:Zt,scale:Zt}).strict(),S({kind:W("separate"),vector:G,axis:N().int().min(0).max(2)}).strict(),S({kind:W("ramp"),factor:G,colors:D(Zt).length(257),interpolate:Q()}).strict(),S({kind:W("map_range"),interpolation:H(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:Q(),value:G,from_min:G,from_max:G,to_min:G,to_max:G,steps:G}).strict(),S({kind:W("sky"),sun_elevation:et,sun_rotation:et,altitude:et,air_density:et,aerosol_density:et,ozone_density:et}).strict()])),jo=S({color:Zt,strength:et,shader:G.optional()}),Cr=jo.extend({volume:D(S({kind:H(["absorption","scatter","principled","emission"]),phase:R(),alpha:G,weight:G,color:G,density:G,anisotropy:G,absorption_color:G,emission_color:G,emission_strength:G,blackbody_intensity:G,temperature:G,blackbody_tint:G}).strict()).optional(),lighting:jo.strict().optional()}).strict(),kr=4,ln=new Map,Wn=new Set;function Bo(o,t,n){const a=Dt(o);if(a&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const s=JSON.stringify([o,a?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),f=ln.get(s);if(f!==void 0)return ro(f,t,256,128);const u=new x,_=new fo,l=n?new Z().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,i=n?.getWorldPosition(new x),m=Sr(o,256,128,a?d=>(u.set(d.x,d.z,-d.y),n.isPerspectiveCamera&&u.add(i),_.set(u.x,u.y,u.z,1).applyMatrix4(l),_.w===0?u.set(0,0,0):u.set(_.x/_.w*.5+.5,_.y/_.w*.5+.5,0)):void 0);return ln.set(s,m),ln.size>kr&&ln.delete(ln.keys().next().value),ro(m,t,256,128)}function $r(o,t,n,e){const r=fn.toHalfFloat(1);for(let a=0;a<e;a++)o[a*4]=fn.toHalfFloat(t[a*3]*n),o[a*4+1]=fn.toHalfFloat(t[a*3+1]*n),o[a*4+2]=fn.toHalfFloat(t[a*3+2]*n),o[a*4+3]=r}function ro(o,t,n,e){const r=new Uint16Array(n*e*4);$r(r,o,t,n*e);const a=new zn(r,n,e,Dn,co);return a.mapping=We,a.colorSpace=vt,a.minFilter=Xt,a.magFilter=Xt,a.needsUpdate=!0,a}class po{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 r=po.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=n.shader??n.color,s=this.generation,u=[...Lo(a),...n.lighting?Lo(n.lighting.shader??n.lighting.color):[]].filter(l=>!br(l));if(u.length===0){this.compose(r,n,a,e);return}const _=(async()=>{const l=await Promise.all(u.map(Ar));u.forEach((i,c)=>{Oe(i,l[c])}),!(this.generation!==s||this.applied?.scene!==r)&&(this.compose(r,n,a,e),Ot())})();this.pending=_,Wn.add(_),_.then(()=>Wn.delete(_),()=>Wn.delete(_))}compose(t,n,e,r){if(this.texture=Bo(e,n.strength,r),Dt(e)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=ro(Pr(e,512,512,r),n.strength,512,512),this.screenTexture.mapping=Ue,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const s=r.getWorldDirection(new x);s.set(s.x,-s.z,s.y);const f=at(n.shader??n.color)(s);t.background=typeof f=="number"?new wt().setRGB(f,f,f).multiplyScalar(n.strength):new wt().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:a}=n;this.environmentTexture=a?Bo(a.shader??a.color,a.strength,r):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function Te(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 Lr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=Te(o);if(n.every(l=>t.containsPoint(l)))return n;const e=[...t.planes,new Bt(new x(1,0,0),-o.min.x),new Bt(new x(-1,0,0),o.max.x),new Bt(new x(0,1,0),-o.min.y),new Bt(new x(0,-1,0),o.max.y),new Bt(new x(0,0,1),-o.min.z),new Bt(new x(0,0,-1),o.max.z)],r=[],a=new x,s=new x,f=new x,u=new x,_=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let l=0;l<e.length;l++)for(let i=l+1;i<e.length;i++)for(let c=i+1;c<e.length;c++){const m=e[l],d=e[i],h=e[c];a.crossVectors(d.normal,h.normal);const p=m.normal.dot(a);Math.abs(p)<1e-12||(s.crossVectors(h.normal,m.normal),f.crossVectors(m.normal,d.normal),u.copy(a).multiplyScalar(-m.constant).addScaledVector(s,-d.constant).addScaledVector(f,-h.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-_)&&r.push(u.clone()))}return r}function Vr(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,r=e.matrixWorldInverse,a=new dn().setFromPoints(t.map(c=>c.clone().applyMatrix4(r))),s=a.getSize(new x),f=Math.max(s.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,_=Math.max(s.x,s.y,f)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),l=2*Math.SQRT2*_,i=u*_;a.min.x-=i,a.min.y-=i,a.max.x+=i,a.max.y+=i;for(const c of n){if(c.isEmpty())continue;const m=new dn().setFromPoints(Te(c).map(d=>d.applyMatrix4(r)));m.max.x<a.min.x||m.min.x>a.max.x||m.max.y<a.min.y||m.min.y>a.max.y||(a.min.z=Math.min(a.min.z,m.min.z),a.max.z=Math.max(a.max.z,m.max.z))}e.left=a.min.x,e.right=a.max.x,e.bottom=a.min.y,e.top=a.max.y,e.near=-a.max.z-l-f,e.far=-a.min.z+l+f,e.updateProjectionMatrix(),o.shadow.normalBias=l}const tn=N().finite(),Uo=L([tn,tn,tn]),Se=S({min:L([N().int(),N().int(),N().int()]),max:L([N().int(),N().int(),N().int()]),density:D(tn),voxelSize:tn.positive(),color:Uo,emission:Uo,densityScale:tn.nonnegative()}).strict();function jr(o){const t=o.max.map((l,i)=>l-o.min[i]+1);if(t.some(l=>l<=0)||t.reduce((l,i)=>l*i,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new He(new Float32Array(o.density),t[0],t[1],t[2]);n.format=qe,n.type=fe,n.minFilter=n.magFilter=Xt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),r=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),a=new Ge(r.x,r.y,r.z),s=a.getAttribute("position");for(let l=0;l<s.count;l++)s.setXYZ(l,e.x+(s.getX(l)>0?r.x:0),e.y+(s.getY(l)>0?r.y:0),e.z+(s.getZ(l)>0?r.z:0));s.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const f=new lo({glslVersion:Ye,side:Xe,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:e},extent:{value:r},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 ie}},vertexShader:`
|
|
20
20
|
out vec3 localPosition;
|
|
21
21
|
void main() {
|
|
22
22
|
localPosition = position;
|
|
@@ -58,7 +58,7 @@ import{a as ne,b as oe,L as ee}from"./LineSegments2-DN9pUfWA.js";import{bh as lt
|
|
|
58
58
|
outputColor = vec4(radiance, 1.0 - transmission);
|
|
59
59
|
#include <tonemapping_fragment>
|
|
60
60
|
#include <colorspace_fragment>
|
|
61
|
-
}`}),u=new Rt(
|
|
61
|
+
}`}),u=new Rt(a,f),_=new Z;return u.onBeforeRender=(l,i,c)=>{_.copy(u.matrixWorld).invert(),f.uniforms.cameraLocal.value.setFromMatrixPosition(c.matrixWorld).applyMatrix4(_),c.getWorldDirection(f.uniforms.rayLocal.value).transformDirection(_),f.uniforms.orthographic.value=!!c.isOrthographicCamera,f.uniforms.worldScale.value.setFromMatrix4(u.matrixWorld)},f.addEventListener("dispose",()=>n.dispose()),u}const Br=`#define constexpr const
|
|
62
62
|
#define bool32_t bool
|
|
63
63
|
#define bool2 bvec2
|
|
64
64
|
#define bool3 bvec3
|
|
@@ -200,7 +200,7 @@ mat3x3 to_float3x3(mat3x4 m) { return mat3x3(m); }
|
|
|
200
200
|
#define float4_from_float(v) float4(float3(v), 1.0f)
|
|
201
201
|
#define gpu_dfdx(x) dFdx(x)
|
|
202
202
|
#define gpu_dfdy(x) dFdy(x)
|
|
203
|
-
#define gpu_fwidth(x) fwidth(x)`,
|
|
203
|
+
#define gpu_fwidth(x) fwidth(x)`,io={"gpu_shader_common_math.glsl":{deps:["gpu_shader_math_constants_lib.glsl","gpu_shader_math_base_lib.glsl","gpu_shader_math_safe_lib.glsl"],code:`void math_add(float a, float b, float c, _ref(float ,result))
|
|
204
204
|
{
|
|
205
205
|
result = a + b;
|
|
206
206
|
}
|
|
@@ -6879,7 +6879,7 @@ void curves_float_mixed(float factor,
|
|
|
6879
6879
|
curves_float(
|
|
6880
6880
|
value, curve_map, layer, range_minimum, range_divider, start_slope, end_slope, result);
|
|
6881
6881
|
result = mix(value, result, factor);
|
|
6882
|
-
}`}},Wo=N().finite(),Hn=H(["float","vec2","vec3","vec4"]),
|
|
6882
|
+
}`}},Wo=N().finite(),Hn=H(["float","vec2","vec3","vec4"]),Pe=Lt([Wo,D(Wo)]),Me=L([R(),N().int().nonnegative()]),Mn=Lt([S({value:Pe}).strict(),S({link:Me}).strict()]),Ur=["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"],Wr=S({type:H(Ur),props:bt(R(),he()),inputs:D(Lt([S({value:Pe,id:R(),gpu:Hn,enabled:Q()}).strict(),S({link:Me,id:R(),gpu:Hn,enabled:Q()}).strict()])),outputs:D(S({id:R(),gpu:Hn.or(W("closure")).nullable()}).strict())}).strict(),_n=de(()=>Lt([S({principled:W(!0)}).strict(),S({emission:L([Mn,Mn])}).strict(),S({transparent:N()}).strict(),S({none:W(!0)}).strict(),S({mix:L([Mn,_n,_n])}).strict(),S({add:L([_n,_n])}).strict()])),Hr=S({surface:H(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:bt(R(),Mn),closure:_n.optional(),nodes:bt(R(),Wr)}).strict();function qr(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 Ee="vec3(0.2126729, 0.7151522, 0.0721750)",Gr=o=>o==="float"?1:Number(o[3]);function Xr(o,t){const n=typeof t=="number"?[t]:t,e=Gr(o);return Array.from({length:e},(r,a)=>n[a]??(a===3?1:0))}function Yr(o,t,n){if(t===n)return o;const e=a=>a==="float"?"float":`float${a[3]}`,r=t==="vec4"&&n==="float"?`, ${Ee}`:"";return`${e(n)}_from_${e(t)}(${o}${r})`}const Zr={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},Qr={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},Ho={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"},Jr={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},ti={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},ni=(()=>{const o=new Map;for(const[t,n]of Object.entries(io))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 C(o,t){if(!(t in o.props))throw new Error(`${o.type} arrived without its '${t}' property`);return o.props[t]}const oi=`
|
|
6883
6883
|
#define GPU_FRAGMENT_SHADER
|
|
6884
6884
|
#define FrontFacing gl_FrontFacing
|
|
6885
6885
|
#ifndef USE_TRANSMISSION
|
|
@@ -6936,7 +6936,7 @@ void blender_init_globals() {
|
|
|
6936
6936
|
g_data.curve_T = vec3(0.0);
|
|
6937
6937
|
g_data.barycentric_coords = vec2(0.0);
|
|
6938
6938
|
}
|
|
6939
|
-
`,
|
|
6939
|
+
`,ei=`
|
|
6940
6940
|
uniform vec2 blenderViewport;
|
|
6941
6941
|
vec3 blender_orco() {
|
|
6942
6942
|
// attr_load_orco: the orco attribute (\`orcoAttribute\`), interpolated.
|
|
@@ -7019,44 +7019,48 @@ vec3 blender_reflection() {
|
|
|
7019
7019
|
: normalize(cameraPosition - vBlenderWorldPosition);
|
|
7020
7020
|
return blender_from_three * -reflect(incident, normalize(vBlenderWorldNormal));
|
|
7021
7021
|
}
|
|
7022
|
-
`;class vo{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=Wr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Qr.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 f=this.node(e,r)[a];if(!f)throw new Error(`${e} has no output ${a}`);return this.s.structure.push(["l",e,a]),Hr(f.name,f.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(${Kt("")}, 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((l,c)=>({name:`${a}_${c}`,type:l.gpu==="closure"||l.gpu===null?"float":l.gpu}));this.emitted.set(t,r);const i=l=>`${r[l].type} ${r[l].name} = ${r[l].type}(0.0);`,f=r.map((l,c)=>i(c)).join(" "),u=l=>l.map(c=>r[c].name).join(", "),h=(l=[])=>[...n.inputs.map(_=>this.source(_,_.gpu)),...l,...r.map(_=>_.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=[f];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const l=r[0].type;s.push(`${r[0].name} = ${this.uniform(l,C(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Kt("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((c,_)=>{r[_]&&s.push(`${r[_].name} = ${this.d(c)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const l=C(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(l),this.s.structure.push(["a",l]);const c=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(c)}(${io(l)}, ${u(r.map((_,d)=>d))});`);for(const _ of r)s.push(`${_.name} = ${this.d(_.name)};`);break}case"ShaderNodeUVMap":{const l=C(n,"uv_map");this.s.uvs.add(l),s.push(`${r[0].name} = ${this.d(`vec3(${Kt(l)}, 0.0)`)};`);break}case"ShaderNodeMath":{const l=C(n,"operation"),c=this.use(qr[l]??`math_${l.toLowerCase()}`);s.push(`${c}(${h()});`),C(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const l=C(n,"operation");s.push(`${this.use(Gr[l]??`vector_math_${l.toLowerCase()}`)}(${h()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${C(n,"vector_type").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${h()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${h()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${h()});`);break;case"ShaderNodeMix":{const l=C(n,"data_type"),c=C(n,"factor_mode")==="NON_UNIFORM",_={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[l];if(!_)throw new Error(`Mix has data type ${l}`);const d=l==="VECTOR"&&c;let m=this.input(n,d?"Factor_Vector":"Factor_Float");if(C(n,"clamp_factor")){const g=`${a}_fac`;s.push(d?`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=l==="FLOAT"?"node_mix_float":l==="VECTOR"?c?"node_mix_vector_non_uniform":"node_mix_vector":l==="RGBA"?`node_mix_${Ho[C(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${_}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${_}`)}, ${this.input(n,`B_${_}`)}, ${u([v])});`),l==="RGBA"&&C(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 l=`${a}_fac`;s.push(`float ${l}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${l});`);const c=n.inputs.slice(1).map(_=>this.source(_,_.gpu));s.push(`${this.use(`mix_${Ho[C(n,"blend_type")]}`)}(${[l,...c,u([0])].join(", ")});`),C(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const l=C(n,"color_ramp"),c=this.input(n,"Fac"),[_,d]=l.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(l.elements.length===1)s.push(`${u([0])} = ${m(_)}; ${u([1])} = ${u([0])}.a;`);else if(l.elements.length===2&&l.color_mode==="RGB"&&d&&l.interpolation!=="B_SPLINE"&&l.interpolation!=="CARDINAL")if(l.interpolation==="CONSTANT")s.push(`${this.use("valtorgb_opti_constant")}(${c}, ${this.uniform("float",Math.max(_[0],d[0]))}, ${m(_)}, ${m(d)}, ${u([0,1])});`);else{const p=1/(d[0]-_[0]),v=l.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${c}, ${this.uniform("vec2",[p,-p*_[0]])}, ${m(_)}, ${m(d)}, ${u([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:l.table}),this.s.structure.push(["ramp",l.interpolation==="CONSTANT"]),s.push(l.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${c}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${c}, 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 l=C(n,"curve_mapping"),c=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:c,table:l.table}),this.s.structure.push(["curve"]);const _=this.input(n,n.inputs.some(d=>d.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${_}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${c}, 0.5, ${this.uniform("vec4",l.minimums)}, ${this.uniform("vec4",l.dividers)}, ${this.uniform("vec4",l.starts)}, ${this.uniform("vec4",l.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?s.push(`${this.use("curves_vector_mixed")}(${_}, ${this.input(n,"Vector","vec3")}, ${c}, 0.5, ${this.uniform("vec3",l.minimums.slice(0,3))}, ${this.uniform("vec3",l.dividers.slice(0,3))}, ${this.uniform("vec3",l.starts.slice(0,3))}, ${this.uniform("vec3",l.ends.slice(0,3))}, ${u([0])});`):s.push(`${this.use("curves_float_mixed")}(${_}, ${this.input(n,"Value","float")}, ${c}, 0.5, ${this.uniform("float",l.minimums[0])}, ${this.uniform("float",l.dividers[0])}, ${this.uniform("float",l.starts[0])}, ${this.uniform("float",l.ends[0])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const l=Number(C(n,"noise_dimensions")[0]),c=this.use(`node_noise_tex_${Xr[C(n,"noise_type")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=C(n,"normalize")?"1.0":"0.0";s.push(`${c}(${[_,...d,m,"1.0",u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const l=Number(C(n,"voronoi_dimensions")[0]),c=this.use(`node_tex_voronoi_${Yr[C(n,"feature")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Zr[C(n,"distance")].toFixed(1)}`,p=C(n,"normalize")?"1.0":"0.0";s.push(`${c}(${[_,...d,m,p,u(r.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const l=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(_=>this.source(_,_.gpu));s.push(`${this.use("node_tex_checker")}(${[l,...c,u(r.map((_,d)=>d))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const l=Number(C(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${l}d`)}(${h()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const l=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),_=p=>C(n,`${p}#value`).toFixed(1),d=n.type==="ShaderNodeTexWave"?[_("wave_type"),_("bands_direction"),_("rings_direction"),_("wave_profile")]:n.type==="ShaderNodeTexGradient"?[_("gradient_type")]:n.type==="ShaderNodeTexMagic"?[C(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",C(n,"offset")),C(n,"offset_frequency").toFixed(1),this.uniform("float",C(n,"squash")),C(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)}(${[l,...c,...d,u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const l=C(n,"data_type")==="FLOAT_VECTOR",c=C(n,"interpolation_type").toLowerCase(),_=C(n,"clamp");s.push(`${this.use(`${l?"vector_":""}map_range_${c}`)}(${h([_?"1.0":"0.0"])});`),_&&!l&&(c==="linear"||c==="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(C(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${h()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${h()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${h()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${h()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${h([Se])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${C(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${C(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeVectorRotate":{const l={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[C(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${l}`)}(${h([C(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const l=n.inputs[1],c="link"in l?this.source(l,"vec3"):"g_data.N";"link"in l||this.s.structure.push("world-normal");const _=this.source(n.inputs[0],"float"),d=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(d)}(${[_,c,u(r.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const l=n.inputs.find(w=>w.id==="Height"),c=n.inputs.find(w=>w.id==="Normal"),_=c&&"link"in c?this.source(c,"vec3"):"g_data.N";if(!l||!("link"in l)){s.push(`${u([0])} = ${_};`);break}const d=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new vo(this.graph,this.s,!0,`${d}_`),p=m.source(l,"float");this.s.functions[Number(d.slice(8))]=`float ${d}() {
|
|
7023
|
-
${
|
|
7022
|
+
`;class vo{constructor(t,n,e=!1,r="bgN"){this.graph=t,this.derivative=e,this.prefix=r,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}`,r=Xr(t,n);return this.s.uniforms.set(e,t==="float"?r[0]:r),this.s.uniformTypes.set(e,t),e}use(t){const n=ni.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,r]=t.link,a=this.graph.nodes[e];if(!a)throw new Error(`The graph links to ${e}, which it does not carry`);const f=this.node(e,a)[r];if(!f)throw new Error(`${e} has no output ${r}`);return this.s.structure.push(["l",e,r]),Yr(f.name,f.type,n)}input(t,n,e){const r=t.inputs.find(a=>a.id===n)??t.inputs.find(a=>a.id.replace(/_/g," ")===n);if(!r)throw new Error(`${t.type} arrived without its '${n}' input`);return this.source(r,e??r.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(${Kt("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const r=`${this.prefix}${this.emitted.size}`,a=n.outputs.map((i,c)=>({name:`${r}_${c}`,type:i.gpu==="closure"||i.gpu===null?"float":i.gpu}));this.emitted.set(t,a);const s=i=>`${a[i].type} ${a[i].name} = ${a[i].type}(0.0);`,f=a.map((i,c)=>s(c)).join(" "),u=i=>i.map(c=>a[c].name).join(", "),_=(i=[])=>[...n.inputs.map(m=>this.source(m,m.gpu)),...i,...a.map(m=>m.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 l=[f];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const i=a[0].type;l.push(`${a[0].name} = ${this.uniform(i,C(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Kt("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((c,m)=>{a[m]&&l.push(`${a[m].name} = ${this.d(c)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const i=C(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(i),this.s.structure.push(["a",i]);const c=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";l.push(`${this.use(c)}(${so(i)}, ${u(a.map((m,d)=>d))});`);for(const m of a)l.push(`${m.name} = ${this.d(m.name)};`);break}case"ShaderNodeUVMap":{const i=C(n,"uv_map");this.s.uvs.add(i),l.push(`${a[0].name} = ${this.d(`vec3(${Kt(i)}, 0.0)`)};`);break}case"ShaderNodeMath":{const i=C(n,"operation"),c=this.use(Zr[i]??`math_${i.toLowerCase()}`);l.push(`${c}(${_()});`),C(n,"use_clamp")&&l.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const i=C(n,"operation");l.push(`${this.use(Qr[i]??`vector_math_${i.toLowerCase()}`)}(${_()});`);break}case"ShaderNodeMapping":l.push(`${this.use(`mapping_${C(n,"vector_type").toLowerCase()}`)}(${_()});`);break;case"ShaderNodeInvert":l.push(`${this.use("invert")}(${_()});`);break;case"ShaderNodeSeparateXYZ":l.push(`${this.use("separate_xyz")}(${_()});`);break;case"ShaderNodeCombineXYZ":l.push(`${this.use("combine_xyz")}(${_()});`);break;case"ShaderNodeMix":{const i=C(n,"data_type"),c=C(n,"factor_mode")==="NON_UNIFORM",m={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[i];if(!m)throw new Error(`Mix has data type ${i}`);const d=i==="VECTOR"&&c;let h=this.input(n,d?"Factor_Vector":"Factor_Float");if(C(n,"clamp_factor")){const g=`${r}_fac`;l.push(d?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${h}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${h}, 0.0, 1.0, ${g});`),h=g}const p=i==="FLOAT"?"node_mix_float":i==="VECTOR"?c?"node_mix_vector_non_uniform":"node_mix_vector":i==="RGBA"?`node_mix_${Ho[C(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${m}`);l.push(`${this.use(p)}(${h}, ${this.input(n,`A_${m}`)}, ${this.input(n,`B_${m}`)}, ${u([v])});`),i==="RGBA"&&C(n,"clamp_result")&&l.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const i=`${r}_fac`;l.push(`float ${i}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${i});`);const c=n.inputs.slice(1).map(m=>this.source(m,m.gpu));l.push(`${this.use(`mix_${Ho[C(n,"blend_type")]}`)}(${[i,...c,u([0])].join(", ")});`),C(n,"use_clamp")&&l.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const i=C(n,"color_ramp"),c=this.input(n,"Fac"),[m,d]=i.elements,h=p=>this.uniform("vec4",p.slice(1,5));if(i.elements.length===1)l.push(`${u([0])} = ${h(m)}; ${u([1])} = ${u([0])}.a;`);else if(i.elements.length===2&&i.color_mode==="RGB"&&d&&i.interpolation!=="B_SPLINE"&&i.interpolation!=="CARDINAL")if(i.interpolation==="CONSTANT")l.push(`${this.use("valtorgb_opti_constant")}(${c}, ${this.uniform("float",Math.max(m[0],d[0]))}, ${h(m)}, ${h(d)}, ${u([0,1])});`);else{const p=1/(d[0]-m[0]),v=i.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";l.push(`${this.use(v)}(${c}, ${this.uniform("vec2",[p,-p*m[0]])}, ${h(m)}, ${h(d)}, ${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"]),l.push(i.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${c}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${c}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),l.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const i=C(n,"curve_mapping"),c=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:c,table:i.table}),this.s.structure.push(["curve"]);const m=this.input(n,n.inputs.some(d=>d.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?l.push(`${this.use("curves_combined_rgb")}(${m}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${c}, 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"?l.push(`${this.use("curves_vector_mixed")}(${m}, ${this.input(n,"Vector","vec3")}, ${c}, 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])});`):l.push(`${this.use("curves_float_mixed")}(${m}, ${this.input(n,"Value","float")}, ${c}, 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(C(n,"noise_dimensions")[0]),c=this.use(`node_noise_tex_${Kr[C(n,"noise_type")]}_${i}d`),m=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),h=C(n,"normalize")?"1.0":"0.0";l.push(`${c}(${[m,...d,h,"1.0",u(a.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const i=Number(C(n,"voronoi_dimensions")[0]),c=this.use(`node_tex_voronoi_${Jr[C(n,"feature")]}_${i}d`),m=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),h=`${ti[C(n,"distance")].toFixed(1)}`,p=C(n,"normalize")?"1.0":"0.0";l.push(`${c}(${[m,...d,h,p,u(a.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const i=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(m=>this.source(m,m.gpu));l.push(`${this.use("node_tex_checker")}(${[i,...c,u(a.map((m,d)=>d))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const i=Number(C(n,"noise_dimensions")[0]);l.push(`${this.use(`node_white_noise_${i}d`)}(${_()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const i=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=p=>C(n,`${p}#value`).toFixed(1),d=n.type==="ShaderNodeTexWave"?[m("wave_type"),m("bands_direction"),m("rings_direction"),m("wave_profile")]:n.type==="ShaderNodeTexGradient"?[m("gradient_type")]:n.type==="ShaderNodeTexMagic"?[C(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",C(n,"offset")),C(n,"offset_frequency").toFixed(1),this.uniform("float",C(n,"squash")),C(n,"squash_frequency").toFixed(1)],h={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];l.push(`${this.use(h)}(${[i,...c,...d,u(a.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const i=C(n,"data_type")==="FLOAT_VECTOR",c=C(n,"interpolation_type").toLowerCase(),m=C(n,"clamp");l.push(`${this.use(`${i?"vector_":""}map_range_${c}`)}(${_([m?"1.0":"0.0"])});`),m&&!i&&(c==="linear"||c==="stepped")&&l.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":l.push(`${this.use(C(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${_()});`);break;case"ShaderNodeHueSaturation":l.push(`${this.use("hue_sat")}(${_()});`);break;case"ShaderNodeBrightContrast":l.push(`${this.use("brightness_contrast")}(${_()});`);break;case"ShaderNodeGamma":l.push(`${this.use("node_gamma")}(${_()});`);break;case"ShaderNodeRGBToBW":l.push(`${this.use("rgbtobw")}(${_([Ee])});`);break;case"ShaderNodeSeparateColor":l.push(`${this.use(`separate_color_${C(n,"mode").toLowerCase()}`)}(${_()});`);break;case"ShaderNodeCombineColor":l.push(`${this.use(`combine_color_${C(n,"mode").toLowerCase()}`)}(${_()});`);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"}[C(n,"rotation_type")];l.push(`${this.use(`node_vector_rotate_${i}`)}(${_([C(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const i=n.inputs[1],c="link"in i?this.source(i,"vec3"):"g_data.N";"link"in i||this.s.structure.push("world-normal");const m=this.source(n.inputs[0],"float"),d=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";l.push(`${this.use(d)}(${[m,c,u(a.map((h,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const i=n.inputs.find(w=>w.id==="Height"),c=n.inputs.find(w=>w.id==="Normal"),m=c&&"link"in c?this.source(c,"vec3"):"g_data.N";if(!i||!("link"in i)){l.push(`${u([0])} = ${m};`);break}const d=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const h=new vo(this.graph,this.s,!0,`${d}_`),p=h.source(i,"float");this.s.functions[Number(d.slice(8))]=`float ${d}() {
|
|
7023
|
+
${h.lines.join(`
|
|
7024
7024
|
`)}
|
|
7025
7025
|
return ${p};
|
|
7026
|
-
}`;const v=this.input(n,"Filter Width","float");
|
|
7026
|
+
}`;const v=this.input(n,"Filter Width","float");l.push(`float ${r}_h = ${d}();`,`g_derivative_filter_width = ${v} * derivative_scale_get();`,`g_derivative_flag = 1; float ${r}_hx = ${d}();`,`g_derivative_flag = -1; float ${r}_hy = ${d}();`,"g_derivative_flag = 0;");const g=C(n,"invert")?"-1.0":"1.0";l.push(`${this.use("node_bump")}(${this.input(n,"Strength","float")}, ${this.input(n,"Distance","float")}, ${v}, ${r}_h, ${m}, vec2(${r}_hx, ${r}_hy), ${g}, ${u([0])});`);break}case"ShaderNodeNormalMap":{const i=C(n,"space"),c=this.input(n,"Strength","float"),m=this.input(n,"Color","vec3"),d=`${r}_n`;if(l.push(`vec3 ${d}; ${this.use(i.startsWith("BLENDER_")?"color_to_blender_normal_new_shading":"color_to_normal_new_shading")}(${m}, ${d});`),n.props.convention==="DIRECTX"&&l.push(`${this.use("color_invert_green_channel")}(${d}, ${d});`),i==="TANGENT"){const h=C(n,"uv_map");this.s.uvs.add(h),l.push(`${this.use("node_normal_map")}(blender_uv_tangent(${Kt(h)}), ${c}, ${d}, g_data.Ni, ${u([0])});`)}else(i==="OBJECT"||i==="BLENDER_OBJECT")&&l.push(`${this.use("normal_transform_object_to_world")}(${d}, ${d});`),l.push(`${this.use("node_normal_map_mix")}(${c}, ${d}, ${u([0])});`);break}case"ShaderNodeNewGeometry":{l.push(`${this.use("node_geometry")}(${["blender_orco()",u(a.map((i,c)=>c))].join(", ")});`),a[0]&&l.push(`${a[0].name} = ${this.d(a[0].name)};`);for(const i of[1,2,4])a[i]&&l.push(`${a[i].name} = normalize(${a[i].name});`);break}case"ShaderNodeTexImage":{const i=C(n,"image");if(i===null){l.push(n.props.image_missing===!0?`${u([0])} = vec4(1.0, 0.0, 1.0, 1.0); ${u([1])} = 1.0;`:`${u([0])} = vec4(0.0); ${u([1])} = 0.0;`);break}const c=C(n,"projection"),m=C(n,"interpolation"),d=m==="Cubic"||m==="Smart",h=C(n,"extension"),p=`bgImage${this.s.images.length}`;this.s.images.push({uniform:p,node:t,name:i.name,revision:i.revision,extension:h,closest:m==="Closest",mipmap:c!=="SPHERE"&&c!=="TUBE",tiled:c==="FLAT"&&n.props.image_tiled===!0});const v=this.s.images.at(-1).tiled;this.s.structure.push(["img",c,d,v]);let g=this.coordinate(n,"uv");const w=u([0]),y=u([1]);if(c==="BOX"){const O=`${r}_n`;l.push(`vec3 ${O}; ${this.use("world_normals_get")}(${O}); ${this.use("normal_transform_world_to_object")}(${O}, ${O});`,`vec4 ${r}_c1, ${r}_c2, ${r}_c3;`,`${this.use(d?"tex_box_sample_cubic":"tex_box_sample_linear")}(${g}, ${O}, ${p}, ${r}_c1, ${r}_c2, ${r}_c3);`,`${this.use("tex_box_blend")}(${O}, ${r}_c1, ${r}_c2, ${r}_c3, ${this.uniform("float",C(n,"projection_blend"))}, ${w}, ${y});`)}else if(v)d&&this.use("cubic_bspline_coefficients"),l.push(`${d?"blender_tex_tile_cubic":"blender_tex_tile_linear"}(${g}, ${p}, ${p}Map, ${w}, ${y});`);else{if(c==="SPHERE"||c==="TUBE"){const O=`${r}_co`;l.push(`vec3 ${O}; ${this.use("point_texco_remap_square")}(${g}, ${O});`,`${this.use(c==="SPHERE"?"point_map_to_sphere":"point_map_to_tube")}(${O}, ${O});`),g=O}l.push(`${this.use(d?"node_tex_image_cubic":"node_tex_image_linear")}(${g}, ${p}, ${w}, ${y});`),h==="CLIP"&&l.push(`if (any(lessThan(${g}.xy, vec2(0.0))) || any(greaterThan(${g}.xy, vec2(1.0)))) { ${w} = vec4(0.0); ${y} = 0.0; }`)}const P=C(n,"image_alpha_mode"),A=this.uses(t,1),T=u([0]);P==="NONE"||P==="CHANNEL_PACKED"||C(n,"image_is_data")?l.push(`${T}.a = 1.0;`):P==="PREMUL"?l.push(A?`if (${T}.a != 0.0 && ${T}.a != 1.0) ${T}.rgb /= ${T}.a;`:`${T}.a = 1.0;`):l.push(A?`${T}.a = 1.0;`:`${T}.rgb *= ${T}.a;`);break}}return this.lines.push(...l),a}uses(t,n){const e=a=>"link"in a&&a.link[0]===t&&a.link[1]===n,r=a=>a!==void 0&&("emission"in a?a.emission.some(e):"mix"in a?e(a.mix[0])||r(a.mix[1])||r(a.mix[2]):"add"in a?r(a.add[0])||r(a.add[1]):!1);return Object.values(this.graph.inputs).some(e)||Object.values(this.graph.nodes).some(a=>a.inputs.some(e))||r(this.graph.closure)}compile(){const t=this.graph.surface==="ShaderNodeEmission"?{Color:"vec4",Strength:"float"}:{"Base Color":"vec4",Metallic:"float",Roughness:"float",Alpha:"float","Emission Color":"vec4","Emission Strength":"float",Normal:"vec3"},n={},e=[];let r=0;for(const[i,c]of Object.entries(t)){const m=this.graph.inputs[i];if(!m||i==="Normal"&&!("link"in m))continue;const d=`bgOut${r++}`;n[i]={global:d,type:c},this.s.structure.push(["out",i]),e.push(`${d} = ${this.source(m,c)};`)}const a=this.graph.closure;if(a){let i=0;const c=(m,d)=>{if("principled"in m)this.s.structure.push("cP"),e.push(`bgClosureP += ${d};`);else if("emission"in m)this.s.structure.push("cE"),e.push(`bgClosureE += ${d} * ${this.source(m.emission[0],"vec4")}.rgb * ${this.source(m.emission[1],"float")};`);else if("transparent"in m)this.s.structure.push("cT"),e.push(`bgClosureT += ${d} * ${this.source({value:m.transparent},"float")};`);else if("mix"in m){this.s.structure.push("cM");const h=`bgClosureF${i++}`;e.push(`float ${h} = clamp(${this.source(m.mix[0],"float")}, 0.0, 1.0);`),c(m.mix[1],`${d} * (1.0 - ${h})`),c(m.mix[2],`${d} * ${h}`)}else"add"in m?(this.s.structure.push("cA"),c(m.add[0],d),c(m.add[1],d)):this.s.structure.push("c0")};e.push("bgClosureP = 0.0;","bgClosureE = vec3(0.0);","bgClosureT = 0.0;"),c(a,"1.0")}const s=[],f=new Set,u=i=>{if(!f.has(i)){f.add(i);for(const c of io[i].deps)u(c);s.push(i)}};for(const i of this.s.files)u(i);const _=`void blenderGraph() {
|
|
7027
7027
|
blender_init_globals();
|
|
7028
7028
|
${[...this.lines,...e].join(`
|
|
7029
7029
|
`)}
|
|
7030
|
-
}`,
|
|
7030
|
+
}`,l=[Br,ai(oi+s.map(i=>io[i].code).join(`
|
|
7031
7031
|
`)+`
|
|
7032
|
-
`+
|
|
7033
|
-
`)),...[...this.s.uniformTypes].map(([
|
|
7034
|
-
uniform highp sampler2D ${
|
|
7035
|
-
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:
|
|
7032
|
+
`+ei,[...this.s.functions,_].join(`
|
|
7033
|
+
`)),...[...this.s.uniformTypes].map(([i,c])=>`uniform ${c} ${i};`),...this.images.map(i=>i.tiled?`uniform highp sampler2DArray ${i.uniform};
|
|
7034
|
+
uniform highp sampler2D ${i.uniform}Map;`:`uniform sampler2D ${i.uniform};`),...this.ramps.map(i=>`uniform sampler2D ${i.uniform};`),...Object.values(n).map(i=>`${i.type} ${i.global};`),...a?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,_].join(`
|
|
7035
|
+
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:l,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:a!==void 0}}}function ai(o,t){const n=[],e=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let r=0;for(let u;u=e.exec(o);){if(u.index<r)continue;let _=u.index+u[0].length;for(let m=1;_<o.length&&m>0;_++)m+=o[_]==="("?1:o[_]===")"?-1:0;const l=o.slice(_).match(/^\s*(\{|;)/);if(!l||/^\s*#/.test(o.slice(o.lastIndexOf(`
|
|
7036
7036
|
`,u.index)+1,u.index+1))||o.slice(Math.max(0,u.index-2),u.index).endsWith(`\\
|
|
7037
|
-
`))continue;let c=
|
|
7038
|
-
`).find(
|
|
7037
|
+
`))continue;let c=_+l[0].length;if(l[1]==="{")for(let m=1;c<o.length&&m>0;c++)m+=o[c]==="{"?1:o[c]==="}"?-1:0;n.push({text:o.slice(r,u.index),name:null}),n.push({text:o.slice(u.index,c),name:u[1]}),r=c,e.lastIndex=c}n.push({text:o.slice(r),name:null});const a=new Set(n.filter(u=>u.name===null)),s=new Set,f=u=>{for(const _ of u.matchAll(/[A-Za-z_]\w*/g))s.add(_[0])};f(t);for(const u of a)f(u.text);for(let u=!0;u;){u=!1;for(const _ of n)a.has(_)||_.name===null||!s.has(_.name)||(a.add(_),f(_.text),u=!0)}return n.filter(u=>a.has(u)).map(u=>u.text).join("")}function so(o){return`v${kt(o)}`}function Kt(o){return o===""?"vBlenderUvRender":`vBlenderUv_${[...o].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function ri(o){return new vo(o).compile()}function ii(o){const t=new Uint16Array(o.length*4);o.forEach((e,r)=>t.set([e[0]??0,e[1]??0,e[2]??0,e[3]??1].map(a=>fn.toHalfFloat(a)),r*4));const n=new zn(t,o.length,1,Dn,co);return n.minFilter=n.magFilter=Xt,n.wrapS=n.wrapT=ce,n.needsUpdate=!0,n}const pt=new WeakMap,Ne=new Set,Ct=new WeakMap,xn=new WeakMap;function bn(o){const t=Ct.get(o);if(t){Ct.delete(o);for(const n of t.binding.ramps)n.dispose()}}function si(o,t,n,e=!1){const r=pt.get(o);if(t&&Ne.has(t.key)&&(t=null),!t){if(bn(o),r){for(const f of r.ramps)f.dispose();pt.delete(o),o.needsUpdate=!0}return}if(r&&r.compiled.key===t.key){bn(o),yn(r,t,n);return}if(e){bn(o);for(const u of r?.ramps??[])u.dispose();const f={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};yn(f,t,n),pt.set(o,f),o.needsUpdate=!0;return}const a=Ct.get(o);if(a&&a.binding.compiled.key===t.key){yn(a.binding,t,n);return}bn(o);const s={compiled:t,uniforms:{},ramps:[],channels:r?.channels??{}};yn(s,t,n),Ct.set(o,{binding:s,started:!1})}function yn(o,t,n){o.compiled=t;for(const[e,r]of t.uniforms){const a=typeof r=="number"?r:r.length===2?new Gt(...r):r.length===3?new x(...r):new fo(...r),s=o.uniforms[e];s?s.value=a:o.uniforms[e]={value:a}}for(const e of o.ramps)e.dispose();o.ramps=t.ramps.map(e=>{const r=ii(e.table);return(o.uniforms[e.uniform]??={value:null}).value=r,r});for(const e of t.images){const r=n(e);if(e.tiled){const a=r!==null&&"tiles"in r?r:null;(o.uniforms[e.uniform]??={value:null}).value=a?.tiles??null,(o.uniforms[`${e.uniform}Map`]??={value:null}).value=a?.map??null}else(o.uniforms[e.uniform]??={value:null}).value=r!==null&&"tiles"in r?null:r}}function li(o){const t=pt.get(o);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function fi(o){return Object.values(pt.get(o)?.channels??{})}function ci(o,t){const n=new Set(["position","normal","uv"]);if(t.hasAttribute("tangent")&&n.add("tangent"),o.vertexColors&&n.add("color"),!(o instanceof nn))return n;const e=t.userData.blenderUvChannels,r=a=>{const s=a===""?0:e?.[a]??9;n.add(s===0?"uv":`uv${s}`)};for(const a of[o.map,o.roughnessMap,o.normalMap])a&&r(a.userData.blenderUvName??"");for(const a of[pt.get(o),Ct.get(o)?.binding])if(a){n.add("blenderOrco");for(const s of a.compiled.uvs)r(s);for(const s of a.compiled.attributes)n.add(kt(s))}return n}function qo(o,t){const n=t.userData.blenderUvChannels,e=t.getAttribute("position")?.count??0,r={};for(const a of o.uvs){let s=a===""?0:n?.[a];s===void 0&&(s=9,t.getAttribute("uv9")?.count!==e&&t.setAttribute("uv9",new dt(new Float32Array(e*2),2))),r[a]=s}return r}function ui(o,t,n,e,r,a,s){const f=xn.get(o);f&&++f.draws>1&&(f.shadow.dispose(),xn.delete(o));const u=Ct.get(o);if(u&&!u.started){u.started=!0,u.binding.channels=qo(u.binding.compiled,t);const c=s(o);pt.set(c,u.binding);const m=new Rt(t,c);m.castShadow=a.castShadow,m.receiveShadow=a.receiveShadow;const d=()=>{if(Ct.get(o)!==u){c.dispose();return}Ct.delete(o);for(const h of pt.get(o)?.ramps??[])h.dispose();pt.set(o,u.binding),o.needsUpdate=!0,xn.get(o)?.shadow.dispose(),xn.set(o,{shadow:c,draws:0}),Ot()};n.compileAsync(m,r,e).then(d,d)}const _=pt.get(o);if(!_)return;const l=n.properties.get(o).currentProgram;if(l?.diagnostics?.runnable===!1&&l.cacheKey?.includes(_.compiled.key)){Ne.add(_.compiled.key),pt.delete(o),o.needsUpdate=!0;const c=l.diagnostics.fragmentShader.log.split(`
|
|
7038
|
+
`).find(m=>m.startsWith("ERROR"))??"";console.warn(`Blender material "${o.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${c}`);return}const i=qo(_.compiled,t);JSON.stringify(i)!==JSON.stringify(_.channels)&&(_.channels=i,o.needsUpdate=!0)}function _i(o){const t=Array.isArray(o.material)?o.material:[o.material];if(!t.some(u=>u instanceof nn&&pt.has(u)))return;const n=o.geometry,e=o.userData.blenderTexspace??null,r=n.getAttribute("position"),a=JSON.stringify([e,r?.version??0,r?.count??0]);!n.userData.blenderOrcoFromDoor&&n.userData.blenderOrcoStamp!==a&&(n.setAttribute("blenderOrco",mi(n,e)),n.userData.blenderOrcoStamp=a);const s=r?.count??0,f=o.userData.blenderDefaultColor;for(const u of t){const _=u instanceof nn?pt.get(u):void 0;for(const l of _?.compiled.attributes??[]){const i=kt(l),c=l===""?f===void 0?void 0:n.getAttribute(kt(f)):n.getAttribute(i);c&&c.count===s?n.getAttribute(i)!==c&&n.setAttribute(i,c):n.getAttribute(i)?.count!==s&&n.setAttribute(i,new dt(new Float32Array(s*4),4))}}}function mi(o,t){const n=o.getAttribute("position");let e,r;if(t)e=[...t[0]],r=[...t[1]];else{o.computeBoundingBox();const s=o.boundingBox;e=[(s.min.x+s.max.x)/2,(s.min.y+s.max.y)/2,(s.min.z+s.max.z)/2],r=[(s.max.x-s.min.x)/2,(s.max.y-s.min.y)/2,(s.max.z-s.min.z)/2]}r=r.map(s=>s===0?1:s);const a=new Float32Array(n.count*3);for(let s=0;s<n.count;s++)a[s*3]=(n.getX(s)-e[0])/r[0]*.5+.5,a[s*3+1]=(n.getY(s)-e[1])/r[1]*.5+.5,a[s*3+2]=(n.getZ(s)-e[2])/r[2]*.5+.5;return new dt(a,3)}function di(o,t){const n=pt.get(o);if(!n)return;const{compiled:e,channels:r}=n;Object.assign(t.uniforms,n.uniforms,{blenderViewport:{value:Re}});const a=v=>v===0?"uv":`uv${v}`,s=`varying vec3 vBlenderObjectPosition;
|
|
7039
7039
|
varying vec3 vBlenderObjectNormal;
|
|
7040
7040
|
varying vec3 vBlenderWorldPosition;
|
|
7041
7041
|
varying vec3 vBlenderWorldNormal;
|
|
7042
7042
|
varying vec3 vBlenderOrco;
|
|
7043
|
-
${e.attributes.map(v=>`varying vec4 ${
|
|
7043
|
+
${e.attributes.map(v=>`varying vec4 ${so(v)};`).join(`
|
|
7044
7044
|
`)}
|
|
7045
7045
|
${e.uvs.map(v=>`varying vec2 ${Kt(v)};`).join(`
|
|
7046
|
-
`)}`,f=e.attributes.map(v=>`attribute vec4 ${
|
|
7046
|
+
`)}`,f=e.attributes.map(v=>`attribute vec4 ${kt(v)};`).join(`
|
|
7047
7047
|
`);t.vertexShader=`attribute vec3 blenderOrco;
|
|
7048
7048
|
${f}
|
|
7049
|
-
${
|
|
7049
|
+
${s}
|
|
7050
7050
|
${t.vertexShader}`.replace("#include <project_vertex>",`vBlenderObjectPosition = transformed;
|
|
7051
7051
|
vBlenderObjectNormal = objectNormal;
|
|
7052
|
-
|
|
7053
|
-
|
|
7052
|
+
mat4 blenderWorldMatrix = modelMatrix;
|
|
7053
|
+
#ifdef USE_INSTANCING
|
|
7054
|
+
blenderWorldMatrix = modelMatrix * instanceMatrix;
|
|
7055
|
+
#endif
|
|
7056
|
+
vBlenderWorldPosition = (blenderWorldMatrix * vec4(transformed, 1.0)).xyz;
|
|
7057
|
+
vBlenderWorldNormal = normalize(transpose(inverse(mat3(blenderWorldMatrix))) * objectNormal);
|
|
7054
7058
|
vBlenderOrco = blenderOrco;
|
|
7055
|
-
${e.attributes.map(v=>`${
|
|
7059
|
+
${e.attributes.map(v=>`${so(v)} = ${kt(v)};`).join(`
|
|
7056
7060
|
`)}
|
|
7057
|
-
${e.uvs.map(v=>`${Kt(v)} = ${r
|
|
7061
|
+
${e.uvs.map(v=>`${Kt(v)} = ${a(r[v]??0)};`).join(`
|
|
7058
7062
|
`)}
|
|
7059
|
-
#include <project_vertex>`);const u=v=>e.outputs[v]?.global,
|
|
7063
|
+
#include <project_vertex>`);const u=v=>e.outputs[v]?.global,_=[];e.surface==="ShaderNodeEmission"?(_.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),_.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Color")}.rgb * ${u("Strength")};`,!1]),_.push(["#include <opaque_fragment>","outgoingLight = totalEmissiveRadiance;",!0])):e.surface==="closure"?(_.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),_.push(["#include <emissivemap_fragment>","totalEmissiveRadiance = vec3(0.0);",!1])):(_.push(["#include <color_fragment>",`diffuseColor.rgb = ${u("Base Color")}.rgb;`,!1]),_.push(["#include <alphamap_fragment>",`diffuseColor.a = ${u("Alpha")};`,!1]),_.push(["#include <metalnessmap_fragment>",`roughnessFactor = ${u("Roughness")};`,!0]),_.push(["#include <metalnessmap_fragment>",`metalnessFactor = ${u("Metallic")};`,!1]),_.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Emission Color")}.rgb * ${u("Emission Strength")};`,!1]),u("Normal")&&_.push(["#include <clearcoat_normal_fragment_begin>",`normal = normalize((viewMatrix * vec4(transpose(blender_from_three) * ${u("Normal")}, 0.0)).xyz);`,!0])),e.closure&&_.push(["#include <opaque_fragment>",`{
|
|
7060
7064
|
float blenderCoverage = diffuseColor.a;
|
|
7061
7065
|
vec3 blenderRadiance = bgClosureP * blenderCoverage * outgoingLight + bgClosureE;
|
|
7062
7066
|
float blenderAlpha = 1.0 - min(bgClosureT + bgClosureP * (1.0 - blenderCoverage), 1.0);
|
|
@@ -7066,17 +7070,17 @@ ${e.uvs.map(v=>`${Kt(v)} = ${r(a[v]??0)};`).join(`
|
|
|
7066
7070
|
outgoingLight = blenderRadiance / max(blenderAlpha, 1e-4);
|
|
7067
7071
|
#endif
|
|
7068
7072
|
diffuseColor.a = blenderAlpha;
|
|
7069
|
-
}`,!0]);const
|
|
7070
|
-
`);let p=t.fragmentShader.replace("void main() {",`${
|
|
7071
|
-
${
|
|
7073
|
+
}`,!0]);const l=v=>v.replace(/^[ \t]*#include <(\w+)>/gm,(g,w)=>l(Ut[w]??"")),i=l(t.fragmentShader.slice(0,t.fragmentShader.indexOf("void main() {"))),c=new Map([...i.matchAll(/^[ \t]*#define[ \t]+(\w+).*$/gm)].map(v=>[v[1],v[0].trim()])),d=[...new Set([...e.declarations.matchAll(/^[ \t]*#define[ \t]+(\w+)/gm)].map(v=>v[1]))].filter(v=>c.has(v)),h=[...d.map(v=>`#undef ${v}`),e.declarations,...d.flatMap(v=>[`#undef ${v}`,c.get(v)])].join(`
|
|
7074
|
+
`);let p=t.fragmentShader.replace("void main() {",`${s}
|
|
7075
|
+
${h}
|
|
7072
7076
|
void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
|
|
7073
|
-
blenderGraph();`);for(const[v,g,w]of
|
|
7077
|
+
blenderGraph();`);for(const[v,g,w]of _){if(!p.includes(v))throw new Error(`three's physical shader has no ${v}`);p=p.replace(v,w?`${g}
|
|
7074
7078
|
${v}`:`${v}
|
|
7075
|
-
${g}`)}t.fragmentShader=p}const
|
|
7079
|
+
${g}`)}t.fragmentShader=p}const Re=new Gt(1,1);function hi(o){o.getDrawingBufferSize(Re)}function pi(o,t){const n=t.userData.blenderUvChannels;for(const e of[o.map,o.roughnessMap,o.normalMap]){if(!e)continue;const r=e.userData.blenderUvName;let a=r?n?.[r]:0;if(a===void 0){a=9;const s=t.getAttribute("position")?.count;if(s===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==s&&t.setAttribute("uv9",new dt(new Float32Array(s*2),2))}e.channel!==a&&(e.channel=a,o.needsUpdate=!0)}}class vi{constructor(){this.bindings=new Map}get(t,n,e,r,a=""){let s=this.bindings.get(t);if(!s||s.source!==n){this.delete(t),s={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,s);const _=s;r&&r.then(()=>{_.disposed||(_.texture.needsUpdate=!0,_.version=n.version,Ot())},()=>{})}const f=e==="REPEAT"?Ze:e==="MIRROR"?Qe:ce,u=s.texture.wrapS!==f||s.texture.wrapT!==f;return s.texture.wrapS=s.texture.wrapT=f,s.texture.userData.blenderUvName=a,n.image&&(u||s.version!==n.version)&&(s.texture.needsUpdate=!0,s.version=n.version),s.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 yt=N().finite(),qn=L([yt,yt,yt]),gi=S({coat:yt,coat_roughness:yt,coat_ior:yt,coat_tint:qn,sheen:yt,sheen_roughness:yt,sheen_tint:qn,anisotropy:yt,anisotropy_rotation:yt,specular_level:yt,specular_tint:qn,film_thickness:yt,film_ior:yt}).strict(),xi={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},on=new WeakMap;function bi(o,t){on.has(o)||go(o),on.get(o).blenderWorldExtinction.value.copy(t)}function yi(o){const t=new nn,n=on.get(o);go(t),t.copy(o);const e=on.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 go(o,t,n={}){const e=t??xi;o.clearcoat=e.coat,o.clearcoatRoughness=e.coat_roughness,o.sheen=e.sheen,o.sheenRoughness=e.sheen_roughness,o.sheenColor.setRGB(...e.sheen_tint,vt),o.anisotropy=e.anisotropy,o.anisotropyRotation=e.anisotropy_rotation*Math.PI*2,o.specularIntensity=e.specular_level*2,o.specularColor.setRGB(...e.specular_tint,vt),o.iridescence=e.film_thickness>0?1:0,o.iridescenceIOR=e.film_ior,o.iridescenceThicknessRange=[e.film_thickness,e.film_thickness];let r=on.get(o);if(!r){r={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new wt(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new x}},on.set(o,r);const a=r;o.customProgramCacheKey=()=>`blender-principled-physical-v5${li(o)}`,o.onBeforeRender=(s,f,u,_,l)=>{pi(o,_),ui(o,_,s,f,u,l,yi),hi(s)},o.onBeforeCompile=s=>{const f=new Set([o.map,o.roughnessMap,o.normalMap].flatMap(d=>d?[d.channel]:[]).concat(fi(o)));s.vertexShader=[...f].filter(d=>d>0).sort((d,h)=>d-h).map(d=>d<=3?`#ifndef USE_UV${d}
|
|
7076
7080
|
attribute vec2 uv${d};
|
|
7077
7081
|
#endif`:`attribute vec2 uv${d};`).join(`
|
|
7078
7082
|
`)+`
|
|
7079
|
-
`+
|
|
7083
|
+
`+s.vertexShader,Object.assign(s.uniforms,a),s.fragmentShader=`uniform float blenderCoatIor;
|
|
7080
7084
|
uniform vec3 blenderWorldExtinction;
|
|
7081
7085
|
vec3 blenderInfiniteTransmission() { return vec3(
|
|
7082
7086
|
blenderWorldExtinction.x>0.?0.:1., blenderWorldExtinction.y>0.?0.:1., blenderWorldExtinction.z>0.?0.:1.); }
|
|
@@ -7087,35 +7091,35 @@ attribute vec2 uv${d};
|
|
|
7087
7091
|
if (clipImage && (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0))))) pixel = vec4(0.0);
|
|
7088
7092
|
return pixel;
|
|
7089
7093
|
}
|
|
7090
|
-
`+
|
|
7094
|
+
`+s.fragmentShader;const u=Ut.lights_physical_fragment.replace("material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );","material.specularF90 = 1.0;").replace("material.clearcoatF0 = vec3( 0.04 );","material.clearcoatF0 = vec3( pow2( ( blenderCoatIor - 1.0 ) / ( blenderCoatIor + 1.0 ) ) );"),_=Ut.normal_fragment_maps.replace("normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;","vec3 blenderBaseNormal = normal; normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; normal.y *= normalScale.y < 0.0 ? -1.0 : 1.0;").replace("normal = normalize( normalMatrix * normal );","normal = normalize(mix(blenderBaseNormal, normalize(normalMatrix * normal), max(0.0, normalScale.x)));").replace("mapN.xy *= normalScale;","mapN.xy *= normalScale; mapN.z = mix(1.0, mapN.z, clamp(normalScale.x, 0.0, 1.0));").replaceAll("texture2D( normalMap, vNormalMapUv )","blenderImageSample(normalMap, vNormalMapUv, blenderNormalClip)"),l=Ut.map_fragment.replace("texture2D( map, vMapUv )","blenderImageSample(map, vMapUv, blenderMapClip)").replace("diffuseColor *= sampledDiffuseColor;","diffuseColor.rgb *= sampledDiffuseColor.rgb;"),i=Ut.roughnessmap_fragment.replace("texture2D( roughnessMap, vRoughnessMapUv )","blenderImageSample(roughnessMap, vRoughnessMapUv, blenderRoughnessClip)"),c=Ut.lights_fragment_begin.replace("getPointLightInfo( pointLight, geometryPosition, directLight );","getPointLightInfo( pointLight, geometryPosition, directLight ); directLight.color *= exp(-blenderWorldExtinction * length(pointLight.position-geometryPosition));").replace("getSpotLightInfo( spotLight, geometryPosition, directLight );","getSpotLightInfo( spotLight, geometryPosition, directLight ); directLight.color *= exp(-blenderWorldExtinction * length(spotLight.position-geometryPosition));").replace("getDirectionalLightInfo( directionalLight, directLight );","getDirectionalLightInfo( directionalLight, directLight ); directLight.color *= blenderInfiniteTransmission();").replace("rectAreaLight = rectAreaLights[ i ];","rectAreaLight = rectAreaLights[ i ]; rectAreaLight.color *= exp(-blenderWorldExtinction * length(rectAreaLight.position-geometryPosition));").replace("getAmbientLightIrradiance( ambientLightColor )","getAmbientLightIrradiance( ambientLightColor ) * blenderInfiniteTransmission()"),m=Ut.lights_fragment_maps.replaceAll(/(getIBL(?:Irradiance|Radiance|AnisotropyRadiance)\([^;]+\))/g,"$1 * blenderInfiniteTransmission()");s.fragmentShader=s.fragmentShader.replace("#include <lights_physical_fragment>",u).replace("#include <lights_fragment_begin>",c).replace("#include <lights_fragment_maps>",m).replace("#include <normal_fragment_maps>",_).replace("#include <map_fragment>",l).replace("#include <roughnessmap_fragment>",i).replace("vec3 Fcc = F_Schlick",`
|
|
7091
7095
|
// Blender's slab_transmittance_at_angle (gpu_shader_material_principled.glsl):
|
|
7092
7096
|
// Beer-Lambert attenuation through a refracting coat at this view angle.
|
|
7093
7097
|
float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
|
|
7094
7098
|
blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
|
|
7095
7099
|
outgoingLight *= mix(vec3(1.0), pow(max(blenderCoatTint, vec3(0.0)), vec3(coatPath)), material.clearcoat);
|
|
7096
|
-
vec3 Fcc = F_Schlick`),
|
|
7097
|
-
`;let v="1.0",g="1.0";if(d instanceof Qn&&(
|
|
7098
|
-
`,g=`smoothstep(cone${
|
|
7099
|
-
`,v=d instanceof Zn?`getPointShadow(sm${
|
|
7100
|
+
vec3 Fcc = F_Schlick`),di(o,s)},o.needsUpdate=!0}r.blenderCoatIor.value=Math.max(1,e.coat_ior),r.blenderCoatTint.value.setRGB(...e.coat_tint,vt),r.blenderMapClip.value=n.map===!0,r.blenderRoughnessClip.value=n.roughness===!0,r.blenderNormalClip.value=n.normal===!0}function xo(o){const t=r=>{if(!(!r||typeof r!="object")){if("kind"in r&&["direction","window","sky"].includes(String(r.kind)))throw new Error(`World volume spatial input ${r.kind} is not implemented`);for(const a of Object.values(r))t(a)}};t(o);const n=at(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 Yt(o){const t=xo(o);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function wn(o){const t=xo(o);return(typeof t=="number"?new x().setScalar(t):t.clone()).max(new x)}function wi(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(a=>o>=a).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],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],r=[[596945309e-19,-485742887e-16,-970622247e-13,-.00407936148],[240430366e-19,555021075e-16,-.000198503712,.0289312858],[-140949732e-19,189878968e-15,-.000356632824,.0910767778],[-361460868e-19,284822009e-15,-.000493211319,.15672344],[-197075738e-19,175359352e-15,-.000250542825,-.0222783266],[-161997957e-21,-164216008e-16,.000386216271,-.738077418],[672650283e-21,-273078809e-16,.000424098264,-.752335691]][t];return new x(n[0]/o+n[1]*o+n[2],e[0]/o+e[1]*o+e[2],((r[0]*o+r[1])*o+r[2])*o+r[3]).max(new x)}function Go(o){if(!o?.volume?.length)return null;const t={extinction:new x,emission:new x,lobes:[]};for(const n of o.volume){const e=Yt(n.weight);if(e===0)continue;const r=wn(n.color),a=Yt(n.density),s=new x,f=new x;if(n.kind==="absorption"&&s.set(1-r.x,1-r.y,1-r.z).max(new x).multiplyScalar(a),n.kind==="scatter"||n.kind==="principled"){f.copy(r).multiplyScalar(a);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const _=xo(n.anisotropy);if(typeof _!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:f.clone().multiplyScalar(e),g:u==="RAYLEIGH"?0:xt.clamp(_,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?Yt(n.alpha):0})}if(n.kind==="principled"){const u=wn(n.absorption_color);s.set(Math.max(1-r.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-r.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-r.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(a);const _=Yt(n.blackbody_intensity);if(_>.001){const l=Yt(n.temperature),i=5670373e-20/Math.PI*(1+_*(l**4-1));t.emission.add(wi(l).multiply(wn(n.blackbody_tint)).multiplyScalar(i*e))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?r:wn(n.emission_color)).multiplyScalar(Yt(n.emission_strength)*e)),t.extinction.add(s.add(f).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 Oi{constructor(t){this.medium=t,this.target=new Ke(1,1,{type:co,depthBuffer:!1}),this.geometry=new ue(2,2),this.scene=new Je,this.camera=new ta}render(t,n,e,r){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const a={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:r.projectionMatrixInverse},cameraWorld:{value:r.matrixWorld},orthographic:{value:r.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let s="",f="",u=0,_=2;e.traverseVisible(m=>{if(!(m instanceof Zn||m instanceof Qn||m instanceof Sn))return;const d=m,h=u++,p=d.getWorldPosition(new x);a[`lp${h}`]={value:p},a[`lc${h}`]={value:d.color.clone().multiplyScalar(d.intensity)},s+=`uniform vec3 lp${h}, lc${h};
|
|
7101
|
+
`;let v="1.0",g="1.0";if(d instanceof Qn&&(a[`ld${h}`]={value:d.target.getWorldPosition(new x).sub(p).normalize()},a[`cone${h}`]={value:new Gt(Math.cos(d.angle),Math.cos(d.angle*(1-d.penumbra)))},s+=`uniform vec3 ld${h}; uniform vec2 cone${h};
|
|
7102
|
+
`,g=`smoothstep(cone${h}.x, max(cone${h}.x+1e-6,cone${h}.y),dot(-L,ld${h}))`),!(d instanceof Sn)&&d.castShadow&&d.shadow.map){if(++_>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");a[`sm${h}`]={value:d.shadow.map.texture},a[`sx${h}`]={value:d.shadow.matrix},a[`ss${h}`]={value:d.shadow.mapSize},a[`sb${h}`]={value:d.shadow.bias},a[`sn${h}`]={value:d.shadow.camera.near},a[`sf${h}`]={value:d.shadow.camera.far},s+=`uniform sampler2D sm${h}; uniform mat4 sx${h}; uniform vec2 ss${h}; uniform float sb${h},sn${h},sf${h};
|
|
7103
|
+
`,v=d instanceof Zn?`getPointShadow(sm${h},ss${h},1.0,sb${h},1.0,sx${h}*vec4(p,1.0),sn${h},sf${h})`:`getShadow(sm${h},ss${h},1.0,sb${h},1.0,sx${h}*vec4(p,1.0))`}if(d instanceof Sn){const w=new Z().extractRotation(d.matrixWorld);a[`lx${h}`]={value:new x(d.width,0,0).applyMatrix4(w)},a[`ly${h}`]={value:new x(0,d.height,0).applyMatrix4(w)},a[`ln${h}`]={value:new x(0,0,-1).transformDirection(w)},s+=`uniform vec3 lx${h},ly${h},ln${h};
|
|
7100
7104
|
`,f+=`for(int ax=0;ax<4;ax++) for(int ay=0;ay<4;ay++) {
|
|
7101
|
-
vec3 delta=lp${
|
|
7105
|
+
vec3 delta=lp${h}+lx${h}*((float(ax)+.5)/4.-.5)+ly${h}*((float(ay)+.5)/4.-.5)-p;
|
|
7102
7106
|
float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7103
|
-
sum+=lc${
|
|
7104
|
-
length(lx${
|
|
7105
|
-
`}else
|
|
7106
|
-
`,f+=`{ vec3 delta=lp${
|
|
7107
|
-
float cutoff=cut${
|
|
7108
|
-
sum+=lc${
|
|
7109
|
-
`});let
|
|
7110
|
-
`,
|
|
7107
|
+
sum+=lc${h}*exp(-sigma*d)*phase(dot(L,ray))*max(dot(-L,ln${h}),0.)*
|
|
7108
|
+
length(lx${h})*length(ly${h})/(16.*max(d*d,1e-4)); }
|
|
7109
|
+
`}else a[`cut${h}`]={value:d.distance},a[`decay${h}`]={value:d.decay},s+=`uniform float cut${h},decay${h};
|
|
7110
|
+
`,f+=`{ vec3 delta=lp${h}-p; float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7111
|
+
float cutoff=cut${h}>0.?pow(clamp(1.-pow(d/cut${h},4.),0.,1.),2.):1.;
|
|
7112
|
+
sum+=lc${h}*exp(-sigma*d)*phase(dot(L,ray))*${g}*${v}*cutoff/max(pow(d,decay${h}),.01); }
|
|
7113
|
+
`});let l="vec3 result=vec3(0.);";this.medium.lobes.forEach((m,d)=>{a[`scatter${d}`]={value:m.coefficient},a[`g${d}`]={value:m.g},a[`a${d}`]={value:m.alpha},s+=`uniform vec3 scatter${d}; uniform float g${d},a${d};
|
|
7114
|
+
`,l+=`result+=scatter${d}*(1.-g${d}*g${d})*(1.+a${d}*c*c)/(12.56637061436*(1.+a${d}*(1.+2.*g${d}*g${d})/3.)*pow(1.+g${d}*g${d}-2.*g${d}*c,1.5));`});const i=this.medium.extinction.toArray().filter(m=>m>0);a.range={value:i.length?20/Math.min(...i):1},this.material?.dispose(),this.material=new lo({uniforms:a,depthTest:!1,depthWrite:!1,toneMapped:!1,defines:{USE_SHADOWMAP:"",NUM_DIR_LIGHT_SHADOWS:0,NUM_SPOT_LIGHT_SHADOWS:0,NUM_POINT_LIGHT_SHADOWS:0,NUM_SPOT_LIGHT_COORDS:0},vertexShader:"varying vec2 vUv; void main(){vUv=uv;gl_Position=vec4(position.xy,0.,1.);}",fragmentShader:`
|
|
7111
7115
|
#include <common>
|
|
7112
7116
|
#include <packing>
|
|
7113
7117
|
#include <shadowmap_pars_fragment>
|
|
7114
7118
|
varying vec2 vUv; uniform sampler2D surface,depth;
|
|
7115
7119
|
uniform mat4 inverseProjection,cameraWorld; uniform bool orthographic;
|
|
7116
7120
|
uniform vec3 sigma,emission; uniform float range;
|
|
7117
|
-
${
|
|
7118
|
-
vec3 phase(float c){${
|
|
7121
|
+
${s}
|
|
7122
|
+
vec3 phase(float c){${l} return result;}
|
|
7119
7123
|
vec3 incident(vec3 p,vec3 ray){vec3 sum=vec3(0.);${f}return sum;}
|
|
7120
7124
|
float integral(float s,float d){float x=s*d;return x<.001 ? d*(1.-x*.5+x*x/6.) : (1.-exp(-x))/s;}
|
|
7121
7125
|
void main(){
|
|
@@ -7137,10 +7141,10 @@ attribute vec2 uv${d};
|
|
|
7137
7141
|
radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
|
|
7138
7142
|
}
|
|
7139
7143
|
gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
|
|
7140
|
-
}`}),this.scene.clear(),this.scene.add(new Rt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const c=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(c)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const xl=P({object:R(),group:R(),groupIndex:N().int().nonnegative(),count:N().int().nonnegative(),digest:R(),alertMode:H(["NONE","ACTIVE","ALL"]),unchanged:W(!0).optional(),weightsBase64:R().optional(),alertBase64:R().optional()}).strict();function bl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,i]=yl(2/3*(1-n)),f=new wt;return f.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(i*e)**(1/1.5),Ct),f}function yl(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 wl=0;function Xo(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 Ol{constructor(){this.group=new lt,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 d=Xo(t.weightsBase64);this.held={key:a,weights:new Float32Array(d.buffer,d.byteOffset,t.count),alerts:Xo(t.alertBase64)}}const r=this.held;if(r===null)return null;const i=`${a}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(i===this.signature&&this.mesh!==null)return null;this.signature=i,this.clear();const f=n.geometry.clone(),u=f.getAttribute("position"),h=f.getAttribute("blenderVertex");if(h===void 0)return f.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),l=new wt().setHex(wl,Ct);for(let d=0;d<u.count;d++){const m=h.getX(d),v=t.alertMode!=="NONE"&&r.alerts[m]===1?l:bl(r.weights[m]??0);s[d*3]=v.r,s[d*3+1]=v.g,s[d*3+2]=v.b}f.setAttribute("color",new dt(s,3)),f.deleteAttribute("blenderVertex");const c=new En({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),_=new Rt(f,c);return _.name=`${t.object}:weights`,_.frustumCulled=!1,_.matrixAutoUpdate=!1,_.matrix.copy(e),_.matrix.decompose(_.position,_.quaternion,_.scale),this.geometry=f,this.material=c,this.mesh=_,this.group.add(_),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const wn=N().finite(),Tl=D(L([wn,wn,wn,wn])).length(4),Al=20,Yo=[16724818,9165824,2658559];function Pl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new wt().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Ct)}function Ne(){return new ta({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function Sl(){const o=[],t=[],n=new wt(0,0,0),e=(r,i,f,u,h)=>{for(const s of[r,i]){const l=[0,0,0];l[f]=s*u,o.push(...l),t.push(h.r,h.g,h.b)}};for(let r=0;r<3;r++){const i=new wt().setHex(Yo[r],Ct);e(1,.85,r,1,i),e(.85,.25,r,1,n),e(1,.85,r,-1,Pl(Yo[r])),e(.85,.25,r,-1,n)}const a=new hn;return a.setAttribute("position",new St(o,3)),a.setAttribute("color",new St(t,3)),new ce(a,Ne())}function El(){const t=[],n=[],e=new wt(1,0,0),a=new wt(1,1,1);for(let i=0;i<12;i++){const f=(i+1)%2===0?a:e;for(const u of[i,i+1]){const h=2*Math.PI*u/12;t.push(.5*Math.cos(h),.5*Math.sin(h),0),n.push(f.r,f.g,f.b)}}const r=new hn;return r.setAttribute("position",new St(t,3)),r.setAttribute("color",new St(n,3)),new ce(r,Ne())}class Ml{constructor(){this.group=new lt,this.anchor=new lt,this.lines=Sl(),this.circle=El(),this.seen=null,this.size=new qt,this.scratch=new x,this.parentQuat=new Tt,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 Tt(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 f=n;r=(f.top-f.bottom)/f.zoom/e}else{const f=n;r=2*Math.max(-a.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(gt.degToRad(f.fov)/2)/f.zoom/e}const i=r*Al;this.lines.scale.setScalar(i),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(i),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,a,r){const i=this.seen;if(i===null||e!==i.canvas)return null;const f=i.canvas.getBoundingClientRect(),u=new qt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),h=new Je;h.setFromCamera(u,i.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},l=h.intersectObject(a,!0).find(m=>m.object.isMesh&&r(m.object)&&s(m.object));let c=l?l.point.clone():null;if(c===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=i.camera.getWorldDirection(new x),v=i.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),c=h.ray.intersectPlane(new Vt().setFromNormalAndCoplanarPoint(p,m),new x)}if(c===null)return null;a.updateWorldMatrix(!0,!1);const _=a.worldToLocal(c),d=a.getWorldQuaternion(new Tt).invert().multiply(i.camera.getWorldQuaternion(new Tt));return{location:[_.x,_.y,_.z],rotation:[d.w,d.x,d.y,d.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Lt=N().finite(),Nl=P({display:H(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Lt,image:P({name:R().nullable(),offset:L([Lt,Lt]),depth:H(["DEFAULT","FRONT","BACK"]),side:H(["DOUBLE_SIDED","FRONT","BACK"]),perspective:Z(),orthographic:Z(),axis_aligned:Z(),opacity:Lt.nullable(),tint:L([Lt,Lt,Lt]).default([1,1,1]),premultiplied:Z().default(!1)}).optional()}),Mt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},Rl=1,ot=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function ut(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 vt(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const i=t[r*a%t.length],f=t[(r*a+1)%t.length];ot(o,[i[0],i[1],n],[f[0],f[1],n])}}function Il(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 tt;let a=!1;o.onBeforeRender=(r,i,f,u,h,s)=>{t(r,i,f,u,h,s),i.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),a=!0)},o.onAfterRender=(r,i,f,u,h,s)=>{a&&(o.matrixWorld.copy(e),a=!1),n(r,i,f,u,h,s)}}class Fl{constructor(){this.cameras=new lt,this.lights=new lt,this.empties=new lt,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new qt,this.parentQuat=new Tt,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?Mt.active:Mt.selected:e.type==="CAMERA"?Mt.camera:e.type==="LIGHT"?Mt.light:Mt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,i=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,f=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!r&&!i&&!f)continue;n.add(e.name);const u=i&&e.light?t.lightDistances[e.light]??null:null,h=f?.image?.name?t.image(f.image.name):null,s=JSON.stringify([h?[h.texture.uuid,h.width,h.height]:null,e.matrix,a,r,i,u,f,r?[e.name===t.sceneCamera,t.renderAspect]:null]),l=this.drawn.get(e.name),c=t.presented(e.name);if(l?.key===s){for(const v of l.parts)v.userData.volterPicksAs=c;continue}l&&this.remove(l.parts);const _=new tt().set(...e.matrix.flat()),d=r?this.cameras:i?this.lights:this.empties,m=new Set(d.children);r?this.camera(r,_,a,e.name===t.sceneCamera,t.renderAspect):i?this.light(i,_,a,u):f&&this.empty(f,_,a,h);const p=d.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=c,v.traverse(Il);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 i=t.display_size,u=(t.sensor_fit==="AUTO"?r>=1:t.sensor_fit==="HORIZONTAL")?[1,1/r]:[r,1];let h,s,l,c;if(t.type==="ORTHO")l=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],c=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-i,h=.5*t.ortho_scale;else{const A=.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;h=i/2/((1/O.x+1/O.y+1/O.z)/3),s=h*t.lens/-A,l=[h*u[0],h*u[1]],c=[t.shift_x*h*2,t.shift_y*h*2]}const _=[[c[0]+l[0],c[1]+l[1],s],[c[0]+l[0],c[1]-l[1],s],[c[0]-l[0],c[1]-l[1],s],[c[0]-l[0],c[1]+l[1],s]],d=[];for(let A=0;A<4;A++)ot(d,_[A],_[(A+1)%4]),ot(d,_[A],[0,0,0]);const m=.7*h,p=.1*h,v=c[1]+l[1]+p,g=[[c[0]-m,v,s],[c[0]+m,v,s],[c[0],v+m,s]],w=Gn(n);this.cameras.add(this.lines(d,e,1,w));let y;if(a){const A=new hn;A.setAttribute("position",new St(g.flat(),3)),y=new Rt(A,this.fill(e)),y.matrixAutoUpdate=!1,y.matrix.copy(w)}else{const A=[];for(let O=0;O<3;O++)ot(A,g[O],g[(O+1)%3]);y=this.lines(A,e,1,w)}const S=new x,T=y.onBeforeRender.bind(y);y.onBeforeRender=(A,O,M,k,j,q)=>{S.setFromMatrixPosition(w).applyMatrix4(this.cameras.matrixWorld);const Q=M.getWorldPosition(this.scratch).distanceToSquared(S)>1e-8;y.matrix.copy(w),Q||y.matrix.scale(new x(0,0,0)),y.updateMatrixWorld(!0),T(A,O,M,k,j,q)},this.cameras.add(y)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),i=[];ot(i,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(i,Mt.light,Mt.lightAlpha,new tt));const f=[];vt(f,ut(1.35,4)),this.lights.add(this.screen(f,Mt.light,Mt.lightAlpha,new x(r.x,r.y,0)));const u=[],h=9;if(vt(u,ut(h*.3,4)),vt(u,ut(h,16),0,!0),vt(u,ut(h*1.33,20),0,!0),t.type==="SUN")for(const[c,_]of ut(h,8))ot(u,[c*1.6,_*1.6,0],[c*1.9,_*1.9,0]),ot(u,[c*2.2,_*2.2,0],[c*2.5,_*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=Gn(n),l=[];if(t.type==="SUN")ot(l,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const c=(t.size??1)/2,_=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?vt(l,ut(1,32).map(([d,m])=>[d*c,m*_])):vt(l,[[c,_],[-c,_],[-c,-_],[c,-_]])}if(l.length>0&&this.lights.add(this.lines(l,e,1,n.clone())),a&&(t.type==="SPOT"||t.type==="AREA")){const c=new x(0,0,-1).transformDirection(n),_=v=>r.clone().addScaledVector(c,v),[d,m]=a,p=[];ot(p,_(d).toArray(),_(m).toArray()),this.lights.add(this.lines(p,e,1,new tt));for(const v of[d,m]){const g=[];vt(g,ut(1.2,4)),this.lights.add(this.screen(g,e,1,_(v)))}}if(t.type==="SPOT"){const c=(t.spot_size??Math.PI/4)/2,_=Math.cos(c),d=t.spot_blend??.15,m=_*d-_-d,p=Math.sqrt((_*_-_*_*m*m)/(m*m-_*_*m*m)),v=Math.sqrt(1-_*_),g=Gn(n).multiply(new tt().makeScale(10,10,10)),w=[];vt(w,ut(v,32),-_),vt(w,ut(v*p,32),-_),this.lights.add(this.lines(w,e,1,g.clone())),this.lights.add(this.silhouette(v,_,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const c=[];vt(c,ut(t.radius,32)),this.lights.add(this.facing(c,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,a){const r=t.size,i=[],f=(h,s)=>{const l=ut(1,s);for(let c=0;c<s;c++){const[_,d]=l[c],[m,p]=l[(c+1)%s],v=(g,w)=>h==="xy"?[g,w,0]:h==="xz"?[g,0,w]:[0,g,w];ot(i,v(_,d),v(m,p))}};switch(t.display){case"PLAIN_AXES":ot(i,[0,-1,0],[0,1,0]),ot(i,[-1,0,0],[1,0,0]),ot(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{ot(i,[0,0,0],[0,0,.75]);for(const[h,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])ot(i,[0,0,1],[h,s,.75]);vt(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[h,s]of zl)ot(i,Zo[h],Zo[s]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const h=ut(1,8);for(let s=0;s<8;s++){const[l,c]=h[s],[_,d]=h[(s+1)%8];ot(i,[l,0,c],[0,2,0]),ot(i,[l,0,c],[_,0,d])}break}case"ARROWS":for(let h=0;h<3;h++){const s=[0,0,0];s[h]=1,ot(i,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new tt().makeScale(r,r,r));this.empties.add(this.lines(i,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 i=r.geometry.getAttribute("instanceStart").data,f=ut(1,32).map(([_,d])=>new x(_*t,d*t,-n)),u=new x,h=new tt,s=new x,l=new x,c=new x;return this.onDraw(r,(_,d)=>{h.copy(r.matrixWorld).invert();const m=d.isOrthographicCamera;m?d.getWorldDirection(u).negate().transformDirection(h):u.setFromMatrixPosition(d.matrixWorld).applyMatrix4(h);const p=i.array;let v=!1;for(let g=0;g<32;g++){const w=f[g];s.crossVectors(w,f[(g+31)%32]),l.crossVectors(f[(g+1)%32],w),m?c.copy(u):c.copy(u).sub(w);const y=s.dot(c)>0!=l.dot(c)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==y&&(v=!0),p.set([0,0,0,y?w.x:0,y?w.y:0,y?w.z:0],g*6)}v&&(i.needsUpdate=!0,Ot())}),r}imageEmpty(t,n,e,a){const r=t.image;if(!r)return;const i=a?.width??0,f=a?.height??0,u=i>0&&f>0?i>=f?[1,f/i]:[i/f,1]:[1,1],h=new x,s=new x,l=new x;n.extractBasis(h,s,l),h.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const c=new x().setFromMatrixPosition(n).addScaledVector(h,r.offset[0]*2+1).addScaledVector(s,r.offset[1]*2+1),_=new tt().makeBasis(h,s,l.clone()).setPosition(c),d=[];vt(d,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(d,e,1,_),p=l.clone().normalize(),v=new x,g=new x,w=(M,k)=>{const j=M.isOrthographicCamera===!0;if(j?!r.orthographic:!r.perspective)return!1;if(!k)return!0;const q=p.clone().transformDirection(this.empties.matrixWorld);M.getWorldDirection(g);let Q,K;if(j)Q=q.dot(g.clone().negate()),K=1e-5;else{const st=c.clone().applyMatrix4(this.empties.matrixWorld);Q=q.dot(v.setFromMatrixPosition(M.matrixWorld).sub(st)),K=0}return!(r.side==="FRONT"&&Q<K||r.side==="BACK"&&Q>-K||r.axis_aligned&&q.clone().projectOnPlane(g).lengthSq()>1e-5)},y=(M,k)=>{const j=M.onBeforeRender.bind(M);M.onBeforeRender=(q,Q,K,st,b,V)=>{M.matrix.copy(_),w(K,k)||M.matrix.scale(new x(0,0,0)),M.updateMatrixWorld(!0),j(q,Q,K,st,b,V)}};if(y(m,!1),this.empties.add(m),!a||r.opacity!==null&&r.opacity<=0)return;const S=r.opacity!==null,T=r.depth==="BACK",A=new En({map:a.texture,side:wo,transparent:S&&!T,opacity:r.opacity??1,alphaTest:S?0:.05,toneMapped:!1,depthTest:r.depth==="DEFAULT",depthWrite:r.depth==="DEFAULT"&&!S});A.color.setRGB(...r.tint,pt),S&&T&&(A.blending=na,A.blendSrc=oa,A.blendDst=ea),A.onBeforeCompile=M=>{const k=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7141
|
-
`:"";
|
|
7142
|
-
${k}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",
|
|
7143
|
-
diffuseColor.a = 1.0;`)},
|
|
7144
|
+
}`}),this.scene.clear(),this.scene.add(new Rt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const c=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(c)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const Ai=S({object:R(),group:R(),groupIndex:N().int().nonnegative(),count:N().int().nonnegative(),digest:R(),alertMode:H(["NONE","ACTIVE","ALL"]),unchanged:W(!0).optional(),weightsBase64:R().optional(),alertBase64:R().optional()}).strict();function Ti(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[r,a,s]=Si(2/3*(1-n)),f=new wt;return f.setRGB((r*e)**(1/1.5),(a*e)**(1/1.5),(s*e)**(1/1.5),$t),f}function Si(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 Pi=0;function Xo(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 Mi{constructor(){this.group=new it,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 r=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==r)return this.clear(),`weights: the session sent a reference to ${r} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${r} carried neither an array nor a reference`;const d=Xo(t.weightsBase64);this.held={key:r,weights:new Float32Array(d.buffer,d.byteOffset,t.count),alerts:Xo(t.alertBase64)}}const a=this.held;if(a===null)return null;const s=`${r}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(s===this.signature&&this.mesh!==null)return null;this.signature=s,this.clear();const f=n.geometry.clone(),u=f.getAttribute("position"),_=f.getAttribute("blenderVertex");if(_===void 0)return f.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const l=new Float32Array(u.count*3),i=new wt().setHex(Pi,$t);for(let d=0;d<u.count;d++){const h=_.getX(d),v=t.alertMode!=="NONE"&&a.alerts[h]===1?i:Ti(a.weights[h]??0);l[d*3]=v.r,l[d*3+1]=v.g,l[d*3+2]=v.b}f.setAttribute("color",new dt(l,3)),f.deleteAttribute("blenderVertex");const c=new En({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),m=new Rt(f,c);return m.name=`${t.object}:weights`,m.frustumCulled=!1,m.matrixAutoUpdate=!1,m.matrix.copy(e),m.matrix.decompose(m.position,m.quaternion,m.scale),this.geometry=f,this.material=c,this.mesh=m,this.group.add(m),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const On=N().finite(),Ei=D(L([On,On,On,On])).length(4),Ni=20,Yo=[16724818,9165824,2658559];function Ri(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new wt().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),$t)}function Ie(){return new oa({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function Ii(){const o=[],t=[],n=new wt(0,0,0),e=(a,s,f,u,_)=>{for(const l of[a,s]){const i=[0,0,0];i[f]=l*u,o.push(...i),t.push(_.r,_.g,_.b)}};for(let a=0;a<3;a++){const s=new wt().setHex(Yo[a],$t);e(1,.85,a,1,s),e(.85,.25,a,1,n),e(1,.85,a,-1,Ri(Yo[a])),e(.85,.25,a,-1,n)}const r=new pn;return r.setAttribute("position",new Pt(o,3)),r.setAttribute("color",new Pt(t,3)),new _e(r,Ie())}function Fi(){const t=[],n=[],e=new wt(1,0,0),r=new wt(1,1,1);for(let s=0;s<12;s++){const f=(s+1)%2===0?r:e;for(const u of[s,s+1]){const _=2*Math.PI*u/12;t.push(.5*Math.cos(_),.5*Math.sin(_),0),n.push(f.r,f.g,f.b)}}const a=new pn;return a.setAttribute("position",new Pt(t,3)),a.setAttribute("color",new Pt(n,3)),new _e(a,Ie())}class zi{constructor(){this.group=new it,this.anchor=new it,this.lines=Ii(),this.circle=Fi(),this.seen=null,this.size=new Gt,this.scratch=new x,this.parentQuat=new At,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,r,a]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new At(e,r,a,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),r=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let a;if(n.isOrthographicCamera){const f=n;a=(f.top-f.bottom)/f.zoom/e}else{const f=n;a=2*Math.max(-r.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(xt.degToRad(f.fov)/2)/f.zoom/e}const s=a*Ni;this.lines.scale.setScalar(s),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(s),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,r,a){const s=this.seen;if(s===null||e!==s.canvas)return null;const f=s.canvas.getBoundingClientRect(),u=new Gt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),_=new na;_.setFromCamera(u,s.camera);const l=h=>{for(let p=h;p!==null;p=p.parent)if(!p.visible)return!1;return!0},i=_.intersectObject(r,!0).find(h=>h.object.isMesh&&a(h.object)&&l(h.object));let c=i?i.point.clone():null;if(c===null){const h=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=s.camera.getWorldDirection(new x),v=s.camera.getWorldPosition(new x),g=h.clone().sub(v).dot(p);g<=0&&h.addScaledVector(p,-2*g+(g===0?1:0)),c=_.ray.intersectPlane(new Bt().setFromNormalAndCoplanarPoint(p,h),new x)}if(c===null)return null;r.updateWorldMatrix(!0,!1);const m=r.worldToLocal(c),d=r.getWorldQuaternion(new At).invert().multiply(s.camera.getWorldQuaternion(new At));return{location:[m.x,m.y,m.z],rotation:[d.w,d.x,d.y,d.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const jt=N().finite(),Di=S({display:H(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:jt,image:S({name:R().nullable(),offset:L([jt,jt]),depth:H(["DEFAULT","FRONT","BACK"]),side:H(["DOUBLE_SIDED","FRONT","BACK"]),perspective:Q(),orthographic:Q(),axis_aligned:Q(),opacity:jt.nullable(),tint:L([jt,jt,jt]).default([1,1,1]),premultiplied:Q().default(!1)}).optional()}),Et={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},Ci=1,ot=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function ut(o,t){return Array.from({length:t},(n,e)=>{const r=2*Math.PI*e/t;return[o*Math.cos(r),o*Math.sin(r)]})}function gt(o,t,n=0,e=!1){const r=e?2:1;for(let a=0;a<Math.floor(t.length/r);a++){const s=t[a*r%t.length],f=t[(a*r+1)%t.length];ot(o,[s[0],s[1],n],[f[0],f[1],n])}}function ki(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 Z;let r=!1;o.onBeforeRender=(a,s,f,u,_,l)=>{t(a,s,f,u,_,l),s.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),r=!0)},o.onAfterRender=(a,s,f,u,_,l)=>{r&&(o.matrixWorld.copy(e),r=!1),n(a,s,f,u,_,l)}}class $i{constructor(){this.cameras=new it,this.lights=new it,this.empties=new it,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new Gt,this.parentQuat=new At,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 r=e.selected?e.name===t.active?Et.active:Et.selected:e.type==="CAMERA"?Et.camera:e.type==="LIGHT"?Et.light:Et.empty,a=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,s=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,f=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!a&&!s&&!f)continue;n.add(e.name);const u=s&&e.light?t.lightDistances[e.light]??null:null,_=f?.image?.name?t.image(f.image.name):null,l=JSON.stringify([_?[_.texture.uuid,_.width,_.height]:null,e.matrix,r,a,s,u,f,a?[e.name===t.sceneCamera,t.renderAspect]:null]),i=this.drawn.get(e.name),c=t.presented(e.name);if(i?.key===l){for(const v of i.parts)v.userData.volterPicksAs=c;continue}i&&this.remove(i.parts);const m=new Z().set(...e.matrix.flat()),d=a?this.cameras:s?this.lights:this.empties,h=new Set(d.children);a?this.camera(a,m,r,e.name===t.sceneCamera,t.renderAspect):s?this.light(s,m,r,u):f&&this.empty(f,m,r,_);const p=d.children.filter(v=>!h.has(v));for(const v of p)v.userData.volterPicksAs=c,v.traverse(ki);this.drawn.set(e.name,{key:l,parts:p})}for(const[e,r]of this.drawn)n.has(e)||(this.remove(r.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,r,a){const s=t.display_size,u=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let _,l,i,c;if(t.type==="ORTHO")i=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],c=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],l=-s,_=.5*t.ortho_scale;else{const T=.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;_=s/2/((1/O.x+1/O.y+1/O.z)/3),l=_*t.lens/-T,i=[_*u[0],_*u[1]],c=[t.shift_x*_*2,t.shift_y*_*2]}const m=[[c[0]+i[0],c[1]+i[1],l],[c[0]+i[0],c[1]-i[1],l],[c[0]-i[0],c[1]-i[1],l],[c[0]-i[0],c[1]+i[1],l]],d=[];for(let T=0;T<4;T++)ot(d,m[T],m[(T+1)%4]),ot(d,m[T],[0,0,0]);const h=.7*_,p=.1*_,v=c[1]+i[1]+p,g=[[c[0]-h,v,l],[c[0]+h,v,l],[c[0],v+h,l]],w=Gn(n);this.cameras.add(this.lines(d,e,1,w));let y;if(r){const T=new pn;T.setAttribute("position",new Pt(g.flat(),3)),y=new Rt(T,this.fill(e)),y.matrixAutoUpdate=!1,y.matrix.copy(w)}else{const T=[];for(let O=0;O<3;O++)ot(T,g[O],g[(O+1)%3]);y=this.lines(T,e,1,w)}const P=new x,A=y.onBeforeRender.bind(y);y.onBeforeRender=(T,O,E,k,j,q)=>{P.setFromMatrixPosition(w).applyMatrix4(this.cameras.matrixWorld);const K=E.getWorldPosition(this.scratch).distanceToSquared(P)>1e-8;y.matrix.copy(w),K||y.matrix.scale(new x(0,0,0)),y.updateMatrixWorld(!0),A(T,O,E,k,j,q)},this.cameras.add(y)}light(t,n,e,r){const a=new x().setFromMatrixPosition(n),s=[];ot(s,[a.x,a.y,a.z],[a.x,a.y,0]),this.lights.add(this.lines(s,Et.light,Et.lightAlpha,new Z));const f=[];gt(f,ut(1.35,4)),this.lights.add(this.screen(f,Et.light,Et.lightAlpha,new x(a.x,a.y,0)));const u=[],_=9;if(gt(u,ut(_*.3,4)),gt(u,ut(_,16),0,!0),gt(u,ut(_*1.33,20),0,!0),t.type==="SUN")for(const[c,m]of ut(_,8))ot(u,[c*1.6,m*1.6,0],[c*1.9,m*1.9,0]),ot(u,[c*2.2,m*2.2,0],[c*2.5,m*2.5,0]);this.lights.add(this.screen(u,e,1,a));const l=Gn(n),i=[];if(t.type==="SUN")ot(i,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const c=(t.size??1)/2,m=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?gt(i,ut(1,32).map(([d,h])=>[d*c,h*m])):gt(i,[[c,m],[-c,m],[-c,-m],[c,-m]])}if(i.length>0&&this.lights.add(this.lines(i,e,1,n.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const c=new x(0,0,-1).transformDirection(n),m=v=>a.clone().addScaledVector(c,v),[d,h]=r,p=[];ot(p,m(d).toArray(),m(h).toArray()),this.lights.add(this.lines(p,e,1,new Z));for(const v of[d,h]){const g=[];gt(g,ut(1.2,4)),this.lights.add(this.screen(g,e,1,m(v)))}}if(t.type==="SPOT"){const c=(t.spot_size??Math.PI/4)/2,m=Math.cos(c),d=t.spot_blend??.15,h=m*d-m-d,p=Math.sqrt((m*m-m*m*h*h)/(h*h-m*m*h*h)),v=Math.sqrt(1-m*m),g=Gn(n).multiply(new Z().makeScale(10,10,10)),w=[];gt(w,ut(v,32),-m),gt(w,ut(v*p,32),-m),this.lights.add(this.lines(w,e,1,g.clone())),this.lights.add(this.silhouette(v,m,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const c=[];gt(c,ut(t.radius,32)),this.lights.add(this.facing(c,e,new x().setFromMatrixPosition(l)))}}empty(t,n,e,r){const a=t.size,s=[],f=(_,l)=>{const i=ut(1,l);for(let c=0;c<l;c++){const[m,d]=i[c],[h,p]=i[(c+1)%l],v=(g,w)=>_==="xy"?[g,w,0]:_==="xz"?[g,0,w]:[0,g,w];ot(s,v(m,d),v(h,p))}};switch(t.display){case"PLAIN_AXES":ot(s,[0,-1,0],[0,1,0]),ot(s,[-1,0,0],[1,0,0]),ot(s,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{ot(s,[0,0,0],[0,0,.75]);for(const[_,l]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])ot(s,[0,0,1],[_,l,.75]);gt(s,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[_,l]of Li)ot(s,Zo[_],Zo[l]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const _=ut(1,8);for(let l=0;l<8;l++){const[i,c]=_[l],[m,d]=_[(l+1)%8];ot(s,[i,0,c],[0,2,0]),ot(s,[i,0,c],[m,0,d])}break}case"ARROWS":for(let _=0;_<3;_++){const l=[0,0,0];l[_]=1,ot(s,[0,0,0],l)}break;case"IMAGE":this.imageEmpty(t,n,e,r);return}const u=n.clone().multiply(new Z().makeScale(a,a,a));this.empties.add(this.lines(s,e,1,u)),t.display==="ARROWS"&&this.axisNames(n,a,e)}silhouette(t,n,e,r){const a=this.lines(new Array(192).fill(0),e,1,r);a.frustumCulled=!1;const s=a.geometry.getAttribute("instanceStart").data,f=ut(1,32).map(([m,d])=>new x(m*t,d*t,-n)),u=new x,_=new Z,l=new x,i=new x,c=new x;return this.onDraw(a,(m,d)=>{_.copy(a.matrixWorld).invert();const h=d.isOrthographicCamera;h?d.getWorldDirection(u).negate().transformDirection(_):u.setFromMatrixPosition(d.matrixWorld).applyMatrix4(_);const p=s.array;let v=!1;for(let g=0;g<32;g++){const w=f[g];l.crossVectors(w,f[(g+31)%32]),i.crossVectors(f[(g+1)%32],w),h?c.copy(u):c.copy(u).sub(w);const y=l.dot(c)>0!=i.dot(c)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==y&&(v=!0),p.set([0,0,0,y?w.x:0,y?w.y:0,y?w.z:0],g*6)}v&&(s.needsUpdate=!0,Ot())}),a}imageEmpty(t,n,e,r){const a=t.image;if(!a)return;const s=r?.width??0,f=r?.height??0,u=s>0&&f>0?s>=f?[1,f/s]:[s/f,1]:[1,1],_=new x,l=new x,i=new x;n.extractBasis(_,l,i),_.multiplyScalar(u[0]*.5*t.size),l.multiplyScalar(u[1]*.5*t.size);const c=new x().setFromMatrixPosition(n).addScaledVector(_,a.offset[0]*2+1).addScaledVector(l,a.offset[1]*2+1),m=new Z().makeBasis(_,l,i.clone()).setPosition(c),d=[];gt(d,[[-1,-1],[1,-1],[1,1],[-1,1]]);const h=this.lines(d,e,1,m),p=i.clone().normalize(),v=new x,g=new x,w=(E,k)=>{const j=E.isOrthographicCamera===!0;if(j?!a.orthographic:!a.perspective)return!1;if(!k)return!0;const q=p.clone().transformDirection(this.empties.matrixWorld);E.getWorldDirection(g);let K,J;if(j)K=q.dot(g.clone().negate()),J=1e-5;else{const lt=c.clone().applyMatrix4(this.empties.matrixWorld);K=q.dot(v.setFromMatrixPosition(E.matrixWorld).sub(lt)),J=0}return!(a.side==="FRONT"&&K<J||a.side==="BACK"&&K>-J||a.axis_aligned&&q.clone().projectOnPlane(g).lengthSq()>1e-5)},y=(E,k)=>{const j=E.onBeforeRender.bind(E);E.onBeforeRender=(q,K,J,lt,b,V)=>{E.matrix.copy(m),w(J,k)||E.matrix.scale(new x(0,0,0)),E.updateMatrixWorld(!0),j(q,K,J,lt,b,V)}};if(y(h,!1),this.empties.add(h),!r||a.opacity!==null&&a.opacity<=0)return;const P=a.opacity!==null,A=a.depth==="BACK",T=new En({map:r.texture,side:wo,transparent:P&&!A,opacity:a.opacity??1,alphaTest:P?0:.05,toneMapped:!1,depthTest:a.depth==="DEFAULT",depthWrite:a.depth==="DEFAULT"&&!P});T.color.setRGB(...a.tint,vt),P&&A&&(T.blending=ea,T.blendSrc=aa,T.blendDst=ra),T.onBeforeCompile=E=>{const k=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7145
|
+
`:"";E.fragmentShader=E.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
7146
|
+
${k}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",P?"#include <alphatest_fragment>":`#include <alphatest_fragment>
|
|
7147
|
+
diffuseColor.a = 1.0;`)},T.customProgramCacheKey=()=>`volter-blender-image:${a.premultiplied}:${P}`;const O=new Rt(new ue(2,2),T);O.matrixAutoUpdate=!1,O.matrix.copy(m),O.renderOrder=a.depth==="FRONT"?1e3:a.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,y(O,!0),this.empties.add(O)}axisNames(t,n,e){const r=[new x,new x,new x];t.extractBasis(r[0],r[1],r[2]);for(let a=0;a<3;a++){const s=r[a].length()*n,f=new x(0,0,0);f.setComponent(a,1.25*n),f.applyMatrix4(t);const u=new x(0,0,0);u.setComponent(a,n),u.applyMatrix4(t);const _=[];for(let c=1;c<=6;c++)gt(_,ut(.007*(4*c/6)*s,4));this.empties.add(this.facing(_,e,u));const l=Vi[a],i=[];for(let c=0;c+1<l.length;c+=2){const[m,d]=l[c],[h,p]=l[c+1];ot(i,[m*4*s,d*4*s,0],[h*4*s,p*4*s,0])}this.empties.add(this.facing(i,e,f))}}material(t,n){const e=`${t}:${n}`;let r=this.lineMaterials.get(e);return r||(r=new ae({color:t,linewidth:Ci,transparent:n<1,opacity:n,depthTest:!0,depthWrite:n>=1,toneMapped:!1}),this.lineMaterials.set(e,r)),r}fill(t){let n=this.fillMaterials.get(t);return n||(n=new En({color:t,side:wo,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,e,r){const a=new ee().setPositions(t),s=new re(a,this.material(n,e));return s.matrixAutoUpdate=!1,s.matrix.copy(r),s.computeLineDistances(),s}screen(t,n,e,r){const a=this.lines(t,n,e,new Z);return a.matrixAutoUpdate=!0,a.position.copy(r),a.scale.setScalar(0),a.frustumCulled=!1,this.onDraw(a,(s,f)=>this.face(a,s,f,!0)),a}facing(t,n,e){const r=this.lines(t,n,1,new Z);return r.matrixAutoUpdate=!0,r.position.copy(e),this.onDraw(r,(a,s)=>this.face(r,a,s,!1)),r}onDraw(t,n){const e=t,r=e.onBeforeRender.bind(e);e.onBeforeRender=(a,s,f,u,_,l)=>{n(a,f),r(a,s,f,u,_,l)}}face(t,n,e,r){t.parent?.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let a=1;if(r){n.getSize(this.size);const s=Math.max(this.size.y,1),f=this.scratch.setFromMatrixPosition(t.matrixWorld);if(e.isOrthographicCamera){const u=e;a=(u.top-u.bottom)/u.zoom/s}else{const u=e;a=2*Math.max(-f.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(xt.degToRad(u.fov)/2)/u.zoom/s}}t.scale.setScalar(a),t.updateMatrixWorld(!0)}dispose(){for(const t of this.drawn.values())this.remove(t.parts);this.drawn.clear();for(const t of this.lineMaterials.values())t.dispose();for(const t of this.fillMaterials.values())t.dispose();this.lineMaterials.clear(),this.fillMaterials.clear()}}function Gn(o){const t=new x,n=new At;return o.decompose(t,n,new x),new Z().compose(t,n,new x(1,1,1))}const Zo=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],Li=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Vi=[[[.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])],_t=N().finite(),Qo=S({name:R(),type:R(),lens:_t,sensor_width:_t,sensor_height:_t,sensor_fit:H(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:_t,clip_start:_t,clip_end:_t,shift_x:_t,shift_y:_t,matrix:D(L([_t,_t,_t,_t])).length(4),passepartout:_t.default(0),display_size:_t.default(1)}),ji={opening:.5,min:.1657359312880715,max:44.98528137423857},An={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function Bi(o,t,n,e){const r=a=>Math.min(1,Math.max(-1,a));return[r(o[0]-n/(2*t)),r(o[1]+e/(2*t))]}function Ko(o,t,n,e){const r=o.type==="ORTHO",a=o.sensor_fit==="VERTICAL"?o.sensor_height:o.sensor_width,s=o.sensor_fit==="AUTO"?t>=n:o.sensor_fit==="HORIZONTAL",f=(r?o.ortho_scale:a/o.lens)/2*e;return s?[f,f*n/t]:[f*t/n,f]}function Ui(o,t,n,e,r,a){const s=Math.max(n.width,1),f=Math.max(n.height,1),[u,_]=Ko(o,s,f,1/e),[l,i]=Ko(o,a,1,1),m=2*((o.sensor_fit==="AUTO"?a>=1:o.sensor_fit==="HORIZONTAL")?l:i),d=l/u,h=i/_,p=-2*r[0]*e,v=2*r[1]*e,g=o.shift_x*m-p*2*u,w=o.shift_y*m+v*2*_,y=new Z().set(...o.matrix.flat()).premultiply(t),P=new x,A=new At;return y.decompose(P,A,new x),{name:o.name,position:P.toArray(),quaternion:[A.x,A.y,A.z,A.w],projection:o.type==="ORTHO"?"orthographic":"perspective",window:{left:g-u,right:g+u,top:w+_,bottom:w-_},near:o.clip_start,far:o.clip_end,frame:{left:.5-d/2+p,top:.5-h/2+v,width:d,height:h},passepartout:{color:An.passepartout,opacity:o.passepartout},border:{solid:An.back,dashed:An.overlay,locked:An.redalert}}}const Wi={color:[.8,.8,.8,1],roughness:.5,metallic:0},Hi=`
|
|
7144
7148
|
uniform vec3 wbDir[4];
|
|
7145
7149
|
uniform vec3 wbDiffuse[4];
|
|
7146
7150
|
uniform vec3 wbSpecular[4];
|
|
@@ -7182,6 +7186,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
|
|
|
7182
7186
|
diffuseLight *= diffuseColor * (1.0 - specEnergy);
|
|
7183
7187
|
return diffuseLight + specularLight;
|
|
7184
7188
|
}
|
|
7185
|
-
`,bo=o=>ho.map(t=>{const[n=0,e=0,
|
|
7189
|
+
`,bo=o=>ho.map(t=>{const[n=0,e=0,r=0]=o(t);return new x(n,e,r)}),qi=bo(o=>o.direction).map(o=>o.normalize()),Gi=bo(o=>o.diffuse),Xi=bo(o=>o.specular),Yi=new fo(...ho.map(o=>o.smooth));function Zi(o,t){const[n,e,r]=o.color,a=new ia({side:t});return a.color.setRGB(n,e,r,vt),a.name="volter:blender-solid",a.onBeforeCompile=s=>{s.uniforms.wbDir={value:qi},s.uniforms.wbDiffuse={value:Gi},s.uniforms.wbSpecular={value:Xi},s.uniforms.wbWrap={value:Yi},s.uniforms.wbRoughness={value:o.roughness},s.uniforms.wbMetallic={value:o.metallic},s.fragmentShader=s.fragmentShader.replace("void main() {",`${Hi}
|
|
7186
7190
|
void main() {`).replace("#include <opaque_fragment>",`outgoingLight = volterWorkbenchLighting(diffuseColor.rgb, normal, isOrthographic ? vec3(0.0, 0.0, 1.0) : normalize(vViewPosition));
|
|
7187
|
-
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const ql={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},F=N().finite(),Re=L([F,F,F]),Tn=L([N().int().nonnegative(),N().int().nonnegative()]),mt={name:R(),domain:H(["POINT","EDGE","FACE","CORNER"])},Gl=wa("type",[P({...mt,type:W("FLOAT2"),data:D(L([F,F]))}).strict(),P({...mt,type:W("FLOAT_VECTOR"),data:D(Re)}).strict(),P({...mt,type:W("FLOAT_COLOR"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("BYTE_COLOR"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("QUATERNION"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("FLOAT4"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("FLOAT4X4"),data:D(D(F).length(16))}).strict(),P({...mt,type:W("INT16_2D"),data:D(L([N().int(),N().int()]))}).strict(),P({...mt,type:W("INT32_2D"),data:D(L([N().int(),N().int()]))}).strict(),P({...mt,type:W("FLOAT"),data:D(F)}).strict(),P({...mt,type:W("INT"),data:D(N().int())}).strict(),P({...mt,type:W("INT8"),data:D(N().int())}).strict(),P({...mt,type:W("BOOLEAN"),data:D(Z())}).strict(),P({...mt,type:W("STRING"),data:D(R())}).strict()]),Xl=P({positions:U(Float32Array),normals:U(Float32Array).nullable(),uv:U(Float32Array).nullable(),uvLayers:D(P({name:R(),data:U(Float32Array)}).strict()).optional(),attributeLayers:D(P({name:R(),data:U(Float32Array)}).strict()).optional(),orco:U(Float32Array).nullable().optional(),indices:U(Uint32Array),groups:D(P({start:N().int().nonnegative(),count:N().int().nonnegative(),materialIndex:N().int().nonnegative()}).strict()),hash:R()}).strict(),Yl=P({v:D(Re),f:D(D(N().int().nonnegative())),e:D(Tn).optional(),edge_order:D(Tn).optional(),m:D(N().int().nonnegative()).optional(),s:D(Z()).optional(),sharp:D(Tn).optional(),seams:D(Tn).optional(),creases:D(L([F,F,F])).optional(),attributes:D(Gl).optional(),active_uv:R().nullable().optional(),render_uv:R().nullable().optional()}).strict(),Zl=P({store:N().int().optional(),revision:N().int(),unchanged:W(!0)}).strict(),Ql=P({co:kt([U(Float32Array),U(Float64Array)]),cornerNormal:U(Float32Array).optional(),cornerTri:U(Uint32Array).optional(),orco:U(Float32Array).optional(),faceStart:U(Uint32Array),corner:U(Uint32Array),cornerEdge:U(Int32Array),edge:U(Uint32Array),edgeSharp:U(Uint8Array),edgeSeam:U(Uint8Array),edgeCrease:U(Float32Array),material:U(Uint32Array),smooth:U(Uint8Array),vertSelect:U(Uint8Array),vertHide:U(Uint8Array),edgeSelect:U(Uint8Array),edgeHide:U(Uint8Array),faceSelect:U(Uint8Array),faceHide:U(Uint8Array)}).strict(),Kl=P({name:R(),domain:H(["POINT","EDGE","FACE","CORNER"]),type:R(),data:Oa(o=>ArrayBuffer.isView(o))}).strict(),Ie=P({columns:Ql,attributes:D(Kl),activeUv:R().nullable(),renderUv:R().nullable(),counts:P({verts:N().int().nonnegative(),edges:N().int().nonnegative(),faces:N().int().nonnegative(),corners:N().int().nonnegative()}).strict(),revision:N().int().nonnegative()}).strict(),Jl=kt([Xl,Ie,Yl,Zl]),Jo=new Set;function ti(o,t){const n=new Blob([o],{type:t}),e=new ua;let a=!1;e.addEventListener("dispose",()=>{a=!0,e.image?.close?.()});const r=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(i=>{if(a){i.close();return}e.image=i,e.needsUpdate=!0,Ot()}).finally(()=>{Jo.delete(r)});return Jo.add(r),r.catch(()=>{}),{texture:e,ready:r}}function ni(o,t,n,e){const a=new zn(o,t,n,Dn,ca);return a.flipY=!1,a.colorSpace=e==="data"?Nn:Ct,a.needsUpdate=!0,a}function oi(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),i=Math.max(...t.map(s=>s.number-1001))+1,f=new Float32Array(i*2*4);for(let s=0;s<i;s++)f[s*4]=-1;t.forEach((s,l)=>{const c=s.rgba??(s.rgbaBase64?to(s.rgbaBase64):void 0);if(!c)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let d=0;d<s.height;d++)r.set(c.subarray(d*s.width*4,(d+1)*s.width*4),(l*a+d)*e*4);const _=s.number-1001;f[_*4]=l,f.set([0,0,s.width/e,s.height/a],(i+_)*4)});const u=new fa(r,e,a,t.length);u.colorSpace=n==="data"?Nn:Ct,u.magFilter=Gt,u.minFilter=ue,u.generateMipmaps=!0,u.needsUpdate=!0;const h=new zn(f,i,2,Dn,ie);return h.magFilter=h.minFilter=Kn,h.needsUpdate=!0,{tiles:u,map:h,frame:t}}const ei=P({width:N().int().positive(),height:N().int().positive(),revision:N().int().nonnegative(),rgba:U(Uint8Array).optional(),rgbaBase64:R().optional(),colorspace:H(["sRGB","data"]).optional(),tiles:D(P({number:N().int().min(1001),width:N().int().positive(),height:N().int().positive(),rgba:U(Uint8Array).optional(),rgbaBase64:R().optional()}).strict()).optional()}).strict(),ai=P({revision:N().int().nonnegative(),encoded:U(Uint8Array).optional(),encodedBase64:R().optional(),mime:H(["image/png","image/jpeg"]),colorspace:H(["sRGB","data"]).optional()}).strict(),Fe=kt([ei,ai]),Xn=P({image:P({name:R(),revision:N().int().nonnegative()}).strict(),extension:H(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:R(),tint:L([F,F,F]).optional()}).strict(),ri=P({name:R(),color:L([F,F,F,F]),roughness:F,metallic:F,transmission:F,ior:F,physical:ml.optional(),normal_texture:Xn.optional(),normal_strength:F.default(1),normal_space:H(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:Z().default(!1),texture:Xn.optional(),roughness_texture:Xn.optional(),emission:P({color:L([F,F,F]),strength:F}).strict().optional(),graph:jr.optional(),viewport:P({color:L([F,F,F,F]),roughness:F,metallic:F}).strict().optional()}).strict(),li=P({session:R(),revision:N().int().nonnegative(),volumes:xt(R(),Te).default({}),lights:xt(R(),Tr).default({}),world:Ir.nullable().default(null),meshes:xt(R(),Jl),materials:xt(R(),ri),images:xt(R(),Fe).default({}),objects:D(P({id:R(),name:R(),type:H(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:R().nullable(),volume:R().nullable().optional(),light:R().nullable().optional(),materials:D(R().nullable()),matrix:D(L([F,F,F,F])).length(4),visible:Z(),render_visible:Z().default(!0),selected:Z(),parent:R().nullable(),texspace:L([L([F,F,F]),L([F,F,F])]).optional(),default_color:R().optional()}).strict()),active:R().nullable(),mode:R(),cameras:xt(R(),xt(R(),me())).default({}),warnings:D(R()).default([]),updated:D(R()).default([]),frame:N().int().default(0),armatures:xt(R(),Sa).default({}),weights:xl.nullable().default(null),cursor:Tl.optional(),camera_view:P({scene_camera:R().nullable(),view_layer_cameras:D(R()),aspect:N().finite().positive()}).optional(),light_distances:xt(R(),L([N().finite(),N().finite()])).default({}),empties:xt(R(),Nl).default({}),view:P({location:L([N(),N(),N()]),rotation:L([N(),N(),N(),N()]),distance:N().finite(),perspective:H(["PERSP","ORTHO","CAMERA"]),lens:N().finite().positive().default(50),shading:H(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:P({frame:N().int(),body:R(),markers:D(L([N().int(),R()]))}).optional(),units:P({system:H(["NONE","METRIC","IMPERIAL"]),scale_length:N().finite()}).optional()}).strict();function ii(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 si={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 Fn{constructor(){this.root=new lt,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new Rr,this.world=new po,this.armatureOverlay=new $a,this.weightOverlay=new Ol,this.cursorOverlay=new Ml,this.extrasOverlay=new Fl,this.armatureRoot=new lt,this.weightRoot=new lt,this.cursorRoot=new lt,this.cameraExtrasRoot=new lt,this.lightExtrasRoot=new lt,this.emptyExtrasRoot=new lt,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 mn({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new _l,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=Cl,this.cameraViewPan=kl,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,this.staged=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=nl(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[r,i]of this.objects)if(i===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 i=r.objects.get(n);i!==void 0&&(i.matrix.copy(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),a=!0)}a&&Ot()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=Aa(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,i=new Tt(e,a,r,n),f=new x(...t.location).applyMatrix4(this.root.matrix),u=h=>h.applyQuaternion(i).applyMatrix4(this.root.matrix).normalize();return{target:f.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?ql[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 tt().copy(this.root.matrix).invert(),a=new tt().compose(new x(...t),new Tt(...n),new x(1,1,1)).premultiply(e),r=new x,i=new Tt;return a.decompose(r,i,new x),{location:r.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,n,e,a){const r=this.frame,i=Qo.safeParse(r?.cameras[t]);return!r?.camera_view||!i.success?null:$l(i.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=ii(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=si[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([f])=>f*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,i=[...t.children];t.removeFromParent();for(const f of i)n.add(f);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,i=>a.has(i));return r!==null&&(this.cursorOverlay.show(r),Ot()),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(Ot,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(),Ot())}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 i=(e.materials.length?e.materials:[null]).map(f=>{const u=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,u.side,n):u});a.material=e.materials.length?i:i[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)??Ll,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let i=this.workbenchMaterials.get(r);return i||(i=Hl(a,n),this.workbenchMaterials.set(r,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Go(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])hl(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 Pr(),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 h=u;if(h.isMesh&&(h.castShadow=t,h.receiveShadow=t,t&&h.visible)){const s=new Mn().setFromObject(h);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,h)=>u.union(h),new Mn).getBoundingSphere(new ra),i=n?new la().setFromProjectionMatrix(new tt().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=i?e.flatMap(u=>Dr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Cr(u,f,e):Mr(u,r.center,r.radius)}applyOverlays(t){const n=i=>{const f=t.objects.find(u=>u.name===i);return f===void 0?null:new tt().set(...f.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],a=t.weights?this.objects.get(t.objects.find(i=>i.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),Ot())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=Qo.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,i=a.width||r?.width||0,f=a.height||r?.height||0;return(i===0||f===0)&&a.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),a.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),Ot()},()=>this.awaitedImages.delete(e))),{texture:a.texture,width:i,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const 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}stageFrame(t){if(t.abort||!t.mesh&&!t.image){for(const e of this.staged?.meshes.values()??[])e.geometry.dispose();this.staged=t.abort?null:{session:t.session,revision:t.revision,meshes:new Map,images:new Map};return}const n=this.staged;if(!n||n.session!==t.session||n.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const e=Ie.parse(t.piece);if(n.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const a=`revision:${e.revision}`;n.meshes.set(t.mesh,{signature:a,geometry:Pn(Io({...e.columns,attributes:e.attributes,activeUv:e.activeUv,renderUv:e.renderUv},a))})}else if(t.image!==void 0){if(n.images.has(t.image))throw new Error("Duplicate Blender image piece");n.images.set(t.image,Fe.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=li.parse(t),a=this.staged;if(a&&(a.session!==e.session||a.revision!==e.revision))throw new Error("Blender frame manifest does not match its staged revision");if(a)for(const[s,l]of a.images)e.images[s]=l;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 r=new Set(e.objects.map(s=>s.id));if(r.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const i=new Map(e.objects.map(s=>[s.id,s]));for(const s of e.objects){if(s.mesh!==null&&!e.meshes[s.mesh])throw new Error(`Missing runtime mesh ${s.mesh}`);if(s.volume&&(!e.volumes[s.volume]||s.mesh!==null))throw new Error(`Invalid runtime volume ${s.volume}`);if(s.light&&(!e.lights[s.light]||s.mesh!==null))throw new Error(`Invalid runtime light ${s.light}`);for(const _ of s.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const l=new Set([s.id]);let c=s.parent;for(;c!==null;){if(l.has(c))throw new Error("Runtime parent cycle");l.add(c);const _=i.get(c);if(!_)throw new Error(`Missing runtime parent ${c}`);c=_.parent}}const f=new Map,u=new Map;try{for(const[s,l]of Object.entries(e.volumes)){const c=JSON.stringify(l);this.frame?.session===e.session&&this.volumes.get(s)?.signature===c||u.set(s,{signature:c,mesh:kr(l)})}for(const[s,l]of Object.entries(e.meshes)){if("unchanged"in l){const m=a?.meshes.get(s);if(m){if(m.signature!==`revision:${l.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(s,m);continue}const p=this.meshes.get(s)?.signature;if(this.frame?.session===e.session&&p!==void 0&&(p===`revision:${l.revision}`||!p.startsWith("revision:")))continue;throw new Error(p===void 0?`${Mo}: the presenter does not hold runtime mesh ${s} (store ${l.store}, revision ${l.revision})`:`${Mo}: the presenter holds runtime mesh ${s} at ${p}, not revision ${l.revision}`)}const c="hash"in l,_="columns"in l,d=_?`revision:${l.revision}`:c?l.hash:JSON.stringify(l);this.frame?.session===e.session&&this.meshes.get(s)?.signature===d||f.set(s,{signature:d,geometry:_?Pn(Io({...l.columns,attributes:l.attributes,activeUv:l.activeUv,renderUv:l.renderUv},d)):c?Pn(l):Qa(l)})}}catch(s){for(const l of f.values())l.geometry.dispose();for(const{mesh:l}of u.values())l.geometry.dispose(),l.material.dispose();throw s}if(a){for(const[s,l]of a.meshes)f.has(s)||l.geometry.dispose();this.staged=null}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[s,l]of u){const c=this.volumes.get(s)?.mesh;c&&(c.removeFromParent(),c.geometry.dispose(),c.material.dispose()),this.volumes.set(s,l)}for(const[s,l]of f)this.meshes.get(s)?.geometry.dispose(),this.meshes.set(s,l),this.geometryBuilds++;for(const[s,l]of Object.entries(e.images)){const c=this.textures.get(s);if("width"in l){const v=l.rgba??(l.rgbaBase64?to(l.rgbaBase64):void 0);if(!v)throw new Error(`Runtime image ${s} carries no raster`);const g=l.tiles?oi(s,l.tiles,l.colorspace??"sRGB"):void 0;if(c?.udim&&(c.udim.tiles.dispose(),c.udim.map.dispose(),delete c.udim),c&&c.width===l.width&&c.height===l.height){const w=c.texture.image;if(w.data){w.data.set(v),c.texture.needsUpdate=!0,c.revision=l.revision,g&&(c.udim=g);continue}}c?.texture.dispose(),this.textures.set(s,{texture:ni(v,l.width,l.height,l.colorspace??"sRGB"),width:l.width,height:l.height,revision:l.revision,...g?{udim:g}:{}});continue}const _=l.encoded??(l.encodedBase64?to(l.encodedBase64):void 0);if(!_)throw new Error(`Runtime image ${s} carries no bytes`);c?.texture.dispose(),c?.udim?.tiles.dispose(),c?.udim?.map.dispose();const d=l.colorspace??"sRGB",{texture:m,ready:p}=ti(_,l.mime);m.colorSpace=d==="data"?Nn:Ct,this.textures.set(s,{texture:m,ready:p,width:0,height:0,revision:l.revision,encoded:{bytes:_.slice(),mime:l.mime,colorspace:d}})}for(const[s,l]of Object.entries(e.materials)){const c=this.materials.get(s)??new mn;c.name=l.name;const _=l.texture?.tint;l.texture!==void 0?c.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,pt):c.color.setRGB(l.color[0],l.color[1],l.color[2],pt),c.opacity=l.color[3];const d=c.opacity<1||l.graph!==void 0&&Br(l.graph);c.transparent!==d&&(c.transparent=d,c.needsUpdate=!0),c.roughness=l.roughness,c.metalness=l.metallic,c.transmission=l.transmission,c.ior=l.ior,go(c,l.physical,{map:l.texture?.extension==="CLIP",roughness:l.roughness_texture?.extension==="CLIP",normal:l.normal_texture?.extension==="CLIP"});const m=l.normal_texture?.image.name;if(m===void 0)c.normalMap&&(this.textureSamplers.delete(`${s}:normal`),c.normalMap=null,c.needsUpdate=!0);else{const y=this.textures.get(m);if(!y)throw new Error(`${en}: missing normal image ${m}`);const S=this.textureSamplers.get(`${s}:normal`,y.texture,l.normal_texture.extension,y.ready,l.normal_texture.uv);c.normalMap!==S&&(c.normalMap=S,c.needsUpdate=!0);const T=l.normal_space==="OBJECT"?ia:sa;c.normalMapType!==T&&(c.normalMapType=T,c.needsUpdate=!0),c.normalScale.set(l.normal_strength,l.normal_strength*(l.normal_directx?-1:1))}l.emission?(c.emissive.setRGB(l.emission.color[0],l.emission.color[1],l.emission.color[2],pt),c.emissiveIntensity=l.emission.strength):(c.emissive.setRGB(0,0,0),c.emissiveIntensity=1);const p=l.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(s)&&(this.textureSamplers.delete(`${s}:roughness`),c.roughnessMap=null,this.roughnessTextureNames.delete(s),c.needsUpdate=!0);else{const y=this.textures.get(p);if(!y)throw new Error(`${en}: the presenter does not hold runtime image ${p} (revision ${l.roughness_texture.image.revision})`);const S=this.textureSamplers.get(`${s}:roughness`,y.texture,l.roughness_texture.extension,y.ready,l.roughness_texture.uv);c.roughnessMap!==S&&(c.roughnessMap=S,this.roughnessTextureNames.set(s,p),c.needsUpdate=!0)}const v=l.texture?.image.name??null;if(v===null)this.textureNames.has(s)&&(this.textureSamplers.delete(`${s}:color`),c.map=null,this.textureNames.delete(s),c.needsUpdate=!0);else{const y=this.textures.get(v);if(!y)throw new Error(`${en}: the presenter does not hold runtime image ${v} (revision ${l.texture.image.revision})`);const S=this.textureSamplers.get(`${s}:color`,y.texture,l.texture.extension,y.ready,l.texture.uv);c.map!==S&&(c.map=S,this.textureNames.set(s,v),c.needsUpdate=!0)}const g=l.graph?this.compiledGraph(l.graph):null,w=new Set;el(c,g,y=>{const S=this.textures.get(y.name);if(!S)throw new Error(`${en}: the presenter does not hold runtime image ${y.name} (revision ${y.revision})`);if(y.tiled){if(!S.udim)throw new Error(`${en}: runtime image ${y.name} arrived without its UDIM tiles`);return S.udim}const T=`${s}:graph:${y.node}`;w.add(T);const A=this.textureSamplers.get(T,S.texture,y.extension,S.ready),O=y.closest?Kn:Gt,M=y.closest?Kn:y.mipmap?ue:Gt;return(A.magFilter!==O||A.minFilter!==M)&&(A.magFilter=O,A.minFilter=M,A.needsUpdate=!0),A},this.photograph);for(const y of this.graphSamplers.get(s)??[])w.has(y)||this.textureSamplers.delete(y);this.graphSamplers.set(s,w),this.materials.set(s,c)}for(const s of e.objects){let l=this.objects.get(s.id);const c=s.volume?this.volumes.get(s.volume).mesh:null;if((!l||(c?l!==c:!!l.isMesh!=(s.mesh!==null)))&&(l?.removeFromParent(),l=c??(s.mesh!==null?new Rt(this.meshes.get(s.mesh).geometry,this.fallback):new re),this.objects.set(s.id,l)),l.name=s.name,s.type==="CAMERA"||s.type==="LIGHT"||s.type==="EMPTY"?l.userData.volterOwnOverlay=!0:delete l.userData.volterOwnOverlay,l.matrixAutoUpdate=!1,l.matrix.set(...s.matrix.flat()),s.parent){const _=new tt().set(...i.get(s.parent).matrix.flat());l.matrix.premultiply(_.invert())}if(l.matrix.decompose(l.position,l.quaternion,l.scale),s.texspace?l.userData.blenderTexspace=s.texspace:delete l.userData.blenderTexspace,s.default_color!==void 0?l.userData.blenderDefaultColor=s.default_color:delete l.userData.blenderDefaultColor,s.mesh!==null){const _=l;_.geometry=this.meshes.get(s.mesh).geometry,_.material=s.materials.length?s.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,il(_)}if(s.light){const _=this.lights.get(s.light)??null,d=Er(e.lights[s.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==l&&l.add(d),d.userData.volterOwnOverlay=!0,Nr(d,l),this.lights.set(s.light,d)}}for(const s of e.objects){const l=this.objects.get(s.id),c=s.parent===null?this.root:this.objects.get(s.parent);l.parent!==c&&c.add(l)}for(const[s,l]of this.objects)r.has(s)||(l.removeFromParent(),this.objects.delete(s));for(const[s,l]of this.volumes)e.volumes[s]||(l.mesh.geometry.dispose(),l.mesh.material.dispose(),this.volumes.delete(s));for(const[s,l]of this.meshes)e.meshes[s]||(l.geometry.dispose(),this.meshes.delete(s));for(const[s,l]of this.materials)if(!e.materials[s]){for(const c of["normal","roughness","color"])this.textureSamplers.delete(`${s}:${c}`);for(const c of this.graphSamplers.get(s)??[])this.textureSamplers.delete(c);this.graphSamplers.delete(s),l.dispose(),this.materials.delete(s)}for(const[s,l]of this.lights)e.lights[s]||(l.removeFromParent(),l.dispose(),this.lights.delete(s));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{},images:{}},this.worldKey=JSON.stringify(e.world??null);const h=this.applyOverlays(e);h.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...h]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const s of[...this.frameListeners])s();for(const s of this.followers)try{s.applyFrame(t)}catch{s.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:i}]of this.meshes){const f=s=>{const l=i.getAttribute(s);if(!l)return null;if(!(l instanceof dt))throw new Error(`Blender capture cannot copy interleaved ${s}`);return new Float32Array(l.array)},u=f("position");if(!u)throw new Error(`Blender capture mesh ${a} has no positions`);const h=i.getIndex();n.meshes[a]={hash:r,positions:u,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(i.userData.blenderUvChannels??{}).map(([s,l])=>{const c=f(`uv${l}`);if(!c)throw new Error(`Blender capture mesh ${a} is missing UV layer ${s}`);return{name:s,data:c}}),orco:i.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(i.userData.blenderAttributes??[]).map(s=>{const l=f(Xt(s));if(!l)throw new Error(`Blender capture mesh ${a} is missing attribute ${s}`);return{name:s,data:l}}),indices:h?new Uint32Array(h.array):Uint32Array.from({length:u.length/3},(s,l)=>l),groups:i.groups.map(s=>({start:s.start,count:s.count,materialIndex:s.materialIndex??0}))}}for(const[a,{signature:r}]of this.volumes)n.volumes[a]=Te.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.encoded)n.images[a]={revision:r.revision,encoded:r.encoded.bytes.slice(),mime:r.encoded.mime,colorspace:r.encoded.colorspace};else{const i=r.texture.image?.data;if(!(i 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:i.slice(),colorspace:r.texture.colorSpace===Nn?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Fn;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 Fn;a.photograph=!0;let r=!1;const i=()=>{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(f){throw i(),f}return{effect:e,root:a.root,session:n.session,revision:n.revision,prepare:f=>{if(r)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,f)},dispose:i}}createWorldVolumePass(){const t=Go(this.frame?.world);return t?new gl(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[i,f]of Object.entries(r))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(i,f);for(const i of[...this.submittedMeshes.keys()])i in r||this.submittedMeshes.delete(i);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.staged?.meshes.values()??[])t.geometry.dispose();this.staged=null;for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const vi=new Fn;function ze(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 Yn(o){const t=ze(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function fi(o){const t=ze(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ci(o){return new tt().set(...o.flat())}function te(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class ui{#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,i)=>r+i.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,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 i=!1;for(const l of e.rigs){if(!l.object||!l.armature||!l.skinIndexBase64||!l.skinWeightBase64){l.reason&&a.push(l.reason);continue}r.add(l.object);const c=te(l,e.frame);if(this.#n.get(l.object)?.signature===c)continue;const _=this.#d(t,l,e.frame,a);_&&(this.#n.get(l.object)?.skeleton.dispose(),this.#n.set(l.object,_),i=!0)}for(const[l,c]of[...this.#n])r.has(l)||(c.skeleton.dispose(),c.boneRoot.removeFromParent(),this.#n.delete(l),i=!0);this.#r++;const f=await n.clip(),u=this.#t,h=f?.action!==u?.action||f?.tracks.length!==u?.tracks.length||f?.clipStart!==u?.clipStart||f?.clipEnd!==u?.clipEnd;this.#t=f??null,f?.reason&&a.push(f.reason),f&&(h||i)&&this.#h(t,f,a);const s=this.#e?.snapshot().playbackState==="playing";f&&!s&&u?.frameCurrent!==f.frameCurrent&&(this.#c(f.frameCurrent),this.#e&&f.fps>0&&this.#e.seek(f.frameCurrent/f.fps)),this.#_=a,this.#f()}#d(t,n,e,a){const r=t.objectForBlenderName(n.object??""),i=t.objectForBlenderName(n.armature??"");if(!r||!i)return null;const f=r,u=f.geometry;if(!u)return null;const h=u.getAttribute("blenderVertex");if(!h)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<h.count;T++)s=Math.max(s,h.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 l=fi(n.skinIndexBase64??""),c=Yn(n.skinWeightBase64??""),_=h.count,d=new Uint16Array(_*4),m=new Float32Array(_*4);for(let T=0;T<_;T++){const A=h.getX(T);for(let O=0;O<4;O++)d[T*4+O]=l[A*4+O]??0,m[T*4+O]=c[A*4+O]??0}u.setAttribute("skinIndex",new _a(d,4)),u.setAttribute("skinWeight",new St(m,4));const p=new lt;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ci(T.pose)),w=new Map(n.bones.map((T,A)=>[T.name,A]));n.bones.forEach((T,A)=>{const O=new ma;O.name=T.name,v.push(O);const M=T.parent===null?void 0:w.get(T.parent);(M===void 0?g[A].clone():g[M].clone().invert().multiply(g[A])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),i.add(p);const y=new da(u,f.material);y.name=f.name,y.matrixAutoUpdate=!1,y.matrix.copy(f.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale),y.userData=f.userData,y.frustumCulled=!1,t.replacePresentedObject(f,y),t.root.updateMatrixWorld(!0);const S=new ha(v);return y.bind(S,y.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:y,boneRoot:p,bones:v,skeleton:S,frame:e,signature:te(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 l of this.#n.values())if(l.armature===n.armature)for(const c of l.bones)r.set(c.name,c);const i=[],f=new Set;for(const l of n.tracks){const c=r.get(l.bone);if(!c){f.add(l.bone);continue}const _=Yn(l.timeBase64),d=Yn(l.valueBase64),m=`${c.uuid}.${l.property}`;i.push(l.property==="quaternion"?new pa(m,Array.from(_),Array.from(d)):new va(m,Array.from(_),Array.from(d)))}if(f.size&&e.push(`${n.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!i.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,h=new ga(a),s=h.clipAction(new xa(n.action??"action",u,i));s.setLoop(ba,Number.POSITIVE_INFINITY),s.play(),this.#o=h,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 Ta(`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 i=this.#t,f=i?.fps||24;return{start:(i?.frameStart??1)/f,end:(i?.frameEnd??250)/f,fps:f}},seek:i=>this.seekSeconds(i)}),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 De=new ui;function gi(o){return De.subscribe(o)}function xi(){return De.version}export{De as a,xi as b,vi as c,gi as s};
|
|
7191
|
+
#include <opaque_fragment>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const Qi=64;function Ki(o,t){return Array.isArray(o)&&Array.isArray(t)?o.length===t.length&&o.every((n,e)=>n===t[e]):o===t}function Jo(o){for(let t=o;t;t=t.parent)if(!t.visible)return!1;return!0}function te(o){if(o.determinant()<=0)return!1;const t=o.elements,n=Math.hypot(t[0],t[1],t[2]),e=Math.hypot(t[4],t[5],t[6]),r=Math.hypot(t[8],t[9],t[10]),a=(s,f)=>t[s]*t[f]+t[s+1]*t[f+1]+t[s+2]*t[f+2];return Number.isFinite(n+e+r)&&Math.min(n,e,r)>0&&Math.abs(a(0,4))<=1e-7*n*e&&Math.abs(a(0,8))<=1e-7*n*r&&Math.abs(a(4,8))<=1e-7*e*r}class Ji{constructor(t){this.root=t,this.batches=[],this.inverse=new Z,this.matrix=new Z,this.box=new dn,this.eligible=0,this.excluded={}}rebuild(t,n){if(this.clear(),!n)return;const e=new Map,r=a=>{this.excluded[a]=(this.excluded[a]??0)+1};this.inverse.copy(this.root.matrixWorld).invert();for(const a of t){const s=a;if(!s.isMesh)continue;if(s.isSkinnedMesh||s.isInstancedMesh||s.morphTargetInfluences||s.layers.mask!==1){r("deformationOrLayers");continue}const f=Array.isArray(s.material)?s.material:[s.material];if(f.some(l=>l.transparent||l.transmission>0||l.isShaderMaterial)){r("material");continue}if(f.some(l=>ci(l,s.geometry).size>12)){r("attributeBudget");continue}if(this.matrix.multiplyMatrices(this.inverse,s.matrixWorld),!te(this.matrix)){r("transform");continue}this.eligible++;const u=`${s.geometry.id}:${Array.isArray(s.material)?"slots":"single"}:`+f.map(l=>l.uuid).join(",")+`:${s.renderOrder}`,_=e.get(u);_?_.push(s):e.set(u,[s])}for(const a of e.values()){if(a.length<2)continue;const s=f=>{if(f.length>Qi){this.box.makeEmpty();for(const d of f)this.box.expandByPoint(new x().setFromMatrixPosition(d.matrixWorld));const i=this.box.getSize(new x),c=i.x>=i.y&&i.x>=i.z?12:i.y>=i.z?13:14;f.sort((d,h)=>d.matrixWorld.elements[c]-h.matrixWorld.elements[c]);const m=Math.floor(f.length/2);s(f.slice(0,m)),s(f.slice(m));return}if(f.length<2)return;const u=f[0],_=new sa(u.geometry,u.material,f.length);_.name="Blender repeated geometry",_.userData.engineInternal=!0,_.matrixAutoUpdate=!1,_.renderOrder=u.renderOrder,_.instanceMatrix.setUsage(la);const l={draw:_,members:f.map(i=>({mesh:i,layers:i.layers.mask}))};_.raycast=(i,c)=>{for(const{mesh:m}of l.members)m.layers.mask===0&&Jo(m)&&m.raycast(i,c)},this.root.add(_),_.updateMatrixWorld(!0),this.batches.push(l)};s(a)}this.sync()}sync(){if(this.batches.length){this.inverse.copy(this.root.matrixWorld).invert();for(const{draw:t,members:n}of this.batches){let e=0,r=!1;for(const a of n){const{mesh:s}=a;if(this.matrix.multiplyMatrices(this.inverse,s.matrixWorld),!(s.parent!==null&&s.geometry===t.geometry&&Ki(s.material,t.material)&&te(this.matrix))){s.layers.mask|=a.layers;continue}if(s.layers.mask&=~a.layers,!Jo(s))continue;const u=e*16;this.matrix.elements.some((_,l)=>Math.fround(_)!==t.instanceMatrix.array[u+l])&&(t.setMatrixAt(e,this.matrix),r=!0),e++}r||=t.count!==e||t.boundingSphere===null,t.count=e,r&&(t.instanceMatrix.needsUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere())}}}clear(){for(const{draw:t,members:n}of this.batches){for(const{mesh:e,layers:r}of n)e.layers.mask|=r;t.removeFromParent(),t.dispose()}this.batches.length=0,this.eligible=0,this.excluded={}}inspect(){return{batches:this.batches.length,instances:this.batches.reduce((t,{draw:n})=>t+n.count,0),eligible:this.eligible,excluded:{...this.excluded}}}}const ts={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},F=N().finite(),Fe=L([F,F,F]),Tn=L([N().int().nonnegative(),N().int().nonnegative()]),mt={name:R(),domain:H(["POINT","EDGE","FACE","CORNER"])},ns=Sa("type",[S({...mt,type:W("FLOAT2"),data:D(L([F,F]))}).strict(),S({...mt,type:W("FLOAT_VECTOR"),data:D(Fe)}).strict(),S({...mt,type:W("FLOAT_COLOR"),data:D(L([F,F,F,F]))}).strict(),S({...mt,type:W("BYTE_COLOR"),data:D(L([F,F,F,F]))}).strict(),S({...mt,type:W("QUATERNION"),data:D(L([F,F,F,F]))}).strict(),S({...mt,type:W("FLOAT4"),data:D(L([F,F,F,F]))}).strict(),S({...mt,type:W("FLOAT4X4"),data:D(D(F).length(16))}).strict(),S({...mt,type:W("INT16_2D"),data:D(L([N().int(),N().int()]))}).strict(),S({...mt,type:W("INT32_2D"),data:D(L([N().int(),N().int()]))}).strict(),S({...mt,type:W("FLOAT"),data:D(F)}).strict(),S({...mt,type:W("INT"),data:D(N().int())}).strict(),S({...mt,type:W("INT8"),data:D(N().int())}).strict(),S({...mt,type:W("BOOLEAN"),data:D(Q())}).strict(),S({...mt,type:W("STRING"),data:D(R())}).strict()]),os=S({positions:U(Float32Array),normals:U(Float32Array).nullable(),uv:U(Float32Array).nullable(),uvLayers:D(S({name:R(),data:U(Float32Array)}).strict()).optional(),attributeLayers:D(S({name:R(),data:U(Float32Array)}).strict()).optional(),orco:U(Float32Array).nullable().optional(),indices:U(Uint32Array),groups:D(S({start:N().int().nonnegative(),count:N().int().nonnegative(),materialIndex:N().int().nonnegative()}).strict()),hash:R()}).strict(),es=S({v:D(Fe),f:D(D(N().int().nonnegative())),e:D(Tn).optional(),edge_order:D(Tn).optional(),m:D(N().int().nonnegative()).optional(),s:D(Q()).optional(),sharp:D(Tn).optional(),seams:D(Tn).optional(),creases:D(L([F,F,F])).optional(),attributes:D(ns).optional(),active_uv:R().nullable().optional(),render_uv:R().nullable().optional()}).strict(),as=S({store:N().int().optional(),revision:N().int(),unchanged:W(!0)}).strict(),rs=S({co:Lt([U(Float32Array),U(Float64Array)]),cornerNormal:U(Float32Array).optional(),cornerTri:U(Uint32Array).optional(),orco:U(Float32Array).optional(),faceStart:U(Uint32Array),corner:U(Uint32Array),cornerEdge:U(Int32Array),edge:U(Uint32Array),edgeSharp:U(Uint8Array),edgeSeam:U(Uint8Array),edgeCrease:U(Float32Array),material:U(Uint32Array),smooth:U(Uint8Array),vertSelect:U(Uint8Array),vertHide:U(Uint8Array),edgeSelect:U(Uint8Array),edgeHide:U(Uint8Array),faceSelect:U(Uint8Array),faceHide:U(Uint8Array)}).strict(),is=S({name:R(),domain:H(["POINT","EDGE","FACE","CORNER"]),type:R(),data:Pa(o=>ArrayBuffer.isView(o))}).strict(),ze=S({columns:rs,attributes:D(is),activeUv:R().nullable(),renderUv:R().nullable(),counts:S({verts:N().int().nonnegative(),edges:N().int().nonnegative(),faces:N().int().nonnegative(),corners:N().int().nonnegative()}).strict(),revision:N().int().nonnegative()}).strict(),ss=Lt([os,ze,es,as]),ne=new Set;function ls(o,t){const n=new Blob([o],{type:t}),e=new ha;let r=!1;e.addEventListener("dispose",()=>{r=!0,e.image?.close?.()});const a=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(s=>{if(r){s.close();return}e.image=s,e.needsUpdate=!0,Ot()}).finally(()=>{ne.delete(a)});return ne.add(a),a.catch(()=>{}),{texture:e,ready:a}}function fs(o,t,n,e){const r=new zn(o,t,n,Dn,da);return r.flipY=!1,r.colorSpace=e==="data"?Nn:$t,r.needsUpdate=!0,r}function cs(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(l=>l.width)),r=Math.max(...t.map(l=>l.height)),a=new Uint8Array(e*r*4*t.length),s=Math.max(...t.map(l=>l.number-1001))+1,f=new Float32Array(s*2*4);for(let l=0;l<s;l++)f[l*4]=-1;t.forEach((l,i)=>{const c=l.rgba??(l.rgbaBase64?to(l.rgbaBase64):void 0);if(!c)throw new Error(`Runtime image ${o} tile ${l.number} carries no raster`);for(let d=0;d<l.height;d++)a.set(c.subarray(d*l.width*4,(d+1)*l.width*4),(i*r+d)*e*4);const m=l.number-1001;f[m*4]=i,f.set([0,0,l.width/e,l.height/r],(s+m)*4)});const u=new ma(a,e,r,t.length);u.colorSpace=n==="data"?Nn:$t,u.magFilter=Xt,u.minFilter=me,u.generateMipmaps=!0,u.needsUpdate=!0;const _=new zn(f,s,2,Dn,fe);return _.magFilter=_.minFilter=Kn,_.needsUpdate=!0,{tiles:u,map:_,frame:t}}const us=S({width:N().int().positive(),height:N().int().positive(),revision:N().int().nonnegative(),rgba:U(Uint8Array).optional(),rgbaBase64:R().optional(),colorspace:H(["sRGB","data"]).optional(),tiles:D(S({number:N().int().min(1001),width:N().int().positive(),height:N().int().positive(),rgba:U(Uint8Array).optional(),rgbaBase64:R().optional()}).strict()).optional()}).strict(),_s=S({revision:N().int().nonnegative(),encoded:U(Uint8Array).optional(),encodedBase64:R().optional(),mime:H(["image/png","image/jpeg"]),colorspace:H(["sRGB","data"]).optional()}).strict(),De=Lt([us,_s]),Xn=S({image:S({name:R(),revision:N().int().nonnegative()}).strict(),extension:H(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:R(),tint:L([F,F,F]).optional()}).strict(),ms=S({name:R(),color:L([F,F,F,F]),roughness:F,metallic:F,transmission:F,ior:F,physical:gi.optional(),normal_texture:Xn.optional(),normal_strength:F.default(1),normal_space:H(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:Q().default(!1),texture:Xn.optional(),roughness_texture:Xn.optional(),emission:S({color:L([F,F,F]),strength:F}).strict().optional(),graph:Hr.optional(),viewport:S({color:L([F,F,F,F]),roughness:F,metallic:F}).strict().optional()}).strict(),ds=S({session:R(),revision:N().int().nonnegative(),volumes:bt(R(),Se).default({}),lights:bt(R(),Mr).default({}),world:Cr.nullable().default(null),meshes:bt(R(),ss),materials:bt(R(),ms),images:bt(R(),De).default({}),objects:D(S({id:R(),name:R(),type:H(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:R().nullable(),volume:R().nullable().optional(),light:R().nullable().optional(),materials:D(R().nullable()),matrix:D(L([F,F,F,F])).length(4),visible:Q(),render_visible:Q().default(!0),selected:Q(),parent:R().nullable(),texspace:L([L([F,F,F]),L([F,F,F])]).optional(),default_color:R().optional()}).strict()),active:R().nullable(),mode:R(),cameras:bt(R(),bt(R(),he())).default({}),warnings:D(R()).default([]),updated:D(R()).default([]),frame:N().int().default(0),armatures:bt(R(),Ra).default({}),weights:Ai.nullable().default(null),cursor:Ei.optional(),camera_view:S({scene_camera:R().nullable(),view_layer_cameras:D(R()),aspect:N().finite().positive()}).optional(),light_distances:bt(R(),L([N().finite(),N().finite()])).default({}),empties:bt(R(),Di).default({}),view:S({location:L([N(),N(),N()]),rotation:L([N(),N(),N(),N()]),distance:N().finite(),perspective:H(["PERSP","ORTHO","CAMERA"]),lens:N().finite().positive().default(50),shading:H(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:S({frame:N().int(),body:R(),markers:D(L([N().int(),R()]))}).optional(),units:S({system:H(["NONE","METRIC","IMPERIAL"]),scale_length:N().finite()}).optional()}).strict();function hs(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 ps={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 Fn{constructor(){this.root=new it,this.instances=new Ji(this.root),this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new Dr,this.world=new po,this.armatureOverlay=new Ba,this.weightOverlay=new Mi,this.cursorOverlay=new zi,this.extrasOverlay=new $i,this.armatureRoot=new it,this.weightRoot=new it,this.cursorRoot=new it,this.cameraExtrasRoot=new it,this.lightExtrasRoot=new it,this.emptyExtrasRoot=new it,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 nn({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new vi,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=ji,this.cameraViewPan=Bi,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,this.staged=null;const t=this.root.updateMatrixWorld.bind(this.root);this.root.updateMatrixWorld=n=>{t(n),this.instances.sync()},this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[n,e]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group],[this.cursorRoot,this.cursorOverlay.group],[this.cameraExtrasRoot,this.extrasOverlay.cameras],[this.lightExtrasRoot,this.extrasOverlay.lights],[this.emptyExtrasRoot,this.extrasOverlay.empties]])n.matrixAutoUpdate=!1,n.matrix.copy(this.root.matrix),n.add(e),n.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const n of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])n.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let e=this.graphs.get(n);return e||(e=ri(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[a,s]of this.objects)if(s===t){n=a;break}if(n===null)return;const e=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let r=!1;for(const a of e){if(a===this)continue;const s=a.objects.get(n);s!==void 0&&(s.matrix.copy(t.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.updateMatrixWorld(!0),r=!0)}r&&Ot()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=Ea(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(r=>r.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,r,a]=t.rotation,s=new At(e,r,a,n),f=new x(...t.location).applyMatrix4(this.root.matrix),u=_=>_.applyQuaternion(s).applyMatrix4(this.root.matrix).normalize();return{target:f.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?ts[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 Z().copy(this.root.matrix).invert(),r=new Z().compose(new x(...t),new At(...n),new x(1,1,1)).premultiply(e),a=new x,s=new At;return r.decompose(a,s,new x),{location:a.toArray(),rotation:[s.w,s.x,s.y,s.z]}}cameraView(t,n,e,r){const a=this.frame,s=Qo.safeParse(a?.cameras[t]);return!a?.camera_view||!s.success?null:Ui(s.data,this.root.matrix,n,e,r,a.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const e=t??n.frame,r=hs(n.markers,e);return`(${e})${n.body}${r===null?"":` <${r}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const e=ps[n.system],r=6*t,a=1/(n.scale_length||1);return(e.find(([f])=>f*a>r)??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,r]of this.objects)if(r===t){const a=t.parent,s=[...t.children];t.removeFromParent();for(const f of s)n.add(f);a?.add(n),this.objects.set(e,n),this.instances.rebuild(this.objects.values(),!this.rendered);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 r=new Set(this.objects.values()),a=this.cursorOverlay.placementAt(t,n,e,this.root,s=>r.has(s));return a!==null&&(this.cursorOverlay.show(a),Ot()),a}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(r=>r.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(Ot,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(),Ot())}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 r=this.objects.get(e.id);if(!r?.isMesh)continue;const s=(e.materials.length?e.materials:[null]).map(f=>{const u=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,u.side,n):u});r.material=e.materials.length?s:s[0]}for(const[e,r]of this.workbenchMaterials)n.has(e)||(r.dispose(),this.workbenchMaterials.delete(e));this.instances.rebuild(this.objects.values(),!this.rendered)}workbenchFor(t,n,e){const r=(t!==null?this.frame?.materials[t]?.viewport:void 0)??Wi,a=`${r.color.join(",")}|${r.roughness}|${r.metallic}|${n}`;e.add(a);let s=this.workbenchMaterials.get(a);return s||(s=Zi(r,n),this.workbenchMaterials.set(a,s)),s}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?Go(this.frame?.world)?.extinction:null)??new x;for(const a of[...this.materials.values(),this.fallback])bi(a,e);this.rendered=t,this.lighting.setRendered(t);const r=t&&n?this.worldKeyFor(n):null;t?(this.capturing||r!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:r,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await Nr(),await Promise.all([...this.textures.values()].map(a=>a.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const e=[];for(const u of this.objects.values()){const _=u;if(_.isMesh&&(_.castShadow=t,_.receiveShadow=t,t&&_.visible)){const l=new dn().setFromObject(_);l.isEmpty()||e.push(l)}}if(!t||!e.length)return;const a=e.reduce((u,_)=>u.union(_),new dn).getBoundingSphere(new fa),s=n?new ca().setFromProjectionMatrix(new Z().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=s?e.flatMap(u=>Lr(u,s)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Vr(u,f,e):Fr(u,a.center,a.radius)}applyOverlays(t){const n=s=>{const f=t.objects.find(u=>u.name===s);return f===void 0?null:new Z().set(...f.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],r=t.weights?this.objects.get(t.objects.find(s=>s.name===t.weights?.object)?.id??""):void 0,a=this.weightOverlay.apply(t.weights,r??null,t.weights?n(t.weights.object):null);return a!==null&&e.push(a),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),e}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),Ot())}applyExtras(t){const n={};for(const[e,r]of Object.entries(t.cameras)){const a=Qo.safeParse(r);a.success&&(n[e]=a.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 r=t.objects.find(a=>a.name===e);return r?this.objects.get(r.id)??null:null},image:e=>{const r=this.textures.get(e);if(!r)return null;const a=r.texture.image,s=r.width||a?.width||0,f=r.height||a?.height||0;return(s===0||f===0)&&r.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),r.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),Ot()},()=>this.awaitedImages.delete(e))),{texture:r.texture,width:s,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const 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}stageFrame(t){if(t.abort||!t.mesh&&!t.image){for(const e of this.staged?.meshes.values()??[])e.geometry.dispose();this.staged=t.abort?null:{session:t.session,revision:t.revision,meshes:new Map,images:new Map};return}const n=this.staged;if(!n||n.session!==t.session||n.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const e=ze.parse(t.piece);if(n.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const r=`revision:${e.revision}`;n.meshes.set(t.mesh,{signature:r,geometry:Pn(Io({...e.columns,attributes:e.attributes,activeUv:e.activeUv,renderUv:e.renderUv},r))})}else if(t.image!==void 0){if(n.images.has(t.image))throw new Error("Duplicate Blender image piece");n.images.set(t.image,De.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=ds.parse(t),r=this.staged;if(r&&(r.session!==e.session||r.revision!==e.revision))throw new Error("Blender frame manifest does not match its staged revision");if(r)for(const[l,i]of r.images)e.images[l]=i;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(l=>l.id));if(a.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const s=new Map(e.objects.map(l=>[l.id,l]));for(const l of e.objects){if(l.mesh!==null&&!e.meshes[l.mesh])throw new Error(`Missing runtime mesh ${l.mesh}`);if(l.volume&&(!e.volumes[l.volume]||l.mesh!==null))throw new Error(`Invalid runtime volume ${l.volume}`);if(l.light&&(!e.lights[l.light]||l.mesh!==null))throw new Error(`Invalid runtime light ${l.light}`);for(const m of l.materials)if(m!==null&&!e.materials[m])throw new Error(`Missing runtime material ${m}`);const i=new Set([l.id]);let c=l.parent;for(;c!==null;){if(i.has(c))throw new Error("Runtime parent cycle");i.add(c);const m=s.get(c);if(!m)throw new Error(`Missing runtime parent ${c}`);c=m.parent}}const f=new Map,u=new Map;try{for(const[l,i]of Object.entries(e.volumes)){const c=JSON.stringify(i);this.frame?.session===e.session&&this.volumes.get(l)?.signature===c||u.set(l,{signature:c,mesh:jr(i)})}for(const[l,i]of Object.entries(e.meshes)){if("unchanged"in i){const h=r?.meshes.get(l);if(h){if(h.signature!==`revision:${i.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(l,h);continue}const p=this.meshes.get(l)?.signature;if(this.frame?.session===e.session&&p!==void 0&&(p===`revision:${i.revision}`||!p.startsWith("revision:")))continue;throw new Error(p===void 0?`${Eo}: the presenter does not hold runtime mesh ${l} (store ${i.store}, revision ${i.revision})`:`${Eo}: the presenter holds runtime mesh ${l} at ${p}, not revision ${i.revision}`)}const c="hash"in i,m="columns"in i,d=m?`revision:${i.revision}`:c?i.hash:JSON.stringify(i);this.frame?.session===e.session&&this.meshes.get(l)?.signature===d||f.set(l,{signature:d,geometry:m?Pn(Io({...i.columns,attributes:i.attributes,activeUv:i.activeUv,renderUv:i.renderUv},d)):c?Pn(i):nr(i)})}}catch(l){for(const i of f.values())i.geometry.dispose();for(const{mesh:i}of u.values())i.geometry.dispose(),i.material.dispose();throw l}if(r){for(const[l,i]of r.meshes)f.has(l)||i.geometry.dispose();this.staged=null}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[l,i]of u){const c=this.volumes.get(l)?.mesh;c&&(c.removeFromParent(),c.geometry.dispose(),c.material.dispose()),this.volumes.set(l,i)}for(const[l,i]of f)this.meshes.get(l)?.geometry.dispose(),this.meshes.set(l,i),this.geometryBuilds++;for(const[l,i]of Object.entries(e.images)){const c=this.textures.get(l);if("width"in i){const v=i.rgba??(i.rgbaBase64?to(i.rgbaBase64):void 0);if(!v)throw new Error(`Runtime image ${l} carries no raster`);const g=i.tiles?cs(l,i.tiles,i.colorspace??"sRGB"):void 0;if(c?.udim&&(c.udim.tiles.dispose(),c.udim.map.dispose(),delete c.udim),c&&c.width===i.width&&c.height===i.height){const w=c.texture.image;if(w.data){w.data.set(v),c.texture.needsUpdate=!0,c.revision=i.revision,g&&(c.udim=g);continue}}c?.texture.dispose(),this.textures.set(l,{texture:fs(v,i.width,i.height,i.colorspace??"sRGB"),width:i.width,height:i.height,revision:i.revision,...g?{udim:g}:{}});continue}const m=i.encoded??(i.encodedBase64?to(i.encodedBase64):void 0);if(!m)throw new Error(`Runtime image ${l} carries no bytes`);c?.texture.dispose(),c?.udim?.tiles.dispose(),c?.udim?.map.dispose();const d=i.colorspace??"sRGB",{texture:h,ready:p}=ls(m,i.mime);h.colorSpace=d==="data"?Nn:$t,this.textures.set(l,{texture:h,ready:p,width:0,height:0,revision:i.revision,encoded:{bytes:m.slice(),mime:i.mime,colorspace:d}})}for(const[l,i]of Object.entries(e.materials)){const c=this.materials.get(l)??new nn;c.name=i.name;const m=i.texture?.tint;i.texture!==void 0?c.color.setRGB(m?.[0]??1,m?.[1]??1,m?.[2]??1,vt):c.color.setRGB(i.color[0],i.color[1],i.color[2],vt),c.opacity=i.color[3];const d=c.opacity<1||i.graph!==void 0&&qr(i.graph);c.transparent!==d&&(c.transparent=d,c.needsUpdate=!0),c.roughness=i.roughness,c.metalness=i.metallic,c.transmission=i.transmission,c.ior=i.ior,go(c,i.physical,{map:i.texture?.extension==="CLIP",roughness:i.roughness_texture?.extension==="CLIP",normal:i.normal_texture?.extension==="CLIP"});const h=i.normal_texture?.image.name;if(h===void 0)c.normalMap&&(this.textureSamplers.delete(`${l}:normal`),c.normalMap=null,c.needsUpdate=!0);else{const y=this.textures.get(h);if(!y)throw new Error(`${an}: missing normal image ${h}`);const P=this.textureSamplers.get(`${l}:normal`,y.texture,i.normal_texture.extension,y.ready,i.normal_texture.uv);c.normalMap!==P&&(c.normalMap=P,c.needsUpdate=!0);const A=i.normal_space==="OBJECT"?ua:_a;c.normalMapType!==A&&(c.normalMapType=A,c.needsUpdate=!0),c.normalScale.set(i.normal_strength,i.normal_strength*(i.normal_directx?-1:1))}i.emission?(c.emissive.setRGB(i.emission.color[0],i.emission.color[1],i.emission.color[2],vt),c.emissiveIntensity=i.emission.strength):(c.emissive.setRGB(0,0,0),c.emissiveIntensity=1);const p=i.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(l)&&(this.textureSamplers.delete(`${l}:roughness`),c.roughnessMap=null,this.roughnessTextureNames.delete(l),c.needsUpdate=!0);else{const y=this.textures.get(p);if(!y)throw new Error(`${an}: the presenter does not hold runtime image ${p} (revision ${i.roughness_texture.image.revision})`);const P=this.textureSamplers.get(`${l}:roughness`,y.texture,i.roughness_texture.extension,y.ready,i.roughness_texture.uv);c.roughnessMap!==P&&(c.roughnessMap=P,this.roughnessTextureNames.set(l,p),c.needsUpdate=!0)}const v=i.texture?.image.name??null;if(v===null)this.textureNames.has(l)&&(this.textureSamplers.delete(`${l}:color`),c.map=null,this.textureNames.delete(l),c.needsUpdate=!0);else{const y=this.textures.get(v);if(!y)throw new Error(`${an}: the presenter does not hold runtime image ${v} (revision ${i.texture.image.revision})`);const P=this.textureSamplers.get(`${l}:color`,y.texture,i.texture.extension,y.ready,i.texture.uv);c.map!==P&&(c.map=P,this.textureNames.set(l,v),c.needsUpdate=!0)}const g=i.graph?this.compiledGraph(i.graph):null,w=new Set;si(c,g,y=>{const P=this.textures.get(y.name);if(!P)throw new Error(`${an}: the presenter does not hold runtime image ${y.name} (revision ${y.revision})`);if(y.tiled){if(!P.udim)throw new Error(`${an}: runtime image ${y.name} arrived without its UDIM tiles`);return P.udim}const A=`${l}:graph:${y.node}`;w.add(A);const T=this.textureSamplers.get(A,P.texture,y.extension,P.ready),O=y.closest?Kn:Xt,E=y.closest?Kn:y.mipmap?me:Xt;return(T.magFilter!==O||T.minFilter!==E)&&(T.magFilter=O,T.minFilter=E,T.needsUpdate=!0),T},this.photograph);for(const y of this.graphSamplers.get(l)??[])w.has(y)||this.textureSamplers.delete(y);this.graphSamplers.set(l,w),this.materials.set(l,c)}for(const l of e.objects){let i=this.objects.get(l.id);const c=l.volume?this.volumes.get(l.volume).mesh:null;if((!i||(c?i!==c:!!i.isMesh!=(l.mesh!==null)))&&(i?.removeFromParent(),i=c??(l.mesh!==null?new Rt(this.meshes.get(l.mesh).geometry,this.fallback):new se),this.objects.set(l.id,i)),i.name=l.name,l.type==="CAMERA"||l.type==="LIGHT"||l.type==="EMPTY"?i.userData.volterOwnOverlay=!0:delete i.userData.volterOwnOverlay,i.matrixAutoUpdate=!1,i.matrix.set(...l.matrix.flat()),l.parent){const m=new Z().set(...s.get(l.parent).matrix.flat());i.matrix.premultiply(m.invert())}if(i.matrix.decompose(i.position,i.quaternion,i.scale),l.texspace?i.userData.blenderTexspace=l.texspace:delete i.userData.blenderTexspace,l.default_color!==void 0?i.userData.blenderDefaultColor=l.default_color:delete i.userData.blenderDefaultColor,l.mesh!==null){const m=i;m.geometry=this.meshes.get(l.mesh).geometry,m.material=l.materials.length?l.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,_i(m)}if(l.light){const m=this.lights.get(l.light)??null,d=Ir(e.lights[l.light],m);m&&m!==d&&(m.removeFromParent(),m.dispose()),d.parent!==i&&i.add(d),d.userData.volterOwnOverlay=!0,zr(d,i),this.lights.set(l.light,d)}}for(const l of e.objects){const i=this.objects.get(l.id),c=l.parent===null?this.root:this.objects.get(l.parent);i.parent!==c&&c.add(i)}for(const[l,i]of this.objects)a.has(l)||(i.removeFromParent(),this.objects.delete(l));for(const[l,i]of this.volumes)e.volumes[l]||(i.mesh.geometry.dispose(),i.mesh.material.dispose(),this.volumes.delete(l));for(const[l,i]of this.meshes)e.meshes[l]||(i.geometry.dispose(),this.meshes.delete(l));for(const[l,i]of this.materials)if(!e.materials[l]){for(const c of["normal","roughness","color"])this.textureSamplers.delete(`${l}:${c}`);for(const c of this.graphSamplers.get(l)??[])this.textureSamplers.delete(c);this.graphSamplers.delete(l),i.dispose(),this.materials.delete(l)}for(const[l,i]of this.lights)e.lights[l]||(i.removeFromParent(),i.dispose(),this.lights.delete(l));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{},images:{}},this.worldKey=JSON.stringify(e.world??null);const _=this.applyOverlays(e);_.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,..._]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const l of[...this.frameListeners])l();for(const l of this.followers)try{l.applyFrame(t)}catch{l.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,instancing:this.instances.inspect(),objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}drawStatistics(){return this.instances.inspect()}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[r,{signature:a,geometry:s}]of this.meshes){const f=l=>{const i=s.getAttribute(l);if(!i)return null;if(!(i instanceof dt))throw new Error(`Blender capture cannot copy interleaved ${l}`);return new Float32Array(i.array)},u=f("position");if(!u)throw new Error(`Blender capture mesh ${r} has no positions`);const _=s.getIndex();n.meshes[r]={hash:a,positions:u,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(s.userData.blenderUvChannels??{}).map(([l,i])=>{const c=f(`uv${i}`);if(!c)throw new Error(`Blender capture mesh ${r} is missing UV layer ${l}`);return{name:l,data:c}}),orco:s.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(s.userData.blenderAttributes??[]).map(l=>{const i=f(kt(l));if(!i)throw new Error(`Blender capture mesh ${r} is missing attribute ${l}`);return{name:l,data:i}}),indices:_?new Uint32Array(_.array):Uint32Array.from({length:u.length/3},(l,i)=>i),groups:s.groups.map(l=>({start:l.start,count:l.count,materialIndex:l.materialIndex??0}))}}for(const[r,{signature:a}]of this.volumes)n.volumes[r]=Se.parse(JSON.parse(a));const e=new Set(Object.values(n.materials).flatMap(r=>[r.texture?.image.name,r.roughness_texture?.image.name,r.normal_texture?.image.name,...Object.values(r.graph?.nodes??{}).map(a=>a.props.image?.name)].filter(a=>a!==void 0)));for(const r of e){const a=this.textures.get(r);if(!a)throw new Error(`Blender capture image ${r} is not resident`);if(a.encoded)n.images[r]={revision:a.revision,encoded:a.encoded.bytes.slice(),mime:a.encoded.mime,colorspace:a.encoded.colorspace};else{const s=a.texture.image?.data;if(!(s instanceof Uint8Array))throw new Error(`Blender capture image ${r} has no resident raster`);n.images[r]={revision:a.revision,width:a.width,height:a.height,rgba:s.slice(),colorspace:a.texture.colorSpace===Nn?"data":"sRGB",...a.udim?{tiles:a.udim.frame}:{}}}}return n}follow(){const t=new Fn;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(),r=new Fn;r.photograph=!0;let a=!1;const s=()=>{a||(a=!0,e?.dispose(),r.dispose(),r.root.removeFromParent())};try{r.applyFrame(t),this.root.updateWorldMatrix(!0,!1),r.root.matrix.copy(this.root.matrixWorld),r.root.updateMatrixWorld(!0)}catch(f){throw s(),f}return{effect:e,root:r.root,session:n.session,revision:n.revision,prepare:f=>{if(a)throw new Error("Blender capture snapshot is disposed");return r.setRendered(!0,f)},dispose:s}}createWorldVolumePass(){const t=Go(this.frame?.world);return t?new Oi(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 r=typeof n.session=="string"?n.session:null;r!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=r);const a=e;for(const[s,f]of Object.entries(a))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(s,f);for(const s of[...this.submittedMeshes.keys()])s in a||this.submittedMeshes.delete(s);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){this.instances.clear();for(const t of this.staged?.meshes.values()??[])t.geometry.dispose();this.staged=null;for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const Ts=new Fn;function Ce(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 Yn(o){const t=Ce(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function vs(o){const t=Ce(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function gs(o){return new Z().set(...o.flat())}function oe(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class xs{#n=new Map;#o=null;#a=null;#t=null;#s=null;#e=null;#i=null;#l=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#l.add(t),()=>this.#l.delete(t)}#f(){this.#u++;for(const t of[...this.#l])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,r=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:r,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((a,s)=>a+s.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#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.#s!==null?this.#s: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 r=[],a=new Set;let s=!1;for(const i of e.rigs){if(!i.object||!i.armature||!i.skinIndexBase64||!i.skinWeightBase64){i.reason&&r.push(i.reason);continue}a.add(i.object);const c=oe(i,e.frame);if(this.#n.get(i.object)?.signature===c)continue;const m=this.#d(t,i,e.frame,r);m&&(this.#n.get(i.object)?.skeleton.dispose(),this.#n.set(i.object,m),s=!0)}for(const[i,c]of[...this.#n])a.has(i)||(c.skeleton.dispose(),c.boneRoot.removeFromParent(),this.#n.delete(i),s=!0);this.#r++;const f=await n.clip(),u=this.#t,_=f?.action!==u?.action||f?.tracks.length!==u?.tracks.length||f?.clipStart!==u?.clipStart||f?.clipEnd!==u?.clipEnd;this.#t=f??null,f?.reason&&r.push(f.reason),f&&(_||s)&&this.#h(t,f,r);const l=this.#e?.snapshot().playbackState==="playing";f&&!l&&u?.frameCurrent!==f.frameCurrent&&(this.#c(f.frameCurrent),this.#e&&f.fps>0&&this.#e.seek(f.frameCurrent/f.fps)),this.#_=r,this.#f()}#d(t,n,e,r){const a=t.objectForBlenderName(n.object??""),s=t.objectForBlenderName(n.armature??"");if(!a||!s)return null;const f=a,u=f.geometry;if(!u)return null;const _=u.getAttribute("blenderVertex");if(!_)return r.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let l=0;for(let A=0;A<_.count;A++)l=Math.max(l,_.getX(A));if(l>=n.vertexCount)return r.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${l} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const i=vs(n.skinIndexBase64??""),c=Yn(n.skinWeightBase64??""),m=_.count,d=new Uint16Array(m*4),h=new Float32Array(m*4);for(let A=0;A<m;A++){const T=_.getX(A);for(let O=0;O<4;O++)d[A*4+O]=i[T*4+O]??0,h[A*4+O]=c[T*4+O]??0}u.setAttribute("skinIndex",new pa(d,4)),u.setAttribute("skinWeight",new Pt(h,4));const p=new it;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(A=>gs(A.pose)),w=new Map(n.bones.map((A,T)=>[A.name,T]));n.bones.forEach((A,T)=>{const O=new va;O.name=A.name,v.push(O);const E=A.parent===null?void 0:w.get(A.parent);(E===void 0?g[T].clone():g[E].clone().invert().multiply(g[T])).decompose(O.position,O.quaternion,O.scale),(E===void 0?p:v[E]).add(O)}),s.add(p);const y=new ga(u,f.material);y.name=f.name,y.matrixAutoUpdate=!1,y.matrix.copy(f.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale),y.userData=f.userData,y.frustumCulled=!1,t.replacePresentedObject(f,y),t.root.updateMatrixWorld(!0);const P=new xa(v);return y.bind(P,y.matrixWorld.clone()),n.constrainedBones?.length&&r.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&r.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:y,boneRoot:p,bones:v,skeleton:P,frame:e,signature:oe(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 r=n.armature?t.objectForBlenderName(n.armature):null;if(!r)return;const a=new Map;for(const i of this.#n.values())if(i.armature===n.armature)for(const c of i.bones)a.set(c.name,c);const s=[],f=new Set;for(const i of n.tracks){const c=a.get(i.bone);if(!c){f.add(i.bone);continue}const m=Yn(i.timeBase64),d=Yn(i.valueBase64),h=`${c.uuid}.${i.property}`;s.push(i.property==="quaternion"?new ba(h,Array.from(m),Array.from(d)):new ya(h,Array.from(m),Array.from(d)))}if(f.size&&e.push(`${n.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!s.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,_=new wa(r),l=_.clipAction(new Oa(n.action??"action",u,s));l.setLoop(Aa,Number.POSITIVE_INFINITY),l.play(),this.#o=_,this.#a=l,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.#s=e;const r=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.min(r-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.#i?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const s=this.#t,f=s?.fps||24;return{start:(s?.frameStart??1)/f,end:(s?.frameEnd??250)/f,fps:f}},seek:s=>this.seekSeconds(s)}),e=t.onSettled(()=>{this.writeBookmark()}),r=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#i=null};this.#i=r;const a=this.#t;return a&&a.fps>0&&t.seek(a.frameCurrent/a.fps),r}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#i?.(),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 ke=new xs;function Ss(o){return ke.subscribe(o)}function Ps(){return ke.version}export{ke as a,Ps as b,Ts as c,Ss as s};
|