@splinetool/runtime 2.0.3 → 2.0.5
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/build/hana-ui.js +46 -31
- package/build/hana-ui.js.br +0 -0
- package/build/hana-ui.js.gz +0 -0
- package/build/hana-ui.wasm +0 -0
- package/build/hana-ui.wasm.br +0 -0
- package/build/hana-ui.wasm.gz +0 -0
- package/build/runtime-aiAssistant-RMA2DMFU.js +1 -0
- package/build/runtime-aiAssistant-RMA2DMFU.js.br +0 -0
- package/build/runtime-aiAssistant-RMA2DMFU.js.gz +0 -0
- package/build/runtime-apiServices-KA4FEP5Y.js +1 -0
- package/build/runtime-apiServices-KA4FEP5Y.js.br +0 -0
- package/build/runtime-apiServices-KA4FEP5Y.js.gz +0 -0
- package/build/{runtime-audio-Y3GYW4YQ.js → runtime-audio-BQSRM3W2.js} +1 -1
- package/build/runtime-audio-BQSRM3W2.js.br +0 -0
- package/build/runtime-audio-BQSRM3W2.js.gz +0 -0
- package/build/{runtime-chunk-RAAW7WHN.js → runtime-chunk-243VQV5T.js} +1 -1
- package/build/runtime-chunk-243VQV5T.js.br +0 -0
- package/build/runtime-chunk-243VQV5T.js.gz +0 -0
- package/build/{runtime-chunk-W7THORYR.js → runtime-chunk-2657LZHS.js} +1 -1
- package/build/runtime-chunk-2657LZHS.js.br +0 -0
- package/build/runtime-chunk-2657LZHS.js.gz +0 -0
- package/build/{runtime-chunk-Z5OH244S.js → runtime-chunk-5XUI4Z6R.js} +1 -1
- package/build/runtime-chunk-5XUI4Z6R.js.br +0 -0
- package/build/runtime-chunk-5XUI4Z6R.js.gz +0 -0
- package/build/{runtime-chunk-MC3OVJQU.js → runtime-chunk-6WHNEYAL.js} +1 -1
- package/build/runtime-chunk-6WHNEYAL.js.br +0 -0
- package/build/runtime-chunk-6WHNEYAL.js.gz +0 -0
- package/build/{runtime-chunk-D2IFC55F.js → runtime-chunk-CDZQF4NV.js} +1 -1
- package/build/runtime-chunk-CDZQF4NV.js.br +0 -0
- package/build/runtime-chunk-CDZQF4NV.js.gz +0 -0
- package/build/{runtime-chunk-ZHNGVKGZ.js → runtime-chunk-DNWPGXEC.js} +1 -1
- package/build/runtime-chunk-DNWPGXEC.js.br +0 -0
- package/build/runtime-chunk-DNWPGXEC.js.gz +0 -0
- package/build/{runtime-chunk-TQBPVLGB.js → runtime-chunk-DSGSWXCQ.js} +1 -1
- package/build/runtime-chunk-DSGSWXCQ.js.br +0 -0
- package/build/runtime-chunk-DSGSWXCQ.js.gz +0 -0
- package/build/{runtime-chunk-6UQ4Z4JG.js → runtime-chunk-DZOSSY2K.js} +1 -1
- package/build/runtime-chunk-DZOSSY2K.js.br +0 -0
- package/build/runtime-chunk-DZOSSY2K.js.gz +0 -0
- package/build/{runtime-chunk-BCJEHBXX.js → runtime-chunk-EGI7ABC6.js} +1 -1
- package/build/runtime-chunk-EGI7ABC6.js.br +0 -0
- package/build/runtime-chunk-EGI7ABC6.js.gz +0 -0
- package/build/{runtime-chunk-D6NWJJTR.js → runtime-chunk-F7OUYIT6.js} +1 -1
- package/build/runtime-chunk-F7OUYIT6.js.br +0 -0
- package/build/runtime-chunk-F7OUYIT6.js.gz +0 -0
- package/build/{runtime-chunk-4FAMJWEB.js → runtime-chunk-IGBRWWDI.js} +1 -1
- package/build/runtime-chunk-IGBRWWDI.js.br +0 -0
- package/build/runtime-chunk-IGBRWWDI.js.gz +0 -0
- package/build/{runtime-chunk-Y2GFSK5L.js → runtime-chunk-IK4H7UNI.js} +1 -1
- package/build/runtime-chunk-IK4H7UNI.js.br +0 -0
- package/build/runtime-chunk-IK4H7UNI.js.gz +0 -0
- package/build/{runtime-chunk-SQKBNW2G.js → runtime-chunk-J4FFQBNR.js} +1 -1
- package/build/runtime-chunk-J4FFQBNR.js.br +0 -0
- package/build/runtime-chunk-J4FFQBNR.js.gz +0 -0
- package/build/runtime-chunk-LALFWESO.js +1 -0
- package/build/runtime-chunk-LALFWESO.js.br +0 -0
- package/build/runtime-chunk-LALFWESO.js.gz +0 -0
- package/build/{runtime-chunk-PXPQZ7SX.js → runtime-chunk-NIDXMSZY.js} +1 -1
- package/build/runtime-chunk-NIDXMSZY.js.br +0 -0
- package/build/runtime-chunk-NIDXMSZY.js.gz +0 -0
- package/build/{runtime-chunk-U5ACSO5E.js → runtime-chunk-OTAMLWBD.js} +1 -1
- package/build/runtime-chunk-OTAMLWBD.js.br +0 -0
- package/build/runtime-chunk-OTAMLWBD.js.gz +0 -0
- package/build/{runtime-chunk-NGWM5WPD.js → runtime-chunk-P2QJHRIH.js} +1 -1
- package/build/runtime-chunk-P2QJHRIH.js.br +0 -0
- package/build/runtime-chunk-P2QJHRIH.js.gz +0 -0
- package/build/runtime-chunk-PLJ25O2X.js +1 -0
- package/build/runtime-chunk-PLJ25O2X.js.br +0 -0
- package/build/runtime-chunk-PLJ25O2X.js.gz +0 -0
- package/build/runtime-chunk-PRQYD4EW.js +1 -0
- package/build/runtime-chunk-PRQYD4EW.js.br +0 -0
- package/build/runtime-chunk-PRQYD4EW.js.gz +0 -0
- package/build/runtime-chunk-QPB2TL3G.js +1 -0
- package/build/runtime-chunk-QPB2TL3G.js.br +0 -0
- package/build/runtime-chunk-QPB2TL3G.js.gz +0 -0
- package/build/runtime-chunk-QVC5UDJO.js +1 -0
- package/build/runtime-chunk-QVC5UDJO.js.br +0 -0
- package/build/runtime-chunk-QVC5UDJO.js.gz +0 -0
- package/build/{runtime-chunk-MVRGHRTL.js → runtime-chunk-RSPDUS6G.js} +1 -1
- package/build/runtime-chunk-RSPDUS6G.js.br +0 -0
- package/build/runtime-chunk-RSPDUS6G.js.gz +0 -0
- package/build/{runtime-chunk-EXHPAC6T.js → runtime-chunk-RWL6KR5S.js} +1 -1
- package/build/runtime-chunk-RWL6KR5S.js.br +0 -0
- package/build/runtime-chunk-RWL6KR5S.js.gz +0 -0
- package/build/{runtime-chunk-ZULFQKQK.js → runtime-chunk-SXDO5LXF.js} +1 -1
- package/build/runtime-chunk-SXDO5LXF.js.br +0 -0
- package/build/runtime-chunk-SXDO5LXF.js.gz +0 -0
- package/build/{runtime-chunk-Q4H7PFTE.js → runtime-chunk-U6S2BBR7.js} +1 -1
- package/build/runtime-chunk-U6S2BBR7.js.br +0 -0
- package/build/runtime-chunk-U6S2BBR7.js.gz +0 -0
- package/build/{runtime-chunk-G5XH52BM.js → runtime-chunk-V3U2TPGQ.js} +1 -1
- package/build/runtime-chunk-V3U2TPGQ.js.br +0 -0
- package/build/runtime-chunk-V3U2TPGQ.js.gz +0 -0
- package/build/{runtime-chunk-32ZE2X4C.js → runtime-chunk-Y365A3K5.js} +1 -1
- package/build/runtime-chunk-Y365A3K5.js.br +0 -0
- package/build/runtime-chunk-Y365A3K5.js.gz +0 -0
- package/build/runtime-chunk-YWT6AWL4.js +1 -0
- package/build/runtime-chunk-YWT6AWL4.js.br +0 -0
- package/build/runtime-chunk-YWT6AWL4.js.gz +0 -0
- package/build/{runtime-classicRuntime-IFIIFBNS.js → runtime-classicRuntime-BD2WFYXF.js} +1 -1
- package/build/runtime-classicRuntime-BD2WFYXF.js.br +0 -0
- package/build/runtime-classicRuntime-BD2WFYXF.js.gz +0 -0
- package/build/runtime-cloners-ST66KGZH.js +1 -0
- package/build/runtime-cloners-ST66KGZH.js.br +1 -0
- package/build/runtime-cloners-ST66KGZH.js.gz +0 -0
- package/build/{runtime-components-LNJJ3QLB.js → runtime-components-RLXFVT5A.js} +1 -1
- package/build/runtime-components-RLXFVT5A.js.br +0 -0
- package/build/runtime-components-RLXFVT5A.js.gz +0 -0
- package/build/runtime-conditional-DCOFCW5I.js +1 -0
- package/build/runtime-conditional-DCOFCW5I.js.br +0 -0
- package/build/runtime-conditional-DCOFCW5I.js.gz +0 -0
- package/build/{runtime-createDestroy-DWI7C4WO.js → runtime-createDestroy-4PG4ZWLI.js} +1 -1
- package/build/runtime-createDestroy-4PG4ZWLI.js.br +0 -0
- package/build/runtime-createDestroy-4PG4ZWLI.js.gz +0 -0
- package/build/{runtime-dragDrop-46CHKTIE.js → runtime-dragDrop-CTXPZ6OW.js} +1 -1
- package/build/runtime-dragDrop-CTXPZ6OW.js.br +0 -0
- package/build/runtime-dragDrop-CTXPZ6OW.js.gz +0 -0
- package/build/runtime-gameControls-LUALVLF5.js +1 -0
- package/build/runtime-gameControls-LUALVLF5.js.br +0 -0
- package/build/runtime-gameControls-LUALVLF5.js.gz +0 -0
- package/build/runtime-hair-JNRT3G3X.js +1 -0
- package/build/runtime-hair-JNRT3G3X.js.br +1 -0
- package/build/runtime-hair-JNRT3G3X.js.gz +0 -0
- package/build/{runtime-mergeStaticGeometries-O5XKFANJ.js → runtime-mergeStaticGeometries-QDKIDV27.js} +1 -1
- package/build/runtime-mergeStaticGeometries-QDKIDV27.js.br +0 -0
- package/build/runtime-mergeStaticGeometries-QDKIDV27.js.gz +0 -0
- package/build/{runtime-miscActions-IRARI4E6.js → runtime-miscActions-FCQTXDEH.js} +1 -1
- package/build/runtime-miscActions-FCQTXDEH.js.br +0 -0
- package/build/runtime-miscActions-FCQTXDEH.js.gz +0 -0
- package/build/runtime-mouseHover-GP5TEPLG.js +1 -0
- package/build/runtime-mouseHover-GP5TEPLG.js.br +0 -0
- package/build/runtime-mouseHover-GP5TEPLG.js.gz +0 -0
- package/build/{runtime-particles-INK4LA4P.js → runtime-particles-VMYZZSAL.js} +1 -1
- package/build/runtime-particles-VMYZZSAL.js.br +0 -0
- package/build/runtime-particles-VMYZZSAL.js.gz +0 -0
- package/build/{runtime-paths-LRTW3RNL.js → runtime-paths-TGU7JOOY.js} +1 -1
- package/build/runtime-paths-TGU7JOOY.js.br +0 -0
- package/build/runtime-paths-TGU7JOOY.js.gz +0 -0
- package/build/runtime-resize-O3Y2XS2Q.js +1 -0
- package/build/runtime-resize-O3Y2XS2Q.js.br +0 -0
- package/build/runtime-resize-O3Y2XS2Q.js.gz +0 -0
- package/build/{runtime-sceneTransition-X7RGRC3W.js → runtime-sceneTransition-4DDTFDJN.js} +1 -1
- package/build/runtime-sceneTransition-4DDTFDJN.js.br +0 -0
- package/build/runtime-sceneTransition-4DDTFDJN.js.gz +0 -0
- package/build/{runtime-scroll-VK7XXJPE.js → runtime-scroll-ET44H7JC.js} +1 -1
- package/build/runtime-scroll-ET44H7JC.js.br +0 -0
- package/build/runtime-scroll-ET44H7JC.js.gz +0 -0
- package/build/runtime-shapeBlends-3FCSH6PN.js +1 -0
- package/build/runtime-shapeBlends-3FCSH6PN.js.br +2 -0
- package/build/runtime-shapeBlends-3FCSH6PN.js.gz +0 -0
- package/build/{runtime-text-KC66JGLC.js → runtime-text-UQIUL5X6.js} +1 -1
- package/build/runtime-text-UQIUL5X6.js.br +0 -0
- package/build/runtime-text-UQIUL5X6.js.gz +0 -0
- package/build/{runtime-textInputs-Y7CREUMS.js → runtime-textInputs-E72WPYQU.js} +1 -1
- package/build/runtime-textInputs-E72WPYQU.js.br +0 -0
- package/build/runtime-textInputs-E72WPYQU.js.gz +0 -0
- package/build/runtime-timeline-2VAMFUOE.js +1 -0
- package/build/runtime-timeline-2VAMFUOE.js.br +0 -0
- package/build/runtime-timeline-2VAMFUOE.js.gz +0 -0
- package/build/{runtime-tracking-FA45SGZJ.js → runtime-tracking-E72XXGER.js} +1 -1
- package/build/runtime-tracking-E72XXGER.js.br +0 -0
- package/build/runtime-tracking-E72XXGER.js.gz +0 -0
- package/build/{runtime-transitions-A7UP5OMB.js → runtime-transitions-JOHZRI2L.js} +1 -1
- package/build/runtime-transitions-JOHZRI2L.js.br +0 -0
- package/build/runtime-transitions-JOHZRI2L.js.gz +0 -0
- package/build/runtime-ui2d-PJKKRE32.js +1 -0
- package/build/runtime-ui2d-PJKKRE32.js.br +0 -0
- package/build/runtime-ui2d-PJKKRE32.js.gz +0 -0
- package/build/{runtime-variables-U36KPJ5V.js → runtime-variables-Q6Q2JCGI.js} +1 -1
- package/build/runtime-variables-Q6Q2JCGI.js.br +0 -0
- package/build/runtime-variables-Q6Q2JCGI.js.gz +0 -0
- package/build/{runtime-vectorShapes-MA6PKTF5.js → runtime-vectorShapes-FKC6EQWI.js} +1 -1
- package/build/runtime-vectorShapes-FKC6EQWI.js.br +0 -0
- package/build/runtime-vectorShapes-FKC6EQWI.js.gz +0 -0
- package/build/{runtime-video-7GHZOZRJ.js → runtime-video-DUDXGADJ.js} +1 -1
- package/build/runtime-video-DUDXGADJ.js.br +0 -0
- package/build/runtime-video-DUDXGADJ.js.gz +0 -0
- package/build/runtime-webgpu-TBHSGHNI.js +1 -0
- package/build/runtime-webgpu-TBHSGHNI.js.br +0 -0
- package/build/runtime-webgpu-TBHSGHNI.js.gz +0 -0
- package/build/runtime.cjs +325 -325
- package/build/runtime.js +1 -1
- package/build/runtime.js.br +0 -0
- package/build/runtime.js.gz +0 -0
- package/build/runtime.standalone.js +1 -1
- package/build/runtime.standalone.js.br +0 -0
- package/build/runtime.standalone.js.gz +0 -0
- package/build/runtime.standalone.webgl.js +1 -1
- package/build/runtime.standalone.webgl.js.br +0 -0
- package/build/runtime.standalone.webgl.js.gz +0 -0
- package/build/runtime.standalone.webgpu.js +1 -1
- package/build/runtime.standalone.webgpu.js.br +0 -0
- package/build/runtime.standalone.webgpu.js.gz +0 -0
- package/build/runtime.standalone.webgpu.micro.js +1 -1
- package/build/runtime.standalone.webgpu.micro.js.br +0 -0
- package/build/runtime.standalone.webgpu.micro.js.gz +0 -0
- package/build/runtime.standalone.webgpu.min.js +1 -1
- package/build/runtime.standalone.webgpu.min.js.br +0 -0
- package/build/runtime.standalone.webgpu.min.js.gz +0 -0
- package/package.json +1 -1
- package/build/runtime-aiAssistant-XJVJ7TQB.js +0 -1
- package/build/runtime-aiAssistant-XJVJ7TQB.js.br +0 -0
- package/build/runtime-aiAssistant-XJVJ7TQB.js.gz +0 -0
- package/build/runtime-apiServices-KAO5SQJZ.js +0 -1
- package/build/runtime-apiServices-KAO5SQJZ.js.br +0 -0
- package/build/runtime-apiServices-KAO5SQJZ.js.gz +0 -0
- package/build/runtime-audio-Y3GYW4YQ.js.br +0 -0
- package/build/runtime-audio-Y3GYW4YQ.js.gz +0 -0
- package/build/runtime-chunk-32ZE2X4C.js.br +0 -0
- package/build/runtime-chunk-32ZE2X4C.js.gz +0 -0
- package/build/runtime-chunk-4FAMJWEB.js.br +0 -0
- package/build/runtime-chunk-4FAMJWEB.js.gz +0 -0
- package/build/runtime-chunk-6UQ4Z4JG.js.br +0 -0
- package/build/runtime-chunk-6UQ4Z4JG.js.gz +0 -0
- package/build/runtime-chunk-BCJEHBXX.js.br +0 -0
- package/build/runtime-chunk-BCJEHBXX.js.gz +0 -0
- package/build/runtime-chunk-D2IFC55F.js.br +0 -0
- package/build/runtime-chunk-D2IFC55F.js.gz +0 -0
- package/build/runtime-chunk-D6NWJJTR.js.br +0 -0
- package/build/runtime-chunk-D6NWJJTR.js.gz +0 -0
- package/build/runtime-chunk-EXHPAC6T.js.br +0 -0
- package/build/runtime-chunk-EXHPAC6T.js.gz +0 -0
- package/build/runtime-chunk-G5XH52BM.js.br +0 -0
- package/build/runtime-chunk-G5XH52BM.js.gz +0 -0
- package/build/runtime-chunk-MC3OVJQU.js.br +0 -0
- package/build/runtime-chunk-MC3OVJQU.js.gz +0 -0
- package/build/runtime-chunk-MM75L5X4.js +0 -1
- package/build/runtime-chunk-MM75L5X4.js.br +0 -0
- package/build/runtime-chunk-MM75L5X4.js.gz +0 -0
- package/build/runtime-chunk-MVRGHRTL.js.br +0 -0
- package/build/runtime-chunk-MVRGHRTL.js.gz +0 -0
- package/build/runtime-chunk-NGWM5WPD.js.br +0 -0
- package/build/runtime-chunk-NGWM5WPD.js.gz +0 -0
- package/build/runtime-chunk-NRJDJMQZ.js +0 -1
- package/build/runtime-chunk-NRJDJMQZ.js.br +0 -0
- package/build/runtime-chunk-NRJDJMQZ.js.gz +0 -0
- package/build/runtime-chunk-PXPQZ7SX.js.br +0 -0
- package/build/runtime-chunk-PXPQZ7SX.js.gz +0 -0
- package/build/runtime-chunk-Q4H7PFTE.js.br +0 -0
- package/build/runtime-chunk-Q4H7PFTE.js.gz +0 -0
- package/build/runtime-chunk-QFGFABLH.js +0 -1
- package/build/runtime-chunk-QFGFABLH.js.br +0 -0
- package/build/runtime-chunk-QFGFABLH.js.gz +0 -0
- package/build/runtime-chunk-RAAW7WHN.js.br +0 -0
- package/build/runtime-chunk-RAAW7WHN.js.gz +0 -0
- package/build/runtime-chunk-SQKBNW2G.js.br +0 -0
- package/build/runtime-chunk-SQKBNW2G.js.gz +0 -0
- package/build/runtime-chunk-TQBPVLGB.js.br +0 -0
- package/build/runtime-chunk-TQBPVLGB.js.gz +0 -0
- package/build/runtime-chunk-U5ACSO5E.js.br +0 -0
- package/build/runtime-chunk-U5ACSO5E.js.gz +0 -0
- package/build/runtime-chunk-W7THORYR.js.br +0 -0
- package/build/runtime-chunk-W7THORYR.js.gz +0 -0
- package/build/runtime-chunk-XTKPUDRE.js +0 -1
- package/build/runtime-chunk-XTKPUDRE.js.br +0 -0
- package/build/runtime-chunk-XTKPUDRE.js.gz +0 -0
- package/build/runtime-chunk-XV2ZLRKD.js +0 -1
- package/build/runtime-chunk-XV2ZLRKD.js.br +0 -0
- package/build/runtime-chunk-XV2ZLRKD.js.gz +0 -0
- package/build/runtime-chunk-Y2GFSK5L.js.br +0 -0
- package/build/runtime-chunk-Y2GFSK5L.js.gz +0 -0
- package/build/runtime-chunk-Z5OH244S.js.br +0 -0
- package/build/runtime-chunk-Z5OH244S.js.gz +0 -0
- package/build/runtime-chunk-ZHNGVKGZ.js.br +0 -0
- package/build/runtime-chunk-ZHNGVKGZ.js.gz +0 -0
- package/build/runtime-chunk-ZLW3UWOA.js +0 -1
- package/build/runtime-chunk-ZLW3UWOA.js.br +0 -0
- package/build/runtime-chunk-ZLW3UWOA.js.gz +0 -0
- package/build/runtime-chunk-ZULFQKQK.js.br +0 -0
- package/build/runtime-chunk-ZULFQKQK.js.gz +0 -0
- package/build/runtime-classicRuntime-IFIIFBNS.js.br +0 -0
- package/build/runtime-classicRuntime-IFIIFBNS.js.gz +0 -0
- package/build/runtime-cloners-WEF7XIM4.js +0 -1
- package/build/runtime-cloners-WEF7XIM4.js.br +0 -2
- package/build/runtime-cloners-WEF7XIM4.js.gz +0 -0
- package/build/runtime-components-LNJJ3QLB.js.br +0 -0
- package/build/runtime-components-LNJJ3QLB.js.gz +0 -0
- package/build/runtime-conditional-3A423CXW.js +0 -1
- package/build/runtime-conditional-3A423CXW.js.br +0 -0
- package/build/runtime-conditional-3A423CXW.js.gz +0 -0
- package/build/runtime-createDestroy-DWI7C4WO.js.br +0 -0
- package/build/runtime-createDestroy-DWI7C4WO.js.gz +0 -0
- package/build/runtime-dragDrop-46CHKTIE.js.br +0 -0
- package/build/runtime-dragDrop-46CHKTIE.js.gz +0 -0
- package/build/runtime-gameControls-YA2YP4UH.js +0 -1
- package/build/runtime-gameControls-YA2YP4UH.js.br +0 -0
- package/build/runtime-gameControls-YA2YP4UH.js.gz +0 -0
- package/build/runtime-hair-XVWLJEZC.js +0 -1
- package/build/runtime-hair-XVWLJEZC.js.br +0 -3
- package/build/runtime-hair-XVWLJEZC.js.gz +0 -0
- package/build/runtime-mergeStaticGeometries-O5XKFANJ.js.br +0 -0
- package/build/runtime-mergeStaticGeometries-O5XKFANJ.js.gz +0 -0
- package/build/runtime-miscActions-IRARI4E6.js.br +0 -0
- package/build/runtime-miscActions-IRARI4E6.js.gz +0 -0
- package/build/runtime-mouseHover-3LVJJIFG.js +0 -1
- package/build/runtime-mouseHover-3LVJJIFG.js.br +0 -0
- package/build/runtime-mouseHover-3LVJJIFG.js.gz +0 -0
- package/build/runtime-particles-INK4LA4P.js.br +0 -0
- package/build/runtime-particles-INK4LA4P.js.gz +0 -0
- package/build/runtime-paths-LRTW3RNL.js.br +0 -0
- package/build/runtime-paths-LRTW3RNL.js.gz +0 -0
- package/build/runtime-resize-4OIVU46M.js +0 -1
- package/build/runtime-resize-4OIVU46M.js.br +0 -0
- package/build/runtime-resize-4OIVU46M.js.gz +0 -0
- package/build/runtime-sceneTransition-X7RGRC3W.js.br +0 -0
- package/build/runtime-sceneTransition-X7RGRC3W.js.gz +0 -0
- package/build/runtime-scroll-VK7XXJPE.js.br +0 -0
- package/build/runtime-scroll-VK7XXJPE.js.gz +0 -0
- package/build/runtime-shapeBlends-VLITROES.js +0 -1
- package/build/runtime-shapeBlends-VLITROES.js.br +0 -2
- package/build/runtime-shapeBlends-VLITROES.js.gz +0 -0
- package/build/runtime-text-KC66JGLC.js.br +0 -0
- package/build/runtime-text-KC66JGLC.js.gz +0 -0
- package/build/runtime-textInputs-Y7CREUMS.js.br +0 -0
- package/build/runtime-textInputs-Y7CREUMS.js.gz +0 -0
- package/build/runtime-timeline-KTMKRAZU.js +0 -1
- package/build/runtime-timeline-KTMKRAZU.js.br +0 -0
- package/build/runtime-timeline-KTMKRAZU.js.gz +0 -0
- package/build/runtime-tracking-FA45SGZJ.js.br +0 -0
- package/build/runtime-tracking-FA45SGZJ.js.gz +0 -0
- package/build/runtime-transitions-A7UP5OMB.js.br +0 -0
- package/build/runtime-transitions-A7UP5OMB.js.gz +0 -0
- package/build/runtime-ui2d-XLYMHVMW.js +0 -1
- package/build/runtime-ui2d-XLYMHVMW.js.br +0 -0
- package/build/runtime-ui2d-XLYMHVMW.js.gz +0 -0
- package/build/runtime-variables-U36KPJ5V.js.br +0 -0
- package/build/runtime-variables-U36KPJ5V.js.gz +0 -0
- package/build/runtime-vectorShapes-MA6PKTF5.js.br +0 -0
- package/build/runtime-vectorShapes-MA6PKTF5.js.gz +0 -0
- package/build/runtime-video-7GHZOZRJ.js.br +0 -0
- package/build/runtime-video-7GHZOZRJ.js.gz +0 -0
- package/build/runtime-webgpu-JPQ4VPBY.js +0 -1
- package/build/runtime-webgpu-JPQ4VPBY.js.br +0 -0
- package/build/runtime-webgpu-JPQ4VPBY.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,d as t,e as i}from"./runtime-chunk-GFTBNL2W.js";import{b as n,e as s}from"./runtime-chunk-MM75L5X4.js";import{b as r,v as o}from"./runtime-chunk-ZLW3UWOA.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-Z5OH244S.js";import{a,d as l}from"./runtime-chunk-TZCHGFVF.js";import{T as u,l as c}from"./runtime-chunk-OW6T4XFV.js";import{Aa as h,Cc as d,Dc as m,Ec as p,Ed as v,Fc as f,Gd as y,Ic as S,Ja as g,Jc as x,Pc as z,Rc as b,Vd as T,Wc as E,Wd as R,Xd as P,bd as _,dd as C,kd as A,ld as D,nd as w,pd as F,qd as I,te as V}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var N=new E,U=new f,O=new m,L=new m,M=new m,Q=class{constructor(e){this.geometry=e.geometry,this.randomFunction=Math.random,this.indexAttribute=this.geometry.index,this.positionAttribute=this.geometry.getAttribute("position"),this.normalAttribute=this.geometry.getAttribute("normal"),this.colorAttribute=this.geometry.getAttribute("color"),this.uvAttribute=this.geometry.getAttribute("uv"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){let e=this.indexAttribute,t=this.positionAttribute,i=this.weightAttribute,n=e?e.count/3:t.count/3,s=new Float32Array(n);for(let r=0;r<n;r++){let n=1,o=3*r,a=3*r+1,l=3*r+2;e&&(o=e.getX(o),a=e.getX(a),l=e.getX(l)),i&&(n=i.getX(o)+i.getX(a)+i.getX(l)),N.a.fromBufferAttribute(t,o),N.b.fromBufferAttribute(t,a),N.c.fromBufferAttribute(t,l),n*=N.getArea(),s[r]=n}let r=new Float32Array(n),o=0;for(let e=0;e<n;e++)o+=s[e],r[e]=o;return this.distribution=r,this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,i,n){let s=this._sampleFaceIndex();return this._sampleFace(s,e,t,i,n)}_sampleFaceIndex(){let e=this.distribution[this.distribution.length-1];return this._binarySearch(this.randomFunction()*e)}_binarySearch(e){let t=this.distribution,i=0,n=t.length-1,s=-1;for(;i<=n;){let r=Math.ceil((i+n)/2);if(0===r||t[r-1]<=e&&t[r]>e){s=r;break}e<t[r]?n=r-1:i=r+1}return s}_sampleFace(e,t,i,n,s){let r=this.randomFunction(),o=this.randomFunction();r+o>1&&(r=1-r,o=1-o);let a=this.indexAttribute,l=3*e,u=3*e+1,c=3*e+2;return a&&(l=a.getX(l),u=a.getX(u),c=a.getX(c)),N.a.fromBufferAttribute(this.positionAttribute,l),N.b.fromBufferAttribute(this.positionAttribute,u),N.c.fromBufferAttribute(this.positionAttribute,c),t.set(0,0,0).addScaledVector(N.a,r).addScaledVector(N.b,o).addScaledVector(N.c,1-(r+o)),void 0!==i&&(void 0!==this.normalAttribute?(N.a.fromBufferAttribute(this.normalAttribute,l),N.b.fromBufferAttribute(this.normalAttribute,u),N.c.fromBufferAttribute(this.normalAttribute,c),i.set(0,0,0).addScaledVector(N.a,r).addScaledVector(N.b,o).addScaledVector(N.c,1-(r+o)).normalize()):N.getNormal(i)),void 0!==n&&void 0!==this.colorAttribute&&(N.a.fromBufferAttribute(this.colorAttribute,l),N.b.fromBufferAttribute(this.colorAttribute,u),N.c.fromBufferAttribute(this.colorAttribute,c),U.set(0,0,0).addScaledVector(N.a,r).addScaledVector(N.b,o).addScaledVector(N.c,1-(r+o)),n.r=U.x,n.g=U.y,n.b=U.z),void 0!==s&&void 0!==this.uvAttribute&&(O.fromBufferAttribute(this.uvAttribute,l),L.fromBufferAttribute(this.uvAttribute,u),M.fromBufferAttribute(this.uvAttribute,c),s.set(0,0).addScaledVector(O,r).addScaledVector(L,o).addScaledVector(M,1-(r+o))),this}};function B(e,t){let i=e,n=new Float32Array(4*t*t);for(let e=0;e<t*t;e++)n[4*e]=i[3*e],n[4*e+1]=i[3*e+1],n[4*e+2]=i[3*e+2],n[4*e+3]=0;let s=new w(n,t,t,g,h);return s.needsUpdate=!0,s}var W=class{constructor(e,t,i,n){this.type="SphereEmitterShape",this.targetMesh=void 0,this.size=e,this.type=i,this.textureSize=function(e){let t=Math.ceil(Math.sqrt(e));return Math.max(t,1)}(t),this.targetMesh="BufferGeometry"===n?.geometry.type||"Mesh"===n?.type&&n&&n.geometry.hasAttribute("position")&&n.geometry.hasAttribute("normal")?n:this.getMesh(i,1);let{positions:s,dataTexture:r,dataTextureNormals:o}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(i,1));this.positionsTexture=r,this.positionsAttribute=s,this.directionsTexture=o}createPositions(e,t){let{positions:i,normals:n}=function(e,t){let i=new D(e.geometry,e.material),n=[],s=[],r=new f,o=new f;null!==i.geometry.index&&(i.geometry=i.geometry.toNonIndexed());let a=new Q(i).build();for(let e=0;e<t;e++)a.sample(r,o),n.push(r.x,r.y,r.z),s.push(o.x,o.y,o.z);return{positions:new Float32Array(n),normals:new Float32Array(s)}}(t,e*e);return{dataTexture:B(i,e),positions:i,dataTextureNormals:B(n,e)}}getMesh(e,t){let i=null;switch(e){case"SphereEmitterShape":i=new R(.5*t,32,32);break;case"TorusEmitterShape":i=new P(.5*t,.3,15,40);break;case"ConeEmitterShape":i=new y(t,t,15);break;case"BoxEmitterShape":i=new v(t,t,t);break;case"PlaneEmitterShape":i=new T(t,t),i.rotateX(-Math.PI/2);break;default:i=new R(t,32,32)}return new D(i,new A({color:16711680}))}applyToShader(e,t){this.size=(new f).fromArray(t.size.map(e=>"number"==typeof e?e:1)),e.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function k(e){let t={...e},i=u.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let n={...i.shape,...t.shape},s={...i.renderMaterial,...t.renderMaterial};return{...i,...t,shape:n,renderMaterial:s}}var q=class extends b{constructor(n,s){super(),this.type="ParticleEmitter",this.debugMode=!1,this.worldSpace=!0,this.rootObject=null,this.gpuCompute=null,this.positionSimRT=null,this.velocitySimRT=null,this.emissionRateSimRT=null,this.emitterShape=void 0,this.isEmitting=!1,this.hasBeenReset=!1,this.emittedParticlesAmount=0,this.lastEmitTime=0,this.globalTime=0,this.targetFPS=60,this.previousRatio=1,this.lerpFactor=.4,this.particlesAmount=0,this.noiseStrength=0,this.noiseScale=0,this.isBillboardBased=!0,this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1},this.textureLoader=new V,this.textureRequestId=0,this.currentWorldPosition=new f,this.systemQuaternion=new p,this.worldGravity=new f(0,0,0),this.directionAxis=new f(0,0,0),this.colliderV3=new f(0,0,0),this.colliderQuaternion=new p(0,0,0,1),this.matrixAutoUpdate=!0,this.renderer=n,this.system=s,this.shared=s.context.shared;let r=s.data;this.material=i(n)?e()?.createMaterial(r.renderMaterial,s.context)??t().createMaterial(r.renderMaterial,s.context):t().createMaterial(r.renderMaterial,s.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:r.renderMaterial.color},uColor2:{value:r.renderMaterial.color2},uPosition:{value:new f(0,0,0)},uEmissionData:{value:new f(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new f(0,0,0)},uWorldQuaternion:{value:new x(0,0,0,1)},uRandScaleFactor:{value:r.randomScale??0},uRandRotationFactor:{value:r.randomRotation??0},uRotation:{value:r.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:r.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,r.renderMaterial.texture),this.init(r)}setTexture(e,t){let i=t.data,n=++this.textureRequestId;if("string"==typeof t){let i=this.shared.image(t),s=()=>{if(n!==this.textureRequestId)return;let t=new S(i.img);t.needsUpdate=!0,e.uTexture.value=t};return void(i.loaded?s():i.loadPromise.then(s))}if("string"!=typeof i){let t=new Image;t.onload=()=>{if(n!==this.textureRequestId)return;let i=new S(t);i.needsUpdate=!0,e.uTexture.value=i};let s=new Blob([i],{type:"image/*"}),r=URL.createObjectURL(s);t.src=r}}updateGeometryAttributes(e,t){let n=function(e){let t=new Float32Array(e*e*2);for(let i=0;i<e;i++)for(let n=0;n<e;n++){let s=i*e+n;t[2*s+0]=i/(e-1),t[2*s+1]=n/(e-1)}return t}(t);if(!this.emitterShape?.positionsAttribute)return;let s=new F(n,2);e.geometry.setAttribute("ref",s),i(this.renderer)&&e.geometry.setAttribute("particleRef",s)}applyWorldSpace(){if(!(this.system.started&&this.worldSpace&&this.positionSimRT&&this.velocitySimRT))return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset)return void this.reset();this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let i=1e3/t,n=this.targetFPS/i,s=this.previousRatio+(n-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=s,this.previousRatio=s;let r=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=r,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],t=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&t&&this.init(k({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),0===this.colliderV3.y&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=e.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;"size"===t[2]&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),"sizeEnd"===t[2]&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let i=(e,t)=>{let i=[...this.system.data.shape.size];i[e]=t,this.updateParticleState({shape:{...this.system.data.shape,size:i}})};"shape_size_0"===t[2]&&i(0,e),"shape_size_1"===t[2]&&i(1,e),"shape_size_2"===t[2]&&i(2,e),"speed"===t[2]&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/10),"gravity"===t[2]&&this.worldGravity.set(0,e/100,0),"noiseStrength"===t[2]&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),"noiseScale"===t[2]&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),"direction_x"===t[2]&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),"direction_y"===t[2]&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),"direction_z"===t[2]&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(this.positionSimRT&&this.velocitySimRT){if(this.shouldReInitGPUCompute(e)&&this.init(k(this.system.data)),void 0!==e.life&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),void 0!==e.speed&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/10),void 0!==e.collisionBounce&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),void 0!==e.noiseStrength&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),void 0!==e.noiseScale&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),void 0!==e.noiseSeed&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),void 0!==e.randomMass&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),void 0!==e.renderMaterial?.size){let t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}if(void 0!==e.renderMaterial?.spriteRotation&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),void 0!==e.shape){let t=e.shape.size??this.system.data.shape.size,i=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],n={...k(this.system.data).shape,size:i};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,n)}if(void 0!==e.gravity&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),void 0!==e.direction){let t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}void 0!==e.randomRotation&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),void 0!==e.randomScale&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(void 0!==e.forceIntensity&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),void 0!==e.forceDambing&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*d.DEG2RAD,Number(e[1])*d.DEG2RAD,Number(e[2])*d.DEG2RAD],i=new z(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:i,colliderEntityId:n,shape:s,emitTimeDuration:r,emitTimeCycle:o,life:a,directionMode:l,noiseType:u}=e;return void 0!==t||void 0!==i||n||null===n||void 0!==o||void 0!==s||void 0!==a||void 0!==r||void 0!==l||void 0!==u}init(n){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:n.birthRatePerSec,particleMaxLifeTime:n.life,loopDuration:"infinity"===n.emitTimeCycle?0:n.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn("The maximum number of particles is limited to 100000."),this.particlesAmount=1e5),this.emitterShape=this.createShape(n.shape,this.particlesAmount);let s=setInterval(()=>{if(!this.emitterShape)return;let e=this.emitterShape.positionsTexture.source.data.data;e&&!isNaN(e[0])?clearInterval(s):this.init(n)},100);if(!this.emitterShape)return;let r=this.updateSimulationDefinition(n),o=i(this.renderer)?e().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer,this.simFeaturesDefinition):t().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),a=o.addVariable("uCurrentPosition",r+"\n\n\n\nuniform sampler2D uOriginalPosition;\nuniform float uTime;\nuniform float uSpeed; \nuniform vec3 uWorldOffset; \nuniform vec4 uWorldQuaternion;\nuniform float uMaxLifeTime;\nuniform vec3 uEmitterSize;\nuniform float uFPSRatio; \n\nfloat random (vec2 st) {\n return fract(sin(dot(st.xy,\n vec2(12.9898,78.233)))*\n 43758.5453123);\n}\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n}\n\nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n }\n \n\nvoid main() {\n vec2 vUv = gl_FragCoord.xy / resolution.xy;\n vec3 position = texture2D( uCurrentPosition, vUv ).xyz;\n float currentLife = texture2D( uCurrentPosition, vUv ).w; \n float isSpawning = texture2D( uCurrentEmissionRate, vUv ).r; \n float isActive = texture2D( uCurrentEmissionRate, vUv ).g; \n float timeStart = texture2D( uCurrentEmissionRate, vUv ).b; \n vec3 originalPosition = ((texture2D( uOriginalPosition, vUv ).xyz) * uEmitterSize);\n vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;\n float collisionFlag = texture2D( uCurrentVelocity, vUv ).w; \n float lifeTime = uMaxLifeTime;\n\n \n \n float isColliding = step(0.5, collisionFlag); \n float bounceOffset = 3.0 * isColliding; \n vec3 collisionAdjustedVelocity = velocity * (1.0 + bounceOffset);\n\n \n vec3 fpsVelocity = velocity * min(uFPSRatio, 5.0);\n position += mix(fpsVelocity, collisionAdjustedVelocity, isColliding);\n\n \n \n \n vec3 newPosition = applyQuaternionToVector(uWorldQuaternion, originalPosition) + uWorldOffset;\n originalPosition = mix(originalPosition, newPosition, isSpawning);\n position = mix(position, originalPosition, isSpawning);;\n timeStart = mix(timeStart, uTime, isSpawning);\n\n \n float timeLeft = max(lifeTime - (uTime - timeStart), 0.0);\n float life_Normalize = timeLeft / lifeTime;\n\n \n vec4 activeColor = vec4(position, life_Normalize);\n \n gl_FragColor = mix(vec4(0.0), activeColor, isActive);\n\n}\n",this.emitterShape.positionsTexture),l=o.addVariable("uCurrentVelocity",r+"\n\n\n\nuniform sampler2D uOriginalPosition;\nuniform sampler2D uDirections; \nuniform vec3 uDirectionsAxis;\nuniform vec4 uWorldQuaternion;\nuniform vec3 uGravity; \nuniform float uNoiseStrength; \nuniform float uNoiseScale; \nuniform float uNoiseSeed; \nuniform float particleSize;\nuniform float uSpeed; \nuniform float uRandomMassFactor;\n\n\nuniform vec3 uColliderPos; \nuniform vec3 uColliderSize; \nuniform vec4 uColliderQuaternion; \nuniform vec4 uColliderQuaternionInvert; \nuniform float uBounce; \nuniform float uForceDamping;\nuniform float uForceIntensity;\n\n\n\n\n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n \n vec4 mod289(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n \n vec4 permute(vec4 x) {\n return mod289(((x*34.0)+1.0)*x);\n }\n \n vec4 taylorInvSqrt(vec4 r)\n {\n return 1.79284291400159 - 0.85373472095314 * r;\n }\n \n vec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\n float snoise(vec3 v)\n {\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; \n vec3 x3 = x0 - D.yyy; \n \n \n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n \n \n \n float n_ = 0.142857142857; \n vec3 ns = n_ * D.wyz - D.xzx;\n \n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); \n \n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); \n \n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n \n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n \n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n \n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n \n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n \n \n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n \n \n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n }\n \n vec3 snoiseVec3( vec3 x ){\n \n float s = snoise(vec3( x ));\n float s1 = snoise(vec3( x.y - 19.1 , x.z + 33.4 , x.x + 47.2 ));\n float s2 = snoise(vec3( x.z + 74.2 , x.x - 124.5 , x.y + 99.4 ));\n vec3 c = vec3( s , s1 , s2 );\n return c;\n \n }\n \n \n vec3 curlNoise( vec3 p, float seed){\n p += seed;\n const float e = .1;\n vec3 dx = vec3( e , 0.0 , 0.0 );\n vec3 dy = vec3( 0.0 , e , 0.0 );\n vec3 dz = vec3( 0.0 , 0.0 , e );\n \n vec3 p_x0 = snoiseVec3( p - dx );\n vec3 p_x1 = snoiseVec3( p + dx );\n vec3 p_y0 = snoiseVec3( p - dy );\n vec3 p_y1 = snoiseVec3( p + dy );\n vec3 p_z0 = snoiseVec3( p - dz );\n vec3 p_z1 = snoiseVec3( p + dz );\n \n float x = p_y1.z - p_y0.z - p_z1.y + p_z0.y;\n float y = p_z1.x - p_z0.x - p_x1.z + p_x0.z;\n float z = p_x1.y - p_x0.y - p_y1.x + p_y0.x;\n \n const float divisor = 1.0 / ( 2.0 * e );\n return normalize( vec3( x , y , z ) * divisor );\n \n }\n\n\n\nfloat cnoise(vec3 P)\n{\n vec3 Pi0 = floor(P); \n vec3 Pi1 = Pi0 + vec3(1.0); \n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); \n vec3 Pf1 = Pf0 - vec3(1.0); \n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); \n return 2.2 * n_xyz;\n}\n\n\nvec3 fbm_vec3(vec3 p, float frequency, float offset)\n{\n return vec3(\n cnoise((p+vec3(offset))*frequency),\n cnoise((p+vec3(offset+20.0))*frequency),\n cnoise((p+vec3(offset-30.0))*frequency)\n );\n}\n\n\nfloat rand(vec2 co){\n return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);\n}\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n } \nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n}\n\nvec4 conjugate(vec4 q) {\n return vec4(q.w, -q.x, -q.y, -q.z);\n}\n\n\nvec3 ellipsoidNormal(vec3 p, vec3 radii) {\n return normalize(p / (radii * radii));\n}\n\nfloat friction = .3;\n\nvoid main() {\n vec2 vUv = gl_FragCoord.xy / resolution.xy;\n vec3 position = texture2D( uCurrentPosition, vUv ).xyz;\n vec3 originalPosition = texture2D( uOriginalPosition, vUv ).xyz;\n float timeLeft = texture2D( uCurrentPosition, vUv ).w;\n vec3 directions = texture2D( uDirections, vUv ).xyz; \n vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;\n float mass = rand(originalPosition.xy) * 0.5 + 0.5;\n float isSpawning = texture2D( uCurrentEmissionRate, vUv ).x; \n float isActive = texture2D( uCurrentEmissionRate, vUv ).y; \n float collisionFlag =texture2D( uCurrentVelocity, vUv ).w; \n\n \n mass = (1.0 - (uRandomMassFactor * mass));\n \n if (isActive == 1.0) {\n \n \n \n #ifdef USE_CURL_NOISE\n if (uNoiseScale > 0.0 ) {\n velocity = curlNoise(position * uNoiseScale * .002, uNoiseSeed) * ( uNoiseStrength + 1.0) * .05 * uSpeed;\n }\n \n if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) {\n velocity += curlNoise( position, uNoiseSeed) * uNoiseStrength * 0.05 * uSpeed;\n }\n #endif\n \n #ifdef USE_SIMPLEX_NOISE\n if (uNoiseScale > 0.0 ) {\n velocity = vec3(snoise(position * uNoiseScale * .001) * ( uNoiseStrength + 1.0) * .1);\n velocity *= uSpeed;\n }\n \n if (uNoiseStrength > 0.0 && uNoiseScale == 0.0) {\n velocity += vec3(snoise(position * uNoiseStrength * .001) * .05 * uSpeed);\n }\n #endif\n \n #ifdef USE_FBM_NOISE\n if (uNoiseScale > 0.0 ) {\n velocity = fbm_vec3(position * uNoiseScale * .001, ( uNoiseStrength + 1.0), uNoiseSeed);\n velocity *= uSpeed;\n }\n \n if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) { \n velocity += fbm_vec3(position * uNoiseStrength * .001, ( uNoiseStrength + 1.0), uNoiseSeed) * .1 * uSpeed;\n }\n #endif\n\n \n \n #ifdef USE_COLLIDER\n float restitution = max(uBounce * 2., .01); \n \n \n #ifdef USE_SPHERE_COLLIDER \n \n vec3 radii = uColliderSize;\n \n vec3 relPos = position - uColliderPos;\n \n relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); \n \n vec3 scaledPos = relPos / radii;\n \n float dist = length(scaledPos); \n \n \n if (dist <= 1. + particleSize / length(radii) && collisionFlag == 0.0) {\n \n vec3 adjustedPos = scaledPos * (1.0 + particleSize / length(radii)); \n \n vec3 normal = ellipsoidNormal(adjustedPos, radii);\n \n normal = applyQuaternionToVector(uColliderQuaternion, normal);\n \n velocity = reflect(velocity, normal) * restitution;\n\n collisionFlag = 1.0;\n } else {\n collisionFlag = 0.0;\n }\n #endif\n\n \n \n #ifdef USE_BOX_COLLIDER\n \n vec3 boxHalfSize = uColliderSize / 2.0;\n \n vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); \n \n vec3 localDistance = abs(localPos) - boxHalfSize;\n float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z)); \n\n \n if (distToSurface <= particleSize * 0.5 && collisionFlag == 0.0) { \n \n vec3 normal;\n if (localDistance.x > localDistance.y && localDistance.x > localDistance.z) {\n normal = vec3(sign(localPos.x), 0.0, 0.0);\n } else if (localDistance.y > localDistance.z) {\n normal = vec3(0.0, sign(localPos.y), 0.0);\n } else {\n normal = vec3(0.0, 0.0, sign(localPos.z));\n } \n \n normal = applyQuaternionToVector(uColliderQuaternion, normal); \n \n velocity = reflect(velocity, normal) * restitution;\n \n collisionFlag = 1.0;\n } else {\n collisionFlag = 0.0;\n }\n #endif \n #endif \n \n\n \n \n #ifdef USE_ATTRACTOR\n\n #ifdef USE_SPHERE_COLLIDER \n \n vec3 radii = uColliderSize;\n \n vec3 relPos = position - uColliderPos;\n \n relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); \n \n vec3 scaledPos = relPos / radii;\n \n float distToSurface = length(scaledPos); \n float insideCheck = 1.0;\n\n #endif\n\n\n #ifdef USE_BOX_COLLIDER\n \n vec3 boxHalfSize = uColliderSize / 2.0;\n \n vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); \n vec3 localDistance = abs(localPos) - boxHalfSize;\n float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));\n float insideCheck = particleSize;\n #endif \n \n \n #ifdef USE_FORCE_LOCAL_SPACE\n if (distToSurface <= insideCheck ) { \n \n #ifdef USE_SPHERE_COLLIDER \n float attractorStrength = (1.0 - distToSurface ) * uForceIntensity; \n #endif\n\n #ifdef USE_BOX_COLLIDER\n float attractorStrength = max((1.0 - insideCheck / distToSurface), 0.) * uForceIntensity; \n #endif\n\n float attractorDamping = uForceDamping; \n \n \n vec3 attractorRadii = uColliderSize;\n \n vec3 relPos = position - uColliderPos;\n \n relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); \n \n vec3 scaledPos = relPos / attractorRadii;\n\n \n float attractorRadius = length(scaledPos);\n \n vec3 relativePosition = position - uColliderPos;\n \n vec3 attractorForce = normalize(relativePosition) * attractorStrength;\n \n velocity -= attractorForce;\n \n velocity *= attractorDamping;\n }\n #else \n \n vec3 relativePosition = position - uColliderPos;\n \n vec3 attractorForce = normalize(relativePosition) * uForceIntensity;\n \n velocity -= attractorForce;\n \n velocity *= uForceDamping;\n #endif \n #endif \n \n \n \n #ifdef USE_VORTEX\n \n vec3 boxHalfSize = uColliderSize / 2.0;\n \n vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); \n vec3 localDistance = abs(localPos) - boxHalfSize;\n float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));\n\n \n if (distToSurface <= particleSize) {\n float vortexStrength = uForceIntensity;\n vec3 localTopCenter = vec3(0.0, 0., 0.0);\n\n \n vec3 vortexCenter = uColliderPos + applyQuaternionToVector(uColliderQuaternion, localTopCenter);\n \n vec3 vortexVector = vortexCenter - position;\n\n \n \n vec3 upVector = vec3(0.0, 1.0, 0.01);\n vec3 rotationAxis = cross(upVector, applyQuaternionToVector(uColliderQuaternion, vortexVector));\n rotationAxis = normalize(rotationAxis);\n\n \n float rotationSpeed = length(vortexVector * vortexStrength * 3.0) ; \n\n vec3 rotationVelocity = rotationAxis * rotationSpeed;\n \n velocity = rotationVelocity * 0.005 ;\n\n \n \n \n vec3 originDirection = applyQuaternionToVector(uWorldQuaternion, directions);\n velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);\n }\n #endif \n\n } \n \n\n \n \n \n #ifdef USE_NORMALS\n velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, directions) * uSpeed, isSpawning);\n #else\n velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, uDirectionsAxis) * uSpeed, isSpawning); \n #endif\n \n \n velocity += applyForce(uGravity, mass * .5) * (1.0 - collisionFlag);\n\n gl_FragColor = vec4(velocity, collisionFlag);\n}\n",this.emitterShape.directionsTexture),u=o.addVariable("uCurrentEmissionRate","\n\n\n\n\nuniform sampler2D uIndex; \nuniform float uLastIndexEmitted; \nuniform float uParticlesToEmit; \nuniform float uTime;\n\nvoid main() {\n vec2 vUv = gl_FragCoord.xy / resolution.xy;\n float particleIndex = texture(uIndex, vUv).x;\n float timeLeft = texture2D( uCurrentPosition, vUv ).w;\n float isActive = texture2D( uCurrentEmissionRate, vUv ).g; \n float timeStart = texture2D( uCurrentEmissionRate, vUv ).b;\n\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n float emitLowerBound = step(uLastIndexEmitted, particleIndex);\n float emitUpperBound = step(particleIndex, uLastIndexEmitted + uParticlesToEmit - 1.0);\n float emitParticle = emitLowerBound * emitUpperBound; \n\n \n timeStart = mix(timeStart, uTime, emitParticle);\n gl_FragColor = vec4(emitParticle, mix(isActive, 1.0, emitParticle), timeStart, 1.0);\n\n\n}\n",function(e){let t=new Float32Array(4*e*e);for(let i=0;i<e*e;i++)t[4*i]=0,t[4*i+1]=0,t[4*i+2]=0,t[4*i+3]=0;let i=new w(t,e,e,g,h);return i.needsUpdate=!0,i}(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,l,u]),o.setVariableDependencies(l,[a,l,u]),o.setVariableDependencies(u,[a,l,u]);let c=function({size:e}){let t=new Float32Array(4*e*e);for(let i=0;i<e*e;i++)t[4*i]=i,t[4*i+1]=0,t[4*i+2]=0,t[4*i+3]=0;let i=new w(t,e,e,g,h);return i.needsUpdate=!0,i}({size:this.emitterShape.textureSize}),d={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new f(0,0,0)},uWorldQuaternion:{value:new x(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:n.life},uEmitterSize:{value:new f(Number(this.shared.getVariable(n.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(n.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(n.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=d;let m=this.getDirectionFromVariable(n.direction);this.directionAxis=this.getDirectionAxis(m),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(n.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(n.noiseScale,[this.uuid,"particles","noiseScale"]));let p=n.colliderEntityId&&this.system.getColliderData(n.colliderEntityId),v={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new x(0,0,0,1)},uColliderPos:{value:new f(0,0,0)},uColliderSize:{value:new f(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new x(0,0,0,1)},uColliderQuaternionInvert:{value:new x(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:n.noiseSeed},uRandomMassFactor:{value:n.randomMass},uBounce:{value:n.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(n.speed,[this.uuid,"particles","speed"]))/10}};l.material.uniforms=v;let y={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};u.material.uniforms=y;let S=[Number(this.shared.getVariable(n.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(n.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(n.shape.size[2],[this.uuid,"particles","shape_size_2"]))],z={...k(this.system.data).shape,size:S};this.emitterShape.applyToShader(a.material.uniforms,z),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=l,this.emissionRateSimRT=u,this.material.uniforms.uPosition.value=o.getCurrentRenderTarget(a)?.texture,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){return[Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]))]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let t=this.system.getColliderData(e.colliderEntityId);switch(t?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0}let i=t?.colliderType;"sphere"===i&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),"box"===i&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),"helper"===t?.forceRange&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}"normals"===e.directionMode&&(this.simFeaturesDefinition.USE_NORMALS=!0),"curl"===e.noiseType&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),"simplex"===e.noiseType&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),"fbm"===e.noiseType&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[e,i]of Object.entries(this.simFeaturesDefinition))i&&(t+=`#define ${e}\n`);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let i=new f(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if("MeshEmitterShape"===e.type){let n=null;return this.system.context.scene.traverseEntity(t=>{t.uuid===e.fromMeshId&&(n=t)}),n?new W(i,t,e.type,n):new W(i,t,"SphereEmitterShape")}return new W(i,t,e.type)}createPrimaryEmitter(e){let t=e*e,i=new I(new T(1,1,1),this.material,t);return this.updateGeometryAttributes(i,e),this.material.needsUpdate=!0,i.onBeforeRender=()=>{this.applyWorldSpace()},i}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:i=0}){return Math.ceil(e*(t+i))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let i=e-this.lastEmitTime,n=1/t;if(i>=n){let t=Math.max(1,Math.floor(i/n));return this.lastEmitTime=e,this.emittedParticlesAmount+t>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=t,t}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(k(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}},X=class extends o{constructor(e,t,i){super(e,t),this.type="ParticleSystem",this.isParticleSystem=!0,this.geometry=new C,this.actualTime=0,this.currentLoopTime=0,this.started=!1,this.stopped=!1,this.timeoutId=void 0,this.isFrozen=!1,this.isIdle=!0,this.emitter=null,this.colliderEntities=[],this.renderer=null,this.isPreWarm=!1,this._hasOnAfterRenderBeenCalled=!1,this.onAfterRender=e=>{e.warmupInFlight||this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))},this.context=i,this.data={...t,...k(t)},this.geometry.setAttribute("position",new _([],3)),this.material=new A({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new q(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t="one_time"===this.data.emitTimeCycle;if(("loop"===this.data.emitTimeCycle||t)&&this.currentLoopTime>1e3*this.data.emitTimeDuration&&(this.stopped||(this.stop(),t||this.start(1e3*this.data.emitTimeDelay))),this.emitter&&this.started){let t=this.actualTime/1e3;this.emitter.update(t,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(t=>t.identity===e);return t?t.data:null}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),r(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...c.drop(e,1).props}}),r(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...c.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(this.emitter){if(void 0!==e.colliderEntityId&&null!==e.colliderEntityId){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}null===e.colliderEntityId&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){this.currentLoopTime=0,e?this.timeoutId=window.setTimeout(()=>{this.start(0)},e):(this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3),this._requestRender())}froze(){this.isFrozen=!0,this._requestRender()}unFroze(){this.isFrozen=!1,this._requestRender()}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId),this._requestRender()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset(),this._requestRender()}_requestRender(){this.context.shared.requestRender()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}},j=class{constructor(e,t,i,n){this.data=e,this.page=t,this.shared=i,this.condition=n,this.delay=0,this.emission=e.emission,void 0!==e.delay&&(this.delay=e.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},e):this.particleSystem.start()}stop(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},e):this.particleSystem.stop()}freeze(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},e):this.particleSystem.froze()}unFreeze(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},e):this.particleSystem.unFroze()}reset(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},e):this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze()}}dispatchBasic(){if(!1===s(this.shared,this.condition)||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay)}}dispatchConditional(){if(!1===s(this.shared,this.condition)||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay)}}dispatchGameControl(e){if(!1===s(this.shared,this.condition)||!this.particleSystem)return!1;"start"===e?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};l("Particle",(e,t,i)=>new X(e,t,i)),n("Particles",({data:e,page:t,shared:i,actionCondition:n})=>new j(e,t,i,n)),a("particles");
|
|
1
|
+
import{b as e,d as t,e as i}from"./runtime-chunk-GFTBNL2W.js";import{b as n,e as s}from"./runtime-chunk-QVC5UDJO.js";import{b as r,v as o}from"./runtime-chunk-PLJ25O2X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a,d as l}from"./runtime-chunk-TZCHGFVF.js";import{T as u,l as c}from"./runtime-chunk-OW6T4XFV.js";import{Aa as h,Cc as d,Dc as m,Ec as p,Ed as v,Fc as f,Gd as y,Ic as S,Ja as g,Jc as x,Pc as z,Rc as b,Vd as T,Wc as E,Wd as R,Xd as P,bd as _,dd as C,kd as A,ld as D,nd as w,pd as F,qd as I,te as V}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var N=new E,U=new f,O=new m,L=new m,M=new m,Q=class{constructor(e){this.geometry=e.geometry,this.randomFunction=Math.random,this.indexAttribute=this.geometry.index,this.positionAttribute=this.geometry.getAttribute("position"),this.normalAttribute=this.geometry.getAttribute("normal"),this.colorAttribute=this.geometry.getAttribute("color"),this.uvAttribute=this.geometry.getAttribute("uv"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){let e=this.indexAttribute,t=this.positionAttribute,i=this.weightAttribute,n=e?e.count/3:t.count/3,s=new Float32Array(n);for(let r=0;r<n;r++){let n=1,o=3*r,a=3*r+1,l=3*r+2;e&&(o=e.getX(o),a=e.getX(a),l=e.getX(l)),i&&(n=i.getX(o)+i.getX(a)+i.getX(l)),N.a.fromBufferAttribute(t,o),N.b.fromBufferAttribute(t,a),N.c.fromBufferAttribute(t,l),n*=N.getArea(),s[r]=n}let r=new Float32Array(n),o=0;for(let e=0;e<n;e++)o+=s[e],r[e]=o;return this.distribution=r,this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,i,n){let s=this._sampleFaceIndex();return this._sampleFace(s,e,t,i,n)}_sampleFaceIndex(){let e=this.distribution[this.distribution.length-1];return this._binarySearch(this.randomFunction()*e)}_binarySearch(e){let t=this.distribution,i=0,n=t.length-1,s=-1;for(;i<=n;){let r=Math.ceil((i+n)/2);if(0===r||t[r-1]<=e&&t[r]>e){s=r;break}e<t[r]?n=r-1:i=r+1}return s}_sampleFace(e,t,i,n,s){let r=this.randomFunction(),o=this.randomFunction();r+o>1&&(r=1-r,o=1-o);let a=this.indexAttribute,l=3*e,u=3*e+1,c=3*e+2;return a&&(l=a.getX(l),u=a.getX(u),c=a.getX(c)),N.a.fromBufferAttribute(this.positionAttribute,l),N.b.fromBufferAttribute(this.positionAttribute,u),N.c.fromBufferAttribute(this.positionAttribute,c),t.set(0,0,0).addScaledVector(N.a,r).addScaledVector(N.b,o).addScaledVector(N.c,1-(r+o)),void 0!==i&&(void 0!==this.normalAttribute?(N.a.fromBufferAttribute(this.normalAttribute,l),N.b.fromBufferAttribute(this.normalAttribute,u),N.c.fromBufferAttribute(this.normalAttribute,c),i.set(0,0,0).addScaledVector(N.a,r).addScaledVector(N.b,o).addScaledVector(N.c,1-(r+o)).normalize()):N.getNormal(i)),void 0!==n&&void 0!==this.colorAttribute&&(N.a.fromBufferAttribute(this.colorAttribute,l),N.b.fromBufferAttribute(this.colorAttribute,u),N.c.fromBufferAttribute(this.colorAttribute,c),U.set(0,0,0).addScaledVector(N.a,r).addScaledVector(N.b,o).addScaledVector(N.c,1-(r+o)),n.r=U.x,n.g=U.y,n.b=U.z),void 0!==s&&void 0!==this.uvAttribute&&(O.fromBufferAttribute(this.uvAttribute,l),L.fromBufferAttribute(this.uvAttribute,u),M.fromBufferAttribute(this.uvAttribute,c),s.set(0,0).addScaledVector(O,r).addScaledVector(L,o).addScaledVector(M,1-(r+o))),this}};function B(e,t){let i=e,n=new Float32Array(4*t*t);for(let e=0;e<t*t;e++)n[4*e]=i[3*e],n[4*e+1]=i[3*e+1],n[4*e+2]=i[3*e+2],n[4*e+3]=0;let s=new w(n,t,t,g,h);return s.needsUpdate=!0,s}var W=class{constructor(e,t,i,n){this.type="SphereEmitterShape",this.targetMesh=void 0,this.size=e,this.type=i,this.textureSize=function(e){let t=Math.ceil(Math.sqrt(e));return Math.max(t,1)}(t),this.targetMesh="BufferGeometry"===n?.geometry.type||"Mesh"===n?.type&&n&&n.geometry.hasAttribute("position")&&n.geometry.hasAttribute("normal")?n:this.getMesh(i,1);let{positions:s,dataTexture:r,dataTextureNormals:o}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(i,1));this.positionsTexture=r,this.positionsAttribute=s,this.directionsTexture=o}createPositions(e,t){let{positions:i,normals:n}=function(e,t){let i=new D(e.geometry,e.material),n=[],s=[],r=new f,o=new f;null!==i.geometry.index&&(i.geometry=i.geometry.toNonIndexed());let a=new Q(i).build();for(let e=0;e<t;e++)a.sample(r,o),n.push(r.x,r.y,r.z),s.push(o.x,o.y,o.z);return{positions:new Float32Array(n),normals:new Float32Array(s)}}(t,e*e);return{dataTexture:B(i,e),positions:i,dataTextureNormals:B(n,e)}}getMesh(e,t){let i=null;switch(e){case"SphereEmitterShape":i=new R(.5*t,32,32);break;case"TorusEmitterShape":i=new P(.5*t,.3,15,40);break;case"ConeEmitterShape":i=new y(t,t,15);break;case"BoxEmitterShape":i=new v(t,t,t);break;case"PlaneEmitterShape":i=new T(t,t),i.rotateX(-Math.PI/2);break;default:i=new R(t,32,32)}return new D(i,new A({color:16711680}))}applyToShader(e,t){this.size=(new f).fromArray(t.size.map(e=>"number"==typeof e?e:1)),e.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function k(e){let t={...e},i=u.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let n={...i.shape,...t.shape},s={...i.renderMaterial,...t.renderMaterial};return{...i,...t,shape:n,renderMaterial:s}}var q=class extends b{constructor(n,s){super(),this.type="ParticleEmitter",this.debugMode=!1,this.worldSpace=!0,this.rootObject=null,this.gpuCompute=null,this.positionSimRT=null,this.velocitySimRT=null,this.emissionRateSimRT=null,this.emitterShape=void 0,this.isEmitting=!1,this.hasBeenReset=!1,this.emittedParticlesAmount=0,this.lastEmitTime=0,this.globalTime=0,this.targetFPS=60,this.previousRatio=1,this.lerpFactor=.4,this.particlesAmount=0,this.noiseStrength=0,this.noiseScale=0,this.isBillboardBased=!0,this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1},this.textureLoader=new V,this.textureRequestId=0,this.currentWorldPosition=new f,this.systemQuaternion=new p,this.worldGravity=new f(0,0,0),this.directionAxis=new f(0,0,0),this.colliderV3=new f(0,0,0),this.colliderQuaternion=new p(0,0,0,1),this.matrixAutoUpdate=!0,this.renderer=n,this.system=s,this.shared=s.context.shared;let r=s.data;this.material=i(n)?e()?.createMaterial(r.renderMaterial,s.context)??t().createMaterial(r.renderMaterial,s.context):t().createMaterial(r.renderMaterial,s.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:r.renderMaterial.color},uColor2:{value:r.renderMaterial.color2},uPosition:{value:new f(0,0,0)},uEmissionData:{value:new f(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new f(0,0,0)},uWorldQuaternion:{value:new x(0,0,0,1)},uRandScaleFactor:{value:r.randomScale??0},uRandRotationFactor:{value:r.randomRotation??0},uRotation:{value:r.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:r.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,r.renderMaterial.texture),this.init(r)}setTexture(e,t){let i=t.data,n=++this.textureRequestId;if("string"==typeof t){let i=this.shared.image(t),s=()=>{if(n!==this.textureRequestId)return;let t=new S(i.img);t.needsUpdate=!0,e.uTexture.value=t};return void(i.loaded?s():i.loadPromise.then(s))}if("string"!=typeof i){let t=new Image;t.onload=()=>{if(n!==this.textureRequestId)return;let i=new S(t);i.needsUpdate=!0,e.uTexture.value=i};let s=new Blob([i],{type:"image/*"}),r=URL.createObjectURL(s);t.src=r}}updateGeometryAttributes(e,t){let n=function(e){let t=new Float32Array(e*e*2);for(let i=0;i<e;i++)for(let n=0;n<e;n++){let s=i*e+n;t[2*s+0]=i/(e-1),t[2*s+1]=n/(e-1)}return t}(t);if(!this.emitterShape?.positionsAttribute)return;let s=new F(n,2);e.geometry.setAttribute("ref",s),i(this.renderer)&&e.geometry.setAttribute("particleRef",s)}applyWorldSpace(){if(!(this.system.started&&this.worldSpace&&this.positionSimRT&&this.velocitySimRT))return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,t){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset)return void this.reset();this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let i=1e3/t,n=this.targetFPS/i,s=this.previousRatio+(n-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=s,this.previousRatio=s;let r=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=r,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],t=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&t&&this.init(k({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),0===this.colliderV3.y&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let i=e.data.size;this.colliderV3.fromArray(i),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,t){if(!this.velocitySimRT||!this.positionSimRT)return;"size"===t[2]&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),"sizeEnd"===t[2]&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let i=(e,t)=>{let i=[...this.system.data.shape.size];i[e]=t,this.updateParticleState({shape:{...this.system.data.shape,size:i}})};"shape_size_0"===t[2]&&i(0,e),"shape_size_1"===t[2]&&i(1,e),"shape_size_2"===t[2]&&i(2,e),"speed"===t[2]&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/10),"gravity"===t[2]&&this.worldGravity.set(0,e/100,0),"noiseStrength"===t[2]&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),"noiseScale"===t[2]&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),"direction_x"===t[2]&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),"direction_y"===t[2]&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),"direction_z"===t[2]&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(this.positionSimRT&&this.velocitySimRT){if(this.shouldReInitGPUCompute(e)&&this.init(k(this.system.data)),void 0!==e.life&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),void 0!==e.speed&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/10),void 0!==e.collisionBounce&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),void 0!==e.noiseStrength&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),void 0!==e.noiseScale&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),void 0!==e.noiseSeed&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),void 0!==e.randomMass&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),void 0!==e.renderMaterial?.size){let t=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(t)}if(void 0!==e.renderMaterial?.spriteRotation&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),void 0!==e.shape){let t=e.shape.size??this.system.data.shape.size,i=[Number(this.shared.getVariable(t[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(t[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(t[2],[this.uuid,"particles","shape_size_2"]))],n={...k(this.system.data).shape,size:i};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,n)}if(void 0!==e.gravity&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),void 0!==e.direction){let t=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(t),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}void 0!==e.randomRotation&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),void 0!==e.randomScale&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(void 0!==e.forceIntensity&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),void 0!==e.forceDambing&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let t=[Number(e[0])*d.DEG2RAD,Number(e[1])*d.DEG2RAD,Number(e[2])*d.DEG2RAD],i=new z(t[0],t[1],t[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(i).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:t,rootObjectType:i,colliderEntityId:n,shape:s,emitTimeDuration:r,emitTimeCycle:o,life:a,directionMode:l,noiseType:u}=e;return void 0!==t||void 0!==i||n||null===n||void 0!==o||void 0!==s||void 0!==a||void 0!==r||void 0!==l||void 0!==u}init(n){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:n.birthRatePerSec,particleMaxLifeTime:n.life,loopDuration:"infinity"===n.emitTimeCycle?0:n.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn("The maximum number of particles is limited to 100000."),this.particlesAmount=1e5),this.emitterShape=this.createShape(n.shape,this.particlesAmount);let s=setInterval(()=>{if(!this.emitterShape)return;let e=this.emitterShape.positionsTexture.source.data.data;e&&!isNaN(e[0])?clearInterval(s):this.init(n)},100);if(!this.emitterShape)return;let r=this.updateSimulationDefinition(n),o=i(this.renderer)?e().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer,this.simFeaturesDefinition):t().createComputation(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),a=o.addVariable("uCurrentPosition",r+"\n\n\n\nuniform sampler2D uOriginalPosition;\nuniform float uTime;\nuniform float uSpeed; \nuniform vec3 uWorldOffset; \nuniform vec4 uWorldQuaternion;\nuniform float uMaxLifeTime;\nuniform vec3 uEmitterSize;\nuniform float uFPSRatio; \n\nfloat random (vec2 st) {\n return fract(sin(dot(st.xy,\n vec2(12.9898,78.233)))*\n 43758.5453123);\n}\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n}\n\nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n }\n \n\nvoid main() {\n vec2 vUv = gl_FragCoord.xy / resolution.xy;\n vec3 position = texture2D( uCurrentPosition, vUv ).xyz;\n float currentLife = texture2D( uCurrentPosition, vUv ).w; \n float isSpawning = texture2D( uCurrentEmissionRate, vUv ).r; \n float isActive = texture2D( uCurrentEmissionRate, vUv ).g; \n float timeStart = texture2D( uCurrentEmissionRate, vUv ).b; \n vec3 originalPosition = ((texture2D( uOriginalPosition, vUv ).xyz) * uEmitterSize);\n vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;\n float collisionFlag = texture2D( uCurrentVelocity, vUv ).w; \n float lifeTime = uMaxLifeTime;\n\n \n \n float isColliding = step(0.5, collisionFlag); \n float bounceOffset = 3.0 * isColliding; \n vec3 collisionAdjustedVelocity = velocity * (1.0 + bounceOffset);\n\n \n vec3 fpsVelocity = velocity * min(uFPSRatio, 5.0);\n position += mix(fpsVelocity, collisionAdjustedVelocity, isColliding);\n\n \n \n \n vec3 newPosition = applyQuaternionToVector(uWorldQuaternion, originalPosition) + uWorldOffset;\n originalPosition = mix(originalPosition, newPosition, isSpawning);\n position = mix(position, originalPosition, isSpawning);;\n timeStart = mix(timeStart, uTime, isSpawning);\n\n \n float timeLeft = max(lifeTime - (uTime - timeStart), 0.0);\n float life_Normalize = timeLeft / lifeTime;\n\n \n vec4 activeColor = vec4(position, life_Normalize);\n \n gl_FragColor = mix(vec4(0.0), activeColor, isActive);\n\n}\n",this.emitterShape.positionsTexture),l=o.addVariable("uCurrentVelocity",r+"\n\n\n\nuniform sampler2D uOriginalPosition;\nuniform sampler2D uDirections; \nuniform vec3 uDirectionsAxis;\nuniform vec4 uWorldQuaternion;\nuniform vec3 uGravity; \nuniform float uNoiseStrength; \nuniform float uNoiseScale; \nuniform float uNoiseSeed; \nuniform float particleSize;\nuniform float uSpeed; \nuniform float uRandomMassFactor;\n\n\nuniform vec3 uColliderPos; \nuniform vec3 uColliderSize; \nuniform vec4 uColliderQuaternion; \nuniform vec4 uColliderQuaternionInvert; \nuniform float uBounce; \nuniform float uForceDamping;\nuniform float uForceIntensity;\n\n\n\n\n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n \n vec4 mod289(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n \n vec4 permute(vec4 x) {\n return mod289(((x*34.0)+1.0)*x);\n }\n \n vec4 taylorInvSqrt(vec4 r)\n {\n return 1.79284291400159 - 0.85373472095314 * r;\n }\n \n vec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\n float snoise(vec3 v)\n {\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; \n vec3 x3 = x0 - D.yyy; \n \n \n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n \n \n \n float n_ = 0.142857142857; \n vec3 ns = n_ * D.wyz - D.xzx;\n \n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); \n \n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); \n \n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n \n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n \n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n \n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n \n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n \n \n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n \n \n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n }\n \n vec3 snoiseVec3( vec3 x ){\n \n float s = snoise(vec3( x ));\n float s1 = snoise(vec3( x.y - 19.1 , x.z + 33.4 , x.x + 47.2 ));\n float s2 = snoise(vec3( x.z + 74.2 , x.x - 124.5 , x.y + 99.4 ));\n vec3 c = vec3( s , s1 , s2 );\n return c;\n \n }\n \n \n vec3 curlNoise( vec3 p, float seed){\n p += seed;\n const float e = .1;\n vec3 dx = vec3( e , 0.0 , 0.0 );\n vec3 dy = vec3( 0.0 , e , 0.0 );\n vec3 dz = vec3( 0.0 , 0.0 , e );\n \n vec3 p_x0 = snoiseVec3( p - dx );\n vec3 p_x1 = snoiseVec3( p + dx );\n vec3 p_y0 = snoiseVec3( p - dy );\n vec3 p_y1 = snoiseVec3( p + dy );\n vec3 p_z0 = snoiseVec3( p - dz );\n vec3 p_z1 = snoiseVec3( p + dz );\n \n float x = p_y1.z - p_y0.z - p_z1.y + p_z0.y;\n float y = p_z1.x - p_z0.x - p_x1.z + p_x0.z;\n float z = p_x1.y - p_x0.y - p_y1.x + p_y0.x;\n \n const float divisor = 1.0 / ( 2.0 * e );\n return normalize( vec3( x , y , z ) * divisor );\n \n }\n\n\n\nfloat cnoise(vec3 P)\n{\n vec3 Pi0 = floor(P); \n vec3 Pi1 = Pi0 + vec3(1.0); \n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); \n vec3 Pf1 = Pf0 - vec3(1.0); \n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); \n return 2.2 * n_xyz;\n}\n\n\nvec3 fbm_vec3(vec3 p, float frequency, float offset)\n{\n return vec3(\n cnoise((p+vec3(offset))*frequency),\n cnoise((p+vec3(offset+20.0))*frequency),\n cnoise((p+vec3(offset-30.0))*frequency)\n );\n}\n\n\nfloat rand(vec2 co){\n return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);\n}\nvec3 applyQuaternionToVector( vec4 q, vec3 v ){\n return v + 2.0 * cross( q.xyz, cross( q.xyz, v ) + q.w * v );\n } \nvec3 applyForce(vec3 force, float mass) {\n vec3 acceleration = force / mass;\n \n return acceleration;\n}\n\nvec4 conjugate(vec4 q) {\n return vec4(q.w, -q.x, -q.y, -q.z);\n}\n\n\nvec3 ellipsoidNormal(vec3 p, vec3 radii) {\n return normalize(p / (radii * radii));\n}\n\nfloat friction = .3;\n\nvoid main() {\n vec2 vUv = gl_FragCoord.xy / resolution.xy;\n vec3 position = texture2D( uCurrentPosition, vUv ).xyz;\n vec3 originalPosition = texture2D( uOriginalPosition, vUv ).xyz;\n float timeLeft = texture2D( uCurrentPosition, vUv ).w;\n vec3 directions = texture2D( uDirections, vUv ).xyz; \n vec3 velocity = texture2D( uCurrentVelocity, vUv ).xyz;\n float mass = rand(originalPosition.xy) * 0.5 + 0.5;\n float isSpawning = texture2D( uCurrentEmissionRate, vUv ).x; \n float isActive = texture2D( uCurrentEmissionRate, vUv ).y; \n float collisionFlag =texture2D( uCurrentVelocity, vUv ).w; \n\n \n mass = (1.0 - (uRandomMassFactor * mass));\n \n if (isActive == 1.0) {\n \n \n \n #ifdef USE_CURL_NOISE\n if (uNoiseScale > 0.0 ) {\n velocity = curlNoise(position * uNoiseScale * .002, uNoiseSeed) * ( uNoiseStrength + 1.0) * .05 * uSpeed;\n }\n \n if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) {\n velocity += curlNoise( position, uNoiseSeed) * uNoiseStrength * 0.05 * uSpeed;\n }\n #endif\n \n #ifdef USE_SIMPLEX_NOISE\n if (uNoiseScale > 0.0 ) {\n velocity = vec3(snoise(position * uNoiseScale * .001) * ( uNoiseStrength + 1.0) * .1);\n velocity *= uSpeed;\n }\n \n if (uNoiseStrength > 0.0 && uNoiseScale == 0.0) {\n velocity += vec3(snoise(position * uNoiseStrength * .001) * .05 * uSpeed);\n }\n #endif\n \n #ifdef USE_FBM_NOISE\n if (uNoiseScale > 0.0 ) {\n velocity = fbm_vec3(position * uNoiseScale * .001, ( uNoiseStrength + 1.0), uNoiseSeed);\n velocity *= uSpeed;\n }\n \n if (uNoiseStrength > 0.0 && uNoiseScale == 0.0 ) { \n velocity += fbm_vec3(position * uNoiseStrength * .001, ( uNoiseStrength + 1.0), uNoiseSeed) * .1 * uSpeed;\n }\n #endif\n\n \n \n #ifdef USE_COLLIDER\n float restitution = max(uBounce * 2., .01); \n \n \n #ifdef USE_SPHERE_COLLIDER \n \n vec3 radii = uColliderSize;\n \n vec3 relPos = position - uColliderPos;\n \n relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); \n \n vec3 scaledPos = relPos / radii;\n \n float dist = length(scaledPos); \n \n \n if (dist <= 1. + particleSize / length(radii) && collisionFlag == 0.0) {\n \n vec3 adjustedPos = scaledPos * (1.0 + particleSize / length(radii)); \n \n vec3 normal = ellipsoidNormal(adjustedPos, radii);\n \n normal = applyQuaternionToVector(uColliderQuaternion, normal);\n \n velocity = reflect(velocity, normal) * restitution;\n\n collisionFlag = 1.0;\n } else {\n collisionFlag = 0.0;\n }\n #endif\n\n \n \n #ifdef USE_BOX_COLLIDER\n \n vec3 boxHalfSize = uColliderSize / 2.0;\n \n vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); \n \n vec3 localDistance = abs(localPos) - boxHalfSize;\n float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z)); \n\n \n if (distToSurface <= particleSize * 0.5 && collisionFlag == 0.0) { \n \n vec3 normal;\n if (localDistance.x > localDistance.y && localDistance.x > localDistance.z) {\n normal = vec3(sign(localPos.x), 0.0, 0.0);\n } else if (localDistance.y > localDistance.z) {\n normal = vec3(0.0, sign(localPos.y), 0.0);\n } else {\n normal = vec3(0.0, 0.0, sign(localPos.z));\n } \n \n normal = applyQuaternionToVector(uColliderQuaternion, normal); \n \n velocity = reflect(velocity, normal) * restitution;\n \n collisionFlag = 1.0;\n } else {\n collisionFlag = 0.0;\n }\n #endif \n #endif \n \n\n \n \n #ifdef USE_ATTRACTOR\n\n #ifdef USE_SPHERE_COLLIDER \n \n vec3 radii = uColliderSize;\n \n vec3 relPos = position - uColliderPos;\n \n relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); \n \n vec3 scaledPos = relPos / radii;\n \n float distToSurface = length(scaledPos); \n float insideCheck = 1.0;\n\n #endif\n\n\n #ifdef USE_BOX_COLLIDER\n \n vec3 boxHalfSize = uColliderSize / 2.0;\n \n vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); \n vec3 localDistance = abs(localPos) - boxHalfSize;\n float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));\n float insideCheck = particleSize;\n #endif \n \n \n #ifdef USE_FORCE_LOCAL_SPACE\n if (distToSurface <= insideCheck ) { \n \n #ifdef USE_SPHERE_COLLIDER \n float attractorStrength = (1.0 - distToSurface ) * uForceIntensity; \n #endif\n\n #ifdef USE_BOX_COLLIDER\n float attractorStrength = max((1.0 - insideCheck / distToSurface), 0.) * uForceIntensity; \n #endif\n\n float attractorDamping = uForceDamping; \n \n \n vec3 attractorRadii = uColliderSize;\n \n vec3 relPos = position - uColliderPos;\n \n relPos = applyQuaternionToVector(uColliderQuaternionInvert, relPos); \n \n vec3 scaledPos = relPos / attractorRadii;\n\n \n float attractorRadius = length(scaledPos);\n \n vec3 relativePosition = position - uColliderPos;\n \n vec3 attractorForce = normalize(relativePosition) * attractorStrength;\n \n velocity -= attractorForce;\n \n velocity *= attractorDamping;\n }\n #else \n \n vec3 relativePosition = position - uColliderPos;\n \n vec3 attractorForce = normalize(relativePosition) * uForceIntensity;\n \n velocity -= attractorForce;\n \n velocity *= uForceDamping;\n #endif \n #endif \n \n \n \n #ifdef USE_VORTEX\n \n vec3 boxHalfSize = uColliderSize / 2.0;\n \n vec3 localPos = applyQuaternionToVector(uColliderQuaternionInvert, position - uColliderPos); \n vec3 localDistance = abs(localPos) - boxHalfSize;\n float distToSurface = max(localDistance.x, max(localDistance.y, localDistance.z));\n\n \n if (distToSurface <= particleSize) {\n float vortexStrength = uForceIntensity;\n vec3 localTopCenter = vec3(0.0, 0., 0.0);\n\n \n vec3 vortexCenter = uColliderPos + applyQuaternionToVector(uColliderQuaternion, localTopCenter);\n \n vec3 vortexVector = vortexCenter - position;\n\n \n \n vec3 upVector = vec3(0.0, 1.0, 0.01);\n vec3 rotationAxis = cross(upVector, applyQuaternionToVector(uColliderQuaternion, vortexVector));\n rotationAxis = normalize(rotationAxis);\n\n \n float rotationSpeed = length(vortexVector * vortexStrength * 3.0) ; \n\n vec3 rotationVelocity = rotationAxis * rotationSpeed;\n \n velocity = rotationVelocity * 0.005 ;\n\n \n \n \n vec3 originDirection = applyQuaternionToVector(uWorldQuaternion, directions);\n velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);\n }\n #endif \n\n } \n \n\n \n \n \n #ifdef USE_NORMALS\n velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, directions) * uSpeed, isSpawning);\n #else\n velocity = mix(velocity, applyQuaternionToVector(uWorldQuaternion, uDirectionsAxis) * uSpeed, isSpawning); \n #endif\n \n \n velocity += applyForce(uGravity, mass * .5) * (1.0 - collisionFlag);\n\n gl_FragColor = vec4(velocity, collisionFlag);\n}\n",this.emitterShape.directionsTexture),u=o.addVariable("uCurrentEmissionRate","\n\n\n\n\nuniform sampler2D uIndex; \nuniform float uLastIndexEmitted; \nuniform float uParticlesToEmit; \nuniform float uTime;\n\nvoid main() {\n vec2 vUv = gl_FragCoord.xy / resolution.xy;\n float particleIndex = texture(uIndex, vUv).x;\n float timeLeft = texture2D( uCurrentPosition, vUv ).w;\n float isActive = texture2D( uCurrentEmissionRate, vUv ).g; \n float timeStart = texture2D( uCurrentEmissionRate, vUv ).b;\n\n\n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n float emitLowerBound = step(uLastIndexEmitted, particleIndex);\n float emitUpperBound = step(particleIndex, uLastIndexEmitted + uParticlesToEmit - 1.0);\n float emitParticle = emitLowerBound * emitUpperBound; \n\n \n timeStart = mix(timeStart, uTime, emitParticle);\n gl_FragColor = vec4(emitParticle, mix(isActive, 1.0, emitParticle), timeStart, 1.0);\n\n\n}\n",function(e){let t=new Float32Array(4*e*e);for(let i=0;i<e*e;i++)t[4*i]=0,t[4*i+1]=0,t[4*i+2]=0,t[4*i+3]=0;let i=new w(t,e,e,g,h);return i.needsUpdate=!0,i}(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,l,u]),o.setVariableDependencies(l,[a,l,u]),o.setVariableDependencies(u,[a,l,u]);let c=function({size:e}){let t=new Float32Array(4*e*e);for(let i=0;i<e*e;i++)t[4*i]=i,t[4*i+1]=0,t[4*i+2]=0,t[4*i+3]=0;let i=new w(t,e,e,g,h);return i.needsUpdate=!0,i}({size:this.emitterShape.textureSize}),d={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new f(0,0,0)},uWorldQuaternion:{value:new x(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:n.life},uEmitterSize:{value:new f(Number(this.shared.getVariable(n.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(n.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(n.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=d;let m=this.getDirectionFromVariable(n.direction);this.directionAxis=this.getDirectionAxis(m),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(n.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(n.noiseScale,[this.uuid,"particles","noiseScale"]));let p=n.colliderEntityId&&this.system.getColliderData(n.colliderEntityId),v={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new x(0,0,0,1)},uColliderPos:{value:new f(0,0,0)},uColliderSize:{value:new f(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new x(0,0,0,1)},uColliderQuaternionInvert:{value:new x(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:n.noiseSeed},uRandomMassFactor:{value:n.randomMass},uBounce:{value:n.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(n.speed,[this.uuid,"particles","speed"]))/10}};l.material.uniforms=v;let y={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};u.material.uniforms=y;let S=[Number(this.shared.getVariable(n.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(n.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(n.shape.size[2],[this.uuid,"particles","shape_size_2"]))],z={...k(this.system.data).shape,size:S};this.emitterShape.applyToShader(a.material.uniforms,z),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=l,this.emissionRateSimRT=u,this.material.uniforms.uPosition.value=o.getCurrentRenderTarget(a)?.texture,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){return[Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]))]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let t=this.system.getColliderData(e.colliderEntityId);switch(t?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0}let i=t?.colliderType;"sphere"===i&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),"box"===i&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),"helper"===t?.forceRange&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}"normals"===e.directionMode&&(this.simFeaturesDefinition.USE_NORMALS=!0),"curl"===e.noiseType&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),"simplex"===e.noiseType&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),"fbm"===e.noiseType&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let t="";for(let[e,i]of Object.entries(this.simFeaturesDefinition))i&&(t+=`#define ${e}\n`);return t}createShape(e,t){this.emitterShape&&this.emitterShape.dispose();let i=new f(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if("MeshEmitterShape"===e.type){let n=null;return this.system.context.scene.traverseEntity(t=>{t.uuid===e.fromMeshId&&(n=t)}),n?new W(i,t,e.type,n):new W(i,t,"SphereEmitterShape")}return new W(i,t,e.type)}createPrimaryEmitter(e){let t=e*e,i=new I(new T(1,1,1),this.material,t);return this.updateGeometryAttributes(i,e),this.material.needsUpdate=!0,i.onBeforeRender=()=>{this.applyWorldSpace()},i}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:t,loopDuration:i=0}){return Math.ceil(e*(t+i))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,t){let i=e-this.lastEmitTime,n=1/t;if(i>=n){let t=Math.max(1,Math.floor(i/n));return this.lastEmitTime=e,this.emittedParticlesAmount+t>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=t,t}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(k(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}},X=class extends o{constructor(e,t,i){super(e,t),this.type="ParticleSystem",this.isParticleSystem=!0,this.geometry=new C,this.actualTime=0,this.currentLoopTime=0,this.started=!1,this.stopped=!1,this.timeoutId=void 0,this.isFrozen=!1,this.isIdle=!0,this.emitter=null,this.colliderEntities=[],this.renderer=null,this.isPreWarm=!1,this._hasOnAfterRenderBeenCalled=!1,this.onAfterRender=e=>{e.warmupInFlight||this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))},this.context=i,this.data={...t,...k(t)},this.geometry.setAttribute("position",new _([],3)),this.material=new A({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new q(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let t="one_time"===this.data.emitTimeCycle;if(("loop"===this.data.emitTimeCycle||t)&&this.currentLoopTime>1e3*this.data.emitTimeDuration&&(this.stopped||(this.stop(),t||this.start(1e3*this.data.emitTimeDelay))),this.emitter&&this.started){let t=this.actualTime/1e3;this.emitter.update(t,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(t=>t.identity===e)}getColliderData(e){let t=this.colliderEntities.find(t=>t.identity===e);return t?t.data:null}updateByPatchedOp(e,t,i){super.updateByPatchedOp(e,t,i),r(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...c.drop(e,1).props}}),r(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...c.drop(e,1).props}})}updateState(e,t){super.updateState(e,t),this.updateParticleState(e)}updateParticleState(e){if(this.emitter){if(void 0!==e.colliderEntityId&&null!==e.colliderEntityId){let t=this.context.scene.find(e.colliderEntityId);this.colliderEntities=t?[t]:[]}null===e.colliderEntityId&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){this.currentLoopTime=0,e?this.timeoutId=window.setTimeout(()=>{this.start(0)},e):(this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3),this._requestRender())}froze(){this.isFrozen=!0,this._requestRender()}unFroze(){this.isFrozen=!1,this._requestRender()}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId),this._requestRender()}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset(),this._requestRender()}_requestRender(){this.context.shared.requestRender()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}},j=class{constructor(e,t,i,n){this.data=e,this.page=t,this.shared=i,this.condition=n,this.delay=0,this.emission=e.emission,void 0!==e.delay&&(this.delay=e.delay),this.particleSystem=this.page.scene.find(this.data.emitterObjectId)}toggleEmitting(){this.particleSystem.started&&!this.particleSystem.stopped?this.stop(this.delay):this.start(this.delay)}toggleFroze(){this.particleSystem.started&&!this.particleSystem.isFrozen?this.freeze(this.delay):this.unFreeze(this.delay)}start(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.start(0),this.clearDelay()},e):this.particleSystem.start()}stop(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.stop(0),this.clearDelay()},e):this.particleSystem.stop()}freeze(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.freeze(0),this.clearDelay()},e):this.particleSystem.froze()}unFreeze(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.unFreeze(0),this.clearDelay()},e):this.particleSystem.unFroze()}reset(e=0){e?this.delayTimerId=window.setTimeout(()=>{this.reset(0),this.clearDelay()},e):this.particleSystem.reset()}reverseFromCurrent(){switch(this.emission){case"emitToggle":this.toggleEmitting();break;case"pauseToggle":this.toggleFroze()}}dispatchBasic(){if(!1===s(this.shared,this.condition)||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"emitToggle":this.toggleEmitting();break;case"pause":this.freeze(this.delay);break;case"pauseToggle":this.toggleFroze();break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay)}}dispatchConditional(){if(!1===s(this.shared,this.condition)||!this.particleSystem)return!1;switch(this.emission){case"start":this.start(this.delay);break;case"stop":this.stop(this.delay);break;case"reset":this.reset(this.delay)}}dispatchGameControl(e){if(!1===s(this.shared,this.condition)||!this.particleSystem)return!1;"start"===e?this.start(this.delay):this.stop(this.delay)}dispose(){!this.particleSystem||(this.particleSystem.reset(),this.clearDelay())}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}};l("Particle",(e,t,i)=>new X(e,t,i)),n("Particles",({data:e,page:t,shared:i,actionCondition:n})=>new j(e,t,i,n)),a("particles");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,ea as t,q as s,r as i,s as n,t as a,u as r,v as o,w as l,x as h,y as u,z as p}from"./runtime-chunk-NRJDJMQZ.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{g as c,u as d}from"./runtime-chunk-ZLW3UWOA.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-Z5OH244S.js";import{a as m,f as g,h as y}from"./runtime-chunk-TZCHGFVF.js";import{ja as f,ka as v,la as w}from"./runtime-chunk-OW6T4XFV.js";import{Cc as x,Dc as S,Fc as b,Gc as _,Oc as P,Zc as C,dd as M}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var A=class extends t{constructor(e,t,s){super(e,t,s),this.isPathObject=!0,this._shapeId=null,this._lastShapeParams=null,this._lastShape=null,this._context=s}updateState(e,t){super.updateState(e,t),this.updateShape(),this.refreshAttachedCloners(t)}updateShape(){let t,s={...this.data.geometry.extrusion.shape};for(let e in s)"string"==typeof s[e]&&(s[e]=this._context.shared.getVariable(s[e],[this.uuid,"geometry","extrusion","shape",e]));if("Custom"===s.type){let e=s.shapeId;if(e!==this._shapeId&&this.detachShape(),e){this._shapeId=e;let s=this._context.scene.find(e);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(null!==this._lastShape&&this._sameShapeParams(s))t=this._lastShape;else{let i;switch(s.type){case"Rectangle":i=p;break;case"Ellipse":i=h;break;case"Polygon":i=u;break;case"Star":i=e;break;default:throw new Error(`Unknown shape type: ${s.type}`)}t=i.create({parameters:s}).userData.shape,this._lastShapeParams=s,this._lastShape=t??null}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build())}_sameShapeParams(e){let t=this._lastShapeParams;if(null===t)return!1;for(let s in e)if(!Object.is(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1;return!0}detachShape(){null!==this._shapeId&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let s=this.geometry.getAttribute("position");void 0!==s&&s.count>0?d(s,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:s.count,e,t):super.updateEntityBoxSize(e,t)}},D=new P,O=new P,k=new P,I=new b,R=new b,T=new b,z=new b,E=new b,j=new b,U=new b,G=new WeakMap,F=new WeakMap,B=new WeakMap;function V(e){e.setIndex(null),e.setAttribute("position",new C(new Float32Array(0),3)),e.setAttribute("normal",new C(new Float32Array(0),3)),e.setAttribute("uv",new C(new Float32Array(0),2)),e.setDrawRange(0,0)}var N=class extends M{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&1===this.inputs.parameters.extrusion.depth}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&1===e.depth&&function(e){let t=2*Math.PI;return(e%t+t)%t===(0%t+t)%t}(e.twist)&&e.startScale===e.endScale)}build(){let{points:e,matrices:t}=this._getSampledPath();if(e.length<2)return void V(this);let{depth:s,offset:i}=this.inputs.parameters.extrusion;s=Math.max(0,Math.min(s,1)),i=Math.max(0,Math.min(i,1));let n=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(i*n),r=this.inputs.path.isClosed?Math.ceil((s+i)*n):Math.ceil(Math.min(1,s+i)*n),o=Math.min(Math.max(2,r-a+1),n+2),h=[],u=[];for(let s=0;s<o;s++){let i=this.inputs.path.isClosed?(s+a)%e.length:Math.min(s+a,e.length-1);h.push(e[i].clone()),u.push(t[i].clone())}let p=(e,t,s)=>{h[e]=h[e].clone().lerp(h[t],s),u[e]=function(e,t,s){let i=[new b,new b,new b],n=[new b,new b,new b];return e.extractBasis(i[0],i[1],i[2]),t.extractBasis(n[0],n[1],n[2]),i.forEach((e,t)=>{let i=n[t],a=x.lerp(e.length(),i.length(),s);e.lerp(i,s).setLength(a)}),(new P).makeBasis(i[0],i[1],i[2])}(u[e],u[t],s)},c=0,d=i*n%1;(!this.inputs.path.isClosed||s<=1)&&(d||0===i)&&(c=d,p(0,1,c));let m=0,g=(i+s)*n%1;if((this.inputs.path.isClosed&&s<=1||!this.inputs.path.isClosed&&i+s<1)&&g&&(m=g,p(h.length-1,h.length-2,1-m)),0===s){let e=h.length-1;h[e].copy(h[0]),u[e].copy(u[0])}this._applyPathModifiers(u,c,m);let{bevel:y,bevelSides:f}=this.inputs.parameters.extrusion,v=y>0?this.inputs.parameters.extrusion.capType:"flat",w=5;"Custom"===this.inputs.parameters.extrusion.shape.type&&(w="low"===this.inputs.parameters.extrusion.shape.shapeQuality?5:12);let S,{regions:_,infos:M,vertices:A}=this._getShapePoints(w),k=0;if("round"===v){let e=this.inputs.shapeData,t=B.get(e);void 0!==t&&t.bevel===y&&t.curveSegments===w&&t.bevelSides===f?S=t.geometry:(S=new l(e,2*y,y,w,f,void 0,!0),B.set(e,{bevel:y,curveSegments:w,bevelSides:f,geometry:S})),k=S.getAttribute("position").count}let I=0,R=0;M.sort((e,t)=>e.start-t.start),M.forEach(e=>{e.verticesStart=I,e.verticesCount=e.continuous.reduce((e,t,s)=>e+(0!==s&&t?1:2),0),R+=e.verticesCount,I=R});let T,z=R*o,E=0;this._isOpenEnded()&&"flat"===v&&(T=this._getSurfaceTesselation(_),E=T.vertexCount);let j=z+2*E+2*k,U=z+2*E,G={positions:new Float32Array(3*j),normals:new Float32Array(3*j),uvs:new Float32Array(2*j)},F=S?S.getIndex().array:null,N=0;M.forEach(e=>{N+=e.count});let Z=N*(o-1)*6+(T?2*T.elementCount*3:0)+(F?2*F.length:0),H=new Uint32Array(Z),q=0;if(M.forEach(e=>{q=this._extrudeRegion(e,A,u,h,G,H,q,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(q=this._closeEnd(T,z,H,q,G,u[0],h[0],!1),q=this._closeEnd(T,z+E,H,q,G,u[u.length-1],h[h.length-1],!0)),S){G.positions.set(S.getAttribute("position").array,3*U),G.normals.set(S.getAttribute("normal").array,3*U),G.uvs.set(S.getAttribute("uv").array,2*U);for(let e=U;e<U+k;e++)G.uvs[2*e+1]=1e-4;let e=q;for(let e=0;e<F.length;e++)H[q++]=F[e]+U;U+=k,G.positions.set(S.getAttribute("position").array,3*U),G.normals.set(S.getAttribute("normal").array,3*U),G.uvs.set(S.getAttribute("uv").array,2*U);let t=q;for(let e=0;e<F.length;e++)H[q++]=F[e]+U;this.setAttribute("position",new C(G.positions,3)),this.setAttribute("normal",new C(G.normals,3)),this.setAttribute("uv",new C(G.uvs,2)),this._setIndexFromUint32(H);let s=D;s.copy(u[u.length-1]).setPosition(h[h.length-1]),this.applyMatrix4OnRange(s,U,j),s.copy(u[0]).setPosition(h[0]).multiply(O.makeScale(1,1,-1)),this.applyMatrix4OnRange(s,U-k,U),this.reverseIndicesOnRange(e,t)}else this.setAttribute("position",new C(G.positions,3)),this.setAttribute("normal",new C(G.normals,3)),this.setAttribute("uv",new C(G.uvs,2)),this._setIndexFromUint32(H)}_setIndexFromUint32(e){let t=!1;for(let s=e.length-1;s>=0;--s)if(e[s]>=65535){t=!0;break}this.setIndex(new C(t?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,t=c(e),s=G.get(t);if(void 0===s||s.subdivisions!==e.subdivisions||s.subdivisionMode!==e.subdivisionMode){let i=this._extractPathPoints(t),n=i.length<2?[]:this._computeBasisMatrices(i);s={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:i,matrices:n},G.set(t,s)}return s}_extractPathPoints(e){let t=this.inputs.path.subdivisions,s="uniform"===this.inputs.path.subdivisionMode?e.getSpacedPoints(4*t):e.getPoints(t);if(s.length<2)return[];let i=[s[0]];return s.forEach(e=>{i[i.length-1].distanceToSquared(e)>.001&&i.push(e)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let t=[],s=e.length,i=this.inputs.path.isClosed,n=new b,a=new b,r=new b,o=new b,l=new b(0,1,0);for(let h=0;h<s;h++){let u,p,c=e[h];u=0===h?i?e[e.length-2]:I.copy(c).multiplyScalar(2).sub(e[1]):e[h-1],p=h===s-1?i?e[1]:I.copy(c).multiplyScalar(2).sub(e[h-1]):e[h+1],R.subVectors(c,u).normalize(),T.subVectors(p,c).normalize();let d=z.addVectors(R,T).normalize();r.copy(d),0===h&&(d.equals(l)||E.copy(d).negate().equals(l))&&l.set(0,0,1);let m=j.crossVectors(l,d).normalize(),g=U.crossVectors(d,m).normalize();l.copy(g),o.copy(m),0===h&&(n.copy(g),a.copy(d));let y=(new P).makeBasis(m,g,d);t.push(y)}let h=i?a:r,u=i?n:new b(0,1,0),p=h.clone().cross(o).normalize(),c=Math.acos(u.dot(p));if(isNaN(c))return t;let d=u.clone().cross(p);h.dot(d)>0&&(c*=-1);for(let e=1;e<t.length;e++)t[e].multiply(k.makeRotationZ(c*e/t.length));return t}_applyPathModifiers(e,t,s){let i=e.length,{angle:n,twist:a,startScale:r,endScale:o}=this.inputs.parameters.extrusion,l=new P,h=new P;return e.forEach((e,u)=>{let p=0===u?0:u===i-1?1:(u-t)/(i-(0===s?0:1)-(t+(1-s)));l.makeRotationZ(x.lerp(n,n+a,p)*x.DEG2RAD);let c=x.lerp(r,o,p);h.makeScale(c,c,c),e.multiply(l).multiply(h)}),e}_getShapePoints(e,t=s.ODD){let i=this.inputs.shapeData,n=F.get(i);return(void 0===n||n.curveSegments!==e||n.windingRule!==t)&&(n={curveSegments:e,windingRule:t,shapePoints:this._computeShapePoints(e,t)},F.set(i,n)),n.shapePoints}_getSurfaceTesselation(e){let t,a=F.get(this.inputs.shapeData);if(void 0!==a?.surfaceTesselation)return a.surfaceTesselation;try{t=n({windingRule:s.ODD,elementType:i.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{t=o}return void 0!==a&&(a.surfaceTesselation=t),t}_computeShapePoints(e=12,t=s.ODD){let o,l,h=this.inputs.shapeData,u=h.extractShapePointsToFlatArray([],e),p=h.shapeHoles.map(t=>{let s=t.extractShapePointsToFlatArray([],e),i=[];for(let e=s.length-1;e>=1;e-=2){let t=s[e-1],n=s[e-0];i.push(t,n)}return i});try{o=n({windingRule:t,elementType:i.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{o=a}try{l=n({windingRule:s.ODD,elementType:i.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...p]})}catch{l=r}if(!o)throw new Error("error generating geometry");let c=o.elementCount;if(l){o.elementCount+=l.elementCount;for(let e=0;e<l.elements.length;e++){let t=l.elements[e],s=e%2==0?o.vertexCount:0;o.elements.push(t+s)}for(let e=0;e<l.vertexIndices.length;e++){let t=l.vertexIndices[e],s=o.vertexCount;o.vertexIndices.push(t+s)}for(let e=0;e<l.vertices.length;e++){let t=l.vertices[e];o.vertices.push(t)}}let d=1/0,m=-1/0,g=1/0,y=-1/0;for(let e=0,t=o.vertexCount;e<t;e++){let t=2*e,s=o.vertices[t+0],i=o.vertices[t+1];s<d&&(d=s),s>m&&(m=s),i<g&&(g=i),i>y&&(y=i)}let f=[];for(let e=o.elementCount-1;e>=0;e--){let t=e>=c,s=2*e,i=o.elements[s+0],n=o.elements[s+1],a=i+n,r={start:i,count:n,normals:[],isHole:t,continuous:[],verticesStart:0,verticesCount:0};f.push(r);let l=i,u=a-1,p=i+1,d=h.roundedCurves.length;do{let e=l-i,s=o.vertices[2*u+0],c=o.vertices[2*u+1],m=o.vertices[2*l+0],g=o.vertices[2*l+1],y=o.vertices[2*p+0],f=o.vertices[2*p+1],v=m-s,w=g-c,x=Math.sqrt(v*v+w*w);v/=x,w/=x;let S=m-y,b=g-f,_=Math.sqrt(S*S+b*b);S/=_,b/=_,r.normals[2*e+0]=-b,r.normals[2*e+1]=S;let P=o.vertexIndices[l];if(Array.isArray(P))r.continuous[e]=!1;else{let[t,s]=h.getCurveIndexFromVertexId(P-1,!0);if(s>0&&s<1)r.continuous[e]=!0;else{let i=1===s?t+1:t-1;i=(i+d)%d;let n=1===s?0:1,a=h.roundedCurves[t].getTangent(s),o=h.roundedCurves[i].getTangent(n);r.continuous[e]=a.dot(o)>.95}}t&&(r.normals[2*e+0]*=-1,r.normals[2*e+1]*=-1),[u,l,p]=[l,p,p+1],p>=a&&(p-=n)}while(p!==i+1)}return{regions:[u,...p],infos:f,vertices:o.vertices}}_insertVertex(e,t,s,i,n){let a=2*t,r=3*t;e.positions[r+0]=s.x,e.positions[r+1]=s.y,e.positions[r+2]=s.z,e.normals[r+0]=i.x,e.normals[r+1]=i.y,e.normals[r+2]=i.z,e.uvs[a+0]=n.x,e.uvs[a+1]=n.y}_extrudeRegion(e,t,s,i,n,a,r,o){let l=e.wallTemplate;if(void 0===l){l=[];for(let s=0;s<e.count;s++){let i,n,a=2*(e.start+s),r=t[a+0],o=t[a+1];if(e.continuous[s])i=e.normals[2*s+0],n=e.normals[2*s+1];else{let l=0===s?2*(e.start+e.count-1):a-2,h=r-t[l+0];i=-(o-t[l+1]),n=h,e.isHole||(i=-i,n=-n)}let h=0===s?1:s/e.count;if(l.push(r,o,i,n,h,0),!e.continuous[s]||0===s)if(0===s)l.push(r,o,e.normals[0],e.normals[1],0,1);else{let u=s===e.count-1?2*e.start:a+2,p=t[u+0]-r;i=-(t[u+1]-o),n=p,e.isHole||(i=-i,n=-n),l.push(r,o,i,n,h,1)}}e.wallTemplate=l}let h=s.length,u=l.length,p=n.positions,c=n.normals,d=n.uvs;for(let t=0;t<h;t++){let n=s[t].elements,a=n[0],r=n[1],o=n[2],m=n[4],g=n[5],y=n[6],f=n[12],v=n[13],w=n[14],x=i[t],S=t/(h-1),b=0,_=0,P=0,C=e.verticesStart*h+e.verticesCount*t;for(let e=0;e<u;e+=6){if(0===l[e+5]){let t=l[e+0],s=l[e+1];b=a*t+m*s+f+x.x,_=r*t+g*s+v+x.y,P=o*t+y*s+w+x.z}let t=l[e+2],s=l[e+3],i=a*t+m*s+f,n=r*t+g*s+v,h=o*t+y*s+w,u=1/(Math.sqrt(i*i+n*n+h*h)||1);i*=u,n*=u,h*=u;let M=2*C,A=3*C;p[A+0]=b,p[A+1]=_,p[A+2]=P,c[A+0]=i,c[A+1]=n,c[A+2]=h,d[M+0]=l[e+4],d[M+1]=S,C++}}let m=e.wallQuadPattern;if(void 0===m){m=[];let t=0;for(let s=0;s<e.count;s++)(!e.continuous[s]||0===s)&&t++,m.push(t,s===e.count-1?0:t+1),t++;e.wallQuadPattern=m}let g=h-1,y=m.length,f=e.isHole;for(let t=0;t<g;t++){let s=e.verticesStart*h+e.verticesCount*t,i=s+e.verticesCount;for(let e=0;e<y;e+=2){let t=s+m[e],n=s+m[e+1],o=i+m[e+1],l=i+m[e];f?(a[r++]=t,a[r++]=o,a[r++]=n,a[r++]=t,a[r++]=l,a[r++]=o):(a[r++]=t,a[r++]=n,a[r++]=o,a[r++]=t,a[r++]=o,a[r++]=l)}}return r}_closeEnd(e,t,s,i,n,a,r,o){let l=e.vertexCount,h=new b(0,0,o?-1:1).applyMatrix4(a),u=new b,p=new S;for(let s=0;s<l;s++){let i=2*s;u.set(e.vertices[i+0],e.vertices[i+1],0).applyMatrix4(a).add(r),this._insertVertex(n,t+s,u,h,p)}let c=e.elements;for(let n=0;n<e.elementCount;n++){let e=3*n;s[i++]=c[e+0]+t,s[i++]=c[e+(o?1:2)]+t,s[i++]=c[e+(o?2:1)]+t}return i}applyMatrix4OnRange(e,t,s){let i,n,a,r,o=e.elements,l=(new _).getNormalMatrix(e).elements,h=this.attributes.position,u=this.attributes.normal;if(!h||!u)return;let p=h.array,c=u.array,d=h.itemSize;for(let e=t*d,h=s*d;e<h;e+=d)i=p[e+0],n=p[e+1],a=p[e+2],r=1/(o[3]*i+o[7]*n+o[11]*a+o[15]),p[e+0]=(o[0]*i+o[4]*n+o[8]*a+o[12])*r,p[e+1]=(o[1]*i+o[5]*n+o[9]*a+o[13])*r,p[e+2]=(o[2]*i+o[6]*n+o[10]*a+o[14])*r,i=c[e+0],n=c[e+1],a=c[e+2],c[e+0]=l[0]*i+l[3]*n+l[6]*a,c[e+1]=l[1]*i+l[4]*n+l[7]*a,c[e+2]=l[2]*i+l[5]*n+l[8]*a;h.needsUpdate=!0,u.needsUpdate=!0}reverseIndicesOnRange(e,t){let s=this.index;if(s){for(let i=e;i<t;i+=3){let e=s.getX(i),t=s.getX(i+1),n=s.getX(i+2);s.setXYZ(i,n,t,e)}s.needsUpdate=!0}}};g("PathGeometry",(e,t,s)=>new A(e,t,s)),y("PathGeometry",class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let s=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),i=Math.abs(s.width),n=Math.abs(s.height??s.width),a=Math.abs(s.depth??0),r=t?.shapeData??h.create({parameters:{...v,width:"number"==typeof v.width?v.width:100,height:"number"==typeof v.height?v.height:100}}).userData.shape;return{path:e.path??f.defaultData(),parameters:Object.assign(s,{width:i,height:n,depth:a,extrusion:{...w,...s.extrusion}}),shapeData:r}}static build(e){if(e.path.points.length>=2){let t=new N(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}{let t=new M;return V(t),Object.assign(t,{userData:{...e,type:"PathGeometry"}})}}}),m("3d-paths");
|
|
1
|
+
import{A as e,ea as t,q as s,r as i,s as n,t as a,u as r,v as o,w as l,x as h,y as u,z as p}from"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{g as c,u as d}from"./runtime-chunk-PLJ25O2X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as m,f as g,h as y}from"./runtime-chunk-TZCHGFVF.js";import{ja as f,ka as v,la as w}from"./runtime-chunk-OW6T4XFV.js";import{Cc as x,Dc as S,Fc as b,Gc as _,Oc as P,Zc as C,dd as M}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var A=class extends t{constructor(e,t,s){super(e,t,s),this.isPathObject=!0,this._shapeId=null,this._lastShapeParams=null,this._lastShape=null,this._context=s}updateState(e,t){super.updateState(e,t),this.updateShape(),this.refreshAttachedCloners(t)}updateShape(){let t,s={...this.data.geometry.extrusion.shape};for(let e in s)"string"==typeof s[e]&&(s[e]=this._context.shared.getVariable(s[e],[this.uuid,"geometry","extrusion","shape",e]));if("Custom"===s.type){let e=s.shapeId;if(e!==this._shapeId&&this.detachShape(),e){this._shapeId=e;let s=this._context.scene.find(e);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(null!==this._lastShape&&this._sameShapeParams(s))t=this._lastShape;else{let i;switch(s.type){case"Rectangle":i=p;break;case"Ellipse":i=h;break;case"Polygon":i=u;break;case"Star":i=e;break;default:throw new Error(`Unknown shape type: ${s.type}`)}t=i.create({parameters:s}).userData.shape,this._lastShapeParams=s,this._lastShape=t??null}let i=this.geometry;t&&i.inputs&&(i.inputs.shapeData=t,i.build())}_sameShapeParams(e){let t=this._lastShapeParams;if(null===t)return!1;for(let s in e)if(!Object.is(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1;return!0}detachShape(){null!==this._shapeId&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,t){return super.updateTransformState(e,t)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let s=this.geometry.getAttribute("position");void 0!==s&&s.count>0?d(s,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:s.count,e,t):super.updateEntityBoxSize(e,t)}},D=new P,O=new P,k=new P,I=new b,R=new b,T=new b,E=new b,z=new b,j=new b,U=new b,F=new WeakMap,G=new WeakMap,B=new WeakMap;function V(e){e.setIndex(null),e.setAttribute("position",new C(new Float32Array(0),3)),e.setAttribute("normal",new C(new Float32Array(0),3)),e.setAttribute("uv",new C(new Float32Array(0),2)),e.setDrawRange(0,0)}var N=class extends M{constructor(e){super(),this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&1===this.inputs.parameters.extrusion.depth}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&1===e.depth&&function(e){let t=2*Math.PI;return(e%t+t)%t===(0%t+t)%t}(e.twist)&&e.startScale===e.endScale)}build(){let{points:e,matrices:t}=this._getSampledPath();if(e.length<2)return void V(this);let{depth:s,offset:i}=this.inputs.parameters.extrusion;s=Math.max(0,Math.min(s,1)),i=Math.max(0,Math.min(i,1));let n=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(i*n),r=this.inputs.path.isClosed?Math.ceil((s+i)*n):Math.ceil(Math.min(1,s+i)*n),o=Math.min(Math.max(2,r-a+1),n+2),h=[],u=[];for(let s=0;s<o;s++){let i=this.inputs.path.isClosed?(s+a)%e.length:Math.min(s+a,e.length-1);h.push(e[i].clone()),u.push(t[i].clone())}let p=(e,t,s)=>{h[e]=h[e].clone().lerp(h[t],s),u[e]=function(e,t,s){let i=[new b,new b,new b],n=[new b,new b,new b];return e.extractBasis(i[0],i[1],i[2]),t.extractBasis(n[0],n[1],n[2]),i.forEach((e,t)=>{let i=n[t],a=x.lerp(e.length(),i.length(),s);e.lerp(i,s).setLength(a)}),(new P).makeBasis(i[0],i[1],i[2])}(u[e],u[t],s)},c=0,d=i*n%1;(!this.inputs.path.isClosed||s<=1)&&(d||0===i)&&(c=d,p(0,1,c));let m=0,g=(i+s)*n%1;if((this.inputs.path.isClosed&&s<=1||!this.inputs.path.isClosed&&i+s<1)&&g&&(m=g,p(h.length-1,h.length-2,1-m)),0===s){let e=h.length-1;h[e].copy(h[0]),u[e].copy(u[0])}this._applyPathModifiers(u,c,m);let{bevel:y,bevelSides:f}=this.inputs.parameters.extrusion,v=y>0?this.inputs.parameters.extrusion.capType:"flat",w=5;"Custom"===this.inputs.parameters.extrusion.shape.type&&(w="low"===this.inputs.parameters.extrusion.shape.shapeQuality?5:12);let S,{regions:_,infos:M,vertices:A}=this._getShapePoints(w),k=0;if("round"===v){let e=this.inputs.shapeData,t=B.get(e);void 0!==t&&t.bevel===y&&t.curveSegments===w&&t.bevelSides===f?S=t.geometry:(S=new l(e,2*y,y,w,f,void 0,!0),B.set(e,{bevel:y,curveSegments:w,bevelSides:f,geometry:S})),k=S.getAttribute("position").count}let I=0,R=0;M.sort((e,t)=>e.start-t.start),M.forEach(e=>{e.verticesStart=I,e.verticesCount=e.continuous.reduce((e,t,s)=>e+(0!==s&&t?1:2),0),R+=e.verticesCount,I=R});let T,E=R*o,z=0;this._isOpenEnded()&&"flat"===v&&(T=this._getSurfaceTesselation(_),z=T.vertexCount);let j=E+2*z+2*k,U=E+2*z,F={positions:new Float32Array(3*j),normals:new Float32Array(3*j),uvs:new Float32Array(2*j)},G=S?S.getIndex().array:null,N=0;M.forEach(e=>{N+=e.count});let X=N*(o-1)*6+(T?2*T.elementCount*3:0)+(G?2*G.length:0),H=new Uint32Array(X),Z=0;if(M.forEach(e=>{Z=this._extrudeRegion(e,A,u,h,F,H,Z,this._isGeometryClosed()&&!this._isOpenEnded())}),T&&(Z=this._closeEnd(T,E,H,Z,F,u[0],h[0],!1),Z=this._closeEnd(T,E+z,H,Z,F,u[u.length-1],h[h.length-1],!0)),S){F.positions.set(S.getAttribute("position").array,3*U),F.normals.set(S.getAttribute("normal").array,3*U),F.uvs.set(S.getAttribute("uv").array,2*U);for(let e=U;e<U+k;e++)F.uvs[2*e+1]=1e-4;let e=Z;for(let e=0;e<G.length;e++)H[Z++]=G[e]+U;U+=k,F.positions.set(S.getAttribute("position").array,3*U),F.normals.set(S.getAttribute("normal").array,3*U),F.uvs.set(S.getAttribute("uv").array,2*U);let t=Z;for(let e=0;e<G.length;e++)H[Z++]=G[e]+U;this.setAttribute("position",new C(F.positions,3)),this.setAttribute("normal",new C(F.normals,3)),this.setAttribute("uv",new C(F.uvs,2)),this._setIndexFromUint32(H);let s=D;s.copy(u[u.length-1]).setPosition(h[h.length-1]),this.applyMatrix4OnRange(s,U,j),s.copy(u[0]).setPosition(h[0]).multiply(O.makeScale(1,1,-1)),this.applyMatrix4OnRange(s,U-k,U),this.reverseIndicesOnRange(e,t)}else this.setAttribute("position",new C(F.positions,3)),this.setAttribute("normal",new C(F.normals,3)),this.setAttribute("uv",new C(F.uvs,2)),this._setIndexFromUint32(H)}_setIndexFromUint32(e){let t=!1;for(let s=e.length-1;s>=0;--s)if(e[s]>=65535){t=!0;break}this.setIndex(new C(t?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,t=c(e),s=F.get(t);if(void 0===s||s.subdivisions!==e.subdivisions||s.subdivisionMode!==e.subdivisionMode){let i=this._extractPathPoints(t),n=i.length<2?[]:this._computeBasisMatrices(i);s={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:i,matrices:n},F.set(t,s)}return s}_extractPathPoints(e){let t=this.inputs.path.subdivisions,s="uniform"===this.inputs.path.subdivisionMode?e.getSpacedPoints(4*t):e.getPoints(t);if(s.length<2)return[];let i=[s[0]];return s.forEach(e=>{i[i.length-1].distanceToSquared(e)>.001&&i.push(e)}),this.inputs.path.isClosed&&i[i.length-1].distanceTo(i[0])<.001&&i.pop(),i}_computeBasisMatrices(e){let t=[],s=e.length,i=this.inputs.path.isClosed,n=new b,a=new b,r=new b,o=new b,l=new b(0,1,0);for(let h=0;h<s;h++){let u,p,c=e[h];u=0===h?i?e[e.length-2]:I.copy(c).multiplyScalar(2).sub(e[1]):e[h-1],p=h===s-1?i?e[1]:I.copy(c).multiplyScalar(2).sub(e[h-1]):e[h+1],R.subVectors(c,u).normalize(),T.subVectors(p,c).normalize();let d=E.addVectors(R,T).normalize();r.copy(d),0===h&&(d.equals(l)||z.copy(d).negate().equals(l))&&l.set(0,0,1);let m=j.crossVectors(l,d).normalize(),g=U.crossVectors(d,m).normalize();l.copy(g),o.copy(m),0===h&&(n.copy(g),a.copy(d));let y=(new P).makeBasis(m,g,d);t.push(y)}let h=i?a:r,u=i?n:new b(0,1,0),p=h.clone().cross(o).normalize(),c=Math.acos(u.dot(p));if(isNaN(c))return t;let d=u.clone().cross(p);h.dot(d)>0&&(c*=-1);for(let e=1;e<t.length;e++)t[e].multiply(k.makeRotationZ(c*e/t.length));return t}_applyPathModifiers(e,t,s){let i=e.length,{angle:n,twist:a,startScale:r,endScale:o}=this.inputs.parameters.extrusion,l=new P,h=new P;return e.forEach((e,u)=>{let p=0===u?0:u===i-1?1:(u-t)/(i-(0===s?0:1)-(t+(1-s)));l.makeRotationZ(x.lerp(n,n+a,p)*x.DEG2RAD);let c=x.lerp(r,o,p);h.makeScale(c,c,c),e.multiply(l).multiply(h)}),e}_getShapePoints(e,t=s.ODD){let i=this.inputs.shapeData,n=G.get(i);return(void 0===n||n.curveSegments!==e||n.windingRule!==t)&&(n={curveSegments:e,windingRule:t,shapePoints:this._computeShapePoints(e,t)},G.set(i,n)),n.shapePoints}_getSurfaceTesselation(e){let t,a=G.get(this.inputs.shapeData);if(void 0!==a?.surfaceTesselation)return a.surfaceTesselation;try{t=n({windingRule:s.ODD,elementType:i.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{t=o}return void 0!==a&&(a.surfaceTesselation=t),t}_computeShapePoints(e=12,t=s.ODD){let o,l,h=this.inputs.shapeData,u=h.extractShapePointsToFlatArray([],e),p=h.shapeHoles.map(t=>{let s=t.extractShapePointsToFlatArray([],e),i=[];for(let e=s.length-1;e>=1;e-=2){let t=s[e-1],n=s[e-0];i.push(t,n)}return i});try{o=n({windingRule:t,elementType:i.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{o=a}try{l=n({windingRule:s.ODD,elementType:i.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...p]})}catch{l=r}if(!o)throw new Error("error generating geometry");let c=o.elementCount;if(l){o.elementCount+=l.elementCount;for(let e=0;e<l.elements.length;e++){let t=l.elements[e],s=e%2==0?o.vertexCount:0;o.elements.push(t+s)}for(let e=0;e<l.vertexIndices.length;e++){let t=l.vertexIndices[e],s=o.vertexCount;o.vertexIndices.push(t+s)}for(let e=0;e<l.vertices.length;e++){let t=l.vertices[e];o.vertices.push(t)}}let d=1/0,m=-1/0,g=1/0,y=-1/0;for(let e=0,t=o.vertexCount;e<t;e++){let t=2*e,s=o.vertices[t+0],i=o.vertices[t+1];s<d&&(d=s),s>m&&(m=s),i<g&&(g=i),i>y&&(y=i)}let f=[];for(let e=o.elementCount-1;e>=0;e--){let t=e>=c,s=2*e,i=o.elements[s+0],n=o.elements[s+1],a=i+n,r={start:i,count:n,normals:[],isHole:t,continuous:[],verticesStart:0,verticesCount:0};f.push(r);let l=i,u=a-1,p=i+1,d=h.roundedCurves.length;do{let e=l-i,s=o.vertices[2*u+0],c=o.vertices[2*u+1],m=o.vertices[2*l+0],g=o.vertices[2*l+1],y=o.vertices[2*p+0],f=o.vertices[2*p+1],v=m-s,w=g-c,x=Math.sqrt(v*v+w*w);v/=x,w/=x;let S=m-y,b=g-f,_=Math.sqrt(S*S+b*b);S/=_,b/=_,r.normals[2*e+0]=-b,r.normals[2*e+1]=S;let P=o.vertexIndices[l];if(Array.isArray(P))r.continuous[e]=!1;else{let[t,s]=h.getCurveIndexFromVertexId(P-1,!0);if(s>0&&s<1)r.continuous[e]=!0;else{let i=1===s?t+1:t-1;i=(i+d)%d;let n=1===s?0:1,a=h.roundedCurves[t].getTangent(s),o=h.roundedCurves[i].getTangent(n);r.continuous[e]=a.dot(o)>.95}}t&&(r.normals[2*e+0]*=-1,r.normals[2*e+1]*=-1),[u,l,p]=[l,p,p+1],p>=a&&(p-=n)}while(p!==i+1)}return{regions:[u,...p],infos:f,vertices:o.vertices}}_insertVertex(e,t,s,i,n){let a=2*t,r=3*t;e.positions[r+0]=s.x,e.positions[r+1]=s.y,e.positions[r+2]=s.z,e.normals[r+0]=i.x,e.normals[r+1]=i.y,e.normals[r+2]=i.z,e.uvs[a+0]=n.x,e.uvs[a+1]=n.y}_extrudeRegion(e,t,s,i,n,a,r,o){let l=e.wallTemplate;if(void 0===l){l=[];for(let s=0;s<e.count;s++){let i,n,a=2*(e.start+s),r=t[a+0],o=t[a+1];if(e.continuous[s])i=e.normals[2*s+0],n=e.normals[2*s+1];else{let l=0===s?2*(e.start+e.count-1):a-2,h=r-t[l+0];i=-(o-t[l+1]),n=h,e.isHole||(i=-i,n=-n)}let h=0===s?1:s/e.count;if(l.push(r,o,i,n,h,0),!e.continuous[s]||0===s)if(0===s)l.push(r,o,e.normals[0],e.normals[1],0,1);else{let u=s===e.count-1?2*e.start:a+2,p=t[u+0]-r;i=-(t[u+1]-o),n=p,e.isHole||(i=-i,n=-n),l.push(r,o,i,n,h,1)}}e.wallTemplate=l}let h=s.length,u=l.length,p=n.positions,c=n.normals,d=n.uvs;for(let t=0;t<h;t++){let n=s[t].elements,a=n[0],r=n[1],o=n[2],m=n[4],g=n[5],y=n[6],f=n[12],v=n[13],w=n[14],x=i[t],S=t/(h-1),b=0,_=0,P=0,C=e.verticesStart*h+e.verticesCount*t;for(let e=0;e<u;e+=6){if(0===l[e+5]){let t=l[e+0],s=l[e+1];b=a*t+m*s+f+x.x,_=r*t+g*s+v+x.y,P=o*t+y*s+w+x.z}let t=l[e+2],s=l[e+3],i=a*t+m*s+f,n=r*t+g*s+v,h=o*t+y*s+w,u=1/(Math.sqrt(i*i+n*n+h*h)||1);i*=u,n*=u,h*=u;let M=2*C,A=3*C;p[A+0]=b,p[A+1]=_,p[A+2]=P,c[A+0]=i,c[A+1]=n,c[A+2]=h,d[M+0]=l[e+4],d[M+1]=S,C++}}let m=e.wallQuadPattern;if(void 0===m){m=[];let t=0;for(let s=0;s<e.count;s++)(!e.continuous[s]||0===s)&&t++,m.push(t,s===e.count-1?0:t+1),t++;e.wallQuadPattern=m}let g=h-1,y=m.length,f=e.isHole;for(let t=0;t<g;t++){let s=e.verticesStart*h+e.verticesCount*t,i=s+e.verticesCount;for(let e=0;e<y;e+=2){let t=s+m[e],n=s+m[e+1],o=i+m[e+1],l=i+m[e];f?(a[r++]=t,a[r++]=o,a[r++]=n,a[r++]=t,a[r++]=l,a[r++]=o):(a[r++]=t,a[r++]=n,a[r++]=o,a[r++]=t,a[r++]=o,a[r++]=l)}}return r}_closeEnd(e,t,s,i,n,a,r,o){let l=e.vertexCount,h=new b(0,0,o?-1:1).applyMatrix4(a),u=new b,p=new S;for(let s=0;s<l;s++){let i=2*s;u.set(e.vertices[i+0],e.vertices[i+1],0).applyMatrix4(a).add(r),this._insertVertex(n,t+s,u,h,p)}let c=e.elements;for(let n=0;n<e.elementCount;n++){let e=3*n;s[i++]=c[e+0]+t,s[i++]=c[e+(o?1:2)]+t,s[i++]=c[e+(o?2:1)]+t}return i}applyMatrix4OnRange(e,t,s){let i,n,a,r,o=e.elements,l=(new _).getNormalMatrix(e).elements,h=this.attributes.position,u=this.attributes.normal;if(!h||!u)return;let p=h.array,c=u.array,d=h.itemSize;for(let e=t*d,h=s*d;e<h;e+=d)i=p[e+0],n=p[e+1],a=p[e+2],r=1/(o[3]*i+o[7]*n+o[11]*a+o[15]),p[e+0]=(o[0]*i+o[4]*n+o[8]*a+o[12])*r,p[e+1]=(o[1]*i+o[5]*n+o[9]*a+o[13])*r,p[e+2]=(o[2]*i+o[6]*n+o[10]*a+o[14])*r,i=c[e+0],n=c[e+1],a=c[e+2],c[e+0]=l[0]*i+l[3]*n+l[6]*a,c[e+1]=l[1]*i+l[4]*n+l[7]*a,c[e+2]=l[2]*i+l[5]*n+l[8]*a;h.needsUpdate=!0,u.needsUpdate=!0}reverseIndicesOnRange(e,t){let s=this.index;if(s){for(let i=e;i<t;i+=3){let e=s.getX(i),t=s.getX(i+1),n=s.getX(i+2);s.setXYZ(i,n,t,e)}s.needsUpdate=!0}}};g("PathGeometry",(e,t,s)=>new A(e,t,s)),y("PathGeometry",class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){let s=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),i=Math.abs(s.width),n=Math.abs(s.height??s.width),a=Math.abs(s.depth??0),r=t?.shapeData??h.create({parameters:{...v,width:"number"==typeof v.width?v.width:100,height:"number"==typeof v.height?v.height:100}}).userData.shape;return{path:e.path??f.defaultData(),parameters:Object.assign(s,{width:i,height:n,depth:a,extrusion:{...w,...s.extrusion}}),shapeData:r}}static build(e){if(e.path.points.length>=2){let t=new N(e);return Object.assign(t,{userData:{...e,type:"PathGeometry"}})}{let t=new M;return V(t),Object.assign(t,{userData:{...e,type:"PathGeometry"}})}}}),m("3d-paths");
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as t}from"./runtime-chunk-EGI7ABC6.js";import"./runtime-chunk-IGBRWWDI.js";import"./runtime-chunk-DNWPGXEC.js";import"./runtime-chunk-TU4KDRKR.js";import{a as i,b as s}from"./runtime-chunk-DZNU62CT.js";import"./runtime-chunk-2657LZHS.js";import"./runtime-chunk-6WHNEYAL.js";import"./runtime-chunk-CDZQF4NV.js";import"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{f as e,g as a}from"./runtime-chunk-QVC5UDJO.js";import"./runtime-chunk-PLJ25O2X.js";import{f as n}from"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as r}from"./runtime-chunk-TZCHGFVF.js";import{u as o}from"./runtime-chunk-OW6T4XFV.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var c=class{constructor(t,i,s,a,n,r,o,c){this.eventId=t,this.id=i,this.data=s,this.dataEvent=a,this.object=n,this.stage=!1,this.actions=e(a,s.actions,r,o,c,n)}disconnect(){a(this.actions)}dispatchIn(){this.actions.Audio.forEach(t=>t.dispatchBasic()),this.actions.Particles.forEach(t=>t.dispatchBasic()),this.actions.Video.forEach(t=>t.dispatchBasic()),this.actions.Create.forEach(t=>t.dispatch()),this.actions.Destroy.forEach(t=>t.dispatch()),this.actions.Reset.forEach(t=>t.dispatch()),this.actions.Link.forEach(t=>t.dispatch()),this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.actions.Transition.forEach(t=>t.toggle()),this.actions.Animation.forEach(t=>t.play()),this.actions.SwitchCamera.forEach(t=>t.play()),this.actions.SceneTransition.forEach(t=>t.dispatch()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchOut(){this.actions.Transition.forEach(t=>{t.toggle()})}},h=class extends i{constructor(t,i){super(t),this.eventManager=i,this.breakpoints=[],this.resize=(t,i)=>{this.breakpoints.forEach(s=>{let e,a=o.deviceToSize(s.data.size),n="horizontal"===s.dataEvent.orientation?t:i;switch(s.data.operator){case"<":e=n<a[0];break;case">":e=n>a[0];break;case"<>":e=n>a[0]&&n<a[1]}s.stage!==e&&(s.stage=e,s.stage?s.dispatchIn():s.dispatchOut())})},this.onResizeObserver=new ResizeObserver(t=>{for(let i of t){let{width:t,height:s}=i.contentRect;this.resize(t,s)}})}connect(){let{page:i,sharedAssets:s,domElement:e}=this.eventContext;this.onResizeObserver.observe(e);let a=t=>{if(t.visible&&t.data?.events.length)for(let{data:e,id:a}of t.data.events)e.disabled||"Resize"===e.type&&e.breakpoints.forEach(({data:n,id:r})=>{try{let o=new c(a,r,n,e,t,i,s,this.eventManager);this.breakpoints.push(o)}catch(t){}})};i.traverseEntity(i=>{(n(i)||i instanceof t)&&i.frame?.traverse(t=>{a(t)}),a(i)})}disconnect(){this.onResizeObserver.disconnect(),this.breakpoints.forEach(t=>{t.disconnect()}),this.breakpoints=[]}};s("Resize",({eventContext:t,eventManager:i})=>new h(t,i)),r("resize");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./runtime-chunk-
|
|
1
|
+
import{a as t}from"./runtime-chunk-IK4H7UNI.js";import"./runtime-chunk-EGI7ABC6.js";import"./runtime-chunk-IGBRWWDI.js";import"./runtime-chunk-DNWPGXEC.js";import"./runtime-chunk-TU4KDRKR.js";import"./runtime-chunk-2657LZHS.js";import"./runtime-chunk-6WHNEYAL.js";import"./runtime-chunk-CDZQF4NV.js";import"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{b as e,e as i}from"./runtime-chunk-QVC5UDJO.js";import"./runtime-chunk-PLJ25O2X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-OW6T4XFV.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var n=class{constructor(t,e,i,a,n){this.data=t,this.page=e,this.eventManager=i,this.shared=a,this.condition=n,this.timeOutId=-1,this.scene=e.scene}dispatch(){if(!1===i(this.shared,this.condition))return!1;this.data.target!==this.page.uuid&&(window.clearTimeout(this.timeOutId),this.timeOutId=window.setTimeout(()=>{this.play()},1e3*this.data.delay))}dispose(){window.clearTimeout(this.timeOutId)}play(){if(this.scene.children.every(t=>t.uuid!==this.data.target||t.data.uiScene))return;"fade"===this.data.transition&&this.data.duration>0&&this.eventManager.eventContext.renderer.renderFromSceneForSceneTransitionPass(this.scene,this.scene.activeCamera,1e3*this.data.duration),this.eventManager.deactivate(),this.eventManager.controlsManager.deactivate();let e=this.scene.activeCamera;this.scene.updatePage(this.data.target),this.scene.traverseVisibleEntity(t=>{"ParticleSystem"===t.type&&(t.sleep(),t.wakeUp(),t.data.autoPlay?t.start():t.stop())}),this.scene.activePage.switchToPlayCamera(),this.scene.activeCamera.copyViewPlaneSize(e),t(this.scene.activePage,this.shared),this.eventManager.activate(),this.eventManager.controlsManager.activate(this.eventManager)}};e("SceneTransition",({data:t,page:e,eventManager:i,shared:a,actionCondition:s})=>new n(t,e,i,a,s)),a("scene-transition");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./runtime-chunk-NBYTQLIB.js";import{h as e}from"./runtime-chunk-
|
|
1
|
+
import{a as t}from"./runtime-chunk-NBYTQLIB.js";import{h as e}from"./runtime-chunk-EGI7ABC6.js";import"./runtime-chunk-IGBRWWDI.js";import"./runtime-chunk-DNWPGXEC.js";import"./runtime-chunk-TU4KDRKR.js";import{a as i,b as s}from"./runtime-chunk-DZNU62CT.js";import"./runtime-chunk-2657LZHS.js";import"./runtime-chunk-6WHNEYAL.js";import"./runtime-chunk-CDZQF4NV.js";import"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import{f as n,g as o}from"./runtime-chunk-QVC5UDJO.js";import"./runtime-chunk-PLJ25O2X.js";import{f as r}from"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-OW6T4XFV.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var h=class{constructor(t,e,i,s,o,r){this.id=t,this.data=e,this.object=i,this.scrollCounter=0,this.actions=n(e,e.actions,s,o,r,i)}connect(){this.scrollCounter=0}disconnect(){o(this.actions)}dispatch(t){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())});let e=t>0?1:-1;this.scrollCounter+=e,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let i=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(t=>t.seek(i)),this.actions.Animation.forEach(t=>t.seek(e)),this.actions.TimelineAnimation.forEach(t=>t.seek(i)),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatchUserEvent(t){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),t?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()}),this.actions.TimelineAnimation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},c=class{constructor(t,e,i,s,o,r,a){this.id=t,this.data=e,this.object=i,this.domElement=r,this.eventManager=a,this.scrollStart=0,this.scrollEnd=0,this.actions=n(e,e.actions,s,o,a,i)}getStickyParentElement(){let t=this.domElement;for(;t;){if("sticky"===window.getComputedStyle(t).position)return t;t=t.parentElement}return null}computeScrollBounds(){let t=this.getStickyParentElement(),e=t?.parentElement,i=this.domElement.getBoundingClientRect(),s={top:i.top,bottom:i.bottom,left:i.left,right:i.right,width:i.width,height:i.height};if(e){let n=e.getBoundingClientRect(),o=window.getComputedStyle(t),r=parseFloat(o.marginTop)+parseFloat(o.marginBottom),a=parseFloat(o.top),h=parseFloat(o.bottom),c=n.height-r;if(isNaN(a)){if(!isNaN(h)){let t=document.body.clientHeight??window.innerHeight,e=window.innerWidth-(document.documentElement.clientWidth??window.innerWidth);i.bottom===t-h?(s.top+=n.top-i.height+h+e,s.bottom+=n.top-i.height+h+e):i.bottom<t-h&&(s.top-=c-i.height,s.bottom-=c-i.height)}}else i.top===a?(s.top+=n.top-a,s.bottom+=n.top-a):i.top<0&&(s.top-=c-i.height,s.bottom-=c-i.height)}let n=document.body,o=document.documentElement,r=window.pageYOffset||o.scrollTop||n.scrollTop,a=o.clientTop||n.clientTop||0,h=Math.round(s.top+r-a);if("enter"===this.data.startFrom){let t=window.innerHeight,e=s.height,i=this.data.enterAnchor,n="top"===i?t:"bottom"===i?t-e:t-.5*e;this.scrollStart=h-n}else this.scrollStart=0;this.scrollStart+=this.data.startOffset??0,this.scrollEnd=this.scrollStart+(this.data.endAfter??400),this.box=s,this.computeScroll({x:window.scrollX,y:window.scrollY})}connect(){this.computeScrollBounds()}disconnect(){o(this.actions)}handleResize(){this.computeScrollBounds()}get isInvalidBox(){return void 0===this.box||0===this.box.width&&0===this.box.height&&0===this.box.top&&0===this.box.bottom}computeScroll({x:t,y:e}){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())});let i=this.scrollEnd-this.scrollStart,s=Math.min(1,Math.max(0,(e-this.scrollStart)/i));this.actions.Transition.forEach(t=>t.seek(s)),this.actions.Animation.forEach(t=>t.seek(s)),this.actions.TimelineAnimation.forEach(t=>t.seek(s)),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}dispatch(t){this.isInvalidBox&&this.computeScrollBounds(),this.computeScroll(t)}dispatchUserEvent(t){this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),t?(this.actions.Transition.forEach(t=>t.reverseFromCurrent()),this.actions.Animation.forEach(t=>t.reverseFromCurrent()),this.actions.TimelineAnimation.forEach(t=>t.reverseFromCurrent())):(this.actions.Transition.forEach(t=>{t.playFromCurrent()}),this.actions.Animation.forEach(t=>{t.playFromCurrent()}),this.actions.TimelineAnimation.forEach(t=>{t.playFromCurrent()})),this.actions.Create.forEach(t=>t.dispatchThrottled()),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch())}},l=class extends i{constructor(e,i){super(e),this.managers=i,this.wheelEventsPerObject=new Map,this.scrollEventsPerObject=new Map,this.isInview=!0,this.handleResize=()=>{[...this.scrollEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(t=>t.handleResize())})},this.onScroll=t=>{if(!this.isInview)return;let e={y:window.scrollY,x:window.scrollX};[...this.scrollEventsPerObject.entries()].forEach(([t,i])=>{t.dispatchEvent({type:"beginEvent",eventName:"Scroll",scroll:e}),i.forEach(t=>t.dispatch(e))})},this.onWheel=t=>{!this.isInview||t.ctrlKey||[...this.wheelEventsPerObject.entries()].forEach(([e,i])=>{e.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:t.deltaY}),i.forEach(e=>e.dispatch(t.deltaY))})},this.onUserEvent=({eventName:e,target:i,reverse:s})=>{if(!e||!i)return;let n=t(e);n&&"Scroll"===n&&(i.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.wheelEventsPerObject.get(i)?.forEach(t=>{t.dispatchUserEvent(s)}))}}connect(){let{page:t,sharedAssets:i,domElement:s,isExport:n}=this.eventContext,o=e=>{if(e.data?.events.length)for(let{id:o,data:r}of e.data.events)if(!r.disabled&&"Scroll"===r.type)if("load"!==r.trigger&&n){let n=new c(o,r,e,t,i,s,this.managers);this.scrollEventsPerObject.has(e)?this.scrollEventsPerObject.get(e)?.push(n):this.scrollEventsPerObject.set(e,[n])}else{let s=new h(o,r,e,t,i,this.managers);this.wheelEventsPerObject.has(e)?this.wheelEventsPerObject.get(e)?.push(s):this.wheelEventsPerObject.set(e,[s])}};t.traverseEntity(t=>{(r(t)||t instanceof e)&&t.frame?.traverse(t=>{o(t)}),o(t)}),this.intersectionObserver=new IntersectionObserver(t=>{let e=t[0];e&&(this.isInview=e.isIntersecting)},{root:null}),this.intersectionObserver.observe(this.eventContext.domElement),[...this.wheelEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(t=>t.connect()),t.addEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(t=>t.connect()),t.addEventListener("userEvent",this.onUserEvent)}),[...this.wheelEventsPerObject.values()].some(t=>t.length)&&(this.domEventsNeeded.add("wheel"),window.addEventListener("wheel",this.onWheel)),[...this.scrollEventsPerObject.values()].some(t=>t.length)&&(this.domEventsNeeded.add("scroll"),window.addEventListener("scroll",this.onScroll),window.addEventListener("resize",this.handleResize))}disconnect(){window.removeEventListener("wheel",this.onWheel),window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.handleResize),this.intersectionObserver.unobserve(this.eventContext.domElement),this.domEventsNeeded.clear(),[...this.wheelEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(t=>t.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)}),[...this.scrollEventsPerObject.entries()].forEach(([t,e])=>{e.forEach(t=>t.disconnect()),t.removeEventListener("userEvent",this.onUserEvent)})}};s("Scroll",({eventContext:t,eventManager:e})=>new l(t,e)),a("scroll");
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as m}from"./runtime-chunk-Y365A3K5.js";import"./runtime-chunk-U6S2BBR7.js";import"./runtime-chunk-243VQV5T.js";import"./runtime-chunk-SXDO5LXF.js";import"./runtime-chunk-F7OUYIT6.js";import"./runtime-chunk-6WHNEYAL.js";import"./runtime-chunk-DZOSSY2K.js";import"./runtime-chunk-CDZQF4NV.js";import"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import"./runtime-chunk-PLJ25O2X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as n,f as r}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-OW6T4XFV.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";r("ShapeBlendGeometry",(n,r,t)=>new m(n,r,t)),n("shape-blends");
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./runtime-chunk-
|
|
1
|
+
import{a as t}from"./runtime-chunk-243VQV5T.js";import{a as e,b as i}from"./runtime-chunk-T53JMQSH.js";import{B as r,n}from"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import"./runtime-chunk-PLJ25O2X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as s,f as o,h as a}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-OW6T4XFV.js";import{Dc as h,Jd as l,Ld as u,Nd as c,Qd as f,Qe as d,Rd as p,Sd as g,Tc as m}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var y=class{constructor(){this.type="ShapePath",this.color=new m,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new f,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,i,r){return this.currentPath?.quadraticCurveTo(t,e,i,r),this}bezierCurveTo(t,e,i,r,n,s){return this.currentPath?.bezierCurveTo(t,e,i,r,n,s),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let t={loc:0,t:0};function e(e,r,n,s){let o=e.x,a=r.x,h=n.x,l=s.x,u=e.y,c=r.y,f=n.y,d=s.y,p=(l-h)*(u-f)-(d-f)*(o-h),g=(d-f)*(a-o)-(l-h)*(c-u),m=p/g,y=((a-o)*(u-f)-(c-u)*(o-h))/g;if(0===g&&0!==p||m<=0||m>=1||y<0||y>1)return null;if(0===p&&0===g){for(let h=0;h<2;h++){if(i(0===h?n:s,e,r),0===t.loc){let e=0===h?n:s;return{x:e.x,y:e.y,t:t.t}}if(2===t.loc)return{x:+(o+t.t*(a-o)).toPrecision(10),y:+(u+t.t*(c-u)).toPrecision(10),t:t.t}}return null}for(let o=0;o<2;o++)if(i(0===o?n:s,e,r),0===t.loc){let e=0===o?n:s;return{x:e.x,y:e.y,t:t.t}}return{x:+(o+m*(a-o)).toPrecision(10),y:+(u+m*(c-u)).toPrecision(10),t:m}}function i(e,i,r){let n,s=r.x-i.x,o=r.y-i.y,a=e.x-i.x,h=e.y-i.y,l=s*h-a*o;return e.x===i.x&&e.y===i.y?(t.loc=0,void(t.t=0)):e.x===r.x&&e.y===r.y?(t.loc=1,void(t.t=1)):void(l<-Number.EPSILON?t.loc=3:l>Number.EPSILON?t.loc=4:s*a<0||o*h<0?t.loc=5:Math.sqrt(s*s+o*o)<Math.sqrt(a*a+h*h)?t.loc=6:(n=0!==s?a/s:h/o,t.loc=2,t.t=n))}let r=0,n=999999999,s=-999999999,o=[];this.subPaths.forEach(t=>{let e=t.getPoints(),i=-999999999,a=999999999,l=-999999999,u=999999999;for(let t=0;t<e.length;t++){let r=e[t];r.y>i&&(i=r.y),r.y<a&&(a=r.y),r.x>l&&(l=r.x),r.x<u&&(u=r.x)}s<=l&&(s=l+1),n>=u&&(n=u-1),e.length&&o.push({curves:t.curves,points:e,isCW:g.isClockWise(e),identifier:r++,boundingBox:new d(new h(u,a),new h(l,i))})});let a=o.map(t=>function(t,i,r,n,s){(null==s||""===s)&&(s="nonzero");let o=new h;t.boundingBox.getCenter(o);let a=function(t,i,r){let n=new h;i.getCenter(n);let s=[];return r.forEach(i=>{i.boundingBox.containsPoint(n)&&function(t,i){let r=[],n=[];for(let s=1;s<t.length;s++){let o=t[s-1],a=t[s];for(let t=1;t<i.length;t++){let s=e(o,a,i[t-1],i[t]);null!==s&&void 0===r.find(t=>t.t<=s.t+Number.EPSILON&&t.t>=s.t-Number.EPSILON)&&(r.push(s),n.push(new h(s.x,s.y)))}}return n}(t,i.points).forEach(t=>{s.push({identifier:i.identifier,isCW:i.isCW,point:t})})}),s.sort((t,e)=>t.point.x-e.point.x),s}([new h(r,o.y),new h(n,o.y)],t.boundingBox,i);a.sort((t,e)=>t.point.x-e.point.x);let l=[],u=[];a.forEach(e=>{e.identifier===t.identifier?l.push(e):u.push(e)});let c=l[0].point.x,f=[],d=0;for(;d<u.length&&u[d].point.x<c;)f.length>0&&f[f.length-1]===u[d].identifier?f.pop():f.push(u[d].identifier),d++;if(f.push(t.identifier),"evenodd"===s){let e=f.length%2==0,i=f[f.length-2];return{identifier:t.identifier,isHole:e,for:i}}if("nonzero"===s){let e=!0,r=null,n=null;for(let t=0;t<f.length;t++){let s=f[t];i[s]&&(e?(n=i[s].isCW,e=!1,r=s):n!==i[s].isCW&&(n=i[s].isCW,e=!0))}return{identifier:t.identifier,isHole:e,for:r}}console.warn('fill-rule: "'+s+'" is currently not implemented.')}(t,o,n,s,this.userData?.style.fillRule)),l=[];return o.forEach(t=>{let e=a[t.identifier];if(e&&!e.isHole){let e=new p;e.curves=t.curves,a.filter(e=>e?.isHole&&e.for===t.identifier).forEach(t=>{if(t){let i=o[t.identifier],r=new f;r.curves=i.curves,e.holes.push(r)}}),l.push(e)}}),l}},x=new class{async load(t,e,r=()=>{}){let{load:n}=await i;n(t,(t,i)=>{t||!i?r(t??"Something went wrong"):e(i)})}async parse(t){let{parse:e,Bidi:r}=await i;try{let i=e(t),n=new r,s=t=>i.charToGlyphIndex(t.char);return n.registerModifier("glyphIndex",null,s),n.applyFeatures(i,i.defaultRenderOptions.features),{font:i,bidi:n}}catch(t){console.error(t)}}};function b(t,e){return e.state.glyphIndex===t||e.state.fina===t||e.state.medi===t||e.state.init===t}o("TextGeometry",(e,i,r)=>new t(e,i,r));var w={create:(t,e)=>new r(t,e)};a("TextGeometry",w),a("InputGeometry",w),n(class{constructor(t){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=this.load(t)}async load(t){try{let i=await async function(t){let i,r,n=!1;if(t.url?(i=await async function(t){let e;try{e=await fetch(t)}catch(e){throw new Error(`could not fetch the font at ${t}: ${e}`)}if(!e.ok)throw new Error(`${e.status} ${e.statusText} fetching the font at ${t}`);return await e.arrayBuffer()}(t.url),r=t.url,n=t.url.startsWith("/")):t.data&&(i=t.data.buffer.slice(t.data.byteOffset,t.data.byteOffset+t.data.byteLength)),i){if(!e)return{font:void 0,url:r,intercepted:n,arr:i,bidi:null};{let t=await x.parse(i);if(t)return{font:t.font,url:r,intercepted:n,arr:i,bidi:t.bidi}}}}(t);i&&(this._arrayBuffer=i.arr,this._url=i.url,this.font=i.font,this._intercepted=i.intercepted,this._isLoaded=!0,this._bidi=i.bidi)}catch(e){console.warn(`Could not load the font "${t.url??"(inline data)"}"`,e)}}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(e);let n=r.tokenizer.tokens,s=[],o=0,a=i.length===n.length;for(let r=0;r<i.length;r++){let h=i[r].index,l=String.fromCharCode(i[r].unicode),u=n[o];if(b(h,u)||a)s.push({char:l,index:h,replacements:[u.state.glyphIndex],replacementChars:[u.char]}),o++;else{let i=u.char,r="",n=[u.state.glyphIndex],a=[],c=!1;for(;!c;)o++,r=e.charAt(o),i+=r,n.push(t.charToGlyphIndex(r)),a=t.stringToGlyphs(i),1===a.length&&a[0].index===h&&(c=!0),o>e.length&&(c=!0);s.push({char:l,index:h,replacements:n,replacementChars:Array.from(i)}),o++}}return s}generateShapes(t,e,i){if(!this._isLoaded)return;let r=this.font,n=e.fontSize/this.unitsPerEm,s=e.fontSize*e.lineHeight,o=t.map(t=>this.getTextWidth(t,e)),a="string"==typeof e.width?Number(i.getVariable(e.width)):e.width,h="string"==typeof e.height?Number(i.getVariable(e.height)):e.height,l=this.getCharWidth("\n",e),u=1===e.horizontalAlign?l:0,c=this.getLineInitialOffsetX(o[0],a,e.horizontalAlign,t[0],l),f=this.getLineInitialOffsetY(s,t.length,h,n,e.verticalAlign),d=[],p=t.map(()=>[]),g=t.map(()=>[]);for(let h=0;h<t.length;h++){let m=t[h],y={features:{liga:!0},letterSpacing:e.letterSpacing},x=[];try{x=r.stringToGlyphs(m,y)}catch(t){console.warn(t)}c=this.getLineInitialOffsetX(o[h],a,e.horizontalAlign,m,l);let b=[];try{b=this.reverseLigaturesTable(r,m,x)}catch(t){console.warn(t)}let w=this.computeSpaceWidthForLine(t,h,e,i),P=0,v=x[0];v&&2===e.horizontalAlign&&void 0!==v.leftSideBearing&&(c-=v.leftSideBearing*n),this.font?.forEachGlyph(m,c,f,e.fontSize,y,(t,i,s,o,a)=>{let l=0===t.index?"\n":t.unicode?String.fromCharCode(t.unicode):void 0,c=b[P],f=0;if("\n"===l)f=u;else if(" "===l)f=w;else{let r=this.createPath(t,n,i,s,e);r&&(f=r.offsetX,d.push(r.path))}if(1===c.replacements.length)g[h].push([i,s]),p[h].push(f);else{let t=c.replacements.map(t=>(r.glyphs.get(t).advanceWidth??0)*n),e=t.reduce((t,e)=>t+e,0),o=t.map(t=>t/e),a=i;for(let t=0;t<o.length;t++){let e=f*o[t];g[h].push([a,s]),p[h].push(e),a+=e}}P++}),f-=s}let m=[];for(let t=0,e=d.length;t<e;t++)m.push(...d[t].toShapes());return{shapes:m,charWidths:p,lineWidths:o,charCoords:g}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,i,r,n){return(3===i||2===i)&&r.indexOf("\n")>=0&&(t-=n),3===i?.5*e-.5*t:2===i?e-t:0}getLineInitialOffsetY(t,e,i,r,n){let s=e*t,o=t-Math.abs(this.ascender-this.descender)*r,a=-this.ascender*r-o/2;return 3===n?-(i-s-a):2===n?-(.5*i-.5*s-a):a}createPath(t,e,i,r,n){let s=t.getPath(i,-r,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!s)return void console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");let o=new y,a=(t.advanceWidth??1)*e;if(t)for(let t of s.commands){let e=o.currentPath?.currentPoint;if(!e||"Z"===t.type||e.x!==t.x||-e.y!==t.y)switch(t.type){case"M":o.moveTo(t.x,-t.y);break;case"L":o.lineTo(t.x,-t.y);break;case"Q":o.quadraticCurveTo(t.x1,-t.y1,t.x,-t.y);break;case"C":o.bezierCurveTo(t.x1,-t.y1,t.x2,-t.y2,t.x,-t.y)}}return o.subPaths.forEach(t=>{let e=function(t){if(t.length){let e=t[0];if(e instanceof u)return e.v1;if(e instanceof l||e instanceof c)return e.v0}}(t.curves);void 0!==e&&t.currentPoint.distanceTo(e)>0&&t.lineTo(e.x,e.y)}),{offsetX:a,path:o}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,i,r){let n=this.getCharWidth(" ",i),s=t[e];if(s){let o=this.countSpaces(s.trimEnd());if(4===i.horizontalAlign&&e<t.length-1&&o)return(("string"==typeof i.width?Number(r.getVariable(i.width)):i.width)-(this.getTextWidth(s,i)-o*n))/o}return n}countSpaces(t){return(t.match(/ /g)||[]).length}}),s("text");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t}from"./runtime-chunk-RAAW7WHN.js";import{a as e,b as i}from"./runtime-chunk-DZNU62CT.js";import{a as s}from"./runtime-chunk-VAVYZ35B.js";import{c as n}from"./runtime-chunk-FQNSP44B.js";import"./runtime-chunk-NRJDJMQZ.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import"./runtime-chunk-ZLW3UWOA.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-Z5OH244S.js";import{a as r,f as a}from"./runtime-chunk-TZCHGFVF.js";import{D as o,Ha as h}from"./runtime-chunk-OW6T4XFV.js";import{Dc as l,Fc as p,Gc as u,Sc as d,Vc as c,Vd as g,bd as m,dd as x,kd as v,l as y,ld as M,rd as I}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var f=class extends t{constructor(t,e,i){super(t,e,i),this.data=e}},C=class extends d{constructor(){super(),this.caretIndex=0,this._caretVisibleAlpha=1,this._selectionVisibleAlpha=.3,this.current={start:0,end:void 0},this.matrixAutoUpdate=!1,this.caretMesh=new M(new g(1,1),new v({transparent:!0,opacity:0,side:y})),this.add(this.caretMesh),this.selectionMesh=new M(new g(1,1),new v({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:y})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(t){this.visible=!0,this.object=t,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=.5*-this.caretHeight,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(void 0===this.object)return;this.updateHelperMatrix();let{depth:t}=this.object.geometry.userData.parameters;this.caretMesh.position.z=t,this.selectionMesh.position.z=t}updateHelperMatrix(){if(void 0===this.object)return;let t=this.object,e=t.parent;null!==e&&e.updateWorldMatrix(!0,!1),t.matrixAutoUpdate&&t.updateMatrix(),null!==e?(this.matrixWorld.multiplyMatrices(e.matrixWorld,t.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,t.matrix)):this.matrixWorld.multiplyMatrices(t.hiddenMatrix,t.matrix),this.matrix.copy(this.matrixWorld);for(let t of this.children)t.matrixWorld.copy(this.matrixWorld);t.updateWorldMatrix(!0,!0)}setCaretColor(t){let e=this.caretMesh.material;e.color.setRGB(t.r,t.g,t.b);let i=this._caretVisibleAlpha===e.opacity;this._caretVisibleAlpha=t.a,i&&(e.opacity=this._caretVisibleAlpha)}setSelectionColor(t){this.selectionMesh.material.color.setRGB(t.r,t.g,t.b)}setCaretPosition(t,e={}){if(void 0===this.object)return;this.caretIndex=t;let i=this.object.wrappedText,[s,n]=_(i,t),[r,a]=t>0?_(i,t-1):[null,null];"\n"===(t>0&&i.length?i[r].charAt(a):null)&&(s++,n=0),this.current.start=t,this.current.end=void 0;let[o,h]=b(this.object,s,n),{AD:l,descender:p}=this.object,u=p+.5*l,{width:d,height:c,depth:g}=this.object.geometry.userData.parameters,m="string"==typeof d?0:d,x="string"==typeof c?0:c;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(o-.5*m,h+u+.5*x,g),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(t,e){if(void 0===this.object)return;let i=this.object.wrappedText;this.current.start=t,this.current.end=e;let s=[],n=[],r=function(t,e,i){let[s,n]=_(t,e),[r,a]=_(t,i),o=[];n>=t[s].length&&(s++,n=0);for(let e=s;e<=r;e++){let i=t[e],h=e===s?n:0,l=e===r?a:i.length;o.push([e,h,l])}return o}(i,t,e),{lineHeight:a,AD:o,descender:h}=this.object,l=h+.5*o-.5*a;for(let[t,e,i]of r)if(e!==i){let[r,o]=b(this.object,t,e),[h,p]=b(this.object,t,i),u=o,d=p;u+=l,d+=l,d+=a;let c=s.length/3;s.push(r,u,0),s.push(h,u,0),s.push(h,d,0),s.push(r,d,0),n.push(c+0,c+1,c+2),n.push(c+2,c+3,c+0)}let p=new x;p.setIndex(n),p.setAttribute("position",new m(s,3));let{width:u,height:d,depth:c}=this.object.geometry.userData.parameters,g="string"==typeof u?0:u,v="string"==typeof d?0:d;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=p,this.selectionMesh.position.x=.5*-g,this.selectionMesh.position.y=.5*v,this.selectionMesh.position.z=c,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(t,e,i="previous"){if(void 0===this.object||void 0===this.object.font)return;let s=this.object.wrappedText,n=s.length,r=this.object.lineHeight,a=n*r,{height:o,verticalAlign:h}=this.object.geometry.userData.parameters,l="string"==typeof o?0:o,p=0;3===h?p=l-a:2===h&&(p=.5*l-.5*a);let u=Math.min(Math.floor(Math.max(Math.min(-e-p,a),0)/r),n-1),d=this.object.charCoords[u],c=this.object.charWidths[u],g=0,m=!1;if("previous"===i){for(let e=0;e<d.length;e++)if(d[e][0]+.5*c[e]-t>0){g=e,m=!0;break}}else if("closest"===i){let e=1/0;for(let i=0;i<d.length;i++){let s=d[i][0]+.5*c[i],n=Math.abs(s-t);n<e&&(e=n,g=i,m=!0)}}else for(let e=0;e<d.length;e++){let i=d[e][0],s=d[e][0]+c[e];if(t>=i&&t<s){g=e,m=!0;break}}return m||(g=d.length),{index:this.getGlobalIndexFromLineAndCharIndexes(s,u,g),lineIndex:u,characterIndex:g}}getGlobalIndexFromLineAndCharIndexes(t,e,i){return t.slice(0,e).reduce((t,e)=>t+e.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function b(t,e,i){let{charCoords:s,charWidths:n,initialOffsetY:r,lineHeight:a}=t;if(s[e]&&0===s[e].length||0===s.length){let i=0,{horizontalAlign:s}=t.data.geometry,n=t.wrappedText,{width:o}=t.geometry.userData.parameters;return 1===n.length&&0===n[0].length&&(3===s?i=.5*o:2===s&&(i=o)),[i,r-a*e]}let o=s[e];if(void 0===o||0===o.length)return[0,0];let[h,l]=o[Math.min(i,o.length-1)],p=h;return i>=o.length&&(p+=n[e][i-1]),[p,l]}function _(t,e){let i=0;for(let s=0;s<t.length;s++){let n=t[s],r=e-i;if(r<=n.length)return[s,r];i+=n.length}return[Math.max(0,t.length-1),t[t.length-1]?.length??0]}function w(t,e){return"string"==typeof t?e.data.colors[t]:t}function k(t){return t.colors[0]}var E=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=t=>{let e=[t.clientX,t.clientY],i=(new Date).getTime();if(this._clickCount>0){let t=e[0]-this._lastPosition[0],i=e[1]-this._lastPosition[1];Math.sqrt(t*t+i*i)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=t=>{}}start(t,e=500,i=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=i,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}},j=new p(0,0,1),D=new p,T=new p,A=new u,S=class{constructor(t,e,i,s,n){this.containerScene=t,this.raycaster=e,this.sharedAssets=i,this.requestRender=s,this.onExit=n,this.htmlInput=null,this.virtualInput=null,this.helper=new C,this.doubleClickHandler=new E,this.isDragging=!1,this.plane=new I,this.caretInterval=0,this.planeIntersection=new p,this.projected=new l,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{let t=this.virtualInput?.data;if(void 0!==this.virtualInput&&t){let e=t.material,i=function(t,e){let i=o.fromHex(3223857),s=.8;for(let n of t.layers){if("light"===n.data.type||"displace"===n.data.type||"fresnel"===n.data.type||"dust"===n.data.type||"matcap"===n.data.type||"texture"===n.data.type||"toon"===n.data.type||"outline"===n.data.type||"transmission"===n.data.type||"noise"===n.data.type||"vertexColor"===n.data.type)continue;let t="string"==typeof n.data.alpha?Number(e.getVariable(n.data.alpha)):n.data.alpha;if("color"===n.data.type&&t>.3){i=w(n.data.color,e),s=t;break}if(("depth"===n.data.type||"gradient"===n.data.type)&&t>.3){let t=k(n.data);i={r:t[0],g:t[1],b:t[2]},s="string"==typeof n.data.alpha?1:n.data.alpha;break}}return{...i,a:s}}("string"==typeof e?this.sharedAssets.data.materials[e]:e,this.sharedAssets);this.helper.setCaretColor(i)}},this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)},this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))},this.handleCaretUpdate=t=>{if(!this.htmlInput||!this.virtualInput)return;let e=this.helper,i="ArrowLeft"===t?.key||"ArrowRight"===t?.key,s="ArrowUp"===t?.key||"ArrowDown"===t?.key;this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(e.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:i,verticalKeyMove:s}),this.startAnimateTextCursor()):e.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=function(){let t=document.createElement("textarea");return t.style.position="fixed",t.style.top="200px",t.style.left="400px",t.style.zIndex="-1",t.style.border="1px solid rgba(255,0,0,0.5)",t.style.width="10px",t.style.height="500px",t.style.color="white",t.style.opacity="0.5",t.style.background="transparent",t.style.display="none",t.style.margin="0px",t.style.padding="0px",t.style.boxSizing="content-box",t.style.pointerEvents="none",t}(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,e=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0},{lineIndex:i}=e,{index:s,characterIndex:n}=e;this.virtualInput?.wrappedText?.length&&"\n"===this.virtualInput.wrappedText[i][Math.max(0,n-1)]&&(s--,n--),this._lastIndex=s,this._isFirstDragMove=!0;let r=this.checkClickedObject();if(1===t){if(null===r)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=s,this.isDragging=!0,this.setInputSelection(s)}else r===this.virtualInput&&(2===t?this.selectClosestWord(i,n):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let t=this.data?.geometry.text;this.htmlInput.value="string"==typeof t?"":t?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:i,characterIndex:s}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0},n=e;void 0!==i&&void 0!==s&&"\n"===this.virtualInput?.wrappedText[i][s-1]&&n--,this.htmlInput.setSelectionRange(Math.min(t,n),Math.max(t,n))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof f)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,s=i[t],n=e+1,r=e;" "!==s[e]&&(n=this.findNextCharOccurence(s,e,"forward"," "),r=this.findNextCharOccurence(s,e,"backward"," "),r>0&&r++,n>=s.length-1&&t===i.length-1&&n++);let a=this.helper,o=a.getGlobalIndexFromLineAndCharIndexes(i,t,r),h=a.getGlobalIndexFromLineAndCharIndexes(i,t,n);this.setInputSelection(o,h)}findNextCharOccurence(t,e,i,s=" "){let n=Math.max(0,t.length-1),r="forward"===i?n:0,a="forward"===i?1:-1,o=Math.max(Math.min(e,n),0);for(;o!==r;)if(o+=a,t.charAt(o)===s)return o;return r}getPointOnPlane(){let t=this.virtualInput?.data;if(this.virtualInput&&t&&this.raycaster.ray.intersectsPlane(this.plane)){null===this.planeIntersection&&(this.planeIntersection=new p);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let i="number"==typeof t.geometry.width?t.geometry.width:1,s="number"==typeof t.geometry.height?t.geometry.height:1;this.projected.set(e.x+.5*i,e.y-.5*s)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(A.getNormalMatrix(this.virtualInput.matrixWorld),D.copy(j).applyMatrix3(A).normalize(),this.virtualInput.localToWorld(T.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(D,T))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),n&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;var e;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=4===(e=t.geometry.horizontalAlign)?"justify":2===e?"right":3===e?"center":"left")}},L=(t,e)=>{if("string"==typeof t){let i=e.data(t);if(i)return L(i.value,e)}return h.getDisplayedValue(t)};function U(t,e){let i=t.text,s="";if("string"==typeof i){let t=e.variables.data(s);t&&(s=L(t.value,e.variables))}else s=i.textValue.toString();return s}var H=class extends e{constructor(t,e){super(t),this.eventManager=e,this._textInputs=[],this.sceneHelpers=new c,this.helper=new C,this._onMouseDownFocusIn=t=>{if(s.length>1)return;this.eventContext.updateRaycaster(t);let e=null;if(this.eventContext.raycaster)for(let t of this._textInputs)if(this.eventContext.raycaster.intersectObject(t,!0).length>0){e=t;break}this.focusOnTextInput(e),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(t),this._onMouseDown(t)},this.onExit=()=>{let{virtualInput:t}=this.textInputManager;if(null===t)return;let e=this.textInputManager.htmlInput;this.helper.hide(),e?.setSelectionRange(e.value.length,e.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:i}=this.eventContext;i.removeEventListener("pointerdown",this._onMouseDown,!1),i.removeEventListener("pointerup",this._onMouseUp,!1),i.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),i.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=t=>{this.eventContext.updateRaycaster(t),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=t=>{this.eventContext.updateRaycaster(t),this.textInputManager.handleMouseMove()},this._onTextEdit=t=>{let{htmlInput:e,virtualInput:i,helper:s}=this.textInputManager;if(!e||!i)return;let n=e.value;i.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let r=i.data;s.update();let a=r.geometry.text;if("string"==typeof a){let t=a;this.eventContext.sharedAssets.updateVariable(t,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=t=>{this.textInputManager.handleCaretUpdate(t)},this._onKeyPress=t=>{"Escape"===t.key&&this.onExit()},this.textInputManager=new S(this.sceneHelpers,t.raycaster,t.sharedAssets,t.requestRender,this.onExit)}connect(){let t=[];if(this.eventContext.scene.traverseEntity(e=>{e instanceof f&&t.push(e)}),this._textInputs=t,0===t.length)return;let{domElement:e}=this.eventContext;e.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let t=this.textInputManager.htmlInput,{domElement:e,sharedAssets:i}=this.eventContext;e.removeEventListener("pointerdown",this._onMouseDownFocusIn),t?.removeEventListener("keyup",this._onCaretUpdate),t?.removeEventListener("keydown",this._onCaretUpdate),t?.removeEventListener("beforeinput",this._onCaretUpdate),t?.removeEventListener("paste",this._onCaretUpdate),t?.removeEventListener("cut",this._onCaretUpdate),t?.removeEventListener("select",this._onCaretUpdate),t?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(t=>{let e=U(t.data.geometry,this.eventContext.sharedAssets.data);t.textGeometry.setText(e,i)}),e.removeEventListener("pointerdown",this._onMouseDown,!1),e.removeEventListener("pointerup",this._onMouseUp,!1),e.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(t){this.textInputManager.focus(t),this.textInputManager.onTextMaterialChanged();let e=this.textInputManager.htmlInput;if(!e||null===t)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=U(t.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);e.value=i,e.setSelectionRange(0,0),this.textInputManager.helper.show(t),e.style.display="block",e.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDownFocusIn),s.addEventListener("pointerdown",this._onMouseDown,!1),s.addEventListener("pointerup",this._onMouseUp,!1),s.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};i("Textfields",({eventContext:t,eventManager:e})=>new H(t,e)),a("InputGeometry",(t,e,i)=>new f(t,e,i)),r("textinputs");
|
|
1
|
+
import{a as t}from"./runtime-chunk-243VQV5T.js";import{a as e,b as i}from"./runtime-chunk-DZNU62CT.js";import{a as s}from"./runtime-chunk-VAVYZ35B.js";import{c as n}from"./runtime-chunk-FQNSP44B.js";import"./runtime-chunk-LALFWESO.js";import"./runtime-chunk-4YV3EXSU.js";import"./runtime-chunk-NSD7DU3P.js";import"./runtime-chunk-PLJ25O2X.js";import"./runtime-chunk-2PT2WH66.js";import"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as r,f as a}from"./runtime-chunk-TZCHGFVF.js";import{D as o,Ha as h}from"./runtime-chunk-OW6T4XFV.js";import{Dc as l,Fc as p,Gc as u,Sc as d,Vc as c,Vd as g,bd as m,dd as x,kd as v,l as y,ld as I,rd as M}from"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var f=class extends t{constructor(t,e,i){super(t,e,i),this.data=e}},C=class extends d{constructor(){super(),this.caretIndex=0,this._caretVisibleAlpha=1,this._selectionVisibleAlpha=.3,this.current={start:0,end:void 0},this.matrixAutoUpdate=!1,this.caretMesh=new I(new g(1,1),new v({transparent:!0,opacity:0,side:y})),this.add(this.caretMesh),this.selectionMesh=new I(new g(1,1),new v({color:2857471,transparent:!0,depthTest:!1,depthWrite:!1,opacity:0,side:y})),this.add(this.selectionMesh),this.hide()}get caretHeight(){return this.object?.AD??0}show(t){this.visible=!0,this.object=t,this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.y=.5*-this.caretHeight,this.setCaretPosition(this.caretIndex),this.update()}hide(){this.visible=!1}update(){if(void 0===this.object)return;this.updateHelperMatrix();let{depth:t}=this.object.geometry.userData.parameters;this.caretMesh.position.z=t,this.selectionMesh.position.z=t}updateHelperMatrix(){if(void 0===this.object)return;let t=this.object,e=t.parent;null!==e&&e.updateWorldMatrix(!0,!1),t.matrixAutoUpdate&&t.updateMatrix(),null!==e?(this.matrixWorld.multiplyMatrices(e.matrixWorld,t.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,t.matrix)):this.matrixWorld.multiplyMatrices(t.hiddenMatrix,t.matrix),this.matrix.copy(this.matrixWorld);for(let t of this.children)t.matrixWorld.copy(this.matrixWorld);t.updateWorldMatrix(!0,!0)}setCaretColor(t){let e=this.caretMesh.material;e.color.setRGB(t.r,t.g,t.b);let i=this._caretVisibleAlpha===e.opacity;this._caretVisibleAlpha=t.a,i&&(e.opacity=this._caretVisibleAlpha)}setSelectionColor(t){this.selectionMesh.material.color.setRGB(t.r,t.g,t.b)}setCaretPosition(t,e={}){if(void 0===this.object)return;this.caretIndex=t;let i=this.object.wrappedText,[s,n]=_(i,t),[r,a]=t>0?_(i,t-1):[null,null];"\n"===(t>0&&i.length?i[r].charAt(a):null)&&(s++,n=0),this.current.start=t,this.current.end=void 0;let[o,h]=b(this.object,s,n),{AD:l,descender:p}=this.object,u=p+.5*l,{width:d,height:c,depth:g}=this.object.geometry.userData.parameters,m="string"==typeof d?0:d,x="string"==typeof c?0:c;this.caretMesh.scale.set(1,this.caretHeight,1),this.caretMesh.position.set(o-.5*m,h+u+.5*x,g),this.hideSelectionMesh(),this.showCaretMesh()}setSelection(t,e){if(void 0===this.object)return;let i=this.object.wrappedText;this.current.start=t,this.current.end=e;let s=[],n=[],r=function(t,e,i){let[s,n]=_(t,e),[r,a]=_(t,i),o=[];n>=t[s].length&&(s++,n=0);for(let e=s;e<=r;e++){let i=t[e],h=e===s?n:0,l=e===r?a:i.length;o.push([e,h,l])}return o}(i,t,e),{lineHeight:a,AD:o,descender:h}=this.object,l=h+.5*o-.5*a;for(let[t,e,i]of r)if(e!==i){let[r,o]=b(this.object,t,e),[h,p]=b(this.object,t,i),u=o,d=p;u+=l,d+=l,d+=a;let c=s.length/3;s.push(r,u,0),s.push(h,u,0),s.push(h,d,0),s.push(r,d,0),n.push(c+0,c+1,c+2),n.push(c+2,c+3,c+0)}let p=new x;p.setIndex(n),p.setAttribute("position",new m(s,3));let{width:u,height:d,depth:c}=this.object.geometry.userData.parameters,g="string"==typeof u?0:u,v="string"==typeof d?0:d;this.selectionMesh.geometry.dispose(),this.selectionMesh.geometry=p,this.selectionMesh.position.x=.5*-g,this.selectionMesh.position.y=.5*v,this.selectionMesh.position.z=c,this.showSelectionMesh(),this.hideCaretMesh()}getSelectionFromPosition(t,e,i="previous"){if(void 0===this.object||void 0===this.object.font)return;let s=this.object.wrappedText,n=s.length,r=this.object.lineHeight,a=n*r,{height:o,verticalAlign:h}=this.object.geometry.userData.parameters,l="string"==typeof o?0:o,p=0;3===h?p=l-a:2===h&&(p=.5*l-.5*a);let u=Math.min(Math.floor(Math.max(Math.min(-e-p,a),0)/r),n-1),d=this.object.charCoords[u],c=this.object.charWidths[u],g=0,m=!1;if("previous"===i){for(let e=0;e<d.length;e++)if(d[e][0]+.5*c[e]-t>0){g=e,m=!0;break}}else if("closest"===i){let e=1/0;for(let i=0;i<d.length;i++){let s=d[i][0]+.5*c[i],n=Math.abs(s-t);n<e&&(e=n,g=i,m=!0)}}else for(let e=0;e<d.length;e++){let i=d[e][0],s=d[e][0]+c[e];if(t>=i&&t<s){g=e,m=!0;break}}return m||(g=d.length),{index:this.getGlobalIndexFromLineAndCharIndexes(s,u,g),lineIndex:u,characterIndex:g}}getGlobalIndexFromLineAndCharIndexes(t,e,i){return t.slice(0,e).reduce((t,e)=>t+e.length,0)+i}showSelectionMesh(){this.selectionMesh.material.opacity=this._selectionVisibleAlpha}hideSelectionMesh(){this.selectionMesh.material.opacity=0}showCaretMesh(){this.caretMesh.material.opacity=this._caretVisibleAlpha}hideCaretMesh(){this.caretMesh.material.opacity=0}};function b(t,e,i){let{charCoords:s,charWidths:n,initialOffsetY:r,lineHeight:a}=t;if(s[e]&&0===s[e].length||0===s.length){let i=0,{horizontalAlign:s}=t.data.geometry,n=t.wrappedText,{width:o}=t.geometry.userData.parameters;return 1===n.length&&0===n[0].length&&(3===s?i=.5*o:2===s&&(i=o)),[i,r-a*e]}let o=s[e];if(void 0===o||0===o.length)return[0,0];let[h,l]=o[Math.min(i,o.length-1)],p=h;return i>=o.length&&(p+=n[e][i-1]),[p,l]}function _(t,e){let i=0;for(let s=0;s<t.length;s++){let n=t[s],r=e-i;if(r<=n.length)return[s,r];i+=n.length}return[Math.max(0,t.length-1),t[t.length-1]?.length??0]}function w(t,e){return"string"==typeof t?e.data.colors[t]:t}function k(t){return t.colors[0]}var E=class{constructor(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0],this._delay=500,this._distance=2,this._onMouseDown=t=>{let e=[t.clientX,t.clientY],i=(new Date).getTime();if(this._clickCount>0){let t=e[0]-this._lastPosition[0],i=e[1]-this._lastPosition[1];Math.sqrt(t*t+i*i)>this._distance&&(this._clickCount=0)}this._lastPosition=e,this._clickCount=i-this._lastTime>this._delay?1:this._clickCount+1,this._lastTime=i},this._onMouseUp=t=>{}}start(t,e=500,i=2){this._target&&this.stop(),this.reset(),this._delay=e,this._distance=i,this._target=t,this._target.addEventListener("pointerdown",this._onMouseDown,!1),this._target.addEventListener("pointerup",this._onMouseUp,!1)}stop(){this._target&&(this._target.removeEventListener("pointerdown",this._onMouseDown,!1),this._target.removeEventListener("pointerup",this._onMouseUp,!1),this._target=void 0)}get clickCount(){return this._clickCount}reset(){this._clickCount=0,this._lastTime=0,this._lastPosition=[0,0]}},j=new p(0,0,1),T=new p,D=new p,L=new u,S=class{constructor(t,e,i,s,n){this.containerScene=t,this.raycaster=e,this.sharedAssets=i,this.requestRender=s,this.onExit=n,this.htmlInput=null,this.virtualInput=null,this.helper=new C,this.doubleClickHandler=new E,this.isDragging=!1,this.plane=new M,this.caretInterval=0,this.planeIntersection=new p,this.projected=new l,this._lastIndex=0,this._isFirstDragMove=!1,this.selectionOnDragStart=0,this.onTextMaterialChanged=()=>{let t=this.virtualInput?.data;if(void 0!==this.virtualInput&&t){let e=t.material,i=function(t,e){let i=o.fromHex(3223857),s=.8;for(let n of t.layers){if("light"===n.data.type||"displace"===n.data.type||"fresnel"===n.data.type||"dust"===n.data.type||"matcap"===n.data.type||"texture"===n.data.type||"toon"===n.data.type||"outline"===n.data.type||"transmission"===n.data.type||"noise"===n.data.type||"vertexColor"===n.data.type)continue;let t="string"==typeof n.data.alpha?Number(e.getVariable(n.data.alpha)):n.data.alpha;if("color"===n.data.type&&t>.3){i=w(n.data.color,e),s=t;break}if(("depth"===n.data.type||"gradient"===n.data.type)&&t>.3){let t=k(n.data);i={r:t[0],g:t[1],b:t[2]},s="string"==typeof n.data.alpha?1:n.data.alpha;break}}return{...i,a:s}}("string"==typeof e?this.sharedAssets.data.materials[e]:e,this.sharedAssets);this.helper.setCaretColor(i)}},this.stopAnimateTextCursor=()=>{clearInterval(this.caretInterval),this.helper&&(this.helper.caretMesh.visible=!1)},this.startAnimateTextCursor=()=>{this.stopAnimateTextCursor(),this.helper&&(this.helper.caretMesh.visible=!0,this.caretInterval=setInterval(()=>{this.helper&&(this.helper.caretMesh.visible=!this.helper.caretMesh.visible),this.requestRender()},600))},this.handleCaretUpdate=t=>{if(!this.htmlInput||!this.virtualInput)return;let e=this.helper,i="ArrowLeft"===t?.key||"ArrowRight"===t?.key,s="ArrowUp"===t?.key||"ArrowDown"===t?.key;this.htmlInput.selectionStart===this.htmlInput.selectionEnd?(e.setCaretPosition(this.htmlInput.selectionStart,{horizontalKeyMove:i,verticalKeyMove:s}),this.startAnimateTextCursor()):e.setSelection(this.htmlInput.selectionStart,this.htmlInput.selectionEnd),this.requestRender()},this.containerScene.add(this.helper)}createInput(){return this.htmlInput=function(){let t=document.createElement("textarea");return t.style.position="fixed",t.style.top="200px",t.style.left="400px",t.style.zIndex="-1",t.style.border="1px solid rgba(255,0,0,0.5)",t.style.width="10px",t.style.height="500px",t.style.color="white",t.style.opacity="0.5",t.style.background="transparent",t.style.display="none",t.style.margin="0px",t.style.padding="0px",t.style.boxSizing="content-box",t.style.pointerEvents="none",t}(),this.htmlInput}connect(){}disconnect(){this.stopAnimateTextCursor(),this.helper.hide(),this.htmlInput?.remove(),this.doubleClickHandler.stop()}handleMouseDown(){if(!this.htmlInput||!this.virtualInput)return!0;this.getPointOnPlane();let t=this.doubleClickHandler.clickCount,e=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,t>1?"inside":"previous")??{index:0,lineIndex:0,characterIndex:0},{lineIndex:i}=e,{index:s,characterIndex:n}=e;this.virtualInput?.wrappedText?.length&&"\n"===this.virtualInput.wrappedText[i][Math.max(0,n-1)]&&(s--,n--),this._lastIndex=s,this._isFirstDragMove=!0;let r=this.checkClickedObject();if(1===t){if(null===r)return this.onExit(this.virtualInput),!0;this.selectionOnDragStart=s,this.isDragging=!0,this.setInputSelection(s)}else r===this.virtualInput&&(2===t?this.selectClosestWord(i,n):t>2&&(this.setInputSelection(0,this.htmlInput.value.length),this.doubleClickHandler.reset()))}handleMouseUp(){this.applyRangeToTextInput(),this.isDragging=!1,this._isFirstDragMove=!1}handleMouseMove(){!this.virtualInput||(this._isFirstDragMove&&this.doubleClickHandler.clickCount>1&&(this.selectionOnDragStart=this._lastIndex,this.isDragging=!0,this.setInputSelection(this._lastIndex)),this._isFirstDragMove=!1,this.getPointOnPlane(),this.applyRangeToTextInput())}focus(t){if(this.virtualInput=t,this.updateTextInputStyles(),this.htmlInput)if(t){let t=this.data?.geometry.text;this.htmlInput.value="string"==typeof t?"":t?.textValue.toString()??""}else this.htmlInput.value=""}blur(){}get data(){let{virtualInput:t}=this;if(t)return t.dataPatched}applyRangeToTextInput(){if(!this.isDragging||!this.virtualInput||!this.htmlInput)return;let t=this.selectionOnDragStart,{index:e,lineIndex:i,characterIndex:s}=this.helper.getSelectionFromPosition(this.projected.x,this.projected.y,this.doubleClickHandler.clickCount>2?"inside":"previous")??{index:0},n=e;void 0!==i&&void 0!==s&&"\n"===this.virtualInput?.wrappedText[i][s-1]&&n--,this.htmlInput.setSelectionRange(Math.min(t,n),Math.max(t,n))}checkClickedObject(){if(this.virtualInput){let t=this.raycaster.intersectObject(this.virtualInput,!1);if(t.length>0){let e=t[0];if(e.object instanceof f)return e.object}}return null}selectClosestWord(t,e){if(!this.virtualInput)return;let i=this.virtualInput.wrappedText,s=i[t],n=e+1,r=e;" "!==s[e]&&(n=this.findNextCharOccurence(s,e,"forward"," "),r=this.findNextCharOccurence(s,e,"backward"," "),r>0&&r++,n>=s.length-1&&t===i.length-1&&n++);let a=this.helper,o=a.getGlobalIndexFromLineAndCharIndexes(i,t,r),h=a.getGlobalIndexFromLineAndCharIndexes(i,t,n);this.setInputSelection(o,h)}findNextCharOccurence(t,e,i,s=" "){let n=Math.max(0,t.length-1),r="forward"===i?n:0,a="forward"===i?1:-1,o=Math.max(Math.min(e,n),0);for(;o!==r;)if(o+=a,t.charAt(o)===s)return o;return r}getPointOnPlane(){let t=this.virtualInput?.data;if(this.virtualInput&&t&&this.raycaster.ray.intersectsPlane(this.plane)){null===this.planeIntersection&&(this.planeIntersection=new p);let e=this.raycaster.ray.intersectPlane(this.plane,this.planeIntersection);if(e){this.planeIntersection.copy(this.virtualInput.worldToLocal(e));let i="number"==typeof t.geometry.width?t.geometry.width:1,s="number"==typeof t.geometry.height?t.geometry.height:1;this.projected.set(e.x+.5*i,e.y-.5*s)}}}updatePlane(){let t=this.virtualInput?.data;this.virtualInput&&t&&(L.getNormalMatrix(this.virtualInput.matrixWorld),T.copy(j).applyMatrix3(L).normalize(),this.virtualInput.localToWorld(D.set(0,0,t.geometry.depth)),this.plane.setFromNormalAndCoplanarPoint(T,D))}setInputSelection(t,e=t){this.htmlInput?.setSelectionRange(t,e),n&&this.htmlInput?.focus(),setTimeout(()=>{this.htmlInput?.focus()})}updateTextInputStyles(){let t=this.virtualInput?.data;var e;this.virtualInput&&t&&this.htmlInput&&(this.htmlInput.style.fontSize=t.geometry.fontSize+"px",this.htmlInput.style.letterSpacing=t.geometry.letterSpacing*t.geometry.fontSize+"px",this.htmlInput.style.lineHeight=t.geometry.fontSize*t.geometry.lineHeight+"px",this.htmlInput.style.width=t.geometry.width+"px",this.htmlInput.style.height=t.geometry.height+"px",this.htmlInput.style.textAlign=4===(e=t.geometry.horizontalAlign)?"justify":2===e?"right":3===e?"center":"left")}},A=(t,e)=>{if("string"==typeof t){let i=e.data(t);if(i)return A(i.value,e)}return h.getDisplayedValue(t)};function U(t,e){let i=t.text,s="";if("string"==typeof i){let t=e.variables.data(s);t&&(s=A(t.value,e.variables))}else s=i.textValue.toString();return s}var H=class extends e{constructor(t,e){super(t),this.eventManager=e,this._textInputs=[],this.sceneHelpers=new c,this.helper=new C,this._onMouseDownFocusIn=t=>{if(s.length>1)return;this.eventContext.updateRaycaster(t);let e=null;if(this.eventContext.raycaster)for(let t of this._textInputs)if(this.eventContext.raycaster.intersectObject(t,!0).length>0){e=t;break}this.focusOnTextInput(e),this._onCaretUpdate(),this._onMouseUp(),this.textInputManager.doubleClickHandler.start(this.eventContext.domElement),this.textInputManager.doubleClickHandler._onMouseDown(t),this._onMouseDown(t)},this.onExit=()=>{let{virtualInput:t}=this.textInputManager;if(null===t)return;let e=this.textInputManager.htmlInput;this.helper.hide(),e?.setSelectionRange(e.value.length,e.value.length),this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!0);let{domElement:i}=this.eventContext;i.removeEventListener("pointerdown",this._onMouseDown,!1),i.removeEventListener("pointerup",this._onMouseUp,!1),i.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.textInputManager.doubleClickHandler.reset(),i.addEventListener("pointerdown",this._onMouseDownFocusIn),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers()},this._onMouseDown=t=>{this.eventContext.updateRaycaster(t),this.textInputManager.handleMouseDown(),this.textInputManager.virtualInput&&this.eventContext.raycaster.intersectObject(this.textInputManager.virtualInput,!0).length>0&&this.eventManager.controlsManager.orbitControls&&(this.eventManager.controlsManager.orbitControls.enabled=!1)},this._onMouseUp=()=>{this.textInputManager.handleMouseUp(),this.eventManager.controlsManager.orbitControls&&!this.eventManager.controlsManager.orbitControls.enabled&&(this.eventManager.controlsManager.orbitControls.enabled=!0)},this._onMouseMove=t=>{this.eventContext.updateRaycaster(t),this.textInputManager.handleMouseMove()},this._onTextEdit=t=>{let{htmlInput:e,virtualInput:i,helper:s}=this.textInputManager;if(!e||!i)return;let n=e.value;i.textGeometry.setText(n,this.eventContext.sharedAssets).then(()=>{this.eventContext.requestRender()});let r=i.data;s.update();let a=r.geometry.text;if("string"==typeof a){let t=a;this.eventContext.sharedAssets.updateVariable(t,{textValue:n})}this.textInputManager.updateTextInputStyles(),this._onCaretUpdate()},this._onCaretUpdate=t=>{this.textInputManager.handleCaretUpdate(t)},this._onKeyPress=t=>{"Escape"===t.key&&this.onExit()},this.textInputManager=new S(this.sceneHelpers,t.raycaster,t.sharedAssets,t.requestRender,this.onExit)}connect(){let t=[];if(this.eventContext.scene.traverseEntity(e=>{e instanceof f&&t.push(e)}),this._textInputs=t,0===t.length)return;let{domElement:e}=this.eventContext;e.addEventListener("pointerdown",this._onMouseDownFocusIn),this.textInputManager.connect();let i=this.textInputManager.createInput();document.body.appendChild(i),i.style.display="none",i.addEventListener("keyup",this._onCaretUpdate),i.addEventListener("keydown",this._onCaretUpdate),i.addEventListener("beforeinput",this._onCaretUpdate),i.addEventListener("paste",this._onCaretUpdate),i.addEventListener("cut",this._onCaretUpdate),i.addEventListener("select",this._onCaretUpdate),i.addEventListener("selectstart",this._onCaretUpdate)}disconnect(){let t=this.textInputManager.htmlInput,{domElement:e,sharedAssets:i}=this.eventContext;e.removeEventListener("pointerdown",this._onMouseDownFocusIn),t?.removeEventListener("keyup",this._onCaretUpdate),t?.removeEventListener("keydown",this._onCaretUpdate),t?.removeEventListener("beforeinput",this._onCaretUpdate),t?.removeEventListener("paste",this._onCaretUpdate),t?.removeEventListener("cut",this._onCaretUpdate),t?.removeEventListener("select",this._onCaretUpdate),t?.removeEventListener("selectstart",this._onCaretUpdate),this._textInputs.forEach(t=>{let e=U(t.data.geometry,this.eventContext.sharedAssets.data);t.textGeometry.setText(e,i)}),e.removeEventListener("pointerdown",this._onMouseDown,!1),e.removeEventListener("pointerup",this._onMouseUp,!1),e.removeEventListener("pointermove",this._onMouseMove,!1),window.removeEventListener("keydown",this._onKeyPress),this.eventContext.renderer.sceneHelpersOnTop=void 0,this.eventContext.renderer.pipeline.disableHelpers(),this.textInputManager.disconnect()}focusOnTextInput(t){this.textInputManager.focus(t),this.textInputManager.onTextMaterialChanged();let e=this.textInputManager.htmlInput;if(!e||null===t)return;this.textInputManager.updateTextInputStyles(),this.eventContext.renderer.sceneHelpersOnTop=this.sceneHelpers,this.eventContext.renderer.pipeline.enableHelpers(),this.textInputManager.isDragging=!1;let i=U(t.textGeometry.userData.parameters,this.eventContext.sharedAssets.data);e.value=i,e.setSelectionRange(0,0),this.textInputManager.helper.show(t),e.style.display="block",e.addEventListener("input",this._onTextEdit),this.textInputManager.updatePlane();let{domElement:s}=this.eventContext;s.removeEventListener("pointerdown",this._onMouseDownFocusIn),s.addEventListener("pointerdown",this._onMouseDown,!1),s.addEventListener("pointerup",this._onMouseUp,!1),s.addEventListener("pointermove",this._onMouseMove,!1),window.addEventListener("keydown",this._onKeyPress)}};i("Textfields",({eventContext:t,eventManager:e})=>new H(t,e)),a("InputGeometry",(t,e,i)=>new f(t,e,i)),r("textinputs");
|
|
Binary file
|
|
Binary file
|