@volter/game-editor 0.5.117 → 0.5.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUNDLED_NOTICES +22 -22
- package/catalog/entries/blender.json +2 -2
- package/catalog/entries/music.json +2 -2
- package/dist/.vite/manifest.json +2163 -2163
- package/dist/assets/{AssetBudgetPanel-C3ktrntz.js → AssetBudgetPanel-HqXuzq3a.js} +3 -3
- package/dist/assets/{AudioViewer-DZdZAy4A.js → AudioViewer-DQVH0hNK.js} +1 -1
- package/dist/assets/{CanvasBoardDocument-DsCSciSC.js → CanvasBoardDocument-BSu5ZZWY.js} +1 -1
- package/dist/assets/{CanvasSceneViewport-DP0dTNXv.js → CanvasSceneViewport-C5RoaG7I.js} +1 -1
- package/dist/assets/{ColorInput-BN6Sksjk.js → ColorInput-DVD-8awT.js} +1 -1
- package/dist/assets/{ColorPicker-B76LmE6h.js → ColorPicker-BZI7zqQx.js} +1 -1
- package/dist/assets/{EntityModelDocument-hrUqEuvd.js → EntityModelDocument-Bzuj9RRw.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-BhAbBL9x.js → EnvironmentAssetDocument-B8Yx6hdu.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-O0K6MuzG.js → GameplaySessionTimeline-BEbFFHE0.js} +1 -1
- package/dist/assets/{ImageViewer-BBx46cOu.js → ImageViewer-vfZT5nGX.js} +1 -1
- package/dist/assets/InspectorObjectPreview-ZX3qJB89.js +1 -0
- package/dist/assets/{JsonAssetDocument-ZUCXmUBz.js → JsonAssetDocument-Bwvz7zsL.js} +1 -1
- package/dist/assets/{LiveModuleDocument-DuY9SmFp.js → LiveModuleDocument-DYJl03Cs.js} +1 -1
- package/dist/assets/{LutAssetDocument-DjxOl21m.js → LutAssetDocument-D9cd-cAQ.js} +1 -1
- package/dist/assets/{ModelAssetDocument-DwbuSNGD.js → ModelAssetDocument-Bzw9ZSLy.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-CYHVR-Hz.js → NonThreeAuthoringBootstrap-ptbJfPLv.js} +1 -1
- package/dist/assets/{Object3DDocumentToolbar-BDHutCDl.js → Object3DDocumentToolbar-vnVDSoG8.js} +1 -1
- package/dist/assets/Object3DDocumentViewport-_Ta156Nu.js +2 -0
- package/dist/assets/{Object3DPreview-Dr9nj_z2.js → Object3DPreview-B-jygv_z.js} +1 -1
- package/dist/assets/{OnlineAssetDetail-BG5XJ3Un.js → OnlineAssetDetail-Bzu7E1Pr.js} +1 -1
- package/dist/assets/{PlayBar-DUI9-ZXC.js → PlayBar-CSBeiHyp.js} +1 -1
- package/dist/assets/{QuarksAssetDocument-DTiRvQPL.js → QuarksAssetDocument-XTVTfvcn.js} +1 -1
- package/dist/assets/{ReactCanvasControls-XnnzrwCo.js → ReactCanvasControls-CmX1xMIz.js} +1 -1
- package/dist/assets/{RootSelectionOverlay-FMiu-poB.js → RootSelectionOverlay-DMTg_M22.js} +1 -1
- package/dist/assets/{ShaderAssetDocument-4tRvE91q.js → ShaderAssetDocument-BD-gA9si.js} +1 -1
- package/dist/assets/{ShadowEditor-BpVAEirI.js → ShadowEditor-DQlwf09O.js} +1 -1
- package/dist/assets/{SourceAssetViewer-3P0858z5.js → SourceAssetViewer-CE0AbdsH.js} +1 -1
- package/dist/assets/{StageHost-7UErMg6u.js → StageHost-D94S-LXy.js} +2 -2
- package/dist/assets/{StoryPreviewMount-BBlVAlRY.js → StoryPreviewMount-CCFugHBf.js} +1 -1
- package/dist/assets/{ThreeBoardDocument-DK53_YAX.js → ThreeBoardDocument-Dw8kQu3e.js} +2 -2
- package/dist/assets/{ThreeIsolationSceneContent-qdUEzAND.js → ThreeIsolationSceneContent-BUOG6DR0.js} +1 -1
- package/dist/assets/{ToolObject3DPreview-DsWlZd8B.js → ToolObject3DPreview-DXn3BZXl.js} +1 -1
- package/dist/assets/{Toolbar-whqYcmiS.js → Toolbar-CKfCB7C5.js} +1 -1
- package/dist/assets/{TransientHint-BKaDeHXM.js → TransientHint-C_znI6kF.js} +1 -1
- package/dist/assets/{VideoViewer-CTEVUoaa.js → VideoViewer-ByKN3zV8.js} +1 -1
- package/dist/assets/{ViewportShadingMenu-DtRQHmb8.js → ViewportShadingMenu-CiwDFdZ3.js} +1 -1
- package/dist/assets/{active-ingest-DutfA1v2.js → active-ingest-D7vF0_WM.js} +2 -2
- package/dist/assets/{animation-clock-DdjDOr9_.js → animation-clock-9uOmSLnh.js} +1 -1
- package/dist/assets/{animation-mixers.service-BowFSgLp.js → animation-mixers.service-CezYh0uP.js} +1 -1
- package/dist/assets/{animation-timeline.utility-CgUv6Sm7.js → animation-timeline.utility-N08ogFNx.js} +1 -1
- package/dist/assets/{asset-budget-asset.menu-BpfhGqPG.js → asset-budget-asset.menu-CNb7-JeF.js} +1 -1
- package/dist/assets/{asset-budget.action-DhpViDZH.js → asset-budget.action-t7yUxtux.js} +1 -1
- package/dist/assets/{asset-budget.document-d83SOYMm.js → asset-budget.document-CepgaRk2.js} +1 -1
- package/dist/assets/{asset-budget.menu-XBWaxw1e.js → asset-budget.menu-CTikGjea.js} +1 -1
- package/dist/assets/{asset-editor-persistence-C57Ygr55.js → asset-editor-persistence-BeOkWj7s.js} +1 -1
- package/dist/assets/{asset-loaders-C84nx9Q-.js → asset-loaders-DUlmV2N7.js} +1 -1
- package/dist/assets/{asset-preview-CfITAp9I.js → asset-preview-AyKlHOUG.js} +1 -1
- package/dist/assets/{audio-unlock.service-DnnTTLZ7.js → audio-unlock.service-D9EB2KFU.js} +1 -1
- package/dist/assets/{audio.utility-kVrU3d_Z.js → audio.utility-DTA2tIvc.js} +1 -1
- package/dist/assets/autoplay.service-BaV1jauU.js +1 -0
- package/dist/assets/{babylon-authoring-adapter-CKIK8_RI.js → babylon-authoring-adapter-B9wh_FNi.js} +1 -1
- package/dist/assets/{binding-resolver-Bw9NHH6D.js → binding-resolver-Bj4lXGJM.js} +2 -2
- package/dist/assets/{blender-node-editor.document-CpmEWYqS.js → blender-node-editor.document-GFtxXIGD.js} +1 -1
- package/dist/assets/{blender-properties-tab-BqzNQYYj.js → blender-properties-tab-D8P-ENR0.js} +1 -1
- package/dist/assets/{blender-runtime-host-Ce-6lPKR.js → blender-runtime-host-DDpok1JE.js} +1 -1
- package/dist/assets/{blender-runtime-skin-Bmj6NwqI.js → blender-runtime-skin-CsQYIDah.js} +33 -33
- package/dist/assets/{blender-runtime.document-fQm8jfOR.js → blender-runtime.document-BkLGZyCs.js} +1 -1
- package/dist/assets/{blender-screenshot.menu-D6z6gPx2.js → blender-screenshot.menu-BxULFKVG.js} +1 -1
- package/dist/assets/{blender-timeline.document-COcMnV4P.js → blender-timeline.document-qanxaCRV.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-CCldDOrb.js → blender-uv-editor.document-Dupon7VB.js} +1 -1
- package/dist/assets/{blender-version.status-CQcek3bs.js → blender-version.status-C0QhIFZf.js} +1 -1
- package/dist/assets/{blender.command-nx7fbZaN.js → blender.command-CAbLvvLY.js} +1 -1
- package/dist/assets/{board-guides-CJhpaM4Y.js → board-guides-D5c2iM0M.js} +1 -1
- package/dist/assets/{bridge.command-CM2oB0DL.js → bridge.command-jsbw5GvJ.js} +3 -3
- package/dist/assets/{browserAll-YVE01_g6.js → browserAll-Bq2ZxEEc.js} +1 -1
- package/dist/assets/{build-player.document-ZuyCnu8R.js → build-player.document-BKv66fYH.js} +1 -1
- package/dist/assets/{build-profiles.document-DFsJ688E.js → build-profiles.document-DUMRQcWP.js} +1 -1
- package/dist/assets/{build-progress.status-B5tu0uSU.js → build-progress.status-CSLBDvVn.js} +1 -1
- package/dist/assets/{build-session-HBNiEqfG.js → build-session-CoVPhaCV.js} +1 -1
- package/dist/assets/{build.action-B1HcItm2.js → build.action-C8Pu0Qaa.js} +1 -1
- package/dist/assets/{build.command-JnzmVI1I.js → build.command-Y7ZFB16B.js} +1 -1
- package/dist/assets/{build.header-Scr4Om6R.js → build.header-C9cApJlp.js} +1 -1
- package/dist/assets/{build.menu-B27qwD29.js → build.menu-zKiRZ-GW.js} +1 -1
- package/dist/assets/{build.service-j05ziYI4.js → build.service-BGdLfM7q.js} +1 -1
- package/dist/assets/{camera-D7hXuRtx.js → camera-Birs8s_0.js} +1 -1
- package/dist/assets/{camera-runtime.inspector-DaCMA860.js → camera-runtime.inspector-CUNGATjE.js} +1 -1
- package/dist/assets/{canvas-design-mount-Bk-EnFSI.js → canvas-design-mount-BJse4KWh.js} +3 -3
- package/dist/assets/{canvas-entry-runtime-BvUkzblV.js → canvas-entry-runtime-C2m3kEjI.js} +2 -2
- package/dist/assets/{canvas-preview-frames-DxAJx35P.js → canvas-preview-frames-BGCULuzb.js} +1 -1
- package/dist/assets/{canvas-story-capture.service-Dcv8Ibb8.js → canvas-story-capture.service-D6lgNuqO.js} +2 -2
- package/dist/assets/{capability-coverage-K_0BAIJU.js → capability-coverage-l_R9gCUV.js} +1 -1
- package/dist/assets/{collaboration-presence-CneIKoPa.js → collaboration-presence-6bJbIMPv.js} +1 -1
- package/dist/assets/{collider-BccZNdIw.js → collider-DCENOEQ6.js} +1 -1
- package/dist/assets/{component-board.service-D1jNfabq.js → component-board.service-BmFiXn58.js} +2 -2
- package/dist/assets/{component-board.service-Cs4o_Pmv.js → component-board.service-CIMa_5-V.js} +2 -2
- package/dist/assets/{component-board.service-CvzV2CKA.js → component-board.service-MkNl3te3.js} +2 -2
- package/dist/assets/{component-contracts.service-V1W-u2S9.js → component-contracts.service-B-EpU1r1.js} +1 -1
- package/dist/assets/{component-instance-root-h1Rflrqv.js → component-instance-root-1XORgnxr.js} +1 -1
- package/dist/assets/{component-verbs.command-xKxDnGqP.js → component-verbs.command-CStHQ_Bz.js} +1 -1
- package/dist/assets/{component-verbs.service-CWbkFEcM.js → component-verbs.service-Wp5bZlu9.js} +1 -1
- package/dist/assets/{config-DX3-CpHt.js → config-DKBEKx6m.js} +2 -2
- package/dist/assets/{configurations-Cs8SnMrq.js → configurations-CYmpAbNH.js} +1 -1
- package/dist/assets/{connection.status-Dn0RTNEw.js → connection.status-BnD4-dZT.js} +1 -1
- package/dist/assets/{constraints.inspector-Cpy5rhJS.js → constraints.inspector-lGhV8mr_.js} +1 -1
- package/dist/assets/{content-bounds-DVWAzm9f.js → content-bounds-Dm610thJ.js} +1 -1
- package/dist/assets/{contract-system-adapters-qNph3R6b.js → contract-system-adapters-BOsHzp5j.js} +1 -1
- package/dist/assets/{coverage.service-ByfW9X4H.js → coverage.service-G_1NEc3Q.js} +1 -1
- package/dist/assets/{create-runtime-CWPvbU_l.js → create-runtime-BEEjK4hH.js} +1 -1
- package/dist/assets/{curve-C3wndxn2.js → curve-C6m7I0EV.js} +1 -1
- package/dist/assets/{data-asset-C2Z6itFZ.js → data-asset-DwoqAORY.js} +1 -1
- package/dist/assets/{data-ref-Ce8LtHGi.js → data-ref-BhZ1uPKR.js} +1 -1
- package/dist/assets/{debug-bridge-Bmj0Li8p.js → debug-bridge-TB8wZAZ5.js} +1 -1
- package/dist/assets/{debug-registry-D-FgdH_H.js → debug-registry-BHb12FP7.js} +1 -1
- package/dist/assets/{deferred-ingest-play-B2wgrovp.js → deferred-ingest-play-CpmJ0gP7.js} +2 -2
- package/dist/assets/{design-time-canvas-mount-DOkVlNVk.js → design-time-canvas-mount-C4-MrRaz.js} +2 -2
- package/dist/assets/{design-time-layers-M6o2CVXg.js → design-time-layers-BuyHIesr.js} +1 -1
- package/dist/assets/{design-time-mount.service-CVFa4k-2.js → design-time-mount.service-BlAOrzrK.js} +2 -2
- package/dist/assets/{design-time-mount.service-DFHRGai1.js → design-time-mount.service-DBGcEAWr.js} +2 -2
- package/dist/assets/{design-time-react-mount-BuIgYRLs.js → design-time-react-mount-BYw17WQh.js} +1 -1
- package/dist/assets/{document-preview-three-CSJT6-30.js → document-preview-three-CE0Ac35n.js} +1 -1
- package/dist/assets/{dom-authoring-adapter-BijfMbzl.js → dom-authoring-adapter-nF3yjN7P.js} +1 -1
- package/dist/assets/{draco3d-B69Ry2Se.js → draco3d-B-Z1CpIy.js} +1 -1
- package/dist/assets/{edit-mode-audio.service-DR6XWs99.js → edit-mode-audio.service-FZej7fwZ.js} +1 -1
- package/dist/assets/{edit-mode-authoring-1VsqGvER.js → edit-mode-authoring-fpFMRgys.js} +1 -1
- package/dist/assets/{edit-mode-networking.service-Cc2mfOwp.js → edit-mode-networking.service-DNWxywj7.js} +1 -1
- package/dist/assets/{editor-api-CcAdYERA.js → editor-api-CI_Qw-N0.js} +1 -1
- package/dist/assets/{editor-layers-Bwn6K1Ky.js → editor-layers-Cuup-Y7g.js} +1 -1
- package/dist/assets/{editor-shell-store-Bw3pK03h.js → editor-shell-store-DE5vHuYk.js} +1 -1
- package/dist/assets/{entity-object-gqyR3fgx.js → entity-object-DExVBckP.js} +1 -1
- package/dist/assets/{extend-CjPoJR18.js → extend-xDmv3OxU.js} +1 -1
- package/dist/assets/{fork-menu-YR2i30zs.js → fork-menu-7xaPK_gU.js} +1 -1
- package/dist/assets/{frame-debugger-store-4_X7-Ujc.js → frame-debugger-store-BlhhH3pp.js} +1 -1
- package/dist/assets/{game-contract-seams-Bx5G1BLD.js → game-contract-seams-CKqbpHvU.js} +1 -1
- package/dist/assets/{game-css-scope-transform-Drjn-mgv.js → game-css-scope-transform-UkxSXYmn.js} +1 -1
- package/dist/assets/{game-document.service-DBdUvKzX.js → game-document.service-Ciz46KwF.js} +1 -1
- package/dist/assets/{game-eval.command-D-na3sdH.js → game-eval.command-Df1bHfKA.js} +1 -1
- package/dist/assets/{game-module-access-CSPO6YZ9.js → game-module-access-1zbEtLRW.js} +1 -1
- package/dist/assets/{game-network-CLJ7qTbE.js → game-network-DDTDYWaq.js} +3 -3
- package/dist/assets/{gameplay-export-sJ3B_j4Z.js → gameplay-export-BDwW4ZeA.js} +1 -1
- package/dist/assets/{gameplay-replay-DZdbHEST.js → gameplay-replay-BbxpFQrx.js} +1 -1
- package/dist/assets/{gameplay.command-D9nckU6s.js → gameplay.command-DtsNBOvd.js} +1 -1
- package/dist/assets/{generation-jobs-DupRqWi-.js → generation-jobs-BP43G8_Q.js} +1 -1
- package/dist/assets/{generation.service-CQNhtOYa.js → generation.service-BScQu8Sg.js} +1 -1
- package/dist/assets/{generations-nBks8sue.js → generations-BtJzN99e.js} +1 -1
- package/dist/assets/{generations.status-DUTDEbmm.js → generations.status-Cp38CoT7.js} +1 -1
- package/dist/assets/{hierarchy-marks-CO_ecrau.js → hierarchy-marks-Dz55bvuk.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-u30qTmDc.js → hosted-asset-materialization-Bsc70fRl.js} +1 -1
- package/dist/assets/{index-Bs-JJBoj.js → index-BC5NeEVa.js} +2 -2
- package/dist/assets/{index-DhhhiiLJ.js → index-BInT63XM.js} +1 -1
- package/dist/assets/{index-6bVz1BMz.js → index-C2LW-ago.js} +1 -1
- package/dist/assets/{index-B20JTxwn.js → index-C4oYQeJh.js} +1 -1
- package/dist/assets/{index-cdOfmiK4.js → index-CBAvzZFY.js} +1 -1
- package/dist/assets/{index-Dt5jm3bx.js → index-CIvW6PQY.js} +7 -7
- package/dist/assets/{index-ywphVnYA.js → index-CL8BNyV7.js} +1 -1
- package/dist/assets/{index-D1uSj66l.js → index-D1xtpB4l.js} +1 -1
- package/dist/assets/{index-p2Kb3X1e.js → index-DAQswRB0.js} +1 -1
- package/dist/assets/{inference-diagnostics-B32cN1KY.js → inference-diagnostics-BopptVH6.js} +1 -1
- package/dist/assets/{ingest-boot-viewport-Bs2ZgRaJ.js → ingest-boot-viewport-DDnhjnTi.js} +1 -1
- package/dist/assets/{ingest-siblings-DwzuubQ3.js → ingest-siblings-CRdWhngP.js} +1 -1
- package/dist/assets/{ingest-source-persistence-CMpSUZnL.js → ingest-source-persistence-By_F6LJR.js} +1 -1
- package/dist/assets/{ingest.service-BjmjdEXH.js → ingest.service-DlAsqV7Q.js} +1 -1
- package/dist/assets/{inspect-Br6bvKYF.js → inspect-CzUqDCsp.js} +1 -1
- package/dist/assets/instances.command-Bx5I5SFi.js +1 -0
- package/dist/assets/{json-history-resource-_clmB965.js → json-history-resource-vSNgROIK.js} +1 -1
- package/dist/assets/{layered-pick-C_WeiIoE.js → layered-pick-BT_GgsY-.js} +1 -1
- package/dist/assets/{light-WOrPHDb-.js → light-5_m5IbUA.js} +1 -1
- package/dist/assets/{live-project-verbs-C2jF4YJL.js → live-project-verbs-BDRLedOB.js} +1 -1
- package/dist/assets/{machine.document-DTbenFr7.js → machine.document-BjRrgqHf.js} +1 -1
- package/dist/assets/{machines.finder-BS0dBMs1.js → machines.finder-CBDSpnDe.js} +1 -1
- package/dist/assets/{material-CD2DR79m.js → material-CM-xU0DE.js} +1 -1
- package/dist/assets/{material-factory-B4aM15jS.js → material-factory-CUWU6Zu0.js} +1 -1
- package/dist/assets/{mesh-DTofF_go.js → mesh-Cu4CDso3.js} +1 -1
- package/dist/assets/{model-asset-sections.service-BxEhl0ko.js → model-asset-sections.service-CL2WtGng.js} +1 -1
- package/dist/assets/{model-inspection-BEPkYxZm.js → model-inspection-Dao1B-ji.js} +1 -1
- package/dist/assets/{model-thumbnail-BT7oIq1o.js → model-thumbnail-BiA0hed5.js} +1 -1
- package/dist/assets/{models.finder-DaMe1qYN.js → models.finder-Cs4ldn9p.js} +1 -1
- package/dist/assets/{module-mode-BddTykwB.js → module-mode-D7OVp-ls.js} +2 -2
- package/dist/assets/{mount-canvas-ingest-root-DXvGskTU.js → mount-canvas-ingest-root-BahyyoSm.js} +2 -2
- package/dist/assets/{mount-dom-ingest-root-CKhZMS30.js → mount-dom-ingest-root-BRJIxA08.js} +2 -2
- package/dist/assets/{mount-ingest-root-99LbxpVS.js → mount-ingest-root-Bzp__CIu.js} +2 -2
- package/dist/assets/{mount-manifest-BSjGZJtM.js → mount-manifest-DnvIhEMH.js} +1 -1
- package/dist/assets/{mount-three-ingest-root-7ndKUA_v.js → mount-three-ingest-root-CFwkgF-d.js} +1 -1
- package/dist/assets/{mounted-authoring-B7_F5jnJ.js → mounted-authoring-BLnHIXL0.js} +1 -1
- package/dist/assets/{mounted-story-viewport-source-DK5VrFqH.js → mounted-story-viewport-source-BTc7aSjb.js} +1 -1
- package/dist/assets/{native-debug-module-739ES-Zm.js → native-debug-module-D4aoSlIt.js} +1 -1
- package/dist/assets/{navigation-C6ZlGnSt.js → navigation-B5NuXfr8.js} +1 -1
- package/dist/assets/{navmesh.menu-x5By6bBe.js → navmesh.menu-D6TyIUuc.js} +1 -1
- package/dist/assets/{navmesh.service-Btopj44G.js → navmesh.service-DAWrobDD.js} +1 -1
- package/dist/assets/network-observer.service-CwU_C1Ir.js +1 -0
- package/dist/assets/{network.utility-5MBcxgB_.js → network.utility-D0lqV8bb.js} +1 -1
- package/dist/assets/{object3d-document-session-registry-j6Y5JrzG.js → object3d-document-session-registry-D8ERLHaX.js} +2 -2
- package/dist/assets/{oid-transform-B7bZOfh0.js → oid-transform-7cVqkub5.js} +1 -1
- package/dist/assets/{particles-BcTfNklT.js → particles-C_j1vf_7.js} +1 -1
- package/dist/assets/{pixi-authoring-adapter-CnYwoVLZ.js → pixi-authoring-adapter-DxhYKDJ8.js} +1 -1
- package/dist/assets/{pixi-live-write-target-3Q4ukIef.js → pixi-live-write-target-Lr5agPuW.js} +1 -1
- package/dist/assets/{play.command-CsXpcIJO.js → play.command-Ds-4_rH8.js} +2 -2
- package/dist/assets/{presentation-Dyo74fnC.js → presentation-Dgs5jGc2.js} +1 -1
- package/dist/assets/{product-D_CEDap_.js → product-BccUu3Jb.js} +1 -1
- package/dist/assets/{profiler.action-4pakkT-I.js → profiler.action-Zq2jf4o4.js} +1 -1
- package/dist/assets/{profiler.menu-C3qMbQDL.js → profiler.menu-sXzn65nz.js} +1 -1
- package/dist/assets/{profiler.utility-DopaGlcK.js → profiler.utility-DZZAqxgp.js} +1 -1
- package/dist/assets/{project-authoring-session-BErT1Vxt.js → project-authoring-session-C927zHSE.js} +2 -2
- package/dist/assets/{properties-bone-constraints.inspector-DrwOv8lP.js → properties-bone-constraints.inspector-CUIOVDQV.js} +1 -1
- package/dist/assets/{properties-bone.inspector-Cgm5HNYg.js → properties-bone.inspector-DiWlK9Tg.js} +1 -1
- package/dist/assets/{properties-collection.inspector-BpRHp08N.js → properties-collection.inspector-DCjnGSMu.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-Bcps7O7L.js → properties-constraints.inspector-DvZWlM_N.js} +1 -1
- package/dist/assets/{properties-data.inspector-Cbm0WQCb.js → properties-data.inspector-BIlswH2t.js} +1 -1
- package/dist/assets/{properties-material.inspector-b2HVBeRi.js → properties-material.inspector-DIMuUuQF.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-bJ2xlb_E.js → properties-modifiers.inspector-CdLYLU78.js} +1 -1
- package/dist/assets/{properties-object.inspector-E1TqDSQi.js → properties-object.inspector-D10d_Lz3.js} +1 -1
- package/dist/assets/{properties-output.inspector-DvWo2xp8.js → properties-output.inspector-DnzQmOKt.js} +1 -1
- package/dist/assets/{properties-particles.inspector-D_QiAw0d.js → properties-particles.inspector-DrZViJE-.js} +1 -1
- package/dist/assets/{properties-physics.inspector-BIh1EfkD.js → properties-physics.inspector-Hpgu-3dC.js} +1 -1
- package/dist/assets/{properties-render.inspector-CQ_T14za.js → properties-render.inspector-DKfPTQiU.js} +1 -1
- package/dist/assets/{properties-scene.inspector-d3xZpohF.js → properties-scene.inspector-J4fSpzXT.js} +1 -1
- package/dist/assets/{properties-texture.inspector-CiodVE2E.js → properties-texture.inspector-BKqdvqgo.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-BTvjGbST.js → properties-view-layer.inspector-COm8b5K-.js} +1 -1
- package/dist/assets/{properties-world.inspector-HjQ_XQWr.js → properties-world.inspector-Bj3KKJ_C.js} +1 -1
- package/dist/assets/{r3f-design-session-CgJHKbHk.js → r3f-design-session-BEATXGy2.js} +2 -2
- package/dist/assets/{r3f-physics-binding-Bs90cL2H.js → r3f-physics-binding-sqfaF1ib.js} +1 -1
- package/dist/assets/{r3f-source-authoring-adapter-Dz-2gR6C.js → r3f-source-authoring-adapter-DZdYQWzy.js} +1 -1
- package/dist/assets/{react-canvas-navigation-BuUlk_hY.js → react-canvas-navigation-p37EiJMh.js} +1 -1
- package/dist/assets/{react-inspector.service-he9nhYSF.js → react-inspector.service-mbf-R-2Q.js} +1 -1
- package/dist/assets/{react-story-board-DFX_3Eor.js → react-story-board-B33NoSzW.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-Cqb1QJsp.js → react-three-rapier.esm-DtMZOCKx.js} +1 -1
- package/dist/assets/{react-world-authoring-adapter-4OOk2v75.js → react-world-authoring-adapter-DxDW0ty7.js} +1 -1
- package/dist/assets/{realm-services-B51BueDW.js → realm-services-F7Kj_vrK.js} +1 -1
- package/dist/assets/{reflection-probe-capture.inspector-Cibd2Skj.js → reflection-probe-capture.inspector-C-2IOPHX.js} +1 -1
- package/dist/assets/{registry-BJ0P13Qw.js → registry-BFgdbozc.js} +1 -1
- package/dist/assets/{relative-import-specifier-Bg1UDyTq.js → relative-import-specifier-Bi2_a2rG.js} +1 -1
- package/dist/assets/{render-env-DClqJsug.js → render-env-miIZ6IrK.js} +1 -1
- package/dist/assets/{render-features-BgLAARMw.js → render-features-BO6TVhcc.js} +1 -1
- package/dist/assets/{render-settings-TkRnwGvq.js → render-settings-L80fXhuT.js} +1 -1
- package/dist/assets/{resolve-three-DNMNH9g9.js → resolve-three-Be3HCdVu.js} +3 -3
- package/dist/assets/{root-seam-contract-BAI8C8KI.js → root-seam-contract-ITdzkz3q.js} +1 -1
- package/dist/assets/{run-selection-C62JWX8Y.js → run-selection-CVuEJNpv.js} +1 -1
- package/dist/assets/{scene-capture-Csu-9Z3v.js → scene-capture-CLnRf-ay.js} +1 -1
- package/dist/assets/{scene-document.service-CXu3hwi9.js → scene-document.service-C1WttMW4.js} +2 -2
- package/dist/assets/{scene-framing-DgQMZG99.js → scene-framing-hzkM8H3d.js} +1 -1
- package/dist/assets/{seeded-random-xhwosly5.js → seeded-random-bWJ1RCY7.js} +1 -1
- package/dist/assets/{setup-renderer-sNRGFHD3.js → setup-renderer-o_UHSQ11.js} +1 -1
- package/dist/assets/{source-object3d-authoring-adapter-DiUz2ONX.js → source-object3d-authoring-adapter-DLz7rWxd.js} +1 -1
- package/dist/assets/{source-persistence-backend-DKdo7qA1.js → source-persistence-backend-CQAxNrZO.js} +1 -1
- package/dist/assets/{stage-keyboard-CCAEPBds.js → stage-keyboard-D6SLGzpO.js} +1 -1
- package/dist/assets/{stage-overlay-set-BIT1H7YG.js → stage-overlay-set-BiJpW1Z1.js} +1 -1
- package/dist/assets/{stage-presence-markers-Dde0uo4f.js → stage-presence-markers-DyX7CTfo.js} +1 -1
- package/dist/assets/{stage-transform-tools-C5xuzlvB.js → stage-transform-tools-BGu616ns.js} +1 -1
- package/dist/assets/{standard-viewport-dressing-4mM0Zr-0.js → standard-viewport-dressing-6Jw1V5qc.js} +1 -1
- package/dist/assets/{state-watch.action-BocmVXfv.js → state-watch.action-D8ZNvRzJ.js} +1 -1
- package/dist/assets/{state-watch.menu-VacWy0Ty.js → state-watch.menu-xtLjviBo.js} +1 -1
- package/dist/assets/{state-watch.utility-f6mj3xS-.js → state-watch.utility-B9aBTWo1.js} +1 -1
- package/dist/assets/{story-capture-D3oUwSdi.js → story-capture-CD5mQix-.js} +1 -1
- package/dist/assets/{story-documents-BvxE0Jgp.js → story-documents-6Ju7lp6l.js} +1 -1
- package/dist/assets/{story-documents.service-Ci9hEaEi.js → story-documents.service-4qxegHX4.js} +1 -1
- package/dist/assets/{story-documents.service-BPkgxZFz.js → story-documents.service-BnJA-Peb.js} +1 -1
- package/dist/assets/{story-media-presence-nuojiKa3.js → story-media-presence-jZL4cO64.js} +1 -1
- package/dist/assets/{story-pixi-preview-MPFqGD8z.js → story-pixi-preview-BQp48tx-.js} +1 -1
- package/dist/assets/{story-presentation-Bi6tUUJT.js → story-presentation-NqyFbI4F.js} +1 -1
- package/dist/assets/{story-three-preview-CquJrBi1.js → story-three-preview-BmU6ZF6y.js} +2 -2
- package/dist/assets/{studio-environment-PbtbyxPv.js → studio-environment-iufbXOBi.js} +1 -1
- package/dist/assets/{surface-state-vm1S5q1D.js → surface-state-DXubqNo5.js} +1 -1
- package/dist/assets/{syntactic-prop-specs-CRrIsekh.js → syntactic-prop-specs-BM3YTEOR.js} +1 -1
- package/dist/assets/{team-playtest.service-gQVOEk6C.js → team-playtest.service-BykmNzR-.js} +1 -1
- package/dist/assets/{three-C_mp4XTZ.js → three-CLmOBdem.js} +1 -1
- package/dist/assets/{three-authoring-adapter-D4_90yFr.js → three-authoring-adapter-Cm5jfSwc.js} +1 -1
- package/dist/assets/three-authoring.service-D-d2Gcx8.js +2 -0
- package/dist/assets/{three-ingest-runtime-BPcTsDxh.js → three-ingest-runtime-CYpDOZTv.js} +1 -1
- package/dist/assets/{three-integration-CD3ATFnX.js → three-integration-CoYYjm63.js} +2 -2
- package/dist/assets/three-integration.service-DtpqKgz-.js +1 -0
- package/dist/assets/{three-projection-core-DbYmRPci.js → three-projection-core-DZTszel5.js} +1 -1
- package/dist/assets/{three-state-BPIytwjV.js → three-state-DrJWKuiO.js} +1 -1
- package/dist/assets/{three-story-capture.service-CFKkQGtX.js → three-story-capture.service-BClm29Ug.js} +2 -2
- package/dist/assets/{three-story-model-DJE_sYaC.js → three-story-model-CPRkC3Z7.js} +1 -1
- package/dist/assets/{three-viewport-presentation-CNXPLHEX.js → three-viewport-presentation-FMAOITDK.js} +1 -1
- package/dist/assets/{transform-mode-request-B-gJ5g51.js → transform-mode-request-N66cicyJ.js} +1 -1
- package/dist/assets/{transport-strip-B36KBNDz.js → transport-strip-D7f4gfsu.js} +1 -1
- package/dist/assets/transport.header-BmL-sNkq.js +1 -0
- package/dist/assets/{tuples-D_IQElzZ.js → tuples-BEd4OCzm.js} +1 -1
- package/dist/assets/{ui-board-document-BL31txjD.js → ui-board-document-D5ynSZAE.js} +2 -2
- package/dist/assets/{user-data-DZ8WeiSK.js → user-data-ewYRLR68.js} +1 -1
- package/dist/assets/{utility-view-state-CJp6vkri.js → utility-view-state-BON-K1XX.js} +1 -1
- package/dist/assets/{viewport-door-Bdlxiiu3.js → viewport-door-Bk2lmKCe.js} +1 -1
- package/dist/assets/{viewport-root-presentation-lfnmV2dZ.js → viewport-root-presentation-CtKgppro.js} +1 -1
- package/dist/assets/{viewport-surface-status-BkWCfY-g.js → viewport-surface-status-4TZe3TJM.js} +1 -1
- package/dist/assets/{webworkerAll-DrO32SxK.js → webworkerAll-yldn-lq8.js} +1 -1
- package/dist/assets/{workspace-arrangement-9RRX0-sM.js → workspace-arrangement-Bykd8P3-.js} +1 -1
- package/dist/assets/{world-documents-BjqjhIv6.js → world-documents-C8B1VJMM.js} +1 -1
- package/dist/assets/{world-root-stage-binding-BGWAd6qi.js → world-root-stage-binding-CskI2r49.js} +1 -1
- package/dist/assets/{xstate-animation-binding-qDvqsOQe.js → xstate-animation-binding-BT4gAJE-.js} +1 -1
- package/dist/assets/{xstate-animation-meta-DG39Stxz.js → xstate-animation-meta-pJUO-heu.js} +1 -1
- package/dist-node/cli.js +16 -16
- package/package.json +16 -16
- package/dist/assets/InspectorObjectPreview-cEL6iskI.js +0 -1
- package/dist/assets/Object3DDocumentViewport-Dy6oCsqf.js +0 -2
- package/dist/assets/autoplay.service-S6u51gjV.js +0 -1
- package/dist/assets/instances.command-CS1LShqz.js +0 -1
- package/dist/assets/network-observer.service-B_aXblWh.js +0 -1
- package/dist/assets/three-authoring.service-0XLcjtfj.js +0 -2
- package/dist/assets/three-integration.service-DjQ3BgqY.js +0 -1
- package/dist/assets/transport.header-CAIoNhnT.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/RectAreaLightUniformsLib-DpPyArRG.js","assets/three.module-BLhyNg0e.js","assets/three.core-3arARmh6.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as
|
|
2
|
+
import{a as ne,b as oe,L as ee}from"./LineSegments2-DN9pUfWA.js";import{bh as lt,cl as ae,fo as x,cm as tt,N as hn,a$ as St,em as so,b4 as Ce,co as Rt,ey as ke,cp as En,_ as wt,ej as Ct,fd as qt,er as $e,M as dt,cj as gt,dp as Tt,aV as Le,cW as re,aE as le,c7 as pt,j as Ve,f6 as je,fp as fo,au as zn,dw as Dn,bi as co,aT as Be,c1 as Gt,dd as Zn,eC as Qn,e7 as An,aw as sn,da as Vt,I as Mn,as as Ue,e8 as We,b0 as ie,K as He,B as qe,b9 as Ge,Y as se,cw as mn,ed as Xe,cA as Ye,fx as Ze,db as fe,el as Qe,R as Ke,e6 as Je,c0 as ce,bX as ta,aI as wo,ao as na,eG as oa,d3 as ea,cs as aa,ex as ra,b5 as la,cO as Nn,cY as ia,eU as sa,cE as Kn,c5 as ue,at as fa,ff as ca,eW as ua,f7 as _a,F as ma,ev as da,et as ha,dq as pa,fq as va,n as ga,l as xa,cf as ba}from"./three.core-3arARmh6.js";import{u as P,v as D,w as R,c5 as Z,c4 as H,c6 as N,e2 as L,_ as ya,mB as _e,d_ as kt,x as W,kE as xt,e1 as me,mC as U,dZ as wa,mD as Oa}from"./index-CIvW6PQY.js";import{S as jt}from"./three.module-BLhyNg0e.js";import{t as Ta}from"./blender-runtime-host-DDpok1JE.js";const Jn=new Set;function Ot(){for(const o of[...Jn])o()}function Aa(o){return Jn.add(o),()=>{Jn.delete(o)}}function to(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}const on=N().finite(),Pa=P({name:R(),parent:R().nullable(),connected:Z(),hide:Z(),length:on,matrix:D(L([on,on,on,on])).length(4),select:Z(),active:Z(),lockedWeight:Z()}).strict(),Sa=P({object:R(),displayType:H(["OCTAHEDRAL","STICK","BBONE","ENVELOPE","WIRE"]),showInFront:Z(),mode:R(),bones:D(Pa)}).strict(),Pt={solid:11711154,pose:5294335,poseActive:9240575,poseActiveUnsel:794150,wire:0,vertex:0,lockedWeight:16711680,lockedWeightFactor:128/255};function Ea(o){return new wt(o.r*o.r*.1,o.g*o.g*.1,o.b*o.b*.1)}const kn=[[0,0,0],[.1,.1,.1],[.1,.1,-.1],[-.1,.1,-.1],[-.1,.1,.1],[0,1,0]],Oo=[[2,1,0],[3,2,0],[4,3,0],[1,4,0],[5,1,2],[5,2,3],[5,3,4],[5,4,1]],It=Math.SQRT1_2,Ma=[[It,-It,0],[0,-It,-It],[-It,-It,0],[0,-It,It],[.99388373,.11043154,0],[0,.11043154,-.99388373],[-.99388373,.11043154,0],[0,.11043154,.99388373]],Na=[[0,1],[1,5],[5,3],[3,0],[0,4],[4,5],[5,2],[2,0],[1,2],[2,3],[3,4],[4,1]],Ra=.05;function To(o){return o.select||o.active?2:1}const Ia=10,Fa=4,za=`
|
|
3
3
|
attribute vec3 aSolid;
|
|
4
4
|
attribute vec3 aHint;
|
|
5
5
|
varying vec3 vColor;
|
|
@@ -10,13 +10,13 @@ import{a as Ho,b as qo,L as Go}from"./LineSegments2-DN9pUfWA.js";import{bh as ot
|
|
|
10
10
|
vColor = mix(aHint, aSolid, fac * fac);
|
|
11
11
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`,Da=`
|
|
14
14
|
varying vec3 vColor;
|
|
15
15
|
void main() {
|
|
16
16
|
gl_FragColor = vec4(vColor, 1.0);
|
|
17
17
|
#include <colorspace_fragment>
|
|
18
18
|
}
|
|
19
|
-
`;function St(o){return new ht().setHex(o,Mt)}function ho(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=St(xt.poseActive):t.active?e=St(xt.poseActiveUnsel):t.select?e=St(xt.pose):e=St(xt.wire):e=St(xt.vertex),n&&t.lockedWeight&&e.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),e}function po(o,t){const n=St(xt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(St(xt.lockedWeight),xt.lockedWeightFactor),n}const Ea=new X,Ma=new x,vo=new Xo;function go(o,t){return new X().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class Na{constructor(){this.group=new ot,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],a=JSON.stringify(t);if(a===this.signature)return e;this.signature=a,this.clear();for(const r of Object.values(t)){const i=n(r.object);if(i===null)continue;r.displayType!=="OCTAHEDRAL"&&r.displayType!=="STICK"&&e.push(`armature ${r.object}: Blender's ${r.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),r.mode==="EDIT"&&e.push(`armature ${r.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const f=r.bones.filter(h=>!h.hide);if(f.length===0)continue;const u=r.displayType==="STICK"?this.buildStick(r,f,i):this.buildOctahedral(r,f,i);r.showInFront&&u.traverse(h=>{const s=h.material;s&&"depthTest"in s&&(s.depthTest=!1),h.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[],h=[],s=[],l=[],c=[],_=[],d=[];for(const m of n){const p=go(e,m),v=po(t,m),g=ba(v),w=ho(t,m);vo.setFromMatrix4(p).invert().transpose();for(let T=0;T<_o.length;T++){const A=Ma.set(...ya[T]).applyMatrix3(vo).normalize().clone();for(const O of _o[T]){const E=new x(...Mn[O]).applyMatrix4(p);r.push(E.x,E.y,E.z),i.push(A.x,A.y,A.z),f.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const y=mo(m)===2?l:h,S=mo(m)===2?c:s;for(const[T,A]of wa){const O=new x(...Mn[T]).applyMatrix4(p),E=new x(...Mn[A]).applyMatrix4(p);y.push(O.x,O.y,O.z,E.x,E.y,E.z),S.push(w.r,w.g,w.b,w.r,w.g,w.b)}m.parent!==null&&m.connected||(_.push(p.clone()),d.push(v)),_.push(p.clone().multiply(Ea.makeTranslation(0,1,0))),d.push(v)}a.add(this.solidMesh(r,i,f,u)),h.length&&a.add(this.lines(h,s,1)),l.length&&a.add(this.lines(l,c,2));for(let m=0;m<_.length;m++)a.add(this.point(_[m],d[m]));return a}buildStick(t,n,e){const a=new ot;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[];for(const h of n){const s=go(e,h),l=new x().setFromMatrixPosition(s),c=new x(0,1,0).applyMatrix4(s),_=ho(t,h),d=po(t,h);r.push(l.x,l.y,l.z,c.x,c.y,c.z),i.push(_.r,_.g,_.b,_.r,_.g,_.b),f.push(l.x,l.y,l.z,c.x,c.y,c.z),u.push(d.r,d.g,d.b,d.r,d.g,d.b)}return a.add(this.lines(r,i,Ta)),a.add(this.lines(f,u,Aa)),a}solidMesh(t,n,e,a){const r=new fn;r.setAttribute("position",new bt(t,3)),r.setAttribute("normal",new bt(n,3)),r.setAttribute("aSolid",new bt(e,3)),r.setAttribute("aHint",new bt(a,3));const i=new to({vertexShader:Pa,fragmentShader:Sa,side:Ee});this.disposables.push(r,i);const f=new Tt(r,i);return f.frustumCulled=!1,f}lines(t,n,e){const a=new Ho;a.setPositions(t),a.setColors(n);const r=new qo({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const i=new Go(a,r);return i.frustumCulled=!1,i}point(t,n){const e=new Me(Oa,12,8),a=new yn({color:n});this.disposables.push(e,a);const r=new Tt(e,a);return r.applyMatrix4(t),r.frustumCulled=!1,r}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const xo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",Qt="RUNTIME_FRAME_UNKNOWN_IMAGE";function Ra(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),a=t(1/e);return{unit:[t(o[0]*a),t(o[1]*a),t(o[2]*a)],length:e}}return{unit:[0,0,0],length:0}}const R=Math.fround,Tn=R(2*Math.PI),Nn=R(1-1e-4),zt=(o,t)=>R(R(R(o[0]*t[0])+R(o[1]*t[1]))+R(o[2]*t[2])),rn=(o,t,n=1)=>o.map((e,a)=>R(e+R(t[a]*n))),Ia=(o,t)=>o.map((n,e)=>R(n-t[e]));function Kt(o){const t=R(Math.sqrt(zt(o,o)));return t>0?o.map(n=>R(n/t)):[0,0,0]}function Jt(o){const t=Math.abs(o)<1?R(1-R(1-Math.abs(o))):1;let n=R(R(.077980478)+R(t*R(-.02164095)));n=R(R(-.213300989)+R(t*n)),n=R(R(1.5707963267)+R(t*n));const e=R(R(Math.sqrt(R(1-t)))*n);return o<0?R(R(Math.PI)-e):e}function Fa(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let a=0;a<3;a++){const r=(a+1)%3,i=(a+2)%3;n[a]=R(n[a]+R(R(t[r]-e[r])*R(t[i]+e[i])))}t=e}return n}function Da(o){const t=[],n=[],e=(d,m)=>d<m?`${d}:${m}`:`${m}:${d}`,a=new Map((o.edge_order??[]).map(([d,m],p)=>[e(d,m),p])),r=new Set((o.sharp??[]).map(([d,m])=>e(d,m))),i=new Map;for(const[d,m]of o.f.entries()){const p=t.length,v=Ra(Fa(m.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<m.length;g++){const w=e(m[g],m[(g+1)%m.length]);a.has(w)||a.set(w,a.size);const y=o.face_edges?.[d]?.[g]??a.get(w),S=t.length;t.push({vertex:m[g],face:d,edge:y,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=i.get(y)??[];T.push(S),i.set(y,T)}}const f=new Map,u=new Map;for(const[d,m]of i){if(m.length!==2||o.edge_sharp?.[d])continue;const[p,v]=m,g=t[p],w=t[v];!o.s?.[g.face]||!o.s?.[w.face]||g.vertex!==t[w.next].vertex||w.vertex!==t[g.next].vertex||!o.edge_sharp&&r.has(e(g.vertex,w.vertex))||(u.set(p,w.next),f.set(w.next,p),u.set(v,g.next),f.set(g.next,v))}const h=[],s=[],l=[],c=[],_=(d,m)=>Kt(Ia(o.v[t[t[d][m]].vertex],o.v[t[d].vertex]));for(let d=0;d<t.length;d++){if(s[d]!==void 0)continue;let m=d;const p=new Set([m]);for(;u.has(m)&&!p.has(u.get(m));)m=u.get(m),p.add(m);u.has(m)&&(m=Math.min(...p));const v=[m];for(;f.has(v.at(-1))&&f.get(v.at(-1))!==m;)v.push(f.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[m].face];else{for(const E of v)g=rn(g,n[t[E].face],Jt(zt(_(E,"prev"),_(E,"next"))));g=Kt(g)}const w=_(m,"next"),y=v.at(-1),S=_(y,"prev"),T=zt(w,g),A=zt(S,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<Nn&&Math.abs(A)<Nn){const E=v.length>1?v.map(pt=>_(pt,"next")):[];E.length&&t[t[y].prev].edge!==t[m].edge&&E.push(S),O.alpha=E.length?R(E.reduce((pt,b)=>R(pt+Jt(zt(b,g))),0)/E.length):R(R(Jt(T)+Jt(A))/2),O.reference=Kt(rn(w,g,-T));const C=g,V=O.reference;O.ortho=Kt([R(R(C[1]*V[2])-R(C[2]*V[1])),R(R(C[2]*V[0])-R(C[0]*V[2])),R(R(C[0]*V[1])-R(C[1]*V[0]))]);const H=Kt(rn(S,g,-A)),Q=zt(O.reference,H),tt=Jt(Q);O.beta=Q<Nn?zt(O.ortho,H)<0?R(Tn-tt):tt:Tn}O.alpha===0&&(O.normal=[0,0,0]);for(const E of v)s[E]=h.length;h.push(v),l.push(O),c.push(g)}return{corners:t,fans:h,fanOf:s,spaces:l,faceNormals:n,fanNormals:c}}function za(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=R(t[0]/32767),e=R(t[1]/32767),a=R((n>0?o.alpha:R(Tn-o.alpha))*n),r=R((e>0?o.beta:R(Tn-o.beta))*e);let i=o.normal.map(f=>R(f*R(Math.cos(a))));return i=rn(i,o.reference,R(R(Math.sin(a))*R(Math.cos(r)))),e!==0&&(i=rn(i,o.ortho,R(R(Math.sin(a))*R(Math.sin(r))))),i}function ae(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Da(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const r=new Array(n.length);for(const[i,f]of e.entries()){const u=f.reduce((s,l)=>{const c=t.data[l];return[s[0]+c[0],s[1]+c[1]]},[0,0]),h=za(a[i],u.map(s=>Math.trunc(s/f.length)));for(const s of f)r[s]=h}return r}if(t.type==="FLOAT_VECTOR")return n.map((r,i)=>{const f=t.domain==="POINT"?r.vertex:t.domain==="FACE"?r.face:i;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Rn={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},Ca=1e-6;function ka(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t.x+=(e.y-a.y)*(e.z+a.z),t.y+=(e.z-a.z)*(e.x+a.x),t.z+=(e.x-a.x)*(e.y+a.y)}return t.multiplyScalar(.5)}const $a=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),bo=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function La(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t+=e.x*a.y-a.x*e.y}return t}function yo(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let a=0;for(const[r,i,f]of o){const u=$a(t[r],t[i],t[f]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Ca*Math.abs(n)}function Va(o){const t=o.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=ka(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:bo(t),sound:!1,method:"fan"};const a=n.clone().divideScalar(e),r=Math.abs(a.x)<.9?new x(1,0,0):new x(0,1,0),i=new x().crossVectors(r,a).normalize(),f=new x().crossVectors(a,i),u=o[0],h=o.map(_=>{const d=_.clone().sub(u);return new Lt(d.dot(i),d.dot(f))}),s=La(h),l=bo(t);if(yo(l,h,s))return{triangles:l,sound:!0,method:"fan"};let c=[];try{c=Ne.triangulateShape(h,[]).map(_=>[_[0],_[1],_[2]])}catch{return{triangles:l,sound:!1,method:"fan"}}return yo(c,h,s)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:l,sound:!1,method:c.length>0?"earcut":"fan"}}const ja=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function In(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function Fn(o,t,n){switch(o){case"FLOAT":{const e=Number(t[n]);return[e,e,e,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[In(Number(t[n*4])),In(Number(t[n*4+1])),In(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function re(o,t){return o.filter(n=>ja.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),a=[0,0,0,0];return{name:n.name,domain:n.domain,read:(r,i,f)=>n.domain==="POINT"?Fn(n.type,e,r):n.domain==="CORNER"?i===void 0?a:Fn(n.type,e,i):f===void 0?a:Fn(n.type,e,f)}})}function le(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,a=o.cornerVerts,r=e[n];let i=t;for(let b=0;b<n;b++)i+=(e[b+1]-e[b]-2)*3;const f=new Uint32Array(r),u=new Uint8Array(r),h=new Uint8Array(t),s=new Uint32Array(r);let l=!1;for(let b=0;b<n;b++)if(o.smooth(b)){l=!0;break}const c=(b,L)=>t<94906265?Math.min(b,L)*t+Math.max(b,L):`${Math.min(b,L)}:${Math.max(b,L)}`,_=new Map,d=new Set;for(const[b,L]of o.sharp)d.add(c(b,L));if(o.edges)for(const[b,L]of o.edges){if(b===L)throw new Error("Runtime mesh edge needs distinct vertices");_.set(c(b,L),-1)}const m=b=>{for(;s[b]!==b;)s[b]=s[s[b]],b=s[b];return b},p=(b,L)=>{const z=m(b),Y=m(L);s[Math.max(z,Y)]=Math.min(z,Y)};for(let b=0;b<n;b++){const L=e[b],z=e[b+1]-L,Y=o.smooth(b)?1:0;for(let Z=0;Z<z;Z++){const k=L+Z;h[a[k]]=1,f[k]=L+(Z+1)%z,u[k]=Y,s[k]=k}}for(let b=0;b<r;b++){const L=f[b],z=a[b],Y=a[L],Z=c(z,Y),k=_.get(Z);if(k!==void 0&&k>=0&&u[b]&&u[k]&&!d.has(Z)){const G=f[k];p(b,a[k]===z?k:G),p(L,a[k]===z?G:k)}(k===void 0||k<0||!u[k]&&u[b])&&_.set(Z,b)}const v=o.uv,g=new Float32Array(i*3),w=new Float32Array(i*2),y=new Uint32Array(i),S=(o.uvLayers??[]).map(b=>({...b,data:new Float32Array(i*2)})),T=(o.attributeLayers??[]).map(b=>({...b,data:new Float32Array(i*4)})),A=o.orco?new Float32Array(i*3):null,O=new Uint32Array(i),E=new Map,C=[],V=o.normals||o.cornerNormal?new Float32Array(i*3):null;let H=0,Q=0;const tt=(b,L,z,Y,Z)=>{const k=H++;for(const G of T)G.data.set(G.read(b,Y,Z),k*4);if(A)for(let G=0;G<3;G++)A[k*3+G]=o.orco[b*3+G]*.5+.5;if(y[k]=b,o.co(b).toArray(g,k*3),L&&w.set(L,k*2),z&&V.set(z,k*3),Y!==void 0)for(const G of S)G.data.set(G.read(Y),k*2);return k},pt=(b,L)=>{const z=v?.(b),Y=o.cornerNormal?[o.cornerNormal[b*3],o.cornerNormal[b*3+1],o.cornerNormal[b*3+2]]:o.normals?.[b];if(!l)return tt(a[b],z,Y,b,L);const Z=`${u[b]?m(b):b}${z?`:${z[0]}:${z[1]}`:""}${Y?`:n${Y.join(":")}`:""}${S.map(G=>":"+G.read(b).join(":")).join("")}${T.map(G=>G.domain==="POINT"?"":":"+Array.from(G.read(a[b],b,L)).join(":")).join("")}`;let k=E.get(Z);return k===void 0&&(k=tt(a[b],z,Y,b,L),E.set(Z,k)),k};for(let b=0;b<n;b++){const L=Q,z=e[b],Y=e[b+1]-z,Z=[];for(let Yt=0;Yt<Y;Yt++)Z.push(o.co(a[z+Yt]));for(const Yt of Va(Z).triangles)for(const Se of Yt)O[Q++]=pt(z+Se,b);const k=o.material(b),G=C.at(-1);G?.materialIndex===k?G.count+=Q-L:C.push({start:L,count:Q-L,materialIndex:k})}for(let b=0;b<t;b++)h[b]||tt(b);return{positions:g.slice(0,H*3),normals:V?.slice(0,H*3)??null,uv:v?w.slice(0,H*2):null,uvLayers:S.map(b=>({name:b.name,data:b.data.slice(0,H*2)})),attributeLayers:T.map(b=>({name:b.name,data:b.data.slice(0,H*4)})),orco:A?A.slice(0,H*3):null,indices:O.slice(0,Q),sourceVertex:y.slice(0,H),groups:C}}function jt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function xn(o){const t=new fn;t.setAttribute("position",new it(o.positions,3)),t.setAttribute("uv",new it(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new it(o.indices,1));const n=Object.create(null);for(const[e,a]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[a.name]=e+1,t.setAttribute(`uv${e+1}`,new it(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(jt(e.name),new it(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new it(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new it(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new it(o.sourceVertex,1)),t}function wo(o,t){const n=o.co.length/3,e=o.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),a=o.renderUv??o.activeUv??e[0]?.name,r=e.find(m=>m.name===a);if(a&&!r)throw new Error(`Runtime UV map ${a} is missing`);const i=r?r.data:null,f=o.edge.length/2,u=new Array(f);for(let m=0;m<f;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const h=[];for(let m=0;m<f;m++)o.edgeSharp[m]===1&&h.push(u[m]);const s=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),l=s?{v:Array.from({length:n},(m,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:h,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,c=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/Rn[s.type].size},(m,p)=>Array.from({length:Rn[s.type].size},(v,g)=>Number(s.data[p*Rn[s.type].size+g])))}:void 0,_=new x,d={vertexCount:n,normals:l?ae(l,c):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>_.set(o.co[m*3],o.co[m*3+1],o.co[m*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:m=>o.smooth[m]===1,material:m=>o.material[m],edges:u,sharp:h,uv:i?m=>[i[m*2],i[m*2+1]]:null,uvLayers:e.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:re(o.attributes,m=>m)};return{...le(d),hash:t}}function Ba(o){const t=o.v.map(l=>new x(...l)),n=l=>{const c=t[l];if(!c)throw new Error(`Runtime mesh vertex ${l} is missing`);return c},e=new Uint32Array(o.f.length+1);o.f.forEach((l,c)=>{if(l.length<3||new Set(l).size!==l.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[c+1]=e[c]+l.length});const a=new Uint32Array(e[o.f.length]);o.f.forEach((l,c)=>l.forEach((_,d)=>{n(_),a[e[c]+d]=_}));for(const[l,c]of o.edge_order??o.e??[])n(l),n(c);const r={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:a.length};for(const l of o.attributes??[])if(l.domain!=="EDGE"&&l.data.length!==r[l.domain])throw new Error(`Runtime attribute ${l.name} has ${l.data.length} values for ${r[l.domain]} ${l.domain} elements`);const i=(o.attributes??[]).filter(l=>l.type==="FLOAT2"&&l.domain==="CORNER"),f=o.render_uv??o.active_uv??i[0]?.name,u=i.find(l=>l.name===f);if(f&&!u)throw new Error(`Runtime UV map ${f} is missing`);const h=u?.data,s={vertexCount:t.length,normals:ae(o,o.attributes?.find(l=>l.name==="custom_normal")),co:n,starts:e,cornerVerts:a,smooth:l=>!!o.s?.[l],material:l=>o.m?.[l]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:h?l=>h[l]:null,uvLayers:i.map(l=>({name:l.name,read:c=>l.data[c]})),attributeLayers:re(o.attributes??[],l=>Array.from(l).flat())};return xn(le(s))}const sn=1.5707963267948966,Ct=6.283185307179586,ie=.3183098861837067,se=.0795774715459476,Ua=.3,Wa=se,Ha=3/16*ie,Gn=.8,Oo=Gn*Gn,kt=6371,fe=100,Xn=kt+fe,To=64,Ao=64,et=256,Rt=64,qa=[1.679,1.828,1.986,1.307],Ga=[.006605,.01067,.01842,.03156],Xa=[3472e-28,3914e-28,1349e-28,1103e-29],Ya=334.5,Za=[28722e-28,46168e-28,79706e-28,13578e-27],Qa=[15908e-26,17711e-26,20942e-26,24033e-26],Po=13681e16,Ka=2e6,Ja=.73,Dn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],yt=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],An=o=>o*o,on=o=>o<0?0:o>1?1:o,Ot=(o,t,n)=>o+n*(t-o),tr=o=>Math.sqrt(Math.max(o,0)),ce=o=>[-Math.sqrt(1-o*o),0,o];function Yn(o,t,n,e,a,r,i){const f=o*e+t*a+n*r,u=o*o+t*t+n*n-i*i;if(u>0&&f>0)return-1;const h=f*f-u;return h<0?-1:h>=f*f?-f+Math.sqrt(h):-f-Math.sqrt(h)}const nr=o=>Ha*(1+An(o));function or(o){const t=1+Oo+2*Gn*o;return se*(1-Oo)/(t*Math.sqrt(t))}const er=o=>Po*(Math.exp(-o/Ja)+Ka/Po);function eo(o,t){let n=o%Ct;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=sn||n<=-sn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Ct,e<0&&(e+=Ct),e=Ct-e,[n,e]}class ar{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array(Rt*et*4)}coefficients(t,n){const e=er(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-An(a-3.22261)*5.55555555-a),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=Za[f]*e,n[4+f]=Qa[f]*e,n[8+f]=Xa[f]*Ya*r*this.ozone,n[12+f]=Ga[f]*i*this.air}transmittance(t,n,e){const[a,r,i]=ce(t),f=Ot(kt,Xn,n),h=Yn(0,0,f,a,r,i,Xn)/To,s=[0,0,0,0],l=new Float64Array(16);for(let c=0;c<To;c++){const _=(c+.5)*h,d=a*_,m=r*_,p=f+i*_,v=Math.max(Math.hypot(d,m,p)-kt,0);this.coefficients(v,l);for(let g=0;g<4;g++)s[g]+=(l[g]+l[4+g]+l[8+g]+l[12+g])*h}for(let c=0;c<4;c++)e[c]=Math.exp(-s[c])}precompute(){const t=new Float64Array(4);for(let n=0;n<Rt;n++)for(let e=0;e<et;e++){const a=e/(et-1),r=n/(Rt-1);this.transmittance(a*2-1,r,t);const i=(n*et+e)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,n,e){const a=(et-1)*on(t*.5+.5),r=(Rt-1)*on(n),i=Math.trunc(a),f=Math.trunc(r),u=Math.min(i+1,et-1),h=Math.min(f+1,Rt-1),s=a-i,l=r-f,c=(f*et+i)*4,_=(f*et+u)*4,d=(h*et+i)*4,m=(h*et+u)*4;for(let p=0;p<4;p++)e[p]=Ot(Ot(this.lut[c+p],this.lut[_+p],s),Ot(this.lut[d+p],this.lut[m+p],s),l)}lookupAtGround(t,n){const e=(et-1)*on(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,et-1),i=e-a;for(let f=0;f<4;f++)n[f]=Ot(this.lut[a*4+f],this.lut[r*4+f],i)}lookupToSun(t,n){const e=(Rt-1)*on(t),a=Math.trunc(e),r=Math.min(a+1,Rt-1),i=e-a,f=et-1;for(let u=0;u<4;u++)n[u]=Ot(this.lut[(a*et+f)*4+u],this.lut[(r*et+f)*4+u],i)}inscattering(t,n,e,a,r,i,f,u,h){const s=-(r*t[0]+i*t[1]+f*t[2]),l=nr(s),c=or(s),_=u/Ao,d=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),w=new Float64Array(4),y=[0,0,0,0],S=[1,1,1,1];for(let T=0;T<Ao;T++){const A=(T+.5)*_,O=n+r*A,E=e+i*A,C=a+f*A,V=Math.hypot(O,E,C),H=Math.max(V-kt,0),Q=H/fe,tt=(O*t[0]+E*t[1]+C*t[2])/V;this.coefficients(H,d),this.lookup(tt,Q,m);const pt=Ct*(1-tr(1-An(kt/V)));this.lookupAtGround(tt,v),this.lookupToSun(0,g),this.lookupToSun(Q,w);const b=1/(1+5*Math.exp(-17.92*tt)),L=[.217,.347,.594,1];for(let z=0;z<4;z++){const Y=g[z]/w[z],Z=Wa*pt*(Ua*ie)*v[z]*Y*tt;p[z]=.02*L[z]*b+Z}for(let z=0;z<4;z++){const Y=d[z]+d[4+z]+d[8+z]+d[12+z],Z=qa[z]*(d[12+z]*(l*m[z]+p[z])+d[4+z]*(c*m[z]+p[z])),k=Math.exp(-_*Y),G=Math.max(Y,1e-7);y[z]+=S[z]*((Z-Z*k)/G),S[z]*=k}}for(let T=0;T<4;T++)h[T]=y[T]}}const st=512,qt=256;function ue(o,t){const n=new ar(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=ce(Math.cos(sn-t)),r=new Float32Array(st*qt*3),i=st/2,f=new Float64Array(4);for(let u=0;u<qt;u++)for(let h=0;h<i;h++){const s=(h+.5)/st,l=(u+.5)/qt,c=Ct*s,_=l*2-1,d=Math.sign(_)*An(_)*sn,m=Math.cos(d)*Math.cos(c),p=Math.cos(d)*Math.sin(c),v=Math.sin(d),g=kt+e,w=Yn(0,0,g,m,p,v,Xn),y=Yn(0,0,g,m,p,v,kt),S=y<0?w:y;n.inscattering(a,0,0,g,m,p,v,S,f);let T=0,A=0,O=0;for(let V=0;V<4;V++)T+=Dn[V][0]*f[V],A+=Dn[V][1]*f[V],O+=Dn[V][2]*f[V];const E=(u*st+h)*3;r[E]=T,r[E+1]=A,r[E+2]=O;const C=(u*st+(st-h-1))*3;r[C]=T,r[C+1]=A,r[C+2]=O}return r}function rr(o){const[t]=eo(o.sunElevation,o.sunRotation);return ue(o,t)}function ao(o){const[t]=eo(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const lr=6,Wt=new Map;function ir(o){return Wt.has(ao(o))}function _e(o,t){Wt.set(ao(o),t),Wt.size>lr&&Wt.delete(Wt.keys().next().value)}function sr(o){const[t,n]=eo(o.sunElevation,o.sunRotation),e=ao(o);let a=Wt.get(e);a===void 0&&(a=ue(o,t),_e(o,a));const r=new x;return i=>{const f=Math.hypot(i.x,i.y),u=Math.atan2(i.z,f);let s=(Math.atan2(i.x,i.y)+Math.PI+n)/Ct;s-=Math.floor(s);const l=Math.abs(u),c=on(Math.sqrt(l/sn)*Math.sign(u)*.5+.5),_=s*st-.5,d=c*qt-.5,m=Math.floor(_),p=Math.floor(d),v=_-m,g=d-p,w=C=>(C%st+st)%st,y=C=>C<0?0:C>qt-1?qt-1:C,S=w(m),T=w(m+1),A=y(p),O=y(p+1),E=[0,0,0];for(let C=0;C<3;C++){const V=Ot(a[(A*st+S)*3+C],a[(A*st+T)*3+C],v),H=Ot(a[(O*st+S)*3+C],a[(O*st+T)*3+C],v);E[C]=Ot(V,H,g)}return r.set(yt[0][0]*E[0]+yt[0][1]*E[1]+yt[0][2]*E[2],yt[1][0]*E[0]+yt[1][1]*E[1]+yt[1][2]*E[2],yt[2][0]*E[0]+yt[2][1]*E[1]+yt[2][2]*E[2])}}let Pt=null,cn=!1,fr=0;const en=new Map;function cr(){if(Pt||cn)return Pt;if(typeof Worker>"u")return cn=!0,null;try{Pt=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return cn=!0,null}return Pt.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,a=en.get(t);a&&(en.delete(t),n?a.resolve(n):a.reject(new Error(e??"sky worker returned nothing")))},Pt.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of en.values())n.reject(t);en.clear(),Pt?.terminate(),Pt=null,cn=!0},Pt}function ur(o){const t=cr();if(!t)return Promise.resolve(rr(o));const n=fr++,e={id:n,parameters:o};return new Promise((a,r)=>{en.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function _r(o,t,n,e={}){switch(e.type??"LINEAR"){case"QUADRATIC":{const a=Math.max(o,0);return a*a}case"EASING":{const a=Math.min(1,Math.max(0,o));return a*a*(3-2*a)}case"DIAGONAL":return(o+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(o,t,n),0);case"QUADRATIC_SPHERE":{const a=Math.max(.999999-Math.hypot(o,t,n),0);return a*a}case"RADIAL":return Math.atan2(t,o)/(2*Math.PI)+.5;default:return o}}const zn=(o,t)=>t!==0?o/t:0,So=o=>Math.min(1,Math.max(-1,o)),Eo=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},me={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:zn,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:zn(Math.log(o),Math.log(t)),SQRT:o=>Math.sqrt(Math.max(o,0)),INVERSE_SQRT:o=>o>0?1/Math.sqrt(o):0,ABSOLUTE:Math.abs,RADIANS:o=>o*Math.PI/180,DEGREES:o=>o*180/Math.PI,MINIMUM:(o,t)=>Math.min(o,t),MAXIMUM:(o,t)=>Math.max(o,t),LESS_THAN:(o,t)=>+(o<t),GREATER_THAN:(o,t)=>+(o>t),ROUND:o=>Math.floor(o+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:o=>o-Math.floor(o),MODULO:(o,t)=>t!==0?o%t:0,FLOORED_MODULO:(o,t)=>t!==0?o-Math.floor(o/t)*t:0,TRUNC:Math.trunc,SNAP:(o,t)=>Math.floor(zn(o,t))*t,WRAP:(o,t,n)=>t!==n?o-(t-n)*Math.floor((o-n)/(t-n)):n,PINGPONG:(o,t)=>{if(t===0)return 0;const n=(o-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:o=>Math.asin(So(o)),ARCCOSINE:o=>Math.acos(So(o)),ARCTANGENT:Math.atan,ARCTAN2:(o,t)=>o===0&&t===0?0:Math.atan2(o,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(o,t,n)=>+(o===t||Math.abs(o-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(o,t,n)=>o*t+n,SMOOTH_MIN:Eo,SMOOTH_MAX:(o,t,n)=>-Eo(-o,-t,n)};function nt(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const a=new x(...o);return()=>a}if(o.kind==="direction")return a=>a;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const a=nt(o.vector,t),r={type:o.gradient_type},i=new x;return f=>{const u=a(f),h=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,l=typeof u=="number"?u:u.z,c=ut.clamp(_r(h,s,l,r),0,1);return o.output==="Fac"?c:i.setScalar(c)}}if(o.kind==="to_float"){const a=nt(o.value,t);return r=>{const i=a(r);return typeof i=="number"?i:Math.fround(o.source_type==="RGBA"?i.x*.212639+i.y*.7151687+i.z*.0721923:(i.x+i.y+i.z)/3)}}if(o.kind==="math"){const a=o.inputs.map(f=>nt(f,t)),r=me[o.operation],i=(f,u)=>{const h=a[f]?.(u)??0;if(typeof h!="number")throw new Error("World Math needs scalar inputs");return Math.fround(h)};return f=>{const u=Math.fround(r(i(0,f),i(1,f),i(2,f)));return o.clamp?ut.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=nt(o.factor,t),r=nt(o.a,t),i=nt(o.b,t),f=new x,u=new x;return h=>{const s=a(h);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const l=r(h);typeof l=="number"?f.setScalar(l):f.copy(l);const c=i(h);return typeof c=="number"?u.setScalar(c):u.copy(c),f.lerp(u,o.clamp_factor?ut.clamp(s,0,1):s),o.clamp_result&&f.clampScalar(0,1),f}}if(o.kind==="sky"){const a=sr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return r=>a(r)}if(o.kind==="mapping"){const a=nt(o.vector,t),r=new x(...o.location),i=new x(...o.scale),f=new gt().setFromEuler(new Re(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=f.clone().invert(),h=new x(...o.scale.map(l=>l===0?0:1/l)),s=new x;return l=>{const c=a(l);switch(typeof c=="number"?s.setScalar(c):s.copy(c),o.vector_type??"POINT"){case"TEXTURE":return s.sub(r).applyQuaternion(u).multiply(h);case"VECTOR":return s.multiply(i).applyQuaternion(f);case"NORMAL":return s.multiply(h).applyQuaternion(f).normalize();case"POINT":return s.multiply(i).applyQuaternion(f).add(r)}}}if(o.kind==="map_range"){const a=nt(o.value,t),r=nt(o.from_min,t),i=nt(o.from_max,t),f=nt(o.to_min,t),u=nt(o.to_max,t),h=nt(o.steps,t),s=(_,d)=>{const m=_(d);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},l=o.interpolation,c=o.clamp;return _=>{const d=s(a,_),m=s(r,_),p=s(i,_),v=s(f,_),g=s(u,_);if(m===p)return 0;let w;if(l==="STEPPED"){const S=s(h,_),T=(d-m)/(p-m);w=S>0?Math.floor(T*(S+1))/S:0}else if(l==="SMOOTHSTEP"||l==="SMOOTHERSTEP"){const S=ut.clamp((d-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=l==="SMOOTHSTEP"?S*S*(3-2*S):S*S*S*(S*(S*6-15)+10);w=m>p?1-T:T}else w=(d-m)/(p-m);const y=v+w*(g-v);return c?v>g?ut.clamp(y,g,v):ut.clamp(y,v,g):y}}if(o.kind==="separate"){const a=nt(o.vector,t);return r=>{const i=a(r);return typeof i=="number"?i:i.getComponent(o.axis)}}const n=nt(o.factor,t),e=new x;return a=>{const r=n(a);if(typeof r!="number")throw new Error("World ColorRamp needs a scalar factor");const i=ut.clamp(r,0,1)*256,f=Math.floor(i),u=o.colors[f],h=o.colors[Math.min(f+1,256)],s=o.interpolate?i-f:0;return e.set(ut.lerp(u[0],h[0],s),ut.lerp(u[1],h[1],s),ut.lerp(u[2],h[2],s))}}function mr(o,t,n,e){const a=new Float32Array(t*n*3),r=nt(o,e),i=new x;for(let f=0;f<n;f++){const u=((f+.5)/n-.5)*Math.PI;for(let h=0;h<t;h++){const s=((h+.5)/t-.5)*2*Math.PI;i.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const l=r(i),c=(f*t+h)*3;a[c]=typeof l=="number"?l:l.x,a[c+1]=typeof l=="number"?l:l.y,a[c+2]=typeof l=="number"?l:l.z}}return a}function Mo(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Et(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Et(o.vector);case"ramp":return Et(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Et);case"math":return o.inputs.some(Et);case"to_float":return Et(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Et);default:return!1}}function dr(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,i=nt(o,()=>r),f=new x,u=e.getWorldPosition(new x),h=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let l=0;l<t;l++){const c=(l+.5)/t,_=(s+.5)/n;r.set(c,_,0),e.isOrthographicCamera?f.copy(h):f.set(c*2-1,_*2-1,.5).unproject(e).sub(u).normalize(),f.set(f.x,-f.z,f.y);const d=i(f),m=(s*t+l)*3;a[m]=typeof d=="number"?d:d.x,a[m+1]=typeof d=="number"?d:d.y,a[m+2]=typeof d=="number"?d:d.z}return a}const J=M().finite(),hr=P({type:U(["POINT","SUN","SPOT","AREA"]),color:$([J,J,J]),energy:J,use_shadow:q().default(!0),radius:J.optional(),spot_size:J.optional(),spot_blend:J.optional(),shape:U(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:J.optional(),size_y:J.optional()}).strict();let Zn;function pr(){return Zn??=ma(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),vt()}),Zn}function vr(){return Zn??Promise.resolve()}const gr=o=>{const t=o.size??0,n=o.size_y??t;if(o.shape==="RECTANGLE")return[t,n];if(o.shape==="DISK"){const e=Math.sqrt(Math.PI*t*t/4);return[e,e]}if(o.shape==="ELLIPSE"){const e=Math.sqrt(Math.PI/4);return[t*e,n*e]}return[t,t]};function xr(o,t){const n=(i,f)=>t&&f(t)?t:new i;if(o.type==="SUN"){const i=n(Zo,f=>f.isDirectionalLight);return i.intensity=o.energy,i.color.setRGB(o.color[0],o.color[1],o.color[2],ft),i.castShadow=o.use_shadow,i}if(o.type==="POINT"){const i=n(Bn,f=>f.isPointLight);return i.intensity=o.energy/(4*Math.PI),i.distance=0,i.decay=2,i.color.setRGB(o.color[0],o.color[1],o.color[2],ft),i.castShadow=o.use_shadow,i}if(o.type==="SPOT"){const i=n(Un,f=>f.isSpotLight);return i.intensity=o.energy/(4*Math.PI),i.distance=0,i.decay=2,i.angle=(o.spot_size??0)/2,i.penumbra=o.spot_blend??0,i.color.setRGB(o.color[0],o.color[1],o.color[2],ft),i.castShadow=o.use_shadow,i}pr();const e=n(gn,i=>i.isRectAreaLight),[a,r]=gr(o);return e.width=a,e.height=r,e.intensity=o.energy/(Math.max(a*r,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],ft),e}function br(o,t,n){if(!o.castShadow||n<=0)return;const a=o.getWorldPosition(new x).distanceTo(t),r=o.shadow;if(!r)return;const i=r.camera;i.near=Math.max(n*.001,a-n),i.far=a+n,o.isDirectionalLight&&(i.left=-n,i.right=n,i.top=n,i.bottom=-n),i.updateProjectionMatrix()}function yr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ro=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],No=.69;class wr{constructor(){this.group=new ot,this.lights=[],this.group.name="BlenderSolidStudio";const t=new Yo;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new ht(0,0,0);for(const[a,r]of ro.entries()){const i=(1+r.smooth)**2,f=new Zo(16777215,Math.PI*No/i);f.name=`BlenderSolidLight${a}`,f.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],ft),f.position.set(r.direction[0],r.direction[1],r.direction[2]),f.target=t,this.group.add(f),this.lights.push(f),n.r+=r.diffuse[0]*r.smooth/i,n.g+=r.diffuse[1]*r.smooth/i,n.b+=r.diffuse[2]*r.smooth/i}const e=new Ie(16777215,Math.PI*No);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Ut=$([J,J,J]),W=oe(()=>Nt([J,Ut,P({kind:j("direction")}).strict(),P({kind:j("window")}).strict(),P({kind:j("gradient"),gradient_type:U(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:U(["Fac","Color"]),vector:W}).strict(),P({kind:j("to_float"),source_type:U(["RGBA","VECTOR"]),value:W}).strict(),P({kind:j("math"),operation:U(Object.keys(me)),clamp:q(),inputs:F(W).min(1).max(3)}).strict(),P({kind:j("mix_color"),factor:W,a:W,b:W,clamp_factor:q(),clamp_result:q()}).strict(),P({kind:j("mapping"),vector_type:U(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:W,location:Ut,rotation:Ut,scale:Ut}).strict(),P({kind:j("separate"),vector:W,axis:M().int().min(0).max(2)}).strict(),P({kind:j("ramp"),factor:W,colors:F(Ut).length(257),interpolate:q()}).strict(),P({kind:j("map_range"),interpolation:U(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:q(),value:W,from_min:W,from_max:W,to_min:W,to_max:W,steps:W}).strict(),P({kind:j("sky"),sun_elevation:J,sun_rotation:J,altitude:J,air_density:J,aerosol_density:J,ozone_density:J}).strict()])),Ro=P({color:Ut,strength:J,shader:W.optional()}),Or=Ro.extend({volume:F(P({kind:U(["absorption","scatter","principled","emission"]),phase:N(),alpha:W,weight:W,color:W,density:W,anisotropy:W,absorption_color:W,emission_color:W,emission_strength:W,blackbody_intensity:W,temperature:W,blackbody_tint:W}).strict()).optional(),lighting:Ro.strict().optional()}).strict(),Tr=4,tn=new Map,Cn=new Set;function Io(o,t,n){const r=Et(o);if(r&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const i=JSON.stringify([o,r?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),f=tn.get(i);if(f!==void 0)return Qn(f,t,256,128);const u=new x,h=new no,s=n?new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,l=n?.getWorldPosition(new x),_=mr(o,256,128,r?d=>(u.set(d.x,d.z,-d.y),n.isPerspectiveCamera&&u.add(l),h.set(u.x,u.y,u.z,1).applyMatrix4(s),h.w===0?u.set(0,0,0):u.set(h.x/h.w*.5+.5,h.y/h.w*.5+.5,0)):void 0);return tn.set(i,_),tn.size>Tr&&tn.delete(tn.keys().next().value),Qn(_,t,256,128)}function Ar(o,t,n,e){const a=nn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=nn.toHalfFloat(t[r*3]*n),o[r*4+1]=nn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=nn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function Qn(o,t,n,e){const a=new Uint16Array(n*e*4);Ar(a,o,t,n*e);const r=new Sn(a,n,e,En,oo);return r.mapping=De,r.colorSpace=ft,r.minFilter=Vt,r.magFilter=Vt,r.needsUpdate=!0,r}class lo{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const a=lo.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,i=this.generation,u=[...Mo(r),...n.lighting?Mo(n.lighting.shader??n.lighting.color):[]].filter(s=>!ir(s));if(u.length===0){this.compose(a,n,r,e);return}const h=(async()=>{const s=await Promise.all(u.map(ur));u.forEach((l,c)=>{_e(l,s[c])}),!(this.generation!==i||this.applied?.scene!==a)&&(this.compose(a,n,r,e),vt())})();this.pending=h,Cn.add(h),h.then(()=>Cn.delete(h),()=>Cn.delete(h))}compose(t,n,e,a){if(this.texture=Io(e,n.strength,a),Et(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=Qn(dr(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=Fe,t.background=this.screenTexture}else if(a&&a.isOrthographicCamera){const i=a.getWorldDirection(new x);i.set(i.x,-i.z,i.y);const f=nt(n.shader??n.color)(i);t.background=typeof f=="number"?new ht().setRGB(f,f,f).multiplyScalar(n.strength):new ht().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?Io(r.shader??r.color,r.strength,a):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function de(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Pr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=de(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new Ft(new x(1,0,0),-o.min.x),new Ft(new x(-1,0,0),o.max.x),new Ft(new x(0,1,0),-o.min.y),new Ft(new x(0,-1,0),o.max.y),new Ft(new x(0,0,1),-o.min.z),new Ft(new x(0,0,-1),o.max.z)],a=[],r=new x,i=new x,f=new x,u=new x,h=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let l=s+1;l<e.length;l++)for(let c=l+1;c<e.length;c++){const _=e[s],d=e[l],m=e[c];r.crossVectors(d.normal,m.normal);const p=_.normal.dot(r);Math.abs(p)<1e-12||(i.crossVectors(m.normal,_.normal),f.crossVectors(_.normal,d.normal),u.copy(r).multiplyScalar(-_.constant).addScaledVector(i,-d.constant).addScaledVector(f,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-h)&&a.push(u.clone()))}return a}function Sr(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new wn().setFromPoints(t.map(c=>c.clone().applyMatrix4(a))),i=r.getSize(new x),f=Math.max(i.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,h=Math.max(i.x,i.y,f)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*h,l=u*h;r.min.x-=l,r.min.y-=l,r.max.x+=l,r.max.y+=l;for(const c of n){if(c.isEmpty())continue;const _=new wn().setFromPoints(de(c).map(d=>d.applyMatrix4(a)));_.max.x<r.min.x||_.min.x>r.max.x||_.max.y<r.min.y||_.min.y>r.max.y||(r.min.z=Math.min(r.min.z,_.min.z),r.max.z=Math.max(r.max.z,_.max.z))}e.left=r.min.x,e.right=r.max.x,e.bottom=r.min.y,e.top=r.max.y,e.near=-r.max.z-s-f,e.far=-r.min.z+s+f,e.updateProjectionMatrix(),o.shadow.normalBias=s}const Gt=M().finite(),Fo=$([Gt,Gt,Gt]),he=P({min:$([M().int(),M().int(),M().int()]),max:$([M().int(),M().int(),M().int()]),density:F(Gt),voxelSize:Gt.positive(),color:Fo,emission:Fo,densityScale:Gt.nonnegative()}).strict();function Er(o){const t=o.max.map((s,l)=>s-o.min[l]+1);if(t.some(s=>s<=0)||t.reduce((s,l)=>s*l,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new ze(new Float32Array(o.density),t[0],t[1],t[2]);n.format=Ce,n.type=Qo,n.minFilter=n.magFilter=Vt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),a=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),r=new ke(a.x,a.y,a.z),i=r.getAttribute("position");for(let s=0;s<i.count;s++)i.setXYZ(s,e.x+(i.getX(s)>0?a.x:0),e.y+(i.getY(s)>0?a.y:0),e.z+(i.getZ(s)>0?a.z:0));i.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere();const f=new to({glslVersion:Le,side:$e,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:e},extent:{value:a},voxelSize:{value:o.voxelSize},densityScale:{value:o.densityScale},volumeColor:{value:new x(...o.color)},emission:{value:new x(...o.emission)},cameraLocal:{value:new x},rayLocal:{value:new x},orthographic:{value:!1},worldScale:{value:new Xo}},vertexShader:`
|
|
19
|
+
`;function zt(o){return new wt().setHex(o,Ct)}function Ao(o,t){const n=o.mode==="POSE";let e;return n?t.active&&t.select?e=zt(Pt.poseActive):t.active?e=zt(Pt.poseActiveUnsel):t.select?e=zt(Pt.pose):e=zt(Pt.wire):e=zt(Pt.vertex),n&&t.lockedWeight&&e.lerp(zt(Pt.lockedWeight),Pt.lockedWeightFactor),e}function Po(o,t){const n=zt(Pt.solid);return o.mode==="POSE"&&t.lockedWeight&&n.lerp(zt(Pt.lockedWeight),Pt.lockedWeightFactor),n}const Ca=new tt,ka=new x,So=new ae;function Eo(o,t){return new tt().set(...t.matrix.flat()).premultiply(o).scale(new x().setScalar(t.length))}class $a{constructor(){this.group=new lt,this.disposables=[],this.signature="",this.group.name="BlenderArmatureOverlay"}apply(t,n){const e=[],a=JSON.stringify(t);if(a===this.signature)return e;this.signature=a,this.clear();for(const r of Object.values(t)){const i=n(r.object);if(i===null)continue;r.displayType!=="OCTAHEDRAL"&&r.displayType!=="STICK"&&e.push(`armature ${r.object}: Blender's ${r.displayType} bone display needs data this door does not carry (B-Bone segment matrices, envelope radii), so its bones are drawn octahedral`),r.mode==="EDIT"&&e.push(`armature ${r.object}: in Edit Mode Blender draws the EDIT bones, and this overlay draws the pose — the shapes are the rest pose, not the edited one`);const f=r.bones.filter(h=>!h.hide);if(f.length===0)continue;const u=r.displayType==="STICK"?this.buildStick(r,f,i):this.buildOctahedral(r,f,i);r.showInFront&&u.traverse(h=>{const s=h.material;s&&"depthTest"in s&&(s.depthTest=!1),h.renderOrder=10}),this.group.add(u)}return e}buildOctahedral(t,n,e){const a=new lt;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[],h=[],s=[],l=[],c=[],_=[],d=[];for(const m of n){const p=Eo(e,m),v=Po(t,m),g=Ea(v),w=Ao(t,m);So.setFromMatrix4(p).invert().transpose();for(let T=0;T<Oo.length;T++){const A=ka.set(...Ma[T]).applyMatrix3(So).normalize().clone();for(const O of Oo[T]){const M=new x(...kn[O]).applyMatrix4(p);r.push(M.x,M.y,M.z),i.push(A.x,A.y,A.z),f.push(v.r,v.g,v.b),u.push(g.r,g.g,g.b)}}const y=To(m)===2?l:h,S=To(m)===2?c:s;for(const[T,A]of Na){const O=new x(...kn[T]).applyMatrix4(p),M=new x(...kn[A]).applyMatrix4(p);y.push(O.x,O.y,O.z,M.x,M.y,M.z),S.push(w.r,w.g,w.b,w.r,w.g,w.b)}m.parent!==null&&m.connected||(_.push(p.clone()),d.push(v)),_.push(p.clone().multiply(Ca.makeTranslation(0,1,0))),d.push(v)}a.add(this.solidMesh(r,i,f,u)),h.length&&a.add(this.lines(h,s,1)),l.length&&a.add(this.lines(l,c,2));for(let m=0;m<_.length;m++)a.add(this.point(_[m],d[m]));return a}buildStick(t,n,e){const a=new lt;a.name=`${t.object}:bones`;const r=[],i=[],f=[],u=[];for(const h of n){const s=Eo(e,h),l=new x().setFromMatrixPosition(s),c=new x(0,1,0).applyMatrix4(s),_=Ao(t,h),d=Po(t,h);r.push(l.x,l.y,l.z,c.x,c.y,c.z),i.push(_.r,_.g,_.b,_.r,_.g,_.b),f.push(l.x,l.y,l.z,c.x,c.y,c.z),u.push(d.r,d.g,d.b,d.r,d.g,d.b)}return a.add(this.lines(r,i,Ia)),a.add(this.lines(f,u,Fa)),a}solidMesh(t,n,e,a){const r=new hn;r.setAttribute("position",new St(t,3)),r.setAttribute("normal",new St(n,3)),r.setAttribute("aSolid",new St(e,3)),r.setAttribute("aHint",new St(a,3));const i=new so({vertexShader:za,fragmentShader:Da,side:Ce});this.disposables.push(r,i);const f=new Rt(r,i);return f.frustumCulled=!1,f}lines(t,n,e){const a=new ne;a.setPositions(t),a.setColors(n);const r=new oe({linewidth:e,vertexColors:!0});this.disposables.push(a,r);const i=new ee(a,r);return i.frustumCulled=!1,i}point(t,n){const e=new ke(Ra,12,8),a=new En({color:n});this.disposables.push(e,a);const r=new Rt(e,a);return r.applyMatrix4(t),r.frustumCulled=!1,r}clear(){for(const t of[...this.group.children])this.group.remove(t);for(const t of this.disposables)t.dispose();this.disposables.length=0}dispose(){this.clear(),this.signature=""}}const Mo="RUNTIME_FRAME_UNKNOWN_GEOMETRY",en="RUNTIME_FRAME_UNKNOWN_IMAGE";function La(o){const t=Math.fround,n=t(t(t(o[0]*o[0])+t(o[1]*o[1]))+t(o[2]*o[2]));if(n>1e-35){const e=t(Math.sqrt(n)),a=t(1/e);return{unit:[t(o[0]*a),t(o[1]*a),t(o[2]*a)],length:e}}return{unit:[0,0,0],length:0}}const I=Math.fround,Rn=I(2*Math.PI),$n=I(1-1e-4),Bt=(o,t)=>I(I(I(o[0]*t[0])+I(o[1]*t[1]))+I(o[2]*t[2])),_n=(o,t,n=1)=>o.map((e,a)=>I(e+I(t[a]*n))),Va=(o,t)=>o.map((n,e)=>I(n-t[e]));function an(o){const t=I(Math.sqrt(Bt(o,o)));return t>0?o.map(n=>I(n/t)):[0,0,0]}function rn(o){const t=Math.abs(o)<1?I(1-I(1-Math.abs(o))):1;let n=I(I(.077980478)+I(t*I(-.02164095)));n=I(I(-.213300989)+I(t*n)),n=I(I(1.5707963267)+I(t*n));const e=I(I(Math.sqrt(I(1-t)))*n);return o<0?I(I(Math.PI)-e):e}function ja(o){let t=o.at(-1);const n=[0,0,0];for(const e of o){for(let a=0;a<3;a++){const r=(a+1)%3,i=(a+2)%3;n[a]=I(n[a]+I(I(t[r]-e[r])*I(t[i]+e[i])))}t=e}return n}function Ba(o){const t=[],n=[],e=(d,m)=>d<m?`${d}:${m}`:`${m}:${d}`,a=new Map((o.edge_order??[]).map(([d,m],p)=>[e(d,m),p])),r=new Set((o.sharp??[]).map(([d,m])=>e(d,m))),i=new Map;for(const[d,m]of o.f.entries()){const p=t.length,v=La(ja(m.map(g=>o.v[g]))).unit;n.push(v.some(Boolean)?v:[0,0,1]);for(let g=0;g<m.length;g++){const w=e(m[g],m[(g+1)%m.length]);a.has(w)||a.set(w,a.size);const y=o.face_edges?.[d]?.[g]??a.get(w),S=t.length;t.push({vertex:m[g],face:d,edge:y,prev:p+(g+m.length-1)%m.length,next:p+(g+1)%m.length});const T=i.get(y)??[];T.push(S),i.set(y,T)}}const f=new Map,u=new Map;for(const[d,m]of i){if(m.length!==2||o.edge_sharp?.[d])continue;const[p,v]=m,g=t[p],w=t[v];!o.s?.[g.face]||!o.s?.[w.face]||g.vertex!==t[w.next].vertex||w.vertex!==t[g.next].vertex||!o.edge_sharp&&r.has(e(g.vertex,w.vertex))||(u.set(p,w.next),f.set(w.next,p),u.set(v,g.next),f.set(g.next,v))}const h=[],s=[],l=[],c=[],_=(d,m)=>an(Va(o.v[t[t[d][m]].vertex],o.v[t[d].vertex]));for(let d=0;d<t.length;d++){if(s[d]!==void 0)continue;let m=d;const p=new Set([m]);for(;u.has(m)&&!p.has(u.get(m));)m=u.get(m),p.add(m);u.has(m)&&(m=Math.min(...p));const v=[m];for(;f.has(v.at(-1))&&f.get(v.at(-1))!==m;)v.push(f.get(v.at(-1)));let g=[0,0,0];if(v.length===1)g=n[t[m].face];else{for(const M of v)g=_n(g,n[t[M].face],rn(Bt(_(M,"prev"),_(M,"next"))));g=an(g)}const w=_(m,"next"),y=v.at(-1),S=_(y,"prev"),T=Bt(w,g),A=Bt(S,g),O={normal:g,reference:[0,0,0],ortho:[0,0,0],alpha:0,beta:0};if(Math.abs(T)<$n&&Math.abs(A)<$n){const M=v.length>1?v.map(st=>_(st,"next")):[];M.length&&t[t[y].prev].edge!==t[m].edge&&M.push(S),O.alpha=M.length?I(M.reduce((st,b)=>I(st+rn(Bt(b,g))),0)/M.length):I(I(rn(T)+rn(A))/2),O.reference=an(_n(w,g,-T));const k=g,j=O.reference;O.ortho=an([I(I(k[1]*j[2])-I(k[2]*j[1])),I(I(k[2]*j[0])-I(k[0]*j[2])),I(I(k[0]*j[1])-I(k[1]*j[0]))]);const q=an(_n(S,g,-A)),Q=Bt(O.reference,q),K=rn(Q);O.beta=Q<$n?Bt(O.ortho,q)<0?I(Rn-K):K:Rn}O.alpha===0&&(O.normal=[0,0,0]);for(const M of v)s[M]=h.length;h.push(v),l.push(O),c.push(g)}return{corners:t,fans:h,fanOf:s,spaces:l,faceNormals:n,fanNormals:c}}function Ua(o,t){if(!t[0]||o.alpha===0||o.beta===0)return o.normal;const n=I(t[0]/32767),e=I(t[1]/32767),a=I((n>0?o.alpha:I(Rn-o.alpha))*n),r=I((e>0?o.beta:I(Rn-o.beta))*e);let i=o.normal.map(f=>I(f*I(Math.cos(a))));return i=_n(i,o.reference,I(I(Math.sin(a))*I(Math.cos(r)))),e!==0&&(i=_n(i,o.ortho,I(I(Math.sin(a))*I(Math.sin(r))))),i}function de(o,t){if(!t)return null;const{corners:n,fans:e,spaces:a}=Ba(o);if(t.type==="INT16_2D"&&t.domain==="CORNER"){const r=new Array(n.length);for(const[i,f]of e.entries()){const u=f.reduce((s,l)=>{const c=t.data[l];return[s[0]+c[0],s[1]+c[1]]},[0,0]),h=Ua(a[i],u.map(s=>Math.trunc(s/f.length)));for(const s of f)r[s]=h}return r}if(t.type==="FLOAT_VECTOR")return n.map((r,i)=>{const f=t.domain==="POINT"?r.vertex:t.domain==="FACE"?r.face:i;return t.data[f]});throw new Error(`Unsupported custom_normal attribute: ${t.type}/${t.domain}`)}const Ln={FLOAT:{size:1},INT:{size:1},INT8:{size:1},BOOLEAN:{size:1},FLOAT2:{size:2},FLOAT_VECTOR:{size:3},FLOAT_COLOR:{size:4},BYTE_COLOR:{size:4},INT16_2D:{size:2},INT32_2D:{size:2},QUATERNION:{size:4},FLOAT4X4:{size:16},FLOAT4:{size:4},STRING:{size:1}},Wa=1e-6;function Ha(o){const t=new x;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t.x+=(e.y-a.y)*(e.z+a.z),t.y+=(e.z-a.z)*(e.x+a.x),t.z+=(e.x-a.x)*(e.y+a.y)}return t.multiplyScalar(.5)}const qa=(o,t,n)=>(t.x-o.x)*(n.y-o.y)-(t.y-o.y)*(n.x-o.x),No=o=>Array.from({length:o-2},(t,n)=>[0,n+1,n+2]);function Ga(o){let t=0;for(let n=0;n<o.length;n++){const e=o[n],a=o[(n+1)%o.length];t+=e.x*a.y-a.x*e.y}return t}function Ro(o,t,n){if(o.length!==t.length-2||!(Math.abs(n)>0))return!1;const e=Math.sign(n);let a=0;for(const[r,i,f]of o){const u=qa(t[r],t[i],t[f]);if(u*e<0)return!1;a+=Math.abs(u)}return Math.abs(a-Math.abs(n))<=Wa*Math.abs(n)}function Xa(o){const t=o.length;if(t<3)return{triangles:[],sound:!1,method:"fan"};if(t===3)return{triangles:[[0,1,2]],sound:!0,method:"fan"};const n=Ha(o),e=n.length();if(!(e>0)||!Number.isFinite(e))return{triangles:No(t),sound:!1,method:"fan"};const a=n.clone().divideScalar(e),r=Math.abs(a.x)<.9?new x(1,0,0):new x(0,1,0),i=new x().crossVectors(r,a).normalize(),f=new x().crossVectors(a,i),u=o[0],h=o.map(_=>{const d=_.clone().sub(u);return new qt(d.dot(i),d.dot(f))}),s=Ga(h),l=No(t);if(Ro(l,h,s))return{triangles:l,sound:!0,method:"fan"};let c=[];try{c=$e.triangulateShape(h,[]).map(_=>[_[0],_[1],_[2]])}catch{return{triangles:l,sound:!1,method:"fan"}}return Ro(c,h,s)?{triangles:c,sound:!0,method:"earcut"}:{triangles:c.length>0?c:l,sound:!1,method:c.length>0?"earcut":"fan"}}const Ya=new Set(["FLOAT","FLOAT2","FLOAT_VECTOR","FLOAT_COLOR","BYTE_COLOR"]);function Vn(o){const t=o/255;return t<.04045?t<0?0:t*(1/12.92):((t+.055)*(1/1.055))**2.4}function jn(o,t,n){switch(o){case"FLOAT":{const e=Number(t[n]);return[e,e,e,1]}case"FLOAT2":return[Number(t[n*2]),Number(t[n*2+1]),0,1];case"FLOAT_VECTOR":return[Number(t[n*3]),Number(t[n*3+1]),Number(t[n*3+2]),1];case"BYTE_COLOR":return[Vn(Number(t[n*4])),Vn(Number(t[n*4+1])),Vn(Number(t[n*4+2])),Number(t[n*4+3])/255];default:return[Number(t[n*4]),Number(t[n*4+1]),Number(t[n*4+2]),Number(t[n*4+3])]}}function uo(o,t){return o.filter(n=>Ya.has(n.type)&&n.domain!=="EDGE"&&!n.name.startsWith(".")&&n.name!=="position"&&n.name!=="custom_normal"&&!(n.type==="FLOAT2"&&n.domain==="CORNER")).map(n=>{const e=t(n.data,n.type),a=[0,0,0,0];return{name:n.name,domain:n.domain,read:(r,i,f)=>n.domain==="POINT"?jn(n.type,e,r):n.domain==="CORNER"?i===void 0?a:jn(n.type,e,i):f===void 0?a:jn(n.type,e,f)}})}function he(o){const t=o.vertexCount,n=o.starts.length-1,e=o.starts,a=o.cornerVerts,r=e[n];let i=t;for(let b=0;b<n;b++)i+=(e[b+1]-e[b]-2)*3;const f=new Uint32Array(r),u=new Uint8Array(r),h=new Uint8Array(t),s=new Uint32Array(r);let l=!1;for(let b=0;b<n;b++)if(o.smooth(b)){l=!0;break}const c=(b,V)=>t<94906265?Math.min(b,V)*t+Math.max(b,V):`${Math.min(b,V)}:${Math.max(b,V)}`,_=new Map,d=new Set;for(const[b,V]of o.sharp)d.add(c(b,V));if(o.edges)for(const[b,V]of o.edges){if(b===V)throw new Error("Runtime mesh edge needs distinct vertices");_.set(c(b,V),-1)}const m=b=>{for(;s[b]!==b;)s[b]=s[s[b]],b=s[b];return b},p=(b,V)=>{const z=m(b),X=m(V);s[Math.max(z,X)]=Math.min(z,X)};for(let b=0;b<n;b++){const V=e[b],z=e[b+1]-V,X=o.smooth(b)?1:0;for(let Y=0;Y<z;Y++){const $=V+Y;h[a[$]]=1,f[$]=V+(Y+1)%z,u[$]=X,s[$]=$}}for(let b=0;b<r;b++){const V=f[b],z=a[b],X=a[V],Y=c(z,X),$=_.get(Y);if($!==void 0&&$>=0&&u[b]&&u[$]&&!d.has(Y)){const E=f[$];p(b,a[$]===z?$:E),p(V,a[$]===z?E:$)}($===void 0||$<0||!u[$]&&u[b])&&_.set(Y,b)}const v=o.uv,g=new Float32Array(i*3),w=new Float32Array(i*2),y=new Uint32Array(i),S=(o.uvLayers??[]).map(b=>({...b,data:new Float32Array(i*2)})),T=(o.attributeLayers??[]).map(b=>({...b,data:new Float32Array(i*4)})),A=o.orco?new Float32Array(i*3):null,O=new Uint32Array(i),M=new Map,k=[],j=o.normals||o.cornerNormal?new Float32Array(i*3):null;let q=0,Q=0;const K=(b,V,z,X,Y)=>{const $=q++;for(const E of T)E.data.set(E.read(b,X,Y),$*4);if(A)for(let E=0;E<3;E++)A[$*3+E]=o.orco[b*3+E]*.5+.5;if(y[$]=b,o.co(b).toArray(g,$*3),V&&w.set(V,$*2),z&&j.set(z,$*3),X!==void 0)for(const E of S)E.data.set(E.read(X),$*2);return $},st=(b,V)=>{const z=v?.(b),X=o.cornerNormal?[o.cornerNormal[b*3],o.cornerNormal[b*3+1],o.cornerNormal[b*3+2]]:o.normals?.[b];if(!l)return K(a[b],z,X,b,V);const Y=`${u[b]?m(b):b}${z?`:${z[0]}:${z[1]}`:""}${X?`:n${X.join(":")}`:""}${S.map(E=>":"+E.read(b).join(":")).join("")}${T.map(E=>E.domain==="POINT"?"":":"+Array.from(E.read(a[b],b,V)).join(":")).join("")}`;let $=M.get(Y);return $===void 0&&($=K(a[b],z,X,b,V),M.set(Y,$)),$};for(let b=0;b<n;b++){const V=Q,z=e[b],X=e[b+1]-z,Y=[];for(let B=0;B<X;B++)Y.push(o.co(a[z+B]));for(const B of Xa(Y).triangles)for(const J of B)O[Q++]=st(z+J,b);const $=o.material(b),E=k.at(-1);E?.materialIndex===$?E.count+=Q-V:k.push({start:V,count:Q-V,materialIndex:$})}for(let b=0;b<t;b++)h[b]||K(b);return{positions:g.slice(0,q*3),normals:j?.slice(0,q*3)??null,uv:v?w.slice(0,q*2):null,uvLayers:S.map(b=>({name:b.name,data:b.data.slice(0,q*2)})),attributeLayers:T.map(b=>({name:b.name,data:b.data.slice(0,q*4)})),orco:A?A.slice(0,q*3):null,indices:O.slice(0,Q),sourceVertex:y.slice(0,q),groups:k}}function Xt(o){return`blenderA_${Array.from(new TextEncoder().encode(o),t=>t.toString(16).padStart(2,"0")).join("")}`}function Pn(o){const t=new hn;t.setAttribute("position",new dt(o.positions,3)),t.setAttribute("uv",new dt(o.uv??new Float32Array(o.positions.length/3*2),2)),t.setIndex(new dt(o.indices,1));const n=Object.create(null);for(const[e,a]of(o.uvLayers??[]).entries()){if(e>=8)throw new Error("A Blender mesh supports at most eight UV maps");n[a.name]=e+1,t.setAttribute(`uv${e+1}`,new dt(a.data,2))}t.userData.blenderUvChannels=n;for(const e of o.attributeLayers??[])t.setAttribute(Xt(e.name),new dt(e.data,4));t.userData.blenderAttributes=(o.attributeLayers??[]).map(e=>e.name),o.orco&&(t.setAttribute("blenderOrco",new dt(o.orco,3)),t.userData.blenderOrcoFromDoor=!0);for(const e of o.groups)t.addGroup(e.start,e.count,e.materialIndex);return o.normals?t.setAttribute("normal",new dt(o.normals,3)):t.computeVertexNormals(),o.sourceVertex&&t.setAttribute("blenderVertex",new dt(o.sourceVertex,1)),t}function Za(o,t){const n=o.cornerTri,e=o.cornerNormal,a=o.co.length/3,r=o.corner.length,i=o.faceStart.length-1,f=o.attributes.filter(E=>E.type==="FLOAT2"&&E.domain==="CORNER"),u=o.renderUv??o.activeUv??f[0]?.name,h=f.findIndex(E=>E.name===u);if(u&&h<0)throw new Error(`Runtime UV map ${u} is missing`);const s=uo(o.attributes,E=>E),l=3+f.length*2+s.length*4,c=new Float32Array(l),_=new Float32Array(l),d=new Uint32Array(c.buffer),m=new Uint32Array(_.buffer),p=new Uint32Array(r),v=new Uint32Array(r),g=new Uint32Array(r),w=new Uint32Array(r),y=new Uint8Array(a);let S=1;for(;S<Math.max(1,r*2);)S*=2;const T=new Uint32Array(S),A=(E,B,J,nt)=>{let ct=0;for(let rt=0;rt<3;rt++)nt[ct++]=e[E*3+rt];for(const rt of f)for(let it=0;it<2;it++)nt[ct++]=Number(rt.data[E*2+it]);for(const rt of s){const it=rt.read(J,E,B);for(let At=0;At<4;At++)nt[ct++]=Number(it[At])}};let O=0;for(let E=0;E<i;E++)for(let B=o.faceStart[E];B<o.faceStart[E+1];B++){const J=o.corner[B];if(J>=a)throw new Error("Native mesh corner references a missing vertex");p[B]=E,y[J]=1,A(B,E,J,c);let nt=Math.imul(J^2166136261,16777619);for(const it of d)nt=Math.imul(nt^it,16777619);const ct=nt>>>0&S-1;let rt=-1;for(let it=T[ct];it;it=w[it-1]){const At=it-1,Cn=g[At];if(o.corner[Cn]!==J)continue;A(Cn,p[Cn],J,_);let yo=!0;for(let pn=0;pn<l;pn++)if(d[pn]!==m[pn]){yo=!1;break}if(yo){rt=At;break}}rt<0&&(rt=O++,g[rt]=B,w[rt]=T[ct],T[ct]=rt+1),v[B]=rt}let M=0;for(const E of y)E||M++;const k=O+M,j=new Float32Array(k*3),q=new Float32Array(k*3),Q=new Uint32Array(k),K=f.map(E=>({name:E.name,data:new Float32Array(k*2)})),st=s.map(E=>({name:E.name,data:new Float32Array(k*4)})),b=o.orco?new Float32Array(k*3):null,V=(E,B)=>{Q[E]=B;for(let J=0;J<3;J++)j[E*3+J]=o.co[B*3+J],b&&(b[E*3+J]=o.orco[B*3+J]*.5+.5)};for(let E=0;E<O;E++){const B=g[E],J=o.corner[B];V(E,J),A(B,p[B],J,c),q.set(c.subarray(0,3),E*3);let nt=3;for(const ct of K)ct.data.set(c.subarray(nt,nt+2),E*2),nt+=2;for(const ct of st)ct.data.set(c.subarray(nt,nt+4),E*4),nt+=4}let z=O;for(let E=0;E<a;E++)if(!y[E]){V(z,E);for(let B=0;B<s.length;B++)st[B].data.set(s[B].read(E,void 0,void 0),z*4);z++}const X=new Uint32Array(n.length),Y=[];let $=0;for(let E=0;E<i;E++){const B=o.faceStart[E],J=o.faceStart[E+1],nt=Math.max(0,J-B-2)*3;if($+nt>n.length)throw new Error("Native mesh triangulation is incomplete");for(let it=0;it<nt;it++){const At=n[$+it];if(At<B||At>=J)throw new Error("Native triangle references a different face");X[$+it]=v[At]}const ct=o.material[E],rt=Y.at(-1);rt?.materialIndex===ct?rt.count+=nt:Y.push({start:$,count:nt,materialIndex:ct}),$+=nt}if($!==n.length)throw new Error("Native mesh triangulation has extra triangles");return{positions:j,normals:q,sourceVertex:Q,uv:h<0?null:K[h].data,uvLayers:K,attributeLayers:st,orco:b,indices:X,groups:Y,hash:t}}function Io(o,t){if(o.cornerTri&&o.cornerNormal)return Za(o,t);const n=o.co.length/3,e=o.attributes.filter(m=>m.type==="FLOAT2"&&m.domain==="CORNER"),a=o.renderUv??o.activeUv??e[0]?.name,r=e.find(m=>m.name===a);if(a&&!r)throw new Error(`Runtime UV map ${a} is missing`);const i=r?r.data:null,f=o.edge.length/2,u=new Array(f);for(let m=0;m<f;m++)u[m]=[o.edge[m*2],o.edge[m*2+1]];const h=[];for(let m=0;m<f;m++)o.edgeSharp[m]===1&&h.push(u[m]);const s=o.cornerNormal?void 0:o.attributes.find(m=>m.name==="custom_normal"),l=s?{v:Array.from({length:n},(m,p)=>[o.co[p*3],o.co[p*3+1],o.co[p*3+2]]),f:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.corner.subarray(o.faceStart[p],o.faceStart[p+1]))),s:Array.from(o.smooth,Boolean),edge_order:u,sharp:h,face_edges:Array.from({length:o.faceStart.length-1},(m,p)=>Array.from(o.cornerEdge.subarray(o.faceStart[p],o.faceStart[p+1]))),edge_sharp:Array.from(o.edgeSharp,Boolean)}:null,c=s?{type:s.type,domain:s.domain,data:Array.from({length:s.data.length/Ln[s.type].size},(m,p)=>Array.from({length:Ln[s.type].size},(v,g)=>Number(s.data[p*Ln[s.type].size+g])))}:void 0,_=new x,d={vertexCount:n,normals:l?de(l,c):null,cornerNormal:o.cornerNormal,orco:o.orco,co:m=>_.set(o.co[m*3],o.co[m*3+1],o.co[m*3+2]).clone(),starts:o.faceStart,cornerVerts:o.corner,smooth:m=>o.smooth[m]===1,material:m=>o.material[m],edges:u,sharp:h,uv:i?m=>[i[m*2],i[m*2+1]]:null,uvLayers:e.map(m=>({name:m.name,read:p=>[Number(m.data[p*2]),Number(m.data[p*2+1])]})),attributeLayers:uo(o.attributes,m=>m)};return{...he(d),hash:t}}function Qa(o){const t=o.v.map(l=>new x(...l)),n=l=>{const c=t[l];if(!c)throw new Error(`Runtime mesh vertex ${l} is missing`);return c},e=new Uint32Array(o.f.length+1);o.f.forEach((l,c)=>{if(l.length<3||new Set(l).size!==l.length)throw new Error("Runtime mesh face needs at least three distinct vertices");e[c+1]=e[c]+l.length});const a=new Uint32Array(e[o.f.length]);o.f.forEach((l,c)=>l.forEach((_,d)=>{n(_),a[e[c]+d]=_}));for(const[l,c]of o.edge_order??o.e??[])n(l),n(c);const r={POINT:t.length,EDGE:(o.edge_order??o.e??[]).length,FACE:o.f.length,CORNER:a.length};for(const l of o.attributes??[])if(l.domain!=="EDGE"&&l.data.length!==r[l.domain])throw new Error(`Runtime attribute ${l.name} has ${l.data.length} values for ${r[l.domain]} ${l.domain} elements`);const i=(o.attributes??[]).filter(l=>l.type==="FLOAT2"&&l.domain==="CORNER"),f=o.render_uv??o.active_uv??i[0]?.name,u=i.find(l=>l.name===f);if(f&&!u)throw new Error(`Runtime UV map ${f} is missing`);const h=u?.data,s={vertexCount:t.length,normals:de(o,o.attributes?.find(l=>l.name==="custom_normal")),co:n,starts:e,cornerVerts:a,smooth:l=>!!o.s?.[l],material:l=>o.m?.[l]??0,edges:o.edge_order??o.e??null,sharp:o.sharp??[],uv:h?l=>h[l]:null,uvLayers:i.map(l=>({name:l.name,read:c=>l.data[c]})),attributeLayers:uo(o.attributes??[],l=>Array.from(l).flat())};return Pn(he(s))}const dn=1.5707963267948966,Ut=6.283185307179586,pe=.3183098861837067,ve=.0795774715459476,Ka=.3,Ja=ve,tr=3/16*pe,no=.8,Fo=no*no,Wt=6371,ge=100,oo=Wt+ge,zo=64,Do=64,ft=256,$t=64,nr=[1.679,1.828,1.986,1.307],or=[.006605,.01067,.01842,.03156],er=[3472e-28,3914e-28,1349e-28,1103e-29],ar=334.5,rr=[28722e-28,46168e-28,79706e-28,13578e-27],lr=[15908e-26,17711e-26,20942e-26,24033e-26],Co=13681e16,ir=2e6,sr=.73,Bn=[[53.38691773856467,22.981337506691023,0],[43.90484446636936,71.3477957000534,.10250686796574131],[1.6137278251608962,18.422960591455485,31.742921188390806],[20.762668673810577,2.361421352331437,110.4800964325214]],Et=[[3.2409698963165283,-1.5373831987380981,-.49861079454421997],[-.969243586063385,1.8759675025939941,.041555099189281464],[.05563009902834892,-.20397700369358063,1.056971549987793]],In=o=>o*o,fn=o=>o<0?0:o>1?1:o,Nt=(o,t,n)=>o+n*(t-o),fr=o=>Math.sqrt(Math.max(o,0)),xe=o=>[-Math.sqrt(1-o*o),0,o];function eo(o,t,n,e,a,r,i){const f=o*e+t*a+n*r,u=o*o+t*t+n*n-i*i;if(u>0&&f>0)return-1;const h=f*f-u;return h<0?-1:h>=f*f?-f+Math.sqrt(h):-f-Math.sqrt(h)}const cr=o=>tr*(1+In(o));function ur(o){const t=1+Fo+2*no*o;return ve*(1-Fo)/(t*Math.sqrt(t))}const _r=o=>Co*(Math.exp(-o/sr)+ir/Co);function _o(o,t){let n=o%Ut;Math.abs(n)>=Math.PI&&(n-=Math.sign(n)*2*Math.PI);let e=t;return(n>=dn||n<=-dn)&&(n=Math.sign(n)*Math.PI-n,e+=Math.PI),e=e%Ut,e<0&&(e+=Ut),e=Ut-e,[n,e]}class mr{constructor(t,n,e){this.air=t,this.aerosol=n,this.ozone=e,this.lut=new Float32Array($t*ft*4)}coefficients(t,n){const e=_r(t)*this.aerosol,a=Math.log(Math.max(t,1e-4)),r=378547397e12*Math.exp(-In(a-3.22261)*5.55555555-a),i=Math.exp(-.07771971*t**1.16364243);for(let f=0;f<4;f++)n[f]=rr[f]*e,n[4+f]=lr[f]*e,n[8+f]=er[f]*ar*r*this.ozone,n[12+f]=or[f]*i*this.air}transmittance(t,n,e){const[a,r,i]=xe(t),f=Nt(Wt,oo,n),h=eo(0,0,f,a,r,i,oo)/zo,s=[0,0,0,0],l=new Float64Array(16);for(let c=0;c<zo;c++){const _=(c+.5)*h,d=a*_,m=r*_,p=f+i*_,v=Math.max(Math.hypot(d,m,p)-Wt,0);this.coefficients(v,l);for(let g=0;g<4;g++)s[g]+=(l[g]+l[4+g]+l[8+g]+l[12+g])*h}for(let c=0;c<4;c++)e[c]=Math.exp(-s[c])}precompute(){const t=new Float64Array(4);for(let n=0;n<$t;n++)for(let e=0;e<ft;e++){const a=e/(ft-1),r=n/($t-1);this.transmittance(a*2-1,r,t);const i=(n*ft+e)*4;for(let f=0;f<4;f++)this.lut[i+f]=t[f]}}lookup(t,n,e){const a=(ft-1)*fn(t*.5+.5),r=($t-1)*fn(n),i=Math.trunc(a),f=Math.trunc(r),u=Math.min(i+1,ft-1),h=Math.min(f+1,$t-1),s=a-i,l=r-f,c=(f*ft+i)*4,_=(f*ft+u)*4,d=(h*ft+i)*4,m=(h*ft+u)*4;for(let p=0;p<4;p++)e[p]=Nt(Nt(this.lut[c+p],this.lut[_+p],s),Nt(this.lut[d+p],this.lut[m+p],s),l)}lookupAtGround(t,n){const e=(ft-1)*fn(t*.5+.5),a=Math.trunc(e),r=Math.min(a+1,ft-1),i=e-a;for(let f=0;f<4;f++)n[f]=Nt(this.lut[a*4+f],this.lut[r*4+f],i)}lookupToSun(t,n){const e=($t-1)*fn(t),a=Math.trunc(e),r=Math.min(a+1,$t-1),i=e-a,f=ft-1;for(let u=0;u<4;u++)n[u]=Nt(this.lut[(a*ft+f)*4+u],this.lut[(r*ft+f)*4+u],i)}inscattering(t,n,e,a,r,i,f,u,h){const s=-(r*t[0]+i*t[1]+f*t[2]),l=cr(s),c=ur(s),_=u/Do,d=new Float64Array(16),m=new Float64Array(4),p=new Float64Array(4),v=new Float64Array(4),g=new Float64Array(4),w=new Float64Array(4),y=[0,0,0,0],S=[1,1,1,1];for(let T=0;T<Do;T++){const A=(T+.5)*_,O=n+r*A,M=e+i*A,k=a+f*A,j=Math.hypot(O,M,k),q=Math.max(j-Wt,0),Q=q/ge,K=(O*t[0]+M*t[1]+k*t[2])/j;this.coefficients(q,d),this.lookup(K,Q,m);const st=Ut*(1-fr(1-In(Wt/j)));this.lookupAtGround(K,v),this.lookupToSun(0,g),this.lookupToSun(Q,w);const b=1/(1+5*Math.exp(-17.92*K)),V=[.217,.347,.594,1];for(let z=0;z<4;z++){const X=g[z]/w[z],Y=Ja*st*(Ka*pe)*v[z]*X*K;p[z]=.02*V[z]*b+Y}for(let z=0;z<4;z++){const X=d[z]+d[4+z]+d[8+z]+d[12+z],Y=nr[z]*(d[12+z]*(l*m[z]+p[z])+d[4+z]*(c*m[z]+p[z])),$=Math.exp(-_*X),E=Math.max(X,1e-7);y[z]+=S[z]*((Y-Y*$)/E),S[z]*=$}}for(let T=0;T<4;T++)h[T]=y[T]}}const ht=512,Jt=256;function be(o,t){const n=new mr(o.airDensity,o.aerosolDensity,o.ozoneDensity);n.precompute();const e=Math.min(Math.max(o.altitude,1),99999)/1e3,a=xe(Math.cos(dn-t)),r=new Float32Array(ht*Jt*3),i=ht/2,f=new Float64Array(4);for(let u=0;u<Jt;u++)for(let h=0;h<i;h++){const s=(h+.5)/ht,l=(u+.5)/Jt,c=Ut*s,_=l*2-1,d=Math.sign(_)*In(_)*dn,m=Math.cos(d)*Math.cos(c),p=Math.cos(d)*Math.sin(c),v=Math.sin(d),g=Wt+e,w=eo(0,0,g,m,p,v,oo),y=eo(0,0,g,m,p,v,Wt),S=y<0?w:y;n.inscattering(a,0,0,g,m,p,v,S,f);let T=0,A=0,O=0;for(let j=0;j<4;j++)T+=Bn[j][0]*f[j],A+=Bn[j][1]*f[j],O+=Bn[j][2]*f[j];const M=(u*ht+h)*3;r[M]=T,r[M+1]=A,r[M+2]=O;const k=(u*ht+(ht-h-1))*3;r[k]=T,r[k+1]=A,r[k+2]=O}return r}function dr(o){const[t]=_o(o.sunElevation,o.sunRotation);return be(o,t)}function mo(o){const[t]=_o(o.sunElevation,o.sunRotation);return JSON.stringify([t,o.altitude,o.airDensity,o.aerosolDensity,o.ozoneDensity])}const hr=6,Qt=new Map;function pr(o){return Qt.has(mo(o))}function ye(o,t){Qt.set(mo(o),t),Qt.size>hr&&Qt.delete(Qt.keys().next().value)}function vr(o){const[t,n]=_o(o.sunElevation,o.sunRotation),e=mo(o);let a=Qt.get(e);a===void 0&&(a=be(o,t),ye(o,a));const r=new x;return i=>{const f=Math.hypot(i.x,i.y),u=Math.atan2(i.z,f);let s=(Math.atan2(i.x,i.y)+Math.PI+n)/Ut;s-=Math.floor(s);const l=Math.abs(u),c=fn(Math.sqrt(l/dn)*Math.sign(u)*.5+.5),_=s*ht-.5,d=c*Jt-.5,m=Math.floor(_),p=Math.floor(d),v=_-m,g=d-p,w=k=>(k%ht+ht)%ht,y=k=>k<0?0:k>Jt-1?Jt-1:k,S=w(m),T=w(m+1),A=y(p),O=y(p+1),M=[0,0,0];for(let k=0;k<3;k++){const j=Nt(a[(A*ht+S)*3+k],a[(A*ht+T)*3+k],v),q=Nt(a[(O*ht+S)*3+k],a[(O*ht+T)*3+k],v);M[k]=Nt(j,q,g)}return r.set(Et[0][0]*M[0]+Et[0][1]*M[1]+Et[0][2]*M[2],Et[1][0]*M[0]+Et[1][1]*M[1]+Et[1][2]*M[2],Et[2][0]*M[0]+Et[2][1]*M[1]+Et[2][2]*M[2])}}let Ft=null,vn=!1,gr=0;const cn=new Map;function xr(){if(Ft||vn)return Ft;if(typeof Worker>"u")return vn=!0,null;try{Ft=new Worker(new URL("/assets/sky-precompute-worker-ChN7J87v.js",import.meta.url),{type:"module"})}catch{return vn=!0,null}return Ft.onmessage=o=>{const{id:t,pixels:n,error:e}=o.data,a=cn.get(t);a&&(cn.delete(t),n?a.resolve(n):a.reject(new Error(e??"sky worker returned nothing")))},Ft.onerror=o=>{const t=new Error(`sky worker failed: ${o.message||"unknown error"}`);for(const n of cn.values())n.reject(t);cn.clear(),Ft?.terminate(),Ft=null,vn=!0},Ft}function br(o){const t=xr();if(!t)return Promise.resolve(dr(o));const n=gr++,e={id:n,parameters:o};return new Promise((a,r)=>{cn.set(n,{resolve:a,reject:r}),t.postMessage(e)})}function yr(o,t,n,e={}){switch(e.type??"LINEAR"){case"QUADRATIC":{const a=Math.max(o,0);return a*a}case"EASING":{const a=Math.min(1,Math.max(0,o));return a*a*(3-2*a)}case"DIAGONAL":return(o+t)/2;case"SPHERICAL":return Math.max(.999999-Math.hypot(o,t,n),0);case"QUADRATIC_SPHERE":{const a=Math.max(.999999-Math.hypot(o,t,n),0);return a*a}case"RADIAL":return Math.atan2(t,o)/(2*Math.PI)+.5;default:return o}}const Un=(o,t)=>t!==0?o/t:0,ko=o=>Math.min(1,Math.max(-1,o)),$o=(o,t,n)=>{const e=n!==0?Math.max(n-Math.abs(o-t),0)/n:0;return Math.min(o,t)-e*e*e*n/6},we={ADD:(o,t)=>o+t,SUBTRACT:(o,t)=>o-t,MULTIPLY:(o,t)=>o*t,DIVIDE:Un,POWER:(o,t)=>t===0?1:o===0||o<0&&!Number.isInteger(t)?0:o**t,LOGARITHM:(o,t)=>o<=0||t<=0?0:Un(Math.log(o),Math.log(t)),SQRT:o=>Math.sqrt(Math.max(o,0)),INVERSE_SQRT:o=>o>0?1/Math.sqrt(o):0,ABSOLUTE:Math.abs,RADIANS:o=>o*Math.PI/180,DEGREES:o=>o*180/Math.PI,MINIMUM:(o,t)=>Math.min(o,t),MAXIMUM:(o,t)=>Math.max(o,t),LESS_THAN:(o,t)=>+(o<t),GREATER_THAN:(o,t)=>+(o>t),ROUND:o=>Math.floor(o+.5),FLOOR:Math.floor,CEIL:Math.ceil,FRACT:o=>o-Math.floor(o),MODULO:(o,t)=>t!==0?o%t:0,FLOORED_MODULO:(o,t)=>t!==0?o-Math.floor(o/t)*t:0,TRUNC:Math.trunc,SNAP:(o,t)=>Math.floor(Un(o,t))*t,WRAP:(o,t,n)=>t!==n?o-(t-n)*Math.floor((o-n)/(t-n)):n,PINGPONG:(o,t)=>{if(t===0)return 0;const n=(o-t)/(t*2);return Math.abs((n-Math.floor(n))*t*2-t)},SINE:Math.sin,COSINE:Math.cos,TANGENT:Math.tan,SINH:Math.sinh,COSH:Math.cosh,TANH:Math.tanh,ARCSINE:o=>Math.asin(ko(o)),ARCCOSINE:o=>Math.acos(ko(o)),ARCTANGENT:Math.atan,ARCTAN2:(o,t)=>o===0&&t===0?0:Math.atan2(o,t),SIGN:Math.sign,EXPONENT:Math.exp,COMPARE:(o,t,n)=>+(o===t||Math.abs(o-t)<=Math.max(n,2**-23)),MULTIPLY_ADD:(o,t,n)=>o*t+n,SMOOTH_MIN:$o,SMOOTH_MAX:(o,t,n)=>-$o(-o,-t,n)};function at(o,t){if(typeof o=="number")return()=>o;if(Array.isArray(o)){const a=new x(...o);return()=>a}if(o.kind==="direction")return a=>a;if(o.kind==="window"){if(!t)throw new Error("World Window coordinates need a render camera");return t}if(o.kind==="gradient"){const a=at(o.vector,t),r={type:o.gradient_type},i=new x;return f=>{const u=a(f),h=typeof u=="number"?u:u.x,s=typeof u=="number"?u:u.y,l=typeof u=="number"?u:u.z,c=gt.clamp(yr(h,s,l,r),0,1);return o.output==="Fac"?c:i.setScalar(c)}}if(o.kind==="to_float"){const a=at(o.value,t);return r=>{const i=a(r);return typeof i=="number"?i:Math.fround(o.source_type==="RGBA"?i.x*.212639+i.y*.7151687+i.z*.0721923:(i.x+i.y+i.z)/3)}}if(o.kind==="math"){const a=o.inputs.map(f=>at(f,t)),r=we[o.operation],i=(f,u)=>{const h=a[f]?.(u)??0;if(typeof h!="number")throw new Error("World Math needs scalar inputs");return Math.fround(h)};return f=>{const u=Math.fround(r(i(0,f),i(1,f),i(2,f)));return o.clamp?gt.clamp(u,0,1):u}}if(o.kind==="mix_color"){const a=at(o.factor,t),r=at(o.a,t),i=at(o.b,t),f=new x,u=new x;return h=>{const s=a(h);if(typeof s!="number")throw new Error("World color Mix needs a scalar factor");const l=r(h);typeof l=="number"?f.setScalar(l):f.copy(l);const c=i(h);return typeof c=="number"?u.setScalar(c):u.copy(c),f.lerp(u,o.clamp_factor?gt.clamp(s,0,1):s),o.clamp_result&&f.clampScalar(0,1),f}}if(o.kind==="sky"){const a=vr({sunElevation:o.sun_elevation,sunRotation:o.sun_rotation,altitude:o.altitude,airDensity:o.air_density,aerosolDensity:o.aerosol_density,ozoneDensity:o.ozone_density});return r=>a(r)}if(o.kind==="mapping"){const a=at(o.vector,t),r=new x(...o.location),i=new x(...o.scale),f=new Tt().setFromEuler(new Le(o.rotation[0],o.rotation[1],o.rotation[2],"ZYX")),u=f.clone().invert(),h=new x(...o.scale.map(l=>l===0?0:1/l)),s=new x;return l=>{const c=a(l);switch(typeof c=="number"?s.setScalar(c):s.copy(c),o.vector_type??"POINT"){case"TEXTURE":return s.sub(r).applyQuaternion(u).multiply(h);case"VECTOR":return s.multiply(i).applyQuaternion(f);case"NORMAL":return s.multiply(h).applyQuaternion(f).normalize();case"POINT":return s.multiply(i).applyQuaternion(f).add(r)}}}if(o.kind==="map_range"){const a=at(o.value,t),r=at(o.from_min,t),i=at(o.from_max,t),f=at(o.to_min,t),u=at(o.to_max,t),h=at(o.steps,t),s=(_,d)=>{const m=_(d);if(typeof m!="number")throw new Error("World Map Range needs scalar inputs");return m},l=o.interpolation,c=o.clamp;return _=>{const d=s(a,_),m=s(r,_),p=s(i,_),v=s(f,_),g=s(u,_);if(m===p)return 0;let w;if(l==="STEPPED"){const S=s(h,_),T=(d-m)/(p-m);w=S>0?Math.floor(T*(S+1))/S:0}else if(l==="SMOOTHSTEP"||l==="SMOOTHERSTEP"){const S=gt.clamp((d-Math.min(m,p))/(Math.max(m,p)-Math.min(m,p)),0,1),T=l==="SMOOTHSTEP"?S*S*(3-2*S):S*S*S*(S*(S*6-15)+10);w=m>p?1-T:T}else w=(d-m)/(p-m);const y=v+w*(g-v);return c?v>g?gt.clamp(y,g,v):gt.clamp(y,v,g):y}}if(o.kind==="separate"){const a=at(o.vector,t);return r=>{const i=a(r);return typeof i=="number"?i:i.getComponent(o.axis)}}const n=at(o.factor,t),e=new x;return a=>{const r=n(a);if(typeof r!="number")throw new Error("World ColorRamp needs a scalar factor");const i=gt.clamp(r,0,1)*256,f=Math.floor(i),u=o.colors[f],h=o.colors[Math.min(f+1,256)],s=o.interpolate?i-f:0;return e.set(gt.lerp(u[0],h[0],s),gt.lerp(u[1],h[1],s),gt.lerp(u[2],h[2],s))}}function wr(o,t,n,e){const a=new Float32Array(t*n*3),r=at(o,e),i=new x;for(let f=0;f<n;f++){const u=((f+.5)/n-.5)*Math.PI;for(let h=0;h<t;h++){const s=((h+.5)/t-.5)*2*Math.PI;i.set(Math.cos(u)*Math.cos(s),-Math.cos(u)*Math.sin(s),Math.sin(u));const l=r(i),c=(f*t+h)*3;a[c]=typeof l=="number"?l:l.x,a[c+1]=typeof l=="number"?l:l.y,a[c+2]=typeof l=="number"?l:l.z}}return a}function Lo(o){const t=[],n=e=>{if(!(typeof e=="number"||Array.isArray(e)))switch(e.kind){case"sky":t.push({sunElevation:e.sun_elevation,sunRotation:e.sun_rotation,altitude:e.altitude,airDensity:e.air_density,aerosolDensity:e.aerosol_density,ozoneDensity:e.ozone_density});return;case"mapping":case"gradient":case"separate":n(e.vector);return;case"ramp":n(e.factor);return;case"mix_color":n(e.factor),n(e.a),n(e.b);return;case"math":e.inputs.forEach(n);return;case"to_float":n(e.value);return;case"map_range":n(e.value),n(e.from_min),n(e.from_max),n(e.to_min),n(e.to_max),n(e.steps);return;default:return}};return n(o),t}function Dt(o){if(typeof o=="number"||Array.isArray(o))return!1;switch(o.kind){case"window":return!0;case"mapping":case"gradient":case"separate":return Dt(o.vector);case"ramp":return Dt(o.factor);case"mix_color":return[o.factor,o.a,o.b].some(Dt);case"math":return o.inputs.some(Dt);case"to_float":return Dt(o.value);case"map_range":return[o.value,o.from_min,o.from_max,o.to_min,o.to_max,o.steps].some(Dt);default:return!1}}function Or(o,t,n,e){e.updateMatrixWorld();const a=new Float32Array(t*n*3),r=new x,i=at(o,()=>r),f=new x,u=e.getWorldPosition(new x),h=e.getWorldDirection(new x);for(let s=0;s<n;s++)for(let l=0;l<t;l++){const c=(l+.5)/t,_=(s+.5)/n;r.set(c,_,0),e.isOrthographicCamera?f.copy(h):f.set(c*2-1,_*2-1,.5).unproject(e).sub(u).normalize(),f.set(f.x,-f.z,f.y);const d=i(f),m=(s*t+l)*3;a[m]=typeof d=="number"?d:d.x,a[m+1]=typeof d=="number"?d:d.y,a[m+2]=typeof d=="number"?d:d.z}return a}const et=N().finite(),Tr=P({type:H(["POINT","SUN","SPOT","AREA"]),color:L([et,et,et]),energy:et,use_shadow:Z().default(!0),radius:et.optional(),spot_size:et.optional(),spot_blend:et.optional(),shape:H(["SQUARE","RECTANGLE","DISK","ELLIPSE"]).optional(),size:et.optional(),size_y:et.optional()}).strict();let ao;function Ar(){return ao??=ya(async()=>{const{RectAreaLightUniformsLib:o}=await import("./RectAreaLightUniformsLib-DpPyArRG.js");return{RectAreaLightUniformsLib:o}},__vite__mapDeps([0,1,2])).then(({RectAreaLightUniformsLib:o})=>{o.init(),Ot()}),ao}function Pr(){return ao??Promise.resolve()}const Sr=o=>{const t=o.size??0,n=o.size_y??t;if(o.shape==="RECTANGLE")return[t,n];if(o.shape==="DISK"){const e=Math.sqrt(Math.PI*t*t/4);return[e,e]}if(o.shape==="ELLIPSE"){const e=Math.sqrt(Math.PI/4);return[t*e,n*e]}return[t,t]};function Er(o,t){const n=(i,f)=>t&&f(t)?t:new i;if(o.type==="SUN"){const i=n(le,f=>f.isDirectionalLight);return i.intensity=o.energy,i.color.setRGB(o.color[0],o.color[1],o.color[2],pt),i.castShadow=o.use_shadow,i}if(o.type==="POINT"){const i=n(Zn,f=>f.isPointLight);return i.intensity=o.energy/(4*Math.PI),i.distance=0,i.decay=2,i.color.setRGB(o.color[0],o.color[1],o.color[2],pt),i.castShadow=o.use_shadow,i}if(o.type==="SPOT"){const i=n(Qn,f=>f.isSpotLight);return i.intensity=o.energy/(4*Math.PI),i.distance=0,i.decay=2,i.angle=(o.spot_size??0)/2,i.penumbra=o.spot_blend??0,i.color.setRGB(o.color[0],o.color[1],o.color[2],pt),i.castShadow=o.use_shadow,i}Ar();const e=n(An,i=>i.isRectAreaLight),[a,r]=Sr(o);return e.width=a,e.height=r,e.intensity=o.energy/(Math.max(a*r,Number.MIN_VALUE)*Math.PI),e.color.setRGB(o.color[0],o.color[1],o.color[2],pt),e}function Mr(o,t,n){if(!o.castShadow||n<=0)return;const a=o.getWorldPosition(new x).distanceTo(t),r=o.shadow;if(!r)return;const i=r.camera;i.near=Math.max(n*.001,a-n),i.far=a+n,o.isDirectionalLight&&(i.left=-n,i.right=n,i.top=n,i.bottom=-n),i.updateProjectionMatrix()}function Nr(o,t){o.position.set(0,0,0);const n=o;o.isRectAreaLight||n.target&&n.target.parent!==t&&(n.target.position.set(0,0,-1),t.add(n.target))}const ho=[{direction:[-.352546,.170931,-.920051],diffuse:[.033103,.033103,.033103],specular:[.266761,.266761,.266761],smooth:.52662},{direction:[-.408163,.346939,.844415],diffuse:[.521083,.538226,.538226],specular:[.59903,.59903,.59903],smooth:0},{direction:[.521739,.826087,.212999],diffuse:[.038403,.034357,.04953],specular:[.106102,.125981,.158523],smooth:.478261},{direction:[.624519,-.562067,-.542269],diffuse:[.090838,.08208,.072255],specular:[.106535,.084771,.06608],smooth:.2}],Vo=.69;class Rr{constructor(){this.group=new lt,this.lights=[],this.group.name="BlenderSolidStudio";const t=new re;t.name="BlenderSolidStudioTarget",this.group.add(t);const n=new wt(0,0,0);for(const[a,r]of ho.entries()){const i=(1+r.smooth)**2,f=new le(16777215,Math.PI*Vo/i);f.name=`BlenderSolidLight${a}`,f.color.setRGB(r.diffuse[0],r.diffuse[1],r.diffuse[2],pt),f.position.set(r.direction[0],r.direction[1],r.direction[2]),f.target=t,this.group.add(f),this.lights.push(f),n.r+=r.diffuse[0]*r.smooth/i,n.g+=r.diffuse[1]*r.smooth/i,n.b+=r.diffuse[2]*r.smooth/i}const e=new Ve(16777215,Math.PI*Vo);e.name="BlenderSolidWrapFill",e.color.copy(n),this.group.add(e),this.lights.push(e)}setRendered(t){this.group.visible=!t}dispose(){for(const t of this.lights)t.dispose();this.group.clear()}}const Zt=L([et,et,et]),G=_e(()=>kt([et,Zt,P({kind:W("direction")}).strict(),P({kind:W("window")}).strict(),P({kind:W("gradient"),gradient_type:H(["LINEAR","QUADRATIC","EASING","DIAGONAL","SPHERICAL","QUADRATIC_SPHERE","RADIAL"]),output:H(["Fac","Color"]),vector:G}).strict(),P({kind:W("to_float"),source_type:H(["RGBA","VECTOR"]),value:G}).strict(),P({kind:W("math"),operation:H(Object.keys(we)),clamp:Z(),inputs:D(G).min(1).max(3)}).strict(),P({kind:W("mix_color"),factor:G,a:G,b:G,clamp_factor:Z(),clamp_result:Z()}).strict(),P({kind:W("mapping"),vector_type:H(["POINT","TEXTURE","VECTOR","NORMAL"]).optional(),vector:G,location:Zt,rotation:Zt,scale:Zt}).strict(),P({kind:W("separate"),vector:G,axis:N().int().min(0).max(2)}).strict(),P({kind:W("ramp"),factor:G,colors:D(Zt).length(257),interpolate:Z()}).strict(),P({kind:W("map_range"),interpolation:H(["LINEAR","STEPPED","SMOOTHSTEP","SMOOTHERSTEP"]),clamp:Z(),value:G,from_min:G,from_max:G,to_min:G,to_max:G,steps:G}).strict(),P({kind:W("sky"),sun_elevation:et,sun_rotation:et,altitude:et,air_density:et,aerosol_density:et,ozone_density:et}).strict()])),jo=P({color:Zt,strength:et,shader:G.optional()}),Ir=jo.extend({volume:D(P({kind:H(["absorption","scatter","principled","emission"]),phase:R(),alpha:G,weight:G,color:G,density:G,anisotropy:G,absorption_color:G,emission_color:G,emission_strength:G,blackbody_intensity:G,temperature:G,blackbody_tint:G}).strict()).optional(),lighting:jo.strict().optional()}).strict(),Fr=4,ln=new Map,Wn=new Set;function Bo(o,t,n){const r=Dt(o);if(r&&!n)throw new Error("World Window coordinates need a render camera");n?.updateMatrixWorld();const i=JSON.stringify([o,r?[n.matrixWorld.elements,n.projectionMatrix.elements]:null]),f=ln.get(i);if(f!==void 0)return ro(f,t,256,128);const u=new x,h=new fo,s=n?new tt().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse):null,l=n?.getWorldPosition(new x),_=wr(o,256,128,r?d=>(u.set(d.x,d.z,-d.y),n.isPerspectiveCamera&&u.add(l),h.set(u.x,u.y,u.z,1).applyMatrix4(s),h.w===0?u.set(0,0,0):u.set(h.x/h.w*.5+.5,h.y/h.w*.5+.5,0)):void 0);return ln.set(i,_),ln.size>Fr&&ln.delete(ln.keys().next().value),ro(_,t,256,128)}function zr(o,t,n,e){const a=sn.toHalfFloat(1);for(let r=0;r<e;r++)o[r*4]=sn.toHalfFloat(t[r*3]*n),o[r*4+1]=sn.toHalfFloat(t[r*3+1]*n),o[r*4+2]=sn.toHalfFloat(t[r*3+2]*n),o[r*4+3]=a}function ro(o,t,n,e){const a=new Uint16Array(n*e*4);zr(a,o,t,n*e);const r=new zn(a,n,e,Dn,co);return r.mapping=Be,r.colorSpace=pt,r.minFilter=Gt,r.magFilter=Gt,r.needsUpdate=!0,r}class po{constructor(){this.pending=null,this.texture=null,this.environmentTexture=null,this.screenTexture=null,this.applied=null,this.generation=0}async ready(){await this.pending}static sceneOf(t){let n=t;for(;n;){if(n.isScene)return n;n=n.parent}return null}apply(t,n,e){if(this.clear(),this.pending=null,!n)return;const a=po.sceneOf(t);if(!a)return;this.applied={scene:a,background:a.background,environment:a.environment};const r=n.shader??n.color,i=this.generation,u=[...Lo(r),...n.lighting?Lo(n.lighting.shader??n.lighting.color):[]].filter(s=>!pr(s));if(u.length===0){this.compose(a,n,r,e);return}const h=(async()=>{const s=await Promise.all(u.map(br));u.forEach((l,c)=>{ye(l,s[c])}),!(this.generation!==i||this.applied?.scene!==a)&&(this.compose(a,n,r,e),Ot())})();this.pending=h,Wn.add(h),h.then(()=>Wn.delete(h),()=>Wn.delete(h))}compose(t,n,e,a){if(this.texture=Bo(e,n.strength,a),Dt(e)){if(!a)throw new Error("World Window coordinates need a render camera");this.screenTexture=ro(Or(e,512,512,a),n.strength,512,512),this.screenTexture.mapping=je,t.background=this.screenTexture}else if(a&&a.isOrthographicCamera){const i=a.getWorldDirection(new x);i.set(i.x,-i.z,i.y);const f=at(n.shader??n.color)(i);t.background=typeof f=="number"?new wt().setRGB(f,f,f).multiplyScalar(n.strength):new wt().setRGB(f.x,f.y,f.z).multiplyScalar(n.strength)}else t.background=this.texture;const{lighting:r}=n;this.environmentTexture=r?Bo(r.shader??r.color,r.strength,a):null,t.environment=this.environmentTexture??this.texture}clear(){this.generation++,this.applied&&(this.applied.scene.background=this.applied.background,this.applied.scene.environment=this.applied.environment,this.applied=null,this.texture?.dispose(),this.texture=null,this.environmentTexture?.dispose(),this.environmentTexture=null,this.screenTexture?.dispose(),this.screenTexture=null)}dispose(){this.clear()}}function Oe(o){return[o.min.x,o.max.x].flatMap(t=>[o.min.y,o.max.y].flatMap(n=>[o.min.z,o.max.z].map(e=>new x(t,n,e))))}function Dr(o,t){if(o.isEmpty()||!t.intersectsBox(o))return[];const n=Oe(o);if(n.every(s=>t.containsPoint(s)))return n;const e=[...t.planes,new Vt(new x(1,0,0),-o.min.x),new Vt(new x(-1,0,0),o.max.x),new Vt(new x(0,1,0),-o.min.y),new Vt(new x(0,-1,0),o.max.y),new Vt(new x(0,0,1),-o.min.z),new Vt(new x(0,0,-1),o.max.z)],a=[],r=new x,i=new x,f=new x,u=new x,h=Math.max(1,o.min.length(),o.max.length())*1e-8;for(let s=0;s<e.length;s++)for(let l=s+1;l<e.length;l++)for(let c=l+1;c<e.length;c++){const _=e[s],d=e[l],m=e[c];r.crossVectors(d.normal,m.normal);const p=_.normal.dot(r);Math.abs(p)<1e-12||(i.crossVectors(m.normal,_.normal),f.crossVectors(_.normal,d.normal),u.copy(r).multiplyScalar(-_.constant).addScaledVector(i,-d.constant).addScaledVector(f,-m.constant).divideScalar(p),e.every(v=>v.distanceToPoint(u)>=-h)&&a.push(u.clone()))}return a}function Cr(o,t,n){if(!o.castShadow||!t.length)return;o.shadow.updateMatrices(o);const e=o.shadow.camera,a=e.matrixWorldInverse,r=new Mn().setFromPoints(t.map(c=>c.clone().applyMatrix4(a))),i=r.getSize(new x),f=Math.max(i.length()*1e-6,Number.EPSILON),u=2+2*Math.SQRT2,h=Math.max(i.x,i.y,f)/Math.max(1,Math.min(o.shadow.mapSize.x,o.shadow.mapSize.y)-2*u),s=2*Math.SQRT2*h,l=u*h;r.min.x-=l,r.min.y-=l,r.max.x+=l,r.max.y+=l;for(const c of n){if(c.isEmpty())continue;const _=new Mn().setFromPoints(Oe(c).map(d=>d.applyMatrix4(a)));_.max.x<r.min.x||_.min.x>r.max.x||_.max.y<r.min.y||_.min.y>r.max.y||(r.min.z=Math.min(r.min.z,_.min.z),r.max.z=Math.max(r.max.z,_.max.z))}e.left=r.min.x,e.right=r.max.x,e.bottom=r.min.y,e.top=r.max.y,e.near=-r.max.z-s-f,e.far=-r.min.z+s+f,e.updateProjectionMatrix(),o.shadow.normalBias=s}const tn=N().finite(),Uo=L([tn,tn,tn]),Te=P({min:L([N().int(),N().int(),N().int()]),max:L([N().int(),N().int(),N().int()]),density:D(tn),voxelSize:tn.positive(),color:Uo,emission:Uo,densityScale:tn.nonnegative()}).strict();function kr(o){const t=o.max.map((s,l)=>s-o.min[l]+1);if(t.some(s=>s<=0)||t.reduce((s,l)=>s*l,1)!==o.density.length)throw new Error("Volume density dimensions do not match the evaluated grid");const n=new Ue(new Float32Array(o.density),t[0],t[1],t[2]);n.format=We,n.type=ie,n.minFilter=n.magFilter=Gt,n.unpackAlignment=1,n.needsUpdate=!0;const e=new x(...o.min).addScalar(-.5).multiplyScalar(o.voxelSize),a=new x(t[0],t[1],t[2]).multiplyScalar(o.voxelSize),r=new He(a.x,a.y,a.z),i=r.getAttribute("position");for(let s=0;s<i.count;s++)i.setXYZ(s,e.x+(i.getX(s)>0?a.x:0),e.y+(i.getY(s)>0?a.y:0),e.z+(i.getZ(s)>0?a.z:0));i.needsUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere();const f=new so({glslVersion:Ge,side:qe,transparent:!0,depthWrite:!1,premultipliedAlpha:!0,uniforms:{densityGrid:{value:n},minimum:{value:e},extent:{value:a},voxelSize:{value:o.voxelSize},densityScale:{value:o.densityScale},volumeColor:{value:new x(...o.color)},emission:{value:new x(...o.emission)},cameraLocal:{value:new x},rayLocal:{value:new x},orthographic:{value:!1},worldScale:{value:new ae}},vertexShader:`
|
|
20
20
|
out vec3 localPosition;
|
|
21
21
|
void main() {
|
|
22
22
|
localPosition = position;
|
|
@@ -58,7 +58,7 @@ import{a as Ho,b as qo,L as Go}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
|
|
61
|
+
}`}),u=new Rt(r,f),h=new tt;return u.onBeforeRender=(s,l,c)=>{h.copy(u.matrixWorld).invert(),f.uniforms.cameraLocal.value.setFromMatrixPosition(c.matrixWorld).applyMatrix4(h),c.getWorldDirection(f.uniforms.rayLocal.value).transformDirection(h),f.uniforms.orthographic.value=!!c.isOrthographicCamera,f.uniforms.worldScale.value.setFromMatrix4(u.matrixWorld)},f.addEventListener("dispose",()=>n.dispose()),u}const $r=`#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)`,lo={"gpu_shader_common_math.glsl":{deps:["gpu_shader_math_constants_lib.glsl","gpu_shader_math_base_lib.glsl","gpu_shader_math_safe_lib.glsl"],code:`void math_add(float a, float b, float c, _ref(float ,result))
|
|
204
204
|
{
|
|
205
205
|
result = a + b;
|
|
206
206
|
}
|
|
@@ -6879,7 +6879,7 @@ void curves_float_mixed(float factor,
|
|
|
6879
6879
|
curves_float(
|
|
6880
6880
|
value, curve_map, layer, range_minimum, range_divider, start_slope, end_slope, result);
|
|
6881
6881
|
result = mix(value, result, factor);
|
|
6882
|
-
}`}},
|
|
6882
|
+
}`}},Wo=N().finite(),Hn=H(["float","vec2","vec3","vec4"]),Ae=kt([Wo,D(Wo)]),Pe=L([R(),N().int().nonnegative()]),Sn=kt([P({value:Ae}).strict(),P({link:Pe}).strict()]),Lr=["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"],Vr=P({type:H(Lr),props:xt(R(),me()),inputs:D(kt([P({value:Ae,id:R(),gpu:Hn,enabled:Z()}).strict(),P({link:Pe,id:R(),gpu:Hn,enabled:Z()}).strict()])),outputs:D(P({id:R(),gpu:Hn.or(W("closure")).nullable()}).strict())}).strict(),un=_e(()=>kt([P({principled:W(!0)}).strict(),P({emission:L([Sn,Sn])}).strict(),P({transparent:N()}).strict(),P({none:W(!0)}).strict(),P({mix:L([Sn,un,un])}).strict(),P({add:L([un,un])}).strict()])),jr=P({surface:H(["ShaderNodeBsdfPrincipled","ShaderNodeEmission","closure"]),inputs:xt(R(),Sn),closure:un.optional(),nodes:xt(R(),Vr)}).strict();function Br(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 Se="vec3(0.2126729, 0.7151522, 0.0721750)",Ur=o=>o==="float"?1:Number(o[3]);function Wr(o,t){const n=typeof t=="number"?[t]:t,e=Ur(o);return Array.from({length:e},(a,r)=>n[r]??(r===3?1:0))}function Hr(o,t,n){if(t===n)return o;const e=r=>r==="float"?"float":`float${r[3]}`,a=t==="vec4"&&n==="float"?`, ${Se}`:"";return`${e(n)}_from_${e(t)}(${o}${a})`}const qr={INVERSE_SQRT:"math_inversesqrt",FRACT:"math_fraction",SMOOTH_MIN:"math_smoothmin",SMOOTH_MAX:"math_smoothmax"},Gr={CROSS_PRODUCT:"vector_math_cross",DOT_PRODUCT:"vector_math_dot"},Ho={MIX:"blend",ADD:"add",MULTIPLY:"mult",SUBTRACT:"sub",SCREEN:"screen",DIVIDE:"div_fallback",DIFFERENCE:"diff",EXCLUSION:"exclusion",DARKEN:"dark",LIGHTEN:"light",OVERLAY:"overlay",DODGE:"dodge",BURN:"burn",HUE:"hue",SATURATION:"sat",VALUE:"val",COLOR:"color",SOFT_LIGHT:"soft",LINEAR_LIGHT:"linear"},Xr={MULTIFRACTAL:"multi_fractal",FBM:"fbm",HYBRID_MULTIFRACTAL:"hybrid_multi_fractal",RIDGED_MULTIFRACTAL:"ridged_multi_fractal",HETERO_TERRAIN:"hetero_terrain"},Yr={F1:"f1",F2:"f2",SMOOTH_F1:"smooth_f1",DISTANCE_TO_EDGE:"distance_to_edge",N_SPHERE_RADIUS:"n_sphere_radius"},Zr={EUCLIDEAN:0,MANHATTAN:1,CHEBYCHEV:2,MINKOWSKI:3},Qr=(()=>{const o=new Map;for(const[t,n]of Object.entries(lo))for(const e of n.code.matchAll(/^(?:void|float\d?)\s+([A-Za-z_]\w*)\s*\(/gm))o.has(e[1])||o.set(e[1],t);return o})();function C(o,t){if(!(t in o.props))throw new Error(`${o.type} arrived without its '${t}' property`);return o.props[t]}const Kr=`
|
|
6883
6883
|
#define GPU_FRAGMENT_SHADER
|
|
6884
6884
|
#define FrontFacing gl_FrontFacing
|
|
6885
6885
|
#ifndef USE_TRANSMISSION
|
|
@@ -6936,7 +6936,7 @@ void blender_init_globals() {
|
|
|
6936
6936
|
g_data.curve_T = vec3(0.0);
|
|
6937
6937
|
g_data.barycentric_coords = vec2(0.0);
|
|
6938
6938
|
}
|
|
6939
|
-
`,
|
|
6939
|
+
`,Jr=`
|
|
6940
6940
|
uniform vec2 blenderViewport;
|
|
6941
6941
|
vec3 blender_orco() {
|
|
6942
6942
|
// attr_load_orco: the orco attribute (\`orcoAttribute\`), interpolated.
|
|
@@ -7019,31 +7019,31 @@ vec3 blender_reflection() {
|
|
|
7019
7019
|
: normalize(cameraPosition - vBlenderWorldPosition);
|
|
7020
7020
|
return blender_from_three * -reflect(incident, normalize(vBlenderWorldNormal));
|
|
7021
7021
|
}
|
|
7022
|
-
`;class io{constructor(t,n,e=!1,a="bgN"){this.graph=t,this.derivative=e,this.prefix=a,this.lines=[],this.emitted=new Map,this.s=n??{files:new Set,uniforms:new Map,uniformTypes:new Map,images:[],ramps:[],uvs:new Set,attributes:new Set,structure:[],functions:[]}}get uniforms(){return this.s.uniforms}get images(){return this.s.images}get ramps(){return this.s.ramps}d(t){return this.derivative?`(${t} + dF_impl(${t}))`:t}uniform(t,n){const e=`bgU${this.s.uniforms.size}`,a=zr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Br.get(t);if(!n)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(n),t}source(t,n){if("value"in t)return this.s.structure.push("v"),this.uniform(n,t.value);const[e,a]=t.link,r=this.graph.nodes[e];if(!r)throw new Error(`The graph links to ${e}, which it does not carry`);const f=this.node(e,r)[a];if(!f)throw new Error(`${e} has no output ${a}`);return this.s.structure.push(["l",e,a]),Cr(f.name,f.type,n)}input(t,n,e){const a=t.inputs.find(r=>r.id===n)??t.inputs.find(r=>r.id.replace(/_/g," ")===n);if(!a)throw new Error(`${t.type} arrived without its '${n}' input`);return this.source(a,e??a.gpu)}coordinate(t,n){const e=t.inputs[0];return"link"in e?this.source(e,"vec3"):(this.s.structure.push(["default",n]),n==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${Ht("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const a=`${this.prefix}${this.emitted.size}`,r=n.outputs.map((l,c)=>({name:`${a}_${c}`,type:l.gpu==="closure"||l.gpu===null?"float":l.gpu}));this.emitted.set(t,r);const i=l=>`${r[l].type} ${r[l].name} = ${r[l].type}(0.0);`,f=r.map((l,c)=>i(c)).join(" "),u=l=>l.map(c=>r[c].name).join(", "),h=(l=[])=>[...n.inputs.map(_=>this.source(_,_.gpu)),...l,...r.map(_=>_.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const s=[f];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const l=r[0].type;s.push(`${r[0].name} = ${this.uniform(l,D(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Ht("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((c,_)=>{r[_]&&s.push(`${r[_].name} = ${this.d(c)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const l=D(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(l),this.s.structure.push(["a",l]);const c=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(c)}(${Jn(l)}, ${u(r.map((_,d)=>d))});`);for(const _ of r)s.push(`${_.name} = ${this.d(_.name)};`);break}case"ShaderNodeUVMap":{const l=D(n,"uv_map");this.s.uvs.add(l),s.push(`${r[0].name} = ${this.d(`vec3(${Ht(l)}, 0.0)`)};`);break}case"ShaderNodeMath":{const l=D(n,"operation"),c=this.use(kr[l]??`math_${l.toLowerCase()}`);s.push(`${c}(${h()});`),D(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const l=D(n,"operation");s.push(`${this.use($r[l]??`vector_math_${l.toLowerCase()}`)}(${h()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${D(n,"vector_type").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${h()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${h()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${h()});`);break;case"ShaderNodeMix":{const l=D(n,"data_type"),c=D(n,"factor_mode")==="NON_UNIFORM",_={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[l];if(!_)throw new Error(`Mix has data type ${l}`);const d=l==="VECTOR"&&c;let m=this.input(n,d?"Factor_Vector":"Factor_Float");if(D(n,"clamp_factor")){const g=`${a}_fac`;s.push(d?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${g});`),m=g}const p=l==="FLOAT"?"node_mix_float":l==="VECTOR"?c?"node_mix_vector_non_uniform":"node_mix_vector":l==="RGBA"?`node_mix_${zo[D(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${_}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${_}`)}, ${this.input(n,`B_${_}`)}, ${u([v])});`),l==="RGBA"&&D(n,"clamp_result")&&s.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const l=`${a}_fac`;s.push(`float ${l}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${l});`);const c=n.inputs.slice(1).map(_=>this.source(_,_.gpu));s.push(`${this.use(`mix_${zo[D(n,"blend_type")]}`)}(${[l,...c,u([0])].join(", ")});`),D(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const l=D(n,"color_ramp"),c=this.input(n,"Fac"),[_,d]=l.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(l.elements.length===1)s.push(`${u([0])} = ${m(_)}; ${u([1])} = ${u([0])}.a;`);else if(l.elements.length===2&&l.color_mode==="RGB"&&d&&l.interpolation!=="B_SPLINE"&&l.interpolation!=="CARDINAL")if(l.interpolation==="CONSTANT")s.push(`${this.use("valtorgb_opti_constant")}(${c}, ${this.uniform("float",Math.max(_[0],d[0]))}, ${m(_)}, ${m(d)}, ${u([0,1])});`);else{const p=1/(d[0]-_[0]),v=l.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${c}, ${this.uniform("vec2",[p,-p*_[0]])}, ${m(_)}, ${m(d)}, ${u([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:l.table}),this.s.structure.push(["ramp",l.interpolation==="CONSTANT"]),s.push(l.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${c}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${c}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),s.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const l=D(n,"curve_mapping"),c=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:c,table:l.table}),this.s.structure.push(["curve"]);const _=this.input(n,n.inputs.some(d=>d.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${_}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${c}, 0.5, ${this.uniform("vec4",l.minimums)}, ${this.uniform("vec4",l.dividers)}, ${this.uniform("vec4",l.starts)}, ${this.uniform("vec4",l.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?s.push(`${this.use("curves_vector_mixed")}(${_}, ${this.input(n,"Vector","vec3")}, ${c}, 0.5, ${this.uniform("vec3",l.minimums.slice(0,3))}, ${this.uniform("vec3",l.dividers.slice(0,3))}, ${this.uniform("vec3",l.starts.slice(0,3))}, ${this.uniform("vec3",l.ends.slice(0,3))}, ${u([0])});`):s.push(`${this.use("curves_float_mixed")}(${_}, ${this.input(n,"Value","float")}, ${c}, 0.5, ${this.uniform("float",l.minimums[0])}, ${this.uniform("float",l.dividers[0])}, ${this.uniform("float",l.starts[0])}, ${this.uniform("float",l.ends[0])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const l=Number(D(n,"noise_dimensions")[0]),c=this.use(`node_noise_tex_${Lr[D(n,"noise_type")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=D(n,"normalize")?"1.0":"0.0";s.push(`${c}(${[_,...d,m,"1.0",u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const l=Number(D(n,"voronoi_dimensions")[0]),c=this.use(`node_tex_voronoi_${Vr[D(n,"feature")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${jr[D(n,"distance")].toFixed(1)}`,p=D(n,"normalize")?"1.0":"0.0";s.push(`${c}(${[_,...d,m,p,u(r.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const l=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(_=>this.source(_,_.gpu));s.push(`${this.use("node_tex_checker")}(${[l,...c,u(r.map((_,d)=>d))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const l=Number(D(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${l}d`)}(${h()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const l=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),_=p=>D(n,`${p}#value`).toFixed(1),d=n.type==="ShaderNodeTexWave"?[_("wave_type"),_("bands_direction"),_("rings_direction"),_("wave_profile")]:n.type==="ShaderNodeTexGradient"?[_("gradient_type")]:n.type==="ShaderNodeTexMagic"?[D(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",D(n,"offset")),D(n,"offset_frequency").toFixed(1),this.uniform("float",D(n,"squash")),D(n,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];s.push(`${this.use(m)}(${[l,...c,...d,u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const l=D(n,"data_type")==="FLOAT_VECTOR",c=D(n,"interpolation_type").toLowerCase(),_=D(n,"clamp");s.push(`${this.use(`${l?"vector_":""}map_range_${c}`)}(${h([_?"1.0":"0.0"])});`),_&&!l&&(c==="linear"||c==="stepped")&&s.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":s.push(`${this.use(D(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${h()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${h()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${h()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${h()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${h([ge])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${D(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${D(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeVectorRotate":{const l={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[D(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${l}`)}(${h([D(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const l=n.inputs[1],c="link"in l?this.source(l,"vec3"):"g_data.N";"link"in l||this.s.structure.push("world-normal");const _=this.source(n.inputs[0],"float"),d=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(d)}(${[_,c,u(r.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const l=n.inputs.find(w=>w.id==="Height"),c=n.inputs.find(w=>w.id==="Normal"),_=c&&"link"in c?this.source(c,"vec3"):"g_data.N";if(!l||!("link"in l)){s.push(`${u([0])} = ${_};`);break}const d=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new io(this.graph,this.s,!0,`${d}_`),p=m.source(l,"float");this.s.functions[Number(d.slice(8))]=`float ${d}() {
|
|
7022
|
+
`;class vo{constructor(t,n,e=!1,a="bgN"){this.graph=t,this.derivative=e,this.prefix=a,this.lines=[],this.emitted=new Map,this.s=n??{files:new Set,uniforms:new Map,uniformTypes:new Map,images:[],ramps:[],uvs:new Set,attributes:new Set,structure:[],functions:[]}}get uniforms(){return this.s.uniforms}get images(){return this.s.images}get ramps(){return this.s.ramps}d(t){return this.derivative?`(${t} + dF_impl(${t}))`:t}uniform(t,n){const e=`bgU${this.s.uniforms.size}`,a=Wr(t,n);return this.s.uniforms.set(e,t==="float"?a[0]:a),this.s.uniformTypes.set(e,t),e}use(t){const n=Qr.get(t);if(!n)throw new Error(`Blender's node library has no ${t}`);return this.s.files.add(n),t}source(t,n){if("value"in t)return this.s.structure.push("v"),this.uniform(n,t.value);const[e,a]=t.link,r=this.graph.nodes[e];if(!r)throw new Error(`The graph links to ${e}, which it does not carry`);const f=this.node(e,r)[a];if(!f)throw new Error(`${e} has no output ${a}`);return this.s.structure.push(["l",e,a]),Hr(f.name,f.type,n)}input(t,n,e){const a=t.inputs.find(r=>r.id===n)??t.inputs.find(r=>r.id.replace(/_/g," ")===n);if(!a)throw new Error(`${t.type} arrived without its '${n}' input`);return this.source(a,e??a.gpu)}coordinate(t,n){const e=t.inputs[0];return"link"in e?this.source(e,"vec3"):(this.s.structure.push(["default",n]),n==="orco"?this.d("blender_orco()"):(this.s.uvs.add(""),this.d(`vec3(${Kt("")}, 0.0)`)))}node(t,n){const e=this.emitted.get(t);if(e)return e;const a=`${this.prefix}${this.emitted.size}`,r=n.outputs.map((l,c)=>({name:`${a}_${c}`,type:l.gpu==="closure"||l.gpu===null?"float":l.gpu}));this.emitted.set(t,r);const i=l=>`${r[l].type} ${r[l].name} = ${r[l].type}(0.0);`,f=r.map((l,c)=>i(c)).join(" "),u=l=>l.map(c=>r[c].name).join(", "),h=(l=[])=>[...n.inputs.map(_=>this.source(_,_.gpu)),...l,...r.map(_=>_.name)].join(", ");this.s.structure.push(["n",n.type,n.props.operation,n.props.blend_type,n.props.data_type,n.props.factor_mode,n.props.clamp_factor,n.props.clamp_result,n.props.use_clamp,n.props.noise_dimensions,n.props.noise_type,n.props.voronoi_dimensions,n.props.feature,n.props.distance,n.props.vector_type,n.props.uv_map,n.props.extension,n.props.interpolation,n.props.image_alpha_mode,n.props.image_is_data,n.props.color_ramp?.elements?.length,n.props.color_ramp?.interpolation]);const s=[f];switch(n.type){case"ShaderNodeValue":case"ShaderNodeRGB":{const l=r[0].type;s.push(`${r[0].name} = ${this.uniform(l,C(n,"value"))};`);break}case"ShaderNodeTexCoord":{this.s.uvs.add(""),["blender_orco()","blender_object_normal()",`vec3(${Kt("")}, 0.0)`,"vBlenderObjectPosition","blender_camera()","blender_window()","blender_reflection()"].forEach((c,_)=>{r[_]&&s.push(`${r[_].name} = ${this.d(c)};`)});break}case"ShaderNodeVertexColor":case"ShaderNodeAttribute":{const l=C(n,n.type==="ShaderNodeAttribute"?"attribute_name":"layer_name");this.s.attributes.add(l),this.s.structure.push(["a",l]);const c=n.type==="ShaderNodeAttribute"?"node_attribute":"node_vertex_color";s.push(`${this.use(c)}(${io(l)}, ${u(r.map((_,d)=>d))});`);for(const _ of r)s.push(`${_.name} = ${this.d(_.name)};`);break}case"ShaderNodeUVMap":{const l=C(n,"uv_map");this.s.uvs.add(l),s.push(`${r[0].name} = ${this.d(`vec3(${Kt(l)}, 0.0)`)};`);break}case"ShaderNodeMath":{const l=C(n,"operation"),c=this.use(qr[l]??`math_${l.toLowerCase()}`);s.push(`${c}(${h()});`),C(n,"use_clamp")&&s.push(`${this.use("clamp_value")}(${u([0])}, 0.0, 1.0, ${u([0])});`);break}case"ShaderNodeVectorMath":{const l=C(n,"operation");s.push(`${this.use(Gr[l]??`vector_math_${l.toLowerCase()}`)}(${h()});`);break}case"ShaderNodeMapping":s.push(`${this.use(`mapping_${C(n,"vector_type").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeInvert":s.push(`${this.use("invert")}(${h()});`);break;case"ShaderNodeSeparateXYZ":s.push(`${this.use("separate_xyz")}(${h()});`);break;case"ShaderNodeCombineXYZ":s.push(`${this.use("combine_xyz")}(${h()});`);break;case"ShaderNodeMix":{const l=C(n,"data_type"),c=C(n,"factor_mode")==="NON_UNIFORM",_={FLOAT:"Float",VECTOR:"Vector",RGBA:"Color",ROTATION:"Rotation"}[l];if(!_)throw new Error(`Mix has data type ${l}`);const d=l==="VECTOR"&&c;let m=this.input(n,d?"Factor_Vector":"Factor_Float");if(C(n,"clamp_factor")){const g=`${a}_fac`;s.push(d?`vec3 ${g}; ${this.use("node_mix_clamp_vector")}(${m}, vec3(0.0), vec3(1.0), ${g});`:`float ${g}; ${this.use("node_mix_clamp_value")}(${m}, 0.0, 1.0, ${g});`),m=g}const p=l==="FLOAT"?"node_mix_float":l==="VECTOR"?c?"node_mix_vector_non_uniform":"node_mix_vector":l==="RGBA"?`node_mix_${Ho[C(n,"blend_type")]}`:"node_mix_rotation",v=n.outputs.findIndex(g=>g.id===`Result_${_}`);s.push(`${this.use(p)}(${m}, ${this.input(n,`A_${_}`)}, ${this.input(n,`B_${_}`)}, ${u([v])});`),l==="RGBA"&&C(n,"clamp_result")&&s.push(`${this.use("node_mix_clamp_color")}(${u([v])}, vec4(0.0), vec4(1.0), ${u([v])});`);break}case"ShaderNodeMixRGB":{const l=`${a}_fac`;s.push(`float ${l}; ${this.use("clamp_value")}(${this.input(n,"Fac")}, 0.0, 1.0, ${l});`);const c=n.inputs.slice(1).map(_=>this.source(_,_.gpu));s.push(`${this.use(`mix_${Ho[C(n,"blend_type")]}`)}(${[l,...c,u([0])].join(", ")});`),C(n,"use_clamp")&&s.push(`${this.use("clamp_color")}(${u([0])}, vec4(0.0), vec4(1.0), ${u([0])});`);break}case"ShaderNodeValToRGB":{const l=C(n,"color_ramp"),c=this.input(n,"Fac"),[_,d]=l.elements,m=p=>this.uniform("vec4",p.slice(1,5));if(l.elements.length===1)s.push(`${u([0])} = ${m(_)}; ${u([1])} = ${u([0])}.a;`);else if(l.elements.length===2&&l.color_mode==="RGB"&&d&&l.interpolation!=="B_SPLINE"&&l.interpolation!=="CARDINAL")if(l.interpolation==="CONSTANT")s.push(`${this.use("valtorgb_opti_constant")}(${c}, ${this.uniform("float",Math.max(_[0],d[0]))}, ${m(_)}, ${m(d)}, ${u([0,1])});`);else{const p=1/(d[0]-_[0]),v=l.interpolation==="EASE"?"valtorgb_opti_ease":"valtorgb_opti_linear";s.push(`${this.use(v)}(${c}, ${this.uniform("vec2",[p,-p*_[0]])}, ${m(_)}, ${m(d)}, ${u([0,1])});`)}else{const p=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:p,table:l.table}),this.s.structure.push(["ramp",l.interpolation==="CONSTANT"]),s.push(l.interpolation==="CONSTANT"?`${u([0])} = texelFetch(${p}, ivec2(int(clamp(${c}, 0.0, 1.0) * 256.0), 0), 0);`:`${u([0])} = texture(${p}, vec2(clamp(${c}, 0.0, 1.0) * (256.0 / 257.0) + 0.5 / 257.0, 0.5));`),s.push(`${u([1])} = ${u([0])}.a;`)}break}case"ShaderNodeRGBCurve":case"ShaderNodeVectorCurve":case"ShaderNodeFloatCurve":{const l=C(n,"curve_mapping"),c=`bgRamp${this.s.ramps.length}`;this.s.ramps.push({uniform:c,table:l.table}),this.s.structure.push(["curve"]);const _=this.input(n,n.inputs.some(d=>d.id==="Factor")?"Factor":"Fac","float");n.type==="ShaderNodeRGBCurve"?s.push(`${this.use("curves_combined_rgb")}(${_}, ${this.input(n,"Color","vec4")}, vec4(0.0, 0.0, 0.0, 1.0), vec4(1.0), ${c}, 0.5, ${this.uniform("vec4",l.minimums)}, ${this.uniform("vec4",l.dividers)}, ${this.uniform("vec4",l.starts)}, ${this.uniform("vec4",l.ends)}, ${u([0])});`):n.type==="ShaderNodeVectorCurve"?s.push(`${this.use("curves_vector_mixed")}(${_}, ${this.input(n,"Vector","vec3")}, ${c}, 0.5, ${this.uniform("vec3",l.minimums.slice(0,3))}, ${this.uniform("vec3",l.dividers.slice(0,3))}, ${this.uniform("vec3",l.starts.slice(0,3))}, ${this.uniform("vec3",l.ends.slice(0,3))}, ${u([0])});`):s.push(`${this.use("curves_float_mixed")}(${_}, ${this.input(n,"Value","float")}, ${c}, 0.5, ${this.uniform("float",l.minimums[0])}, ${this.uniform("float",l.dividers[0])}, ${this.uniform("float",l.starts[0])}, ${this.uniform("float",l.ends[0])}, ${u([0])});`);break}case"ShaderNodeTexNoise":{const l=Number(C(n,"noise_dimensions")[0]),c=this.use(`node_noise_tex_${Xr[C(n,"noise_type")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),m=C(n,"normalize")?"1.0":"0.0";s.push(`${c}(${[_,...d,m,"1.0",u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeTexVoronoi":{const l=Number(C(n,"voronoi_dimensions")[0]),c=this.use(`node_tex_voronoi_${Yr[C(n,"feature")]}_${l}d`),_=this.coordinate(n,"orco"),d=n.inputs.slice(1).map(v=>this.source(v,v.gpu)),m=`${Zr[C(n,"distance")].toFixed(1)}`,p=C(n,"normalize")?"1.0":"0.0";s.push(`${c}(${[_,...d,m,p,u(r.map((v,g)=>g))].join(", ")});`);break}case"ShaderNodeTexChecker":{const l=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(_=>this.source(_,_.gpu));s.push(`${this.use("node_tex_checker")}(${[l,...c,u(r.map((_,d)=>d))].join(", ")});`);break}case"ShaderNodeTexWhiteNoise":{const l=Number(C(n,"noise_dimensions")[0]);s.push(`${this.use(`node_white_noise_${l}d`)}(${h()});`);break}case"ShaderNodeTexWave":case"ShaderNodeTexGradient":case"ShaderNodeTexMagic":case"ShaderNodeTexBrick":{const l=this.coordinate(n,"orco"),c=n.inputs.slice(1).map(p=>this.source(p,p.gpu)),_=p=>C(n,`${p}#value`).toFixed(1),d=n.type==="ShaderNodeTexWave"?[_("wave_type"),_("bands_direction"),_("rings_direction"),_("wave_profile")]:n.type==="ShaderNodeTexGradient"?[_("gradient_type")]:n.type==="ShaderNodeTexMagic"?[C(n,"turbulence_depth").toFixed(1)]:[this.uniform("float",C(n,"offset")),C(n,"offset_frequency").toFixed(1),this.uniform("float",C(n,"squash")),C(n,"squash_frequency").toFixed(1)],m={ShaderNodeTexWave:"node_tex_wave",ShaderNodeTexGradient:"node_tex_gradient",ShaderNodeTexMagic:"node_tex_magic",ShaderNodeTexBrick:"node_tex_brick"}[n.type];s.push(`${this.use(m)}(${[l,...c,...d,u(r.map((p,v)=>v))].join(", ")});`);break}case"ShaderNodeMapRange":{const l=C(n,"data_type")==="FLOAT_VECTOR",c=C(n,"interpolation_type").toLowerCase(),_=C(n,"clamp");s.push(`${this.use(`${l?"vector_":""}map_range_${c}`)}(${h([_?"1.0":"0.0"])});`),_&&!l&&(c==="linear"||c==="stepped")&&s.push(`${this.use("clamp_range")}(${u([0])}, ${this.input(n,"To Min","float")}, ${this.input(n,"To Max","float")}, ${u([0])});`);break}case"ShaderNodeClamp":s.push(`${this.use(C(n,"clamp_type")==="MINMAX"?"clamp_minmax":"clamp_range")}(${h()});`);break;case"ShaderNodeHueSaturation":s.push(`${this.use("hue_sat")}(${h()});`);break;case"ShaderNodeBrightContrast":s.push(`${this.use("brightness_contrast")}(${h()});`);break;case"ShaderNodeGamma":s.push(`${this.use("node_gamma")}(${h()});`);break;case"ShaderNodeRGBToBW":s.push(`${this.use("rgbtobw")}(${h([Se])});`);break;case"ShaderNodeSeparateColor":s.push(`${this.use(`separate_color_${C(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeCombineColor":s.push(`${this.use(`combine_color_${C(n,"mode").toLowerCase()}`)}(${h()});`);break;case"ShaderNodeVectorRotate":{const l={AXIS_ANGLE:"axis_angle",X_AXIS:"axis_x",Y_AXIS:"axis_y",Z_AXIS:"axis_z",EULER_XYZ:"euler_xyz"}[C(n,"rotation_type")];s.push(`${this.use(`node_vector_rotate_${l}`)}(${h([C(n,"invert")?"-1.0":"1.0"])});`);break}case"ShaderNodeFresnel":case"ShaderNodeLayerWeight":{const l=n.inputs[1],c="link"in l?this.source(l,"vec3"):"g_data.N";"link"in l||this.s.structure.push("world-normal");const _=this.source(n.inputs[0],"float"),d=n.type==="ShaderNodeFresnel"?"node_fresnel":"node_layer_weight";s.push(`${this.use(d)}(${[_,c,u(r.map((m,p)=>p))].join(", ")});`);break}case"ShaderNodeBump":{const l=n.inputs.find(w=>w.id==="Height"),c=n.inputs.find(w=>w.id==="Normal"),_=c&&"link"in c?this.source(c,"vec3"):"g_data.N";if(!l||!("link"in l)){s.push(`${u([0])} = ${_};`);break}const d=`bgHeight${this.s.functions.length}`;this.s.functions.push("");const m=new vo(this.graph,this.s,!0,`${d}_`),p=m.source(l,"float");this.s.functions[Number(d.slice(8))]=`float ${d}() {
|
|
7023
7023
|
${m.lines.join(`
|
|
7024
7024
|
`)}
|
|
7025
7025
|
return ${p};
|
|
7026
|
-
}`;const v=this.input(n,"Filter Width","float");s.push(`float ${a}_h = ${d}();`,`g_derivative_filter_width = ${v} * derivative_scale_get();`,`g_derivative_flag = 1; float ${a}_hx = ${d}();`,`g_derivative_flag = -1; float ${a}_hy = ${d}();`,"g_derivative_flag = 0;");const g=
|
|
7026
|
+
}`;const v=this.input(n,"Filter Width","float");s.push(`float ${a}_h = ${d}();`,`g_derivative_filter_width = ${v} * derivative_scale_get();`,`g_derivative_flag = 1; float ${a}_hx = ${d}();`,`g_derivative_flag = -1; float ${a}_hy = ${d}();`,"g_derivative_flag = 0;");const g=C(n,"invert")?"-1.0":"1.0";s.push(`${this.use("node_bump")}(${this.input(n,"Strength","float")}, ${this.input(n,"Distance","float")}, ${v}, ${a}_h, ${_}, vec2(${a}_hx, ${a}_hy), ${g}, ${u([0])});`);break}case"ShaderNodeNormalMap":{const l=C(n,"space"),c=this.input(n,"Strength","float"),_=this.input(n,"Color","vec3"),d=`${a}_n`;if(s.push(`vec3 ${d}; ${this.use(l.startsWith("BLENDER_")?"color_to_blender_normal_new_shading":"color_to_normal_new_shading")}(${_}, ${d});`),n.props.convention==="DIRECTX"&&s.push(`${this.use("color_invert_green_channel")}(${d}, ${d});`),l==="TANGENT"){const m=C(n,"uv_map");this.s.uvs.add(m),s.push(`${this.use("node_normal_map")}(blender_uv_tangent(${Kt(m)}), ${c}, ${d}, g_data.Ni, ${u([0])});`)}else(l==="OBJECT"||l==="BLENDER_OBJECT")&&s.push(`${this.use("normal_transform_object_to_world")}(${d}, ${d});`),s.push(`${this.use("node_normal_map_mix")}(${c}, ${d}, ${u([0])});`);break}case"ShaderNodeNewGeometry":{s.push(`${this.use("node_geometry")}(${["blender_orco()",u(r.map((l,c)=>c))].join(", ")});`),r[0]&&s.push(`${r[0].name} = ${this.d(r[0].name)};`);for(const l of[1,2,4])r[l]&&s.push(`${r[l].name} = normalize(${r[l].name});`);break}case"ShaderNodeTexImage":{const l=C(n,"image");if(l===null){s.push(n.props.image_missing===!0?`${u([0])} = vec4(1.0, 0.0, 1.0, 1.0); ${u([1])} = 1.0;`:`${u([0])} = vec4(0.0); ${u([1])} = 0.0;`);break}const c=C(n,"projection"),_=C(n,"interpolation"),d=_==="Cubic"||_==="Smart",m=C(n,"extension"),p=`bgImage${this.s.images.length}`;this.s.images.push({uniform:p,node:t,name:l.name,revision:l.revision,extension:m,closest:_==="Closest",mipmap:c!=="SPHERE"&&c!=="TUBE",tiled:c==="FLAT"&&n.props.image_tiled===!0});const v=this.s.images.at(-1).tiled;this.s.structure.push(["img",c,d,v]);let g=this.coordinate(n,"uv");const w=u([0]),y=u([1]);if(c==="BOX"){const O=`${a}_n`;s.push(`vec3 ${O}; ${this.use("world_normals_get")}(${O}); ${this.use("normal_transform_world_to_object")}(${O}, ${O});`,`vec4 ${a}_c1, ${a}_c2, ${a}_c3;`,`${this.use(d?"tex_box_sample_cubic":"tex_box_sample_linear")}(${g}, ${O}, ${p}, ${a}_c1, ${a}_c2, ${a}_c3);`,`${this.use("tex_box_blend")}(${O}, ${a}_c1, ${a}_c2, ${a}_c3, ${this.uniform("float",C(n,"projection_blend"))}, ${w}, ${y});`)}else if(v)d&&this.use("cubic_bspline_coefficients"),s.push(`${d?"blender_tex_tile_cubic":"blender_tex_tile_linear"}(${g}, ${p}, ${p}Map, ${w}, ${y});`);else{if(c==="SPHERE"||c==="TUBE"){const O=`${a}_co`;s.push(`vec3 ${O}; ${this.use("point_texco_remap_square")}(${g}, ${O});`,`${this.use(c==="SPHERE"?"point_map_to_sphere":"point_map_to_tube")}(${O}, ${O});`),g=O}s.push(`${this.use(d?"node_tex_image_cubic":"node_tex_image_linear")}(${g}, ${p}, ${w}, ${y});`),m==="CLIP"&&s.push(`if (any(lessThan(${g}.xy, vec2(0.0))) || any(greaterThan(${g}.xy, vec2(1.0)))) { ${w} = vec4(0.0); ${y} = 0.0; }`)}const S=C(n,"image_alpha_mode"),T=this.uses(t,1),A=u([0]);S==="NONE"||S==="CHANNEL_PACKED"||C(n,"image_is_data")?s.push(`${A}.a = 1.0;`):S==="PREMUL"?s.push(T?`if (${A}.a != 0.0 && ${A}.a != 1.0) ${A}.rgb /= ${A}.a;`:`${A}.a = 1.0;`):s.push(T?`${A}.a = 1.0;`:`${A}.rgb *= ${A}.a;`);break}}return this.lines.push(...s),r}uses(t,n){const e=r=>"link"in r&&r.link[0]===t&&r.link[1]===n,a=r=>r!==void 0&&("emission"in r?r.emission.some(e):"mix"in r?e(r.mix[0])||a(r.mix[1])||a(r.mix[2]):"add"in r?a(r.add[0])||a(r.add[1]):!1);return Object.values(this.graph.inputs).some(e)||Object.values(this.graph.nodes).some(r=>r.inputs.some(e))||a(this.graph.closure)}compile(){const t=this.graph.surface==="ShaderNodeEmission"?{Color:"vec4",Strength:"float"}:{"Base Color":"vec4",Metallic:"float",Roughness:"float",Alpha:"float","Emission Color":"vec4","Emission Strength":"float",Normal:"vec3"},n={},e=[];let a=0;for(const[l,c]of Object.entries(t)){const _=this.graph.inputs[l];if(!_||l==="Normal"&&!("link"in _))continue;const d=`bgOut${a++}`;n[l]={global:d,type:c},this.s.structure.push(["out",l]),e.push(`${d} = ${this.source(_,c)};`)}const r=this.graph.closure;if(r){let l=0;const c=(_,d)=>{if("principled"in _)this.s.structure.push("cP"),e.push(`bgClosureP += ${d};`);else if("emission"in _)this.s.structure.push("cE"),e.push(`bgClosureE += ${d} * ${this.source(_.emission[0],"vec4")}.rgb * ${this.source(_.emission[1],"float")};`);else if("transparent"in _)this.s.structure.push("cT"),e.push(`bgClosureT += ${d} * ${this.source({value:_.transparent},"float")};`);else if("mix"in _){this.s.structure.push("cM");const m=`bgClosureF${l++}`;e.push(`float ${m} = clamp(${this.source(_.mix[0],"float")}, 0.0, 1.0);`),c(_.mix[1],`${d} * (1.0 - ${m})`),c(_.mix[2],`${d} * ${m}`)}else"add"in _?(this.s.structure.push("cA"),c(_.add[0],d),c(_.add[1],d)):this.s.structure.push("c0")};e.push("bgClosureP = 0.0;","bgClosureE = vec3(0.0);","bgClosureT = 0.0;"),c(r,"1.0")}const i=[],f=new Set,u=l=>{if(!f.has(l)){f.add(l);for(const c of lo[l].deps)u(c);i.push(l)}};for(const l of this.s.files)u(l);const h=`void blenderGraph() {
|
|
7027
7027
|
blender_init_globals();
|
|
7028
7028
|
${[...this.lines,...e].join(`
|
|
7029
7029
|
`)}
|
|
7030
|
-
}`,s=[
|
|
7030
|
+
}`,s=[$r,tl(Kr+i.map(l=>lo[l].code).join(`
|
|
7031
7031
|
`)+`
|
|
7032
|
-
`+
|
|
7032
|
+
`+Jr,[...this.s.functions,h].join(`
|
|
7033
7033
|
`)),...[...this.s.uniformTypes].map(([l,c])=>`uniform ${c} ${l};`),...this.images.map(l=>l.tiled?`uniform highp sampler2DArray ${l.uniform};
|
|
7034
7034
|
uniform highp sampler2D ${l.uniform}Map;`:`uniform sampler2D ${l.uniform};`),...this.ramps.map(l=>`uniform sampler2D ${l.uniform};`),...Object.values(n).map(l=>`${l.type} ${l.global};`),...r?["float bgClosureP;","vec3 bgClosureE;","float bgClosureT;"]:[],...this.s.functions,h].join(`
|
|
7035
|
-
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:s,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:r!==void 0}}}function
|
|
7035
|
+
`);return{key:JSON.stringify([this.graph.surface,this.s.structure,[...this.s.uvs].sort()]),declarations:s,uniforms:this.uniforms,images:this.images,ramps:this.ramps,uvs:[...this.s.uvs],attributes:[...this.s.attributes],outputs:n,surface:this.graph.surface,closure:r!==void 0}}}function tl(o,t){const n=[],e=/^[A-Za-z_][\w ]*?\b([A-Za-z_]\w*)\s*\(/gm;let a=0;for(let u;u=e.exec(o);){if(u.index<a)continue;let h=u.index+u[0].length;for(let _=1;h<o.length&&_>0;h++)_+=o[h]==="("?1:o[h]===")"?-1:0;const s=o.slice(h).match(/^\s*(\{|;)/);if(!s||/^\s*#/.test(o.slice(o.lastIndexOf(`
|
|
7036
7036
|
`,u.index)+1,u.index+1))||o.slice(Math.max(0,u.index-2),u.index).endsWith(`\\
|
|
7037
|
-
`))continue;let c=h+s[0].length;if(s[1]==="{")for(let _=1;c<o.length&&_>0;c++)_+=o[c]==="{"?1:o[c]==="}"?-1:0;n.push({text:o.slice(a,u.index),name:null}),n.push({text:o.slice(u.index,c),name:u[1]}),a=c,e.lastIndex=c}n.push({text:o.slice(a),name:null});const r=new Set(n.filter(u=>u.name===null)),i=new Set,f=u=>{for(const h of u.matchAll(/[A-Za-z_]\w*/g))i.add(h[0])};f(t);for(const u of r)f(u.text);for(let u=!0;u;){u=!1;for(const h of n)r.has(h)||h.name===null||!i.has(h.name)||(r.add(h),f(h.text),u=!0)}return n.filter(u=>r.has(u)).map(u=>u.text).join("")}function
|
|
7038
|
-
`).find(_=>_.startsWith("ERROR"))??"";console.warn(`Blender material "${o.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${c}`);return}const l=
|
|
7037
|
+
`))continue;let c=h+s[0].length;if(s[1]==="{")for(let _=1;c<o.length&&_>0;c++)_+=o[c]==="{"?1:o[c]==="}"?-1:0;n.push({text:o.slice(a,u.index),name:null}),n.push({text:o.slice(u.index,c),name:u[1]}),a=c,e.lastIndex=c}n.push({text:o.slice(a),name:null});const r=new Set(n.filter(u=>u.name===null)),i=new Set,f=u=>{for(const h of u.matchAll(/[A-Za-z_]\w*/g))i.add(h[0])};f(t);for(const u of r)f(u.text);for(let u=!0;u;){u=!1;for(const h of n)r.has(h)||h.name===null||!i.has(h.name)||(r.add(h),f(h.text),u=!0)}return n.filter(u=>r.has(u)).map(u=>u.text).join("")}function io(o){return`v${Xt(o)}`}function Kt(o){return o===""?"vBlenderUvRender":`vBlenderUv_${[...o].map(t=>t.charCodeAt(0).toString(16)).join("")}`}function nl(o){return new vo(o).compile()}function ol(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=>sn.toHalfFloat(r)),a*4));const n=new zn(t,o.length,1,Dn,co);return n.minFilter=n.magFilter=Gt,n.wrapS=n.wrapT=se,n.needsUpdate=!0,n}const yt=new WeakMap,Ee=new Set,Ht=new WeakMap,gn=new WeakMap;function xn(o){const t=Ht.get(o);if(t){Ht.delete(o);for(const n of t.binding.ramps)n.dispose()}}function el(o,t,n,e=!1){const a=yt.get(o);if(t&&Ee.has(t.key)&&(t=null),!t){if(xn(o),a){for(const f of a.ramps)f.dispose();yt.delete(o),o.needsUpdate=!0}return}if(a&&a.compiled.key===t.key){xn(o),bn(a,t,n);return}if(e){xn(o);for(const u of a?.ramps??[])u.dispose();const f={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};bn(f,t,n),yt.set(o,f),o.needsUpdate=!0;return}const r=Ht.get(o);if(r&&r.binding.compiled.key===t.key){bn(r.binding,t,n);return}xn(o);const i={compiled:t,uniforms:{},ramps:[],channels:a?.channels??{}};bn(i,t,n),Ht.set(o,{binding:i,started:!1})}function bn(o,t,n){o.compiled=t;for(const[e,a]of t.uniforms){const r=typeof a=="number"?a:a.length===2?new qt(...a):a.length===3?new x(...a):new fo(...a),i=o.uniforms[e];i?i.value=r:o.uniforms[e]={value:r}}for(const e of o.ramps)e.dispose();o.ramps=t.ramps.map(e=>{const a=ol(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 al(o){const t=yt.get(o);return t?`${t.compiled.key}|${JSON.stringify(t.channels)}`:""}function rl(o){return Object.values(yt.get(o)?.channels??{})}function qo(o,t){const n=t.userData.blenderUvChannels,e=t.getAttribute("position")?.count??0,a={};for(const r of o.uvs){let i=r===""?0:n?.[r];i===void 0&&(i=9,t.getAttribute("uv9")?.count!==e&&t.setAttribute("uv9",new dt(new Float32Array(e*2),2))),a[r]=i}return a}function ll(o,t,n,e,a,r,i){const f=gn.get(o);f&&++f.draws>1&&(f.shadow.dispose(),gn.delete(o));const u=Ht.get(o);if(u&&!u.started){u.started=!0,u.binding.channels=qo(u.binding.compiled,t);const c=i(o);yt.set(c,u.binding);const _=new Rt(t,c);_.castShadow=r.castShadow,_.receiveShadow=r.receiveShadow;const d=()=>{if(Ht.get(o)!==u){c.dispose();return}Ht.delete(o);for(const m of yt.get(o)?.ramps??[])m.dispose();yt.set(o,u.binding),o.needsUpdate=!0,gn.get(o)?.shadow.dispose(),gn.set(o,{shadow:c,draws:0}),Ot()};n.compileAsync(_,a,e).then(d,d)}const h=yt.get(o);if(!h)return;const s=n.properties.get(o).currentProgram;if(s?.diagnostics?.runnable===!1&&s.cacheKey?.includes(h.compiled.key)){Ee.add(h.compiled.key),yt.delete(o),o.needsUpdate=!0;const c=s.diagnostics.fragmentShader.log.split(`
|
|
7038
|
+
`).find(_=>_.startsWith("ERROR"))??"";console.warn(`Blender material "${o.name}": its node graph did not compile for WebGL, so it is drawn with its constant values. ${c}`);return}const l=qo(h.compiled,t);JSON.stringify(l)!==JSON.stringify(h.channels)&&(h.channels=l,o.needsUpdate=!0)}function il(o){const t=Array.isArray(o.material)?o.material:[o.material];if(!t.some(u=>u instanceof mn&&yt.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",sl(n,e)),n.userData.blenderOrcoStamp=r);const i=a?.count??0,f=o.userData.blenderDefaultColor;for(const u of t){const h=u instanceof mn?yt.get(u):void 0;for(const s of h?.compiled.attributes??[]){const l=Xt(s),c=s===""?f===void 0?void 0:n.getAttribute(Xt(f)):n.getAttribute(l);c&&c.count===i?n.getAttribute(l)!==c&&n.setAttribute(l,c):n.getAttribute(l)?.count!==i&&n.setAttribute(l,new dt(new Float32Array(i*4),4))}}}function sl(o,t){const n=o.getAttribute("position");let e,a;if(t)e=[...t[0]],a=[...t[1]];else{o.computeBoundingBox();const i=o.boundingBox;e=[(i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2],a=[(i.max.x-i.min.x)/2,(i.max.y-i.min.y)/2,(i.max.z-i.min.z)/2]}a=a.map(i=>i===0?1:i);const r=new Float32Array(n.count*3);for(let i=0;i<n.count;i++)r[i*3]=(n.getX(i)-e[0])/a[0]*.5+.5,r[i*3+1]=(n.getY(i)-e[1])/a[1]*.5+.5,r[i*3+2]=(n.getZ(i)-e[2])/a[2]*.5+.5;return new dt(r,3)}function fl(o,t){const n=yt.get(o);if(!n)return;const{compiled:e,channels:a}=n;Object.assign(t.uniforms,n.uniforms,{blenderViewport:{value:Me}});const r=v=>v===0?"uv":`uv${v}`,i=`varying vec3 vBlenderObjectPosition;
|
|
7039
7039
|
varying vec3 vBlenderObjectNormal;
|
|
7040
7040
|
varying vec3 vBlenderWorldPosition;
|
|
7041
7041
|
varying vec3 vBlenderWorldNormal;
|
|
7042
7042
|
varying vec3 vBlenderOrco;
|
|
7043
|
-
${e.attributes.map(v=>`varying vec4 ${
|
|
7043
|
+
${e.attributes.map(v=>`varying vec4 ${io(v)};`).join(`
|
|
7044
7044
|
`)}
|
|
7045
|
-
${e.uvs.map(v=>`varying vec2 ${
|
|
7046
|
-
`)}`,f=e.attributes.map(v=>`attribute vec4 ${
|
|
7045
|
+
${e.uvs.map(v=>`varying vec2 ${Kt(v)};`).join(`
|
|
7046
|
+
`)}`,f=e.attributes.map(v=>`attribute vec4 ${Xt(v)};`).join(`
|
|
7047
7047
|
`);t.vertexShader=`attribute vec3 blenderOrco;
|
|
7048
7048
|
${f}
|
|
7049
7049
|
${i}
|
|
@@ -7052,9 +7052,9 @@ vBlenderObjectNormal = objectNormal;
|
|
|
7052
7052
|
vBlenderWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;
|
|
7053
7053
|
vBlenderWorldNormal = normalize(transpose(inverse(mat3(modelMatrix))) * objectNormal);
|
|
7054
7054
|
vBlenderOrco = blenderOrco;
|
|
7055
|
-
${e.attributes.map(v=>`${
|
|
7055
|
+
${e.attributes.map(v=>`${io(v)} = ${Xt(v)};`).join(`
|
|
7056
7056
|
`)}
|
|
7057
|
-
${e.uvs.map(v=>`${
|
|
7057
|
+
${e.uvs.map(v=>`${Kt(v)} = ${r(a[v]??0)};`).join(`
|
|
7058
7058
|
`)}
|
|
7059
7059
|
#include <project_vertex>`);const u=v=>e.outputs[v]?.global,h=[];e.surface==="ShaderNodeEmission"?(h.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),h.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Color")}.rgb * ${u("Strength")};`,!1]),h.push(["#include <opaque_fragment>","outgoingLight = totalEmissiveRadiance;",!0])):e.surface==="closure"?(h.push(["#include <color_fragment>","diffuseColor = vec4(0.0, 0.0, 0.0, 1.0);",!1]),h.push(["#include <emissivemap_fragment>","totalEmissiveRadiance = vec3(0.0);",!1])):(h.push(["#include <color_fragment>",`diffuseColor.rgb = ${u("Base Color")}.rgb;`,!1]),h.push(["#include <alphamap_fragment>",`diffuseColor.a = ${u("Alpha")};`,!1]),h.push(["#include <metalnessmap_fragment>",`roughnessFactor = ${u("Roughness")};`,!0]),h.push(["#include <metalnessmap_fragment>",`metalnessFactor = ${u("Metallic")};`,!1]),h.push(["#include <emissivemap_fragment>",`totalEmissiveRadiance = ${u("Emission Color")}.rgb * ${u("Emission Strength")};`,!1]),u("Normal")&&h.push(["#include <clearcoat_normal_fragment_begin>",`normal = normalize((viewMatrix * vec4(transpose(blender_from_three) * ${u("Normal")}, 0.0)).xyz);`,!0])),e.closure&&h.push(["#include <opaque_fragment>",`{
|
|
7060
7060
|
float blenderCoverage = diffuseColor.a;
|
|
@@ -7066,13 +7066,13 @@ ${e.uvs.map(v=>`${Ht(v)} = ${r(a[v]??0)};`).join(`
|
|
|
7066
7066
|
outgoingLight = blenderRadiance / max(blenderAlpha, 1e-4);
|
|
7067
7067
|
#endif
|
|
7068
7068
|
diffuseColor.a = blenderAlpha;
|
|
7069
|
-
}`,!0]);const s=v=>v.replace(/^[ \t]*#include <(\w+)>/gm,(g,w)=>s(
|
|
7069
|
+
}`,!0]);const s=v=>v.replace(/^[ \t]*#include <(\w+)>/gm,(g,w)=>s(jt[w]??"")),l=s(t.fragmentShader.slice(0,t.fragmentShader.indexOf("void main() {"))),c=new Map([...l.matchAll(/^[ \t]*#define[ \t]+(\w+).*$/gm)].map(v=>[v[1],v[0].trim()])),d=[...new Set([...e.declarations.matchAll(/^[ \t]*#define[ \t]+(\w+)/gm)].map(v=>v[1]))].filter(v=>c.has(v)),m=[...d.map(v=>`#undef ${v}`),e.declarations,...d.flatMap(v=>[`#undef ${v}`,c.get(v)])].join(`
|
|
7070
7070
|
`);let p=t.fragmentShader.replace("void main() {",`${i}
|
|
7071
7071
|
${m}
|
|
7072
7072
|
void main() {`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
|
|
7073
7073
|
blenderGraph();`);for(const[v,g,w]of h){if(!p.includes(v))throw new Error(`three's physical shader has no ${v}`);p=p.replace(v,w?`${g}
|
|
7074
7074
|
${v}`:`${v}
|
|
7075
|
-
${g}`)}t.fragmentShader=p}const
|
|
7075
|
+
${g}`)}t.fragmentShader=p}const Me=new qt(1,1);function cl(o){o.getDrawingBufferSize(Me)}function ul(o,t){const n=t.userData.blenderUvChannels;for(const e of[o.map,o.roughnessMap,o.normalMap]){if(!e)continue;const a=e.userData.blenderUvName;let r=a?n?.[a]:0;if(r===void 0){r=9;const i=t.getAttribute("position")?.count;if(i===void 0)throw new Error("A textured Blender draw has no positions");t.getAttribute("uv9")?.count!==i&&t.setAttribute("uv9",new dt(new Float32Array(i*2),2))}e.channel!==r&&(e.channel=r,o.needsUpdate=!0)}}class _l{constructor(){this.bindings=new Map}get(t,n,e,a,r=""){let i=this.bindings.get(t);if(!i||i.source!==n){this.delete(t),i={source:n,texture:n.clone(),version:-1,disposed:!1},this.bindings.set(t,i);const h=i;a&&a.then(()=>{h.disposed||(h.texture.needsUpdate=!0,h.version=n.version,Ot())},()=>{})}const f=e==="REPEAT"?Xe:e==="MIRROR"?Ye:se,u=i.texture.wrapS!==f||i.texture.wrapT!==f;return i.texture.wrapS=i.texture.wrapT=f,i.texture.userData.blenderUvName=r,n.image&&(u||i.version!==n.version)&&(i.texture.needsUpdate=!0,i.version=n.version),i.texture}delete(t){const n=this.bindings.get(t);n&&(n.disposed=!0,n.texture.dispose(),this.bindings.delete(t))}clear(){for(const t of this.bindings.keys())this.delete(t)}}const bt=N().finite(),qn=L([bt,bt,bt]),ml=P({coat:bt,coat_roughness:bt,coat_ior:bt,coat_tint:qn,sheen:bt,sheen_roughness:bt,sheen_tint:qn,anisotropy:bt,anisotropy_rotation:bt,specular_level:bt,specular_tint:qn,film_thickness:bt,film_ior:bt}).strict(),dl={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},nn=new WeakMap;function hl(o,t){nn.has(o)||go(o),nn.get(o).blenderWorldExtinction.value.copy(t)}function pl(o){const t=new mn,n=nn.get(o);go(t),t.copy(o);const e=nn.get(t);return n&&(e.blenderCoatIor.value=n.blenderCoatIor.value,e.blenderCoatTint.value.copy(n.blenderCoatTint.value),e.blenderMapClip.value=n.blenderMapClip.value,e.blenderRoughnessClip.value=n.blenderRoughnessClip.value,e.blenderNormalClip.value=n.blenderNormalClip.value,e.blenderWorldExtinction.value.copy(n.blenderWorldExtinction.value)),t}function go(o,t,n={}){const e=t??dl;o.clearcoat=e.coat,o.clearcoatRoughness=e.coat_roughness,o.sheen=e.sheen,o.sheenRoughness=e.sheen_roughness,o.sheenColor.setRGB(...e.sheen_tint,pt),o.anisotropy=e.anisotropy,o.anisotropyRotation=e.anisotropy_rotation*Math.PI*2,o.specularIntensity=e.specular_level*2,o.specularColor.setRGB(...e.specular_tint,pt),o.iridescence=e.film_thickness>0?1:0,o.iridescenceIOR=e.film_ior,o.iridescenceThicknessRange=[e.film_thickness,e.film_thickness];let a=nn.get(o);if(!a){a={blenderCoatIor:{value:1.5},blenderCoatTint:{value:new wt(1,1,1)},blenderMapClip:{value:!1},blenderRoughnessClip:{value:!1},blenderNormalClip:{value:!1},blenderWorldExtinction:{value:new x}},nn.set(o,a);const r=a;o.customProgramCacheKey=()=>`blender-principled-physical-v5${al(o)}`,o.onBeforeRender=(i,f,u,h,s)=>{ul(o,h),ll(o,h,i,f,u,s,pl),cl(i)},o.onBeforeCompile=i=>{const f=new Set([o.map,o.roughnessMap,o.normalMap].flatMap(d=>d?[d.channel]:[]).concat(rl(o)));i.vertexShader=[...f].filter(d=>d>0).sort((d,m)=>d-m).map(d=>d<=3?`#ifndef USE_UV${d}
|
|
7076
7076
|
attribute vec2 uv${d};
|
|
7077
7077
|
#endif`:`attribute vec2 uv${d};`).join(`
|
|
7078
7078
|
`)+`
|
|
@@ -7087,16 +7087,16 @@ attribute vec2 uv${d};
|
|
|
7087
7087
|
if (clipImage && (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0))))) pixel = vec4(0.0);
|
|
7088
7088
|
return pixel;
|
|
7089
7089
|
}
|
|
7090
|
-
`+i.fragmentShader;const u=
|
|
7090
|
+
`+i.fragmentShader;const u=jt.lights_physical_fragment.replace("material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );","material.specularF90 = 1.0;").replace("material.clearcoatF0 = vec3( 0.04 );","material.clearcoatF0 = vec3( pow2( ( blenderCoatIor - 1.0 ) / ( blenderCoatIor + 1.0 ) ) );"),h=jt.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=jt.map_fragment.replace("texture2D( map, vMapUv )","blenderImageSample(map, vMapUv, blenderMapClip)").replace("diffuseColor *= sampledDiffuseColor;","diffuseColor.rgb *= sampledDiffuseColor.rgb;"),l=jt.roughnessmap_fragment.replace("texture2D( roughnessMap, vRoughnessMapUv )","blenderImageSample(roughnessMap, vRoughnessMapUv, blenderRoughnessClip)"),c=jt.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()"),_=jt.lights_fragment_maps.replaceAll(/(getIBL(?:Irradiance|Radiance|AnisotropyRadiance)\([^;]+\))/g,"$1 * blenderInfiniteTransmission()");i.fragmentShader=i.fragmentShader.replace("#include <lights_physical_fragment>",u).replace("#include <lights_fragment_begin>",c).replace("#include <lights_fragment_maps>",_).replace("#include <normal_fragment_maps>",h).replace("#include <map_fragment>",s).replace("#include <roughnessmap_fragment>",l).replace("vec3 Fcc = F_Schlick",`
|
|
7091
7091
|
// Blender's slab_transmittance_at_angle (gpu_shader_material_principled.glsl):
|
|
7092
7092
|
// Beer-Lambert attenuation through a refracting coat at this view angle.
|
|
7093
7093
|
float coatPath = blenderCoatIor * inversesqrt(max(1e-8,
|
|
7094
7094
|
blenderCoatIor * blenderCoatIor - (1.0 - dotNVcc * dotNVcc)));
|
|
7095
7095
|
outgoingLight *= mix(vec3(1.0), pow(max(blenderCoatTint, vec3(0.0)), vec3(coatPath)), material.clearcoat);
|
|
7096
|
-
vec3 Fcc = F_Schlick`),
|
|
7097
|
-
`;let v="1.0",g="1.0";if(d instanceof
|
|
7098
|
-
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(d instanceof
|
|
7099
|
-
`,v=d instanceof
|
|
7096
|
+
vec3 Fcc = F_Schlick`),fl(o,i)},o.needsUpdate=!0}a.blenderCoatIor.value=Math.max(1,e.coat_ior),a.blenderCoatTint.value.setRGB(...e.coat_tint,pt),a.blenderMapClip.value=n.map===!0,a.blenderRoughnessClip.value=n.roughness===!0,a.blenderNormalClip.value=n.normal===!0}function xo(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=at(o)(new x);if(!(typeof n=="number"?[n]:n.toArray()).every(Number.isFinite))throw new Error("World volume input is not finite");return n}function Yt(o){const t=xo(o);if(typeof t!="number")throw new Error("World volume scalar input resolved to a color");return Math.max(0,t)}function yn(o){const t=xo(o);return(typeof t=="number"?new x().setScalar(t):t.clone()).max(new x)}function vl(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 Go(o){if(!o?.volume?.length)return null;const t={extinction:new x,emission:new x,lobes:[]};for(const n of o.volume){const e=Yt(n.weight);if(e===0)continue;const a=yn(n.color),r=Yt(n.density),i=new x,f=new x;if(n.kind==="absorption"&&i.set(1-a.x,1-a.y,1-a.z).max(new x).multiplyScalar(r),n.kind==="scatter"||n.kind==="principled"){f.copy(a).multiplyScalar(r);const u=n.kind==="principled"?"HENYEY_GREENSTEIN":n.phase;if(!["HENYEY_GREENSTEIN","DRAINE","RAYLEIGH"].includes(u))throw new Error(`World volume ${u} phase is not implemented`);const h=xo(n.anisotropy);if(typeof h!="number")throw new Error("World volume anisotropy must be scalar");t.lobes.push({coefficient:f.clone().multiplyScalar(e),g:u==="RAYLEIGH"?0:gt.clamp(h,-.999,.999),alpha:u==="RAYLEIGH"?1:u==="DRAINE"?Yt(n.alpha):0})}if(n.kind==="principled"){const u=yn(n.absorption_color);i.set(Math.max(1-a.x,0)*Math.max(1-Math.sqrt(u.x),0),Math.max(1-a.y,0)*Math.max(1-Math.sqrt(u.y),0),Math.max(1-a.z,0)*Math.max(1-Math.sqrt(u.z),0)).multiplyScalar(r);const h=Yt(n.blackbody_intensity);if(h>.001){const s=Yt(n.temperature),l=5670373e-20/Math.PI*(1+h*(s**4-1));t.emission.add(vl(s).multiply(yn(n.blackbody_tint)).multiplyScalar(l*e))}}(n.kind==="principled"||n.kind==="emission")&&t.emission.add((n.kind==="emission"?a:yn(n.emission_color)).multiplyScalar(Yt(n.emission_strength)*e)),t.extinction.add(i.add(f).multiplyScalar(e))}for(const n of["x","y","z"])if(t.extinction[n]===0&&t.emission[n]>0)throw new Error("Unbounded emissive World volume with zero extinction has divergent radiance");return t}class gl{constructor(t){this.medium=t,this.target=new Ze(1,1,{type:co,depthBuffer:!1}),this.geometry=new fe(2,2),this.scene=new Qe,this.camera=new Ke}render(t,n,e,a){if(!n.depthTexture)throw new Error("World volume render requires surface depth");const r={surface:{value:n.texture},depth:{value:n.depthTexture},inverseProjection:{value:a.projectionMatrixInverse},cameraWorld:{value:a.matrixWorld},orthographic:{value:a.isOrthographicCamera===!0},sigma:{value:this.medium.extinction},emission:{value:this.medium.emission}};let i="",f="",u=0,h=2;e.traverseVisible(_=>{if(!(_ instanceof Zn||_ instanceof Qn||_ instanceof An))return;const d=_,m=u++,p=d.getWorldPosition(new x);r[`lp${m}`]={value:p},r[`lc${m}`]={value:d.color.clone().multiplyScalar(d.intensity)},i+=`uniform vec3 lp${m}, lc${m};
|
|
7097
|
+
`;let v="1.0",g="1.0";if(d instanceof Qn&&(r[`ld${m}`]={value:d.target.getWorldPosition(new x).sub(p).normalize()},r[`cone${m}`]={value:new qt(Math.cos(d.angle),Math.cos(d.angle*(1-d.penumbra)))},i+=`uniform vec3 ld${m}; uniform vec2 cone${m};
|
|
7098
|
+
`,g=`smoothstep(cone${m}.x, max(cone${m}.x+1e-6,cone${m}.y),dot(-L,ld${m}))`),!(d instanceof An)&&d.castShadow&&d.shadow.map){if(++h>t.capabilities.maxTextures)throw new Error("World volume shadow samplers exceed this GPU texture-unit limit");r[`sm${m}`]={value:d.shadow.map.texture},r[`sx${m}`]={value:d.shadow.matrix},r[`ss${m}`]={value:d.shadow.mapSize},r[`sb${m}`]={value:d.shadow.bias},r[`sn${m}`]={value:d.shadow.camera.near},r[`sf${m}`]={value:d.shadow.camera.far},i+=`uniform sampler2D sm${m}; uniform mat4 sx${m}; uniform vec2 ss${m}; uniform float sb${m},sn${m},sf${m};
|
|
7099
|
+
`,v=d instanceof Zn?`getPointShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0),sn${m},sf${m})`:`getShadow(sm${m},ss${m},1.0,sb${m},1.0,sx${m}*vec4(p,1.0))`}if(d instanceof An){const w=new tt().extractRotation(d.matrixWorld);r[`lx${m}`]={value:new x(d.width,0,0).applyMatrix4(w)},r[`ly${m}`]={value:new x(0,d.height,0).applyMatrix4(w)},r[`ln${m}`]={value:new x(0,0,-1).transformDirection(w)},i+=`uniform vec3 lx${m},ly${m},ln${m};
|
|
7100
7100
|
`,f+=`for(int ax=0;ax<4;ax++) for(int ay=0;ay<4;ay++) {
|
|
7101
7101
|
vec3 delta=lp${m}+lx${m}*((float(ax)+.5)/4.-.5)+ly${m}*((float(ay)+.5)/4.-.5)-p;
|
|
7102
7102
|
float d=length(delta); vec3 L=delta/max(d,1e-6);
|
|
@@ -7107,7 +7107,7 @@ attribute vec2 uv${d};
|
|
|
7107
7107
|
float cutoff=cut${m}>0.?pow(clamp(1.-pow(d/cut${m},4.),0.,1.),2.):1.;
|
|
7108
7108
|
sum+=lc${m}*exp(-sigma*d)*phase(dot(L,ray))*${g}*${v}*cutoff/max(pow(d,decay${m}),.01); }
|
|
7109
7109
|
`});let s="vec3 result=vec3(0.);";this.medium.lobes.forEach((_,d)=>{r[`scatter${d}`]={value:_.coefficient},r[`g${d}`]={value:_.g},r[`a${d}`]={value:_.alpha},i+=`uniform vec3 scatter${d}; uniform float g${d},a${d};
|
|
7110
|
-
`,s+=`result+=scatter${d}*(1.-g${d}*g${d})*(1.+a${d}*c*c)/(12.56637061436*(1.+a${d}*(1.+2.*g${d}*g${d})/3.)*pow(1.+g${d}*g${d}-2.*g${d}*c,1.5));`});const l=this.medium.extinction.toArray().filter(_=>_>0);r.range={value:l.length?20/Math.min(...l):1},this.material?.dispose(),this.material=new
|
|
7110
|
+
`,s+=`result+=scatter${d}*(1.-g${d}*g${d})*(1.+a${d}*c*c)/(12.56637061436*(1.+a${d}*(1.+2.*g${d}*g${d})/3.)*pow(1.+g${d}*g${d}-2.*g${d}*c,1.5));`});const l=this.medium.extinction.toArray().filter(_=>_>0);r.range={value:l.length?20/Math.min(...l):1},this.material?.dispose(),this.material=new so({uniforms:r,depthTest:!1,depthWrite:!1,toneMapped:!1,defines:{USE_SHADOWMAP:"",NUM_DIR_LIGHT_SHADOWS:0,NUM_SPOT_LIGHT_SHADOWS:0,NUM_POINT_LIGHT_SHADOWS:0,NUM_SPOT_LIGHT_COORDS:0},vertexShader:"varying vec2 vUv; void main(){vUv=uv;gl_Position=vec4(position.xy,0.,1.);}",fragmentShader:`
|
|
7111
7111
|
#include <common>
|
|
7112
7112
|
#include <packing>
|
|
7113
7113
|
#include <shadowmap_pars_fragment>
|
|
@@ -7137,10 +7137,10 @@ attribute vec2 uv${d};
|
|
|
7137
7137
|
radiance+=incident(origin+ray*t,ray)*exp(-sigma*t)*(hi-lo);
|
|
7138
7138
|
}
|
|
7139
7139
|
gl_FragColor=vec4(radiance,base.a+(1.-base.a)*(1.-dot(tr,vec3(1./3.))));
|
|
7140
|
-
}`}),this.scene.clear(),this.scene.add(new Tt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const c=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(c)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const cl=P({object:N(),group:N(),groupIndex:M().int().nonnegative(),count:M().int().nonnegative(),digest:N(),alertMode:U(["NONE","ACTIVE","ALL"]),unchanged:j(!0).optional(),weightsBase64:N().optional(),alertBase64:N().optional()}).strict();function ul(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,i]=_l(2/3*(1-n)),f=new ht;return f.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(i*e)**(1/1.5),Mt),f}function _l(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const ml=0;function $o(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class dl{constructor(){this.group=new ot,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const a=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==a)return this.clear(),`weights: the session sent a reference to ${a} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${a} carried neither an array nor a reference`;const d=$o(t.weightsBase64);this.held={key:a,weights:new Float32Array(d.buffer,d.byteOffset,t.count),alerts:$o(t.alertBase64)}}const r=this.held;if(r===null)return null;const i=`${a}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(i===this.signature&&this.mesh!==null)return null;this.signature=i,this.clear();const f=n.geometry.clone(),u=f.getAttribute("position"),h=f.getAttribute("blenderVertex");if(h===void 0)return f.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),l=new ht().setHex(ml,Mt);for(let d=0;d<u.count;d++){const m=h.getX(d),v=t.alertMode!=="NONE"&&r.alerts[m]===1?l:ul(r.weights[m]??0);s[d*3]=v.r,s[d*3+1]=v.g,s[d*3+2]=v.b}f.setAttribute("color",new it(s,3)),f.deleteAttribute("blenderVertex");const c=new yn({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),_=new Tt(f,c);return _.name=`${t.object}:weights`,_.frustumCulled=!1,_.matrixAutoUpdate=!1,_.matrix.copy(e),_.matrix.decompose(_.position,_.quaternion,_.scale),this.geometry=f,this.material=c,this.mesh=_,this.group.add(_),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const hn=M().finite(),hl=F($([hn,hn,hn,hn])).length(4),pl=20,Lo=[16724818,9165824,2658559];function vl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new ht().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Mt)}function ye(){return new qe({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function gl(){const o=[],t=[],n=new ht(0,0,0),e=(r,i,f,u,h)=>{for(const s of[r,i]){const l=[0,0,0];l[f]=s*u,o.push(...l),t.push(h.r,h.g,h.b)}};for(let r=0;r<3;r++){const i=new ht().setHex(Lo[r],Mt);e(1,.85,r,1,i),e(.85,.25,r,1,n),e(1,.85,r,-1,vl(Lo[r])),e(.85,.25,r,-1,n)}const a=new fn;return a.setAttribute("position",new bt(o,3)),a.setAttribute("color",new bt(t,3)),new te(a,ye())}function xl(){const t=[],n=[],e=new ht(1,0,0),a=new ht(1,1,1);for(let i=0;i<12;i++){const f=(i+1)%2===0?a:e;for(const u of[i,i+1]){const h=2*Math.PI*u/12;t.push(.5*Math.cos(h),.5*Math.sin(h),0),n.push(f.r,f.g,f.b)}}const r=new fn;return r.setAttribute("position",new bt(t,3)),r.setAttribute("color",new bt(n,3)),new te(r,ye())}class bl{constructor(){this.group=new ot,this.anchor=new ot,this.lines=gl(),this.circle=xl(),this.seen=null,this.size=new Lt,this.scratch=new x,this.parentQuat=new gt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,a,r]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new gt(e,a,r,n),new x(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const e=Math.max(this.size.y,1),a=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let r;if(n.isOrthographicCamera){const f=n;r=(f.top-f.bottom)/f.zoom/e}else{const f=n;r=2*Math.max(-a.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(ut.degToRad(f.fov)/2)/f.zoom/e}const i=r*pl;this.lines.scale.setScalar(i),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(i),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,a,r){const i=this.seen;if(i===null||e!==i.canvas)return null;const f=i.canvas.getBoundingClientRect(),u=new Lt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),h=new He;h.setFromCamera(u,i.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},l=h.intersectObject(a,!0).find(m=>m.object.isMesh&&r(m.object)&&s(m.object));let c=l?l.point.clone():null;if(c===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=i.camera.getWorldDirection(new x),v=i.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),c=h.ray.intersectPlane(new Ft().setFromNormalAndCoplanarPoint(p,m),new x)}if(c===null)return null;a.updateWorldMatrix(!0,!1);const _=a.worldToLocal(c),d=a.getWorldQuaternion(new gt).invert().multiply(i.camera.getWorldQuaternion(new gt));return{location:[_.x,_.y,_.z],rotation:[d.w,d.x,d.y,d.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const It=M().finite(),yl=P({display:U(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:It,image:P({name:N().nullable(),offset:$([It,It]),depth:U(["DEFAULT","FRONT","BACK"]),side:U(["DOUBLE_SIDED","FRONT","BACK"]),perspective:q(),orthographic:q(),axis_aligned:q(),opacity:It.nullable(),tint:$([It,It,It]).default([1,1,1]),premultiplied:q().default(!1)}).optional()}),wt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},wl=1,K=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function at(o,t){return Array.from({length:t},(n,e)=>{const a=2*Math.PI*e/t;return[o*Math.cos(a),o*Math.sin(a)]})}function ct(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const i=t[r*a%t.length],f=t[(r*a+1)%t.length];K(o,[i[0],i[1],n],[f[0],f[1],n])}}function Ol(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new X;let a=!1;o.onBeforeRender=(r,i,f,u,h,s)=>{t(r,i,f,u,h,s),i.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),a=!0)},o.onAfterRender=(r,i,f,u,h,s)=>{a&&(o.matrixWorld.copy(e),a=!1),n(r,i,f,u,h,s)}}class Tl{constructor(){this.cameras=new ot,this.lights=new ot,this.empties=new ot,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new Lt,this.parentQuat=new gt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const a=e.selected?e.name===t.active?wt.active:wt.selected:e.type==="CAMERA"?wt.camera:e.type==="LIGHT"?wt.light:wt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,i=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,f=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!r&&!i&&!f)continue;n.add(e.name);const u=i&&e.light?t.lightDistances[e.light]??null:null,h=f?.image?.name?t.image(f.image.name):null,s=JSON.stringify([h?[h.texture.uuid,h.width,h.height]:null,e.matrix,a,r,i,u,f,r?[e.name===t.sceneCamera,t.renderAspect]:null]),l=this.drawn.get(e.name),c=t.presented(e.name);if(l?.key===s){for(const v of l.parts)v.userData.volterPicksAs=c;continue}l&&this.remove(l.parts);const _=new X().set(...e.matrix.flat()),d=r?this.cameras:i?this.lights:this.empties,m=new Set(d.children);r?this.camera(r,_,a,e.name===t.sceneCamera,t.renderAspect):i?this.light(i,_,a,u):f&&this.empty(f,_,a,h);const p=d.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=c,v.traverse(Ol);this.drawn.set(e.name,{key:s,parts:p})}for(const[e,a]of this.drawn)n.has(e)||(this.remove(a.parts),this.drawn.delete(e))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,e,a,r){const i=t.display_size,u=(t.sensor_fit==="AUTO"?r>=1:t.sensor_fit==="HORIZONTAL")?[1,1/r]:[r,1];let h,s,l,c;if(t.type==="ORTHO")l=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],c=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-i,h=.5*t.ortho_scale;else{const A=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new x().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;h=i/2/((1/O.x+1/O.y+1/O.z)/3),s=h*t.lens/-A,l=[h*u[0],h*u[1]],c=[t.shift_x*h*2,t.shift_y*h*2]}const _=[[c[0]+l[0],c[1]+l[1],s],[c[0]+l[0],c[1]-l[1],s],[c[0]-l[0],c[1]-l[1],s],[c[0]-l[0],c[1]+l[1],s]],d=[];for(let A=0;A<4;A++)K(d,_[A],_[(A+1)%4]),K(d,_[A],[0,0,0]);const m=.7*h,p=.1*h,v=c[1]+l[1]+p,g=[[c[0]-m,v,s],[c[0]+m,v,s],[c[0],v+m,s]],w=Ln(n);this.cameras.add(this.lines(d,e,1,w));let y;if(a){const A=new fn;A.setAttribute("position",new bt(g.flat(),3)),y=new Tt(A,this.fill(e)),y.matrixAutoUpdate=!1,y.matrix.copy(w)}else{const A=[];for(let O=0;O<3;O++)K(A,g[O],g[(O+1)%3]);y=this.lines(A,e,1,w)}const S=new x,T=y.onBeforeRender.bind(y);y.onBeforeRender=(A,O,E,C,V,H)=>{S.setFromMatrixPosition(w).applyMatrix4(this.cameras.matrixWorld);const Q=E.getWorldPosition(this.scratch).distanceToSquared(S)>1e-8;y.matrix.copy(w),Q||y.matrix.scale(new x(0,0,0)),y.updateMatrixWorld(!0),T(A,O,E,C,V,H)},this.cameras.add(y)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),i=[];K(i,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(i,wt.light,wt.lightAlpha,new X));const f=[];ct(f,at(1.35,4)),this.lights.add(this.screen(f,wt.light,wt.lightAlpha,new x(r.x,r.y,0)));const u=[],h=9;if(ct(u,at(h*.3,4)),ct(u,at(h,16),0,!0),ct(u,at(h*1.33,20),0,!0),t.type==="SUN")for(const[c,_]of at(h,8))K(u,[c*1.6,_*1.6,0],[c*1.9,_*1.9,0]),K(u,[c*2.2,_*2.2,0],[c*2.5,_*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=Ln(n),l=[];if(t.type==="SUN")K(l,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const c=(t.size??1)/2,_=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?ct(l,at(1,32).map(([d,m])=>[d*c,m*_])):ct(l,[[c,_],[-c,_],[-c,-_],[c,-_]])}if(l.length>0&&this.lights.add(this.lines(l,e,1,n.clone())),a&&(t.type==="SPOT"||t.type==="AREA")){const c=new x(0,0,-1).transformDirection(n),_=v=>r.clone().addScaledVector(c,v),[d,m]=a,p=[];K(p,_(d).toArray(),_(m).toArray()),this.lights.add(this.lines(p,e,1,new X));for(const v of[d,m]){const g=[];ct(g,at(1.2,4)),this.lights.add(this.screen(g,e,1,_(v)))}}if(t.type==="SPOT"){const c=(t.spot_size??Math.PI/4)/2,_=Math.cos(c),d=t.spot_blend??.15,m=_*d-_-d,p=Math.sqrt((_*_-_*_*m*m)/(m*m-_*_*m*m)),v=Math.sqrt(1-_*_),g=Ln(n).multiply(new X().makeScale(10,10,10)),w=[];ct(w,at(v,32),-_),ct(w,at(v*p,32),-_),this.lights.add(this.lines(w,e,1,g.clone())),this.lights.add(this.silhouette(v,_,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const c=[];ct(c,at(t.radius,32)),this.lights.add(this.facing(c,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,a){const r=t.size,i=[],f=(h,s)=>{const l=at(1,s);for(let c=0;c<s;c++){const[_,d]=l[c],[m,p]=l[(c+1)%s],v=(g,w)=>h==="xy"?[g,w,0]:h==="xz"?[g,0,w]:[0,g,w];K(i,v(_,d),v(m,p))}};switch(t.display){case"PLAIN_AXES":K(i,[0,-1,0],[0,1,0]),K(i,[-1,0,0],[1,0,0]),K(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{K(i,[0,0,0],[0,0,.75]);for(const[h,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])K(i,[0,0,1],[h,s,.75]);ct(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[h,s]of Al)K(i,Vo[h],Vo[s]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const h=at(1,8);for(let s=0;s<8;s++){const[l,c]=h[s],[_,d]=h[(s+1)%8];K(i,[l,0,c],[0,2,0]),K(i,[l,0,c],[_,0,d])}break}case"ARROWS":for(let h=0;h<3;h++){const s=[0,0,0];s[h]=1,K(i,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new X().makeScale(r,r,r));this.empties.add(this.lines(i,e,1,u)),t.display==="ARROWS"&&this.axisNames(n,r,e)}silhouette(t,n,e,a){const r=this.lines(new Array(192).fill(0),e,1,a);r.frustumCulled=!1;const i=r.geometry.getAttribute("instanceStart").data,f=at(1,32).map(([_,d])=>new x(_*t,d*t,-n)),u=new x,h=new X,s=new x,l=new x,c=new x;return this.onDraw(r,(_,d)=>{h.copy(r.matrixWorld).invert();const m=d.isOrthographicCamera;m?d.getWorldDirection(u).negate().transformDirection(h):u.setFromMatrixPosition(d.matrixWorld).applyMatrix4(h);const p=i.array;let v=!1;for(let g=0;g<32;g++){const w=f[g];s.crossVectors(w,f[(g+31)%32]),l.crossVectors(f[(g+1)%32],w),m?c.copy(u):c.copy(u).sub(w);const y=s.dot(c)>0!=l.dot(c)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==y&&(v=!0),p.set([0,0,0,y?w.x:0,y?w.y:0,y?w.z:0],g*6)}v&&(i.needsUpdate=!0,vt())}),r}imageEmpty(t,n,e,a){const r=t.image;if(!r)return;const i=a?.width??0,f=a?.height??0,u=i>0&&f>0?i>=f?[1,f/i]:[i/f,1]:[1,1],h=new x,s=new x,l=new x;n.extractBasis(h,s,l),h.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const c=new x().setFromMatrixPosition(n).addScaledVector(h,r.offset[0]*2+1).addScaledVector(s,r.offset[1]*2+1),_=new X().makeBasis(h,s,l.clone()).setPosition(c),d=[];ct(d,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(d,e,1,_),p=l.clone().normalize(),v=new x,g=new x,w=(E,C)=>{const V=E.isOrthographicCamera===!0;if(V?!r.orthographic:!r.perspective)return!1;if(!C)return!0;const H=p.clone().transformDirection(this.empties.matrixWorld);E.getWorldDirection(g);let Q,tt;if(V)Q=H.dot(g.clone().negate()),tt=1e-5;else{const pt=c.clone().applyMatrix4(this.empties.matrixWorld);Q=H.dot(v.setFromMatrixPosition(E.matrixWorld).sub(pt)),tt=0}return!(r.side==="FRONT"&&Q<tt||r.side==="BACK"&&Q>-tt||r.axis_aligned&&H.clone().projectOnPlane(g).lengthSq()>1e-5)},y=(E,C)=>{const V=E.onBeforeRender.bind(E);E.onBeforeRender=(H,Q,tt,pt,b,L)=>{E.matrix.copy(_),w(tt,C)||E.matrix.scale(new x(0,0,0)),E.updateMatrixWorld(!0),V(H,Q,tt,pt,b,L)}};if(y(m,!1),this.empties.add(m),!a||r.opacity!==null&&r.opacity<=0)return;const S=r.opacity!==null,T=r.depth==="BACK",A=new yn({map:a.texture,side:uo,transparent:S&&!T,opacity:r.opacity??1,alphaTest:S?0:.05,toneMapped:!1,depthTest:r.depth==="DEFAULT",depthWrite:r.depth==="DEFAULT"&&!S});A.color.setRGB(...r.tint,ft),S&&T&&(A.blending=Ge,A.blendSrc=Xe,A.blendDst=Ye),A.onBeforeCompile=E=>{const C=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7141
|
-
`:"";
|
|
7142
|
-
${
|
|
7143
|
-
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${r.premultiplied}:${S}`;const O=new
|
|
7140
|
+
}`}),this.scene.clear(),this.scene.add(new Rt(this.geometry,this.material)),this.target.setSize(n.width,n.height);const c=t.getRenderTarget();try{t.setRenderTarget(this.target),t.render(this.scene,this.camera)}finally{t.setRenderTarget(c)}return this.target}dispose(){this.material?.dispose(),this.geometry.dispose(),this.target.dispose(),this.scene.clear()}}const xl=P({object:R(),group:R(),groupIndex:N().int().nonnegative(),count:N().int().nonnegative(),digest:R(),alertMode:H(["NONE","ACTIVE","ALL"]),unchanged:W(!0).optional(),weightsBase64:R().optional(),alertBase64:R().optional()}).strict();function bl(o){const n=o<0?0:o>1?1:o,e=(.5+.5*n)**1.5,[a,r,i]=yl(2/3*(1-n)),f=new wt;return f.setRGB((a*e)**(1/1.5),(r*e)**(1/1.5),(i*e)**(1/1.5),Ct),f}function yl(o){const t=(o%1+1)%1,n=Math.floor(t*6),e=t*6-n;switch(n%6){case 0:return[1,e,0];case 1:return[1-e,1,0];case 2:return[0,1,e];case 3:return[0,1-e,1];case 4:return[e,0,1];default:return[1,0,1-e]}}const wl=0;function Xo(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class Ol{constructor(){this.group=new lt,this.mesh=null,this.material=null,this.geometry=null,this.held=null,this.signature="",this.group.name="BlenderWeightOverlay"}apply(t,n,e){if(t===null||n===null||!n.isMesh||e===null)return this.clear(),this.signature="",null;const a=`${t.object}:${t.group}`;if(t.unchanged===!0){if(this.held?.key!==a)return this.clear(),`weights: the session sent a reference to ${a} that this overlay does not hold; the colours reappear on the next change to the mesh or the group`}else{if(t.weightsBase64===void 0||t.alertBase64===void 0)return this.clear(),`weights: ${a} carried neither an array nor a reference`;const d=Xo(t.weightsBase64);this.held={key:a,weights:new Float32Array(d.buffer,d.byteOffset,t.count),alerts:Xo(t.alertBase64)}}const r=this.held;if(r===null)return null;const i=`${a}:${t.digest}:${n.geometry.uuid}:${t.alertMode}:${e.elements.join(",")}`;if(i===this.signature&&this.mesh!==null)return null;this.signature=i,this.clear();const f=n.geometry.clone(),u=f.getAttribute("position"),h=f.getAttribute("blenderVertex");if(h===void 0)return f.dispose(),"weights: the presented geometry carries no per-vertex Blender index (`blenderVertex`), so the weights cannot be laid over it";const s=new Float32Array(u.count*3),l=new wt().setHex(wl,Ct);for(let d=0;d<u.count;d++){const m=h.getX(d),v=t.alertMode!=="NONE"&&r.alerts[m]===1?l:bl(r.weights[m]??0);s[d*3]=v.r,s[d*3+1]=v.g,s[d*3+2]=v.b}f.setAttribute("color",new dt(s,3)),f.deleteAttribute("blenderVertex");const c=new En({vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-1}),_=new Rt(f,c);return _.name=`${t.object}:weights`,_.frustumCulled=!1,_.matrixAutoUpdate=!1,_.matrix.copy(e),_.matrix.decompose(_.position,_.quaternion,_.scale),this.geometry=f,this.material=c,this.mesh=_,this.group.add(_),null}clear(){this.mesh&&this.group.remove(this.mesh),this.geometry?.dispose(),this.material?.dispose(),this.mesh=null,this.geometry=null,this.material=null}dispose(){this.clear(),this.held=null,this.signature=""}}const wn=N().finite(),Tl=D(L([wn,wn,wn,wn])).length(4),Al=20,Yo=[16724818,9165824,2658559];function Pl(o){const t=n=>Math.min(255,Math.max(0,Math.floor(.75*n+63.75)-60))/255;return new wt().setRGB(t(o>>16&255),t(o>>8&255),t(o&255),Ct)}function Ne(){return new ta({vertexColors:!0,depthTest:!1,depthWrite:!1,transparent:!0,toneMapped:!1})}function Sl(){const o=[],t=[],n=new wt(0,0,0),e=(r,i,f,u,h)=>{for(const s of[r,i]){const l=[0,0,0];l[f]=s*u,o.push(...l),t.push(h.r,h.g,h.b)}};for(let r=0;r<3;r++){const i=new wt().setHex(Yo[r],Ct);e(1,.85,r,1,i),e(.85,.25,r,1,n),e(1,.85,r,-1,Pl(Yo[r])),e(.85,.25,r,-1,n)}const a=new hn;return a.setAttribute("position",new St(o,3)),a.setAttribute("color",new St(t,3)),new ce(a,Ne())}function El(){const t=[],n=[],e=new wt(1,0,0),a=new wt(1,1,1);for(let i=0;i<12;i++){const f=(i+1)%2===0?a:e;for(const u of[i,i+1]){const h=2*Math.PI*u/12;t.push(.5*Math.cos(h),.5*Math.sin(h),0),n.push(f.r,f.g,f.b)}}const r=new hn;return r.setAttribute("position",new St(t,3)),r.setAttribute("color",new St(n,3)),new ce(r,Ne())}class Ml{constructor(){this.group=new lt,this.anchor=new lt,this.lines=Sl(),this.circle=El(),this.seen=null,this.size=new qt,this.scratch=new x,this.parentQuat=new Tt,this.group.name="BlenderCursor",this.present(!1),this.anchor.matrixAutoUpdate=!1,this.group.add(this.anchor,this.circle),this.anchor.add(this.lines);for(const t of[this.lines,this.circle])t.renderOrder=1001,t.frustumCulled=!1;this.lines.onBeforeRender=(t,n,e)=>this.fit(t,e),this.circle.onBeforeRender=(t,n,e)=>this.fit(t,e)}apply(t){if(t===void 0){this.present(!1);return}this.anchor.matrix.set(...t.flat()),this.anchor.updateMatrixWorld(!0),this.present(!0)}present(t){this.anchor.visible=t,this.circle.visible=t}show(t){const[n,e,a,r]=t.rotation;this.anchor.matrix.compose(new x(...t.location),new Tt(e,a,r,n),new x(1,1,1)),this.anchor.updateMatrixWorld(!0),this.present(!0)}fit(t,n){this.seen={camera:n,canvas:t.domElement},t.getSize(this.size);const e=Math.max(this.size.y,1),a=this.scratch.setFromMatrixPosition(this.anchor.matrixWorld);let r;if(n.isOrthographicCamera){const f=n;r=(f.top-f.bottom)/f.zoom/e}else{const f=n;r=2*Math.max(-a.applyMatrix4(n.matrixWorldInverse).z,1e-6)*Math.tan(gt.degToRad(f.fov)/2)/f.zoom/e}const i=r*Al;this.lines.scale.setScalar(i),this.lines.updateMatrixWorld(!0),this.circle.position.setFromMatrixPosition(this.anchor.matrix),this.group.getWorldQuaternion(this.parentQuat).invert(),n.getWorldQuaternion(this.circle.quaternion).premultiply(this.parentQuat),this.circle.scale.setScalar(i),this.circle.updateMatrixWorld(!0)}placementAt(t,n,e,a,r){const i=this.seen;if(i===null||e!==i.canvas)return null;const f=i.canvas.getBoundingClientRect(),u=new qt((t-f.left)/Math.max(f.width,1)*2-1,-((n-f.top)/Math.max(f.height,1))*2+1),h=new Je;h.setFromCamera(u,i.camera);const s=m=>{for(let p=m;p!==null;p=p.parent)if(!p.visible)return!1;return!0},l=h.intersectObject(a,!0).find(m=>m.object.isMesh&&r(m.object)&&s(m.object));let c=l?l.point.clone():null;if(c===null){const m=new x().setFromMatrixPosition(this.anchor.matrixWorld),p=i.camera.getWorldDirection(new x),v=i.camera.getWorldPosition(new x),g=m.clone().sub(v).dot(p);g<=0&&m.addScaledVector(p,-2*g+(g===0?1:0)),c=h.ray.intersectPlane(new Vt().setFromNormalAndCoplanarPoint(p,m),new x)}if(c===null)return null;a.updateWorldMatrix(!0,!1);const _=a.worldToLocal(c),d=a.getWorldQuaternion(new Tt).invert().multiply(i.camera.getWorldQuaternion(new Tt));return{location:[_.x,_.y,_.z],rotation:[d.w,d.x,d.y,d.z]}}dispose(){for(const t of[this.lines,this.circle])t.geometry.dispose(),t.material.dispose();this.seen=null}}const Lt=N().finite(),Nl=P({display:H(["PLAIN_AXES","ARROWS","SINGLE_ARROW","CIRCLE","CUBE","SPHERE","CONE","IMAGE"]),size:Lt,image:P({name:R().nullable(),offset:L([Lt,Lt]),depth:H(["DEFAULT","FRONT","BACK"]),side:H(["DOUBLE_SIDED","FRONT","BACK"]),perspective:Z(),orthographic:Z(),axis_aligned:Z(),opacity:Lt.nullable(),tint:L([Lt,Lt,Lt]).default([1,1,1]),premultiplied:Z().default(!1)}).optional()}),Mt={selected:15554304,active:16752680,camera:0,light:0,lightAlpha:80/255,empty:0},Rl=1,ot=(o,t,n)=>o.push(t[0],t[1],t[2],n[0],n[1],n[2]);function ut(o,t){return Array.from({length:t},(n,e)=>{const a=2*Math.PI*e/t;return[o*Math.cos(a),o*Math.sin(a)]})}function vt(o,t,n=0,e=!1){const a=e?2:1;for(let r=0;r<Math.floor(t.length/a);r++){const i=t[r*a%t.length],f=t[(r*a+1)%t.length];ot(o,[i[0],i[1],n],[f[0],f[1],n])}}function Il(o){if(!o.isMesh||o.userData.volterOverrideStandDown)return;o.userData.volterOverrideStandDown=!0;const t=o.onBeforeRender.bind(o),n=o.onAfterRender.bind(o),e=new tt;let a=!1;o.onBeforeRender=(r,i,f,u,h,s)=>{t(r,i,f,u,h,s),i.overrideMaterial&&(e.copy(o.matrixWorld),o.matrixWorld.makeScale(0,0,0),a=!0)},o.onAfterRender=(r,i,f,u,h,s)=>{a&&(o.matrixWorld.copy(e),a=!1),n(r,i,f,u,h,s)}}class Fl{constructor(){this.cameras=new lt,this.lights=new lt,this.empties=new lt,this.lineMaterials=new Map,this.drawn=new Map,this.fillMaterials=new Map,this.scratch=new x,this.size=new qt,this.parentQuat=new Tt,this.cameras.name="BlenderCameras",this.lights.name="BlenderLights",this.empties.name="BlenderEmpties"}apply(t){const n=new Set;for(const e of t.objects){const a=e.selected?e.name===t.active?Mt.active:Mt.selected:e.type==="CAMERA"?Mt.camera:e.type==="LIGHT"?Mt.light:Mt.empty,r=e.type==="CAMERA"&&e.name!==t.lookingThrough?t.cameras[e.name]:void 0,i=e.type==="LIGHT"&&e.light?t.lights[e.light]:void 0,f=e.type==="EMPTY"?t.empties[e.name]:void 0;if(!r&&!i&&!f)continue;n.add(e.name);const u=i&&e.light?t.lightDistances[e.light]??null:null,h=f?.image?.name?t.image(f.image.name):null,s=JSON.stringify([h?[h.texture.uuid,h.width,h.height]:null,e.matrix,a,r,i,u,f,r?[e.name===t.sceneCamera,t.renderAspect]:null]),l=this.drawn.get(e.name),c=t.presented(e.name);if(l?.key===s){for(const v of l.parts)v.userData.volterPicksAs=c;continue}l&&this.remove(l.parts);const _=new tt().set(...e.matrix.flat()),d=r?this.cameras:i?this.lights:this.empties,m=new Set(d.children);r?this.camera(r,_,a,e.name===t.sceneCamera,t.renderAspect):i?this.light(i,_,a,u):f&&this.empty(f,_,a,h);const p=d.children.filter(v=>!m.has(v));for(const v of p)v.userData.volterPicksAs=c,v.traverse(Il);this.drawn.set(e.name,{key:s,parts:p})}for(const[e,a]of this.drawn)n.has(e)||(this.remove(a.parts),this.drawn.delete(e))}remove(t){for(const n of t)n.removeFromParent(),n.geometry?.dispose(),n.userData.volterOwnMaterial&&n.material.dispose()}camera(t,n,e,a,r){const i=t.display_size,u=(t.sensor_fit==="AUTO"?r>=1:t.sensor_fit==="HORIZONTAL")?[1,1/r]:[r,1];let h,s,l,c;if(t.type==="ORTHO")l=[.5*t.ortho_scale*u[0],.5*t.ortho_scale*u[1]],c=[t.shift_x*t.ortho_scale,t.shift_y*t.ortho_scale],s=-i,h=.5*t.ortho_scale;else{const A=.5*(t.sensor_fit==="VERTICAL"?t.sensor_height:t.sensor_width),O=new x().setFromMatrixScale(n);if(O.x===0||O.y===0||O.z===0)return;h=i/2/((1/O.x+1/O.y+1/O.z)/3),s=h*t.lens/-A,l=[h*u[0],h*u[1]],c=[t.shift_x*h*2,t.shift_y*h*2]}const _=[[c[0]+l[0],c[1]+l[1],s],[c[0]+l[0],c[1]-l[1],s],[c[0]-l[0],c[1]-l[1],s],[c[0]-l[0],c[1]+l[1],s]],d=[];for(let A=0;A<4;A++)ot(d,_[A],_[(A+1)%4]),ot(d,_[A],[0,0,0]);const m=.7*h,p=.1*h,v=c[1]+l[1]+p,g=[[c[0]-m,v,s],[c[0]+m,v,s],[c[0],v+m,s]],w=Gn(n);this.cameras.add(this.lines(d,e,1,w));let y;if(a){const A=new hn;A.setAttribute("position",new St(g.flat(),3)),y=new Rt(A,this.fill(e)),y.matrixAutoUpdate=!1,y.matrix.copy(w)}else{const A=[];for(let O=0;O<3;O++)ot(A,g[O],g[(O+1)%3]);y=this.lines(A,e,1,w)}const S=new x,T=y.onBeforeRender.bind(y);y.onBeforeRender=(A,O,M,k,j,q)=>{S.setFromMatrixPosition(w).applyMatrix4(this.cameras.matrixWorld);const Q=M.getWorldPosition(this.scratch).distanceToSquared(S)>1e-8;y.matrix.copy(w),Q||y.matrix.scale(new x(0,0,0)),y.updateMatrixWorld(!0),T(A,O,M,k,j,q)},this.cameras.add(y)}light(t,n,e,a){const r=new x().setFromMatrixPosition(n),i=[];ot(i,[r.x,r.y,r.z],[r.x,r.y,0]),this.lights.add(this.lines(i,Mt.light,Mt.lightAlpha,new tt));const f=[];vt(f,ut(1.35,4)),this.lights.add(this.screen(f,Mt.light,Mt.lightAlpha,new x(r.x,r.y,0)));const u=[],h=9;if(vt(u,ut(h*.3,4)),vt(u,ut(h,16),0,!0),vt(u,ut(h*1.33,20),0,!0),t.type==="SUN")for(const[c,_]of ut(h,8))ot(u,[c*1.6,_*1.6,0],[c*1.9,_*1.9,0]),ot(u,[c*2.2,_*2.2,0],[c*2.5,_*2.5,0]);this.lights.add(this.screen(u,e,1,r));const s=Gn(n),l=[];if(t.type==="SUN")ot(l,[0,0,0],[0,0,-20]);else if(t.type==="AREA"){const c=(t.size??1)/2,_=(t.shape==="RECTANGLE"||t.shape==="ELLIPSE"?t.size_y??t.size??1:t.size??1)/2;t.shape==="DISK"||t.shape==="ELLIPSE"?vt(l,ut(1,32).map(([d,m])=>[d*c,m*_])):vt(l,[[c,_],[-c,_],[-c,-_],[c,-_]])}if(l.length>0&&this.lights.add(this.lines(l,e,1,n.clone())),a&&(t.type==="SPOT"||t.type==="AREA")){const c=new x(0,0,-1).transformDirection(n),_=v=>r.clone().addScaledVector(c,v),[d,m]=a,p=[];ot(p,_(d).toArray(),_(m).toArray()),this.lights.add(this.lines(p,e,1,new tt));for(const v of[d,m]){const g=[];vt(g,ut(1.2,4)),this.lights.add(this.screen(g,e,1,_(v)))}}if(t.type==="SPOT"){const c=(t.spot_size??Math.PI/4)/2,_=Math.cos(c),d=t.spot_blend??.15,m=_*d-_-d,p=Math.sqrt((_*_-_*_*m*m)/(m*m-_*_*m*m)),v=Math.sqrt(1-_*_),g=Gn(n).multiply(new tt().makeScale(10,10,10)),w=[];vt(w,ut(v,32),-_),vt(w,ut(v*p,32),-_),this.lights.add(this.lines(w,e,1,g.clone())),this.lights.add(this.silhouette(v,_,e,g))}if((t.type==="POINT"||t.type==="SPOT")&&(t.radius??0)>0){const c=[];vt(c,ut(t.radius,32)),this.lights.add(this.facing(c,e,new x().setFromMatrixPosition(s)))}}empty(t,n,e,a){const r=t.size,i=[],f=(h,s)=>{const l=ut(1,s);for(let c=0;c<s;c++){const[_,d]=l[c],[m,p]=l[(c+1)%s],v=(g,w)=>h==="xy"?[g,w,0]:h==="xz"?[g,0,w]:[0,g,w];ot(i,v(_,d),v(m,p))}};switch(t.display){case"PLAIN_AXES":ot(i,[0,-1,0],[0,1,0]),ot(i,[-1,0,0],[1,0,0]),ot(i,[0,0,-1],[0,0,1]);break;case"SINGLE_ARROW":{ot(i,[0,0,0],[0,0,.75]);for(const[h,s]of[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]])ot(i,[0,0,1],[h,s,.75]);vt(i,[[.035,.035],[-.035,.035],[-.035,-.035],[.035,-.035]],.75);break}case"CUBE":for(const[h,s]of zl)ot(i,Zo[h],Zo[s]);break;case"CIRCLE":f("xz",64);break;case"SPHERE":f("xy",32),f("xz",32),f("yz",32);break;case"CONE":{const h=ut(1,8);for(let s=0;s<8;s++){const[l,c]=h[s],[_,d]=h[(s+1)%8];ot(i,[l,0,c],[0,2,0]),ot(i,[l,0,c],[_,0,d])}break}case"ARROWS":for(let h=0;h<3;h++){const s=[0,0,0];s[h]=1,ot(i,[0,0,0],s)}break;case"IMAGE":this.imageEmpty(t,n,e,a);return}const u=n.clone().multiply(new tt().makeScale(r,r,r));this.empties.add(this.lines(i,e,1,u)),t.display==="ARROWS"&&this.axisNames(n,r,e)}silhouette(t,n,e,a){const r=this.lines(new Array(192).fill(0),e,1,a);r.frustumCulled=!1;const i=r.geometry.getAttribute("instanceStart").data,f=ut(1,32).map(([_,d])=>new x(_*t,d*t,-n)),u=new x,h=new tt,s=new x,l=new x,c=new x;return this.onDraw(r,(_,d)=>{h.copy(r.matrixWorld).invert();const m=d.isOrthographicCamera;m?d.getWorldDirection(u).negate().transformDirection(h):u.setFromMatrixPosition(d.matrixWorld).applyMatrix4(h);const p=i.array;let v=!1;for(let g=0;g<32;g++){const w=f[g];s.crossVectors(w,f[(g+31)%32]),l.crossVectors(f[(g+1)%32],w),m?c.copy(u):c.copy(u).sub(w);const y=s.dot(c)>0!=l.dot(c)>0;(p[g*6+3]!==0||p[g*6+5]!==0)!==y&&(v=!0),p.set([0,0,0,y?w.x:0,y?w.y:0,y?w.z:0],g*6)}v&&(i.needsUpdate=!0,Ot())}),r}imageEmpty(t,n,e,a){const r=t.image;if(!r)return;const i=a?.width??0,f=a?.height??0,u=i>0&&f>0?i>=f?[1,f/i]:[i/f,1]:[1,1],h=new x,s=new x,l=new x;n.extractBasis(h,s,l),h.multiplyScalar(u[0]*.5*t.size),s.multiplyScalar(u[1]*.5*t.size);const c=new x().setFromMatrixPosition(n).addScaledVector(h,r.offset[0]*2+1).addScaledVector(s,r.offset[1]*2+1),_=new tt().makeBasis(h,s,l.clone()).setPosition(c),d=[];vt(d,[[-1,-1],[1,-1],[1,1],[-1,1]]);const m=this.lines(d,e,1,_),p=l.clone().normalize(),v=new x,g=new x,w=(M,k)=>{const j=M.isOrthographicCamera===!0;if(j?!r.orthographic:!r.perspective)return!1;if(!k)return!0;const q=p.clone().transformDirection(this.empties.matrixWorld);M.getWorldDirection(g);let Q,K;if(j)Q=q.dot(g.clone().negate()),K=1e-5;else{const st=c.clone().applyMatrix4(this.empties.matrixWorld);Q=q.dot(v.setFromMatrixPosition(M.matrixWorld).sub(st)),K=0}return!(r.side==="FRONT"&&Q<K||r.side==="BACK"&&Q>-K||r.axis_aligned&&q.clone().projectOnPlane(g).lengthSq()>1e-5)},y=(M,k)=>{const j=M.onBeforeRender.bind(M);M.onBeforeRender=(q,Q,K,st,b,V)=>{M.matrix.copy(_),w(K,k)||M.matrix.scale(new x(0,0,0)),M.updateMatrixWorld(!0),j(q,Q,K,st,b,V)}};if(y(m,!1),this.empties.add(m),!a||r.opacity!==null&&r.opacity<=0)return;const S=r.opacity!==null,T=r.depth==="BACK",A=new En({map:a.texture,side:wo,transparent:S&&!T,opacity:r.opacity??1,alphaTest:S?0:.05,toneMapped:!1,depthTest:r.depth==="DEFAULT",depthWrite:r.depth==="DEFAULT"&&!S});A.color.setRGB(...r.tint,pt),S&&T&&(A.blending=na,A.blendSrc=oa,A.blendDst=ea),A.onBeforeCompile=M=>{const k=r.premultiplied?`if ( sampledDiffuseColor.a > 0.0 && sampledDiffuseColor.a < 1.0 ) sampledDiffuseColor.rgb /= sampledDiffuseColor.a;
|
|
7141
|
+
`:"";M.fragmentShader=M.fragmentShader.replace("#include <map_fragment>",`vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
7142
|
+
${k}diffuseColor *= sampledDiffuseColor;`).replace("#include <alphatest_fragment>",S?"#include <alphatest_fragment>":`#include <alphatest_fragment>
|
|
7143
|
+
diffuseColor.a = 1.0;`)},A.customProgramCacheKey=()=>`volter-blender-image:${r.premultiplied}:${S}`;const O=new Rt(new fe(2,2),A);O.matrixAutoUpdate=!1,O.matrix.copy(_),O.renderOrder=r.depth==="FRONT"?1e3:r.depth==="BACK"?-1e3:0,O.userData.volterOwnMaterial=!0,y(O,!0),this.empties.add(O)}axisNames(t,n,e){const a=[new x,new x,new x];t.extractBasis(a[0],a[1],a[2]);for(let r=0;r<3;r++){const i=a[r].length()*n,f=new x(0,0,0);f.setComponent(r,1.25*n),f.applyMatrix4(t);const u=new x(0,0,0);u.setComponent(r,n),u.applyMatrix4(t);const h=[];for(let c=1;c<=6;c++)vt(h,ut(.007*(4*c/6)*i,4));this.empties.add(this.facing(h,e,u));const s=Dl[r],l=[];for(let c=0;c+1<s.length;c+=2){const[_,d]=s[c],[m,p]=s[c+1];ot(l,[_*4*i,d*4*i,0],[m*4*i,p*4*i,0])}this.empties.add(this.facing(l,e,f))}}material(t,n){const e=`${t}:${n}`;let a=this.lineMaterials.get(e);return a||(a=new oe({color:t,linewidth:Rl,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 En({color:t,side:wo,toneMapped:!1}),this.fillMaterials.set(t,n)),n}lines(t,n,e,a){const r=new ne().setPositions(t),i=new ee(r,this.material(n,e));return i.matrixAutoUpdate=!1,i.matrix.copy(a),i.computeLineDistances(),i}screen(t,n,e,a){const r=this.lines(t,n,e,new tt);return r.matrixAutoUpdate=!0,r.position.copy(a),r.scale.setScalar(0),r.frustumCulled=!1,this.onDraw(r,(i,f)=>this.face(r,i,f,!0)),r}facing(t,n,e){const a=this.lines(t,n,1,new tt);return a.matrixAutoUpdate=!0,a.position.copy(e),this.onDraw(a,(r,i)=>this.face(a,r,i,!1)),a}onDraw(t,n){const e=t,a=e.onBeforeRender.bind(e);e.onBeforeRender=(r,i,f,u,h,s)=>{n(r,f),a(r,i,f,u,h,s)}}face(t,n,e,a){t.parent?.getWorldQuaternion(this.parentQuat).invert(),e.getWorldQuaternion(t.quaternion).premultiply(this.parentQuat);let r=1;if(a){n.getSize(this.size);const i=Math.max(this.size.y,1),f=this.scratch.setFromMatrixPosition(t.matrixWorld);if(e.isOrthographicCamera){const u=e;r=(u.top-u.bottom)/u.zoom/i}else{const u=e;r=2*Math.max(-f.applyMatrix4(e.matrixWorldInverse).z,1e-6)*Math.tan(gt.degToRad(u.fov)/2)/u.zoom/i}}t.scale.setScalar(r),t.updateMatrixWorld(!0)}dispose(){for(const t of this.drawn.values())this.remove(t.parts);this.drawn.clear();for(const t of this.lineMaterials.values())t.dispose();for(const t of this.fillMaterials.values())t.dispose();this.lineMaterials.clear(),this.fillMaterials.clear()}}function Gn(o){const t=new x,n=new Tt;return o.decompose(t,n,new x),new tt().compose(t,n,new x(1,1,1))}const Zo=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],zl=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],Dl=[[[.9,1],[-1,-1],[-.9,1],[1,-1]].map(([o,t])=>[o*.0215,t*.025]),[[-1,1],[0,-.1],[1,1],[0,-.1],[0,-.1],[0,-1]].map(([o,t])=>[o*.0175,t*.025]),[[-.95,1],[.95,1],[.95,1],[.95,.9],[.95,.9],[-1,-.9],[-1,-.9],[-1,-1],[-1,-1],[1,-1]].map(([o,t])=>[o*.02,t*.025])],_t=N().finite(),Qo=P({name:R(),type:R(),lens:_t,sensor_width:_t,sensor_height:_t,sensor_fit:H(["AUTO","HORIZONTAL","VERTICAL"]),ortho_scale:_t,clip_start:_t,clip_end:_t,shift_x:_t,shift_y:_t,matrix:D(L([_t,_t,_t,_t])).length(4),passepartout:_t.default(0),display_size:_t.default(1)}),Cl={opening:.5,min:.1657359312880715,max:44.98528137423857},On={passepartout:"#000000",back:"#3d3d3d",overlay:"#000000",redalert:"#991616"};function kl(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 Ko(o,t,n,e){const a=o.type==="ORTHO",r=o.sensor_fit==="VERTICAL"?o.sensor_height:o.sensor_width,i=o.sensor_fit==="AUTO"?t>=n:o.sensor_fit==="HORIZONTAL",f=(a?o.ortho_scale:r/o.lens)/2*e;return i?[f,f*n/t]:[f*t/n,f]}function $l(o,t,n,e,a,r){const i=Math.max(n.width,1),f=Math.max(n.height,1),[u,h]=Ko(o,i,f,1/e),[s,l]=Ko(o,r,1,1),_=2*((o.sensor_fit==="AUTO"?r>=1:o.sensor_fit==="HORIZONTAL")?s:l),d=s/u,m=l/h,p=-2*a[0]*e,v=2*a[1]*e,g=o.shift_x*_-p*2*u,w=o.shift_y*_+v*2*h,y=new tt().set(...o.matrix.flat()).premultiply(t),S=new x,T=new Tt;return y.decompose(S,T,new x),{name:o.name,position:S.toArray(),quaternion:[T.x,T.y,T.z,T.w],projection:o.type==="ORTHO"?"orthographic":"perspective",window:{left:g-u,right:g+u,top:w+h,bottom:w-h},near:o.clip_start,far:o.clip_end,frame:{left:.5-d/2+p,top:.5-m/2+v,width:d,height:m},passepartout:{color:On.passepartout,opacity:o.passepartout},border:{solid:On.back,dashed:On.overlay,locked:On.redalert}}}const Ll={color:[.8,.8,.8,1],roughness:.5,metallic:0},Vl=`
|
|
7144
7144
|
uniform vec3 wbDir[4];
|
|
7145
7145
|
uniform vec3 wbDiffuse[4];
|
|
7146
7146
|
uniform vec3 wbSpecular[4];
|
|
@@ -7182,6 +7182,6 @@ vec3 volterWorkbenchLighting(vec3 baseColor, vec3 N, vec3 I) {
|
|
|
7182
7182
|
diffuseLight *= diffuseColor * (1.0 - specEnergy);
|
|
7183
7183
|
return diffuseLight + specularLight;
|
|
7184
7184
|
}
|
|
7185
|
-
`,
|
|
7185
|
+
`,bo=o=>ho.map(t=>{const[n=0,e=0,a=0]=o(t);return new x(n,e,a)}),jl=bo(o=>o.direction).map(o=>o.normalize()),Bl=bo(o=>o.diffuse),Ul=bo(o=>o.specular),Wl=new fo(...ho.map(o=>o.smooth));function Hl(o,t){const[n,e,a]=o.color,r=new aa({side:t});return r.color.setRGB(n,e,a,pt),r.name="volter:blender-solid",r.onBeforeCompile=i=>{i.uniforms.wbDir={value:jl},i.uniforms.wbDiffuse={value:Bl},i.uniforms.wbSpecular={value:Ul},i.uniforms.wbWrap={value:Wl},i.uniforms.wbRoughness={value:o.roughness},i.uniforms.wbMetallic={value:o.metallic},i.fragmentShader=i.fragmentShader.replace("void main() {",`${Vl}
|
|
7186
7186
|
void main() {`).replace("#include <opaque_fragment>",`outgoingLight = volterWorkbenchLighting(diffuseColor.rgb, normal, isOrthographic ? vec3(0.0, 0.0, 1.0) : normalize(vViewPosition));
|
|
7187
|
-
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const kl={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},I=M().finite(),we=$([I,I,I]),vn=$([M().int().nonnegative(),M().int().nonnegative()]),lt={name:N(),domain:U(["POINT","EDGE","FACE","CORNER"])},$l=da("type",[P({...lt,type:j("FLOAT2"),data:F($([I,I]))}).strict(),P({...lt,type:j("FLOAT_VECTOR"),data:F(we)}).strict(),P({...lt,type:j("FLOAT_COLOR"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("BYTE_COLOR"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("QUATERNION"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("FLOAT4"),data:F($([I,I,I,I]))}).strict(),P({...lt,type:j("FLOAT4X4"),data:F(F(I).length(16))}).strict(),P({...lt,type:j("INT16_2D"),data:F($([M().int(),M().int()]))}).strict(),P({...lt,type:j("INT32_2D"),data:F($([M().int(),M().int()]))}).strict(),P({...lt,type:j("FLOAT"),data:F(I)}).strict(),P({...lt,type:j("INT"),data:F(M().int())}).strict(),P({...lt,type:j("INT8"),data:F(M().int())}).strict(),P({...lt,type:j("BOOLEAN"),data:F(q())}).strict(),P({...lt,type:j("STRING"),data:F(N())}).strict()]),Ll=P({positions:B(Float32Array),normals:B(Float32Array).nullable(),uv:B(Float32Array).nullable(),uvLayers:F(P({name:N(),data:B(Float32Array)}).strict()).optional(),attributeLayers:F(P({name:N(),data:B(Float32Array)}).strict()).optional(),orco:B(Float32Array).nullable().optional(),indices:B(Uint32Array),groups:F(P({start:M().int().nonnegative(),count:M().int().nonnegative(),materialIndex:M().int().nonnegative()}).strict()),hash:N()}).strict(),Vl=P({v:F(we),f:F(F(M().int().nonnegative())),e:F(vn).optional(),edge_order:F(vn).optional(),m:F(M().int().nonnegative()).optional(),s:F(q()).optional(),sharp:F(vn).optional(),seams:F(vn).optional(),creases:F($([I,I,I])).optional(),attributes:F($l).optional(),active_uv:N().nullable().optional(),render_uv:N().nullable().optional()}).strict(),jl=P({store:M().int().optional(),revision:M().int(),unchanged:j(!0)}).strict(),Bl=P({co:Nt([B(Float32Array),B(Float64Array)]),cornerNormal:B(Float32Array).optional(),orco:B(Float32Array).optional(),faceStart:B(Uint32Array),corner:B(Uint32Array),cornerEdge:B(Int32Array),edge:B(Uint32Array),edgeSharp:B(Uint8Array),edgeSeam:B(Uint8Array),edgeCrease:B(Float32Array),material:B(Uint32Array),smooth:B(Uint8Array),vertSelect:B(Uint8Array),vertHide:B(Uint8Array),edgeSelect:B(Uint8Array),edgeHide:B(Uint8Array),faceSelect:B(Uint8Array),faceHide:B(Uint8Array)}).strict(),Ul=P({name:N(),domain:U(["POINT","EDGE","FACE","CORNER"]),type:N(),data:ha(o=>ArrayBuffer.isView(o))}).strict(),Oe=P({columns:Bl,attributes:F(Ul),activeUv:N().nullable(),renderUv:N().nullable(),counts:P({verts:M().int().nonnegative(),edges:M().int().nonnegative(),faces:M().int().nonnegative(),corners:M().int().nonnegative()}).strict(),revision:M().int().nonnegative()}).strict(),Wl=Nt([Ll,Oe,Vl,jl]),Uo=new Set;function Hl(o,t){const n=new Blob([o],{type:t}),e=new ea;let a=!1;e.addEventListener("dispose",()=>{a=!0,e.image?.close?.()});const r=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(i=>{if(a){i.close();return}e.image=i,e.needsUpdate=!0,vt()}).finally(()=>{Uo.delete(r)});return Uo.add(r),r.catch(()=>{}),{texture:e,ready:r}}function ql(o,t,n,e){const a=new Sn(o,t,n,En,oa);return a.flipY=!1,a.colorSpace=e==="data"?On:Mt,a.needsUpdate=!0,a}function Gl(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(s=>s.width)),a=Math.max(...t.map(s=>s.height)),r=new Uint8Array(e*a*4*t.length),i=Math.max(...t.map(s=>s.number-1001))+1,f=new Float32Array(i*2*4);for(let s=0;s<i;s++)f[s*4]=-1;t.forEach((s,l)=>{const c=s.rgba??(s.rgbaBase64?qn(s.rgbaBase64):void 0);if(!c)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let d=0;d<s.height;d++)r.set(c.subarray(d*s.width*4,(d+1)*s.width*4),(l*a+d)*e*4);const _=s.number-1001;f[_*4]=l,f.set([0,0,s.width/e,s.height/a],(i+_)*4)});const u=new na(r,e,a,t.length);u.colorSpace=n==="data"?On:Mt,u.magFilter=Vt,u.minFilter=ne,u.generateMipmaps=!0,u.needsUpdate=!0;const h=new Sn(f,i,2,En,Qo);return h.magFilter=h.minFilter=Wn,h.needsUpdate=!0,{tiles:u,map:h,frame:t}}const Xl=P({width:M().int().positive(),height:M().int().positive(),revision:M().int().nonnegative(),rgba:B(Uint8Array).optional(),rgbaBase64:N().optional(),colorspace:U(["sRGB","data"]).optional(),tiles:F(P({number:M().int().min(1001),width:M().int().positive(),height:M().int().positive(),rgba:B(Uint8Array).optional(),rgbaBase64:N().optional()}).strict()).optional()}).strict(),Yl=P({revision:M().int().nonnegative(),encoded:B(Uint8Array).optional(),encodedBase64:N().optional(),mime:U(["image/png","image/jpeg"]),colorspace:U(["sRGB","data"]).optional()}).strict(),Te=Nt([Xl,Yl]),Vn=P({image:P({name:N(),revision:M().int().nonnegative()}).strict(),extension:U(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:N(),tint:$([I,I,I]).optional()}).strict(),Zl=P({name:N(),color:$([I,I,I,I]),roughness:I,metallic:I,transmission:I,ior:I,physical:al.optional(),normal_texture:Vn.optional(),normal_strength:I.default(1),normal_space:U(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:q().default(!1),texture:Vn.optional(),roughness_texture:Vn.optional(),emission:P({color:$([I,I,I]),strength:I}).strict().optional(),graph:Ir.optional(),viewport:P({color:$([I,I,I,I]),roughness:I,metallic:I}).strict().optional()}).strict(),Ql=P({session:N(),revision:M().int().nonnegative(),volumes:_t(N(),he).default({}),lights:_t(N(),hr).default({}),world:Or.nullable().default(null),meshes:_t(N(),Wl),materials:_t(N(),Zl),images:_t(N(),Te).default({}),objects:F(P({id:N(),name:N(),type:U(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:N().nullable(),volume:N().nullable().optional(),light:N().nullable().optional(),materials:F(N().nullable()),matrix:F($([I,I,I,I])).length(4),visible:q(),render_visible:q().default(!0),selected:q(),parent:N().nullable(),texspace:$([$([I,I,I]),$([I,I,I])]).optional(),default_color:N().optional()}).strict()),active:N().nullable(),mode:N(),cameras:_t(N(),_t(N(),ee())).default({}),warnings:F(N()).default([]),updated:F(N()).default([]),frame:M().int().default(0),armatures:_t(N(),xa).default({}),weights:cl.nullable().default(null),cursor:hl.optional(),camera_view:P({scene_camera:N().nullable(),view_layer_cameras:F(N()),aspect:M().finite().positive()}).optional(),light_distances:_t(N(),$([M().finite(),M().finite()])).default({}),empties:_t(N(),yl).default({}),view:P({location:$([M(),M(),M()]),rotation:$([M(),M(),M(),M()]),distance:M().finite(),perspective:U(["PERSP","ORTHO","CAMERA"]),lens:M().finite().positive().default(50),shading:U(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:P({frame:M().int(),body:N(),markers:F($([M().int(),N()]))}).optional(),units:P({system:U(["NONE","METRIC","IMPERIAL"]),scale_length:M().finite()}).optional()}).strict();function Kl(o,t){for(let n=0,e=o.length-1;n<o.length&&e>=0;n++,e--){if(o[n][0]===t)return o[n][1];if(n===e)break;if(o[e][0]===t)return o[e][1]}return null}const Jl={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class Pn{constructor(){this.root=new ot,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new wr,this.world=new lo,this.armatureOverlay=new Na,this.weightOverlay=new dl,this.cursorOverlay=new bl,this.extrasOverlay=new Tl,this.armatureRoot=new ot,this.weightRoot=new ot,this.cursorRoot=new ot,this.cameraExtrasRoot=new ot,this.lightExtrasRoot=new ot,this.emptyExtrasRoot=new ot,this.rendered=!1,this.heldRendered=null,this.worldApplied=null,this.worldKey="null",this.capturing=!1,this.workbench=!1,this.workbenchMaterials=new Map,this.fallback=new ln({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new el,this.graphSamplers=new Map,this.photograph=!1,this.graphs=new Map,this.frame=null,this.retiredSessions=new Set,this.geometryBuilds=0,this.submittedMeshes=new Map,this.submitted=null,this.submittedSession=null,this.photographs=[],this.frameListeners=new Set,this.followers=new Set,this.leader=null,this.cameraViewZoom=Sl,this.cameraViewPan=El,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,this.staged=null,this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[t,n]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group],[this.cursorRoot,this.cursorOverlay.group],[this.cameraExtrasRoot,this.extrasOverlay.cameras],[this.lightExtrasRoot,this.extrasOverlay.lights],[this.emptyExtrasRoot,this.extrasOverlay.empties]])t.matrixAutoUpdate=!1,t.matrix.copy(this.root.matrix),t.add(n),t.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const t of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])t.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let e=this.graphs.get(n);return e||(e=qr(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[r,i]of this.objects)if(i===t){n=r;break}if(n===null)return;const e=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let a=!1;for(const r of e){if(r===this)continue;const i=r.objects.get(n);i!==void 0&&(i.matrix.copy(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),a=!0)}a&&vt()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=va(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(a=>a.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,a,r]=t.rotation,i=new gt(e,a,r,n),f=new x(...t.location).applyMatrix4(this.root.matrix),u=h=>h.applyQuaternion(i).applyMatrix4(this.root.matrix).normalize();return{target:f.toArray(),direction:u(new x(0,0,1)).toArray(),up:u(new x(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?kl[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new X().copy(this.root.matrix).invert(),a=new X().compose(new x(...t),new gt(...n),new x(1,1,1)).premultiply(e),r=new x,i=new gt;return a.decompose(r,i,new x),{location:r.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,n,e,a){const r=this.frame,i=jo.safeParse(r?.cameras[t]);return!r?.camera_view||!i.success?null:Ml(i.data,this.root.matrix,n,e,a,r.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const e=t??n.frame,a=Kl(n.markers,e);return`(${e})${n.body}${a===null?"":` <${a}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const e=Jl[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([f])=>f*r>a)??e[e.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(e=>e.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[e,a]of this.objects)if(a===t){const r=t.parent,i=[...t.children];t.removeFromParent();for(const f of i)n.add(f);r?.add(n),this.objects.set(e,n);return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,e){const a=new Set(this.objects.values()),r=this.cursorOverlay.placementAt(t,n,e,this.root,i=>a.has(i));return r!==null&&(this.cursorOverlay.show(r),vt()),r}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(a=>a.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(vt,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),vt())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const a=this.objects.get(e.id);if(!a?.isMesh)continue;const i=(e.materials.length?e.materials:[null]).map(f=>{const u=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,u.side,n):u});a.material=e.materials.length?i:i[0]}for(const[e,a]of this.workbenchMaterials)n.has(e)||(a.dispose(),this.workbenchMaterials.delete(e))}workbenchFor(t,n,e){const a=(t!==null?this.frame?.materials[t]?.viewport:void 0)??Nl,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let i=this.workbenchMaterials.get(r);return i||(i=Cl(a,n),this.workbenchMaterials.set(r,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?ko(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])ll(r,e);this.rendered=t,this.lighting.setRendered(t);const a=t&&n?this.worldKeyFor(n):null;t?(this.capturing||a!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:a,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await vr(),await Promise.all([...this.textures.values()].map(r=>r.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const e=[];for(const u of this.objects.values()){const h=u;if(h.isMesh&&(h.castShadow=t,h.receiveShadow=t,t&&h.visible)){const s=new wn().setFromObject(h);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,h)=>u.union(h),new wn).getBoundingSphere(new Qe),i=n?new Ke().setFromProjectionMatrix(new X().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=i?e.flatMap(u=>Pr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Sr(u,f,e):br(u,r.center,r.radius)}applyOverlays(t){const n=i=>{const f=t.objects.find(u=>u.name===i);return f===void 0?null:new X().set(...f.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],a=t.weights?this.objects.get(t.objects.find(i=>i.name===t.weights?.object)?.id??""):void 0,r=this.weightOverlay.apply(t.weights,a??null,t.weights?n(t.weights.object):null);return r!==null&&e.push(r),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),e}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),vt())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=jo.safeParse(a);r.success&&(n[e]=r.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(e=>e.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:e=>{const a=t.objects.find(r=>r.name===e);return a?this.objects.get(a.id)??null:null},image:e=>{const a=this.textures.get(e);if(!a)return null;const r=a.texture.image,i=a.width||r?.width||0,f=a.height||r?.height||0;return(i===0||f===0)&&a.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),a.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),vt()},()=>this.awaitedImages.delete(e))),{texture:a.texture,width:i,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const e=this.lights.get(t.light);e&&(e.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.capturing,this.weightOverlay.group.visible=!this.capturing,this.cursorOverlay.group.visible=!this.capturing;for(const t of[this.extrasOverlay.cameras,this.extrasOverlay.lights,this.extrasOverlay.empties])t.visible=!this.capturing}stageFrame(t){if(t.abort||!t.mesh&&!t.image){for(const e of this.staged?.meshes.values()??[])e.geometry.dispose();this.staged=t.abort?null:{session:t.session,revision:t.revision,meshes:new Map,images:new Map};return}const n=this.staged;if(!n||n.session!==t.session||n.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const e=Oe.parse(t.piece);if(n.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const a=`revision:${e.revision}`;n.meshes.set(t.mesh,{signature:a,geometry:xn(wo({...e.columns,attributes:e.attributes,activeUv:e.activeUv,renderUv:e.renderUv},a))})}else if(t.image!==void 0){if(n.images.has(t.image))throw new Error("Duplicate Blender image piece");n.images.set(t.image,Te.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=Ql.parse(t),a=this.staged;if(a&&(a.session!==e.session||a.revision!==e.revision))throw new Error("Blender frame manifest does not match its staged revision");if(a)for(const[s,l]of a.images)e.images[s]=l;if(this.retiredSessions.has(e.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===e.session&&e.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const r=new Set(e.objects.map(s=>s.id));if(r.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const i=new Map(e.objects.map(s=>[s.id,s]));for(const s of e.objects){if(s.mesh!==null&&!e.meshes[s.mesh])throw new Error(`Missing runtime mesh ${s.mesh}`);if(s.volume&&(!e.volumes[s.volume]||s.mesh!==null))throw new Error(`Invalid runtime volume ${s.volume}`);if(s.light&&(!e.lights[s.light]||s.mesh!==null))throw new Error(`Invalid runtime light ${s.light}`);for(const _ of s.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const l=new Set([s.id]);let c=s.parent;for(;c!==null;){if(l.has(c))throw new Error("Runtime parent cycle");l.add(c);const _=i.get(c);if(!_)throw new Error(`Missing runtime parent ${c}`);c=_.parent}}const f=new Map,u=new Map;try{for(const[s,l]of Object.entries(e.volumes)){const c=JSON.stringify(l);this.frame?.session===e.session&&this.volumes.get(s)?.signature===c||u.set(s,{signature:c,mesh:Er(l)})}for(const[s,l]of Object.entries(e.meshes)){if("unchanged"in l){const m=a?.meshes.get(s);if(m){if(m.signature!==`revision:${l.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(s,m);continue}const p=this.meshes.get(s)?.signature;if(this.frame?.session===e.session&&p!==void 0&&(p===`revision:${l.revision}`||!p.startsWith("revision:")))continue;throw new Error(p===void 0?`${xo}: the presenter does not hold runtime mesh ${s} (store ${l.store}, revision ${l.revision})`:`${xo}: the presenter holds runtime mesh ${s} at ${p}, not revision ${l.revision}`)}const c="hash"in l,_="columns"in l,d=_?`revision:${l.revision}`:c?l.hash:JSON.stringify(l);this.frame?.session===e.session&&this.meshes.get(s)?.signature===d||f.set(s,{signature:d,geometry:_?xn(wo({...l.columns,attributes:l.attributes,activeUv:l.activeUv,renderUv:l.renderUv},d)):c?xn(l):Ba(l)})}}catch(s){for(const l of f.values())l.geometry.dispose();for(const{mesh:l}of u.values())l.geometry.dispose(),l.material.dispose();throw s}if(a){for(const[s,l]of a.meshes)f.has(s)||l.geometry.dispose();this.staged=null}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[s,l]of u){const c=this.volumes.get(s)?.mesh;c&&(c.removeFromParent(),c.geometry.dispose(),c.material.dispose()),this.volumes.set(s,l)}for(const[s,l]of f)this.meshes.get(s)?.geometry.dispose(),this.meshes.set(s,l),this.geometryBuilds++;for(const[s,l]of Object.entries(e.images)){const c=this.textures.get(s);if("width"in l){const v=l.rgba??(l.rgbaBase64?qn(l.rgbaBase64):void 0);if(!v)throw new Error(`Runtime image ${s} carries no raster`);const g=l.tiles?Gl(s,l.tiles,l.colorspace??"sRGB"):void 0;if(c?.udim&&(c.udim.tiles.dispose(),c.udim.map.dispose(),delete c.udim),c&&c.width===l.width&&c.height===l.height){const w=c.texture.image;if(w.data){w.data.set(v),c.texture.needsUpdate=!0,c.revision=l.revision,g&&(c.udim=g);continue}}c?.texture.dispose(),this.textures.set(s,{texture:ql(v,l.width,l.height,l.colorspace??"sRGB"),width:l.width,height:l.height,revision:l.revision,...g?{udim:g}:{}});continue}const _=l.encoded??(l.encodedBase64?qn(l.encodedBase64):void 0);if(!_)throw new Error(`Runtime image ${s} carries no bytes`);c?.texture.dispose(),c?.udim?.tiles.dispose(),c?.udim?.map.dispose();const d=l.colorspace??"sRGB",{texture:m,ready:p}=Hl(_,l.mime);m.colorSpace=d==="data"?On:Mt,this.textures.set(s,{texture:m,ready:p,width:0,height:0,revision:l.revision,encoded:{bytes:_.slice(),mime:l.mime,colorspace:d}})}for(const[s,l]of Object.entries(e.materials)){const c=this.materials.get(s)??new ln;c.name=l.name;const _=l.texture?.tint;l.texture!==void 0?c.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,ft):c.color.setRGB(l.color[0],l.color[1],l.color[2],ft),c.opacity=l.color[3];const d=c.opacity<1||l.graph!==void 0&&Fr(l.graph);c.transparent!==d&&(c.transparent=d,c.needsUpdate=!0),c.roughness=l.roughness,c.metalness=l.metallic,c.transmission=l.transmission,c.ior=l.ior,so(c,l.physical,{map:l.texture?.extension==="CLIP",roughness:l.roughness_texture?.extension==="CLIP",normal:l.normal_texture?.extension==="CLIP"});const m=l.normal_texture?.image.name;if(m===void 0)c.normalMap&&(this.textureSamplers.delete(`${s}:normal`),c.normalMap=null,c.needsUpdate=!0);else{const y=this.textures.get(m);if(!y)throw new Error(`${Qt}: missing normal image ${m}`);const S=this.textureSamplers.get(`${s}:normal`,y.texture,l.normal_texture.extension,y.ready,l.normal_texture.uv);c.normalMap!==S&&(c.normalMap=S,c.needsUpdate=!0);const T=l.normal_space==="OBJECT"?Je:ta;c.normalMapType!==T&&(c.normalMapType=T,c.needsUpdate=!0),c.normalScale.set(l.normal_strength,l.normal_strength*(l.normal_directx?-1:1))}l.emission?(c.emissive.setRGB(l.emission.color[0],l.emission.color[1],l.emission.color[2],ft),c.emissiveIntensity=l.emission.strength):(c.emissive.setRGB(0,0,0),c.emissiveIntensity=1);const p=l.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(s)&&(this.textureSamplers.delete(`${s}:roughness`),c.roughnessMap=null,this.roughnessTextureNames.delete(s),c.needsUpdate=!0);else{const y=this.textures.get(p);if(!y)throw new Error(`${Qt}: the presenter does not hold runtime image ${p} (revision ${l.roughness_texture.image.revision})`);const S=this.textureSamplers.get(`${s}:roughness`,y.texture,l.roughness_texture.extension,y.ready,l.roughness_texture.uv);c.roughnessMap!==S&&(c.roughnessMap=S,this.roughnessTextureNames.set(s,p),c.needsUpdate=!0)}const v=l.texture?.image.name??null;if(v===null)this.textureNames.has(s)&&(this.textureSamplers.delete(`${s}:color`),c.map=null,this.textureNames.delete(s),c.needsUpdate=!0);else{const y=this.textures.get(v);if(!y)throw new Error(`${Qt}: the presenter does not hold runtime image ${v} (revision ${l.texture.image.revision})`);const S=this.textureSamplers.get(`${s}:color`,y.texture,l.texture.extension,y.ready,l.texture.uv);c.map!==S&&(c.map=S,this.textureNames.set(s,v),c.needsUpdate=!0)}const g=l.graph?this.compiledGraph(l.graph):null,w=new Set;Xr(c,g,y=>{const S=this.textures.get(y.name);if(!S)throw new Error(`${Qt}: the presenter does not hold runtime image ${y.name} (revision ${y.revision})`);if(y.tiled){if(!S.udim)throw new Error(`${Qt}: runtime image ${y.name} arrived without its UDIM tiles`);return S.udim}const T=`${s}:graph:${y.node}`;w.add(T);const A=this.textureSamplers.get(T,S.texture,y.extension,S.ready),O=y.closest?Wn:Vt,E=y.closest?Wn:y.mipmap?ne:Vt;return(A.magFilter!==O||A.minFilter!==E)&&(A.magFilter=O,A.minFilter=E,A.needsUpdate=!0),A},this.photograph);for(const y of this.graphSamplers.get(s)??[])w.has(y)||this.textureSamplers.delete(y);this.graphSamplers.set(s,w),this.materials.set(s,c)}for(const s of e.objects){let l=this.objects.get(s.id);const c=s.volume?this.volumes.get(s.volume).mesh:null;if((!l||(c?l!==c:!!l.isMesh!=(s.mesh!==null)))&&(l?.removeFromParent(),l=c??(s.mesh!==null?new Tt(this.meshes.get(s.mesh).geometry,this.fallback):new Yo),this.objects.set(s.id,l)),l.name=s.name,s.type==="CAMERA"||s.type==="LIGHT"||s.type==="EMPTY"?l.userData.volterOwnOverlay=!0:delete l.userData.volterOwnOverlay,l.matrixAutoUpdate=!1,l.matrix.set(...s.matrix.flat()),s.parent){const _=new X().set(...i.get(s.parent).matrix.flat());l.matrix.premultiply(_.invert())}if(l.matrix.decompose(l.position,l.quaternion,l.scale),s.texspace?l.userData.blenderTexspace=s.texspace:delete l.userData.blenderTexspace,s.default_color!==void 0?l.userData.blenderDefaultColor=s.default_color:delete l.userData.blenderDefaultColor,s.mesh!==null){const _=l;_.geometry=this.meshes.get(s.mesh).geometry,_.material=s.materials.length?s.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,Kr(_)}if(s.light){const _=this.lights.get(s.light)??null,d=xr(e.lights[s.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==l&&l.add(d),d.userData.volterOwnOverlay=!0,yr(d,l),this.lights.set(s.light,d)}}for(const s of e.objects){const l=this.objects.get(s.id),c=s.parent===null?this.root:this.objects.get(s.parent);l.parent!==c&&c.add(l)}for(const[s,l]of this.objects)r.has(s)||(l.removeFromParent(),this.objects.delete(s));for(const[s,l]of this.volumes)e.volumes[s]||(l.mesh.geometry.dispose(),l.mesh.material.dispose(),this.volumes.delete(s));for(const[s,l]of this.meshes)e.meshes[s]||(l.geometry.dispose(),this.meshes.delete(s));for(const[s,l]of this.materials)if(!e.materials[s]){for(const c of["normal","roughness","color"])this.textureSamplers.delete(`${s}:${c}`);for(const c of this.graphSamplers.get(s)??[])this.textureSamplers.delete(c);this.graphSamplers.delete(s),l.dispose(),this.materials.delete(s)}for(const[s,l]of this.lights)e.lights[s]||(l.removeFromParent(),l.dispose(),this.lights.delete(s));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{},images:{}},this.worldKey=JSON.stringify(e.world??null);const h=this.applyOverlays(e);h.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...h]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const s of[...this.frameListeners])s();for(const s of this.followers)try{s.applyFrame(t)}catch{s.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[a,{signature:r,geometry:i}]of this.meshes){const f=s=>{const l=i.getAttribute(s);if(!l)return null;if(!(l instanceof it))throw new Error(`Blender capture cannot copy interleaved ${s}`);return new Float32Array(l.array)},u=f("position");if(!u)throw new Error(`Blender capture mesh ${a} has no positions`);const h=i.getIndex();n.meshes[a]={hash:r,positions:u,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(i.userData.blenderUvChannels??{}).map(([s,l])=>{const c=f(`uv${l}`);if(!c)throw new Error(`Blender capture mesh ${a} is missing UV layer ${s}`);return{name:s,data:c}}),orco:i.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(i.userData.blenderAttributes??[]).map(s=>{const l=f(jt(s));if(!l)throw new Error(`Blender capture mesh ${a} is missing attribute ${s}`);return{name:s,data:l}}),indices:h?new Uint32Array(h.array):Uint32Array.from({length:u.length/3},(s,l)=>l),groups:i.groups.map(s=>({start:s.start,count:s.count,materialIndex:s.materialIndex??0}))}}for(const[a,{signature:r}]of this.volumes)n.volumes[a]=he.parse(JSON.parse(r));const e=new Set(Object.values(n.materials).flatMap(a=>[a.texture?.image.name,a.roughness_texture?.image.name,a.normal_texture?.image.name,...Object.values(a.graph?.nodes??{}).map(r=>r.props.image?.name)].filter(r=>r!==void 0)));for(const a of e){const r=this.textures.get(a);if(!r)throw new Error(`Blender capture image ${a} is not resident`);if(r.encoded)n.images[a]={revision:r.revision,encoded:r.encoded.bytes.slice(),mime:r.encoded.mime,colorspace:r.encoded.colorspace};else{const i=r.texture.image?.data;if(!(i instanceof Uint8Array))throw new Error(`Blender capture image ${a} has no resident raster`);n.images[a]={revision:r.revision,width:r.width,height:r.height,rgba:i.slice(),colorspace:r.texture.colorSpace===On?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Pn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,e=this.createWorldVolumePass(),a=new Pn;a.photograph=!0;let r=!1;const i=()=>{r||(r=!0,e?.dispose(),a.dispose(),a.root.removeFromParent())};try{a.applyFrame(t),this.root.updateWorldMatrix(!0,!1),a.root.matrix.copy(this.root.matrixWorld),a.root.updateMatrixWorld(!0)}catch(f){throw i(),f}return{effect:e,root:a.root,session:n.session,revision:n.revision,prepare:f=>{if(r)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,f)},dispose:i}}createWorldVolumePass(){const t=ko(this.frame?.world);return t?new fl(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const a=typeof n.session=="string"?n.session:null;a!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=a);const r=e;for(const[i,f]of Object.entries(r))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(i,f);for(const i of[...this.submittedMeshes.keys()])i in r||this.submittedMeshes.delete(i);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.staged?.meshes.values()??[])t.geometry.dispose();this.staged=null;for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const si=new Pn;function Ae(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function jn(o){const t=Ae(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function ti(o){const t=Ae(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ni(o){return new X().set(...o.flat())}function Wo(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class oi{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,a=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:a,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((r,i)=>r+i.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:this.#i!==null?this.#i:t.clipStart+this.#a.time*t.fps}get playable(){return this.#a!==null}async bind(t,n){this.#r++;const e=await n.rig();if(!e)return;const a=[],r=new Set;let i=!1;for(const l of e.rigs){if(!l.object||!l.armature||!l.skinIndexBase64||!l.skinWeightBase64){l.reason&&a.push(l.reason);continue}r.add(l.object);const c=Wo(l,e.frame);if(this.#n.get(l.object)?.signature===c)continue;const _=this.#d(t,l,e.frame,a);_&&(this.#n.get(l.object)?.skeleton.dispose(),this.#n.set(l.object,_),i=!0)}for(const[l,c]of[...this.#n])r.has(l)||(c.skeleton.dispose(),c.boneRoot.removeFromParent(),this.#n.delete(l),i=!0);this.#r++;const f=await n.clip(),u=this.#t,h=f?.action!==u?.action||f?.tracks.length!==u?.tracks.length||f?.clipStart!==u?.clipStart||f?.clipEnd!==u?.clipEnd;this.#t=f??null,f?.reason&&a.push(f.reason),f&&(h||i)&&this.#h(t,f,a);const s=this.#e?.snapshot().playbackState==="playing";f&&!s&&u?.frameCurrent!==f.frameCurrent&&(this.#c(f.frameCurrent),this.#e&&f.fps>0&&this.#e.seek(f.frameCurrent/f.fps)),this.#_=a,this.#f()}#d(t,n,e,a){const r=t.objectForBlenderName(n.object??""),i=t.objectForBlenderName(n.armature??"");if(!r||!i)return null;const f=r,u=f.geometry;if(!u)return null;const h=u.getAttribute("blenderVertex");if(!h)return a.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let s=0;for(let T=0;T<h.count;T++)s=Math.max(s,h.getX(T));if(s>=n.vertexCount)return a.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${s} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const l=ti(n.skinIndexBase64??""),c=jn(n.skinWeightBase64??""),_=h.count,d=new Uint16Array(_*4),m=new Float32Array(_*4);for(let T=0;T<_;T++){const A=h.getX(T);for(let O=0;O<4;O++)d[T*4+O]=l[A*4+O]??0,m[T*4+O]=c[A*4+O]??0}u.setAttribute("skinIndex",new aa(d,4)),u.setAttribute("skinWeight",new bt(m,4));const p=new ot;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ni(T.pose)),w=new Map(n.bones.map((T,A)=>[T.name,A]));n.bones.forEach((T,A)=>{const O=new ra;O.name=T.name,v.push(O);const E=T.parent===null?void 0:w.get(T.parent);(E===void 0?g[A].clone():g[E].clone().invert().multiply(g[A])).decompose(O.position,O.quaternion,O.scale),(E===void 0?p:v[E]).add(O)}),i.add(p);const y=new la(u,f.material);y.name=f.name,y.matrixAutoUpdate=!1,y.matrix.copy(f.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale),y.userData=f.userData,y.frustumCulled=!1,t.replacePresentedObject(f,y),t.root.updateMatrixWorld(!0);const S=new ia(v);return y.bind(S,y.matrixWorld.clone()),n.constrainedBones?.length&&a.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&a.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:y,boneRoot:p,bones:v,skeleton:S,frame:e,signature:Wo(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const a=n.armature?t.objectForBlenderName(n.armature):null;if(!a)return;const r=new Map;for(const l of this.#n.values())if(l.armature===n.armature)for(const c of l.bones)r.set(c.name,c);const i=[],f=new Set;for(const l of n.tracks){const c=r.get(l.bone);if(!c){f.add(l.bone);continue}const _=jn(l.timeBase64),d=jn(l.valueBase64),m=`${c.uuid}.${l.property}`;i.push(l.property==="quaternion"?new sa(m,Array.from(_),Array.from(d)):new fa(m,Array.from(_),Array.from(d)))}if(f.size&&e.push(`${n.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!i.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,h=new ca(a),s=h.clipAction(new ua(n.action??"action",u,i));s.setLoop(_a,Number.POSITIVE_INFINITY),s.play(),this.#o=h,this.#a=s,this.#c(n.frameCurrent),this.#m()}#c(t){const n=this.#t;if(!n||!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const e=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#i=e;const a=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.min(a-1e-4,(e-n.clipStart)/n.fps)),this.#m()}#m(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const e=n.scene;return!e||n.frameCurrent===t||(this.#r++,await pa(`bpy.data.scenes[${JSON.stringify(e)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const i=this.#t,f=i?.fps||24;return{start:(i?.frameStart??1)/f,end:(i?.frameEnd??250)/f,fps:f}},seek:i=>this.seekSeconds(i)}),e=t.onSettled(()=>{this.writeBookmark()}),a=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#l=null};this.#l=a;const r=this.#t;return r&&r.fps>0&&t.seek(r.frameCurrent/r.fps),a}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#l?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const Pe=new oi;function fi(o){return Pe.subscribe(o)}function ci(){return Pe.version}export{Pe as a,ci as b,si as c,fi as s};
|
|
7187
|
+
#include <opaque_fragment>`)},r.customProgramCacheKey=()=>"volter-blender-workbench",r}const ql={WIREFRAME:"wireframe",SOLID:"solid",MATERIAL:"preview",RENDERED:"rendered"},F=N().finite(),Re=L([F,F,F]),Tn=L([N().int().nonnegative(),N().int().nonnegative()]),mt={name:R(),domain:H(["POINT","EDGE","FACE","CORNER"])},Gl=wa("type",[P({...mt,type:W("FLOAT2"),data:D(L([F,F]))}).strict(),P({...mt,type:W("FLOAT_VECTOR"),data:D(Re)}).strict(),P({...mt,type:W("FLOAT_COLOR"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("BYTE_COLOR"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("QUATERNION"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("FLOAT4"),data:D(L([F,F,F,F]))}).strict(),P({...mt,type:W("FLOAT4X4"),data:D(D(F).length(16))}).strict(),P({...mt,type:W("INT16_2D"),data:D(L([N().int(),N().int()]))}).strict(),P({...mt,type:W("INT32_2D"),data:D(L([N().int(),N().int()]))}).strict(),P({...mt,type:W("FLOAT"),data:D(F)}).strict(),P({...mt,type:W("INT"),data:D(N().int())}).strict(),P({...mt,type:W("INT8"),data:D(N().int())}).strict(),P({...mt,type:W("BOOLEAN"),data:D(Z())}).strict(),P({...mt,type:W("STRING"),data:D(R())}).strict()]),Xl=P({positions:U(Float32Array),normals:U(Float32Array).nullable(),uv:U(Float32Array).nullable(),uvLayers:D(P({name:R(),data:U(Float32Array)}).strict()).optional(),attributeLayers:D(P({name:R(),data:U(Float32Array)}).strict()).optional(),orco:U(Float32Array).nullable().optional(),indices:U(Uint32Array),groups:D(P({start:N().int().nonnegative(),count:N().int().nonnegative(),materialIndex:N().int().nonnegative()}).strict()),hash:R()}).strict(),Yl=P({v:D(Re),f:D(D(N().int().nonnegative())),e:D(Tn).optional(),edge_order:D(Tn).optional(),m:D(N().int().nonnegative()).optional(),s:D(Z()).optional(),sharp:D(Tn).optional(),seams:D(Tn).optional(),creases:D(L([F,F,F])).optional(),attributes:D(Gl).optional(),active_uv:R().nullable().optional(),render_uv:R().nullable().optional()}).strict(),Zl=P({store:N().int().optional(),revision:N().int(),unchanged:W(!0)}).strict(),Ql=P({co:kt([U(Float32Array),U(Float64Array)]),cornerNormal:U(Float32Array).optional(),cornerTri:U(Uint32Array).optional(),orco:U(Float32Array).optional(),faceStart:U(Uint32Array),corner:U(Uint32Array),cornerEdge:U(Int32Array),edge:U(Uint32Array),edgeSharp:U(Uint8Array),edgeSeam:U(Uint8Array),edgeCrease:U(Float32Array),material:U(Uint32Array),smooth:U(Uint8Array),vertSelect:U(Uint8Array),vertHide:U(Uint8Array),edgeSelect:U(Uint8Array),edgeHide:U(Uint8Array),faceSelect:U(Uint8Array),faceHide:U(Uint8Array)}).strict(),Kl=P({name:R(),domain:H(["POINT","EDGE","FACE","CORNER"]),type:R(),data:Oa(o=>ArrayBuffer.isView(o))}).strict(),Ie=P({columns:Ql,attributes:D(Kl),activeUv:R().nullable(),renderUv:R().nullable(),counts:P({verts:N().int().nonnegative(),edges:N().int().nonnegative(),faces:N().int().nonnegative(),corners:N().int().nonnegative()}).strict(),revision:N().int().nonnegative()}).strict(),Jl=kt([Xl,Ie,Yl,Zl]),Jo=new Set;function ti(o,t){const n=new Blob([o],{type:t}),e=new ua;let a=!1;e.addEventListener("dispose",()=>{a=!0,e.image?.close?.()});const r=createImageBitmap(n,{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(i=>{if(a){i.close();return}e.image=i,e.needsUpdate=!0,Ot()}).finally(()=>{Jo.delete(r)});return Jo.add(r),r.catch(()=>{}),{texture:e,ready:r}}function ni(o,t,n,e){const a=new zn(o,t,n,Dn,ca);return a.flipY=!1,a.colorSpace=e==="data"?Nn:Ct,a.needsUpdate=!0,a}function oi(o,t,n){if(t.length===0)throw new Error(`Runtime image ${o} is tiled with no tiles`);const e=Math.max(...t.map(s=>s.width)),a=Math.max(...t.map(s=>s.height)),r=new Uint8Array(e*a*4*t.length),i=Math.max(...t.map(s=>s.number-1001))+1,f=new Float32Array(i*2*4);for(let s=0;s<i;s++)f[s*4]=-1;t.forEach((s,l)=>{const c=s.rgba??(s.rgbaBase64?to(s.rgbaBase64):void 0);if(!c)throw new Error(`Runtime image ${o} tile ${s.number} carries no raster`);for(let d=0;d<s.height;d++)r.set(c.subarray(d*s.width*4,(d+1)*s.width*4),(l*a+d)*e*4);const _=s.number-1001;f[_*4]=l,f.set([0,0,s.width/e,s.height/a],(i+_)*4)});const u=new fa(r,e,a,t.length);u.colorSpace=n==="data"?Nn:Ct,u.magFilter=Gt,u.minFilter=ue,u.generateMipmaps=!0,u.needsUpdate=!0;const h=new zn(f,i,2,Dn,ie);return h.magFilter=h.minFilter=Kn,h.needsUpdate=!0,{tiles:u,map:h,frame:t}}const ei=P({width:N().int().positive(),height:N().int().positive(),revision:N().int().nonnegative(),rgba:U(Uint8Array).optional(),rgbaBase64:R().optional(),colorspace:H(["sRGB","data"]).optional(),tiles:D(P({number:N().int().min(1001),width:N().int().positive(),height:N().int().positive(),rgba:U(Uint8Array).optional(),rgbaBase64:R().optional()}).strict()).optional()}).strict(),ai=P({revision:N().int().nonnegative(),encoded:U(Uint8Array).optional(),encodedBase64:R().optional(),mime:H(["image/png","image/jpeg"]),colorspace:H(["sRGB","data"]).optional()}).strict(),Fe=kt([ei,ai]),Xn=P({image:P({name:R(),revision:N().int().nonnegative()}).strict(),extension:H(["REPEAT","EXTEND","MIRROR","CLIP"]).default("REPEAT"),uv:R(),tint:L([F,F,F]).optional()}).strict(),ri=P({name:R(),color:L([F,F,F,F]),roughness:F,metallic:F,transmission:F,ior:F,physical:ml.optional(),normal_texture:Xn.optional(),normal_strength:F.default(1),normal_space:H(["TANGENT","OBJECT"]).default("TANGENT"),normal_directx:Z().default(!1),texture:Xn.optional(),roughness_texture:Xn.optional(),emission:P({color:L([F,F,F]),strength:F}).strict().optional(),graph:jr.optional(),viewport:P({color:L([F,F,F,F]),roughness:F,metallic:F}).strict().optional()}).strict(),li=P({session:R(),revision:N().int().nonnegative(),volumes:xt(R(),Te).default({}),lights:xt(R(),Tr).default({}),world:Ir.nullable().default(null),meshes:xt(R(),Jl),materials:xt(R(),ri),images:xt(R(),Fe).default({}),objects:D(P({id:R(),name:R(),type:H(["MESH","CURVE","SURFACE","FONT","META","ARMATURE","LATTICE","VOLUME","EMPTY","CAMERA","LIGHT","SPEAKER","GREASEPENCIL","POINTCLOUD","LIGHT_PROBE"]),mesh:R().nullable(),volume:R().nullable().optional(),light:R().nullable().optional(),materials:D(R().nullable()),matrix:D(L([F,F,F,F])).length(4),visible:Z(),render_visible:Z().default(!0),selected:Z(),parent:R().nullable(),texspace:L([L([F,F,F]),L([F,F,F])]).optional(),default_color:R().optional()}).strict()),active:R().nullable(),mode:R(),cameras:xt(R(),xt(R(),me())).default({}),warnings:D(R()).default([]),updated:D(R()).default([]),frame:N().int().default(0),armatures:xt(R(),Sa).default({}),weights:xl.nullable().default(null),cursor:Tl.optional(),camera_view:P({scene_camera:R().nullable(),view_layer_cameras:D(R()),aspect:N().finite().positive()}).optional(),light_distances:xt(R(),L([N().finite(),N().finite()])).default({}),empties:xt(R(),Nl).default({}),view:P({location:L([N(),N(),N()]),rotation:L([N(),N(),N(),N()]),distance:N().finite(),perspective:H(["PERSP","ORTHO","CAMERA"]),lens:N().finite().positive().default(50),shading:H(["WIREFRAME","SOLID","MATERIAL","RENDERED"]).optional()}).nullable().optional(),subject:P({frame:N().int(),body:R(),markers:D(L([N().int(),R()]))}).optional(),units:P({system:H(["NONE","METRIC","IMPERIAL"]),scale_length:N().finite()}).optional()}).strict();function ii(o,t){for(let n=0,e=o.length-1;n<o.length&&e>=0;n++,e--){if(o[n][0]===t)return o[n][1];if(n===e)break;if(o[e][0]===t)return o[e][1]}return null}const si={METRIC:[[1e-6,"Micrometers"],[.001,"Millimeters"],[.01,"Centimeters"],[.1,"10 Centimeters"],[1,"Meters"],[10,"10 Meters"],[100,"100 Meters"],[1e3,"Kilometers"]],IMPERIAL:[[254e-7,"Thou"],[.0254,"Inches"],[.3048,"Feet"],[.9144,"Yards"],[20.1168,"Chains"],[201.168,"Furlongs"],[1609.344,"Miles"]]};class Fn{constructor(){this.root=new lt,this.objects=new Map,this.meshes=new Map,this.volumes=new Map,this.materials=new Map,this.lights=new Map,this.lighting=new Rr,this.world=new po,this.armatureOverlay=new $a,this.weightOverlay=new Ol,this.cursorOverlay=new Ml,this.extrasOverlay=new Fl,this.armatureRoot=new lt,this.weightRoot=new lt,this.cursorRoot=new lt,this.cameraExtrasRoot=new lt,this.lightExtrasRoot=new lt,this.emptyExtrasRoot=new lt,this.rendered=!1,this.heldRendered=null,this.worldApplied=null,this.worldKey="null",this.capturing=!1,this.workbench=!1,this.workbenchMaterials=new Map,this.fallback=new mn({color:12172998,roughness:.72}),this.textures=new Map,this.textureNames=new Map,this.roughnessTextureNames=new Map,this.textureSamplers=new _l,this.graphSamplers=new Map,this.photograph=!1,this.graphs=new Map,this.frame=null,this.retiredSessions=new Set,this.geometryBuilds=0,this.submittedMeshes=new Map,this.submitted=null,this.submittedSession=null,this.photographs=[],this.frameListeners=new Set,this.followers=new Set,this.leader=null,this.cameraViewZoom=Cl,this.cameraViewPan=kl,this.mode=null,this.awaitedImages=new Set,this.lookingThrough=null,this.staged=null,this.root.name="Model",this.root.matrixAutoUpdate=!1,this.root.matrix.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),this.root.updateMatrixWorld(!0);for(const[t,n]of[[this.armatureRoot,this.armatureOverlay.group],[this.weightRoot,this.weightOverlay.group],[this.cursorRoot,this.cursorOverlay.group],[this.cameraExtrasRoot,this.extrasOverlay.cameras],[this.lightExtrasRoot,this.extrasOverlay.lights],[this.emptyExtrasRoot,this.extrasOverlay.empties]])t.matrixAutoUpdate=!1,t.matrix.copy(this.root.matrix),t.add(n),t.updateMatrixWorld(!0);this.armatureRoot.name="BlenderBones",this.weightRoot.name="BlenderWeights",this.cursorRoot.name="Blender3DCursor",this.cameraExtrasRoot.name="BlenderCameraExtras";for(const t of[this.cameraExtrasRoot,this.lightExtrasRoot,this.emptyExtrasRoot])t.userData.volterPickable=!0;this.lightExtrasRoot.name="BlenderLightExtras",this.emptyExtrasRoot.name="BlenderEmptyExtras"}compiledGraph(t){const n=JSON.stringify(t);let e=this.graphs.get(n);return e||(e=nl(t),this.graphs.size>256&&this.graphs.clear(),this.graphs.set(n,e)),e}mirrorPose(t){let n=null;for(const[r,i]of this.objects)if(i===t){n=r;break}if(n===null)return;const e=this.leader?[this.leader,...this.leader.followers]:[...this.followers];let a=!1;for(const r of e){if(r===this)continue;const i=r.objects.get(n);i!==void 0&&(i.matrix.copy(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),a=!0)}a&&Ot()}subscribeFrames(t){return this.frameListeners.add(t),()=>{this.frameListeners.delete(t)}}onChange(t){const n=this.subscribeFrames(t),e=Aa(t);return()=>{n(),e()}}blenderObjectName(t){for(const[n,e]of this.objects)if(e===t)return this.frame?.objects.find(a=>a.id===n)?.name??null;return null}noteSavedShading(t){this.frame?.view&&(this.frame.view.shading=t)}savedView(){const t=this.frame?.view;if(!t)return null;const[n,e,a,r]=t.rotation,i=new Tt(e,a,r,n),f=new x(...t.location).applyMatrix4(this.root.matrix),u=h=>h.applyQuaternion(i).applyMatrix4(this.root.matrix).normalize();return{target:f.toArray(),direction:u(new x(0,0,1)).toArray(),up:u(new x(0,1,0)).toArray(),distance:t.distance,projection:t.perspective==="ORTHO"?"orthographic":"perspective",lens:t.lens,drawMode:t.shading?ql[t.shading]:null}}cameraViewCamera(){const t=this.frame,n=t?.camera_view;return!t||!n?null:n.scene_camera!==null&&t.cameras[n.scene_camera]?n.scene_camera:t.active!==null&&t.cameras[t.active]?t.active:n.view_layer_cameras.find(e=>t.cameras[e])??null}blenderPose(t,n){const e=new tt().copy(this.root.matrix).invert(),a=new tt().compose(new x(...t),new Tt(...n),new x(1,1,1)).premultiply(e),r=new x,i=new Tt;return a.decompose(r,i,new x),{location:r.toArray(),rotation:[i.w,i.x,i.y,i.z]}}cameraView(t,n,e,a){const r=this.frame,i=Qo.safeParse(r?.cameras[t]);return!r?.camera_view||!i.success?null:$l(i.data,this.root.matrix,n,e,a,r.camera_view.aspect)}subjectLine(t){const n=this.frame?.subject;if(n===void 0)return null;const e=t??n.frame,a=ii(n.markers,e);return`(${e})${n.body}${a===null?"":` <${a}>`}`}gridUnitName(t){const n=this.frame?.units;if(n===void 0||n.system==="NONE")return null;const e=si[n.system],a=6*t,r=1/(n.scale_length||1);return(e.find(([f])=>f*r>a)??e[e.length-1])[1]}blenderSelection(){const t=this.frame;return t===null?{selected:[],active:null}:{selected:t.objects.filter(n=>n.selected).map(n=>n.name),active:t.active}}setStageMode(t){this.mode=t}stageMode(){return this.mode}objectForBlenderName(t){const n=this.frame?.objects.find(e=>e.name===t);return n===void 0?null:this.objects.get(n.id)??null}replacePresentedObject(t,n){for(const[e,a]of this.objects)if(a===t){const r=t.parent,i=[...t.children];t.removeFromParent();for(const f of i)n.add(f);r?.add(n),this.objects.set(e,n);return}}studioLights(){return this.lighting.group}overlayGroups(){return[{kind:"skeletons",object:this.armatureRoot},{kind:"weights",object:this.weightRoot},{kind:"cursor",object:this.cursorRoot},{kind:"cameras",object:this.cameraExtrasRoot},{kind:"lights",object:this.lightExtrasRoot},{kind:"empties",object:this.emptyExtrasRoot}]}placeCursor(t,n,e){const a=new Set(this.objects.values()),r=this.cursorOverlay.placementAt(t,n,e,this.root,i=>a.has(i));return r!==null&&(this.cursorOverlay.show(r),Ot()),r}holdRendered(t){t!==this.heldRendered&&(this.heldRendered=t,!this.capturing&&this.report(t===null?this.applyRendered(!1):this.applyRendered(!0,t())))}refreshRendered(){if(this.heldRendered===null||this.capturing)return;const t=this.heldRendered();this.worldKeyFor(t)!==this.worldApplied&&this.report(this.applyRendered(!0,t))}worldKeyFor(t){const e=t.isOrthographicCamera?t.getWorldDirection(new x).toArray().map(a=>a.toFixed(1)).join(","):"";return`${t.uuid}:${e}:${this.worldKey}`}report(t){t.then(Ot,n=>console.error(`Rendered shading could not be applied: ${n instanceof Error?n.message:String(n)}`))}setWorkbench(t){t!==this.workbench&&(this.workbench=t,this.applyWorkbench(),Ot())}applyWorkbench(){const t=this.workbench&&!this.rendered,n=new Set;for(const e of this.frame?.objects??[]){if(e.mesh===null||e.volume)continue;const a=this.objects.get(e.id);if(!a?.isMesh)continue;const i=(e.materials.length?e.materials:[null]).map(f=>{const u=f===null?this.fallback:this.materials.get(f)??this.fallback;return t?this.workbenchFor(f,u.side,n):u});a.material=e.materials.length?i:i[0]}for(const[e,a]of this.workbenchMaterials)n.has(e)||(a.dispose(),this.workbenchMaterials.delete(e))}workbenchFor(t,n,e){const a=(t!==null?this.frame?.materials[t]?.viewport:void 0)??Ll,r=`${a.color.join(",")}|${a.roughness}|${a.metallic}|${n}`;e.add(r);let i=this.workbenchMaterials.get(r);return i||(i=Hl(a,n),this.workbenchMaterials.set(r,i)),i}renderedHeld(){return this.heldRendered!==null}async setRendered(t,n){return this.capturing=t,!t&&this.heldRendered!==null?this.applyRendered(!0,this.heldRendered()):this.applyRendered(t,n)}async applyRendered(t,n){const e=(t?Go(this.frame?.world)?.extinction:null)??new x;for(const r of[...this.materials.values(),this.fallback])hl(r,e);this.rendered=t,this.lighting.setRendered(t);const a=t&&n?this.worldKeyFor(n):null;t?(this.capturing||a!==this.worldApplied)&&this.world.apply(this.root,this.frame?.world??null,n):this.world.clear(),this.worldApplied=this.capturing?null:a,this.applyVisibility(),this.applyWorkbench(),this.applyShadows(t,n),t&&(await Pr(),await Promise.all([...this.textures.values()].map(r=>r.ready)),await this.world.ready())}applyShadows(t,n){this.root.updateMatrixWorld(!0);const e=[];for(const u of this.objects.values()){const h=u;if(h.isMesh&&(h.castShadow=t,h.receiveShadow=t,t&&h.visible)){const s=new Mn().setFromObject(h);s.isEmpty()||e.push(s)}}if(!t||!e.length)return;const r=e.reduce((u,h)=>u.union(h),new Mn).getBoundingSphere(new ra),i=n?new la().setFromProjectionMatrix(new tt().multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse)):null,f=i?e.flatMap(u=>Dr(u,i)):[];for(const u of this.lights.values())u.isDirectionalLight&&n?Cr(u,f,e):Mr(u,r.center,r.radius)}applyOverlays(t){const n=i=>{const f=t.objects.find(u=>u.name===i);return f===void 0?null:new tt().set(...f.matrix.flat())},e=[...this.armatureOverlay.apply(t.armatures,n)],a=t.weights?this.objects.get(t.objects.find(i=>i.name===t.weights?.object)?.id??""):void 0,r=this.weightOverlay.apply(t.weights,a??null,t.weights?n(t.weights.object):null);return r!==null&&e.push(r),this.cursorOverlay.apply(t.cursor),this.applyExtras(t),e}setCameraViewShowing(t){this.lookingThrough!==t&&(this.lookingThrough=t,this.frame&&this.applyExtras(this.frame),Ot())}applyExtras(t){const n={};for(const[e,a]of Object.entries(t.cameras)){const r=Qo.safeParse(a);r.success&&(n[e]=r.data)}this.extrasOverlay.apply({lookingThrough:this.lookingThrough,lightDistances:t.light_distances,objects:t.objects.filter(e=>e.visible),active:t.active,cameras:n,lights:t.lights,empties:t.empties,sceneCamera:t.camera_view?.scene_camera??null,renderAspect:t.camera_view?.aspect??1,presented:e=>{const a=t.objects.find(r=>r.name===e);return a?this.objects.get(a.id)??null:null},image:e=>{const a=this.textures.get(e);if(!a)return null;const r=a.texture.image,i=a.width||r?.width||0,f=a.height||r?.height||0;return(i===0||f===0)&&a.ready&&!this.awaitedImages.has(e)&&(this.awaitedImages.add(e),a.ready.then(()=>{this.awaitedImages.delete(e),this.frame&&this.applyExtras(this.frame),Ot()},()=>this.awaitedImages.delete(e))),{texture:a.texture,width:i,height:f}}})}applyVisibility(){for(const t of this.frame?.objects??[]){const n=this.objects.get(t.id);if(n&&(n.visible=this.rendered?t.render_visible:t.visible),!t.light)continue;const e=this.lights.get(t.light);e&&(e.visible=this.rendered&&t.render_visible)}this.armatureOverlay.group.visible=!this.capturing,this.weightOverlay.group.visible=!this.capturing,this.cursorOverlay.group.visible=!this.capturing;for(const t of[this.extrasOverlay.cameras,this.extrasOverlay.lights,this.extrasOverlay.empties])t.visible=!this.capturing}stageFrame(t){if(t.abort||!t.mesh&&!t.image){for(const e of this.staged?.meshes.values()??[])e.geometry.dispose();this.staged=t.abort?null:{session:t.session,revision:t.revision,meshes:new Map,images:new Map};return}const n=this.staged;if(!n||n.session!==t.session||n.revision!==t.revision)throw new Error("Blender frame piece does not belong to the pending revision");if(t.mesh!==void 0){const e=Ie.parse(t.piece);if(n.meshes.has(t.mesh))throw new Error("Duplicate Blender mesh piece");const a=`revision:${e.revision}`;n.meshes.set(t.mesh,{signature:a,geometry:Pn(Io({...e.columns,attributes:e.attributes,activeUv:e.activeUv,renderUv:e.renderUv},a))})}else if(t.image!==void 0){if(n.images.has(t.image))throw new Error("Duplicate Blender image piece");n.images.set(t.image,Fe.parse(t.piece))}}applyFrame(t){const n=this.frame===null?null:{session:this.frame.session,revision:this.frame.revision},e=li.parse(t),a=this.staged;if(a&&(a.session!==e.session||a.revision!==e.revision))throw new Error("Blender frame manifest does not match its staged revision");if(a)for(const[s,l]of a.images)e.images[s]=l;if(this.retiredSessions.has(e.session))throw new Error("The runtime session was replaced; its delayed frame cannot overwrite the active model");if(this.frame?.session===e.session&&e.revision<this.frame.revision)throw new Error("The runtime frame is older than the displayed model");const r=new Set(e.objects.map(s=>s.id));if(r.size!==e.objects.length)throw new Error("Runtime object IDs must be unique");const i=new Map(e.objects.map(s=>[s.id,s]));for(const s of e.objects){if(s.mesh!==null&&!e.meshes[s.mesh])throw new Error(`Missing runtime mesh ${s.mesh}`);if(s.volume&&(!e.volumes[s.volume]||s.mesh!==null))throw new Error(`Invalid runtime volume ${s.volume}`);if(s.light&&(!e.lights[s.light]||s.mesh!==null))throw new Error(`Invalid runtime light ${s.light}`);for(const _ of s.materials)if(_!==null&&!e.materials[_])throw new Error(`Missing runtime material ${_}`);const l=new Set([s.id]);let c=s.parent;for(;c!==null;){if(l.has(c))throw new Error("Runtime parent cycle");l.add(c);const _=i.get(c);if(!_)throw new Error(`Missing runtime parent ${c}`);c=_.parent}}const f=new Map,u=new Map;try{for(const[s,l]of Object.entries(e.volumes)){const c=JSON.stringify(l);this.frame?.session===e.session&&this.volumes.get(s)?.signature===c||u.set(s,{signature:c,mesh:kr(l)})}for(const[s,l]of Object.entries(e.meshes)){if("unchanged"in l){const m=a?.meshes.get(s);if(m){if(m.signature!==`revision:${l.revision}`)throw new Error("Staged Blender mesh revision mismatch");f.set(s,m);continue}const p=this.meshes.get(s)?.signature;if(this.frame?.session===e.session&&p!==void 0&&(p===`revision:${l.revision}`||!p.startsWith("revision:")))continue;throw new Error(p===void 0?`${Mo}: the presenter does not hold runtime mesh ${s} (store ${l.store}, revision ${l.revision})`:`${Mo}: the presenter holds runtime mesh ${s} at ${p}, not revision ${l.revision}`)}const c="hash"in l,_="columns"in l,d=_?`revision:${l.revision}`:c?l.hash:JSON.stringify(l);this.frame?.session===e.session&&this.meshes.get(s)?.signature===d||f.set(s,{signature:d,geometry:_?Pn(Io({...l.columns,attributes:l.attributes,activeUv:l.activeUv,renderUv:l.renderUv},d)):c?Pn(l):Qa(l)})}}catch(s){for(const l of f.values())l.geometry.dispose();for(const{mesh:l}of u.values())l.geometry.dispose(),l.material.dispose();throw s}if(a){for(const[s,l]of a.meshes)f.has(s)||l.geometry.dispose();this.staged=null}this.frame?.session!==e.session&&(this.frame&&this.retiredSessions.add(this.frame.session),this.clear());for(const[s,l]of u){const c=this.volumes.get(s)?.mesh;c&&(c.removeFromParent(),c.geometry.dispose(),c.material.dispose()),this.volumes.set(s,l)}for(const[s,l]of f)this.meshes.get(s)?.geometry.dispose(),this.meshes.set(s,l),this.geometryBuilds++;for(const[s,l]of Object.entries(e.images)){const c=this.textures.get(s);if("width"in l){const v=l.rgba??(l.rgbaBase64?to(l.rgbaBase64):void 0);if(!v)throw new Error(`Runtime image ${s} carries no raster`);const g=l.tiles?oi(s,l.tiles,l.colorspace??"sRGB"):void 0;if(c?.udim&&(c.udim.tiles.dispose(),c.udim.map.dispose(),delete c.udim),c&&c.width===l.width&&c.height===l.height){const w=c.texture.image;if(w.data){w.data.set(v),c.texture.needsUpdate=!0,c.revision=l.revision,g&&(c.udim=g);continue}}c?.texture.dispose(),this.textures.set(s,{texture:ni(v,l.width,l.height,l.colorspace??"sRGB"),width:l.width,height:l.height,revision:l.revision,...g?{udim:g}:{}});continue}const _=l.encoded??(l.encodedBase64?to(l.encodedBase64):void 0);if(!_)throw new Error(`Runtime image ${s} carries no bytes`);c?.texture.dispose(),c?.udim?.tiles.dispose(),c?.udim?.map.dispose();const d=l.colorspace??"sRGB",{texture:m,ready:p}=ti(_,l.mime);m.colorSpace=d==="data"?Nn:Ct,this.textures.set(s,{texture:m,ready:p,width:0,height:0,revision:l.revision,encoded:{bytes:_.slice(),mime:l.mime,colorspace:d}})}for(const[s,l]of Object.entries(e.materials)){const c=this.materials.get(s)??new mn;c.name=l.name;const _=l.texture?.tint;l.texture!==void 0?c.color.setRGB(_?.[0]??1,_?.[1]??1,_?.[2]??1,pt):c.color.setRGB(l.color[0],l.color[1],l.color[2],pt),c.opacity=l.color[3];const d=c.opacity<1||l.graph!==void 0&&Br(l.graph);c.transparent!==d&&(c.transparent=d,c.needsUpdate=!0),c.roughness=l.roughness,c.metalness=l.metallic,c.transmission=l.transmission,c.ior=l.ior,go(c,l.physical,{map:l.texture?.extension==="CLIP",roughness:l.roughness_texture?.extension==="CLIP",normal:l.normal_texture?.extension==="CLIP"});const m=l.normal_texture?.image.name;if(m===void 0)c.normalMap&&(this.textureSamplers.delete(`${s}:normal`),c.normalMap=null,c.needsUpdate=!0);else{const y=this.textures.get(m);if(!y)throw new Error(`${en}: missing normal image ${m}`);const S=this.textureSamplers.get(`${s}:normal`,y.texture,l.normal_texture.extension,y.ready,l.normal_texture.uv);c.normalMap!==S&&(c.normalMap=S,c.needsUpdate=!0);const T=l.normal_space==="OBJECT"?ia:sa;c.normalMapType!==T&&(c.normalMapType=T,c.needsUpdate=!0),c.normalScale.set(l.normal_strength,l.normal_strength*(l.normal_directx?-1:1))}l.emission?(c.emissive.setRGB(l.emission.color[0],l.emission.color[1],l.emission.color[2],pt),c.emissiveIntensity=l.emission.strength):(c.emissive.setRGB(0,0,0),c.emissiveIntensity=1);const p=l.roughness_texture?.image.name??null;if(p===null)this.roughnessTextureNames.has(s)&&(this.textureSamplers.delete(`${s}:roughness`),c.roughnessMap=null,this.roughnessTextureNames.delete(s),c.needsUpdate=!0);else{const y=this.textures.get(p);if(!y)throw new Error(`${en}: the presenter does not hold runtime image ${p} (revision ${l.roughness_texture.image.revision})`);const S=this.textureSamplers.get(`${s}:roughness`,y.texture,l.roughness_texture.extension,y.ready,l.roughness_texture.uv);c.roughnessMap!==S&&(c.roughnessMap=S,this.roughnessTextureNames.set(s,p),c.needsUpdate=!0)}const v=l.texture?.image.name??null;if(v===null)this.textureNames.has(s)&&(this.textureSamplers.delete(`${s}:color`),c.map=null,this.textureNames.delete(s),c.needsUpdate=!0);else{const y=this.textures.get(v);if(!y)throw new Error(`${en}: the presenter does not hold runtime image ${v} (revision ${l.texture.image.revision})`);const S=this.textureSamplers.get(`${s}:color`,y.texture,l.texture.extension,y.ready,l.texture.uv);c.map!==S&&(c.map=S,this.textureNames.set(s,v),c.needsUpdate=!0)}const g=l.graph?this.compiledGraph(l.graph):null,w=new Set;el(c,g,y=>{const S=this.textures.get(y.name);if(!S)throw new Error(`${en}: the presenter does not hold runtime image ${y.name} (revision ${y.revision})`);if(y.tiled){if(!S.udim)throw new Error(`${en}: runtime image ${y.name} arrived without its UDIM tiles`);return S.udim}const T=`${s}:graph:${y.node}`;w.add(T);const A=this.textureSamplers.get(T,S.texture,y.extension,S.ready),O=y.closest?Kn:Gt,M=y.closest?Kn:y.mipmap?ue:Gt;return(A.magFilter!==O||A.minFilter!==M)&&(A.magFilter=O,A.minFilter=M,A.needsUpdate=!0),A},this.photograph);for(const y of this.graphSamplers.get(s)??[])w.has(y)||this.textureSamplers.delete(y);this.graphSamplers.set(s,w),this.materials.set(s,c)}for(const s of e.objects){let l=this.objects.get(s.id);const c=s.volume?this.volumes.get(s.volume).mesh:null;if((!l||(c?l!==c:!!l.isMesh!=(s.mesh!==null)))&&(l?.removeFromParent(),l=c??(s.mesh!==null?new Rt(this.meshes.get(s.mesh).geometry,this.fallback):new re),this.objects.set(s.id,l)),l.name=s.name,s.type==="CAMERA"||s.type==="LIGHT"||s.type==="EMPTY"?l.userData.volterOwnOverlay=!0:delete l.userData.volterOwnOverlay,l.matrixAutoUpdate=!1,l.matrix.set(...s.matrix.flat()),s.parent){const _=new tt().set(...i.get(s.parent).matrix.flat());l.matrix.premultiply(_.invert())}if(l.matrix.decompose(l.position,l.quaternion,l.scale),s.texspace?l.userData.blenderTexspace=s.texspace:delete l.userData.blenderTexspace,s.default_color!==void 0?l.userData.blenderDefaultColor=s.default_color:delete l.userData.blenderDefaultColor,s.mesh!==null){const _=l;_.geometry=this.meshes.get(s.mesh).geometry,_.material=s.materials.length?s.materials.map(d=>d===null?this.fallback:this.materials.get(d)):this.fallback,il(_)}if(s.light){const _=this.lights.get(s.light)??null,d=Er(e.lights[s.light],_);_&&_!==d&&(_.removeFromParent(),_.dispose()),d.parent!==l&&l.add(d),d.userData.volterOwnOverlay=!0,Nr(d,l),this.lights.set(s.light,d)}}for(const s of e.objects){const l=this.objects.get(s.id),c=s.parent===null?this.root:this.objects.get(s.parent);l.parent!==c&&c.add(l)}for(const[s,l]of this.objects)r.has(s)||(l.removeFromParent(),this.objects.delete(s));for(const[s,l]of this.volumes)e.volumes[s]||(l.mesh.geometry.dispose(),l.mesh.material.dispose(),this.volumes.delete(s));for(const[s,l]of this.meshes)e.meshes[s]||(l.geometry.dispose(),this.meshes.delete(s));for(const[s,l]of this.materials)if(!e.materials[s]){for(const c of["normal","roughness","color"])this.textureSamplers.delete(`${s}:${c}`);for(const c of this.graphSamplers.get(s)??[])this.textureSamplers.delete(c);this.graphSamplers.delete(s),l.dispose(),this.materials.delete(s)}for(const[s,l]of this.lights)e.lights[s]||(l.removeFromParent(),l.dispose(),this.lights.delete(s));this.root.updateMatrixWorld(!0),this.frame={...e,meshes:{},volumes:{},images:{}},this.worldKey=JSON.stringify(e.world??null);const h=this.applyOverlays(e);h.length&&(this.frame={...this.frame,warnings:[...this.frame.warnings,...h]}),this.applyVisibility(),this.applyWorkbench(),this.heldRendered!==null&&!this.capturing&&this.report(this.applyRendered(!0,this.heldRendered()));for(const s of[...this.frameListeners])s();for(const s of this.followers)try{s.applyFrame(t)}catch{s.applyFrame(this.fullFrame())}return{...this.inspect(),held:n}}inspect(){return{session:this.frame?.session,revision:this.frame?.revision,active:this.frame?.active,mode:this.frame?.mode,geometryBuilds:this.geometryBuilds,objects:[...this.objects].map(([t,n])=>({id:t,name:n.name,uuid:n.uuid,geometry:n.geometry?.uuid,visible:n.visible}))}}snapshot(){return this.frame}fullFrame(){const t=this.frame;if(!t)throw new Error("Blender capture requires a presented frame");const n=structuredClone({...t,images:{},armatures:{},weights:null});for(const[a,{signature:r,geometry:i}]of this.meshes){const f=s=>{const l=i.getAttribute(s);if(!l)return null;if(!(l instanceof dt))throw new Error(`Blender capture cannot copy interleaved ${s}`);return new Float32Array(l.array)},u=f("position");if(!u)throw new Error(`Blender capture mesh ${a} has no positions`);const h=i.getIndex();n.meshes[a]={hash:r,positions:u,normals:f("normal"),uv:f("uv"),uvLayers:Object.entries(i.userData.blenderUvChannels??{}).map(([s,l])=>{const c=f(`uv${l}`);if(!c)throw new Error(`Blender capture mesh ${a} is missing UV layer ${s}`);return{name:s,data:c}}),orco:i.userData.blenderOrcoFromDoor?f("blenderOrco"):null,attributeLayers:(i.userData.blenderAttributes??[]).map(s=>{const l=f(Xt(s));if(!l)throw new Error(`Blender capture mesh ${a} is missing attribute ${s}`);return{name:s,data:l}}),indices:h?new Uint32Array(h.array):Uint32Array.from({length:u.length/3},(s,l)=>l),groups:i.groups.map(s=>({start:s.start,count:s.count,materialIndex:s.materialIndex??0}))}}for(const[a,{signature:r}]of this.volumes)n.volumes[a]=Te.parse(JSON.parse(r));const e=new Set(Object.values(n.materials).flatMap(a=>[a.texture?.image.name,a.roughness_texture?.image.name,a.normal_texture?.image.name,...Object.values(a.graph?.nodes??{}).map(r=>r.props.image?.name)].filter(r=>r!==void 0)));for(const a of e){const r=this.textures.get(a);if(!r)throw new Error(`Blender capture image ${a} is not resident`);if(r.encoded)n.images[a]={revision:r.revision,encoded:r.encoded.bytes.slice(),mime:r.encoded.mime,colorspace:r.encoded.colorspace};else{const i=r.texture.image?.data;if(!(i instanceof Uint8Array))throw new Error(`Blender capture image ${a} has no resident raster`);n.images[a]={revision:r.revision,width:r.width,height:r.height,rgba:i.slice(),colorspace:r.texture.colorSpace===Nn?"data":"sRGB",...r.udim?{tiles:r.udim.frame}:{}}}}return n}follow(){const t=new Fn;this.frame&&t.applyFrame(this.fullFrame()),this.followers.add(t),t.leader=this;let n=!1;return{view:t,dispose:()=>{n||(n=!0,this.followers.delete(t),t.leader=null,t.dispose(),t.root.removeFromParent())}}}captureSnapshot(){const t=this.fullFrame(),n=this.frame,e=this.createWorldVolumePass(),a=new Fn;a.photograph=!0;let r=!1;const i=()=>{r||(r=!0,e?.dispose(),a.dispose(),a.root.removeFromParent())};try{a.applyFrame(t),this.root.updateWorldMatrix(!0,!1),a.root.matrix.copy(this.root.matrixWorld),a.root.updateMatrixWorld(!0)}catch(f){throw i(),f}return{effect:e,root:a.root,session:n.session,revision:n.revision,prepare:f=>{if(r)throw new Error("Blender capture snapshot is disposed");return a.setRendered(!0,f)},dispose:i}}createWorldVolumePass(){const t=Go(this.frame?.world);return t?new gl(t):void 0}recordPresentation(t){if(typeof t!="object"||t===null)return;const n=t,e=n.meshes;if(typeof e!="object"||e===null)return;const a=typeof n.session=="string"?n.session:null;a!==this.submittedSession&&(this.submittedMeshes.clear(),this.photographs.length=0,this.submittedSession=a);const r=e;for(const[i,f]of Object.entries(r))typeof f=="object"&&f!==null&&!("unchanged"in f)&&this.submittedMeshes.set(i,f);for(const i of[...this.submittedMeshes.keys()])i in r||this.submittedMeshes.delete(i);this.submitted={...n,meshes:Object.fromEntries(this.submittedMeshes)}}recordPhotograph(t){this.photographs.push(t)}observations(){return{presentation:this.submitted,photographs:this.photographs}}clear(){for(const t of this.staged?.meshes.values()??[])t.geometry.dispose();this.staged=null;for(const t of this.lights.values())t.removeFromParent(),t.dispose();this.lights.clear();for(const t of this.objects.values())t.removeFromParent();for(const t of this.meshes.values())t.geometry.dispose();for(const t of this.materials.values())t.dispose();for(const{mesh:t}of this.volumes.values())t.geometry.dispose(),t.material.dispose();for(const{texture:t,udim:n}of this.textures.values())t.dispose(),n?.tiles.dispose(),n?.map.dispose();this.textures.clear(),this.textureNames.clear(),this.roughnessTextureNames.clear(),this.textureSamplers.clear(),this.volumes.clear(),this.objects.clear(),this.meshes.clear(),this.materials.clear()}dispose(){this.clear(),this.fallback.dispose(),this.lighting.dispose(),this.world.dispose(),this.armatureOverlay.dispose(),this.weightOverlay.dispose(),this.cursorOverlay.dispose(),this.extrasOverlay.dispose();for(const t of this.workbenchMaterials.values())t.dispose();this.workbenchMaterials.clear(),this.frame=null,this.retiredSessions.clear(),this.submittedMeshes.clear(),this.submitted=null,this.submittedSession=null,this.photographs.length=0}}const vi=new Fn;function ze(o){const t=atob(o),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Yn(o){const t=ze(o);return new Float32Array(t.buffer,t.byteOffset,t.byteLength>>2)}function fi(o){const t=ze(o);return new Uint16Array(t.buffer,t.byteOffset,t.byteLength>>1)}function ci(o){return new tt().set(...o.flat())}function te(o,t){return[o.object,o.mesh,o.armature,o.vertexCount,o.bones.length,t].join("|")}class ui{#n=new Map;#o=null;#a=null;#t=null;#i=null;#e=null;#l=null;#s=new Set;#u=0;#_=[];#r=0;get version(){return this.#u}get engineCalls(){return this.#r}subscribe(t){return this.#s.add(t),()=>this.#s.delete(t)}#f(){this.#u++;for(const t of[...this.#s])t()}state(){const t=this.#t,n=t?.frameStart??1,e=t?.frameEnd??250,a=t?.fps??24;return{frame:this.frame(),start:n,end:e,fps:a,action:t?.action??null,object:t?.object??null,armature:t?.armature??null,bones:[...this.#n.values()].reduce((r,i)=>r+i.bones.length,0),keyframes:t?.keyframes??[],summary:t?.summary??[],clipStart:t?.clipStart??null,clipEnd:t?.clipEnd??null,tracks:t?.tracks.length??0,bound:[...this.#n.keys()],warnings:this.#_,engineCalls:this.#r,blenderFrame:t?.frameCurrent??null}}playhead(){return this.#t?this.frame():null}frame(){const t=this.#t;return!t||!this.#a||t.clipStart===void 0?t?.frameCurrent??1:this.#i!==null?this.#i:t.clipStart+this.#a.time*t.fps}get playable(){return this.#a!==null}async bind(t,n){this.#r++;const e=await n.rig();if(!e)return;const a=[],r=new Set;let i=!1;for(const l of e.rigs){if(!l.object||!l.armature||!l.skinIndexBase64||!l.skinWeightBase64){l.reason&&a.push(l.reason);continue}r.add(l.object);const c=te(l,e.frame);if(this.#n.get(l.object)?.signature===c)continue;const _=this.#d(t,l,e.frame,a);_&&(this.#n.get(l.object)?.skeleton.dispose(),this.#n.set(l.object,_),i=!0)}for(const[l,c]of[...this.#n])r.has(l)||(c.skeleton.dispose(),c.boneRoot.removeFromParent(),this.#n.delete(l),i=!0);this.#r++;const f=await n.clip(),u=this.#t,h=f?.action!==u?.action||f?.tracks.length!==u?.tracks.length||f?.clipStart!==u?.clipStart||f?.clipEnd!==u?.clipEnd;this.#t=f??null,f?.reason&&a.push(f.reason),f&&(h||i)&&this.#h(t,f,a);const s=this.#e?.snapshot().playbackState==="playing";f&&!s&&u?.frameCurrent!==f.frameCurrent&&(this.#c(f.frameCurrent),this.#e&&f.fps>0&&this.#e.seek(f.frameCurrent/f.fps)),this.#_=a,this.#f()}#d(t,n,e,a){const r=t.objectForBlenderName(n.object??""),i=t.objectForBlenderName(n.armature??"");if(!r||!i)return null;const f=r,u=f.geometry;if(!u)return null;const h=u.getAttribute("blenderVertex");if(!h)return a.push(`"${n.object}" cannot be skinned: its presented geometry carries no \`blenderVertex\` attribute, so a per-Blender-vertex weight cannot be expanded onto its drawn vertices.`),null;if(n.vertexCount===0)return null;let s=0;for(let T=0;T<h.count;T++)s=Math.max(s,h.getX(T));if(s>=n.vertexCount)return a.push(`"${n.object}" is not skinned here: its presented geometry references Blender vertex ${s} while the mesh declares ${n.vertexCount}, which is a generative modifier (Subdivision, Mirror, Array…) between the two. Blender's own viewport shows the evaluated result; this presenter shows the exported columns unskinned.`),null;const l=fi(n.skinIndexBase64??""),c=Yn(n.skinWeightBase64??""),_=h.count,d=new Uint16Array(_*4),m=new Float32Array(_*4);for(let T=0;T<_;T++){const A=h.getX(T);for(let O=0;O<4;O++)d[T*4+O]=l[A*4+O]??0,m[T*4+O]=c[A*4+O]??0}u.setAttribute("skinIndex",new _a(d,4)),u.setAttribute("skinWeight",new St(m,4));const p=new lt;p.name=`${n.armature}:bones`;const v=[],g=n.bones.map(T=>ci(T.pose)),w=new Map(n.bones.map((T,A)=>[T.name,A]));n.bones.forEach((T,A)=>{const O=new ma;O.name=T.name,v.push(O);const M=T.parent===null?void 0:w.get(T.parent);(M===void 0?g[A].clone():g[M].clone().invert().multiply(g[A])).decompose(O.position,O.quaternion,O.scale),(M===void 0?p:v[M]).add(O)}),i.add(p);const y=new da(u,f.material);y.name=f.name,y.matrixAutoUpdate=!1,y.matrix.copy(f.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale),y.userData=f.userData,y.frustumCulled=!1,t.replacePresentedObject(f,y),t.root.updateMatrixWorld(!0);const S=new ha(v);return y.bind(S,y.matrixWorld.clone()),n.constrainedBones?.length&&a.push(`Bone constraints on ${n.constrainedBones.join(", ")}: the clip is derived from the F-Curves alone, so those bones play their channels rather than Blender's solved pose.`),n.unmappedGroups?.length&&a.push(`${n.object} carries vertex groups no bone is named for (${n.unmappedGroups.join(", ")}); they weight nothing here, exactly as they deform nothing in Blender.`),{object:n.object??"",armature:n.armature??"",mesh:y,boneRoot:p,bones:v,skeleton:S,frame:e,signature:te(n,e)}}#h(t,n,e){if(this.#o?.stopAllAction(),this.#o=null,this.#a=null,!n.tracks.length||n.clipStart===void 0||n.clipEnd===void 0)return;const a=n.armature?t.objectForBlenderName(n.armature):null;if(!a)return;const r=new Map;for(const l of this.#n.values())if(l.armature===n.armature)for(const c of l.bones)r.set(c.name,c);const i=[],f=new Set;for(const l of n.tracks){const c=r.get(l.bone);if(!c){f.add(l.bone);continue}const _=Yn(l.timeBase64),d=Yn(l.valueBase64),m=`${c.uuid}.${l.property}`;i.push(l.property==="quaternion"?new pa(m,Array.from(_),Array.from(d)):new va(m,Array.from(_),Array.from(d)))}if(f.size&&e.push(`${n.action} animates ${[...f].join(", ")}, which this binding has no bone for.`),!i.length)return;const u=n.duration??(n.clipEnd-n.clipStart)/n.fps,h=new ga(a),s=h.clipAction(new xa(n.action??"action",u,i));s.setLoop(ba,Number.POSITIVE_INFINITY),s.play(),this.#o=h,this.#a=s,this.#c(n.frameCurrent),this.#m()}#c(t){const n=this.#t;if(!n||!this.#o||n.clipStart===void 0||n.clipEnd===void 0)return;const e=Math.min(n.clipEnd,Math.max(n.clipStart,t));this.#i=e;const a=(n.clipEnd-n.clipStart)/n.fps;this.#o.setTime(Math.min(a-1e-4,(e-n.clipStart)/n.fps)),this.#m()}#m(){for(const t of this.#n.values())t.boneRoot.updateMatrixWorld(!0),t.skeleton.update()}get scene(){return this.#t?.scene??null}async writeBookmark(){const t=Math.round(this.frame()),n=this.#t;if(!n)return t;const e=n.scene;return!e||n.frameCurrent===t||(this.#r++,await Ta(`bpy.data.scenes[${JSON.stringify(e)}]`,"frame_current",t,void 0,!1),this.#t={...n,frameCurrent:t},this.#f()),t}get transport(){return this.#e}attachTo(t){this.#l?.(),this.#e=t;const n=t.attach({id:this.#t?.action??"blender-action",label:this.#t?.action??"Action",range:()=>{const i=this.#t,f=i?.fps||24;return{start:(i?.frameStart??1)/f,end:(i?.frameEnd??250)/f,fps:f}},seek:i=>this.seekSeconds(i)}),e=t.onSettled(()=>{this.writeBookmark()}),a=()=>{e(),n(),this.#e===t&&(this.#e=null),this.#l=null};this.#l=a;const r=this.#t;return r&&r.fps>0&&t.seek(r.frameCurrent/r.fps),a}seekSeconds(t){const n=this.#t?.fps||24;this.#c(Math.round(t*n)),this.#f()}keyframes(){return(this.#t?.keyframes??[]).map(t=>t.frame)}dispose(){this.#l?.(),this.#o?.stopAllAction(),this.#o=null,this.#a=null;for(const t of this.#n.values())t.skeleton.dispose(),t.boneRoot.removeFromParent();this.#n.clear()}}const De=new ui;function gi(o){return De.subscribe(o)}function xi(){return De.version}export{De as a,xi as b,vi as c,gi as s};
|