@splinetool/runtime 2.0.4 → 2.0.6
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/opentype.js +1 -1
- package/build/opentype.js.br +0 -0
- package/build/opentype.js.gz +0 -0
- package/build/{runtime-aiAssistant-RMA2DMFU.js → runtime-aiAssistant-KA7ZJ3F6.js} +1 -1
- package/build/runtime-aiAssistant-KA7ZJ3F6.js.br +0 -0
- package/build/runtime-aiAssistant-KA7ZJ3F6.js.gz +0 -0
- package/build/{runtime-apiServices-KA4FEP5Y.js → runtime-apiServices-CGMAW2B4.js} +1 -1
- package/build/runtime-apiServices-CGMAW2B4.js.br +0 -0
- package/build/runtime-apiServices-CGMAW2B4.js.gz +0 -0
- package/build/{runtime-audio-BQSRM3W2.js → runtime-audio-GCUGVRQ3.js} +1 -1
- package/build/runtime-audio-GCUGVRQ3.js.br +0 -0
- package/build/runtime-audio-GCUGVRQ3.js.gz +0 -0
- package/build/{runtime-chunk-R7NC6CZZ.js → runtime-chunk-3KIZF7P5.js} +1 -1
- package/build/runtime-chunk-3KIZF7P5.js.br +0 -0
- package/build/runtime-chunk-3KIZF7P5.js.gz +0 -0
- package/build/{runtime-chunk-TPKGBIJU.js → runtime-chunk-4DNX5FPP.js} +1 -1
- package/build/runtime-chunk-4DNX5FPP.js.br +0 -0
- package/build/runtime-chunk-4DNX5FPP.js.gz +0 -0
- package/build/{runtime-chunk-I5QFGBIU.js → runtime-chunk-4E4NQ6GS.js} +1 -1
- package/build/runtime-chunk-4E4NQ6GS.js.br +0 -0
- package/build/runtime-chunk-4E4NQ6GS.js.gz +0 -0
- package/build/{runtime-chunk-OOC7YSI5.js → runtime-chunk-4KX4KQWR.js} +1 -1
- package/build/runtime-chunk-4KX4KQWR.js.br +0 -0
- package/build/runtime-chunk-4KX4KQWR.js.gz +0 -0
- package/build/{runtime-chunk-MBBODDV7.js → runtime-chunk-5H2Z5KYI.js} +1 -1
- package/build/runtime-chunk-5H2Z5KYI.js.br +0 -0
- package/build/{runtime-chunk-MBBODDV7.js.gz → runtime-chunk-5H2Z5KYI.js.gz} +0 -0
- package/build/{runtime-chunk-RF63UVAU.js → runtime-chunk-AKWBEROQ.js} +1 -1
- package/build/runtime-chunk-AKWBEROQ.js.br +0 -0
- package/build/runtime-chunk-AKWBEROQ.js.gz +0 -0
- package/build/{runtime-chunk-4I22JDL6.js → runtime-chunk-BPYFB4BD.js} +1 -1
- package/build/runtime-chunk-BPYFB4BD.js.br +0 -0
- package/build/runtime-chunk-BPYFB4BD.js.gz +0 -0
- package/build/runtime-chunk-CCJD7IX7.js +1 -0
- package/build/runtime-chunk-CCJD7IX7.js.br +0 -0
- package/build/runtime-chunk-CCJD7IX7.js.gz +0 -0
- package/build/{runtime-chunk-W4ZCHGLQ.js → runtime-chunk-CEAWQBAS.js} +1 -1
- package/build/runtime-chunk-CEAWQBAS.js.br +0 -0
- package/build/runtime-chunk-CEAWQBAS.js.gz +0 -0
- package/build/{runtime-chunk-ZMXEX5NX.js → runtime-chunk-CX2MRLZA.js} +1 -1
- package/build/runtime-chunk-CX2MRLZA.js.br +0 -0
- package/build/runtime-chunk-CX2MRLZA.js.gz +0 -0
- package/build/{runtime-chunk-WHKBOV2O.js → runtime-chunk-FY3XD5P2.js} +1 -1
- package/build/runtime-chunk-FY3XD5P2.js.br +0 -0
- package/build/runtime-chunk-FY3XD5P2.js.gz +0 -0
- package/build/{runtime-chunk-DSJY3WL2.js → runtime-chunk-GN3HDYV2.js} +1 -1
- package/build/runtime-chunk-GN3HDYV2.js.br +0 -0
- package/build/runtime-chunk-GN3HDYV2.js.gz +0 -0
- package/build/{runtime-chunk-LT4UVXE2.js → runtime-chunk-GO25U5WN.js} +1 -1
- package/build/runtime-chunk-GO25U5WN.js.br +0 -0
- package/build/runtime-chunk-GO25U5WN.js.gz +0 -0
- package/build/{runtime-chunk-ESZD4IRS.js → runtime-chunk-H7D3VFTJ.js} +1 -1
- package/build/runtime-chunk-H7D3VFTJ.js.br +0 -0
- package/build/runtime-chunk-H7D3VFTJ.js.gz +0 -0
- package/build/runtime-chunk-HUFJRFTO.js +1 -0
- package/build/runtime-chunk-HUFJRFTO.js.br +0 -0
- package/build/runtime-chunk-HUFJRFTO.js.gz +0 -0
- package/build/{runtime-chunk-SL64ZYCB.js → runtime-chunk-ITLS6YIC.js} +1 -1
- package/build/runtime-chunk-ITLS6YIC.js.br +0 -0
- package/build/runtime-chunk-ITLS6YIC.js.gz +0 -0
- package/build/{runtime-chunk-V5NUL7BL.js → runtime-chunk-JQ3A6ENO.js} +1 -1
- package/build/runtime-chunk-JQ3A6ENO.js.br +1 -0
- package/build/runtime-chunk-JQ3A6ENO.js.gz +0 -0
- package/build/{runtime-chunk-36FZTFCC.js → runtime-chunk-KYA2CB5O.js} +1 -1
- package/build/runtime-chunk-KYA2CB5O.js.br +0 -0
- package/build/runtime-chunk-KYA2CB5O.js.gz +0 -0
- package/build/{runtime-chunk-NTW4X3NC.js → runtime-chunk-LX3KCQF6.js} +1 -1
- package/build/runtime-chunk-LX3KCQF6.js.br +0 -0
- package/build/runtime-chunk-LX3KCQF6.js.gz +0 -0
- package/build/{runtime-chunk-USXMESRF.js → runtime-chunk-M3ZKF7PK.js} +1 -1
- package/build/runtime-chunk-M3ZKF7PK.js.br +0 -0
- package/build/runtime-chunk-M3ZKF7PK.js.gz +0 -0
- package/build/{runtime-chunk-GPACKOH2.js → runtime-chunk-MM2G3DLE.js} +1 -1
- package/build/runtime-chunk-MM2G3DLE.js.br +0 -0
- package/build/runtime-chunk-MM2G3DLE.js.gz +0 -0
- package/build/runtime-chunk-NAJSQF6K.js +1 -0
- package/build/runtime-chunk-NAJSQF6K.js.br +0 -0
- package/build/runtime-chunk-NAJSQF6K.js.gz +0 -0
- package/build/{runtime-chunk-QVC5UDJO.js → runtime-chunk-NWCLOXDY.js} +1 -1
- package/build/runtime-chunk-NWCLOXDY.js.br +0 -0
- package/build/runtime-chunk-NWCLOXDY.js.gz +0 -0
- package/build/{runtime-chunk-V7XDOE2W.js → runtime-chunk-OF7IZ6BI.js} +1 -1
- package/build/runtime-chunk-OF7IZ6BI.js.br +0 -0
- package/build/runtime-chunk-OF7IZ6BI.js.gz +0 -0
- package/build/{runtime-chunk-ZJPGZKPX.js → runtime-chunk-PUBEJSJO.js} +1 -1
- package/build/runtime-chunk-PUBEJSJO.js.br +0 -0
- package/build/runtime-chunk-PUBEJSJO.js.gz +0 -0
- package/build/{runtime-chunk-5XUI4Z6R.js → runtime-chunk-R34HNX2O.js} +1 -1
- package/build/runtime-chunk-R34HNX2O.js.br +0 -0
- package/build/runtime-chunk-R34HNX2O.js.gz +0 -0
- package/build/runtime-chunk-RBM3UDQF.js +1 -0
- package/build/runtime-chunk-RBM3UDQF.js.br +0 -0
- package/build/runtime-chunk-RBM3UDQF.js.gz +0 -0
- package/build/{runtime-chunk-CIBY4YG3.js → runtime-chunk-RRXSRYPQ.js} +1 -1
- package/build/runtime-chunk-RRXSRYPQ.js.br +0 -0
- package/build/runtime-chunk-RRXSRYPQ.js.gz +0 -0
- package/build/{runtime-chunk-YFAATRJU.js → runtime-chunk-SXPM42HJ.js} +1 -1
- package/build/runtime-chunk-SXPM42HJ.js.br +0 -0
- package/build/runtime-chunk-SXPM42HJ.js.gz +0 -0
- package/build/{runtime-chunk-WMWQXAOH.js → runtime-chunk-XUM5HEC6.js} +1 -1
- package/build/runtime-chunk-XUM5HEC6.js.br +0 -0
- package/build/runtime-chunk-XUM5HEC6.js.gz +0 -0
- package/build/{runtime-chunk-3J5YHSQW.js → runtime-chunk-XXRCB3ME.js} +1 -1
- package/build/runtime-chunk-XXRCB3ME.js.br +0 -0
- package/build/runtime-chunk-XXRCB3ME.js.gz +0 -0
- package/build/{runtime-classicRuntime-UOZ6RID5.js → runtime-classicRuntime-PJ7JLKSY.js} +1 -1
- package/build/runtime-classicRuntime-PJ7JLKSY.js.br +0 -0
- package/build/runtime-classicRuntime-PJ7JLKSY.js.gz +0 -0
- package/build/runtime-cloners-SM2IKR3Q.js +1 -0
- package/build/runtime-cloners-SM2IKR3Q.js.br +3 -0
- package/build/runtime-cloners-SM2IKR3Q.js.gz +0 -0
- package/build/{runtime-components-IGNRKI6T.js → runtime-components-VRLLFORJ.js} +1 -1
- package/build/runtime-components-VRLLFORJ.js.br +0 -0
- package/build/runtime-components-VRLLFORJ.js.gz +0 -0
- package/build/{runtime-conditional-DCOFCW5I.js → runtime-conditional-VA7AKA6O.js} +1 -1
- package/build/runtime-conditional-VA7AKA6O.js.br +0 -0
- package/build/runtime-conditional-VA7AKA6O.js.gz +0 -0
- package/build/{runtime-createDestroy-JLB7IIQL.js → runtime-createDestroy-IQVBLQ24.js} +1 -1
- package/build/runtime-createDestroy-IQVBLQ24.js.br +0 -0
- package/build/runtime-createDestroy-IQVBLQ24.js.gz +0 -0
- package/build/{runtime-dragDrop-ERDSNA3S.js → runtime-dragDrop-XFI62H3C.js} +1 -1
- package/build/runtime-dragDrop-XFI62H3C.js.br +0 -0
- package/build/runtime-dragDrop-XFI62H3C.js.gz +0 -0
- package/build/{runtime-fxBloom-IGFV4KJD.js → runtime-fxBloom-KENIJKIM.js} +1 -1
- package/build/runtime-fxBloom-KENIJKIM.js.br +0 -0
- package/build/runtime-fxBloom-KENIJKIM.js.gz +0 -0
- package/build/runtime-fxDepthOfField-XNWQKT4G.js +1 -0
- package/build/runtime-fxDepthOfField-XNWQKT4G.js.br +0 -0
- package/build/runtime-fxDepthOfField-XNWQKT4G.js.gz +0 -0
- package/build/{runtime-gameControls-XKOQVZZC.js → runtime-gameControls-W3YS7OS2.js} +1 -1
- package/build/runtime-gameControls-W3YS7OS2.js.br +0 -0
- package/build/runtime-gameControls-W3YS7OS2.js.gz +0 -0
- package/build/runtime-hair-CWPDHNZF.js +1 -0
- package/build/runtime-hair-CWPDHNZF.js.br +1 -0
- package/build/runtime-hair-CWPDHNZF.js.gz +0 -0
- package/build/{runtime-mergeStaticGeometries-4Y3LE3VX.js → runtime-mergeStaticGeometries-KJFDZ7TP.js} +1 -1
- package/build/runtime-mergeStaticGeometries-KJFDZ7TP.js.br +0 -0
- package/build/runtime-mergeStaticGeometries-KJFDZ7TP.js.gz +0 -0
- package/build/{runtime-miscActions-KIRLTM7C.js → runtime-miscActions-UGVVC2QC.js} +1 -1
- package/build/runtime-miscActions-UGVVC2QC.js.br +0 -0
- package/build/runtime-miscActions-UGVVC2QC.js.gz +0 -0
- package/build/{runtime-mouseHover-WULIJFG2.js → runtime-mouseHover-O7Y26SM5.js} +1 -1
- package/build/runtime-mouseHover-O7Y26SM5.js.br +0 -0
- package/build/runtime-mouseHover-O7Y26SM5.js.gz +0 -0
- package/build/{runtime-particles-NNV35DLD.js → runtime-particles-GFRULQXO.js} +1 -1
- package/build/runtime-particles-GFRULQXO.js.br +0 -0
- package/build/runtime-particles-GFRULQXO.js.gz +0 -0
- package/build/{runtime-paths-RRXZ3PXM.js → runtime-paths-Q7I56BAX.js} +1 -1
- package/build/runtime-paths-Q7I56BAX.js.br +0 -0
- package/build/runtime-paths-Q7I56BAX.js.gz +0 -0
- package/build/{runtime-resize-V6LZSOZB.js → runtime-resize-2ZFLSK2M.js} +1 -1
- package/build/runtime-resize-2ZFLSK2M.js.br +0 -0
- package/build/runtime-resize-2ZFLSK2M.js.gz +0 -0
- package/build/{runtime-sceneTransition-CP5TI3VP.js → runtime-sceneTransition-Z65VROHI.js} +1 -1
- package/build/runtime-sceneTransition-Z65VROHI.js.br +0 -0
- package/build/runtime-sceneTransition-Z65VROHI.js.gz +0 -0
- package/build/{runtime-scroll-Q7VGS5NM.js → runtime-scroll-NWKW6A6L.js} +1 -1
- package/build/runtime-scroll-NWKW6A6L.js.br +0 -0
- package/build/runtime-scroll-NWKW6A6L.js.gz +0 -0
- package/build/runtime-shapeBlends-QB7JKEHC.js +1 -0
- package/build/runtime-shapeBlends-QB7JKEHC.js.br +5 -0
- package/build/runtime-shapeBlends-QB7JKEHC.js.gz +0 -0
- package/build/runtime-text-VK3OGBSY.js +1 -0
- package/build/runtime-text-VK3OGBSY.js.br +0 -0
- package/build/runtime-text-VK3OGBSY.js.gz +0 -0
- package/build/{runtime-textInputs-IW2E6BNU.js → runtime-textInputs-JJQSKO3C.js} +1 -1
- package/build/runtime-textInputs-JJQSKO3C.js.br +0 -0
- package/build/runtime-textInputs-JJQSKO3C.js.gz +0 -0
- package/build/{runtime-timeline-JA2JZIS7.js → runtime-timeline-WRAEBCRZ.js} +1 -1
- package/build/runtime-timeline-WRAEBCRZ.js.br +0 -0
- package/build/runtime-timeline-WRAEBCRZ.js.gz +0 -0
- package/build/{runtime-tracking-M57J2PGK.js → runtime-tracking-KYP5WOMH.js} +1 -1
- package/build/runtime-tracking-KYP5WOMH.js.br +0 -0
- package/build/runtime-tracking-KYP5WOMH.js.gz +0 -0
- package/build/{runtime-transitions-PELRDE7B.js → runtime-transitions-FDRKYMVP.js} +1 -1
- package/build/runtime-transitions-FDRKYMVP.js.br +0 -0
- package/build/runtime-transitions-FDRKYMVP.js.gz +0 -0
- package/build/runtime-ui2d-YO6M74VQ.js +1 -0
- package/build/runtime-ui2d-YO6M74VQ.js.br +0 -0
- package/build/runtime-ui2d-YO6M74VQ.js.gz +0 -0
- package/build/{runtime-updater-3ELP7WMM.js → runtime-updater-FS5YHXO4.js} +1 -1
- package/build/runtime-updater-FS5YHXO4.js.br +1 -0
- package/build/runtime-updater-FS5YHXO4.js.gz +0 -0
- package/build/{runtime-variables-Q6Q2JCGI.js → runtime-variables-CYDDC6HF.js} +1 -1
- package/build/runtime-variables-CYDDC6HF.js.br +0 -0
- package/build/runtime-variables-CYDDC6HF.js.gz +0 -0
- package/build/{runtime-vectorShapes-ISY7MWHY.js → runtime-vectorShapes-VMDJ36X2.js} +1 -1
- package/build/runtime-vectorShapes-VMDJ36X2.js.br +0 -0
- package/build/runtime-vectorShapes-VMDJ36X2.js.gz +0 -0
- package/build/{runtime-video-DUDXGADJ.js → runtime-video-MTXK33PT.js} +1 -1
- package/build/runtime-video-MTXK33PT.js.br +0 -0
- package/build/runtime-video-MTXK33PT.js.gz +0 -0
- package/build/runtime-webgpu-WDY6L7BV.js +1 -0
- package/build/runtime-webgpu-WDY6L7BV.js.br +0 -0
- package/build/runtime-webgpu-WDY6L7BV.js.gz +0 -0
- package/build/runtime.cjs +323 -323
- 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 +2 -1
- package/build/runtime-aiAssistant-RMA2DMFU.js.br +0 -0
- package/build/runtime-aiAssistant-RMA2DMFU.js.gz +0 -0
- package/build/runtime-apiServices-KA4FEP5Y.js.br +0 -0
- package/build/runtime-apiServices-KA4FEP5Y.js.gz +0 -0
- package/build/runtime-audio-BQSRM3W2.js.br +0 -0
- package/build/runtime-audio-BQSRM3W2.js.gz +0 -0
- package/build/runtime-chunk-36FZTFCC.js.br +0 -0
- package/build/runtime-chunk-36FZTFCC.js.gz +0 -0
- package/build/runtime-chunk-3J5YHSQW.js.br +0 -0
- package/build/runtime-chunk-3J5YHSQW.js.gz +0 -0
- package/build/runtime-chunk-4I22JDL6.js.br +0 -0
- package/build/runtime-chunk-4I22JDL6.js.gz +0 -0
- package/build/runtime-chunk-5XUI4Z6R.js.br +0 -0
- package/build/runtime-chunk-5XUI4Z6R.js.gz +0 -0
- package/build/runtime-chunk-6UUF5VIS.js +0 -1
- package/build/runtime-chunk-6UUF5VIS.js.br +0 -0
- package/build/runtime-chunk-6UUF5VIS.js.gz +0 -0
- package/build/runtime-chunk-CIBY4YG3.js.br +0 -0
- package/build/runtime-chunk-CIBY4YG3.js.gz +0 -0
- package/build/runtime-chunk-DKGQ6OYZ.js +0 -1
- package/build/runtime-chunk-DKGQ6OYZ.js.br +0 -0
- package/build/runtime-chunk-DKGQ6OYZ.js.gz +0 -0
- package/build/runtime-chunk-DSJY3WL2.js.br +0 -0
- package/build/runtime-chunk-DSJY3WL2.js.gz +0 -0
- package/build/runtime-chunk-ESZD4IRS.js.br +0 -0
- package/build/runtime-chunk-ESZD4IRS.js.gz +0 -0
- package/build/runtime-chunk-GPACKOH2.js.br +0 -0
- package/build/runtime-chunk-GPACKOH2.js.gz +0 -0
- package/build/runtime-chunk-I5QFGBIU.js.br +0 -0
- package/build/runtime-chunk-I5QFGBIU.js.gz +0 -0
- package/build/runtime-chunk-JNSHQPHC.js +0 -1
- package/build/runtime-chunk-JNSHQPHC.js.br +0 -0
- package/build/runtime-chunk-JNSHQPHC.js.gz +0 -0
- package/build/runtime-chunk-LT4UVXE2.js.br +0 -0
- package/build/runtime-chunk-LT4UVXE2.js.gz +0 -0
- package/build/runtime-chunk-MBBODDV7.js.br +0 -0
- package/build/runtime-chunk-NTW4X3NC.js.br +0 -0
- package/build/runtime-chunk-NTW4X3NC.js.gz +0 -0
- package/build/runtime-chunk-OOC7YSI5.js.br +0 -0
- package/build/runtime-chunk-OOC7YSI5.js.gz +0 -0
- package/build/runtime-chunk-OW6T4XFV.js +0 -1
- package/build/runtime-chunk-OW6T4XFV.js.br +0 -0
- package/build/runtime-chunk-OW6T4XFV.js.gz +0 -0
- package/build/runtime-chunk-QVC5UDJO.js.br +0 -0
- package/build/runtime-chunk-QVC5UDJO.js.gz +0 -0
- package/build/runtime-chunk-R7NC6CZZ.js.br +0 -0
- package/build/runtime-chunk-R7NC6CZZ.js.gz +0 -0
- package/build/runtime-chunk-RF63UVAU.js.br +0 -0
- package/build/runtime-chunk-RF63UVAU.js.gz +0 -0
- package/build/runtime-chunk-SL64ZYCB.js.br +0 -0
- package/build/runtime-chunk-SL64ZYCB.js.gz +0 -0
- package/build/runtime-chunk-TPKGBIJU.js.br +0 -0
- package/build/runtime-chunk-TPKGBIJU.js.gz +0 -0
- package/build/runtime-chunk-USXMESRF.js.br +0 -0
- package/build/runtime-chunk-USXMESRF.js.gz +0 -0
- package/build/runtime-chunk-V5NUL7BL.js.br +0 -1
- package/build/runtime-chunk-V5NUL7BL.js.gz +0 -0
- package/build/runtime-chunk-V7XDOE2W.js.br +0 -0
- package/build/runtime-chunk-V7XDOE2W.js.gz +0 -0
- package/build/runtime-chunk-W4ZCHGLQ.js.br +0 -0
- package/build/runtime-chunk-W4ZCHGLQ.js.gz +0 -0
- package/build/runtime-chunk-WHKBOV2O.js.br +0 -0
- package/build/runtime-chunk-WHKBOV2O.js.gz +0 -0
- package/build/runtime-chunk-WMWQXAOH.js.br +0 -0
- package/build/runtime-chunk-WMWQXAOH.js.gz +0 -0
- package/build/runtime-chunk-YFAATRJU.js.br +0 -0
- package/build/runtime-chunk-YFAATRJU.js.gz +0 -0
- package/build/runtime-chunk-ZJPGZKPX.js.br +0 -0
- package/build/runtime-chunk-ZJPGZKPX.js.gz +0 -0
- package/build/runtime-chunk-ZMXEX5NX.js.br +0 -0
- package/build/runtime-chunk-ZMXEX5NX.js.gz +0 -0
- package/build/runtime-classicRuntime-UOZ6RID5.js.br +0 -0
- package/build/runtime-classicRuntime-UOZ6RID5.js.gz +0 -0
- package/build/runtime-cloners-DALMNZYL.js +0 -1
- package/build/runtime-cloners-DALMNZYL.js.br +0 -0
- package/build/runtime-cloners-DALMNZYL.js.gz +0 -0
- package/build/runtime-components-IGNRKI6T.js.br +0 -0
- package/build/runtime-components-IGNRKI6T.js.gz +0 -0
- package/build/runtime-conditional-DCOFCW5I.js.br +0 -0
- package/build/runtime-conditional-DCOFCW5I.js.gz +0 -0
- package/build/runtime-createDestroy-JLB7IIQL.js.br +0 -0
- package/build/runtime-createDestroy-JLB7IIQL.js.gz +0 -0
- package/build/runtime-dragDrop-ERDSNA3S.js.br +0 -0
- package/build/runtime-dragDrop-ERDSNA3S.js.gz +0 -0
- package/build/runtime-fxBloom-IGFV4KJD.js.br +0 -0
- package/build/runtime-fxBloom-IGFV4KJD.js.gz +0 -0
- package/build/runtime-fxDepthOfField-WX7WD3K4.js +0 -1
- package/build/runtime-fxDepthOfField-WX7WD3K4.js.br +0 -0
- package/build/runtime-fxDepthOfField-WX7WD3K4.js.gz +0 -0
- package/build/runtime-gameControls-XKOQVZZC.js.br +0 -0
- package/build/runtime-gameControls-XKOQVZZC.js.gz +0 -0
- package/build/runtime-hair-EOZHA2BH.js +0 -1
- package/build/runtime-hair-EOZHA2BH.js.br +0 -0
- package/build/runtime-hair-EOZHA2BH.js.gz +0 -0
- package/build/runtime-mergeStaticGeometries-4Y3LE3VX.js.br +0 -0
- package/build/runtime-mergeStaticGeometries-4Y3LE3VX.js.gz +0 -0
- package/build/runtime-miscActions-KIRLTM7C.js.br +0 -0
- package/build/runtime-miscActions-KIRLTM7C.js.gz +0 -0
- package/build/runtime-mouseHover-WULIJFG2.js.br +0 -0
- package/build/runtime-mouseHover-WULIJFG2.js.gz +0 -0
- package/build/runtime-particles-NNV35DLD.js.br +0 -0
- package/build/runtime-particles-NNV35DLD.js.gz +0 -0
- package/build/runtime-paths-RRXZ3PXM.js.br +0 -0
- package/build/runtime-paths-RRXZ3PXM.js.gz +0 -0
- package/build/runtime-resize-V6LZSOZB.js.br +0 -0
- package/build/runtime-resize-V6LZSOZB.js.gz +0 -0
- package/build/runtime-sceneTransition-CP5TI3VP.js.br +0 -0
- package/build/runtime-sceneTransition-CP5TI3VP.js.gz +0 -0
- package/build/runtime-scroll-Q7VGS5NM.js.br +0 -0
- package/build/runtime-scroll-Q7VGS5NM.js.gz +0 -0
- package/build/runtime-shapeBlends-UN7GGFRG.js +0 -1
- package/build/runtime-shapeBlends-UN7GGFRG.js.br +0 -0
- package/build/runtime-shapeBlends-UN7GGFRG.js.gz +0 -0
- package/build/runtime-text-N6XLUSM2.js +0 -1
- package/build/runtime-text-N6XLUSM2.js.br +0 -0
- package/build/runtime-text-N6XLUSM2.js.gz +0 -0
- package/build/runtime-textInputs-IW2E6BNU.js.br +0 -0
- package/build/runtime-textInputs-IW2E6BNU.js.gz +0 -0
- package/build/runtime-timeline-JA2JZIS7.js.br +0 -0
- package/build/runtime-timeline-JA2JZIS7.js.gz +0 -0
- package/build/runtime-tracking-M57J2PGK.js.br +0 -0
- package/build/runtime-tracking-M57J2PGK.js.gz +0 -0
- package/build/runtime-transitions-PELRDE7B.js.br +0 -0
- package/build/runtime-transitions-PELRDE7B.js.gz +0 -0
- package/build/runtime-ui2d-IOB5Y76W.js +0 -1
- package/build/runtime-ui2d-IOB5Y76W.js.br +0 -0
- package/build/runtime-ui2d-IOB5Y76W.js.gz +0 -0
- package/build/runtime-updater-3ELP7WMM.js.br +0 -1
- package/build/runtime-updater-3ELP7WMM.js.gz +0 -0
- package/build/runtime-variables-Q6Q2JCGI.js.br +0 -0
- package/build/runtime-variables-Q6Q2JCGI.js.gz +0 -0
- package/build/runtime-vectorShapes-ISY7MWHY.js.br +0 -0
- package/build/runtime-vectorShapes-ISY7MWHY.js.gz +0 -0
- package/build/runtime-video-DUDXGADJ.js.br +0 -0
- package/build/runtime-video-DUDXGADJ.js.gz +0 -0
- package/build/runtime-webgpu-4ZCV5EAD.js +0 -1
- package/build/runtime-webgpu-4ZCV5EAD.js.br +0 -0
- package/build/runtime-webgpu-4ZCV5EAD.js.gz +0 -0
package/build/opentype.js.br
CHANGED
|
Binary file
|
package/build/opentype.js.gz
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./runtime-chunk-NTUTXO7Q.js";import{a as t,b as s}from"./runtime-chunk-DZNU62CT.js";import{c as i}from"./runtime-chunk-4YV3EXSU.js";import{f as a}from"./runtime-chunk-QVC5UDJO.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as n}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-OW6T4XFV.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var r=class extends t{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:e,frequencies:t})=>{this.events.forEach(e=>{e.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"AIAssistantListener"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new o(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},o=class{constructor(e,t,s,i,n,r){this.id=e,this.data=t,this.object=s,this.actions=a(t,t.actions,i,n,r,s)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}},c=class extends t{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:e,direction:t})=>{let s=this.events.find(t=>t.data.description===e);s&&("backward"===t?s.dispatchReverse():s.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"AIAssistantTrigger"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new h(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},h=class{constructor(e,t,s,i,n,r){this.id=e,this.data=t,this.object=s,this.actions=a(t,t.actions,i,n,r,s)}dispatch(){let e=this.actions;e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(e=>e.reverseFromCurrent()),e.Particles.forEach(e=>e.reverseFromCurrent()),e.Animation.forEach(e=>e.reverseFromCurrent()),e.SwitchCamera.forEach(e=>e.reverseFromCurrent()),e.Create.forEach(e=>e.dispatchStop())}},l=function(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(e,t,s,i)=>String(t+t+s+s+i+i));let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},d=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],p=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],u=[],f=[];for(let e=1;e<=8;e++)for(let t=0;t<d.length;t++){let s=d[t];u.push(s/Math.pow(2,8-e)),f.push(p[t]+e)}var v=[32,2e3],m=u.filter((e,t)=>u[t]>v[0]&&u[t]<v[1]),y=f.filter((e,t)=>u[t]>v[0]&&u[t]<v[1]),g=class{static getFrequencies(e,t,s,i="frequency",a=-100,n=-30){s||(s=new Float32Array(e.frequencyBinCount),e.getFloatFrequencyData(s));let r,o,c,h=t/2,l=1/s.length*h;if("music"===i||"voice"===i){let e="voice"===i?m:u,t=Array(e.length).fill(a);for(let i=0;i<s.length;i++){let a=i*l,n=s[i];for(let s=e.length-1;s>=0;s--)if(a>e[s]){t[s]=Math.max(t[s],n);break}}r=t,o="voice"===i?m:u,c="voice"===i?y:f}else r=Array.from(s),o=r.map((e,t)=>l*t),c=o.map(e=>`${e.toFixed(2)} Hz`);let d=r.map(e=>Math.max(0,Math.min((e-a)/(n-a),1)));return{values:new Float32Array(d),frequencies:o,labels:c}}},E=class{constructor(e){this.value=0,this.frequencies=new Float32Array(0);let t=new AudioContext;this.source=t.createMediaStreamSource(e),this.analyser=t.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(e=-100,t=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return g.getFrequencies(this.analyser,44100,void 0,"voice",e,t)}update(){let e=this.getFrequencies(),t=e.values.reduce((e,t)=>e+t,0)/e.values.length;this.value=t,this.frequencies=e.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},b=class{constructor(e){this.callbacks=e,this.rafId=0,this.isOpen=!1,this.onMessage=e=>{this.callbacks.onMessage(e.data)},this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()},this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(e){let t=await async function(e){try{return(await(await fetch("https://relayserver.spline.design/session?uuidfile="+e)).json()).token}catch(e){console.error("Token generation error:",e)}}(e);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=e=>{let t=e.streams[0];this.audioElement.srcObject=t,this.analyser=new E(t)};let s=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(s.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let i=await this.pc.createOffer();await this.pc.setLocalDescription(i);let a={type:"answer",sdp:await(await fetch("https://api.openai.com/v1/realtime/calls?model=gpt-realtime",{method:"POST",body:i.sdp,headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(a),this.animate()}send(e){return!!this.dc&&(this.dc.send(e),!0)}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(e=>{e.track&&e.track.stop()}),this.pc?.close(),this.pc=void 0}};var w=class{constructor(t,s,i){this.data=t,this.id=s,this.shared=i,this.emitter=e(),this.voice=0,this.frequencies=new Float32Array([0]),this.events=[],this.isConnected=!1,this.isToolsAdded=!1,this.tools=[],this.onServerEvent=e=>{let t=JSON.parse(e);if(this.appendEvent(t),"session.created"===t.type&&this.onSessionCreated(),"response.done"===t.type&&t.response?.output)for(let e of t.response.output)if("function_call"===e.type)for(let[t,s]of this.tools)e.name===t.name&&(s(JSON.parse(e.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))},this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()},this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(e){this.data=e}setColorByName(e,t){let s=this.shared.getColorByName(e);if(s){let{id:e}=s,{r:i,g:a,b:n}=l(t)??{r:0,g:0,b:0};this.shared.updateColor(e,{r:i/255,g:a/255,b:n/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let e={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,t)=>{this.voice=e,this.frequencies=t,this.emitter.emit("voice",{value:e,frequencies:t})}};this.hosted=function(e,t,s){if(!function(){try{return!0===window.__SPLINE_PLAY_VOICE_HOST__&&window.parent!==window}catch{return!1}}())return null;let i=!1,a=e=>{window.parent.postMessage({__splinePlayFrame:!0,...e},"*")},n=t=>{if(t.source!==window.parent)return;let a=t.data;!a||!0!==a.__splinePlayFrameHost||a.id!==e||("voice-open"===a.type?(i=!0,s.onOpen()):"voice-message"===a.type&&"string"==typeof a.data?s.onMessage(a.data):"voice-level"===a.type&&"number"==typeof a.value?s.onVoice(a.value,a.frequencies instanceof Float32Array?a.frequencies:new Float32Array(0)):"voice-error"===a.type&&console.error("Voice assistant host error:",a.message))};return window.addEventListener("message",n),a({type:"voice-connect",id:e,hash:t}),{send:t=>!!i&&(a({type:"voice-send",id:e,message:t}),!0),disconnect:()=>{i=!1,window.removeEventListener("message",n),a({type:"voice-disconnect",id:e})}}}(this.id,this.data.integration.hash,e),!this.hosted&&(this.session=new b(e),await this.session.connect(this.data.integration.hash))}appendEvent(e){this.events=[e,...this.events]}sendClientEvent(e){e.event_id=e.event_id||crypto.randomUUID();let t=JSON.stringify(e);(this.hosted?this.hosted.send(t):this.session?.send(t))?this.appendEvent(e):console.error("Failed to send message - no data channel available",e)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:e})=>{this.setColorByName("Voice Assistant Color",e)});let e=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${e}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:e,value:t})=>{let s=this.shared.getVariableByName(e);if(s){let e,i=this.shared.getVariable(s.id);e="number"==typeof i?parseFloat(t):"boolean"==typeof i?"true"===t.toLowerCase():{textValue:t},this.shared.updateVariable(s.id,e)}});let t=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${t}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:e,value:t})=>{this.setColorByName(e,t)});let s=this.shared.scene,i=[];s.traverseEntity(e=>{e.data.events.forEach(e=>{if("AIAssistantTrigger"===e.data.type){let{description:t}=e.data;i.push(t)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(i)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:e,direction:t})=>{this.emitter.emit("trigger_event",{description:e,direction:t})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([e])=>e)}})}registerTool(e,t){this.tools.push([e,t])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(e){if("range"===e.analysis){let t=this.frequencies.slice(...e.analysisRange);return t.reduce((e,t)=>e+t,0)/t.length}return"single"===e.analysis?this.frequencies[e.analysisSingle]:this.voice}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}};s("AIAssistantListener",({eventContext:e,eventManager:t})=>new r(e,t)),s("AIAssistantTrigger",({eventContext:e,eventManager:t})=>new c(e,t)),i((e,t,s)=>new w(e,t,s)),n("ai-assistant");
|
|
1
|
+
import{a as e}from"./runtime-chunk-NTUTXO7Q.js";import{a as t,b as s}from"./runtime-chunk-DZNU62CT.js";import{c as i}from"./runtime-chunk-4YV3EXSU.js";import{f as a}from"./runtime-chunk-NWCLOXDY.js";import"./runtime-chunk-R34HNX2O.js";import{a as n}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-RBM3UDQF.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var r=class extends t{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onVoice=({value:e,frequencies:t})=>{this.events.forEach(e=>{e.dispatch()})}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"AIAssistantListener"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new o(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("voice",this.onVoice))}disconnect(){this.openAIRealtime?.off("voice",this.onVoice)}},o=class{constructor(e,t,s,i,n,r){this.id=e,this.data=t,this.object=s,this.actions=a(t,t.actions,i,n,r,s)}dispatch(){this.dispatchActions(this.actions)}dispatchActions(e){e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}},c=class extends t{constructor(e,t){super(e),this.eventManager=t,this.events=[],this.onTriggerEvent=({description:e,direction:t})=>{let s=this.events.find(t=>t.data.description===e);s&&("backward"===t?s.dispatchReverse():s.dispatch())}}connect(){this.openAIRealtime=this.eventContext.sharedAssets.openAIRealtime,this.openAIRealtime&&(this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"AIAssistantTrigger"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new h(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),this.openAIRealtime.on("trigger_event",this.onTriggerEvent))}disconnect(){this.openAIRealtime?.off("trigger_event",this.onTriggerEvent)}},h=class{constructor(e,t,s,i,n,r){this.id=e,this.data=t,this.object=s,this.actions=a(t,t.actions,i,n,r,s)}dispatch(){let e=this.actions;e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}dispatchReverse(){let e=this.actions;e.Transition.forEach(e=>e.reverseFromCurrent()),e.Particles.forEach(e=>e.reverseFromCurrent()),e.Animation.forEach(e=>e.reverseFromCurrent()),e.SwitchCamera.forEach(e=>e.reverseFromCurrent()),e.Create.forEach(e=>e.dispatchStop())}},l=function(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(e,t,s,i)=>String(t+t+s+s+i+i));let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},d=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],p=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],u=[],f=[];for(let e=1;e<=8;e++)for(let t=0;t<d.length;t++){let s=d[t];u.push(s/Math.pow(2,8-e)),f.push(p[t]+e)}var v=[32,2e3],m=u.filter((e,t)=>u[t]>v[0]&&u[t]<v[1]),y=f.filter((e,t)=>u[t]>v[0]&&u[t]<v[1]),g=class{static getFrequencies(e,t,s,i="frequency",a=-100,n=-30){s||(s=new Float32Array(e.frequencyBinCount),e.getFloatFrequencyData(s));let r,o,c,h=t/2,l=1/s.length*h;if("music"===i||"voice"===i){let e="voice"===i?m:u,t=Array(e.length).fill(a);for(let i=0;i<s.length;i++){let a=i*l,n=s[i];for(let s=e.length-1;s>=0;s--)if(a>e[s]){t[s]=Math.max(t[s],n);break}}r=t,o="voice"===i?m:u,c="voice"===i?y:f}else r=Array.from(s),o=r.map((e,t)=>l*t),c=o.map(e=>`${e.toFixed(2)} Hz`);let d=r.map(e=>Math.max(0,Math.min((e-a)/(n-a),1)));return{values:new Float32Array(d),frequencies:o,labels:c}}},E=class{constructor(e){this.value=0,this.frequencies=new Float32Array(0);let t=new AudioContext;this.source=t.createMediaStreamSource(e),this.analyser=t.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(e=-100,t=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return g.getFrequencies(this.analyser,44100,void 0,"voice",e,t)}update(){let e=this.getFrequencies(),t=e.values.reduce((e,t)=>e+t,0)/e.values.length;this.value=t,this.frequencies=e.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},b=class{constructor(e){this.callbacks=e,this.rafId=0,this.isOpen=!1,this.onMessage=e=>{this.callbacks.onMessage(e.data)},this.onOpen=()=>{this.isOpen=!0,this.callbacks.onOpen()},this.animate=()=>{this.rafId=requestAnimationFrame(this.animate),this.isOpen&&this.analyser&&(this.analyser.update(),this.callbacks.onVoice(this.analyser.value,this.analyser.frequencies))}}async connect(e){let t=await async function(e){try{return(await(await fetch("https://relayserver.spline.design/session?uuidfile="+e)).json()).token}catch(e){console.error("Token generation error:",e)}}(e);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=e=>{let t=e.streams[0];this.audioElement.srcObject=t,this.analyser=new E(t)};let s=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(s.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let i=await this.pc.createOffer();await this.pc.setLocalDescription(i);let a={type:"answer",sdp:await(await fetch("https://api.openai.com/v1/realtime/calls?model=gpt-realtime",{method:"POST",body:i.sdp,headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(a),this.animate()}send(e){return!!this.dc&&(this.dc.send(e),!0)}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.isOpen=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(e=>{e.track&&e.track.stop()}),this.pc?.close(),this.pc=void 0}};var w=class{constructor(t,s,i){this.data=t,this.id=s,this.shared=i,this.emitter=e(),this.voice=0,this.frequencies=new Float32Array([0]),this.events=[],this.isConnected=!1,this.isToolsAdded=!1,this.tools=[],this.onServerEvent=e=>{let t=JSON.parse(e);if(this.appendEvent(t),"session.created"===t.type&&this.onSessionCreated(),"response.done"===t.type&&t.response?.output)for(let e of t.response.output)if("function_call"===e.type)for(let[t,s]of this.tools)e.name===t.name&&(s(JSON.parse(e.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))},this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()},this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})}}update(e){this.data=e}setColorByName(e,t){let s=this.shared.getColorByName(e);if(s){let{id:e}=s,{r:i,g:a,b:n}=l(t)??{r:0,g:0,b:0};this.shared.updateColor(e,{r:i/255,g:a/255,b:n/255})}}async connect(){if(this.isConnected||this.session||this.hosted)return;let e={onMessage:this.onServerEvent,onOpen:this.onOpen,onVoice:(e,t)=>{this.voice=e,this.frequencies=t,this.emitter.emit("voice",{value:e,frequencies:t})}};this.hosted=function(e,t,s){if(!function(){try{return!0===window.__SPLINE_PLAY_VOICE_HOST__&&window.parent!==window}catch{return!1}}())return null;let i=!1,a=e=>{window.parent.postMessage({__splinePlayFrame:!0,...e},"*")},n=t=>{if(t.source!==window.parent)return;let a=t.data;!a||!0!==a.__splinePlayFrameHost||a.id!==e||("voice-open"===a.type?(i=!0,s.onOpen()):"voice-message"===a.type&&"string"==typeof a.data?s.onMessage(a.data):"voice-level"===a.type&&"number"==typeof a.value?s.onVoice(a.value,a.frequencies instanceof Float32Array?a.frequencies:new Float32Array(0)):"voice-error"===a.type&&console.error("Voice assistant host error:",a.message))};return window.addEventListener("message",n),a({type:"voice-connect",id:e,hash:t}),{send:t=>!!i&&(a({type:"voice-send",id:e,message:t}),!0),disconnect:()=>{i=!1,window.removeEventListener("message",n),a({type:"voice-disconnect",id:e})}}}(this.id,this.data.integration.hash,e),!this.hosted&&(this.session=new b(e),await this.session.connect(this.data.integration.hash))}appendEvent(e){this.events=[e,...this.events]}sendClientEvent(e){e.event_id=e.event_id||crypto.randomUUID();let t=JSON.stringify(e);(this.hosted?this.hosted.send(t):this.session?.send(t))?this.appendEvent(e):console.error("Failed to send message - no data channel available",e)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:e})=>{this.setColorByName("Voice Assistant Color",e)});let e=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${e}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:e,value:t})=>{let s=this.shared.getVariableByName(e);if(s){let e,i=this.shared.getVariable(s.id);e="number"==typeof i?parseFloat(t):"boolean"==typeof i?"true"===t.toLowerCase():{textValue:t},this.shared.updateVariable(s.id,e)}});let t=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${t}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:e,value:t})=>{this.setColorByName(e,t)});let s=this.shared.scene,i=[];s.traverseEntity(e=>{e.data.events.forEach(e=>{if("AIAssistantTrigger"===e.data.type){let{description:t}=e.data;i.push(t)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(i)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:e,direction:t})=>{this.emitter.emit("trigger_event",{description:e,direction:t})}),this.sendClientEvent({type:"session.update",session:{type:"realtime",tools:this.tools.map(([e])=>e)}})}registerTool(e,t){this.tools.push([e,t])}disconnect(){this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.session?.disconnect(),this.session=void 0,this.hosted?.disconnect(),this.hosted=null}computeAnalysisForListenerEvent(e){if("range"===e.analysis){let t=this.frequencies.slice(...e.analysisRange);return t.reduce((e,t)=>e+t,0)/t.length}return"single"===e.analysis?this.frequencies[e.analysisSingle]:this.voice}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}};s("AIAssistantListener",({eventContext:e,eventManager:t})=>new r(e,t)),s("AIAssistantTrigger",({eventContext:e,eventManager:t})=>new c(e,t)),i((e,t,s)=>new w(e,t,s)),n("ai-assistant");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./runtime-chunk-NTUTXO7Q.js";import{a as t,b as s}from"./runtime-chunk-DZNU62CT.js";import{a as r}from"./runtime-chunk-4YV3EXSU.js";import{b as i,e as n,f as o}from"./runtime-chunk-QVC5UDJO.js";import{a}from"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-5XUI4Z6R.js";import{a as h}from"./runtime-chunk-TZCHGFVF.js";import{Ga as c,Ha as d,o as u}from"./runtime-chunk-OW6T4XFV.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var l=class extends t{constructor(e,t){super(e),this.eventManager=t,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:e})=>{this.events.forEach(t=>{t.data.userAPIId===e&&t.dispatchSuccess()})},this.onError=({userAPIId:e})=>{this.events.forEach(t=>{t.data.userAPIId===e&&t.dispatchError()})},this.userAPIs=e.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"API"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new p(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([e,t])=>{t.on("success",this.onSuccess),t.on("error",this.onError),t.autostart&&t.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([e,t])=>{t.off("success",this.onSuccess),t.off("error",this.onError)})}},p=class{constructor(e,t,s,r,i,n){this.id=e,this.data=t,this.object=s,this.successActions=o(t,t.successActions,r,i,n,s),this.errorActions=o(t,t.errorActions,r,i,n,s)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(e){e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}},f=class extends t{constructor(e,t){super(e),this.eventManager=t,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:e})=>{this.events.forEach(t=>{t.data.userWebhookId===e&&t.dispatch()})},this.userWebhooks=e.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"WEBHOOK"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new m(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([e,t])=>{t.connect(),t.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([e,t])=>{t.off("message",this.onMessage),t.disconnect()})}},m=class{constructor(e,t,s,r,i,n){this.id=e,this.data=t,this.object=s,this.actions=o(t,t.actions,r,i,n,s)}dispatch(){let e=this.actions;e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}},v=class{constructor(e,t,s,r){this.data=e,this.page=t,this.shared=s,this.condition=r}dispatch(){if(!1===n(this.shared,this.condition))return!1;if(this.data.userAPIId){let e=this.shared.getUserAPI(this.data.userAPIId);e&&"callUserAPI"in e&&e.callUserAPI(this.shared)}}dispose(){}},E=class{constructor(t,s,r){this.id=t,this.userAPI=s,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(e=>e()),this.emitter=e(),this._innerCallUserAPI=async e=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await async function(e,t,s=new AbortController){let r,i,n=e.url,o=e.proxy?.enabled??!1;if("OpenAI"===e.integration?.type){let s=b(""===e.integration.prompt?[]:JSON.parse(e.integration.prompt),t),r=""===e.integration.behavior?[]:b(JSON.parse(e.integration.behavior),t);i=`{\n\t\t"model": "${e.integration.model}",\n\t\t"messages": [${e.integration.useBehavior?`\n\t\t{\n\t\t\t"role": "system",\n\t\t\t"content": "${r}"\n\t\t},`:""}\n\t\t{\n\t\t\t"role": "user",\n\t\t\t"content": "${s}"\n\t\t}\n\t\t]\n\t}`}if(o){let s;n=`https://apis.spline.design/file/${e.proxy.fileId}/external-api/request?uuidexternalapi=${e.proxy.proxyId}`,void 0!==i?s=i:"POST"===e.method&&e.body&&(s=b(JSON.parse(e.body),t)),void 0!==s&&(n+=`&data=${encodeURIComponent(s.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else"OpenAI"===e.integration?.type?r=i:"POST"===e.method&&e.body&&(r=b(JSON.parse(e.body),t));let a=await fetch(n,{method:o?"GET":e.method,headers:o?void 0:g(e),signal:s.signal,body:r});if(!a.ok)throw new Error("status:"+a.status+"_:_"+a.statusText);if("OpenAI"===e.integration?.type){let e=await a.json();return o&&(e=e.response),{content:e.choices[0].message.content}}{let e=await a.json();return o&&(e=e.response),e}}(this.userAPI,e),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let t=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=t,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0},"OpenAI"===s?.integration?.type?this.result={content:""}:"GET"===s.method&&""!==s.url&&(this.prefetchPromise=this.prefetch(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=a(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=void 0!==this.userAPI.debounce&&this.userAPI.debounce>0?a(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(e){await this.callUserAPI(e)}async callUserAPI(e){await this._debouncedCallUserAPI(e)}update(e,t,s=!0){this.userAPI=e,this._updateDebouncedCallUserAPI(),""!==this.userAPI.url&&"GET"===this.userAPI.method&&s&&this._debouncedPrefetch(t)}retrieveValue(e){if(this.result)try{return u.zoom(this.result,e)}catch(e){console.error(e)}}retrieveZoomedKeyValues(e){if(this.result){let s=e&&e.length?u.zoom(this.result,e):this.result;if("object"==typeof(t=s)&&null!==t)return Object.entries(s);if(function(e){return Array.isArray(e)}(s))return s.map((e,t)=>[t.toString(),e]);throw function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null===e}(s)?new Error("This path points to a value, use retrieveValue() instead. "+e?.join(".")):new Error("Path error"+e?.join("."))}var t}dispose(){}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}get autostart(){return this.userAPI.autoStart}};function g(e){let t=new Headers;return e.headers.forEach(e=>{""!==e.data.key&&t.append(e.data.key,e.data.value)}),t}var A=(e,t)=>{if("string"==typeof e){let s=t.getVariable(e);if(s)return A(s,t)}return d.isBoolean(e)?d.getDisplayedValue(e).toLowerCase():d.getDisplayedValue(e)},b=(e,t)=>e.map((e,s)=>{if("text"in e)return e.text;if("type"in e){if("paragraph"===e.type)return(s>0?"\n":"")+b(e.children,t);if("variable"===e.type){let s=t.getVariable(e.variableId);if(void 0!==s)return A(s,t)}}return""}).join(""),I=1e3,P=512*I,y=class{constructor(t,s){this.id=t,this.userWebhook=s,this.result=void 0,this._connected=!1,this.emitter=e(),this.reconnectWaitFor=I,this._onError=e=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()},this._onConnected=e=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=I,this._connected=!0},this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=I,this._connected=!1},this._onMessage=e=>{let t,s=e.data;try{t=JSON.parse(s)}catch(e){console.error("Error parsing webhook message",e)}if(t){let e=!1;this.userWebhook.parametersSchemas.forEach(({data:s})=>{void 0!==t[s.name]&&function(e,t){let s=typeof e;return!!(("string"===t||"number"===t)&&s===t||"boolean"===t&&("true"===e||"false"===e||!0===e||!1===e)||"image"===t&&"string"===s&&e.startsWith("http"))}(t[s.name],s.type)&&(void 0===this.result&&(this.result={}),this.result[s.name]=t[s.name],e=!0)}),e&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource("https://hooks.spline.design/events?hashFile="+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>P&&(this.reconnectWaitFor=P),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(e){this.userWebhook=e}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(e=>e.data.name)}getParameterValue(e){if(this.getParametersKeys().includes(e)){if(this.result)return this.result?.[e];for(let t of this.userWebhook.parametersSchemas)if(t.data.name===e)return c.defaultParameterValueByType(t.data.type)}}};s("API",({eventContext:e,eventManager:t})=>new l(e,t)),s("WEBHOOK",({eventContext:e,eventManager:t})=>new f(e,t)),i("UserAPI",({data:e,page:t,shared:s,actionCondition:r})=>new v(e,t,s,r)),r({createUserAPI:(e,t,s)=>new E(e,t,s),createUserWebhook:(e,t)=>new y(e,t)}),h("api-services");
|
|
1
|
+
import{a as e}from"./runtime-chunk-NTUTXO7Q.js";import{a as t,b as s}from"./runtime-chunk-DZNU62CT.js";import{a as r}from"./runtime-chunk-4YV3EXSU.js";import{b as i,e as n,f as o}from"./runtime-chunk-NWCLOXDY.js";import{a}from"./runtime-chunk-4KZXQGUQ.js";import"./runtime-chunk-R34HNX2O.js";import{a as h}from"./runtime-chunk-TZCHGFVF.js";import{Ga as c,Ha as d,o as u}from"./runtime-chunk-RBM3UDQF.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var l=class extends t{constructor(e,t){super(e),this.eventManager=t,this.userAPIs={},this.events=[],this.onSuccess=({userAPIId:e})=>{this.events.forEach(t=>{t.data.userAPIId===e&&t.dispatchSuccess()})},this.onError=({userAPIId:e})=>{this.events.forEach(t=>{t.data.userAPIId===e&&t.dispatchError()})},this.userAPIs=e.sharedAssets.getUserAPIs()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"API"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new p(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userAPIs).forEach(([e,t])=>{t.on("success",this.onSuccess),t.on("error",this.onError),t.autostart&&t.callUserAPI(this.eventContext.sharedAssets)})}disconnect(){Object.entries(this.userAPIs).forEach(([e,t])=>{t.off("success",this.onSuccess),t.off("error",this.onError)})}},p=class{constructor(e,t,s,r,i,n){this.id=e,this.data=t,this.object=s,this.successActions=o(t,t.successActions,r,i,n,s),this.errorActions=o(t,t.errorActions,r,i,n,s)}dispatchSuccess(){this.dispatchActions(this.successActions)}dispatchError(){this.dispatchActions(this.errorActions)}dispatchActions(e){e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}},f=class extends t{constructor(e,t){super(e),this.eventManager=t,this.userWebhooks={},this.events=[],this.onMessage=({userWebhookId:e})=>{this.events.forEach(t=>{t.data.userWebhookId===e&&t.dispatch()})},this.userWebhooks=e.sharedAssets.getUserWebhooks()}connect(){this.eventContext.page.traverseEntity(e=>{e.data?.events.filter(e=>"WEBHOOK"===e.data.type&&!e.data.disabled).forEach(t=>{this.events.push(new m(t.id,t.data,e,this.eventContext.page,this.eventContext.sharedAssets,this.eventManager))})}),Object.entries(this.userWebhooks).forEach(([e,t])=>{t.connect(),t.on("message",this.onMessage)})}disconnect(){Object.entries(this.userWebhooks).forEach(([e,t])=>{t.off("message",this.onMessage),t.disconnect()})}},m=class{constructor(e,t,s,r,i,n){this.id=e,this.data=t,this.object=s,this.actions=o(t,t.actions,r,i,n,s)}dispatch(){let e=this.actions;e.Audio.forEach(e=>e.dispatchConditional()),e.Particles.forEach(e=>e.dispatchConditional()),e.Video.forEach(e=>e.dispatchConditional()),e.Create.forEach(e=>e.dispatch()),e.Destroy.forEach(e=>e.dispatch()),e.Reset.forEach(e=>e.dispatch()),e.Transition.forEach(e=>{e.object.currentTransitionEvent!==this&&(e.object.currentTransitionEvent=this),e.init()}),e.Transition.forEach(e=>e.play()),e.Animation.forEach(e=>e.play()),e.SwitchCamera.forEach(e=>e.play()),e.SceneTransition.forEach(e=>e.dispatch()),e.SetVariable.forEach(e=>e.checkConditions()),e.SetVariable.forEach(e=>e.dispatch()),e.DynamicVariablePlay.forEach(e=>e.dispatch()),e.ClearLocalStorage.forEach(e=>e.dispatch()),e.UserAPI.forEach(e=>e.dispatch())}},v=class{constructor(e,t,s,r){this.data=e,this.page=t,this.shared=s,this.condition=r}dispatch(){if(!1===n(this.shared,this.condition))return!1;if(this.data.userAPIId){let e=this.shared.getUserAPI(this.data.userAPIId);e&&"callUserAPI"in e&&e.callUserAPI(this.shared)}}dispose(){}},E=class{constructor(t,s,r){this.id=t,this.userAPI=s,this.result=void 0,this.error="null",this.isPrefetched=!1,this.isLoading=!1,this.isLoaded=!1,this.prefetchPromise=new Promise(e=>e()),this.emitter=e(),this._innerCallUserAPI=async e=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await async function(e,t,s=new AbortController){let r,i,n=e.url,o=e.proxy?.enabled??!1;if("OpenAI"===e.integration?.type){let s=b(""===e.integration.prompt?[]:JSON.parse(e.integration.prompt),t),r=""===e.integration.behavior?[]:b(JSON.parse(e.integration.behavior),t);i=`{\n\t\t"model": "${e.integration.model}",\n\t\t"messages": [${e.integration.useBehavior?`\n\t\t{\n\t\t\t"role": "system",\n\t\t\t"content": "${r}"\n\t\t},`:""}\n\t\t{\n\t\t\t"role": "user",\n\t\t\t"content": "${s}"\n\t\t}\n\t\t]\n\t}`}if(o){let s;n=`https://apis.spline.design/file/${e.proxy.fileId}/external-api/request?uuidexternalapi=${e.proxy.proxyId}`,void 0!==i?s=i:"POST"===e.method&&e.body&&(s=b(JSON.parse(e.body),t)),void 0!==s&&(n+=`&data=${encodeURIComponent(s.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else"OpenAI"===e.integration?.type?r=i:"POST"===e.method&&e.body&&(r=b(JSON.parse(e.body),t));let a=await fetch(n,{method:o?"GET":e.method,headers:o?void 0:g(e),signal:s.signal,body:r});if(!a.ok)throw new Error("status:"+a.status+"_:_"+a.statusText);if("OpenAI"===e.integration?.type){let e=await a.json();return o&&(e=e.response),{content:e.choices[0].message.content}}{let e=await a.json();return o&&(e=e.response),e}}(this.userAPI,e),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let t=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=t,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0},"OpenAI"===s?.integration?.type?this.result={content:""}:"GET"===s.method&&""!==s.url&&(this.prefetchPromise=this.prefetch(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=a(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=void 0!==this.userAPI.debounce&&this.userAPI.debounce>0?a(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(e){await this.callUserAPI(e)}async callUserAPI(e){await this._debouncedCallUserAPI(e)}update(e,t,s=!0){this.userAPI=e,this._updateDebouncedCallUserAPI(),""!==this.userAPI.url&&"GET"===this.userAPI.method&&s&&this._debouncedPrefetch(t)}retrieveValue(e){if(this.result)try{return u.zoom(this.result,e)}catch(e){console.error(e)}}retrieveZoomedKeyValues(e){if(this.result){let s=e&&e.length?u.zoom(this.result,e):this.result;if("object"==typeof(t=s)&&null!==t)return Object.entries(s);if(function(e){return Array.isArray(e)}(s))return s.map((e,t)=>[t.toString(),e]);throw function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null===e}(s)?new Error("This path points to a value, use retrieveValue() instead. "+e?.join(".")):new Error("Path error"+e?.join("."))}var t}dispose(){}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}get autostart(){return this.userAPI.autoStart}};function g(e){let t=new Headers;return e.headers.forEach(e=>{""!==e.data.key&&t.append(e.data.key,e.data.value)}),t}var A=(e,t)=>{if("string"==typeof e){let s=t.getVariable(e);if(s)return A(s,t)}return d.isBoolean(e)?d.getDisplayedValue(e).toLowerCase():d.getDisplayedValue(e)},b=(e,t)=>e.map((e,s)=>{if("text"in e)return e.text;if("type"in e){if("paragraph"===e.type)return(s>0?"\n":"")+b(e.children,t);if("variable"===e.type){let s=t.getVariable(e.variableId);if(void 0!==s)return A(s,t)}}return""}).join(""),I=1e3,P=512*I,y=class{constructor(t,s){this.id=t,this.userWebhook=s,this.result=void 0,this._connected=!1,this.emitter=e(),this.reconnectWaitFor=I,this._onError=e=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()},this._onConnected=e=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=I,this._connected=!0},this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=I,this._connected=!1},this._onMessage=e=>{let t,s=e.data;try{t=JSON.parse(s)}catch(e){console.error("Error parsing webhook message",e)}if(t){let e=!1;this.userWebhook.parametersSchemas.forEach(({data:s})=>{void 0!==t[s.name]&&function(e,t){let s=typeof e;return!!(("string"===t||"number"===t)&&s===t||"boolean"===t&&("true"===e||"false"===e||!0===e||!1===e)||"image"===t&&"string"===s&&e.startsWith("http"))}(t[s.name],s.type)&&(void 0===this.result&&(this.result={}),this.result[s.name]=t[s.name],e=!0)}),e&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource("https://hooks.spline.design/events?hashFile="+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>P&&(this.reconnectWaitFor=P),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(e){this.userWebhook=e}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(e=>e.data.name)}getParameterValue(e){if(this.getParametersKeys().includes(e)){if(this.result)return this.result?.[e];for(let t of this.userWebhook.parametersSchemas)if(t.data.name===e)return c.defaultParameterValueByType(t.data.type)}}};s("API",({eventContext:e,eventManager:t})=>new l(e,t)),s("WEBHOOK",({eventContext:e,eventManager:t})=>new f(e,t)),i("UserAPI",({data:e,page:t,shared:s,actionCondition:r})=>new v(e,t,s,r)),r({createUserAPI:(e,t,s)=>new E(e,t,s),createUserWebhook:(e,t)=>new y(e,t)}),h("api-services");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./runtime-chunk-NSD7DU3P.js";import{b as i,e as a}from"./runtime-chunk-
|
|
1
|
+
import{c as t}from"./runtime-chunk-NSD7DU3P.js";import{b as i,e as a}from"./runtime-chunk-NWCLOXDY.js";import"./runtime-chunk-R34HNX2O.js";import{a as s}from"./runtime-chunk-TZCHGFVF.js";import"./runtime-chunk-RBM3UDQF.js";import"./runtime-chunk-VGN7YHB7.js";import"./runtime-chunk-ML3Z74BL.js";var e=new Map,o=new Map,d=class{constructor(i,a,s,d){this.data=a,this.isPlayAudioAction=!0;let{audio:n,volume:r,delay:h,loop:u}=a;if(!n)throw new Error("Missing property");try{let i="string"==typeof n?d.getAudio(n).src:n.data;this.audioPlayer=new t({src:i,volume:r,delay:h,loop:u})}catch{console.warn(`Could not create an audio player for this object: "${s.name}" and this audio: "${n}"`)}o.has(s.uuid)?o.get(s.uuid).push(this):o.set(s.uuid,[this]),e.set(i,this)}playByToggle(){"stop"===this.data.toggle?"playing"===this.audioPlayer?.status?this.audioPlayer.stop():(this.audioPlayer?.stop(),this.audioPlayer?.play()):"pause"===this.data.toggle?"playing"===this.audioPlayer?.status?this.audioPlayer?.pause():this.audioPlayer?.play():(this.audioPlayer?.stop(),this.audioPlayer?.play())}dispose(){this.audioPlayer?.stop()}},n=class{constructor(t){this.data=t,this.isPauseAudioAction=!0}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(t){let i=e.get(t);!i||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{i.audioPlayer?.[this.data.interaction](),this.disposeDelay()},this.data.delay)):i.audioPlayer?.[this.data.interaction]())}pauseAllAudiosFromObject(t){let i=o.get(t);!i?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{i.forEach(t=>t.audioPlayer?.[this.data.interaction]()),this.disposeDelay()},this.data.delay)):i.forEach(t=>t.audioPlayer?.[this.data.interaction]()))}pauseAllAudios(){let t=[...o.values()];!t.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(t=>{t.forEach(t=>{t.audioPlayer?.[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):t.forEach(t=>{t.forEach(t=>{t.audioPlayer?.[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},r=class{constructor(t,i,a,s,e){if(this.data=i,this.shared=s,this.condition=e,"play"===i.interaction)this.interaction=new d(t,i,a,s);else{if("pause"!==i.interaction&&"stop"!==i.interaction)throw new Error("Missing property");this.interaction=new n(i)}}dispatchBasic(){if(!1===a(this.shared,this.condition))return!1;this.interaction instanceof d?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){if(!1===a(this.shared,this.condition))return!1;this.interaction instanceof d?this.interaction.audioPlayer?.play():this.interaction.dispatch()}dispatchGameControl(t){if(!1===a(this.shared,this.condition))return!1;this.interaction instanceof d&&("start"===t?this.interaction.audioPlayer?.play():this.interaction.audioPlayer?.stop())}dispose(){this.interaction.dispose()}};i("Audio",({id:t,data:i,object:a,shared:s,actionCondition:e})=>new r(t,i,a,s,e)),s("audio");
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as t}from"./runtime-chunk-N2ZRGNPR.js";import{a as e,c as i}from"./runtime-chunk-VAVYZ35B.js";import{b as s,c as o,d as a,e as n}from"./runtime-chunk-FQNSP44B.js";import{a as r}from"./runtime-chunk-V5NUL7BL.js";import{G as h,a as l}from"./runtime-chunk-YFAATRJU.js";import{f as d,g as c}from"./runtime-chunk-QVC5UDJO.js";import{h as p}from"./runtime-chunk-OOC7YSI5.js";import{a as m,g as u,h as y,i as v}from"./runtime-chunk-2PT2WH66.js";import{a as g}from"./runtime-chunk-4KZXQGUQ.js";import{c as f}from"./runtime-chunk-TZCHGFVF.js";import{Fa as b}from"./runtime-chunk-OW6T4XFV.js";import{Bc as E,Dc as P,Ec as C,Fc as M,Oc as x,Oe as T,Pc as S,Rc as D,Xc as w,b as R,bd as j,cd as L,dd as G}from"./runtime-chunk-VGN7YHB7.js";var B=200,A=null;function W(t){A=t}function O(){return A}function I(t){let e=!1;return t.scene.objects.forEach(i=>{"Page"===i.data.type&&!e&&i.data.publish.gameControlObject&&b.traverseModuleInstances(t,i.id,(t,i,s)=>{for(let t of s)"GameControl"===t.data.type&&t.data.navmesh.enabled&&(e=!0)})}),e}function F(t){return s?t.metaKey:t.ctrlKey}function k(t,e){return Math.abs(t+3*e)<=2||Math.abs(t+3*window.devicePixelRatio*e)<=2}var V={type:"change"},z={type:"start"},H={type:"end",nonOrbit:!0},Z={type:"end",nonOrbit:!1},U={type:"end",isZoom:!0,nonOrbit:!0},Y={type:"end",changed:!1},X={type:"cameraAnimatingInTimeline"},N=new C,K=new P,_=2*Math.PI,q=new M,Q=new P,J=new M,$=new C,tt=new x,et={type:"requestRender"},it=class extends E{constructor(t,i,s={isPlayMode:!1,isExport:!1},a){super(),this.object=t,this.domElement=i,this.options=s,this.timelineState=a,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,R.DOLLY_ROTATE,R.PAN],this.offset=new M,this.eye=new M,this.lastPosition=new M,this.lastQuaternion=new C,this.current=new P,this.overShoot=new P,this.overRatio=new P,this.spherical=new T,this.sphericalDelta=new T,this.panOffset=new M,this.panLeftV=new M,this.panUpV=new M,this.panV=new M,this.rotateStart=new P,this.rotateEnd=new P,this.rotateDelta=new P,this.panStart=new P,this.panEnd=new P,this.panDelta=new P,this.dollyStart=new P,this.dollyEnd=new P,this.dollyDelta=new P,this.rotationRangeFactor=new P,this.panRangeFactor=new P,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=t=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=t.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&-1===this.state&&this.rotateLeft((!0===this.autoRotateClockwise?1:-1)*this.getAutoRotationAngle()),0!==this.rotationLimitsMode&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),2!==this.rotationLimitsMode&&(this.spherical.phi+=this.sphericalDelta.phi),(1!==this.rotationLimitsMode||!0===this.autoRotate)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),0!==this.panLimitsMode&&(this.target.applyQuaternion(N.copy($).invert()),this.panOffset.applyQuaternion(N),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion($),this.panOffset.applyQuaternion($)),2===this.panLimitsMode&&(this.panOffset.y=0),1===this.panLimitsMode&&(this.panOffset.x=0),-1!==this.state||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),J.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(tt.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(tt));let t=this.spherical.phi%_;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(D.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),t>0&&t>Math.PI||t<0&&t>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),-1===this.state||!0===this.enableDamping){let t=1===this.hoverRotatePanMode?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-t,this.sphericalDelta.phi*=1-t}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(V),this.object.dispatchEvent(et),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=t=>{!1!==this.enabled&&("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerDownTouch(t):this.onPointerDownMouse(t),-1!==this.state&&(this.isPointerDown=!0,this.dispatchEvent(z),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.setPointerCapture(t.pointerId)))},this.onPointerLeave=t=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(1===this.hoverRotatePanMode?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,q.subVectors(this.position0,this.target0),this.spherical.setFromVector3(q),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):2===this.hoverRotatePanMode&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=t},this.onPointerEnter=t=>{this.resetHoverEffectOnPointerLeave||void 0===this.pointerLeaveEvent?Q.set(t.clientX-this.domElement.clientWidth/2,t.clientY-this.domElement.clientHeight/2):Q.set(t.clientX-this.pointerLeaveEvent.clientX,t.clientY-this.pointerLeaveEvent.clientY),1===this.hoverRotatePanMode?(this.rotateDelta.copy(Q).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(K,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(t.clientX,t.clientY)):2===this.hoverRotatePanMode&&(this.panDelta.copy(Q).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(t.clientX,t.clientY)),this.update()},this.onPointerMove=t=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(X):!1!==this.enabled&&(this.checkRaycastLock()||("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t),t.stopPropagation()))},this.onPointerUp=t=>{this.isPointerDown=!1,0===e.length&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),e.length>1&&t.preventDefault(),this.hasChange?this.dispatchEvent(0===this.state?Z:H):this.dispatchEvent(Y),this.state=-1,t&&(t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.releasePointerCapture(t.pointerId))},this.onPointerDownMouse=t=>{let e;switch(e=this.useKeyEvents?this.mouseButtons[t.button]:this.mouseButtonsPlay[t.button],e){case 0:if(!0!==t.altKey||t.shiftKey||F(t)){if(" "===this.key){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 4:if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(F(t)||t.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(F(t)||t.shiftKey){if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(t)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=t=>{switch(e.length>1&&t.preventDefault(),this.touches[e.length-1]){case R.ROTATE:if(!1===this.enableRotate)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case R.PAN:if(!1===this.enablePan)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case R.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchStartDollyPan(),this.state=5;break;case R.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=t=>{switch(e.length>1&&t.preventDefault(),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this.handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=g(()=>{this.zoomChanged?this.dispatchEvent(U):this.dispatchEvent(H),this.zoomChanged=!1},33),this.onMouseWheel=t=>{if(!1!==this.enabled&&(!1!==this.enableZoom||!1!==this.enablePan)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(z),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(X);this.handleMouseWheel(t),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=t=>{if(t.preventDefault(),!1!==this.enabled&&!this.checkRaycastLock()&&!o){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(X);if("gesturechange"===t.type){if(!1===this.enableZoom||!1===this.isTouchZoom)return;this.dispatchEvent(z),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(H)}},this.onContextMenu=t=>{t.preventDefault()},this.onTouchEnd=t=>{t.preventDefault()},this.onKeyDown=t=>{!1!==this.enabled&&(this.key=t.key," "===t.key&&this.dispatchEvent(z))},this.onKeyUp=t=>{this.key=void 0,!1!==this.enabled&&(-1!==this.state&&"Alt"===t.key&&this.onPointerUp(e[0])," "===t.key&&this.dispatchEvent(H))},this.onPointerHover=t=>{"mouse"!==t.pointerType||!1===this.enabled||-1!==this.state||2===this.hoverRotatePanMode&&this.isPanOverShoot||1===this.hoverRotatePanMode&&this.isRotateOverShoot||(this.isPointerDown=!0,2===this.hoverRotatePanMode?this.handleMouseMovePan(t,this.hoverRotatePanStrength):1===this.hoverRotatePanMode&&this.handleMouseMoveRotate(t,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=t=>{t.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(t){"start"===t.type?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(t)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(t){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=t,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(t,e){this.rotateFactor=t.rotationSpeed??1,this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.thetaIsFree=t.rotationHorizontalOffset.min===t.rotationHorizontalOffset.max&&t.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=t.rotationVerticalOffset.min===t.rotationVerticalOffset.max&&t.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.hoverRotateDamping=t.hoverRotateDamping??this.dampingFactor,this.useWindowEvents="window"===e,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=t.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,this.autoRotateSpeed=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let s=this.object.getTarget().applyQuaternion(N.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+s.y,this.maxV=t.panVerticalOffset.max+s.y,this.minH=-t.panHorizontalOffset.min+s.x,this.maxH=t.panHorizontalOffset.max+s.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=st(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=st(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=st(st(this.spherical.theta)-t.rotationHorizontalOffset.min),this.maxTheta=st(st(this.spherical.theta)+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,1===t.orbitTouches&&(this.touches[0]=R.ROTATE),1===t.panTouches&&(this.touches[0]=R.PAN),2===t.orbitTouches&&(this.touches[1]=R.DOLLY_ROTATE),2===t.panTouches&&(this.touches[1]=R.DOLLY_PAN),3===t.orbitTouches&&(this.touches[2]=R.ROTATE),3===t.panTouches&&(this.touches[2]=R.PAN),this.isTouchZoom=t.isTouchZoom,this.resetHoverEffectOnPointerLeave=t.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,e,i,s,o,a,n,r){let h,l,d;this.overShoot.set(0,0),t instanceof M?(h=t.x,l=t.y,this.current.set(this.target.x,this.target.y),d=!0):(h=t.theta,l=t.phi,this.current.set(st(this.spherical.theta),st(this.spherical.phi)),d=!1),0===i&&(this.current.x+=h,this.current.y+=l),(3===e||2===e)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x)),(3===e||1===e)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<n&&(this.overShoot.y=n-this.current.y)),d||(this.overShoot.x=st(this.overShoot.x),this.overShoot.y=st(this.overShoot.y)),0!==i?(this.overRatio.copy(this.overShoot).divide(r),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),1===i&&(this.overRatio.x=ot(Math.abs(this.overRatio.x)),this.overRatio.y=ot(Math.abs(this.overRatio.y))),this.isPointerDown||1===i?2===i&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(h*this.overShoot.x<0&&!this.thetaIsFree&&(h*=1-this.overRatio.x),l*this.overShoot.y<0&&!this.phiIsFree&&(l*=1-this.overRatio.y)):2===i&&(!d&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(h=.05*this.overShoot.x),this.phiIsFree||(l=.05*this.overShoot.y),d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,l+=this.overShoot.y),t instanceof M?(t.x=h,t.y=l):(this.thetaIsFree||(t.theta=h),this.phiIsFree||(t.phi=l))}setEnableDampingSpeed(t){this.enableDamping=t,this.rotateSpeed=(!0===t?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(t,e,i){this.stopDamping(),this.target.set(t,e,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,e){this.panLeftV.setFromMatrixColumn(e,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,e){this.panUpV.setFromMatrixColumn(e,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,e){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrixWorld),this.panUp(2*e*o/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(V)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}setZoom(t){if(this.dispatchEvent(z),this.object.isPerspectiveCamera){let e=this.initialSphericalRadius/t/this.spherical.radius;this.scale=e}else this.object.isOrthographicCamera&&(this.object.zoom=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(H)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,e=1){void 0!==t.movementX?this.rotateDelta.set(t.movementX,t.movementY):(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*e).rotateAround(K,-this.object.angleOffsetFromUp);let i=this.domElement,s=this.useWindowEvents?window.innerHeight:i.clientHeight,o=2*Math.PI*this.rotateDelta.x/s,a=2*Math.PI*this.rotateDelta.y/s;this.rotateLeft(o),this.rotateUp(a),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,e=1){void 0!==t.movementX?this.panDelta.set(t.movementX,t.movementY):(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*e),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(0===t.deltaX&&0===t.deltaY)return;let e=!0===t.ctrlKey||!0===F(t),i=!1===F(t)&&!0===(0===(r=t).wheelDeltaY||0===r.deltaY?!(s&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120)&&(r.wheelDeltaX?k(r.wheelDeltaX,r.deltaX):0===r.deltaMode):r.wheelDeltaY?k(r.wheelDeltaY,r.deltaY):0===r.deltaMode),o=!1===e&&(!0===this.gesture||t.timeStamp-this.lastTrackpadPanTime<300),n=!1===e&&!1===o&&t.timeStamp-this.lastMouseWheelZoomTime<300;var r;if(!1!==a||!1!==n||!0!==i&&!0!==o){if(!1===this.enableZoom)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)),!1===e&&!1===i&&(this.lastMouseWheelZoomTime=t.timeStamp),0===t.deltaY?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(!1===this.enablePan)return;let e=!1===this.gesture&&!1===o;this.lastTrackpadPanTime=t.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),!1===e&&(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)},100)}}handleTouchStartRotate(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.rotateStart.set(t,i)}else this.rotateStart.set(e[0].pageX,e[0].pageY)}handleTouchStartPan(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.panStart.set(t,i)}else this.panStart.set(e[0].pageX,e[0].pageY)}handleTouchStartDolly(){let t=e[0].pageX-e[1].pageX,i=e[0].pageY-e[1].pageY,s=Math.sqrt(t*t+i*i);this.dollyStart.set(0,s)}handleTouchStartDollyPan(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let s=this.domElement;s&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/s.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/s.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.panEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let e=i(t),s=t.pageX-e.x,o=t.pageY-e.y,a=Math.sqrt(s*s+o*o);this.dollyEnd.set(0,a),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=this.options?.showCameraLock;return t&&t(),!0}}return!1}};function st(t){let e=2*Math.PI;for(;t<=-Math.PI;)t+=e;for(;t>Math.PI;)t-=e;return t}function ot(t){return 1-Math.pow(1-t,4)}var at,nt,rt=new Promise(t=>{at=t});function ht(t){return nt||(nt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.4/build",i=import("./physics.js"),[s,o]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(t=>t.arrayBuffer())]);await s.init(o),at(s)}())}function lt(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,s=e[4]**2+e[5]**2+e[6]**2,o=e[8]**2+e[9]**2+e[10]**2,a=e[0]**2+e[4]**2+e[8]**2,n=e[1]**2+e[5]**2+e[9]**2,r=e[2]**2+e[6]**2+e[10]**2,h=1e-8;return i<h||s<h||o<h||a<h||n<h||r<h}function dt(t,e){let i=new G;if(e&<(e))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;let{positions:s,triIndices:o}=h(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new j(s,3)),i.setIndex(o),e&&i.applyMatrix4(e),i}var ct,pt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=d(e,e.actions,s,o,a,i),this.target=e.target}disconnect(){c(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},mt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.page=s,this.currentIntersectedObjects=[],this.actions=d(e,e.actions,s,o,a,i),this.target=e.target,this.triggeringObjects=[];for(let t of e.triggeringObjects){let e=s.scene.find(t);e&&this.triggeringObjects.push(e)}}isValidTriggeringObject(t){return"all"===this.target||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){c(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.SwitchCamera.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),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()))}};rt.then(t=>ct=t);var ut=new M,yt=new C,vt=new M,gt=(new S(0,0,0,"YXZ"),new S(0,0,0,"XYZ")),ft=new M,bt=new M,Et=new M(1,1,1),Pt=new C,Ct=new x,Mt=new x,xt={type:"updateMatrix"},Tt=new C,St=new L,Dt=.01,wt={type:"beginEvent",eventName:"Collision"},Rt={type:"beginEvent",eventName:"Trigger"};function jt(t){if(b.physicsEnabled(t.scene.objects))return!0;let e=!1;return t.scene.objects.traverse((t,i)=>{if(i.events)if(Array.isArray(i.events)){for(let t of i.events)if(!0!==t.data.disabled&&"GameControl"===t.data.type&&t.data.collisionEnabled){e=!0;break}}else for(let t of Object.values(i.events))if(!0!==t.disabled&&"GameControl"===t.type&&t.collisionEnabled){e=!0;break}}),e}var Lt=t=>t.states.some(t=>void 0!==t.data.position||void 0!==t.data.rotation||void 0!==t.data.hiddenMatrix||void 0!==t.data.cloner||void 0!==t.data.pathSnapping);function Gt(t){return u(v(t)?t.object:t)}var Bt,At,Wt,Ot=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=t=>{if(t.bodyType()!==ct.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,i,s]=this.rigidBodyToMesh.get(t.handle);if(ut.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),yt.copy(t.rotation()),e.matrixWorld.compose(ut,yt,i),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(xt),s){let t=e.cloner;if(t&&void 0===t.objectForSample){t.matrixWorld.copy(e.matrixWorld);for(let e of t.children)e.updateMatrixWorld(!0)}for(let t of e.children)t.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,e,i)=>{if(!1===i)return;let s,o;if(this.sensorToTriggerEvent[t]?(s=this.sensorToTriggerEvent[t],o=this.sharedGameControlGlobals.colliderToEntity.get(e)):this.sensorToTriggerEvent[e]&&(s=this.sensorToTriggerEvent[e],o=this.sharedGameControlGlobals.colliderToEntity.get(t)),s&&o&&s.isValidTriggeringObject(o))s.dispatch();else{for(let i=this.sharedGameControlGlobals.createdObjects.length-1;i>=0;i--){let s=this.sharedGameControlGlobals.createdObjects[i];if(s.userData.hasCollisionDestroy&&(s.rigidBody?.collider(0).handle===t||s.rigidBody?.collider(0).handle===e)){this.sharedGameControlGlobals.createdObjects.splice(i,1),s.removeFromParent(),requestAnimationFrame(()=>this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(s.rigidBody));break}}if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let t=this.sharedGameControlGlobals.colliderToEntity.get(e),i=this.sharedGameControlGlobals.entityToCollisionEvents[t.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,t,e)}else if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let e=this.sharedGameControlGlobals.colliderToEntity.get(t),i=this.sharedGameControlGlobals.entityToCollisionEvents[e.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,e,t)}else{let i=this.sharedGameControlGlobals.colliderToEntity.get(t),s=this.sharedGameControlGlobals.entityToCollisionEvents[i.uuid];if(void 0!==s)for(let e of s)"scene"===e.data.target&&this.dispatchCollisionEvent(e,i,t);let o=this.sharedGameControlGlobals.colliderToEntity.get(e),a=this.sharedGameControlGlobals.entityToCollisionEvents[o?.uuid];if(void 0!==a)for(let t of a)"scene"===t.data.target&&this.dispatchCollisionEvent(t,o,e)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events){if(!0===t.data.disabled)continue;let e=t.data.actions?.find(t=>"Destroy"===t.data.type)?.data;if(e)for(let t of e.objects){let e=this.page.scene.find(t);e&&(e.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events)if(!0!==t.data.disabled&&"DragDrop"===t.data.type)for(let e of t.data.objects){let t=this.page.scene.find(e);t&&(t.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return void 0===e&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(null===t())return void f("collision-bvh","trigger/collision detection");let e=[],i=[];if(this.page.traverseChildren(t=>{let s,o=t instanceof r,a=m(t);if(y(t)||o||a)return;s=v(t)?t.object:t;let n=s.dataPatched;if("visibility"===n.physics?.enabled?!n.visible:!n.physics?.enabled)return!0;let h=t.geometry,l=!0===s.userData.hasDestroy,d=!0===s.userData.hasDrag;if(Lt(n)||l||d||s.dataPatched.events.some(t=>!0!==t.data.disabled&&("GameControl"===t.data.type||"Follow"===t.data.type)))return t.updateMatrixWorldRigid(),this.addBoundsTree(t),!0;if(h){let s=h.getAttribute("position");if(void 0!==s&&s.count>0){e.push({geometry:h,matrixWorld:t.matrixWorld}),i.push(h.id,this._staticBVHIdOf(s),s.version,null!==h.index?this._staticBVHIdOf(h.index):-1,null!==h.index?h.index.version:-1);for(let e of t.matrixWorld.elements)i.push(e)}}return!!Gt(t)||void 0}),e.length>0){let s=this._staticBVHCache;if(void 0!==s&&s.signature.length===i.length&&s.signature.every((t,e)=>t===i[e]))return void(this.sharedGameControlGlobals.staticMeshBVH=s.bvh);let o=e.map(t=>dt(t.geometry,t.matrixWorld)),a=l(o,!1),n=new(t())(a);this._staticBVHCache={signature:i,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(t,e,i){if(lt(t.matrixWorld))return;let s=[],o="geometry"in t?t.geometry:void 0,a=e.dataPatched;if(void 0!==o?.getAttribute("position")&&s.push(dt(o,t.shearScale)),a.physics.fusedBody){let e=this.gatherChildrenGeom(t,s);t.traverseObject(e),t.children.forEach(t=>t.updateMatrixWorld(!0));let i=t.cloner;i&&void 0===i.objectForSample&&"dynamic"===a.physics.rigidBody&&(i.traverseObject(e),i.children.forEach(t=>t.updateMatrixWorld(!0)))}if(s.length>0){let n,r=!1,h=!i.fromCreate&&"dynamic"===a.physics.rigidBody||i.fromCreate&&i.dynamic;h?(n=ct.RigidBodyDesc.dynamic(),n.setLinearDamping(a.physics.damping).setAngularDamping(a.physics.damping).setAdditionalMass(1e-9).setGravityScale(a.physics.gravityScale).enabledRotations(...a.physics.enabledRotation).enabledTranslations(...a.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(n=ct.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),r=!0):n=ct.RigidBodyDesc.fixed();let d=l(s);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt),t.position0=ut.clone().divideScalar(this.pixelsPerMeter),t.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),n.setTranslation(ut.x,ut.y,ut.z).setRotation(yt),o?d?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):d?.scale(vt.x/this.pixelsPerMeter,vt.y/this.pixelsPerMeter,vt.z/this.pixelsPerMeter);let c=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);h?this.rigidBodyToMesh.set(c.handle,[t,vt.clone(),a.physics.fusedBody]):r?this.sharedGameControlGlobals.kinematicBodyToEntity.set(c.handle,t):this.fixedBodiesToWatch.push([t,c,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]);let p=!(void 0===a.geometry||"SubdivGeometry"===a.geometry.type||"NonParametricGeometry"===a.geometry.type||"BooleanGeometry"===a.geometry.type||"VectorGeometry"===a.geometry.type||"StarGeometry"===a.geometry.type||"RectangleGeometry"===a.geometry.type||"EllipseGeometry"===a.geometry.type||"TriangleGeometry"===a.geometry.type||"TorusGeometry"===a.geometry.type||"HelixGeometry"===a.geometry.type);try{this.addCollider(c,a.physics,d,e,p)}catch{try{this.addCollider(c,a.physics,d,e,!1)}catch(t){console.error(t)}}t.rigidBody=c}}addBoundsTree(e){let i=[];if(void 0!==e.geometry?.getAttribute("position")&&e.geometry?.getAttribute("position").count>0&&i.push(dt(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,i)),e.children.forEach(t=>t.updateMatrixWorld(!0)),i.length>0){let s=l(i,!1);e.bvhGeometry=s,s.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(t())(s),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(t,e,i,s,o=!0){if(0===i?.getAttribute("position").count||0===i?.getIndex()?.count)return;let a;i&&(a="trimesh"===e.colliderType?ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ct.ColliderDesc.convexMesh(i.getAttribute("position").array,o?i.getIndex().array:void 0)),a.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setRestitutionCombineRule(ct.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let n=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t);this.sharedGameControlGlobals.colliderToEntity.set(n.handle,s),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]?.some(t=>"scene"===t.target)&&n.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Gt(t);return(s,o)=>{if(0===o)return;if(i&&s.parent===t)return!0;let a;if(y(s)){if(!s.objectForSample)return!0===s.object.dataPatched.physics.fusedBody&&"dynamic"===s.object.dataPatched.physics.rigidBody||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;a=s.object}else if(v(s))a=s.object;else if(a=s,a.dataPatched.cloner?.hideBase)return!0;let n=a.dataPatched;if("visibility"===n.physics.enabled?!n.visible:!n.physics.enabled)return!0;1===o?t.hasNonUniformScale?s.matrixWorld.multiplyMatrices(t.shearScale,s.hiddenMatrix):s.matrixWorld.copy(s.hiddenMatrix):s.matrixWorld.multiplyMatrices(s.parent.matrixWorld,s.hiddenMatrix),s.matrixWorld.multiply(s.matrix);let r=s.geometry;return void 0!==r?.getAttribute("position")&&e.push(dt(r,s.matrixWorld)),!!Gt(s)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(!1===e.data.disabled&&"Trigger"===e.data.type)return this.needsCollisionDetection=!0,!0});let s=O();if(null!==s?i=s.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:null!==this.page.data.publish.gameControlObject&&f("game-controls","the scene's game controls"),!1===i){let{enableRotate:t,enablePan:i,enableZoom:s,autoRotate:o,hoverRotatePanMode:a}=this.eventManager.publish.orbitControls;(t||i||s||o||0!==a)&&(this.orbitControls=new it(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let o=this.renderer.domElement.width/this.renderer.getPixelRatio(),a=this.renderer.domElement.height/this.renderer.getPixelRatio();O()?.createJoysticks(this,o,a),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(t=>t.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ct.World(new ct.Vector3(0,this.gravity,0)),this.events=new ct.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(i=>{let s;if(y(i)){if(!i.objectForSample)return!0===i.object.dataPatched.physics.fusedBody&&"dynamic"===i.object.dataPatched.physics.rigidBody||void 0;if(i.objectForSample.dataPatched.physics.fusedBody)return;s=i.object}else if(v(i))s=i.object;else{if(m(i)||i instanceof r)return;if(s=i,!1===s.dataPatched.cloner?.disabled&&s.dataPatched.cloner?.hideBase&&!0!==s.dataPatched.physics?.fusedBody)return!0}let o,a=s.dataPatched;for(let t of a.events)!0!==t.data.disabled&&"GameControl"===t.data.type&&(o=t.data);if(!a.physics||("visibility"===a.physics.enabled?!a.visible:!a.physics.enabled))return!0;i.updateMatrixWorldRigid();let n=Lt(a),h=!1,l=s.userData.hasDestroy,d=s.userData.hasDrag,c=!1;for(let t of a.events)if(!0!==t.data.disabled)if("Collision"===t.data.type){h=!0;let e=new pt(t.id,t.data,s,this.page,this.sharedAssets,this.eventManager);e.initialDisabled=!0,this.collisionEvents.push(e),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].every(e=>e.id!==t.id)?this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].push(e):this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]=[e]}else if("Follow"===t.data.type){c=!0;let e=t.data.target;i.traverseVisible(t=>{t.userData.isFollowingObj=e})}"dynamic"===a.physics.rigidBody&&!1===a.physics.fusedBody&&(i.matrixWorldFusedFalse=i.matrixWorld.clone());let p=i.geometry;if(void 0!==o){let t=ct.RigidBodyDesc.kinematicPositionBased();(i.hasNonUniformScale?i.matrixWorldRigid:i.matrixWorld).decompose(ut,yt,vt),i.position0=ut.clone().divideScalar(this.pixelsPerMeter),i.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),t.setTranslation(ut.x,ut.y,ut.z).setRotation(yt);let e,n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(t);i.rigidBody=n,e="sphere"===o.collider.type?ct.ColliderDesc.ball(o.collider.radius/this.pixelsPerMeter):"capsule"===o.collider.type?ct.ColliderDesc.capsule((o.collider.height/2-o.collider.radius)/this.pixelsPerMeter,o.collider.radius/this.pixelsPerMeter):ct.ColliderDesc.cuboid(o.collider.width/this.pixelsPerMeter/2,o.collider.height/this.pixelsPerMeter/2,o.collider.depth/this.pixelsPerMeter/2),e.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setDensity(a.physics.density).setFriction(a.physics.friction).setRestitution(0).setRestitutionCombineRule(ct.CoefficientCombineRule.Min);let r=this.sharedGameControlGlobals.rapierWorld.createCollider(e,n);this.sharedGameControlGlobals.colliderToEntity.set(r.handle,s),ut.fromArray(o.collider.position.map(t=>"number"==typeof t?t:0)).multiply(vt.setFromMatrixScale(s.matrixWorld)).divideScalar(this.pixelsPerMeter),r.setTranslationWrtParent(ut);let h=(new C).setFromEuler((new S).setFromVector3((new M).fromArray(o.collider.rotation.map(t=>"number"==typeof t?t:0))));r.setRotationWrtParent(h),r.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(s,!0)}else"dynamic"===a.physics.rigidBody||n||c||l||d||h?(this.addRigidBody(i,s,{hasFollow:c,hasTransformAnim:n,hasDrag:d}),this.generateSensorColliderDescs(s,a.physics.fusedBody)):(p&&t.push(dt(p,i.matrixWorld)),a.physics.fusedBody&&!Gt(i)&&i.traverseObject((e,i)=>{if(0===i)return;let s;if(y(e)){if(!e.objectForSample)return!0===e.object.dataPatched.physics.fusedBody&&"dynamic"===e.object.dataPatched.physics.rigidBody||void 0;if(e.objectForSample.dataPatched.physics.fusedBody)return;s=e.object}else{if(m(e)||e instanceof r)return;if(v(e))s=e.object;else if(s=e,s.dataPatched.cloner?.hideBase)return!0}let o=s.dataPatched;if("visibility"===o.physics.enabled?!o.visible:!o.physics.enabled)return!0;let a=e.geometry;return void 0!==a?.getAttribute("position")&&t.push(dt(a,e.matrixWorld)),!!Gt(e)||void 0}),this.generateSensorColliderDescs(s,a.physics.fusedBody,e));return!(!0!==a.physics?.fusedBody&&!o&&!Gt(i))||void 0}),0===t.length)return;let i=l(t);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ct.RigidBodyDesc.fixed(),o=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s),a=ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ct.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ct.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);for(let[t,i]of e){let e=this.sharedGameControlGlobals.rapierWorld.createCollider(t,o);this.sensorToTriggerEvent[e.handle]=i}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let i=new mt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),s=(new x).compose(ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Et);if("box"===e.data.triggerZone){let o=new w;o.min.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(-.5),o.max.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([o,s,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,s,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(void 0!==this.orbitControls&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):2===this.initializationCounter&&this.gameControl&&(e=!this.gameControl.update(t)&&e),!1===this.usePhysics&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(0===t)e=this.stepPhysics()&&e;else{let s=t/1e3;s<i&&s>.55*i&&(s=i),this.accumulator+=s;let o=performance.now(),a=0,n=6;for(;this.accumulator>=i&&a<n&&(e=this.stepPhysics()&&e,this.accumulator-=i,a++,!(performance.now()-o>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt);let e=t;void 0===e.prevQ?(e.prevQ=yt.clone(),e.prevT=ut.clone()):(e.prevQ.copy(yt),e.prevT.copy(ut))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,s]=this.fixedBodiesToWatch[t];(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(s)||(i.setBodyType(ct.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1))}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(void 0===t)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),s=t.translation(),o=Math.hypot(i.x,i.z);for(let a=0;a<t.numColliders();a++){let n=t.collider(a);e.contactPairsWith(n,t=>{let a=t.parent();if(null===a||!a.isDynamic())return;let r=a.translation(),h=-1/0,l=0,d=0;if(e.contactPair(n,t,t=>{let e=t.normal(),o=e.x*(r.x-s.x)+e.y*(r.y-s.y)+e.z*(r.z-s.z)<0?-1:1;if(Math.abs(e.y)>.7)return;let a=o*e.x,n=o*e.z,c=Math.hypot(a,n);if(c<1e-4)return;let p=(i.x*a+i.z*n)/c;p>h&&(h=p,l=a/c,d=n/c)}),h===-1/0)return;let c=i.x*l+i.z*d;if(c<-Dt)return;let p=a.linvel();if(o>Dt&&c>Dt){let t=p.x*l+p.z*d;if(t<=0)return;let e=Math.min(t,c);return void a.setLinvel({x:l*e,y:p.y,z:d*e},!0)}let m=p.x*l+p.z*d-Math.max(0,c);if(m<=0)return;let u=.5*m;a.setLinvel({x:p.x-l*u,y:p.y,z:p.z-d*u},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let t of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(t),t.rigidBody.setNextKinematicTranslation(ut.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(yt);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)!0!==t.rigidBody?.isKinematic()&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let s,o=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner)for(let t of e.cloner.children)if(t.rigidBody===o){s=t;break}t.dispatch(s),e.dispatchEvent(wt)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let s=Mt.copy(t.matrixWorld).invert();t.traverseEntity((o,a)=>{if(!1===e&&1===a)return!0;for(let e of o.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let a,n=new mt(e.id,e.data,o,this.page,this.sharedAssets,this.eventManager);if(a="box"===e.data.triggerZone?ct.ColliderDesc.cuboid(...e.data.size.map(t=>("number"==typeof t?t:1)/(2*this.pixelsPerMeter))):ct.ColliderDesc.ball(e.data.radius/this.pixelsPerMeter),a.setDensity(0).setSensor(!0).setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Ct.compose(ft,Pt,Et).premultiply(o.matrixWorld),i?(Ct.decompose(ft,Pt,bt),a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED)):(Ct.premultiply(s).decompose(ft,Pt,bt),t.rigidBody.bodyType()===ct.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ct.RigidBodyType.Fixed?a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED):a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ct.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),ft.divideScalar(this.pixelsPerMeter),a.setTranslation(ft.x,ft.y,ft.z),a.setRotation(Pt),i)i.push([a,n]);else{let e=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t.rigidBody);this.sensorToTriggerEvent[e.handle]=n}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,s,o,a]=this.sharedGameControlGlobals.triggers[e];for(let e=0;e<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;e++){let n=this.sharedGameControlGlobals.entitiesWithTransformAnim[e];if(o===n||!1===a.isValidTriggeringObject(p.is(n)?n:n.object))continue;let r=Mt.copy(o.matrixWorld).decompose(ft,Tt,bt).compose(ft,Tt,Et).multiply(s),h=Ct.copy(n.matrixWorld).invert().multiply(r),l=n.bvhGeometry.boundsTree;i instanceof w?t=l.intersectsBox(i,h):(St.radius=i,St.center.setFromMatrixPosition(h),t=l.intersectsSphere(St)),t?-1===a.currentIntersectedObjects.indexOf(n)&&(a.currentIntersectedObjects.push(n),a.dispatch(),o.dispatchEvent(Rt)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(t=>t!==n)}}}},It=new Promise(t=>{Bt=t});function Ft(t){return Wt||(Wt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.4/build";typeof window<"u"&&(At=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(t=>t.arrayBuffer())]),a=s.default,n=await a({wasmBinary:o});Bt(n)}())}export{it as a,ht as b,B as c,W as d,I as e,dt as f,wt as g,jt as h,Lt as i,Ot as j,It as k,At as l,Ft as m};
|
|
1
|
+
import{b as t}from"./runtime-chunk-N2ZRGNPR.js";import{a as e,c as i}from"./runtime-chunk-VAVYZ35B.js";import{b as s,c as o,d as a,e as n}from"./runtime-chunk-FQNSP44B.js";import{a as r}from"./runtime-chunk-JQ3A6ENO.js";import{G as h,a as l}from"./runtime-chunk-SXPM42HJ.js";import{f as d,g as c}from"./runtime-chunk-NWCLOXDY.js";import{h as p}from"./runtime-chunk-4KX4KQWR.js";import{a as m,g as u,h as y,i as v}from"./runtime-chunk-2PT2WH66.js";import{a as g}from"./runtime-chunk-4KZXQGUQ.js";import{c as f}from"./runtime-chunk-TZCHGFVF.js";import{Fa as b}from"./runtime-chunk-RBM3UDQF.js";import{Bc as E,Dc as P,Ec as C,Fc as M,Oc as x,Oe as T,Pc as S,Rc as D,Xc as w,b as R,bd as j,cd as G,dd as L}from"./runtime-chunk-VGN7YHB7.js";var B=200,A=null;function W(t){A=t}function O(){return A}function I(t){let e=!1;return t.scene.objects.forEach(i=>{"Page"===i.data.type&&!e&&i.data.publish.gameControlObject&&b.traverseModuleInstances(t,i.id,(t,i,s)=>{for(let t of s)"GameControl"===t.data.type&&t.data.navmesh.enabled&&(e=!0)})}),e}function F(t){return s?t.metaKey:t.ctrlKey}function k(t,e){return Math.abs(t+3*e)<=2||Math.abs(t+3*window.devicePixelRatio*e)<=2}var V={type:"change"},z={type:"start"},H={type:"end",nonOrbit:!0},Z={type:"end",nonOrbit:!1},U={type:"end",isZoom:!0,nonOrbit:!0},Y={type:"end",changed:!1},X={type:"cameraAnimatingInTimeline"},N=new C,K=new P,_=2*Math.PI,Q=new M,q=new P,J=new M,$=new C,tt=new x,et={type:"requestRender"},it=class extends E{constructor(t,i,s={isPlayMode:!1,isExport:!1},a){super(),this.object=t,this.domElement=i,this.options=s,this.timelineState=a,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,R.DOLLY_ROTATE,R.PAN],this.offset=new M,this.eye=new M,this.lastPosition=new M,this.lastQuaternion=new C,this.current=new P,this.overShoot=new P,this.overRatio=new P,this.spherical=new T,this.sphericalDelta=new T,this.panOffset=new M,this.panLeftV=new M,this.panUpV=new M,this.panV=new M,this.rotateStart=new P,this.rotateEnd=new P,this.rotateDelta=new P,this.panStart=new P,this.panEnd=new P,this.panDelta=new P,this.dollyStart=new P,this.dollyEnd=new P,this.dollyDelta=new P,this.rotationRangeFactor=new P,this.panRangeFactor=new P,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=t=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=t.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,Q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&-1===this.state&&this.rotateLeft((!0===this.autoRotateClockwise?1:-1)*this.getAutoRotationAngle()),0!==this.rotationLimitsMode&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),2!==this.rotationLimitsMode&&(this.spherical.phi+=this.sphericalDelta.phi),(1!==this.rotationLimitsMode||!0===this.autoRotate)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),0!==this.panLimitsMode&&(this.target.applyQuaternion(N.copy($).invert()),this.panOffset.applyQuaternion(N),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion($),this.panOffset.applyQuaternion($)),2===this.panLimitsMode&&(this.panOffset.y=0),1===this.panLimitsMode&&(this.panOffset.x=0),-1!==this.state||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),J.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(tt.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(tt));let t=this.spherical.phi%_;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(D.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),t>0&&t>Math.PI||t<0&&t>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),-1===this.state||!0===this.enableDamping){let t=1===this.hoverRotatePanMode?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-t,this.sphericalDelta.phi*=1-t}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(V),this.object.dispatchEvent(et),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=t=>{!1!==this.enabled&&("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerDownTouch(t):this.onPointerDownMouse(t),-1!==this.state&&(this.isPointerDown=!0,this.dispatchEvent(z),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.setPointerCapture(t.pointerId)))},this.onPointerLeave=t=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(1===this.hoverRotatePanMode?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,Q.subVectors(this.position0,this.target0),this.spherical.setFromVector3(Q),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):2===this.hoverRotatePanMode&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=t},this.onPointerEnter=t=>{this.resetHoverEffectOnPointerLeave||void 0===this.pointerLeaveEvent?q.set(t.clientX-this.domElement.clientWidth/2,t.clientY-this.domElement.clientHeight/2):q.set(t.clientX-this.pointerLeaveEvent.clientX,t.clientY-this.pointerLeaveEvent.clientY),1===this.hoverRotatePanMode?(this.rotateDelta.copy(q).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(K,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(t.clientX,t.clientY)):2===this.hoverRotatePanMode&&(this.panDelta.copy(q).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(t.clientX,t.clientY)),this.update()},this.onPointerMove=t=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(X):!1!==this.enabled&&(this.checkRaycastLock()||("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t),t.stopPropagation()))},this.onPointerUp=t=>{this.isPointerDown=!1,0===e.length&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),e.length>1&&t.preventDefault(),this.hasChange?this.dispatchEvent(0===this.state?Z:H):this.dispatchEvent(Y),this.state=-1,t&&(t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.releasePointerCapture(t.pointerId))},this.onPointerDownMouse=t=>{let e;switch(e=this.useKeyEvents?this.mouseButtons[t.button]:this.mouseButtonsPlay[t.button],e){case 0:if(!0!==t.altKey||t.shiftKey||F(t)){if(" "===this.key){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 4:if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(F(t)||t.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(F(t)||t.shiftKey){if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(t)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=t=>{switch(e.length>1&&t.preventDefault(),this.touches[e.length-1]){case R.ROTATE:if(!1===this.enableRotate)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case R.PAN:if(!1===this.enablePan)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case R.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchStartDollyPan(),this.state=5;break;case R.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=t=>{switch(e.length>1&&t.preventDefault(),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this.handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=g(()=>{this.zoomChanged?this.dispatchEvent(U):this.dispatchEvent(H),this.zoomChanged=!1},33),this.onMouseWheel=t=>{if(!1!==this.enabled&&(!1!==this.enableZoom||!1!==this.enablePan)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(z),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(X);this.handleMouseWheel(t),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=t=>{if(t.preventDefault(),!1!==this.enabled&&!this.checkRaycastLock()&&!o){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(X);if("gesturechange"===t.type){if(!1===this.enableZoom||!1===this.isTouchZoom)return;this.dispatchEvent(z),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(H)}},this.onContextMenu=t=>{t.preventDefault()},this.onTouchEnd=t=>{t.preventDefault()},this.onKeyDown=t=>{!1!==this.enabled&&(this.key=t.key," "===t.key&&this.dispatchEvent(z))},this.onKeyUp=t=>{this.key=void 0,!1!==this.enabled&&(-1!==this.state&&"Alt"===t.key&&this.onPointerUp(e[0])," "===t.key&&this.dispatchEvent(H))},this.onPointerHover=t=>{"mouse"!==t.pointerType||!1===this.enabled||-1!==this.state||2===this.hoverRotatePanMode&&this.isPanOverShoot||1===this.hoverRotatePanMode&&this.isRotateOverShoot||(this.isPointerDown=!0,2===this.hoverRotatePanMode?this.handleMouseMovePan(t,this.hoverRotatePanStrength):1===this.hoverRotatePanMode&&this.handleMouseMoveRotate(t,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=t=>{t.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,Q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(t){"start"===t.type?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(t)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(t){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=t,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(t,e){this.rotateFactor=t.rotationSpeed??1,this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.thetaIsFree=t.rotationHorizontalOffset.min===t.rotationHorizontalOffset.max&&t.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=t.rotationVerticalOffset.min===t.rotationVerticalOffset.max&&t.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.hoverRotateDamping=t.hoverRotateDamping??this.dampingFactor,this.useWindowEvents="window"===e,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=t.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,this.autoRotateSpeed=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let s=this.object.getTarget().applyQuaternion(N.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+s.y,this.maxV=t.panVerticalOffset.max+s.y,this.minH=-t.panHorizontalOffset.min+s.x,this.maxH=t.panHorizontalOffset.max+s.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=st(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=st(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=st(st(this.spherical.theta)-t.rotationHorizontalOffset.min),this.maxTheta=st(st(this.spherical.theta)+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,1===t.orbitTouches&&(this.touches[0]=R.ROTATE),1===t.panTouches&&(this.touches[0]=R.PAN),2===t.orbitTouches&&(this.touches[1]=R.DOLLY_ROTATE),2===t.panTouches&&(this.touches[1]=R.DOLLY_PAN),3===t.orbitTouches&&(this.touches[2]=R.ROTATE),3===t.panTouches&&(this.touches[2]=R.PAN),this.isTouchZoom=t.isTouchZoom,this.resetHoverEffectOnPointerLeave=t.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,e,i,s,o,a,n,r){let h,l,d;this.overShoot.set(0,0),t instanceof M?(h=t.x,l=t.y,this.current.set(this.target.x,this.target.y),d=!0):(h=t.theta,l=t.phi,this.current.set(st(this.spherical.theta),st(this.spherical.phi)),d=!1),0===i&&(this.current.x+=h,this.current.y+=l),(3===e||2===e)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x)),(3===e||1===e)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<n&&(this.overShoot.y=n-this.current.y)),d||(this.overShoot.x=st(this.overShoot.x),this.overShoot.y=st(this.overShoot.y)),0!==i?(this.overRatio.copy(this.overShoot).divide(r),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),1===i&&(this.overRatio.x=ot(Math.abs(this.overRatio.x)),this.overRatio.y=ot(Math.abs(this.overRatio.y))),this.isPointerDown||1===i?2===i&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(h*this.overShoot.x<0&&!this.thetaIsFree&&(h*=1-this.overRatio.x),l*this.overShoot.y<0&&!this.phiIsFree&&(l*=1-this.overRatio.y)):2===i&&(!d&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(h=.05*this.overShoot.x),this.phiIsFree||(l=.05*this.overShoot.y),d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,l+=this.overShoot.y),t instanceof M?(t.x=h,t.y=l):(this.thetaIsFree||(t.theta=h),this.phiIsFree||(t.phi=l))}setEnableDampingSpeed(t){this.enableDamping=t,this.rotateSpeed=(!0===t?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(t,e,i){this.stopDamping(),this.target.set(t,e,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,e){this.panLeftV.setFromMatrixColumn(e,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,e){this.panUpV.setFromMatrixColumn(e,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,e){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrixWorld),this.panUp(2*e*o/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(V)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}setZoom(t){if(this.dispatchEvent(z),this.object.isPerspectiveCamera){let e=this.initialSphericalRadius/t/this.spherical.radius;this.scale=e}else this.object.isOrthographicCamera&&(this.object.zoom=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(H)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,e=1){void 0!==t.movementX?this.rotateDelta.set(t.movementX,t.movementY):(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*e).rotateAround(K,-this.object.angleOffsetFromUp);let i=this.domElement,s=this.useWindowEvents?window.innerHeight:i.clientHeight,o=2*Math.PI*this.rotateDelta.x/s,a=2*Math.PI*this.rotateDelta.y/s;this.rotateLeft(o),this.rotateUp(a),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,e=1){void 0!==t.movementX?this.panDelta.set(t.movementX,t.movementY):(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*e),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(0===t.deltaX&&0===t.deltaY)return;let e=!0===t.ctrlKey||!0===F(t),i=!1===F(t)&&!0===(0===(r=t).wheelDeltaY||0===r.deltaY?!(s&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120)&&(r.wheelDeltaX?k(r.wheelDeltaX,r.deltaX):0===r.deltaMode):r.wheelDeltaY?k(r.wheelDeltaY,r.deltaY):0===r.deltaMode),o=!1===e&&(!0===this.gesture||t.timeStamp-this.lastTrackpadPanTime<300),n=!1===e&&!1===o&&t.timeStamp-this.lastMouseWheelZoomTime<300;var r;if(!1!==a||!1!==n||!0!==i&&!0!==o){if(!1===this.enableZoom)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)),!1===e&&!1===i&&(this.lastMouseWheelZoomTime=t.timeStamp),0===t.deltaY?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(!1===this.enablePan)return;let e=!1===this.gesture&&!1===o;this.lastTrackpadPanTime=t.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),!1===e&&(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)},100)}}handleTouchStartRotate(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.rotateStart.set(t,i)}else this.rotateStart.set(e[0].pageX,e[0].pageY)}handleTouchStartPan(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.panStart.set(t,i)}else this.panStart.set(e[0].pageX,e[0].pageY)}handleTouchStartDolly(){let t=e[0].pageX-e[1].pageX,i=e[0].pageY-e[1].pageY,s=Math.sqrt(t*t+i*i);this.dollyStart.set(0,s)}handleTouchStartDollyPan(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let s=this.domElement;s&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/s.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/s.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.panEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let e=i(t),s=t.pageX-e.x,o=t.pageY-e.y,a=Math.sqrt(s*s+o*o);this.dollyEnd.set(0,a),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=this.options?.showCameraLock;return t&&t(),!0}}return!1}};function st(t){let e=2*Math.PI;for(;t<=-Math.PI;)t+=e;for(;t>Math.PI;)t-=e;return t}function ot(t){return 1-Math.pow(1-t,4)}var at,nt,rt=new Promise(t=>{at=t});function ht(t){return nt||(nt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.6/build",i=import("./physics.js"),[s,o]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(t=>t.arrayBuffer())]);await s.init(o),at(s)}())}function lt(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,s=e[4]**2+e[5]**2+e[6]**2,o=e[8]**2+e[9]**2+e[10]**2,a=e[0]**2+e[4]**2+e[8]**2,n=e[1]**2+e[5]**2+e[9]**2,r=e[2]**2+e[6]**2+e[10]**2,h=1e-8;return i<h||s<h||o<h||a<h||n<h||r<h}function dt(t,e){let i=new L;if(e&<(e))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;let{positions:s,triIndices:o}=h(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new j(s,3)),i.setIndex(o),e&&i.applyMatrix4(e),i}var ct,pt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=d(e,e.actions,s,o,a,i),this.target=e.target}disconnect(){c(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},mt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.page=s,this.currentIntersectedObjects=[],this.actions=d(e,e.actions,s,o,a,i),this.target=e.target,this.triggeringObjects=[];for(let t of e.triggeringObjects){let e=s.scene.find(t);e&&this.triggeringObjects.push(e)}}isValidTriggeringObject(t){return"all"===this.target||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){c(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.SwitchCamera.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),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()))}};rt.then(t=>ct=t);var ut=new M,yt=new C,vt=new M,gt=(new S(0,0,0,"YXZ"),new S(0,0,0,"XYZ")),ft=new M,bt=new M,Et=new M(1,1,1),Pt=new C,Ct=new x,Mt=new x,xt={type:"updateMatrix"},Tt=new C,St=new G,Dt=.01,wt={type:"beginEvent",eventName:"Collision"},Rt={type:"beginEvent",eventName:"Trigger"};function jt(t){if(b.physicsEnabled(t.scene.objects))return!0;let e=!1;return t.scene.objects.traverse((t,i)=>{if(i.events)if(Array.isArray(i.events)){for(let t of i.events)if(!0!==t.data.disabled&&"GameControl"===t.data.type&&t.data.collisionEnabled){e=!0;break}}else for(let t of Object.values(i.events))if(!0!==t.disabled&&"GameControl"===t.type&&t.collisionEnabled){e=!0;break}}),e}var Gt=t=>t.states.some(t=>void 0!==t.data.position||void 0!==t.data.rotation||void 0!==t.data.hiddenMatrix||void 0!==t.data.cloner||void 0!==t.data.pathSnapping);function Lt(t){return u(v(t)?t.object:t)}var Bt,At,Wt,Ot=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=t=>{if(t.bodyType()!==ct.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,i,s]=this.rigidBodyToMesh.get(t.handle);if(ut.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),yt.copy(t.rotation()),e.matrixWorld.compose(ut,yt,i),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(xt),s){let t=e.cloner;if(t&&void 0===t.objectForSample){t.matrixWorld.copy(e.matrixWorld);for(let e of t.children)e.updateMatrixWorld(!0)}for(let t of e.children)t.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,e,i)=>{if(!1===i)return;let s,o;if(this.sensorToTriggerEvent[t]?(s=this.sensorToTriggerEvent[t],o=this.sharedGameControlGlobals.colliderToEntity.get(e)):this.sensorToTriggerEvent[e]&&(s=this.sensorToTriggerEvent[e],o=this.sharedGameControlGlobals.colliderToEntity.get(t)),s&&o&&s.isValidTriggeringObject(o))s.dispatch();else{for(let i=this.sharedGameControlGlobals.createdObjects.length-1;i>=0;i--){let s=this.sharedGameControlGlobals.createdObjects[i];if(s.userData.hasCollisionDestroy&&(s.rigidBody?.collider(0).handle===t||s.rigidBody?.collider(0).handle===e)){this.sharedGameControlGlobals.createdObjects.splice(i,1),s.removeFromParent();let t=s.rigidBody;requestAnimationFrame(()=>{s.rigidBody===t&&(this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(t),s.rigidBody=void 0)});break}}if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let t=this.sharedGameControlGlobals.colliderToEntity.get(e),i=this.sharedGameControlGlobals.entityToCollisionEvents[t.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,t,e)}else if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let e=this.sharedGameControlGlobals.colliderToEntity.get(t),i=this.sharedGameControlGlobals.entityToCollisionEvents[e.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,e,t)}else{let i=this.sharedGameControlGlobals.colliderToEntity.get(t),s=this.sharedGameControlGlobals.entityToCollisionEvents[i.uuid];if(void 0!==s)for(let e of s)"scene"===e.data.target&&this.dispatchCollisionEvent(e,i,t);let o=this.sharedGameControlGlobals.colliderToEntity.get(e),a=this.sharedGameControlGlobals.entityToCollisionEvents[o?.uuid];if(void 0!==a)for(let t of a)"scene"===t.data.target&&this.dispatchCollisionEvent(t,o,e)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events){if(!0===t.data.disabled)continue;let e=t.data.actions?.find(t=>"Destroy"===t.data.type)?.data;if(e)for(let t of e.objects){let e=this.page.scene.find(t);e&&(e.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events)if(!0!==t.data.disabled&&"DragDrop"===t.data.type)for(let e of t.data.objects){let t=this.page.scene.find(e);t&&(t.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return void 0===e&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(null===t())return void f("collision-bvh","trigger/collision detection");let e=[],i=[];if(this.page.traverseChildren(t=>{let s,o=t instanceof r,a=m(t);if(y(t)||o||a)return;s=v(t)?t.object:t;let n=s.dataPatched;if("visibility"===n.physics?.enabled?!n.visible:!n.physics?.enabled)return!0;let h=t.geometry,l=!0===s.userData.hasDestroy,d=!0===s.userData.hasDrag;if(Gt(n)||l||d||s.dataPatched.events.some(t=>!0!==t.data.disabled&&("GameControl"===t.data.type||"Follow"===t.data.type)))return t.updateMatrixWorldRigid(),this.addBoundsTree(t),!0;if(h){let s=h.getAttribute("position");if(void 0!==s&&s.count>0){e.push({geometry:h,matrixWorld:t.matrixWorld}),i.push(h.id,this._staticBVHIdOf(s),s.version,null!==h.index?this._staticBVHIdOf(h.index):-1,null!==h.index?h.index.version:-1);for(let e of t.matrixWorld.elements)i.push(e)}}return!!Lt(t)||void 0}),e.length>0){let s=this._staticBVHCache;if(void 0!==s&&s.signature.length===i.length&&s.signature.every((t,e)=>t===i[e]))return void(this.sharedGameControlGlobals.staticMeshBVH=s.bvh);let o=e.map(t=>dt(t.geometry,t.matrixWorld)),a=l(o,!1),n=new(t())(a);this._staticBVHCache={signature:i,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(t,e,i){if(lt(t.matrixWorld))return;let s=[],o="geometry"in t?t.geometry:void 0,a=e.dataPatched;if(void 0!==o?.getAttribute("position")&&s.push(dt(o,t.shearScale)),a.physics.fusedBody){let e=this.gatherChildrenGeom(t,s);t.traverseObject(e),t.children.forEach(t=>t.updateMatrixWorld(!0));let i=t.cloner;i&&void 0===i.objectForSample&&"dynamic"===a.physics.rigidBody&&(i.traverseObject(e),i.children.forEach(t=>t.updateMatrixWorld(!0)))}if(s.length>0){let n,r=!1,h=!i.fromCreate&&"dynamic"===a.physics.rigidBody||i.fromCreate&&i.dynamic;h?(n=ct.RigidBodyDesc.dynamic(),n.setLinearDamping(a.physics.damping).setAngularDamping(a.physics.damping).setAdditionalMass(1e-9).setGravityScale(a.physics.gravityScale).enabledRotations(...a.physics.enabledRotation).enabledTranslations(...a.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(n=ct.RigidBodyDesc.kinematicPositionBased(),r=!0):n=ct.RigidBodyDesc.fixed();let d=l(s);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt),t.position0=ut.clone().divideScalar(this.pixelsPerMeter),t.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),n.setTranslation(ut.x,ut.y,ut.z).setRotation(yt),o?d?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):d?.scale(vt.x/this.pixelsPerMeter,vt.y/this.pixelsPerMeter,vt.z/this.pixelsPerMeter);let c=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n),p=!(void 0===a.geometry||"SubdivGeometry"===a.geometry.type||"NonParametricGeometry"===a.geometry.type||"BooleanGeometry"===a.geometry.type||"VectorGeometry"===a.geometry.type||"StarGeometry"===a.geometry.type||"RectangleGeometry"===a.geometry.type||"EllipseGeometry"===a.geometry.type||"TriangleGeometry"===a.geometry.type||"TorusGeometry"===a.geometry.type||"HelixGeometry"===a.geometry.type);try{this.addCollider(c,a.physics,d,e,p)}catch{try{this.addCollider(c,a.physics,d,e,!1)}catch(t){console.error(t)}}if(0===c.numColliders())return void this.sharedGameControlGlobals.rapierWorld.removeRigidBody(c);h?this.rigidBodyToMesh.set(c.handle,[t,vt.clone(),a.physics.fusedBody]):r?(this.sharedGameControlGlobals.kinematicBodyToEntity.set(c.handle,t),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t)):this.fixedBodiesToWatch.push([t,c,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]),t.rigidBody=c}}addBoundsTree(e){let i=[];if(void 0!==e.geometry?.getAttribute("position")&&e.geometry?.getAttribute("position").count>0&&i.push(dt(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,i)),e.children.forEach(t=>t.updateMatrixWorld(!0)),i.length>0){let s=l(i,!1);e.bvhGeometry=s,s.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(t())(s),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(t,e,i,s,o=!0){if(0===i?.getAttribute("position").count||0===i?.getIndex()?.count)return;let a;i&&(a="trimesh"===e.colliderType?ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ct.ColliderDesc.convexMesh(i.getAttribute("position").array,o?i.getIndex().array:void 0)),a.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setRestitutionCombineRule(ct.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let n=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t);this.sharedGameControlGlobals.colliderToEntity.set(n.handle,s),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]?.some(t=>"scene"===t.target)&&n.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Lt(t);return(s,o)=>{if(0===o)return;if(i&&s.parent===t)return!0;let a;if(y(s)){if(!s.objectForSample)return!0===s.object.dataPatched.physics.fusedBody&&"dynamic"===s.object.dataPatched.physics.rigidBody||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;a=s.object}else if(v(s))a=s.object;else if(a=s,a.dataPatched.cloner?.hideBase)return!0;let n=a.dataPatched;if("visibility"===n.physics.enabled?!n.visible:!n.physics.enabled)return!0;1===o?t.hasNonUniformScale?s.matrixWorld.multiplyMatrices(t.shearScale,s.hiddenMatrix):s.matrixWorld.copy(s.hiddenMatrix):s.matrixWorld.multiplyMatrices(s.parent.matrixWorld,s.hiddenMatrix),s.matrixWorld.multiply(s.matrix);let r=s.geometry;return void 0!==r?.getAttribute("position")&&e.push(dt(r,s.matrixWorld)),!!Lt(s)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(!1===e.data.disabled&&"Trigger"===e.data.type)return this.needsCollisionDetection=!0,!0});let s=O();if(null!==s?i=s.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:null!==this.page.data.publish.gameControlObject&&f("game-controls","the scene's game controls"),!1===i){let{enableRotate:t,enablePan:i,enableZoom:s,autoRotate:o,hoverRotatePanMode:a}=this.eventManager.publish.orbitControls;(t||i||s||o||0!==a)&&(this.orbitControls=new it(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let o=this.renderer.domElement.width/this.renderer.getPixelRatio(),a=this.renderer.domElement.height/this.renderer.getPixelRatio();O()?.createJoysticks(this,o,a),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(t=>t.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ct.World(new ct.Vector3(0,this.gravity,0)),this.events=new ct.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(i=>{let s;if(y(i)){if(!i.objectForSample)return!0===i.object.dataPatched.physics.fusedBody&&"dynamic"===i.object.dataPatched.physics.rigidBody||void 0;if(i.objectForSample.dataPatched.physics.fusedBody)return;s=i.object}else if(v(i))s=i.object;else{if(m(i)||i instanceof r)return;if(s=i,!1===s.dataPatched.cloner?.disabled&&s.dataPatched.cloner?.hideBase&&!0!==s.dataPatched.physics?.fusedBody)return!0}let o,a=s.dataPatched;for(let t of a.events)!0!==t.data.disabled&&"GameControl"===t.data.type&&(o=t.data);if(!a.physics||("visibility"===a.physics.enabled?!a.visible:!a.physics.enabled))return!0;i.updateMatrixWorldRigid();let n=Gt(a),h=!1,l=s.userData.hasDestroy,d=s.userData.hasDrag,c=!1;for(let t of a.events)if(!0!==t.data.disabled)if("Collision"===t.data.type){h=!0;let e=new pt(t.id,t.data,s,this.page,this.sharedAssets,this.eventManager);e.initialDisabled=!0,this.collisionEvents.push(e),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].every(e=>e.id!==t.id)?this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].push(e):this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]=[e]}else if("Follow"===t.data.type){c=!0;let e=t.data.target;i.traverseVisible(t=>{t.userData.isFollowingObj=e})}"dynamic"===a.physics.rigidBody&&!1===a.physics.fusedBody&&(i.matrixWorldFusedFalse=i.matrixWorld.clone());let p=i.geometry;if(void 0!==o){let t=ct.RigidBodyDesc.kinematicPositionBased();(i.hasNonUniformScale?i.matrixWorldRigid:i.matrixWorld).decompose(ut,yt,vt),i.position0=ut.clone().divideScalar(this.pixelsPerMeter),i.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),t.setTranslation(ut.x,ut.y,ut.z).setRotation(yt);let e,n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(t);i.rigidBody=n,e="sphere"===o.collider.type?ct.ColliderDesc.ball(o.collider.radius/this.pixelsPerMeter):"capsule"===o.collider.type?ct.ColliderDesc.capsule((o.collider.height/2-o.collider.radius)/this.pixelsPerMeter,o.collider.radius/this.pixelsPerMeter):ct.ColliderDesc.cuboid(o.collider.width/this.pixelsPerMeter/2,o.collider.height/this.pixelsPerMeter/2,o.collider.depth/this.pixelsPerMeter/2),e.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setDensity(a.physics.density).setFriction(a.physics.friction).setRestitution(0).setRestitutionCombineRule(ct.CoefficientCombineRule.Min);let r=this.sharedGameControlGlobals.rapierWorld.createCollider(e,n);this.sharedGameControlGlobals.colliderToEntity.set(r.handle,s),ut.fromArray(o.collider.position.map(t=>"number"==typeof t?t:0)).multiply(vt.setFromMatrixScale(s.matrixWorld)).divideScalar(this.pixelsPerMeter),r.setTranslationWrtParent(ut);let h=(new C).setFromEuler((new S).setFromVector3((new M).fromArray(o.collider.rotation.map(t=>"number"==typeof t?t:0))));r.setRotationWrtParent(h),r.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(s,!0)}else"dynamic"===a.physics.rigidBody||n||c||l||d||h?(this.addRigidBody(i,s,{hasFollow:c,hasTransformAnim:n,hasDrag:d}),this.generateSensorColliderDescs(s,a.physics.fusedBody)):(p&&t.push(dt(p,i.matrixWorld)),a.physics.fusedBody&&!Lt(i)&&i.traverseObject((e,i)=>{if(0===i)return;let s;if(y(e)){if(!e.objectForSample)return!0===e.object.dataPatched.physics.fusedBody&&"dynamic"===e.object.dataPatched.physics.rigidBody||void 0;if(e.objectForSample.dataPatched.physics.fusedBody)return;s=e.object}else{if(m(e)||e instanceof r)return;if(v(e))s=e.object;else if(s=e,s.dataPatched.cloner?.hideBase)return!0}let o=s.dataPatched;if("visibility"===o.physics.enabled?!o.visible:!o.physics.enabled)return!0;let a=e.geometry;return void 0!==a?.getAttribute("position")&&t.push(dt(a,e.matrixWorld)),!!Lt(e)||void 0}),this.generateSensorColliderDescs(s,a.physics.fusedBody,e));return!(!0!==a.physics?.fusedBody&&!o&&!Lt(i))||void 0}),0===t.length)return;let i=l(t);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ct.RigidBodyDesc.fixed(),o=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s),a=ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ct.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ct.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);for(let[t,i]of e){let e=this.sharedGameControlGlobals.rapierWorld.createCollider(t,o);this.sensorToTriggerEvent[e.handle]=i}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let i=new mt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),s=(new x).compose(ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Et);if("box"===e.data.triggerZone){let o=new w;o.min.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(-.5),o.max.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([o,s,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,s,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(void 0!==this.orbitControls&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):2===this.initializationCounter&&this.gameControl&&(e=!this.gameControl.update(t)&&e),!1===this.usePhysics&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(0===t)e=this.stepPhysics()&&e;else{let s=t/1e3;s<i&&s>.55*i&&(s=i),this.accumulator+=s;let o=performance.now(),a=0,n=6;for(;this.accumulator>=i&&a<n&&(e=this.stepPhysics()&&e,this.accumulator-=i,a++,!(performance.now()-o>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt);let e=t;void 0===e.prevQ?(e.prevQ=yt.clone(),e.prevT=ut.clone()):(e.prevQ.copy(yt),e.prevT.copy(ut))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,s]=this.fixedBodiesToWatch[t];(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(s)||(i.setBodyType(ct.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1))}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(void 0===t)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),s=t.translation(),o=Math.hypot(i.x,i.z);for(let a=0;a<t.numColliders();a++){let n=t.collider(a);e.contactPairsWith(n,t=>{let a=t.parent();if(null===a||!a.isDynamic())return;let r=a.translation(),h=-1/0,l=0,d=0;if(e.contactPair(n,t,t=>{let e=t.normal(),o=e.x*(r.x-s.x)+e.y*(r.y-s.y)+e.z*(r.z-s.z)<0?-1:1;if(Math.abs(e.y)>.7)return;let a=o*e.x,n=o*e.z,c=Math.hypot(a,n);if(c<1e-4)return;let p=(i.x*a+i.z*n)/c;p>h&&(h=p,l=a/c,d=n/c)}),h===-1/0)return;let c=i.x*l+i.z*d;if(c<-Dt)return;let p=a.linvel();if(o>Dt&&c>Dt){let t=p.x*l+p.z*d;if(t<=0)return;let e=Math.min(t,c);return void a.setLinvel({x:l*e,y:p.y,z:d*e},!0)}let m=p.x*l+p.z*d-Math.max(0,c);if(m<=0)return;let u=.5*m;a.setLinvel({x:p.x-l*u,y:p.y,z:p.z-d*u},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let t of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(t),t.rigidBody.setNextKinematicTranslation(ut.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(yt);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)!0!==t.rigidBody?.isKinematic()&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let s,o=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner)for(let t of e.cloner.children)if(t.rigidBody===o){s=t;break}t.dispatch(s),e.dispatchEvent(wt)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let s=Mt.copy(t.matrixWorld).invert();t.traverseEntity((o,a)=>{if(!1===e&&1===a)return!0;for(let e of o.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let a,n=new mt(e.id,e.data,o,this.page,this.sharedAssets,this.eventManager);if(a="box"===e.data.triggerZone?ct.ColliderDesc.cuboid(...e.data.size.map(t=>("number"==typeof t?t:1)/(2*this.pixelsPerMeter))):ct.ColliderDesc.ball(e.data.radius/this.pixelsPerMeter),a.setDensity(0).setSensor(!0).setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Ct.compose(ft,Pt,Et).premultiply(o.matrixWorld),i?(Ct.decompose(ft,Pt,bt),a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED)):(Ct.premultiply(s).decompose(ft,Pt,bt),t.rigidBody.bodyType()===ct.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ct.RigidBodyType.Fixed?a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED):a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ct.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),ft.divideScalar(this.pixelsPerMeter),a.setTranslation(ft.x,ft.y,ft.z),a.setRotation(Pt),i)i.push([a,n]);else{let e=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t.rigidBody);this.sensorToTriggerEvent[e.handle]=n}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,s,o,a]=this.sharedGameControlGlobals.triggers[e];for(let e=0;e<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;e++){let n=this.sharedGameControlGlobals.entitiesWithTransformAnim[e];if(o===n||!1===a.isValidTriggeringObject(p.is(n)?n:n.object))continue;let r=Mt.copy(o.matrixWorld).decompose(ft,Tt,bt).compose(ft,Tt,Et).multiply(s),h=Ct.copy(n.matrixWorld).invert().multiply(r),l=n.bvhGeometry.boundsTree;i instanceof w?t=l.intersectsBox(i,h):(St.radius=i,St.center.setFromMatrixPosition(h),t=l.intersectsSphere(St)),t?-1===a.currentIntersectedObjects.indexOf(n)&&(a.currentIntersectedObjects.push(n),a.dispatch(),o.dispatchEvent(Rt)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(t=>t!==n)}}}},It=new Promise(t=>{Bt=t});function Ft(t){return Wt||(Wt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.6/build";typeof window<"u"&&(At=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(t=>t.arrayBuffer())]),a=s.default,n=await a({wasmBinary:o});Bt(n)}())}export{it as a,ht as b,B as c,W as d,I as e,dt as f,wt as g,jt as h,Gt as i,Ot as j,It as k,At as l,Ft as m};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t}from"./runtime-chunk-
|
|
1
|
+
import{a as e,b as t}from"./runtime-chunk-GN3HDYV2.js";import{b as a,e as i,g as r}from"./runtime-chunk-XXRCB3ME.js";import{a as s}from"./runtime-chunk-TU4KDRKR.js";import{a as n}from"./runtime-chunk-H7D3VFTJ.js";import{a as l,b as o}from"./runtime-chunk-ITLS6YIC.js";import{T as h,d as u,da as c,e as d,h as p}from"./runtime-chunk-SXPM42HJ.js";import{b as y,h as m,j as g,v as f}from"./runtime-chunk-4KX4KQWR.js";import{c as b}from"./runtime-chunk-2PT2WH66.js";import{c as v,l as C}from"./runtime-chunk-TZCHGFVF.js";import{qa as S,ta as k,w as A,za as w}from"./runtime-chunk-RBM3UDQF.js";import{Ne as F,Oc as L,Tc as H,Uc as O,Vc as j,cd as T,jd as B,ld as M,ve as D}from"./runtime-chunk-VGN7YHB7.js";function U(e){return e instanceof c&&e.needsAO&&!b(e)&&!0!==e.isDecalObject}function z(e){let t=e.cloner;if(t&&Array.isArray(t.children))for(let a of t.children)a?.layers&&(a.layers.mask=e.layers.mask)}function I(e){return e.getLayersOfType("reflection").filter(e=>e.data.visible).length}function P(e){return e.getLayersOfType("reflection").some(e=>e.data.visible&&1===e.data.mirror)}function x(e){let t=1/0,a=-1/0;for(let i of e.getLayersOfType("reflection")){let e=i.data;if(!e.visible||1===e.mirror)continue;let r="number"==typeof e.blur?e.blur:null;t=Math.min(t,r??0),a=Math.max(a,r??10)}return t===1/0?null:{min:t,max:a}}function E(e){for(let t of e.getLayersOfType("reflection")){let e=t.data;if(!e.visible)continue;let{blur:a,thickness:i,steps:r,stepSize:s}=e;return"number"!=typeof a||"number"!=typeof i||"number"!=typeof r||"number"!=typeof s?"variable":{blur:a,thickness:i,steps:r,stepSize:s,tracingMode:1===e.tracingMode?1:0}}return null}function V(e,t){let a={outline:!1,cavity:!1},i=512&e.layers.mask,r=t.getLayersOfType("transmission"),s=t.getLayersOfType("outline"),n=I(t),h=t.getLayersOfType("cavity");return(s.length>0||h.length>0)&&(e.layers.set(8),r.length>0&&e.layers.enable(3),n>0&&e.layers.enable(4),a.outline=s.length>0,a.cavity=h.length>0,o(e),l(e)),0===r.length&&0===s.length&&0===h.length&&0===n&&e.layers.set(0),i&&e.layers.set(9),!i&&U(e)&&e.layers.enable(5),z(e),a}function W(e,t){if(!t.layers)return!1;let a=512&e.layers.mask,i=!1,r=t.getLayersOfType("transmission").filter(e=>e.data.visible),s=t.getLayersOfType("outline").filter(e=>e.data.visible),n=I(t),l=t.getLayersOfType("cavity").filter(e=>e.data.visible);return r.length>0&&(e.layers.set(3),(s.length>0||l.length>0)&&e.layers.enable(8),n>0&&e.layers.enable(4),i=!0),0===r.length&&0===s.length&&0===l.length&&0===n&&e.layers.set(0),a&&e.layers.set(9),!a&&U(e)&&e.layers.enable(5),z(e),i}function G(e,t){var a;if(!t.layers)return!1;let i=512&e.layers.mask,r=!1,s=I(t),n=t.getLayersOfType("transmission").filter(e=>e.data.visible),l=t.getLayersOfType("outline").filter(e=>e.data.visible),o=t.getLayersOfType("cavity").filter(e=>e.data.visible);return s>0&&((a=e.userData).__splinePlanarMirror??(a.__splinePlanarMirror=0),e.layers.set(4),n.length>0&&e.layers.enable(3),(l.length>0||o.length>0)&&e.layers.enable(8),r=!0),0===s&&0===n.length&&0===l.length&&0===o.length&&e.layers.set(0),i&&e.layers.set(9),!i&&U(e)&&e.layers.enable(5),z(e),r}function R(e){let t={outline:!1,cavity:!1},a=e=>{t.outline=t.outline||e.outline,t.cavity=t.cavity||e.cavity};return e.traverseEntity(e=>{if(e instanceof c)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)a(V(e,e.material[t]));else a(V(e,e.material))}),t}function _(e){let t=!1;return e.traverseEntity(e=>{if(e instanceof c)if(Array.isArray(e.material))for(let a=0;a<e.material.length;a++)W(e,e.material[a])&&(t=!0);else W(e,e.material)&&(t=!0)}),t}function K(e){let t=!1;return e.traverseEntity(e=>{if(e instanceof c)if(Array.isArray(e.material))for(let a=0;a<e.material.length;a++)G(e,e.material[a])&&(t=!0);else G(e,e.material)&&(t=!0)}),t}var Q=new F,X=new L,N=new B,Y=new T;function J(e,t,a,i=!1){let r=e.cloner;if(r){let s=null;if(e.raycast===M.prototype.raycast||e.raycast===f.prototype.raycast){let t=e.geometry;t&&(null===t.boundingSphere&&t.computeBoundingSphere(),s=t.boundingSphere)}for(let n of r.children){if(null!==s&&(Y.copy(s).applyMatrix4(n.matrixWorld),!t.ray.intersectsSphere(Y)))continue;let r=X.copy(n.matrixWorld).invert(),l=N.copy(t.ray).applyMatrix4(r),o=e.matrixWorld;l.applyMatrix4(o);let h=Q;h.set(l.origin,l.direction),h.near=t.near,h.far=t.far,h.layers.mask=t.layers.mask;let u=h.intersectObject(e,!1);u.length>0&&a.push({...u[0],object:i?n:e})}}}var q=class extends(g(j)){constructor(e,t,a){if(super(),this.data=t,this.bgColor=new p(1,1,1,1),this.fog=null,this.backupFog=new O(16777215,.1,2e3),this.fogUseBGColor=!1,this.fogMode="linear",this.fogDensity=S.getDensity({}),this.fogHeightFalloff=S.getHeightFalloff({}),this.fogHeightBase=S.getHeightBase({}),this.isActive=!1,this.skyState=null,this.skyStateVersion=0,this.gradingState=null,this.skyHdriHolder=null,this.aoColor=new H,this.penumbraSizeArrayCache=null,this.super_Entity(e,t),this.personalCamera=new n(A,{...w.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new D(13882323,8553090,.75*Math.PI),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),t.uiScene){let i=C();null===i?v("ui-2d","a page's 2D scene"):this.uiScene=new i.Scene2D((Array.isArray(e)?e[0]:e)+"-ui",t.uiScene,{dpr:window.devicePixelRatio,shared:a.shared})}else t.uiFrame&&this.createUICanvas(t.uiFrame,a)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,t){let a=C();null!==a?(this.uiCanvas=new a.UICanvas(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,t),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})):v("ui-2d","a page's UI canvas")}updateVisible(){}setBackgroundColor(e){this.bgColor=e,!0===this.fogUseBGColor&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,t){void 0!==e.color&&(this.ambientLight.color=s(e.color,t)),void 0!==e.intensity&&(this.ambientLight.intensity=e.intensity*Math.PI),void 0!==e.enabled&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(e=>{e instanceof a&&e.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof c)if(Array.isArray(e.material))for(let t of e.material)t.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){if(void 0===e.softShadowQuality&&void 0===e.type||!this.isActive)return;let t=this.data.shadow,a=k.isSoft(t);h(a,t?.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,t){e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive&&(this.scene.fog=this.fog),this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=s(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far,this.fogMode=S.getMode(e),this.fogDensity=S.getDensity(e),this.fogHeightFalloff=S.getHeightFalloff(e),this.fogHeightBase=S.getHeightBase(e)}updateSky(e,t){this.skyState=e??null,this.skyStateVersion++;let a=e?.hdri?.image;this.skyHdriHolder=null!=a?t.image(a):null}updateAo(e,t){void 0!==e.aoColor&&(this.aoColor=s(e.aoColor,t))}updateByOp(e,t,a,i){let r=this.data.uiFrame;super.updateByOp(e,t,a,i);let s=t;y(e.path,["fog"])?this.updateFog(s.fog,a.shared):y(e.path,["sky"])?this.updateSky(s.sky,a.shared):y(e.path,["grading"])?this.gradingState=s.grading??null:y(e.path,["ao"])?this.updateAo(s.ao,a.shared):y(e.path,["ambient"])?this.updateAmbientLight(s.ambient,a.shared):y(e.path,["shadow"])?this.updateShadow(s.shadow):0===e.type&&0===e.path.length&&(void 0!==e.props.uiFrame||r!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,a)}updateUIFrame(e,t){e?(this.uiCanvas||this.createUICanvas(e,t),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,t){this.updateState_Entity(e,t),void 0!==e.backgroundColor&&this.setBackgroundColor(s(e.backgroundColor,t.shared)),void 0!==e.fog&&this.updateFog(e.fog,t.shared),void 0!==e.sky&&this.updateSky(e.sky,t.shared),void 0!==e.grading&&(this.gradingState=e.grading),void 0!==e.ambient&&this.updateAmbientLight(e.ambient,t.shared),void 0!==e.ao&&this.updateAo(e.ao,t.shared),void 0!==e.shadow&&this.updateShadow(e.shadow)}createFrame(e,t){}raycast(e,t){super.raycast(e,t)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return null===this.penumbraSizeArrayCache&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(u).fill(.5);let a=0,i=0;this.traverseEntity(r=>{if(!r.visible)return!0;r instanceof e&&r.visible&&a<d&&(this.penumbraSizeArrayCache[a]=r.data.penumbraSize??.5,a+=1),r instanceof t&&r.visible&&a<u-d&&(this.penumbraSizeArrayCache[d+i]=r.data.penumbraSize??.5,i+=1)})}raycastWithClones(e){let t=[],a=s=>{for(let n of s.children){let s=n.cloner;m.is(n)&&(n.visible||s?.object.data.visible)&&((i(n)||r(n)&&this.scene.enableHelpers&&n.objectHelper.visible)&&(e.intersectObject(n,!1,t),J(n,e,t,!0)),a(n))}};return a(this),t}updateEntity2DByOp(e,t,a,i){this.uiCanvas?.updateEntity2DByOp(e,t,a,i)}};export{P as a,x as b,E as c,R as d,_ as e,K as f,J as g,q as h};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,b as e}from"./runtime-chunk-
|
|
1
|
+
import{a as t,b as e}from"./runtime-chunk-AKWBEROQ.js";import{Ec as s,Fc as r,Sc as a,Xe as i}from"./runtime-chunk-VGN7YHB7.js";var o=new r(1,1,1),m=new r,d=new r,u=new s,c=class extends(t(i)){constructor(t,e=15){super(e),this.object=t,this.dummy=new a,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(t,s){e(this.object,c.geometryHelper,t,s,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(t){this.object.matrixWorld.decompose(m,u,d),this.matrix.compose(m,u,o),super.updateMatrixWorld(t)}updateWorldMatrix(t,e){}};export{c as a};
|
|
Binary file
|
|
Binary file
|