@volter/game-editor 0.5.81 → 0.5.83
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/catalog/entries/reflections.json +1 -1
- package/catalog/project-source/src/lib/reflections/ReflectionProbe.tsx +34 -5
- package/catalog/project-source/src/lib/reflections/index.ts +1 -0
- package/catalog/project-source/src/lib/reflections/probe-controller.ts +44 -3
- package/catalog/project-source/src/lib/reflections/reflection-probe-registry.ts +32 -7
- package/catalog/project-source/src/lib/reflections/volume-reflection-material.ts +638 -160
- package/dist/.vite/manifest.json +2184 -2165
- package/dist/assets/{AssetBudgetPanel-CfVYW4ED.js → AssetBudgetPanel-SrgQ5Lx5.js} +3 -3
- package/dist/assets/{AudioViewer-J10BXrtm.js → AudioViewer-BqEwLSZN.js} +1 -1
- package/dist/assets/{CanvasBoardDocument-BgIbuOQF.js → CanvasBoardDocument-BfzWZdLX.js} +1 -1
- package/dist/assets/CanvasSceneViewport-CQ7ewAlO.js +1 -0
- package/dist/assets/{ColorInput-fX1V5l8_.js → ColorInput-DQ6YyPD_.js} +1 -1
- package/dist/assets/EntityModelDocument-By-BM9dS.js +1 -0
- package/dist/assets/{EnvironmentAssetDocument-QuLkCom9.js → EnvironmentAssetDocument-CrD37BI0.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-D0z5Mc0R.js → GameplaySessionTimeline-DYtnW0Si.js} +1 -1
- package/dist/assets/{ImageViewer-DWUPPWRf.js → ImageViewer-CZNpdUEA.js} +1 -1
- package/dist/assets/InspectorObjectPreview-gWOVV6Ll.js +1 -0
- package/dist/assets/{JsonAssetDocument-C0Lr6RwY.js → JsonAssetDocument-Bg74MDXy.js} +1 -1
- package/dist/assets/{LiveModuleDocument-CaGmr0EA.js → LiveModuleDocument-CSqzNMjn.js} +1 -1
- package/dist/assets/{LutAssetDocument-B6GmsOYd.js → LutAssetDocument-CsboXa8x.js} +1 -1
- package/dist/assets/ModelAssetDocument-DDVoKZpQ.js +1 -0
- package/dist/assets/{NonThreeAuthoringBootstrap-byKqf1kp.js → NonThreeAuthoringBootstrap-DcqD6_34.js} +1 -1
- package/dist/assets/Object3DDocumentToolbar-p2pd2TuS.js +1 -0
- package/dist/assets/Object3DDocumentViewport-BvNfSHi_.js +2 -0
- package/dist/assets/{Object3DPreview-pn9i3vwZ.js → Object3DPreview-Bv0fZcdS.js} +1 -1
- package/dist/assets/{OnlineAssetDetail-PDCDAcqz.js → OnlineAssetDetail-CPDafN4x.js} +1 -1
- package/dist/assets/{PlayBar-DEnkv3v6.js → PlayBar-CBD4rcED.js} +1 -1
- package/dist/assets/{QuarksAssetDocument-2x66XymD.js → QuarksAssetDocument-DUUhKUxZ.js} +1 -1
- package/dist/assets/{ReactCanvasControls-rFwp2CeP.js → ReactCanvasControls-3ual87uP.js} +1 -1
- package/dist/assets/{RootSelectionOverlay-B9rf-SSV.js → RootSelectionOverlay-DtX8yWUQ.js} +1 -1
- package/dist/assets/{ShaderAssetDocument-ImI6jbzB.js → ShaderAssetDocument-rkhRdPRk.js} +5 -5
- package/dist/assets/{ShadowEditor-DXxVxTzk.js → ShadowEditor-B-3FlftY.js} +1 -1
- package/dist/assets/{SourceAssetViewer-CMbp_o7v.js → SourceAssetViewer-CsMPohqK.js} +1 -1
- package/dist/assets/StageHost-BOaImrmu.js +2 -0
- package/dist/assets/{StoryPreviewMount-D2zLWzWy.js → StoryPreviewMount-BI-ANJix.js} +1 -1
- package/dist/assets/{ThreeBoardDocument-nX3UiY3u.js → ThreeBoardDocument-CoBjs8BP.js} +2 -2
- package/dist/assets/{ThreeIsolationSceneContent-CGHM0vsg.js → ThreeIsolationSceneContent-uShwSK1O.js} +1 -1
- package/dist/assets/{ToolObject3DPreview-BfNcqtFv.js → ToolObject3DPreview-CBZdWA_7.js} +1 -1
- package/dist/assets/{Toolbar-BJRJsbHG.js → Toolbar-DJK7o_be.js} +1 -1
- package/dist/assets/{TransientHint-CDvYgnzu.js → TransientHint-Dgu6u7U5.js} +1 -1
- package/dist/assets/{VideoViewer-B6Dv2zeQ.js → VideoViewer-BwTcASO2.js} +1 -1
- package/dist/assets/{ViewportShadingMenu-CrTY7tnk.js → ViewportShadingMenu-DUROUZdC.js} +1 -1
- package/dist/assets/{active-ingest-lrfMBhf9.js → active-ingest-Ra07ruDo.js} +3 -3
- package/dist/assets/{animation-clock-DktVGV5-.js → animation-clock-CKeqYCt9.js} +1 -1
- package/dist/assets/{animation-mixers.service-fkojNtor.js → animation-mixers.service-BNiEU2dA.js} +1 -1
- package/dist/assets/{animation-timeline.utility-DDrUZKe8.js → animation-timeline.utility-DQqMh1lF.js} +1 -1
- package/dist/assets/{asset-budget-asset.menu-CDlgKSO9.js → asset-budget-asset.menu-DFFih9b4.js} +1 -1
- package/dist/assets/{asset-budget.action-D6n-wIR3.js → asset-budget.action-C3SMMeSX.js} +1 -1
- package/dist/assets/{asset-budget.document-DFByoagB.js → asset-budget.document-B5NTy5dU.js} +1 -1
- package/dist/assets/{asset-budget.menu-B2u_1dWR.js → asset-budget.menu-Cclz2utV.js} +1 -1
- package/dist/assets/{asset-editor-persistence-e6bYhVnm.js → asset-editor-persistence-DsIjTddX.js} +1 -1
- package/dist/assets/{asset-loaders-Bsq-3hNt.js → asset-loaders-CQiLyapK.js} +1 -1
- package/dist/assets/{asset-preview-B7j9QV6N.js → asset-preview-BkFAKkZH.js} +1 -1
- package/dist/assets/{audio-unlock.service-7oO4YVIj.js → audio-unlock.service-CupzdUuC.js} +1 -1
- package/dist/assets/{audio.utility-9fcsT3YY.js → audio.utility-0il96T5s.js} +1 -1
- package/dist/assets/autoplay.service-SQBFaKvM.js +1 -0
- package/dist/assets/{babylon-authoring-adapter-BJfYxqDM.js → babylon-authoring-adapter-HZ_SbAet.js} +1 -1
- package/dist/assets/{binding-resolver-CBXePHiR.js → binding-resolver-BoecCqTq.js} +2 -2
- package/dist/assets/blender-emscripten-engine-Dk-rq4bm.js +2 -0
- package/dist/assets/{blender-node-editor.document-xA7eGv3-.js → blender-node-editor.document-B_MGPd1D.js} +1 -1
- package/dist/assets/{blender-properties-tab-nY8UOQUL.js → blender-properties-tab-ITmWT_gZ.js} +1 -1
- package/dist/assets/blender-runtime-host-CACzxt1b.js +4 -0
- package/dist/assets/{blender-runtime-skin-D3Arti9-.js → blender-runtime-skin-CwFW2Hj7.js} +36 -36
- package/dist/assets/blender-runtime.document-CozOB5TX.js +13 -0
- package/dist/assets/blender-screenshot.menu-BFR44H0L.js +1 -0
- package/dist/assets/{blender-timeline.document-DXoQ7y8E.js → blender-timeline.document-C0Zzi8Vo.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-CMOyob1N.js → blender-uv-editor.document-BktbYoor.js} +1 -1
- package/dist/assets/{blender-version.status-16xnuezC.js → blender-version.status-CLPjDPFV.js} +1 -1
- package/dist/assets/blender-wali-engine-CUWSQ_vI.js +2 -0
- package/dist/assets/{blender.command-Br2EUk6Q.js → blender.command-DdHEHM62.js} +1 -1
- package/dist/assets/{board-guides-whelE-Dr.js → board-guides-DhwRYHGT.js} +1 -1
- package/dist/assets/bridge.command-D4O9w4ft.js +3 -0
- package/dist/assets/{browserAll-BfZu7-UJ.js → browserAll-BhQBgoJL.js} +1 -1
- package/dist/assets/build-player.document-DFr-d97N.js +1 -0
- package/dist/assets/{build-profiles.document-DNncGOL3.js → build-profiles.document-C-64YHSV.js} +2 -2
- package/dist/assets/{build-progress.status-DnJetNft.js → build-progress.status-DVm95Lmt.js} +1 -1
- package/dist/assets/{build-session-BaEmzCkm.js → build-session-C_SD2MNJ.js} +1 -1
- package/dist/assets/{build.action-exbllMgM.js → build.action-CPee4b_9.js} +1 -1
- package/dist/assets/{build.command-Imykh8LN.js → build.command-CrZ5sHYt.js} +1 -1
- package/dist/assets/{build.header-9RzLy3UQ.js → build.header-DDbhXD6t.js} +1 -1
- package/dist/assets/{build.menu-CRhA3yID.js → build.menu-Ci-W_A1E.js} +1 -1
- package/dist/assets/{build.service-CxIdSEPw.js → build.service-CpUtTLP4.js} +1 -1
- package/dist/assets/{camera-BiBGeQQ4.js → camera-BZM67LhS.js} +1 -1
- package/dist/assets/{camera-runtime.inspector-DmRFynxC.js → camera-runtime.inspector-BLgPGd97.js} +1 -1
- package/dist/assets/{canvas-design-mount-DJ6zQJKG.js → canvas-design-mount-DPAhHuIQ.js} +6 -6
- package/dist/assets/{canvas-entry-runtime-Cjga4XYp.js → canvas-entry-runtime-DeyvFKWS.js} +2 -2
- package/dist/assets/{canvas-preview-frames-EoYgD6W4.js → canvas-preview-frames-Cm0GJ-40.js} +1 -1
- package/dist/assets/{canvas-story-capture.service-D5UntNCd.js → canvas-story-capture.service-Ziv9XNot.js} +2 -2
- package/dist/assets/{capability-coverage-9qm5WVwt.js → capability-coverage-39yK3DGt.js} +4 -4
- package/dist/assets/collaboration-presence-MR8LW4mZ.js +1 -0
- package/dist/assets/{collider-CTHtUvnl.js → collider-4Sgmy-qt.js} +1 -1
- package/dist/assets/{component-board.service-yIS2UB-T.js → component-board.service-BdcOkwgn.js} +2 -2
- package/dist/assets/{component-board.service-Bf-ETQF0.js → component-board.service-DO_oHdnS.js} +2 -2
- package/dist/assets/{component-board.service-foqmr9Ii.js → component-board.service-DRJcETCR.js} +2 -2
- package/dist/assets/{component-contracts.service-Do9hADdW.js → component-contracts.service-BYQTO1HK.js} +1 -1
- package/dist/assets/{component-instance-root-MBgAuUpp.js → component-instance-root-CzRnRMe6.js} +1 -1
- package/dist/assets/{component-verbs.command-DtMdPuyO.js → component-verbs.command-CFv5y_pR.js} +1 -1
- package/dist/assets/component-verbs.service-BMBAwqjA.js +1 -0
- package/dist/assets/{config-B6tt9xy3.js → config-C6iAsozB.js} +2 -2
- package/dist/assets/configurations-Dua_x6Wx.js +1 -0
- package/dist/assets/{connection.status-BNPvWdJD.js → connection.status-DQJvEgdT.js} +1 -1
- package/dist/assets/{constraints.inspector-DoOn25Lk.js → constraints.inspector-AHeP-LBc.js} +1 -1
- package/dist/assets/{content-bounds-BFpR_e--.js → content-bounds-tMCAobKq.js} +1 -1
- package/dist/assets/{contract-system-adapters-BRHtWOi_.js → contract-system-adapters-D6ion7SF.js} +1 -1
- package/dist/assets/{coverage.service-BB1XhwsL.js → coverage.service-Dm_H5o74.js} +2 -2
- package/dist/assets/{create-runtime-B6u6x5eK.js → create-runtime-C82CmCbc.js} +2 -2
- package/dist/assets/{curve-D11mIGoN.js → curve-C7Gg05DV.js} +1 -1
- package/dist/assets/{data-asset-DejEwzXj.js → data-asset-BquhdFX2.js} +1 -1
- package/dist/assets/{data-ref-DJNVzksb.js → data-ref-Dcq9KJIG.js} +1 -1
- package/dist/assets/{debug-bridge-DlGIEyTc.js → debug-bridge-DODnLefz.js} +1 -1
- package/dist/assets/{debug-registry-Dagj3b6J.js → debug-registry-CwYeaZ9J.js} +1 -1
- package/dist/assets/deferred-ingest-play-7EJo_GNB.js +2 -0
- package/dist/assets/{design-time-canvas-mount-Cpb_jITI.js → design-time-canvas-mount-DCINR1Hg.js} +2 -2
- package/dist/assets/{design-time-layers-DT4X-pJp.js → design-time-layers-i1N-JjPz.js} +1 -1
- package/dist/assets/{design-time-mount.service-DEa-41ij.js → design-time-mount.service-CtnijZJJ.js} +2 -2
- package/dist/assets/{design-time-mount.service-Ck5Hjxtn.js → design-time-mount.service-DrUVDx2-.js} +2 -2
- package/dist/assets/{design-time-react-mount-DCTpYS51.js → design-time-react-mount-CpgoPMGr.js} +1 -1
- package/dist/assets/{document-preview-three-TjlxMDBR.js → document-preview-three-CuBUMP4o.js} +1 -1
- package/dist/assets/{dom-authoring-adapter-C3ZsI41l.js → dom-authoring-adapter-DSM-2JgU.js} +1 -1
- package/dist/assets/{draco3d-Ddr7J1sS.js → draco3d--d91Ay95.js} +1 -1
- package/dist/assets/{edit-mode-audio.service-D047aZ6I.js → edit-mode-audio.service-C9_299G0.js} +1 -1
- package/dist/assets/{edit-mode-authoring-DubxVdEM.js → edit-mode-authoring-DgvzXpiM.js} +1 -1
- package/dist/assets/{edit-mode-networking.service-DitjC2ZL.js → edit-mode-networking.service-B6l9ESo-.js} +1 -1
- package/dist/assets/editor-api-D9NJWRVZ.js +1 -0
- package/dist/assets/{editor-layers-BK3fNRb7.js → editor-layers-D7HXdvWY.js} +1 -1
- package/dist/assets/{editor-shell-store-Bro0arjr.js → editor-shell-store-CGWO4Ldz.js} +1 -1
- package/dist/assets/{entity-object-BFppZ54X.js → entity-object-Dl04-FE8.js} +1 -1
- package/dist/assets/{extend-MkXq6t1H.js → extend-GXzJ7XU_.js} +1 -1
- package/dist/assets/fork-menu-DO1KASKk.js +1 -0
- package/dist/assets/{frame-debugger-store-xbOH83D0.js → frame-debugger-store-DOewah-x.js} +1 -1
- package/dist/assets/{game-contract-seams-5IUqvr7b.js → game-contract-seams-B5a-Ev-f.js} +1 -1
- package/dist/assets/{game-css-scope-transform-DDAoTvZQ.js → game-css-scope-transform-CQhuDfMR.js} +1 -1
- package/dist/assets/game-document.service-CMc6SfH9.js +1 -0
- package/dist/assets/{game-eval.command-DcFoKUe7.js → game-eval.command-MY5YxNL-.js} +1 -1
- package/dist/assets/{game-module-access-ABBzTWg7.js → game-module-access-BafPamOR.js} +1 -1
- package/dist/assets/game-network-COQRxS_4.js +22 -0
- package/dist/assets/gameplay-export-i_fnSpRp.js +1 -0
- package/dist/assets/gameplay-replay-BM_frdpr.js +1 -0
- package/dist/assets/{gameplay.command-qdQLKC3A.js → gameplay.command-Dkp2IG9Q.js} +1 -1
- package/dist/assets/generation-jobs-B6T_j2D_.js +1 -0
- package/dist/assets/{generation.service-CdwRWoIV.js → generation.service-BXJTa6dr.js} +1 -1
- package/dist/assets/{generations-nW4LG5qG.js → generations-DqNhoKz8.js} +1 -1
- package/dist/assets/{generations.status-DgjVrgGL.js → generations.status-Dt8TW7Lk.js} +1 -1
- package/dist/assets/{hierarchy-marks-Pb6wnNcu.js → hierarchy-marks-fSNwXIFe.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-BCnTLunr.js → hosted-asset-materialization-76jdNP28.js} +2 -2
- package/dist/assets/ibl-override-material-C09OAhCc.js +6 -0
- package/dist/assets/{index-CvGsVzTo.js → index-C5tasxXb.js} +294 -294
- package/dist/assets/{index-D7q1gYjq.js → index-CKznhnFr.js} +1 -1
- package/dist/assets/{index-BPuw4yre.js → index-CO6HFW9e.js} +1 -1
- package/dist/assets/{index-CaZZDx3x.js → index-Cf-uQvPt.js} +1 -1
- package/dist/assets/{index-BlWeDGvp.js → index-Cub6ESrb.js} +2 -2
- package/dist/assets/{index-Ds9fZyOU.js → index-D5pDWxZH.js} +1 -1
- package/dist/assets/{index-BYoN6-Qw.js → index-c6fd_bqy.js} +1 -1
- package/dist/assets/{index-Bz4YDJ7o.js → index-cGaEzVz5.js} +1 -1
- package/dist/assets/{index-Db2ixdvK.js → index-cNdu8TlA.js} +1 -1
- package/dist/assets/{inference-diagnostics-BCwXk-CS.js → inference-diagnostics-D7uYs70A.js} +1 -1
- package/dist/assets/{ingest-boot-viewport-BPER30gQ.js → ingest-boot-viewport-CjtFKkMD.js} +1 -1
- package/dist/assets/ingest-siblings-Dlx0quan.js +1 -0
- package/dist/assets/{ingest-source-persistence-CPlDA2D8.js → ingest-source-persistence-SAe0xIy-.js} +1 -1
- package/dist/assets/{ingest.service-BhwFGlqY.js → ingest.service-BXkZ1vXa.js} +1 -1
- package/dist/assets/{inspect-DxfAFkho.js → inspect-BqIL-41D.js} +1 -1
- package/dist/assets/instances.command-wpQVWPb9.js +1 -0
- package/dist/assets/{json-history-resource-CckDydoO.js → json-history-resource-BUJgH5iK.js} +1 -1
- package/dist/assets/layered-pick-RElCrqXb.js +1 -0
- package/dist/assets/{light-DF4nTzTq.js → light-DLADuHH2.js} +1 -1
- package/dist/assets/live-project-verbs-Cc1GXtG5.js +1 -0
- package/dist/assets/{machine.document-DaPLAXaa.js → machine.document-ER7OD-37.js} +1 -1
- package/dist/assets/{machines.finder-C9s8SFtp.js → machines.finder-CZ2ZxPFR.js} +1 -1
- package/dist/assets/material-CspuVO3Q.js +1 -0
- package/dist/assets/{material-factory-CCcnlv8E.js → material-factory-KV4mqSzl.js} +1 -1
- package/dist/assets/{mesh-CVBvSsCX.js → mesh-CrIkl8_H.js} +1 -1
- package/dist/assets/{model-asset-sections.service-vVRv6iOD.js → model-asset-sections.service-Cyom1FRs.js} +1 -1
- package/dist/assets/{model-inspection-Dd-hn5v2.js → model-inspection-BLOiPoW4.js} +1 -1
- package/dist/assets/{model-thumbnail-BDU_QU37.js → model-thumbnail-B7DVMYtQ.js} +1 -1
- package/dist/assets/{models.finder-CQMZz5xX.js → models.finder-At2wuWE3.js} +1 -1
- package/dist/assets/{module-mode-DcBz3aI7.js → module-mode-CHqvCb69.js} +2 -2
- package/dist/assets/{mount-canvas-ingest-root-DMWeT_c3.js → mount-canvas-ingest-root-uISMj3zn.js} +2 -2
- package/dist/assets/{mount-dom-ingest-root-Bx1TmleJ.js → mount-dom-ingest-root-C8PsgrCd.js} +2 -2
- package/dist/assets/{mount-ingest-root-BDP8atUq.js → mount-ingest-root-Dmb_D_oY.js} +2 -2
- package/dist/assets/{mount-manifest-C5QVCZlS.js → mount-manifest-CGwCOZO6.js} +1 -1
- package/dist/assets/{mount-three-ingest-root-DSmhgOJn.js → mount-three-ingest-root-BGdd6UoG.js} +1 -1
- package/dist/assets/{mounted-authoring-D-tXkNKH.js → mounted-authoring-BS53gpIm.js} +1 -1
- package/dist/assets/{mounted-story-viewport-source-Snu9yn1n.js → mounted-story-viewport-source-CL9Ra-_N.js} +1 -1
- package/dist/assets/{native-debug-module-XfhvyMrK.js → native-debug-module-DRmkIrIW.js} +1 -1
- package/dist/assets/{navigation-CTTcWe0R.js → navigation-DOuNvaV6.js} +1 -1
- package/dist/assets/{navmesh.menu-mFjQ30B0.js → navmesh.menu-9g4nO2dp.js} +1 -1
- package/dist/assets/{navmesh.service-BJPp7ZXu.js → navmesh.service-B7MllQj9.js} +1 -1
- package/dist/assets/network-observer.service-DY_39EdG.js +1 -0
- package/dist/assets/{network.utility-C-_7MTIV.js → network.utility-BgzPLUS5.js} +1 -1
- package/dist/assets/object3d-document-session-registry-Bk-I9jZH.js +2 -0
- package/dist/assets/{oid-transform-Bgdv7kST.js → oid-transform-CHeHFNUu.js} +1 -1
- package/dist/assets/{particles-CHXYb9Jd.js → particles-RD4cI69F.js} +1 -1
- package/dist/assets/{pixi-authoring-adapter-lj5CidSR.js → pixi-authoring-adapter-BuP3Qc7X.js} +1 -1
- package/dist/assets/{pixi-live-write-target-BEL9GCCr.js → pixi-live-write-target-DzyXhmiw.js} +1 -1
- package/dist/assets/play.command-C7iZbm26.js +2 -0
- package/dist/assets/{presentation-CmK-bEDi.js → presentation-43UAzXCV.js} +1 -1
- package/dist/assets/{product-gjrRHe-K.js → product-BfaoEtK8.js} +1 -1
- package/dist/assets/{profiler.action-CZ6UQi9A.js → profiler.action-DIp4OPNA.js} +1 -1
- package/dist/assets/{profiler.menu-DxbnC3d6.js → profiler.menu-tHZqii7c.js} +1 -1
- package/dist/assets/{profiler.utility-BvARl7sM.js → profiler.utility-CSg5WNN8.js} +1 -1
- package/dist/assets/{project-authoring-session-CBKXzBlD.js → project-authoring-session-BbwFHEzZ.js} +2 -2
- package/dist/assets/{properties-bone-constraints.inspector-Co8UpbhC.js → properties-bone-constraints.inspector-ooGWoGiI.js} +1 -1
- package/dist/assets/{properties-bone.inspector-CFXh2lQH.js → properties-bone.inspector-C_UdJjDe.js} +1 -1
- package/dist/assets/{properties-collection.inspector-Jq9X8fEq.js → properties-collection.inspector-Dm4MNZQK.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-CMcKD_Jc.js → properties-constraints.inspector-DlCHF3Nd.js} +1 -1
- package/dist/assets/{properties-data.inspector-cP3izSat.js → properties-data.inspector-DTfv2ILq.js} +1 -1
- package/dist/assets/{properties-material.inspector-CrZIovv9.js → properties-material.inspector-C_-GsOvF.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-DqQMxoiL.js → properties-modifiers.inspector-BELGiG49.js} +1 -1
- package/dist/assets/{properties-object.inspector-DM63eANJ.js → properties-object.inspector-COLlzAo4.js} +1 -1
- package/dist/assets/{properties-output.inspector-B475IBEd.js → properties-output.inspector-DLpqLRCp.js} +1 -1
- package/dist/assets/{properties-particles.inspector-vGXQ4kWx.js → properties-particles.inspector-C8ZhuG-X.js} +1 -1
- package/dist/assets/{properties-physics.inspector-CfwqpVGS.js → properties-physics.inspector-DQ3fUdPx.js} +1 -1
- package/dist/assets/{properties-render.inspector-BYLknsM7.js → properties-render.inspector-DlPuoXQ-.js} +1 -1
- package/dist/assets/{properties-scene.inspector-BcIZBfGk.js → properties-scene.inspector-itnV8qGu.js} +1 -1
- package/dist/assets/{properties-texture.inspector-p3Owurhl.js → properties-texture.inspector-BZbBAQ_O.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-CN-5jzB9.js → properties-view-layer.inspector-CNOevOy3.js} +1 -1
- package/dist/assets/{properties-world.inspector-DVp8fYWx.js → properties-world.inspector-C7u-dAkO.js} +1 -1
- package/dist/assets/r3f-design-session-DbXiRez3.js +2 -0
- package/dist/assets/{r3f-physics-binding-BcTFD1ZS.js → r3f-physics-binding-B8Je7bNy.js} +1 -1
- package/dist/assets/{r3f-source-authoring-adapter-DVnhzoxp.js → r3f-source-authoring-adapter-CarxaAwC.js} +1 -1
- package/dist/assets/{react-canvas-navigation-CBorZtWB.js → react-canvas-navigation-BTVCmK_d.js} +1 -1
- package/dist/assets/{react-inspector.service-Dc99kogU.js → react-inspector.service-BV9ZVls7.js} +1 -1
- package/dist/assets/{react-story-board-6-BjI32N.js → react-story-board-CETbMKNG.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-BO2XPUEM.js → react-three-rapier.esm-BQ3IBcaP.js} +1 -1
- package/dist/assets/{react-world-authoring-adapter-B6BiehHR.js → react-world-authoring-adapter-DsywMgco.js} +1 -1
- package/dist/assets/{realm-services-DCnaxwIb.js → realm-services-DoN23Ol2.js} +1 -1
- package/dist/assets/{reflection-probe-capture.inspector-CWneVfEe.js → reflection-probe-capture.inspector-D0grUDdX.js} +1 -1
- package/dist/assets/{registry-BQ9YcFZF.js → registry-CZxNkOhN.js} +1 -1
- package/dist/assets/{relative-import-specifier-BvzqkvYS.js → relative-import-specifier-DMppRnNH.js} +1 -1
- package/dist/assets/{render-env-F320_iHT.js → render-env-BAO3Rc6G.js} +1 -1
- package/dist/assets/{render-features-DFwHsGxu.js → render-features-CBm-s0QE.js} +1 -1
- package/dist/assets/{render-settings-BPcHd4LA.js → render-settings-DCZaLK-j.js} +1 -1
- package/dist/assets/{resolve-three-CnxafYrg.js → resolve-three-Bwj7rkZB.js} +13 -13
- package/dist/assets/{root-seam-contract-CueaHgB9.js → root-seam-contract-DMUsCBFW.js} +1 -1
- package/dist/assets/{run-selection-BMQWV9Fn.js → run-selection-DRkjJF-w.js} +1 -1
- package/dist/assets/{scene-capture-DcMYbX9_.js → scene-capture-DVXdql_1.js} +1 -1
- package/dist/assets/{scene-document.service-CZpLI3b6.js → scene-document.service-CxGQ1BN-.js} +2 -2
- package/dist/assets/{scene-framing-nVyYC4Y-.js → scene-framing-DUd4lKtW.js} +1 -1
- package/dist/assets/{seeded-random-D0QPgfm6.js → seeded-random-DzZFJTfh.js} +1 -1
- package/dist/assets/{setup-renderer-ji8Qt-PP.js → setup-renderer-DF2zFw-E.js} +1 -1
- package/dist/assets/{source-object3d-authoring-adapter-owosRx07.js → source-object3d-authoring-adapter-RimvAMDG.js} +1 -1
- package/dist/assets/{source-persistence-backend-Djuk0m-7.js → source-persistence-backend-BRcy23H9.js} +1 -1
- package/dist/assets/stage-keyboard-JRZ1CNbL.js +1 -0
- package/dist/assets/stage-overlay-set-DHN11xPU.js +1 -0
- package/dist/assets/{stage-presence-markers-CQlXR9fX.js → stage-presence-markers-AQuGIbnu.js} +1 -1
- package/dist/assets/stage-transform-tools-B8u8n8gJ.js +1 -0
- package/dist/assets/{standard-viewport-dressing-e4mnLmI6.js → standard-viewport-dressing-NHKaiGVg.js} +3 -3
- package/dist/assets/{state-watch.action-Cv3W67Kr.js → state-watch.action-B_conRk5.js} +1 -1
- package/dist/assets/{state-watch.menu-Cuziz9RM.js → state-watch.menu-B6GNrnYH.js} +1 -1
- package/dist/assets/{state-watch.utility-B1zkFd_6.js → state-watch.utility-CxuUOPhl.js} +1 -1
- package/dist/assets/story-capture-DYXQlnlZ.js +1 -0
- package/dist/assets/{story-documents-Cjoy-ydN.js → story-documents-D_Tg0idt.js} +1 -1
- package/dist/assets/{story-documents.service-Csto-LsX.js → story-documents.service-DQh0SkkQ.js} +1 -1
- package/dist/assets/{story-documents.service-gVxcUtso.js → story-documents.service-ES8nxeNu.js} +1 -1
- package/dist/assets/story-media-presence-D4w-waFJ.js +1 -0
- package/dist/assets/{story-pixi-preview-uA6AevDw.js → story-pixi-preview-B6GFGUQG.js} +1 -1
- package/dist/assets/{story-presentation-DgAoj9Qt.js → story-presentation-6qhUDkv4.js} +1 -1
- package/dist/assets/{story-three-preview-CQYi1rZ_.js → story-three-preview-BgLSJIlN.js} +2 -2
- package/dist/assets/{studio-environment-DK0ke0m0.js → studio-environment-BGU84AOG.js} +1 -1
- package/dist/assets/{surface-state-DlUcJe84.js → surface-state-BtNEZzCd.js} +1 -1
- package/dist/assets/{syntactic-prop-specs-92aOVqyZ.js → syntactic-prop-specs-B309atpv.js} +1 -1
- package/dist/assets/{team-playtest.service-CGBismiY.js → team-playtest.service-B8leDEE-.js} +1 -1
- package/dist/assets/{three-bdxPiUPb.js → three-BRZq2Px5.js} +1 -1
- package/dist/assets/{three-authoring-adapter-BuqO9MDt.js → three-authoring-adapter-DkfGlaNQ.js} +1 -1
- package/dist/assets/three-authoring.service-sOchR4o8.js +2 -0
- package/dist/assets/{three-ingest-runtime-CwRnwvb0.js → three-ingest-runtime-D9JoNRjk.js} +1 -1
- package/dist/assets/three-integration-D3zBmOoj.js +2 -0
- package/dist/assets/three-integration.service-CE8aNHob.js +1 -0
- package/dist/assets/{three-projection-core-BO23VKAP.js → three-projection-core-Dt5ARGlM.js} +1 -1
- package/dist/assets/{three-state-BhQOBgKC.js → three-state-3qPk0Sq8.js} +1 -1
- package/dist/assets/{three-story-capture.service-BAtrzxHq.js → three-story-capture.service-B3U2L4qG.js} +2 -2
- package/dist/assets/{three-story-model-D_bo7Gl-.js → three-story-model-C96x-E0V.js} +1 -1
- package/dist/assets/{three-viewport-presentation-CWanX03c.js → three-viewport-presentation-DGctcUkE.js} +5 -5
- package/dist/assets/transform-mode-request-C0cdwtJf.js +1 -0
- package/dist/assets/{transport-strip-CFLRAIQd.js → transport-strip-8OsPiJIm.js} +1 -1
- package/dist/assets/transport.header-D1Otpit3.js +1 -0
- package/dist/assets/{tuples-BKzzn3tK.js → tuples-CaBWqclR.js} +1 -1
- package/dist/assets/ui-board-document-BMTAhmJP.js +2 -0
- package/dist/assets/{user-data-DfBtZvxw.js → user-data-4Ls0MsfF.js} +1 -1
- package/dist/assets/{utility-view-state-CL4NJh3n.js → utility-view-state-gIzv2Oo_.js} +1 -1
- package/dist/assets/{viewport-door-CuJjGYTz.js → viewport-door-C4Fu0zS3.js} +1 -1
- package/dist/assets/{viewport-root-presentation-CkSAEMH-.js → viewport-root-presentation-DMMIH4rt.js} +1 -1
- package/dist/assets/{viewport-surface-status-D3t-0oLs.js → viewport-surface-status-CdI6sQko.js} +1 -1
- package/dist/assets/{webworkerAll-DCmB9rsA.js → webworkerAll-BINEvomm.js} +1 -1
- package/dist/assets/worker-Cu9kIzIf.js +2 -0
- package/dist/assets/{workspace-arrangement-C9uemwSK.js → workspace-arrangement-w-T2xUGF.js} +1 -1
- package/dist/assets/{world-documents-Dvn8e5I0.js → world-documents-feEUCgVE.js} +1 -1
- package/dist/assets/{world-root-stage-binding-BB7acZV_.js → world-root-stage-binding-BDb6wt_C.js} +1 -1
- package/dist/assets/{xstate-animation-binding-DctwT981.js → xstate-animation-binding-Bhz1Uhhw.js} +1 -1
- package/dist/assets/{xstate-animation-meta-s4Vc8Wu3.js → xstate-animation-meta-CvDlYgrt.js} +1 -1
- package/dist-node/cli.js +21 -18
- package/package.json +16 -16
- package/template/src/lib/reflections/ReflectionProbe.tsx +34 -5
- package/template/src/lib/reflections/index.ts +1 -0
- package/template/src/lib/reflections/probe-controller.ts +44 -3
- package/template/src/lib/reflections/reflection-probe-registry.ts +32 -7
- package/template/src/lib/reflections/volume-reflection-material.ts +638 -160
- package/dist/assets/CanvasSceneViewport-Z8OReqpB.js +0 -1
- package/dist/assets/EntityModelDocument-BltE1A7W.js +0 -1
- package/dist/assets/InspectorObjectPreview-BpttBw3o.js +0 -1
- package/dist/assets/ModelAssetDocument-BBDnXTQm.js +0 -1
- package/dist/assets/Object3DDocumentToolbar-BHuuMZnS.js +0 -1
- package/dist/assets/Object3DDocumentViewport-ByDDwGJD.js +0 -2
- package/dist/assets/StageHost-D1Sz5aud.js +0 -2
- package/dist/assets/autoplay.service-DncOrn-K.js +0 -1
- package/dist/assets/blender-emscripten-engine-DQljvfR7.js +0 -2
- package/dist/assets/blender-runtime-host-CcqXT39s.js +0 -4
- package/dist/assets/blender-runtime.document-DDW5jIJe.js +0 -12
- package/dist/assets/blender-wali-engine-CO-jG_ik.js +0 -2
- package/dist/assets/bridge.command-T93eURWq.js +0 -3
- package/dist/assets/build-player.document-DJQLP4xM.js +0 -1
- package/dist/assets/collaboration-presence-Q6zcL5v0.js +0 -1
- package/dist/assets/component-verbs.service-CJYq28Zw.js +0 -1
- package/dist/assets/configurations-BcYOQ7i-.js +0 -1
- package/dist/assets/deferred-ingest-play-DZiOEH9a.js +0 -2
- package/dist/assets/editor-api-CPh65aBN.js +0 -1
- package/dist/assets/fork-menu-DzoCyQvA.js +0 -1
- package/dist/assets/game-document.service-CxfiFnxt.js +0 -1
- package/dist/assets/game-network-BPTyOFqA.js +0 -22
- package/dist/assets/gameplay-export-CRnHCUBb.js +0 -1
- package/dist/assets/gameplay-replay-yPaMxi2o.js +0 -1
- package/dist/assets/generation-jobs-Cy1oE-Ff.js +0 -1
- package/dist/assets/ibl-override-material-CMo_a49U.js +0 -6
- package/dist/assets/ingest-siblings-2QHhcCgA.js +0 -1
- package/dist/assets/instances.command-BJ-I9vtW.js +0 -1
- package/dist/assets/layered-pick-BaxBYi7u.js +0 -1
- package/dist/assets/live-project-verbs-B7S-wGjC.js +0 -1
- package/dist/assets/material-rGFsBrD0.js +0 -1
- package/dist/assets/network-observer.service-CjeDB1Id.js +0 -1
- package/dist/assets/object3d-document-session-registry-CWaOPDYg.js +0 -2
- package/dist/assets/play.command-C9QyYFgv.js +0 -2
- package/dist/assets/r3f-design-session-Cyy1sDGH.js +0 -2
- package/dist/assets/stage-keyboard-G6HMStmP.js +0 -1
- package/dist/assets/stage-overlay-set-ChHqsFiR.js +0 -1
- package/dist/assets/stage-transform-tools-BM9u9Awe.js +0 -1
- package/dist/assets/story-capture-Drqhmo7i.js +0 -1
- package/dist/assets/story-media-presence-CYc2fP4y.js +0 -1
- package/dist/assets/three-authoring.service-CMym8IbB.js +0 -2
- package/dist/assets/three-integration-BHoulbny.js +0 -2
- package/dist/assets/three-integration.service-BlgF9hV3.js +0 -1
- package/dist/assets/transform-mode-request-Bg6T_rOC.js +0 -1
- package/dist/assets/transport.header-B3dK1KaC.js +0 -1
- package/dist/assets/ui-board-document-DMxgQ-9n.js +0 -2
- package/dist/assets/worker-CJIsrsP6.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 Uo,b as Wo,L as Ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ot,cl as qo,fo as x,cm as X,N as fn,a$ as bt,em as
|
|
2
|
+
import{a as Uo,b as Wo,L as Ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ot,cl as qo,fo as x,cm as X,N as fn,a$ as bt,em as Jn,b4 as Te,co as Tt,ey as Pe,cp as bn,_ as ht,ej as Mt,fd as $t,er as Ae,M as it,cj as ut,dp as gt,aV as Se,cW as Go,aE as Xo,c7 as ft,j as Ee,f6 as Me,fp as to,au as Pn,dw as An,bi as no,aT as Ne,c1 as Lt,dd as Vn,eC as jn,e7 as gn,aw as nn,da as It,I as yn,as as Re,e8 as Ie,b0 as Yo,K as Fe,B as ze,b9 as De,Y as Zo,cw as ln,ed as Ce,cA as ke,fx as $e,db as Qo,el as Le,R as Ve,e6 as je,c0 as Ko,bX as Be,aI as uo,ao as Ue,eG as We,d3 as He,cs as qe,ex as Ge,b5 as Xe,cY as Ye,eU as Ze,cE as Bn,c5 as Jo,cO as oo,at as Qe,ff as Ke,eW as Je,f7 as ta,F as na,ev as oa,et as ea,dq as aa,fq as ra,n as la,l as ia,cf as sa}from"./three.core-3arARmh6.js";import{u as P,v as F,w as E,c5 as q,c4 as W,c6 as S,e2 as $,_ as fa,mB as te,d_ as jt,x as j,kD as _t,e1 as ne,mC as B,dZ as ca,mD as ua}from"./index-C5tasxXb.js";import{S as Ft}from"./three.module-BLhyNg0e.js";import{t as _a}from"./blender-runtime-host-CACzxt1b.js";const Un=new Set;function vt(){for(const o of[...Un])o()}function ma(o){return Un.add(o),()=>{Un.delete(o)}}function Wn(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const Zt=S().finite(),da=P({name:E(),parent:E().nullable(),connected:q(),hide:q(),length:Zt,matrix:F($([Zt,Zt,Zt,Zt])).length(4),select:q(),active:q(),lockedWeight:q()}).strict(),ha=P({object:E(),displayType:W(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:q(),mode:E(),bones:F(da)}).strict(),xt={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function pa(o){return new ht(o.r*o.r*.1,o.g*o.g*.1,o.b*o.b*.1)}const Sn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],_o=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],Pt=Math.SQRT1_2,va=[[Pt,-Pt,0],[0,-Pt,-Pt],[-Pt,-Pt,0],[0,-Pt,Pt],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],ga=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],xa=.05;function mo(o){return o.select||o.active?2:1}const ba=10,ya=4,wa=`
|
|
3
3
|
attribute vec3 aSolid;
|
|
4
4
|
attribute vec3 aHint;
|
|
5
5
|
varying vec3 vColor;
|
|
@@ -16,7 +16,7 @@ import{a as Uo,b as Wo,L as Ho}from"./LineSegments2-DN9pUfWA.js";import{bh as ot
|
|
|
16
16
|
gl_FragColor = vec4(vColor, 1.0);
|
|
17
17
|
#include <colorspace_fragment>
|
|
18
18
|
}
|
|
19
|
-
`;function St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Ta=new X,Pa=new x,vo=new qo;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Aa{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 i=n(a.object);if(i===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,i):this.buildOctahedral(a,c,i);a.showInFront&&u.traverse(f=>{const s=f.material;s&&"depthTest"in s&&(s.depthTest=!1),f.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const r=new ot;r.name=`${t.object}:bones`;const a=[],i=[],c=[],u=[],f=[],s=[],l=[],_=[],h=[],d=[];for(const m of n){const p=go(e,m),v=po(t,m),g=pa(v),b=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const A=Pa.set(...va[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const M=new x(...An[O]).applyMatrix4(p);a.push(M.x,M.y,M.z),i.push(A.x,A.y,A.z),c.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const w=mo(m)===2?l:f,R=mo(m)===2?_:s;for(const[T,A]of ga){const O=new x(...An[T]).applyMatrix4(p),M=new x(...An[A]).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||(h.push(p.clone()),d.push(v)),h.push(p.clone().multiply(Ta.makeTranslation(0,1,0))),d.push(v)}r.add(this.solidMesh(a,i,c,u)),f.length&&r.add(this.lines(f,s,1)),l.length&&r.add(this.lines(l,_,2));for(let m=0;m<h.length;m++)r.add(this.point(h[m],d[m]));return r}buildStick(t,n,e){const r=new ot;r.name=`${t.object}:bones`;const a=[],i=[],c=[],u=[];for(const f of n){const s=go(e,f),l=new x().setFromMatrixPosition(s),_=new x(0,1,0).applyMatrix4(s),h=ho(t,f),d=po(t,f);a.push(l.x,l.y,l.z,_.x,_.y,_.z),i.push(h.r,h.g,h.b,h.r,h.g,h.b),c.push(l.x,l.y,l.z,_.x,_.y,_.z),u.push(d.r,d.g,d.b,d.r,d.g,d.b)}return r.add(this.lines(a,i,ba)),r.add(this.lines(c,u,ya)),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 i=new Kn({vertexShader:wa,fragmentShader:Oa,side:Te});this.disposables.push(a,i);const c=new Tt(a,i);return c.frustumCulled=!1,c}lines(t,n,e){const r=new Uo;r.setPositions(t),r.setColors(n);const a=new Wo({linewidth:e,vertexColors:!0});this.disposables.push(r,a);const i=new Ho(r,a);return i.frustumCulled=!1,i}point(t,n){const e=new Pe(xa,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 Sa="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ea(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),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,wn=N(2*Math.PI),Sn=N(1-1e-4),Ft=(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(Ft(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,i=(r+2)%3;n[r]=N(n[r]+N(N(t[a]-e[a])*N(t[i]+e[i])))}t=e}return n}function Ra(o){const t=[],n=[],e=(d,m)=>d<m?`${d}:${m}`:`${m}:${d}`,r=new Map((o.edge_order??[]).map(([d,m],p)=>[e(d,m),p])),a=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=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?.[d]?.[g]??r.get(b),R=t.length;t.push({vertex:m[g],face:d,edge:w,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=i.get(w)??[];T.push(R),i.set(w,T)}}const c=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],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=[],s=[],l=[],_=[],h=(d,m)=>Kt(Ma(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(;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(Ft(h(M,"prev"),h(M,"next"))));g=Kt(g)}const b=h(m,"next"),w=v.at(-1),R=h(w,"prev"),T=Ft(b,g),A=Ft(R,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<Sn&&Math.abs(A)<Sn){const M=v.length>1?v.map(pt=>h(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(Ft(y,g))),0)/M.length):N(N(Jt(T)+Jt(A))/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,-A)),Q=Ft(O.reference,H),tt=Jt(Q);O.beta=Q<Sn?Ft(O.ortho,H)<0?N(wn-tt):tt:wn}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)s[M]=f.length;f.push(v),l.push(O),_.push(g)}return{corners:t,fans:f,fanOf:s,spaces:l,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(wn-o.alpha))*n),a=N((e>0?o.beta:N(wn-o.beta))*e);let i=o.normal.map(c=>N(c*N(Math.cos(r))));return i=rn(i,o.reference,N(N(Math.sin(r))*N(Math.cos(a)))),e!==0&&(i=rn(i,o.ortho,N(N(Math.sin(r))*N(Math.sin(a))))),i}function oe(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[i,c]of e.entries()){const u=c.reduce((s,l)=>{const _=t.data[l];return[s[0]+_[0],s[1]+_[1]]},[0,0]),f=Ia(r[i],u.map(s=>Math.trunc(s/c.length)));for(const s of c)a[s]=f}return a}if(t.type==="FLOAT_VECTOR")return n.map((a,i)=>{const c=t.domain==="POINT"?a.vertex:t.domain==="FACE"?a.face:i;return t.data[c]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const En={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}},za=1e-6;function Fa(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),xo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ca(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],r=o[(n+1)%o.length];t+=e.x*r.y-r.x*e.y}return t}function bo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let r=0;for(const[a,i,c]of o){const u=Da(t[a],t[i],t[c]);if(u*e<0)return!1;r+=Math.abs(u)}return Math.abs(r-Math.abs(n))<=za*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=Fa(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:xo(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),i=new x().crossVectors(a,r).normalize(),c=new x().crossVectors(r,i),u=o[0],f=o.map(h=>{const d=h.clone().sub(u);return new $t(d.dot(i),d.dot(c))}),s=Ca(f),l=xo(t);if(bo(l,f,s))return{triangles:l,sound:!0,method:"fan"};let _=[];try{_=Ae.triangulateShape(f,[]).map(h=>[h[0],h[1],h[2]])}catch{return{triangles:l,sound:!1,method:"fan"}}return bo(_,f,s)?{triangles:_,sound:!0,method:"earcut"}:{triangles:_.length>0?_:l,sound:!1,method:_.length>0?"earcut":"fan"}}const $a=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Mn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Nn(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[Mn(Number(t[n*4])),Mn(Number(t[n*4+1])),Mn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function ee(o,t){return o.filter(n=>$a.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),r=[0,0,0,0];return{name:n.name,domain:n.domain,read:(a,i,c)=>n.domain==="POINT"?Nn(n.type,e,a):n.domain==="CORNER"?i===void 0?r:Nn(n.type,e,i):c===void 0?r:Nn(n.type,e,c)}})}function ae(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,r=o.cornerVerts,a=e[n];let i=t;for(let y=0;y<n;y++)i+=(e[y+1]-e[y]-2)*3;const c=new Uint32Array(a),u=new Uint8Array(a),f=new Uint8Array(t),s=new Uint32Array(a);let l=!1;for(let y=0;y<n;y++)if(o.smooth(y)){l=!0;break}const _=(y,L)=>t<94906265?Math.min(y,L)*t+Math.max(y,L):`${Math.min(y,L)}:${Math.max(y,L)}`,h=new Map,d=new Set;for(const[y,L]of o.sharp)d.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");h.set(_(y,L),-1)}const m=y=>{for(;s[y]!==y;)s[y]=s[s[y]],y=s[y];return y},p=(y,L)=>{const D=m(y),Y=m(L);s[Math.max(D,Y)]=Math.min(D,Y)};for(let y=0;y<n;y++){const L=e[y],D=e[y+1]-L,Y=o.smooth(y)?1:0;for(let Z=0;Z<D;Z++){const k=L+Z;f[r[k]]=1,c[k]=L+(Z+1)%D,u[k]=Y,s[k]=k}}for(let y=0;y<a;y++){const L=c[y],D=r[y],Y=r[L],Z=_(D,Y),k=h.get(Z);if(k!==void 0&&k>=0&&u[y]&&u[k]&&!d.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])&&h.set(Z,y)}const v=o.uv,g=new Float32Array(i*3),b=new Float32Array(i*2),w=new Uint32Array(i),R=(o.uvLayers??[]).map(y=>({...y,data:new Float32Array(i*2)})),T=(o.attributeLayers??[]).map(y=>({...y,data:new Float32Array(i*4)})),A=o.orco?new Float32Array(i*3):null,O=new Uint32Array(i),M=new Map,C=[],V=o.normals||o.cornerNormal?new Float32Array(i*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(A)for(let G=0;G<3;G++)A[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(!l)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 Oe of Yt)O[Q++]=pt(D+Oe,y);const k=o.material(y),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let y=0;y<t;y++)f[y]||tt(y);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?b.slice(0,H*2):null,uvLayers:R.map(y=>({name:y.name,data:y.data.slice(0,H*2)})),attributeLayers:T.map(y=>({name:y.name,data:y.data.slice(0,H*4)})),orco:A?A.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 Wn(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 i=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 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:f,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,_=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/En[s.type].size},(m,p)=>Array.from({length:En[s.type].size},(v,g)=>Number(s.data[p*En[s.type].size+g])))}:void 0,h=new x,d={vertexCount:n,normals:l?oe(l,_):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>h.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: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:ee(o.attributes,m=>m)};return{...ae(d),hash:t}}function Va(o){const t=o.v.map(l=>new x(...l)),n=l=>{const _=t[l];if(!_)throw new Error(`Runtime mesh vertex ${l} is missing`);return _},e=new Uint32Array(o.f.length+1);o.f.forEach((l,_)=>{if(l.length<3||new Set(l).size!==l.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[_+1]=e[_]+l.length});const r=new Uint32Array(e[o.f.length]);o.f.forEach((l,_)=>l.forEach((h,d)=>{n(h),r[e[_]+d]=h}));for(const[l,_]of o.edge_order??o.e??[])n(l),n(_);const a={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:r.length};for(const l of o.attributes??[])if(l.domain!=="EDGE"&&l.data.length!==a[l.domain])throw new Error(`Runtime attribute ${l.name} has ${l.data.length} values for ${a[l.domain]} ${l.domain} elements`);const i=(o.attributes??[]).filter(l=>l.type==="FLOAT2"&&l.domain==="CORNER"),c=o.render_uv??o.active_uv??i[0]?.name,u=i.find(l=>l.name===c);if(c&&!u)throw new Error(`Runtime UV map ${c} is missing`);const f=u?.data,s={vertexCount:t.length,normals:oe(o,o.attributes?.find(l=>l.name==="custom_normal")),co:n,starts:e,cornerVerts:r,smooth:l=>!!o.s?.[l],material:l=>o.m?.[l]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:f?l=>f[l]:null,uvLayers:i.map(l=>({name:l.name,read:_=>l.data[_]})),attributeLayers:ee(o.attributes??[],l=>Array.from(l).flat())};return Wn(ae(s))}const sn=1.5707963267948966,Dt=6.283185307179586,re=.3183098861837067,le=.0795774715459476,ja=.3,Ba=le,Ua=3/16*re,Hn=.8,yo=Hn*Hn,Ct=6371,ie=100,qn=Ct+ie,wo=64,Oo=64,et=256,Nt=64,Wa=[1.679,1.828,1.986,1.307],Ha=[.006605,.01067,.01842,.03156],qa=[3472e-28,3914e-28,1349e-28,1103e-29],Ga=334.5,Xa=[28722e-28,46168e-28,79706e-28,13578e-27],Ya=[15908e-26,17711e-26,20942e-26,24033e-26],To=13681e16,Za=2e6,Qa=.73,Rn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],On=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),Ka=o=>Math.sqrt(Math.max(o,0)),se=o=>[-Math.sqrt(1-o*o),0,o];function Gn(o,t,n,e,r,a,i){const c=o*e+t*r+n*a,u=o*o+t*t+n*n-i*i;if(u>0&&c>0)return-1;const f=c*c-u;return f<0?-1:f>=c*c?-c+Math.sqrt(f):-c-Math.sqrt(f)}const Ja=o=>Ua*(1+On(o));function tr(o){const t=1+yo+2*Hn*o;return le*(1-yo)/(t*Math.sqrt(t))}const nr=o=>To*(Math.exp(-o/Qa)+Za/To);function oo(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(-On(r-3.22261)*5.55555555-r),i=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]*i*this.air}transmittance(t,n,e){const[r,a,i]=se(t),c=Ot(Ct,qn,n),f=Gn(0,0,c,r,a,i,qn)/wo,s=[0,0,0,0],l=new Float64Array(16);for(let _=0;_<wo;_++){const h=(_+.5)*f,d=r*h,m=a*h,p=c+i*h,v=Math.max(Math.hypot(d,m,p)-Ct,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])*f}for(let _=0;_<4;_++)e[_]=Math.exp(-s[_])}precompute(){const t=new Float64Array(4);for(let n=0;n<Nt;n++)for(let e=0;e<et;e++){const r=e/(et-1),a=n/(Nt-1);this.transmittance(r*2-1,a,t);const i=(n*et+e)*4;for(let c=0;c<4;c++)this.lut[i+c]=t[c]}}lookup(t,n,e){const r=(et-1)*on(t*.5+.5),a=(Nt-1)*on(n),i=Math.trunc(r),c=Math.trunc(a),u=Math.min(i+1,et-1),f=Math.min(c+1,Nt-1),s=r-i,l=a-c,_=(c*et+i)*4,h=(c*et+u)*4,d=(f*et+i)*4,m=(f*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[_+p],this.lut[h+p],s),Ot(this.lut[d+p],this.lut[m+p],s),l)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),r=Math.trunc(e),a=Math.min(r+1,et-1),i=e-r;for(let c=0;c<4;c++)n[c]=Ot(this.lut[r*4+c],this.lut[a*4+c],i)}lookupToSun(t,n){const e=(Nt-1)*on(t),r=Math.trunc(e),a=Math.min(r+1,Nt-1),i=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],i)}inscattering(t,n,e,r,a,i,c,u,f){const s=-(a*t[0]+i*t[1]+c*t[2]),l=Ja(s),_=tr(s),h=u/Oo,d=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),b=new Float64Array(4),w=[0,0,0,0],R=[1,1,1,1];for(let T=0;T<Oo;T++){const A=(T+.5)*h,O=n+a*A,M=e+i*A,C=r+c*A,V=Math.hypot(O,M,C),H=Math.max(V-Ct,0),Q=H/ie,tt=(O*t[0]+M*t[1]+C*t[2])/V;this.coefficients(H,d),this.lookup(tt,Q,m);const pt=Dt*(1-Ka(1-On(Ct/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,b);const y=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let D=0;D<4;D++){const Y=g[D]/b[D],Z=Ba*pt*(ja*re)*v[D]*Y*tt;p[D]=.02*L[D]*y+Z}for(let D=0;D<4;D++){const Y=d[D]+d[4+D]+d[8+D]+d[12+D],Z=Wa[D]*(d[12+D]*(l*m[D]+p[D])+d[4+D]*(_*m[D]+p[D])),k=Math.exp(-h*Y),G=Math.max(Y,1e-7);w[D]+=R[D]*((Z-Z*k)/G),R[D]*=k}}for(let T=0;T<4;T++)f[T]=w[T]}}const st=512,qt=256;function fe(o,t){const n=new or(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,r=se(Math.cos(sn-t)),a=new Float32Array(st*qt*3),i=st/2,c=new Float64Array(4);for(let u=0;u<qt;u++)for(let f=0;f<i;f++){const s=(f+.5)/st,l=(u+.5)/qt,_=Dt*s,h=l*2-1,d=Math.sign(h)*On(h)*sn,m=Math.cos(d)*Math.cos(_),p=Math.cos(d)*Math.sin(_),v=Math.sin(d),g=Ct+e,b=Gn(0,0,g,m,p,v,qn),w=Gn(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,A=0,O=0;for(let V=0;V<4;V++)T+=Rn[V][0]*c[V],A+=Rn[V][1]*c[V],O+=Rn[V][2]*c[V];const M=(u*st+f)*3;a[M]=T,a[M+1]=A,a[M+2]=O;const C=(u*st+(st-f-1))*3;a[C]=T,a[C+1]=A,a[C+2]=O}return a}function er(o){const[t]=oo(o.sunElevation,o.sunRotation);return fe(o,t)}function eo(o){const[t]=oo(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(eo(o))}function ce(o,t){Wt.set(eo(o),t),Wt.size>ar&&Wt.delete(Wt.keys().next().value)}function lr(o){const[t,n]=oo(o.sunElevation,o.sunRotation),e=eo(o);let r=Wt.get(e);r===void 0&&(r=fe(o,t),ce(o,r));const a=new x;return i=>{const c=Math.hypot(i.x,i.y),u=Math.atan2(i.z,c);let s=(Math.atan2(i.x,i.y)+Math.PI+n)/Dt;s-=Math.floor(s);const l=Math.abs(u),_=on(Math.sqrt(l/sn)*Math.sign(u)*.5+.5),h=s*st-.5,d=_*qt-.5,m=Math.floor(h),p=Math.floor(d),v=h-m,g=d-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),A=w(p),O=w(p+1),M=[0,0,0];for(let C=0;C<3;C++){const V=Ot(r[(A*st+R)*3+C],r[(A*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 At=null,cn=!1,ir=0;const en=new Map;function sr(){if(At||cn)return At;if(typeof Worker>"u")return cn=!0,null;try{At=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return At.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")))},At.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),At?.terminate(),At=null,cn=!0},At}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 In=(o,t)=>t!==0?o/t:0,Po=o=>Math.min(1,Math.max(-1,o)),Ao=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},ue={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:In,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:In(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(In(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:Ao,SMOOTH_MAX:(o,t,n)=>-Ao(-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},i=new x;return c=>{const u=r(c),f=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,l=typeof u=="number"?u:u.z,_=ut.clamp(cr(f,s,l,a),0,1);return o.output==="Fac"?_:i.setScalar(_)}}if(o.kind==="to_float"){const r=nt(o.value,t);return a=>{const i=r(a);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 r=o.inputs.map(c=>nt(c,t)),a=ue[o.operation],i=(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(i(0,c),i(1,c),i(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),i=nt(o.b,t),c=new x,u=new x;return f=>{const s=r(f);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const l=a(f);typeof l=="number"?c.setScalar(l):c.copy(l);const _=i(f);return typeof _=="number"?u.setScalar(_):u.copy(_),c.lerp(u,o.clamp_factor?ut.clamp(s,0,1):s),o.clamp_result&&c.clampScalar(0,1),c}}if(o.kind==="sky"){const 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),i=new x(...o.scale),c=new gt().setFromEuler(new Se(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=c.clone().invert(),f=new x(...o.scale.map(l=>l===0?0:1/l)),s=new x;return l=>{const _=r(l);switch(typeof _=="number"?s.setScalar(_):s.copy(_),o.vector_type??"POINT"){case"TEXTURE":return s.sub(a).applyQuaternion(u).multiply(f);case"VECTOR":return s.multiply(i).applyQuaternion(c);case"NORMAL":return s.multiply(f).applyQuaternion(c).normalize();case"POINT":return s.multiply(i).applyQuaternion(c).add(a)}}}if(o.kind==="map_range"){const r=nt(o.value,t),a=nt(o.from_min,t),i=nt(o.from_max,t),c=nt(o.to_min,t),u=nt(o.to_max,t),f=nt(o.steps,t),s=(h,d)=>{const m=h(d);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},l=o.interpolation,_=o.clamp;return h=>{const d=s(r,h),m=s(a,h),p=s(i,h),v=s(c,h),g=s(u,h);if(m===p)return 0;let b;if(l==="STEPPED"){const R=s(f,h),T=(d-m)/(p-m);b=R>0?Math.floor(T*(R+1))/R:0}else if(l==="SMOOTHSTEP"||l==="SMOOTHERSTEP"){const R=ut.clamp((d-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=l==="SMOOTHSTEP"?R*R*(3-2*R):R*R*R*(R*(R*6-15)+10);b=m>p?1-T:T}else b=(d-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 i=r(a);return typeof i=="number"?i:i.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 i=ut.clamp(a,0,1)*256,c=Math.floor(i),u=o.colors[c],f=o.colors[Math.min(c+1,256)],s=o.interpolate?i-c:0;return e.set(ut.lerp(u[0],f[0],s),ut.lerp(u[1],f[1],s),ut.lerp(u[2],f[2],s))}}function ur(o,t,n,e){const r=new Float32Array(t*n*3),a=nt(o,e),i=new x;for(let c=0;c<n;c++){const u=((c+.5)/n-.5)*Math.PI;for(let f=0;f<t;f++){const s=((f+.5)/t-.5)*2*Math.PI;i.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const l=a(i),_=(c*t+f)*3;r[_]=typeof l=="number"?l:l.x,r[_+1]=typeof l=="number"?l:l.y,r[_+2]=typeof l=="number"?l:l.z}}return r}function So(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function _r(o,t,n,e){e.updateMatrixWorld();const r=new Float32Array(t*n*3),a=new x,i=nt(o,()=>a),c=new x,u=e.getWorldPosition(new x),f=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let l=0;l<t;l++){const _=(l+.5)/t,h=(s+.5)/n;a.set(_,h,0),e.isOrthographicCamera?c.copy(f):c.set(_*2-1,h*2-1,.5).unproject(e).sub(u).normalize(),c.set(c.x,-c.z,c.y);const d=i(c),m=(s*t+l)*3;r[m]=typeof d=="number"?d:d.x,r[m+1]=typeof d=="number"?d:d.y,r[m+2]=typeof d=="number"?d:d.z}return r}const J=S().finite(),mr=P({type:W(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:W(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Xn;function dr(){return Xn??=fa(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Xn}function hr(){return Xn??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=(i,c)=>t&&c(t)?t:new i;if(o.type==="SUN"){const i=n(Xo,c=>c.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(Ln,c=>c.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(Vn,c=>c.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}dr();const e=n(gn,i=>i.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 i=a.camera;i.near=Math.max(n*.001,r-n),i.far=r+n,o.isDirectionalLight&&(i.left=-n,i.right=n,i.top=n,i.bottom=-n),i.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 ao=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],Eo=.69;class br{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Go;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[r,a]of ao.entries()){const i=(1+a.smooth)**2,c=new Xo(16777215,Math.PI*Eo/i);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/i,n.g+=a.diffuse[1]*a.smooth/i,n.b+=a.diffuse[2]*a.smooth/i}const e=new Ee(16777215,Math.PI*Eo);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),U=te(()=>jt([J,Ut,P({kind:j("direction")}).strict(),P({kind:j("window")}).strict(),P({kind:j("gradient"),gradient_type:W(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:W(["Fac","Color"]),vector:U}).strict(),P({kind:j("to_float"),source_type:W(["RGBA","VECTOR"]),value:U}).strict(),P({kind:j("math"),operation:W(Object.keys(ue)),clamp:q(),inputs:z(U).min(1).max(3)}).strict(),P({kind:j("mix_color"),factor:U,a:U,b:U,clamp_factor:q(),clamp_result:q()}).strict(),P({kind:j("mapping"),vector_type:W(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:U,location:Ut,rotation:Ut,scale:Ut}).strict(),P({kind:j("separate"),vector:U,axis:S().int().min(0).max(2)}).strict(),P({kind:j("ramp"),factor:U,colors:z(Ut).length(257),interpolate:q()}).strict(),P({kind:j("map_range"),interpolation:W(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:U,from_min:U,from_max:U,to_min:U,to_max:U,steps:U}).strict(),P({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),Mo=P({color:Ut,strength:J,shader:U.optional()}),yr=Mo.extend({volume:z(P({kind:W(["absorption","scatter","principled","emission"]),phase:E(),alpha:U,weight:U,color:U,density:U,anisotropy:U,absorption_color:U,emission_color:U,emission_strength:U,blackbody_intensity:U,temperature:U,blackbody_tint:U}).strict()).optional(),lighting:Mo.strict().optional()}).strict(),wr=4,tn=new Map,zn=new Set;function No(o,t,n){const a=Et(o);if(a&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const i=JSON.stringify([o,a?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),c=tn.get(i);if(c!==void 0)return Yn(c,t,256,128);const u=new x,f=new Jn,s=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,l=n?.getWorldPosition(new x),h=ur(o,256,128,a?d=>(u.set(d.x,d.z,-d.y),n.isPerspectiveCamera&&u.add(l),f.set(u.x,u.y,u.z,1).applyMatrix4(s),f.w===0?u.set(0,0,0):u.set(f.x/f.w*.5+.5,f.y/f.w*.5+.5,0)):void 0);return tn.set(i,h),tn.size>wr&&tn.delete(tn.keys().next().value),Yn(h,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 Yn(o,t,n,e){const r=new Uint16Array(n*e*4);Or(r,o,t,n*e);const a=new Tn(r,n,e,Pn,to);return a.mapping=Ne,a.colorSpace=ft,a.minFilter=Lt,a.magFilter=Lt,a.needsUpdate=!0,a}class ro{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=ro.sceneOf(t);if(!r)return;this.applied={scene:r,background:r.background,environment:r.environment};const a=n.shader??n.color,i=this.generation,u=[...So(a),...n.lighting?So(n.lighting.shader??n.lighting.color):[]].filter(s=>!rr(s));if(u.length===0){this.compose(r,n,a,e);return}const f=(async()=>{const s=await Promise.all(u.map(fr));u.forEach((l,_)=>{ce(l,s[_])}),!(this.generation!==i||this.applied?.scene!==r)&&(this.compose(r,n,a,e),vt())})();this.pending=f,zn.add(f),f.then(()=>zn.delete(f),()=>zn.delete(f))}compose(t,n,e,r){if(this.texture=No(e,n.strength,r),Et(e)){if(!r)throw new Error("World Window coordinates need a render camera");this.screenTexture=Yn(_r(e,512,512,r),n.strength,512,512),this.screenTexture.mapping=Me,t.background=this.screenTexture}else if(r&&r.isOrthographicCamera){const i=r.getWorldDirection(new x);i.set(i.x,-i.z,i.y);const c=nt(n.shader??n.color)(i);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?No(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 _e(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Tr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=_e(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new It(new x(1,0,0),-o.min.x),new It(new x(-1,0,0),o.max.x),new It(new x(0,1,0),-o.min.y),new It(new x(0,-1,0),o.max.y),new It(new x(0,0,1),-o.min.z),new It(new x(0,0,-1),o.max.z)],r=[],a=new x,i=new x,c=new x,u=new x,f=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let l=s+1;l<e.length;l++)for(let _=l+1;_<e.length;_++){const h=e[s],d=e[l],m=e[_];a.crossVectors(d.normal,m.normal);const p=h.normal.dot(a);Math.abs(p)<1e-12||(i.crossVectors(m.normal,h.normal),c.crossVectors(h.normal,d.normal),u.copy(a).multiplyScalar(-h.constant).addScaledVector(i,-d.constant).addScaledVector(c,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-f)&&r.push(u.clone()))}return r}function Pr(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))),i=a.getSize(new x),c=Math.max(i.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,f=Math.max(i.x,i.y,c)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*f,l=u*f;a.min.x-=l,a.min.y-=l,a.max.x+=l,a.max.y+=l;for(const _ of n){if(_.isEmpty())continue;const h=new yn().setFromPoints(_e(_).map(d=>d.applyMatrix4(r)));h.max.x<a.min.x||h.min.x>a.max.x||h.max.y<a.min.y||h.min.y>a.max.y||(a.min.z=Math.min(a.min.z,h.min.z),a.max.z=Math.max(a.max.z,h.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-s-c,e.far=-a.min.z+s+c,e.updateProjectionMatrix(),o.shadow.normalBias=s}const Gt=S().finite(),Ro=$([Gt,Gt,Gt]),me=P({min:$([S().int(),S().int(),S().int()]),max:$([S().int(),S().int(),S().int()]),density:z(Gt),voxelSize:Gt.positive(),color:Ro,emission:Ro,densityScale:Gt.nonnegative()}).strict();function Ar(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 Re(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Ie,n.type=Yo,n.minFilter=n.magFilter=Lt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),r=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),a=new ze(r.x,r.y,r.z),i=a.getAttribute("position");for(let s=0;s<i.count;s++)i.setXYZ(s,e.x+(i.getX(s)>0?r.x:0),e.y+(i.getY(s)>0?r.y:0),e.z+(i.getZ(s)>0?r.z:0));i.needsUpdate=!0,a.computeBoundingBox(),a.computeBoundingSphere();const c=new Kn({glslVersion:De,side:Fe,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 qo}},vertexShader:`
|
|
19
|
+
`;function St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Ta=new X,Pa=new x,vo=new qo;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Aa{constructor(){this.group=new ot,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],a=JSON.stringify(t);if(a===this.signature)return e;this.signature=a,this.clear();for(const r of Object.values(t)){const l=n(r.object);if(l===null)continue;r.displayType!=="OCTAHEDRAL"&&r.displayType!=="STICK"&&e.push(`armature ${r.object}: Blender's ${r.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),r.mode==="EDIT"&&e.push(`armature ${r.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const c=r.bones.filter(f=>!f.hide);if(c.length===0)continue;const u=r.displayType==="STICK"?this.buildStick(r,c,l):this.buildOctahedral(r,c,l);r.showInFront&&u.traverse(f=>{const s=f.material;s&&"depthTest"in s&&(s.depthTest=!1),f.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],l=[],c=[],u=[],f=[],s=[],i=[],_=[],d=[],h=[];for(const m of n){const p=go(e,m),v=po(t,m),g=pa(v),b=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const A=Pa.set(...va[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const M=new x(...Sn[O]).applyMatrix4(p);r.push(M.x,M.y,M.z),l.push(A.x,A.y,A.z),c.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const w=mo(m)===2?i:f,R=mo(m)===2?_:s;for(const[T,A]of ga){const O=new x(...Sn[T]).applyMatrix4(p),M=new x(...Sn[A]).applyMatrix4(p);w.push(O.x,O.y,O.z,M.x,M.y,M.z),R.push(b.r,b.g,b.b,b.r,b.g,b.b)}m.parent!==null&&m.connected||(d.push(p.clone()),h.push(v)),d.push(p.clone().multiply(Ta.makeTranslation(0,1,0))),h.push(v)}a.add(this.solidMesh(r,l,c,u)),f.length&&a.add(this.lines(f,s,1)),i.length&&a.add(this.lines(i,_,2));for(let m=0;m<d.length;m++)a.add(this.point(d[m],h[m]));return a}buildStick(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],l=[],c=[],u=[];for(const f of n){const s=go(e,f),i=new x().setFromMatrixPosition(s),_=new x(0,1,0).applyMatrix4(s),d=ho(t,f),h=po(t,f);r.push(i.x,i.y,i.z,_.x,_.y,_.z),l.push(d.r,d.g,d.b,d.r,d.g,d.b),c.push(i.x,i.y,i.z,_.x,_.y,_.z),u.push(h.r,h.g,h.b,h.r,h.g,h.b)}return a.add(this.lines(r,l,ba)),a.add(this.lines(c,u,ya)),a}solidMesh(t,n,e,a){const r=new fn;r.setAttribute("position",new bt(t,3)),r.setAttribute("normal",new bt(n,3)),r.setAttribute("aSolid",new bt(e,3)),r.setAttribute("aHint",new bt(a,3));const l=new Jn({vertexShader:wa,fragmentShader:Oa,side:Te});this.disposables.push(r,l);const c=new Tt(r,l);return c.frustumCulled=!1,c}lines(t,n,e){const a=new Uo;a.setPositions(t),a.setColors(n);const r=new Wo({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const l=new Ho(a,r);return l.frustumCulled=!1,l}point(t,n){const e=new Pe(xa,12,8),a=new bn({color:n});this.disposables.push(e,a);const r=new Tt(e,a);return r.applyMatrix4(t),r.frustumCulled=!1,r}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const Sa="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ea(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),a=t(1/e);return{unit:[t(o[0]*a),t(o[1]*a),t(o[2]*a)],length:e}}return{unit:[0,0,0],length:0}}const N=Math.fround,wn=N(2*Math.PI),En=N(1-1e-4),zt=(o,t)=>N(N(N(o[0]*t[0])+N(o[1]*t[1]))+N(o[2]*t[2])),rn=(o,t,n=1)=>o.map((e,a)=>N(e+N(t[a]*n))),Ma=(o,t)=>o.map((n,e)=>N(n-t[e]));function Kt(o){const t=N(Math.sqrt(zt(o,o)));return t>0?o.map(n=>N(n/t)):[0,0,0]}function Jt(o){const t=Math.abs(o)<1?N(1-N(1-Math.abs(o))):1;let n=N(N(.077980478)+N(t*N(-.02164095)));n=N(N(-.213300989)+N(t*n)),n=N(N(1.5707963267)+N(t*n));const e=N(N(Math.sqrt(N(1-t)))*n);return o<0?N(N(Math.PI)-e):e}function Na(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let a=0;a<3;a++){const r=(a+1)%3,l=(a+2)%3;n[a]=N(n[a]+N(N(t[r]-e[r])*N(t[l]+e[l])))}t=e}return n}function Ra(o){const t=[],n=[],e=(h,m)=>h<m?`${h}:${m}`:`${m}:${h}`,a=new Map((o.edge_order??[]).map(([h,m],p)=>[e(h,m),p])),r=new Set((o.sharp??[]).map(([h,m])=>e(h,m))),l=new Map;for(const[h,m]of o.f.entries()){const p=t.length,v=Ea(Na(m.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<m.length;g++){const b=e(m[g],m[(g+1)%m.length]);a.has(b)||a.set(b,a.size);const w=o.face_edges?.[h]?.[g]??a.get(b),R=t.length;t.push({vertex:m[g],face:h,edge:w,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=l.get(w)??[];T.push(R),l.set(w,T)}}const c=new Map,u=new Map;for(const[h,m]of l){if(m.length!==2||o.edge_sharp?.[h])continue;const[p,v]=m,g=t[p],b=t[v];!o.s?.[g.face]||!o.s?.[b.face]||g.vertex!==t[b.next].vertex||b.vertex!==t[g.next].vertex||!o.edge_sharp&&r.has(e(g.vertex,b.vertex))||(u.set(p,b.next),c.set(b.next,p),u.set(v,g.next),c.set(g.next,v))}const f=[],s=[],i=[],_=[],d=(h,m)=>Kt(Ma(o.v[t[t[h][m]].vertex],o.v[t[h].vertex]));for(let h=0;h<t.length;h++){if(s[h]!==void 0)continue;let m=h;const p=new Set([m]);for(;u.has(m)&&!p.has(u.get(m));)m=u.get(m),p.add(m);u.has(m)&&(m=Math.min(...p));const v=[m];for(;c.has(v.at(-1))&&c.get(v.at(-1))!==m;)v.push(c.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[m].face];else{for(const M of v)g=rn(g,n[t[M].face],Jt(zt(d(M,"prev"),d(M,"next"))));g=Kt(g)}const b=d(m,"next"),w=v.at(-1),R=d(w,"prev"),T=zt(b,g),A=zt(R,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<En&&Math.abs(A)<En){const M=v.length>1?v.map(pt=>d(pt,"next")):[];M.length&&t[t[w].prev].edge!==t[m].edge&&M.push(R),O.alpha=M.length?N(M.reduce((pt,y)=>N(pt+Jt(zt(y,g))),0)/M.length):N(N(Jt(T)+Jt(A))/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,-A)),Q=zt(O.reference,H),tt=Jt(Q);O.beta=Q<En?zt(O.ortho,H)<0?N(wn-tt):tt:wn}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)s[M]=f.length;f.push(v),i.push(O),_.push(g)}return{corners:t,fans:f,fanOf:s,spaces:i,faceNormals:n,fanNormals:_}}function Ia(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=N(t[0]/32767),e=N(t[1]/32767),a=N((n>0?o.alpha:N(wn-o.alpha))*n),r=N((e>0?o.beta:N(wn-o.beta))*e);let l=o.normal.map(c=>N(c*N(Math.cos(a))));return l=rn(l,o.reference,N(N(Math.sin(a))*N(Math.cos(r)))),e!==0&&(l=rn(l,o.ortho,N(N(Math.sin(a))*N(Math.sin(r))))),l}function oe(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Ra(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const r=new Array(n.length);for(const[l,c]of e.entries()){const u=c.reduce((s,i)=>{const _=t.data[i];return[s[0]+_[0],s[1]+_[1]]},[0,0]),f=Ia(a[l],u.map(s=>Math.trunc(s/c.length)));for(const s of c)r[s]=f}return r}if(t.type==="FLOAT_VECTOR")return n.map((r,l)=>{const c=t.domain==="POINT"?r.vertex:t.domain==="FACE"?r.face:l;return t.data[c]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Mn={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},Fa=1e-6;function za(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t.x+=(e.y-a.y)*(e.z+a.z),t.y+=(e.z-a.z)*(e.x+a.x),t.z+=(e.x-a.x)*(e.y+a.y)}return t.multiplyScalar(.5)}const Da=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),xo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ca(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t+=e.x*a.y-a.x*e.y}return t}function bo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let a=0;for(const[r,l,c]of o){const u=Da(t[r],t[l],t[c]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Fa*Math.abs(n)}function ka(o){const t=o.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=za(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:xo(t),sound:!1,method:"fan"};const a=n.clone().divideScalar(e),r=Math.abs(a.x)<.9?new x(1,0,0):new x(0,1,0),l=new x().crossVectors(r,a).normalize(),c=new x().crossVectors(a,l),u=o[0],f=o.map(d=>{const h=d.clone().sub(u);return new $t(h.dot(l),h.dot(c))}),s=Ca(f),i=xo(t);if(bo(i,f,s))return{triangles:i,sound:!0,method:"fan"};let _=[];try{_=Ae.triangulateShape(f,[]).map(d=>[d[0],d[1],d[2]])}catch{return{triangles:i,sound:!1,method:"fan"}}return bo(_,f,s)?{triangles:_,sound:!0,method:"earcut"}:{triangles:_.length>0?_:i,sound:!1,method:_.length>0?"earcut":"fan"}}const $a=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Nn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Rn(o,t,n){switch(o){case"FLOAT":{const e=Number(t[n]);return[e,e,e,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[Nn(Number(t[n*4])),Nn(Number(t[n*4+1])),Nn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function ee(o,t){return o.filter(n=>$a.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),a=[0,0,0,0];return{name:n.name,domain:n.domain,read:(r,l,c)=>n.domain==="POINT"?Rn(n.type,e,r):n.domain==="CORNER"?l===void 0?a:Rn(n.type,e,l):c===void 0?a:Rn(n.type,e,c)}})}function ae(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,a=o.cornerVerts,r=e[n];let l=t;for(let y=0;y<n;y++)l+=(e[y+1]-e[y]-2)*3;const c=new Uint32Array(r),u=new Uint8Array(r),f=new Uint8Array(t),s=new Uint32Array(r);let i=!1;for(let y=0;y<n;y++)if(o.smooth(y)){i=!0;break}const _=(y,L)=>t<94906265?Math.min(y,L)*t+Math.max(y,L):`${Math.min(y,L)}:${Math.max(y,L)}`,d=new Map,h=new Set;for(const[y,L]of o.sharp)h.add(_(y,L));if(o.edges)for(const[y,L]of o.edges){if(y===L)throw new Error("Runtime mesh edge needs distinct vertices");d.set(_(y,L),-1)}const m=y=>{for(;s[y]!==y;)s[y]=s[s[y]],y=s[y];return y},p=(y,L)=>{const D=m(y),Y=m(L);s[Math.max(D,Y)]=Math.min(D,Y)};for(let y=0;y<n;y++){const L=e[y],D=e[y+1]-L,Y=o.smooth(y)?1:0;for(let Z=0;Z<D;Z++){const k=L+Z;f[a[k]]=1,c[k]=L+(Z+1)%D,u[k]=Y,s[k]=k}}for(let y=0;y<r;y++){const L=c[y],D=a[y],Y=a[L],Z=_(D,Y),k=d.get(Z);if(k!==void 0&&k>=0&&u[y]&&u[k]&&!h.has(Z)){const G=c[k];p(y,a[k]===D?k:G),p(L,a[k]===D?G:k)}(k===void 0||k<0||!u[k]&&u[y])&&d.set(Z,y)}const v=o.uv,g=new Float32Array(l*3),b=new Float32Array(l*2),w=new Uint32Array(l),R=(o.uvLayers??[]).map(y=>({...y,data:new Float32Array(l*2)})),T=(o.attributeLayers??[]).map(y=>({...y,data:new Float32Array(l*4)})),A=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(A)for(let G=0;G<3;G++)A[k*3+G]=o.orco[y*3+G]*.5+.5;if(w[k]=y,o.co(y).toArray(g,k*3),L&&b.set(L,k*2),D&&V.set(D,k*3),Y!==void 0)for(const G of R)G.data.set(G.read(Y),k*2);return k},pt=(y,L)=>{const D=v?.(y),Y=o.cornerNormal?[o.cornerNormal[y*3],o.cornerNormal[y*3+1],o.cornerNormal[y*3+2]]:o.normals?.[y];if(!i)return tt(a[y],D,Y,y,L);const Z=`${u[y]?m(y):y}${D?`:${D[0]}:${D[1]}`:""}${Y?`:n${Y.join(":")}`:""}${R.map(G=>":"+G.read(y).join(":")).join("")}${T.map(G=>G.domain==="POINT"?"":":"+Array.from(G.read(a[y],y,L)).join(":")).join("")}`;let k=M.get(Z);return k===void 0&&(k=tt(a[y],D,Y,y,L),M.set(Z,k)),k};for(let y=0;y<n;y++){const L=Q,D=e[y],Y=e[y+1]-D,Z=[];for(let Yt=0;Yt<Y;Yt++)Z.push(o.co(a[D+Yt]));for(const Yt of ka(Z).triangles)for(const Oe of Yt)O[Q++]=pt(D+Oe,y);const k=o.material(y),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let y=0;y<t;y++)f[y]||tt(y);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?b.slice(0,H*2):null,uvLayers:R.map(y=>({name:y.name,data:y.data.slice(0,H*2)})),attributeLayers:T.map(y=>({name:y.name,data:y.data.slice(0,H*4)})),orco:A?A.slice(0,H*3):null,indices:O.slice(0,Q),sourceVertex:w.slice(0,H),groups:C}}function Vt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function Hn(o){const t=new fn;t.setAttribute("position",new it(o.positions,3)),t.setAttribute("uv",new it(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new it(o.indices,1));const n=Object.create(null);for(const[e,a]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[a.name]=e+1,t.setAttribute(`uv${e+1}`,new it(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(Vt(e.name),new it(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new it(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new it(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new it(o.sourceVertex,1)),t}function La(o,t){const n=o.co.length/3,e=o.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),a=o.renderUv??o.activeUv??e[0]?.name,r=e.find(m=>m.name===a);if(a&&!r)throw new Error(`Runtime UV map ${a} is missing`);const l=r?r.data:null,c=o.edge.length/2,u=new Array(c);for(let m=0;m<c;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const f=[];for(let m=0;m<c;m++)o.edgeSharp[m]===1&&f.push(u[m]);const s=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),i=s?{v:Array.from({length:n},(m,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:f,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,_=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/Mn[s.type].size},(m,p)=>Array.from({length:Mn[s.type].size},(v,g)=>Number(s.data[p*Mn[s.type].size+g])))}:void 0,d=new x,h={vertexCount:n,normals:i?oe(i,_):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>d.set(o.co[m*3],o.co[m*3+1],o.co[m*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:m=>o.smooth[m]===1,material:m=>o.material[m],edges:u,sharp:f,uv:l?m=>[l[m*2],l[m*2+1]]:null,uvLayers:e.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:ee(o.attributes,m=>m)};return{...ae(h),hash:t}}function Va(o){const t=o.v.map(i=>new x(...i)),n=i=>{const _=t[i];if(!_)throw new Error(`Runtime mesh vertex ${i} is missing`);return _},e=new Uint32Array(o.f.length+1);o.f.forEach((i,_)=>{if(i.length<3||new Set(i).size!==i.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[_+1]=e[_]+i.length});const a=new Uint32Array(e[o.f.length]);o.f.forEach((i,_)=>i.forEach((d,h)=>{n(d),a[e[_]+h]=d}));for(const[i,_]of o.edge_order??o.e??[])n(i),n(_);const r={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:a.length};for(const i of o.attributes??[])if(i.domain!=="EDGE"&&i.data.length!==r[i.domain])throw new Error(`Runtime attribute ${i.name} has ${i.data.length} values for ${r[i.domain]} ${i.domain} elements`);const l=(o.attributes??[]).filter(i=>i.type==="FLOAT2"&&i.domain==="CORNER"),c=o.render_uv??o.active_uv??l[0]?.name,u=l.find(i=>i.name===c);if(c&&!u)throw new Error(`Runtime UV map ${c} is missing`);const f=u?.data,s={vertexCount:t.length,normals:oe(o,o.attributes?.find(i=>i.name==="custom_normal")),co:n,starts:e,cornerVerts:a,smooth:i=>!!o.s?.[i],material:i=>o.m?.[i]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:f?i=>f[i]:null,uvLayers:l.map(i=>({name:i.name,read:_=>i.data[_]})),attributeLayers:ee(o.attributes??[],i=>Array.from(i).flat())};return Hn(ae(s))}const sn=1.5707963267948966,Dt=6.283185307179586,re=.3183098861837067,le=.0795774715459476,ja=.3,Ba=le,Ua=3/16*re,qn=.8,yo=qn*qn,Ct=6371,ie=100,Gn=Ct+ie,wo=64,Oo=64,et=256,Nt=64,Wa=[1.679,1.828,1.986,1.307],Ha=[.006605,.01067,.01842,.03156],qa=[3472e-28,3914e-28,1349e-28,1103e-29],Ga=334.5,Xa=[28722e-28,46168e-28,79706e-28,13578e-27],Ya=[15908e-26,17711e-26,20942e-26,24033e-26],To=13681e16,Za=2e6,Qa=.73,In=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],On=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),Ka=o=>Math.sqrt(Math.max(o,0)),se=o=>[-Math.sqrt(1-o*o),0,o];function Xn(o,t,n,e,a,r,l){const c=o*e+t*a+n*r,u=o*o+t*t+n*n-l*l;if(u>0&&c>0)return-1;const f=c*c-u;return f<0?-1:f>=c*c?-c+Math.sqrt(f):-c-Math.sqrt(f)}const Ja=o=>Ua*(1+On(o));function tr(o){const t=1+yo+2*qn*o;return le*(1-yo)/(t*Math.sqrt(t))}const nr=o=>To*(Math.exp(-o/Qa)+Za/To);function eo(o,t){let n=o%Dt;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=sn||n<=-sn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Dt,e<0&&(e+=Dt),e=Dt-e,[n,e]}class or{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Nt*et*4)}coefficients(t,n){const e=nr(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-On(a-3.22261)*5.55555555-a),l=Math.exp(-.07771971*t**1.16364243);for(let c=0;c<4;c++)n[c]=Xa[c]*e,n[4+c]=Ya[c]*e,n[8+c]=qa[c]*Ga*r*this.ozone,n[12+c]=Ha[c]*l*this.air}transmittance(t,n,e){const[a,r,l]=se(t),c=Ot(Ct,Gn,n),f=Xn(0,0,c,a,r,l,Gn)/wo,s=[0,0,0,0],i=new Float64Array(16);for(let _=0;_<wo;_++){const d=(_+.5)*f,h=a*d,m=r*d,p=c+l*d,v=Math.max(Math.hypot(h,m,p)-Ct,0);this.coefficients(v,i);for(let g=0;g<4;g++)s[g]+=(i[g]+i[4+g]+i[8+g]+i[12+g])*f}for(let _=0;_<4;_++)e[_]=Math.exp(-s[_])}precompute(){const t=new Float64Array(4);for(let n=0;n<Nt;n++)for(let e=0;e<et;e++){const a=e/(et-1),r=n/(Nt-1);this.transmittance(a*2-1,r,t);const l=(n*et+e)*4;for(let c=0;c<4;c++)this.lut[l+c]=t[c]}}lookup(t,n,e){const a=(et-1)*on(t*.5+.5),r=(Nt-1)*on(n),l=Math.trunc(a),c=Math.trunc(r),u=Math.min(l+1,et-1),f=Math.min(c+1,Nt-1),s=a-l,i=r-c,_=(c*et+l)*4,d=(c*et+u)*4,h=(f*et+l)*4,m=(f*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[_+p],this.lut[d+p],s),Ot(this.lut[h+p],this.lut[m+p],s),i)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,et-1),l=e-a;for(let c=0;c<4;c++)n[c]=Ot(this.lut[a*4+c],this.lut[r*4+c],l)}lookupToSun(t,n){const e=(Nt-1)*on(t),a=Math.trunc(e),r=Math.min(a+1,Nt-1),l=e-a,c=et-1;for(let u=0;u<4;u++)n[u]=Ot(this.lut[(a*et+c)*4+u],this.lut[(r*et+c)*4+u],l)}inscattering(t,n,e,a,r,l,c,u,f){const s=-(r*t[0]+l*t[1]+c*t[2]),i=Ja(s),_=tr(s),d=u/Oo,h=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),b=new Float64Array(4),w=[0,0,0,0],R=[1,1,1,1];for(let T=0;T<Oo;T++){const A=(T+.5)*d,O=n+r*A,M=e+l*A,C=a+c*A,V=Math.hypot(O,M,C),H=Math.max(V-Ct,0),Q=H/ie,tt=(O*t[0]+M*t[1]+C*t[2])/V;this.coefficients(H,h),this.lookup(tt,Q,m);const pt=Dt*(1-Ka(1-On(Ct/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,b);const y=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let D=0;D<4;D++){const Y=g[D]/b[D],Z=Ba*pt*(ja*re)*v[D]*Y*tt;p[D]=.02*L[D]*y+Z}for(let D=0;D<4;D++){const Y=h[D]+h[4+D]+h[8+D]+h[12+D],Z=Wa[D]*(h[12+D]*(i*m[D]+p[D])+h[4+D]*(_*m[D]+p[D])),k=Math.exp(-d*Y),G=Math.max(Y,1e-7);w[D]+=R[D]*((Z-Z*k)/G),R[D]*=k}}for(let T=0;T<4;T++)f[T]=w[T]}}const st=512,qt=256;function fe(o,t){const n=new or(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=se(Math.cos(sn-t)),r=new Float32Array(st*qt*3),l=st/2,c=new Float64Array(4);for(let u=0;u<qt;u++)for(let f=0;f<l;f++){const s=(f+.5)/st,i=(u+.5)/qt,_=Dt*s,d=i*2-1,h=Math.sign(d)*On(d)*sn,m=Math.cos(h)*Math.cos(_),p=Math.cos(h)*Math.sin(_),v=Math.sin(h),g=Ct+e,b=Xn(0,0,g,m,p,v,Gn),w=Xn(0,0,g,m,p,v,Ct),R=w<0?b:w;n.inscattering(a,0,0,g,m,p,v,R,c);let T=0,A=0,O=0;for(let V=0;V<4;V++)T+=In[V][0]*c[V],A+=In[V][1]*c[V],O+=In[V][2]*c[V];const M=(u*st+f)*3;r[M]=T,r[M+1]=A,r[M+2]=O;const C=(u*st+(st-f-1))*3;r[C]=T,r[C+1]=A,r[C+2]=O}return r}function er(o){const[t]=eo(o.sunElevation,o.sunRotation);return fe(o,t)}function ao(o){const[t]=eo(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const ar=6,Wt=new Map;function rr(o){return Wt.has(ao(o))}function ce(o,t){Wt.set(ao(o),t),Wt.size>ar&&Wt.delete(Wt.keys().next().value)}function lr(o){const[t,n]=eo(o.sunElevation,o.sunRotation),e=ao(o);let a=Wt.get(e);a===void 0&&(a=fe(o,t),ce(o,a));const r=new x;return l=>{const c=Math.hypot(l.x,l.y),u=Math.atan2(l.z,c);let s=(Math.atan2(l.x,l.y)+Math.PI+n)/Dt;s-=Math.floor(s);const i=Math.abs(u),_=on(Math.sqrt(i/sn)*Math.sign(u)*.5+.5),d=s*st-.5,h=_*qt-.5,m=Math.floor(d),p=Math.floor(h),v=d-m,g=h-p,b=C=>(C%st+st)%st,w=C=>C<0?0:C>qt-1?qt-1:C,R=b(m),T=b(m+1),A=w(p),O=w(p+1),M=[0,0,0];for(let C=0;C<3;C++){const V=Ot(a[(A*st+R)*3+C],a[(A*st+T)*3+C],v),H=Ot(a[(O*st+R)*3+C],a[(O*st+T)*3+C],v);M[C]=Ot(V,H,g)}return r.set(yt[0][0]*M[0]+yt[0][1]*M[1]+yt[0][2]*M[2],yt[1][0]*M[0]+yt[1][1]*M[1]+yt[1][2]*M[2],yt[2][0]*M[0]+yt[2][1]*M[1]+yt[2][2]*M[2])}}let At=null,cn=!1,ir=0;const en=new Map;function sr(){if(At||cn)return At;if(typeof Worker>"u")return cn=!0,null;try{At=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return At.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")))},At.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),At?.terminate(),At=null,cn=!0},At}function fr(o){const t=sr();if(!t)return Promise.resolve(er(o));const n=ir++,e={id:n,parameters:o};return new Promise((a,r)=>{en.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function cr(o,t,n,e={}){switch(e.type??"LINEAR"){case"QUADRATIC":{const a=Math.max(o,0);return a*a}case"EASING":{const a=Math.min(1,Math.max(0,o));return a*a*(3-2*a)}case"DIAGONAL":return(o+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(o,t,n),0);case"QUADRATIC_SPHERE":{const a=Math.max(.999999-Math.hypot(o,t,n),0);return a*a}case"RADIAL":return Math.atan2(t,o)/(2*Math.PI)+.5;default:return o}}const Fn=(o,t)=>t!==0?o/t:0,Po=o=>Math.min(1,Math.max(-1,o)),Ao=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},ue={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:Fn,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:Fn(Math.log(o),Math.log(t)),SQRT:o=>Math.sqrt(Math.max(o,0)),INVERSE_SQRT:o=>o>0?1/Math.sqrt(o):0,ABSOLUTE:Math.abs,RADIANS:o=>o*Math.PI/180,DEGREES:o=>o*180/Math.PI,MINIMUM:(o,t)=>Math.min(o,t),MAXIMUM:(o,t)=>Math.max(o,t),LESS_THAN:(o,t)=>+(o<t),GREATER_THAN:(o,t)=>+(o>t),ROUND:o=>Math.floor(o+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:o=>o-Math.floor(o),MODULO:(o,t)=>t!==0?o%t:0,FLOORED_MODULO:(o,t)=>t!==0?o-Math.floor(o/t)*t:0,TRUNC:Math.trunc,SNAP:(o,t)=>Math.floor(Fn(o,t))*t,WRAP:(o,t,n)=>t!==n?o-(t-n)*Math.floor((o-n)/(t-n)):n,PINGPONG:(o,t)=>{if(t===0)return 0;const n=(o-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:o=>Math.asin(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:Ao,SMOOTH_MAX:(o,t,n)=>-Ao(-o,-t,n)};function nt(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const a=new x(...o);return()=>a}if(o.kind==="direction")return a=>a;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const a=nt(o.vector,t),r={type:o.gradient_type},l=new x;return c=>{const u=a(c),f=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,i=typeof u=="number"?u:u.z,_=ut.clamp(cr(f,s,i,r),0,1);return o.output==="Fac"?_:l.setScalar(_)}}if(o.kind==="to_float"){const a=nt(o.value,t);return r=>{const l=a(r);return typeof l=="number"?l:Math.fround(o.source_type==="RGBA"?l.x*.212639+l.y*.7151687+l.z*.0721923:(l.x+l.y+l.z)/3)}}if(o.kind==="math"){const a=o.inputs.map(c=>nt(c,t)),r=ue[o.operation],l=(c,u)=>{const f=a[c]?.(u)??0;if(typeof f!="number")throw new Error("World Math needs scalar inputs");return Math.fround(f)};return c=>{const u=Math.fround(r(l(0,c),l(1,c),l(2,c)));return o.clamp?ut.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=nt(o.factor,t),r=nt(o.a,t),l=nt(o.b,t),c=new x,u=new x;return f=>{const s=a(f);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const i=r(f);typeof i=="number"?c.setScalar(i):c.copy(i);const _=l(f);return typeof _=="number"?u.setScalar(_):u.copy(_),c.lerp(u,o.clamp_factor?ut.clamp(s,0,1):s),o.clamp_result&&c.clampScalar(0,1),c}}if(o.kind==="sky"){const a=lr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return r=>a(r)}if(o.kind==="mapping"){const a=nt(o.vector,t),r=new x(...o.location),l=new x(...o.scale),c=new gt().setFromEuler(new Se(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=c.clone().invert(),f=new x(...o.scale.map(i=>i===0?0:1/i)),s=new x;return i=>{const _=a(i);switch(typeof _=="number"?s.setScalar(_):s.copy(_),o.vector_type??"POINT"){case"TEXTURE":return s.sub(r).applyQuaternion(u).multiply(f);case"VECTOR":return s.multiply(l).applyQuaternion(c);case"NORMAL":return s.multiply(f).applyQuaternion(c).normalize();case"POINT":return s.multiply(l).applyQuaternion(c).add(r)}}}if(o.kind==="map_range"){const a=nt(o.value,t),r=nt(o.from_min,t),l=nt(o.from_max,t),c=nt(o.to_min,t),u=nt(o.to_max,t),f=nt(o.steps,t),s=(d,h)=>{const m=d(h);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},i=o.interpolation,_=o.clamp;return d=>{const h=s(a,d),m=s(r,d),p=s(l,d),v=s(c,d),g=s(u,d);if(m===p)return 0;let b;if(i==="STEPPED"){const R=s(f,d),T=(h-m)/(p-m);b=R>0?Math.floor(T*(R+1))/R:0}else if(i==="SMOOTHSTEP"||i==="SMOOTHERSTEP"){const R=ut.clamp((h-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=i==="SMOOTHSTEP"?R*R*(3-2*R):R*R*R*(R*(R*6-15)+10);b=m>p?1-T:T}else b=(h-m)/(p-m);const w=v+b*(g-v);return _?v>g?ut.clamp(w,g,v):ut.clamp(w,v,g):w}}if(o.kind==="separate"){const a=nt(o.vector,t);return r=>{const l=a(r);return typeof l=="number"?l:l.getComponent(o.axis)}}const n=nt(o.factor,t),e=new x;return a=>{const r=n(a);if(typeof r!="number")throw new Error("World ColorRamp needs a scalar factor");const l=ut.clamp(r,0,1)*256,c=Math.floor(l),u=o.colors[c],f=o.colors[Math.min(c+1,256)],s=o.interpolate?l-c:0;return e.set(ut.lerp(u[0],f[0],s),ut.lerp(u[1],f[1],s),ut.lerp(u[2],f[2],s))}}function ur(o,t,n,e){const a=new Float32Array(t*n*3),r=nt(o,e),l=new x;for(let c=0;c<n;c++){const u=((c+.5)/n-.5)*Math.PI;for(let f=0;f<t;f++){const s=((f+.5)/t-.5)*2*Math.PI;l.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const i=r(l),_=(c*t+f)*3;a[_]=typeof i=="number"?i:i.x,a[_+1]=typeof i=="number"?i:i.y,a[_+2]=typeof i=="number"?i:i.z}}return a}function So(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function _r(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,l=nt(o,()=>r),c=new x,u=e.getWorldPosition(new x),f=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let i=0;i<t;i++){const _=(i+.5)/t,d=(s+.5)/n;r.set(_,d,0),e.isOrthographicCamera?c.copy(f):c.set(_*2-1,d*2-1,.5).unproject(e).sub(u).normalize(),c.set(c.x,-c.z,c.y);const h=l(c),m=(s*t+i)*3;a[m]=typeof h=="number"?h:h.x,a[m+1]=typeof h=="number"?h:h.y,a[m+2]=typeof h=="number"?h:h.z}return a}const J=S().finite(),mr=P({type:W(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:W(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Yn;function dr(){return Yn??=fa(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Yn}function hr(){return Yn??Promise.resolve()}const pr=o=>{const t=o.size??0,n=o.size_y??t;if(o.shape==="RECTANGLE")return[t,n];if(o.shape==="DISK"){const e=Math.sqrt(Math.PI*t*t/4);return[e,e]}if(o.shape==="ELLIPSE"){const e=Math.sqrt(Math.PI/4);return[t*e,n*e]}return[t,t]};function vr(o,t){const n=(l,c)=>t&&c(t)?t:new l;if(o.type==="SUN"){const l=n(Xo,c=>c.isDirectionalLight);return l.intensity=o.energy,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="POINT"){const l=n(Vn,c=>c.isPointLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}if(o.type==="SPOT"){const l=n(jn,c=>c.isSpotLight);return l.intensity=o.energy/(4*Math.PI),l.distance=0,l.decay=2,l.angle=(o.spot_size??0)/2,l.penumbra=o.spot_blend??0,l.color.setRGB(o.color[0],o.color[1],o.color[2],ft),l.castShadow=o.use_shadow,l}dr();const e=n(gn,l=>l.isRectAreaLight),[a,r]=pr(o);return e.width=a,e.height=r,e.intensity=o.energy/(Math.max(a*r,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],ft),e}function gr(o,t,n){if(!o.castShadow||n<=0)return;const a=o.getWorldPosition(new x).distanceTo(t),r=o.shadow;if(!r)return;const l=r.camera;l.near=Math.max(n*.001,a-n),l.far=a+n,o.isDirectionalLight&&(l.left=-n,l.right=n,l.top=n,l.bottom=-n),l.updateProjectionMatrix()}function xr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ro=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],Eo=.69;class br{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Go;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[a,r]of ro.entries()){const l=(1+r.smooth)**2,c=new Xo(16777215,Math.PI*Eo/l);c.name=`BlenderSolidLight${a}`,c.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],ft),c.position.set(r.direction[0],r.direction[1],r.direction[2]),c.target=t,this.group.add(c),this.lights.push(c),n.r+=r.diffuse[0]*r.smooth/l,n.g+=r.diffuse[1]*r.smooth/l,n.b+=r.diffuse[2]*r.smooth/l}const e=new Ee(16777215,Math.PI*Eo);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),U=te(()=>jt([J,Ut,P({kind:j("direction")}).strict(),P({kind:j("window")}).strict(),P({kind:j("gradient"),gradient_type:W(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:W(["Fac","Color"]),vector:U}).strict(),P({kind:j("to_float"),source_type:W(["RGBA","VECTOR"]),value:U}).strict(),P({kind:j("math"),operation:W(Object.keys(ue)),clamp:q(),inputs:F(U).min(1).max(3)}).strict(),P({kind:j("mix_color"),factor:U,a:U,b:U,clamp_factor:q(),clamp_result:q()}).strict(),P({kind:j("mapping"),vector_type:W(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:U,location:Ut,rotation:Ut,scale:Ut}).strict(),P({kind:j("separate"),vector:U,axis:S().int().min(0).max(2)}).strict(),P({kind:j("ramp"),factor:U,colors:F(Ut).length(257),interpolate:q()}).strict(),P({kind:j("map_range"),interpolation:W(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:U,from_min:U,from_max:U,to_min:U,to_max:U,steps:U}).strict(),P({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),Mo=P({color:Ut,strength:J,shader:U.optional()}),yr=Mo.extend({volume:F(P({kind:W(["absorption","scatter","principled","emission"]),phase:E(),alpha:U,weight:U,color:U,density:U,anisotropy:U,absorption_color:U,emission_color:U,emission_strength:U,blackbody_intensity:U,temperature:U,blackbody_tint:U}).strict()).optional(),lighting:Mo.strict().optional()}).strict(),wr=4,tn=new Map,zn=new Set;function No(o,t,n){const r=Et(o);if(r&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const l=JSON.stringify([o,r?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),c=tn.get(l);if(c!==void 0)return Zn(c,t,256,128);const u=new x,f=new to,s=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,i=n?.getWorldPosition(new x),d=ur(o,256,128,r?h=>(u.set(h.x,h.z,-h.y),n.isPerspectiveCamera&&u.add(i),f.set(u.x,u.y,u.z,1).applyMatrix4(s),f.w===0?u.set(0,0,0):u.set(f.x/f.w*.5+.5,f.y/f.w*.5+.5,0)):void 0);return tn.set(l,d),tn.size>wr&&tn.delete(tn.keys().next().value),Zn(d,t,256,128)}function Or(o,t,n,e){const a=nn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=nn.toHalfFloat(t[r*3]*n),o[r*4+1]=nn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=nn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function Zn(o,t,n,e){const a=new Uint16Array(n*e*4);Or(a,o,t,n*e);const r=new Pn(a,n,e,An,no);return r.mapping=Ne,r.colorSpace=ft,r.minFilter=Lt,r.magFilter=Lt,r.needsUpdate=!0,r}class lo{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const a=lo.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,l=this.generation,u=[...So(r),...n.lighting?So(n.lighting.shader??n.lighting.color):[]].filter(s=>!rr(s));if(u.length===0){this.compose(a,n,r,e);return}const f=(async()=>{const s=await Promise.all(u.map(fr));u.forEach((i,_)=>{ce(i,s[_])}),!(this.generation!==l||this.applied?.scene!==a)&&(this.compose(a,n,r,e),vt())})();this.pending=f,zn.add(f),f.then(()=>zn.delete(f),()=>zn.delete(f))}compose(t,n,e,a){if(this.texture=No(e,n.strength,a),Et(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=Zn(_r(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=Me,t.background=this.screenTexture}else if(a&&a.isOrthographicCamera){const l=a.getWorldDirection(new x);l.set(l.x,-l.z,l.y);const c=nt(n.shader??n.color)(l);t.background=typeof c=="number"?new ht().setRGB(c,c,c).multiplyScalar(n.strength):new ht().setRGB(c.x,c.y,c.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?No(r.shader??r.color,r.strength,a):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function _e(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Tr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=_e(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new It(new x(1,0,0),-o.min.x),new It(new x(-1,0,0),o.max.x),new It(new x(0,1,0),-o.min.y),new It(new x(0,-1,0),o.max.y),new It(new x(0,0,1),-o.min.z),new It(new x(0,0,-1),o.max.z)],a=[],r=new x,l=new x,c=new x,u=new x,f=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let i=s+1;i<e.length;i++)for(let _=i+1;_<e.length;_++){const d=e[s],h=e[i],m=e[_];r.crossVectors(h.normal,m.normal);const p=d.normal.dot(r);Math.abs(p)<1e-12||(l.crossVectors(m.normal,d.normal),c.crossVectors(d.normal,h.normal),u.copy(r).multiplyScalar(-d.constant).addScaledVector(l,-h.constant).addScaledVector(c,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-f)&&a.push(u.clone()))}return a}function Pr(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new yn().setFromPoints(t.map(_=>_.clone().applyMatrix4(a))),l=r.getSize(new x),c=Math.max(l.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,f=Math.max(l.x,l.y,c)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*f,i=u*f;r.min.x-=i,r.min.y-=i,r.max.x+=i,r.max.y+=i;for(const _ of n){if(_.isEmpty())continue;const d=new yn().setFromPoints(_e(_).map(h=>h.applyMatrix4(a)));d.max.x<r.min.x||d.min.x>r.max.x||d.max.y<r.min.y||d.min.y>r.max.y||(r.min.z=Math.min(r.min.z,d.min.z),r.max.z=Math.max(r.max.z,d.max.z))}e.left=r.min.x,e.right=r.max.x,e.bottom=r.min.y,e.top=r.max.y,e.near=-r.max.z-s-c,e.far=-r.min.z+s+c,e.updateProjectionMatrix(),o.shadow.normalBias=s}const Gt=S().finite(),Ro=$([Gt,Gt,Gt]),me=P({min:$([S().int(),S().int(),S().int()]),max:$([S().int(),S().int(),S().int()]),density:F(Gt),voxelSize:Gt.positive(),color:Ro,emission:Ro,densityScale:Gt.nonnegative()}).strict();function Ar(o){const t=o.max.map((s,i)=>s-o.min[i]+1);if(t.some(s=>s<=0)||t.reduce((s,i)=>s*i,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Re(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Ie,n.type=Yo,n.minFilter=n.magFilter=Lt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),a=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),r=new Fe(a.x,a.y,a.z),l=r.getAttribute("position");for(let s=0;s<l.count;s++)l.setXYZ(s,e.x+(l.getX(s)>0?a.x:0),e.y+(l.getY(s)>0?a.y:0),e.z+(l.getZ(s)>0?a.z:0));l.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere();const c=new Jn({glslVersion:De,side:ze,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:e},extent:{value:a},voxelSize:{value:o.voxelSize},densityScale:{value:o.densityScale},volumeColor:{value:new x(...o.color)},emission:{value:new x(...o.emission)},cameraLocal:{value:new x},rayLocal:{value:new x},orthographic:{value:!1},worldScale:{value:new qo}},vertexShader:`
|
|
20
20
|
out vec3 localPosition;
|
|
21
21
|
void main() {
|
|
22
22
|
localPosition = position;
|
|
@@ -58,7 +58,7 @@ import{a as Uo,b as Wo,L as Ho}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,c),f=new X;return u.onBeforeRender=(s,i,_)=>{f.copy(u.matrixWorld).invert(),c.uniforms.cameraLocal.value.setFromMatrixPosition(_.matrixWorld).applyMatrix4(f),_.getWorldDirection(c.uniforms.rayLocal.value).transformDirection(f),c.uniforms.orthographic.value=!!_.isOrthographicCamera,c.uniforms.worldScale.value.setFromMatrix4(u.matrixWorld)},c.addEventListener("dispose",()=>n.dispose()),u}const Sr=`#define constexpr const
|
|
62
62
|
#define bool32_t bool
|
|
63
63
|
#define bool2 bvec2
|
|
64
64
|
#define bool3 bvec3
|
|
@@ -200,7 +200,7 @@ mat3x3 to_float3x3(mat3x4 m) { return mat3x3(m); }
|
|
|
200
200
|
#define float4_from_float(v) float4(float3(v), 1.0f)
|
|
201
201
|
#define gpu_dfdx(x) dFdx(x)
|
|
202
202
|
#define gpu_dfdy(x) dFdy(x)
|
|
203
|
-
#define gpu_fwidth(x) fwidth(x)`,
|
|
203
|
+
#define gpu_fwidth(x) fwidth(x)`,Qn={"gpu_shader_common_math.glsl":{deps:["gpu_shader_math_constants_lib.glsl","gpu_shader_math_base_lib.glsl","gpu_shader_math_safe_lib.glsl"],code:`void math_add(float a, float b, float c, _ref(float ,result))
|
|
204
204
|
{
|
|
205
205
|
result = a + b;
|
|
206
206
|
}
|
|
@@ -6879,7 +6879,7 @@ void curves_float_mixed(float factor,
|
|
|
6879
6879
|
curves_float(
|
|
6880
6880
|
value, curve_map, layer, range_minimum, range_divider, start_slope, end_slope, result);
|
|
6881
6881
|
result = mix(value, result, factor);
|
|
6882
|
-
}`}},Io=S().finite(),
|
|
6882
|
+
}`}},Io=S().finite(),Dn=W(["float","vec2","vec3","vec4"]),de=jt([Io,F(Io)]),he=$([E(),S().int().nonnegative()]),xn=jt([P({value:de}).strict(),P({link:he}).strict()]),Er=["ShaderNodeTexCoord","ShaderNodeUVMap","ShaderNodeValue","ShaderNodeRGB","ShaderNodeTexImage","ShaderNodeMapping","ShaderNodeMath","ShaderNodeVectorMath","ShaderNodeMix","ShaderNodeMixRGB","ShaderNodeValToRGB","ShaderNodeInvert","ShaderNodeSeparateXYZ","ShaderNodeCombineXYZ","ShaderNodeTexNoise","ShaderNodeTexVoronoi","ShaderNodeTexChecker","ShaderNodeTexWhiteNoise","ShaderNodeTexWave","ShaderNodeTexGradient","ShaderNodeTexMagic","ShaderNodeTexBrick","ShaderNodeMapRange","ShaderNodeClamp","ShaderNodeHueSaturation","ShaderNodeBrightContrast","ShaderNodeGamma","ShaderNodeRGBToBW","ShaderNodeSeparateColor","ShaderNodeCombineColor","ShaderNodeVectorRotate","ShaderNodeFresnel","ShaderNodeLayerWeight","ShaderNodeBump","ShaderNodeNormalMap","ShaderNodeNewGeometry","ShaderNodeVertexColor","ShaderNodeAttribute","ShaderNodeRGBCurve","ShaderNodeVectorCurve","ShaderNodeFloatCurve"],Mr=P({type:W(Er),props:_t(E(),ne()),inputs:F(jt([P({value:de,id:E(),gpu:Dn,enabled:q()}).strict(),P({link:he,id:E(),gpu:Dn,enabled:q()}).strict()])),outputs:F(P({id:E(),gpu:Dn.or(j("closure")).nullable()}).strict())}).strict(),an=te(()=>jt([P({principled:j(!0)}).strict(),P({emission:$([xn,xn])}).strict(),P({transparent:S()}).strict(),P({none:j(!0)}).strict(),P({mix:$([xn,an,an])}).strict(),P({add:$([an,an])}).strict()])),Nr=P({surface:W(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:_t(E(),xn),closure:an.optional(),nodes:_t(E(),Mr)}).strict();function Rr(o){const t=o.inputs.Alpha,n=e=>"transparent"in e||"mix"in e&&(n(e.mix[1])||n(e.mix[2]))||"add"in e&&(n(e.add[0])||n(e.add[1]));return t!==void 0&&"link"in t||o.closure!==void 0&&n(o.closure)}const pe="vec3(0.2126729, 0.7151522, 0.0721750)",Ir=o=>o==="float"?1:Number(o[3]);function Fr(o,t){const n=typeof t=="number"?[t]:t,e=Ir(o);return Array.from({length:e},(a,r)=>n[r]??(r===3?1:0))}function zr(o,t,n){if(t===n)return o;const e=r=>r==="float"?"float":`float${r[3]}`,a=t==="vec4"&&n==="float"?`, ${pe}`:"";return`${e(n)}_from_${e(t)}(${o}${a})`}const Dr={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},Cr={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},Fo={MIX:"blend",ADD:"add",MULTIPLY:"mult",SUBTRACT:"sub",SCREEN:"screen",DIVIDE:"div_fallback",DIFFERENCE:"diff",EXCLUSION:"exclusion",DARKEN:"dark",LIGHTEN:"light",OVERLAY:"overlay",DODGE:"dodge",BURN:"burn",HUE:"hue",SATURATION:"sat",VALUE:"val",COLOR:"color",SOFT_LIGHT:"soft",LINEAR_LIGHT:"linear"},kr={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},$r={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},Lr={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},Vr=(()=>{const o=new Map;for(const[t,n]of Object.entries(Qn))for(const e of n.code.matchAll(/^(?:void|float\d?)\s+([A-Za-z_]\w*)\s*\(/gm))o.has(e[1])||o.set(e[1],t);return o})();function z(o,t){if(!(t in o.props))throw new Error(`${o.type} arrived without its '${t}' property`);return o.props[t]}const jr=`
|
|
6883
6883
|
#define GPU_FRAGMENT_SHADER
|
|
6884
6884
|
#define FrontFacing gl_FrontFacing
|
|
6885
6885
|
uniform mat4 modelMatrix;
|
|
@@ -7017,42 +7017,42 @@ vec3 blender_reflection() {
|
|
|
7017
7017
|
: normalize(cameraPosition - vBlenderWorldPosition);
|
|
7018
7018
|
return blender_from_three * -reflect(incident, normalize(vBlenderWorldNormal));
|
|
7019
7019
|
}
|
|
7020
|
-
`;class lo{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=zr(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]),Fr(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((l,_)=>({name:`${r}_${_}`,type:l.gpu==="closure"||l.gpu===null?"float":l.gpu}));this.emitted.set(t,a);const i=l=>`${a[l].type} ${a[l].name} = ${a[l].type}(0.0);`,c=a.map((l,_)=>i(_)).join(" "),u=l=>l.map(_=>a[_].name).join(", "),f=(l=[])=>[...n.inputs.map(h=>this.source(h,h.gpu)),...l,...a.map(h=>h.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const s=[c];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const l=a[0].type;s.push(`${a[0].name} = ${this.uniform(l,F(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((_,h)=>{a[h]&&s.push(`${a[h].name} = ${this.d(_)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const l=F(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(l),this.s.structure.push(["a",l]);const _=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(_)}(${Qn(l)}, ${u(a.map((h,d)=>d))});`);for(const h of a)s.push(`${h.name} = ${this.d(h.name)};`);break}case"ShaderNodeUVMap":{const l=F(n,"uv_map");this.s.uvs.add(l),s.push(`${a[0].name} = ${this.d(`vec3(${Ht(l)}, 0.0)`)};`);break}case"ShaderNodeMath":{const l=F(n,"operation"),_=this.use(Dr[l]??`math_${l.toLowerCase()}`);s.push(`${_}(${f()});`),F(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const l=F(n,"operation");s.push(`${this.use(Cr[l]??`vector_math_${l.toLowerCase()}`)}(${f()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${F(n,"vector_type").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${f()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${f()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${f()});`);break;case"ShaderNodeMix":{const l=F(n,"data_type"),_=F(n,"factor_mode")==="NON_UNIFORM",h={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[l];if(!h)throw new Error(`Mix has data type ${l}`);const d=l==="VECTOR"&&_;let m=this.input(n,d?"Factor_Vector":"Factor_Float");if(F(n,"clamp_factor")){const g=`${r}_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"?_?"node_mix_vector_non_uniform":"node_mix_vector":l==="RGBA"?`node_mix_${zo[F(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${h}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${h}`)}, ${this.input(n,`B_${h}`)}, ${u([v])});`),l==="RGBA"&&F(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=`${r}_fac`;s.push(`float ${l}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${l});`);const _=n.inputs.slice(1).map(h=>this.source(h,h.gpu));s.push(`${this.use(`mix_${zo[F(n,"blend_type")]}`)}(${[l,..._,u([0])].join(", ")});`),F(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const l=F(n,"color_ramp"),_=this.input(n,"Fac"),[h,d]=l.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(l.elements.length===1)s.push(`${u([0])} = ${m(h)}; ${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")}(${_}, ${this.uniform("float",Math.max(h[0],d[0]))}, ${m(h)}, ${m(d)}, ${u([0,1])});`);else{const p=1/(d[0]-h[0]),v=l.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${_}, ${this.uniform("vec2",[p,-p*h[0]])}, ${m(h)}, ${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(${_}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${_}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),s.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const l=F(n,"curve_mapping"),_=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:_,table:l.table}),this.s.structure.push(["curve"]);const h=this.input(n,n.inputs.some(d=>d.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${h}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${_}, 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")}(${h}, ${this.input(n,"Vector","vec3")}, ${_}, 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")}(${h}, ${this.input(n,"Value","float")}, ${_}, 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(F(n,"noise_dimensions")[0]),_=this.use(`node_noise_tex_${kr[F(n,"noise_type")]}_${l}d`),h=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=F(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[h,...d,m,"1.0",u(a.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const l=Number(F(n,"voronoi_dimensions")[0]),_=this.use(`node_tex_voronoi_${$r[F(n,"feature")]}_${l}d`),h=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Lr[F(n,"distance")].toFixed(1)}`,p=F(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[h,...d,m,p,u(a.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const l=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(h=>this.source(h,h.gpu));s.push(`${this.use("node_tex_checker")}(${[l,..._,u(a.map((h,d)=>d))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const l=Number(F(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${l}d`)}(${f()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const l=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),h=p=>F(n,`${p}#value`).toFixed(1),d=n.type==="ShaderNodeTexWave"?[h("wave_type"),h("bands_direction"),h("rings_direction"),h("wave_profile")]:n.type==="ShaderNodeTexGradient"?[h("gradient_type")]:n.type==="ShaderNodeTexMagic"?[F(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",F(n,"offset")),F(n,"offset_frequency").toFixed(1),this.uniform("float",F(n,"squash")),F(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,..._,...d,u(a.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const l=F(n,"data_type")==="FLOAT_VECTOR",_=F(n,"interpolation_type").toLowerCase(),h=F(n,"clamp");s.push(`${this.use(`${l?"vector_":""}map_range_${_}`)}(${f([h?"1.0":"0.0"])});`),h&&!l&&(_==="linear"||_==="stepped")&&s.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":s.push(`${this.use(F(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${f()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${f()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${f()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${f()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${f([pe])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${F(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${F(n,"mode").toLowerCase()}`)}(${f()});`);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"}[F(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${l}`)}(${f([F(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const l=n.inputs[1],_="link"in l?this.source(l,"vec3"):"g_data.N";"link"in l||this.s.structure.push("world-normal");const h=this.source(n.inputs[0],"float"),d=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(d)}(${[h,_,u(a.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const l=n.inputs.find(b=>b.id==="Height"),_=n.inputs.find(b=>b.id==="Normal"),h=_&&"link"in _?this.source(_,"vec3"):"g_data.N";if(!l||!("link"in l)){s.push(`${u([0])} = ${h};`);break}const d=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new lo(this.graph,this.s,!0,`${d}_`),p=m.source(l,"float");this.s.functions[Number(d.slice(8))]=`float ${d}() {
|
|
7020
|
+
`;class io{constructor(t,n,e=!1,a="bgN"){this.graph=t,this.derivative=e,this.prefix=a,this.lines=[],this.emitted=new Map,this.s=n??{files:new Set,uniforms:new Map,uniformTypes:new Map,images:[],ramps:[],uvs:new Set,attributes:new Set,structure:[],functions:[]}}get uniforms(){return this.s.uniforms}get images(){return this.s.images}get ramps(){return this.s.ramps}d(t){return this.derivative?`(${t} + dF_impl(${t}))`:t}uniform(t,n){const e=`bgU${this.s.uniforms.size}`,a=Fr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Vr.get(t);if(!n)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(n),t}source(t,n){if("value"in t)return this.s.structure.push("v"),this.uniform(n,t.value);const[e,a]=t.link,r=this.graph.nodes[e];if(!r)throw new Error(`The graph links to ${e}, which it does not carry`);const c=this.node(e,r)[a];if(!c)throw new Error(`${e} has no output ${a}`);return this.s.structure.push(["l",e,a]),zr(c.name,c.type,n)}input(t,n,e){const a=t.inputs.find(r=>r.id===n)??t.inputs.find(r=>r.id.replace(/_/g," ")===n);if(!a)throw new Error(`${t.type} arrived without its '${n}' input`);return this.source(a,e??a.gpu)}coordinate(t,n){const e=t.inputs[0];return"link"in e?this.source(e,"vec3"):(this.s.structure.push(["default",n]),n==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${Ht("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const a=`${this.prefix}${this.emitted.size}`,r=n.outputs.map((i,_)=>({name:`${a}_${_}`,type:i.gpu==="closure"||i.gpu===null?"float":i.gpu}));this.emitted.set(t,r);const l=i=>`${r[i].type} ${r[i].name} = ${r[i].type}(0.0);`,c=r.map((i,_)=>l(_)).join(" "),u=i=>i.map(_=>r[_].name).join(", "),f=(i=[])=>[...n.inputs.map(d=>this.source(d,d.gpu)),...i,...r.map(d=>d.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const s=[c];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const i=r[0].type;s.push(`${r[0].name} = ${this.uniform(i,z(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Ht("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((_,d)=>{r[d]&&s.push(`${r[d].name} = ${this.d(_)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const i=z(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(i),this.s.structure.push(["a",i]);const _=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(_)}(${Kn(i)}, ${u(r.map((d,h)=>h))});`);for(const d of r)s.push(`${d.name} = ${this.d(d.name)};`);break}case"ShaderNodeUVMap":{const i=z(n,"uv_map");this.s.uvs.add(i),s.push(`${r[0].name} = ${this.d(`vec3(${Ht(i)}, 0.0)`)};`);break}case"ShaderNodeMath":{const i=z(n,"operation"),_=this.use(Dr[i]??`math_${i.toLowerCase()}`);s.push(`${_}(${f()});`),z(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const i=z(n,"operation");s.push(`${this.use(Cr[i]??`vector_math_${i.toLowerCase()}`)}(${f()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${z(n,"vector_type").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${f()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${f()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${f()});`);break;case"ShaderNodeMix":{const i=z(n,"data_type"),_=z(n,"factor_mode")==="NON_UNIFORM",d={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[i];if(!d)throw new Error(`Mix has data type ${i}`);const h=i==="VECTOR"&&_;let m=this.input(n,h?"Factor_Vector":"Factor_Float");if(z(n,"clamp_factor")){const g=`${a}_fac`;s.push(h?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${g});`),m=g}const p=i==="FLOAT"?"node_mix_float":i==="VECTOR"?_?"node_mix_vector_non_uniform":"node_mix_vector":i==="RGBA"?`node_mix_${Fo[z(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${d}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${d}`)}, ${this.input(n,`B_${d}`)}, ${u([v])});`),i==="RGBA"&&z(n,"clamp_result")&&s.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const i=`${a}_fac`;s.push(`float ${i}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${i});`);const _=n.inputs.slice(1).map(d=>this.source(d,d.gpu));s.push(`${this.use(`mix_${Fo[z(n,"blend_type")]}`)}(${[i,..._,u([0])].join(", ")});`),z(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const i=z(n,"color_ramp"),_=this.input(n,"Fac"),[d,h]=i.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(i.elements.length===1)s.push(`${u([0])} = ${m(d)}; ${u([1])} = ${u([0])}.a;`);else if(i.elements.length===2&&i.color_mode==="RGB"&&h&&i.interpolation!=="B_SPLINE"&&i.interpolation!=="CARDINAL")if(i.interpolation==="CONSTANT")s.push(`${this.use("valtorgb_opti_constant")}(${_}, ${this.uniform("float",Math.max(d[0],h[0]))}, ${m(d)}, ${m(h)}, ${u([0,1])});`);else{const p=1/(h[0]-d[0]),v=i.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${_}, ${this.uniform("vec2",[p,-p*d[0]])}, ${m(d)}, ${m(h)}, ${u([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:i.table}),this.s.structure.push(["ramp",i.interpolation==="CONSTANT"]),s.push(i.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${_}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${_}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),s.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const i=z(n,"curve_mapping"),_=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:_,table:i.table}),this.s.structure.push(["curve"]);const d=this.input(n,n.inputs.some(h=>h.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${d}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${_}, 0.5, ${this.uniform("vec4",i.minimums)}, ${this.uniform("vec4",i.dividers)}, ${this.uniform("vec4",i.starts)}, ${this.uniform("vec4",i.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?s.push(`${this.use("curves_vector_mixed")}(${d}, ${this.input(n,"Vector","vec3")}, ${_}, 0.5, ${this.uniform("vec3",i.minimums.slice(0,3))}, ${this.uniform("vec3",i.dividers.slice(0,3))}, ${this.uniform("vec3",i.starts.slice(0,3))}, ${this.uniform("vec3",i.ends.slice(0,3))}, ${u([0])});`):s.push(`${this.use("curves_float_mixed")}(${d}, ${this.input(n,"Value","float")}, ${_}, 0.5, ${this.uniform("float",i.minimums[0])}, ${this.uniform("float",i.dividers[0])}, ${this.uniform("float",i.starts[0])}, ${this.uniform("float",i.ends[0])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const i=Number(z(n,"noise_dimensions")[0]),_=this.use(`node_noise_tex_${kr[z(n,"noise_type")]}_${i}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=z(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[d,...h,m,"1.0",u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const i=Number(z(n,"voronoi_dimensions")[0]),_=this.use(`node_tex_voronoi_${$r[z(n,"feature")]}_${i}d`),d=this.coordinate(n,"orco"),h=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Lr[z(n,"distance")].toFixed(1)}`,p=z(n,"normalize")?"1.0":"0.0";s.push(`${_}(${[d,...h,m,p,u(r.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const i=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(d=>this.source(d,d.gpu));s.push(`${this.use("node_tex_checker")}(${[i,..._,u(r.map((d,h)=>h))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const i=Number(z(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${i}d`)}(${f()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const i=this.coordinate(n,"orco"),_=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),d=p=>z(n,`${p}#value`).toFixed(1),h=n.type==="ShaderNodeTexWave"?[d("wave_type"),d("bands_direction"),d("rings_direction"),d("wave_profile")]:n.type==="ShaderNodeTexGradient"?[d("gradient_type")]:n.type==="ShaderNodeTexMagic"?[z(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",z(n,"offset")),z(n,"offset_frequency").toFixed(1),this.uniform("float",z(n,"squash")),z(n,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];s.push(`${this.use(m)}(${[i,..._,...h,u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const i=z(n,"data_type")==="FLOAT_VECTOR",_=z(n,"interpolation_type").toLowerCase(),d=z(n,"clamp");s.push(`${this.use(`${i?"vector_":""}map_range_${_}`)}(${f([d?"1.0":"0.0"])});`),d&&!i&&(_==="linear"||_==="stepped")&&s.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":s.push(`${this.use(z(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${f()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${f()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${f()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${f()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${f([pe])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${z(n,"mode").toLowerCase()}`)}(${f()});`);break;case"ShaderNodeVectorRotate":{const i={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[z(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${i}`)}(${f([z(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const i=n.inputs[1],_="link"in i?this.source(i,"vec3"):"g_data.N";"link"in i||this.s.structure.push("world-normal");const d=this.source(n.inputs[0],"float"),h=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(h)}(${[d,_,u(r.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const i=n.inputs.find(b=>b.id==="Height"),_=n.inputs.find(b=>b.id==="Normal"),d=_&&"link"in _?this.source(_,"vec3"):"g_data.N";if(!i||!("link"in i)){s.push(`${u([0])} = ${d};`);break}const h=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new io(this.graph,this.s,!0,`${h}_`),p=m.source(i,"float");this.s.functions[Number(h.slice(8))]=`float ${h}() {
|
|
7021
7021
|
${m.lines.join(`
|
|
7022
7022
|
`)}
|
|
7023
7023
|
return ${p};
|
|
7024
|
-
}`;const v=this.input(n,"Filter Width","float");s.push(`float ${
|
|
7024
|
+
}`;const v=this.input(n,"Filter Width","float");s.push(`float ${a}_h = ${h}();`,`g_derivative_filter_width = ${v} * derivative_scale_get();`,`g_derivative_flag = 1; float ${a}_hx = ${h}();`,`g_derivative_flag = -1; float ${a}_hy = ${h}();`,"g_derivative_flag = 0;");const g=z(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, ${d}, vec2(${a}_hx, ${a}_hy), ${g}, ${u([0])});`);break}case"ShaderNodeNormalMap":{const i=z(n,"space"),_=this.input(n,"Strength","float"),d=this.input(n,"Color","vec3"),h=`${a}_n`;if(s.push(`vec3 ${h}; ${this.use(i.startsWith("BLENDER_")?"color_to_blender_normal_new_shading":"color_to_normal_new_shading")}(${d}, ${h});`),n.props.convention==="DIRECTX"&&s.push(`${this.use("color_invert_green_channel")}(${h}, ${h});`),i==="TANGENT"){const m=z(n,"uv_map");this.s.uvs.add(m),s.push(`${this.use("node_normal_map")}(blender_uv_tangent(${Ht(m)}), ${_}, ${h}, g_data.Ni, ${u([0])});`)}else(i==="OBJECT"||i==="BLENDER_OBJECT")&&s.push(`${this.use("normal_transform_object_to_world")}(${h}, ${h});`),s.push(`${this.use("node_normal_map_mix")}(${_}, ${h}, ${u([0])});`);break}case"ShaderNodeNewGeometry":{s.push(`${this.use("node_geometry")}(${["blender_orco()",u(r.map((i,_)=>_))].join(", ")});`),r[0]&&s.push(`${r[0].name} = ${this.d(r[0].name)};`);for(const i of[1,2,4])r[i]&&s.push(`${r[i].name} = normalize(${r[i].name});`);break}case"ShaderNodeTexImage":{const i=z(n,"image");if(i===null){s.push(`${u([0])} = vec4(0.0); ${u([1])} = 0.0;`);break}const _=z(n,"projection"),d=z(n,"interpolation"),h=d==="Cubic"||d==="Smart",m=z(n,"extension"),p=`bgImage${this.s.images.length}`;this.s.images.push({uniform:p,node:t,name:i.name,revision:i.revision,extension:m,closest:d==="Closest",mipmap:_!=="SPHERE"&&_!=="TUBE",tiled:_==="FLAT"&&n.props.image_tiled===!0});const v=this.s.images.at(-1).tiled;this.s.structure.push(["img",_,h,v]);let g=this.coordinate(n,"uv");const b=u([0]),w=u([1]);if(_==="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(h?"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",z(n,"projection_blend"))}, ${b}, ${w});`)}else if(v)h&&this.use("cubic_bspline_coefficients"),s.push(`${h?"blender_tex_tile_cubic":"blender_tex_tile_linear"}(${g}, ${p}, ${p}Map, ${b}, ${w});`);else{if(_==="SPHERE"||_==="TUBE"){const O=`${a}_co`;s.push(`vec3 ${O}; ${this.use("point_texco_remap_square")}(${g}, ${O});`,`${this.use(_==="SPHERE"?"point_map_to_sphere":"point_map_to_tube")}(${O}, ${O});`),g=O}s.push(`${this.use(h?"node_tex_image_cubic":"node_tex_image_linear")}(${g}, ${p}, ${b}, ${w});`),m==="CLIP"&&s.push(`if (any(lessThan(${g}.xy, vec2(0.0))) || any(greaterThan(${g}.xy, vec2(1.0)))) { ${b} = vec4(0.0); ${w} = 0.0; }`)}const R=z(n,"image_alpha_mode"),T=this.uses(t,1),A=u([0]);R==="NONE"||R==="CHANNEL_PACKED"||z(n,"image_is_data")?s.push(`${A}.a = 1.0;`):R==="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[i,_]of Object.entries(t)){const d=this.graph.inputs[i];if(!d||i==="Normal"&&!("link"in d))continue;const h=`bgOut${a++}`;n[i]={global:h,type:_},this.s.structure.push(["out",i]),e.push(`${h} = ${this.source(d,_)};`)}const r=this.graph.closure;if(r){let i=0;const _=(d,h)=>{if("principled"in d)this.s.structure.push("cP"),e.push(`bgClosureP += ${h};`);else if("emission"in d)this.s.structure.push("cE"),e.push(`bgClosureE += ${h} * ${this.source(d.emission[0],"vec4")}.rgb * ${this.source(d.emission[1],"float")};`);else if("transparent"in d)this.s.structure.push("cT"),e.push(`bgClosureT += ${h} * ${this.source({value:d.transparent},"float")};`);else if("mix"in d){this.s.structure.push("cM");const m=`bgClosureF${i++}`;e.push(`float ${m} = clamp(${this.source(d.mix[0],"float")}, 0.0, 1.0);`),_(d.mix[1],`${h} * (1.0 - ${m})`),_(d.mix[2],`${h} * ${m}`)}else"add"in d?(this.s.structure.push("cA"),_(d.add[0],h),_(d.add[1],h)):this.s.structure.push("c0")};e.push("bgClosureP = 0.0;","bgClosureE = vec3(0.0);","bgClosureT = 0.0;"),_(r,"1.0")}const l=[],c=new Set,u=i=>{if(!c.has(i)){c.add(i);for(const _ of Qn[i].deps)u(_);l.push(i)}};for(const i of this.s.files)u(i);const f=`void blenderGraph() {
|
|
7025
7025
|
blender_init_globals();
|
|
7026
7026
|
${[...this.lines,...e].join(`
|
|
7027
7027
|
`)}
|
|
7028
|
-
}`,s=[Sr,Ur(jr+
|
|
7028
|
+
}`,s=[Sr,Ur(jr+l.map(i=>Qn[i].code).join(`
|
|
7029
7029
|
`)+`
|
|
7030
7030
|
`+Br,[...this.s.functions,f].join(`
|
|
7031
|
-
`)),...[...this.s.uniformTypes].map(([
|
|
7032
|
-
uniform highp sampler2D ${
|
|
7033
|
-
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:s,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:
|
|
7031
|
+
`)),...[...this.s.uniformTypes].map(([i,_])=>`uniform ${_} ${i};`),...this.images.map(i=>i.tiled?`uniform highp sampler2DArray ${i.uniform};
|
|
7032
|
+
uniform highp sampler2D ${i.uniform}Map;`:`uniform sampler2D ${i.uniform};`),...this.ramps.map(i=>`uniform sampler2D ${i.uniform};`),...Object.values(n).map(i=>`${i.type} ${i.global};`),...r?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,f].join(`
|
|
7033
|
+
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:s,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:r!==void 0}}}function Ur(o,t){const n=[],e=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let a=0;for(let u;u=e.exec(o);){if(u.index<a)continue;let f=u.index+u[0].length;for(let d=1;f<o.length&&d>0;f++)d+=o[f]==="("?1:o[f]===")"?-1:0;const s=o.slice(f).match(/^\s*(\{|;)/);if(!s||/^\s*#/.test(o.slice(o.lastIndexOf(`
|
|
7034
7034
|
`,u.index)+1,u.index+1))||o.slice(Math.max(0,u.index-2),u.index).endsWith(`\\
|
|
7035
|
-
`))continue;let _=f+s[0].length;if(s[1]==="{")for(let
|
|
7036
|
-
`).find(
|
|
7035
|
+
`))continue;let _=f+s[0].length;if(s[1]==="{")for(let d=1;_<o.length&&d>0;_++)d+=o[_]==="{"?1:o[_]==="}"?-1:0;n.push({text:o.slice(a,u.index),name:null}),n.push({text:o.slice(u.index,_),name:u[1]}),a=_,e.lastIndex=_}n.push({text:o.slice(a),name:null});const r=new Set(n.filter(u=>u.name===null)),l=new Set,c=u=>{for(const f of u.matchAll(/[A-Za-z_]\w*/g))l.add(f[0])};c(t);for(const u of r)c(u.text);for(let u=!0;u;){u=!1;for(const f of n)r.has(f)||f.name===null||!l.has(f.name)||(r.add(f),c(f.text),u=!0)}return n.filter(u=>r.has(u)).map(u=>u.text).join("")}function Kn(o){return`v${Vt(o)}`}function Ht(o){return o===""?"vBlenderUvRender":`vBlenderUv_${[...o].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function Wr(o){return new io(o).compile()}function Hr(o){const t=new Uint16Array(o.length*4);o.forEach((e,a)=>t.set([e[0]??0,e[1]??0,e[2]??0,e[3]??1].map(r=>nn.toHalfFloat(r)),a*4));const n=new Pn(t,o.length,1,An,no);return n.minFilter=n.magFilter=Lt,n.wrapS=n.wrapT=Zo,n.needsUpdate=!0,n}const dt=new WeakMap,ve=new Set,kt=new WeakMap,un=new WeakMap;function _n(o){const t=kt.get(o);if(t){kt.delete(o);for(const n of t.binding.ramps)n.dispose()}}function qr(o,t,n,e=!1){const a=dt.get(o);if(t&&ve.has(t.key)&&(t=null),!t){if(_n(o),a){for(const c of a.ramps)c.dispose();dt.delete(o),o.needsUpdate=!0}return}if(a&&a.compiled.key===t.key){_n(o),mn(a,t,n);return}if(e){_n(o);for(const u of a?.ramps??[])u.dispose();const c={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};mn(c,t,n),dt.set(o,c),o.needsUpdate=!0;return}const r=kt.get(o);if(r&&r.binding.compiled.key===t.key){mn(r.binding,t,n);return}_n(o);const l={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};mn(l,t,n),kt.set(o,{binding:l,started:!1})}function mn(o,t,n){o.compiled=t;for(const[e,a]of t.uniforms){const r=typeof a=="number"?a:a.length===2?new $t(...a):a.length===3?new x(...a):new to(...a),l=o.uniforms[e];l?l.value=r:o.uniforms[e]={value:r}}for(const e of o.ramps)e.dispose();o.ramps=t.ramps.map(e=>{const a=Hr(e.table);return(o.uniforms[e.uniform]??={value:null}).value=a,a});for(const e of t.images){const a=n(e);if(e.tiled){const r=a!==null&&"tiles"in a?a:null;(o.uniforms[e.uniform]??={value:null}).value=r?.tiles??null,(o.uniforms[`${e.uniform}Map`]??={value:null}).value=r?.map??null}else(o.uniforms[e.uniform]??={value:null}).value=a!==null&&"tiles"in a?null:a}}function Gr(o){const t=dt.get(o);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function Xr(o){return Object.values(dt.get(o)?.channels??{})}function zo(o,t){const n=t.userData.blenderUvChannels,e=t.getAttribute("position")?.count??0,a={};for(const r of o.uvs){let l=r===""?0:n?.[r];l===void 0&&(l=9,t.getAttribute("uv9")?.count!==e&&t.setAttribute("uv9",new it(new Float32Array(e*2),2))),a[r]=l}return a}function Yr(o,t,n,e,a,r,l){const c=un.get(o);c&&++c.draws>1&&(c.shadow.dispose(),un.delete(o));const u=kt.get(o);if(u&&!u.started){u.started=!0,u.binding.channels=zo(u.binding.compiled,t);const _=l(o);dt.set(_,u.binding);const d=new Tt(t,_);d.castShadow=r.castShadow,d.receiveShadow=r.receiveShadow;const h=()=>{if(kt.get(o)!==u){_.dispose();return}kt.delete(o);for(const m of dt.get(o)?.ramps??[])m.dispose();dt.set(o,u.binding),o.needsUpdate=!0,un.get(o)?.shadow.dispose(),un.set(o,{shadow:_,draws:0}),vt()};n.compileAsync(d,a,e).then(h,h)}const f=dt.get(o);if(!f)return;const s=n.properties.get(o).currentProgram;if(s?.diagnostics?.runnable===!1&&s.cacheKey?.includes(f.compiled.key)){ve.add(f.compiled.key),dt.delete(o),o.needsUpdate=!0;const _=s.diagnostics.fragmentShader.log.split(`
|
|
7036
|
+
`).find(d=>d.startsWith("ERROR"))??"";console.warn(`Blender material "${o.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${_}`);return}const i=zo(f.compiled,t);JSON.stringify(i)!==JSON.stringify(f.channels)&&(f.channels=i,o.needsUpdate=!0)}function Zr(o){const t=Array.isArray(o.material)?o.material:[o.material];if(!t.some(u=>u instanceof ln&&dt.has(u)))return;const n=o.geometry,e=o.userData.blenderTexspace??null,a=n.getAttribute("position"),r=JSON.stringify([e,a?.version??0,a?.count??0]);!n.userData.blenderOrcoFromDoor&&n.userData.blenderOrcoStamp!==r&&(n.setAttribute("blenderOrco",Qr(n,e)),n.userData.blenderOrcoStamp=r);const l=a?.count??0,c=o.userData.blenderDefaultColor;for(const u of t){const f=u instanceof ln?dt.get(u):void 0;for(const s of f?.compiled.attributes??[]){const i=Vt(s),_=s===""?c===void 0?void 0:n.getAttribute(Vt(c)):n.getAttribute(i);_&&_.count===l?n.getAttribute(i)!==_&&n.setAttribute(i,_):n.getAttribute(i)?.count!==l&&n.setAttribute(i,new it(new Float32Array(l*4),4))}}}function Qr(o,t){const n=o.getAttribute("position");let e,a;if(t)e=[...t[0]],a=[...t[1]];else{o.computeBoundingBox();const l=o.boundingBox;e=[(l.min.x+l.max.x)/2,(l.min.y+l.max.y)/2,(l.min.z+l.max.z)/2],a=[(l.max.x-l.min.x)/2,(l.max.y-l.min.y)/2,(l.max.z-l.min.z)/2]}a=a.map(l=>l===0?1:l);const r=new Float32Array(n.count*3);for(let l=0;l<n.count;l++)r[l*3]=(n.getX(l)-e[0])/a[0]*.5+.5,r[l*3+1]=(n.getY(l)-e[1])/a[1]*.5+.5,r[l*3+2]=(n.getZ(l)-e[2])/a[2]*.5+.5;return new it(r,3)}function Kr(o,t){const n=dt.get(o);if(!n)return;const{compiled:e,channels:a}=n;Object.assign(t.uniforms,n.uniforms,{blenderViewport:{value:ge}});const r=v=>v===0?"uv":`uv${v}`,l=`varying vec3 vBlenderObjectPosition;
|
|
7037
7037
|
varying vec3 vBlenderObjectNormal;
|
|
7038
7038
|
varying vec3 vBlenderWorldPosition;
|
|
7039
7039
|
varying vec3 vBlenderWorldNormal;
|
|
7040
7040
|
varying vec3 vBlenderOrco;
|
|
7041
|
-
${e.attributes.map(v=>`varying vec4 ${
|
|
7041
|
+
${e.attributes.map(v=>`varying vec4 ${Kn(v)};`).join(`
|
|
7042
7042
|
`)}
|
|
7043
7043
|
${e.uvs.map(v=>`varying vec2 ${Ht(v)};`).join(`
|
|
7044
7044
|
`)}`,c=e.attributes.map(v=>`attribute vec4 ${Vt(v)};`).join(`
|
|
7045
7045
|
`);t.vertexShader=`attribute vec3 blenderOrco;
|
|
7046
7046
|
${c}
|
|
7047
|
-
${
|
|
7047
|
+
${l}
|
|
7048
7048
|
${t.vertexShader}`.replace("#include <project_vertex>",`vBlenderObjectPosition = transformed;
|
|
7049
7049
|
vBlenderObjectNormal = objectNormal;
|
|
7050
7050
|
vBlenderWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;
|
|
7051
7051
|
vBlenderWorldNormal = normalize(transpose(inverse(mat3(modelMatrix))) * objectNormal);
|
|
7052
7052
|
vBlenderOrco = blenderOrco;
|
|
7053
|
-
${e.attributes.map(v=>`${
|
|
7053
|
+
${e.attributes.map(v=>`${Kn(v)} = ${Vt(v)};`).join(`
|
|
7054
7054
|
`)}
|
|
7055
|
-
${e.uvs.map(v=>`${Ht(v)} = ${a
|
|
7055
|
+
${e.uvs.map(v=>`${Ht(v)} = ${r(a[v]??0)};`).join(`
|
|
7056
7056
|
`)}
|
|
7057
7057
|
#include <project_vertex>`);const u=v=>e.outputs[v]?.global,f=[];e.surface==="ShaderNodeEmission"?(f.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),f.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Color")}.rgb * ${u("Strength")};`,!1]),f.push(["#include <opaque_fragment>","outgoingLight = totalEmissiveRadiance;",!0])):e.surface==="closure"?(f.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),f.push(["#include <emissivemap_fragment>","totalEmissiveRadiance = vec3(0.0);",!1])):(f.push(["#include <color_fragment>",`diffuseColor.rgb = ${u("Base Color")}.rgb;`,!1]),f.push(["#include <alphamap_fragment>",`diffuseColor.a = ${u("Alpha")};`,!1]),f.push(["#include <metalnessmap_fragment>",`roughnessFactor = ${u("Roughness")};`,!0]),f.push(["#include <metalnessmap_fragment>",`metalnessFactor = ${u("Metallic")};`,!1]),f.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Emission Color")}.rgb * ${u("Emission Strength")};`,!1]),u("Normal")&&f.push(["#include <clearcoat_normal_fragment_begin>",`normal = normalize((viewMatrix * vec4(transpose(blender_from_three) * ${u("Normal")}, 0.0)).xyz);`,!0])),e.closure&&f.push(["#include <opaque_fragment>",`{
|
|
7058
7058
|
float blenderCoverage = diffuseColor.a;
|
|
@@ -7064,17 +7064,17 @@ ${e.uvs.map(v=>`${Ht(v)} = ${a(r[v]??0)};`).join(`
|
|
|
7064
7064
|
outgoingLight = blenderRadiance / max(blenderAlpha, 1e-4);
|
|
7065
7065
|
#endif
|
|
7066
7066
|
diffuseColor.a = blenderAlpha;
|
|
7067
|
-
}`,!0]);const s=v=>v.replace(/^[ \t]*#include <(\w+)>/gm,(g,b)=>s(
|
|
7068
|
-
`);let p=t.fragmentShader.replace("void main() {",`${
|
|
7067
|
+
}`,!0]);const s=v=>v.replace(/^[ \t]*#include <(\w+)>/gm,(g,b)=>s(Ft[b]??"")),i=s(t.fragmentShader.slice(0,t.fragmentShader.indexOf("void main() {"))),_=new Map([...i.matchAll(/^[ \t]*#define[ \t]+(\w+).*$/gm)].map(v=>[v[1],v[0].trim()])),h=[...new Set([...e.declarations.matchAll(/^[ \t]*#define[ \t]+(\w+)/gm)].map(v=>v[1]))].filter(v=>_.has(v)),m=[...h.map(v=>`#undef ${v}`),e.declarations,...h.flatMap(v=>[`#undef ${v}`,_.get(v)])].join(`
|
|
7068
|
+
`);let p=t.fragmentShader.replace("void main() {",`${l}
|
|
7069
7069
|
${m}
|
|
7070
7070
|
void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
|
|
7071
7071
|
blenderGraph();`);for(const[v,g,b]of f){if(!p.includes(v))throw new Error(`three's physical shader has no ${v}`);p=p.replace(v,b?`${g}
|
|
7072
7072
|
${v}`:`${v}
|
|
7073
|
-
${g}`)}t.fragmentShader=p}const ge=new $t(1,1);function Jr(o){o.getDrawingBufferSize(ge)}function tl(o,t){const n=t.userData.blenderUvChannels;for(const e of[o.map,o.roughnessMap,o.normalMap]){if(!e)continue;const
|
|
7074
|
-
attribute vec2 uv${
|
|
7075
|
-
#endif`:`attribute vec2 uv${
|
|
7073
|
+
${g}`)}t.fragmentShader=p}const ge=new $t(1,1);function Jr(o){o.getDrawingBufferSize(ge)}function tl(o,t){const n=t.userData.blenderUvChannels;for(const e of[o.map,o.roughnessMap,o.normalMap]){if(!e)continue;const a=e.userData.blenderUvName;let r=a?n?.[a]:0;if(r===void 0){r=9;const l=t.getAttribute("position")?.count;if(l===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==l&&t.setAttribute("uv9",new it(new Float32Array(l*2),2))}e.channel!==r&&(e.channel=r,o.needsUpdate=!0)}}class nl{constructor(){this.bindings=new Map}get(t,n,e,a,r=""){let l=this.bindings.get(t);if(!l||l.source!==n){this.delete(t),l={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,l);const f=l;a&&a.then(()=>{f.disposed||(f.texture.needsUpdate=!0,f.version=n.version,vt())},()=>{})}const c=e==="REPEAT"?Ce:e==="MIRROR"?ke:Zo,u=l.texture.wrapS!==c||l.texture.wrapT!==c;return l.texture.wrapS=l.texture.wrapT=c,l.texture.userData.blenderUvName=r,n.image&&(u||l.version!==n.version)&&(l.texture.needsUpdate=!0,l.version=n.version),l.texture}delete(t){const n=this.bindings.get(t);n&&(n.disposed=!0,n.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const mt=S().finite(),Cn=$([mt,mt,mt]),ol=P({coat:mt,coat_roughness:mt,coat_ior:mt,coat_tint:Cn,sheen:mt,sheen_roughness:mt,sheen_tint:Cn,anisotropy:mt,anisotropy_rotation:mt,specular_level:mt,specular_tint:Cn,film_thickness:mt,film_ior:mt}).strict(),el={coat:0,coat_roughness:.03,coat_ior:1.5,coat_tint:[1,1,1],sheen:0,sheen_roughness:.5,sheen_tint:[1,1,1],anisotropy:0,anisotropy_rotation:0,specular_level:.5,specular_tint:[1,1,1],film_thickness:0,film_ior:1.33},Xt=new WeakMap;function al(o,t){Xt.has(o)||so(o),Xt.get(o).blenderWorldExtinction.value.copy(t)}function rl(o){const t=new ln,n=Xt.get(o);so(t),t.copy(o);const e=Xt.get(t);return n&&(e.blenderCoatIor.value=n.blenderCoatIor.value,e.blenderCoatTint.value.copy(n.blenderCoatTint.value),e.blenderMapClip.value=n.blenderMapClip.value,e.blenderRoughnessClip.value=n.blenderRoughnessClip.value,e.blenderNormalClip.value=n.blenderNormalClip.value,e.blenderWorldExtinction.value.copy(n.blenderWorldExtinction.value)),t}function so(o,t,n={}){const e=t??el;o.clearcoat=e.coat,o.clearcoatRoughness=e.coat_roughness,o.sheen=e.sheen,o.sheenRoughness=e.sheen_roughness,o.sheenColor.setRGB(...e.sheen_tint,ft),o.anisotropy=e.anisotropy,o.anisotropyRotation=e.anisotropy_rotation*Math.PI*2,o.specularIntensity=e.specular_level*2,o.specularColor.setRGB(...e.specular_tint,ft),o.iridescence=e.film_thickness>0?1:0,o.iridescenceIOR=e.film_ior,o.iridescenceThicknessRange=[e.film_thickness,e.film_thickness];let a=Xt.get(o);if(!a){a={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new ht(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new x}},Xt.set(o,a);const r=a;o.customProgramCacheKey=()=>`blender-principled-physical-v5${Gr(o)}`,o.onBeforeRender=(l,c,u,f,s)=>{tl(o,f),Yr(o,f,l,c,u,s,rl),Jr(l)},o.onBeforeCompile=l=>{const c=new Set([o.map,o.roughnessMap,o.normalMap].flatMap(h=>h?[h.channel]:[]).concat(Xr(o)));l.vertexShader=[...c].filter(h=>h>0).sort((h,m)=>h-m).map(h=>h<=3?`#ifndef USE_UV${h}
|
|
7074
|
+
attribute vec2 uv${h};
|
|
7075
|
+
#endif`:`attribute vec2 uv${h};`).join(`
|
|
7076
7076
|
`)+`
|
|
7077
|
-
`+
|
|
7077
|
+
`+l.vertexShader,Object.assign(l.uniforms,r),l.fragmentShader=`uniform float blenderCoatIor;
|
|
7078
7078
|
uniform vec3 blenderWorldExtinction;
|
|
7079
7079
|
vec3 blenderInfiniteTransmission() { return vec3(
|
|
7080
7080
|
blenderWorldExtinction.x>0.?0.:1., blenderWorldExtinction.y>0.?0.:1., blenderWorldExtinction.z>0.?0.:1.); }
|
|
@@ -7085,34 +7085,34 @@ attribute vec2 uv${d};
|
|
|
7085
7085
|
if (clipImage && (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0))))) pixel = vec4(0.0);
|
|
7086
7086
|
return pixel;
|
|
7087
7087
|
}
|
|
7088
|
-
`+
|
|
7088
|
+
`+l.fragmentShader;const u=Ft.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 ) ) );"),f=Ft.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=Ft.map_fragment.replace("texture2D( map, vMapUv )","blenderImageSample(map, vMapUv, blenderMapClip)").replace("diffuseColor *= sampledDiffuseColor;","diffuseColor.rgb *= sampledDiffuseColor.rgb;"),i=Ft.roughnessmap_fragment.replace("texture2D( roughnessMap, vRoughnessMapUv )","blenderImageSample(roughnessMap, vRoughnessMapUv, blenderRoughnessClip)"),_=Ft.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()"),d=Ft.lights_fragment_maps.replaceAll(/(getIBL(?:Irradiance|Radiance|AnisotropyRadiance)\([^;]+\))/g,"$1 * blenderInfiniteTransmission()");l.fragmentShader=l.fragmentShader.replace("#include <lights_physical_fragment>",u).replace("#include <lights_fragment_begin>",_).replace("#include <lights_fragment_maps>",d).replace("#include <normal_fragment_maps>",f).replace("#include <map_fragment>",s).replace("#include <roughnessmap_fragment>",i).replace("vec3 Fcc = F_Schlick",`
|
|
7089
7089
|
// Blender's slab_transmittance_at_angle (gpu_shader_material_principled.glsl):
|
|
7090
7090
|
// Beer-Lambert attenuation through a refracting coat at this view angle.
|
|
7091
7091
|
float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
|
|
7092
7092
|
blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
|
|
7093
7093
|
outgoingLight *= mix(vec3(1.0), pow(max(blenderCoatTint, vec3(0.0)), vec3(coatPath)), material.clearcoat);
|
|
7094
|
-
vec3 Fcc = F_Schlick`),Kr(o,
|
|
7095
|
-
`;let v="1.0",g="1.0";if(
|
|
7096
|
-
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(
|
|
7097
|
-
`,v=
|
|
7094
|
+
vec3 Fcc = F_Schlick`),Kr(o,l)},o.needsUpdate=!0}a.blenderCoatIor.value=Math.max(1,e.coat_ior),a.blenderCoatTint.value.setRGB(...e.coat_tint,ft),a.blenderMapClip.value=n.map===!0,a.blenderRoughnessClip.value=n.roughness===!0,a.blenderNormalClip.value=n.normal===!0}function fo(o){const t=a=>{if(!(!a||typeof a!="object")){if("kind"in a&&["direction","window","sky"].includes(String(a.kind)))throw new Error(`World volume spatial input ${a.kind} is not implemented`);for(const r of Object.values(a))t(r)}};t(o);const n=nt(o)(new x);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function Bt(o){const t=fo(o);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function dn(o){const t=fo(o);return(typeof t=="number"?new x().setScalar(t):t.clone()).max(new x)}function ll(o){if(o<800)return new x(5.413294490189271,0,0);if(o>=12e3)return new x(.8262954810464208,.9945080501520986,1.566307710274283);const t=[965,1167,1449,1902,3315,6365].filter(r=>o>=r).length,n=[[1619.19106,-.00205010916,5.02995757],[2488.45471,-.00111330907,3.22621544],[3341.43193,-.000486551192,1.76486769],[4094.61742,-.000127446582,.725731635],[4670.28036,291258199e-13,.126703442],[4595.09185,287495649e-13,.15034502],[3787.1745,935907826e-14,.399075871]][t],e=[[-488.999748,.000604330754,-.0755807526],[-755.994277,.000316730098,.478306139],[-1023.63977,.00012022347,.936662319],[-1265.71316,487340896e-14,1.27054498],[-1425.29332,-401150431e-13,1.43972784],[-1175.54822,-216378048e-13,1.30408023],[-500.799571,-459832026e-14,1.09098763]][t],a=[[596945309e-19,-485742887e-16,-970622247e-13,-.00407936148],[240430366e-19,555021075e-16,-.000198503712,.0289312858],[-140949732e-19,189878968e-15,-.000356632824,.0910767778],[-361460868e-19,284822009e-15,-.000493211319,.15672344],[-197075738e-19,175359352e-15,-.000250542825,-.0222783266],[-161997957e-21,-164216008e-16,.000386216271,-.738077418],[672650283e-21,-273078809e-16,.000424098264,-.752335691]][t];return new x(n[0]/o+n[1]*o+n[2],e[0]/o+e[1]*o+e[2],((a[0]*o+a[1])*o+a[2])*o+a[3]).max(new x)}function Do(o){if(!o?.volume?.length)return null;const t={extinction:new x,emission:new x,lobes:[]};for(const n of o.volume){const e=Bt(n.weight);if(e===0)continue;const a=dn(n.color),r=Bt(n.density),l=new x,c=new x;if(n.kind==="absorption"&&l.set(1-a.x,1-a.y,1-a.z).max(new x).multiplyScalar(r),n.kind==="scatter"||n.kind==="principled"){c.copy(a).multiplyScalar(r);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const f=fo(n.anisotropy);if(typeof f!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:c.clone().multiplyScalar(e),g:u==="RAYLEIGH"?0:ut.clamp(f,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?Bt(n.alpha):0})}if(n.kind==="principled"){const u=dn(n.absorption_color);l.set(Math.max(1-a.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-a.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-a.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(r);const f=Bt(n.blackbody_intensity);if(f>.001){const s=Bt(n.temperature),i=5670373e-20/Math.PI*(1+f*(s**4-1));t.emission.add(ll(s).multiply(dn(n.blackbody_tint)).multiplyScalar(i*e))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?a:dn(n.emission_color)).multiplyScalar(Bt(n.emission_strength)*e)),t.extinction.add(l.add(c).multiplyScalar(e))}for(const n of["x","y","z"])if(t.extinction[n]===0&&t.emission[n]>0)throw new Error("Unbounded emissive World volume with zero extinction has divergent radiance");return t}class il{constructor(t){this.medium=t,this.target=new $e(1,1,{type:no,depthBuffer:!1}),this.geometry=new Qo(2,2),this.scene=new Le,this.camera=new Ve}render(t,n,e,a){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const r={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:a.projectionMatrixInverse},cameraWorld:{value:a.matrixWorld},orthographic:{value:a.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let l="",c="",u=0,f=2;e.traverseVisible(d=>{if(!(d instanceof Vn||d instanceof jn||d instanceof gn))return;const h=d,m=u++,p=h.getWorldPosition(new x);r[`lp${m}`]={value:p},r[`lc${m}`]={value:h.color.clone().multiplyScalar(h.intensity)},l+=`uniform vec3 lp${m}, lc${m};
|
|
7095
|
+
`;let v="1.0",g="1.0";if(h instanceof jn&&(r[`ld${m}`]={value:h.target.getWorldPosition(new x).sub(p).normalize()},r[`cone${m}`]={value:new $t(Math.cos(h.angle),Math.cos(h.angle*(1-h.penumbra)))},l+=`uniform vec3 ld${m}; uniform vec2 cone${m};
|
|
7096
|
+
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(h instanceof gn)&&h.castShadow&&h.shadow.map){if(++f>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");r[`sm${m}`]={value:h.shadow.map.texture},r[`sx${m}`]={value:h.shadow.matrix},r[`ss${m}`]={value:h.shadow.mapSize},r[`sb${m}`]={value:h.shadow.bias},r[`sn${m}`]={value:h.shadow.camera.near},r[`sf${m}`]={value:h.shadow.camera.far},l+=`uniform sampler2D sm${m}; uniform mat4 sx${m}; uniform vec2 ss${m}; uniform float sb${m},sn${m},sf${m};
|
|
7097
|
+
`,v=h instanceof Vn?`getPointShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0),sn${m},sf${m})`:`getShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0))`}if(h instanceof gn){const b=new X().extractRotation(h.matrixWorld);r[`lx${m}`]={value:new x(h.width,0,0).applyMatrix4(b)},r[`ly${m}`]={value:new x(0,h.height,0).applyMatrix4(b)},r[`ln${m}`]={value:new x(0,0,-1).transformDirection(b)},l+=`uniform vec3 lx${m},ly${m},ln${m};
|
|
7098
7098
|
`,c+=`for(int ax=0;ax<4;ax++) for(int ay=0;ay<4;ay++) {
|
|
7099
7099
|
vec3 delta=lp${m}+lx${m}*((float(ax)+.5)/4.-.5)+ly${m}*((float(ay)+.5)/4.-.5)-p;
|
|
7100
7100
|
float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7101
7101
|
sum+=lc${m}*exp(-sigma*d)*phase(dot(L,ray))*max(dot(-L,ln${m}),0.)*
|
|
7102
7102
|
length(lx${m})*length(ly${m})/(16.*max(d*d,1e-4)); }
|
|
7103
|
-
`}else
|
|
7103
|
+
`}else r[`cut${m}`]={value:h.distance},r[`decay${m}`]={value:h.decay},l+=`uniform float cut${m},decay${m};
|
|
7104
7104
|
`,c+=`{ vec3 delta=lp${m}-p; float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
7105
7105
|
float cutoff=cut${m}>0.?pow(clamp(1.-pow(d/cut${m},4.),0.,1.),2.):1.;
|
|
7106
7106
|
sum+=lc${m}*exp(-sigma*d)*phase(dot(L,ray))*${g}*${v}*cutoff/max(pow(d,decay${m}),.01); }
|
|
7107
|
-
`});let s="vec3 result=vec3(0.);";this.medium.lobes.forEach((h
|
|
7108
|
-
`,s+=`result+=scatter${
|
|
7107
|
+
`});let s="vec3 result=vec3(0.);";this.medium.lobes.forEach((d,h)=>{r[`scatter${h}`]={value:d.coefficient},r[`g${h}`]={value:d.g},r[`a${h}`]={value:d.alpha},l+=`uniform vec3 scatter${h}; uniform float g${h},a${h};
|
|
7108
|
+
`,s+=`result+=scatter${h}*(1.-g${h}*g${h})*(1.+a${h}*c*c)/(12.56637061436*(1.+a${h}*(1.+2.*g${h}*g${h})/3.)*pow(1.+g${h}*g${h}-2.*g${h}*c,1.5));`});const i=this.medium.extinction.toArray().filter(d=>d>0);r.range={value:i.length?20/Math.min(...i):1},this.material?.dispose(),this.material=new Jn({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:`
|
|
7109
7109
|
#include <common>
|
|
7110
7110
|
#include <packing>
|
|
7111
7111
|
#include <shadowmap_pars_fragment>
|
|
7112
7112
|
varying vec2 vUv; uniform sampler2D surface,depth;
|
|
7113
7113
|
uniform mat4 inverseProjection,cameraWorld; uniform bool orthographic;
|
|
7114
7114
|
uniform vec3 sigma,emission; uniform float range;
|
|
7115
|
-
${
|
|
7115
|
+
${l}
|
|
7116
7116
|
vec3 phase(float c){${s} return result;}
|
|
7117
7117
|
vec3 incident(vec3 p,vec3 ray){vec3 sum=vec3(0.);${c}return sum;}
|
|
7118
7118
|
float integral(float s,float d){float x=s*d;return x<.001 ? d*(1.-x*.5+x*x/6.) : (1.-exp(-x))/s;}
|
|
@@ -7135,10 +7135,10 @@ attribute vec2 uv${d};
|
|
|
7135
7135
|
radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
|
|
7136
7136
|
}
|
|
7137
7137
|
gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
|
|
7138
|
-
}`}),this.scene.clear(),this.scene.add(new Tt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const _=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(_)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const sl=P({object:E(),group:E(),groupIndex:S().int().nonnegative(),count:S().int().nonnegative(),digest:E(),alertMode:W(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:E().optional(),alertBase64:E().optional()}).strict();function fl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[r,a,i]=cl(2/3*(1-n)),c=new ht;return c.setRGB((r*e)**(1/1.5),(a*e)**(1/1.5),(i*e)**(1/1.5),Mt),c}function cl(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const ul=0;function Co(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class _l{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const r=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==r)return this.clear(),`weights: the session sent a reference to ${r} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${r} carried neither an array nor a reference`;const d=Co(t.weightsBase64);this.held={key:r,weights:new Float32Array(d.buffer,d.byteOffset,t.count),alerts:Co(t.alertBase64)}}const a=this.held;if(a===null)return null;const i=`${r}:${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 c=n.geometry.clone(),u=c.getAttribute("position"),f=c.getAttribute("blenderVertex");if(f===void 0)return c.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),l=new ht().setHex(ul,Mt);for(let d=0;d<u.count;d++){const m=f.getX(d),v=t.alertMode!=="NONE"&&a.alerts[m]===1?l:fl(a.weights[m]??0);s[d*3]=v.r,s[d*3+1]=v.g,s[d*3+2]=v.b}c.setAttribute("color",new it(s,3)),c.deleteAttribute("blenderVertex");const _=new bn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),h=new Tt(c,_);return h.name=`${t.object}:weights`,h.frustumCulled=!1,h.matrixAutoUpdate=!1,h.matrix.copy(e),h.matrix.decompose(h.position,h.quaternion,h.scale),this.geometry=c,this.material=_,this.mesh=h,this.group.add(h),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=z($([hn,hn,hn,hn])).length(4),dl=20,ko=[16724818,9165824,2658559];function hl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function xe(){return new Be({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function pl(){const o=[],t=[],n=new ht(0,0,0),e=(a,i,c,u,f)=>{for(const s of[a,i]){const l=[0,0,0];l[c]=s*u,o.push(...l),t.push(f.r,f.g,f.b)}};for(let a=0;a<3;a++){const i=new ht().setHex(ko[a],Mt);e(1,.85,a,1,i),e(.85,.25,a,1,n),e(1,.85,a,-1,hl(ko[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 Ko(r,xe())}function vl(){const t=[],n=[],e=new ht(1,0,0),r=new ht(1,1,1);for(let i=0;i<12;i++){const c=(i+1)%2===0?r:e;for(const u of[i,i+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 Ko(a,xe())}class gl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=pl(),this.circle=vl(),this.seen=null,this.size=new $t,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,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 i=a*dl;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,r,a){const i=this.seen;if(i===null||e!==i.canvas)return null;const c=i.canvas.getBoundingClientRect(),u=new $t((t-c.left)/Math.max(c.width,1)*2-1,-((n-c.top)/Math.max(c.height,1))*2+1),f=new je;f.setFromCamera(u,i.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},l=f.intersectObject(r,!0).find(m=>m.object.isMesh&&a(m.object)&&s(m.object));let _=l?l.point.clone():null;if(_===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)),_=f.ray.intersectPlane(new It().setFromNormalAndCoplanarPoint(p,m),new x)}if(_===null)return null;r.updateWorldMatrix(!0,!1);const h=r.worldToLocal(_),d=r.getWorldQuaternion(new gt).invert().multiply(i.camera.getWorldQuaternion(new gt));return{location:[h.x,h.y,h.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 Rt=S().finite(),xl=P({display:W(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Rt,image:P({name:E().nullable(),offset:$([Rt,Rt]),depth:W(["DEFAULT","FRONT","BACK"]),side:W(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:Rt.nullable(),tint:$([Rt,Rt,Rt]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},bl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const 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 i=t[a*r%t.length],c=t[(a*r+1)%t.length];K(o,[i[0],i[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,i,c,u,f,s)=>{t(a,i,c,u,f,s),i.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),r=!0)},o.onAfterRender=(a,i,c,u,f,s)=>{r&&(o.matrixWorld.copy(e),r=!1),n(a,i,c,u,f,s)}}class wl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new $t,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const 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,i=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,c=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!a&&!i&&!c)continue;n.add(e.name);const u=i&&e.light?t.lightDistances[e.light]??null:null,f=c?.image?.name?t.image(c.image.name):null,s=JSON.stringify([f?[f.texture.uuid,f.width,f.height]:null,e.matrix,r,a,i,u,c,a?[e.name===t.sceneCamera,t.renderAspect]:null]),l=this.drawn.get(e.name),_=t.presented(e.name);if(l?.key===s){for(const v of l.parts)v.userData.volterPicksAs=_;continue}l&&this.remove(l.parts);const h=new X().set(...e.matrix.flat()),d=a?this.cameras:i?this.lights:this.empties,m=new Set(d.children);a?this.camera(a,h,r,e.name===t.sceneCamera,t.renderAspect):i?this.light(i,h,r,u):c&&this.empty(c,h,r,f);const p=d.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=_,v.traverse(yl);this.drawn.set(e.name,{key:s,parts:p})}for(const[e,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 i=t.display_size,u=(t.sensor_fit==="AUTO"?a>=1:t.sensor_fit==="HORIZONTAL")?[1,1/a]:[a,1];let f,s,l,_;if(t.type==="ORTHO")l=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],_=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-i,f=.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;f=i/2/((1/O.x+1/O.y+1/O.z)/3),s=f*t.lens/-A,l=[f*u[0],f*u[1]],_=[t.shift_x*f*2,t.shift_y*f*2]}const h=[[_[0]+l[0],_[1]+l[1],s],[_[0]+l[0],_[1]-l[1],s],[_[0]-l[0],_[1]-l[1],s],[_[0]-l[0],_[1]+l[1],s]],d=[];for(let A=0;A<4;A++)K(d,h[A],h[(A+1)%4]),K(d,h[A],[0,0,0]);const m=.7*f,p=.1*f,v=_[1]+l[1]+p,g=[[_[0]-m,v,s],[_[0]+m,v,s],[_[0],v+m,s]],b=Cn(n);this.cameras.add(this.lines(d,e,1,b));let w;if(r){const A=new fn;A.setAttribute("position",new bt(g.flat(),3)),w=new Tt(A,this.fill(e)),w.matrixAutoUpdate=!1,w.matrix.copy(b)}else{const A=[];for(let O=0;O<3;O++)K(A,g[O],g[(O+1)%3]);w=this.lines(A,e,1,b)}const R=new x,T=w.onBeforeRender.bind(w);w.onBeforeRender=(A,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(A,O,M,C,V,H)},this.cameras.add(w)}light(t,n,e,r){const a=new x().setFromMatrixPosition(n),i=[];K(i,[a.x,a.y,a.z],[a.x,a.y,0]),this.lights.add(this.lines(i,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[_,h]of at(f,8))K(u,[_*1.6,h*1.6,0],[_*1.9,h*1.9,0]),K(u,[_*2.2,h*2.2,0],[_*2.5,h*2.5,0]);this.lights.add(this.screen(u,e,1,a));const s=Cn(n),l=[];if(t.type==="SUN")K(l,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const _=(t.size??1)/2,h=(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*_,m*h])):ct(l,[[_,h],[-_,h],[-_,-h],[_,-h]])}if(l.length>0&&this.lights.add(this.lines(l,e,1,n.clone())),r&&(t.type==="SPOT"||t.type==="AREA")){const _=new x(0,0,-1).transformDirection(n),h=v=>a.clone().addScaledVector(_,v),[d,m]=r,p=[];K(p,h(d).toArray(),h(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,h(v)))}}if(t.type==="SPOT"){const _=(t.spot_size??Math.PI/4)/2,h=Math.cos(_),d=t.spot_blend??.15,m=h*d-h-d,p=Math.sqrt((h*h-h*h*m*m)/(m*m-h*h*m*m)),v=Math.sqrt(1-h*h),g=Cn(n).multiply(new X().makeScale(10,10,10)),b=[];ct(b,at(v,32),-h),ct(b,at(v*p,32),-h),this.lights.add(this.lines(b,e,1,g.clone())),this.lights.add(this.silhouette(v,h,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const _=[];ct(_,at(t.radius,32)),this.lights.add(this.facing(_,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,r){const a=t.size,i=[],c=(f,s)=>{const l=at(1,s);for(let _=0;_<s;_++){const[h,d]=l[_],[m,p]=l[(_+1)%s],v=(g,b)=>f==="xy"?[g,b,0]:f==="xz"?[g,0,b]:[0,g,b];K(i,v(h,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[f,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(i,[0,0,1],[f,s,.75]);ct(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[f,s]of Ol)K(i,$o[f],$o[s]);break;case"CIRCLE":c("xz",64);break;case"SPHERE":c("xy",32),c("xz",32),c("yz",32);break;case"CONE":{const f=at(1,8);for(let s=0;s<8;s++){const[l,_]=f[s],[h,d]=f[(s+1)%8];K(i,[l,0,_],[0,2,0]),K(i,[l,0,_],[h,0,d])}break}case"ARROWS":for(let f=0;f<3;f++){const s=[0,0,0];s[f]=1,K(i,[0,0,0],s)}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(i,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 i=a.geometry.getAttribute("instanceStart").data,c=at(1,32).map(([h,d])=>new x(h*t,d*t,-n)),u=new x,f=new X,s=new x,l=new x,_=new x;return this.onDraw(a,(h,d)=>{f.copy(a.matrixWorld).invert();const m=d.isOrthographicCamera;m?d.getWorldDirection(u).negate().transformDirection(f):u.setFromMatrixPosition(d.matrixWorld).applyMatrix4(f);const p=i.array;let v=!1;for(let g=0;g<32;g++){const b=c[g];s.crossVectors(b,c[(g+31)%32]),l.crossVectors(c[(g+1)%32],b),m?_.copy(u):_.copy(u).sub(b);const w=s.dot(_)>0!=l.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&&(i.needsUpdate=!0,vt())}),a}imageEmpty(t,n,e,r){const a=t.image;if(!a)return;const i=r?.width??0,c=r?.height??0,u=i>0&&c>0?i>=c?[1,c/i]:[i/c,1]:[1,1],f=new x,s=new x,l=new x;n.extractBasis(f,s,l),f.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const _=new x().setFromMatrixPosition(n).addScaledVector(f,a.offset[0]*2+1).addScaledVector(s,a.offset[1]*2+1),h=new X().makeBasis(f,s,l.clone()).setPosition(_),d=[];ct(d,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(d,e,1,h),p=l.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(h),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",A=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});A.color.setRGB(...a.tint,ft),R&&T&&(A.blending=Ue,A.blendSrc=We,A.blendDst=He),A.onBeforeCompile=M=>{const C=a.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7138
|
+
}`}),this.scene.clear(),this.scene.add(new Tt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const _=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(_)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const sl=P({object:E(),group:E(),groupIndex:S().int().nonnegative(),count:S().int().nonnegative(),digest:E(),alertMode:W(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:E().optional(),alertBase64:E().optional()}).strict();function fl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,l]=cl(2/3*(1-n)),c=new ht;return c.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(l*e)**(1/1.5),Mt),c}function cl(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const ul=0;function Co(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class _l{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const a=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==a)return this.clear(),`weights: the session sent a reference to ${a} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${a} carried neither an array nor a reference`;const h=Co(t.weightsBase64);this.held={key:a,weights:new Float32Array(h.buffer,h.byteOffset,t.count),alerts:Co(t.alertBase64)}}const r=this.held;if(r===null)return null;const l=`${a}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(l===this.signature&&this.mesh!==null)return null;this.signature=l,this.clear();const c=n.geometry.clone(),u=c.getAttribute("position"),f=c.getAttribute("blenderVertex");if(f===void 0)return c.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),i=new ht().setHex(ul,Mt);for(let h=0;h<u.count;h++){const m=f.getX(h),v=t.alertMode!=="NONE"&&r.alerts[m]===1?i:fl(r.weights[m]??0);s[h*3]=v.r,s[h*3+1]=v.g,s[h*3+2]=v.b}c.setAttribute("color",new it(s,3)),c.deleteAttribute("blenderVertex");const _=new bn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),d=new Tt(c,_);return d.name=`${t.object}:weights`,d.frustumCulled=!1,d.matrixAutoUpdate=!1,d.matrix.copy(e),d.matrix.decompose(d.position,d.quaternion,d.scale),this.geometry=c,this.material=_,this.mesh=d,this.group.add(d),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const hn=S().finite(),ml=F($([hn,hn,hn,hn])).length(4),dl=20,ko=[16724818,9165824,2658559];function hl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function xe(){return new Be({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function pl(){const o=[],t=[],n=new ht(0,0,0),e=(r,l,c,u,f)=>{for(const s of[r,l]){const i=[0,0,0];i[c]=s*u,o.push(...i),t.push(f.r,f.g,f.b)}};for(let r=0;r<3;r++){const l=new ht().setHex(ko[r],Mt);e(1,.85,r,1,l),e(.85,.25,r,1,n),e(1,.85,r,-1,hl(ko[r])),e(.85,.25,r,-1,n)}const a=new fn;return a.setAttribute("position",new bt(o,3)),a.setAttribute("color",new bt(t,3)),new Ko(a,xe())}function vl(){const t=[],n=[],e=new ht(1,0,0),a=new ht(1,1,1);for(let l=0;l<12;l++){const c=(l+1)%2===0?a:e;for(const u of[l,l+1]){const f=2*Math.PI*u/12;t.push(.5*Math.cos(f),.5*Math.sin(f),0),n.push(c.r,c.g,c.b)}}const r=new fn;return r.setAttribute("position",new bt(t,3)),r.setAttribute("color",new bt(n,3)),new Ko(r,xe())}class gl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=pl(),this.circle=vl(),this.seen=null,this.size=new $t,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,a,r]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new gt(e,a,r,n),new x(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const e=Math.max(this.size.y,1),a=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let r;if(n.isOrthographicCamera){const c=n;r=(c.top-c.bottom)/c.zoom/e}else{const c=n;r=2*Math.max(-a.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(c.fov)/2)/c.zoom/e}const l=r*dl;this.lines.scale.setScalar(l),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(l),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,a,r){const l=this.seen;if(l===null||e!==l.canvas)return null;const c=l.canvas.getBoundingClientRect(),u=new $t((t-c.left)/Math.max(c.width,1)*2-1,-((n-c.top)/Math.max(c.height,1))*2+1),f=new je;f.setFromCamera(u,l.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},i=f.intersectObject(a,!0).find(m=>m.object.isMesh&&r(m.object)&&s(m.object));let _=i?i.point.clone():null;if(_===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=l.camera.getWorldDirection(new x),v=l.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),_=f.ray.intersectPlane(new It().setFromNormalAndCoplanarPoint(p,m),new x)}if(_===null)return null;a.updateWorldMatrix(!0,!1);const d=a.worldToLocal(_),h=a.getWorldQuaternion(new gt).invert().multiply(l.camera.getWorldQuaternion(new gt));return{location:[d.x,d.y,d.z],rotation:[h.w,h.x,h.y,h.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Rt=S().finite(),xl=P({display:W(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Rt,image:P({name:E().nullable(),offset:$([Rt,Rt]),depth:W(["DEFAULT","FRONT","BACK"]),side:W(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:Rt.nullable(),tint:$([Rt,Rt,Rt]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},bl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const a=2*Math.PI*e/t;return[o*Math.cos(a),o*Math.sin(a)]})}function ct(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const l=t[r*a%t.length],c=t[(r*a+1)%t.length];K(o,[l[0],l[1],n],[c[0],c[1],n])}}function yl(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new X;let a=!1;o.onBeforeRender=(r,l,c,u,f,s)=>{t(r,l,c,u,f,s),l.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),a=!0)},o.onAfterRender=(r,l,c,u,f,s)=>{a&&(o.matrixWorld.copy(e),a=!1),n(r,l,c,u,f,s)}}class wl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new $t,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const a=e.selected?e.name===t.active?wt.active:wt.selected:e.type==="CAMERA"?wt.camera:e.type==="LIGHT"?wt.light:wt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,l=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,c=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!r&&!l&&!c)continue;n.add(e.name);const u=l&&e.light?t.lightDistances[e.light]??null:null,f=c?.image?.name?t.image(c.image.name):null,s=JSON.stringify([f?[f.texture.uuid,f.width,f.height]:null,e.matrix,a,r,l,u,c,r?[e.name===t.sceneCamera,t.renderAspect]:null]),i=this.drawn.get(e.name),_=t.presented(e.name);if(i?.key===s){for(const v of i.parts)v.userData.volterPicksAs=_;continue}i&&this.remove(i.parts);const d=new X().set(...e.matrix.flat()),h=r?this.cameras:l?this.lights:this.empties,m=new Set(h.children);r?this.camera(r,d,a,e.name===t.sceneCamera,t.renderAspect):l?this.light(l,d,a,u):c&&this.empty(c,d,a,f);const p=h.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=_,v.traverse(yl);this.drawn.set(e.name,{key:s,parts:p})}for(const[e,a]of this.drawn)n.has(e)||(this.remove(a.parts),this.drawn.delete(e))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,e,a,r){const l=t.display_size,u=(t.sensor_fit==="AUTO"?r>=1:t.sensor_fit==="HORIZONTAL")?[1,1/r]:[r,1];let f,s,i,_;if(t.type==="ORTHO")i=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],_=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-l,f=.5*t.ortho_scale;else{const 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;f=l/2/((1/O.x+1/O.y+1/O.z)/3),s=f*t.lens/-A,i=[f*u[0],f*u[1]],_=[t.shift_x*f*2,t.shift_y*f*2]}const d=[[_[0]+i[0],_[1]+i[1],s],[_[0]+i[0],_[1]-i[1],s],[_[0]-i[0],_[1]-i[1],s],[_[0]-i[0],_[1]+i[1],s]],h=[];for(let A=0;A<4;A++)K(h,d[A],d[(A+1)%4]),K(h,d[A],[0,0,0]);const m=.7*f,p=.1*f,v=_[1]+i[1]+p,g=[[_[0]-m,v,s],[_[0]+m,v,s],[_[0],v+m,s]],b=kn(n);this.cameras.add(this.lines(h,e,1,b));let w;if(a){const A=new fn;A.setAttribute("position",new bt(g.flat(),3)),w=new Tt(A,this.fill(e)),w.matrixAutoUpdate=!1,w.matrix.copy(b)}else{const A=[];for(let O=0;O<3;O++)K(A,g[O],g[(O+1)%3]);w=this.lines(A,e,1,b)}const R=new x,T=w.onBeforeRender.bind(w);w.onBeforeRender=(A,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(A,O,M,C,V,H)},this.cameras.add(w)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),l=[];K(l,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(l,wt.light,wt.lightAlpha,new X));const c=[];ct(c,at(1.35,4)),this.lights.add(this.screen(c,wt.light,wt.lightAlpha,new x(r.x,r.y,0)));const u=[],f=9;if(ct(u,at(f*.3,4)),ct(u,at(f,16),0,!0),ct(u,at(f*1.33,20),0,!0),t.type==="SUN")for(const[_,d]of at(f,8))K(u,[_*1.6,d*1.6,0],[_*1.9,d*1.9,0]),K(u,[_*2.2,d*2.2,0],[_*2.5,d*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=kn(n),i=[];if(t.type==="SUN")K(i,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const _=(t.size??1)/2,d=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?ct(i,at(1,32).map(([h,m])=>[h*_,m*d])):ct(i,[[_,d],[-_,d],[-_,-d],[_,-d]])}if(i.length>0&&this.lights.add(this.lines(i,e,1,n.clone())),a&&(t.type==="SPOT"||t.type==="AREA")){const _=new x(0,0,-1).transformDirection(n),d=v=>r.clone().addScaledVector(_,v),[h,m]=a,p=[];K(p,d(h).toArray(),d(m).toArray()),this.lights.add(this.lines(p,e,1,new X));for(const v of[h,m]){const g=[];ct(g,at(1.2,4)),this.lights.add(this.screen(g,e,1,d(v)))}}if(t.type==="SPOT"){const _=(t.spot_size??Math.PI/4)/2,d=Math.cos(_),h=t.spot_blend??.15,m=d*h-d-h,p=Math.sqrt((d*d-d*d*m*m)/(m*m-d*d*m*m)),v=Math.sqrt(1-d*d),g=kn(n).multiply(new X().makeScale(10,10,10)),b=[];ct(b,at(v,32),-d),ct(b,at(v*p,32),-d),this.lights.add(this.lines(b,e,1,g.clone())),this.lights.add(this.silhouette(v,d,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const _=[];ct(_,at(t.radius,32)),this.lights.add(this.facing(_,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,a){const r=t.size,l=[],c=(f,s)=>{const i=at(1,s);for(let _=0;_<s;_++){const[d,h]=i[_],[m,p]=i[(_+1)%s],v=(g,b)=>f==="xy"?[g,b,0]:f==="xz"?[g,0,b]:[0,g,b];K(l,v(d,h),v(m,p))}};switch(t.display){case"PLAIN_AXES":K(l,[0,-1,0],[0,1,0]),K(l,[-1,0,0],[1,0,0]),K(l,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{K(l,[0,0,0],[0,0,.75]);for(const[f,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(l,[0,0,1],[f,s,.75]);ct(l,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[f,s]of Ol)K(l,$o[f],$o[s]);break;case"CIRCLE":c("xz",64);break;case"SPHERE":c("xy",32),c("xz",32),c("yz",32);break;case"CONE":{const f=at(1,8);for(let s=0;s<8;s++){const[i,_]=f[s],[d,h]=f[(s+1)%8];K(l,[i,0,_],[0,2,0]),K(l,[i,0,_],[d,0,h])}break}case"ARROWS":for(let f=0;f<3;f++){const s=[0,0,0];s[f]=1,K(l,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new X().makeScale(r,r,r));this.empties.add(this.lines(l,e,1,u)),t.display==="ARROWS"&&this.axisNames(n,r,e)}silhouette(t,n,e,a){const r=this.lines(new Array(192).fill(0),e,1,a);r.frustumCulled=!1;const l=r.geometry.getAttribute("instanceStart").data,c=at(1,32).map(([d,h])=>new x(d*t,h*t,-n)),u=new x,f=new X,s=new x,i=new x,_=new x;return this.onDraw(r,(d,h)=>{f.copy(r.matrixWorld).invert();const m=h.isOrthographicCamera;m?h.getWorldDirection(u).negate().transformDirection(f):u.setFromMatrixPosition(h.matrixWorld).applyMatrix4(f);const p=l.array;let v=!1;for(let g=0;g<32;g++){const b=c[g];s.crossVectors(b,c[(g+31)%32]),i.crossVectors(c[(g+1)%32],b),m?_.copy(u):_.copy(u).sub(b);const w=s.dot(_)>0!=i.dot(_)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==w&&(v=!0),p.set([0,0,0,w?b.x:0,w?b.y:0,w?b.z:0],g*6)}v&&(l.needsUpdate=!0,vt())}),r}imageEmpty(t,n,e,a){const r=t.image;if(!r)return;const l=a?.width??0,c=a?.height??0,u=l>0&&c>0?l>=c?[1,c/l]:[l/c,1]:[1,1],f=new x,s=new x,i=new x;n.extractBasis(f,s,i),f.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const _=new x().setFromMatrixPosition(n).addScaledVector(f,r.offset[0]*2+1).addScaledVector(s,r.offset[1]*2+1),d=new X().makeBasis(f,s,i.clone()).setPosition(_),h=[];ct(h,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(h,e,1,d),p=i.clone().normalize(),v=new x,g=new x,b=(M,C)=>{const V=M.isOrthographicCamera===!0;if(V?!r.orthographic:!r.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);M.getWorldDirection(g);let Q,tt;if(V)Q=H.dot(g.clone().negate()),tt=1e-5;else{const pt=_.clone().applyMatrix4(this.empties.matrixWorld);Q=H.dot(v.setFromMatrixPosition(M.matrixWorld).sub(pt)),tt=0}return!(r.side==="FRONT"&&Q<tt||r.side==="BACK"&&Q>-tt||r.axis_aligned&&H.clone().projectOnPlane(g).lengthSq()>1e-5)},w=(M,C)=>{const V=M.onBeforeRender.bind(M);M.onBeforeRender=(H,Q,tt,pt,y,L)=>{M.matrix.copy(d),b(tt,C)||M.matrix.scale(new x(0,0,0)),M.updateMatrixWorld(!0),V(H,Q,tt,pt,y,L)}};if(w(m,!1),this.empties.add(m),!a||r.opacity!==null&&r.opacity<=0)return;const R=r.opacity!==null,T=r.depth==="BACK",A=new bn({map:a.texture,side:uo,transparent:R&&!T,opacity:r.opacity??1,alphaTest:R?0:.05,toneMapped:!1,depthTest:r.depth==="DEFAULT",depthWrite:r.depth==="DEFAULT"&&!R});A.color.setRGB(...r.tint,ft),R&&T&&(A.blending=Ue,A.blendSrc=We,A.blendDst=He),A.onBeforeCompile=M=>{const C=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7139
7139
|
`:"";M.fragmentShader=M.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
7140
7140
|
${C}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",R?"#include <alphatest_fragment>":`#include <alphatest_fragment>
|
|
7141
|
-
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${
|
|
7141
|
+
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${r.premultiplied}:${R}`;const O=new Tt(new Qo(2,2),A);O.matrixAutoUpdate=!1,O.matrix.copy(d),O.renderOrder=r.depth==="FRONT"?1e3:r.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,w(O,!0),this.empties.add(O)}axisNames(t,n,e){const a=[new x,new x,new x];t.extractBasis(a[0],a[1],a[2]);for(let r=0;r<3;r++){const l=a[r].length()*n,c=new x(0,0,0);c.setComponent(r,1.25*n),c.applyMatrix4(t);const u=new x(0,0,0);u.setComponent(r,n),u.applyMatrix4(t);const f=[];for(let _=1;_<=6;_++)ct(f,at(.007*(4*_/6)*l,4));this.empties.add(this.facing(f,e,u));const s=Tl[r],i=[];for(let _=0;_+1<s.length;_+=2){const[d,h]=s[_],[m,p]=s[_+1];K(i,[d*4*l,h*4*l,0],[m*4*l,p*4*l,0])}this.empties.add(this.facing(i,e,c))}}material(t,n){const e=`${t}:${n}`;let a=this.lineMaterials.get(e);return a||(a=new Wo({color:t,linewidth:bl,transparent:n<1,opacity:n,depthTest:!0,depthWrite:n>=1,toneMapped:!1}),this.lineMaterials.set(e,a)),a}fill(t){let n=this.fillMaterials.get(t);return n||(n=new bn({color:t,side:uo,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,e,a){const r=new Uo().setPositions(t),l=new Ho(r,this.material(n,e));return l.matrixAutoUpdate=!1,l.matrix.copy(a),l.computeLineDistances(),l}screen(t,n,e,a){const r=this.lines(t,n,e,new X);return r.matrixAutoUpdate=!0,r.position.copy(a),r.scale.setScalar(0),r.frustumCulled=!1,this.onDraw(r,(l,c)=>this.face(r,l,c,!0)),r}facing(t,n,e){const a=this.lines(t,n,1,new X);return a.matrixAutoUpdate=!0,a.position.copy(e),this.onDraw(a,(r,l)=>this.face(a,r,l,!1)),a}onDraw(t,n){const e=t,a=e.onBeforeRender.bind(e);e.onBeforeRender=(r,l,c,u,f,s)=>{n(r,c),a(r,l,c,u,f,s)}}face(t,n,e,a){t.parent?.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let r=1;if(a){n.getSize(this.size);const l=Math.max(this.size.y,1),c=this.scratch.setFromMatrixPosition(t.matrixWorld);if(e.isOrthographicCamera){const u=e;r=(u.top-u.bottom)/u.zoom/l}else{const u=e;r=2*Math.max(-c.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(u.fov)/2)/u.zoom/l}}t.scale.setScalar(r),t.updateMatrixWorld(!0)}dispose(){for(const t of this.drawn.values())this.remove(t.parts);this.drawn.clear();for(const t of this.lineMaterials.values())t.dispose();for(const t of this.fillMaterials.values())t.dispose();this.lineMaterials.clear(),this.fillMaterials.clear()}}function kn(o){const t=new x,n=new gt;return o.decompose(t,n,new x),new X().compose(t,n,new x(1,1,1))}const $o=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],Ol=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Tl=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([o,t])=>[o*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([o,t])=>[o*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([o,t])=>[o*.02,t*.025])],rt=S().finite(),Lo=P({name:E(),type:E(),lens:rt,sensor_width:rt,sensor_height:rt,sensor_fit:W(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:rt,clip_start:rt,clip_end:rt,shift_x:rt,shift_y:rt,matrix:F($([rt,rt,rt,rt])).length(4),passepartout:rt.default(0),display_size:rt.default(1)}),Pl={opening:.5,min:.1657359312880715,max:44.98528137423857},pn={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function Al(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 Vo(o,t,n,e){const a=o.type==="ORTHO",r=o.sensor_fit==="VERTICAL"?o.sensor_height:o.sensor_width,l=o.sensor_fit==="AUTO"?t>=n:o.sensor_fit==="HORIZONTAL",c=(a?o.ortho_scale:r/o.lens)/2*e;return l?[c,c*n/t]:[c*t/n,c]}function Sl(o,t,n,e,a,r){const l=Math.max(n.width,1),c=Math.max(n.height,1),[u,f]=Vo(o,l,c,1/e),[s,i]=Vo(o,r,1,1),d=2*((o.sensor_fit==="AUTO"?r>=1:o.sensor_fit==="HORIZONTAL")?s:i),h=s/u,m=i/f,p=-2*a[0]*e,v=2*a[1]*e,g=o.shift_x*d-p*2*u,b=o.shift_y*d+v*2*f,w=new X().set(...o.matrix.flat()).premultiply(t),R=new x,T=new gt;return w.decompose(R,T,new x),{name:o.name,position:R.toArray(),quaternion:[T.x,T.y,T.z,T.w],projection:o.type==="ORTHO"?"orthographic":"perspective",window:{left:g-u,right:g+u,top:b+f,bottom:b-f},near:o.clip_start,far:o.clip_end,frame:{left:.5-h/2+p,top:.5-m/2+v,width:h,height:m},passepartout:{color:pn.passepartout,opacity:o.passepartout},border:{solid:pn.back,dashed:pn.overlay,locked:pn.redalert}}}const El={color:[.8,.8,.8,1],roughness:.5,metallic:0},Ml=`
|
|
7142
7142
|
uniform vec3 wbDir[4];
|
|
7143
7143
|
uniform vec3 wbDiffuse[4];
|
|
7144
7144
|
uniform vec3 wbSpecular[4];
|
|
@@ -7180,6 +7180,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
|
|
|
7180
7180
|
diffuseLight *= diffuseColor * (1.0 - specEnergy);
|
|
7181
7181
|
return diffuseLight + specularLight;
|
|
7182
7182
|
}
|
|
7183
|
-
`,
|
|
7183
|
+
`,co=o=>ro.map(t=>{const[n=0,e=0,a=0]=o(t);return new x(n,e,a)}),Nl=co(o=>o.direction).map(o=>o.normalize()),Rl=co(o=>o.diffuse),Il=co(o=>o.specular),Fl=new to(...ro.map(o=>o.smooth));function zl(o,t){const[n,e,a]=o.color,r=new qe({side:t});return r.color.setRGB(n,e,a,ft),r.name="volter:blender-solid",r.onBeforeCompile=l=>{l.uniforms.wbDir={value:Nl},l.uniforms.wbDiffuse={value:Rl},l.uniforms.wbSpecular={value:Il},l.uniforms.wbWrap={value:Fl},l.uniforms.wbRoughness={value:o.roughness},l.uniforms.wbMetallic={value:o.metallic},l.fragmentShader=l.fragmentShader.replace("void main() {",`${Ml}
|
|
7184
7184
|
void main() {`).replace("#include <opaque_fragment>",`outgoingLight = volterWorkbenchLighting(diffuseColor.rgb, normal, isOrthographic ? vec3(0.0, 0.0, 1.0) : normalize(vViewPosition));
|
|
7185
|
-
#include <opaque_fragment>`)},a.customProgramCacheKey=()=>"volter-blender-workbench",a}const I=S().finite(),be=$([I,I,I]),vn=$([S().int().nonnegative(),S().int().nonnegative()]),lt={name:E(),domain:W(["POINT","EDGE","FACE","CORNER"])},Dl=ca("type",[P({...lt,type:j("FLOAT2"),data:z($([I,I]))}).strict(),P({...lt,type:j("FLOAT_VECTOR"),data:z(be)}).strict(),P({...lt,type:j("FLOAT_COLOR"),data:z($([I,I,I,I]))}).strict(),P({...lt,type:j("BYTE_COLOR"),data:z($([I,I,I,I]))}).strict(),P({...lt,type:j("QUATERNION"),data:z($([I,I,I,I]))}).strict(),P({...lt,type:j("FLOAT4"),data:z($([I,I,I,I]))}).strict(),P({...lt,type:j("FLOAT4X4"),data:z(z(I).length(16))}).strict(),P({...lt,type:j("INT16_2D"),data:z($([S().int(),S().int()]))}).strict(),P({...lt,type:j("INT32_2D"),data:z($([S().int(),S().int()]))}).strict(),P({...lt,type:j("FLOAT"),data:z(I)}).strict(),P({...lt,type:j("INT"),data:z(S().int())}).strict(),P({...lt,type:j("INT8"),data:z(S().int())}).strict(),P({...lt,type:j("BOOLEAN"),data:z(q())}).strict(),P({...lt,type:j("STRING"),data:z(E())}).strict()]),Cl=P({positions:B(Float32Array),normals:B(Float32Array).nullable(),uv:B(Float32Array).nullable(),uvLayers:z(P({name:E(),data:B(Float32Array)}).strict()).optional(),attributeLayers:z(P({name:E(),data:B(Float32Array)}).strict()).optional(),orco:B(Float32Array).nullable().optional(),indices:B(Uint32Array),groups:z(P({start:S().int().nonnegative(),count:S().int().nonnegative(),materialIndex:S().int().nonnegative()}).strict()),hash:E()}).strict(),kl=P({v:z(be),f:z(z(S().int().nonnegative())),e:z(vn).optional(),edge_order:z(vn).optional(),m:z(S().int().nonnegative()).optional(),s:z(q()).optional(),sharp:z(vn).optional(),seams:z(vn).optional(),creases:z($([I,I,I])).optional(),attributes:z(Dl).optional(),active_uv:E().nullable().optional(),render_uv:E().nullable().optional()}).strict(),$l=P({store:S().int().optional(),revision:S().int(),unchanged:j(!0)}).strict(),Ll=P({co:B(Float64Array),cornerNormal:B(Float32Array).optional(),orco:B(Float32Array).optional(),faceStart:B(Uint32Array),corner:B(Uint32Array),cornerEdge:B(Int32Array),edge:B(Uint32Array),edgeSharp:B(Uint8Array),edgeSeam:B(Uint8Array),edgeCrease:B(Float32Array),material:B(Uint32Array),smooth:B(Uint8Array),vertSelect:B(Uint8Array),vertHide:B(Uint8Array),edgeSelect:B(Uint8Array),edgeHide:B(Uint8Array),faceSelect:B(Uint8Array),faceHide:B(Uint8Array)}).strict(),Vl=P({name:E(),domain:W(["POINT","EDGE","FACE","CORNER"]),type:E(),data:ua(o=>ArrayBuffer.isView(o))}).strict(),jl=P({columns:Ll,attributes:z(Vl),activeUv:E().nullable(),renderUv:E().nullable(),counts:P({verts:S().int().nonnegative(),edges:S().int().nonnegative(),faces:S().int().nonnegative(),corners:S().int().nonnegative()}).strict(),revision:S().int().nonnegative()}).strict(),Bl=jt([Cl,jl,kl,$l]),jo=new Set;function Ul(o){const t=new Blob([o],{type:"image/png"}),n=new Je;let e=!1;n.addEventListener("dispose",()=>{e=!0,n.image?.close?.()});const r=createImageBitmap(t,{imageOrientation:"flipY",premultiplyAlpha:"none"}).then(a=>{if(e){a.close();return}n.image=a,n.needsUpdate=!0,vt()}).finally(()=>{jo.delete(r)});return jo.add(r),r.catch(()=>{}),{texture:n,ready:r}}function Wl(o,t,n,e){const r=new Tn(o,t,n,Pn,Ke);return r.flipY=!1,r.colorSpace=e==="data"?no:Mt,r.needsUpdate=!0,r}function Hl(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)),r=Math.max(...t.map(s=>s.height)),a=new Uint8Array(e*r*4*t.length),i=Math.max(...t.map(s=>s.number-1001))+1,c=new Float32Array(i*2*4);for(let s=0;s<i;s++)c[s*4]=-1;t.forEach((s,l)=>{const _=s.rgba??(s.rgbaBase64?Un(s.rgbaBase64):void 0);if(!_)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let d=0;d<s.height;d++)a.set(_.subarray(d*s.width*4,(d+1)*s.width*4),(l*r+d)*e*4);const h=s.number-1001;c[h*4]=l,c.set([0,0,s.width/e,s.height/r],(i+h)*4)});const u=new Qe(a,e,r,t.length);u.colorSpace=n==="data"?no:Mt,u.magFilter=Lt,u.minFilter=Jo,u.generateMipmaps=!0,u.needsUpdate=!0;const f=new Tn(c,i,2,Pn,Yo);return f.magFilter=f.minFilter=jn,f.needsUpdate=!0,{tiles:u,map:f,frame:t}}const ql=P({width:S().int().positive(),height:S().int().positive(),revision:S().int().nonnegative(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional(),colorspace:W(["sRGB","data"]).optional(),tiles:z(P({number:S().int().min(1001),width:S().int().positive(),height:S().int().positive(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional()}).strict()).optional()}).strict(),Gl=P({revision:S().int().nonnegative(),png:B(Uint8Array).optional(),pngBase64:E().optional()}).strict(),Xl=jt([ql,Gl]),kn=P({image:P({name:E(),revision:S().int().nonnegative()}).strict(),extension:W(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:E(),tint:$([I,I,I]).optional()}).strict(),Yl=P({name:E(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:ol.optional(),normal_texture:kn.optional(),normal_strength:I.default(1),normal_space:W(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:kn.optional(),roughness_texture:kn.optional(),emission:P({color:$([I,I,I]),strength:I}).strict().optional(),graph:Nr.optional(),viewport:P({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Zl=P({session:E(),revision:S().int().nonnegative(),volumes:_t(E(),me).default({}),lights:_t(E(),mr).default({}),world:yr.nullable().default(null),meshes:_t(E(),Bl),materials:_t(E(),Yl),images:_t(E(),Xl).default({}),objects:z(P({id:E(),name:E(),type:W(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:E().nullable(),volume:E().nullable().optional(),light:E().nullable().optional(),materials:z(E().nullable()),matrix:z($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:E().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:E().optional()}).strict()),active:E().nullable(),mode:E(),cameras:_t(E(),_t(E(),ne())).default({}),warnings:z(E()).default([]),updated:z(E()).default([]),frame:S().int().default(0),armatures:_t(E(),ha).default({}),weights:sl.nullable().default(null),cursor:ml.optional(),camera_view:P({scene_camera:E().nullable(),view_layer_cameras:z(E()),aspect:S().finite().positive()}).optional(),light_distances:_t(E(),$([S().finite(),S().finite()])).default({}),empties:_t(E(),xl).default({}),view:P({location:$([S(),S(),S()]),rotation:$([S(),S(),S(),S()]),distance:S().finite(),perspective:W(["PERSP","ORTHO","CAMERA"]),lens:S().finite().positive().default(50)}).nullable().optional(),subject:P({frame:S().int(),body:E(),markers:z($([S().int(),E()]))}).optional(),units:P({system:W(["NONE","METRIC","IMPERIAL"]),scale_length:S().finite()}).optional()}).strict();function Ql(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 Kl={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 co{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 ro,this.armatureOverlay=new Aa,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.cameraViewZoom=Pl,this.cameraViewPan=Al,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}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=ma(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(r=>r.id===n)?.name??null;return null}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,r,a]=t.rotation,i=new gt(e,r,a,n),c=new x(...t.location).applyMatrix4(this.root.matrix),u=f=>f.applyQuaternion(i).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}}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,i=new gt;return r.decompose(a,i,new x),{location:a.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,n,e,r){const a=this.frame,i=Lo.safeParse(a?.cameras[t]);return!a?.camera_view||!i.success?null:Sl(i.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=Ql(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=Kl[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,i=[...t.children];t.removeFromParent();for(const c of i)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,i=>r.has(i));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 i=(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?i:i[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 i=this.workbenchMaterials.get(a);return i||(i=Fl(r,n),this.workbenchMaterials.set(a,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Do(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 s=new yn().setFromObject(f);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const a=e.reduce((u,f)=>u.union(f),new yn).getBoundingSphere(new Ge),i=n?new Xe().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,c=i?e.flatMap(u=>Tr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Pr(u,c,e):gr(u,a.center,a.radius)}applyOverlays(t){const n=i=>{const c=t.objects.find(u=>u.name===i);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(i=>i.name===t.weights?.object)?.id??""):void 0,a=this.weightOverlay.apply(t.weights,r??null,t.weights?n(t.weights.object):null);return a!==null&&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=Lo.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,i=r.width||a?.width||0,c=r.height||a?.height||0;return(i===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:i,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=Zl.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 s=new Set([f.id]);let l=f.parent;for(;l!==null;){if(s.has(l))throw new Error("Runtime parent cycle");s.add(l);const _=a.get(l);if(!_)throw new Error(`Missing runtime parent ${l}`);l=_.parent}}const i=new Map,c=new Map;try{for(const[f,s]of Object.entries(e.volumes)){const l=JSON.stringify(s);this.frame?.session===e.session&&this.volumes.get(f)?.signature===l||c.set(f,{signature:l,mesh:Ar(s)})}for(const[f,s]of Object.entries(e.meshes)){if("unchanged"in s){if(this.frame?.session===e.session&&this.meshes.has(f))continue;throw new Error(`${Sa}: the presenter does not hold runtime mesh ${f} (store ${s.store}, revision ${s.revision})`)}const l="hash"in s,_="columns"in s,h=_?`revision:${s.revision}`:l?s.hash:JSON.stringify(s);this.frame?.session===e.session&&this.meshes.get(f)?.signature===h||i.set(f,{signature:h,geometry:_?Wn(La({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},h)):l?Wn(s):Va(s)})}}catch(f){for(const s of i.values())s.geometry.dispose();for(const{mesh:s}of c.values())s.geometry.dispose(),s.material.dispose();throw f}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[f,s]of c){const l=this.volumes.get(f)?.mesh;l&&(l.removeFromParent(),l.geometry.dispose(),l.material.dispose()),this.volumes.set(f,s)}for(const[f,s]of i)this.meshes.get(f)?.geometry.dispose(),this.meshes.set(f,s),this.geometryBuilds++;for(const[f,s]of Object.entries(e.images)){const l=this.textures.get(f);if("width"in s){const m=s.rgba??(s.rgbaBase64?Un(s.rgbaBase64):void 0);if(!m)throw new Error(`Runtime image ${f} carries no raster`);const p=s.tiles?Hl(f,s.tiles,s.colorspace??"sRGB"):void 0;if(l?.udim&&(l.udim.tiles.dispose(),l.udim.map.dispose(),delete l.udim),l&&l.width===s.width&&l.height===s.height){const v=l.texture.image;if(v.data){v.data.set(m),l.texture.needsUpdate=!0,l.revision=s.revision,p&&(l.udim=p);continue}}l?.texture.dispose(),this.textures.set(f,{texture:Wl(m,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...p?{udim:p}:{}});continue}const _=s.png??(s.pngBase64?Un(s.pngBase64):void 0);if(!_)throw new Error(`Runtime image ${f} carries no bytes`);l?.texture.dispose(),l?.udim?.tiles.dispose(),l?.udim?.map.dispose();const{texture:h,ready:d}=Ul(_);h.colorSpace=Mt,this.textures.set(f,{texture:h,ready:d,width:0,height:0,revision:s.revision,png:_.slice()})}for(const[f,s]of Object.entries(e.materials)){const l=this.materials.get(f)??new ln;l.name=s.name;const _=s.texture?.tint;s.texture!==void 0?l.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):l.color.setRGB(s.color[0],s.color[1],s.color[2],ft),l.opacity=s.color[3];const h=l.opacity<1||s.graph!==void 0&&Rr(s.graph);l.transparent!==h&&(l.transparent=h,l.needsUpdate=!0),l.roughness=s.roughness,l.metalness=s.metallic,l.transmission=s.transmission,l.ior=s.ior,io(l,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const d=s.normal_texture?.image.name;if(d===void 0)l.normalMap&&(this.textureSamplers.delete(`${f}:normal`),l.normalMap=null,l.needsUpdate=!0);else{const b=this.textures.get(d);if(!b)throw new Error(`${Qt}: missing normal image ${d}`);const w=this.textureSamplers.get(`${f}:normal`,b.texture,s.normal_texture.extension,b.ready,s.normal_texture.uv);l.normalMap!==w&&(l.normalMap=w,l.needsUpdate=!0);const R=s.normal_space==="OBJECT"?Ye:Ze;l.normalMapType!==R&&(l.normalMapType=R,l.needsUpdate=!0),l.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(l.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],ft),l.emissiveIntensity=s.emission.strength):(l.emissive.setRGB(0,0,0),l.emissiveIntensity=1);const m=s.roughness_texture?.image.name??null;if(m===null)this.roughnessTextureNames.has(f)&&(this.textureSamplers.delete(`${f}:roughness`),l.roughnessMap=null,this.roughnessTextureNames.delete(f),l.needsUpdate=!0);else{const b=this.textures.get(m);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${m} (revision ${s.roughness_texture.image.revision})`);const w=this.textureSamplers.get(`${f}:roughness`,b.texture,s.roughness_texture.extension,b.ready,s.roughness_texture.uv);l.roughnessMap!==w&&(l.roughnessMap=w,this.roughnessTextureNames.set(f,m),l.needsUpdate=!0)}const p=s.texture?.image.name??null;if(p===null)this.textureNames.has(f)&&(this.textureSamplers.delete(`${f}:color`),l.map=null,this.textureNames.delete(f),l.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${p} (revision ${s.texture.image.revision})`);const w=this.textureSamplers.get(`${f}:color`,b.texture,s.texture.extension,b.ready,s.texture.uv);l.map!==w&&(l.map=w,this.textureNames.set(f,p),l.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,g=new Set;qr(l,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),A=b.closest?jn:Lt,O=b.closest?jn:b.mipmap?Jo:Lt;return(T.magFilter!==A||T.minFilter!==O)&&(T.magFilter=A,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,l)}for(const f of e.objects){let s=this.objects.get(f.id);const l=f.volume?this.volumes.get(f.volume).mesh:null;if((!s||(l?s!==l:!!s.isMesh!=(f.mesh!==null)))&&(s?.removeFromParent(),s=l??(f.mesh!==null?new Tt(this.meshes.get(f.mesh).geometry,this.fallback):new Go),this.objects.set(f.id,s)),s.name=f.name,f.type==="CAMERA"||f.type==="LIGHT"||f.type==="EMPTY"?s.userData.volterOwnOverlay=!0:delete s.userData.volterOwnOverlay,s.matrixAutoUpdate=!1,s.matrix.set(...f.matrix.flat()),f.parent){const _=new X().set(...a.get(f.parent).matrix.flat());s.matrix.premultiply(_.invert())}if(s.matrix.decompose(s.position,s.quaternion,s.scale),f.texspace?s.userData.blenderTexspace=f.texspace:delete s.userData.blenderTexspace,f.default_color!==void 0?s.userData.blenderDefaultColor=f.default_color:delete s.userData.blenderDefaultColor,f.mesh!==null){const _=s;_.geometry=this.meshes.get(f.mesh).geometry,_.material=f.materials.length?f.materials.map(h=>h===null?this.fallback:this.materials.get(h)):this.fallback,Zr(_)}if(f.light){const _=this.lights.get(f.light)??null,h=vr(e.lights[f.light],_);_&&_!==h&&(_.removeFromParent(),_.dispose()),h.parent!==s&&s.add(h),h.userData.volterOwnOverlay=!0,xr(h,s),this.lights.set(f.light,h)}}for(const f of e.objects){const s=this.objects.get(f.id),l=f.parent===null?this.root:this.objects.get(f.parent);s.parent!==l&&l.add(s)}for(const[f,s]of this.objects)r.has(f)||(s.removeFromParent(),this.objects.delete(f));for(const[f,s]of this.volumes)e.volumes[f]||(s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.volumes.delete(f));for(const[f,s]of this.meshes)e.meshes[f]||(s.geometry.dispose(),this.meshes.delete(f));for(const[f,s]of this.materials)if(!e.materials[f]){for(const l of["normal","roughness","color"])this.textureSamplers.delete(`${f}:${l}`);for(const l of this.graphSamplers.get(f)??[])this.textureSamplers.delete(l);this.graphSamplers.delete(f),s.dispose(),this.materials.delete(f)}for(const[f,s]of this.lights)e.lights[f]||(s.removeFromParent(),s.dispose(),this.lights.delete(f));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{}},this.worldKey=JSON.stringify(e.world??null);const u=this.applyOverlays(e);u.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...u]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const f of[...this.frameListeners])f();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}captureSnapshot(){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[u,{signature:f,geometry:s}]of this.meshes){const l=d=>{const m=s.getAttribute(d);if(!m)return null;if(!(m instanceof it))throw new Error(`Blender capture cannot copy interleaved ${d}`);return new Float32Array(m.array)},_=l("position");if(!_)throw new Error(`Blender capture mesh ${u} has no positions`);const h=s.getIndex();n.meshes[u]={hash:f,positions:_,normals:l("normal"),uv:l("uv"),uvLayers:Object.entries(s.userData.blenderUvChannels??{}).map(([d,m])=>{const p=l(`uv${m}`);if(!p)throw new Error(`Blender capture mesh ${u} is missing UV layer ${d}`);return{name:d,data:p}}),orco:s.userData.blenderOrcoFromDoor?l("blenderOrco"):null,attributeLayers:(s.userData.blenderAttributes??[]).map(d=>{const m=l(Vt(d));if(!m)throw new Error(`Blender capture mesh ${u} is missing attribute ${d}`);return{name:d,data:m}}),indices:h?new Uint32Array(h.array):Uint32Array.from({length:_.length/3},(d,m)=>m),groups:s.groups.map(d=>({start:d.start,count:d.count,materialIndex:d.materialIndex??0}))}}for(const[u,{signature:f}]of this.volumes)n.volumes[u]=me.parse(JSON.parse(f));const e=new Set(Object.values(n.materials).flatMap(u=>[u.texture?.image.name,u.roughness_texture?.image.name,u.normal_texture?.image.name,...Object.values(u.graph?.nodes??{}).map(f=>f.props.image?.name)].filter(f=>f!==void 0)));for(const u of e){const f=this.textures.get(u);if(!f)throw new Error(`Blender capture image ${u} is not resident`);if(f.png)n.images[u]={revision:f.revision,png:f.png.slice()};else{const s=f.texture.image?.data;if(!(s instanceof Uint8Array))throw new Error(`Blender capture image ${u} has no resident raster`);n.images[u]={revision:f.revision,width:f.width,height:f.height,rgba:s.slice(),colorspace:f.texture.colorSpace===no?"data":"sRGB",...f.udim?{tiles:f.udim.frame}:{}}}}const r=this.createWorldVolumePass(),a=new co;a.photograph=!0;let i=!1;const c=()=>{i||(i=!0,r?.dispose(),a.dispose(),a.root.removeFromParent())};try{a.applyFrame(n),this.root.updateWorldMatrix(!0,!1),a.root.matrix.copy(this.root.matrixWorld),a.root.updateMatrixWorld(!0)}catch(u){throw c(),u}return{effect:r,root:a.root,session:t.session,revision:t.revision,prepare:u=>{if(i)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,u)},dispose:c}}createWorldVolumePass(){const t=Do(this.frame?.world);return t?new il(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const 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[i,c]of Object.entries(a))typeof c=="object"&&c!==null&&!("unchanged"in c)&&this.submittedMeshes.set(i,c);for(const i of[...this.submittedMeshes.keys()])i in a||this.submittedMeshes.delete(i);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){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 ii=new co;function ye(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function $n(o){const t=ye(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function Jl(o){const t=ye(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ti(o){return new X().set(...o.flat())}function Bo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class ni{#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,i)=>a+i.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,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 i=!1;for(const l of e.rigs){if(!l.object||!l.armature||!l.skinIndexBase64||!l.skinWeightBase64){l.reason&&r.push(l.reason);continue}a.add(l.object);const _=Bo(l,e.frame);if(this.#n.get(l.object)?.signature===_)continue;const h=this.#d(t,l,e.frame,r);h&&(this.#n.get(l.object)?.skeleton.dispose(),this.#n.set(l.object,h),i=!0)}for(const[l,_]of[...this.#n])a.has(l)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(l),i=!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||i)&&this.#h(t,c,r);const s=this.#e?.snapshot().playbackState==="playing";c&&!s&&u?.frameCurrent!==c.frameCurrent&&(this.#c(c.frameCurrent),this.#e&&c.fps>0&&this.#e.seek(c.frameCurrent/c.fps)),this.#_=r,this.#f()}#d(t,n,e,r){const a=t.objectForBlenderName(n.object??""),i=t.objectForBlenderName(n.armature??"");if(!a||!i)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 s=0;for(let T=0;T<f.count;T++)s=Math.max(s,f.getX(T));if(s>=n.vertexCount)return r.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=Jl(n.skinIndexBase64??""),_=$n(n.skinWeightBase64??""),h=f.count,d=new Uint16Array(h*4),m=new Float32Array(h*4);for(let T=0;T<h;T++){const A=f.getX(T);for(let O=0;O<4;O++)d[T*4+O]=l[A*4+O]??0,m[T*4+O]=_[A*4+O]??0}u.setAttribute("skinIndex",new ta(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=>ti(T.pose)),b=new Map(n.bones.map((T,A)=>[T.name,A]));n.bones.forEach((T,A)=>{const O=new na;O.name=T.name,v.push(O);const M=T.parent===null?void 0:b.get(T.parent);(M===void 0?g[A].clone():g[M].clone().invert().multiply(g[A])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),i.add(p);const w=new oa(u,c.material);w.name=c.name,w.matrixAutoUpdate=!1,w.matrix.copy(c.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=c.userData,w.frustumCulled=!1,t.replacePresentedObject(c,w),t.root.updateMatrixWorld(!0);const R=new ea(v);return w.bind(R,w.matrixWorld.clone()),n.constrainedBones?.length&&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:Bo(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const r=n.armature?t.objectForBlenderName(n.armature):null;if(!r)return;const a=new Map;for(const l of this.#n.values())if(l.armature===n.armature)for(const _ of l.bones)a.set(_.name,_);const i=[],c=new Set;for(const l of n.tracks){const _=a.get(l.bone);if(!_){c.add(l.bone);continue}const h=$n(l.timeBase64),d=$n(l.valueBase64),m=`${_.uuid}.${l.property}`;i.push(l.property==="quaternion"?new aa(m,Array.from(h),Array.from(d)):new ra(m,Array.from(h),Array.from(d)))}if(c.size&&e.push(`${n.action} animates ${[...c].join(", ")}, which this binding has no bone for.`),!i.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,f=new la(r),s=f.clipAction(new ia(n.action??"action",u,i));s.setLoop(sa,Number.POSITIVE_INFINITY),s.play(),this.#o=f,this.#a=s,this.#c(n.frameCurrent),this.#m()}#c(t){const n=this.#t;if(!n||!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const e=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#i=e;const 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 _a(`bpy.data.scenes[${JSON.stringify(e)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const i=this.#t,c=i?.fps||24;return{start:(i?.frameStart??1)/c,end:(i?.frameEnd??250)/c,fps:c}},seek:i=>this.seekSeconds(i)}),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 we=new ni;function si(o){return we.subscribe(o)}function fi(){return we.version}export{we as a,fi as b,ii as c,si as s};
|
|
7185
|
+
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const I=S().finite(),be=$([I,I,I]),vn=$([S().int().nonnegative(),S().int().nonnegative()]),lt={name:E(),domain:W(["POINT","EDGE","FACE","CORNER"])},Dl=ca("type",[P({...lt,type:j("FLOAT2"),data:F($([I,I]))}).strict(),P({...lt,type:j("FLOAT_VECTOR"),data:F(be)}).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($([S().int(),S().int()]))}).strict(),P({...lt,type:j("INT32_2D"),data:F($([S().int(),S().int()]))}).strict(),P({...lt,type:j("FLOAT"),data:F(I)}).strict(),P({...lt,type:j("INT"),data:F(S().int())}).strict(),P({...lt,type:j("INT8"),data:F(S().int())}).strict(),P({...lt,type:j("BOOLEAN"),data:F(q())}).strict(),P({...lt,type:j("STRING"),data:F(E())}).strict()]),Cl=P({positions:B(Float32Array),normals:B(Float32Array).nullable(),uv:B(Float32Array).nullable(),uvLayers:F(P({name:E(),data:B(Float32Array)}).strict()).optional(),attributeLayers:F(P({name:E(),data:B(Float32Array)}).strict()).optional(),orco:B(Float32Array).nullable().optional(),indices:B(Uint32Array),groups:F(P({start:S().int().nonnegative(),count:S().int().nonnegative(),materialIndex:S().int().nonnegative()}).strict()),hash:E()}).strict(),kl=P({v:F(be),f:F(F(S().int().nonnegative())),e:F(vn).optional(),edge_order:F(vn).optional(),m:F(S().int().nonnegative()).optional(),s:F(q()).optional(),sharp:F(vn).optional(),seams:F(vn).optional(),creases:F($([I,I,I])).optional(),attributes:F(Dl).optional(),active_uv:E().nullable().optional(),render_uv:E().nullable().optional()}).strict(),$l=P({store:S().int().optional(),revision:S().int(),unchanged:j(!0)}).strict(),Ll=P({co:B(Float64Array),cornerNormal:B(Float32Array).optional(),orco:B(Float32Array).optional(),faceStart:B(Uint32Array),corner:B(Uint32Array),cornerEdge:B(Int32Array),edge:B(Uint32Array),edgeSharp:B(Uint8Array),edgeSeam:B(Uint8Array),edgeCrease:B(Float32Array),material:B(Uint32Array),smooth:B(Uint8Array),vertSelect:B(Uint8Array),vertHide:B(Uint8Array),edgeSelect:B(Uint8Array),edgeHide:B(Uint8Array),faceSelect:B(Uint8Array),faceHide:B(Uint8Array)}).strict(),Vl=P({name:E(),domain:W(["POINT","EDGE","FACE","CORNER"]),type:E(),data:ua(o=>ArrayBuffer.isView(o))}).strict(),jl=P({columns:Ll,attributes:F(Vl),activeUv:E().nullable(),renderUv:E().nullable(),counts:P({verts:S().int().nonnegative(),edges:S().int().nonnegative(),faces:S().int().nonnegative(),corners:S().int().nonnegative()}).strict(),revision:S().int().nonnegative()}).strict(),Bl=jt([Cl,jl,kl,$l]),jo=new Set;function Ul(o){const t=new Blob([o],{type:"image/png"}),n=new Je;let e=!1;n.addEventListener("dispose",()=>{e=!0,n.image?.close?.()});const a=createImageBitmap(t,{imageOrientation:"flipY",premultiplyAlpha:"none"}).then(r=>{if(e){r.close();return}n.image=r,n.needsUpdate=!0,vt()}).finally(()=>{jo.delete(a)});return jo.add(a),a.catch(()=>{}),{texture:n,ready:a}}function Wl(o,t,n,e){const a=new Pn(o,t,n,An,Ke);return a.flipY=!1,a.colorSpace=e==="data"?oo:Mt,a.needsUpdate=!0,a}function Hl(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(s=>s.width)),a=Math.max(...t.map(s=>s.height)),r=new Uint8Array(e*a*4*t.length),l=Math.max(...t.map(s=>s.number-1001))+1,c=new Float32Array(l*2*4);for(let s=0;s<l;s++)c[s*4]=-1;t.forEach((s,i)=>{const _=s.rgba??(s.rgbaBase64?Wn(s.rgbaBase64):void 0);if(!_)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let h=0;h<s.height;h++)r.set(_.subarray(h*s.width*4,(h+1)*s.width*4),(i*a+h)*e*4);const d=s.number-1001;c[d*4]=i,c.set([0,0,s.width/e,s.height/a],(l+d)*4)});const u=new Qe(r,e,a,t.length);u.colorSpace=n==="data"?oo:Mt,u.magFilter=Lt,u.minFilter=Jo,u.generateMipmaps=!0,u.needsUpdate=!0;const f=new Pn(c,l,2,An,Yo);return f.magFilter=f.minFilter=Bn,f.needsUpdate=!0,{tiles:u,map:f,frame:t}}const ql=P({width:S().int().positive(),height:S().int().positive(),revision:S().int().nonnegative(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional(),colorspace:W(["sRGB","data"]).optional(),tiles:F(P({number:S().int().min(1001),width:S().int().positive(),height:S().int().positive(),rgba:B(Uint8Array).optional(),rgbaBase64:E().optional()}).strict()).optional()}).strict(),Gl=P({revision:S().int().nonnegative(),png:B(Uint8Array).optional(),pngBase64:E().optional()}).strict(),Xl=jt([ql,Gl]),$n=P({image:P({name:E(),revision:S().int().nonnegative()}).strict(),extension:W(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:E(),tint:$([I,I,I]).optional()}).strict(),Yl=P({name:E(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:ol.optional(),normal_texture:$n.optional(),normal_strength:I.default(1),normal_space:W(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:$n.optional(),roughness_texture:$n.optional(),emission:P({color:$([I,I,I]),strength:I}).strict().optional(),graph:Nr.optional(),viewport:P({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Zl=P({session:E(),revision:S().int().nonnegative(),volumes:_t(E(),me).default({}),lights:_t(E(),mr).default({}),world:yr.nullable().default(null),meshes:_t(E(),Bl),materials:_t(E(),Yl),images:_t(E(),Xl).default({}),objects:F(P({id:E(),name:E(),type:W(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:E().nullable(),volume:E().nullable().optional(),light:E().nullable().optional(),materials:F(E().nullable()),matrix:F($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:E().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:E().optional()}).strict()),active:E().nullable(),mode:E(),cameras:_t(E(),_t(E(),ne())).default({}),warnings:F(E()).default([]),updated:F(E()).default([]),frame:S().int().default(0),armatures:_t(E(),ha).default({}),weights:sl.nullable().default(null),cursor:ml.optional(),camera_view:P({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:P({location:$([S(),S(),S()]),rotation:$([S(),S(),S(),S()]),distance:S().finite(),perspective:W(["PERSP","ORTHO","CAMERA"]),lens:S().finite().positive().default(50)}).nullable().optional(),subject:P({frame:S().int(),body:E(),markers:F($([S().int(),E()]))}).optional(),units:P({system:W(["NONE","METRIC","IMPERIAL"]),scale_length:S().finite()}).optional()}).strict();function Ql(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 Kl={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class Tn{constructor(){this.root=new ot,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new br,this.world=new lo,this.armatureOverlay=new Aa,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.cameraViewZoom=Pl,this.cameraViewPan=Al,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}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=ma(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(a=>a.id===n)?.name??null;return null}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,a,r]=t.rotation,l=new gt(e,a,r,n),c=new x(...t.location).applyMatrix4(this.root.matrix),u=f=>f.applyQuaternion(l).applyMatrix4(this.root.matrix).normalize();return{target:c.toArray(),direction:u(new x(0,0,1)).toArray(),up:u(new x(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new X().copy(this.root.matrix).invert(),a=new X().compose(new x(...t),new gt(...n),new x(1,1,1)).premultiply(e),r=new x,l=new gt;return a.decompose(r,l,new x),{location:r.toArray(),rotation:[l.w,l.x,l.y,l.z]}}cameraView(t,n,e,a){const r=this.frame,l=Lo.safeParse(r?.cameras[t]);return!r?.camera_view||!l.success?null:Sl(l.data,this.root.matrix,n,e,a,r.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const e=t??n.frame,a=Ql(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=Kl[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([c])=>c*r>a)??e[e.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(e=>e.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[e,a]of this.objects)if(a===t){const r=t.parent,l=[...t.children];t.removeFromParent();for(const c of l)n.add(c);r?.add(n),this.objects.set(e,n);return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,e){const a=new Set(this.objects.values()),r=this.cursorOverlay.placementAt(t,n,e,this.root,l=>a.has(l));return r!==null&&(this.cursorOverlay.show(r),vt()),r}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(a=>a.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(vt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),vt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const a=this.objects.get(e.id);if(!a?.isMesh)continue;const l=(e.materials.length?e.materials:[null]).map(c=>{const u=c===null?this.fallback:this.materials.get(c)??this.fallback;return t?this.workbenchFor(c,u.side,n):u});a.material=e.materials.length?l:l[0]}for(const[e,a]of this.workbenchMaterials)n.has(e)||(a.dispose(),this.workbenchMaterials.delete(e))}workbenchFor(t,n,e){const a=(t!==null?this.frame?.materials[t]?.viewport:void 0)??El,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let l=this.workbenchMaterials.get(r);return l||(l=zl(a,n),this.workbenchMaterials.set(r,l)),l}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Do(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])al(r,e);this.rendered=t,this.lighting.setRendered(t);const a=t&&n?this.worldKeyFor(n):null;t?(this.capturing||a!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:a,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await hr(),await Promise.all([...this.textures.values()].map(r=>r.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const e=[];for(const u of this.objects.values()){const f=u;if(f.isMesh&&(f.castShadow=t,f.receiveShadow=t,t&&f.visible)){const s=new yn().setFromObject(f);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,f)=>u.union(f),new yn).getBoundingSphere(new Ge),l=n?new Xe().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,c=l?e.flatMap(u=>Tr(u,l)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Pr(u,c,e):gr(u,r.center,r.radius)}applyOverlays(t){const n=l=>{const c=t.objects.find(u=>u.name===l);return c===void 0?null:new X().set(...c.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],a=t.weights?this.objects.get(t.objects.find(l=>l.name===t.weights?.object)?.id??""):void 0,r=this.weightOverlay.apply(t.weights,a??null,t.weights?n(t.weights.object):null);return r!==null&&e.push(r),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),e}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),vt())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=Lo.safeParse(a);r.success&&(n[e]=r.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(e=>e.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:e=>{const a=t.objects.find(r=>r.name===e);return a?this.objects.get(a.id)??null:null},image:e=>{const a=this.textures.get(e);if(!a)return null;const r=a.texture.image,l=a.width||r?.width||0,c=a.height||r?.height||0;return(l===0||c===0)&&a.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),a.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),vt()},()=>this.awaitedImages.delete(e))),{texture:a.texture,width:l,height:c}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const e=this.lights.get(t.light);e&&(e.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.capturing,this.weightOverlay.group.visible=!this.capturing,this.cursorOverlay.group.visible=!this.capturing;for(const t of[this.extrasOverlay.cameras,this.extrasOverlay.lights,this.extrasOverlay.empties])t.visible=!this.capturing}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=Zl.parse(t);if(this.retiredSessions.has(e.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===e.session&&e.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const a=new Set(e.objects.map(f=>f.id));if(a.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const r=new Map(e.objects.map(f=>[f.id,f]));for(const f of e.objects){if(f.mesh!==null&&!e.meshes[f.mesh])throw new Error(`Missing runtime mesh ${f.mesh}`);if(f.volume&&(!e.volumes[f.volume]||f.mesh!==null))throw new Error(`Invalid runtime volume ${f.volume}`);if(f.light&&(!e.lights[f.light]||f.mesh!==null))throw new Error(`Invalid runtime light ${f.light}`);for(const _ of f.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const s=new Set([f.id]);let i=f.parent;for(;i!==null;){if(s.has(i))throw new Error("Runtime parent cycle");s.add(i);const _=r.get(i);if(!_)throw new Error(`Missing runtime parent ${i}`);i=_.parent}}const l=new Map,c=new Map;try{for(const[f,s]of Object.entries(e.volumes)){const i=JSON.stringify(s);this.frame?.session===e.session&&this.volumes.get(f)?.signature===i||c.set(f,{signature:i,mesh:Ar(s)})}for(const[f,s]of Object.entries(e.meshes)){if("unchanged"in s){if(this.frame?.session===e.session&&this.meshes.has(f))continue;throw new Error(`${Sa}: the presenter does not hold runtime mesh ${f} (store ${s.store}, revision ${s.revision})`)}const i="hash"in s,_="columns"in s,d=_?`revision:${s.revision}`:i?s.hash:JSON.stringify(s);this.frame?.session===e.session&&this.meshes.get(f)?.signature===d||l.set(f,{signature:d,geometry:_?Hn(La({...s.columns,attributes:s.attributes,activeUv:s.activeUv,renderUv:s.renderUv},d)):i?Hn(s):Va(s)})}}catch(f){for(const s of l.values())s.geometry.dispose();for(const{mesh:s}of c.values())s.geometry.dispose(),s.material.dispose();throw f}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[f,s]of c){const i=this.volumes.get(f)?.mesh;i&&(i.removeFromParent(),i.geometry.dispose(),i.material.dispose()),this.volumes.set(f,s)}for(const[f,s]of l)this.meshes.get(f)?.geometry.dispose(),this.meshes.set(f,s),this.geometryBuilds++;for(const[f,s]of Object.entries(e.images)){const i=this.textures.get(f);if("width"in s){const m=s.rgba??(s.rgbaBase64?Wn(s.rgbaBase64):void 0);if(!m)throw new Error(`Runtime image ${f} carries no raster`);const p=s.tiles?Hl(f,s.tiles,s.colorspace??"sRGB"):void 0;if(i?.udim&&(i.udim.tiles.dispose(),i.udim.map.dispose(),delete i.udim),i&&i.width===s.width&&i.height===s.height){const v=i.texture.image;if(v.data){v.data.set(m),i.texture.needsUpdate=!0,i.revision=s.revision,p&&(i.udim=p);continue}}i?.texture.dispose(),this.textures.set(f,{texture:Wl(m,s.width,s.height,s.colorspace??"sRGB"),width:s.width,height:s.height,revision:s.revision,...p?{udim:p}:{}});continue}const _=s.png??(s.pngBase64?Wn(s.pngBase64):void 0);if(!_)throw new Error(`Runtime image ${f} carries no bytes`);i?.texture.dispose(),i?.udim?.tiles.dispose(),i?.udim?.map.dispose();const{texture:d,ready:h}=Ul(_);d.colorSpace=Mt,this.textures.set(f,{texture:d,ready:h,width:0,height:0,revision:s.revision,png:_.slice()})}for(const[f,s]of Object.entries(e.materials)){const i=this.materials.get(f)??new ln;i.name=s.name;const _=s.texture?.tint;s.texture!==void 0?i.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):i.color.setRGB(s.color[0],s.color[1],s.color[2],ft),i.opacity=s.color[3];const d=i.opacity<1||s.graph!==void 0&&Rr(s.graph);i.transparent!==d&&(i.transparent=d,i.needsUpdate=!0),i.roughness=s.roughness,i.metalness=s.metallic,i.transmission=s.transmission,i.ior=s.ior,so(i,s.physical,{map:s.texture?.extension==="CLIP",roughness:s.roughness_texture?.extension==="CLIP",normal:s.normal_texture?.extension==="CLIP"});const h=s.normal_texture?.image.name;if(h===void 0)i.normalMap&&(this.textureSamplers.delete(`${f}:normal`),i.normalMap=null,i.needsUpdate=!0);else{const b=this.textures.get(h);if(!b)throw new Error(`${Qt}: missing normal image ${h}`);const w=this.textureSamplers.get(`${f}:normal`,b.texture,s.normal_texture.extension,b.ready,s.normal_texture.uv);i.normalMap!==w&&(i.normalMap=w,i.needsUpdate=!0);const R=s.normal_space==="OBJECT"?Ye:Ze;i.normalMapType!==R&&(i.normalMapType=R,i.needsUpdate=!0),i.normalScale.set(s.normal_strength,s.normal_strength*(s.normal_directx?-1:1))}s.emission?(i.emissive.setRGB(s.emission.color[0],s.emission.color[1],s.emission.color[2],ft),i.emissiveIntensity=s.emission.strength):(i.emissive.setRGB(0,0,0),i.emissiveIntensity=1);const m=s.roughness_texture?.image.name??null;if(m===null)this.roughnessTextureNames.has(f)&&(this.textureSamplers.delete(`${f}:roughness`),i.roughnessMap=null,this.roughnessTextureNames.delete(f),i.needsUpdate=!0);else{const b=this.textures.get(m);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${m} (revision ${s.roughness_texture.image.revision})`);const w=this.textureSamplers.get(`${f}:roughness`,b.texture,s.roughness_texture.extension,b.ready,s.roughness_texture.uv);i.roughnessMap!==w&&(i.roughnessMap=w,this.roughnessTextureNames.set(f,m),i.needsUpdate=!0)}const p=s.texture?.image.name??null;if(p===null)this.textureNames.has(f)&&(this.textureSamplers.delete(`${f}:color`),i.map=null,this.textureNames.delete(f),i.needsUpdate=!0);else{const b=this.textures.get(p);if(!b)throw new Error(`${Qt}: the presenter does not hold runtime image ${p} (revision ${s.texture.image.revision})`);const w=this.textureSamplers.get(`${f}:color`,b.texture,s.texture.extension,b.ready,s.texture.uv);i.map!==w&&(i.map=w,this.textureNames.set(f,p),i.needsUpdate=!0)}const v=s.graph?this.compiledGraph(s.graph):null,g=new Set;qr(i,v,b=>{const w=this.textures.get(b.name);if(!w)throw new Error(`${Qt}: the presenter does not hold runtime image ${b.name} (revision ${b.revision})`);if(b.tiled){if(!w.udim)throw new Error(`${Qt}: runtime image ${b.name} arrived without its UDIM tiles`);return w.udim}const R=`${f}:graph:${b.node}`;g.add(R);const T=this.textureSamplers.get(R,w.texture,b.extension,w.ready),A=b.closest?Bn:Lt,O=b.closest?Bn:b.mipmap?Jo:Lt;return(T.magFilter!==A||T.minFilter!==O)&&(T.magFilter=A,T.minFilter=O,T.needsUpdate=!0),T},this.photograph);for(const b of this.graphSamplers.get(f)??[])g.has(b)||this.textureSamplers.delete(b);this.graphSamplers.set(f,g),this.materials.set(f,i)}for(const f of e.objects){let s=this.objects.get(f.id);const i=f.volume?this.volumes.get(f.volume).mesh:null;if((!s||(i?s!==i:!!s.isMesh!=(f.mesh!==null)))&&(s?.removeFromParent(),s=i??(f.mesh!==null?new Tt(this.meshes.get(f.mesh).geometry,this.fallback):new Go),this.objects.set(f.id,s)),s.name=f.name,f.type==="CAMERA"||f.type==="LIGHT"||f.type==="EMPTY"?s.userData.volterOwnOverlay=!0:delete s.userData.volterOwnOverlay,s.matrixAutoUpdate=!1,s.matrix.set(...f.matrix.flat()),f.parent){const _=new X().set(...r.get(f.parent).matrix.flat());s.matrix.premultiply(_.invert())}if(s.matrix.decompose(s.position,s.quaternion,s.scale),f.texspace?s.userData.blenderTexspace=f.texspace:delete s.userData.blenderTexspace,f.default_color!==void 0?s.userData.blenderDefaultColor=f.default_color:delete s.userData.blenderDefaultColor,f.mesh!==null){const _=s;_.geometry=this.meshes.get(f.mesh).geometry,_.material=f.materials.length?f.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,Zr(_)}if(f.light){const _=this.lights.get(f.light)??null,d=vr(e.lights[f.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==s&&s.add(d),d.userData.volterOwnOverlay=!0,xr(d,s),this.lights.set(f.light,d)}}for(const f of e.objects){const s=this.objects.get(f.id),i=f.parent===null?this.root:this.objects.get(f.parent);s.parent!==i&&i.add(s)}for(const[f,s]of this.objects)a.has(f)||(s.removeFromParent(),this.objects.delete(f));for(const[f,s]of this.volumes)e.volumes[f]||(s.mesh.geometry.dispose(),s.mesh.material.dispose(),this.volumes.delete(f));for(const[f,s]of this.meshes)e.meshes[f]||(s.geometry.dispose(),this.meshes.delete(f));for(const[f,s]of this.materials)if(!e.materials[f]){for(const i of["normal","roughness","color"])this.textureSamplers.delete(`${f}:${i}`);for(const i of this.graphSamplers.get(f)??[])this.textureSamplers.delete(i);this.graphSamplers.delete(f),s.dispose(),this.materials.delete(f)}for(const[f,s]of this.lights)e.lights[f]||(s.removeFromParent(),s.dispose(),this.lights.delete(f));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{}},this.worldKey=JSON.stringify(e.world??null);const u=this.applyOverlays(e);u.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...u]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const f of[...this.frameListeners])f();for(const f of this.followers)try{f.applyFrame(t)}catch{f.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[a,{signature:r,geometry:l}]of this.meshes){const c=s=>{const i=l.getAttribute(s);if(!i)return null;if(!(i instanceof it))throw new Error(`Blender capture cannot copy interleaved ${s}`);return new Float32Array(i.array)},u=c("position");if(!u)throw new Error(`Blender capture mesh ${a} has no positions`);const f=l.getIndex();n.meshes[a]={hash:r,positions:u,normals:c("normal"),uv:c("uv"),uvLayers:Object.entries(l.userData.blenderUvChannels??{}).map(([s,i])=>{const _=c(`uv${i}`);if(!_)throw new Error(`Blender capture mesh ${a} is missing UV layer ${s}`);return{name:s,data:_}}),orco:l.userData.blenderOrcoFromDoor?c("blenderOrco"):null,attributeLayers:(l.userData.blenderAttributes??[]).map(s=>{const i=c(Vt(s));if(!i)throw new Error(`Blender capture mesh ${a} is missing attribute ${s}`);return{name:s,data:i}}),indices:f?new Uint32Array(f.array):Uint32Array.from({length:u.length/3},(s,i)=>i),groups:l.groups.map(s=>({start:s.start,count:s.count,materialIndex:s.materialIndex??0}))}}for(const[a,{signature:r}]of this.volumes)n.volumes[a]=me.parse(JSON.parse(r));const e=new Set(Object.values(n.materials).flatMap(a=>[a.texture?.image.name,a.roughness_texture?.image.name,a.normal_texture?.image.name,...Object.values(a.graph?.nodes??{}).map(r=>r.props.image?.name)].filter(r=>r!==void 0)));for(const a of e){const r=this.textures.get(a);if(!r)throw new Error(`Blender capture image ${a} is not resident`);if(r.png)n.images[a]={revision:r.revision,png:r.png.slice()};else{const l=r.texture.image?.data;if(!(l instanceof Uint8Array))throw new Error(`Blender capture image ${a} has no resident raster`);n.images[a]={revision:r.revision,width:r.width,height:r.height,rgba:l.slice(),colorspace:r.texture.colorSpace===oo?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Tn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t);let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,e=this.createWorldVolumePass(),a=new Tn;a.photograph=!0;let r=!1;const l=()=>{r||(r=!0,e?.dispose(),a.dispose(),a.root.removeFromParent())};try{a.applyFrame(t),this.root.updateWorldMatrix(!0,!1),a.root.matrix.copy(this.root.matrixWorld),a.root.updateMatrixWorld(!0)}catch(c){throw l(),c}return{effect:e,root:a.root,session:n.session,revision:n.revision,prepare:c=>{if(r)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,c)},dispose:l}}createWorldVolumePass(){const t=Do(this.frame?.world);return t?new il(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const a=typeof n.session=="string"?n.session:null;a!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=a);const r=e;for(const[l,c]of Object.entries(r))typeof c=="object"&&c!==null&&!("unchanged"in c)&&this.submittedMeshes.set(l,c);for(const l of[...this.submittedMeshes.keys()])l in r||this.submittedMeshes.delete(l);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const ii=new Tn;function ye(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Ln(o){const t=ye(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function Jl(o){const t=ye(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ti(o){return new X().set(...o.flat())}function Bo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class ni{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,a=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:a,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((r,l)=>r+l.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:this.#i!==null?this.#i:t.clipStart+this.#a.time*t.fps}get playable(){return this.#a!==null}async bind(t,n){this.#r++;const e=await n.rig();if(!e)return;const a=[],r=new Set;let l=!1;for(const i of e.rigs){if(!i.object||!i.armature||!i.skinIndexBase64||!i.skinWeightBase64){i.reason&&a.push(i.reason);continue}r.add(i.object);const _=Bo(i,e.frame);if(this.#n.get(i.object)?.signature===_)continue;const d=this.#d(t,i,e.frame,a);d&&(this.#n.get(i.object)?.skeleton.dispose(),this.#n.set(i.object,d),l=!0)}for(const[i,_]of[...this.#n])r.has(i)||(_.skeleton.dispose(),_.boneRoot.removeFromParent(),this.#n.delete(i),l=!0);this.#r++;const c=await n.clip(),u=this.#t,f=c?.action!==u?.action||c?.tracks.length!==u?.tracks.length||c?.clipStart!==u?.clipStart||c?.clipEnd!==u?.clipEnd;this.#t=c??null,c?.reason&&a.push(c.reason),c&&(f||l)&&this.#h(t,c,a);const s=this.#e?.snapshot().playbackState==="playing";c&&!s&&u?.frameCurrent!==c.frameCurrent&&(this.#c(c.frameCurrent),this.#e&&c.fps>0&&this.#e.seek(c.frameCurrent/c.fps)),this.#_=a,this.#f()}#d(t,n,e,a){const r=t.objectForBlenderName(n.object??""),l=t.objectForBlenderName(n.armature??"");if(!r||!l)return null;const c=r,u=c.geometry;if(!u)return null;const f=u.getAttribute("blenderVertex");if(!f)return a.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let s=0;for(let T=0;T<f.count;T++)s=Math.max(s,f.getX(T));if(s>=n.vertexCount)return a.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${s} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const i=Jl(n.skinIndexBase64??""),_=Ln(n.skinWeightBase64??""),d=f.count,h=new Uint16Array(d*4),m=new Float32Array(d*4);for(let T=0;T<d;T++){const A=f.getX(T);for(let O=0;O<4;O++)h[T*4+O]=i[A*4+O]??0,m[T*4+O]=_[A*4+O]??0}u.setAttribute("skinIndex",new ta(h,4)),u.setAttribute("skinWeight",new bt(m,4));const p=new ot;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ti(T.pose)),b=new Map(n.bones.map((T,A)=>[T.name,A]));n.bones.forEach((T,A)=>{const O=new na;O.name=T.name,v.push(O);const M=T.parent===null?void 0:b.get(T.parent);(M===void 0?g[A].clone():g[M].clone().invert().multiply(g[A])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),l.add(p);const w=new oa(u,c.material);w.name=c.name,w.matrixAutoUpdate=!1,w.matrix.copy(c.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale),w.userData=c.userData,w.frustumCulled=!1,t.replacePresentedObject(c,w),t.root.updateMatrixWorld(!0);const R=new ea(v);return w.bind(R,w.matrixWorld.clone()),n.constrainedBones?.length&&a.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&a.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:w,boneRoot:p,bones:v,skeleton:R,frame:e,signature:Bo(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const a=n.armature?t.objectForBlenderName(n.armature):null;if(!a)return;const r=new Map;for(const i of this.#n.values())if(i.armature===n.armature)for(const _ of i.bones)r.set(_.name,_);const l=[],c=new Set;for(const i of n.tracks){const _=r.get(i.bone);if(!_){c.add(i.bone);continue}const d=Ln(i.timeBase64),h=Ln(i.valueBase64),m=`${_.uuid}.${i.property}`;l.push(i.property==="quaternion"?new aa(m,Array.from(d),Array.from(h)):new ra(m,Array.from(d),Array.from(h)))}if(c.size&&e.push(`${n.action} animates ${[...c].join(", ")}, which this binding has no bone for.`),!l.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,f=new la(a),s=f.clipAction(new ia(n.action??"action",u,l));s.setLoop(sa,Number.POSITIVE_INFINITY),s.play(),this.#o=f,this.#a=s,this.#c(n.frameCurrent),this.#m()}#c(t){const n=this.#t;if(!n||!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const e=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#i=e;const a=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.min(a-1e-4,(e-n.clipStart)/n.fps)),this.#m()}#m(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const e=n.scene;return!e||n.frameCurrent===t||(this.#r++,await _a(`bpy.data.scenes[${JSON.stringify(e)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const l=this.#t,c=l?.fps||24;return{start:(l?.frameStart??1)/c,end:(l?.frameEnd??250)/c,fps:c}},seek:l=>this.seekSeconds(l)}),e=t.onSettled(()=>{this.writeBookmark()}),a=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#l=null};this.#l=a;const r=this.#t;return r&&r.fps>0&&t.seek(r.frameCurrent/r.fps),a}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#l?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const we=new ni;function si(o){return we.subscribe(o)}function fi(){return we.version}export{we as a,fi as b,ii as c,si as s};
|