@volter/game-editor 0.5.116 → 0.5.117
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 +2157 -2157
- package/dist/assets/{AssetBudgetPanel-Dbf2SYf_.js → AssetBudgetPanel-C3ktrntz.js} +3 -3
- package/dist/assets/{AudioViewer-beATuSby.js → AudioViewer-DZdZAy4A.js} +1 -1
- package/dist/assets/{CanvasBoardDocument-Cap6Wh9d.js → CanvasBoardDocument-DsCSciSC.js} +1 -1
- package/dist/assets/{CanvasSceneViewport-BypKEM4o.js → CanvasSceneViewport-DP0dTNXv.js} +1 -1
- package/dist/assets/{ColorInput--tFDjIXZ.js → ColorInput-BN6Sksjk.js} +1 -1
- package/dist/assets/{ColorPicker-DHizOJ5s.js → ColorPicker-B76LmE6h.js} +1 -1
- package/dist/assets/{EntityModelDocument-Dx26jeHk.js → EntityModelDocument-hrUqEuvd.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-CY9VCwk7.js → EnvironmentAssetDocument-BhAbBL9x.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-X8gxP319.js → GameplaySessionTimeline-O0K6MuzG.js} +1 -1
- package/dist/assets/{ImageViewer-CBh2kxXS.js → ImageViewer-BBx46cOu.js} +1 -1
- package/dist/assets/InspectorObjectPreview-cEL6iskI.js +1 -0
- package/dist/assets/{JsonAssetDocument-_UjntLTy.js → JsonAssetDocument-ZUCXmUBz.js} +1 -1
- package/dist/assets/{LiveModuleDocument-CtF2P_bg.js → LiveModuleDocument-DuY9SmFp.js} +1 -1
- package/dist/assets/{LutAssetDocument-DFZFNWs4.js → LutAssetDocument-DjxOl21m.js} +1 -1
- package/dist/assets/{ModelAssetDocument-CZ06IzXN.js → ModelAssetDocument-DwbuSNGD.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-DmSDJUnW.js → NonThreeAuthoringBootstrap-CYHVR-Hz.js} +1 -1
- package/dist/assets/{Object3DDocumentToolbar-M715xxzm.js → Object3DDocumentToolbar-BDHutCDl.js} +1 -1
- package/dist/assets/Object3DDocumentViewport-Dy6oCsqf.js +2 -0
- package/dist/assets/{Object3DPreview-ivhY0KDI.js → Object3DPreview-Dr9nj_z2.js} +1 -1
- package/dist/assets/{OnlineAssetDetail-a8HnENrt.js → OnlineAssetDetail-BG5XJ3Un.js} +1 -1
- package/dist/assets/{PlayBar-CYwOCu65.js → PlayBar-DUI9-ZXC.js} +1 -1
- package/dist/assets/{QuarksAssetDocument-B6hbgAb7.js → QuarksAssetDocument-DTiRvQPL.js} +1 -1
- package/dist/assets/{ReactCanvasControls-3q-B8L4X.js → ReactCanvasControls-XnnzrwCo.js} +1 -1
- package/dist/assets/{RootSelectionOverlay-CKAjQ_2N.js → RootSelectionOverlay-FMiu-poB.js} +1 -1
- package/dist/assets/{ShaderAssetDocument-BN1GdVJV.js → ShaderAssetDocument-4tRvE91q.js} +1 -1
- package/dist/assets/{ShadowEditor-D1aQDtbR.js → ShadowEditor-BpVAEirI.js} +1 -1
- package/dist/assets/{SourceAssetViewer-c5W-yZPP.js → SourceAssetViewer-3P0858z5.js} +1 -1
- package/dist/assets/{StageHost-DYLZucLa.js → StageHost-7UErMg6u.js} +2 -2
- package/dist/assets/{StoryPreviewMount-DS7ekT9x.js → StoryPreviewMount-BBlVAlRY.js} +1 -1
- package/dist/assets/{ThreeBoardDocument-C8YxTbGf.js → ThreeBoardDocument-DK53_YAX.js} +2 -2
- package/dist/assets/{ThreeIsolationSceneContent-BAoW1t7T.js → ThreeIsolationSceneContent-qdUEzAND.js} +1 -1
- package/dist/assets/{ToolObject3DPreview-C-D3UBd1.js → ToolObject3DPreview-DsWlZd8B.js} +1 -1
- package/dist/assets/{Toolbar-CazxV81t.js → Toolbar-whqYcmiS.js} +1 -1
- package/dist/assets/{TransientHint-wDIEfHFM.js → TransientHint-BKaDeHXM.js} +1 -1
- package/dist/assets/{VideoViewer-5vkApWH4.js → VideoViewer-CTEVUoaa.js} +1 -1
- package/dist/assets/{ViewportShadingMenu-CnchKpyA.js → ViewportShadingMenu-DtRQHmb8.js} +1 -1
- package/dist/assets/{active-ingest-DICtiguP.js → active-ingest-DutfA1v2.js} +2 -2
- package/dist/assets/{animation-clock-CRUxyOA5.js → animation-clock-DdjDOr9_.js} +1 -1
- package/dist/assets/{animation-mixers.service-DJzyo0lt.js → animation-mixers.service-BowFSgLp.js} +1 -1
- package/dist/assets/{animation-timeline.utility-DYiIUgUz.js → animation-timeline.utility-CgUv6Sm7.js} +1 -1
- package/dist/assets/{asset-budget-asset.menu-Cw6mcOPY.js → asset-budget-asset.menu-BpfhGqPG.js} +1 -1
- package/dist/assets/{asset-budget.action-BLWIrsLM.js → asset-budget.action-DhpViDZH.js} +1 -1
- package/dist/assets/{asset-budget.document-UgXeAjQd.js → asset-budget.document-d83SOYMm.js} +1 -1
- package/dist/assets/{asset-budget.menu-g_sbwXNP.js → asset-budget.menu-XBWaxw1e.js} +1 -1
- package/dist/assets/{asset-editor-persistence-Ceyww3DI.js → asset-editor-persistence-C57Ygr55.js} +1 -1
- package/dist/assets/{asset-loaders-CBVRUTVG.js → asset-loaders-C84nx9Q-.js} +1 -1
- package/dist/assets/{asset-preview-BceJnmGk.js → asset-preview-CfITAp9I.js} +1 -1
- package/dist/assets/{audio-unlock.service-C0VT23qm.js → audio-unlock.service-DnnTTLZ7.js} +1 -1
- package/dist/assets/{audio.utility-FN4yKTI6.js → audio.utility-kVrU3d_Z.js} +1 -1
- package/dist/assets/autoplay.service-S6u51gjV.js +1 -0
- package/dist/assets/{babylon-authoring-adapter-hfhdkCHm.js → babylon-authoring-adapter-CKIK8_RI.js} +1 -1
- package/dist/assets/{binding-resolver-C6c3OrFh.js → binding-resolver-Bw9NHH6D.js} +2 -2
- package/dist/assets/{blender-emscripten-engine-CRz1C2s0.js → blender-emscripten-engine-BYbXicWU.js} +1 -1
- package/dist/assets/{blender-node-editor.document-DM5zVBUd.js → blender-node-editor.document-CpmEWYqS.js} +1 -1
- package/dist/assets/{blender-properties-tab-BQI8b_9K.js → blender-properties-tab-BqzNQYYj.js} +1 -1
- package/dist/assets/blender-runtime-host-Ce-6lPKR.js +7 -0
- package/dist/assets/{blender-runtime-skin-BLtsPD7d.js → blender-runtime-skin-Bmj6NwqI.js} +47 -47
- package/dist/assets/{blender-runtime.document-DYZr0t5g.js → blender-runtime.document-fQm8jfOR.js} +1 -1
- package/dist/assets/{blender-screenshot.menu-ihS0AFro.js → blender-screenshot.menu-D6z6gPx2.js} +1 -1
- package/dist/assets/{blender-timeline.document-WOeljxpA.js → blender-timeline.document-COcMnV4P.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-BxOtAGYB.js → blender-uv-editor.document-CCldDOrb.js} +1 -1
- package/dist/assets/{blender-version.status-CaI0rCGo.js → blender-version.status-CQcek3bs.js} +1 -1
- package/dist/assets/{blender-wali-engine-BmVwcYs-.js → blender-wali-engine-DfoYluoA.js} +1 -1
- package/dist/assets/{blender.command-CqZ4hO44.js → blender.command-nx7fbZaN.js} +1 -1
- package/dist/assets/{board-guides-ZfL2tutw.js → board-guides-CJhpaM4Y.js} +1 -1
- package/dist/assets/{bridge.command-BXA3nd0c.js → bridge.command-CM2oB0DL.js} +3 -3
- package/dist/assets/{browserAll-CSr6ArTY.js → browserAll-YVE01_g6.js} +1 -1
- package/dist/assets/{build-player.document-CdXt3iSx.js → build-player.document-ZuyCnu8R.js} +1 -1
- package/dist/assets/{build-profiles.document-Drv1csxT.js → build-profiles.document-DFsJ688E.js} +1 -1
- package/dist/assets/{build-progress.status-CNH0-epW.js → build-progress.status-B5tu0uSU.js} +1 -1
- package/dist/assets/{build-session-BtZiPMGu.js → build-session-HBNiEqfG.js} +1 -1
- package/dist/assets/{build.action-0nAOIwql.js → build.action-B1HcItm2.js} +1 -1
- package/dist/assets/{build.command-qdyn1KdC.js → build.command-JnzmVI1I.js} +1 -1
- package/dist/assets/{build.header-Cum8ecj3.js → build.header-Scr4Om6R.js} +1 -1
- package/dist/assets/{build.menu-D6Ookwdq.js → build.menu-B27qwD29.js} +1 -1
- package/dist/assets/{build.service-D3Ym2E0M.js → build.service-j05ziYI4.js} +1 -1
- package/dist/assets/{camera-BqVwCVRM.js → camera-D7hXuRtx.js} +1 -1
- package/dist/assets/{camera-runtime.inspector-CX6ttEpR.js → camera-runtime.inspector-DaCMA860.js} +1 -1
- package/dist/assets/{canvas-design-mount-D7oNDZ-6.js → canvas-design-mount-Bk-EnFSI.js} +3 -3
- package/dist/assets/{canvas-entry-runtime-Cum9Sfti.js → canvas-entry-runtime-BvUkzblV.js} +2 -2
- package/dist/assets/{canvas-preview-frames-CfUNp0GH.js → canvas-preview-frames-DxAJx35P.js} +1 -1
- package/dist/assets/{canvas-story-capture.service-DNs72oVp.js → canvas-story-capture.service-Dcv8Ibb8.js} +2 -2
- package/dist/assets/{capability-coverage-CSrAi_w6.js → capability-coverage-K_0BAIJU.js} +1 -1
- package/dist/assets/{collaboration-presence-BRz5G2z4.js → collaboration-presence-CneIKoPa.js} +1 -1
- package/dist/assets/{collider-BpuJW3Bx.js → collider-BccZNdIw.js} +1 -1
- package/dist/assets/{component-board.service-Brmhzvhw.js → component-board.service-Cs4o_Pmv.js} +2 -2
- package/dist/assets/{component-board.service-Ce1OYEhQ.js → component-board.service-CvzV2CKA.js} +2 -2
- package/dist/assets/{component-board.service-Cx6Vdwed.js → component-board.service-D1jNfabq.js} +2 -2
- package/dist/assets/{component-contracts.service-DuQGitkp.js → component-contracts.service-V1W-u2S9.js} +1 -1
- package/dist/assets/{component-instance-root-BdSQQIvo.js → component-instance-root-h1Rflrqv.js} +1 -1
- package/dist/assets/{component-verbs.command-Ci0PUfUd.js → component-verbs.command-xKxDnGqP.js} +1 -1
- package/dist/assets/{component-verbs.service-D6C-vOOO.js → component-verbs.service-CWbkFEcM.js} +1 -1
- package/dist/assets/{config-JAVkaEhD.js → config-DX3-CpHt.js} +2 -2
- package/dist/assets/{configurations-CLvpoGjr.js → configurations-Cs8SnMrq.js} +1 -1
- package/dist/assets/{connection.status-pGohaJyS.js → connection.status-Dn0RTNEw.js} +1 -1
- package/dist/assets/{constraints.inspector-4mlea_AU.js → constraints.inspector-Cpy5rhJS.js} +1 -1
- package/dist/assets/{content-bounds-CZFWoFSx.js → content-bounds-DVWAzm9f.js} +1 -1
- package/dist/assets/{contract-system-adapters-DiyRC4_y.js → contract-system-adapters-qNph3R6b.js} +1 -1
- package/dist/assets/{coverage.service-B4pAWTw7.js → coverage.service-ByfW9X4H.js} +1 -1
- package/dist/assets/{create-runtime-Zmx4MCI4.js → create-runtime-CWPvbU_l.js} +1 -1
- package/dist/assets/{curve-MVj-SOwX.js → curve-C3wndxn2.js} +1 -1
- package/dist/assets/{data-asset-CC9AvVRe.js → data-asset-C2Z6itFZ.js} +1 -1
- package/dist/assets/{data-ref-Dl5jDfl3.js → data-ref-Ce8LtHGi.js} +1 -1
- package/dist/assets/{debug-bridge-JItNU8lT.js → debug-bridge-Bmj0Li8p.js} +1 -1
- package/dist/assets/{debug-registry-DKa8LTY_.js → debug-registry-D-FgdH_H.js} +1 -1
- package/dist/assets/{deferred-ingest-play-CZEvvkO2.js → deferred-ingest-play-B2wgrovp.js} +2 -2
- package/dist/assets/{design-time-canvas-mount-BpeeznvY.js → design-time-canvas-mount-DOkVlNVk.js} +2 -2
- package/dist/assets/{design-time-layers-C60_Xf2X.js → design-time-layers-M6o2CVXg.js} +1 -1
- package/dist/assets/{design-time-mount.service-DPDwzf9f.js → design-time-mount.service-CVFa4k-2.js} +2 -2
- package/dist/assets/{design-time-mount.service-3dQ4v63z.js → design-time-mount.service-DFHRGai1.js} +2 -2
- package/dist/assets/{design-time-react-mount-By07PxNQ.js → design-time-react-mount-BuIgYRLs.js} +1 -1
- package/dist/assets/{document-preview-three-CF-hDbI5.js → document-preview-three-CSJT6-30.js} +1 -1
- package/dist/assets/{dom-authoring-adapter-Cj8UXvPx.js → dom-authoring-adapter-BijfMbzl.js} +1 -1
- package/dist/assets/{draco3d-B5QIRw56.js → draco3d-B69Ry2Se.js} +1 -1
- package/dist/assets/{edit-mode-audio.service-XJUfcIXr.js → edit-mode-audio.service-DR6XWs99.js} +1 -1
- package/dist/assets/{edit-mode-authoring-DTTFx2bp.js → edit-mode-authoring-1VsqGvER.js} +1 -1
- package/dist/assets/{edit-mode-networking.service-x_6ziwSh.js → edit-mode-networking.service-Cc2mfOwp.js} +1 -1
- package/dist/assets/{editor-api-Bgvsl4UP.js → editor-api-CcAdYERA.js} +1 -1
- package/dist/assets/{editor-layers-D1gM7pSS.js → editor-layers-Bwn6K1Ky.js} +1 -1
- package/dist/assets/{editor-shell-store-COc4BwsI.js → editor-shell-store-Bw3pK03h.js} +1 -1
- package/dist/assets/{entity-object-C2U6guWr.js → entity-object-gqyR3fgx.js} +1 -1
- package/dist/assets/{extend-B9C-0M9e.js → extend-CjPoJR18.js} +1 -1
- package/dist/assets/{fork-menu-CKfY9LYE.js → fork-menu-YR2i30zs.js} +1 -1
- package/dist/assets/{frame-debugger-store-D0TjrfIL.js → frame-debugger-store-4_X7-Ujc.js} +1 -1
- package/dist/assets/{game-contract-seams-XRDfgacF.js → game-contract-seams-Bx5G1BLD.js} +1 -1
- package/dist/assets/{game-css-scope-transform-BPBRj-Rw.js → game-css-scope-transform-Drjn-mgv.js} +1 -1
- package/dist/assets/{game-document.service-BHPGNUSQ.js → game-document.service-DBdUvKzX.js} +1 -1
- package/dist/assets/{game-eval.command-BJMOwZgY.js → game-eval.command-D-na3sdH.js} +1 -1
- package/dist/assets/{game-module-access-yIBte4Jr.js → game-module-access-CSPO6YZ9.js} +1 -1
- package/dist/assets/{game-network-DEwe4pOU.js → game-network-CLJ7qTbE.js} +3 -3
- package/dist/assets/{gameplay-export-B3B2Yc8Q.js → gameplay-export-sJ3B_j4Z.js} +1 -1
- package/dist/assets/{gameplay-replay-vN5ZXBds.js → gameplay-replay-DZdbHEST.js} +1 -1
- package/dist/assets/{gameplay.command-DBRYXoMq.js → gameplay.command-D9nckU6s.js} +1 -1
- package/dist/assets/{generation-jobs-CJb-inIk.js → generation-jobs-DupRqWi-.js} +1 -1
- package/dist/assets/{generation.service-Ca3IRcU8.js → generation.service-CQNhtOYa.js} +1 -1
- package/dist/assets/{generations-Dkka4Ual.js → generations-nBks8sue.js} +1 -1
- package/dist/assets/{generations.status-BWCRr5xi.js → generations.status-DUTDEbmm.js} +1 -1
- package/dist/assets/{hierarchy-marks-BdH8DCZN.js → hierarchy-marks-CO_ecrau.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-DWssWqg0.js → hosted-asset-materialization-u30qTmDc.js} +1 -1
- package/dist/assets/{index-Z4__9awY.js → index-6bVz1BMz.js} +1 -1
- package/dist/assets/{index-h_0E6tqW.js → index-B20JTxwn.js} +1 -1
- package/dist/assets/{index-vvjTMrxq.js → index-Bs-JJBoj.js} +2 -2
- package/dist/assets/{index-Dygn0sPj.js → index-D1uSj66l.js} +1 -1
- package/dist/assets/{index-_4lOFm18.js → index-DhhhiiLJ.js} +1 -1
- package/dist/assets/{index-cwI3E5x_.js → index-Dt5jm3bx.js} +7 -7
- package/dist/assets/{index-Sgjfo7TO.js → index-cdOfmiK4.js} +1 -1
- package/dist/assets/{index-BRhDxUKc.js → index-p2Kb3X1e.js} +1 -1
- package/dist/assets/{index-D0VncU2A.js → index-ywphVnYA.js} +1 -1
- package/dist/assets/{inference-diagnostics-C7m9uCne.js → inference-diagnostics-B32cN1KY.js} +1 -1
- package/dist/assets/{ingest-boot-viewport-DghjwhyG.js → ingest-boot-viewport-Bs2ZgRaJ.js} +1 -1
- package/dist/assets/{ingest-siblings-FwrDC_sq.js → ingest-siblings-DwzuubQ3.js} +1 -1
- package/dist/assets/{ingest-source-persistence-CJ3_3GPD.js → ingest-source-persistence-CMpSUZnL.js} +1 -1
- package/dist/assets/{ingest.service-C7uVrf0E.js → ingest.service-BjmjdEXH.js} +1 -1
- package/dist/assets/{inspect-BGl6Ja2n.js → inspect-Br6bvKYF.js} +1 -1
- package/dist/assets/instances.command-CS1LShqz.js +1 -0
- package/dist/assets/{json-history-resource-5_j-rjkX.js → json-history-resource-_clmB965.js} +1 -1
- package/dist/assets/{layered-pick-C38Dg3HH.js → layered-pick-C_WeiIoE.js} +1 -1
- package/dist/assets/{light-BSuEFQJA.js → light-WOrPHDb-.js} +1 -1
- package/dist/assets/{live-project-verbs-DRwu-atm.js → live-project-verbs-C2jF4YJL.js} +1 -1
- package/dist/assets/{machine.document-BZh_K2Wu.js → machine.document-DTbenFr7.js} +1 -1
- package/dist/assets/{machines.finder-D_ACVCqm.js → machines.finder-BS0dBMs1.js} +1 -1
- package/dist/assets/{material-DJoYujnl.js → material-CD2DR79m.js} +1 -1
- package/dist/assets/{material-factory-v6uOi4ep.js → material-factory-B4aM15jS.js} +1 -1
- package/dist/assets/{mesh-C2HmcQvq.js → mesh-DTofF_go.js} +1 -1
- package/dist/assets/{model-asset-sections.service-BvN4LlLP.js → model-asset-sections.service-BxEhl0ko.js} +1 -1
- package/dist/assets/{model-inspection-B2sUacib.js → model-inspection-BEPkYxZm.js} +1 -1
- package/dist/assets/{model-thumbnail-BQxx0ytE.js → model-thumbnail-BT7oIq1o.js} +1 -1
- package/dist/assets/{models.finder-CTGBJoWI.js → models.finder-DaMe1qYN.js} +1 -1
- package/dist/assets/{module-mode-OTQA255s.js → module-mode-BddTykwB.js} +2 -2
- package/dist/assets/{mount-canvas-ingest-root-DA47q9Uw.js → mount-canvas-ingest-root-DXvGskTU.js} +2 -2
- package/dist/assets/{mount-dom-ingest-root-JiS5NqVw.js → mount-dom-ingest-root-CKhZMS30.js} +2 -2
- package/dist/assets/{mount-ingest-root-Dw57oXwA.js → mount-ingest-root-99LbxpVS.js} +2 -2
- package/dist/assets/{mount-manifest-BniG1qCM.js → mount-manifest-BSjGZJtM.js} +1 -1
- package/dist/assets/{mount-three-ingest-root-C3QkQGvw.js → mount-three-ingest-root-7ndKUA_v.js} +1 -1
- package/dist/assets/{mounted-authoring-CHfVd84w.js → mounted-authoring-B7_F5jnJ.js} +1 -1
- package/dist/assets/{mounted-story-viewport-source-CWZEioLI.js → mounted-story-viewport-source-DK5VrFqH.js} +1 -1
- package/dist/assets/{native-debug-module-D5dHsy3O.js → native-debug-module-739ES-Zm.js} +1 -1
- package/dist/assets/{navigation-uguj0NUZ.js → navigation-C6ZlGnSt.js} +1 -1
- package/dist/assets/{navmesh.menu-CzemX-l4.js → navmesh.menu-x5By6bBe.js} +1 -1
- package/dist/assets/{navmesh.service-D9LpqJt7.js → navmesh.service-Btopj44G.js} +1 -1
- package/dist/assets/network-observer.service-B_aXblWh.js +1 -0
- package/dist/assets/{network.utility-hAZvIbqE.js → network.utility-5MBcxgB_.js} +1 -1
- package/dist/assets/{object3d-document-session-registry-BaDS_dIc.js → object3d-document-session-registry-j6Y5JrzG.js} +2 -2
- package/dist/assets/{oid-transform-BZkR7Yy0.js → oid-transform-B7bZOfh0.js} +1 -1
- package/dist/assets/{particles-BW193Cd6.js → particles-BcTfNklT.js} +1 -1
- package/dist/assets/{pixi-authoring-adapter-SgIrgCNu.js → pixi-authoring-adapter-CnYwoVLZ.js} +1 -1
- package/dist/assets/{pixi-live-write-target-BbXVtgvB.js → pixi-live-write-target-3Q4ukIef.js} +1 -1
- package/dist/assets/{play.command-DdM4xXea.js → play.command-CsXpcIJO.js} +2 -2
- package/dist/assets/{presentation-DuOZlhmY.js → presentation-Dyo74fnC.js} +1 -1
- package/dist/assets/{product-S5Z1Mky9.js → product-D_CEDap_.js} +1 -1
- package/dist/assets/{profiler.action-CpSXlaQM.js → profiler.action-4pakkT-I.js} +1 -1
- package/dist/assets/{profiler.menu-HRdrsphA.js → profiler.menu-C3qMbQDL.js} +1 -1
- package/dist/assets/{profiler.utility-BePEXFZN.js → profiler.utility-DopaGlcK.js} +1 -1
- package/dist/assets/{project-authoring-session-JKr6_W1W.js → project-authoring-session-BErT1Vxt.js} +2 -2
- package/dist/assets/{properties-bone-constraints.inspector-C59_MQOE.js → properties-bone-constraints.inspector-DrwOv8lP.js} +1 -1
- package/dist/assets/{properties-bone.inspector-Cz3hdqDc.js → properties-bone.inspector-Cgm5HNYg.js} +1 -1
- package/dist/assets/{properties-collection.inspector-DIZqlCkk.js → properties-collection.inspector-BpRHp08N.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-4NNJhX2P.js → properties-constraints.inspector-Bcps7O7L.js} +1 -1
- package/dist/assets/{properties-data.inspector-DfSdRvY4.js → properties-data.inspector-Cbm0WQCb.js} +1 -1
- package/dist/assets/{properties-material.inspector-q6vlOvCW.js → properties-material.inspector-b2HVBeRi.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-zvTyqYuK.js → properties-modifiers.inspector-bJ2xlb_E.js} +1 -1
- package/dist/assets/{properties-object.inspector-BDN2KU0Q.js → properties-object.inspector-E1TqDSQi.js} +1 -1
- package/dist/assets/{properties-output.inspector-BfQLOwAp.js → properties-output.inspector-DvWo2xp8.js} +1 -1
- package/dist/assets/{properties-particles.inspector-gZqATvaI.js → properties-particles.inspector-D_QiAw0d.js} +1 -1
- package/dist/assets/{properties-physics.inspector-9HVOaSDz.js → properties-physics.inspector-BIh1EfkD.js} +1 -1
- package/dist/assets/{properties-render.inspector-B31WV2uY.js → properties-render.inspector-CQ_T14za.js} +1 -1
- package/dist/assets/{properties-scene.inspector-BlSscbxS.js → properties-scene.inspector-d3xZpohF.js} +1 -1
- package/dist/assets/{properties-texture.inspector-CVAl4l0X.js → properties-texture.inspector-CiodVE2E.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-BZqpjvFL.js → properties-view-layer.inspector-BTvjGbST.js} +1 -1
- package/dist/assets/{properties-world.inspector-TNFFBniv.js → properties-world.inspector-HjQ_XQWr.js} +1 -1
- package/dist/assets/{r3f-design-session-Ijx_yNs8.js → r3f-design-session-CgJHKbHk.js} +2 -2
- package/dist/assets/{r3f-physics-binding-CwWNMANp.js → r3f-physics-binding-Bs90cL2H.js} +1 -1
- package/dist/assets/{r3f-source-authoring-adapter-s-r4MkrL.js → r3f-source-authoring-adapter-Dz-2gR6C.js} +1 -1
- package/dist/assets/{react-canvas-navigation-DxAx4MJm.js → react-canvas-navigation-BuUlk_hY.js} +1 -1
- package/dist/assets/{react-inspector.service-RD_Sxtti.js → react-inspector.service-he9nhYSF.js} +1 -1
- package/dist/assets/{react-story-board-Dp5cp_Iu.js → react-story-board-DFX_3Eor.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-B1xHOqwk.js → react-three-rapier.esm-Cqb1QJsp.js} +1 -1
- package/dist/assets/{react-world-authoring-adapter-CzuuzDlq.js → react-world-authoring-adapter-4OOk2v75.js} +1 -1
- package/dist/assets/{realm-services-C1HKeom1.js → realm-services-B51BueDW.js} +1 -1
- package/dist/assets/{reflection-probe-capture.inspector-DazZpo1t.js → reflection-probe-capture.inspector-Cibd2Skj.js} +1 -1
- package/dist/assets/{registry-DZge95xx.js → registry-BJ0P13Qw.js} +1 -1
- package/dist/assets/{relative-import-specifier-DzgNQ7dA.js → relative-import-specifier-Bg1UDyTq.js} +1 -1
- package/dist/assets/{render-env-Dnugrr6a.js → render-env-DClqJsug.js} +1 -1
- package/dist/assets/{render-features-CNTnutX5.js → render-features-BgLAARMw.js} +1 -1
- package/dist/assets/{render-settings-GLj2l9c2.js → render-settings-TkRnwGvq.js} +1 -1
- package/dist/assets/{resolve-three-Dw2i2gJr.js → resolve-three-DNMNH9g9.js} +3 -3
- package/dist/assets/{root-seam-contract-D4EZR0ny.js → root-seam-contract-BAI8C8KI.js} +1 -1
- package/dist/assets/{run-selection-7OOPYa7h.js → run-selection-C62JWX8Y.js} +1 -1
- package/dist/assets/{scene-capture-C48aLvx2.js → scene-capture-Csu-9Z3v.js} +1 -1
- package/dist/assets/{scene-document.service-BSjpTVOA.js → scene-document.service-CXu3hwi9.js} +2 -2
- package/dist/assets/{scene-framing-DCf1HiTo.js → scene-framing-DgQMZG99.js} +1 -1
- package/dist/assets/{seeded-random-B-mScQnF.js → seeded-random-xhwosly5.js} +1 -1
- package/dist/assets/{setup-renderer-DJUuEvYi.js → setup-renderer-sNRGFHD3.js} +1 -1
- package/dist/assets/{source-object3d-authoring-adapter-DlVw_UMC.js → source-object3d-authoring-adapter-DiUz2ONX.js} +1 -1
- package/dist/assets/{source-persistence-backend-W13l583V.js → source-persistence-backend-DKdo7qA1.js} +1 -1
- package/dist/assets/{stage-keyboard-Bqs54vgI.js → stage-keyboard-CCAEPBds.js} +1 -1
- package/dist/assets/{stage-overlay-set-DE0rGtml.js → stage-overlay-set-BIT1H7YG.js} +1 -1
- package/dist/assets/{stage-presence-markers-CK1pdDpj.js → stage-presence-markers-Dde0uo4f.js} +1 -1
- package/dist/assets/{stage-transform-tools-CnU2Qt0l.js → stage-transform-tools-C5xuzlvB.js} +1 -1
- package/dist/assets/{standard-viewport-dressing-BQV2vgaB.js → standard-viewport-dressing-4mM0Zr-0.js} +1 -1
- package/dist/assets/{state-watch.action-DGybGeFG.js → state-watch.action-BocmVXfv.js} +1 -1
- package/dist/assets/{state-watch.menu-DMF1nlYu.js → state-watch.menu-VacWy0Ty.js} +1 -1
- package/dist/assets/{state-watch.utility-rn-TakzW.js → state-watch.utility-f6mj3xS-.js} +1 -1
- package/dist/assets/{story-capture-CpNpG_-6.js → story-capture-D3oUwSdi.js} +1 -1
- package/dist/assets/{story-documents-D1FSoWL7.js → story-documents-BvxE0Jgp.js} +1 -1
- package/dist/assets/{story-documents.service-COZvrZAd.js → story-documents.service-BPkgxZFz.js} +1 -1
- package/dist/assets/{story-documents.service-B9Jzg4v_.js → story-documents.service-Ci9hEaEi.js} +1 -1
- package/dist/assets/{story-media-presence-saryIUXk.js → story-media-presence-nuojiKa3.js} +1 -1
- package/dist/assets/{story-pixi-preview-BG4xiPLe.js → story-pixi-preview-MPFqGD8z.js} +1 -1
- package/dist/assets/{story-presentation-BvWO23xo.js → story-presentation-Bi6tUUJT.js} +1 -1
- package/dist/assets/{story-three-preview-CQpYU1NA.js → story-three-preview-CquJrBi1.js} +2 -2
- package/dist/assets/{studio-environment-DsrGHZw7.js → studio-environment-PbtbyxPv.js} +1 -1
- package/dist/assets/{surface-state-ctM53FaJ.js → surface-state-vm1S5q1D.js} +1 -1
- package/dist/assets/{syntactic-prop-specs-LlMfU08_.js → syntactic-prop-specs-CRrIsekh.js} +1 -1
- package/dist/assets/{team-playtest.service-BNZBlp8J.js → team-playtest.service-gQVOEk6C.js} +1 -1
- package/dist/assets/{three-BcLmUPYp.js → three-C_mp4XTZ.js} +1 -1
- package/dist/assets/{three-authoring-adapter-DCz_lkRH.js → three-authoring-adapter-D4_90yFr.js} +1 -1
- package/dist/assets/three-authoring.service-0XLcjtfj.js +2 -0
- package/dist/assets/{three-ingest-runtime-6kERQfjh.js → three-ingest-runtime-BPcTsDxh.js} +1 -1
- package/dist/assets/{three-integration-ChraRR2B.js → three-integration-CD3ATFnX.js} +2 -2
- package/dist/assets/three-integration.service-DjQ3BgqY.js +1 -0
- package/dist/assets/{three-projection-core-D_GxmEkL.js → three-projection-core-DbYmRPci.js} +1 -1
- package/dist/assets/{three-state-Bj8WnSM0.js → three-state-BPIytwjV.js} +1 -1
- package/dist/assets/{three-story-capture.service-DM8thM5D.js → three-story-capture.service-CFKkQGtX.js} +2 -2
- package/dist/assets/{three-story-model-DRBzTo1O.js → three-story-model-DJE_sYaC.js} +1 -1
- package/dist/assets/{three-viewport-presentation-BupW8FzC.js → three-viewport-presentation-CNXPLHEX.js} +1 -1
- package/dist/assets/{transform-mode-request-CiTBKrjK.js → transform-mode-request-B-gJ5g51.js} +1 -1
- package/dist/assets/{transport-strip-CHjUr-Ni.js → transport-strip-B36KBNDz.js} +1 -1
- package/dist/assets/transport.header-CAIoNhnT.js +1 -0
- package/dist/assets/{tuples-BNB2EaJa.js → tuples-D_IQElzZ.js} +1 -1
- package/dist/assets/{ui-board-document-CiCAnpSs.js → ui-board-document-BL31txjD.js} +2 -2
- package/dist/assets/{user-data-eVlClb7J.js → user-data-DZ8WeiSK.js} +1 -1
- package/dist/assets/{utility-view-state--YPK4ru9.js → utility-view-state-CJp6vkri.js} +1 -1
- package/dist/assets/{viewport-door-BBrTcgIg.js → viewport-door-Bdlxiiu3.js} +1 -1
- package/dist/assets/{viewport-root-presentation-DdiFVeYE.js → viewport-root-presentation-lfnmV2dZ.js} +1 -1
- package/dist/assets/{viewport-surface-status-DwJepreO.js → viewport-surface-status-BkWCfY-g.js} +1 -1
- package/dist/assets/{webworkerAll-Cqc-vl7O.js → webworkerAll-DrO32SxK.js} +1 -1
- package/dist/assets/worker-D3-3vOkS.js +2 -0
- package/dist/assets/{workspace-arrangement-DEFN30gj.js → workspace-arrangement-9RRX0-sM.js} +1 -1
- package/dist/assets/{world-documents-CBXLfrew.js → world-documents-BjqjhIv6.js} +1 -1
- package/dist/assets/{world-root-stage-binding-CeuiGsbv.js → world-root-stage-binding-BGWAd6qi.js} +1 -1
- package/dist/assets/{xstate-animation-binding-3Pz-9eXl.js → xstate-animation-binding-qDvqsOQe.js} +1 -1
- package/dist/assets/{xstate-animation-meta-BbP8Sc0d.js → xstate-animation-meta-DG39Stxz.js} +1 -1
- package/dist-node/cli.js +16 -16
- package/package.json +16 -16
- package/dist/assets/InspectorObjectPreview-DHjbqfqd.js +0 -1
- package/dist/assets/Object3DDocumentViewport-Cjdh6KAS.js +0 -2
- package/dist/assets/autoplay.service-C4L8_eL9.js +0 -1
- package/dist/assets/blender-runtime-host-_nisQfse.js +0 -7
- package/dist/assets/instances.command-C2phruKe.js +0 -1
- package/dist/assets/network-observer.service-DNyZmBh9.js +0 -1
- package/dist/assets/three-authoring.service-4Rv7jK5m.js +0 -2
- package/dist/assets/three-integration.service-CllR_o3-.js +0 -1
- package/dist/assets/transport.header-B0eUvg0x.js +0 -1
- package/dist/assets/worker-BXLmYZTK.js +0 -2
|
@@ -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 Ho,b as qo,L as Go}from"./LineSegments2-DN9pUfWA.js";import{bh as ot,cl as Xo,fo as x,cm as X,N as fn,a$ as bt,em as to,b4 as Ee,co as Tt,ey as Me,cp as yn,_ as ht,ej as Mt,fd as Lt,er as Ne,M as it,cj as ut,dp as gt,aV as Re,cW as Yo,aE as Zo,c7 as ft,j as Ie,f6 as Fe,fp as no,au as Sn,dw as En,bi as oo,aT as De,c1 as Vt,dd as Bn,eC as Un,e7 as gn,aw as nn,da as Ft,I as wn,as as ze,e8 as Ce,b0 as Qo,K as ke,B as $e,b9 as Le,Y as Ko,cw as ln,ed as Ve,cA as je,fx as Be,db as Jo,el as Ue,R as We,e6 as He,c0 as te,bX as qe,aI as uo,ao as Ge,eG as Xe,d3 as Ye,cs as Ze,ex as Qe,b5 as Ke,cO as On,cY as Je,eU as ta,cE as Wn,c5 as ne,at as na,ff as oa,eW as ea,f7 as aa,F as ra,ev as la,et as ia,dq as sa,fq as fa,n as ca,l as ua,cf as _a}from"./three.core-3arARmh6.js";import{u as P,v as F,w as N,c5 as q,c4 as U,c6 as M,e2 as $,_ as ma,mB as oe,d_ as Nt,x as j,kE as _t,e1 as ee,mC as B,dZ as da,mD as ha}from"./index-Dt5jm3bx.js";import{S as Dt}from"./three.module-BLhyNg0e.js";import{t as pa}from"./blender-runtime-host-Ce-6lPKR.js";const Hn=new Set;function vt(){for(const o of[...Hn])o()}function va(o){return Hn.add(o),()=>{Hn.delete(o)}}function qn(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const Zt=M().finite(),ga=P({name:N(),parent:N().nullable(),connected:q(),hide:q(),length:Zt,matrix:F($([Zt,Zt,Zt,Zt])).length(4),select:q(),active:q(),lockedWeight:q()}).strict(),xa=P({object:N(),displayType:U(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:q(),mode:N(),bones:F(ga)}).strict(),xt={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function ba(o){return new ht(o.r*o.r*.1,o.g*o.g*.1,o.b*o.b*.1)}const Mn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],_o=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],At=Math.SQRT1_2,ya=[[At,-At,0],[0,-At,-At],[-At,-At,0],[0,-At,At],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],wa=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],Oa=.05;function mo(o){return o.select||o.active?2:1}const Ta=10,Aa=4,Pa=`
|
|
3
3
|
attribute vec3 aSolid;
|
|
4
4
|
attribute vec3 aHint;
|
|
5
5
|
varying vec3 vColor;
|
|
@@ -10,13 +10,13 @@ import{a as Wo,b as Ho,L as qo}from"./LineSegments2-DN9pUfWA.js";import{bh as ot
|
|
|
10
10
|
vColor = mix(aHint, aSolid, fac * fac);
|
|
11
11
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`,Sa=`
|
|
14
14
|
varying vec3 vColor;
|
|
15
15
|
void main() {
|
|
16
16
|
gl_FragColor = vec4(vColor, 1.0);
|
|
17
17
|
#include <colorspace_fragment>
|
|
18
18
|
}
|
|
19
|
-
`;function St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Aa=new X,Pa=new x,vo=new Go;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Sa{constructor(){this.group=new ot,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],r=JSON.stringify(t);if(r===this.signature)return e;this.signature=r,this.clear();for(const a of Object.values(t)){const l=n(a.object);if(l===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 c=a.bones.filter(f=>!f.hide);if(c.length===0)continue;const u=a.displayType==="STICK"?this.buildStick(a,c,l):this.buildOctahedral(a,c,l);a.showInFront&&u.traverse(f=>{const i=f.material;i&&"depthTest"in i&&(i.depthTest=!1),f.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const r=new ot;r.name=`${t.object}:bones`;const a=[],l=[],c=[],u=[],f=[],i=[],s=[],_=[],d=[],h=[];for(const m of n){const p=go(e,m),v=po(t,m),g=va(v),b=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const P=Pa.set(...ga[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const M=new x(...En[O]).applyMatrix4(p);a.push(M.x,M.y,M.z),l.push(P.x,P.y,P.z),c.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const w=mo(m)===2?s:f,R=mo(m)===2?_:i;for(const[T,P]of xa){const O=new x(...En[T]).applyMatrix4(p),M=new x(...En[P]).applyMatrix4(p);w.push(O.x,O.y,O.z,M.x,M.y,M.z),R.push(b.r,b.g,b.b,b.r,b.g,b.b)}m.parent!==null&&m.connected||(d.push(p.clone()),h.push(v)),d.push(p.clone().multiply(Aa.makeTranslation(0,1,0))),h.push(v)}r.add(this.solidMesh(a,l,c,u)),f.length&&r.add(this.lines(f,i,1)),s.length&&r.add(this.lines(s,_,2));for(let m=0;m<d.length;m++)r.add(this.point(d[m],h[m]));return r}buildStick(t,n,e){const r=new ot;r.name=`${t.object}:bones`;const a=[],l=[],c=[],u=[];for(const f of n){const i=go(e,f),s=new x().setFromMatrixPosition(i),_=new x(0,1,0).applyMatrix4(i),d=ho(t,f),h=po(t,f);a.push(s.x,s.y,s.z,_.x,_.y,_.z),l.push(d.r,d.g,d.b,d.r,d.g,d.b),c.push(s.x,s.y,s.z,_.x,_.y,_.z),u.push(h.r,h.g,h.b,h.r,h.g,h.b)}return r.add(this.lines(a,l,ya)),r.add(this.lines(c,u,wa)),r}solidMesh(t,n,e,r){const a=new fn;a.setAttribute("position",new bt(t,3)),a.setAttribute("normal",new bt(n,3)),a.setAttribute("aSolid",new bt(e,3)),a.setAttribute("aHint",new bt(r,3));const l=new to({vertexShader:Oa,fragmentShader:Ta,side:Ae});this.disposables.push(a,l);const c=new Tt(a,l);return c.frustumCulled=!1,c}lines(t,n,e){const r=new Wo;r.setPositions(t),r.setColors(n);const a=new Ho({linewidth:e,vertexColors:!0});this.disposables.push(r,a);const l=new qo(r,a);return l.frustumCulled=!1,l}point(t,n){const e=new Pe(ba,12,8),r=new bn({color:n});this.disposables.push(e,r);const a=new Tt(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 xo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ea(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),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 N=Math.fround,On=N(2*Math.PI),Mn=N(1-1e-4),zt=(o,t)=>N(N(N(o[0]*t[0])+N(o[1]*t[1]))+N(o[2]*t[2])),rn=(o,t,n=1)=>o.map((e,r)=>N(e+N(t[r]*n))),Ma=(o,t)=>o.map((n,e)=>N(n-t[e]));function Kt(o){const t=N(Math.sqrt(zt(o,o)));return t>0?o.map(n=>N(n/t)):[0,0,0]}function Jt(o){const t=Math.abs(o)<1?N(1-N(1-Math.abs(o))):1;let n=N(N(.077980478)+N(t*N(-.02164095)));n=N(N(-.213300989)+N(t*n)),n=N(N(1.5707963267)+N(t*n));const e=N(N(Math.sqrt(N(1-t)))*n);return o<0?N(N(Math.PI)-e):e}function Na(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let r=0;r<3;r++){const a=(r+1)%3,l=(r+2)%3;n[r]=N(n[r]+N(N(t[a]-e[a])*N(t[l]+e[l])))}t=e}return n}function Ra(o){const t=[],n=[],e=(h,m)=>h<m?`${h}:${m}`:`${m}:${h}`,r=new Map((o.edge_order??[]).map(([h,m],p)=>[e(h,m),p])),a=new Set((o.sharp??[]).map(([h,m])=>e(h,m))),l=new Map;for(const[h,m]of o.f.entries()){const p=t.length,v=Ea(Na(m.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<m.length;g++){const b=e(m[g],m[(g+1)%m.length]);r.has(b)||r.set(b,r.size);const w=o.face_edges?.[h]?.[g]??r.get(b),R=t.length;t.push({vertex:m[g],face:h,edge:w,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=l.get(w)??[];T.push(R),l.set(w,T)}}const c=new Map,u=new Map;for(const[h,m]of l){if(m.length!==2||o.edge_sharp?.[h])continue;const[p,v]=m,g=t[p],b=t[v];!o.s?.[g.face]||!o.s?.[b.face]||g.vertex!==t[b.next].vertex||b.vertex!==t[g.next].vertex||!o.edge_sharp&&a.has(e(g.vertex,b.vertex))||(u.set(p,b.next),c.set(b.next,p),u.set(v,g.next),c.set(g.next,v))}const f=[],i=[],s=[],_=[],d=(h,m)=>Kt(Ma(o.v[t[t[h][m]].vertex],o.v[t[h].vertex]));for(let h=0;h<t.length;h++){if(i[h]!==void 0)continue;let m=h;const p=new Set([m]);for(;u.has(m)&&!p.has(u.get(m));)m=u.get(m),p.add(m);u.has(m)&&(m=Math.min(...p));const v=[m];for(;c.has(v.at(-1))&&c.get(v.at(-1))!==m;)v.push(c.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[m].face];else{for(const M of v)g=rn(g,n[t[M].face],Jt(zt(d(M,"prev"),d(M,"next"))));g=Kt(g)}const b=d(m,"next"),w=v.at(-1),R=d(w,"prev"),T=zt(b,g),P=zt(R,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<Mn&&Math.abs(P)<Mn){const M=v.length>1?v.map(pt=>d(pt,"next")):[];M.length&&t[t[w].prev].edge!==t[m].edge&&M.push(R),O.alpha=M.length?N(M.reduce((pt,y)=>N(pt+Jt(zt(y,g))),0)/M.length):N(N(Jt(T)+Jt(P))/2),O.reference=Kt(rn(b,g,-T));const C=g,V=O.reference;O.ortho=Kt([N(N(C[1]*V[2])-N(C[2]*V[1])),N(N(C[2]*V[0])-N(C[0]*V[2])),N(N(C[0]*V[1])-N(C[1]*V[0]))]);const H=Kt(rn(R,g,-P)),Q=zt(O.reference,H),tt=Jt(Q);O.beta=Q<Mn?zt(O.ortho,H)<0?N(On-tt):tt:On}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)i[M]=f.length;f.push(v),s.push(O),_.push(g)}return{corners:t,fans:f,fanOf:i,spaces:s,faceNormals:n,fanNormals:_}}function Ia(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=N(t[0]/32767),e=N(t[1]/32767),r=N((n>0?o.alpha:N(On-o.alpha))*n),a=N((e>0?o.beta:N(On-o.beta))*e);let l=o.normal.map(c=>N(c*N(Math.cos(r))));return l=rn(l,o.reference,N(N(Math.sin(r))*N(Math.cos(a)))),e!==0&&(l=rn(l,o.ortho,N(N(Math.sin(r))*N(Math.sin(a))))),l}function ee(o,t){if(!t)return null;const{corners:n,fans:e,spaces:r}=Ra(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const a=new Array(n.length);for(const[l,c]of e.entries()){const u=c.reduce((i,s)=>{const _=t.data[s];return[i[0]+_[0],i[1]+_[1]]},[0,0]),f=Ia(r[l],u.map(i=>Math.trunc(i/c.length)));for(const i of c)a[i]=f}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,l)=>{const c=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:l;return t.data[c]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Nn={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},Fa=1e-6;function za(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],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 Da=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),bo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ca(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],r=o[(n+1)%o.length];t+=e.x*r.y-r.x*e.y}return t}function yo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let r=0;for(const[a,l,c]of o){const u=Da(t[a],t[l],t[c]);if(u*e<0)return!1;r+=Math.abs(u)}return Math.abs(r-Math.abs(n))<=Fa*Math.abs(n)}function ka(o){const t=o.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=za(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:bo(t),sound:!1,method:"fan"};const r=n.clone().divideScalar(e),a=Math.abs(r.x)<.9?new x(1,0,0):new x(0,1,0),l=new x().crossVectors(a,r).normalize(),c=new x().crossVectors(r,l),u=o[0],f=o.map(d=>{const h=d.clone().sub(u);return new $t(h.dot(l),h.dot(c))}),i=Ca(f),s=bo(t);if(yo(s,f,i))return{triangles:s,sound:!0,method:"fan"};let _=[];try{_=Se.triangulateShape(f,[]).map(d=>[d[0],d[1],d[2]])}catch{return{triangles:s,sound:!1,method:"fan"}}return yo(_,f,i)?{triangles:_,sound:!0,method:"earcut"}:{triangles:_.length>0?_:s,sound:!1,method:_.length>0?"earcut":"fan"}}const $a=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Rn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function In(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[Rn(Number(t[n*4])),Rn(Number(t[n*4+1])),Rn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function ae(o,t){return o.filter(n=>$a.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),r=[0,0,0,0];return{name:n.name,domain:n.domain,read:(a,l,c)=>n.domain==="POINT"?In(n.type,e,a):n.domain==="CORNER"?l===void 0?r:In(n.type,e,l):c===void 0?r:In(n.type,e,c)}})}function re(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,r=o.cornerVerts,a=e[n];let l=t;for(let y=0;y<n;y++)l+=(e[y+1]-e[y]-2)*3;const c=new Uint32Array(a),u=new Uint8Array(a),f=new Uint8Array(t),i=new Uint32Array(a);let s=!1;for(let y=0;y<n;y++)if(o.smooth(y)){s=!0;break}const _=(y,L)=>t<94906265?Math.min(y,L)*t+Math.max(y,L):`${Math.min(y,L)}:${Math.max(y,L)}`,d=new Map,h=new Set;for(const[y,L]of o.sharp)h.add(_(y,L));if(o.edges)for(const[y,L]of o.edges){if(y===L)throw new Error("Runtime mesh edge needs distinct vertices");d.set(_(y,L),-1)}const m=y=>{for(;i[y]!==y;)i[y]=i[i[y]],y=i[y];return y},p=(y,L)=>{const D=m(y),Y=m(L);i[Math.max(D,Y)]=Math.min(D,Y)};for(let y=0;y<n;y++){const L=e[y],D=e[y+1]-L,Y=o.smooth(y)?1:0;for(let Z=0;Z<D;Z++){const k=L+Z;f[r[k]]=1,c[k]=L+(Z+1)%D,u[k]=Y,i[k]=k}}for(let y=0;y<a;y++){const L=c[y],D=r[y],Y=r[L],Z=_(D,Y),k=d.get(Z);if(k!==void 0&&k>=0&&u[y]&&u[k]&&!h.has(Z)){const G=c[k];p(y,r[k]===D?k:G),p(L,r[k]===D?G:k)}(k===void 0||k<0||!u[k]&&u[y])&&d.set(Z,y)}const v=o.uv,g=new Float32Array(l*3),b=new Float32Array(l*2),w=new Uint32Array(l),R=(o.uvLayers??[]).map(y=>({...y,data:new Float32Array(l*2)})),T=(o.attributeLayers??[]).map(y=>({...y,data:new Float32Array(l*4)})),P=o.orco?new Float32Array(l*3):null,O=new Uint32Array(l),M=new Map,C=[],V=o.normals||o.cornerNormal?new Float32Array(l*3):null;let H=0,Q=0;const tt=(y,L,D,Y,Z)=>{const k=H++;for(const G of T)G.data.set(G.read(y,Y,Z),k*4);if(P)for(let G=0;G<3;G++)P[k*3+G]=o.orco[y*3+G]*.5+.5;if(w[k]=y,o.co(y).toArray(g,k*3),L&&b.set(L,k*2),D&&V.set(D,k*3),Y!==void 0)for(const G of R)G.data.set(G.read(Y),k*2);return k},pt=(y,L)=>{const D=v?.(y),Y=o.cornerNormal?[o.cornerNormal[y*3],o.cornerNormal[y*3+1],o.cornerNormal[y*3+2]]:o.normals?.[y];if(!s)return tt(r[y],D,Y,y,L);const Z=`${u[y]?m(y):y}${D?`:${D[0]}:${D[1]}`:""}${Y?`:n${Y.join(":")}`:""}${R.map(G=>":"+G.read(y).join(":")).join("")}${T.map(G=>G.domain==="POINT"?"":":"+Array.from(G.read(r[y],y,L)).join(":")).join("")}`;let k=M.get(Z);return k===void 0&&(k=tt(r[y],D,Y,y,L),M.set(Z,k)),k};for(let y=0;y<n;y++){const L=Q,D=e[y],Y=e[y+1]-D,Z=[];for(let Yt=0;Yt<Y;Yt++)Z.push(o.co(r[D+Yt]));for(const Yt of ka(Z).triangles)for(const Te of Yt)O[Q++]=pt(D+Te,y);const k=o.material(y),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let y=0;y<t;y++)f[y]||tt(y);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?b.slice(0,H*2):null,uvLayers:R.map(y=>({name:y.name,data:y.data.slice(0,H*2)})),attributeLayers:T.map(y=>({name:y.name,data:y.data.slice(0,H*4)})),orco:P?P.slice(0,H*3):null,indices:O.slice(0,Q),sourceVertex:w.slice(0,H),groups:C}}function Vt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function qn(o){const t=new fn;t.setAttribute("position",new it(o.positions,3)),t.setAttribute("uv",new it(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new it(o.indices,1));const n=Object.create(null);for(const[e,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 it(r.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(Vt(e.name),new it(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new it(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new it(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new it(o.sourceVertex,1)),t}function La(o,t){const n=o.co.length/3,e=o.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),r=o.renderUv??o.activeUv??e[0]?.name,a=e.find(m=>m.name===r);if(r&&!a)throw new Error(`Runtime UV map ${r} is missing`);const l=a?a.data:null,c=o.edge.length/2,u=new Array(c);for(let m=0;m<c;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const f=[];for(let m=0;m<c;m++)o.edgeSharp[m]===1&&f.push(u[m]);const i=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),s=i?{v:Array.from({length:n},(m,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:f,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,_=i?{type:i.type,domain:i.domain,data:Array.from({length:i.data.length/Nn[i.type].size},(m,p)=>Array.from({length:Nn[i.type].size},(v,g)=>Number(i.data[p*Nn[i.type].size+g])))}:void 0,d=new x,h={vertexCount:n,normals:s?ee(s,_):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>d.set(o.co[m*3],o.co[m*3+1],o.co[m*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:m=>o.smooth[m]===1,material:m=>o.material[m],edges:u,sharp:f,uv:l?m=>[l[m*2],l[m*2+1]]:null,uvLayers:e.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:ae(o.attributes,m=>m)};return{...re(h),hash:t}}function Va(o){const t=o.v.map(s=>new x(...s)),n=s=>{const _=t[s];if(!_)throw new Error(`Runtime mesh vertex ${s} is missing`);return _},e=new Uint32Array(o.f.length+1);o.f.forEach((s,_)=>{if(s.length<3||new Set(s).size!==s.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[_+1]=e[_]+s.length});const r=new Uint32Array(e[o.f.length]);o.f.forEach((s,_)=>s.forEach((d,h)=>{n(d),r[e[_]+h]=d}));for(const[s,_]of o.edge_order??o.e??[])n(s),n(_);const a={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:r.length};for(const s of o.attributes??[])if(s.domain!=="EDGE"&&s.data.length!==a[s.domain])throw new Error(`Runtime attribute ${s.name} has ${s.data.length} values for ${a[s.domain]} ${s.domain} elements`);const l=(o.attributes??[]).filter(s=>s.type==="FLOAT2"&&s.domain==="CORNER"),c=o.render_uv??o.active_uv??l[0]?.name,u=l.find(s=>s.name===c);if(c&&!u)throw new Error(`Runtime UV map ${c} is missing`);const f=u?.data,i={vertexCount:t.length,normals:ee(o,o.attributes?.find(s=>s.name==="custom_normal")),co:n,starts:e,cornerVerts:r,smooth:s=>!!o.s?.[s],material:s=>o.m?.[s]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:f?s=>f[s]:null,uvLayers:l.map(s=>({name:s.name,read:_=>s.data[_]})),attributeLayers:ae(o.attributes??[],s=>Array.from(s).flat())};return qn(re(i))}const sn=1.5707963267948966,Dt=6.283185307179586,le=.3183098861837067,ie=.0795774715459476,ja=.3,Ba=ie,Ua=3/16*le,Gn=.8,wo=Gn*Gn,Ct=6371,se=100,Xn=Ct+se,Oo=64,To=64,et=256,Nt=64,Wa=[1.679,1.828,1.986,1.307],Ha=[.006605,.01067,.01842,.03156],qa=[3472e-28,3914e-28,1349e-28,1103e-29],Ga=334.5,Xa=[28722e-28,46168e-28,79706e-28,13578e-27],Ya=[15908e-26,17711e-26,20942e-26,24033e-26],Ao=13681e16,Za=2e6,Qa=.73,Fn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],Tn=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),Ka=o=>Math.sqrt(Math.max(o,0)),fe=o=>[-Math.sqrt(1-o*o),0,o];function Yn(o,t,n,e,r,a,l){const c=o*e+t*r+n*a,u=o*o+t*t+n*n-l*l;if(u>0&&c>0)return-1;const f=c*c-u;return f<0?-1:f>=c*c?-c+Math.sqrt(f):-c-Math.sqrt(f)}const Ja=o=>Ua*(1+Tn(o));function tr(o){const t=1+wo+2*Gn*o;return ie*(1-wo)/(t*Math.sqrt(t))}const nr=o=>Ao*(Math.exp(-o/Qa)+Za/Ao);function eo(o,t){let n=o%Dt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=sn||n<=-sn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Dt,e<0&&(e+=Dt),e=Dt-e,[n,e]}class or{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Nt*et*4)}coefficients(t,n){const e=nr(t)*this.aerosol,r=Math.log(Math.max(t,1e-4)),a=378547397e12*Math.exp(-Tn(r-3.22261)*5.55555555-r),l=Math.exp(-.07771971*t**1.16364243);for(let c=0;c<4;c++)n[c]=Xa[c]*e,n[4+c]=Ya[c]*e,n[8+c]=qa[c]*Ga*a*this.ozone,n[12+c]=Ha[c]*l*this.air}transmittance(t,n,e){const[r,a,l]=fe(t),c=Ot(Ct,Xn,n),f=Yn(0,0,c,r,a,l,Xn)/Oo,i=[0,0,0,0],s=new Float64Array(16);for(let _=0;_<Oo;_++){const d=(_+.5)*f,h=r*d,m=a*d,p=c+l*d,v=Math.max(Math.hypot(h,m,p)-Ct,0);this.coefficients(v,s);for(let g=0;g<4;g++)i[g]+=(s[g]+s[4+g]+s[8+g]+s[12+g])*f}for(let _=0;_<4;_++)e[_]=Math.exp(-i[_])}precompute(){const t=new Float64Array(4);for(let n=0;n<Nt;n++)for(let e=0;e<et;e++){const r=e/(et-1),a=n/(Nt-1);this.transmittance(r*2-1,a,t);const l=(n*et+e)*4;for(let c=0;c<4;c++)this.lut[l+c]=t[c]}}lookup(t,n,e){const r=(et-1)*on(t*.5+.5),a=(Nt-1)*on(n),l=Math.trunc(r),c=Math.trunc(a),u=Math.min(l+1,et-1),f=Math.min(c+1,Nt-1),i=r-l,s=a-c,_=(c*et+l)*4,d=(c*et+u)*4,h=(f*et+l)*4,m=(f*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[_+p],this.lut[d+p],i),Ot(this.lut[h+p],this.lut[m+p],i),s)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),r=Math.trunc(e),a=Math.min(r+1,et-1),l=e-r;for(let c=0;c<4;c++)n[c]=Ot(this.lut[r*4+c],this.lut[a*4+c],l)}lookupToSun(t,n){const e=(Nt-1)*on(t),r=Math.trunc(e),a=Math.min(r+1,Nt-1),l=e-r,c=et-1;for(let u=0;u<4;u++)n[u]=Ot(this.lut[(r*et+c)*4+u],this.lut[(a*et+c)*4+u],l)}inscattering(t,n,e,r,a,l,c,u,f){const i=-(a*t[0]+l*t[1]+c*t[2]),s=Ja(i),_=tr(i),d=u/To,h=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),b=new Float64Array(4),w=[0,0,0,0],R=[1,1,1,1];for(let T=0;T<To;T++){const P=(T+.5)*d,O=n+a*P,M=e+l*P,C=r+c*P,V=Math.hypot(O,M,C),H=Math.max(V-Ct,0),Q=H/se,tt=(O*t[0]+M*t[1]+C*t[2])/V;this.coefficients(H,h),this.lookup(tt,Q,m);const pt=Dt*(1-Ka(1-Tn(Ct/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,b);const y=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let D=0;D<4;D++){const Y=g[D]/b[D],Z=Ba*pt*(ja*le)*v[D]*Y*tt;p[D]=.02*L[D]*y+Z}for(let D=0;D<4;D++){const Y=h[D]+h[4+D]+h[8+D]+h[12+D],Z=Wa[D]*(h[12+D]*(s*m[D]+p[D])+h[4+D]*(_*m[D]+p[D])),k=Math.exp(-d*Y),G=Math.max(Y,1e-7);w[D]+=R[D]*((Z-Z*k)/G),R[D]*=k}}for(let T=0;T<4;T++)f[T]=w[T]}}const st=512,qt=256;function ce(o,t){const n=new or(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,r=fe(Math.cos(sn-t)),a=new Float32Array(st*qt*3),l=st/2,c=new Float64Array(4);for(let u=0;u<qt;u++)for(let f=0;f<l;f++){const i=(f+.5)/st,s=(u+.5)/qt,_=Dt*i,d=s*2-1,h=Math.sign(d)*Tn(d)*sn,m=Math.cos(h)*Math.cos(_),p=Math.cos(h)*Math.sin(_),v=Math.sin(h),g=Ct+e,b=Yn(0,0,g,m,p,v,Xn),w=Yn(0,0,g,m,p,v,Ct),R=w<0?b:w;n.inscattering(r,0,0,g,m,p,v,R,c);let T=0,P=0,O=0;for(let V=0;V<4;V++)T+=Fn[V][0]*c[V],P+=Fn[V][1]*c[V],O+=Fn[V][2]*c[V];const M=(u*st+f)*3;a[M]=T,a[M+1]=P,a[M+2]=O;const C=(u*st+(st-f-1))*3;a[C]=T,a[C+1]=P,a[C+2]=O}return a}function er(o){const[t]=eo(o.sunElevation,o.sunRotation);return ce(o,t)}function ao(o){const[t]=eo(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const ar=6,Wt=new Map;function rr(o){return Wt.has(ao(o))}function ue(o,t){Wt.set(ao(o),t),Wt.size>ar&&Wt.delete(Wt.keys().next().value)}function lr(o){const[t,n]=eo(o.sunElevation,o.sunRotation),e=ao(o);let r=Wt.get(e);r===void 0&&(r=ce(o,t),ue(o,r));const a=new x;return l=>{const c=Math.hypot(l.x,l.y),u=Math.atan2(l.z,c);let i=(Math.atan2(l.x,l.y)+Math.PI+n)/Dt;i-=Math.floor(i);const s=Math.abs(u),_=on(Math.sqrt(s/sn)*Math.sign(u)*.5+.5),d=i*st-.5,h=_*qt-.5,m=Math.floor(d),p=Math.floor(h),v=d-m,g=h-p,b=C=>(C%st+st)%st,w=C=>C<0?0:C>qt-1?qt-1:C,R=b(m),T=b(m+1),P=w(p),O=w(p+1),M=[0,0,0];for(let C=0;C<3;C++){const V=Ot(r[(P*st+R)*3+C],r[(P*st+T)*3+C],v),H=Ot(r[(O*st+R)*3+C],r[(O*st+T)*3+C],v);M[C]=Ot(V,H,g)}return a.set(yt[0][0]*M[0]+yt[0][1]*M[1]+yt[0][2]*M[2],yt[1][0]*M[0]+yt[1][1]*M[1]+yt[1][2]*M[2],yt[2][0]*M[0]+yt[2][1]*M[1]+yt[2][2]*M[2])}}let Pt=null,cn=!1,ir=0;const en=new Map;function sr(){if(Pt||cn)return Pt;if(typeof Worker>"u")return cn=!0,null;try{Pt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return Pt.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,r=en.get(t);r&&(en.delete(t),n?r.resolve(n):r.reject(new Error(e??"sky worker returned nothing")))},Pt.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),Pt?.terminate(),Pt=null,cn=!0},Pt}function fr(o){const t=sr();if(!t)return Promise.resolve(er(o));const n=ir++,e={id:n,parameters:o};return new Promise((r,a)=>{en.set(n,{resolve:r,reject:a}),t.postMessage(e)})}function cr(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 zn=(o,t)=>t!==0?o/t:0,Po=o=>Math.min(1,Math.max(-1,o)),So=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},_e={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:zn,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:zn(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(zn(o,t))*t,WRAP:(o,t,n)=>t!==n?o-(t-n)*Math.floor((o-n)/(t-n)):n,PINGPONG:(o,t)=>{if(t===0)return 0;const n=(o-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:o=>Math.asin(Po(o)),ARCCOSINE:o=>Math.acos(Po(o)),ARCTANGENT:Math.atan,ARCTAN2:(o,t)=>o===0&&t===0?0:Math.atan2(o,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(o,t,n)=>+(o===t||Math.abs(o-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(o,t,n)=>o*t+n,SMOOTH_MIN:So,SMOOTH_MAX:(o,t,n)=>-So(-o,-t,n)};function nt(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const 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=nt(o.vector,t),a={type:o.gradient_type},l=new x;return c=>{const u=r(c),f=typeof u=="number"?u:u.x,i=typeof u=="number"?u:u.y,s=typeof u=="number"?u:u.z,_=ut.clamp(cr(f,i,s,a),0,1);return o.output==="Fac"?_:l.setScalar(_)}}if(o.kind==="to_float"){const r=nt(o.value,t);return a=>{const l=r(a);return typeof l=="number"?l:Math.fround(o.source_type==="RGBA"?l.x*.212639+l.y*.7151687+l.z*.0721923:(l.x+l.y+l.z)/3)}}if(o.kind==="math"){const r=o.inputs.map(c=>nt(c,t)),a=_e[o.operation],l=(c,u)=>{const f=r[c]?.(u)??0;if(typeof f!="number")throw new Error("World Math needs scalar inputs");return Math.fround(f)};return c=>{const u=Math.fround(a(l(0,c),l(1,c),l(2,c)));return o.clamp?ut.clamp(u,0,1):u}}if(o.kind==="mix_color"){const r=nt(o.factor,t),a=nt(o.a,t),l=nt(o.b,t),c=new x,u=new x;return f=>{const i=r(f);if(typeof i!="number")throw new Error("World color Mix needs a scalar factor");const s=a(f);typeof s=="number"?c.setScalar(s):c.copy(s);const _=l(f);return typeof _=="number"?u.setScalar(_):u.copy(_),c.lerp(u,o.clamp_factor?ut.clamp(i,0,1):i),o.clamp_result&&c.clampScalar(0,1),c}}if(o.kind==="sky"){const r=lr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return a=>r(a)}if(o.kind==="mapping"){const r=nt(o.vector,t),a=new x(...o.location),l=new x(...o.scale),c=new gt().setFromEuler(new Ee(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=c.clone().invert(),f=new x(...o.scale.map(s=>s===0?0:1/s)),i=new x;return s=>{const _=r(s);switch(typeof _=="number"?i.setScalar(_):i.copy(_),o.vector_type??"POINT"){case"TEXTURE":return i.sub(a).applyQuaternion(u).multiply(f);case"VECTOR":return i.multiply(l).applyQuaternion(c);case"NORMAL":return i.multiply(f).applyQuaternion(c).normalize();case"POINT":return i.multiply(l).applyQuaternion(c).add(a)}}}if(o.kind==="map_range"){const r=nt(o.value,t),a=nt(o.from_min,t),l=nt(o.from_max,t),c=nt(o.to_min,t),u=nt(o.to_max,t),f=nt(o.steps,t),i=(d,h)=>{const m=d(h);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},s=o.interpolation,_=o.clamp;return d=>{const h=i(r,d),m=i(a,d),p=i(l,d),v=i(c,d),g=i(u,d);if(m===p)return 0;let b;if(s==="STEPPED"){const R=i(f,d),T=(h-m)/(p-m);b=R>0?Math.floor(T*(R+1))/R:0}else if(s==="SMOOTHSTEP"||s==="SMOOTHERSTEP"){const R=ut.clamp((h-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=s==="SMOOTHSTEP"?R*R*(3-2*R):R*R*R*(R*(R*6-15)+10);b=m>p?1-T:T}else b=(h-m)/(p-m);const w=v+b*(g-v);return _?v>g?ut.clamp(w,g,v):ut.clamp(w,v,g):w}}if(o.kind==="separate"){const r=nt(o.vector,t);return a=>{const l=r(a);return typeof l=="number"?l:l.getComponent(o.axis)}}const n=nt(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 l=ut.clamp(a,0,1)*256,c=Math.floor(l),u=o.colors[c],f=o.colors[Math.min(c+1,256)],i=o.interpolate?l-c:0;return e.set(ut.lerp(u[0],f[0],i),ut.lerp(u[1],f[1],i),ut.lerp(u[2],f[2],i))}}function ur(o,t,n,e){const r=new Float32Array(t*n*3),a=nt(o,e),l=new x;for(let c=0;c<n;c++){const u=((c+.5)/n-.5)*Math.PI;for(let f=0;f<t;f++){const i=((f+.5)/t-.5)*2*Math.PI;l.set(Math.cos(u)*Math.cos(i),-Math.cos(u)*Math.sin(i),Math.sin(u));const s=a(l),_=(c*t+f)*3;r[_]=typeof s=="number"?s:s.x,r[_+1]=typeof s=="number"?s:s.y,r[_+2]=typeof s=="number"?s:s.z}}return r}function Eo(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function _r(o,t,n,e){e.updateMatrixWorld();const r=new Float32Array(t*n*3),a=new x,l=nt(o,()=>a),c=new x,u=e.getWorldPosition(new x),f=e.getWorldDirection(new x);for(let i=0;i<n;i++)for(let s=0;s<t;s++){const _=(s+.5)/t,d=(i+.5)/n;a.set(_,d,0),e.isOrthographicCamera?c.copy(f):c.set(_*2-1,d*2-1,.5).unproject(e).sub(u).normalize(),c.set(c.x,-c.z,c.y);const h=l(c),m=(i*t+s)*3;r[m]=typeof h=="number"?h:h.x,r[m+1]=typeof h=="number"?h:h.y,r[m+2]=typeof h=="number"?h:h.z}return r}const J=S().finite(),mr=A({type:B(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:B(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Zn;function dr(){return Zn??=ca(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Zn}function hr(){return Zn??Promise.resolve()}const pr=o=>{const t=o.size??0,n=o.size_y??t;if(o.shape==="RECTANGLE")return[t,n];if(o.shape==="DISK"){const e=Math.sqrt(Math.PI*t*t/4);return[e,e]}if(o.shape==="ELLIPSE"){const e=Math.sqrt(Math.PI/4);return[t*e,n*e]}return[t,t]};function vr(o,t){const n=(l,c)=>t&&c(t)?t:new l;if(o.type==="SUN"){const l=n(Yo,c=>c.isDirectionalLight);return l.intensity=o.energy,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="POINT"){const l=n(jn,c=>c.isPointLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="SPOT"){const l=n(Bn,c=>c.isSpotLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.angle=(o.spot_size??0)/2,l.penumbra=o.spot_blend??0,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}dr();const e=n(gn,l=>l.isRectAreaLight),[r,a]=pr(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],ft),e}function gr(o,t,n){if(!o.castShadow||n<=0)return;const r=o.getWorldPosition(new x).distanceTo(t),a=o.shadow;if(!a)return;const l=a.camera;l.near=Math.max(n*.001,r-n),l.far=r+n,o.isDirectionalLight&&(l.left=-n,l.right=n,l.top=n,l.bottom=-n),l.updateProjectionMatrix()}function xr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ro=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],Mo=.69;class br{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Xo;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[r,a]of ro.entries()){const l=(1+a.smooth)**2,c=new Yo(16777215,Math.PI*Mo/l);c.name=`BlenderSolidLight${r}`,c.color.setRGB(a.diffuse[0],a.diffuse[1],a.diffuse[2],ft),c.position.set(a.direction[0],a.direction[1],a.direction[2]),c.target=t,this.group.add(c),this.lights.push(c),n.r+=a.diffuse[0]*a.smooth/l,n.g+=a.diffuse[1]*a.smooth/l,n.b+=a.diffuse[2]*a.smooth/l}const e=new Me(16777215,Math.PI*Mo);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),W=ne(()=>jt([J,Ut,A({kind:j("direction")}).strict(),A({kind:j("window")}).strict(),A({kind:j("gradient"),gradient_type:B(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:B(["Fac","Color"]),vector:W}).strict(),A({kind:j("to_float"),source_type:B(["RGBA","VECTOR"]),value:W}).strict(),A({kind:j("math"),operation:B(Object.keys(_e)),clamp:q(),inputs:F(W).min(1).max(3)}).strict(),A({kind:j("mix_color"),factor:W,a:W,b:W,clamp_factor:q(),clamp_result:q()}).strict(),A({kind:j("mapping"),vector_type:B(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:W,location:Ut,rotation:Ut,scale:Ut}).strict(),A({kind:j("separate"),vector:W,axis:S().int().min(0).max(2)}).strict(),A({kind:j("ramp"),factor:W,colors:F(Ut).length(257),interpolate:q()}).strict(),A({kind:j("map_range"),interpolation:B(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:W,from_min:W,from_max:W,to_min:W,to_max:W,steps:W}).strict(),A({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),No=A({color:Ut,strength:J,shader:W.optional()}),yr=No.extend({volume:F(A({kind:B(["absorption","scatter","principled","emission"]),phase:E(),alpha:W,weight:W,color:W,density:W,anisotropy:W,absorption_color:W,emission_color:W,emission_strength:W,blackbody_intensity:W,temperature:W,blackbody_tint:W}).strict()).optional(),lighting:No.strict().optional()}).strict(),wr=4,tn=new Map,Dn=new Set;function Ro(o,t,n){const a=Et(o);if(a&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const l=JSON.stringify([o,a?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),c=tn.get(l);if(c!==void 0)return Qn(c,t,256,128);const u=new x,f=new no,i=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,s=n?.getWorldPosition(new x),d=ur(o,256,128,a?h=>(u.set(h.x,h.z,-h.y),n.isPerspectiveCamera&&u.add(s),f.set(u.x,u.y,u.z,1).applyMatrix4(i),f.w===0?u.set(0,0,0):u.set(f.x/f.w*.5+.5,f.y/f.w*.5+.5,0)):void 0);return tn.set(l,d),tn.size>wr&&tn.delete(tn.keys().next().value),Qn(d,t,256,128)}function Or(o,t,n,e){const r=nn.toHalfFloat(1);for(let a=0;a<e;a++)o[a*4]=nn.toHalfFloat(t[a*3]*n),o[a*4+1]=nn.toHalfFloat(t[a*3+1]*n),o[a*4+2]=nn.toHalfFloat(t[a*3+2]*n),o[a*4+3]=r}function Qn(o,t,n,e){const r=new Uint16Array(n*e*4);Or(r,o,t,n*e);const a=new Pn(r,n,e,Sn,oo);return a.mapping=Re,a.colorSpace=ft,a.minFilter=Lt,a.magFilter=Lt,a.needsUpdate=!0,a}class lo{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const r=lo.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=n.shader??n.color,l=this.generation,u=[...Eo(a),...n.lighting?Eo(n.lighting.shader??n.lighting.color):[]].filter(i=>!rr(i));if(u.length===0){this.compose(r,n,a,e);return}const f=(async()=>{const i=await Promise.all(u.map(fr));u.forEach((s,_)=>{ue(s,i[_])}),!(this.generation!==l||this.applied?.scene!==r)&&(this.compose(r,n,a,e),vt())})();this.pending=f,Dn.add(f),f.then(()=>Dn.delete(f),()=>Dn.delete(f))}compose(t,n,e,r){if(this.texture=Ro(e,n.strength,r),Et(e)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=Qn(_r(e,512,512,r),n.strength,512,512),this.screenTexture.mapping=Ne,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const l=r.getWorldDirection(new x);l.set(l.x,-l.z,l.y);const c=nt(n.shader??n.color)(l);t.background=typeof c=="number"?new ht().setRGB(c,c,c).multiplyScalar(n.strength):new ht().setRGB(c.x,c.y,c.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:a}=n;this.environmentTexture=a?Ro(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 me(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Tr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=me(o);if(n.every(i=>t.containsPoint(i)))return n;const e=[...t.planes,new It(new x(1,0,0),-o.min.x),new It(new x(-1,0,0),o.max.x),new It(new x(0,1,0),-o.min.y),new It(new x(0,-1,0),o.max.y),new It(new x(0,0,1),-o.min.z),new It(new x(0,0,-1),o.max.z)],r=[],a=new x,l=new x,c=new x,u=new x,f=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let i=0;i<e.length;i++)for(let s=i+1;s<e.length;s++)for(let _=s+1;_<e.length;_++){const d=e[i],h=e[s],m=e[_];a.crossVectors(h.normal,m.normal);const p=d.normal.dot(a);Math.abs(p)<1e-12||(l.crossVectors(m.normal,d.normal),c.crossVectors(d.normal,h.normal),u.copy(a).multiplyScalar(-d.constant).addScaledVector(l,-h.constant).addScaledVector(c,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-f)&&r.push(u.clone()))}return r}function Ar(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,r=e.matrixWorldInverse,a=new yn().setFromPoints(t.map(_=>_.clone().applyMatrix4(r))),l=a.getSize(new x),c=Math.max(l.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,f=Math.max(l.x,l.y,c)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),i=2*Math.SQRT2*f,s=u*f;a.min.x-=s,a.min.y-=s,a.max.x+=s,a.max.y+=s;for(const _ of n){if(_.isEmpty())continue;const d=new yn().setFromPoints(me(_).map(h=>h.applyMatrix4(r)));d.max.x<a.min.x||d.min.x>a.max.x||d.max.y<a.min.y||d.min.y>a.max.y||(a.min.z=Math.min(a.min.z,d.min.z),a.max.z=Math.max(a.max.z,d.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-i-c,e.far=-a.min.z+i+c,e.updateProjectionMatrix(),o.shadow.normalBias=i}const Gt=S().finite(),Io=$([Gt,Gt,Gt]),de=A({min:$([S().int(),S().int(),S().int()]),max:$([S().int(),S().int(),S().int()]),density:F(Gt),voxelSize:Gt.positive(),color:Io,emission:Io,densityScale:Gt.nonnegative()}).strict();function Pr(o){const t=o.max.map((i,s)=>i-o.min[s]+1);if(t.some(i=>i<=0)||t.reduce((i,s)=>i*s,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Ie(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Fe,n.type=Zo,n.minFilter=n.magFilter=Lt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),r=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),a=new ze(r.x,r.y,r.z),l=a.getAttribute("position");for(let i=0;i<l.count;i++)l.setXYZ(i,e.x+(l.getX(i)>0?r.x:0),e.y+(l.getY(i)>0?r.y:0),e.z+(l.getZ(i)>0?r.z:0));l.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const c=new to({glslVersion:Ce,side:De,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 Go}},vertexShader:`
|
|
19
|
+
`;function St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Ea=new X,Ma=new x,vo=new Xo;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Na{constructor(){this.group=new ot,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],a=JSON.stringify(t);if(a===this.signature)return e;this.signature=a,this.clear();for(const r of Object.values(t)){const 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 ot;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[],h=[],s=[],l=[],c=[],_=[],d=[];for(const m of n){const p=go(e,m),v=po(t,m),g=ba(v),w=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const A=Ma.set(...ya[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const E=new x(...Mn[O]).applyMatrix4(p);r.push(E.x,E.y,E.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=mo(m)===2?l:h,S=mo(m)===2?c:s;for(const[T,A]of wa){const O=new x(...Mn[T]).applyMatrix4(p),E=new x(...Mn[A]).applyMatrix4(p);y.push(O.x,O.y,O.z,E.x,E.y,E.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(Ea.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 ot;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[];for(const h of n){const s=go(e,h),l=new x().setFromMatrixPosition(s),c=new x(0,1,0).applyMatrix4(s),_=ho(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,Ta)),a.add(this.lines(f,u,Aa)),a}solidMesh(t,n,e,a){const r=new fn;r.setAttribute("position",new bt(t,3)),r.setAttribute("normal",new bt(n,3)),r.setAttribute("aSolid",new bt(e,3)),r.setAttribute("aHint",new bt(a,3));const i=new to({vertexShader:Pa,fragmentShader:Sa,side:Ee});this.disposables.push(r,i);const f=new Tt(r,i);return f.frustumCulled=!1,f}lines(t,n,e){const a=new Ho;a.setPositions(t),a.setColors(n);const r=new qo({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const i=new Go(a,r);return i.frustumCulled=!1,i}point(t,n){const e=new Me(Oa,12,8),a=new yn({color:n});this.disposables.push(e,a);const r=new Tt(e,a);return r.applyMatrix4(t),r.frustumCulled=!1,r}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const xo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ra(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 R=Math.fround,Tn=R(2*Math.PI),Nn=R(1-1e-4),zt=(o,t)=>R(R(R(o[0]*t[0])+R(o[1]*t[1]))+R(o[2]*t[2])),rn=(o,t,n=1)=>o.map((e,a)=>R(e+R(t[a]*n))),Ia=(o,t)=>o.map((n,e)=>R(n-t[e]));function Kt(o){const t=R(Math.sqrt(zt(o,o)));return t>0?o.map(n=>R(n/t)):[0,0,0]}function Jt(o){const t=Math.abs(o)<1?R(1-R(1-Math.abs(o))):1;let n=R(R(.077980478)+R(t*R(-.02164095)));n=R(R(-.213300989)+R(t*n)),n=R(R(1.5707963267)+R(t*n));const e=R(R(Math.sqrt(R(1-t)))*n);return o<0?R(R(Math.PI)-e):e}function Fa(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]=R(n[a]+R(R(t[r]-e[r])*R(t[i]+e[i])))}t=e}return n}function Da(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=Ra(Fa(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)=>Kt(Ia(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 E of v)g=rn(g,n[t[E].face],Jt(zt(_(E,"prev"),_(E,"next"))));g=Kt(g)}const w=_(m,"next"),y=v.at(-1),S=_(y,"prev"),T=zt(w,g),A=zt(S,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<Nn&&Math.abs(A)<Nn){const E=v.length>1?v.map(pt=>_(pt,"next")):[];E.length&&t[t[y].prev].edge!==t[m].edge&&E.push(S),O.alpha=E.length?R(E.reduce((pt,b)=>R(pt+Jt(zt(b,g))),0)/E.length):R(R(Jt(T)+Jt(A))/2),O.reference=Kt(rn(w,g,-T));const C=g,V=O.reference;O.ortho=Kt([R(R(C[1]*V[2])-R(C[2]*V[1])),R(R(C[2]*V[0])-R(C[0]*V[2])),R(R(C[0]*V[1])-R(C[1]*V[0]))]);const H=Kt(rn(S,g,-A)),Q=zt(O.reference,H),tt=Jt(Q);O.beta=Q<Nn?zt(O.ortho,H)<0?R(Tn-tt):tt:Tn}O.alpha===0&&(O.normal=[0,0,0]);for(const E of v)s[E]=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 za(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=R(t[0]/32767),e=R(t[1]/32767),a=R((n>0?o.alpha:R(Tn-o.alpha))*n),r=R((e>0?o.beta:R(Tn-o.beta))*e);let i=o.normal.map(f=>R(f*R(Math.cos(a))));return i=rn(i,o.reference,R(R(Math.sin(a))*R(Math.cos(r)))),e!==0&&(i=rn(i,o.ortho,R(R(Math.sin(a))*R(Math.sin(r))))),i}function ae(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Da(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=za(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 Rn={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}},Ca=1e-6;function ka(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 $a=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),bo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function La(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t+=e.x*a.y-a.x*e.y}return t}function yo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let a=0;for(const[r,i,f]of o){const u=$a(t[r],t[i],t[f]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Ca*Math.abs(n)}function Va(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=ka(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:bo(t),sound:!1,method:"fan"};const a=n.clone().divideScalar(e),r=Math.abs(a.x)<.9?new x(1,0,0):new x(0,1,0),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 Lt(d.dot(i),d.dot(f))}),s=La(h),l=bo(t);if(yo(l,h,s))return{triangles:l,sound:!0,method:"fan"};let c=[];try{c=Ne.triangulateShape(h,[]).map(_=>[_[0],_[1],_[2]])}catch{return{triangles:l,sound:!1,method:"fan"}}return yo(c,h,s)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:l,sound:!1,method:c.length>0?"earcut":"fan"}}const ja=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function In(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Fn(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[In(Number(t[n*4])),In(Number(t[n*4+1])),In(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 re(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),a=[0,0,0,0];return{name:n.name,domain:n.domain,read:(r,i,f)=>n.domain==="POINT"?Fn(n.type,e,r):n.domain==="CORNER"?i===void 0?a:Fn(n.type,e,i):f===void 0?a:Fn(n.type,e,f)}})}function le(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,L)=>t<94906265?Math.min(b,L)*t+Math.max(b,L):`${Math.min(b,L)}:${Math.max(b,L)}`,_=new Map,d=new Set;for(const[b,L]of o.sharp)d.add(c(b,L));if(o.edges)for(const[b,L]of o.edges){if(b===L)throw new Error("Runtime mesh edge needs distinct vertices");_.set(c(b,L),-1)}const m=b=>{for(;s[b]!==b;)s[b]=s[s[b]],b=s[b];return b},p=(b,L)=>{const z=m(b),Y=m(L);s[Math.max(z,Y)]=Math.min(z,Y)};for(let b=0;b<n;b++){const L=e[b],z=e[b+1]-L,Y=o.smooth(b)?1:0;for(let Z=0;Z<z;Z++){const k=L+Z;h[a[k]]=1,f[k]=L+(Z+1)%z,u[k]=Y,s[k]=k}}for(let b=0;b<r;b++){const L=f[b],z=a[b],Y=a[L],Z=c(z,Y),k=_.get(Z);if(k!==void 0&&k>=0&&u[b]&&u[k]&&!d.has(Z)){const G=f[k];p(b,a[k]===z?k:G),p(L,a[k]===z?G:k)}(k===void 0||k<0||!u[k]&&u[b])&&_.set(Z,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),E=new Map,C=[],V=o.normals||o.cornerNormal?new Float32Array(i*3):null;let H=0,Q=0;const tt=(b,L,z,Y,Z)=>{const k=H++;for(const G of T)G.data.set(G.read(b,Y,Z),k*4);if(A)for(let G=0;G<3;G++)A[k*3+G]=o.orco[b*3+G]*.5+.5;if(y[k]=b,o.co(b).toArray(g,k*3),L&&w.set(L,k*2),z&&V.set(z,k*3),Y!==void 0)for(const G of S)G.data.set(G.read(Y),k*2);return k},pt=(b,L)=>{const z=v?.(b),Y=o.cornerNormal?[o.cornerNormal[b*3],o.cornerNormal[b*3+1],o.cornerNormal[b*3+2]]:o.normals?.[b];if(!l)return tt(a[b],z,Y,b,L);const Z=`${u[b]?m(b):b}${z?`:${z[0]}:${z[1]}`:""}${Y?`:n${Y.join(":")}`:""}${S.map(G=>":"+G.read(b).join(":")).join("")}${T.map(G=>G.domain==="POINT"?"":":"+Array.from(G.read(a[b],b,L)).join(":")).join("")}`;let k=E.get(Z);return k===void 0&&(k=tt(a[b],z,Y,b,L),E.set(Z,k)),k};for(let b=0;b<n;b++){const L=Q,z=e[b],Y=e[b+1]-z,Z=[];for(let Yt=0;Yt<Y;Yt++)Z.push(o.co(a[z+Yt]));for(const Yt of Va(Z).triangles)for(const Se of Yt)O[Q++]=pt(z+Se,b);const k=o.material(b),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let b=0;b<t;b++)h[b]||tt(b);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?w.slice(0,H*2):null,uvLayers:S.map(b=>({name:b.name,data:b.data.slice(0,H*2)})),attributeLayers:T.map(b=>({name:b.name,data:b.data.slice(0,H*4)})),orco:A?A.slice(0,H*3):null,indices:O.slice(0,Q),sourceVertex:y.slice(0,H),groups:C}}function jt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function xn(o){const t=new fn;t.setAttribute("position",new it(o.positions,3)),t.setAttribute("uv",new it(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new it(o.indices,1));const n=Object.create(null);for(const[e,a]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[a.name]=e+1,t.setAttribute(`uv${e+1}`,new it(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(jt(e.name),new it(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new it(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new it(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new it(o.sourceVertex,1)),t}function wo(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/Rn[s.type].size},(m,p)=>Array.from({length:Rn[s.type].size},(v,g)=>Number(s.data[p*Rn[s.type].size+g])))}:void 0,_=new x,d={vertexCount:n,normals:l?ae(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:re(o.attributes,m=>m)};return{...le(d),hash:t}}function Ba(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:ae(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:re(o.attributes??[],l=>Array.from(l).flat())};return xn(le(s))}const sn=1.5707963267948966,Ct=6.283185307179586,ie=.3183098861837067,se=.0795774715459476,Ua=.3,Wa=se,Ha=3/16*ie,Gn=.8,Oo=Gn*Gn,kt=6371,fe=100,Xn=kt+fe,To=64,Ao=64,et=256,Rt=64,qa=[1.679,1.828,1.986,1.307],Ga=[.006605,.01067,.01842,.03156],Xa=[3472e-28,3914e-28,1349e-28,1103e-29],Ya=334.5,Za=[28722e-28,46168e-28,79706e-28,13578e-27],Qa=[15908e-26,17711e-26,20942e-26,24033e-26],Po=13681e16,Ka=2e6,Ja=.73,Dn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],An=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),tr=o=>Math.sqrt(Math.max(o,0)),ce=o=>[-Math.sqrt(1-o*o),0,o];function Yn(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 nr=o=>Ha*(1+An(o));function or(o){const t=1+Oo+2*Gn*o;return se*(1-Oo)/(t*Math.sqrt(t))}const er=o=>Po*(Math.exp(-o/Ja)+Ka/Po);function eo(o,t){let n=o%Ct;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=sn||n<=-sn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Ct,e<0&&(e+=Ct),e=Ct-e,[n,e]}class ar{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Rt*et*4)}coefficients(t,n){const e=er(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-An(a-3.22261)*5.55555555-a),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=Za[f]*e,n[4+f]=Qa[f]*e,n[8+f]=Xa[f]*Ya*r*this.ozone,n[12+f]=Ga[f]*i*this.air}transmittance(t,n,e){const[a,r,i]=ce(t),f=Ot(kt,Xn,n),h=Yn(0,0,f,a,r,i,Xn)/To,s=[0,0,0,0],l=new Float64Array(16);for(let c=0;c<To;c++){const _=(c+.5)*h,d=a*_,m=r*_,p=f+i*_,v=Math.max(Math.hypot(d,m,p)-kt,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<Rt;n++)for(let e=0;e<et;e++){const a=e/(et-1),r=n/(Rt-1);this.transmittance(a*2-1,r,t);const i=(n*et+e)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,n,e){const a=(et-1)*on(t*.5+.5),r=(Rt-1)*on(n),i=Math.trunc(a),f=Math.trunc(r),u=Math.min(i+1,et-1),h=Math.min(f+1,Rt-1),s=a-i,l=r-f,c=(f*et+i)*4,_=(f*et+u)*4,d=(h*et+i)*4,m=(h*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[c+p],this.lut[_+p],s),Ot(this.lut[d+p],this.lut[m+p],s),l)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,et-1),i=e-a;for(let f=0;f<4;f++)n[f]=Ot(this.lut[a*4+f],this.lut[r*4+f],i)}lookupToSun(t,n){const e=(Rt-1)*on(t),a=Math.trunc(e),r=Math.min(a+1,Rt-1),i=e-a,f=et-1;for(let u=0;u<4;u++)n[u]=Ot(this.lut[(a*et+f)*4+u],this.lut[(r*et+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=nr(s),c=or(s),_=u/Ao,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<Ao;T++){const A=(T+.5)*_,O=n+r*A,E=e+i*A,C=a+f*A,V=Math.hypot(O,E,C),H=Math.max(V-kt,0),Q=H/fe,tt=(O*t[0]+E*t[1]+C*t[2])/V;this.coefficients(H,d),this.lookup(tt,Q,m);const pt=Ct*(1-tr(1-An(kt/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,w);const b=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let z=0;z<4;z++){const Y=g[z]/w[z],Z=Wa*pt*(Ua*ie)*v[z]*Y*tt;p[z]=.02*L[z]*b+Z}for(let z=0;z<4;z++){const Y=d[z]+d[4+z]+d[8+z]+d[12+z],Z=qa[z]*(d[12+z]*(l*m[z]+p[z])+d[4+z]*(c*m[z]+p[z])),k=Math.exp(-_*Y),G=Math.max(Y,1e-7);y[z]+=S[z]*((Z-Z*k)/G),S[z]*=k}}for(let T=0;T<4;T++)h[T]=y[T]}}const st=512,qt=256;function ue(o,t){const n=new ar(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=ce(Math.cos(sn-t)),r=new Float32Array(st*qt*3),i=st/2,f=new Float64Array(4);for(let u=0;u<qt;u++)for(let h=0;h<i;h++){const s=(h+.5)/st,l=(u+.5)/qt,c=Ct*s,_=l*2-1,d=Math.sign(_)*An(_)*sn,m=Math.cos(d)*Math.cos(c),p=Math.cos(d)*Math.sin(c),v=Math.sin(d),g=kt+e,w=Yn(0,0,g,m,p,v,Xn),y=Yn(0,0,g,m,p,v,kt),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 V=0;V<4;V++)T+=Dn[V][0]*f[V],A+=Dn[V][1]*f[V],O+=Dn[V][2]*f[V];const E=(u*st+h)*3;r[E]=T,r[E+1]=A,r[E+2]=O;const C=(u*st+(st-h-1))*3;r[C]=T,r[C+1]=A,r[C+2]=O}return r}function rr(o){const[t]=eo(o.sunElevation,o.sunRotation);return ue(o,t)}function ao(o){const[t]=eo(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const lr=6,Wt=new Map;function ir(o){return Wt.has(ao(o))}function _e(o,t){Wt.set(ao(o),t),Wt.size>lr&&Wt.delete(Wt.keys().next().value)}function sr(o){const[t,n]=eo(o.sunElevation,o.sunRotation),e=ao(o);let a=Wt.get(e);a===void 0&&(a=ue(o,t),_e(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)/Ct;s-=Math.floor(s);const l=Math.abs(u),c=on(Math.sqrt(l/sn)*Math.sign(u)*.5+.5),_=s*st-.5,d=c*qt-.5,m=Math.floor(_),p=Math.floor(d),v=_-m,g=d-p,w=C=>(C%st+st)%st,y=C=>C<0?0:C>qt-1?qt-1:C,S=w(m),T=w(m+1),A=y(p),O=y(p+1),E=[0,0,0];for(let C=0;C<3;C++){const V=Ot(a[(A*st+S)*3+C],a[(A*st+T)*3+C],v),H=Ot(a[(O*st+S)*3+C],a[(O*st+T)*3+C],v);E[C]=Ot(V,H,g)}return r.set(yt[0][0]*E[0]+yt[0][1]*E[1]+yt[0][2]*E[2],yt[1][0]*E[0]+yt[1][1]*E[1]+yt[1][2]*E[2],yt[2][0]*E[0]+yt[2][1]*E[1]+yt[2][2]*E[2])}}let Pt=null,cn=!1,fr=0;const en=new Map;function cr(){if(Pt||cn)return Pt;if(typeof Worker>"u")return cn=!0,null;try{Pt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return Pt.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,a=en.get(t);a&&(en.delete(t),n?a.resolve(n):a.reject(new Error(e??"sky worker returned nothing")))},Pt.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),Pt?.terminate(),Pt=null,cn=!0},Pt}function ur(o){const t=cr();if(!t)return Promise.resolve(rr(o));const n=fr++,e={id:n,parameters:o};return new Promise((a,r)=>{en.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function _r(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 zn=(o,t)=>t!==0?o/t:0,So=o=>Math.min(1,Math.max(-1,o)),Eo=(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},me={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:zn,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:zn(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(zn(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(So(o)),ARCCOSINE:o=>Math.acos(So(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:Eo,SMOOTH_MAX:(o,t,n)=>-Eo(-o,-t,n)};function nt(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const a=new x(...o);return()=>a}if(o.kind==="direction")return a=>a;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const a=nt(o.vector,t),r={type:o.gradient_type},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=ut.clamp(_r(h,s,l,r),0,1);return o.output==="Fac"?c:i.setScalar(c)}}if(o.kind==="to_float"){const a=nt(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=>nt(f,t)),r=me[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?ut.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=nt(o.factor,t),r=nt(o.a,t),i=nt(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?ut.clamp(s,0,1):s),o.clamp_result&&f.clampScalar(0,1),f}}if(o.kind==="sky"){const a=sr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return r=>a(r)}if(o.kind==="mapping"){const a=nt(o.vector,t),r=new x(...o.location),i=new x(...o.scale),f=new gt().setFromEuler(new Re(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=nt(o.value,t),r=nt(o.from_min,t),i=nt(o.from_max,t),f=nt(o.to_min,t),u=nt(o.to_max,t),h=nt(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=ut.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?ut.clamp(y,g,v):ut.clamp(y,v,g):y}}if(o.kind==="separate"){const a=nt(o.vector,t);return r=>{const i=a(r);return typeof i=="number"?i:i.getComponent(o.axis)}}const n=nt(o.factor,t),e=new x;return a=>{const r=n(a);if(typeof r!="number")throw new Error("World ColorRamp needs a scalar factor");const i=ut.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(ut.lerp(u[0],h[0],s),ut.lerp(u[1],h[1],s),ut.lerp(u[2],h[2],s))}}function mr(o,t,n,e){const a=new Float32Array(t*n*3),r=nt(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 Mo(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function dr(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,i=nt(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 J=M().finite(),hr=P({type:U(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:U(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Zn;function pr(){return Zn??=ma(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Zn}function vr(){return Zn??Promise.resolve()}const gr=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 xr(o,t){const n=(i,f)=>t&&f(t)?t:new i;if(o.type==="SUN"){const i=n(Zo,f=>f.isDirectionalLight);return i.intensity=o.energy,i.color.setRGB(o.color[0],o.color[1],o.color[2],ft),i.castShadow=o.use_shadow,i}if(o.type==="POINT"){const i=n(Bn,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],ft),i.castShadow=o.use_shadow,i}if(o.type==="SPOT"){const i=n(Un,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],ft),i.castShadow=o.use_shadow,i}pr();const e=n(gn,i=>i.isRectAreaLight),[a,r]=gr(o);return e.width=a,e.height=r,e.intensity=o.energy/(Math.max(a*r,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],ft),e}function br(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 yr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ro=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],No=.69;class wr{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Yo;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[a,r]of ro.entries()){const i=(1+r.smooth)**2,f=new Zo(16777215,Math.PI*No/i);f.name=`BlenderSolidLight${a}`,f.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],ft),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 Ie(16777215,Math.PI*No);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),W=oe(()=>Nt([J,Ut,P({kind:j("direction")}).strict(),P({kind:j("window")}).strict(),P({kind:j("gradient"),gradient_type:U(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:U(["Fac","Color"]),vector:W}).strict(),P({kind:j("to_float"),source_type:U(["RGBA","VECTOR"]),value:W}).strict(),P({kind:j("math"),operation:U(Object.keys(me)),clamp:q(),inputs:F(W).min(1).max(3)}).strict(),P({kind:j("mix_color"),factor:W,a:W,b:W,clamp_factor:q(),clamp_result:q()}).strict(),P({kind:j("mapping"),vector_type:U(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:W,location:Ut,rotation:Ut,scale:Ut}).strict(),P({kind:j("separate"),vector:W,axis:M().int().min(0).max(2)}).strict(),P({kind:j("ramp"),factor:W,colors:F(Ut).length(257),interpolate:q()}).strict(),P({kind:j("map_range"),interpolation:U(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:W,from_min:W,from_max:W,to_min:W,to_max:W,steps:W}).strict(),P({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),Ro=P({color:Ut,strength:J,shader:W.optional()}),Or=Ro.extend({volume:F(P({kind:U(["absorption","scatter","principled","emission"]),phase:N(),alpha:W,weight:W,color:W,density:W,anisotropy:W,absorption_color:W,emission_color:W,emission_strength:W,blackbody_intensity:W,temperature:W,blackbody_tint:W}).strict()).optional(),lighting:Ro.strict().optional()}).strict(),Tr=4,tn=new Map,Cn=new Set;function Io(o,t,n){const r=Et(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=tn.get(i);if(f!==void 0)return Qn(f,t,256,128);const u=new x,h=new no,s=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,l=n?.getWorldPosition(new x),_=mr(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 tn.set(i,_),tn.size>Tr&&tn.delete(tn.keys().next().value),Qn(_,t,256,128)}function Ar(o,t,n,e){const a=nn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=nn.toHalfFloat(t[r*3]*n),o[r*4+1]=nn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=nn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function Qn(o,t,n,e){const a=new Uint16Array(n*e*4);Ar(a,o,t,n*e);const r=new Sn(a,n,e,En,oo);return r.mapping=De,r.colorSpace=ft,r.minFilter=Vt,r.magFilter=Vt,r.needsUpdate=!0,r}class lo{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const a=lo.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,i=this.generation,u=[...Mo(r),...n.lighting?Mo(n.lighting.shader??n.lighting.color):[]].filter(s=>!ir(s));if(u.length===0){this.compose(a,n,r,e);return}const h=(async()=>{const s=await Promise.all(u.map(ur));u.forEach((l,c)=>{_e(l,s[c])}),!(this.generation!==i||this.applied?.scene!==a)&&(this.compose(a,n,r,e),vt())})();this.pending=h,Cn.add(h),h.then(()=>Cn.delete(h),()=>Cn.delete(h))}compose(t,n,e,a){if(this.texture=Io(e,n.strength,a),Et(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=Qn(dr(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=Fe,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=nt(n.shader??n.color)(i);t.background=typeof f=="number"?new ht().setRGB(f,f,f).multiplyScalar(n.strength):new ht().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?Io(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 de(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 Pr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=de(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new Ft(new x(1,0,0),-o.min.x),new Ft(new x(-1,0,0),o.max.x),new Ft(new x(0,1,0),-o.min.y),new Ft(new x(0,-1,0),o.max.y),new Ft(new x(0,0,1),-o.min.z),new Ft(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 Sr(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new wn().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 wn().setFromPoints(de(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 Gt=M().finite(),Fo=$([Gt,Gt,Gt]),he=P({min:$([M().int(),M().int(),M().int()]),max:$([M().int(),M().int(),M().int()]),density:F(Gt),voxelSize:Gt.positive(),color:Fo,emission:Fo,densityScale:Gt.nonnegative()}).strict();function Er(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 ze(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Ce,n.type=Qo,n.minFilter=n.magFilter=Vt,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 ke(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 to({glslVersion:Le,side:$e,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 Xo}},vertexShader:`
|
|
20
20
|
out vec3 localPosition;
|
|
21
21
|
void main() {
|
|
22
22
|
localPosition = position;
|
|
@@ -58,7 +58,7 @@ import{a as Wo,b as Ho,L as qo}from"./LineSegments2-DN9pUfWA.js";import{bh as ot
|
|
|
58
58
|
outputColor = vec4(radiance, 1.0 - transmission);
|
|
59
59
|
#include <tonemapping_fragment>
|
|
60
60
|
#include <colorspace_fragment>
|
|
61
|
-
}`}),u=new Tt(
|
|
61
|
+
}`}),u=new Tt(r,f),h=new X;return u.onBeforeRender=(s,l,c)=>{h.copy(u.matrixWorld).invert(),f.uniforms.cameraLocal.value.setFromMatrixPosition(c.matrixWorld).applyMatrix4(h),c.getWorldDirection(f.uniforms.rayLocal.value).transformDirection(h),f.uniforms.orthographic.value=!!c.isOrthographicCamera,f.uniforms.worldScale.value.setFromMatrix4(u.matrixWorld)},f.addEventListener("dispose",()=>n.dispose()),u}const Mr=`#define constexpr const
|
|
62
62
|
#define bool32_t bool
|
|
63
63
|
#define bool2 bvec2
|
|
64
64
|
#define bool3 bvec3
|
|
@@ -6879,7 +6879,7 @@ void curves_float_mixed(float factor,
|
|
|
6879
6879
|
curves_float(
|
|
6880
6880
|
value, curve_map, layer, range_minimum, range_divider, start_slope, end_slope, result);
|
|
6881
6881
|
result = mix(value, result, factor);
|
|
6882
|
-
}`}},
|
|
6882
|
+
}`}},Do=M().finite(),kn=U(["float","vec2","vec3","vec4"]),pe=Nt([Do,F(Do)]),ve=$([N(),M().int().nonnegative()]),bn=Nt([P({value:pe}).strict(),P({link:ve}).strict()]),Nr=["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"],Rr=P({type:U(Nr),props:_t(N(),ee()),inputs:F(Nt([P({value:pe,id:N(),gpu:kn,enabled:q()}).strict(),P({link:ve,id:N(),gpu:kn,enabled:q()}).strict()])),outputs:F(P({id:N(),gpu:kn.or(j("closure")).nullable()}).strict())}).strict(),an=oe(()=>Nt([P({principled:j(!0)}).strict(),P({emission:$([bn,bn])}).strict(),P({transparent:M()}).strict(),P({none:j(!0)}).strict(),P({mix:$([bn,an,an])}).strict(),P({add:$([an,an])}).strict()])),Ir=P({surface:U(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:_t(N(),bn),closure:an.optional(),nodes:_t(N(),Rr)}).strict();function Fr(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 ge="vec3(0.2126729, 0.7151522, 0.0721750)",Dr=o=>o==="float"?1:Number(o[3]);function zr(o,t){const n=typeof t=="number"?[t]:t,e=Dr(o);return Array.from({length:e},(a,r)=>n[r]??(r===3?1:0))}function Cr(o,t,n){if(t===n)return o;const e=r=>r==="float"?"float":`float${r[3]}`,a=t==="vec4"&&n==="float"?`, ${ge}`:"";return`${e(n)}_from_${e(t)}(${o}${a})`}const kr={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},$r={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},zo={MIX:"blend",ADD:"add",MULTIPLY:"mult",SUBTRACT:"sub",SCREEN:"screen",DIVIDE:"div_fallback",DIFFERENCE:"diff",EXCLUSION:"exclusion",DARKEN:"dark",LIGHTEN:"light",OVERLAY:"overlay",DODGE:"dodge",BURN:"burn",HUE:"hue",SATURATION:"sat",VALUE:"val",COLOR:"color",SOFT_LIGHT:"soft",LINEAR_LIGHT:"linear"},Lr={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},Vr={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},jr={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},Br=(()=>{const o=new Map;for(const[t,n]of Object.entries(Kn))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 D(o,t){if(!(t in o.props))throw new Error(`${o.type} arrived without its '${t}' property`);return o.props[t]}const Ur=`
|
|
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
|
+
`,Wr=`
|
|
6940
6940
|
uniform vec2 blenderViewport;
|
|
6941
6941
|
vec3 blender_orco() {
|
|
6942
6942
|
// attr_load_orco: the orco attribute (\`orcoAttribute\`), interpolated.
|
|
@@ -7019,23 +7019,23 @@ vec3 blender_reflection() {
|
|
|
7019
7019
|
: normalize(cameraPosition - vBlenderWorldPosition);
|
|
7020
7020
|
return blender_from_three * -reflect(incident, normalize(vBlenderWorldNormal));
|
|
7021
7021
|
}
|
|
7022
|
-
`;class io{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=Fr(t,n);return this.s.uniforms.set(e,t==="float"?r[0]:r),this.s.uniformTypes.set(e,t),e}use(t){const n=Vr.get(t);if(!n)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(n),t}source(t,n){if("value"in t)return this.s.structure.push("v"),this.uniform(n,t.value);const[e,r]=t.link,a=this.graph.nodes[e];if(!a)throw new Error(`The graph links to ${e}, which it does not carry`);const c=this.node(e,a)[r];if(!c)throw new Error(`${e} has no output ${r}`);return this.s.structure.push(["l",e,r]),zr(c.name,c.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(${Ht("")}, 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((s,_)=>({name:`${r}_${_}`,type:s.gpu==="closure"||s.gpu===null?"float":s.gpu}));this.emitted.set(t,a);const l=s=>`${a[s].type} ${a[s].name} = ${a[s].type}(0.0);`,c=a.map((s,_)=>l(_)).join(" "),u=s=>s.map(_=>a[_].name).join(", "),f=(s=[])=>[...n.inputs.map(d=>this.source(d,d.gpu)),...s,...a.map(d=>d.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const i=[c];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const s=a[0].type;i.push(`${a[0].name} = ${this.uniform(s,z(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Ht("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((_,d)=>{a[d]&&i.push(`${a[d].name} = ${this.d(_)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const s=z(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(s),this.s.structure.push(["a",s]);const _=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";i.push(`${this.use(_)}(${Jn(s)}, ${u(a.map((d,h)=>h))});`);for(const d of a)i.push(`${d.name} = ${this.d(d.name)};`);break}case"ShaderNodeUVMap":{const s=z(n,"uv_map");this.s.uvs.add(s),i.push(`${a[0].name} = ${this.d(`vec3(${Ht(s)}, 0.0)`)};`);break}case"ShaderNodeMath":{const s=z(n,"operation"),_=this.use(Dr[s]??`math_${s.toLowerCase()}`);i.push(`${_}(${f()});`),z(n,"use_clamp")&&i.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const s=z(n,"operation");i.push(`${this.use(Cr[s]??`vector_math_${s.toLowerCase()}`)}(${f()});`);break}case"ShaderNodeMapping":i.push(`${this.use(`mapping_${z(n,"vector_type").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeInvert":i.push(`${this.use("invert")}(${f()});`);break;case"ShaderNodeSeparateXYZ":i.push(`${this.use("separate_xyz")}(${f()});`);break;case"ShaderNodeCombineXYZ":i.push(`${this.use("combine_xyz")}(${f()});`);break;case"ShaderNodeMix":{const s=z(n,"data_type"),_=z(n,"factor_mode")==="NON_UNIFORM",d={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[s];if(!d)throw new Error(`Mix has data type ${s}`);const h=s==="VECTOR"&&_;let m=this.input(n,h?"Factor_Vector":"Factor_Float");if(z(n,"clamp_factor")){const g=`${r}_fac`;i.push(h?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${g});`),m=g}const p=s==="FLOAT"?"node_mix_float":s==="VECTOR"?_?"node_mix_vector_non_uniform":"node_mix_vector":s==="RGBA"?`node_mix_${zo[z(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${d}`);i.push(`${this.use(p)}(${m}, ${this.input(n,`A_${d}`)}, ${this.input(n,`B_${d}`)}, ${u([v])});`),s==="RGBA"&&z(n,"clamp_result")&&i.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const s=`${r}_fac`;i.push(`float ${s}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${s});`);const _=n.inputs.slice(1).map(d=>this.source(d,d.gpu));i.push(`${this.use(`mix_${zo[z(n,"blend_type")]}`)}(${[s,..._,u([0])].join(", ")});`),z(n,"use_clamp")&&i.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const s=z(n,"color_ramp"),_=this.input(n,"Fac"),[d,h]=s.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(s.elements.length===1)i.push(`${u([0])} = ${m(d)}; ${u([1])} = ${u([0])}.a;`);else if(s.elements.length===2&&s.color_mode==="RGB"&&h&&s.interpolation!=="B_SPLINE"&&s.interpolation!=="CARDINAL")if(s.interpolation==="CONSTANT")i.push(`${this.use("valtorgb_opti_constant")}(${_}, ${this.uniform("float",Math.max(d[0],h[0]))}, ${m(d)}, ${m(h)}, ${u([0,1])});`);else{const p=1/(h[0]-d[0]),v=s.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";i.push(`${this.use(v)}(${_}, ${this.uniform("vec2",[p,-p*d[0]])}, ${m(d)}, ${m(h)}, ${u([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:s.table}),this.s.structure.push(["ramp",s.interpolation==="CONSTANT"]),i.push(s.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${_}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${_}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),i.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const s=z(n,"curve_mapping"),_=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:_,table:s.table}),this.s.structure.push(["curve"]);const d=this.input(n,n.inputs.some(h=>h.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?i.push(`${this.use("curves_combined_rgb")}(${d}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${_}, 0.5, ${this.uniform("vec4",s.minimums)}, ${this.uniform("vec4",s.dividers)}, ${this.uniform("vec4",s.starts)}, ${this.uniform("vec4",s.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?i.push(`${this.use("curves_vector_mixed")}(${d}, ${this.input(n,"Vector","vec3")}, ${_}, 0.5, ${this.uniform("vec3",s.minimums.slice(0,3))}, ${this.uniform("vec3",s.dividers.slice(0,3))}, ${this.uniform("vec3",s.starts.slice(0,3))}, ${this.uniform("vec3",s.ends.slice(0,3))}, ${u([0])});`):i.push(`${this.use("curves_float_mixed")}(${d}, ${this.input(n,"Value","float")}, ${_}, 0.5, ${this.uniform("float",s.minimums[0])}, ${this.uniform("float",s.dividers[0])}, ${this.uniform("float",s.starts[0])}, ${this.uniform("float",s.ends[0])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const s=Number(z(n,"noise_dimensions")[0]),_=this.use(`node_noise_tex_${kr[z(n,"noise_type")]}_${s}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=z(n,"normalize")?"1.0":"0.0";i.push(`${_}(${[d,...h,m,"1.0",u(a.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const s=Number(z(n,"voronoi_dimensions")[0]),_=this.use(`node_tex_voronoi_${$r[z(n,"feature")]}_${s}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Lr[z(n,"distance")].toFixed(1)}`,p=z(n,"normalize")?"1.0":"0.0";i.push(`${_}(${[d,...h,m,p,u(a.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const s=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(d=>this.source(d,d.gpu));i.push(`${this.use("node_tex_checker")}(${[s,..._,u(a.map((d,h)=>h))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const s=Number(z(n,"noise_dimensions")[0]);i.push(`${this.use(`node_white_noise_${s}d`)}(${f()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const s=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),d=p=>z(n,`${p}#value`).toFixed(1),h=n.type==="ShaderNodeTexWave"?[d("wave_type"),d("bands_direction"),d("rings_direction"),d("wave_profile")]:n.type==="ShaderNodeTexGradient"?[d("gradient_type")]:n.type==="ShaderNodeTexMagic"?[z(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",z(n,"offset")),z(n,"offset_frequency").toFixed(1),this.uniform("float",z(n,"squash")),z(n,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];i.push(`${this.use(m)}(${[s,..._,...h,u(a.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const s=z(n,"data_type")==="FLOAT_VECTOR",_=z(n,"interpolation_type").toLowerCase(),d=z(n,"clamp");i.push(`${this.use(`${s?"vector_":""}map_range_${_}`)}(${f([d?"1.0":"0.0"])});`),d&&!s&&(_==="linear"||_==="stepped")&&i.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":i.push(`${this.use(z(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${f()});`);break;case"ShaderNodeHueSaturation":i.push(`${this.use("hue_sat")}(${f()});`);break;case"ShaderNodeBrightContrast":i.push(`${this.use("brightness_contrast")}(${f()});`);break;case"ShaderNodeGamma":i.push(`${this.use("node_gamma")}(${f()});`);break;case"ShaderNodeRGBToBW":i.push(`${this.use("rgbtobw")}(${f([ve])});`);break;case"ShaderNodeSeparateColor":i.push(`${this.use(`separate_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeCombineColor":i.push(`${this.use(`combine_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeVectorRotate":{const s={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[z(n,"rotation_type")];i.push(`${this.use(`node_vector_rotate_${s}`)}(${f([z(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const s=n.inputs[1],_="link"in s?this.source(s,"vec3"):"g_data.N";"link"in s||this.s.structure.push("world-normal");const d=this.source(n.inputs[0],"float"),h=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";i.push(`${this.use(h)}(${[d,_,u(a.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const s=n.inputs.find(b=>b.id==="Height"),_=n.inputs.find(b=>b.id==="Normal"),d=_&&"link"in _?this.source(_,"vec3"):"g_data.N";if(!s||!("link"in s)){i.push(`${u([0])} = ${d};`);break}const h=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new io(this.graph,this.s,!0,`${h}_`),p=m.source(s,"float");this.s.functions[Number(h.slice(8))]=`float ${h}() {
|
|
7022
|
+
`;class io{constructor(t,n,e=!1,a="bgN"){this.graph=t,this.derivative=e,this.prefix=a,this.lines=[],this.emitted=new Map,this.s=n??{files:new Set,uniforms:new Map,uniformTypes:new Map,images:[],ramps:[],uvs:new Set,attributes:new Set,structure:[],functions:[]}}get uniforms(){return this.s.uniforms}get images(){return this.s.images}get ramps(){return this.s.ramps}d(t){return this.derivative?`(${t} + dF_impl(${t}))`:t}uniform(t,n){const e=`bgU${this.s.uniforms.size}`,a=zr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Br.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]),Cr(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(${Ht("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const a=`${this.prefix}${this.emitted.size}`,r=n.outputs.map((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,D(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Ht("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((c,_)=>{r[_]&&s.push(`${r[_].name} = ${this.d(c)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const l=D(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)}(${Jn(l)}, ${u(r.map((_,d)=>d))});`);for(const _ of r)s.push(`${_.name} = ${this.d(_.name)};`);break}case"ShaderNodeUVMap":{const l=D(n,"uv_map");this.s.uvs.add(l),s.push(`${r[0].name} = ${this.d(`vec3(${Ht(l)}, 0.0)`)};`);break}case"ShaderNodeMath":{const l=D(n,"operation"),c=this.use(kr[l]??`math_${l.toLowerCase()}`);s.push(`${c}(${h()});`),D(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const l=D(n,"operation");s.push(`${this.use($r[l]??`vector_math_${l.toLowerCase()}`)}(${h()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${D(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=D(n,"data_type"),c=D(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(D(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_${zo[D(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"&&D(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_${zo[D(n,"blend_type")]}`)}(${[l,...c,u([0])].join(", ")});`),D(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const l=D(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=D(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(D(n,"noise_dimensions")[0]),c=this.use(`node_noise_tex_${Lr[D(n,"noise_type")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=D(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(D(n,"voronoi_dimensions")[0]),c=this.use(`node_tex_voronoi_${Vr[D(n,"feature")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${jr[D(n,"distance")].toFixed(1)}`,p=D(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(D(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=>D(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"?[D(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",D(n,"offset")),D(n,"offset_frequency").toFixed(1),this.uniform("float",D(n,"squash")),D(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=D(n,"data_type")==="FLOAT_VECTOR",c=D(n,"interpolation_type").toLowerCase(),_=D(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(D(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([ge])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${D(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${D(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"}[D(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${l}`)}(${h([D(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 io(this.graph,this.s,!0,`${d}_`),p=m.source(l,"float");this.s.functions[Number(d.slice(8))]=`float ${d}() {
|
|
7023
7023
|
${m.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");s.push(`float ${a}_h = ${d}();`,`g_derivative_filter_width = ${v} * derivative_scale_get();`,`g_derivative_flag = 1; float ${a}_hx = ${d}();`,`g_derivative_flag = -1; float ${a}_hy = ${d}();`,"g_derivative_flag = 0;");const g=D(n,"invert")?"-1.0":"1.0";s.push(`${this.use("node_bump")}(${this.input(n,"Strength","float")}, ${this.input(n,"Distance","float")}, ${v}, ${a}_h, ${_}, vec2(${a}_hx, ${a}_hy), ${g}, ${u([0])});`);break}case"ShaderNodeNormalMap":{const l=D(n,"space"),c=this.input(n,"Strength","float"),_=this.input(n,"Color","vec3"),d=`${a}_n`;if(s.push(`vec3 ${d}; ${this.use(l.startsWith("BLENDER_")?"color_to_blender_normal_new_shading":"color_to_normal_new_shading")}(${_}, ${d});`),n.props.convention==="DIRECTX"&&s.push(`${this.use("color_invert_green_channel")}(${d}, ${d});`),l==="TANGENT"){const m=D(n,"uv_map");this.s.uvs.add(m),s.push(`${this.use("node_normal_map")}(blender_uv_tangent(${Ht(m)}), ${c}, ${d}, g_data.Ni, ${u([0])});`)}else(l==="OBJECT"||l==="BLENDER_OBJECT")&&s.push(`${this.use("normal_transform_object_to_world")}(${d}, ${d});`),s.push(`${this.use("node_normal_map_mix")}(${c}, ${d}, ${u([0])});`);break}case"ShaderNodeNewGeometry":{s.push(`${this.use("node_geometry")}(${["blender_orco()",u(r.map((l,c)=>c))].join(", ")});`),r[0]&&s.push(`${r[0].name} = ${this.d(r[0].name)};`);for(const l of[1,2,4])r[l]&&s.push(`${r[l].name} = normalize(${r[l].name});`);break}case"ShaderNodeTexImage":{const l=D(n,"image");if(l===null){s.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=D(n,"projection"),_=D(n,"interpolation"),d=_==="Cubic"||_==="Smart",m=D(n,"extension"),p=`bgImage${this.s.images.length}`;this.s.images.push({uniform:p,node:t,name:l.name,revision:l.revision,extension:m,closest:_==="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=`${a}_n`;s.push(`vec3 ${O}; ${this.use("world_normals_get")}(${O}); ${this.use("normal_transform_world_to_object")}(${O}, ${O});`,`vec4 ${a}_c1, ${a}_c2, ${a}_c3;`,`${this.use(d?"tex_box_sample_cubic":"tex_box_sample_linear")}(${g}, ${O}, ${p}, ${a}_c1, ${a}_c2, ${a}_c3);`,`${this.use("tex_box_blend")}(${O}, ${a}_c1, ${a}_c2, ${a}_c3, ${this.uniform("float",D(n,"projection_blend"))}, ${w}, ${y});`)}else if(v)d&&this.use("cubic_bspline_coefficients"),s.push(`${d?"blender_tex_tile_cubic":"blender_tex_tile_linear"}(${g}, ${p}, ${p}Map, ${w}, ${y});`);else{if(c==="SPHERE"||c==="TUBE"){const O=`${a}_co`;s.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}s.push(`${this.use(d?"node_tex_image_cubic":"node_tex_image_linear")}(${g}, ${p}, ${w}, ${y});`),m==="CLIP"&&s.push(`if (any(lessThan(${g}.xy, vec2(0.0))) || any(greaterThan(${g}.xy, vec2(1.0)))) { ${w} = vec4(0.0); ${y} = 0.0; }`)}const S=D(n,"image_alpha_mode"),T=this.uses(t,1),A=u([0]);S==="NONE"||S==="CHANNEL_PACKED"||D(n,"image_is_data")?s.push(`${A}.a = 1.0;`):S==="PREMUL"?s.push(T?`if (${A}.a != 0.0 && ${A}.a != 1.0) ${A}.rgb /= ${A}.a;`:`${A}.a = 1.0;`):s.push(T?`${A}.a = 1.0;`:`${A}.rgb *= ${A}.a;`);break}}return this.lines.push(...s),r}uses(t,n){const e=r=>"link"in r&&r.link[0]===t&&r.link[1]===n,a=r=>r!==void 0&&("emission"in r?r.emission.some(e):"mix"in r?e(r.mix[0])||a(r.mix[1])||a(r.mix[2]):"add"in r?a(r.add[0])||a(r.add[1]):!1);return Object.values(this.graph.inputs).some(e)||Object.values(this.graph.nodes).some(r=>r.inputs.some(e))||a(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 a=0;for(const[l,c]of Object.entries(t)){const _=this.graph.inputs[l];if(!_||l==="Normal"&&!("link"in _))continue;const d=`bgOut${a++}`;n[l]={global:d,type:c},this.s.structure.push(["out",l]),e.push(`${d} = ${this.source(_,c)};`)}const r=this.graph.closure;if(r){let l=0;const c=(_,d)=>{if("principled"in _)this.s.structure.push("cP"),e.push(`bgClosureP += ${d};`);else if("emission"in _)this.s.structure.push("cE"),e.push(`bgClosureE += ${d} * ${this.source(_.emission[0],"vec4")}.rgb * ${this.source(_.emission[1],"float")};`);else if("transparent"in _)this.s.structure.push("cT"),e.push(`bgClosureT += ${d} * ${this.source({value:_.transparent},"float")};`);else if("mix"in _){this.s.structure.push("cM");const m=`bgClosureF${l++}`;e.push(`float ${m} = clamp(${this.source(_.mix[0],"float")}, 0.0, 1.0);`),c(_.mix[1],`${d} * (1.0 - ${m})`),c(_.mix[2],`${d} * ${m}`)}else"add"in _?(this.s.structure.push("cA"),c(_.add[0],d),c(_.add[1],d)):this.s.structure.push("c0")};e.push("bgClosureP = 0.0;","bgClosureE = vec3(0.0);","bgClosureT = 0.0;"),c(r,"1.0")}const i=[],f=new Set,u=l=>{if(!f.has(l)){f.add(l);for(const c of Kn[l].deps)u(c);i.push(l)}};for(const l of this.s.files)u(l);const h=`void blenderGraph() {
|
|
7027
7027
|
blender_init_globals();
|
|
7028
7028
|
${[...this.lines,...e].join(`
|
|
7029
7029
|
`)}
|
|
7030
|
-
}`,
|
|
7030
|
+
}`,s=[Mr,Hr(Ur+i.map(l=>Kn[l].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
|
+
`+Wr,[...this.s.functions,h].join(`
|
|
7033
|
+
`)),...[...this.s.uniformTypes].map(([l,c])=>`uniform ${c} ${l};`),...this.images.map(l=>l.tiled?`uniform highp sampler2DArray ${l.uniform};
|
|
7034
|
+
uniform highp sampler2D ${l.uniform}Map;`:`uniform sampler2D ${l.uniform};`),...this.ramps.map(l=>`uniform sampler2D ${l.uniform};`),...Object.values(n).map(l=>`${l.type} ${l.global};`),...r?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,h].join(`
|
|
7035
|
+
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:s,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:r!==void 0}}}function Hr(o,t){const n=[],e=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let a=0;for(let u;u=e.exec(o);){if(u.index<a)continue;let h=u.index+u[0].length;for(let _=1;h<o.length&&_>0;h++)_+=o[h]==="("?1:o[h]===")"?-1:0;const s=o.slice(h).match(/^\s*(\{|;)/);if(!s||/^\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
|
|
7038
|
-
`).find(
|
|
7037
|
+
`))continue;let c=h+s[0].length;if(s[1]==="{")for(let _=1;c<o.length&&_>0;c++)_+=o[c]==="{"?1:o[c]==="}"?-1:0;n.push({text:o.slice(a,u.index),name:null}),n.push({text:o.slice(u.index,c),name:u[1]}),a=c,e.lastIndex=c}n.push({text:o.slice(a),name:null});const r=new Set(n.filter(u=>u.name===null)),i=new Set,f=u=>{for(const h of u.matchAll(/[A-Za-z_]\w*/g))i.add(h[0])};f(t);for(const u of r)f(u.text);for(let u=!0;u;){u=!1;for(const h of n)r.has(h)||h.name===null||!i.has(h.name)||(r.add(h),f(h.text),u=!0)}return n.filter(u=>r.has(u)).map(u=>u.text).join("")}function Jn(o){return`v${jt(o)}`}function Ht(o){return o===""?"vBlenderUvRender":`vBlenderUv_${[...o].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function qr(o){return new io(o).compile()}function Gr(o){const t=new Uint16Array(o.length*4);o.forEach((e,a)=>t.set([e[0]??0,e[1]??0,e[2]??0,e[3]??1].map(r=>nn.toHalfFloat(r)),a*4));const n=new Sn(t,o.length,1,En,oo);return n.minFilter=n.magFilter=Vt,n.wrapS=n.wrapT=Ko,n.needsUpdate=!0,n}const dt=new WeakMap,xe=new Set,$t=new WeakMap,un=new WeakMap;function _n(o){const t=$t.get(o);if(t){$t.delete(o);for(const n of t.binding.ramps)n.dispose()}}function Xr(o,t,n,e=!1){const a=dt.get(o);if(t&&xe.has(t.key)&&(t=null),!t){if(_n(o),a){for(const f of a.ramps)f.dispose();dt.delete(o),o.needsUpdate=!0}return}if(a&&a.compiled.key===t.key){_n(o),mn(a,t,n);return}if(e){_n(o);for(const u of a?.ramps??[])u.dispose();const f={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};mn(f,t,n),dt.set(o,f),o.needsUpdate=!0;return}const r=$t.get(o);if(r&&r.binding.compiled.key===t.key){mn(r.binding,t,n);return}_n(o);const i={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};mn(i,t,n),$t.set(o,{binding:i,started:!1})}function mn(o,t,n){o.compiled=t;for(const[e,a]of t.uniforms){const r=typeof a=="number"?a:a.length===2?new Lt(...a):a.length===3?new x(...a):new no(...a),i=o.uniforms[e];i?i.value=r:o.uniforms[e]={value:r}}for(const e of o.ramps)e.dispose();o.ramps=t.ramps.map(e=>{const a=Gr(e.table);return(o.uniforms[e.uniform]??={value:null}).value=a,a});for(const e of t.images){const a=n(e);if(e.tiled){const r=a!==null&&"tiles"in a?a:null;(o.uniforms[e.uniform]??={value:null}).value=r?.tiles??null,(o.uniforms[`${e.uniform}Map`]??={value:null}).value=r?.map??null}else(o.uniforms[e.uniform]??={value:null}).value=a!==null&&"tiles"in a?null:a}}function Yr(o){const t=dt.get(o);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function Zr(o){return Object.values(dt.get(o)?.channels??{})}function Co(o,t){const n=t.userData.blenderUvChannels,e=t.getAttribute("position")?.count??0,a={};for(const r of o.uvs){let i=r===""?0:n?.[r];i===void 0&&(i=9,t.getAttribute("uv9")?.count!==e&&t.setAttribute("uv9",new it(new Float32Array(e*2),2))),a[r]=i}return a}function Qr(o,t,n,e,a,r,i){const f=un.get(o);f&&++f.draws>1&&(f.shadow.dispose(),un.delete(o));const u=$t.get(o);if(u&&!u.started){u.started=!0,u.binding.channels=Co(u.binding.compiled,t);const c=i(o);dt.set(c,u.binding);const _=new Tt(t,c);_.castShadow=r.castShadow,_.receiveShadow=r.receiveShadow;const d=()=>{if($t.get(o)!==u){c.dispose();return}$t.delete(o);for(const m of dt.get(o)?.ramps??[])m.dispose();dt.set(o,u.binding),o.needsUpdate=!0,un.get(o)?.shadow.dispose(),un.set(o,{shadow:c,draws:0}),vt()};n.compileAsync(_,a,e).then(d,d)}const h=dt.get(o);if(!h)return;const s=n.properties.get(o).currentProgram;if(s?.diagnostics?.runnable===!1&&s.cacheKey?.includes(h.compiled.key)){xe.add(h.compiled.key),dt.delete(o),o.needsUpdate=!0;const c=s.diagnostics.fragmentShader.log.split(`
|
|
7038
|
+
`).find(_=>_.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 l=Co(h.compiled,t);JSON.stringify(l)!==JSON.stringify(h.channels)&&(h.channels=l,o.needsUpdate=!0)}function Kr(o){const t=Array.isArray(o.material)?o.material:[o.material];if(!t.some(u=>u instanceof ln&&dt.has(u)))return;const n=o.geometry,e=o.userData.blenderTexspace??null,a=n.getAttribute("position"),r=JSON.stringify([e,a?.version??0,a?.count??0]);!n.userData.blenderOrcoFromDoor&&n.userData.blenderOrcoStamp!==r&&(n.setAttribute("blenderOrco",Jr(n,e)),n.userData.blenderOrcoStamp=r);const i=a?.count??0,f=o.userData.blenderDefaultColor;for(const u of t){const h=u instanceof ln?dt.get(u):void 0;for(const s of h?.compiled.attributes??[]){const l=jt(s),c=s===""?f===void 0?void 0:n.getAttribute(jt(f)):n.getAttribute(l);c&&c.count===i?n.getAttribute(l)!==c&&n.setAttribute(l,c):n.getAttribute(l)?.count!==i&&n.setAttribute(l,new it(new Float32Array(i*4),4))}}}function Jr(o,t){const n=o.getAttribute("position");let e,a;if(t)e=[...t[0]],a=[...t[1]];else{o.computeBoundingBox();const i=o.boundingBox;e=[(i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2],a=[(i.max.x-i.min.x)/2,(i.max.y-i.min.y)/2,(i.max.z-i.min.z)/2]}a=a.map(i=>i===0?1:i);const r=new Float32Array(n.count*3);for(let i=0;i<n.count;i++)r[i*3]=(n.getX(i)-e[0])/a[0]*.5+.5,r[i*3+1]=(n.getY(i)-e[1])/a[1]*.5+.5,r[i*3+2]=(n.getZ(i)-e[2])/a[2]*.5+.5;return new it(r,3)}function tl(o,t){const n=dt.get(o);if(!n)return;const{compiled:e,channels:a}=n;Object.assign(t.uniforms,n.uniforms,{blenderViewport:{value:be}});const r=v=>v===0?"uv":`uv${v}`,i=`varying vec3 vBlenderObjectPosition;
|
|
7039
7039
|
varying vec3 vBlenderObjectNormal;
|
|
7040
7040
|
varying vec3 vBlenderWorldPosition;
|
|
7041
7041
|
varying vec3 vBlenderWorldNormal;
|
|
@@ -7043,20 +7043,20 @@ varying vec3 vBlenderOrco;
|
|
|
7043
7043
|
${e.attributes.map(v=>`varying vec4 ${Jn(v)};`).join(`
|
|
7044
7044
|
`)}
|
|
7045
7045
|
${e.uvs.map(v=>`varying vec2 ${Ht(v)};`).join(`
|
|
7046
|
-
`)}`,
|
|
7046
|
+
`)}`,f=e.attributes.map(v=>`attribute vec4 ${jt(v)};`).join(`
|
|
7047
7047
|
`);t.vertexShader=`attribute vec3 blenderOrco;
|
|
7048
|
-
${
|
|
7049
|
-
${
|
|
7048
|
+
${f}
|
|
7049
|
+
${i}
|
|
7050
7050
|
${t.vertexShader}`.replace("#include <project_vertex>",`vBlenderObjectPosition = transformed;
|
|
7051
7051
|
vBlenderObjectNormal = objectNormal;
|
|
7052
7052
|
vBlenderWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;
|
|
7053
7053
|
vBlenderWorldNormal = normalize(transpose(inverse(mat3(modelMatrix))) * objectNormal);
|
|
7054
7054
|
vBlenderOrco = blenderOrco;
|
|
7055
|
-
${e.attributes.map(v=>`${Jn(v)} = ${
|
|
7055
|
+
${e.attributes.map(v=>`${Jn(v)} = ${jt(v)};`).join(`
|
|
7056
7056
|
`)}
|
|
7057
|
-
${e.uvs.map(v=>`${Ht(v)} = ${a
|
|
7057
|
+
${e.uvs.map(v=>`${Ht(v)} = ${r(a[v]??0)};`).join(`
|
|
7058
7058
|
`)}
|
|
7059
|
-
#include <project_vertex>`);const u=v=>e.outputs[v]?.global,
|
|
7059
|
+
#include <project_vertex>`);const u=v=>e.outputs[v]?.global,h=[];e.surface==="ShaderNodeEmission"?(h.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),h.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Color")}.rgb * ${u("Strength")};`,!1]),h.push(["#include <opaque_fragment>","outgoingLight = totalEmissiveRadiance;",!0])):e.surface==="closure"?(h.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),h.push(["#include <emissivemap_fragment>","totalEmissiveRadiance = vec3(0.0);",!1])):(h.push(["#include <color_fragment>",`diffuseColor.rgb = ${u("Base Color")}.rgb;`,!1]),h.push(["#include <alphamap_fragment>",`diffuseColor.a = ${u("Alpha")};`,!1]),h.push(["#include <metalnessmap_fragment>",`roughnessFactor = ${u("Roughness")};`,!0]),h.push(["#include <metalnessmap_fragment>",`metalnessFactor = ${u("Metallic")};`,!1]),h.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Emission Color")}.rgb * ${u("Emission Strength")};`,!1]),u("Normal")&&h.push(["#include <clearcoat_normal_fragment_begin>",`normal = normalize((viewMatrix * vec4(transpose(blender_from_three) * ${u("Normal")}, 0.0)).xyz);`,!0])),e.closure&&h.push(["#include <opaque_fragment>",`{
|
|
7060
7060
|
float blenderCoverage = diffuseColor.a;
|
|
7061
7061
|
vec3 blenderRadiance = bgClosureP * blenderCoverage * outgoingLight + bgClosureE;
|
|
7062
7062
|
float blenderAlpha = 1.0 - min(bgClosureT + bgClosureP * (1.0 - blenderCoverage), 1.0);
|
|
@@ -7066,17 +7066,17 @@ ${e.uvs.map(v=>`${Ht(v)} = ${a(r[v]??0)};`).join(`
|
|
|
7066
7066
|
outgoingLight = blenderRadiance / max(blenderAlpha, 1e-4);
|
|
7067
7067
|
#endif
|
|
7068
7068
|
diffuseColor.a = blenderAlpha;
|
|
7069
|
-
}`,!0]);const
|
|
7070
|
-
`);let p=t.fragmentShader.replace("void main() {",`${
|
|
7069
|
+
}`,!0]);const s=v=>v.replace(/^[ \t]*#include <(\w+)>/gm,(g,w)=>s(Dt[w]??"")),l=s(t.fragmentShader.slice(0,t.fragmentShader.indexOf("void main() {"))),c=new Map([...l.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)),m=[...d.map(v=>`#undef ${v}`),e.declarations,...d.flatMap(v=>[`#undef ${v}`,c.get(v)])].join(`
|
|
7070
|
+
`);let p=t.fragmentShader.replace("void main() {",`${i}
|
|
7071
7071
|
${m}
|
|
7072
7072
|
void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
|
|
7073
|
-
blenderGraph();`);for(const[v,g,
|
|
7073
|
+
blenderGraph();`);for(const[v,g,w]of h){if(!p.includes(v))throw new Error(`three's physical shader has no ${v}`);p=p.replace(v,w?`${g}
|
|
7074
7074
|
${v}`:`${v}
|
|
7075
|
-
${g}`)}t.fragmentShader=p}const
|
|
7076
|
-
attribute vec2 uv${
|
|
7077
|
-
#endif`:`attribute vec2 uv${
|
|
7075
|
+
${g}`)}t.fragmentShader=p}const be=new Lt(1,1);function nl(o){o.getDrawingBufferSize(be)}function ol(o,t){const n=t.userData.blenderUvChannels;for(const e of[o.map,o.roughnessMap,o.normalMap]){if(!e)continue;const a=e.userData.blenderUvName;let r=a?n?.[a]:0;if(r===void 0){r=9;const i=t.getAttribute("position")?.count;if(i===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==i&&t.setAttribute("uv9",new it(new Float32Array(i*2),2))}e.channel!==r&&(e.channel=r,o.needsUpdate=!0)}}class el{constructor(){this.bindings=new Map}get(t,n,e,a,r=""){let i=this.bindings.get(t);if(!i||i.source!==n){this.delete(t),i={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,i);const h=i;a&&a.then(()=>{h.disposed||(h.texture.needsUpdate=!0,h.version=n.version,vt())},()=>{})}const f=e==="REPEAT"?Ve:e==="MIRROR"?je:Ko,u=i.texture.wrapS!==f||i.texture.wrapT!==f;return i.texture.wrapS=i.texture.wrapT=f,i.texture.userData.blenderUvName=r,n.image&&(u||i.version!==n.version)&&(i.texture.needsUpdate=!0,i.version=n.version),i.texture}delete(t){const n=this.bindings.get(t);n&&(n.disposed=!0,n.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const mt=M().finite(),$n=$([mt,mt,mt]),al=P({coat:mt,coat_roughness:mt,coat_ior:mt,coat_tint:$n,sheen:mt,sheen_roughness:mt,sheen_tint:$n,anisotropy:mt,anisotropy_rotation:mt,specular_level:mt,specular_tint:$n,film_thickness:mt,film_ior:mt}).strict(),rl={coat:0,coat_roughness:.03,coat_ior:1.5,coat_tint:[1,1,1],sheen:0,sheen_roughness:.5,sheen_tint:[1,1,1],anisotropy:0,anisotropy_rotation:0,specular_level:.5,specular_tint:[1,1,1],film_thickness:0,film_ior:1.33},Xt=new WeakMap;function ll(o,t){Xt.has(o)||so(o),Xt.get(o).blenderWorldExtinction.value.copy(t)}function il(o){const t=new ln,n=Xt.get(o);so(t),t.copy(o);const e=Xt.get(t);return n&&(e.blenderCoatIor.value=n.blenderCoatIor.value,e.blenderCoatTint.value.copy(n.blenderCoatTint.value),e.blenderMapClip.value=n.blenderMapClip.value,e.blenderRoughnessClip.value=n.blenderRoughnessClip.value,e.blenderNormalClip.value=n.blenderNormalClip.value,e.blenderWorldExtinction.value.copy(n.blenderWorldExtinction.value)),t}function so(o,t,n={}){const e=t??rl;o.clearcoat=e.coat,o.clearcoatRoughness=e.coat_roughness,o.sheen=e.sheen,o.sheenRoughness=e.sheen_roughness,o.sheenColor.setRGB(...e.sheen_tint,ft),o.anisotropy=e.anisotropy,o.anisotropyRotation=e.anisotropy_rotation*Math.PI*2,o.specularIntensity=e.specular_level*2,o.specularColor.setRGB(...e.specular_tint,ft),o.iridescence=e.film_thickness>0?1:0,o.iridescenceIOR=e.film_ior,o.iridescenceThicknessRange=[e.film_thickness,e.film_thickness];let a=Xt.get(o);if(!a){a={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new ht(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new x}},Xt.set(o,a);const r=a;o.customProgramCacheKey=()=>`blender-principled-physical-v5${Yr(o)}`,o.onBeforeRender=(i,f,u,h,s)=>{ol(o,h),Qr(o,h,i,f,u,s,il),nl(i)},o.onBeforeCompile=i=>{const f=new Set([o.map,o.roughnessMap,o.normalMap].flatMap(d=>d?[d.channel]:[]).concat(Zr(o)));i.vertexShader=[...f].filter(d=>d>0).sort((d,m)=>d-m).map(d=>d<=3?`#ifndef USE_UV${d}
|
|
7076
|
+
attribute vec2 uv${d};
|
|
7077
|
+
#endif`:`attribute vec2 uv${d};`).join(`
|
|
7078
7078
|
`)+`
|
|
7079
|
-
`+
|
|
7079
|
+
`+i.vertexShader,Object.assign(i.uniforms,r),i.fragmentShader=`uniform float blenderCoatIor;
|
|
7080
7080
|
uniform vec3 blenderWorldExtinction;
|
|
7081
7081
|
vec3 blenderInfiniteTransmission() { return vec3(
|
|
7082
7082
|
blenderWorldExtinction.x>0.?0.:1., blenderWorldExtinction.y>0.?0.:1., blenderWorldExtinction.z>0.?0.:1.); }
|
|
@@ -7087,36 +7087,36 @@ attribute vec2 uv${h};
|
|
|
7087
7087
|
if (clipImage && (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0))))) pixel = vec4(0.0);
|
|
7088
7088
|
return pixel;
|
|
7089
7089
|
}
|
|
7090
|
-
`+
|
|
7090
|
+
`+i.fragmentShader;const u=Dt.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 ) ) );"),h=Dt.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)"),s=Dt.map_fragment.replace("texture2D( map, vMapUv )","blenderImageSample(map, vMapUv, blenderMapClip)").replace("diffuseColor *= sampledDiffuseColor;","diffuseColor.rgb *= sampledDiffuseColor.rgb;"),l=Dt.roughnessmap_fragment.replace("texture2D( roughnessMap, vRoughnessMapUv )","blenderImageSample(roughnessMap, vRoughnessMapUv, blenderRoughnessClip)"),c=Dt.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()"),_=Dt.lights_fragment_maps.replaceAll(/(getIBL(?:Irradiance|Radiance|AnisotropyRadiance)\([^;]+\))/g,"$1 * blenderInfiniteTransmission()");i.fragmentShader=i.fragmentShader.replace("#include <lights_physical_fragment>",u).replace("#include <lights_fragment_begin>",c).replace("#include <lights_fragment_maps>",_).replace("#include <normal_fragment_maps>",h).replace("#include <map_fragment>",s).replace("#include <roughnessmap_fragment>",l).replace("vec3 Fcc = F_Schlick",`
|
|
7091
7091
|
// Blender's slab_transmittance_at_angle (gpu_shader_material_principled.glsl):
|
|
7092
7092
|
// Beer-Lambert attenuation through a refracting coat at this view angle.
|
|
7093
7093
|
float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
|
|
7094
7094
|
blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
|
|
7095
7095
|
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(
|
|
7098
|
-
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(
|
|
7099
|
-
`,v=
|
|
7100
|
-
`,
|
|
7096
|
+
vec3 Fcc = F_Schlick`),tl(o,i)},o.needsUpdate=!0}a.blenderCoatIor.value=Math.max(1,e.coat_ior),a.blenderCoatTint.value.setRGB(...e.coat_tint,ft),a.blenderMapClip.value=n.map===!0,a.blenderRoughnessClip.value=n.roughness===!0,a.blenderNormalClip.value=n.normal===!0}function fo(o){const t=a=>{if(!(!a||typeof a!="object")){if("kind"in a&&["direction","window","sky"].includes(String(a.kind)))throw new Error(`World volume spatial input ${a.kind} is not implemented`);for(const r of Object.values(a))t(r)}};t(o);const n=nt(o)(new x);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function Bt(o){const t=fo(o);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function dn(o){const t=fo(o);return(typeof t=="number"?new x().setScalar(t):t.clone()).max(new x)}function sl(o){if(o<800)return new x(5.413294490189271,0,0);if(o>=12e3)return new x(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(r=>o>=r).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],e=[[-488.999748,.000604330754,-.0755807526],[-755.994277,.000316730098,.478306139],[-1023.63977,.00012022347,.936662319],[-1265.71316,487340896e-14,1.27054498],[-1425.29332,-401150431e-13,1.43972784],[-1175.54822,-216378048e-13,1.30408023],[-500.799571,-459832026e-14,1.09098763]][t],a=[[596945309e-19,-485742887e-16,-970622247e-13,-.00407936148],[240430366e-19,555021075e-16,-.000198503712,.0289312858],[-140949732e-19,189878968e-15,-.000356632824,.0910767778],[-361460868e-19,284822009e-15,-.000493211319,.15672344],[-197075738e-19,175359352e-15,-.000250542825,-.0222783266],[-161997957e-21,-164216008e-16,.000386216271,-.738077418],[672650283e-21,-273078809e-16,.000424098264,-.752335691]][t];return new x(n[0]/o+n[1]*o+n[2],e[0]/o+e[1]*o+e[2],((a[0]*o+a[1])*o+a[2])*o+a[3]).max(new x)}function ko(o){if(!o?.volume?.length)return null;const t={extinction:new x,emission:new x,lobes:[]};for(const n of o.volume){const e=Bt(n.weight);if(e===0)continue;const a=dn(n.color),r=Bt(n.density),i=new x,f=new x;if(n.kind==="absorption"&&i.set(1-a.x,1-a.y,1-a.z).max(new x).multiplyScalar(r),n.kind==="scatter"||n.kind==="principled"){f.copy(a).multiplyScalar(r);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const h=fo(n.anisotropy);if(typeof h!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:f.clone().multiplyScalar(e),g:u==="RAYLEIGH"?0:ut.clamp(h,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?Bt(n.alpha):0})}if(n.kind==="principled"){const u=dn(n.absorption_color);i.set(Math.max(1-a.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-a.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-a.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(r);const h=Bt(n.blackbody_intensity);if(h>.001){const s=Bt(n.temperature),l=5670373e-20/Math.PI*(1+h*(s**4-1));t.emission.add(sl(s).multiply(dn(n.blackbody_tint)).multiplyScalar(l*e))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?a:dn(n.emission_color)).multiplyScalar(Bt(n.emission_strength)*e)),t.extinction.add(i.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 fl{constructor(t){this.medium=t,this.target=new Be(1,1,{type:oo,depthBuffer:!1}),this.geometry=new Jo(2,2),this.scene=new Ue,this.camera=new We}render(t,n,e,a){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const r={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:a.projectionMatrixInverse},cameraWorld:{value:a.matrixWorld},orthographic:{value:a.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let i="",f="",u=0,h=2;e.traverseVisible(_=>{if(!(_ instanceof Bn||_ instanceof Un||_ instanceof gn))return;const d=_,m=u++,p=d.getWorldPosition(new x);r[`lp${m}`]={value:p},r[`lc${m}`]={value:d.color.clone().multiplyScalar(d.intensity)},i+=`uniform vec3 lp${m}, lc${m};
|
|
7097
|
+
`;let v="1.0",g="1.0";if(d instanceof Un&&(r[`ld${m}`]={value:d.target.getWorldPosition(new x).sub(p).normalize()},r[`cone${m}`]={value:new Lt(Math.cos(d.angle),Math.cos(d.angle*(1-d.penumbra)))},i+=`uniform vec3 ld${m}; uniform vec2 cone${m};
|
|
7098
|
+
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(d instanceof gn)&&d.castShadow&&d.shadow.map){if(++h>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");r[`sm${m}`]={value:d.shadow.map.texture},r[`sx${m}`]={value:d.shadow.matrix},r[`ss${m}`]={value:d.shadow.mapSize},r[`sb${m}`]={value:d.shadow.bias},r[`sn${m}`]={value:d.shadow.camera.near},r[`sf${m}`]={value:d.shadow.camera.far},i+=`uniform sampler2D sm${m}; uniform mat4 sx${m}; uniform vec2 ss${m}; uniform float sb${m},sn${m},sf${m};
|
|
7099
|
+
`,v=d instanceof Bn?`getPointShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0),sn${m},sf${m})`:`getShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0))`}if(d instanceof gn){const w=new X().extractRotation(d.matrixWorld);r[`lx${m}`]={value:new x(d.width,0,0).applyMatrix4(w)},r[`ly${m}`]={value:new x(0,d.height,0).applyMatrix4(w)},r[`ln${m}`]={value:new x(0,0,-1).transformDirection(w)},i+=`uniform vec3 lx${m},ly${m},ln${m};
|
|
7100
|
+
`,f+=`for(int ax=0;ax<4;ax++) for(int ay=0;ay<4;ay++) {
|
|
7101
7101
|
vec3 delta=lp${m}+lx${m}*((float(ax)+.5)/4.-.5)+ly${m}*((float(ay)+.5)/4.-.5)-p;
|
|
7102
7102
|
float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7103
7103
|
sum+=lc${m}*exp(-sigma*d)*phase(dot(L,ray))*max(dot(-L,ln${m}),0.)*
|
|
7104
7104
|
length(lx${m})*length(ly${m})/(16.*max(d*d,1e-4)); }
|
|
7105
|
-
`}else
|
|
7106
|
-
`,
|
|
7105
|
+
`}else r[`cut${m}`]={value:d.distance},r[`decay${m}`]={value:d.decay},i+=`uniform float cut${m},decay${m};
|
|
7106
|
+
`,f+=`{ vec3 delta=lp${m}-p; float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7107
7107
|
float cutoff=cut${m}>0.?pow(clamp(1.-pow(d/cut${m},4.),0.,1.),2.):1.;
|
|
7108
7108
|
sum+=lc${m}*exp(-sigma*d)*phase(dot(L,ray))*${g}*${v}*cutoff/max(pow(d,decay${m}),.01); }
|
|
7109
|
-
`});let
|
|
7110
|
-
`,
|
|
7109
|
+
`});let s="vec3 result=vec3(0.);";this.medium.lobes.forEach((_,d)=>{r[`scatter${d}`]={value:_.coefficient},r[`g${d}`]={value:_.g},r[`a${d}`]={value:_.alpha},i+=`uniform vec3 scatter${d}; uniform float g${d},a${d};
|
|
7110
|
+
`,s+=`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 l=this.medium.extinction.toArray().filter(_=>_>0);r.range={value:l.length?20/Math.min(...l):1},this.material?.dispose(),this.material=new to({uniforms:r,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
7111
|
#include <common>
|
|
7112
7112
|
#include <packing>
|
|
7113
7113
|
#include <shadowmap_pars_fragment>
|
|
7114
7114
|
varying vec2 vUv; uniform sampler2D surface,depth;
|
|
7115
7115
|
uniform mat4 inverseProjection,cameraWorld; uniform bool orthographic;
|
|
7116
7116
|
uniform vec3 sigma,emission; uniform float range;
|
|
7117
|
-
${
|
|
7118
|
-
vec3 phase(float c){${
|
|
7119
|
-
vec3 incident(vec3 p,vec3 ray){vec3 sum=vec3(0.);${
|
|
7117
|
+
${i}
|
|
7118
|
+
vec3 phase(float c){${s} return result;}
|
|
7119
|
+
vec3 incident(vec3 p,vec3 ray){vec3 sum=vec3(0.);${f}return sum;}
|
|
7120
7120
|
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
7121
|
void main(){
|
|
7122
7122
|
float z=texture2D(depth,vUv).r; vec4 base=texture2D(surface,vUv);
|
|
@@ -7137,10 +7137,10 @@ attribute vec2 uv${h};
|
|
|
7137
7137
|
radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
|
|
7138
7138
|
}
|
|
7139
7139
|
gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
|
|
7140
|
-
}`}),this.scene.clear(),this.scene.add(new Tt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const _=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(_)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const sl=A({object:E(),group:E(),groupIndex:S().int().nonnegative(),count:S().int().nonnegative(),digest:E(),alertMode:B(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:E().optional(),alertBase64:E().optional()}).strict();function fl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[r,a,l]=cl(2/3*(1-n)),c=new ht;return c.setRGB((r*e)**(1/1.5),(a*e)**(1/1.5),(l*e)**(1/1.5),Mt),c}function cl(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const ul=0;function ko(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class _l{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const r=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==r)return this.clear(),`weights: the session sent a reference to ${r} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${r} carried neither an array nor a reference`;const h=ko(t.weightsBase64);this.held={key:r,weights:new Float32Array(h.buffer,h.byteOffset,t.count),alerts:ko(t.alertBase64)}}const a=this.held;if(a===null)return null;const l=`${r}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(l===this.signature&&this.mesh!==null)return null;this.signature=l,this.clear();const c=n.geometry.clone(),u=c.getAttribute("position"),f=c.getAttribute("blenderVertex");if(f===void 0)return c.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const i=new Float32Array(u.count*3),s=new ht().setHex(ul,Mt);for(let h=0;h<u.count;h++){const m=f.getX(h),v=t.alertMode!=="NONE"&&a.alerts[m]===1?s:fl(a.weights[m]??0);i[h*3]=v.r,i[h*3+1]=v.g,i[h*3+2]=v.b}c.setAttribute("color",new it(i,3)),c.deleteAttribute("blenderVertex");const _=new bn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),d=new Tt(c,_);return d.name=`${t.object}:weights`,d.frustumCulled=!1,d.matrixAutoUpdate=!1,d.matrix.copy(e),d.matrix.decompose(d.position,d.quaternion,d.scale),this.geometry=c,this.material=_,this.mesh=d,this.group.add(d),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const hn=S().finite(),ml=F($([hn,hn,hn,hn])).length(4),dl=20,$o=[16724818,9165824,2658559];function hl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function be(){return new Ue({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function pl(){const o=[],t=[],n=new ht(0,0,0),e=(a,l,c,u,f)=>{for(const i of[a,l]){const s=[0,0,0];s[c]=i*u,o.push(...s),t.push(f.r,f.g,f.b)}};for(let a=0;a<3;a++){const l=new ht().setHex($o[a],Mt);e(1,.85,a,1,l),e(.85,.25,a,1,n),e(1,.85,a,-1,hl($o[a])),e(.85,.25,a,-1,n)}const r=new fn;return r.setAttribute("position",new bt(o,3)),r.setAttribute("color",new bt(t,3)),new Jo(r,be())}function vl(){const t=[],n=[],e=new ht(1,0,0),r=new ht(1,1,1);for(let l=0;l<12;l++){const c=(l+1)%2===0?r:e;for(const u of[l,l+1]){const f=2*Math.PI*u/12;t.push(.5*Math.cos(f),.5*Math.sin(f),0),n.push(c.r,c.g,c.b)}}const a=new fn;return a.setAttribute("position",new bt(t,3)),a.setAttribute("color",new bt(n,3)),new Jo(a,be())}class gl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=pl(),this.circle=vl(),this.seen=null,this.size=new $t,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,r,a]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new gt(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 c=n;a=(c.top-c.bottom)/c.zoom/e}else{const c=n;a=2*Math.max(-r.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(c.fov)/2)/c.zoom/e}const l=a*dl;this.lines.scale.setScalar(l),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(l),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,r,a){const l=this.seen;if(l===null||e!==l.canvas)return null;const c=l.canvas.getBoundingClientRect(),u=new $t((t-c.left)/Math.max(c.width,1)*2-1,-((n-c.top)/Math.max(c.height,1))*2+1),f=new Be;f.setFromCamera(u,l.camera);const i=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},s=f.intersectObject(r,!0).find(m=>m.object.isMesh&&a(m.object)&&i(m.object));let _=s?s.point.clone():null;if(_===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=l.camera.getWorldDirection(new x),v=l.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),_=f.ray.intersectPlane(new It().setFromNormalAndCoplanarPoint(p,m),new x)}if(_===null)return null;r.updateWorldMatrix(!0,!1);const d=r.worldToLocal(_),h=r.getWorldQuaternion(new gt).invert().multiply(l.camera.getWorldQuaternion(new gt));return{location:[d.x,d.y,d.z],rotation:[h.w,h.x,h.y,h.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Rt=S().finite(),xl=A({display:B(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Rt,image:A({name:E().nullable(),offset:$([Rt,Rt]),depth:B(["DEFAULT","FRONT","BACK"]),side:B(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:Rt.nullable(),tint:$([Rt,Rt,Rt]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},bl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const r=2*Math.PI*e/t;return[o*Math.cos(r),o*Math.sin(r)]})}function ct(o,t,n=0,e=!1){const r=e?2:1;for(let a=0;a<Math.floor(t.length/r);a++){const l=t[a*r%t.length],c=t[(a*r+1)%t.length];K(o,[l[0],l[1],n],[c[0],c[1],n])}}function yl(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new X;let r=!1;o.onBeforeRender=(a,l,c,u,f,i)=>{t(a,l,c,u,f,i),l.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),r=!0)},o.onAfterRender=(a,l,c,u,f,i)=>{r&&(o.matrixWorld.copy(e),r=!1),n(a,l,c,u,f,i)}}class wl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new $t,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const r=e.selected?e.name===t.active?wt.active:wt.selected:e.type==="CAMERA"?wt.camera:e.type==="LIGHT"?wt.light:wt.empty,a=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,l=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,c=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!a&&!l&&!c)continue;n.add(e.name);const u=l&&e.light?t.lightDistances[e.light]??null:null,f=c?.image?.name?t.image(c.image.name):null,i=JSON.stringify([f?[f.texture.uuid,f.width,f.height]:null,e.matrix,r,a,l,u,c,a?[e.name===t.sceneCamera,t.renderAspect]:null]),s=this.drawn.get(e.name),_=t.presented(e.name);if(s?.key===i){for(const v of s.parts)v.userData.volterPicksAs=_;continue}s&&this.remove(s.parts);const d=new X().set(...e.matrix.flat()),h=a?this.cameras:l?this.lights:this.empties,m=new Set(h.children);a?this.camera(a,d,r,e.name===t.sceneCamera,t.renderAspect):l?this.light(l,d,r,u):c&&this.empty(c,d,r,f);const p=h.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=_,v.traverse(yl);this.drawn.set(e.name,{key:i,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 l=t.display_size,u=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let f,i,s,_;if(t.type==="ORTHO")s=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],_=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],i=-l,f=.5*t.ortho_scale;else{const P=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new x().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;f=l/2/((1/O.x+1/O.y+1/O.z)/3),i=f*t.lens/-P,s=[f*u[0],f*u[1]],_=[t.shift_x*f*2,t.shift_y*f*2]}const d=[[_[0]+s[0],_[1]+s[1],i],[_[0]+s[0],_[1]-s[1],i],[_[0]-s[0],_[1]-s[1],i],[_[0]-s[0],_[1]+s[1],i]],h=[];for(let P=0;P<4;P++)K(h,d[P],d[(P+1)%4]),K(h,d[P],[0,0,0]);const m=.7*f,p=.1*f,v=_[1]+s[1]+p,g=[[_[0]-m,v,i],[_[0]+m,v,i],[_[0],v+m,i]],b=$n(n);this.cameras.add(this.lines(h,e,1,b));let w;if(r){const P=new fn;P.setAttribute("position",new bt(g.flat(),3)),w=new Tt(P,this.fill(e)),w.matrixAutoUpdate=!1,w.matrix.copy(b)}else{const P=[];for(let O=0;O<3;O++)K(P,g[O],g[(O+1)%3]);w=this.lines(P,e,1,b)}const R=new x,T=w.onBeforeRender.bind(w);w.onBeforeRender=(P,O,M,C,V,H)=>{R.setFromMatrixPosition(b).applyMatrix4(this.cameras.matrixWorld);const Q=M.getWorldPosition(this.scratch).distanceToSquared(R)>1e-8;w.matrix.copy(b),Q||w.matrix.scale(new x(0,0,0)),w.updateMatrixWorld(!0),T(P,O,M,C,V,H)},this.cameras.add(w)}light(t,n,e,r){const a=new x().setFromMatrixPosition(n),l=[];K(l,[a.x,a.y,a.z],[a.x,a.y,0]),this.lights.add(this.lines(l,wt.light,wt.lightAlpha,new X));const c=[];ct(c,at(1.35,4)),this.lights.add(this.screen(c,wt.light,wt.lightAlpha,new x(a.x,a.y,0)));const u=[],f=9;if(ct(u,at(f*.3,4)),ct(u,at(f,16),0,!0),ct(u,at(f*1.33,20),0,!0),t.type==="SUN")for(const[_,d]of at(f,8))K(u,[_*1.6,d*1.6,0],[_*1.9,d*1.9,0]),K(u,[_*2.2,d*2.2,0],[_*2.5,d*2.5,0]);this.lights.add(this.screen(u,e,1,a));const i=$n(n),s=[];if(t.type==="SUN")K(s,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const _=(t.size??1)/2,d=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?ct(s,at(1,32).map(([h,m])=>[h*_,m*d])):ct(s,[[_,d],[-_,d],[-_,-d],[_,-d]])}if(s.length>0&&this.lights.add(this.lines(s,e,1,n.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const _=new x(0,0,-1).transformDirection(n),d=v=>a.clone().addScaledVector(_,v),[h,m]=r,p=[];K(p,d(h).toArray(),d(m).toArray()),this.lights.add(this.lines(p,e,1,new X));for(const v of[h,m]){const g=[];ct(g,at(1.2,4)),this.lights.add(this.screen(g,e,1,d(v)))}}if(t.type==="SPOT"){const _=(t.spot_size??Math.PI/4)/2,d=Math.cos(_),h=t.spot_blend??.15,m=d*h-d-h,p=Math.sqrt((d*d-d*d*m*m)/(m*m-d*d*m*m)),v=Math.sqrt(1-d*d),g=$n(n).multiply(new X().makeScale(10,10,10)),b=[];ct(b,at(v,32),-d),ct(b,at(v*p,32),-d),this.lights.add(this.lines(b,e,1,g.clone())),this.lights.add(this.silhouette(v,d,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const _=[];ct(_,at(t.radius,32)),this.lights.add(this.facing(_,e,new x().setFromMatrixPosition(i)))}}empty(t,n,e,r){const a=t.size,l=[],c=(f,i)=>{const s=at(1,i);for(let _=0;_<i;_++){const[d,h]=s[_],[m,p]=s[(_+1)%i],v=(g,b)=>f==="xy"?[g,b,0]:f==="xz"?[g,0,b]:[0,g,b];K(l,v(d,h),v(m,p))}};switch(t.display){case"PLAIN_AXES":K(l,[0,-1,0],[0,1,0]),K(l,[-1,0,0],[1,0,0]),K(l,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{K(l,[0,0,0],[0,0,.75]);for(const[f,i]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(l,[0,0,1],[f,i,.75]);ct(l,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[f,i]of Ol)K(l,Lo[f],Lo[i]);break;case"CIRCLE":c("xz",64);break;case"SPHERE":c("xy",32),c("xz",32),c("yz",32);break;case"CONE":{const f=at(1,8);for(let i=0;i<8;i++){const[s,_]=f[i],[d,h]=f[(i+1)%8];K(l,[s,0,_],[0,2,0]),K(l,[s,0,_],[d,0,h])}break}case"ARROWS":for(let f=0;f<3;f++){const i=[0,0,0];i[f]=1,K(l,[0,0,0],i)}break;case"IMAGE":this.imageEmpty(t,n,e,r);return}const u=n.clone().multiply(new X().makeScale(a,a,a));this.empties.add(this.lines(l,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 l=a.geometry.getAttribute("instanceStart").data,c=at(1,32).map(([d,h])=>new x(d*t,h*t,-n)),u=new x,f=new X,i=new x,s=new x,_=new x;return this.onDraw(a,(d,h)=>{f.copy(a.matrixWorld).invert();const m=h.isOrthographicCamera;m?h.getWorldDirection(u).negate().transformDirection(f):u.setFromMatrixPosition(h.matrixWorld).applyMatrix4(f);const p=l.array;let v=!1;for(let g=0;g<32;g++){const b=c[g];i.crossVectors(b,c[(g+31)%32]),s.crossVectors(c[(g+1)%32],b),m?_.copy(u):_.copy(u).sub(b);const w=i.dot(_)>0!=s.dot(_)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==w&&(v=!0),p.set([0,0,0,w?b.x:0,w?b.y:0,w?b.z:0],g*6)}v&&(l.needsUpdate=!0,vt())}),a}imageEmpty(t,n,e,r){const a=t.image;if(!a)return;const l=r?.width??0,c=r?.height??0,u=l>0&&c>0?l>=c?[1,c/l]:[l/c,1]:[1,1],f=new x,i=new x,s=new x;n.extractBasis(f,i,s),f.multiplyScalar(u[0]*.5*t.size),i.multiplyScalar(u[1]*.5*t.size);const _=new x().setFromMatrixPosition(n).addScaledVector(f,a.offset[0]*2+1).addScaledVector(i,a.offset[1]*2+1),d=new X().makeBasis(f,i,s.clone()).setPosition(_),h=[];ct(h,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(h,e,1,d),p=s.clone().normalize(),v=new x,g=new x,b=(M,C)=>{const V=M.isOrthographicCamera===!0;if(V?!a.orthographic:!a.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);M.getWorldDirection(g);let Q,tt;if(V)Q=H.dot(g.clone().negate()),tt=1e-5;else{const pt=_.clone().applyMatrix4(this.empties.matrixWorld);Q=H.dot(v.setFromMatrixPosition(M.matrixWorld).sub(pt)),tt=0}return!(a.side==="FRONT"&&Q<tt||a.side==="BACK"&&Q>-tt||a.axis_aligned&&H.clone().projectOnPlane(g).lengthSq()>1e-5)},w=(M,C)=>{const V=M.onBeforeRender.bind(M);M.onBeforeRender=(H,Q,tt,pt,y,L)=>{M.matrix.copy(d),b(tt,C)||M.matrix.scale(new x(0,0,0)),M.updateMatrixWorld(!0),V(H,Q,tt,pt,y,L)}};if(w(m,!1),this.empties.add(m),!r||a.opacity!==null&&a.opacity<=0)return;const R=a.opacity!==null,T=a.depth==="BACK",P=new bn({map:r.texture,side:uo,transparent:R&&!T,opacity:a.opacity??1,alphaTest:R?0:.05,toneMapped:!1,depthTest:a.depth==="DEFAULT",depthWrite:a.depth==="DEFAULT"&&!R});P.color.setRGB(...a.tint,ft),R&&T&&(P.blending=We,P.blendSrc=He,P.blendDst=qe),P.onBeforeCompile=M=>{const C=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7141
|
-
`:"";
|
|
7142
|
-
${C}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",
|
|
7143
|
-
diffuseColor.a = 1.0;`)},
|
|
7140
|
+
}`}),this.scene.clear(),this.scene.add(new Tt(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 cl=P({object:N(),group:N(),groupIndex:M().int().nonnegative(),count:M().int().nonnegative(),digest:N(),alertMode:U(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:N().optional(),alertBase64:N().optional()}).strict();function ul(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,i]=_l(2/3*(1-n)),f=new ht;return f.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(i*e)**(1/1.5),Mt),f}function _l(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 ml=0;function $o(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 dl{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const a=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==a)return this.clear(),`weights: the session sent a reference to ${a} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${a} carried neither an array nor a reference`;const d=$o(t.weightsBase64);this.held={key:a,weights:new Float32Array(d.buffer,d.byteOffset,t.count),alerts:$o(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 ht().setHex(ml,Mt);for(let d=0;d<u.count;d++){const m=h.getX(d),v=t.alertMode!=="NONE"&&r.alerts[m]===1?l:ul(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 it(s,3)),f.deleteAttribute("blenderVertex");const c=new yn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),_=new Tt(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 hn=M().finite(),hl=F($([hn,hn,hn,hn])).length(4),pl=20,Lo=[16724818,9165824,2658559];function vl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function ye(){return new qe({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function gl(){const o=[],t=[],n=new ht(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 ht().setHex(Lo[r],Mt);e(1,.85,r,1,i),e(.85,.25,r,1,n),e(1,.85,r,-1,vl(Lo[r])),e(.85,.25,r,-1,n)}const a=new fn;return a.setAttribute("position",new bt(o,3)),a.setAttribute("color",new bt(t,3)),new te(a,ye())}function xl(){const t=[],n=[],e=new ht(1,0,0),a=new ht(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 fn;return r.setAttribute("position",new bt(t,3)),r.setAttribute("color",new bt(n,3)),new te(r,ye())}class bl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=gl(),this.circle=xl(),this.seen=null,this.size=new Lt,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,a,r]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new gt(e,a,r,n),new x(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const e=Math.max(this.size.y,1),a=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let r;if(n.isOrthographicCamera){const 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(ut.degToRad(f.fov)/2)/f.zoom/e}const i=r*pl;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 Lt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),h=new He;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 Ft().setFromNormalAndCoplanarPoint(p,m),new x)}if(c===null)return null;a.updateWorldMatrix(!0,!1);const _=a.worldToLocal(c),d=a.getWorldQuaternion(new gt).invert().multiply(i.camera.getWorldQuaternion(new gt));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 It=M().finite(),yl=P({display:U(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:It,image:P({name:N().nullable(),offset:$([It,It]),depth:U(["DEFAULT","FRONT","BACK"]),side:U(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:It.nullable(),tint:$([It,It,It]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},wl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const a=2*Math.PI*e/t;return[o*Math.cos(a),o*Math.sin(a)]})}function ct(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const i=t[r*a%t.length],f=t[(r*a+1)%t.length];K(o,[i[0],i[1],n],[f[0],f[1],n])}}function Ol(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new X;let a=!1;o.onBeforeRender=(r,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 Tl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new Lt,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const a=e.selected?e.name===t.active?wt.active:wt.selected:e.type==="CAMERA"?wt.camera:e.type==="LIGHT"?wt.light:wt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,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 X().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(Ol);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++)K(d,_[A],_[(A+1)%4]),K(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=Ln(n);this.cameras.add(this.lines(d,e,1,w));let y;if(a){const A=new fn;A.setAttribute("position",new bt(g.flat(),3)),y=new Tt(A,this.fill(e)),y.matrixAutoUpdate=!1,y.matrix.copy(w)}else{const A=[];for(let O=0;O<3;O++)K(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,E,C,V,H)=>{S.setFromMatrixPosition(w).applyMatrix4(this.cameras.matrixWorld);const Q=E.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,E,C,V,H)},this.cameras.add(y)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),i=[];K(i,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(i,wt.light,wt.lightAlpha,new X));const f=[];ct(f,at(1.35,4)),this.lights.add(this.screen(f,wt.light,wt.lightAlpha,new x(r.x,r.y,0)));const u=[],h=9;if(ct(u,at(h*.3,4)),ct(u,at(h,16),0,!0),ct(u,at(h*1.33,20),0,!0),t.type==="SUN")for(const[c,_]of at(h,8))K(u,[c*1.6,_*1.6,0],[c*1.9,_*1.9,0]),K(u,[c*2.2,_*2.2,0],[c*2.5,_*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=Ln(n),l=[];if(t.type==="SUN")K(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"?ct(l,at(1,32).map(([d,m])=>[d*c,m*_])):ct(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=[];K(p,_(d).toArray(),_(m).toArray()),this.lights.add(this.lines(p,e,1,new X));for(const v of[d,m]){const g=[];ct(g,at(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=Ln(n).multiply(new X().makeScale(10,10,10)),w=[];ct(w,at(v,32),-_),ct(w,at(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=[];ct(c,at(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=at(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];K(i,v(_,d),v(m,p))}};switch(t.display){case"PLAIN_AXES":K(i,[0,-1,0],[0,1,0]),K(i,[-1,0,0],[1,0,0]),K(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{K(i,[0,0,0],[0,0,.75]);for(const[h,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(i,[0,0,1],[h,s,.75]);ct(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[h,s]of Al)K(i,Vo[h],Vo[s]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const h=at(1,8);for(let s=0;s<8;s++){const[l,c]=h[s],[_,d]=h[(s+1)%8];K(i,[l,0,c],[0,2,0]),K(i,[l,0,c],[_,0,d])}break}case"ARROWS":for(let h=0;h<3;h++){const s=[0,0,0];s[h]=1,K(i,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new X().makeScale(r,r,r));this.empties.add(this.lines(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=at(1,32).map(([_,d])=>new x(_*t,d*t,-n)),u=new x,h=new X,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,vt())}),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 X().makeBasis(h,s,l.clone()).setPosition(c),d=[];ct(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=(E,C)=>{const V=E.isOrthographicCamera===!0;if(V?!r.orthographic:!r.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);E.getWorldDirection(g);let Q,tt;if(V)Q=H.dot(g.clone().negate()),tt=1e-5;else{const pt=c.clone().applyMatrix4(this.empties.matrixWorld);Q=H.dot(v.setFromMatrixPosition(E.matrixWorld).sub(pt)),tt=0}return!(r.side==="FRONT"&&Q<tt||r.side==="BACK"&&Q>-tt||r.axis_aligned&&H.clone().projectOnPlane(g).lengthSq()>1e-5)},y=(E,C)=>{const V=E.onBeforeRender.bind(E);E.onBeforeRender=(H,Q,tt,pt,b,L)=>{E.matrix.copy(_),w(tt,C)||E.matrix.scale(new x(0,0,0)),E.updateMatrixWorld(!0),V(H,Q,tt,pt,b,L)}};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 yn({map:a.texture,side:uo,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,ft),S&&T&&(A.blending=Ge,A.blendSrc=Xe,A.blendDst=Ye),A.onBeforeCompile=E=>{const C=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7141
|
+
`:"";E.fragmentShader=E.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
7142
|
+
${C}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",S?"#include <alphatest_fragment>":`#include <alphatest_fragment>
|
|
7143
|
+
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${r.premultiplied}:${S}`;const O=new Tt(new Jo(2,2),A);O.matrixAutoUpdate=!1,O.matrix.copy(_),O.renderOrder=r.depth==="FRONT"?1e3:r.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,y(O,!0),this.empties.add(O)}axisNames(t,n,e){const a=[new x,new x,new x];t.extractBasis(a[0],a[1],a[2]);for(let r=0;r<3;r++){const i=a[r].length()*n,f=new x(0,0,0);f.setComponent(r,1.25*n),f.applyMatrix4(t);const u=new x(0,0,0);u.setComponent(r,n),u.applyMatrix4(t);const h=[];for(let c=1;c<=6;c++)ct(h,at(.007*(4*c/6)*i,4));this.empties.add(this.facing(h,e,u));const s=Pl[r],l=[];for(let c=0;c+1<s.length;c+=2){const[_,d]=s[c],[m,p]=s[c+1];K(l,[_*4*i,d*4*i,0],[m*4*i,p*4*i,0])}this.empties.add(this.facing(l,e,f))}}material(t,n){const e=`${t}:${n}`;let a=this.lineMaterials.get(e);return a||(a=new qo({color:t,linewidth:wl,transparent:n<1,opacity:n,depthTest:!0,depthWrite:n>=1,toneMapped:!1}),this.lineMaterials.set(e,a)),a}fill(t){let n=this.fillMaterials.get(t);return n||(n=new yn({color:t,side:uo,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,e,a){const r=new Ho().setPositions(t),i=new Go(r,this.material(n,e));return i.matrixAutoUpdate=!1,i.matrix.copy(a),i.computeLineDistances(),i}screen(t,n,e,a){const r=this.lines(t,n,e,new X);return r.matrixAutoUpdate=!0,r.position.copy(a),r.scale.setScalar(0),r.frustumCulled=!1,this.onDraw(r,(i,f)=>this.face(r,i,f,!0)),r}facing(t,n,e){const a=this.lines(t,n,1,new X);return a.matrixAutoUpdate=!0,a.position.copy(e),this.onDraw(a,(r,i)=>this.face(a,r,i,!1)),a}onDraw(t,n){const e=t,a=e.onBeforeRender.bind(e);e.onBeforeRender=(r,i,f,u,h,s)=>{n(r,f),a(r,i,f,u,h,s)}}face(t,n,e,a){t.parent?.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let r=1;if(a){n.getSize(this.size);const i=Math.max(this.size.y,1),f=this.scratch.setFromMatrixPosition(t.matrixWorld);if(e.isOrthographicCamera){const u=e;r=(u.top-u.bottom)/u.zoom/i}else{const u=e;r=2*Math.max(-f.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(u.fov)/2)/u.zoom/i}}t.scale.setScalar(r),t.updateMatrixWorld(!0)}dispose(){for(const t of this.drawn.values())this.remove(t.parts);this.drawn.clear();for(const t of this.lineMaterials.values())t.dispose();for(const t of this.fillMaterials.values())t.dispose();this.lineMaterials.clear(),this.fillMaterials.clear()}}function Ln(o){const t=new x,n=new gt;return o.decompose(t,n,new x),new X().compose(t,n,new x(1,1,1))}const Vo=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],Al=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Pl=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([o,t])=>[o*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([o,t])=>[o*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([o,t])=>[o*.02,t*.025])],rt=M().finite(),jo=P({name:N(),type:N(),lens:rt,sensor_width:rt,sensor_height:rt,sensor_fit:U(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:rt,clip_start:rt,clip_end:rt,shift_x:rt,shift_y:rt,matrix:F($([rt,rt,rt,rt])).length(4),passepartout:rt.default(0),display_size:rt.default(1)}),Sl={opening:.5,min:.1657359312880715,max:44.98528137423857},pn={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function El(o,t,n,e){const a=r=>Math.min(1,Math.max(-1,r));return[a(o[0]-n/(2*t)),a(o[1]+e/(2*t))]}function Bo(o,t,n,e){const a=o.type==="ORTHO",r=o.sensor_fit==="VERTICAL"?o.sensor_height:o.sensor_width,i=o.sensor_fit==="AUTO"?t>=n:o.sensor_fit==="HORIZONTAL",f=(a?o.ortho_scale:r/o.lens)/2*e;return i?[f,f*n/t]:[f*t/n,f]}function Ml(o,t,n,e,a,r){const i=Math.max(n.width,1),f=Math.max(n.height,1),[u,h]=Bo(o,i,f,1/e),[s,l]=Bo(o,r,1,1),_=2*((o.sensor_fit==="AUTO"?r>=1:o.sensor_fit==="HORIZONTAL")?s:l),d=s/u,m=l/h,p=-2*a[0]*e,v=2*a[1]*e,g=o.shift_x*_-p*2*u,w=o.shift_y*_+v*2*h,y=new X().set(...o.matrix.flat()).premultiply(t),S=new x,T=new gt;return y.decompose(S,T,new x),{name:o.name,position:S.toArray(),quaternion:[T.x,T.y,T.z,T.w],projection:o.type==="ORTHO"?"orthographic":"perspective",window:{left:g-u,right:g+u,top:w+h,bottom:w-h},near:o.clip_start,far:o.clip_end,frame:{left:.5-d/2+p,top:.5-m/2+v,width:d,height:m},passepartout:{color:pn.passepartout,opacity:o.passepartout},border:{solid:pn.back,dashed:pn.overlay,locked:pn.redalert}}}const Nl={color:[.8,.8,.8,1],roughness:.5,metallic:0},Rl=`
|
|
7144
7144
|
uniform vec3 wbDir[4];
|
|
7145
7145
|
uniform vec3 wbDiffuse[4];
|
|
7146
7146
|
uniform vec3 wbSpecular[4];
|
|
@@ -7182,6 +7182,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
|
|
|
7182
7182
|
diffuseLight *= diffuseColor * (1.0 - specEnergy);
|
|
7183
7183
|
return diffuseLight + specularLight;
|
|
7184
7184
|
}
|
|
7185
|
-
`,co=o=>ro.map(t=>{const[n=0,e=0,
|
|
7185
|
+
`,co=o=>ro.map(t=>{const[n=0,e=0,a=0]=o(t);return new x(n,e,a)}),Il=co(o=>o.direction).map(o=>o.normalize()),Fl=co(o=>o.diffuse),Dl=co(o=>o.specular),zl=new no(...ro.map(o=>o.smooth));function Cl(o,t){const[n,e,a]=o.color,r=new Ze({side:t});return r.color.setRGB(n,e,a,ft),r.name="volter:blender-solid",r.onBeforeCompile=i=>{i.uniforms.wbDir={value:Il},i.uniforms.wbDiffuse={value:Fl},i.uniforms.wbSpecular={value:Dl},i.uniforms.wbWrap={value:zl},i.uniforms.wbRoughness={value:o.roughness},i.uniforms.wbMetallic={value:o.metallic},i.fragmentShader=i.fragmentShader.replace("void main() {",`${Rl}
|
|
7186
7186
|
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>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const Dl={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},I=S().finite(),ye=$([I,I,I]),vn=$([S().int().nonnegative(),S().int().nonnegative()]),lt={name:E(),domain:B(["POINT","EDGE","FACE","CORNER"])},Cl=ua("type",[A({...lt,type:j("FLOAT2"),data:F($([I,I]))}).strict(),A({...lt,type:j("FLOAT_VECTOR"),data:F(ye)}).strict(),A({...lt,type:j("FLOAT_COLOR"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("BYTE_COLOR"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("QUATERNION"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("FLOAT4"),data:F($([I,I,I,I]))}).strict(),A({...lt,type:j("FLOAT4X4"),data:F(F(I).length(16))}).strict(),A({...lt,type:j("INT16_2D"),data:F($([S().int(),S().int()]))}).strict(),A({...lt,type:j("INT32_2D"),data:F($([S().int(),S().int()]))}).strict(),A({...lt,type:j("FLOAT"),data:F(I)}).strict(),A({...lt,type:j("INT"),data:F(S().int())}).strict(),A({...lt,type:j("INT8"),data:F(S().int())}).strict(),A({...lt,type:j("BOOLEAN"),data:F(q())}).strict(),A({...lt,type:j("STRING"),data:F(E())}).strict()]),kl=A({positions:U(Float32Array),normals:U(Float32Array).nullable(),uv:U(Float32Array).nullable(),uvLayers:F(A({name:E(),data:U(Float32Array)}).strict()).optional(),attributeLayers:F(A({name:E(),data:U(Float32Array)}).strict()).optional(),orco:U(Float32Array).nullable().optional(),indices:U(Uint32Array),groups:F(A({start:S().int().nonnegative(),count:S().int().nonnegative(),materialIndex:S().int().nonnegative()}).strict()),hash:E()}).strict(),$l=A({v:F(ye),f:F(F(S().int().nonnegative())),e:F(vn).optional(),edge_order:F(vn).optional(),m:F(S().int().nonnegative()).optional(),s:F(q()).optional(),sharp:F(vn).optional(),seams:F(vn).optional(),creases:F($([I,I,I])).optional(),attributes:F(Cl).optional(),active_uv:E().nullable().optional(),render_uv:E().nullable().optional()}).strict(),Ll=A({store:S().int().optional(),revision:S().int(),unchanged:j(!0)}).strict(),Vl=A({co:U(Float64Array),cornerNormal:U(Float32Array).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(),jl=A({name:E(),domain:B(["POINT","EDGE","FACE","CORNER"]),type:E(),data:_a(o=>ArrayBuffer.isView(o))}).strict(),Bl=A({columns:Vl,attributes:F(jl),activeUv:E().nullable(),renderUv:E().nullable(),counts:A({verts:S().int().nonnegative(),edges:S().int().nonnegative(),faces:S().int().nonnegative(),corners:S().int().nonnegative()}).strict(),revision:S().int().nonnegative()}).strict(),Ul=jt([kl,Bl,$l,Ll]),Bo=new Set;function Wl(o,t){const n=new Blob([o],{type:t}),e=new ta;let r=!1;e.addEventListener("dispose",()=>{r=!0,e.image?.close?.()});const a=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(l=>{if(r){l.close();return}e.image=l,e.needsUpdate=!0,vt()}).finally(()=>{Bo.delete(a)});return Bo.add(a),a.catch(()=>{}),{texture:e,ready:a}}function Hl(o,t,n,e){const r=new Pn(o,t,n,Sn,Je);return r.flipY=!1,r.colorSpace=e==="data"?wn:Mt,r.needsUpdate=!0,r}function ql(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(i=>i.width)),r=Math.max(...t.map(i=>i.height)),a=new Uint8Array(e*r*4*t.length),l=Math.max(...t.map(i=>i.number-1001))+1,c=new Float32Array(l*2*4);for(let i=0;i<l;i++)c[i*4]=-1;t.forEach((i,s)=>{const _=i.rgba??(i.rgbaBase64?Hn(i.rgbaBase64):void 0);if(!_)throw new Error(`Runtime image ${o} tile ${i.number} carries no raster`);for(let h=0;h<i.height;h++)a.set(_.subarray(h*i.width*4,(h+1)*i.width*4),(s*r+h)*e*4);const d=i.number-1001;c[d*4]=s,c.set([0,0,i.width/e,i.height/r],(l+d)*4)});const u=new Ke(a,e,r,t.length);u.colorSpace=n==="data"?wn:Mt,u.magFilter=Lt,u.minFilter=te,u.generateMipmaps=!0,u.needsUpdate=!0;const f=new Pn(c,l,2,Sn,Zo);return f.magFilter=f.minFilter=Un,f.needsUpdate=!0,{tiles:u,map:f,frame:t}}const Gl=A({width:S().int().positive(),height:S().int().positive(),revision:S().int().nonnegative(),rgba:U(Uint8Array).optional(),rgbaBase64:E().optional(),colorspace:B(["sRGB","data"]).optional(),tiles:F(A({number:S().int().min(1001),width:S().int().positive(),height:S().int().positive(),rgba:U(Uint8Array).optional(),rgbaBase64:E().optional()}).strict()).optional()}).strict(),Xl=A({revision:S().int().nonnegative(),encoded:U(Uint8Array).optional(),encodedBase64:E().optional(),mime:B(["image/png","image/jpeg"]),colorspace:B(["sRGB","data"]).optional()}).strict(),Yl=jt([Gl,Xl]),Ln=A({image:A({name:E(),revision:S().int().nonnegative()}).strict(),extension:B(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:E(),tint:$([I,I,I]).optional()}).strict(),Zl=A({name:E(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:ol.optional(),normal_texture:Ln.optional(),normal_strength:I.default(1),normal_space:B(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:Ln.optional(),roughness_texture:Ln.optional(),emission:A({color:$([I,I,I]),strength:I}).strict().optional(),graph:Nr.optional(),viewport:A({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Ql=A({session:E(),revision:S().int().nonnegative(),volumes:_t(E(),de).default({}),lights:_t(E(),mr).default({}),world:yr.nullable().default(null),meshes:_t(E(),Ul),materials:_t(E(),Zl),images:_t(E(),Yl).default({}),objects:F(A({id:E(),name:E(),type:B(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:E().nullable(),volume:E().nullable().optional(),light:E().nullable().optional(),materials:F(E().nullable()),matrix:F($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:E().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:E().optional()}).strict()),active:E().nullable(),mode:E(),cameras:_t(E(),_t(E(),oe())).default({}),warnings:F(E()).default([]),updated:F(E()).default([]),frame:S().int().default(0),armatures:_t(E(),pa).default({}),weights:sl.nullable().default(null),cursor:ml.optional(),camera_view:A({scene_camera:E().nullable(),view_layer_cameras:F(E()),aspect:S().finite().positive()}).optional(),light_distances:_t(E(),$([S().finite(),S().finite()])).default({}),empties:_t(E(),xl).default({}),view:A({location:$([S(),S(),S()]),rotation:$([S(),S(),S(),S()]),distance:S().finite(),perspective:B(["PERSP","ORTHO","CAMERA"]),lens:S().finite().positive().default(50),shading:B(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:A({frame:S().int(),body:E(),markers:F($([S().int(),E()]))}).optional(),units:A({system:B(["NONE","METRIC","IMPERIAL"]),scale_length:S().finite()}).optional()}).strict();function Kl(o,t){for(let n=0,e=o.length-1;n<o.length&&e>=0;n++,e--){if(o[n][0]===t)return o[n][1];if(n===e)break;if(o[e][0]===t)return o[e][1]}return null}const Jl={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class An{constructor(){this.root=new ot,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new br,this.world=new lo,this.armatureOverlay=new Sa,this.weightOverlay=new _l,this.cursorOverlay=new gl,this.extrasOverlay=new wl,this.armatureRoot=new ot,this.weightRoot=new ot,this.cursorRoot=new ot,this.cameraExtrasRoot=new ot,this.lightExtrasRoot=new ot,this.emptyExtrasRoot=new ot,this.rendered=!1,this.heldRendered=null,this.worldApplied=null,this.worldKey="null",this.capturing=!1,this.workbench=!1,this.workbenchMaterials=new Map,this.fallback=new ln({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new nl,this.graphSamplers=new Map,this.photograph=!1,this.graphs=new Map,this.frame=null,this.retiredSessions=new Set,this.geometryBuilds=0,this.submittedMeshes=new Map,this.submitted=null,this.submittedSession=null,this.photographs=[],this.frameListeners=new Set,this.followers=new Set,this.leader=null,this.cameraViewZoom=Al,this.cameraViewPan=Pl,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[t,n]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group],[this.cursorRoot,this.cursorOverlay.group],[this.cameraExtrasRoot,this.extrasOverlay.cameras],[this.lightExtrasRoot,this.extrasOverlay.lights],[this.emptyExtrasRoot,this.extrasOverlay.empties]])t.matrixAutoUpdate=!1,t.matrix.copy(this.root.matrix),t.add(n),t.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const t of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])t.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let e=this.graphs.get(n);return e||(e=Wr(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[a,l]of this.objects)if(l===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 l=a.objects.get(n);l!==void 0&&(l.matrix.copy(t.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.updateMatrixWorld(!0),r=!0)}r&&vt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=da(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(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,l=new gt(e,r,a,n),c=new x(...t.location).applyMatrix4(this.root.matrix),u=f=>f.applyQuaternion(l).applyMatrix4(this.root.matrix).normalize();return{target:c.toArray(),direction:u(new x(0,0,1)).toArray(),up:u(new x(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?Dl[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new X().copy(this.root.matrix).invert(),r=new X().compose(new x(...t),new gt(...n),new x(1,1,1)).premultiply(e),a=new x,l=new gt;return r.decompose(a,l,new x),{location:a.toArray(),rotation:[l.w,l.x,l.y,l.z]}}cameraView(t,n,e,r){const a=this.frame,l=Vo.safeParse(a?.cameras[t]);return!a?.camera_view||!l.success?null:Sl(l.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=Kl(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=Jl[n.system],r=6*t,a=1/(n.scale_length||1);return(e.find(([c])=>c*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,l=[...t.children];t.removeFromParent();for(const c of l)n.add(c);a?.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 r=new Set(this.objects.values()),a=this.cursorOverlay.placementAt(t,n,e,this.root,l=>r.has(l));return a!==null&&(this.cursorOverlay.show(a),vt()),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(vt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),vt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const r=this.objects.get(e.id);if(!r?.isMesh)continue;const l=(e.materials.length?e.materials:[null]).map(c=>{const u=c===null?this.fallback:this.materials.get(c)??this.fallback;return t?this.workbenchFor(c,u.side,n):u});r.material=e.materials.length?l:l[0]}for(const[e,r]of this.workbenchMaterials)n.has(e)||(r.dispose(),this.workbenchMaterials.delete(e))}workbenchFor(t,n,e){const r=(t!==null?this.frame?.materials[t]?.viewport:void 0)??El,a=`${r.color.join(",")}|${r.roughness}|${r.metallic}|${n}`;e.add(a);let l=this.workbenchMaterials.get(a);return l||(l=zl(r,n),this.workbenchMaterials.set(a,l)),l}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Co(this.frame?.world)?.extinction:null)??new x;for(const a of[...this.materials.values(),this.fallback])al(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 hr(),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 f=u;if(f.isMesh&&(f.castShadow=t,f.receiveShadow=t,t&&f.visible)){const i=new yn().setFromObject(f);i.isEmpty()||e.push(i)}}if(!t||!e.length)return;const a=e.reduce((u,f)=>u.union(f),new yn).getBoundingSphere(new Xe),l=n?new Ye().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,c=l?e.flatMap(u=>Tr(u,l)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Ar(u,c,e):gr(u,a.center,a.radius)}applyOverlays(t){const n=l=>{const c=t.objects.find(u=>u.name===l);return c===void 0?null:new X().set(...c.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],r=t.weights?this.objects.get(t.objects.find(l=>l.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),vt())}applyExtras(t){const n={};for(const[e,r]of Object.entries(t.cameras)){const a=Vo.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,l=r.width||a?.width||0,c=r.height||a?.height||0;return(l===0||c===0)&&r.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),r.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),vt()},()=>this.awaitedImages.delete(e))),{texture:r.texture,width:l,height:c}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const e=this.lights.get(t.light);e&&(e.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.capturing,this.weightOverlay.group.visible=!this.capturing,this.cursorOverlay.group.visible=!this.capturing;for(const t of[this.extrasOverlay.cameras,this.extrasOverlay.lights,this.extrasOverlay.empties])t.visible=!this.capturing}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=Ql.parse(t);if(this.retiredSessions.has(e.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===e.session&&e.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const r=new Set(e.objects.map(f=>f.id));if(r.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const a=new Map(e.objects.map(f=>[f.id,f]));for(const f of e.objects){if(f.mesh!==null&&!e.meshes[f.mesh])throw new Error(`Missing runtime mesh ${f.mesh}`);if(f.volume&&(!e.volumes[f.volume]||f.mesh!==null))throw new Error(`Invalid runtime volume ${f.volume}`);if(f.light&&(!e.lights[f.light]||f.mesh!==null))throw new Error(`Invalid runtime light ${f.light}`);for(const _ of f.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const i=new Set([f.id]);let s=f.parent;for(;s!==null;){if(i.has(s))throw new Error("Runtime parent cycle");i.add(s);const _=a.get(s);if(!_)throw new Error(`Missing runtime parent ${s}`);s=_.parent}}const l=new Map,c=new Map;try{for(const[f,i]of Object.entries(e.volumes)){const s=JSON.stringify(i);this.frame?.session===e.session&&this.volumes.get(f)?.signature===s||c.set(f,{signature:s,mesh:Pr(i)})}for(const[f,i]of Object.entries(e.meshes)){if("unchanged"in i){const h=this.meshes.get(f)?.signature;if(this.frame?.session===e.session&&h!==void 0&&(h===`revision:${i.revision}`||!h.startsWith("revision:")))continue;throw new Error(h===void 0?`${xo}: the presenter does not hold runtime mesh ${f} (store ${i.store}, revision ${i.revision})`:`${xo}: the presenter holds runtime mesh ${f} at ${h}, not revision ${i.revision}`)}const s="hash"in i,_="columns"in i,d=_?`revision:${i.revision}`:s?i.hash:JSON.stringify(i);this.frame?.session===e.session&&this.meshes.get(f)?.signature===d||l.set(f,{signature:d,geometry:_?qn(La({...i.columns,attributes:i.attributes,activeUv:i.activeUv,renderUv:i.renderUv},d)):s?qn(i):Va(i)})}}catch(f){for(const i of l.values())i.geometry.dispose();for(const{mesh:i}of c.values())i.geometry.dispose(),i.material.dispose();throw f}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[f,i]of c){const s=this.volumes.get(f)?.mesh;s&&(s.removeFromParent(),s.geometry.dispose(),s.material.dispose()),this.volumes.set(f,i)}for(const[f,i]of l)this.meshes.get(f)?.geometry.dispose(),this.meshes.set(f,i),this.geometryBuilds++;for(const[f,i]of Object.entries(e.images)){const s=this.textures.get(f);if("width"in i){const p=i.rgba??(i.rgbaBase64?Hn(i.rgbaBase64):void 0);if(!p)throw new Error(`Runtime image ${f} carries no raster`);const v=i.tiles?ql(f,i.tiles,i.colorspace??"sRGB"):void 0;if(s?.udim&&(s.udim.tiles.dispose(),s.udim.map.dispose(),delete s.udim),s&&s.width===i.width&&s.height===i.height){const g=s.texture.image;if(g.data){g.data.set(p),s.texture.needsUpdate=!0,s.revision=i.revision,v&&(s.udim=v);continue}}s?.texture.dispose(),this.textures.set(f,{texture:Hl(p,i.width,i.height,i.colorspace??"sRGB"),width:i.width,height:i.height,revision:i.revision,...v?{udim:v}:{}});continue}const _=i.encoded??(i.encodedBase64?Hn(i.encodedBase64):void 0);if(!_)throw new Error(`Runtime image ${f} carries no bytes`);s?.texture.dispose(),s?.udim?.tiles.dispose(),s?.udim?.map.dispose();const d=i.colorspace??"sRGB",{texture:h,ready:m}=Wl(_,i.mime);h.colorSpace=d==="data"?wn:Mt,this.textures.set(f,{texture:h,ready:m,width:0,height:0,revision:i.revision,encoded:{bytes:_.slice(),mime:i.mime,colorspace:d}})}for(const[f,i]of Object.entries(e.materials)){const s=this.materials.get(f)??new ln;s.name=i.name;const _=i.texture?.tint;i.texture!==void 0?s.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):s.color.setRGB(i.color[0],i.color[1],i.color[2],ft),s.opacity=i.color[3];const d=s.opacity<1||i.graph!==void 0&&Rr(i.graph);s.transparent!==d&&(s.transparent=d,s.needsUpdate=!0),s.roughness=i.roughness,s.metalness=i.metallic,s.transmission=i.transmission,s.ior=i.ior,so(s,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)s.normalMap&&(this.textureSamplers.delete(`${f}:normal`),s.normalMap=null,s.needsUpdate=!0);else{const b=this.textures.get(h);if(!b)throw new Error(`${Qt}: missing normal image ${h}`);const w=this.textureSamplers.get(`${f}:normal`,b.texture,i.normal_texture.extension,b.ready,i.normal_texture.uv);s.normalMap!==w&&(s.normalMap=w,s.needsUpdate=!0);const R=i.normal_space==="OBJECT"?Ze:Qe;s.normalMapType!==R&&(s.normalMapType=R,s.needsUpdate=!0),s.normalScale.set(i.normal_strength,i.normal_strength*(i.normal_directx?-1:1))}i.emission?(s.emissive.setRGB(i.emission.color[0],i.emission.color[1],i.emission.color[2],ft),s.emissiveIntensity=i.emission.strength):(s.emissive.setRGB(0,0,0),s.emissiveIntensity=1);const m=i.roughness_texture?.image.name??null;if(m===null)this.roughnessTextureNames.has(f)&&(this.textureSamplers.delete(`${f}:roughness`),s.roughnessMap=null,this.roughnessTextureNames.delete(f),s.needsUpdate=!0);else{const b=this.textures.get(m);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${m} (revision ${i.roughness_texture.image.revision})`);const w=this.textureSamplers.get(`${f}:roughness`,b.texture,i.roughness_texture.extension,b.ready,i.roughness_texture.uv);s.roughnessMap!==w&&(s.roughnessMap=w,this.roughnessTextureNames.set(f,m),s.needsUpdate=!0)}const p=i.texture?.image.name??null;if(p===null)this.textureNames.has(f)&&(this.textureSamplers.delete(`${f}:color`),s.map=null,this.textureNames.delete(f),s.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${p} (revision ${i.texture.image.revision})`);const w=this.textureSamplers.get(`${f}:color`,b.texture,i.texture.extension,b.ready,i.texture.uv);s.map!==w&&(s.map=w,this.textureNames.set(f,p),s.needsUpdate=!0)}const v=i.graph?this.compiledGraph(i.graph):null,g=new Set;qr(s,v,b=>{const w=this.textures.get(b.name);if(!w)throw new Error(`${Qt}: the presenter does not hold runtime image ${b.name} (revision ${b.revision})`);if(b.tiled){if(!w.udim)throw new Error(`${Qt}: runtime image ${b.name} arrived without its UDIM tiles`);return w.udim}const R=`${f}:graph:${b.node}`;g.add(R);const T=this.textureSamplers.get(R,w.texture,b.extension,w.ready),P=b.closest?Un:Lt,O=b.closest?Un:b.mipmap?te:Lt;return(T.magFilter!==P||T.minFilter!==O)&&(T.magFilter=P,T.minFilter=O,T.needsUpdate=!0),T},this.photograph);for(const b of this.graphSamplers.get(f)??[])g.has(b)||this.textureSamplers.delete(b);this.graphSamplers.set(f,g),this.materials.set(f,s)}for(const f of e.objects){let i=this.objects.get(f.id);const s=f.volume?this.volumes.get(f.volume).mesh:null;if((!i||(s?i!==s:!!i.isMesh!=(f.mesh!==null)))&&(i?.removeFromParent(),i=s??(f.mesh!==null?new Tt(this.meshes.get(f.mesh).geometry,this.fallback):new Xo),this.objects.set(f.id,i)),i.name=f.name,f.type==="CAMERA"||f.type==="LIGHT"||f.type==="EMPTY"?i.userData.volterOwnOverlay=!0:delete i.userData.volterOwnOverlay,i.matrixAutoUpdate=!1,i.matrix.set(...f.matrix.flat()),f.parent){const _=new X().set(...a.get(f.parent).matrix.flat());i.matrix.premultiply(_.invert())}if(i.matrix.decompose(i.position,i.quaternion,i.scale),f.texspace?i.userData.blenderTexspace=f.texspace:delete i.userData.blenderTexspace,f.default_color!==void 0?i.userData.blenderDefaultColor=f.default_color:delete i.userData.blenderDefaultColor,f.mesh!==null){const _=i;_.geometry=this.meshes.get(f.mesh).geometry,_.material=f.materials.length?f.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,Zr(_)}if(f.light){const _=this.lights.get(f.light)??null,d=vr(e.lights[f.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==i&&i.add(d),d.userData.volterOwnOverlay=!0,xr(d,i),this.lights.set(f.light,d)}}for(const f of e.objects){const i=this.objects.get(f.id),s=f.parent===null?this.root:this.objects.get(f.parent);i.parent!==s&&s.add(i)}for(const[f,i]of this.objects)r.has(f)||(i.removeFromParent(),this.objects.delete(f));for(const[f,i]of this.volumes)e.volumes[f]||(i.mesh.geometry.dispose(),i.mesh.material.dispose(),this.volumes.delete(f));for(const[f,i]of this.meshes)e.meshes[f]||(i.geometry.dispose(),this.meshes.delete(f));for(const[f,i]of this.materials)if(!e.materials[f]){for(const s of["normal","roughness","color"])this.textureSamplers.delete(`${f}:${s}`);for(const s of this.graphSamplers.get(f)??[])this.textureSamplers.delete(s);this.graphSamplers.delete(f),i.dispose(),this.materials.delete(f)}for(const[f,i]of this.lights)e.lights[f]||(i.removeFromParent(),i.dispose(),this.lights.delete(f));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{}},this.worldKey=JSON.stringify(e.world??null);const u=this.applyOverlays(e);u.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...u]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const f of[...this.frameListeners])f();for(const f of this.followers)try{f.applyFrame(t)}catch{f.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[r,{signature:a,geometry:l}]of this.meshes){const c=i=>{const s=l.getAttribute(i);if(!s)return null;if(!(s instanceof it))throw new Error(`Blender capture cannot copy interleaved ${i}`);return new Float32Array(s.array)},u=c("position");if(!u)throw new Error(`Blender capture mesh ${r} has no positions`);const f=l.getIndex();n.meshes[r]={hash:a,positions:u,normals:c("normal"),uv:c("uv"),uvLayers:Object.entries(l.userData.blenderUvChannels??{}).map(([i,s])=>{const _=c(`uv${s}`);if(!_)throw new Error(`Blender capture mesh ${r} is missing UV layer ${i}`);return{name:i,data:_}}),orco:l.userData.blenderOrcoFromDoor?c("blenderOrco"):null,attributeLayers:(l.userData.blenderAttributes??[]).map(i=>{const s=c(Vt(i));if(!s)throw new Error(`Blender capture mesh ${r} is missing attribute ${i}`);return{name:i,data:s}}),indices:f?new Uint32Array(f.array):Uint32Array.from({length:u.length/3},(i,s)=>s),groups:l.groups.map(i=>({start:i.start,count:i.count,materialIndex:i.materialIndex??0}))}}for(const[r,{signature:a}]of this.volumes)n.volumes[r]=de.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 l=a.texture.image?.data;if(!(l 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:l.slice(),colorspace:a.texture.colorSpace===wn?"data":"sRGB",...a.udim?{tiles:a.udim.frame}:{}}}}return n}follow(){const t=new An;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 An;r.photograph=!0;let a=!1;const l=()=>{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(c){throw l(),c}return{effect:e,root:r.root,session:n.session,revision:n.revision,prepare:c=>{if(a)throw new Error("Blender capture snapshot is disposed");return r.setRendered(!0,c)},dispose:l}}createWorldVolumePass(){const t=Co(this.frame?.world);return t?new il(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const 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[l,c]of Object.entries(a))typeof c=="object"&&c!==null&&!("unchanged"in c)&&this.submittedMeshes.set(l,c);for(const l of[...this.submittedMeshes.keys()])l in a||this.submittedMeshes.delete(l);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const si=new An;function we(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Vn(o){const t=we(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function ti(o){const t=we(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ni(o){return new X().set(...o.flat())}function Uo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class oi{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,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,l)=>a+l.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:this.#i!==null?this.#i:t.clipStart+this.#a.time*t.fps}get playable(){return this.#a!==null}async bind(t,n){this.#r++;const e=await n.rig();if(!e)return;const r=[],a=new Set;let l=!1;for(const s of e.rigs){if(!s.object||!s.armature||!s.skinIndexBase64||!s.skinWeightBase64){s.reason&&r.push(s.reason);continue}a.add(s.object);const _=Uo(s,e.frame);if(this.#n.get(s.object)?.signature===_)continue;const d=this.#d(t,s,e.frame,r);d&&(this.#n.get(s.object)?.skeleton.dispose(),this.#n.set(s.object,d),l=!0)}for(const[s,_]of[...this.#n])a.has(s)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(s),l=!0);this.#r++;const c=await n.clip(),u=this.#t,f=c?.action!==u?.action||c?.tracks.length!==u?.tracks.length||c?.clipStart!==u?.clipStart||c?.clipEnd!==u?.clipEnd;this.#t=c??null,c?.reason&&r.push(c.reason),c&&(f||l)&&this.#h(t,c,r);const i=this.#e?.snapshot().playbackState==="playing";c&&!i&&u?.frameCurrent!==c.frameCurrent&&(this.#c(c.frameCurrent),this.#e&&c.fps>0&&this.#e.seek(c.frameCurrent/c.fps)),this.#_=r,this.#f()}#d(t,n,e,r){const a=t.objectForBlenderName(n.object??""),l=t.objectForBlenderName(n.armature??"");if(!a||!l)return null;const c=a,u=c.geometry;if(!u)return null;const f=u.getAttribute("blenderVertex");if(!f)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 i=0;for(let T=0;T<f.count;T++)i=Math.max(i,f.getX(T));if(i>=n.vertexCount)return r.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${i} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const s=ti(n.skinIndexBase64??""),_=Vn(n.skinWeightBase64??""),d=f.count,h=new Uint16Array(d*4),m=new Float32Array(d*4);for(let T=0;T<d;T++){const P=f.getX(T);for(let O=0;O<4;O++)h[T*4+O]=s[P*4+O]??0,m[T*4+O]=_[P*4+O]??0}u.setAttribute("skinIndex",new na(h,4)),u.setAttribute("skinWeight",new bt(m,4));const p=new ot;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ni(T.pose)),b=new Map(n.bones.map((T,P)=>[T.name,P]));n.bones.forEach((T,P)=>{const O=new oa;O.name=T.name,v.push(O);const M=T.parent===null?void 0:b.get(T.parent);(M===void 0?g[P].clone():g[M].clone().invert().multiply(g[P])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),l.add(p);const w=new ea(u,c.material);w.name=c.name,w.matrixAutoUpdate=!1,w.matrix.copy(c.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=c.userData,w.frustumCulled=!1,t.replacePresentedObject(c,w),t.root.updateMatrixWorld(!0);const R=new aa(v);return w.bind(R,w.matrixWorld.clone()),n.constrainedBones?.length&&r.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&r.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:w,boneRoot:p,bones:v,skeleton:R,frame:e,signature:Uo(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const r=n.armature?t.objectForBlenderName(n.armature):null;if(!r)return;const a=new Map;for(const s of this.#n.values())if(s.armature===n.armature)for(const _ of s.bones)a.set(_.name,_);const l=[],c=new Set;for(const s of n.tracks){const _=a.get(s.bone);if(!_){c.add(s.bone);continue}const d=Vn(s.timeBase64),h=Vn(s.valueBase64),m=`${_.uuid}.${s.property}`;l.push(s.property==="quaternion"?new ra(m,Array.from(d),Array.from(h)):new la(m,Array.from(d),Array.from(h)))}if(c.size&&e.push(`${n.action} animates ${[...c].join(", ")}, which this binding has no bone for.`),!l.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,f=new ia(r),i=f.clipAction(new sa(n.action??"action",u,l));i.setLoop(fa,Number.POSITIVE_INFINITY),i.play(),this.#o=f,this.#a=i,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 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.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const l=this.#t,c=l?.fps||24;return{start:(l?.frameStart??1)/c,end:(l?.frameEnd??250)/c,fps:c}},seek:l=>this.seekSeconds(l)}),e=t.onSettled(()=>{this.writeBookmark()}),r=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#l=null};this.#l=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.#l?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const Oe=new oi;function fi(o){return Oe.subscribe(o)}function ci(){return Oe.version}export{Oe as a,ci as b,si as c,fi as s};
|
|
7187
|
+
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const kl={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},I=M().finite(),we=$([I,I,I]),vn=$([M().int().nonnegative(),M().int().nonnegative()]),lt={name:N(),domain:U(["POINT","EDGE","FACE","CORNER"])},$l=da("type",[P({...lt,type:j("FLOAT2"),data:F($([I,I]))}).strict(),P({...lt,type:j("FLOAT_VECTOR"),data:F(we)}).strict(),P({...lt,type:j("FLOAT_COLOR"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("BYTE_COLOR"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("QUATERNION"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("FLOAT4"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("FLOAT4X4"),data:F(F(I).length(16))}).strict(),P({...lt,type:j("INT16_2D"),data:F($([M().int(),M().int()]))}).strict(),P({...lt,type:j("INT32_2D"),data:F($([M().int(),M().int()]))}).strict(),P({...lt,type:j("FLOAT"),data:F(I)}).strict(),P({...lt,type:j("INT"),data:F(M().int())}).strict(),P({...lt,type:j("INT8"),data:F(M().int())}).strict(),P({...lt,type:j("BOOLEAN"),data:F(q())}).strict(),P({...lt,type:j("STRING"),data:F(N())}).strict()]),Ll=P({positions:B(Float32Array),normals:B(Float32Array).nullable(),uv:B(Float32Array).nullable(),uvLayers:F(P({name:N(),data:B(Float32Array)}).strict()).optional(),attributeLayers:F(P({name:N(),data:B(Float32Array)}).strict()).optional(),orco:B(Float32Array).nullable().optional(),indices:B(Uint32Array),groups:F(P({start:M().int().nonnegative(),count:M().int().nonnegative(),materialIndex:M().int().nonnegative()}).strict()),hash:N()}).strict(),Vl=P({v:F(we),f:F(F(M().int().nonnegative())),e:F(vn).optional(),edge_order:F(vn).optional(),m:F(M().int().nonnegative()).optional(),s:F(q()).optional(),sharp:F(vn).optional(),seams:F(vn).optional(),creases:F($([I,I,I])).optional(),attributes:F($l).optional(),active_uv:N().nullable().optional(),render_uv:N().nullable().optional()}).strict(),jl=P({store:M().int().optional(),revision:M().int(),unchanged:j(!0)}).strict(),Bl=P({co:Nt([B(Float32Array),B(Float64Array)]),cornerNormal:B(Float32Array).optional(),orco:B(Float32Array).optional(),faceStart:B(Uint32Array),corner:B(Uint32Array),cornerEdge:B(Int32Array),edge:B(Uint32Array),edgeSharp:B(Uint8Array),edgeSeam:B(Uint8Array),edgeCrease:B(Float32Array),material:B(Uint32Array),smooth:B(Uint8Array),vertSelect:B(Uint8Array),vertHide:B(Uint8Array),edgeSelect:B(Uint8Array),edgeHide:B(Uint8Array),faceSelect:B(Uint8Array),faceHide:B(Uint8Array)}).strict(),Ul=P({name:N(),domain:U(["POINT","EDGE","FACE","CORNER"]),type:N(),data:ha(o=>ArrayBuffer.isView(o))}).strict(),Oe=P({columns:Bl,attributes:F(Ul),activeUv:N().nullable(),renderUv:N().nullable(),counts:P({verts:M().int().nonnegative(),edges:M().int().nonnegative(),faces:M().int().nonnegative(),corners:M().int().nonnegative()}).strict(),revision:M().int().nonnegative()}).strict(),Wl=Nt([Ll,Oe,Vl,jl]),Uo=new Set;function Hl(o,t){const n=new Blob([o],{type:t}),e=new ea;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,vt()}).finally(()=>{Uo.delete(r)});return Uo.add(r),r.catch(()=>{}),{texture:e,ready:r}}function ql(o,t,n,e){const a=new Sn(o,t,n,En,oa);return a.flipY=!1,a.colorSpace=e==="data"?On:Mt,a.needsUpdate=!0,a}function Gl(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?qn(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 na(r,e,a,t.length);u.colorSpace=n==="data"?On:Mt,u.magFilter=Vt,u.minFilter=ne,u.generateMipmaps=!0,u.needsUpdate=!0;const h=new Sn(f,i,2,En,Qo);return h.magFilter=h.minFilter=Wn,h.needsUpdate=!0,{tiles:u,map:h,frame:t}}const Xl=P({width:M().int().positive(),height:M().int().positive(),revision:M().int().nonnegative(),rgba:B(Uint8Array).optional(),rgbaBase64:N().optional(),colorspace:U(["sRGB","data"]).optional(),tiles:F(P({number:M().int().min(1001),width:M().int().positive(),height:M().int().positive(),rgba:B(Uint8Array).optional(),rgbaBase64:N().optional()}).strict()).optional()}).strict(),Yl=P({revision:M().int().nonnegative(),encoded:B(Uint8Array).optional(),encodedBase64:N().optional(),mime:U(["image/png","image/jpeg"]),colorspace:U(["sRGB","data"]).optional()}).strict(),Te=Nt([Xl,Yl]),Vn=P({image:P({name:N(),revision:M().int().nonnegative()}).strict(),extension:U(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:N(),tint:$([I,I,I]).optional()}).strict(),Zl=P({name:N(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:al.optional(),normal_texture:Vn.optional(),normal_strength:I.default(1),normal_space:U(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:Vn.optional(),roughness_texture:Vn.optional(),emission:P({color:$([I,I,I]),strength:I}).strict().optional(),graph:Ir.optional(),viewport:P({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Ql=P({session:N(),revision:M().int().nonnegative(),volumes:_t(N(),he).default({}),lights:_t(N(),hr).default({}),world:Or.nullable().default(null),meshes:_t(N(),Wl),materials:_t(N(),Zl),images:_t(N(),Te).default({}),objects:F(P({id:N(),name:N(),type:U(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:N().nullable(),volume:N().nullable().optional(),light:N().nullable().optional(),materials:F(N().nullable()),matrix:F($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:N().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:N().optional()}).strict()),active:N().nullable(),mode:N(),cameras:_t(N(),_t(N(),ee())).default({}),warnings:F(N()).default([]),updated:F(N()).default([]),frame:M().int().default(0),armatures:_t(N(),xa).default({}),weights:cl.nullable().default(null),cursor:hl.optional(),camera_view:P({scene_camera:N().nullable(),view_layer_cameras:F(N()),aspect:M().finite().positive()}).optional(),light_distances:_t(N(),$([M().finite(),M().finite()])).default({}),empties:_t(N(),yl).default({}),view:P({location:$([M(),M(),M()]),rotation:$([M(),M(),M(),M()]),distance:M().finite(),perspective:U(["PERSP","ORTHO","CAMERA"]),lens:M().finite().positive().default(50),shading:U(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:P({frame:M().int(),body:N(),markers:F($([M().int(),N()]))}).optional(),units:P({system:U(["NONE","METRIC","IMPERIAL"]),scale_length:M().finite()}).optional()}).strict();function Kl(o,t){for(let n=0,e=o.length-1;n<o.length&&e>=0;n++,e--){if(o[n][0]===t)return o[n][1];if(n===e)break;if(o[e][0]===t)return o[e][1]}return null}const Jl={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class Pn{constructor(){this.root=new ot,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new wr,this.world=new lo,this.armatureOverlay=new Na,this.weightOverlay=new dl,this.cursorOverlay=new bl,this.extrasOverlay=new Tl,this.armatureRoot=new ot,this.weightRoot=new ot,this.cursorRoot=new ot,this.cameraExtrasRoot=new ot,this.lightExtrasRoot=new ot,this.emptyExtrasRoot=new ot,this.rendered=!1,this.heldRendered=null,this.worldApplied=null,this.worldKey="null",this.capturing=!1,this.workbench=!1,this.workbenchMaterials=new Map,this.fallback=new ln({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new el,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=Sl,this.cameraViewPan=El,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=qr(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&&vt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=va(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 gt(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?kl[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new X().copy(this.root.matrix).invert(),a=new X().compose(new x(...t),new gt(...n),new x(1,1,1)).premultiply(e),r=new x,i=new gt;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=jo.safeParse(r?.cameras[t]);return!r?.camera_view||!i.success?null:Ml(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=Kl(n.markers,e);return`(${e})${n.body}${a===null?"":` <${a}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const e=Jl[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([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),vt()),r}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(a=>a.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(vt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),vt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const a=this.objects.get(e.id);if(!a?.isMesh)continue;const 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)??Nl,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let i=this.workbenchMaterials.get(r);return i||(i=Cl(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?ko(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])ll(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 vr(),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 wn().setFromObject(h);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,h)=>u.union(h),new wn).getBoundingSphere(new Qe),i=n?new Ke().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=i?e.flatMap(u=>Pr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Sr(u,f,e):br(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 X().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),vt())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=jo.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),vt()},()=>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=Oe.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:xn(wo({...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,Te.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=Ql.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:Er(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?`${xo}: the presenter does not hold runtime mesh ${s} (store ${l.store}, revision ${l.revision})`:`${xo}: 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:_?xn(wo({...l.columns,attributes:l.attributes,activeUv:l.activeUv,renderUv:l.renderUv},d)):c?xn(l):Ba(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?qn(l.rgbaBase64):void 0);if(!v)throw new Error(`Runtime image ${s} carries no raster`);const g=l.tiles?Gl(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:ql(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?qn(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}=Hl(_,l.mime);m.colorSpace=d==="data"?On:Mt,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 ln;c.name=l.name;const _=l.texture?.tint;l.texture!==void 0?c.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):c.color.setRGB(l.color[0],l.color[1],l.color[2],ft),c.opacity=l.color[3];const d=c.opacity<1||l.graph!==void 0&&Fr(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,so(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(`${Qt}: 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"?Je:ta;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],ft),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(`${Qt}: 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(`${Qt}: 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;Xr(c,g,y=>{const S=this.textures.get(y.name);if(!S)throw new Error(`${Qt}: the presenter does not hold runtime image ${y.name} (revision ${y.revision})`);if(y.tiled){if(!S.udim)throw new Error(`${Qt}: 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?Wn:Vt,E=y.closest?Wn:y.mipmap?ne:Vt;return(A.magFilter!==O||A.minFilter!==E)&&(A.magFilter=O,A.minFilter=E,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 Tt(this.meshes.get(s.mesh).geometry,this.fallback):new Yo),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 X().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,Kr(_)}if(s.light){const _=this.lights.get(s.light)??null,d=xr(e.lights[s.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==l&&l.add(d),d.userData.volterOwnOverlay=!0,yr(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 it))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(jt(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]=he.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===On?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Pn;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 Pn;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=ko(this.frame?.world);return t?new fl(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 si=new Pn;function Ae(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 jn(o){const t=Ae(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function ti(o){const t=Ae(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ni(o){return new X().set(...o.flat())}function Wo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class oi{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,a=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:a,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((r,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=Wo(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=ti(n.skinIndexBase64??""),c=jn(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 aa(d,4)),u.setAttribute("skinWeight",new bt(m,4));const p=new ot;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ni(T.pose)),w=new Map(n.bones.map((T,A)=>[T.name,A]));n.bones.forEach((T,A)=>{const O=new ra;O.name=T.name,v.push(O);const E=T.parent===null?void 0:w.get(T.parent);(E===void 0?g[A].clone():g[E].clone().invert().multiply(g[A])).decompose(O.position,O.quaternion,O.scale),(E===void 0?p:v[E]).add(O)}),i.add(p);const y=new la(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 ia(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:Wo(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 _=jn(l.timeBase64),d=jn(l.valueBase64),m=`${c.uuid}.${l.property}`;i.push(l.property==="quaternion"?new sa(m,Array.from(_),Array.from(d)):new fa(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 ca(a),s=h.clipAction(new ua(n.action??"action",u,i));s.setLoop(_a,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 pa(`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 Pe=new oi;function fi(o){return Pe.subscribe(o)}function ci(){return Pe.version}export{Pe as a,ci as b,si as c,fi as s};
|